diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 20:03:31 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 20:03:31 +0000 |
commit | d20348675866d9a0369dc5a196d2a26399e402c9 (patch) | |
tree | 518f57aa9fcdf87cc3a3ced949b827473c79fe72 /printing | |
parent | 53a17e24bba43fb1c6b11303b02cce4dfaa2b65d (diff) | |
download | chromium_src-d20348675866d9a0369dc5a196d2a26399e402c9.zip chromium_src-d20348675866d9a0369dc5a196d2a26399e402c9.tar.gz chromium_src-d20348675866d9a0369dc5a196d2a26399e402c9.tar.bz2 |
PrintPreview: [MAC] Set the specified orientation in the print ticket.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6764006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80514 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r-- | printing/printing_context_mac.h | 4 | ||||
-rw-r--r-- | printing/printing_context_mac.mm | 18 |
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]); |