From f95b0743da4239e047db8638c61f90f8bbe54306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Thu, 11 Dec 2014 16:20:49 +0000 Subject: [PATCH] Related: fdo#87242 init VirtualDevice with size of surface otherwise vcl's clipping doesn't work quite right when the render text with vcl apis fallback is used. Manually forced in my case, but it should happen in practice with vertical text, so if there is a bug about vertical text not appearing in slideshows then this is part of the fix for that. Windows and Mac remain unchanged as initialized with 1, 1. If the same problem affects those platforms then they'll need to be adjusted to remember their height/widths from the ctor and those values plugged in here instead Change-Id: I2f82f0db0cf446d7db21f0a7ee4f8c15c7ebdb42 --- canvas/source/cairo/cairo_quartz_cairo.cxx | 2 +- canvas/source/cairo/cairo_win32_cairo.cxx | 2 +- canvas/source/cairo/cairo_xlib_cairo.cxx | 7 ++++++- desktop/source/lib/init.cxx | 2 +- include/vcl/virdev.hxx | 3 ++- vcl/source/gdi/virdev.cxx | 6 ++++-- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/canvas/source/cairo/cairo_quartz_cairo.cxx b/canvas/source/cairo/cairo_quartz_cairo.cxx index 390402a9bde5..b87b993ea532 100644 --- a/canvas/source/cairo/cairo_quartz_cairo.cxx +++ b/canvas/source/cairo/cairo_quartz_cairo.cxx @@ -269,7 +269,7 @@ namespace cairo aSystemGraphicsData.nSize = sizeof(SystemGraphicsData); aSystemGraphicsData.rCGContext = getCGContext(); return boost::shared_ptr( - new VirtualDevice( &aSystemGraphicsData, getDepth() )); + new VirtualDevice( &aSystemGraphicsData, Size(1, 1), getDepth() )); } /** diff --git a/canvas/source/cairo/cairo_win32_cairo.cxx b/canvas/source/cairo/cairo_win32_cairo.cxx index 8d4a4d2ff680..6e1cf6f2f6dd 100644 --- a/canvas/source/cairo/cairo_win32_cairo.cxx +++ b/canvas/source/cairo/cairo_win32_cairo.cxx @@ -197,7 +197,7 @@ namespace cairo aSystemGraphicsData.hDC = cairo_win32_surface_get_dc( mpSurface.get() ); return boost::shared_ptr( - new VirtualDevice( &aSystemGraphicsData, sal::static_int_cast(getDepth()) )); + new VirtualDevice( &aSystemGraphicsData, Size(1, 1), sal::static_int_cast(getDepth()) )); } diff --git a/canvas/source/cairo/cairo_xlib_cairo.cxx b/canvas/source/cairo/cairo_xlib_cairo.cxx index a9e2069f1122..ae9cecb93789 100644 --- a/canvas/source/cairo/cairo_xlib_cairo.cxx +++ b/canvas/source/cairo/cairo_xlib_cairo.cxx @@ -278,8 +278,13 @@ namespace cairo aSystemGraphicsData.hDrawable = getDrawable(); aSystemGraphicsData.pXRenderFormat = getRenderFormat(); + int width = cairo_xlib_surface_get_width(mpSurface.get()); + int height = cairo_xlib_surface_get_height(mpSurface.get()); + return boost::shared_ptr( - new VirtualDevice( &aSystemGraphicsData, std::max( getDepth(), 0 ) )); + new VirtualDevice(&aSystemGraphicsData, + Size(width, height), + std::max(getDepth(), 0))); } /** diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 282cb9917881..9910fd151f65 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -578,7 +578,7 @@ void doc_paintTile (LibreOfficeKitDocument* pThis, SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst); pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA ); - VirtualDevice aDevice(0, (sal_uInt16)32); + VirtualDevice aDevice(0, Size(1, 1), (sal_uInt16)32); boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() ); aDevice.SetOutputSizePixelScaleOffsetAndBuffer( Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx index 624cb2f0f31a..b6361bfbec87 100644 --- a/include/vcl/virdev.hxx +++ b/include/vcl/virdev.hxx @@ -116,7 +116,8 @@ public: Any rendering will happen directly on the context and not on any intermediate bitmap. Note: This might not be supported on all platforms ! */ - explicit VirtualDevice( const SystemGraphicsData *pData, sal_uInt16 nBitCount ); + explicit VirtualDevice(const SystemGraphicsData *pData, const Size &rSize, + sal_uInt16 nBitCount); virtual ~VirtualDevice(); diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index 063bef16b209..eec2fa98768b 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -241,13 +241,15 @@ VirtualDevice::VirtualDevice( const OutputDevice& rCompDev, sal_uInt16 nBitCount mnAlphaDepth = sal::static_int_cast(nAlphaBitCount); } -VirtualDevice::VirtualDevice( const SystemGraphicsData *pData, sal_uInt16 nBitCount ) +VirtualDevice::VirtualDevice(const SystemGraphicsData *pData, const Size &rSize, + sal_uInt16 nBitCount) : mpVirDev( NULL ), meRefDevMode( REFDEV_NONE ) { SAL_INFO( "vcl.gdi", "VirtualDevice::VirtualDevice( " << nBitCount << " )" ); - ImplInitVirDev( Application::GetDefaultDevice(), 1, 1, nBitCount, pData ); + ImplInitVirDev(Application::GetDefaultDevice(), rSize.Width(), rSize.Height(), + nBitCount, pData); } VirtualDevice::~VirtualDevice()