OLD | NEW |
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 #include "printing/units.h" | 9 #include "printing/units.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 PMOrientation orientation = kPMPortrait; | 21 PMOrientation orientation = kPMPortrait; |
22 PMGetOrientation(page_format, &orientation); | 22 PMGetOrientation(page_format, &orientation); |
23 print_settings->SetOrientation(orientation == kPMLandscape); | 23 print_settings->SetOrientation(orientation == kPMLandscape); |
24 | 24 |
25 UInt32 resolution_count = 0; | 25 UInt32 resolution_count = 0; |
26 PMResolution best_resolution = { 72.0, 72.0 }; | 26 PMResolution best_resolution = { 72.0, 72.0 }; |
27 OSStatus status = PMPrinterGetPrinterResolutionCount(printer, | 27 OSStatus status = PMPrinterGetPrinterResolutionCount(printer, |
28 &resolution_count); | 28 &resolution_count); |
29 if (status == noErr) { | 29 if (status == noErr) { |
30 // Resolution indexes are 1-based. | 30 // Resolution indexes are 1-based. |
31 for (uint32 i = 1; i <= resolution_count; ++i) { | 31 for (uint32_t i = 1; i <= resolution_count; ++i) { |
32 PMResolution resolution; | 32 PMResolution resolution; |
33 PMPrinterGetIndexedPrinterResolution(printer, i, &resolution); | 33 PMPrinterGetIndexedPrinterResolution(printer, i, &resolution); |
34 if (resolution.hRes > best_resolution.hRes) | 34 if (resolution.hRes > best_resolution.hRes) |
35 best_resolution = resolution; | 35 best_resolution = resolution; |
36 } | 36 } |
37 } | 37 } |
38 int dpi = best_resolution.hRes; | 38 int dpi = best_resolution.hRes; |
39 print_settings->set_dpi(dpi); | 39 print_settings->set_dpi(dpi); |
40 | 40 |
41 DCHECK_EQ(dpi, best_resolution.vRes); | 41 DCHECK_EQ(dpi, best_resolution.vRes); |
(...skipping 13 matching lines...) Expand all Loading... |
55 (page_rect.right - page_rect.left), | 55 (page_rect.right - page_rect.left), |
56 (page_rect.bottom - page_rect.top)); | 56 (page_rect.bottom - page_rect.top)); |
57 | 57 |
58 DCHECK_EQ(print_settings->device_units_per_inch(), kPointsPerInch); | 58 DCHECK_EQ(print_settings->device_units_per_inch(), kPointsPerInch); |
59 print_settings->SetPrinterPrintableArea(physical_size_device_units, | 59 print_settings->SetPrinterPrintableArea(physical_size_device_units, |
60 printable_area_device_units, | 60 printable_area_device_units, |
61 false); | 61 false); |
62 } | 62 } |
63 | 63 |
64 } // namespace printing | 64 } // namespace printing |
OLD | NEW |