Skip to content

Commit

Permalink
PrintPreview: [MAC] Set the specified orientation in the print ticket.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kmadhusu@chromium.org committed Apr 5, 2011
1 parent 53a17e2 commit d203486
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions printing/printing_context_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;

Expand Down
18 changes: 16 additions & 2 deletions printing/printing_context_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@
return OnError();
}

settings_.SetOrientation(landscape);

if (!SetPrinter(printer_name))
return OnError();

Expand All @@ -111,6 +109,9 @@
if (!SetCollateInPrintSettings(collate))
return OnError();

if (!SetOrientationIsLandscape(landscape))
return OnError();

[print_info_.get() updateFromPMPrintSettings];

InitPrintSettingsFromPrintInfo(ranges);
Expand Down Expand Up @@ -159,6 +160,19 @@
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]);
Expand Down

0 comments on commit d203486

Please sign in to comment.