From b396bc042dad1d553ebf51897ef012c08c41a86a Mon Sep 17 00:00:00 2001 From: Marco Cecchetti Date: Sun, 1 Jan 2017 12:43:45 +0100 Subject: Calc: safer life cycle handling for OutputDevice in SdrPaintWindow Change-Id: I5469332c4ef98bce8cd9c2caff5bf61dbf102b23 Reviewed-on: https://gerrit.libreoffice.org/33220 Tested-by: Jenkins Reviewed-by: Jan Holesovsky --- svx/source/svdraw/sdrpaintwindow.cxx | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'svx/source/svdraw/sdrpaintwindow.cxx') 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::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 -- cgit