From 537f4c7b592a6981f9686297496cb23b461dfd5e Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 25 Apr 2018 18:01:52 +0000 Subject: Use WindowsPrintMode in more places in place of ints. Move WindowsPrintMode assertion into CPSPrinterDriver. Change-Id: I570076b43751e052c5396e89a6674b83a4ad1a1e Reviewed-on: https://pdfium-review.googlesource.com/31298 Reviewed-by: Rebekah Potter Reviewed-by: dsinclair Commit-Queue: Lei Zhang --- core/fxge/cfx_windowsrenderdevice.h | 2 +- core/fxge/win32/fx_win32_device.cpp | 5 +---- core/fxge/win32/fx_win32_print.cpp | 9 ++++++++- core/fxge/win32/win32_int.h | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) (limited to 'core/fxge') diff --git a/core/fxge/cfx_windowsrenderdevice.h b/core/fxge/cfx_windowsrenderdevice.h index c6e6686fab..bbe13415c6 100644 --- a/core/fxge/cfx_windowsrenderdevice.h +++ b/core/fxge/cfx_windowsrenderdevice.h @@ -32,7 +32,7 @@ extern bool g_pdfium_print_text_with_gdi; extern PDFiumEnsureTypefaceCharactersAccessible g_pdfium_typeface_accessible_func; #endif -extern int g_pdfium_print_mode; +extern WindowsPrintMode g_pdfium_print_mode; class CFX_WindowsRenderDevice : public CFX_RenderDevice { public: diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index f5b062ba61..ed03101ecd 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -671,7 +671,7 @@ bool CFX_Win32FontInfo::GetFontCharset(void* hFont, int* charset) { } // namespace -int g_pdfium_print_mode = WindowsPrintMode::kModeEmf; +WindowsPrintMode g_pdfium_print_mode = WindowsPrintMode::kModeEmf; std::unique_ptr SystemFontInfoIface::CreateDefault( const char** pUnused) { @@ -1361,8 +1361,5 @@ RenderDeviceDriverIface* CFX_WindowsRenderDevice::CreateDriver(HDC hDC) { if (g_pdfium_print_mode == WindowsPrintMode::kModeTextOnly) return new CTextOnlyPrinterDriver(hDC); - // Should be PostScript - ASSERT(g_pdfium_print_mode == WindowsPrintMode::kModePostScript2 || - g_pdfium_print_mode == WindowsPrintMode::kModePostScript3); return new CPSPrinterDriver(hDC, g_pdfium_print_mode, false); } diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index 66fbdd9b02..da40b8a762 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -328,8 +328,15 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars, #endif } -CPSPrinterDriver::CPSPrinterDriver(HDC hDC, int pslevel, bool bCmykOutput) +CPSPrinterDriver::CPSPrinterDriver(HDC hDC, + WindowsPrintMode mode, + bool bCmykOutput) : m_hDC(hDC), m_bCmykOutput(bCmykOutput) { + // |mode| should be PostScript. + ASSERT(mode == WindowsPrintMode::kModePostScript2 || + mode == WindowsPrintMode::kModePostScript3); + int pslevel = mode == WindowsPrintMode::kModePostScript2 ? 2 : 3; + m_HorzSize = ::GetDeviceCaps(m_hDC, HORZSIZE); m_VertSize = ::GetDeviceCaps(m_hDC, VERTSIZE); m_Width = ::GetDeviceCaps(m_hDC, HORZRES); diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h index 7d4ec43cb9..fe0e7f3ba9 100644 --- a/core/fxge/win32/win32_int.h +++ b/core/fxge/win32/win32_int.h @@ -14,6 +14,7 @@ #include "core/fxcrt/retain_ptr.h" #include "core/fxge/cfx_pathdata.h" +#include "core/fxge/cfx_windowsrenderdevice.h" #include "core/fxge/renderdevicedriver_iface.h" #include "core/fxge/win32/cfx_psrenderer.h" #include "core/fxge/win32/cpsoutput.h" @@ -270,7 +271,7 @@ class CGdiPrinterDriver : public CGdiDeviceDriver { class CPSPrinterDriver : public RenderDeviceDriverIface { public: - CPSPrinterDriver(HDC hDC, int ps_level, bool bCmykOutput); + CPSPrinterDriver(HDC hDC, WindowsPrintMode mode, bool bCmykOutput); ~CPSPrinterDriver() override; protected: -- cgit v1.2.3