include/svx/sdrpaintwindow.hxx | 14 ++++++------- svx/source/svdraw/sdrpaintwindow.cxx | 36 +++++++++++++++++------------------ 2 files changed, 25 insertions(+), 25 deletions(-)
New commits: commit b396bc042dad1d553ebf51897ef012c08c41a86a Author: Marco Cecchetti <marco.cecche...@collabora.com> Date: Sun Jan 1 12:43:45 2017 +0100 Calc: safer life cycle handling for OutputDevice in SdrPaintWindow Change-Id: I5469332c4ef98bce8cd9c2caff5bf61dbf102b23 Reviewed-on: https://gerrit.libreoffice.org/33220 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Jan Holesovsky <ke...@collabora.com> diff --git a/include/svx/sdrpaintwindow.hxx b/include/svx/sdrpaintwindow.hxx index 25c51c52563b..bcb0b0a8c843 100644 --- a/include/svx/sdrpaintwindow.hxx +++ b/include/svx/sdrpaintwindow.hxx @@ -46,7 +46,7 @@ PaintTransparentChildren(vcl::Window & rWindow, Rectangle const& rPixelRect); class SdrPreRenderDevice { // The original OutputDevice - OutputDevice& mrOutputDevice; + VclPtr<OutputDevice> mpOutputDevice; // The VirtualDevice for PreRendering VclPtr<VirtualDevice> mpPreRenderDevice; @@ -65,7 +65,7 @@ class SVX_DLLPUBLIC SdrPaintWindow { private: // the OutputDevice this window represents - OutputDevice& mrOutputDevice; + VclPtr<OutputDevice> mpOutputDevice; /// In case mrOutputDevice is a buffer for a vcl::Window, this is the window. VclPtr<vcl::Window> mpWindow; @@ -95,7 +95,7 @@ public: // data read accesses SdrPaintView& GetPaintView() const { return mrPaintView; } - OutputDevice& GetOutputDevice() const { return mrOutputDevice; } + OutputDevice& GetOutputDevice() const { return *mpOutputDevice.get(); } vcl::Window* GetWindow() const { return mpWindow; } // OVERLAYMANAGER @@ -108,13 +108,13 @@ public: Rectangle GetVisibleArea() const; // Is OutDev a printer? - bool OutputToPrinter() const { return (OUTDEV_PRINTER == mrOutputDevice.GetOutDevType()); } + bool OutputToPrinter() const { return (OUTDEV_PRINTER == mpOutputDevice->GetOutDevType()); } // Is OutDev a window? - bool OutputToWindow() const { return (OUTDEV_WINDOW == mrOutputDevice.GetOutDevType()); } + bool OutputToWindow() const { return (OUTDEV_WINDOW == mpOutputDevice->GetOutDevType()); } // Is OutDev a VirtualDevice? - bool OutputToVirtualDevice() const { return (OUTDEV_VIRDEV == mrOutputDevice.GetOutDevType()); } + bool OutputToVirtualDevice() const { return (OUTDEV_VIRDEV == mpOutputDevice->GetOutDevType()); } // Is OutDev a recording MetaFile? bool OutputToRecordingMetaFile() const; @@ -134,7 +134,7 @@ public: void setTemporaryTarget(bool bNew) { mbTemporaryTarget = bNew; } // #i72889# get target output device, take into account output buffering - OutputDevice& GetTargetOutputDevice() { if(mpPreRenderDevice) return mpPreRenderDevice->GetPreRenderDevice(); else return mrOutputDevice; } + OutputDevice& GetTargetOutputDevice() { if(mpPreRenderDevice) return mpPreRenderDevice->GetPreRenderDevice(); else return *mpOutputDevice.get(); } }; // typedefs for a list of SdrPaintWindows diff --git a/svx/source/svdraw/sdrpaintwindow.cxx b/svx/source/svdraw/sdrpaintwindow.cxx index a83954a6fef1..8105a65ce05a 100644 --- a/svx/source/svdraw/sdrpaintwindow.cxx +++ b/svx/source/svdraw/sdrpaintwindow.cxx @@ -108,7 +108,7 @@ void CandidateMgr::PaintTransparentChildren(vcl::Window & rWindow, Rectangle con } SdrPreRenderDevice::SdrPreRenderDevice(OutputDevice& rOriginal) -: mrOutputDevice(rOriginal), +: mpOutputDevice(&rOriginal), mpPreRenderDevice(VclPtr<VirtualDevice>::Create()) { } @@ -121,33 +121,33 @@ SdrPreRenderDevice::~SdrPreRenderDevice() void SdrPreRenderDevice::PreparePreRenderDevice() { // compare size of mpPreRenderDevice with size of visible area - if(mpPreRenderDevice->GetOutputSizePixel() != mrOutputDevice.GetOutputSizePixel()) + if(mpPreRenderDevice->GetOutputSizePixel() != mpOutputDevice->GetOutputSizePixel()) { - mpPreRenderDevice->SetOutputSizePixel(mrOutputDevice.GetOutputSizePixel()); + mpPreRenderDevice->SetOutputSizePixel(mpOutputDevice->GetOutputSizePixel()); } // Also compare the MapModes for zoom/scroll changes - if(mpPreRenderDevice->GetMapMode() != mrOutputDevice.GetMapMode()) + if(mpPreRenderDevice->GetMapMode() != mpOutputDevice->GetMapMode()) { - mpPreRenderDevice->SetMapMode(mrOutputDevice.GetMapMode()); + mpPreRenderDevice->SetMapMode(mpOutputDevice->GetMapMode()); } // #i29186# - mpPreRenderDevice->SetDrawMode(mrOutputDevice.GetDrawMode()); - mpPreRenderDevice->SetSettings(mrOutputDevice.GetSettings()); + mpPreRenderDevice->SetDrawMode(mpOutputDevice->GetDrawMode()); + mpPreRenderDevice->SetSettings(mpOutputDevice->GetSettings()); } void SdrPreRenderDevice::OutputPreRenderDevice(const vcl::Region& rExpandedRegion) { // region to pixels - const vcl::Region aRegionPixel(mrOutputDevice.LogicToPixel(rExpandedRegion)); + const vcl::Region aRegionPixel(mpOutputDevice->LogicToPixel(rExpandedRegion)); //RegionHandle aRegionHandle(aRegionPixel.BeginEnumRects()); //Rectangle aRegionRectanglePixel; // MapModes off - bool bMapModeWasEnabledDest(mrOutputDevice.IsMapModeEnabled()); + bool bMapModeWasEnabledDest(mpOutputDevice->IsMapModeEnabled()); bool bMapModeWasEnabledSource(mpPreRenderDevice->IsMapModeEnabled()); - mrOutputDevice.EnableMapMode(false); + mpOutputDevice->EnableMapMode(false); mpPreRenderDevice->EnableMapMode(false); RectangleVector aRectangles; @@ -159,7 +159,7 @@ void SdrPreRenderDevice::OutputPreRenderDevice(const vcl::Region& rExpandedRegio const Point aTopLeft(aRectIter->TopLeft()); const Size aSize(aRectIter->GetSize()); - mrOutputDevice.DrawOutDev( + mpOutputDevice->DrawOutDev( aTopLeft, aSize, aTopLeft, aSize, *mpPreRenderDevice.get()); @@ -175,14 +175,14 @@ void SdrPreRenderDevice::OutputPreRenderDevice(const vcl::Region& rExpandedRegio int nB = comphelper::rng::uniform_int_distribution(0, 0x7F-1); const Color aColor(((((nR|0x80)<<8L)|(nG|0x80))<<8L)|(nB|0x80)); - mrOutputDevice.SetLineColor(aColor); - mrOutputDevice.SetFillColor(); - mrOutputDevice.DrawRect(*aRectIter); + mpOutputDevice->SetLineColor(aColor); + mpOutputDevice->SetFillColor(); + mpOutputDevice->DrawRect(*aRectIter); } #endif } - mrOutputDevice.EnableMapMode(bMapModeWasEnabledDest); + mpOutputDevice->EnableMapMode(bMapModeWasEnabledDest); mpPreRenderDevice->EnableMapMode(bMapModeWasEnabledSource); } @@ -242,7 +242,7 @@ void SdrPaintWindow::impCreateOverlayManager() } SdrPaintWindow::SdrPaintWindow(SdrPaintView& rNewPaintView, OutputDevice& rOut, vcl::Window* pWindow) -: mrOutputDevice(rOut), +: mpOutputDevice(&rOut), mpWindow(pWindow), mrPaintView(rNewPaintView), mpPreRenderDevice(nullptr), @@ -276,7 +276,7 @@ Rectangle SdrPaintWindow::GetVisibleArea() const bool SdrPaintWindow::OutputToRecordingMetaFile() const { - GDIMetaFile* pMetaFile = mrOutputDevice.GetConnectMetaFile(); + GDIMetaFile* pMetaFile = mpOutputDevice->GetConnectMetaFile(); return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause()); } @@ -292,7 +292,7 @@ void SdrPaintWindow::PreparePreRenderDevice() { if(!mpPreRenderDevice) { - mpPreRenderDevice = new SdrPreRenderDevice(mrOutputDevice); + mpPreRenderDevice = new SdrPreRenderDevice(*mpOutputDevice.get()); } } else _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits