summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--printing/printing_context_mac.h4
-rw-r--r--printing/printing_context_mac.mm18
2 files changed, 20 insertions, 2 deletions
diff --git a/printing/printing_context_mac.h b/printing/printing_context_mac.h
index 54ad559..e19ceba 100644
--- a/printing/printing_context_mac.h
+++ b/printing/printing_context_mac.h
@@ -59,6 +59,10 @@ class PrintingContextMac : public PrintingContext {
// Returns true if |collate| is set.
bool SetCollateInPrintSettings(bool collate);
+ // Sets orientation in native print info object.
+ // Returns true if the orientation was set.
+ bool SetOrientationIsLandscape(bool landscape);
+
// 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 cc5b808..25f0ef6 100644
--- a/printing/printing_context_mac.mm
+++ b/printing/printing_context_mac.mm
@@ -100,8 +100,6 @@ PrintingContext::Result PrintingContextMac::UpdatePrintSettings(
return OnError();
}
- settings_.SetOrientation(landscape);
-
if (!SetPrinter(printer_name))
return OnError();
@@ -111,6 +109,9 @@ PrintingContext::Result PrintingContextMac::UpdatePrintSettings(
if (!SetCollateInPrintSettings(collate))
return OnError();
+ if (!SetOrientationIsLandscape(landscape))
+ return OnError();
+
[print_info_.get() updateFromPMPrintSettings];
InitPrintSettingsFromPrintInfo(ranges);
@@ -159,6 +160,19 @@ bool PrintingContextMac::SetCollateInPrintSettings(bool collate) {
return PMSetCollate(pmPrintSettings, collate) == noErr;
}
+bool PrintingContextMac::SetOrientationIsLandscape(bool landscape) {
+ PMPageFormat page_format =
+ static_cast<PMPageFormat>([print_info_.get() PMPageFormat]);
+
+ PMOrientation orientation = landscape ? kPMLandscape : kPMPortrait;
+
+ if (PMSetOrientation(page_format, orientation, false) != noErr)
+ return false;
+
+ [print_info_.get() updateFromPMPageFormat];
+ return true;
+}
+
void PrintingContextMac::ParsePrintInfo(NSPrintInfo* print_info) {
ResetSettings();
print_info_.reset([print_info retain]);