Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: printing/print_settings_initializer_mac.cc

Issue 47823002: De-duplicate job_settings parsing code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Noam's comments Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/print_settings_initializer_mac.h ('k') | printing/print_settings_initializer_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "printing/print_settings_initializer_mac.h" 5 #include "printing/print_settings_initializer_mac.h"
6 6
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "printing/print_settings.h" 8 #include "printing/print_settings.h"
9 9
10 namespace printing { 10 namespace printing {
11 11
12 // static 12 // static
13 void PrintSettingsInitializerMac::InitPrintSettings( 13 void PrintSettingsInitializerMac::InitPrintSettings(
14 PMPrinter printer, 14 PMPrinter printer,
15 PMPageFormat page_format, 15 PMPageFormat page_format,
16 const PageRanges& new_ranges,
17 bool print_selection_only,
18 PrintSettings* print_settings) { 16 PrintSettings* print_settings) {
19 DCHECK(print_settings);
20
21 print_settings->set_device_name( 17 print_settings->set_device_name(
22 base::SysCFStringRefToUTF16(PMPrinterGetID(printer))); 18 base::SysCFStringRefToUTF16(PMPrinterGetID(printer)));
23 print_settings->ranges = new_ranges;
24 19
25 PMOrientation orientation = kPMPortrait; 20 PMOrientation orientation = kPMPortrait;
26 PMGetOrientation(page_format, &orientation); 21 PMGetOrientation(page_format, &orientation);
27 print_settings->set_landscape(orientation == kPMLandscape); 22 print_settings->SetOrientation(orientation == kPMLandscape);
28 print_settings->selection_only = print_selection_only;
29 23
30 UInt32 resolution_count = 0; 24 UInt32 resolution_count = 0;
31 PMResolution best_resolution = { 72.0, 72.0 }; 25 PMResolution best_resolution = { 72.0, 72.0 };
32 OSStatus status = PMPrinterGetPrinterResolutionCount(printer, 26 OSStatus status = PMPrinterGetPrinterResolutionCount(printer,
33 &resolution_count); 27 &resolution_count);
34 if (status == noErr) { 28 if (status == noErr) {
35 // Resolution indexes are 1-based. 29 // Resolution indexes are 1-based.
36 for (uint32 i = 1; i <= resolution_count; ++i) { 30 for (uint32 i = 1; i <= resolution_count; ++i) {
37 PMResolution resolution; 31 PMResolution resolution;
38 PMPrinterGetIndexedPrinterResolution(printer, i, &resolution); 32 PMPrinterGetIndexedPrinterResolution(printer, i, &resolution);
(...skipping 16 matching lines...) Expand all
55 (paper_rect.right - paper_rect.left), 49 (paper_rect.right - paper_rect.left),
56 (paper_rect.bottom - paper_rect.top)); 50 (paper_rect.bottom - paper_rect.top));
57 gfx::Rect printable_area_device_units( 51 gfx::Rect printable_area_device_units(
58 (page_rect.left - paper_rect.left), 52 (page_rect.left - paper_rect.left),
59 (page_rect.top - paper_rect.top), 53 (page_rect.top - paper_rect.top),
60 (page_rect.right - page_rect.left), 54 (page_rect.right - page_rect.left),
61 (page_rect.bottom - page_rect.top)); 55 (page_rect.bottom - page_rect.top));
62 56
63 print_settings->SetPrinterPrintableArea(physical_size_device_units, 57 print_settings->SetPrinterPrintableArea(physical_size_device_units,
64 printable_area_device_units, 58 printable_area_device_units,
65 72); 59 72, false);
66 } 60 }
67 61
68 } // namespace printing 62 } // namespace printing
OLDNEW
« no previous file with comments | « printing/print_settings_initializer_mac.h ('k') | printing/print_settings_initializer_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698