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

Side by Side Diff: printing/printing_context_win.cc

Issue 7817013: PrintPreview: Added code to identify the printer default duplex value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test failures Created 9 years, 3 months 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
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/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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 PrintingContext::Result PrintingContextWin::UpdatePrinterSettings( 305 PrintingContext::Result PrintingContextWin::UpdatePrinterSettings(
306 const DictionaryValue& job_settings, 306 const DictionaryValue& job_settings,
307 const PageRanges& ranges) { 307 const PageRanges& ranges) {
308 DCHECK(!in_print_job_); 308 DCHECK(!in_print_job_);
309 309
310 bool collate; 310 bool collate;
311 bool color; 311 bool color;
312 bool landscape; 312 bool landscape;
313 bool print_to_pdf; 313 bool print_to_pdf;
314 int copies; 314 int copies;
315 int duplex_mode; 315 DictionaryValue* duplex_info;
316 int printer_default_duplex_value;
317 int user_selected_duplex_value;
316 string16 device_name; 318 string16 device_name;
317 319
318 if (!job_settings.GetBoolean(kSettingLandscape, &landscape) || 320 if (!job_settings.GetBoolean(kSettingLandscape, &landscape) ||
319 !job_settings.GetBoolean(kSettingCollate, &collate) || 321 !job_settings.GetBoolean(kSettingCollate, &collate) ||
320 !job_settings.GetBoolean(kSettingColor, &color) || 322 !job_settings.GetBoolean(kSettingColor, &color) ||
321 !job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || 323 !job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) ||
322 !job_settings.GetInteger(kSettingDuplexMode, &duplex_mode) || 324 !job_settings.GetDictionary(kSettingDuplexModeInfo, &duplex_info) ||
325 !duplex_info->GetInteger(kPrinterDefaultDuplexValue,
326 &printer_default_duplex_value) ||
327 !duplex_info->GetInteger(kUserSelectedDuplexValue,
328 &user_selected_duplex_value) ||
323 !job_settings.GetInteger(kSettingCopies, &copies) || 329 !job_settings.GetInteger(kSettingCopies, &copies) ||
324 !job_settings.GetString(kSettingDeviceName, &device_name)) { 330 !job_settings.GetString(kSettingDeviceName, &device_name)) {
325 return OnError(); 331 return OnError();
326 } 332 }
327 333
328 bool print_to_cloud = job_settings.HasKey(printing::kSettingCloudPrintId); 334 bool print_to_cloud = job_settings.HasKey(printing::kSettingCloudPrintId);
329 335
330 if (print_to_pdf || print_to_cloud) { 336 if (print_to_pdf || print_to_cloud) {
331 // Pseudo printer: handle orientation and ranges only. 337 // Pseudo printer: handle orientation and ranges only.
332 settings_.SetOrientation(landscape); 338 settings_.SetOrientation(landscape);
(...skipping 29 matching lines...) Expand all
362 if (dev_mode == NULL) { 368 if (dev_mode == NULL) {
363 buffer.reset(); 369 buffer.reset();
364 ClosePrinter(printer); 370 ClosePrinter(printer);
365 return OnError(); 371 return OnError();
366 } 372 }
367 373
368 dev_mode->dmColor = color ? DMCOLOR_COLOR : DMCOLOR_MONOCHROME; 374 dev_mode->dmColor = color ? DMCOLOR_COLOR : DMCOLOR_MONOCHROME;
369 dev_mode->dmCopies = std::max(copies, 1); 375 dev_mode->dmCopies = std::max(copies, 1);
370 if (dev_mode->dmCopies > 1) // do not change collate unless multiple copies 376 if (dev_mode->dmCopies > 1) // do not change collate unless multiple copies
371 dev_mode->dmCollate = collate ? DMCOLLATE_TRUE : DMCOLLATE_FALSE; 377 dev_mode->dmCollate = collate ? DMCOLLATE_TRUE : DMCOLLATE_FALSE;
372 switch (duplex_mode) { 378 if (printer_default_duplex_value == printing::UNKNOWN) {
373 case LONG_EDGE: 379 dev_mode->dmDuplex = user_selected_duplex_value ? DMDUP_HORIZONTAL :
vandebo (ex-Chrome) 2011/09/02 18:12:50 This assumes that SIMPLEX is "false." Instead, yo
kmadhusu 2011/09/03 00:34:00 As we discussed, I reverted the printing context c
374 dev_mode->dmDuplex = DMDUP_VERTICAL; 380 DMDUP_SIMPLEX;
375 break; 381 } else {
376 case SHORT_EDGE: 382 switch (user_selected_duplex_value) {
377 dev_mode->dmDuplex = DMDUP_HORIZONTAL; 383 case LONG_EDGE:
378 break; 384 dev_mode->dmDuplex = DMDUP_VERTICAL;
379 default: // simplex 385 break;
380 dev_mode->dmDuplex = DMDUP_SIMPLEX; 386 case SHORT_EDGE:
381 break; 387 dev_mode->dmDuplex = DMDUP_HORIZONTAL;
388 break;
389 default: // simplex
390 dev_mode->dmDuplex = DMDUP_SIMPLEX;
391 break;
392 }
382 } 393 }
383 dev_mode->dmOrientation = landscape ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT; 394 dev_mode->dmOrientation = landscape ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT;
384 395
385 // Update data using DocumentProperties. 396 // Update data using DocumentProperties.
386 if (DocumentProperties(NULL, printer, device_name_wide, dev_mode, dev_mode, 397 if (DocumentProperties(NULL, printer, device_name_wide, dev_mode, dev_mode,
387 DM_IN_BUFFER | DM_OUT_BUFFER) != IDOK) { 398 DM_IN_BUFFER | DM_OUT_BUFFER) != IDOK) {
388 ClosePrinter(printer); 399 ClosePrinter(printer);
389 return OnError(); 400 return OnError();
390 } 401 }
391 402
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 if (buf_size) { 767 if (buf_size) {
757 buffer->reset(new uint8[buf_size]); 768 buffer->reset(new uint8[buf_size]);
758 memset(buffer->get(), 0, buf_size); 769 memset(buffer->get(), 0, buf_size);
759 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) { 770 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) {
760 buffer->reset(); 771 buffer->reset();
761 } 772 }
762 } 773 }
763 } 774 }
764 775
765 } // namespace printing 776 } // namespace printing
OLDNEW
« chrome/renderer/print_web_view_helper_browsertest.cc ('K') | « printing/printing_context_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698