| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 !job_settings.GetBoolean(kSettingCollate, &collate) || | 339 !job_settings.GetBoolean(kSettingCollate, &collate) || |
| 340 !job_settings.GetInteger(kSettingColor, &color) || | 340 !job_settings.GetInteger(kSettingColor, &color) || |
| 341 !job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || | 341 !job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || |
| 342 !job_settings.GetInteger(kSettingDuplexMode, &duplex_mode) || | 342 !job_settings.GetInteger(kSettingDuplexMode, &duplex_mode) || |
| 343 !job_settings.GetInteger(kSettingCopies, &copies) || | 343 !job_settings.GetInteger(kSettingCopies, &copies) || |
| 344 !job_settings.GetString(kSettingDeviceName, &device_name) || | 344 !job_settings.GetString(kSettingDeviceName, &device_name) || |
| 345 !job_settings.GetBoolean(kSettingCloudPrintDialog, &is_cloud_dialog)) { | 345 !job_settings.GetBoolean(kSettingCloudPrintDialog, &is_cloud_dialog)) { |
| 346 return OnError(); | 346 return OnError(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 bool print_to_cloud = job_settings.HasKey(printing::kSettingCloudPrintId); | 349 bool print_to_cloud = job_settings.HasKey(kSettingCloudPrintId); |
| 350 | 350 |
| 351 if (print_to_pdf || print_to_cloud || is_cloud_dialog) { | 351 if (print_to_pdf || print_to_cloud || is_cloud_dialog) { |
| 352 // Default fallback to Letter size. | 352 // Default fallback to Letter size. |
| 353 gfx::Size paper_size; | 353 gfx::Size paper_size; |
| 354 gfx::Rect paper_rect; | 354 gfx::Rect paper_rect; |
| 355 paper_size.SetSize(kPDFLetterWidth, kPDFLetterHeight); | 355 paper_size.SetSize(kPDFLetterWidth, kPDFLetterHeight); |
| 356 | 356 |
| 357 // Get settings from locale. Paper type buffer length is at most 4. | 357 // Get settings from locale. Paper type buffer length is at most 4. |
| 358 const int paper_type_buffer_len = 4; | 358 const int paper_type_buffer_len = 4; |
| 359 wchar_t paper_type_buffer[paper_type_buffer_len] = {0}; | 359 wchar_t paper_type_buffer[paper_type_buffer_len] = {0}; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 DM_OUT_BUFFER) == IDOK) { | 402 DM_OUT_BUFFER) == IDOK) { |
| 403 dev_mode = reinterpret_cast<PDEVMODE>(buffer.get()); | 403 dev_mode = reinterpret_cast<PDEVMODE>(buffer.get()); |
| 404 } | 404 } |
| 405 } | 405 } |
| 406 if (dev_mode == NULL) { | 406 if (dev_mode == NULL) { |
| 407 buffer.reset(); | 407 buffer.reset(); |
| 408 ClosePrinter(printer); | 408 ClosePrinter(printer); |
| 409 return OnError(); | 409 return OnError(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 if (color == printing::GRAY) | 412 if (color == GRAY) |
| 413 dev_mode->dmColor = DMCOLOR_MONOCHROME; | 413 dev_mode->dmColor = DMCOLOR_MONOCHROME; |
| 414 else | 414 else |
| 415 dev_mode->dmColor = DMCOLOR_COLOR; | 415 dev_mode->dmColor = DMCOLOR_COLOR; |
| 416 | 416 |
| 417 dev_mode->dmCopies = std::max(copies, 1); | 417 dev_mode->dmCopies = std::max(copies, 1); |
| 418 if (dev_mode->dmCopies > 1) // do not change collate unless multiple copies | 418 if (dev_mode->dmCopies > 1) // do not change collate unless multiple copies |
| 419 dev_mode->dmCollate = collate ? DMCOLLATE_TRUE : DMCOLLATE_FALSE; | 419 dev_mode->dmCollate = collate ? DMCOLLATE_TRUE : DMCOLLATE_FALSE; |
| 420 switch (duplex_mode) { | 420 switch (duplex_mode) { |
| 421 case LONG_EDGE: | 421 case LONG_EDGE: |
| 422 dev_mode->dmDuplex = DMDUP_VERTICAL; | 422 dev_mode->dmDuplex = DMDUP_VERTICAL; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 if (buf_size) { | 806 if (buf_size) { |
| 807 buffer->reset(new uint8[buf_size]); | 807 buffer->reset(new uint8[buf_size]); |
| 808 memset(buffer->get(), 0, buf_size); | 808 memset(buffer->get(), 0, buf_size); |
| 809 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) { | 809 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) { |
| 810 buffer->reset(); | 810 buffer->reset(); |
| 811 } | 811 } |
| 812 } | 812 } |
| 813 } | 813 } |
| 814 | 814 |
| 815 } // namespace printing | 815 } // namespace printing |
| OLD | NEW |