diff options
Diffstat (limited to 'printing')
-rw-r--r-- | printing/printing_context_mac.h | 4 | ||||
-rw-r--r-- | printing/printing_context_mac.mm | 21 |
2 files changed, 24 insertions, 1 deletions
diff --git a/printing/printing_context_mac.h b/printing/printing_context_mac.h index 0979b18..90be22b 100644 --- a/printing/printing_context_mac.h +++ b/printing/printing_context_mac.h @@ -67,6 +67,10 @@ class PrintingContextMac : public PrintingContext { // Returns true if duplex mode is set. bool SetDuplexModeIsTwoSided(bool two_sided); + // Sets output color mode in PMPrintSettings. + // Returns true if color mode is set. + bool SetOutputIsColor(bool color); + // The native print info object. scoped_nsobject<NSPrintInfo> print_info_; diff --git a/printing/printing_context_mac.mm b/printing/printing_context_mac.mm index 063197e..3bb383d 100644 --- a/printing/printing_context_mac.mm +++ b/printing/printing_context_mac.mm @@ -14,6 +14,9 @@ #include "printing/print_job_constants.h" #include "printing/print_settings_initializer_mac.h" +static const CFStringRef kColorModel = CFSTR("ColorModel"); +static const CFStringRef kGrayColor = CFSTR("Gray"); + namespace printing { // static @@ -94,11 +97,13 @@ PrintingContext::Result PrintingContextMac::UpdatePrintSettings( int copies; bool collate; bool two_sided; + 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.GetBoolean(kSettingTwoSided, &two_sided) || + !job_settings.GetBoolean(kSettingColor, &color)) { return OnError(); } @@ -117,6 +122,9 @@ PrintingContext::Result PrintingContextMac::UpdatePrintSettings( if (!SetDuplexModeIsTwoSided(two_sided)) return OnError(); + if (!SetOutputIsColor(color)) + return OnError(); + [print_info_.get() updateFromPMPrintSettings]; InitPrintSettingsFromPrintInfo(ranges); @@ -185,6 +193,17 @@ bool PrintingContextMac::SetDuplexModeIsTwoSided(bool two_sided) { return PMSetDuplex(pmPrintSettings, duplexSetting) == noErr; } +bool PrintingContextMac::SetOutputIsColor(bool color) { + PMPrintSettings pmPrintSettings = + static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); + CFStringRef output_color = color ? NULL : kGrayColor; + + return PMPrintSettingsSetValue(pmPrintSettings, + kColorModel, + output_color, + false) == noErr; +} + void PrintingContextMac::ParsePrintInfo(NSPrintInfo* print_info) { ResetSettings(); print_info_.reset([print_info retain]); |