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

Unified Diff: printing/print_settings_initializer_win.cc

Issue 2691653002: Improve postscript language level detection (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/printing/pdf_to_emf_converter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/print_settings_initializer_win.cc
diff --git a/printing/print_settings_initializer_win.cc b/printing/print_settings_initializer_win.cc
index 6d3ee33aaee69fe6d9cf0a54c96bf137b773790c..95d2fced08b5ff262a5d92de0105878ffee9e397 100644
--- a/printing/print_settings_initializer_win.cc
+++ b/printing/print_settings_initializer_win.cc
@@ -21,6 +21,17 @@ bool IsTechnology(HDC hdc, const char* technology) {
if (::GetDeviceCaps(hdc, TECHNOLOGY) != DT_RASPRINTER)
return false;
+ // If postscript, try to query Postscript Identify and then set to
+ // postscript mode before calling any more ExtEscape functions. Otherwise,
+ // PSLEVEL query will not work.
+ if (strcmp(technology, "PostScript") == 0 &&
Lei Zhang 2017/02/25 02:49:50 Doing this within IsTechnology() seems weird, but
+ HasEscapeSupprt(hdc, POSTSCRIPT_IDENTIFY)) {
+ DWORD mode = PSIDENT_PSCENTRIC;
+ const char* ptr = reinterpret_cast<const char*>(&mode);
+ ExtEscape(hdc, POSTSCRIPT_IDENTIFY, sizeof(DWORD), ptr, 0, nullptr);
+ return true;
+ }
+
if (!HasEscapeSupprt(hdc, GETTECHNOLOGY))
return false;
@@ -37,7 +48,7 @@ bool IsPrinterPostScript(HDC hdc, int* level) {
return false;
}
- // Query the PS Level if possible. Many PS printers do not implement this.
Lei Zhang 2017/02/25 02:49:50 Are there printers that only support this in PS mo
+ // Query the PS Level if possible.
if (HasEscapeSupprt(hdc, GET_PS_FEATURESETTING)) {
constexpr int param = FEATURESETTING_PSLEVEL;
const char* param_char_ptr = reinterpret_cast<const char*>(&param);
@@ -116,10 +127,8 @@ void PrintSettingsInitializerWin::InitPrintSettings(
print_settings->SetPrinterPrintableArea(physical_size_device_units,
printable_area_device_units,
false);
- if (IsPrinterXPS(hdc)) {
- print_settings->set_printer_type(PrintSettings::PrinterType::TYPE_XPS);
- return;
- }
+ // Check for postscript first so that we can change the mode with the
+ // first command.
int level;
if (IsPrinterPostScript(hdc, &level)) {
if (level == 2) {
@@ -132,6 +141,10 @@ void PrintSettingsInitializerWin::InitPrintSettings(
PrintSettings::PrinterType::TYPE_POSTSCRIPT_LEVEL3);
return;
}
+ if (IsPrinterXPS(hdc)) {
+ print_settings->set_printer_type(PrintSettings::PrinterType::TYPE_XPS);
+ return;
+ }
print_settings->set_printer_type(PrintSettings::PrinterType::TYPE_NONE);
}
« no previous file with comments | « chrome/browser/printing/pdf_to_emf_converter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698