summaryrefslogtreecommitdiffstats
path: root/printing
diff options
context:
space:
mode:
authorkmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-07 16:22:13 +0000
committerkmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-07 16:22:13 +0000
commit770f9067864bb6780b580c7dd8ca0c3982109f6b (patch)
tree8b66822a9fb77cdc520e54417c03334c1d4d225f /printing
parent2892f19940a8dd68fba75a5d184c19f57bea418d (diff)
downloadchromium_src-770f9067864bb6780b580c7dd8ca0c3982109f6b.zip
chromium_src-770f9067864bb6780b580c7dd8ca0c3982109f6b.tar.gz
chromium_src-770f9067864bb6780b580c7dd8ca0c3982109f6b.tar.bz2
PrintPreview: [MAC] Set the duplex setting in print ticket.
BUG=none TEST=none Review URL: http://codereview.chromium.org/6792061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80789 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r--printing/print_job_constants.cc3
-rw-r--r--printing/print_job_constants.h1
-rw-r--r--printing/printing_context_mac.h4
-rw-r--r--printing/printing_context_mac.mm14
4 files changed, 21 insertions, 1 deletions
diff --git a/printing/print_job_constants.cc b/printing/print_job_constants.cc
index 5442690..31075f6 100644
--- a/printing/print_job_constants.cc
+++ b/printing/print_job_constants.cc
@@ -24,4 +24,7 @@ const char kSettingPrintToPDF[] = "printToPDF";
// Printer name.
const char kSettingPrinterName[] = "printerName";
+// 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 b34915c..42c6f69 100644
--- a/printing/print_job_constants.h
+++ b/printing/print_job_constants.h
@@ -13,6 +13,7 @@ extern const char kSettingCopies[];
extern const char kSettingLandscape[];
extern const char kSettingPrintToPDF[];
extern const char kSettingPrinterName[];
+extern const char kSettingTwoSided[];
} // namespace printing
diff --git a/printing/printing_context_mac.h b/printing/printing_context_mac.h
index e19ceba..0979b18 100644
--- a/printing/printing_context_mac.h
+++ b/printing/printing_context_mac.h
@@ -63,6 +63,10 @@ class PrintingContextMac : public PrintingContext {
// Returns true if the orientation was set.
bool SetOrientationIsLandscape(bool landscape);
+ // Sets duplex mode in PMPrintSettings.
+ // Returns true if duplex mode is set.
+ bool SetDuplexModeIsTwoSided(bool two_sided);
+
// 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 25f0ef6..063197e 100644
--- a/printing/printing_context_mac.mm
+++ b/printing/printing_context_mac.mm
@@ -93,10 +93,12 @@ PrintingContext::Result PrintingContextMac::UpdatePrintSettings(
std::string printer_name;
int copies;
bool collate;
+ bool two_sided;
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(kSettingCollate, &collate) ||
+ !job_settings.GetBoolean(kSettingTwoSided, &two_sided)) {
return OnError();
}
@@ -112,6 +114,9 @@ PrintingContext::Result PrintingContextMac::UpdatePrintSettings(
if (!SetOrientationIsLandscape(landscape))
return OnError();
+ if (!SetDuplexModeIsTwoSided(two_sided))
+ return OnError();
+
[print_info_.get() updateFromPMPrintSettings];
InitPrintSettingsFromPrintInfo(ranges);
@@ -173,6 +178,13 @@ bool PrintingContextMac::SetOrientationIsLandscape(bool landscape) {
return true;
}
+bool PrintingContextMac::SetDuplexModeIsTwoSided(bool two_sided) {
+ PMDuplexMode duplexSetting = two_sided ? kPMDuplexNoTumble : kPMDuplexNone;
+ PMPrintSettings pmPrintSettings =
+ static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]);
+ return PMSetDuplex(pmPrintSettings, duplexSetting) == noErr;
+}
+
void PrintingContextMac::ParsePrintInfo(NSPrintInfo* print_info) {
ResetSettings();
print_info_.reset([print_info retain]);