Chromium Code Reviews| Index: printing/print_settings_initializer_win.cc |
| diff --git a/printing/print_settings_initializer_win.cc b/printing/print_settings_initializer_win.cc |
| index 0776e9e5c0e5636864e8d611edbbc704ae5686d4..450975674c3f4e6eb239e8ab0cfd9f9a7932b2a8 100644 |
| --- a/printing/print_settings_initializer_win.cc |
| +++ b/printing/print_settings_initializer_win.cc |
| @@ -31,6 +31,38 @@ bool IsTechnology(HDC hdc, const char* technology) { |
| return strcmp(buf, technology) == 0; |
| } |
| +bool IsPrinterPostScript(HDC hdc, int* level) { |
| + static constexpr char kPostScriptDriver[] = "PostScript"; |
| + if (!IsTechnology(hdc, kPostScriptDriver)) { |
| + return false; |
| + } |
| + |
| + // Query the PS Level if possible. Many PS printers do not implement this. |
| + if (HasEscapeSupprt(hdc, GET_PS_FEATURESETTING)) { |
| + constexpr int param = FEATURESETTING_PSLEVEL; |
| + const char* param_char_ptr = reinterpret_cast<const char*>(¶m); |
| + int param_out = -1; |
| + char* param_out_char_ptr = reinterpret_cast<char*>(¶m_out); |
| + if (ExtEscape(hdc, GET_PS_FEATURESETTING, sizeof(param), param_char_ptr, |
| + sizeof(param_out), param_out_char_ptr) > 0) { |
| + if (param_out < 2 || param_out > 3) |
| + return false; |
| + |
| + *level = param_out; |
| + return true; |
| + } |
| + } |
| + |
| + // If it looks like a PS printer. |
| + if (HasEscapeSupprt(hdc, POSTSCRIPT_PASSTHROUGH) && |
| + HasEscapeSupprt(hdc, POSTSCRIPT_DATA)) { |
| + *level = 2; |
| + return true; |
| + } |
| + |
| + return false; |
| +} |
| + |
| bool IsPrinterXPS(HDC hdc) { |
| static constexpr char kXPSDriver[] = |
| "http://schemas.microsoft.com/xps/2005/06"; |
| @@ -86,6 +118,17 @@ void PrintSettingsInitializerWin::InitPrintSettings( |
| false); |
| print_settings->set_printer_is_xps(IsPrinterXPS(hdc)); |
| + if (!print_settings->printer_is_xps()) { |
| + int level; |
| + if (IsPrinterPostScript(hdc, &level)) { |
| + if (level == 2) { |
| + print_settings->set_printer_is_ps2(true); |
|
Vitaly Buka (NO REVIEWS)
2017/01/27 00:38:49
Looks like printer_is* flags exclusive
probably cl
rbpotter
2017/01/27 16:37:21
Done.
|
| + } else { |
| + DCHECK_EQ(3, level); |
| + print_settings->set_printer_is_ps3(true); |
| + } |
| + } |
| + } |
| } |
| } // namespace printing |