| 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_win.h" | 5 #include "printing/print_settings_initializer_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "printing/print_settings.h" | 9 #include "printing/print_settings.h" |
| 10 | 10 |
| 11 namespace printing { | 11 namespace printing { |
| 12 | 12 |
| 13 // static | 13 // static |
| 14 void PrintSettingsInitializerWin::InitPrintSettings( | 14 void PrintSettingsInitializerWin::InitPrintSettings( |
| 15 HDC hdc, | 15 HDC hdc, |
| 16 const DEVMODE& dev_mode, | 16 const DEVMODE& dev_mode, |
| 17 const PageRanges& new_ranges, | |
| 18 const std::wstring& new_device_name, | |
| 19 bool print_selection_only, | |
| 20 PrintSettings* print_settings) { | 17 PrintSettings* print_settings) { |
| 21 DCHECK(hdc); | 18 DCHECK(hdc); |
| 22 DCHECK(print_settings); | 19 DCHECK(print_settings); |
| 23 | 20 print_settings->SetOrientation(dev_mode.dmOrientation == DMORIENT_LANDSCAPE); |
| 24 print_settings->set_device_name(new_device_name); | |
| 25 print_settings->ranges = const_cast<PageRanges&>(new_ranges); | |
| 26 print_settings->set_landscape(dev_mode.dmOrientation == DMORIENT_LANDSCAPE); | |
| 27 print_settings->selection_only = print_selection_only; | |
| 28 | 21 |
| 29 int dpi = GetDeviceCaps(hdc, LOGPIXELSX); | 22 int dpi = GetDeviceCaps(hdc, LOGPIXELSX); |
| 30 print_settings->set_dpi(dpi); | 23 print_settings->set_dpi(dpi); |
| 31 const int kAlphaCaps = SB_CONST_ALPHA | SB_PIXEL_ALPHA; | 24 const int kAlphaCaps = SB_CONST_ALPHA | SB_PIXEL_ALPHA; |
| 32 print_settings->set_supports_alpha_blend( | 25 print_settings->set_supports_alpha_blend( |
| 33 (GetDeviceCaps(hdc, SHADEBLENDCAPS) & kAlphaCaps) == kAlphaCaps); | 26 (GetDeviceCaps(hdc, SHADEBLENDCAPS) & kAlphaCaps) == kAlphaCaps); |
| 34 // No printer device is known to advertise different dpi in X and Y axis; even | 27 // No printer device is known to advertise different dpi in X and Y axis; even |
| 35 // the fax device using the 200x100 dpi setting. It's ought to break so many | 28 // the fax device using the 200x100 dpi setting. It's ought to break so many |
| 36 // applications that it's not even needed to care about. WebKit doesn't | 29 // applications that it's not even needed to care about. WebKit doesn't |
| 37 // support different dpi settings in X and Y axis. | 30 // support different dpi settings in X and Y axis. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 51 // Sanity check the printable_area: we've seen crashes caused by a printable | 44 // Sanity check the printable_area: we've seen crashes caused by a printable |
| 52 // area rect of 0, 0, 0, 0, so it seems some drivers don't set it. | 45 // area rect of 0, 0, 0, 0, so it seems some drivers don't set it. |
| 53 if (printable_area_device_units.IsEmpty() || | 46 if (printable_area_device_units.IsEmpty() || |
| 54 !gfx::Rect(physical_size_device_units).Contains( | 47 !gfx::Rect(physical_size_device_units).Contains( |
| 55 printable_area_device_units)) { | 48 printable_area_device_units)) { |
| 56 printable_area_device_units = gfx::Rect(physical_size_device_units); | 49 printable_area_device_units = gfx::Rect(physical_size_device_units); |
| 57 } | 50 } |
| 58 | 51 |
| 59 print_settings->SetPrinterPrintableArea(physical_size_device_units, | 52 print_settings->SetPrinterPrintableArea(physical_size_device_units, |
| 60 printable_area_device_units, | 53 printable_area_device_units, |
| 61 dpi); | 54 dpi, false); |
| 62 } | 55 } |
| 63 | 56 |
| 64 } // namespace printing | 57 } // namespace printing |
| OLD | NEW |