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

Side by Side Diff: printing/print_settings_initializer_win.cc

Issue 2970473002: Add generic text printing (Closed)
Patch Set: Clean up Created 3 years, 5 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
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/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
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 *level = GetPrinterPostScriptLevel(hdc); 85 *level = GetPrinterPostScriptLevel(hdc);
86 return *level == 2 || *level == 3; 86 return *level == 2 || *level == 3;
87 } 87 }
88 88
89 bool IsPrinterXPS(HDC hdc) { 89 bool IsPrinterXPS(HDC hdc) {
90 static constexpr char kXPSDriver[] = 90 static constexpr char kXPSDriver[] =
91 "http://schemas.microsoft.com/xps/2005/06"; 91 "http://schemas.microsoft.com/xps/2005/06";
92 return IsTechnology(hdc, kXPSDriver); 92 return IsTechnology(hdc, kXPSDriver);
93 } 93 }
94 94
95 bool IsPrinterTextOnly(HDC hdc) {
96 return ::GetDeviceCaps(hdc, TECHNOLOGY) == DT_CHARSTREAM;
97 }
95 } // namespace 98 } // namespace
96 99
97 // static 100 // static
98 void PrintSettingsInitializerWin::InitPrintSettings( 101 void PrintSettingsInitializerWin::InitPrintSettings(
99 HDC hdc, 102 HDC hdc,
100 const DEVMODE& dev_mode, 103 const DEVMODE& dev_mode,
101 PrintSettings* print_settings) { 104 PrintSettings* print_settings) {
102 DCHECK(hdc); 105 DCHECK(hdc);
103 DCHECK(print_settings); 106 DCHECK(print_settings);
104 107
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (level == 2) { 149 if (level == 2) {
147 print_settings->set_printer_type( 150 print_settings->set_printer_type(
148 PrintSettings::PrinterType::TYPE_POSTSCRIPT_LEVEL2); 151 PrintSettings::PrinterType::TYPE_POSTSCRIPT_LEVEL2);
149 return; 152 return;
150 } 153 }
151 DCHECK_EQ(3, level); 154 DCHECK_EQ(3, level);
152 print_settings->set_printer_type( 155 print_settings->set_printer_type(
153 PrintSettings::PrinterType::TYPE_POSTSCRIPT_LEVEL3); 156 PrintSettings::PrinterType::TYPE_POSTSCRIPT_LEVEL3);
154 return; 157 return;
155 } 158 }
159 // Detects the generic / text only driver.
160 if (IsPrinterTextOnly(hdc)) {
161 print_settings->set_printer_type(PrintSettings::PrinterType::TYPE_TEXTONLY);
162 return;
163 }
156 if (IsPrinterXPS(hdc)) { 164 if (IsPrinterXPS(hdc)) {
157 print_settings->set_printer_type(PrintSettings::PrinterType::TYPE_XPS); 165 print_settings->set_printer_type(PrintSettings::PrinterType::TYPE_XPS);
158 return; 166 return;
159 } 167 }
160 print_settings->set_printer_type(PrintSettings::PrinterType::TYPE_NONE); 168 print_settings->set_printer_type(PrintSettings::PrinterType::TYPE_NONE);
161 } 169 }
162 170
163 } // namespace printing 171 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698