From 820576af4fd6441a752742b43d804e9837839925 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 19 Mar 2015 13:54:12 +0200 Subject: start wrapping OutputDevice in VclPtr Change-Id: If3ecbb0599b50d50ce6b3997ca7892200c332ffe --- canvas/source/vcl/bitmapbackbuffer.hxx | 2 +- canvas/source/vcl/impltools.hxx | 2 +- cppcanvas/source/mtfrenderer/implrenderer.cxx | 12 +- .../source/mtfrenderer/transparencygroupaction.cxx | 14 +- desktop/source/splash/splash.cxx | 4 +- .../source/primitive2d/controlprimitive2d.cxx | 8 +- .../primitive2d/graphicprimitivehelper2d.cxx | 48 +++--- .../source/primitive2d/textlayoutdevice.cxx | 4 +- .../source/processor2d/vclhelperbufferdevice.cxx | 8 +- .../source/processor2d/vclhelperbufferdevice.hxx | 6 +- .../source/processor2d/vclmetafileprocessor2d.cxx | 40 ++--- drawinglayer/source/processor2d/vclprocessor2d.hxx | 3 +- drawinglayer/source/tools/converters.cxx | 24 +-- editeng/source/editeng/editeng.cxx | 4 +- editeng/source/editeng/impedit.hxx | 2 +- editeng/source/items/svxfont.cxx | 2 +- include/editeng/outliner.hxx | 3 +- include/svtools/ctrlbox.hxx | 2 +- include/svtools/ctrltool.hxx | 4 +- include/svtools/prnsetup.hxx | 6 +- include/svtools/ruler.hxx | 2 +- include/svtools/valueset.hxx | 2 +- include/toolkit/awt/vclxgraphics.hxx | 3 +- include/vcl/animate.hxx | 9 +- include/vcl/decoview.hxx | 3 +- include/vcl/event.hxx | 4 +- include/vcl/gdimtf.hxx | 3 +- include/vcl/outdev.hxx | 6 +- include/vcl/print.hxx | 9 +- include/vcl/texteng.hxx | 3 +- include/vcl/virdev.hxx | 4 +- include/vcl/window.hxx | 2 +- svtools/source/contnr/imivctl.hxx | 8 +- svtools/source/contnr/imivctl1.cxx | 16 +- svtools/source/control/ctrlbox.cxx | 29 ++-- svtools/source/control/ctrltool.cxx | 2 +- svtools/source/control/ruler.cxx | 98 +++++------ svtools/source/control/valueset.cxx | 74 ++++----- svtools/source/dialogs/prnsetup.cxx | 11 +- svtools/source/graphic/grfmgr2.cxx | 16 +- svtools/source/graphic/provider.cxx | 16 +- svtools/source/inc/renderer.hxx | 2 +- svtools/source/misc/sampletext.cxx | 14 +- svtools/source/table/gridtablerenderer.cxx | 8 +- svtools/source/toolpanel/paneltabbar.cxx | 24 +-- svtools/source/toolpanel/toolpaneldrawer.hxx | 2 +- vcl/inc/brdwin.hxx | 8 +- vcl/inc/controldata.hxx | 2 +- vcl/inc/outdev.h | 3 +- vcl/inc/printdlg.hxx | 2 +- vcl/inc/svdata.hxx | 20 +-- vcl/inc/window.h | 2 +- vcl/source/app/svdata.cxx | 2 + vcl/source/edit/texteng.cxx | 2 +- vcl/source/edit/textview.cxx | 7 +- vcl/source/filter/graphicfilter.cxx | 16 +- vcl/source/filter/sgfbram.cxx | 14 +- vcl/source/filter/sgvmain.cxx | 4 +- vcl/source/filter/sgvtext.cxx | 16 +- vcl/source/filter/wmf/emfwr.cxx | 114 ++++++------- vcl/source/filter/wmf/emfwr.hxx | 2 +- vcl/source/filter/wmf/wmfwr.cxx | 2 +- vcl/source/filter/wmf/wmfwr.hxx | 2 +- vcl/source/gdi/animate.cxx | 6 + vcl/source/gdi/bitmapex.cxx | 14 +- vcl/source/gdi/cvtsvm.cxx | 26 +-- vcl/source/gdi/gdimetafiletools.cxx | 20 +-- vcl/source/gdi/gdimtf.cxx | 180 ++++++++++----------- vcl/source/gdi/impanmvw.cxx | 22 +-- vcl/source/gdi/impanmvw.hxx | 6 +- vcl/source/gdi/impgraph.cxx | 16 +- vcl/source/gdi/impvect.cxx | 4 +- vcl/source/gdi/pdfwriter_impl.cxx | 14 +- vcl/source/gdi/pdfwriter_impl.hxx | 2 +- vcl/source/gdi/pdfwriter_impl2.cxx | 4 +- vcl/source/gdi/print.cxx | 14 +- vcl/source/gdi/print2.cxx | 94 +++++------ vcl/source/gdi/virdev.cxx | 3 +- vcl/source/outdev/bitmap.cxx | 10 +- vcl/source/outdev/outdev.cxx | 4 +- vcl/source/outdev/text.cxx | 48 +++--- vcl/source/outdev/transparent.cxx | 16 +- vcl/source/outdev/wallpaper.cxx | 10 +- vcl/source/window/brdwin.cxx | 10 +- vcl/source/window/clipping.cxx | 6 +- vcl/source/window/decoview.cxx | 2 +- vcl/source/window/paint.cxx | 4 +- vcl/source/window/printdlg.cxx | 47 +++--- vcl/source/window/status.cxx | 4 +- vcl/source/window/window.cxx | 1 + 90 files changed, 695 insertions(+), 678 deletions(-) diff --git a/canvas/source/vcl/bitmapbackbuffer.hxx b/canvas/source/vcl/bitmapbackbuffer.hxx index c3f2a27a7ba7..b51867994a68 100644 --- a/canvas/source/vcl/bitmapbackbuffer.hxx +++ b/canvas/source/vcl/bitmapbackbuffer.hxx @@ -66,7 +66,7 @@ namespace vclcanvas void updateVDev() const; ::canvas::vcltools::VCLObject maBitmap; - mutable VirtualDevice* mpVDev; // created only on demand + mutable VclPtr mpVDev; // created only on demand const OutputDevice& mrRefDevice; diff --git a/canvas/source/vcl/impltools.hxx b/canvas/source/vcl/impltools.hxx index 059495523db0..c294efd89ae7 100644 --- a/canvas/source/vcl/impltools.hxx +++ b/canvas/source/vcl/impltools.hxx @@ -158,7 +158,7 @@ namespace vclcanvas } } - OutputDevice* mpOutDev; + VclPtr mpOutDev; const bool mbMappingWasEnabled; const sal_uInt16 mnAntiAliasing; }; diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index edc3a6ef887d..3f3894681ddf 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -2908,16 +2908,16 @@ namespace cppcanvas VectorOfOutDevStates aStateStack; - VirtualDevice aVDev; - aVDev.EnableOutput( false ); + ScopedVclPtr aVDev = new VirtualDevice; + aVDev->EnableOutput( false ); // Setup VDev for state tracking and mapping // ========================================= - aVDev.SetMapMode( rMtf.GetPrefMapMode() ); + aVDev->SetMapMode( rMtf.GetPrefMapMode() ); const Size aMtfSize( rMtf.GetPrefSize() ); - const Size aMtfSizePixPre( aVDev.LogicToPixel( aMtfSize, + const Size aMtfSizePixPre( aVDev->LogicToPixel( aMtfSize, rMtf.GetPrefMapMode() ) ); // #i44110# correct null-sized output - there are shapes @@ -2928,7 +2928,7 @@ namespace cppcanvas sal_Int32 nCurrActions(0); ActionFactoryParameters aParms(aStateStack, rCanvas, - aVDev, + *aVDev.get(), rParams, nCurrActions ); @@ -2942,7 +2942,7 @@ namespace cppcanvas 1.0 / aMtfSizePix.Height() ); tools::calcLogic2PixelAffineTransform( aStateStack.getState().mapModeTransform, - aVDev ); + *aVDev.get() ); ColorSharedPtr pColor( getCanvas()->createColor() ); diff --git a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx b/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx index fa91a85f1c3f..74a9505bcf08 100644 --- a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx +++ b/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx @@ -242,10 +242,10 @@ namespace cppcanvas // render our content into an appropriately sized // VirtualDevice with alpha channel - VirtualDevice aVDev( - *::Application::GetDefaultDevice(), 0, 0 ); - aVDev.SetOutputSizePixel( aBitmapSizePixel ); - aVDev.SetMapMode(); + ScopedVclPtr aVDev(new VirtualDevice( + *::Application::GetDefaultDevice(), 0, 0 )); + aVDev->SetOutputSizePixel( aBitmapSizePixel ); + aVDev->SetMapMode(); if( rSubset.mnSubsetBegin != 0 || rSubset.mnSubsetEnd != -1 ) @@ -334,7 +334,7 @@ namespace cppcanvas } } - aVDev.DrawTransparent( aMtf, + aVDev->DrawTransparent( aMtf, aEmptyPoint, aOutputSizePixel, *mpAlphaGradient ); @@ -342,7 +342,7 @@ namespace cppcanvas else { // no subsetting - render whole mtf - aVDev.DrawTransparent( *mpGroupMtf, + aVDev->DrawTransparent( *mpGroupMtf, aEmptyPoint, aOutputSizePixel, *mpAlphaGradient ); @@ -352,7 +352,7 @@ namespace cppcanvas // update buffered bitmap and transformation BitmapSharedPtr aBmp( VCLFactory::getInstance().createBitmap( mpCanvas, - aVDev.GetBitmapEx( + aVDev->GetBitmapEx( aEmptyPoint, aBitmapSizePixel ) ) ); mxBufferBitmap = aBmp->getUNOBitmap(); diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index d0eba20cd0e5..fd55c1d77e17 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -63,7 +63,7 @@ private: static osl::Mutex _aMutex; - VirtualDevice _vdev; + ScopedVclPtr _vdev; BitmapEx _aIntroBmp; Color _cProgressFrameColor; Color _cProgressBarColor; @@ -120,7 +120,7 @@ public: SplashScreen::SplashScreen() : IntroWindow() - , _vdev(*((IntroWindow*)this)) + , _vdev(new VirtualDevice(*((IntroWindow*)this))) , _cProgressFrameColor(sal::static_int_cast< ColorData >(NOT_LOADED)) , _cProgressBarColor(sal::static_int_cast< ColorData >(NOT_LOADED)) , _cProgressTextColor(sal::static_int_cast< ColorData >(NOT_LOADED)) diff --git a/drawinglayer/source/primitive2d/controlprimitive2d.cxx b/drawinglayer/source/primitive2d/controlprimitive2d.cxx index b764e02c21d1..bb84b292ab26 100644 --- a/drawinglayer/source/primitive2d/controlprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/controlprimitive2d.cxx @@ -116,15 +116,15 @@ namespace drawinglayer if(nSizeX > 0 && nSizeY > 0) { // prepare VirtualDevice - VirtualDevice aVirtualDevice(*Application::GetDefaultDevice()); + ScopedVclPtr aVirtualDevice(new VirtualDevice(*Application::GetDefaultDevice())); const Size aSizePixel(nSizeX, nSizeY); - aVirtualDevice.SetOutputSizePixel(aSizePixel); + aVirtualDevice->SetOutputSizePixel(aSizePixel); // set size at control xControlWindow->setPosSize(0, 0, nSizeX, nSizeY, awt::PosSize::POSSIZE); // get graphics and view - uno::Reference< awt::XGraphics > xGraphics(aVirtualDevice.CreateUnoGraphics()); + uno::Reference< awt::XGraphics > xGraphics(aVirtualDevice->CreateUnoGraphics()); uno::Reference< awt::XView > xControlView(rXControl, uno::UNO_QUERY); if(xGraphics.is() && xControlView.is()) @@ -190,7 +190,7 @@ namespace drawinglayer xControlView->draw(0, 0); // get bitmap - const Bitmap aContent(aVirtualDevice.GetBitmap(Point(), aSizePixel)); + const Bitmap aContent(aVirtualDevice->GetBitmap(Point(), aSizePixel)); // to avoid scaling, use the Bitmap pixel size as primitive size const Size aBitmapSize(aContent.GetSizePixel()); diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx index ecf3bb257ce0..1f6ee8d82f9a 100644 --- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx @@ -96,16 +96,16 @@ namespace // with a step count of zero if(maAnimation.Count()) { - VirtualDevice aVirtualDevice(*Application::GetDefaultDevice()); - VirtualDevice aVirtualDeviceMask(*Application::GetDefaultDevice(), 1L); + ScopedVclPtr aVirtualDevice(new VirtualDevice(*Application::GetDefaultDevice())); + ScopedVclPtr aVirtualDeviceMask(new VirtualDevice(*Application::GetDefaultDevice(), 1L)); // Prepare VirtualDevices and their states - aVirtualDevice.EnableMapMode(false); - aVirtualDeviceMask.EnableMapMode(false); - aVirtualDevice.SetOutputSizePixel(maAnimation.GetDisplaySizePixel()); - aVirtualDeviceMask.SetOutputSizePixel(maAnimation.GetDisplaySizePixel()); - aVirtualDevice.Erase(); - aVirtualDeviceMask.Erase(); + aVirtualDevice->EnableMapMode(false); + aVirtualDeviceMask->EnableMapMode(false); + aVirtualDevice->SetOutputSizePixel(maAnimation.GetDisplaySizePixel()); + aVirtualDeviceMask->SetOutputSizePixel(maAnimation.GetDisplaySizePixel()); + aVirtualDevice->Erase(); + aVirtualDeviceMask->Erase(); for(sal_uInt16 a(0L); a < maAnimation.Count(); a++) { @@ -119,20 +119,20 @@ namespace { case DISPOSE_NOT: { - aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx); + aVirtualDevice->DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx); Bitmap aMask = rAnimBitmap.aBmpEx.GetMask(); if(aMask.IsEmpty()) { const Point aEmpty; - const Rectangle aRect(aEmpty, aVirtualDeviceMask.GetOutputSizePixel()); + const Rectangle aRect(aEmpty, aVirtualDeviceMask->GetOutputSizePixel()); const Wallpaper aWallpaper(COL_BLACK); - aVirtualDeviceMask.DrawWallpaper(aRect, aWallpaper); + aVirtualDeviceMask->DrawWallpaper(aRect, aWallpaper); } else { BitmapEx aExpandVisibilityMask = BitmapEx(aMask, aMask); - aVirtualDeviceMask.DrawBitmapEx(rAnimBitmap.aPosPix, aExpandVisibilityMask); + aVirtualDeviceMask->DrawBitmapEx(rAnimBitmap.aPosPix, aExpandVisibilityMask); } break; @@ -143,42 +143,42 @@ namespace const Bitmap aMask(rAnimBitmap.aBmpEx.GetMask()); const Bitmap aContent(rAnimBitmap.aBmpEx.GetBitmap()); - aVirtualDeviceMask.Erase(); - aVirtualDevice.DrawBitmap(rAnimBitmap.aPosPix, aContent); + aVirtualDeviceMask->Erase(); + aVirtualDevice->DrawBitmap(rAnimBitmap.aPosPix, aContent); if(aMask.IsEmpty()) { const Rectangle aRect(rAnimBitmap.aPosPix, aContent.GetSizePixel()); - aVirtualDeviceMask.SetFillColor(COL_BLACK); - aVirtualDeviceMask.SetLineColor(); - aVirtualDeviceMask.DrawRect(aRect); + aVirtualDeviceMask->SetFillColor(COL_BLACK); + aVirtualDeviceMask->SetLineColor(); + aVirtualDeviceMask->DrawRect(aRect); } else { - aVirtualDeviceMask.DrawBitmap(rAnimBitmap.aPosPix, aMask); + aVirtualDeviceMask->DrawBitmap(rAnimBitmap.aPosPix, aMask); } break; } case DISPOSE_FULL: { - aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx); + aVirtualDevice->DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx); break; } case DISPOSE_PREVIOUS : { - aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx); - aVirtualDeviceMask.DrawBitmap(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx.GetMask()); + aVirtualDevice->DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx); + aVirtualDeviceMask->DrawBitmap(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx.GetMask()); break; } } // create BitmapEx - Bitmap aMainBitmap = aVirtualDevice.GetBitmap(Point(), aVirtualDevice.GetOutputSizePixel()); + Bitmap aMainBitmap = aVirtualDevice->GetBitmap(Point(), aVirtualDevice->GetOutputSizePixel()); #if defined(MACOSX) || defined(IOS) - AlphaMask aMaskBitmap( aVirtualDeviceMask.GetBitmap( Point(), aVirtualDeviceMask.GetOutputSizePixel())); + AlphaMask aMaskBitmap( aVirtualDeviceMask->GetBitmap( Point(), aVirtualDeviceMask->GetOutputSizePixel())); #else - Bitmap aMaskBitmap = aVirtualDeviceMask.GetBitmap( Point(), aVirtualDeviceMask.GetOutputSizePixel()); + Bitmap aMaskBitmap = aVirtualDeviceMask->GetBitmap( Point(), aVirtualDeviceMask->GetOutputSizePixel()); #endif aNextStep.maBitmapEx = BitmapEx(aMainBitmap, aMaskBitmap); diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx index 919625967845..d34403d819aa 100644 --- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx +++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx @@ -59,7 +59,7 @@ namespace class ImpTimedRefDev : public Timer { scoped_timed_RefDev& mrOwnerOfMe; - VirtualDevice* mpVirDev; + VclPtr mpVirDev; sal_uInt32 mnUseCount; public: @@ -84,7 +84,7 @@ namespace { OSL_ENSURE(0L == mnUseCount, "destruction of a still used ImpTimedRefDev (!)"); const SolarMutexGuard aGuard; - delete mpVirDev; + mpVirDev.disposeAndClear(); } void ImpTimedRefDev::Invoke() diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx index efa41c8565bc..4c22ca4f1c5b 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx @@ -32,7 +32,7 @@ namespace { - typedef ::std::vector< VirtualDevice* > aBuffers; + typedef ::std::vector< VclPtr > aBuffers; class VDevBuffer : public Timer, protected comphelper::OBaseMutex { @@ -69,13 +69,13 @@ namespace while(!maFreeBuffers.empty()) { - delete *(maFreeBuffers.end() - 1); + (*(maFreeBuffers.end() - 1)).disposeAndClear(); maFreeBuffers.pop_back(); } while(!maUsedBuffers.empty()) { - delete *(maUsedBuffers.end() - 1); + (*(maUsedBuffers.end() - 1)).disposeAndClear(); maUsedBuffers.pop_back(); } } @@ -197,7 +197,7 @@ namespace while(!maFreeBuffers.empty()) { - delete *(maFreeBuffers.end() - 1); + (*(maFreeBuffers.end() - 1)).disposeAndClear(); maFreeBuffers.pop_back(); } } diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx index 02aa3c0024ab..0ba73114dc4f 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx @@ -35,9 +35,9 @@ namespace drawinglayer class impBufferDevice { OutputDevice& mrOutDev; - VirtualDevice* mpContent; - VirtualDevice* mpMask; - VirtualDevice* mpAlpha; + VclPtr mpContent; + VclPtr mpMask; + VclPtr mpAlpha; Rectangle maDestPixel; public: diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 2b2c0b86d220..935b0b5e9d53 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -252,20 +252,20 @@ namespace drawinglayer const Rectangle aPrimitiveRectangle( basegfx::fround(aPrimitiveRange.getMinX()), basegfx::fround(aPrimitiveRange.getMinY()), basegfx::fround(aPrimitiveRange.getMaxX()), basegfx::fround(aPrimitiveRange.getMaxY())); - VirtualDevice aContentVDev; + ScopedVclPtr aContentVDev = new VirtualDevice; MapMode aNewMapMode(pLastOutputDevice->GetMapMode()); - mpOutputDevice = &aContentVDev; + mpOutputDevice = aContentVDev.get(); mpMetaFile = &o_rContentMetafile; - aContentVDev.EnableOutput(false); - aContentVDev.SetMapMode(pLastOutputDevice->GetMapMode()); - o_rContentMetafile.Record(&aContentVDev); - aContentVDev.SetLineColor(pLastOutputDevice->GetLineColor()); - aContentVDev.SetFillColor(pLastOutputDevice->GetFillColor()); - aContentVDev.SetFont(pLastOutputDevice->GetFont()); - aContentVDev.SetDrawMode(pLastOutputDevice->GetDrawMode()); - aContentVDev.SetSettings(pLastOutputDevice->GetSettings()); - aContentVDev.SetRefPoint(pLastOutputDevice->GetRefPoint()); + aContentVDev->EnableOutput(false); + aContentVDev->SetMapMode(pLastOutputDevice->GetMapMode()); + o_rContentMetafile.Record(aContentVDev.get()); + aContentVDev->SetLineColor(pLastOutputDevice->GetLineColor()); + aContentVDev->SetFillColor(pLastOutputDevice->GetFillColor()); + aContentVDev->SetFont(pLastOutputDevice->GetFont()); + aContentVDev->SetDrawMode(pLastOutputDevice->GetDrawMode()); + aContentVDev->SetSettings(pLastOutputDevice->GetSettings()); + aContentVDev->SetRefPoint(pLastOutputDevice->GetRefPoint()); // dump to MetaFile process(rContent); @@ -2016,7 +2016,7 @@ namespace drawinglayer const Rectangle aRectPixel(mpOutputDevice->LogicToPixel(aRectLogic)); Size aSizePixel(aRectPixel.GetSize()); const Point aEmptyPoint; - VirtualDevice aBufferDevice; + ScopedVclPtr aBufferDevice = new VirtualDevice; const sal_uInt32 nMaxQuadratPixels(500000); const sal_uInt32 nViewVisibleArea(aSizePixel.getWidth() * aSizePixel.getHeight()); double fReduceFactor(1.0); @@ -2029,20 +2029,20 @@ namespace drawinglayer basegfx::fround((double)aSizePixel.getHeight() * fReduceFactor)); } - if(aBufferDevice.SetOutputSizePixel(aSizePixel)) + if(aBufferDevice->SetOutputSizePixel(aSizePixel)) { // create and set MapModes for target devices MapMode aNewMapMode(mpOutputDevice->GetMapMode()); aNewMapMode.SetOrigin(Point(-aRectLogic.Left(), -aRectLogic.Top())); - aBufferDevice.SetMapMode(aNewMapMode); + aBufferDevice->SetMapMode(aNewMapMode); // prepare view transformation for target renderers // ATTENTION! Need to apply another scaling because of the potential DPI differences // between Printer and VDev (mpOutputDevice and aBufferDevice here). // To get the DPI, LogicToPixel from (1,1) from MAP_INCH needs to be used. - basegfx::B2DHomMatrix aViewTransform(aBufferDevice.GetViewTransformation()); + basegfx::B2DHomMatrix aViewTransform(aBufferDevice->GetViewTransformation()); const Size aDPIOld(mpOutputDevice->LogicToPixel(Size(1, 1), MAP_INCH)); - const Size aDPINew(aBufferDevice.LogicToPixel(Size(1, 1), MAP_INCH)); + const Size aDPINew(aBufferDevice->LogicToPixel(Size(1, 1), MAP_INCH)); const double fDPIXChange((double)aDPIOld.getWidth() / (double)aDPINew.getWidth()); const double fDPIYChange((double)aDPIOld.getHeight() / (double)aDPINew.getHeight()); @@ -2067,16 +2067,16 @@ namespace drawinglayer getViewInformation2D().getViewTime(), getViewInformation2D().getExtendedInformationSequence()); - VclPixelProcessor2D aBufferProcessor(aViewInfo, aBufferDevice); + VclPixelProcessor2D aBufferProcessor(aViewInfo, *aBufferDevice.get()); // draw content using pixel renderer aBufferProcessor.process(rContent); - const Bitmap aBmContent(aBufferDevice.GetBitmap(aEmptyPoint, aSizePixel)); + const Bitmap aBmContent(aBufferDevice->GetBitmap(aEmptyPoint, aSizePixel)); // draw transparence using pixel renderer - aBufferDevice.Erase(); + aBufferDevice->Erase(); aBufferProcessor.process(rTransparence); - const AlphaMask aBmAlpha(aBufferDevice.GetBitmap(aEmptyPoint, aSizePixel)); + const AlphaMask aBmAlpha(aBufferDevice->GetBitmap(aEmptyPoint, aSizePixel)); // paint mpOutputDevice->DrawBitmapEx( diff --git a/drawinglayer/source/processor2d/vclprocessor2d.hxx b/drawinglayer/source/processor2d/vclprocessor2d.hxx index 70de6a19aca1..a527bb27c5e3 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.hxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.hxx @@ -26,6 +26,7 @@ #include #include #include +#include // predefines @@ -70,7 +71,7 @@ namespace drawinglayer { protected: // the destination OutDev - OutputDevice* mpOutputDevice; + VclPtr mpOutputDevice; // the modifiedColorPrimitive stack basegfx::BColorModifierStack maBColorModifierStack; diff --git a/drawinglayer/source/tools/converters.cxx b/drawinglayer/source/tools/converters.cxx index 188bfa9f5327..e06356cabc82 100644 --- a/drawinglayer/source/tools/converters.cxx +++ b/drawinglayer/source/tools/converters.cxx @@ -73,21 +73,21 @@ namespace drawinglayer const Point aEmptyPoint; const Size aSizePixel(nDiscreteWidth, nDiscreteHeight); geometry::ViewInformation2D aViewInformation2D(rViewInformation2D); - VirtualDevice maContent; + ScopedVclPtr maContent = new VirtualDevice; // prepare vdev - maContent.SetOutputSizePixel(aSizePixel, false); - maContent.SetMapMode(aMapModePixel); + maContent->SetOutputSizePixel(aSizePixel, false); + maContent->SetMapMode(aMapModePixel); // set to all white - maContent.SetBackground(Wallpaper(Color(COL_WHITE))); - maContent.Erase(); + maContent->SetBackground(Wallpaper(Color(COL_WHITE))); + maContent->Erase(); // create pixel processor, also already takes care of AAing and // checking the getOptionsDrawinglayer().IsAntiAliasing() switch. If // not wanted, change after this call as needed processor2d::BaseProcessor2D* pContentProcessor = processor2d::createPixelProcessor2DFromOutputDevice( - maContent, + *maContent.get(), aViewInformation2D); if(pContentProcessor) @@ -96,8 +96,8 @@ namespace drawinglayer pContentProcessor->process(aSequence); // get content - maContent.EnableMapMode(false); - const Bitmap aContent(maContent.GetBitmap(aEmptyPoint, aSizePixel)); + maContent->EnableMapMode(false); + const Bitmap aContent(maContent->GetBitmap(aEmptyPoint, aSizePixel)); #ifdef DBG_UTIL if(bDoSaveForVisualControl) @@ -108,10 +108,10 @@ namespace drawinglayer } #endif // prepare for mask creation - maContent.SetMapMode(aMapModePixel); + maContent->SetMapMode(aMapModePixel); // set alpha to all white (fully transparent) - maContent.Erase(); + maContent->Erase(); // embed primitives to paint them black const primitive2d::Primitive2DReference xRef( @@ -127,8 +127,8 @@ namespace drawinglayer delete pContentProcessor; // get alpha cahannel from vdev - maContent.EnableMapMode(false); - const Bitmap aAlpha(maContent.GetBitmap(aEmptyPoint, aSizePixel)); + maContent->EnableMapMode(false); + const Bitmap aAlpha(maContent->GetBitmap(aEmptyPoint, aSizePixel)); #ifdef DBG_UTIL if(bDoSaveForVisualControl) { diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 21bdec0715e9..d795c0f69a9f 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -1755,14 +1755,14 @@ SvxFont EditEngine::GetStandardSvxFont( sal_Int32 nPara ) void EditEngine::StripPortions() { - VirtualDevice aTmpDev; + ScopedVclPtr aTmpDev = new VirtualDevice; Rectangle aBigRect( Point( 0, 0 ), Size( 0x7FFFFFFF, 0x7FFFFFFF ) ); if ( IsVertical() ) { aBigRect.Right() = 0; aBigRect.Left() = -0x7FFFFFFF; } - pImpEditEngine->Paint( &aTmpDev, aBigRect, Point(), true ); + pImpEditEngine->Paint( aTmpDev.get(), aBigRect, Point(), true ); } void EditEngine::GetPortions( sal_Int32 nPara, std::vector& rList ) diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index ac5db16c7bf3..8e2dcb99c0af 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -114,7 +114,7 @@ struct DragAndDropInfo EditPaM aDropDest; sal_Int32 nOutlinerDropDest; ESelection aDropSel; - VirtualDevice* pBackground; + VclPtr pBackground; const SvxFieldItem* pField; bool bVisCursor : 1; bool bDroppedInMe : 1; diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx index e93edd42e372..da7e9183e4ad 100644 --- a/editeng/source/items/svxfont.cxx +++ b/editeng/source/items/svxfont.cxx @@ -163,7 +163,7 @@ OUString SvxFont::CalcCaseMap(const OUString &rTxt) const class SvxDoCapitals { protected: - OutputDevice *pOut; + VclPtr pOut; const OUString &rTxt; const sal_Int32 nIdx; const sal_Int32 nLen; diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index b973e64e1d79..b00cdce52101 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -475,7 +476,7 @@ struct EDITENG_DLLPUBLIC PaintFirstLineInfo long mnBaseLineY; const Point& mrOrigin; short mnOrientation; - OutputDevice* mpOutDev; + VclPtr mpOutDev; PaintFirstLineInfo( sal_Int32 nPara, const Point& rStartPos, long nBaseLineY, const Point& rOrigin, short nOrientation, OutputDevice* pOutDev ) : mnPara( nPara ), mrStartPos( rStartPos ), mnBaseLineY( nBaseLineY ), mrOrigin( rOrigin ), mnOrientation( nOrientation ), mpOutDev( pOutDev ) diff --git a/include/svtools/ctrlbox.hxx b/include/svtools/ctrlbox.hxx index b115065c04a6..bfda380456c4 100644 --- a/include/svtools/ctrlbox.hxx +++ b/include/svtools/ctrlbox.hxx @@ -280,7 +280,7 @@ class SVT_DLLPUBLIC LineListBox : public ListBox long m_nWidth; OUString m_sNone; - VirtualDevice aVirDev; + ScopedVclPtr aVirDev; Size aTxtSize; Color aColor; Color maPaintCol; diff --git a/include/svtools/ctrltool.hxx b/include/svtools/ctrltool.hxx index 23f07b093c14..3e51740bdfe3 100644 --- a/include/svtools/ctrltool.hxx +++ b/include/svtools/ctrltool.hxx @@ -150,8 +150,8 @@ private: OUString maBlack; OUString maBlackItalic; sal_IntPtr* mpSizeAry; - OutputDevice* mpDev; - OutputDevice* mpDev2; + VclPtr mpDev; + VclPtr mpDev2; boost::ptr_vector maEntries; SVT_DLLPRIVATE ImplFontListNameInfo* ImplFind( const OUString& rSearchName, sal_uLong* pIndex ) const; diff --git a/include/svtools/prnsetup.hxx b/include/svtools/prnsetup.hxx index c30062b4aa35..62d430a053c3 100644 --- a/include/svtools/prnsetup.hxx +++ b/include/svtools/prnsetup.hxx @@ -47,9 +47,9 @@ private: VclPtr m_pFiType; VclPtr m_pFiLocation; VclPtr m_pFiComment; - AutoTimer maStatusTimer; - Printer* mpPrinter; - Printer* mpTempPrinter; + AutoTimer maStatusTimer; + VclPtr mpPrinter; + VclPtr mpTempPrinter; SVT_DLLPRIVATE void ImplSetInfo(); diff --git a/include/svtools/ruler.hxx b/include/svtools/ruler.hxx index 9f2ba57093da..2f458c15e33c 100644 --- a/include/svtools/ruler.hxx +++ b/include/svtools/ruler.hxx @@ -625,7 +625,7 @@ class ImplRulerData; class SVT_DLLPUBLIC Ruler : public vcl::Window { private: - VirtualDevice maVirDev; + ScopedVclPtr maVirDev; MapMode maMapMode; long mnBorderOff; long mnWinOff; diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx index 35f5b4af01e0..a6a8e5e47ffc 100644 --- a/include/svtools/valueset.hxx +++ b/include/svtools/valueset.hxx @@ -197,7 +197,7 @@ class SVT_DLLPUBLIC ValueSet : public Control { private: - VirtualDevice maVirDev; + ScopedVclPtr maVirDev; Timer maTimer; ValueItemList mItemList; ValueSetItemPtr mpNoneItem; diff --git a/include/toolkit/awt/vclxgraphics.hxx b/include/toolkit/awt/vclxgraphics.hxx index 627b6759f43b..89a568fe6fa9 100644 --- a/include/toolkit/awt/vclxgraphics.hxx +++ b/include/toolkit/awt/vclxgraphics.hxx @@ -31,6 +31,7 @@ #include #include #include +#include class OutputDevice; namespace vcl { class Region; } @@ -55,7 +56,7 @@ private: // used to return same reference on each call to getDevice() ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice> mxDevice; - OutputDevice* mpOutputDevice; + VclPtr mpOutputDevice; vcl::Font maFont; Color maTextColor; Color maTextFillColor; diff --git a/include/vcl/animate.hxx b/include/vcl/animate.hxx index e966e3feac81..17d62a1a3d1a 100644 --- a/include/vcl/animate.hxx +++ b/include/vcl/animate.hxx @@ -23,6 +23,7 @@ #include #include #include +#include #define ANIMATION_TIMEOUT_ON_CLICK 2147483647L @@ -108,17 +109,13 @@ struct AInfo Point aLastSavePoint; Point aStartOrg; Size aStartSize; - OutputDevice* pOutDev; + VclPtr pOutDev; void* pViewData; long nExtraData; bool bWithSize; bool bPause; - AInfo() : pOutDev( NULL ), - pViewData( NULL ), - nExtraData( 0L ), - bWithSize( false ), - bPause( false ) {} + AInfo(); }; class ImplAnimView; diff --git a/include/vcl/decoview.hxx b/include/vcl/decoview.hxx index 4094f693bca2..2de96a5941dd 100644 --- a/include/vcl/decoview.hxx +++ b/include/vcl/decoview.hxx @@ -21,6 +21,7 @@ #define INCLUDED_VCL_DECOVIEW_HXX #include +#include #include class Rectangle; @@ -70,7 +71,7 @@ class OutputDevice; class VCL_DLLPUBLIC DecorationView { private: - OutputDevice* mpOutDev; + VclPtr mpOutDev; public: DecorationView(OutputDevice* pOutDev); diff --git a/include/vcl/event.hxx b/include/vcl/event.hxx index 22361a6f910b..da38cfa98373 100644 --- a/include/vcl/event.hxx +++ b/include/vcl/event.hxx @@ -27,9 +27,9 @@ #include #include #include +#include class AllSettings; -class OutputDevice; namespace vcl { class Window; } struct IDataObject; @@ -303,7 +303,7 @@ inline HelpEvent::HelpEvent( HelpEventMode nHelpMode ) class VCL_DLLPUBLIC UserDrawEvent { private: - OutputDevice* mpOutDev; + VclPtr mpOutDev; Rectangle maOutRect; sal_uInt16 mnItemId; sal_uInt16 mnStyle; diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx index 05ab48ad2c98..e860dda464b1 100644 --- a/include/vcl/gdimtf.hxx +++ b/include/vcl/gdimtf.hxx @@ -25,6 +25,7 @@ #include #include #include +#include #include class OutputDevice; @@ -80,7 +81,7 @@ private: Link aHookHdlLink; GDIMetaFile* pPrev; GDIMetaFile* pNext; - OutputDevice* pOutDev; + VclPtr pOutDev; bool bPause; bool bRecord; bool bUseCanvas; diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index e53fc65a982e..b9d542fed31f 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -288,8 +288,8 @@ private: OutputDevice& operator=(const OutputDevice&) SAL_DELETED_FUNCTION; mutable SalGraphics* mpGraphics; ///< Graphics context to draw on - mutable OutputDevice* mpPrevGraphics; ///< Previous output device in list - mutable OutputDevice* mpNextGraphics; ///< Next output device in list + mutable VclPtr mpPrevGraphics; ///< Previous output device in list + mutable VclPtr mpNextGraphics; ///< Next output device in list GDIMetaFile* mpMetaFile; mutable ImplFontEntry* mpFontEntry; mutable ImplFontCache* mpFontCache; @@ -303,7 +303,7 @@ private: vcl::ExtOutDevData* mpExtOutDevData; // TEMP TEMP TEMP - VirtualDevice* mpAlphaVDev; + VclPtr mpAlphaVDev; /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) long mnOutOffOrigX; diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx index bf7ea47d56ff..be18fd06bb6a 100644 --- a/include/vcl/print.hxx +++ b/include/vcl/print.hxx @@ -203,9 +203,9 @@ private: SalInfoPrinter* mpInfoPrinter; SalPrinter* mpPrinter; SalGraphics* mpJobGraphics; - Printer* mpPrev; - Printer* mpNext; - VirtualDevice* mpDisplayDev; + VclPtr mpPrev; + VclPtr mpNext; + VclPtr mpDisplayDev; PrinterOptions* mpPrinterOptions; OUString maPrinterName; OUString maDriver; @@ -299,6 +299,7 @@ public: Printer( const QueueInfo& rQueueInfo ); Printer( const OUString& rPrinterName ); virtual ~Printer(); + virtual void dispose() SAL_OVERRIDE; static const std::vector< OUString >& GetPrinterQueues(); static const QueueInfo* GetQueueInfo( const OUString& rPrinterName, bool bStatusUpdate ); @@ -309,7 +310,7 @@ public: const OUString& GetName() const { return maPrinterName; } const OUString& GetDriverName() const { return maDriver; } bool IsDefPrinter() const { return mbDefPrinter; } - bool IsDisplayPrinter() const { return mpDisplayDev != NULL; } + bool IsDisplayPrinter() const { return mpDisplayDev != nullptr; } bool IsValid() const { return !IsDisplayPrinter(); } sal_uLong GetCapabilities( sal_uInt16 nType ) const; diff --git a/include/vcl/texteng.hxx b/include/vcl/texteng.hxx index 5df2098f2d65..46161b5aa1fc 100644 --- a/include/vcl/texteng.hxx +++ b/include/vcl/texteng.hxx @@ -20,6 +20,7 @@ #define INCLUDED_VCL_TEXTENG_HXX #include +#include class TextDoc; class TextView; @@ -91,7 +92,7 @@ class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster private: TextDoc* mpDoc; TEParaPortions* mpTEParaPortions; - OutputDevice* mpRefDev; + VclPtr mpRefDev; TextViews* mpViews; TextView* mpActiveView; diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx index 88f9fb65118c..3720a19c98f3 100644 --- a/include/vcl/virdev.hxx +++ b/include/vcl/virdev.hxx @@ -35,8 +35,8 @@ class VCL_DLLPUBLIC VirtualDevice : public OutputDevice private: SalVirtualDevice* mpVirDev; - VirtualDevice* mpPrev; - VirtualDevice* mpNext; + VclPtr mpPrev; + VclPtr mpNext; sal_uInt16 mnBitCount; bool mbScreenComp; sal_Int8 mnAlphaDepth; diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 5dcfb3543ee1..0ee581a9d298 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -418,7 +418,7 @@ private: // This is a first attempt to start to remove the dependency of Window on // OutputDevice - ::OutputDevice* mpOutputDevice; + VclPtr<::OutputDevice> mpOutputDevice; #ifdef DBG_UTIL friend const char* ::ImplDbgCheckWindow( const void* pObj ); diff --git a/svtools/source/contnr/imivctl.hxx b/svtools/source/contnr/imivctl.hxx index c17497f5acb8..e5a8445b98c7 100644 --- a/svtools/source/contnr/imivctl.hxx +++ b/svtools/source/contnr/imivctl.hxx @@ -200,10 +200,10 @@ class SvxIconChoiceCtrl_Impl SvxIconChoiceCtrlEntry* pPrevDropTarget; SvxIconChoiceCtrlEntry* pHdlEntry; SvxIconChoiceCtrlEntry* pDDRefEntry; - VirtualDevice* pDDDev; - VirtualDevice* pDDBufDev; - VirtualDevice* pDDTempDev; - VirtualDevice* pEntryPaintDev; + VclPtr pDDDev; + VclPtr pDDBufDev; + VclPtr pDDTempDev; + VclPtr pEntryPaintDev; SvxIconChoiceCtrlEntry* pAnchor; // for selection LocalFocus aFocus; // Data for focusrect ::svt::AccessibleFactoryAccess aAccFactory; diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx index 021757701065..2216348cb599 100644 --- a/svtools/source/contnr/imivctl1.cxx +++ b/svtools/source/contnr/imivctl1.cxx @@ -164,10 +164,10 @@ SvxIconChoiceCtrl_Impl::~SvxIconChoiceCtrl_Impl() delete pZOrderList; delete pImpCursor; delete pGridMap; - delete pDDDev; - delete pDDBufDev; - delete pDDTempDev; - delete pEntryPaintDev; + pDDDev.disposeAndClear(); + pDDBufDev.disposeAndClear(); + pDDTempDev.disposeAndClear(); + pEntryPaintDev.disposeAndClear(); ClearSelectedRectList(); ClearColumnList(); aVerSBar.disposeAndClear(); @@ -261,10 +261,10 @@ IMPL_LINK_NOARG(SvxIconChoiceCtrl_Impl, EndScrollHdl) void SvxIconChoiceCtrl_Impl::FontModified() { StopEditTimer(); - DELETEZ(pDDDev); - DELETEZ(pDDBufDev); - DELETEZ(pDDTempDev); - DELETEZ(pEntryPaintDev); + pDDDev.disposeAndClear(); + pDDBufDev.disposeAndClear(); + pDDTempDev.disposeAndClear(); + pEntryPaintDev.disposeAndClear(); SetDefaultTextSize(); ShowCursor( false ); ShowCursor( true ); diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index 0c49ef8a338b..2b95a5e7d586 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -670,8 +670,8 @@ void LineListBox::ImpGetLine( long nLine1, long nLine2, long nDistance, } // Linien malen - aSize = aVirDev.PixelToLogic( aSize ); - long nPix = aVirDev.PixelToLogic( Size( 0, 1 ) ).Height(); + aSize = aVirDev->PixelToLogic( aSize ); + long nPix = aVirDev->PixelToLogic( Size( 0, 1 ) ).Height(); sal_uInt32 n1 = nLine1; sal_uInt32 n2 = nLine2; long nDist = nDistance; @@ -690,24 +690,24 @@ void LineListBox::ImpGetLine( long nLine1, long nLine2, long nDistance, // negative width should not be drawn if ( aSize.Width() > 0 ) { - Size aVirSize = aVirDev.LogicToPixel( aSize ); - if ( aVirDev.GetOutputSizePixel() != aVirSize ) - aVirDev.SetOutputSizePixel( aVirSize ); - aVirDev.SetFillColor( aColorDist ); - aVirDev.DrawRect( Rectangle( Point(), aSize ) ); + Size aVirSize = aVirDev->LogicToPixel( aSize ); + if ( aVirDev->GetOutputSizePixel() != aVirSize ) + aVirDev->SetOutputSizePixel( aVirSize ); + aVirDev->SetFillColor( aColorDist ); + aVirDev->DrawRect( Rectangle( Point(), aSize ) ); - aVirDev.SetFillColor( aColor1 ); + aVirDev->SetFillColor( aColor1 ); double y1 = double( n1 ) / 2; - svtools::DrawLine( aVirDev, basegfx::B2DPoint( 0, y1 ), basegfx::B2DPoint( aSize.Width( ), y1 ), n1, nStyle ); + svtools::DrawLine( *aVirDev.get(), basegfx::B2DPoint( 0, y1 ), basegfx::B2DPoint( aSize.Width( ), y1 ), n1, nStyle ); if ( n2 ) { double y2 = n1 + nDist + double( n2 ) / 2; - aVirDev.SetFillColor( aColor2 ); - svtools::DrawLine( aVirDev, basegfx::B2DPoint( 0, y2 ), basegfx::B2DPoint( aSize.Width(), y2 ), n2, table::BorderLineStyle::SOLID ); + aVirDev->SetFillColor( aColor2 ); + svtools::DrawLine( *aVirDev.get(), basegfx::B2DPoint( 0, y2 ), basegfx::B2DPoint( aSize.Width(), y2 ), n2, table::BorderLineStyle::SOLID ); } - rBmp = aVirDev.GetBitmap( Point(), Size( aSize.Width(), n1+nDist+n2 ) ); + rBmp = aVirDev->GetBitmap( Point(), Size( aSize.Width(), n1+nDist+n2 ) ); } } @@ -719,8 +719,8 @@ void LineListBox::ImplInit() eUnit = FUNIT_POINT; eSourceUnit = FUNIT_POINT; - aVirDev.SetLineColor(); - aVirDev.SetMapMode( MapMode( MAP_TWIP ) ); + aVirDev->SetLineColor(); + aVirDev->SetMapMode( MapMode( MAP_TWIP ) ); UpdatePaintLineColor(); } @@ -729,6 +729,7 @@ LineListBox::LineListBox( vcl::Window* pParent, WinBits nWinStyle ) : ListBox( pParent, nWinStyle ), m_nWidth( 5 ), m_sNone( ), + aVirDev( new VirtualDevice ), aColor( COL_BLACK ), maPaintCol( COL_BLACK ) { diff --git a/svtools/source/control/ctrltool.cxx b/svtools/source/control/ctrltool.cxx index 7babd84d5fbf..bc2af3a7aa3b 100644 --- a/svtools/source/control/ctrltool.cxx +++ b/svtools/source/control/ctrltool.cxx @@ -73,7 +73,7 @@ class ImplFontListFontInfo : public vcl::FontInfo friend class FontList; private: - OutputDevice* mpDevice; + VclPtr mpDevice; ImplFontListFontInfo* mpNext; public: diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx index 230d10e0f743..5e45e596f831 100644 --- a/svtools/source/control/ruler.cxx +++ b/svtools/source/control/ruler.cxx @@ -290,7 +290,7 @@ void Ruler::ImplInit( WinBits nWinBits ) Ruler::Ruler( vcl::Window* pParent, WinBits nWinStyle ) : Window( pParent, nWinStyle & WB_3DLOOK ), - maVirDev( *this ), + maVirDev( new VirtualDevice(*this) ), maMapMode( MAP_100TH_MM ), mpSaveData(new ImplRulerData), mpData(NULL), @@ -362,9 +362,9 @@ void Ruler::ImplVDrawLine( long nX1, long nY1, long nX2, long nY2 ) } if ( mnWinStyle & WB_HORZ ) - maVirDev.DrawLine( Point( nX1, nY1 ), Point( nX2, nY2 ) ); + maVirDev->DrawLine( Point( nX1, nY1 ), Point( nX2, nY2 ) ); else - maVirDev.DrawLine( Point( nY1, nX1 ), Point( nY2, nX2 ) ); + maVirDev->DrawLine( Point( nY1, nX1 ), Point( nY2, nX2 ) ); } void Ruler::ImplVDrawRect( long nX1, long nY1, long nX2, long nY2 ) @@ -384,15 +384,15 @@ void Ruler::ImplVDrawRect( long nX1, long nY1, long nX2, long nY2 ) } if ( mnWinStyle & WB_HORZ ) - maVirDev.DrawRect( Rectangle( nX1, nY1, nX2, nY2 ) ); + maVirDev->DrawRect( Rectangle( nX1, nY1, nX2, nY2 ) ); else - maVirDev.DrawRect( Rectangle( nY1, nX1, nY2, nX2 ) ); + maVirDev->DrawRect( Rectangle( nY1, nX1, nY2, nX2 ) ); } void Ruler::ImplVDrawText( long nX, long nY, const OUString& rText, long nMin, long nMax ) { Rectangle aRect; - maVirDev.GetTextBoundRect( aRect, rText ); + maVirDev->GetTextBoundRect( aRect, rText ); long nShiftX = ( aRect.GetWidth() / 2 ) + aRect.Left(); long nShiftY = ( aRect.GetHeight() / 2 ) + aRect.Top(); @@ -400,9 +400,9 @@ void Ruler::ImplVDrawText( long nX, long nY, const OUString& rText, long nMin, l if ( (nX > -RULER_CLIP) && (nX < mnVirWidth + RULER_CLIP) && ( nX < nMax - nShiftX ) && ( nX > nMin + nShiftX ) ) { if ( mnWinStyle & WB_HORZ ) - maVirDev.DrawText( Point( nX - nShiftX, nY - nShiftY ), rText ); + maVirDev->DrawText( Point( nX - nShiftX, nY - nShiftY ), rText ); else - maVirDev.DrawText( Point( nY - nShiftX, nX - nShiftY ), rText ); + maVirDev->DrawText( Point( nY - nShiftX, nX - nShiftY ), rText ); } } @@ -490,7 +490,7 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nTop, long nB double nAcceptanceDelta = 0.0001; - Size aPixSize = maVirDev.LogicToPixel( Size( nTick4, nTick4 ), maMapMode ); + Size aPixSize = maVirDev->LogicToPixel( Size( nTick4, nTick4 ), maMapMode ); if ( mnUnitIndex == RULER_UNIT_CHAR ) { @@ -522,11 +522,11 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nTop, long nB aFont.SetOrientation( 2700 ); else aFont.SetOrientation( 900 ); - maVirDev.SetFont( aFont ); + maVirDev->SetFont( aFont ); nTickWidth = aPixSize.Height(); } - long nMaxWidth = maVirDev.PixelToLogic( Size( mpData->nPageWidth, 0 ), maMapMode ).Width(); + long nMaxWidth = maVirDev->PixelToLogic( Size( mpData->nPageWidth, 0 ), maMapMode ).Width(); if ( nMaxWidth < 0 ) nMaxWidth = -nMaxWidth; @@ -570,7 +570,7 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nTop, long nB } nTick4 = nOrgTick4 * nMulti; - aPixSize = maVirDev.LogicToPixel( Size( nTick4, nTick4 ), maMapMode ); + aPixSize = maVirDev->LogicToPixel( Size( nTick4, nTick4 ), maMapMode ); if ( mnWinStyle & WB_HORZ ) nTickWidth = aPixSize.Width(); else @@ -580,7 +580,7 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nTop, long nB } else { - maVirDev.SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() ); + maVirDev->SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() ); } if ( !bNoTicks ) @@ -597,11 +597,11 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nTop, long nB Size nTickGapSize; - nTickGapSize = maVirDev.LogicToPixel( Size( nTickCount, nTickCount ), maMapMode ); + nTickGapSize = maVirDev->LogicToPixel( Size( nTickCount, nTickCount ), maMapMode ); long nTickGap1 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height(); - nTickGapSize = maVirDev.LogicToPixel( Size( nTick2, nTick2 ), maMapMode ); + nTickGapSize = maVirDev->LogicToPixel( Size( nTick2, nTick2 ), maMapMode ); long nTickGap2 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height(); - nTickGapSize = maVirDev.LogicToPixel( Size( nTick3, nTick3 ), maMapMode ); + nTickGapSize = maVirDev->LogicToPixel( Size( nTick3, nTick3 ), maMapMode ); long nTickGap3 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height(); while ( ((nStart - n) >= nMin) || ((nStart + n) <= nMax) ) @@ -621,7 +621,7 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nTop, long nB } else { - aPixSize = maVirDev.LogicToPixel( Size( nTick, nTick ), maMapMode ); + aPixSize = maVirDev->LogicToPixel( Size( nTick, nTick ), maMapMode ); if ( mnWinStyle & WB_HORZ ) n = aPixSize.Width(); @@ -721,20 +721,20 @@ void Ruler::ImplDrawBorders( long nMin, long nMax, long nVirTop, long nVirBottom { if ( (n2-n1) > 3 ) { - maVirDev.SetLineColor(); - maVirDev.SetFillColor( rStyleSettings.GetFaceColor() ); + maVirDev->SetLineColor(); + maVirDev->SetFillColor( rStyleSettings.GetFaceColor() ); ImplVDrawRect( n1, nVirTop, n2, nVirBottom ); - maVirDev.SetLineColor( rStyleSettings.GetLightColor() ); + maVirDev->SetLineColor( rStyleSettings.GetLightColor() ); ImplVDrawLine( n1 + 1, nVirTop, n1 + 1, nVirBottom ); ImplVDrawLine( n1, nVirTop, n2, nVirTop ); - maVirDev.SetLineColor( rStyleSettings.GetShadowColor() ); + maVirDev->SetLineColor( rStyleSettings.GetShadowColor() ); ImplVDrawLine( n1, nVirTop, n1, nVirBottom ); ImplVDrawLine( n1, nVirBottom, n2, nVirBottom ); ImplVDrawLine( n2 - 1, nVirTop, n2 - 1, nVirBottom ); - maVirDev.SetLineColor( rStyleSettings.GetDarkShadowColor() ); + maVirDev->SetLineColor( rStyleSettings.GetDarkShadowColor() ); ImplVDrawLine( n2, nVirTop, n2, nVirBottom ); if ( mpData->pBorders[i].nStyle & RULER_BORDER_VARIABLE ) @@ -747,7 +747,7 @@ void Ruler::ImplDrawBorders( long nMin, long nMax, long nVirTop, long nVirBottom long nTemp4 = nTemp2 + RULER_VAR_SIZE - 1; long nTempY = nTemp2; - maVirDev.SetLineColor( rStyleSettings.GetLightColor() ); + maVirDev->SetLineColor( rStyleSettings.GetLightColor() ); while ( nTempY <= nTemp4 ) { ImplVDrawLine( nTemp1, nTempY, nTemp3, nTempY ); @@ -755,7 +755,7 @@ void Ruler::ImplDrawBorders( long nMin, long nMax, long nVirTop, long nVirBottom } nTempY = nTemp2 + 1; - maVirDev.SetLineColor( rStyleSettings.GetShadowColor() ); + maVirDev->SetLineColor( rStyleSettings.GetShadowColor() ); while ( nTempY <= nTemp4 ) { ImplVDrawLine( nTemp1, nTempY, nTemp3, nTempY ); @@ -768,10 +768,10 @@ void Ruler::ImplDrawBorders( long nMin, long nMax, long nVirTop, long nVirBottom { if ( n2-n1 > RULER_VAR_SIZE+10 ) { - maVirDev.SetLineColor( rStyleSettings.GetShadowColor() ); + maVirDev->SetLineColor( rStyleSettings.GetShadowColor() ); ImplVDrawLine( n1 + 4, nVirTop + 3, n1 + 4, nVirBottom - 3 ); ImplVDrawLine( n2 - 5, nVirTop + 3, n2 - 5, nVirBottom - 3 ); - maVirDev.SetLineColor( rStyleSettings.GetLightColor() ); + maVirDev->SetLineColor( rStyleSettings.GetLightColor() ); ImplVDrawLine( n1 + 5, nVirTop + 3, n1 + 5, nVirBottom - 3 ); ImplVDrawLine( n2 - 4, nVirTop + 3, n2 - 4, nVirBottom - 3 ); } @@ -780,7 +780,7 @@ void Ruler::ImplDrawBorders( long nMin, long nMax, long nVirTop, long nVirBottom else { n = n1 + ((n2 - n1) / 2); - maVirDev.SetLineColor( rStyleSettings.GetShadowColor() ); + maVirDev->SetLineColor( rStyleSettings.GetShadowColor() ); if ( mpData->pBorders[i].nStyle & RULER_BORDER_SNAP ) ImplVDrawLine( n, nVirTop, n, nVirBottom ); @@ -790,8 +790,8 @@ void Ruler::ImplDrawBorders( long nMin, long nMax, long nVirTop, long nVirBottom { ImplVDrawLine( n - 1, nVirTop, n - 1, nVirBottom ); ImplVDrawLine( n + 1, nVirTop, n + 1, nVirBottom ); - maVirDev.SetLineColor(); - maVirDev.SetFillColor( rStyleSettings.GetWindowColor() ); + maVirDev->SetLineColor(); + maVirDev->SetFillColor( rStyleSettings.GetWindowColor() ); ImplVDrawRect( n, nVirTop, n, nVirBottom ); } } @@ -806,9 +806,9 @@ void Ruler::ImplDrawIndent( const Polygon& rPoly, sal_uInt16 nStyle, bool bIsHit if ( nStyle & RULER_STYLE_INVISIBLE ) return; - maVirDev.SetLineColor( rStyleSettings.GetDarkShadowColor() ); - maVirDev.SetFillColor( bIsHit ? rStyleSettings.GetDarkShadowColor() : rStyleSettings.GetWorkspaceColor() ); - maVirDev.DrawPolygon( rPoly ); + maVirDev->SetLineColor( rStyleSettings.GetDarkShadowColor() ); + maVirDev->SetFillColor( bIsHit ? rStyleSettings.GetDarkShadowColor() : rStyleSettings.GetWorkspaceColor() ); + maVirDev->DrawPolygon( rPoly ); } void Ruler::ImplDrawIndents( long nMin, long nMax, long nVirTop, long nVirBottom ) @@ -835,7 +835,7 @@ void Ruler::ImplDrawIndents( long nMin, long nMax, long nVirTop, long nVirBottom if (nIndentStyle == RULER_INDENT_BORDER) { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - maVirDev.SetLineColor( rStyleSettings.GetShadowColor() ); + maVirDev->SetLineColor( rStyleSettings.GetShadowColor() ); ImplVDrawLine( n, nVirTop + 1, n, nVirBottom - 1 ); } else if ( nIndentStyle == RULER_INDENT_BOTTOM ) @@ -1039,7 +1039,7 @@ void Ruler::ImplDrawTabs( long nMin, long nMax, long nVirTop, long nVirBottom ) aPosition += +mpData->nNullVirOff; long nTopBottom = (GetStyle() & WB_RIGHT_ALIGNED) ? nVirTop : nVirBottom; if (nMin <= aPosition && aPosition <= nMax) - ImplDrawTab( &maVirDev, Point( aPosition, nTopBottom ), mpData->pTabs[i].nStyle ); + ImplDrawTab( maVirDev.get(), Point( aPosition, nTopBottom ), mpData->pTabs[i].nStyle ); } } @@ -1094,16 +1094,16 @@ void Ruler::ImplInitSettings( bool bFont, bool bForeground, bool bBackground ) SetBackground( aColor ); } - maVirDev.SetSettings( GetSettings() ); - maVirDev.SetBackground( GetBackground() ); + maVirDev->SetSettings( GetSettings() ); + maVirDev->SetBackground( GetBackground() ); vcl::Font aFont = GetFont(); if ( mnWinStyle & WB_VERT ) aFont.SetOrientation( 900 ); - maVirDev.SetFont( aFont ); - maVirDev.SetTextColor( GetTextColor() ); - maVirDev.SetTextFillColor( GetTextFillColor() ); + maVirDev->SetFont( aFont ); + maVirDev->SetTextColor( GetTextColor() ); + maVirDev->SetTextFillColor( GetTextFillColor() ); } void Ruler::ImplCalc() @@ -1201,10 +1201,10 @@ void Ruler::ImplFormat() aVirDevSize.Height() = mnVirWidth; aVirDevSize.Width() = mnVirHeight; } - if ( aVirDevSize != maVirDev.GetOutputSizePixel() ) - maVirDev.SetOutputSizePixel( aVirDevSize, true ); + if ( aVirDevSize != maVirDev->GetOutputSizePixel() ) + maVirDev->SetOutputSizePixel( aVirDevSize, true ); else - maVirDev.Erase(); + maVirDev->Erase(); // calculate margins if ( !(mpData->nMargin1Style & RULER_STYLE_INVISIBLE) ) @@ -1245,7 +1245,7 @@ void Ruler::ImplFormat() } // top/bottom border - maVirDev.SetLineColor( rStyleSettings.GetShadowColor() ); + maVirDev->SetLineColor( rStyleSettings.GetShadowColor() ); ImplVDrawLine( nVirLeft, nVirTop + 1, nM1, nVirTop + 1 ); //top left line ImplVDrawLine( nM2, nVirTop + 1, nP2 - 1, nVirTop + 1 ); //top right line @@ -1253,18 +1253,18 @@ void Ruler::ImplFormat() nVirBottom--; // draw margin1, margin2 and in-between - maVirDev.SetLineColor(); - maVirDev.SetFillColor( rStyleSettings.GetDialogColor() ); + maVirDev->SetLineColor(); + maVirDev->SetFillColor( rStyleSettings.GetDialogColor() ); if ( nM1 > nVirLeft ) ImplVDrawRect( nP1, nVirTop+1, nM1, nVirBottom ); //left gray rectangle if ( nM2 < nP2 ) ImplVDrawRect( nM2, nVirTop+1, nP2, nVirBottom ); //right gray rectangle if ( nM2-nM1 > 0 ) { - maVirDev.SetFillColor( rStyleSettings.GetWindowColor() ); + maVirDev->SetFillColor( rStyleSettings.GetWindowColor() ); ImplVDrawRect( nM1 + 1, nVirTop, nM2 - 1, nVirBottom ); //center rectangle } - maVirDev.SetLineColor( rStyleSettings.GetShadowColor() ); + maVirDev->SetLineColor( rStyleSettings.GetShadowColor() ); if ( nM1 > nVirLeft ) { ImplVDrawLine( nM1, nVirTop + 1, nM1, nVirBottom ); //right line of the left rectangle @@ -1375,7 +1375,7 @@ void Ruler::ImplDraw() { // output the ruler to the virtual device Point aOffPos; - Size aVirDevSize = maVirDev.GetOutputSizePixel(); + Size aVirDevSize = maVirDev->GetOutputSizePixel(); if ( mnWinStyle & WB_HORZ ) { @@ -1390,7 +1390,7 @@ void Ruler::ImplDraw() aOffPos.X() = RULER_OFF; aOffPos.Y() = mnVirOff; } - DrawOutDev( aOffPos, aVirDevSize, Point(), aVirDevSize, maVirDev ); + DrawOutDev( aOffPos, aVirDevSize, Point(), aVirDevSize, *maVirDev.get() ); // redraw positionlines ImplInvertLines( true ); diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 2d0cb078df28..98a0b95a495e 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -89,14 +89,14 @@ void ValueSet::ImplInit() mbHasVisibleItems = false; // #106446#, #106601# force mirroring of virtual device - maVirDev.EnableRTL( GetParent()->IsRTLEnabled() ); + maVirDev->EnableRTL( GetParent()->IsRTLEnabled() ); ImplInitSettings( true, true, true ); } ValueSet::ValueSet( vcl::Window* pParent, WinBits nWinStyle, bool bDisableTransientChildren ) : Control( pParent, nWinStyle ), - maVirDev( *this ), + maVirDev( new VirtualDevice(*this) ), maColor( COL_TRANSPARENT ) { ImplInit(); @@ -116,7 +116,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeValueSet(vcl::Window * ValueSet::ValueSet( vcl::Window* pParent, const ResId& rResId, bool bDisableTransientChildren ) : Control( pParent, rResId ), - maVirDev( *this ), + maVirDev( new VirtualDevice(*this) ), maColor( COL_TRANSPARENT ) { ImplInit(); @@ -239,7 +239,7 @@ void ValueSet::ImplFormatItem( ValueSetItem* pItem, Rectangle aRect ) } else { - DecorationView aView( &maVirDev ); + DecorationView aView( maVirDev.get() ); aRect = aView.DrawFrame( aRect, mnFrameStyle ); } } @@ -253,11 +253,11 @@ void ValueSet::ImplFormatItem( ValueSetItem* pItem, Rectangle aRect ) if ( pItem == mpNoneItem.get() ) { - maVirDev.SetFont( GetFont() ); - maVirDev.SetTextColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor() ); - maVirDev.SetTextFillColor(); - maVirDev.SetFillColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuColor() : rStyleSettings.GetWindowColor() ); - maVirDev.DrawRect( aRect ); + maVirDev->SetFont( GetFont() ); + maVirDev->SetTextColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor() ); + maVirDev->SetTextFillColor(); + maVirDev->SetFillColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuColor() : rStyleSettings.GetWindowColor() ); + maVirDev->DrawRect( aRect ); Point aTxtPos( aRect.Left() + 2, aRect.Top() ); long nTxtWidth = GetTextWidth( pItem->maText ); if ( nStyle & WB_RADIOSEL ) @@ -267,33 +267,33 @@ void ValueSet::ImplFormatItem( ValueSetItem* pItem, Rectangle aRect ) } if ( (aTxtPos.X()+nTxtWidth) > aRect.Right() ) { - maVirDev.SetClipRegion( vcl::Region( aRect ) ); - maVirDev.DrawText( aTxtPos, pItem->maText ); - maVirDev.SetClipRegion(); + maVirDev->SetClipRegion( vcl::Region( aRect ) ); + maVirDev->DrawText( aTxtPos, pItem->maText ); + maVirDev->SetClipRegion(); } else - maVirDev.DrawText( aTxtPos, pItem->maText ); + maVirDev->DrawText( aTxtPos, pItem->maText ); } else if ( pItem->meType == VALUESETITEM_COLOR ) { - maVirDev.SetFillColor( pItem->maColor ); - maVirDev.DrawRect( aRect ); + maVirDev->SetFillColor( pItem->maColor ); + maVirDev->DrawRect( aRect ); } else { if ( IsColor() ) - maVirDev.SetFillColor( maColor ); + maVirDev->SetFillColor( maColor ); else if ( nStyle & WB_MENUSTYLEVALUESET ) - maVirDev.SetFillColor( rStyleSettings.GetMenuColor() ); + maVirDev->SetFillColor( rStyleSettings.GetMenuColor() ); else if ( IsEnabled() ) - maVirDev.SetFillColor( rStyleSettings.GetWindowColor() ); + maVirDev->SetFillColor( rStyleSettings.GetWindowColor() ); else - maVirDev.SetFillColor( rStyleSettings.GetFaceColor() ); - maVirDev.DrawRect( aRect ); + maVirDev->SetFillColor( rStyleSettings.GetFaceColor() ); + maVirDev->DrawRect( aRect ); if ( pItem->meType == VALUESETITEM_USERDRAW ) { - UserDrawEvent aUDEvt( &maVirDev, aRect, pItem->mnId ); + UserDrawEvent aUDEvt( maVirDev.get(), aRect, pItem->mnId ); UserDraw( aUDEvt ); } else @@ -311,12 +311,12 @@ void ValueSet::ImplFormatItem( ValueSetItem* pItem, Rectangle aRect ) if ( aImageSize.Width() > aRectSize.Width() || aImageSize.Height() > aRectSize.Height() ) { - maVirDev.SetClipRegion( vcl::Region( aRect ) ); - maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle); - maVirDev.SetClipRegion(); + maVirDev->SetClipRegion( vcl::Region( aRect ) ); + maVirDev->DrawImage( aPos, pItem->maImage, nImageStyle); + maVirDev->SetClipRegion(); } else - maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle ); + maVirDev->DrawImage( aPos, pItem->maImage, nImageStyle ); } } @@ -331,7 +331,7 @@ void ValueSet::ImplFormatItem( ValueSetItem* pItem, Rectangle aRect ) if(!aBlendFrame.IsEmpty()) { - maVirDev.DrawBitmapEx(aRect.TopLeft(), aBlendFrame); + maVirDev->DrawBitmapEx(aRect.TopLeft(), aBlendFrame); } } } @@ -490,9 +490,9 @@ void ValueSet::Format() } // Init VirDev - maVirDev.SetSettings( GetSettings() ); - maVirDev.SetBackground( GetBackground() ); - maVirDev.SetOutputSizePixel( aWinSize, true ); + maVirDev->SetSettings( GetSettings() ); + maVirDev->SetBackground( GetBackground() ); + maVirDev->SetOutputSizePixel( aWinSize, true ); // nothing is changed in case of too small items if ( (mnItemWidth <= 0) || @@ -565,7 +565,7 @@ void ValueSet::Format() } // calculate and draw items - maVirDev.SetLineColor(); + maVirDev->SetLineColor(); long x = nStartX; long y = nStartY; @@ -907,7 +907,7 @@ void ValueSet::ImplHideSelect( sal_uInt16 nItemId ) HideFocus(); const Point aPos = aRect.TopLeft(); const Size aSize = aRect.GetSize(); - DrawOutDev( aPos, aSize, aPos, aSize, maVirDev ); + DrawOutDev( aPos, aSize, aPos, aSize, *maVirDev.get() ); } void ValueSet::ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection ) @@ -937,7 +937,7 @@ void ValueSet::ImplDraw() HideFocus(); Point aDefPos; - Size aSize = maVirDev.GetOutputSizePixel(); + Size aSize = maVirDev->GetOutputSizePixel(); if ( mxScrollBar.get() && mxScrollBar->IsVisible() ) { @@ -946,17 +946,17 @@ void ValueSet::ImplDraw() Point aTempPos( 0, aScrPos.Y() ); Size aTempSize( aSize.Width(), aScrPos.Y() ); - DrawOutDev( aDefPos, aTempSize, aDefPos, aTempSize, maVirDev ); + DrawOutDev( aDefPos, aTempSize, aDefPos, aTempSize, *maVirDev.get() ); aTempSize.Width() = aScrPos.X() - 1; aTempSize.Height() = aScrSize.Height(); - DrawOutDev( aTempPos, aTempSize, aTempPos, aTempSize, maVirDev ); + DrawOutDev( aTempPos, aTempSize, aTempPos, aTempSize, *maVirDev.get() ); aTempPos.Y() = aScrPos.Y() + aScrSize.Height(); aTempSize.Width() = aSize.Width(); aTempSize.Height() = aSize.Height() - aTempPos.Y(); - DrawOutDev( aTempPos, aTempSize, aTempPos, aTempSize, maVirDev ); + DrawOutDev( aTempPos, aTempSize, aTempPos, aTempSize, *maVirDev.get() ); } else - DrawOutDev( aDefPos, aSize, aDefPos, aSize, maVirDev ); + DrawOutDev( aDefPos, aSize, aDefPos, aSize, *maVirDev.get() ); // draw parting line to the Namefield if ( GetStyle() & WB_NAMEFIELD ) @@ -1422,7 +1422,7 @@ void ValueSet::Paint( const Rectangle& ) const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); SetLineColor(); SetFillColor( rStyleSettings.GetFaceColor() ); - long nOffY = maVirDev.GetOutputSizePixel().Height(); + long nOffY = maVirDev->GetOutputSizePixel().Height(); Size aWinSize = GetOutputSizePixel(); DrawRect( Rectangle( Point( 0, nOffY ), Point( aWinSize.Width(), aWinSize.Height() ) ) ); } diff --git a/svtools/source/dialogs/prnsetup.cxx b/svtools/source/dialogs/prnsetup.cxx index 42b78542ca87..d6f35ef39fdd 100644 --- a/svtools/source/dialogs/prnsetup.cxx +++ b/svtools/source/dialogs/prnsetup.cxx @@ -73,7 +73,7 @@ Printer* ImplPrnDlgListBoxSelect( ListBox* pBox, PushButton* pPropBtn, if ( (pTempPrinter->GetName() != pInfo->GetPrinterName()) || (pTempPrinter->GetDriverName() != pInfo->GetDriver()) ) { - delete pTempPrinter; + VclPtr(pTempPrinter).disposeAndClear(); pTempPrinter = new Printer( *pInfo ); } } @@ -101,8 +101,7 @@ Printer* ImplPrnDlgUpdatePrinter( Printer* pPrinter, Printer* pTempPrinter ) if ( ! Printer::GetQueueInfo( aPrnName, false ) ) { - if ( pTempPrinter ) - delete pTempPrinter; + VclPtr(pTempPrinter).disposeAndClear(); pTempPrinter = new Printer; } @@ -251,8 +250,6 @@ PrinterSetupDialog::~PrinterSetupDialog() void PrinterSetupDialog::dispose() { ImplFreePrnDlgListBox(m_pLbName, false); - delete mpTempPrinter; - mpTempPrinter = NULL; m_pLbName.clear(); m_pBtnProperties.clear(); m_pBtnOptions.clear(); @@ -260,11 +257,11 @@ void PrinterSetupDialog::dispose() m_pFiType.clear(); m_pFiLocation.clear(); m_pFiComment.clear(); + mpTempPrinter.disposeAndClear(); + mpPrinter.clear(); ModalDialog::dispose(); } - - void PrinterSetupDialog::SetOptionsHdl( const Link& rLink ) { m_pBtnOptions->SetClickHdl( rLink ); diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx index a8daae01f1b0..eb7819814dd8 100644 --- a/svtools/source/graphic/grfmgr2.cxx +++ b/svtools/source/graphic/grfmgr2.cxx @@ -1894,19 +1894,19 @@ bool GraphicObject::ImplDrawTiled( OutputDevice* pOut, const Rectangle& rArea, c // First combine very small bitmaps into a larger tile - VirtualDevice aVDev; + ScopedVclPtr aVDev = new VirtualDevice; const int nNumTilesInCacheX( (nTileCacheSize1D + rSizePixel.Width()-1) / rSizePixel.Width() ); const int nNumTilesInCacheY( (nTileCacheSize1D + rSizePixel.Height()-1) / rSizePixel.Height() ); - aVDev.SetOutputSizePixel( Size( nNumTilesInCacheX*rSizePixel.Width(), + aVDev->SetOutputSizePixel( Size( nNumTilesInCacheX*rSizePixel.Width(), nNumTilesInCacheY*rSizePixel.Height() ) ); - aVDev.SetMapMode( aMapMode ); + aVDev->SetMapMode( aMapMode ); // draw bitmap content - if( ImplRenderTempTile( aVDev, SubdivisionExponent, nNumTilesInCacheX, + if( ImplRenderTempTile( *aVDev.get(), SubdivisionExponent, nNumTilesInCacheX, nNumTilesInCacheY, rSizePixel, pAttr, nFlags ) ) { - BitmapEx aTileBitmap( aVDev.GetBitmap( Point(0,0), aVDev.GetOutputSize() ) ); + BitmapEx aTileBitmap( aVDev->GetBitmap( Point(0,0), aVDev->GetOutputSize() ) ); // draw alpha content, if any if( IsTransparent() ) @@ -1918,16 +1918,16 @@ bool GraphicObject::ImplDrawTiled( OutputDevice* pOut, const Rectangle& rArea, c else aAlphaGraphic.SetGraphic( GetGraphic().GetBitmapEx().GetMask() ); - if( aAlphaGraphic.ImplRenderTempTile( aVDev, SubdivisionExponent, nNumTilesInCacheX, + if( aAlphaGraphic.ImplRenderTempTile( *aVDev.get(), SubdivisionExponent, nNumTilesInCacheX, nNumTilesInCacheY, rSizePixel, pAttr, nFlags ) ) { // Combine bitmap and alpha/mask if( GetGraphic().IsAlpha() ) aTileBitmap = BitmapEx( aTileBitmap.GetBitmap(), - AlphaMask( aVDev.GetBitmap( Point(0,0), aVDev.GetOutputSize() ) ) ); + AlphaMask( aVDev->GetBitmap( Point(0,0), aVDev->GetOutputSize() ) ) ); else aTileBitmap = BitmapEx( aTileBitmap.GetBitmap(), - aVDev.GetBitmap( Point(0,0), aVDev.GetOutputSize() ).CreateMask( Color(COL_WHITE) ) ); + aVDev->GetBitmap( Point(0,0), aVDev->GetOutputSize() ).CreateMask( Color(COL_WHITE) ) ); } } diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx index 1229ba122c4c..52e21499cc9d 100644 --- a/svtools/source/graphic/provider.cxx +++ b/svtools/source/graphic/provider.cxx @@ -634,7 +634,7 @@ void ImplApplyFilterData( ::Graphic& rGraphic, uno::Sequence< beans::PropertyVal } else if ( ( rGraphic.GetType() == GRAPHIC_GDIMETAFILE ) && nImageResolution ) { - VirtualDevice aDummyVDev; + ScopedVclPtr aDummyVDev = new VirtualDevice; GDIMetaFile aMtf( rGraphic.GetGDIMetaFile() ); Size aMtfSize( OutputDevice::LogicToLogic( aMtf.GetPrefSize(), aMtf.GetPrefMapMode(), MAP_100TH_MM ) ); if ( aMtfSize.Width() && aMtfSize.Height() ) @@ -642,8 +642,8 @@ void ImplApplyFilterData( ::Graphic& rGraphic, uno::Sequence< beans::PropertyVal MapMode aNewMapMode( MAP_100TH_MM ); aNewMapMode.SetScaleX( static_cast< double >( aLogicalSize.Width ) / static_cast< double >( aMtfSize.Width() ) ); aNewMapMode.SetScaleY( static_cast< double >( aLogicalSize.Height ) / static_cast< double >( aMtfSize.Height() ) ); - aDummyVDev.EnableOutput( false ); - aDummyVDev.SetMapMode( aNewMapMode ); + aDummyVDev->EnableOutput( false ); + aDummyVDev->SetMapMode( aNewMapMode ); for( size_t i = 0, nObjCount = aMtf.GetActionSize(); i < nObjCount; i++ ) { @@ -653,18 +653,18 @@ void ImplApplyFilterData( ::Graphic& rGraphic, uno::Sequence< beans::PropertyVal // only optimizing common bitmap actions: case( META_MAPMODE_ACTION ): { - const_cast< MetaAction* >( pAction )->Execute( &aDummyVDev ); + const_cast< MetaAction* >( pAction )->Execute( aDummyVDev.get() ); break; } case( META_PUSH_ACTION ): { const MetaPushAction* pA = static_cast(pAction); - aDummyVDev.Push( pA->GetFlags() ); + aDummyVDev->Push( pA->GetFlags() ); break; } case( META_POP_ACTION ): { - aDummyVDev.Pop(); + aDummyVDev->Pop(); break; } case( META_BMPSCALE_ACTION ): @@ -688,8 +688,8 @@ void ImplApplyFilterData( ::Graphic& rGraphic, uno::Sequence< beans::PropertyVal aSize = pScaleAction->GetSize(); } ::Graphic aGraphic( aBmpEx ); - const Size aSize100thmm( aDummyVDev.LogicToPixel( aSize ) ); - Size aSize100thmm2( aDummyVDev.PixelToLogic( aSize100thmm, MAP_100TH_MM ) ); + const Size aSize100thmm( aDummyVDev->LogicToPixel( aSize ) ); + Size aSize100thmm2( aDummyVDev->PixelToLogic( aSize100thmm, MAP_100TH_MM ) ); ImplApplyBitmapResolution( aGraphic, nImageResolution, aGraphic.GetSizePixel(), awt::Size( aSize100thmm2.Width(), aSize100thmm2.Height() ) ); diff --git a/svtools/source/inc/renderer.hxx b/svtools/source/inc/renderer.hxx index b50088d2e737..ca3417b640f4 100644 --- a/svtools/source/inc/renderer.hxx +++ b/svtools/source/inc/renderer.hxx @@ -70,7 +70,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > mxDevice; - OutputDevice* mpOutDev; + VclPtr mpOutDev; Rectangle maDestRect; ::com::sun::star::uno::Any maRenderData; }; diff --git a/svtools/source/misc/sampletext.cxx b/svtools/source/misc/sampletext.cxx index 40f5d7d45121..a1cb7a83d111 100644 --- a/svtools/source/misc/sampletext.cxx +++ b/svtools/source/misc/sampletext.cxx @@ -1623,12 +1623,12 @@ OUString makeRepresentativeTextForFont(sal_Int16 nScriptType, const vcl::Font &r { OUString sRet(makeRepresentativeTextForLanguage(rFont.GetLanguage())); - VirtualDevice aDevice; - if (sRet.isEmpty() || (-1 != aDevice.HasGlyphs(rFont, sRet))) + ScopedVclPtr aDevice = new VirtualDevice; + if (sRet.isEmpty() || (-1 != aDevice->HasGlyphs(rFont, sRet))) { - aDevice.SetFont(rFont); + aDevice->SetFont(rFont); vcl::FontCapabilities aFontCapabilities; - if (aDevice.GetFontCapabilities(aFontCapabilities)) + if (aDevice->GetFontCapabilities(aFontCapabilities)) { #if OSL_DEBUG_LEVEL > 2 lcl_dump_unicode_coverage(aFontCapabilities.maUnicodeRange); @@ -1655,7 +1655,7 @@ OUString makeRepresentativeTextForFont(sal_Int16 nScriptType, const vcl::Font &r UScriptCode eScript = getScript(aFontCapabilities); if (nScriptType == com::sun::star::i18n::ScriptType::ASIAN) - eScript = attemptToDisambiguateHan(eScript, aDevice); + eScript = attemptToDisambiguateHan(eScript, *aDevice.get()); sRet = makeRepresentativeTextForScript(eScript); } @@ -1665,10 +1665,10 @@ OUString makeRepresentativeTextForFont(sal_Int16 nScriptType, const vcl::Font &r if (nScriptType == com::sun::star::i18n::ScriptType::COMPLEX) { sRet = makeRepresentativeTextForScript(USCRIPT_HEBREW); - if (-1 != aDevice.HasGlyphs(rFont, sRet)) + if (-1 != aDevice->HasGlyphs(rFont, sRet)) { sRet = makeMinimalTextForScript(USCRIPT_HEBREW); - if (-1 != aDevice.HasGlyphs(rFont, sRet)) + if (-1 != aDevice->HasGlyphs(rFont, sRet)) sRet = makeRepresentativeTextForScript(USCRIPT_ARABIC); } } diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx index e350a2237c12..4f4ad26a4415 100644 --- a/svtools/source/table/gridtablerenderer.cxx +++ b/svtools/source/table/gridtablerenderer.cxx @@ -86,17 +86,17 @@ namespace svt { namespace table Point const aBitmapPos( 0, 0 ); Size const aBitmapSize( nSortIndicatorWidth, nSortIndicatorHeight ); - VirtualDevice aDevice( i_device, 0, 0 ); - aDevice.SetOutputSizePixel( aBitmapSize ); + ScopedVclPtr aDevice = new VirtualDevice( i_device, 0, 0 ); + aDevice->SetOutputSizePixel( aBitmapSize ); - DecorationView aDecoView( &aDevice ); + DecorationView aDecoView( aDevice.get() ); aDecoView.DrawSymbol( Rectangle( aBitmapPos, aBitmapSize ), i_sortAscending ? SymbolType::SPIN_UP : SymbolType::SPIN_DOWN, i_style.GetActiveColor() ); - rBitmap = aDevice.GetBitmapEx( aBitmapPos, aBitmapSize ); + rBitmap = aDevice->GetBitmapEx( aBitmapPos, aBitmapSize ); m_lastHeaderHeight = i_headerHeight; m_lastArrowColor = i_style.GetActiveColor(); } diff --git a/svtools/source/toolpanel/paneltabbar.cxx b/svtools/source/toolpanel/paneltabbar.cxx index 1cb90ccf4973..467793a8b61a 100644 --- a/svtools/source/toolpanel/paneltabbar.cxx +++ b/svtools/source/toolpanel/paneltabbar.cxx @@ -415,7 +415,7 @@ namespace svt TabAlignment m_eTabAlignment; IToolPanelDeck& m_rPanelDeck; - VirtualDevice m_aRenderDevice; + ScopedVclPtr m_aRenderDevice; PTabBarRenderer m_pRenderer; ::boost::optional< size_t > m_aHoveredItem; @@ -499,7 +499,7 @@ namespace svt ,m_aNormalizer() ,m_eTabAlignment( i_eAlignment ) ,m_rPanelDeck( i_rPanelDeck ) - ,m_aRenderDevice( i_rTabBar ) + ,m_aRenderDevice( new VirtualDevice(i_rTabBar) ) ,m_pRenderer() ,m_aHoveredItem() ,m_aFocusedItem() @@ -511,19 +511,19 @@ namespace svt ,m_nScrollPosition( 0 ) { #ifdef WNT - if ( m_aRenderDevice.IsNativeControlSupported( CTRL_TAB_ITEM, PART_ENTIRE_CONTROL ) ) + if ( m_aRenderDevice->IsNativeControlSupported( CTRL_TAB_ITEM, PART_ENTIRE_CONTROL ) ) // this mode requires the NWF framework to be able to render those items onto a virtual // device. For some frameworks (some GTK themes, in particular), this is known to fail. // So, be on the safe side for the moment. m_pRenderer.reset( new NWFTabItemRenderer( m_aRenderDevice ) ); else #endif - if ( m_aRenderDevice.IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) - m_pRenderer.reset( new NWFToolboxItemRenderer( m_aRenderDevice ) ); + if ( m_aRenderDevice->IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) + m_pRenderer.reset( new NWFToolboxItemRenderer( *m_aRenderDevice.get() ) ); else - m_pRenderer.reset( new VCLItemRenderer( m_aRenderDevice ) ); + m_pRenderer.reset( new VCLItemRenderer( *m_aRenderDevice.get() ) ); - m_aRenderDevice.SetLineColor(); + m_aRenderDevice->SetLineColor(); m_rPanelDeck.AddListener( *this ); @@ -710,7 +710,7 @@ namespace svt void PanelTabBar_Impl::CopyFromRenderDevice( const Rectangle& i_rLogicalRect ) const { - BitmapEx aBitmap( m_aRenderDevice.GetBitmapEx( + BitmapEx aBitmap( m_aRenderDevice->GetBitmapEx( i_rLogicalRect.TopLeft(), Size( i_rLogicalRect.GetSize().Width(), @@ -833,7 +833,7 @@ namespace svt const Size aLogicalOutputSize( m_aNormalizer.getReferenceSize() ); // forward actual output size to our render device - m_aRenderDevice.SetOutputSizePixel( aLogicalOutputSize ); + m_aRenderDevice->SetOutputSizePixel( aLogicalOutputSize ); // re-calculate the size of the scroll buttons and of the items m_aGeometry.relayout( aLogicalOutputSize, m_aItems ); @@ -1050,10 +1050,10 @@ namespace svt // background const Rectangle aNormalizedPaintArea( m_pImpl->m_aNormalizer.getNormalized( i_rRect, m_pImpl->m_eTabAlignment ) ); - m_pImpl->m_aRenderDevice.Push( PushFlags::CLIPREGION ); - m_pImpl->m_aRenderDevice.SetClipRegion(vcl::Region(aNormalizedPaintArea)); + m_pImpl->m_aRenderDevice->Push( PushFlags::CLIPREGION ); + m_pImpl->m_aRenderDevice->SetClipRegion(vcl::Region(aNormalizedPaintArea)); m_pImpl->m_pRenderer->renderBackground(); - m_pImpl->m_aRenderDevice.Pop(); + m_pImpl->m_aRenderDevice->Pop(); m_pImpl->CopyFromRenderDevice( aNormalizedPaintArea ); // ensure the items really paint into their own playground only diff --git a/svtools/source/toolpanel/toolpaneldrawer.hxx b/svtools/source/toolpanel/toolpaneldrawer.hxx index 1f66263d0dea..b13a12e34629 100644 --- a/svtools/source/toolpanel/toolpaneldrawer.hxx +++ b/svtools/source/toolpanel/toolpaneldrawer.hxx @@ -97,7 +97,7 @@ namespace svt using Window::Paint; private: - ::std::unique_ptr< VirtualDevice > m_pPaintDevice; + ScopedVclPtr< VirtualDevice > m_pPaintDevice; VclPtr m_aVisualization; bool m_bFocused; bool m_bExpanded; diff --git a/vcl/inc/brdwin.hxx b/vcl/inc/brdwin.hxx index fe1361fc84b8..77a690c75dc0 100644 --- a/vcl/inc/brdwin.hxx +++ b/vcl/inc/brdwin.hxx @@ -175,7 +175,7 @@ public: struct ImplBorderFrameData { VclPtr mpBorderWindow; - OutputDevice* mpOutDev; + VclPtr mpOutDev; Rectangle maTitleRect; Rectangle maPinRect; Rectangle maCloseRect; @@ -254,7 +254,7 @@ public: class ImplSmallBorderWindowView : public ImplBorderWindowView { VclPtr mpBorderWindow; - OutputDevice* mpOutDev; + VclPtr mpOutDev; long mnWidth; long mnHeight; sal_Int32 mnLeftBorder; @@ -276,8 +276,8 @@ public: class ImplStdBorderWindowView : public ImplBorderWindowView { ImplBorderFrameData maFrameData; - VirtualDevice* mpATitleVirDev; - VirtualDevice* mpDTitleVirDev; + VclPtr mpATitleVirDev; + VclPtr mpDTitleVirDev; public: ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow ); diff --git a/vcl/inc/controldata.hxx b/vcl/inc/controldata.hxx index 20720911d038..0ef77c809541 100644 --- a/vcl/inc/controldata.hxx +++ b/vcl/inc/controldata.hxx @@ -30,7 +30,7 @@ namespace vcl struct ImplControlData { mutable ControlLayoutData* mpLayoutData; - OutputDevice* mpReferenceDevice; + VclPtr mpReferenceDevice; ImplControlData() :mpLayoutData( NULL ) diff --git a/vcl/inc/outdev.h b/vcl/inc/outdev.h index a1e1b850d66c..eae0c597a03b 100644 --- a/vcl/inc/outdev.h +++ b/vcl/inc/outdev.h @@ -25,6 +25,7 @@ #include #include +#include #include "outfont.hxx" #include "PhysicalFontFace.hxx" @@ -164,7 +165,7 @@ namespace basegfx { class B2DHomMatrix; } struct ImplOutDevData { - VirtualDevice* mpRotateDev; + VclPtr mpRotateDev; vcl::ControlLayoutData* mpRecordLayout; Rectangle maRecordRect; diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx index b470b7c37742..a071c9d5cbac 100644 --- a/vcl/inc/printdlg.hxx +++ b/vcl/inc/printdlg.hxx @@ -51,7 +51,7 @@ namespace vcl GDIMetaFile maMtf; Size maOrigSize; Size maPreviewSize; - VirtualDevice maPageVDev; + VclPtr maPageVDev; Bitmap maPreviewBitmap; OUString maReplacementString; OUString maToolTipString; diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index 4377d0c58b91..fc285cd7e7ed 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -153,18 +153,18 @@ struct ImplSVAppData struct ImplSVGDIData { - OutputDevice* mpFirstWinGraphics; // First OutputDevice with a Frame Graphics - OutputDevice* mpLastWinGraphics; // Last OutputDevice with a Frame Graphics - OutputDevice* mpFirstVirGraphics; // First OutputDevice with a VirtualDevice Graphics - OutputDevice* mpLastVirGraphics; // Last OutputDevice with a VirtualDevice Graphics - OutputDevice* mpFirstPrnGraphics; // First OutputDevice with a InfoPrinter Graphics - OutputDevice* mpLastPrnGraphics; // Last OutputDevice with a InfoPrinter Graphics - VirtualDevice* mpFirstVirDev; // First VirtualDevice - VirtualDevice* mpLastVirDev; // Last VirtualDevice + VclPtr mpFirstWinGraphics; // First OutputDevice with a Frame Graphics + VclPtr mpLastWinGraphics; // Last OutputDevice with a Frame Graphics + VclPtr mpFirstVirGraphics; // First OutputDevice with a VirtualDevice Graphics + VclPtr mpLastVirGraphics; // Last OutputDevice with a VirtualDevice Graphics + VclPtr mpFirstPrnGraphics; // First OutputDevice with a InfoPrinter Graphics + VclPtr mpLastPrnGraphics; // Last OutputDevice with a InfoPrinter Graphics + VclPtr mpFirstVirDev; // First VirtualDevice + VclPtr mpLastVirDev; // Last VirtualDevice OpenGLContext* mpFirstContext; // First OpenGLContext OpenGLContext* mpLastContext; // Last OpenGLContext - Printer* mpFirstPrinter; // First Printer - Printer* mpLastPrinter; // Last Printer + VclPtr mpFirstPrinter; // First Printer + VclPtr mpLastPrinter; // Last Printer ImplPrnQueueList* mpPrinterQueueList; // List of all printer queue PhysicalFontCollection* mpScreenFontList; // Screen-Font-List ImplFontCache* mpScreenFontCache; // Screen-Font-Cache diff --git a/vcl/inc/window.h b/vcl/inc/window.h index 4bc12075b8a8..dfe65071ac19 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -121,7 +121,7 @@ struct ImplWinData struct ImplOverlapData { - VirtualDevice* mpSaveBackDev; //< saved background bitmap + VclPtr mpSaveBackDev; //< saved background bitmap vcl::Region* mpSaveBackRgn; //< saved region, which must be invalidated VclPtr mpNextBackWin; //< next window with saved background sal_uIntPtr mnSaveBackSize; //< bitmap size of saved background diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx index aafc326065ba..887d082ae8c9 100644 --- a/vcl/source/app/svdata.cxx +++ b/vcl/source/app/svdata.cxx @@ -37,6 +37,8 @@ #include "vcl/layout.hxx" #include "vcl/button.hxx" #include "vcl/dockwin.hxx" +#include "vcl/print.hxx" +#include "vcl/virdev.hxx" #include "salinst.hxx" #include "salframe.hxx" #include "salgdi.hxx" diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index bac8fdbd48d0..4cf6077ce9d2 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -116,7 +116,7 @@ TextEngine::~TextEngine() delete mpDoc; delete mpTEParaPortions; delete mpViews; // only the list, not the Views - delete mpRefDev; + mpRefDev.disposeAndClear(); delete mpUndoManager; delete mpIMEInfos; delete mpLocaleDataWrapper; diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx index cc1a37e3fd32..a3b3b2d2c399 100644 --- a/vcl/source/edit/textview.cxx +++ b/vcl/source/edit/textview.cxx @@ -156,7 +156,7 @@ struct ImpTextView TextDDInfo* mpDDInfo; - VirtualDevice* mpVirtDev; + VclPtr mpVirtDev; SelectionEngine* mpSelEngine; TextSelFunctionSet* mpSelFuncSet; @@ -235,7 +235,7 @@ TextView::~TextView() { delete mpImpl->mpSelEngine; delete mpImpl->mpSelFuncSet; - delete mpImpl->mpVirtDev; + mpImpl->mpVirtDev.disposeAndClear(); if ( mpImpl->mpWindow->GetCursor() == mpImpl->mpCursor ) mpImpl->mpWindow->SetCursor( 0 ); @@ -541,8 +541,7 @@ VirtualDevice* TextView::GetVirtualDevice() void TextView::EraseVirtualDevice() { - delete mpImpl->mpVirtDev; - mpImpl->mpVirtDev = 0; + mpImpl->mpVirtDev.disposeAndClear(); } bool TextView::KeyInput( const KeyEvent& rKeyEvent ) diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 147070e52810..18cd8dddc936 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -1892,16 +1892,16 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString { Size aSizePixel; sal_uLong nColorCount,nBitsPerPixel,nNeededMem,nMaxMem; - VirtualDevice aVirDev; + ScopedVclPtr aVirDev = new VirtualDevice; nMaxMem = 1024; nMaxMem *= 1024; // In Bytes // Calculate how big the image would normally be: - aSizePixel=aVirDev.LogicToPixel(aGraphic.GetPrefSize(),aGraphic.GetPrefMapMode()); + aSizePixel=aVirDev->LogicToPixel(aGraphic.GetPrefSize(),aGraphic.GetPrefMapMode()); // Calculate how much memory the image will take up - nColorCount=aVirDev.GetColorCount(); + nColorCount=aVirDev->GetColorCount(); if (nColorCount<=2) nBitsPerPixel=1; else if (nColorCount<=4) nBitsPerPixel=2; else if (nColorCount<=16) nBitsPerPixel=4; @@ -1918,12 +1918,12 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString aSizePixel.Height()=(sal_uLong)(((double)aSizePixel.Height())*fFak); } - aVirDev.SetMapMode(MapMode(MAP_PIXEL)); - aVirDev.SetOutputSizePixel(aSizePixel); + aVirDev->SetMapMode(MapMode(MAP_PIXEL)); + aVirDev->SetOutputSizePixel(aSizePixel); Graphic aGraphic2=aGraphic; - aGraphic2.Draw(&aVirDev,Point(0,0),aSizePixel); // this changes the MapMode - aVirDev.SetMapMode(MapMode(MAP_PIXEL)); - aGraphic=Graphic(aVirDev.GetBitmap(Point(0,0),aSizePixel)); + aGraphic2.Draw(aVirDev.get(),Point(0,0),aSizePixel); // this changes the MapMode + aVirDev->SetMapMode(MapMode(MAP_PIXEL)); + aGraphic=Graphic(aVirDev->GetBitmap(Point(0,0),aSizePixel)); } } if( rOStm.GetError() ) diff --git a/vcl/source/filter/sgfbram.cxx b/vcl/source/filter/sgfbram.cxx index 8e9d167cd486..d0fe0f13bbf4 100644 --- a/vcl/source/filter/sgfbram.cxx +++ b/vcl/source/filter/sgfbram.cxx @@ -390,7 +390,7 @@ Color Hpgl2SvFarbe( sal_uInt8 nFarb ) bool SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMtf) { - VirtualDevice aOutDev; + ScopedVclPtr aOutDev = new VirtualDevice; SgfVector aVect; sal_uInt8 nFarb; sal_uInt8 nFrb0=7; @@ -401,9 +401,9 @@ bool SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMt Point aP1(0,0); sal_uInt16 RecNr=0; - rMtf.Record(&aOutDev); - aOutDev.SetLineColor(Color(COL_BLACK)); - aOutDev.SetFillColor(Color(COL_BLACK)); + rMtf.Record(aOutDev.get()); + aOutDev->SetLineColor(Color(COL_BLACK)); + aOutDev->SetFillColor(Color(COL_BLACK)); while (!bEoDt && !rInp.GetError()) { ReadSgfVector( rInp, aVect ); RecNr++; @@ -429,15 +429,15 @@ bool SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMt switch(nOTyp) { case 1: if (nFarb!=nFrb0) { switch(rHead.SwGrCol) { - case SgfVectFarb: aOutDev.SetLineColor(Hpgl2SvFarbe(nFarb)); break; + case SgfVectFarb: aOutDev->SetLineColor(Hpgl2SvFarbe(nFarb)); break; case SgfVectGray: break; case SgfVectWdth: break; } } - aOutDev.DrawLine(aP0,aP1); break; // line + aOutDev->DrawLine(aP0,aP1); break; // line case 2: break; // circle case 3: break; // text - case 5: aOutDev.DrawRect(Rectangle(aP0,aP1)); break; // rectangle (solid) + case 5: aOutDev->DrawRect(Rectangle(aP0,aP1)); break; // rectangle (solid) } } aP0=aP1; diff --git a/vcl/source/filter/sgvmain.cxx b/vcl/source/filter/sgvmain.cxx index 63526dccecad..f40afaccf472 100644 --- a/vcl/source/filter/sgvmain.cxx +++ b/vcl/source/filter/sgvmain.cxx @@ -794,13 +794,13 @@ bool SgfFilterSDrw( SvStream& rInp, SgfHeader&, SgfEntry&, GDIMetaFile& rMtf ) { bool bRet = false; PageType aPage; - VirtualDevice aOutDev; + ScopedVclPtr aOutDev = new VirtualDevice; OutputDevice* pOutDev; sal_uLong nStdPos; sal_uLong nCharPos; sal_uInt16 Num; - pOutDev=&aOutDev; + pOutDev=aOutDev.get(); DtHdOverSeek(rInp); // read dataheader nStdPos=rInp.Tell(); diff --git a/vcl/source/filter/sgvtext.cxx b/vcl/source/filter/sgvtext.cxx index 2a01dbcb3ae9..d3b2ed72b19d 100644 --- a/vcl/source/filter/sgvtext.cxx +++ b/vcl/source/filter/sgvtext.cxx @@ -660,7 +660,7 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType& double, double, UCHAR* cLine, bool TextFit) { - VirtualDevice vOut; + ScopedVclPtr vOut = new VirtualDevice; UCHAR c,c0; bool First; // first char ? sal_uInt8 Just = 0; // paragraph format @@ -684,18 +684,18 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType& sal_uInt16 i,j,k,h; sal_uInt16 re,li; - vOut.SetMapMode(MapMode(MAP_10TH_MM,Point(),Fraction(1,4),Fraction(1,4))); + vOut->SetMapMode(MapMode(MAP_10TH_MM,Point(),Fraction(1,4),Fraction(1,4))); nChars=0; - SetTextContext(vOut,AktAtr,false,0,1,1,1,1); + SetTextContext(*vOut.get(),AktAtr,false,0,1,1,1,1); InitProcessCharState(*R,AktAtr,Index); (*R0)=(*R); (*WErec)=(*R); WEnChar=0; c0=0; Border0=false; Border=false; First=true; WordEndCnt=0; do { // check how many words to on that line - if (Border) c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,DoTrenn,Line,cLine); - else c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine); + if (Border) c=ProcessChar(*vOut.get(),TBuf,*R,Atr0,nChars,DoTrenn,Line,cLine); + else c=ProcessChar(*vOut.get(),TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine); AbsEnd=(c==AbsatzEnd || c==TextEnd); //if not AbsEnd then { @@ -729,8 +729,8 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType& (*TRrec)=(*R); TRnChar=nChars; Border0=false; Border=false; do { // first check how many syllables fit - UCHAR ct=ProcessChar(vOut,TBuf,*TRrec,Atr0,TRnChar,DoTrenn,Line,cLine); - c=ProcessChar(vOut,TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine); + UCHAR ct=ProcessChar(*vOut.get(),TBuf,*TRrec,Atr0,TRnChar,DoTrenn,Line,cLine); + c=ProcessChar(*vOut.get(),TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine); AbsEnd=(ct==AbsatzEnd) || (ct==TextEnd) || (nChars>=MaxLineChars); Border=TRrec->ChrXP>UmbWdt; @@ -754,7 +754,7 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType& } while (!(AbsEnd || (Border && ((WordEndCnt>0) || WordEnd || Trenn)))); while (WErec0->IndexIndex) { // to assure Line[] matches } - ProcessChar(vOut,TBuf,*WErec0,Atr0,WEnChar0,WEnChar-WEnChar0-1,Line,cLine); + ProcessChar(*vOut.get(),TBuf,*WErec0,Atr0,WEnChar0,WEnChar-WEnChar0-1,Line,cLine); } (*R)=(*WErec); nChars=WEnChar; diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index ea74f6b618ad..3d50e2667bd9 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -266,7 +266,7 @@ void EMFWriter::ImplWritePlusColor( const Color& rColor, const sal_uInt32& nTran void EMFWriter::ImplWritePlusPoint( const Point& rPoint ) { // Convert to pixels - const Point aPoint(maVDev.LogicToPixel( rPoint, maDestMapMode )); + const Point aPoint(maVDev->LogicToPixel( rPoint, maDestMapMode )); m_rStm.WriteUInt16( aPoint.X() ).WriteUInt16( aPoint.Y() ); } @@ -276,7 +276,7 @@ void EMFWriter::ImplWritePlusFillPolygonRecord( const Polygon& rPoly, const sal_ if( rPoly.GetSize() ) { ImplBeginPlusRecord( EmfPlusFillPolygon, 0xC000 ); // Sets the color as well - ImplWritePlusColor( maVDev.GetFillColor(), nTrans ); + ImplWritePlusColor( maVDev->GetFillColor(), nTrans ); m_rStm.WriteUInt32( rPoly.GetSize() ); for( sal_uInt16 i = 0; i < rPoly.GetSize(); i++ ) ImplWritePlusPoint( rPoly[ i ] ); @@ -289,8 +289,8 @@ bool EMFWriter::WriteEMF(const GDIMetaFile& rMtf) { const sal_uLong nHeaderPos = m_rStm.Tell(); - maVDev.EnableOutput( false ); - maVDev.SetMapMode( rMtf.GetPrefMapMode() ); + maVDev->EnableOutput( false ); + maVDev->SetMapMode( rMtf.GetPrefMapMode() ); // don't work with pixel as destination map mode -> higher resolution preferrable maDestMapMode.SetMapUnit( MAP_100TH_MM ); mpHandlesUsed = new bool[ MAXHANDLES ]; @@ -301,7 +301,7 @@ bool EMFWriter::WriteEMF(const GDIMetaFile& rMtf) mnLineHandle = mnFillHandle = mnTextHandle = HANDLE_INVALID; mnHorTextAlign = 0; - const Size aMtfSizePix( maVDev.LogicToPixel( rMtf.GetPrefSize(), rMtf.GetPrefMapMode() ) ); + const Size aMtfSizePix( maVDev->LogicToPixel( rMtf.GetPrefSize(), rMtf.GetPrefMapMode() ) ); const Size aMtfSizeLog( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_100TH_MM ) ); // seek over header @@ -319,7 +319,7 @@ bool EMFWriter::WriteEMF(const GDIMetaFile& rMtf) ImplEndRecord(); ImplBeginRecord( WIN_EMR_SETVIEWPORTEXTEX ); - m_rStm.WriteInt32( maVDev.GetDPIX() ).WriteInt32( maVDev.GetDPIY() ); + m_rStm.WriteInt32( maVDev->GetDPIX() ).WriteInt32( maVDev->GetDPIY() ); ImplEndRecord(); ImplBeginRecord( WIN_EMR_SETWINDOWEXTEX ); @@ -466,12 +466,12 @@ void EMFWriter::ImplCheckLineAttr() { if( mbLineChanged && ImplPrepareHandleSelect( mnLineHandle, LINE_SELECT ) ) { - sal_uInt32 nStyle = maVDev.IsLineColor() ? 0 : 5; + sal_uInt32 nStyle = maVDev->IsLineColor() ? 0 : 5; sal_uInt32 nWidth = 0, nHeight = 0; ImplBeginRecord( WIN_EMR_CREATEPEN ); m_rStm.WriteUInt32( mnLineHandle ).WriteUInt32( nStyle ).WriteUInt32( nWidth ).WriteUInt32( nHeight ); - ImplWriteColor( maVDev.GetLineColor() ); + ImplWriteColor( maVDev->GetLineColor() ); ImplEndRecord(); ImplBeginRecord( WIN_EMR_SELECTOBJECT ); @@ -484,12 +484,12 @@ void EMFWriter::ImplCheckFillAttr() { if( mbFillChanged && ImplPrepareHandleSelect( mnFillHandle, FILL_SELECT ) ) { - sal_uInt32 nStyle = maVDev.IsFillColor() ? 0 : 1; + sal_uInt32 nStyle = maVDev->IsFillColor() ? 0 : 1; sal_uInt32 nPatternStyle = 0; ImplBeginRecord( WIN_EMR_CREATEBRUSHINDIRECT ); m_rStm.WriteUInt32( mnFillHandle ).WriteUInt32( nStyle ); - ImplWriteColor( maVDev.GetFillColor() ); + ImplWriteColor( maVDev->GetFillColor() ); m_rStm.WriteUInt32( nPatternStyle ); ImplEndRecord(); @@ -503,7 +503,7 @@ void EMFWriter::ImplCheckTextAttr() { if( mbTextChanged && ImplPrepareHandleSelect( mnTextHandle, TEXT_SELECT ) ) { - const vcl::Font& rFont = maVDev.GetFont(); + const vcl::Font& rFont = maVDev->GetFont(); OUString aFontName( rFont.GetName() ); sal_Int32 nWeight; sal_uInt16 i; @@ -601,7 +601,7 @@ void EMFWriter::ImplCheckTextAttr() // Text color ImplBeginRecord( WIN_EMR_SETTEXTCOLOR ); - ImplWriteColor( maVDev.GetTextColor() ); + ImplWriteColor( maVDev->GetTextColor() ); ImplEndRecord(); ImplBeginRecord( WIN_EMR_SELECTOBJECT ); @@ -638,25 +638,25 @@ void EMFWriter::ImplWriteRasterOp( RasterOp eRop ) void EMFWriter::ImplWriteExtent( long nExtent ) { - nExtent = OutputDevice::LogicToLogic( Size( nExtent, 0 ), maVDev.GetMapMode(), maDestMapMode ).Width(); + nExtent = OutputDevice::LogicToLogic( Size( nExtent, 0 ), maVDev->GetMapMode(), maDestMapMode ).Width(); m_rStm.WriteInt32( nExtent ); } void EMFWriter::ImplWritePoint( const Point& rPoint ) { - const Point aPoint( OutputDevice::LogicToLogic( rPoint, maVDev.GetMapMode(), maDestMapMode )); + const Point aPoint( OutputDevice::LogicToLogic( rPoint, maVDev->GetMapMode(), maDestMapMode )); m_rStm.WriteInt32( aPoint.X() ).WriteInt32( aPoint.Y() ); } void EMFWriter::ImplWriteSize( const Size& rSize) { - const Size aSize( OutputDevice::LogicToLogic( rSize, maVDev.GetMapMode(), maDestMapMode )); + const Size aSize( OutputDevice::LogicToLogic( rSize, maVDev->GetMapMode(), maDestMapMode )); m_rStm.WriteInt32( aSize.Width() ).WriteInt32( aSize.Height() ); } void EMFWriter::ImplWriteRect( const Rectangle& rRect ) { - const Rectangle aRect( OutputDevice::LogicToLogic ( rRect, maVDev.GetMapMode(), maDestMapMode )); + const Rectangle aRect( OutputDevice::LogicToLogic ( rRect, maVDev->GetMapMode(), maDestMapMode )); m_rStm .WriteInt32( aRect.Left() ) .WriteInt32( aRect.Top() ) @@ -840,7 +840,7 @@ void EMFWriter::ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt, const sal_uLong nOffPos = m_rStm.Tell(); m_rStm.SeekRel( 16 ); - m_rStm.WriteUInt32( 0 ).WriteInt32( ( ROP_XOR == maVDev.GetRasterOp() && WIN_SRCCOPY == nROP ) ? WIN_SRCINVERT : nROP ); + m_rStm.WriteUInt32( 0 ).WriteInt32( ( ROP_XOR == maVDev->GetRasterOp() && WIN_SRCCOPY == nROP ) ? WIN_SRCINVERT : nROP ); ImplWriteSize( rSz ); WriteDIB(rBmp, aMemStm, true, false); @@ -898,19 +898,19 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, c // get text sizes if( pDXArray ) { - nNormWidth = maVDev.GetTextWidth( rText ); + nNormWidth = maVDev->GetTextWidth( rText ); pDX = const_cast(pDXArray); } else { pOwnArray.reset(new long[ nLen ]); - nNormWidth = maVDev.GetTextArray( rText, pOwnArray.get() ); + nNormWidth = maVDev->GetTextArray( rText, pOwnArray.get() ); pDX = pOwnArray.get(); } if( nLen > 1 ) { - nNormWidth = pDX[ nLen - 2 ] + maVDev.GetTextWidth( OUString(rText[ nLen - 1 ]) ); + nNormWidth = pDX[ nLen - 2 ] + maVDev->GetTextWidth( OUString(rText[ nLen - 1 ]) ); if( nWidth && nNormWidth && ( nWidth != nNormWidth ) ) { @@ -924,7 +924,7 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, c // write text record ImplBeginRecord( WIN_EMR_EXTTEXTOUTW ); - ImplWriteRect( Rectangle( rPos, Size( nNormWidth, maVDev.GetTextHeight() ) ) ); + ImplWriteRect( Rectangle( rPos, Size( nNormWidth, maVDev->GetTextHeight() ) ) ); m_rStm.WriteUInt32( 1 ); m_rStm.WriteInt32( 0 ).WriteInt32( 0 ); ImplWritePoint( rPos ); @@ -975,11 +975,11 @@ void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const bas if(aFillPolyPolygon.count()) { - const Color aOldLineColor(maVDev.GetLineColor()); - const Color aOldFillColor(maVDev.GetFillColor()); + const Color aOldLineColor(maVDev->GetLineColor()); + const Color aOldFillColor(maVDev->GetFillColor()); - maVDev.SetLineColor(); - maVDev.SetFillColor(aOldLineColor); + maVDev->SetLineColor(); + maVDev->SetFillColor(aOldLineColor); for(sal_uInt32 a(0); a < aFillPolyPolygon.count(); a++) { @@ -987,8 +987,8 @@ void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const bas ImplWritePolyPolygonRecord(tools::PolyPolygon(Polygon(aPolygon))); } - maVDev.SetLineColor(aOldLineColor); - maVDev.SetFillColor(aOldFillColor); + maVDev->SetLineColor(aOldLineColor); + maVDev->SetFillColor(aOldFillColor); } } } @@ -1016,14 +1016,14 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_POINT_ACTION ): { - if( maVDev.IsLineColor() ) + if( maVDev->IsLineColor() ) { const MetaPointAction* pA = static_cast(pAction); ImplCheckLineAttr(); ImplBeginRecord( WIN_EMR_SETPIXELV ); ImplWritePoint( pA->GetPoint() ); - ImplWriteColor( maVDev.GetLineColor() ); + ImplWriteColor( maVDev->GetLineColor() ); ImplEndRecord(); } } @@ -1031,7 +1031,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_LINE_ACTION ): { - if( maVDev.IsLineColor() ) + if( maVDev->IsLineColor() ) { const MetaLineAction* pA = static_cast(pAction); @@ -1049,7 +1049,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) ImplBeginRecord( WIN_EMR_SETPIXELV ); ImplWritePoint( pA->GetEndPoint() ); - ImplWriteColor( maVDev.GetLineColor() ); + ImplWriteColor( maVDev->GetLineColor() ); ImplEndRecord(); } else @@ -1066,7 +1066,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_RECT_ACTION ): { - if( maVDev.IsLineColor() || maVDev.IsFillColor() ) + if( maVDev->IsLineColor() || maVDev->IsFillColor() ) { const MetaRectAction* pA = static_cast(pAction); @@ -1082,7 +1082,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_ROUNDRECT_ACTION ): { - if( maVDev.IsLineColor() || maVDev.IsFillColor() ) + if( maVDev->IsLineColor() || maVDev->IsFillColor() ) { const MetaRoundRectAction* pA = static_cast(pAction); @@ -1099,7 +1099,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_ELLIPSE_ACTION ): { - if( maVDev.IsLineColor() || maVDev.IsFillColor() ) + if( maVDev->IsLineColor() || maVDev->IsFillColor() ) { const MetaEllipseAction* pA = static_cast(pAction); @@ -1118,7 +1118,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_CHORD_ACTION ): case( META_POLYGON_ACTION ): { - if( maVDev.IsLineColor() || maVDev.IsFillColor() ) + if( maVDev->IsLineColor() || maVDev->IsFillColor() ) { Polygon aPoly; @@ -1157,7 +1157,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_POLYLINE_ACTION ): { - if( maVDev.IsLineColor() ) + if( maVDev->IsLineColor() ) { const MetaPolyLineAction* pA = static_cast(pAction); const Polygon& rPoly = pA->GetPolygon(); @@ -1180,7 +1180,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_POLYPOLYGON_ACTION ): { - if( maVDev.IsLineColor() || maVDev.IsFillColor() ) + if( maVDev->IsLineColor() || maVDev->IsFillColor() ) ImplWritePolyPolygonRecord( static_cast(pAction)->GetPolyPolygon() ); } break; @@ -1190,7 +1190,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) const MetaGradientAction* pA = static_cast(pAction); GDIMetaFile aTmpMtf; - maVDev.AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf ); + maVDev->AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf ); ImplWrite( aTmpMtf ); } break; @@ -1200,7 +1200,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) const MetaHatchAction* pA = static_cast(pAction); GDIMetaFile aTmpMtf; - maVDev.AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf ); + maVDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf ); ImplWrite( aTmpMtf ); } break; @@ -1261,19 +1261,19 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) const MetaAction* pSubstAct = aSubstitute.GetAction( i ); if( pSubstAct->GetType() == META_BMPSCALE_ACTION ) { - maVDev.Push( PushFlags::ALL ); + maVDev->Push( PushFlags::ALL ); ImplBeginRecord( WIN_EMR_SAVEDC ); ImplEndRecord(); MapMode aMapMode( aSubstitute.GetPrefMapMode() ); - Size aOutSize( OutputDevice::LogicToLogic( pA->GetSize(), maVDev.GetMapMode(), aMapMode ) ); + Size aOutSize( OutputDevice::LogicToLogic( pA->GetSize(), maVDev->GetMapMode(), aMapMode ) ); aMapMode.SetScaleX( Fraction( aOutSize.Width(), aSubstitute.GetPrefSize().Width() ) ); aMapMode.SetScaleY( Fraction( aOutSize.Height(), aSubstitute.GetPrefSize().Height() ) ); - aMapMode.SetOrigin( OutputDevice::LogicToLogic( pA->GetPoint(), maVDev.GetMapMode(), aMapMode ) ); - maVDev.SetMapMode( aMapMode ); + aMapMode.SetOrigin( OutputDevice::LogicToLogic( pA->GetPoint(), maVDev->GetMapMode(), aMapMode ) ); + maVDev->SetMapMode( aMapMode ); ImplWrite( aSubstitute ); - maVDev.Pop(); + maVDev->Pop(); ImplBeginRecord( WIN_EMR_RESTOREDC ); m_rStm.WriteInt32( -1 ); ImplEndRecord(); @@ -1286,7 +1286,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case META_BMP_ACTION: { const MetaBmpAction* pA = static_cast(pAction); - ImplWriteBmpRecord( pA->GetBitmap(), pA->GetPoint(), maVDev.PixelToLogic( pA->GetBitmap().GetSizePixel() ), WIN_SRCCOPY ); + ImplWriteBmpRecord( pA->GetBitmap(), pA->GetPoint(), maVDev->PixelToLogic( pA->GetBitmap().GetSizePixel() ), WIN_SRCCOPY ); } break; @@ -1317,8 +1317,8 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) { aBmp.Replace( aMsk, COL_WHITE ); aMsk.Invert(); - ImplWriteBmpRecord( aMsk, pA->GetPoint(), maVDev.PixelToLogic( aMsk.GetSizePixel() ), WIN_SRCPAINT ); - ImplWriteBmpRecord( aBmp, pA->GetPoint(), maVDev.PixelToLogic( aBmp.GetSizePixel() ), WIN_SRCAND ); + ImplWriteBmpRecord( aMsk, pA->GetPoint(), maVDev->PixelToLogic( aMsk.GetSizePixel() ), WIN_SRCPAINT ); + ImplWriteBmpRecord( aBmp, pA->GetPoint(), maVDev->PixelToLogic( aBmp.GetSizePixel() ), WIN_SRCAND ); } else ImplWriteBmpRecord( aBmp, pA->GetPoint(), aBmp.GetSizePixel(), WIN_SRCCOPY ); @@ -1405,14 +1405,14 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_LINECOLOR_ACTION ): { - const_cast(pAction)->Execute( &maVDev ); + const_cast(pAction)->Execute( maVDev ); mbLineChanged = true; } break; case( META_FILLCOLOR_ACTION ): { - const_cast(pAction)->Execute( &maVDev ); + const_cast(pAction)->Execute( maVDev ); mbFillChanged = true; } break; @@ -1423,14 +1423,14 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_TEXTALIGN_ACTION ): case( META_FONT_ACTION ): { - const_cast(pAction)->Execute( &maVDev ); + const_cast(pAction)->Execute( maVDev ); mbTextChanged = true; } break; case( META_ISECTRECTCLIPREGION_ACTION ): { - const_cast(pAction)->Execute( &maVDev ); + const_cast(pAction)->Execute( maVDev ); ImplBeginRecord( WIN_EMR_INTERSECTCLIPRECT ); ImplWriteRect( static_cast(pAction)->GetRect() ); @@ -1442,18 +1442,18 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_ISECTREGIONCLIPREGION_ACTION ): case( META_MOVECLIPREGION_ACTION ): { - const_cast(pAction)->Execute( &maVDev ); + const_cast(pAction)->Execute( maVDev ); } break; case( META_REFPOINT_ACTION ): case( META_MAPMODE_ACTION ): - const_cast(pAction)->Execute( &maVDev ); + const_cast(pAction)->Execute( maVDev ); break; case( META_PUSH_ACTION ): { - const_cast(pAction)->Execute( &maVDev ); + const_cast(pAction)->Execute( maVDev ); ImplBeginRecord( WIN_EMR_SAVEDC ); ImplEndRecord(); @@ -1462,20 +1462,20 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_POP_ACTION ): { - const_cast(pAction)->Execute( &maVDev ); + const_cast(pAction)->Execute( maVDev ); ImplBeginRecord( WIN_EMR_RESTOREDC ); m_rStm.WriteInt32( -1 ); ImplEndRecord(); - ImplWriteRasterOp( maVDev.GetRasterOp() ); + ImplWriteRasterOp( maVDev->GetRasterOp() ); mbLineChanged = mbFillChanged = mbTextChanged = true; } break; case( META_RASTEROP_ACTION ): { - const_cast(pAction)->Execute( &maVDev ); + const_cast(pAction)->Execute( maVDev ); ImplWriteRasterOp( static_cast(pAction)->GetRasterOp() ); } break; diff --git a/vcl/source/filter/wmf/emfwr.hxx b/vcl/source/filter/wmf/emfwr.hxx index 5bf294a0e323..dd34bbcd3517 100644 --- a/vcl/source/filter/wmf/emfwr.hxx +++ b/vcl/source/filter/wmf/emfwr.hxx @@ -33,7 +33,7 @@ class EMFWriter { private: - VirtualDevice maVDev; + ScopedVclPtr maVDev; MapMode maDestMapMode; SvStream& m_rStm; bool* mpHandlesUsed; diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index 9dcf64459367..7df094cc6375 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -1812,7 +1812,7 @@ bool WMFWriter::WriteWMF( const GDIMetaFile& rMTF, SvStream& rTargetStream, delete pAt; } - delete pVirDev; + pVirDev.disposeAndClear(); if ( xStatusIndicator.is() ) xStatusIndicator->end(); diff --git a/vcl/source/filter/wmf/wmfwr.hxx b/vcl/source/filter/wmf/wmfwr.hxx index c27a8eb3be7f..c017eb53aa61 100644 --- a/vcl/source/filter/wmf/wmfwr.hxx +++ b/vcl/source/filter/wmf/wmfwr.hxx @@ -58,7 +58,7 @@ private: com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator; SvStream* pWMF; - VirtualDevice* pVirDev; + VclPtr pVirDev; MapMode aTargetMapMode; Size aTargetSize; diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx index f4ba559074a8..551e7e70adb6 100644 --- a/vcl/source/gdi/animate.cxx +++ b/vcl/source/gdi/animate.cxx @@ -802,4 +802,10 @@ SvStream& ReadAnimation( SvStream& rIStm, Animation& rAnimation ) return rIStm; } +AInfo::AInfo() : pOutDev( NULL ), + pViewData( NULL ), + nExtraData( 0L ), + bWithSize( false ), + bPause( false ) {} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index d75d6749143e..157e506a030c 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -706,16 +706,16 @@ BitmapEx BitmapEx:: AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize Size aStdSize( aStandardSize, aStandardSize ); Rectangle aRect(aEmptyPoint, aStdSize ); - VirtualDevice aVirDevice( *Application::GetDefaultDevice(), 0, 1 ); - aVirDevice.SetOutputSizePixel( aStdSize ); - aVirDevice.SetFillColor( COL_TRANSPARENT ); - aVirDevice.SetLineColor( COL_TRANSPARENT ); + ScopedVclPtr aVirDevice( new VirtualDevice(*Application::GetDefaultDevice(), 0, 1) ); + aVirDevice->SetOutputSizePixel( aStdSize ); + aVirDevice->SetFillColor( COL_TRANSPARENT ); + aVirDevice->SetLineColor( COL_TRANSPARENT ); // Draw a rect into virDevice - aVirDevice.DrawRect( aRect ); + aVirDevice->DrawRect( aRect ); Point aPointPixel( (long)imgposX, (long)imgposY ); - aVirDevice.DrawBitmapEx( aPointPixel, aRet ); - aRet = aVirDevice.GetBitmapEx( aEmptyPoint, aStdSize ); + aVirDevice->DrawBitmapEx( aPointPixel, aRet ); + aRet = aVirDevice->GetBitmapEx( aEmptyPoint, aStdSize ); return aRet; } diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx index 2f4b17a6ccb0..4edff5df4ebf 100644 --- a/vcl/source/gdi/cvtsvm.cxx +++ b/vcl/source/gdi/cvtsvm.cxx @@ -497,8 +497,8 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) } LineInfo aLineInfo( LINE_NONE, 0 ); - ::std::stack< LineInfo* > aLIStack; - VirtualDevice aFontVDev; + ::std::stack< LineInfo* > aLIStack; + ScopedVclPtr aFontVDev = new VirtualDevice; rtl_TextEncoding eActualCharSet = osl_getThreadTextEncoding(); bool bFatLine = false; @@ -848,7 +848,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rMtf.AddAction( new MetaTextFillColorAction( aFont.GetFillColor(), !aFont.IsTransparent() ) ); // #106172# Track font relevant data in shadow VDev - aFontVDev.SetFont( aFont ); + aFontVDev->SetFont( aFont ); } break; @@ -904,7 +904,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) { boost::scoped_array pTmpAry(new long[nStrLen]); - aFontVDev.GetTextArray( aStr, pTmpAry.get(), nIndex, nLen ); + aFontVDev->GetTextArray( aStr, pTmpAry.get(), nIndex, nLen ); // now, the difference between the // last and the second last DX array @@ -1022,7 +1022,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rMtf.AddAction( new MetaMapModeAction( aMapMode ) ); // #106172# Track font relevant data in shadow VDev - aFontVDev.SetMapMode( aMapMode ); + aFontVDev->SetMapMode( aMapMode ); } break; @@ -1132,7 +1132,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rMtf.AddAction( new MetaPushAction( PushFlags::ALL ) ); // #106172# Track font relevant data in shadow VDev - aFontVDev.Push(); + aFontVDev->Push(); } break; @@ -1159,7 +1159,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rMtf.AddAction( new MetaPopAction() ); // #106172# Track font relevant data in shadow VDev - aFontVDev.Pop(); + aFontVDev->Pop(); } break; @@ -1259,9 +1259,9 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) // #106172# Track font relevant data in shadow VDev if( bSet ) - aFontVDev.SetRefPoint( aRefPoint ); + aFontVDev->SetRefPoint( aRefPoint ); else - aFontVDev.SetRefPoint(); + aFontVDev->SetRefPoint(); } break; @@ -1374,7 +1374,7 @@ void SVMConverter::ImplConvertToSVM1( SvStream& rOStm, GDIMetaFile& rMtf ) rtl_TextEncoding eActualCharSet = osl_getThreadTextEncoding(); const Size aPrefSize( rMtf.GetPrefSize() ); bool bRop_0_1 = false; - VirtualDevice aSaveVDev; + ScopedVclPtr aSaveVDev = new VirtualDevice; Color aLineCol( COL_BLACK ); ::std::stack< Color* > aLineColStack; @@ -1392,7 +1392,7 @@ void SVMConverter::ImplConvertToSVM1( SvStream& rOStm, GDIMetaFile& rMtf ) nCountPos = rOStm.Tell(); rOStm.SeekRel( 4L ); - const sal_Int32 nActCount = ImplWriteActions( rOStm, rMtf, aSaveVDev, bRop_0_1, aLineCol, aLineColStack, eActualCharSet ); + const sal_Int32 nActCount = ImplWriteActions( rOStm, rMtf, *aSaveVDev.get(), bRop_0_1, aLineCol, aLineColStack, eActualCharSet ); const sal_uLong nActPos = rOStm.Tell(); rOStm.Seek( nCountPos ); @@ -2311,10 +2311,10 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { // write actions for hatch - VirtualDevice aVDev; + ScopedVclPtr aVDev = new VirtualDevice; GDIMetaFile aTmpMtf; - aVDev.AddHatchActions( rPolyPoly, rHatch, aTmpMtf ); + aVDev->AddHatchActions( rPolyPoly, rHatch, aTmpMtf ); nAddCount = ImplWriteActions( rOStm, aTmpMtf, rSaveVDev, rRop_0_1, rLineCol, rLineColStack, rActualCharSet ); nNewPos = rOStm.Tell(); rOStm.Seek( nOldPos ); diff --git a/vcl/source/gdi/gdimetafiletools.cxx b/vcl/source/gdi/gdimetafiletools.cxx index 3fa559a6abb8..32b7a839d451 100644 --- a/vcl/source/gdi/gdimetafiletools.cxx +++ b/vcl/source/gdi/gdimetafiletools.cxx @@ -161,23 +161,23 @@ namespace // in pixel mode for alpha channel painting (black is transparent, // white to paint 100% opacity) const Size aSizePixel(rBitmapEx.GetSizePixel()); - VirtualDevice aVDev; + ScopedVclPtr aVDev = new VirtualDevice; - aVDev.SetOutputSizePixel(aSizePixel); - aVDev.EnableMapMode(false); - aVDev.SetFillColor(COL_WHITE); - aVDev.SetLineColor(); + aVDev->SetOutputSizePixel(aSizePixel); + aVDev->EnableMapMode(false); + aVDev->SetFillColor(COL_WHITE); + aVDev->SetLineColor(); if(rBitmapEx.IsTransparent()) { // use given alpha channel - aVDev.DrawBitmap(Point(0, 0), rBitmapEx.GetAlpha().GetBitmap()); + aVDev->DrawBitmap(Point(0, 0), rBitmapEx.GetAlpha().GetBitmap()); } else { // reset alpha channel - aVDev.SetBackground(Wallpaper(Color(COL_BLACK))); - aVDev.Erase(); + aVDev->SetBackground(Wallpaper(Color(COL_BLACK))); + aVDev->Erase(); } // transform polygon from clipping to pixel coordinates @@ -203,11 +203,11 @@ namespace aInvertPixelPoly.append(aPixelPoly); // paint as alpha - aVDev.DrawPolyPolygon(aInvertPixelPoly); + aVDev->DrawPolyPolygon(aInvertPixelPoly); // get created alpha mask and set defaults AlphaMask aAlpha( - aVDev.GetBitmap( + aVDev->GetBitmap( Point(0, 0), aSizePixel)); diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index a761a5d07516..9772a570387d 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -723,10 +723,10 @@ void GDIMetaFile::Move( long nX, long nY ) { const Size aBaseOffset( nX, nY ); Size aOffset( aBaseOffset ); - VirtualDevice aMapVDev; + ScopedVclPtr aMapVDev = new VirtualDevice; - aMapVDev.EnableOutput( false ); - aMapVDev.SetMapMode( GetPrefMapMode() ); + aMapVDev->EnableOutput( false ); + aMapVDev->SetMapMode( GetPrefMapMode() ); for( MetaAction* pAct = FirstAction(); pAct; pAct = NextAction() ) { @@ -745,8 +745,8 @@ void GDIMetaFile::Move( long nX, long nY ) ( META_PUSH_ACTION == nType ) || ( META_POP_ACTION == nType ) ) { - pModAct->Execute( &aMapVDev ); - aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev.GetMapMode() ); + pModAct->Execute( aMapVDev.get() ); + aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev->GetMapMode() ); } pModAct->Move( aOffset.Width(), aOffset.Height() ); @@ -757,11 +757,11 @@ void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY ) { const Size aBaseOffset( nX, nY ); Size aOffset( aBaseOffset ); - VirtualDevice aMapVDev; + ScopedVclPtr aMapVDev = new VirtualDevice; - aMapVDev.EnableOutput( false ); - aMapVDev.SetReferenceDevice( nDPIX, nDPIY ); - aMapVDev.SetMapMode( GetPrefMapMode() ); + aMapVDev->EnableOutput( false ); + aMapVDev->SetReferenceDevice( nDPIX, nDPIY ); + aMapVDev->SetMapMode( GetPrefMapMode() ); for( MetaAction* pAct = FirstAction(); pAct; pAct = NextAction() ) { @@ -780,16 +780,16 @@ void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY ) ( META_PUSH_ACTION == nType ) || ( META_POP_ACTION == nType ) ) { - pModAct->Execute( &aMapVDev ); - if( aMapVDev.GetMapMode().GetMapUnit() == MAP_PIXEL ) + pModAct->Execute( aMapVDev.get() ); + if( aMapVDev->GetMapMode().GetMapUnit() == MAP_PIXEL ) { - aOffset = aMapVDev.LogicToPixel( aBaseOffset, GetPrefMapMode() ); - MapMode aMap( aMapVDev.GetMapMode() ); + aOffset = aMapVDev->LogicToPixel( aBaseOffset, GetPrefMapMode() ); + MapMode aMap( aMapVDev->GetMapMode() ); aOffset.Width() = static_cast(aOffset.Width() * (double)aMap.GetScaleX()); aOffset.Height() = static_cast(aOffset.Height() * (double)aMap.GetScaleY()); } else - aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev.GetMapMode() ); + aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev->GetMapMode() ); } pModAct->Move( aOffset.Width(), aOffset.Height() ); @@ -825,10 +825,10 @@ void GDIMetaFile::Scale( const Fraction& rScaleX, const Fraction& rScaleY ) void GDIMetaFile::Clip( const Rectangle& i_rClipRect ) { Rectangle aCurRect( i_rClipRect ); - VirtualDevice aMapVDev; + ScopedVclPtr aMapVDev = new VirtualDevice; - aMapVDev.EnableOutput( false ); - aMapVDev.SetMapMode( GetPrefMapMode() ); + aMapVDev->EnableOutput( false ); + aMapVDev->SetMapMode( GetPrefMapMode() ); for( MetaAction* pAct = FirstAction(); pAct; pAct = NextAction() ) { @@ -838,8 +838,8 @@ void GDIMetaFile::Clip( const Rectangle& i_rClipRect ) ( META_PUSH_ACTION == nType ) || ( META_POP_ACTION == nType ) ) { - pAct->Execute( &aMapVDev ); - aCurRect = OutputDevice::LogicToLogic( i_rClipRect, GetPrefMapMode(), aMapVDev.GetMapMode() ); + pAct->Execute( aMapVDev.get() ); + aCurRect = OutputDevice::LogicToLogic( i_rClipRect, GetPrefMapMode(), aMapVDev->GetMapMode() ); } else if( nType == META_CLIPREGION_ACTION ) { @@ -892,12 +892,12 @@ void GDIMetaFile::ImplAddGradientEx( GDIMetaFile& rMtf, const Gradient& rGrad ) { // Generate comment, GradientEx and Gradient actions (within DrawGradient) - VirtualDevice aVDev( rMapDev, 0 ); - aVDev.EnableOutput( false ); + ScopedVclPtr aVDev = new VirtualDevice( rMapDev, 0 ); + aVDev->EnableOutput( false ); GDIMetaFile aGradMtf; - aGradMtf.Record( &aVDev ); - aVDev.DrawGradient( rPolyPoly, rGrad ); + aGradMtf.Record( aVDev.get() ); + aVDev->DrawGradient( rPolyPoly, rGrad ); aGradMtf.Stop(); size_t i, nAct( aGradMtf.GetActionSize() ); @@ -917,7 +917,7 @@ void GDIMetaFile::Rotate( long nAngle10 ) if( nAngle10 ) { GDIMetaFile aMtf; - VirtualDevice aMapVDev; + ScopedVclPtr aMapVDev = new VirtualDevice; const double fAngle = F_PI1800 * nAngle10; const double fSin = sin( fAngle ); const double fCos = cos( fAngle ); @@ -926,8 +926,8 @@ void GDIMetaFile::Rotate( long nAngle10 ) aPoly.Rotate( Point(), fSin, fCos ); - aMapVDev.EnableOutput( false ); - aMapVDev.SetMapMode( GetPrefMapMode() ); + aMapVDev->EnableOutput( false ); + aMapVDev->SetMapMode( GetPrefMapMode() ); const Rectangle aNewBound( aPoly.GetBoundRect() ); @@ -1130,7 +1130,7 @@ void GDIMetaFile::Rotate( long nAngle10 ) { MetaGradientAction* pAct = static_cast(pAction); - ImplAddGradientEx( aMtf, aMapVDev, + ImplAddGradientEx( aMtf, *aMapVDev.get(), ImplGetRotatedPolygon( pAct->GetRect(), aRotAnchor, aRotOffset, fSin, fCos ), pAct->GetGradient() ); } @@ -1162,7 +1162,7 @@ void GDIMetaFile::Rotate( long nAngle10 ) { // Add rotated gradientex MetaGradientExAction* pAct = static_cast(pAction); - ImplAddGradientEx( aMtf, aMapVDev, + ImplAddGradientEx( aMtf, *aMapVDev.get(), ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ), pAct->GetGradient() ); } @@ -1225,7 +1225,7 @@ void GDIMetaFile::Rotate( long nAngle10 ) else if ( pCommentAct->GetComment() == "XPATHSTROKE_SEQ_END" || pCommentAct->GetComment() == "XPATHFILL_SEQ_END" ) { - pAction->Execute( &aMapVDev ); + pAction->Execute( aMapVDev.get() ); pAction->Duplicate(); aMtf.AddAction( pAction ); } @@ -1348,7 +1348,7 @@ void GDIMetaFile::Rotate( long nAngle10 ) default: { - pAction->Execute( &aMapVDev ); + pAction->Execute( aMapVDev.get() ); pAction->Duplicate(); aMtf.AddAction( pAction ); @@ -1357,8 +1357,8 @@ void GDIMetaFile::Rotate( long nAngle10 ) ( META_PUSH_ACTION == nActionType ) || ( META_POP_ACTION == nActionType ) ) { - aRotAnchor = OutputDevice::LogicToLogic( aOrigin, aPrefMapMode, aMapVDev.GetMapMode() ); - aRotOffset = OutputDevice::LogicToLogic( aOffset, aPrefMapMode, aMapVDev.GetMapMode() ); + aRotAnchor = OutputDevice::LogicToLogic( aOrigin, aPrefMapMode, aMapVDev->GetMapMode() ); + aRotOffset = OutputDevice::LogicToLogic( aOffset, aPrefMapMode, aMapVDev->GetMapMode() ); } } break; @@ -1400,10 +1400,10 @@ static void ImplActionBounds( Rectangle& o_rOutBounds, Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHairline ) const { GDIMetaFile aMtf; - VirtualDevice aMapVDev( i_rReference ); + ScopedVclPtr aMapVDev = new VirtualDevice( i_rReference ); - aMapVDev.EnableOutput( false ); - aMapVDev.SetMapMode( GetPrefMapMode() ); + aMapVDev->EnableOutput( false ); + aMapVDev->SetMapMode( GetPrefMapMode() ); std::vector aClipStack( 1, Rectangle() ); std::vector aPushFlagStack; @@ -1419,7 +1419,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaAction* pAction = GetAction(a); const sal_uInt16 nActionType = pAction->GetType(); - Rectangle* pUseHairline = (pHairline && aMapVDev.IsLineColor()) ? pHairline : 0; + Rectangle* pUseHairline = (pHairline && aMapVDev->IsLineColor()) ? pHairline : 0; switch( nActionType ) { @@ -1427,8 +1427,8 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaPixelAction* pAct = static_cast(pAction); ImplActionBounds( aBound, - Rectangle( OutputDevice::LogicToLogic( pAct->GetPoint(), aMapVDev.GetMapMode(), GetPrefMapMode() ), - aMapVDev.PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ), + Rectangle( OutputDevice::LogicToLogic( pAct->GetPoint(), aMapVDev->GetMapMode(), GetPrefMapMode() ), + aMapVDev->PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ), aClipStack, pUseHairline ); } break; @@ -1437,8 +1437,8 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaPointAction* pAct = static_cast(pAction); ImplActionBounds( aBound, - Rectangle( OutputDevice::LogicToLogic( pAct->GetPoint(), aMapVDev.GetMapMode(), GetPrefMapMode() ), - aMapVDev.PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ), + Rectangle( OutputDevice::LogicToLogic( pAct->GetPoint(), aMapVDev->GetMapMode(), GetPrefMapMode() ), + aMapVDev->PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ), aClipStack, pUseHairline ); } break; @@ -1458,28 +1458,28 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai pUseHairline = 0; } - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); } break; case( META_RECT_ACTION ): { MetaRectAction* pAct = static_cast(pAction); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); } break; case( META_ROUNDRECT_ACTION ): { MetaRoundRectAction* pAct = static_cast(pAction); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); } break; case( META_ELLIPSE_ACTION ): { MetaEllipseAction* pAct = static_cast(pAction); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); } break; @@ -1488,7 +1488,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai MetaArcAction* pAct = static_cast(pAction); // FIXME: this is imprecise // e.g. for small arcs the whole rectangle is WAY too large - ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); } break; @@ -1497,7 +1497,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai MetaPieAction* pAct = static_cast(pAction); // FIXME: this is imprecise // e.g. for small arcs the whole rectangle is WAY too large - ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); } break; @@ -1506,7 +1506,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai MetaChordAction* pAct = static_cast(pAction); // FIXME: this is imprecise // e.g. for small arcs the whole rectangle is WAY too large - ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); } break; @@ -1523,7 +1523,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai pUseHairline = 0; } - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); } break; @@ -1531,7 +1531,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaPolygonAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetPolygon().GetBoundRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); } break; @@ -1539,7 +1539,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaPolyPolygonAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, pUseHairline ); } break; @@ -1548,10 +1548,10 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai MetaTextAction* pAct = static_cast(pAction); Rectangle aRect; // hdu said base = index - aMapVDev.GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen() ); + aMapVDev->GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen() ); Point aPt( pAct->GetPoint() ); aRect.Move( aPt.X(), aPt.Y() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1560,11 +1560,11 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai MetaTextArrayAction* pAct = static_cast(pAction); Rectangle aRect; // hdu said base = index - aMapVDev.GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(), + aMapVDev->GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(), 0, pAct->GetDXArray() ); Point aPt( pAct->GetPoint() ); aRect.Move( aPt.X(), aPt.Y() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1573,11 +1573,11 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai MetaStretchTextAction* pAct = static_cast(pAction); Rectangle aRect; // hdu said base = index - aMapVDev.GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(), + aMapVDev->GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(), pAct->GetWidth(), NULL ); Point aPt( pAct->GetPoint() ); aRect.Move( aPt.X(), aPt.Y() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1589,11 +1589,11 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai OUString aStr( pStr ); Rectangle aRect; - aMapVDev.GetTextBoundRect( aRect, aStr, 0, 0, aStr.getLength(), 0, NULL ); + aMapVDev->GetTextBoundRect( aRect, aStr, 0, 0, aStr.getLength(), 0, NULL ); Point aPt( pAct->GetStartPoint() ); aRect.Move( aPt.X(), aPt.Y() ); aRect.Right() = aRect.Left() + pAct->GetWidth(); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1601,7 +1601,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaBmpScaleAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetPoint(), pAct->GetSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1609,7 +1609,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaBmpScalePartAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1617,7 +1617,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaBmpExScaleAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetPoint(), pAct->GetSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1625,7 +1625,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaBmpExScalePartAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1633,7 +1633,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaGradientAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1641,7 +1641,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaGradientExAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1655,7 +1655,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaHatchAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1663,7 +1663,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaTransparentAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1673,7 +1673,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai // MetaFloatTransparentAction is defined limiting it's content Metafile // to it's geometry definition(Point, Size), so use these directly const Rectangle aRect( pAct->GetPoint(), pAct->GetSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1681,7 +1681,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaEPSAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetPoint(), pAct->GetSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1689,7 +1689,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaClipRegionAction* pAct = static_cast(pAction); if( pAct->IsClipping() ) - aClipStack.back() = OutputDevice::LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ); + aClipStack.back() = OutputDevice::LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ); else aClipStack.back() = Rectangle(); } @@ -1698,7 +1698,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai case( META_ISECTRECTCLIPREGION_ACTION ): { MetaISectRectClipRegionAction* pAct = static_cast(pAction); - Rectangle aRect( OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ) ); + Rectangle aRect( OutputDevice::LogicToLogic( pAct->GetRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ) ); if( aClipStack.back().IsEmpty() ) aClipStack.back() = aRect; else @@ -1709,7 +1709,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai case( META_ISECTREGIONCLIPREGION_ACTION ): { MetaISectRegionClipRegionAction* pAct = static_cast(pAction); - Rectangle aRect( OutputDevice::LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ) ); + Rectangle aRect( OutputDevice::LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev->GetMapMode(), GetPrefMapMode() ) ); if( aClipStack.back().IsEmpty() ) aClipStack.back() = aRect; else @@ -1720,24 +1720,24 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai case( META_BMP_ACTION ): { MetaBmpAction* pAct = static_cast(pAction); - Rectangle aRect( pAct->GetPoint(), aMapVDev.PixelToLogic( pAct->GetBitmap().GetSizePixel() ) ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmap().GetSizePixel() ) ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; case( META_BMPEX_ACTION ): { MetaBmpExAction* pAct = static_cast(pAction); - Rectangle aRect( pAct->GetPoint(), aMapVDev.PixelToLogic( pAct->GetBitmapEx().GetSizePixel() ) ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmapEx().GetSizePixel() ) ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; case( META_MASK_ACTION ): { MetaMaskAction* pAct = static_cast(pAction); - Rectangle aRect( pAct->GetPoint(), aMapVDev.PixelToLogic( pAct->GetBitmap().GetSizePixel() ) ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + Rectangle aRect( pAct->GetPoint(), aMapVDev->PixelToLogic( pAct->GetBitmap().GetSizePixel() ) ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1745,7 +1745,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaMaskScalePartAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1753,7 +1753,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaMaskScalePartAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1761,7 +1761,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaWallpaperAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1769,7 +1769,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaTextRectAction* pAct = static_cast(pAction); Rectangle aRect( pAct->GetRect() ); - ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); + ImplActionBounds( aBound, OutputDevice::LogicToLogic( aRect, aMapVDev->GetMapMode(), GetPrefMapMode() ), aClipStack, 0 ); } break; @@ -1779,7 +1779,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai if( ! aClipStack.back().IsEmpty() ) { Size aDelta( pAct->GetHorzMove(), pAct->GetVertMove() ); - aDelta = OutputDevice::LogicToLogic( aDelta, aMapVDev.GetMapMode(), GetPrefMapMode() ); + aDelta = OutputDevice::LogicToLogic( aDelta, aMapVDev->GetMapMode(), GetPrefMapMode() ); aClipStack.back().Move( aDelta.Width(), aDelta.Width() ); } } @@ -1787,7 +1787,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai default: { - pAction->Execute( &aMapVDev ); + pAction->Execute( aMapVDev.get() ); if( nActionType == META_PUSH_ACTION ) { @@ -2890,11 +2890,11 @@ SvStream& GDIMetaFile::Write( SvStream& rOStm ) bool GDIMetaFile::CreateThumbnail(BitmapEx& rBitmapEx, sal_uInt32 nMaximumExtent, BmpConversion eColorConversion, long nScaleFlag) const { // initialization seems to be complicated but is used to avoid rounding errors - VirtualDevice aVDev; + ScopedVclPtr aVDev = new VirtualDevice; const Point aNullPt; - const Point aTLPix( aVDev.LogicToPixel( aNullPt, GetPrefMapMode() ) ); - const Point aBRPix( aVDev.LogicToPixel( Point( GetPrefSize().Width() - 1, GetPrefSize().Height() - 1 ), GetPrefMapMode() ) ); - Size aDrawSize( aVDev.LogicToPixel( GetPrefSize(), GetPrefMapMode() ) ); + const Point aTLPix( aVDev->LogicToPixel( aNullPt, GetPrefMapMode() ) ); + const Point aBRPix( aVDev->LogicToPixel( Point( GetPrefSize().Width() - 1, GetPrefSize().Height() - 1 ), GetPrefMapMode() ) ); + Size aDrawSize( aVDev->LogicToPixel( GetPrefSize(), GetPrefMapMode() ) ); Size aSizePix( labs( aBRPix.X() - aTLPix.X() ) + 1, labs( aBRPix.Y() - aTLPix.Y() ) + 1 ); if (!rBitmapEx.IsEmpty()) @@ -2929,7 +2929,7 @@ bool GDIMetaFile::CreateThumbnail(BitmapEx& rBitmapEx, sal_uInt32 nMaximumExtent // draw image(s) into VDev and get resulting image // do it 4x larger to be able to scale it down & get beautiful antialias Size aAntialiasSize(aSizePix.Width() * 4, aSizePix.Height() * 4); - if (aVDev.SetOutputSizePixel(aAntialiasSize)) + if (aVDev->SetOutputSizePixel(aAntialiasSize)) { // antialias: provide 4x larger size, and then scale down the result Size aAntialias(aDrawSize.Width() * 4, aDrawSize.Height() * 4); @@ -2937,10 +2937,10 @@ bool GDIMetaFile::CreateThumbnail(BitmapEx& rBitmapEx, sal_uInt32 nMaximumExtent // draw metafile into VDev Point aBackPosPix; const_cast(this)->WindStart(); - const_cast(this)->Play(&aVDev, aBackPosPix, aAntialias); + const_cast(this)->Play(aVDev.get(), aBackPosPix, aAntialias); // get paint bitmap - Bitmap aBitmap( aVDev.GetBitmap( aNullPt, aVDev.GetOutputSizePixel() ) ); + Bitmap aBitmap( aVDev->GetBitmap( aNullPt, aVDev->GetOutputSizePixel() ) ); // scale down the image to the desired size - use the input scaler for the scaling operation aBitmap.Scale(aDrawSize, nScaleFlag); diff --git a/vcl/source/gdi/impanmvw.cxx b/vcl/source/gdi/impanmvw.cxx index c3e7b793580c..e271ae4d5d74 100644 --- a/vcl/source/gdi/impanmvw.cxx +++ b/vcl/source/gdi/impanmvw.cxx @@ -77,7 +77,7 @@ ImplAnimView::ImplAnimView( Animation* pParent, OutputDevice* pOut, MapMode aTempMap( mpOut->GetMapMode() ); aTempMap.SetOrigin( Point() ); mpBackground->SetMapMode( aTempMap ); - static_cast( mpOut )->SaveBackground( maDispPt, maDispSz, Point(), *mpBackground ); + static_cast( mpOut.get() )->SaveBackground( maDispPt, maDispSz, Point(), *mpBackground ); mpBackground->SetMapMode( MapMode() ); } else @@ -93,8 +93,8 @@ ImplAnimView::ImplAnimView( Animation* pParent, OutputDevice* pOut, ImplAnimView::~ImplAnimView() { - delete mpBackground; - delete mpRestore; + mpBackground.disposeAndClear(); + mpRestore.disposeAndClear(); Animation::ImplDecAnimCount(); } @@ -153,19 +153,19 @@ void ImplAnimView::getPosSize( const AnimationBitmap& rAnm, Point& rPosPix, Size void ImplAnimView::drawToPos( sal_uLong nPos ) { - VirtualDevice aVDev; + ScopedVclPtr aVDev = new VirtualDevice; std::unique_ptr xOldClip(!maClip.IsNull() ? new vcl::Region( mpOut->GetClipRegion() ) : NULL); - aVDev.SetOutputSizePixel( maSzPix, false ); + aVDev->SetOutputSizePixel( maSzPix, false ); nPos = std::min( nPos, (sal_uLong) mpParent->Count() - 1UL ); for( sal_uLong i = 0UL; i <= nPos; i++ ) - draw( i, &aVDev ); + draw( i, aVDev.get() ); if (xOldClip) mpOut->SetClipRegion( maClip ); - mpOut->DrawOutDev( maDispPt, maDispSz, Point(), maSzPix, aVDev ); + mpOut->DrawOutDev( maDispPt, maDispSz, Point(), maSzPix, *aVDev.get() ); if (xOldClip) mpOut->SetClipRegion(*xOldClip); @@ -180,7 +180,7 @@ void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* pVDev ) setMarked( true ); else if( !mbPause ) { - VirtualDevice* pDev; + VclPtr pDev; Point aPosPix; Point aBmpPosPix; Size aSizePix; @@ -273,10 +273,10 @@ void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* pVDev ) xOldClip.reset(); } - delete pDev; + pDev.disposeAndClear(); if( mpOut->GetOutDevType() == OUTDEV_WINDOW ) - static_cast( mpOut )->Sync(); + static_cast( mpOut.get() )->Sync(); } } } @@ -290,7 +290,7 @@ void ImplAnimView::repaint() MapMode aTempMap( mpOut->GetMapMode() ); aTempMap.SetOrigin( Point() ); mpBackground->SetMapMode( aTempMap ); - static_cast( mpOut )->SaveBackground( maDispPt, maDispSz, Point(), *mpBackground ); + static_cast( mpOut.get() )->SaveBackground( maDispPt, maDispSz, Point(), *mpBackground ); mpBackground->SetMapMode( MapMode() ); } else diff --git a/vcl/source/gdi/impanmvw.hxx b/vcl/source/gdi/impanmvw.hxx index ce49476e0718..0955046d7f30 100644 --- a/vcl/source/gdi/impanmvw.hxx +++ b/vcl/source/gdi/impanmvw.hxx @@ -34,7 +34,7 @@ private: friend class Animation; Animation* mpParent; - OutputDevice* mpOut; + VclPtr mpOut; long mnExtraData; Point maPt; Point maDispPt; @@ -45,8 +45,8 @@ private: Size maRestSz; MapMode maMap; vcl::Region maClip; - VirtualDevice* mpBackground; - VirtualDevice* mpRestore; + VclPtr mpBackground; + VclPtr mpRestore; sal_uLong mnActPos; Disposal meLastDisposal; bool mbPause; diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 3f65281a7163..a970919e6dc9 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -467,8 +467,8 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters) if(maEx.IsEmpty()) { // calculate size - VirtualDevice aVDev; - Size aDrawSize(aVDev.LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode())); + ScopedVclPtr aVDev = new VirtualDevice; + Size aDrawSize(aVDev->LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode())); if(rParameters.getSizePixel().Width() && rParameters.getSizePixel().Height()) { @@ -502,7 +502,7 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters) { // get hairline and full bound rect Rectangle aHairlineRect; - const Rectangle aRect(maMetaFile.GetBoundRect(aVDev, &aHairlineRect)); + const Rectangle aRect(maMetaFile.GetBoundRect(*aVDev.get(), &aHairlineRect)); if(!aRect.IsEmpty() && !aHairlineRect.IsEmpty()) { @@ -519,22 +519,22 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters) } } - if(aVDev.SetOutputSizePixel(aPixelSize)) + if(aVDev->SetOutputSizePixel(aPixelSize)) { if(rParameters.getAntiAliase()) { - aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW); + aVDev->SetAntialiasing(aVDev->GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW); } if(rParameters.getSnapHorVerLines()) { - aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_PIXELSNAPHAIRLINE); + aVDev->SetAntialiasing(aVDev->GetAntialiasing() | ANTIALIASING_PIXELSNAPHAIRLINE); } - ImplDraw( &aVDev, Point(), aDrawSize ); + ImplDraw( aVDev.get(), Point(), aDrawSize ); // use maEx as local buffer for rendered metafile - const_cast< ImpGraphic* >(this)->maEx = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() ); + const_cast< ImpGraphic* >(this)->maEx = aVDev->GetBitmap( Point(), aVDev->GetOutputSizePixel() ); } } diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx index 9a71a241fd65..a0ac4c32b305 100644 --- a/vcl/source/gdi/impvect.cxx +++ b/vcl/source/gdi/impvect.cxx @@ -717,8 +717,8 @@ bool ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf, if( rMtf.GetActionSize() ) { MapMode aMap( MAP_100TH_MM ); - VirtualDevice aVDev; - const Size aLogSize1( aVDev.PixelToLogic( Size( 1, 1 ), aMap ) ); + ScopedVclPtr aVDev = new VirtualDevice; + const Size aLogSize1( aVDev->PixelToLogic( Size( 1, 1 ), aMap ) ); rMtf.SetPrefMapMode( aMap ); rMtf.SetPrefSize( Size( nWidth + 2, nHeight + 2 ) ); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 2a4166f4b951..c71c52ff2ecb 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -1874,7 +1874,7 @@ PDFWriterImpl::~PDFWriterImpl() { if( m_aDocDigest ) rtl_digest_destroyMD5( m_aDocDigest ); - delete static_cast(m_pReferenceDevice); + m_pReferenceDevice.disposeAndClear(); if( m_aCipher ) rtl_cipher_destroyARCFOUR( m_aCipher ); @@ -10938,16 +10938,16 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit& rObject ) sal_Int32 nFunctionObject = createObject(); CHECK_RETURN( updateObject( nFunctionObject ) ); - VirtualDevice aDev; - aDev.SetOutputSizePixel( rObject.m_aSize ); - aDev.SetMapMode( MapMode( MAP_PIXEL ) ); + ScopedVclPtr aDev = new VirtualDevice; + aDev->SetOutputSizePixel( rObject.m_aSize ); + aDev->SetMapMode( MapMode( MAP_PIXEL ) ); if( m_aContext.ColorMode == PDFWriter::DrawGreyscale ) - aDev.SetDrawMode( aDev.GetDrawMode() | + aDev->SetDrawMode( aDev->GetDrawMode() | ( DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_GRAYTEXT | DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT ) ); - aDev.DrawGradient( Rectangle( Point( 0, 0 ), rObject.m_aSize ), rObject.m_aGradient ); + aDev->DrawGradient( Rectangle( Point( 0, 0 ), rObject.m_aSize ), rObject.m_aGradient ); - Bitmap aSample = aDev.GetBitmap( Point( 0, 0 ), rObject.m_aSize ); + Bitmap aSample = aDev->GetBitmap( Point( 0, 0 ), rObject.m_aSize ); BitmapReadAccess* pAccess = aSample.AcquireReadAccess(); AccessReleaser aReleaser( pAccess ); diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index 1f2ac6b1558a..60e12f58786b 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -590,7 +590,7 @@ public: private: static const BuiltinFont m_aBuiltinFonts[14]; - OutputDevice* m_pReferenceDevice; + VclPtr m_pReferenceDevice; MapMode m_aMapMode; // PDFWriterImpl scaled units std::vector< PDFPage > m_aPages; diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index 1bcd5cf5fe8c..c632f29197c9 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -244,7 +244,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa { bool bAssertionFired( false ); - std::unique_ptr xPrivateDevice; + ScopedVclPtr xPrivateDevice; if( ! pDummyVDev ) { xPrivateDevice.reset(new VirtualDevice()); @@ -431,7 +431,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa if ( nPixelX && nPixelY ) { Size aDstSizePixel( nPixelX, nPixelY ); - std::unique_ptr xVDev(new VirtualDevice); + ScopedVclPtr xVDev(new VirtualDevice); if( xVDev->SetOutputSizePixel( aDstSizePixel ) ) { Bitmap aPaint, aMask; diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 658363dff292..7ba564581514 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -1014,6 +1014,11 @@ Printer::Printer( const OUString& rPrinterName ) } Printer::~Printer() +{ + disposeOnce(); +} + +void Printer::dispose() { DBG_ASSERT( !IsPrinting(), "Printer::~Printer() - Job is printing" ); DBG_ASSERT( !IsJobActive(), "Printer::~Printer() - Job is active" ); @@ -1024,7 +1029,7 @@ Printer::~Printer() if ( mpInfoPrinter ) ImplGetSVData()->mpDefInst->DestroyInfoPrinter( mpInfoPrinter ); if ( mpDisplayDev ) - delete mpDisplayDev; + mpDisplayDev.disposeAndClear(); else { // OutputDevice Dtor is tryig the same thing; that why we need to set @@ -1060,6 +1065,10 @@ Printer::~Printer() mpNext->mpPrev = mpPrev; else pSVData->maGDIData.mpLastPrinter = mpPrev; + + mpPrev.disposeAndClear(); + mpNext.disposeAndClear(); + OutputDevice::dispose(); } sal_uLong Printer::GetCapabilities( sal_uInt16 nType ) const @@ -1215,8 +1224,7 @@ bool Printer::SetPrinterProps( const Printer* pPrinter ) ReleaseGraphics(); if ( mpDisplayDev ) { - delete mpDisplayDev; - mpDisplayDev = NULL; + mpDisplayDev.disposeAndClear(); } else { diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index 76a471b45d99..5a556c42e218 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -728,10 +728,10 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, ConnectedComponents aBackgroundComponent; // create an OutputDevice to record mapmode changes and the like - VirtualDevice aMapModeVDev; - aMapModeVDev.mnDPIX = mnDPIX; - aMapModeVDev.mnDPIY = mnDPIY; - aMapModeVDev.EnableOutput(false); + ScopedVclPtr aMapModeVDev = new VirtualDevice; + aMapModeVDev->mnDPIX = mnDPIX; + aMapModeVDev->mnDPIY = mnDPIY; + aMapModeVDev->EnableOutput(false); int nLastBgAction, nActionNum; @@ -766,7 +766,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, aBackgroundComponent.aBounds, aBackgroundComponent.aBgColor, static_cast(pCurrAct)->GetRect(), - aMapModeVDev) ) + *aMapModeVDev.get()) ) bStillBackground=false; // incomplete occlusion of background else nLastBgAction=nActionNum; // this _is_ background @@ -782,7 +782,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, aBackgroundComponent.aBounds, aBackgroundComponent.aBgColor, aPoly.GetBoundRect(), - aMapModeVDev) ) + *aMapModeVDev.get()) ) bStillBackground=false; // incomplete occlusion of background else nLastBgAction=nActionNum; // this _is_ background @@ -799,7 +799,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, aBackgroundComponent.aBounds, aBackgroundComponent.aBgColor, aPoly.GetBoundRect(), - aMapModeVDev) ) + *aMapModeVDev.get()) ) bStillBackground=false; // incomplete occlusion of background else nLastBgAction=nActionNum; // this _is_ background @@ -811,7 +811,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, aBackgroundComponent.aBounds, aBackgroundComponent.aBgColor, static_cast(pCurrAct)->GetRect(), - aMapModeVDev) ) + *aMapModeVDev.get()) ) bStillBackground=false; // incomplete occlusion of background else nLastBgAction=nActionNum; // this _is_ background @@ -820,29 +820,29 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, default: { if( ImplIsNotTransparent( *pCurrAct, - aMapModeVDev ) ) + *aMapModeVDev.get() ) ) bStillBackground=false; // non-transparent action, possibly // not uniform else // extend current bounds (next uniform action // needs to fully cover this area) aBackgroundComponent.aBounds.Union( - ImplCalcActionBounds(*pCurrAct, aMapModeVDev) ); + ImplCalcActionBounds(*pCurrAct, *aMapModeVDev.get()) ); break; } } // execute action to get correct MapModes etc. - pCurrAct->Execute( &aMapModeVDev ); + pCurrAct->Execute( aMapModeVDev.get() ); pCurrAct=const_cast(rInMtf).NextAction(); ++nActionNum; } // clean up aMapModeVDev - sal_uInt32 nCount = aMapModeVDev.GetGCStackDepth(); + sal_uInt32 nCount = aMapModeVDev->GetGCStackDepth(); while( nCount-- ) - aMapModeVDev.Pop(); + aMapModeVDev->Pop(); ConnectedComponentsList aCCList; // list containing distinct sets of connected components as elements. @@ -859,7 +859,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, pCurrAct, nActionNum) ); // execute action to get correct MapModes etc. - pCurrAct->Execute( &aMapModeVDev ); + pCurrAct->Execute( aMapModeVDev.get() ); pCurrAct=const_cast(rInMtf).NextAction(); ++nActionNum; } @@ -873,10 +873,10 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, pCurrAct=const_cast(rInMtf).NextAction(), ++nActionNum ) { // execute action to get correct MapModes etc. - pCurrAct->Execute( &aMapModeVDev ); + pCurrAct->Execute( aMapModeVDev.get() ); // cache bounds of current action - const Rectangle aBBCurrAct( ImplCalcActionBounds(*pCurrAct, aMapModeVDev) ); + const Rectangle aBBCurrAct( ImplCalcActionBounds(*pCurrAct, *aMapModeVDev.get()) ); // accumulate collected bounds here, initialize with current action Rectangle aTotalBounds( aBBCurrAct ); // thus, @@ -902,7 +902,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, // not be considered for connected components, // too. Just put each of them into a separate // component. - aTotalComponents.bIsFullyTransparent = !ImplIsNotTransparent(*pCurrAct, aMapModeVDev); + aTotalComponents.bIsFullyTransparent = !ImplIsNotTransparent(*pCurrAct, *aMapModeVDev.get()); if( !aBBCurrAct.IsEmpty() && !aTotalComponents.bIsFullyTransparent ) @@ -1155,16 +1155,16 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, Point aDstPtPix( aBoundRect.TopLeft() ); Size aDstSzPix; - VirtualDevice aMapVDev; // here, we record only mapmode information - aMapVDev.EnableOutput(false); + ScopedVclPtr aMapVDev = new VirtualDevice; // here, we record only mapmode information + aMapVDev->EnableOutput(false); - VirtualDevice aPaintVDev; // into this one, we render. - aPaintVDev.SetBackground( aBackgroundComponent.aBgColor ); + ScopedVclPtr aPaintVDev = new VirtualDevice; // into this one, we render. + aPaintVDev->SetBackground( aBackgroundComponent.aBgColor ); rOutMtf.AddAction( new MetaPushAction( PushFlags::MAPMODE ) ); rOutMtf.AddAction( new MetaMapModeAction() ); - aPaintVDev.SetDrawMode( GetDrawMode() ); + aPaintVDev->SetDrawMode( GetDrawMode() ); while( aDstPtPix.Y() <= aBoundRect.Bottom() ) { @@ -1180,15 +1180,15 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, aDstSzPix.Width() = aBoundRect.Right() - aDstPtPix.X() + 1L; if( !Rectangle( aDstPtPix, aDstSzPix ).Intersection( aBoundRect ).IsEmpty() && - aPaintVDev.SetOutputSizePixel( aDstSzPix ) ) + aPaintVDev->SetOutputSizePixel( aDstSzPix ) ) { - aPaintVDev.Push(); - aMapVDev.Push(); + aPaintVDev->Push(); + aMapVDev->Push(); - aMapVDev.mnDPIX = aPaintVDev.mnDPIX = mnDPIX; - aMapVDev.mnDPIY = aPaintVDev.mnDPIY = mnDPIY; + aMapVDev->mnDPIX = aPaintVDev->mnDPIX = mnDPIX; + aMapVDev->mnDPIY = aPaintVDev->mnDPIY = mnDPIY; - aPaintVDev.EnableOutput(false); + aPaintVDev->EnableOutput(false); // iterate over all actions for( pCurrAct=const_cast(rInMtf).FirstAction(), nActionNum=0; @@ -1200,38 +1200,38 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, // the current aCCList element // (aCurr) if( aCCList_MemberMap[nActionNum] == &(*aCurr) ) - aPaintVDev.EnableOutput(true); + aPaintVDev->EnableOutput(true); // but process every action const sal_uInt16 nType( pCurrAct->GetType() ); if( META_MAPMODE_ACTION == nType ) { - pCurrAct->Execute( &aMapVDev ); + pCurrAct->Execute( aMapVDev.get() ); - MapMode aMtfMap( aMapVDev.GetMapMode() ); - const Point aNewOrg( aMapVDev.PixelToLogic( aDstPtPix ) ); + MapMode aMtfMap( aMapVDev->GetMapMode() ); + const Point aNewOrg( aMapVDev->PixelToLogic( aDstPtPix ) ); aMtfMap.SetOrigin( Point( -aNewOrg.X(), -aNewOrg.Y() ) ); - aPaintVDev.SetMapMode( aMtfMap ); + aPaintVDev->SetMapMode( aMtfMap ); } else if( ( META_PUSH_ACTION == nType ) || ( META_POP_ACTION ) == nType ) { - pCurrAct->Execute( &aMapVDev ); - pCurrAct->Execute( &aPaintVDev ); + pCurrAct->Execute( aMapVDev.get() ); + pCurrAct->Execute( aPaintVDev.get() ); } else if( META_GRADIENT_ACTION == nType ) { MetaGradientAction* pGradientAction = static_cast(pCurrAct); Printer* pPrinter = dynamic_cast< Printer* >(this); if( pPrinter ) - pPrinter->DrawGradientEx( &aPaintVDev, pGradientAction->GetRect(), pGradientAction->GetGradient() ); + pPrinter->DrawGradientEx( aPaintVDev.get(), pGradientAction->GetRect(), pGradientAction->GetGradient() ); else DrawGradient( pGradientAction->GetRect(), pGradientAction->GetGradient() ); } else { - pCurrAct->Execute( &aPaintVDev ); + pCurrAct->Execute( aPaintVDev.get() ); } if( !( nActionNum % 8 ) ) @@ -1239,9 +1239,9 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, } const bool bOldMap = mbMap; - mbMap = aPaintVDev.mbMap = false; + mbMap = aPaintVDev->mbMap = false; - Bitmap aBandBmp( aPaintVDev.GetBitmap( Point(), aDstSzPix ) ); + Bitmap aBandBmp( aPaintVDev->GetBitmap( Point(), aDstSzPix ) ); // scale down bitmap, if requested if( bDownsampleBitmaps ) @@ -1255,10 +1255,10 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, rOutMtf.AddAction( new MetaBmpScaleAction( aDstPtPix, aDstSzPix, aBandBmp ) ); rOutMtf.AddAction( new MetaCommentAction( "PRNSPOOL_TRANSPARENTBITMAP_END" ) ); - aPaintVDev.mbMap = true; + aPaintVDev->mbMap = true; mbMap = bOldMap; - aMapVDev.Pop(); - aPaintVDev.Pop(); + aMapVDev->Pop(); + aPaintVDev->Pop(); } // overlapping bands to avoid missing lines (e.g. PostScript) @@ -1276,9 +1276,9 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, } // clean up aMapModeVDev - nCount = aMapModeVDev.GetGCStackDepth(); + nCount = aMapModeVDev->GetGCStackDepth(); while( nCount-- ) - aMapModeVDev.Pop(); + aMapModeVDev->Pop(); // STAGE 4: Copy actions to output metafile @@ -1309,7 +1309,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, // given background color ImplConvertTransparentAction(rOutMtf, *pCurrAct, - aMapModeVDev, + *aMapModeVDev.get(), aBackgroundComponent.aBgColor); } else @@ -1318,7 +1318,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, rOutMtf.AddAction( ( pCurrAct->Duplicate(), pCurrAct ) ); } - pCurrAct->Execute(&aMapModeVDev); + pCurrAct->Execute(aMapModeVDev.get()); } } @@ -1335,7 +1335,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, else rOutMtf.AddAction( new MetaLineColorAction( COL_BLUE, true) ); - rOutMtf.AddAction( new MetaRectAction( aMapModeVDev.PixelToLogic( aCurr->aBounds ) ) ); + rOutMtf.AddAction( new MetaRectAction( aMapModeVDev->PixelToLogic( aCurr->aBounds ) ) ); } #endif } diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index b8ce392e1773..748eba0f46c1 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -400,8 +400,7 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, // #110958# Setup alpha bitmap if(mpAlphaVDev && mpAlphaVDev->GetOutputSizePixel() != rNewSize) { - delete mpAlphaVDev; - mpAlphaVDev = 0L; + mpAlphaVDev.disposeAndClear(); } if( !mpAlphaVDev ) diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 35ef02d1498a..711a64a61a94 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -410,11 +410,11 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const // If the visible part has been clipped, we have to create a // Bitmap with the correct size in which we copy the clipped // Bitmap to the correct position. - VirtualDevice aVDev( *this ); + ScopedVclPtr aVDev = new VirtualDevice( *this ); - if ( aVDev.SetOutputSizePixel( aRect.GetSize() ) ) + if ( aVDev->SetOutputSizePixel( aRect.GetSize() ) ) { - if ( ((OutputDevice*)&aVDev)->mpGraphics || ((OutputDevice*)&aVDev)->AcquireGraphics() ) + if ( ((OutputDevice*)aVDev.get())->mpGraphics || ((OutputDevice*)aVDev.get())->AcquireGraphics() ) { if ( (nWidth > 0) && (nHeight > 0) ) { @@ -422,14 +422,14 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const (aRect.Left() < mnOutOffX) ? (mnOutOffX - aRect.Left()) : 0L, (aRect.Top() < mnOutOffY) ? (mnOutOffY - aRect.Top()) : 0L, nWidth, nHeight); - (((OutputDevice*)&aVDev)->mpGraphics)->CopyBits( aPosAry, mpGraphics, this, this ); + (((OutputDevice*)aVDev.get())->mpGraphics)->CopyBits( aPosAry, mpGraphics, this, this ); } else { OSL_ENSURE(false, "CopyBits with negative width or height (!)"); } - aBmp = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() ); + aBmp = aVDev->GetBitmap( Point(), aVDev->GetOutputSizePixel() ); } else bClipped = false; diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index d39a76d5ce57..d0d35ce0d57f 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -215,7 +215,7 @@ void OutputDevice::dispose() mpUnoGraphicsList = NULL; } - delete mpOutDevData->mpRotateDev; + mpOutDevData->mpRotateDev.disposeAndClear(); // #i75163# ImplInvalidateViewTransform(); @@ -264,7 +264,7 @@ void OutputDevice::dispose() mpFontCollection = NULL; } - delete mpAlphaVDev; + mpAlphaVDev.disposeAndClear(); } SalGraphics* OutputDevice::GetGraphics() diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 0bd7914bd125..5628302684e3 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -2493,18 +2493,18 @@ bool OutputDevice::GetTextBoundRect( Rectangle& rRect, // fall back to bitmap method to get the bounding rectangle, // so we need a monochrome virtual device with matching font - VirtualDevice aVDev( 1 ); + ScopedVclPtr aVDev(new VirtualDevice( 1 )); vcl::Font aFont( GetFont() ); aFont.SetShadow( false ); aFont.SetOutline( false ); aFont.SetRelief( RELIEF_NONE ); aFont.SetOrientation( 0 ); aFont.SetSize( Size( mpFontEntry->maFontSelData.mnWidth, mpFontEntry->maFontSelData.mnHeight ) ); - aVDev.SetFont( aFont ); - aVDev.SetTextAlign( ALIGN_TOP ); + aVDev->SetFont( aFont ); + aVDev->SetTextAlign( ALIGN_TOP ); // layout the text on the virtual device - pSalLayout = aVDev.ImplLayout( rStr, nIndex, nLen, aPoint, nLayoutWidth, pDXAry ); + pSalLayout = aVDev->ImplLayout( rStr, nIndex, nLen, aPoint, nLayoutWidth, pDXAry ); if( !pSalLayout ) return false; @@ -2514,7 +2514,7 @@ bool OutputDevice::GetTextBoundRect( Rectangle& rRect, long nHeight = mpFontEntry->mnLineHeight + mnEmphasisAscent + mnEmphasisDescent; Point aOffset( nWidth/2, 8 ); Size aOutSize( nWidth + 2*aOffset.X(), nHeight + 2*aOffset.Y() ); - if( !nWidth || !aVDev.SetOutputSizePixel( aOutSize ) ) + if( !nWidth || !aVDev->SetOutputSizePixel( aOutSize ) ) { pSalLayout->Release(); return false; @@ -2522,14 +2522,14 @@ bool OutputDevice::GetTextBoundRect( Rectangle& rRect, // draw text in black pSalLayout->DrawBase() = aOffset; - aVDev.SetTextColor( Color( COL_BLACK ) ); - aVDev.SetTextFillColor(); - aVDev.ImplInitTextColor(); - aVDev.ImplDrawText( *pSalLayout ); + aVDev->SetTextColor( Color( COL_BLACK ) ); + aVDev->SetTextFillColor(); + aVDev->ImplInitTextColor(); + aVDev->ImplDrawText( *pSalLayout ); pSalLayout->Release(); // find extents using the bitmap - Bitmap aBmp = aVDev.GetBitmap( Point(), aOutSize ); + Bitmap aBmp = aVDev->GetBitmap( Point(), aOutSize ); BitmapReadAccess* pAcc = aBmp.AcquireReadAccess(); if( !pAcc ) return false; @@ -2717,7 +2717,7 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, + mnEmphasisDescent; pSalLayout->Release(); - VirtualDevice aVDev(1); + ScopedVclPtr aVDev(new VirtualDevice(1)); vcl::Font aFont(GetFont()); aFont.SetShadow(false); @@ -2727,14 +2727,14 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, if( bOptimize ) { aFont.SetSize( Size( 0, GLYPH_FONT_HEIGHT ) ); - aVDev.SetMapMode( MAP_PIXEL ); + aVDev->SetMapMode( MAP_PIXEL ); } - aVDev.SetFont( aFont ); - aVDev.SetTextAlign( ALIGN_TOP ); - aVDev.SetTextColor( Color(COL_BLACK) ); - aVDev.SetTextFillColor(); + aVDev->SetFont( aFont ); + aVDev->SetTextAlign( ALIGN_TOP ); + aVDev->SetTextColor( Color(COL_BLACK) ); + aVDev->SetTextFillColor(); - pSalLayout = aVDev.ImplLayout( rStr, nIndex, nLen, Point(0,0), nLayoutWidth, pDXArray ); + pSalLayout = aVDev->ImplLayout( rStr, nIndex, nLen, Point(0,0), nLayoutWidth, pDXArray ); if (pSalLayout == 0) return false; long nWidth = pSalLayout->GetTextWidth(); @@ -2754,7 +2754,7 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, { sal_Int32 nStart = ((nBase < nIndex) ? nBase : nIndex); sal_Int32 nLength = ((nBase > nIndex) ? nBase : nIndex) - nStart; - pSalLayout = aVDev.ImplLayout( rStr, nStart, nLength, Point(0,0), nLayoutWidth, pDXArray ); + pSalLayout = aVDev->ImplLayout( rStr, nStart, nLength, Point(0,0), nLayoutWidth, pDXArray ); if( pSalLayout ) { nXOffset = pSalLayout->GetTextWidth(); @@ -2775,25 +2775,25 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, bool bSuccess = false; // draw character into virtual device - pSalLayout = aVDev.ImplLayout( rStr, nCharPos, 1, Point(0,0), nLayoutWidth, pDXArray ); + pSalLayout = aVDev->ImplLayout( rStr, nCharPos, 1, Point(0,0), nLayoutWidth, pDXArray ); if (pSalLayout == 0) return false; long nCharWidth = pSalLayout->GetTextWidth(); Point aOffset(nCharWidth / 2, 8); Size aSize(nCharWidth + 2 * aOffset.X(), nHeight + 2 * aOffset.Y()); - bSuccess = (bool)aVDev.SetOutputSizePixel(aSize); + bSuccess = (bool)aVDev->SetOutputSizePixel(aSize); if( bSuccess ) { // draw glyph into virtual device - aVDev.Erase(); + aVDev->Erase(); pSalLayout->DrawBase() += aOffset; pSalLayout->DrawBase() += Point( ((OutputDevice*)&aVDev)->mnTextOffX, ((OutputDevice*)&aVDev)->mnTextOffY ); pSalLayout->DrawText( *((OutputDevice*)&aVDev)->mpGraphics ); pSalLayout->Release(); // convert character image into outline - Bitmap aBmp( aVDev.GetBitmap(Point(0, 0), aSize)); + Bitmap aBmp( aVDev->GetBitmap(Point(0, 0), aSize)); tools::PolyPolygon aPolyPoly; bool bVectorized = aBmp.Vectorize(aPolyPoly, BMP_VECTORIZE_OUTER | BMP_VECTORIZE_REDUCE_EDGES); @@ -2809,8 +2809,8 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, { Point& rPt = rPoly[k]; rPt -= aOffset; - int nPixelX = rPt.X() - ((OutputDevice&)aVDev).mnTextOffX + nXOffset; - int nPixelY = rPt.Y() - ((OutputDevice&)aVDev).mnTextOffY; + int nPixelX = rPt.X() - ((OutputDevice*)aVDev.get())->mnTextOffX + nXOffset; + int nPixelY = rPt.Y() - ((OutputDevice*)aVDev.get())->mnTextOffY; rPt.X() = ImplDevicePixelToLogicWidth( nPixelX ); rPt.Y() = ImplDevicePixelToLogicHeight( nPixelY ); } diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx index fce446688a73..7cff08f96f76 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -116,7 +116,7 @@ sal_uInt16 OutputDevice::GetAlphaBitCount() const bool OutputDevice::HasAlpha() { - return mpAlphaVDev != NULL; + return mpAlphaVDev != nullptr; } void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask, @@ -431,25 +431,25 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly, if( !bDrawn ) { - VirtualDevice aVDev( *this, 1 ); + ScopedVclPtr aVDev = new VirtualDevice( *this, 1 ); const Size aDstSz( aDstRect.GetSize() ); const sal_uInt8 cTrans = (sal_uInt8) MinMax( FRound( nTransparencePercent * 2.55 ), 0, 255 ); if( aDstRect.Left() || aDstRect.Top() ) aPolyPoly.Move( -aDstRect.Left(), -aDstRect.Top() ); - if( aVDev.SetOutputSizePixel( aDstSz ) ) + if( aVDev->SetOutputSizePixel( aDstSz ) ) { const bool bOldMap = mbMap; EnableMapMode( false ); - aVDev.SetLineColor( COL_BLACK ); - aVDev.SetFillColor( COL_BLACK ); - aVDev.DrawPolyPolygon( aPolyPoly ); + aVDev->SetLineColor( COL_BLACK ); + aVDev->SetFillColor( COL_BLACK ); + aVDev->DrawPolyPolygon( aPolyPoly ); Bitmap aPaint( GetBitmap( aDstRect.TopLeft(), aDstSz ) ); - Bitmap aPolyMask( aVDev.GetBitmap( Point(), aDstSz ) ); + Bitmap aPolyMask( aVDev->GetBitmap( Point(), aDstSz ) ); // #107766# check for non-empty bitmaps before accessing them if( !!aPaint && !!aPolyMask ) @@ -682,7 +682,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, if( !aDstRect.IsEmpty() ) { - std::unique_ptr xVDev(new VirtualDevice); + ScopedVclPtrInstance xVDev; ((OutputDevice*)xVDev.get())->mnDPIX = mnDPIX; ((OutputDevice*)xVDev.get())->mnDPIY = mnDPIY; diff --git a/vcl/source/outdev/wallpaper.cxx b/vcl/source/outdev/wallpaper.cxx index 8e4d86bc321f..87f4314a87cf 100644 --- a/vcl/source/outdev/wallpaper.cxx +++ b/vcl/source/outdev/wallpaper.cxx @@ -129,11 +129,11 @@ void OutputDevice::DrawBitmapWallpaper( long nX, long nY, { if( !pCached && !rWallpaper.GetColor().GetTransparency() ) { - VirtualDevice aVDev( *this ); - aVDev.SetBackground( rWallpaper.GetColor() ); - aVDev.SetOutputSizePixel( Size( nBmpWidth, nBmpHeight ) ); - aVDev.DrawBitmapEx( Point(), aBmpEx ); - aBmpEx = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() ); + ScopedVclPtr aVDev = new VirtualDevice( *this ); + aVDev->SetBackground( rWallpaper.GetColor() ); + aVDev->SetOutputSizePixel( Size( nBmpWidth, nBmpHeight ) ); + aVDev->DrawBitmapEx( Point(), aBmpEx ); + aBmpEx = aVDev->GetBitmap( Point(), aVDev->GetOutputSizePixel() ); } bDrawColorBackground = true; diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx index 127ece3a8f4f..c4d123f42cdb 100644 --- a/vcl/source/window/brdwin.cxx +++ b/vcl/source/window/brdwin.cxx @@ -1013,7 +1013,7 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHei vcl::Window *pWin = NULL, *pCtrl = NULL; if (mpOutDev->GetOutDevType() == OUTDEV_WINDOW) - pWin = static_cast(mpOutDev); + pWin = static_cast(mpOutDev.get()); if (pWin) pCtrl = mpBorderWindow->GetWindow(WINDOW_CLIENT); @@ -1188,7 +1188,7 @@ void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* // control this border belongs to vcl::Window *pWin = NULL, *pCtrl = NULL; if( mpOutDev->GetOutDevType() == OUTDEV_WINDOW ) - pWin = static_cast(mpOutDev); + pWin = static_cast(mpOutDev.get()); ControlType aCtrlType = 0; ControlPart aCtrlPart = PART_ENTIRE_CONTROL; @@ -1359,8 +1359,8 @@ ImplStdBorderWindowView::ImplStdBorderWindowView( ImplBorderWindow* pBorderWindo ImplStdBorderWindowView::~ImplStdBorderWindowView() { - delete mpATitleVirDev; - delete mpDTitleVirDev; + mpATitleVirDev.disposeAndClear(); + mpDTitleVirDev.disposeAndClear(); } bool ImplStdBorderWindowView::MouseMove( const MouseEvent& rMEvt ) @@ -1551,7 +1551,7 @@ long ImplStdBorderWindowView::CalcTitleWidth() const void ImplStdBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* pOutDev, const Point* pOffset ) { ImplBorderFrameData* pData = &maFrameData; - OutputDevice* pDev = pOutDev ? pOutDev : pData->mpOutDev; + OutputDevice* pDev = pOutDev ? pOutDev : pData->mpOutDev.get(); ImplBorderWindow* pBorderWindow = pData->mpBorderWindow; Point aTmpPoint = pOffset ? Point(*pOffset) : Point(); Rectangle aInRect( aTmpPoint, Size( pData->mnWidth, pData->mnHeight ) ); diff --git a/vcl/source/window/clipping.cxx b/vcl/source/window/clipping.cxx index 5fc94df0436a..0e11542000c4 100644 --- a/vcl/source/window/clipping.cxx +++ b/vcl/source/window/clipping.cxx @@ -863,8 +863,7 @@ void Window::ImplSaveOverlapBackground() } else { - delete mpWindowImpl->mpOverlapData->mpSaveBackDev; - mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL; + mpWindowImpl->mpOverlapData->mpSaveBackDev.disposeAndClear(); } } } @@ -915,8 +914,7 @@ void Window::ImplDeleteOverlapBackground() if ( mpWindowImpl->mpOverlapData->mpSaveBackDev ) { mpWindowImpl->mpFrameData->mnAllSaveBackSize -= mpWindowImpl->mpOverlapData->mnSaveBackSize; - delete mpWindowImpl->mpOverlapData->mpSaveBackDev; - mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL; + mpWindowImpl->mpOverlapData->mpSaveBackDev.disposeAndClear(); if ( mpWindowImpl->mpOverlapData->mpSaveBackRgn ) { delete mpWindowImpl->mpOverlapData->mpSaveBackRgn; diff --git a/vcl/source/window/decoview.cxx b/vcl/source/window/decoview.cxx index c04c430ceac3..5bb7b79cbb0e 100644 --- a/vcl/source/window/decoview.cxx +++ b/vcl/source/window/decoview.cxx @@ -1050,7 +1050,7 @@ void DecorationView::DrawSeparator( const Point& rStart, const Point& rStop, boo { Point aStart( rStart ), aStop( rStop ); const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings(); - vcl::Window *const pWin = (mpOutDev->GetOutDevType()==OUTDEV_WINDOW) ? static_cast(mpOutDev) : NULL; + vcl::Window *const pWin = (mpOutDev->GetOutDevType()==OUTDEV_WINDOW) ? static_cast(mpOutDev.get()) : NULL; if(pWin) { ControlPart nPart = ( bVertical ? PART_SEPARATOR_VERT : PART_SEPARATOR_HORZ ); diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx index a2bbfda232a7..0f05ded46af0 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -1094,7 +1094,7 @@ void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rP mpWindowImpl->mbReallyVisible = bRVisible; // paint metafile to VDev - VirtualDevice* pMaskedDevice = new VirtualDevice( *i_pTargetOutDev, 0, 0 ); + VclPtr pMaskedDevice = new VirtualDevice( *i_pTargetOutDev, 0, 0 ); pMaskedDevice->SetOutputSizePixel( GetOutputSizePixel() ); pMaskedDevice->EnableRTL( IsRTLEnabled() ); aMtf.WindStart(); @@ -1102,7 +1102,7 @@ void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rP BitmapEx aBmpEx( pMaskedDevice->GetBitmapEx( Point( 0, 0 ), pMaskedDevice->GetOutputSizePixel() ) ); i_pTargetOutDev->DrawBitmapEx( i_rPos, aBmpEx ); // get rid of virtual device now so they don't pile up during recursive calls - delete pMaskedDevice, pMaskedDevice = NULL; + pMaskedDevice.disposeAndClear(); for( vcl::Window* pChild = mpWindowImpl->mpFirstChild; pChild; pChild = pChild->mpWindowImpl->mpNext ) { diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index d9c89f05b4b1..4ab06b61049c 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -64,7 +64,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeShowNupOrderWindow(vcl PrintDialog::PrintPreviewWindow::PrintPreviewWindow( vcl::Window* i_pParent ) : Window( i_pParent, 0 ) , maOrigSize( 10, 10 ) - , maPageVDev( *this ) + , maPageVDev( new VirtualDevice(*this) ) , maToolTipString(VclResId( SV_PRINT_PRINTPREVIEW_TXT).toString()) , mbGreyscale( false ) , maHorzDim(new FixedLine(this, WB_HORZ | WB_CENTER)) @@ -72,7 +72,7 @@ PrintDialog::PrintPreviewWindow::PrintPreviewWindow( vcl::Window* i_pParent ) { SetPaintTransparent( true ); SetBackground(); - maPageVDev.SetBackground( Color( COL_WHITE ) ); + maPageVDev->SetBackground( Color( COL_WHITE ) ); maHorzDim->Show(); maVertDim->Show(); @@ -87,8 +87,9 @@ PrintDialog::PrintPreviewWindow::~PrintPreviewWindow() void PrintDialog::PrintPreviewWindow::dispose() { - maHorzDim.clear(); - maVertDim.clear(); + maHorzDim.disposeAndClear(); + maVertDim.disposeAndClear(); + maPageVDev.disposeAndClear(); Window::dispose(); } @@ -99,7 +100,7 @@ void PrintDialog::PrintPreviewWindow::DataChanged( const DataChangedEvent& i_rDC // react on settings changed if( i_rDCEvt.GetType() == DataChangedEventType::SETTINGS ) { - maPageVDev.SetBackground( Color( COL_WHITE ) ); + maPageVDev->SetBackground( Color( COL_WHITE ) ); } Window::DataChanged( i_rDCEvt ); } @@ -148,7 +149,7 @@ void PrintDialog::PrintPreviewWindow::Resize() aScaledSize.Width() = PREVIEW_BITMAP_WIDTH; aScaledSize.Height() = PREVIEW_BITMAP_WIDTH * aAspectRatio; - maPageVDev.SetOutputSizePixel( aScaledSize, false ); + maPageVDev->SetOutputSizePixel( aScaledSize, false ); // position dimension lines Point aRef( nTextHeight + (aNewSize.Width() - maPreviewSize.Width())/2, @@ -226,8 +227,8 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi maOrigSize = i_rOrigSize; maReplacementString = i_rReplacement; mbGreyscale = i_bGreyscale; - maPageVDev.SetReferenceDevice( i_nDPIX, i_nDPIY ); - maPageVDev.EnableOutput( true ); + maPageVDev->SetReferenceDevice( i_nDPIX, i_nDPIY ); + maPageVDev->EnableOutput( true ); // use correct measurements const LocaleDataWrapper& rLocWrap( GetSettings().GetLocaleDataWrapper() ); @@ -266,8 +267,8 @@ void PrintDialog::PrintPreviewWindow::preparePreviewBitmap() { GDIMetaFile aMtf( maMtf ); - Size aVDevSize( maPageVDev.GetOutputSizePixel() ); - const Size aLogicSize( maPageVDev.PixelToLogic( aVDevSize, MapMode( MAP_100TH_MM ) ) ); + Size aVDevSize( maPageVDev->GetOutputSizePixel() ); + const Size aLogicSize( maPageVDev->PixelToLogic( aVDevSize, MapMode( MAP_100TH_MM ) ) ); Size aOrigSize( maOrigSize ); if( aOrigSize.Width() < 1 ) aOrigSize.Width() = aLogicSize.Width(); @@ -275,31 +276,31 @@ void PrintDialog::PrintPreviewWindow::preparePreviewBitmap() aOrigSize.Height() = aLogicSize.Height(); double fScale = double(aLogicSize.Width())/double(aOrigSize.Width()); - maPageVDev.Erase(); - maPageVDev.Push(); - maPageVDev.SetMapMode( MAP_100TH_MM ); - sal_uLong nOldDrawMode = maPageVDev.GetDrawMode(); + maPageVDev->Erase(); + maPageVDev->Push(); + maPageVDev->SetMapMode( MAP_100TH_MM ); + sal_uLong nOldDrawMode = maPageVDev->GetDrawMode(); if( mbGreyscale ) - maPageVDev.SetDrawMode( maPageVDev.GetDrawMode() | + maPageVDev->SetDrawMode( maPageVDev->GetDrawMode() | ( DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_GRAYTEXT | DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT ) ); aMtf.WindStart(); aMtf.Scale( fScale, fScale ); aMtf.WindStart(); - const sal_uInt16 nOriginalAA(maPageVDev.GetAntialiasing()); - maPageVDev.SetAntialiasing(nOriginalAA | ANTIALIASING_ENABLE_B2DDRAW); - aMtf.Play( &maPageVDev, Point( 0, 0 ), aLogicSize ); - maPageVDev.SetAntialiasing(nOriginalAA); + const sal_uInt16 nOriginalAA(maPageVDev->GetAntialiasing()); + maPageVDev->SetAntialiasing(nOriginalAA | ANTIALIASING_ENABLE_B2DDRAW); + aMtf.Play( maPageVDev.get(), Point( 0, 0 ), aLogicSize ); + maPageVDev->SetAntialiasing(nOriginalAA); - maPageVDev.Pop(); + maPageVDev->Pop(); SetMapMode( MAP_PIXEL ); - maPageVDev.SetMapMode( MAP_PIXEL ); + maPageVDev->SetMapMode( MAP_PIXEL ); - maPreviewBitmap = Bitmap(maPageVDev.GetBitmap(Point(0, 0), aVDevSize)); + maPreviewBitmap = Bitmap(maPageVDev->GetBitmap(Point(0, 0), aVDevSize)); - maPageVDev.SetDrawMode( nOldDrawMode ); + maPageVDev->SetDrawMode( nOldDrawMode ); } PrintDialog::ShowNupOrderWindow::ShowNupOrderWindow( vcl::Window* i_pParent ) diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx index 95a6d4c20274..0cfbbaa5b4c8 100644 --- a/vcl/source/window/status.cxx +++ b/vcl/source/window/status.cxx @@ -45,7 +45,7 @@ public: ImplData(); ~ImplData(); - VirtualDevice* mpVirDev; + VclPtr mpVirDev; long mnItemBorderWidth; bool mbDrawItemFrames:1; }; @@ -163,7 +163,7 @@ void StatusBar::dispose() delete mpItemList; // delete VirtualDevice - delete mpImplData->mpVirDev; + mpImplData->mpVirDev.disposeAndClear(); delete mpImplData; Window::dispose(); } diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 2af94700afce..fffd6a8ecfca 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -497,6 +497,7 @@ void Window::dispose() // release SalGraphics OutputDevice *pOutDev = GetOutDev(); pOutDev->ReleaseGraphics(); + mpOutputDevice.disposeAndClear(); // notify ImplDelData subscribers of this window about the window deletion ImplDelData* pDelData = mpWindowImpl->mpFirstDel; -- cgit v1.2.3