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/printing_context_win.h" | 5 #include "printing/printing_context_win.h" |
6 | 6 |
7 #include <winspool.h> | 7 #include <winspool.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 } | 376 } |
377 } | 377 } |
378 paper_rect.SetRect(0, 0, paper_size.width(), paper_size.height()); | 378 paper_rect.SetRect(0, 0, paper_size.width(), paper_size.height()); |
379 settings_.SetPrinterPrintableArea(paper_size, paper_rect, kPDFDpi); | 379 settings_.SetPrinterPrintableArea(paper_size, paper_rect, kPDFDpi); |
380 settings_.set_dpi(kPDFDpi); | 380 settings_.set_dpi(kPDFDpi); |
381 settings_.SetOrientation(landscape); | 381 settings_.SetOrientation(landscape); |
382 settings_.ranges = ranges; | 382 settings_.ranges = ranges; |
383 return OK; | 383 return OK; |
384 } | 384 } |
385 | 385 |
386 // Underlying |settings_| do not have these attributes, so we need to | |
387 // operate on printer directly, which involves reloading settings. | |
388 // Therefore, reset the settings anyway. | |
389 ResetSettings(); | |
390 | |
391 HANDLE printer; | 386 HANDLE printer; |
392 LPWSTR device_name_wide = const_cast<wchar_t*>(device_name.c_str()); | 387 LPWSTR device_name_wide = const_cast<wchar_t*>(device_name.c_str()); |
393 if (!OpenPrinter(device_name_wide, &printer, NULL)) | 388 if (!OpenPrinter(device_name_wide, &printer, NULL)) |
394 return OnError(); | 389 return OnError(); |
395 | 390 |
396 // Make printer changes local to Chrome. | 391 // Make printer changes local to Chrome. |
397 // See MSDN documentation regarding DocumentProperties. | 392 // See MSDN documentation regarding DocumentProperties. |
398 scoped_array<uint8> buffer; | 393 scoped_array<uint8> buffer; |
399 DEVMODE* dev_mode = NULL; | 394 DEVMODE* dev_mode = NULL; |
400 LONG buffer_size = DocumentProperties(NULL, printer, device_name_wide, | 395 LONG buffer_size = DocumentProperties(NULL, printer, device_name_wide, |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 if (buf_size) { | 806 if (buf_size) { |
812 buffer->reset(new uint8[buf_size]); | 807 buffer->reset(new uint8[buf_size]); |
813 memset(buffer->get(), 0, buf_size); | 808 memset(buffer->get(), 0, buf_size); |
814 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) { | 809 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) { |
815 buffer->reset(); | 810 buffer->reset(); |
816 } | 811 } |
817 } | 812 } |
818 } | 813 } |
819 | 814 |
820 } // namespace printing | 815 } // namespace printing |
OLD | NEW |