diff options
Diffstat (limited to 'printing')
-rw-r--r-- | printing/print_job_constants.cc | 6 | ||||
-rw-r--r-- | printing/print_job_constants.h | 2 | ||||
-rw-r--r-- | printing/printing_context.h | 7 | ||||
-rw-r--r-- | printing/printing_context_mac.h | 2 | ||||
-rw-r--r-- | printing/printing_context_mac.mm | 22 |
5 files changed, 29 insertions, 10 deletions
diff --git a/printing/print_job_constants.cc b/printing/print_job_constants.cc index bbb8d2b..21a0199 100644 --- a/printing/print_job_constants.cc +++ b/printing/print_job_constants.cc @@ -15,6 +15,9 @@ const char kSettingColor[] = "color"; // Number of copies. const char kSettingCopies[] = "copies"; +// Print job duplex mode. +const char kSettingDuplexMode[] = "duplex"; + // Page orientation: true for landscape, false for portrait. const char kSettingLandscape[] = "landscape"; @@ -24,7 +27,4 @@ const char kSettingPrinterName[] = "printerName"; // Print to PDF option: true if selected, false if not. const char kSettingPrintToPDF[] = "printToPDF"; -// Print job duplex setting. -const char kSettingTwoSided[] = "twoSided"; - } // namespace printing diff --git a/printing/print_job_constants.h b/printing/print_job_constants.h index 30102eb..ec8ca8c 100644 --- a/printing/print_job_constants.h +++ b/printing/print_job_constants.h @@ -10,10 +10,10 @@ namespace printing { extern const char kSettingCollate[]; extern const char kSettingColor[]; extern const char kSettingCopies[]; +extern const char kSettingDuplexMode[]; extern const char kSettingLandscape[]; extern const char kSettingPrinterName[]; extern const char kSettingPrintToPDF[]; -extern const char kSettingTwoSided[]; } // namespace printing diff --git a/printing/printing_context.h b/printing/printing_context.h index c4e2094..77ac844 100644 --- a/printing/printing_context.h +++ b/printing/printing_context.h @@ -99,6 +99,13 @@ class PrintingContext { } protected: + // Print job duplex mode values. + enum DuplexMode { + SIMPLEX, + LONG_EDGE, + SHORT_EDGE, + }; + explicit PrintingContext(const std::string& app_locale); // Reinitializes the settings for object reuse. diff --git a/printing/printing_context_mac.h b/printing/printing_context_mac.h index 90be22b..3005602 100644 --- a/printing/printing_context_mac.h +++ b/printing/printing_context_mac.h @@ -65,7 +65,7 @@ class PrintingContextMac : public PrintingContext { // Sets duplex mode in PMPrintSettings. // Returns true if duplex mode is set. - bool SetDuplexModeIsTwoSided(bool two_sided); + bool SetDuplexModeInPrintSettings(DuplexMode mode); // Sets output color mode in PMPrintSettings. // Returns true if color mode is set. diff --git a/printing/printing_context_mac.mm b/printing/printing_context_mac.mm index 3bb383d..755069a 100644 --- a/printing/printing_context_mac.mm +++ b/printing/printing_context_mac.mm @@ -96,13 +96,13 @@ PrintingContext::Result PrintingContextMac::UpdatePrintSettings( std::string printer_name; int copies; bool collate; - bool two_sided; + int duplex_mode; bool color; if (!job_settings.GetBoolean(kSettingLandscape, &landscape) || !job_settings.GetString(kSettingPrinterName, &printer_name) || !job_settings.GetInteger(kSettingCopies, &copies) || !job_settings.GetBoolean(kSettingCollate, &collate) || - !job_settings.GetBoolean(kSettingTwoSided, &two_sided) || + !job_settings.GetInteger(kSettingDuplexMode, &duplex_mode) || !job_settings.GetBoolean(kSettingColor, &color)) { return OnError(); } @@ -119,7 +119,7 @@ PrintingContext::Result PrintingContextMac::UpdatePrintSettings( if (!SetOrientationIsLandscape(landscape)) return OnError(); - if (!SetDuplexModeIsTwoSided(two_sided)) + if (!SetDuplexModeInPrintSettings(static_cast<DuplexMode>(duplex_mode))) return OnError(); if (!SetOutputIsColor(color)) @@ -186,8 +186,20 @@ bool PrintingContextMac::SetOrientationIsLandscape(bool landscape) { return true; } -bool PrintingContextMac::SetDuplexModeIsTwoSided(bool two_sided) { - PMDuplexMode duplexSetting = two_sided ? kPMDuplexNoTumble : kPMDuplexNone; +bool PrintingContextMac::SetDuplexModeInPrintSettings(DuplexMode mode) { + PMDuplexMode duplexSetting; + switch (mode) { + case LONG_EDGE: + duplexSetting = kPMDuplexNoTumble; + break; + case SHORT_EDGE: + duplexSetting = kPMDuplexTumble; + break; + default: + duplexSetting = kPMDuplexNone; + break; + } + PMPrintSettings pmPrintSettings = static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); return PMSetDuplex(pmPrintSettings, duplexSetting) == noErr; |