[Libreoffice-commits] core.git: Branch 'feature/vclptr' - 11 commits - canvas/source chart2/source compilerplugins/clang cppcanvas/source desktop/source drawinglayer/source editeng/source include/editeng include/svtools include/svx include/toolkit include/vcl sc/inc sc/source sd/inc sd/source starmath/inc starmath/source svtools/source svx/source sw/inc sw/qa sw/source vcl/inc vcl/qa vcl/source vcl/workben

Michael Meeks michael.meeks at collabora.com
Fri Apr 10 04:08:08 PDT 2015


 canvas/source/vcl/backbuffer.cxx                             |   10 
 canvas/source/vcl/backbuffer.hxx                             |    3 
 canvas/source/vcl/bitmapbackbuffer.hxx                       |    2 
 canvas/source/vcl/impltools.hxx                              |    2 
 canvas/source/vcl/spritecanvashelper.cxx                     |   10 
 canvas/source/vcl/spritecanvashelper.hxx                     |    4 
 chart2/source/inc/chartview/DrawModelWrapper.hxx             |    2 
 chart2/source/view/main/DrawModelWrapper.cxx                 |    4 
 compilerplugins/clang/vclwidgets.cxx                         |  112 +++---
 cppcanvas/source/mtfrenderer/implrenderer.cxx                |   12 
 cppcanvas/source/mtfrenderer/transparencygroupaction.cxx     |   14 
 desktop/source/splash/splash.cxx                             |    4 
 drawinglayer/source/primitive2d/controlprimitive2d.cxx       |    8 
 drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx |   48 +-
 drawinglayer/source/primitive2d/textlayoutdevice.cxx         |    4 
 drawinglayer/source/processor2d/vclhelperbufferdevice.cxx    |    8 
 drawinglayer/source/processor2d/vclhelperbufferdevice.hxx    |    6 
 drawinglayer/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                           |   16 
 editeng/source/editeng/impedit2.cxx                          |    6 
 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/svx/sdrpaintwindow.hxx                               |    6 
 include/svx/svdmodel.hxx                                     |    4 
 include/svx/svdobj.hxx                                       |    3 
 include/svx/svdpntv.hxx                                      |    4 
 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/vclptr.hxx                                       |   48 ++
 include/vcl/virdev.hxx                                       |    4 
 include/vcl/window.hxx                                       |    2 
 sc/inc/document.hxx                                          |    4 
 sc/source/core/data/documen2.cxx                             |    4 
 sc/source/core/data/documen8.cxx                             |    6 
 sc/source/ui/dbgui/csvgrid.cxx                               |  136 ++++----
 sc/source/ui/docshell/sizedev.cxx                            |    2 
 sc/source/ui/inc/csvgrid.hxx                                 |    4 
 sc/source/ui/inc/output.hxx                                  |    6 
 sc/source/ui/inc/sizedev.hxx                                 |   12 
 sd/inc/sdmod.hxx                                             |    2 
 sd/source/ui/app/sdmod.cxx                                   |    2 
 sd/source/ui/docshell/docshel4.cxx                           |   14 
 sd/source/ui/docshell/docshell.cxx                           |    2 
 sd/source/ui/inc/DrawDocShell.hxx                            |    2 
 starmath/inc/document.hxx                                    |   12 
 starmath/source/document.cxx                                 |    6 
 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 
 svx/source/svdraw/sdrpaintwindow.cxx                         |   26 -
 svx/source/svdraw/svdedxv.cxx                                |    8 
 svx/source/svdraw/svdpntv.cxx                                |    4 
 svx/source/svdraw/svdview.cxx                                |   14 
 svx/source/unodraw/UnoGraphicExporter.cxx                    |   46 +-
 svx/source/unodraw/unoshape.cxx                              |    6 
 svx/source/xoutdev/_xoutbmp.cxx                              |   38 +-
 svx/source/xoutdev/xattrbmp.cxx                              |   24 -
 svx/source/xoutdev/xtabdash.cxx                              |   16 
 svx/source/xoutdev/xtabgrdt.cxx                              |   10 
 svx/source/xoutdev/xtabhtch.cxx                              |   16 
 svx/source/xoutdev/xtablend.cxx                              |   16 
 sw/inc/viewsh.hxx                                            |   14 
 sw/qa/tiledrendering/tiledrendering.cxx                      |    6 
 sw/source/core/doc/DocumentDeviceManager.cxx                 |   22 -
 sw/source/core/frmedt/fecopy.cxx                             |   18 -
 sw/source/core/inc/DocumentDeviceManager.hxx                 |    6 
 sw/source/core/layout/paintfrm.cxx                           |   14 
 sw/source/core/view/vnew.cxx                                 |    2 
 sw/source/filter/ww8/wrtww8gr.cxx                            |   12 
 vcl/inc/brdwin.hxx                                           |    8 
 vcl/inc/controldata.hxx                                      |    2 
 vcl/inc/outdev.h                                             |    3 
 vcl/inc/printdlg.hxx                                         |    2 
 vcl/inc/svdata.hxx                                           |   22 -
 vcl/inc/window.h                                             |    2 
 vcl/qa/cppunit/outdev.cxx                                    |   26 -
 vcl/source/app/svdata.cxx                                    |   10 
 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/outdevstate.cxx                            |    1 
 vcl/source/outdev/text.cxx                                   |   56 +--
 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/workben/vcldemo.cxx                                      |    5 
 140 files changed, 1147 insertions(+), 1037 deletions(-)

New commits:
commit 057347dad41f7df3222cc483fdff83fa631606bb
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Mar 19 14:38:23 2015 +0000

    Fix OutputDevice members / stack allocation.
    
    Change-Id: Ie57434607b61085a882af40b63d6a4b7aac0d4d3

diff --git a/canvas/source/vcl/spritecanvashelper.cxx b/canvas/source/vcl/spritecanvashelper.cxx
index 8855dd5..51a234f 100644
--- a/canvas/source/vcl/spritecanvashelper.cxx
+++ b/canvas/source/vcl/spritecanvashelper.cxx
@@ -324,7 +324,7 @@ namespace vclcanvas
             mpRedrawManager->forEachSprite(
                 ::boost::bind(
                     &spriteRedraw,
-                    ::boost::ref( maVDev.get() ),
+                    ::boost::ref( *maVDev.get() ),
                     _1 ) );
 
             // flush to screen
@@ -582,7 +582,7 @@ namespace vclcanvas
         ::std::for_each( rSortedUpdateSprites.begin(),
                          rSortedUpdateSprites.end(),
                          ::boost::bind( &spriteRedrawStub2,
-                                        ::boost::ref( maVDev.get() ),
+                                        ::boost::ref( *maVDev.get() ),
                                         ::vcl::unotools::b2DPointFromPoint(
                                             aOutputPosition),
                                         _1 ) );
diff --git a/canvas/source/vcl/spritecanvashelper.hxx b/canvas/source/vcl/spritecanvashelper.hxx
index 0396217..a6b3c03 100644
--- a/canvas/source/vcl/spritecanvashelper.hxx
+++ b/canvas/source/vcl/spritecanvashelper.hxx
@@ -41,7 +41,7 @@ namespace vclcanvas
     {
     public:
         SpriteCanvasHelper();
-        ~SpriteCanvasHelper()
+        ~SpriteCanvasHelper();
 
         void init( const OutDevProviderSharedPtr& rOutDev,
                    SpriteCanvas&                  rOwningSpriteCanvas,
diff --git a/include/svx/sdrpaintwindow.hxx b/include/svx/sdrpaintwindow.hxx
index 3a1f1ef..d8f0918 100644
--- a/include/svx/sdrpaintwindow.hxx
+++ b/include/svx/sdrpaintwindow.hxx
@@ -50,10 +50,10 @@ PaintTransparentChildren(vcl::Window & rWindow, Rectangle const& rPixelRect);
 class SdrPreRenderDevice
 {
     // The original OutputDevice
-    OutputDevice&                                       mrOutputDevice;
+    OutputDevice&          mrOutputDevice;
 
     // The VirtualDevice for PreRendering
-    VirtualDevice                                       maPreRenderDevice;
+    VclPtr<VirtualDevice>  mpPreRenderDevice;
 
 public:
     explicit SdrPreRenderDevice(OutputDevice& rOriginal);
@@ -63,7 +63,7 @@ public:
     void OutputPreRenderDevice(const vcl::Region& rExpandedRegion);
 
     OutputDevice& GetOriginalOutputDevice() const { return mrOutputDevice; }
-    OutputDevice& GetPreRenderDevice() { return maPreRenderDevice; }
+    OutputDevice& GetPreRenderDevice() { return *mpPreRenderDevice.get(); }
 };
 
 
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 971c5b2..95019f2 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -24,6 +24,7 @@
 #include <com/sun/star/uno/Any.hxx>
 #include <cppuhelper/weakref.hxx>
 #include <rtl/ustring.hxx>
+#include <vcl/vclptr.hxx>
 #include <svl/lstner.hxx>
 #include <svl/poolitem.hxx>
 #include <svx/svdtypes.hxx>
@@ -174,7 +175,7 @@ class SVX_DLLPUBLIC SdrObjMacroHitRec
 public:
     Point                       aPos;
     Point                       aDownPos;
-    OutputDevice*               pOut;
+    VclPtr<OutputDevice>        pOut;
     const SetOfByte*            pVisiLayer;
     const SdrPageView*          pPageView;
     sal_uInt16                  nTol;
diff --git a/include/svx/svdpntv.hxx b/include/svx/svdpntv.hxx
index 0959f1c..49ecbe9 100644
--- a/include/svx/svdpntv.hxx
+++ b/include/svx/svdpntv.hxx
@@ -135,8 +135,8 @@ protected:
 #ifdef DBG_UTIL
     VclPtr<SdrItemBrowser>      pItemBrowser;
 #endif
-    const OutputDevice*         pActualOutDev; // Nur zum vergleichen
-    OutputDevice*               pDragWin;
+    VclPtr<OutputDevice>        pActualOutDev; // Nur zum vergleichen
+    VclPtr<OutputDevice>        pDragWin;
     SfxStyleSheet*              pDefaultStyleSheet;
 
     OUString                    aAktLayer;     // Aktueller Zeichenlayer
diff --git a/svx/source/svdraw/sdrpaintwindow.cxx b/svx/source/svdraw/sdrpaintwindow.cxx
index 22e4167..d9cfce3 100644
--- a/svx/source/svdraw/sdrpaintwindow.cxx
+++ b/svx/source/svdraw/sdrpaintwindow.cxx
@@ -113,31 +113,33 @@ void CandidateMgr::PaintTransparentChildren(vcl::Window & rWindow, Rectangle con
 }
 
 SdrPreRenderDevice::SdrPreRenderDevice(OutputDevice& rOriginal)
-:   mrOutputDevice(rOriginal)
+:   mrOutputDevice(rOriginal),
+    mpPreRenderDevice(new VirtualDevice())
 {
 }
 
 SdrPreRenderDevice::~SdrPreRenderDevice()
 {
+    mpPreRenderDevice.disposeAndClear();
 }
 
 void SdrPreRenderDevice::PreparePreRenderDevice()
 {
-    // compare size of maPreRenderDevice with size of visible area
-    if(maPreRenderDevice.GetOutputSizePixel() != mrOutputDevice.GetOutputSizePixel())
+    // compare size of mpPreRenderDevice with size of visible area
+    if(mpPreRenderDevice->GetOutputSizePixel() != mrOutputDevice.GetOutputSizePixel())
     {
-        maPreRenderDevice.SetOutputSizePixel(mrOutputDevice.GetOutputSizePixel());
+        mpPreRenderDevice->SetOutputSizePixel(mrOutputDevice.GetOutputSizePixel());
     }
 
     // Also compare the MapModes for zoom/scroll changes
-    if(maPreRenderDevice.GetMapMode() != mrOutputDevice.GetMapMode())
+    if(mpPreRenderDevice->GetMapMode() != mrOutputDevice.GetMapMode())
     {
-        maPreRenderDevice.SetMapMode(mrOutputDevice.GetMapMode());
+        mpPreRenderDevice->SetMapMode(mrOutputDevice.GetMapMode());
     }
 
     // #i29186#
-    maPreRenderDevice.SetDrawMode(mrOutputDevice.GetDrawMode());
-    maPreRenderDevice.SetSettings(mrOutputDevice.GetSettings());
+    mpPreRenderDevice->SetDrawMode(mrOutputDevice.GetDrawMode());
+    mpPreRenderDevice->SetSettings(mrOutputDevice.GetSettings());
 }
 
 void SdrPreRenderDevice::OutputPreRenderDevice(const vcl::Region& rExpandedRegion)
@@ -149,9 +151,9 @@ void SdrPreRenderDevice::OutputPreRenderDevice(const vcl::Region& rExpandedRegio
 
     // MapModes off
     bool bMapModeWasEnabledDest(mrOutputDevice.IsMapModeEnabled());
-    bool bMapModeWasEnabledSource(maPreRenderDevice.IsMapModeEnabled());
+    bool bMapModeWasEnabledSource(mpPreRenderDevice->IsMapModeEnabled());
     mrOutputDevice.EnableMapMode(false);
-    maPreRenderDevice.EnableMapMode(false);
+    mpPreRenderDevice->EnableMapMode(false);
 
     RectangleVector aRectangles;
     aRegionPixel.GetRegionRectangles(aRectangles);
@@ -165,7 +167,7 @@ void SdrPreRenderDevice::OutputPreRenderDevice(const vcl::Region& rExpandedRegio
         mrOutputDevice.DrawOutDev(
             aTopLeft, aSize,
             aTopLeft, aSize,
-            maPreRenderDevice);
+            *mpPreRenderDevice.get());
 
 #ifdef DBG_UTIL
         // #i74769#
@@ -186,7 +188,7 @@ void SdrPreRenderDevice::OutputPreRenderDevice(const vcl::Region& rExpandedRegio
     }
 
     mrOutputDevice.EnableMapMode(bMapModeWasEnabledDest);
-    maPreRenderDevice.EnableMapMode(bMapModeWasEnabledSource);
+    mpPreRenderDevice->EnableMapMode(bMapModeWasEnabledSource);
 }
 
 
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 660bb90..f46b07d 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1733,7 +1733,7 @@ void SdrObjEditView::ImpMacroUp(const Point& rUpPos)
         aHitRec.nTol=nMacroTol;
         aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
         aHitRec.pPageView=pMacroPV;
-        aHitRec.pOut=pMacroWin;
+        aHitRec.pOut=pMacroWin.get();
         pMacroObj->PaintMacro(*pMacroWin,Rectangle(),aHitRec);
         bMacroDown=false;
     }
@@ -1750,7 +1750,7 @@ void SdrObjEditView::ImpMacroDown(const Point& rDownPos)
         aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
         aHitRec.pPageView=pMacroPV;
         aHitRec.bDown=true;
-        aHitRec.pOut=pMacroWin;
+        aHitRec.pOut=pMacroWin.get();
         pMacroObj->PaintMacro(*pMacroWin,Rectangle(),aHitRec);
         bMacroDown=true;
     }
@@ -1766,7 +1766,7 @@ void SdrObjEditView::MovMacroObj(const Point& rPnt)
         aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
         aHitRec.pPageView=pMacroPV;
         aHitRec.bDown=bMacroDown;
-        aHitRec.pOut=pMacroWin;
+        aHitRec.pOut=pMacroWin.get();
         bool bDown=pMacroObj->IsMacroHit(aHitRec);
         if (bDown) ImpMacroDown(rPnt);
         else ImpMacroUp(rPnt);
@@ -1794,7 +1794,7 @@ bool SdrObjEditView::EndMacroObj()
         aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
         aHitRec.pPageView=pMacroPV;
         aHitRec.bDown=true;
-        aHitRec.pOut=pMacroWin;
+        aHitRec.pOut=pMacroWin.get();
         bool bRet=pMacroObj->DoMacro(aHitRec);
         pMacroObj=NULL;
         pMacroPV=NULL;
diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx
index 7ee54bf..f058b4e 100644
--- a/svx/source/svdraw/svdpntv.cxx
+++ b/svx/source/svdraw/svdpntv.cxx
@@ -406,7 +406,7 @@ sal_uInt16 SdrPaintView::ImpGetHitTolLogic(short nHitTol, const OutputDevice* pO
 
 void SdrPaintView::TheresNewMapMode()
 {
-    if (pActualOutDev!=NULL) {
+    if (pActualOutDev) {
         nHitTolLog=(sal_uInt16)pActualOutDev->PixelToLogic(Size(nHitTolPix,0)).Width();
         nMinMovLog=(sal_uInt16)pActualOutDev->PixelToLogic(Size(nMinMovPix,0)).Width();
     }
@@ -414,7 +414,7 @@ void SdrPaintView::TheresNewMapMode()
 
 void SdrPaintView::SetActualWin(const OutputDevice* pWin)
 {
-    pActualOutDev=pWin;
+    pActualOutDev = const_cast<OutputDevice *>(pWin);
     TheresNewMapMode();
 }
 
diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx
index 44cb7f0..e2dd8d4 100644
--- a/svx/source/svdraw/svdview.cxx
+++ b/svx/source/svdraw/svdview.cxx
@@ -488,7 +488,7 @@ SdrHitKind SdrView::PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) co
                 // we currently don't account for ticker text
                 if(pActualOutDev && pActualOutDev->GetOutDevType() == OUTDEV_WINDOW)
                 {
-                    OutlinerView aOLV(pOutliner, const_cast<vcl::Window*>(static_cast<const vcl::Window*>(pActualOutDev)));
+                    OutlinerView aOLV(pOutliner, const_cast<vcl::Window*>(static_cast<const vcl::Window*>(pActualOutDev.get())));
                     const EditView& aEV=aOLV.GetEditView();
                     const SvxFieldItem* pItem=aEV.GetField(aTemporaryTextRelativePosition);
                     if (pItem!=NULL) {
@@ -822,7 +822,7 @@ bool SdrView::DoMouseEvent(const SdrViewEvent& rVEvt)
                     if (eHit==SDRHIT_TEXTEDIT)
                     {
                         bool bRet2(pActualOutDev && OUTDEV_WINDOW == pActualOutDev->GetOutDevType() &&
-                            SdrBeginTextEdit(rVEvt.pObj, rVEvt.pPV, const_cast<vcl::Window*>(static_cast<const vcl::Window*>(pActualOutDev)), false, (SdrOutliner*)0L));
+                            SdrBeginTextEdit(rVEvt.pObj, rVEvt.pPV, const_cast<vcl::Window*>(static_cast<const vcl::Window*>(pActualOutDev.get())), false, (SdrOutliner*)0L));
 
                         if(bRet2)
                         {
@@ -906,7 +906,7 @@ bool SdrView::DoMouseEvent(const SdrViewEvent& rVEvt)
             } else bRet=BegCreateObj(aLogicPos);
         } break;
         case SDREVENT_BEGMACROOBJ: {
-            bRet=BegMacroObj(aLogicPos,nHitTolLog,rVEvt.pObj,rVEvt.pPV,const_cast<vcl::Window*>(static_cast<const vcl::Window*>(pActualOutDev)));
+            bRet=BegMacroObj(aLogicPos,nHitTolLog,rVEvt.pObj,rVEvt.pPV,const_cast<vcl::Window*>(static_cast<const vcl::Window*>(pActualOutDev.get())));
         } break;
         case SDREVENT_BEGTEXTEDIT: {
             if (!IsObjMarked(rVEvt.pObj)) {
@@ -915,7 +915,7 @@ bool SdrView::DoMouseEvent(const SdrViewEvent& rVEvt)
             }
 
             bRet = pActualOutDev && OUTDEV_WINDOW == pActualOutDev->GetOutDevType()&&
-                 SdrBeginTextEdit(rVEvt.pObj, rVEvt.pPV, const_cast<vcl::Window*>(static_cast<const vcl::Window*>(pActualOutDev)), false, (SdrOutliner*)0L);
+                 SdrBeginTextEdit(rVEvt.pObj, rVEvt.pPV, const_cast<vcl::Window*>(static_cast<const vcl::Window*>(pActualOutDev.get())), false, (SdrOutliner*)0L);
 
             if(bRet)
             {
@@ -927,8 +927,8 @@ bool SdrView::DoMouseEvent(const SdrViewEvent& rVEvt)
         } break;
         default: break;
     } // switch
-    if (bRet && pActualOutDev!=NULL && pActualOutDev->GetOutDevType()==OUTDEV_WINDOW) {
-        vcl::Window* pWin=const_cast<vcl::Window*>(static_cast<const vcl::Window*>(pActualOutDev));
+    if (bRet && pActualOutDev && pActualOutDev->GetOutDevType()==OUTDEV_WINDOW) {
+        vcl::Window* pWin=const_cast<vcl::Window*>(static_cast<const vcl::Window*>(pActualOutDev.get()));
         // left mouse button pressed?
         bool bLeftDown=(rVEvt.nMouseCode&MOUSE_LEFT)!=0 && rVEvt.bMouseDown;
         // left mouse button released?
@@ -970,7 +970,7 @@ Pointer SdrView::GetPreferredPointer(const Point& rMousePos, const OutputDevice*
         aHitRec.nTol=nMacroTol;
         aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
         aHitRec.pPageView=pMacroPV;
-        aHitRec.pOut=pMacroWin;
+        aHitRec.pOut=pMacroWin.get();
         aHitRec.bDown=bMacroDown;
         return pMacroObj->GetMacroPointer(aHitRec);
     }
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx
index cc58203..9c10297 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -624,7 +624,7 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic,
     if( !pPage )
         return false;
 
-    VirtualDevice       aVDev;
+    ScopedVclPtr<VirtualDevice> aVDev( new VirtualDevice() );
     const MapMode       aMap( mpDoc->GetScaleUnit(), Point(), rSettings.maScaleX, rSettings.maScaleY );
 
     SdrOutliner& rOutl=mpDoc->GetDrawOutliner(NULL);
@@ -704,15 +704,15 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic,
                 boost::scoped_ptr< SdrView > pLocalView;
                 if( PTR_CAST( FmFormModel, mpDoc ) )
                 {
-                    pLocalView.reset( new FmFormView( PTR_CAST( FmFormModel, mpDoc ), &aVDev ) );
+                    pLocalView.reset( new FmFormView( PTR_CAST( FmFormModel, mpDoc ), aVDev ) );
                 }
                 else
                 {
-                    pLocalView.reset( new SdrView( mpDoc, &aVDev ) );
+                    pLocalView.reset( new SdrView( mpDoc, aVDev ) );
                 }
 
 
-                boost::scoped_ptr<VirtualDevice> pVDev(CreatePageVDev( pPage, nWidthPix, nHeightPix ));
+                ScopedVclPtr<VirtualDevice> pVDev(CreatePageVDev( pPage, nWidthPix, nHeightPix ));
 
                 if( pVDev )
                 {
@@ -726,22 +726,22 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic,
             {
                 GDIMetaFile aMtf;
 
-                aVDev.SetMapMode( aMap );
+                aVDev->SetMapMode( aMap );
                 if( rSettings.mbUseHighContrast )
-                    aVDev.SetDrawMode( aVDev.GetDrawMode() | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
-                aVDev.EnableOutput( false );
-                aMtf.Record( &aVDev );
+                    aVDev->SetDrawMode( aVDev->GetDrawMode() | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
+                aVDev->EnableOutput( false );
+                aMtf.Record( aVDev );
                 Size aNewSize;
 
                 // create a view
                 boost::scoped_ptr< SdrView > pView;
                 if( PTR_CAST( FmFormModel, mpDoc ) )
                 {
-                    pView.reset(new FmFormView( PTR_CAST( FmFormModel, mpDoc ), &aVDev ));
+                    pView.reset(new FmFormView( PTR_CAST( FmFormModel, mpDoc ), aVDev ));
                 }
                 else
                 {
-                    pView.reset(new SdrView( mpDoc, &aVDev ));
+                    pView.reset(new SdrView( mpDoc, aVDev ));
                 }
 
                 pView->SetBordVisible( false );
@@ -754,17 +754,17 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic,
                 const Rectangle aClipRect( aNewOrg, aNewSize );
                 MapMode         aVMap( aMap );
 
-                aVDev.Push();
+                aVDev->Push();
                 aVMap.SetOrigin( Point( -aNewOrg.X(), -aNewOrg.Y() ) );
-                aVDev.SetRelativeMapMode( aVMap );
-                aVDev.IntersectClipRegion( aClipRect );
+                aVDev->SetRelativeMapMode( aVMap );
+                aVDev->IntersectClipRegion( aClipRect );
 
                 // Use new StandardCheckVisisbilityRedirector
                 ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
 
-                pView->CompleteRedraw(&aVDev, vcl::Region(Rectangle(aNewOrg, aNewSize)), &aRedirector);
+                pView->CompleteRedraw(aVDev, vcl::Region(Rectangle(aNewOrg, aNewSize)), &aRedirector);
 
-                aVDev.Pop();
+                aVDev->Pop();
 
                 aMtf.Stop();
                 aMtf.WindStart();
@@ -907,7 +907,7 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic,
         if( !bSingleGraphic )
         {
             // create a metafile for all shapes
-            VirtualDevice   aOut;
+            ScopedVclPtr<VirtualDevice> aOut;
 
             // calculate bound rect for all shapes
             Rectangle aBound;
@@ -927,18 +927,18 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic,
                 }
             }
 
-            aOut.EnableOutput( false );
-            aOut.SetMapMode( aMap );
+            aOut->EnableOutput( false );
+            aOut->SetMapMode( aMap );
             if( rSettings.mbUseHighContrast )
-                aOut.SetDrawMode( aOut.GetDrawMode() | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
+                aOut->SetDrawMode( aOut->GetDrawMode() | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
 
             GDIMetaFile aMtf;
             aMtf.Clear();
-            aMtf.Record( &aOut );
+            aMtf.Record( aOut );
 
             MapMode aOutMap( aMap );
             aOutMap.SetOrigin( Point( -aBound.TopLeft().X(), -aBound.TopLeft().Y() ) );
-            aOut.SetRelativeMapMode( aOutMap );
+            aOut->SetRelativeMapMode( aOutMap );
 
             sdr::contact::DisplayInfo aDisplayInfo;
 
@@ -956,7 +956,7 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic,
             {
                 // more effective way to paint a vector of SdrObjects. Hand over the processed page
                 // to have it in the
-                sdr::contact::ObjectContactOfObjListPainter aMultiObjectPainter(aOut, aShapes, mpCurrentPage);
+                sdr::contact::ObjectContactOfObjListPainter aMultiObjectPainter(*aOut.get(), aShapes, mpCurrentPage);
                 ImplExportCheckVisisbilityRedirector aCheckVisibilityRedirector(mpCurrentPage);
                 aMultiObjectPainter.SetViewObjectContactRedirector(&aCheckVisibilityRedirector);
 
@@ -966,7 +966,7 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic,
             aMtf.Stop();
             aMtf.WindStart();
 
-            const Size  aExtSize( aOut.PixelToLogic( Size( 0, 0  ) ) );
+            const Size  aExtSize( aOut->PixelToLogic( Size( 0, 0  ) ) );
             Size        aBoundSize( aBound.GetWidth() + ( aExtSize.Width() ),
                                     aBound.GetHeight() + ( aExtSize.Height() ) );
 
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 58a3e7d..9c1981e 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -670,13 +670,13 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const
     if( !mpObj.is() || mpModel == NULL || !mpObj->IsInserted() || NULL == mpObj->GetPage() )
         return aAny;
 
-    VirtualDevice aVDev;
-    aVDev.SetMapMode(MapMode(MAP_100TH_MM));
+    ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
+    pVDev->SetMapMode(MapMode(MAP_100TH_MM));
 
     SdrModel* pModel = mpObj->GetModel();
     SdrPage* pPage = mpObj->GetPage();
 
-    boost::scoped_ptr<E3dView> pView(new E3dView( pModel, &aVDev ));
+    boost::scoped_ptr<E3dView> pView(new E3dView( pModel, pVDev.get() ));
     pView->hideMarkHandles();
     SdrPageView* pPageView = pView->ShowSdrPage(pPage);
 
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx
index 1f39734..5e4a7e7 100644
--- a/svx/source/xoutdev/_xoutbmp.cxx
+++ b/svx/source/xoutdev/_xoutbmp.cxx
@@ -250,27 +250,27 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileNam
                     {
                         if( pMtfSize_100TH_MM && ( rGraphic.GetType() != GRAPHIC_BITMAP ) )
                         {
-                            VirtualDevice aVDev;
-                            const Size    aSize( aVDev.LogicToPixel( *pMtfSize_100TH_MM, MAP_100TH_MM ) );
+                            ScopedVclPtr< VirtualDevice > pVDev(new VirtualDevice());
+                            const Size    aSize( pVDev->LogicToPixel( *pMtfSize_100TH_MM, MAP_100TH_MM ) );
 
-                            if( aVDev.SetOutputSizePixel( aSize ) )
+                            if( pVDev->SetOutputSizePixel( aSize ) )
                             {
-                                const Wallpaper aWallpaper( aVDev.GetBackground() );
+                                const Wallpaper aWallpaper( pVDev->GetBackground() );
                                 const Point     aPt;
 
-                                aVDev.SetBackground( Wallpaper( Color( COL_BLACK ) ) );
-                                aVDev.Erase();
-                                rGraphic.Draw( &aVDev, aPt, aSize );
+                                pVDev->SetBackground( Wallpaper( Color( COL_BLACK ) ) );
+                                pVDev->Erase();
+                                rGraphic.Draw( pVDev.get(), aPt, aSize );
 
-                                const Bitmap aBitmap( aVDev.GetBitmap( aPt, aSize ) );
+                                const Bitmap aBitmap( pVDev->GetBitmap( aPt, aSize ) );
 
-                                aVDev.SetBackground( aWallpaper );
-                                aVDev.Erase();
-                                rGraphic.Draw( &aVDev, aPt, aSize );
+                                pVDev->SetBackground( aWallpaper );
+                                pVDev->Erase();
+                                rGraphic.Draw( pVDev.get(), aPt, aSize );
 
-                                aVDev.SetRasterOp( ROP_XOR );
-                                aVDev.DrawBitmap( aPt, aSize, aBitmap );
-                                aGraphic = BitmapEx( aBitmap, aVDev.GetBitmap( aPt, aSize ) );
+                                pVDev->SetRasterOp( ROP_XOR );
+                                pVDev->DrawBitmap( aPt, aSize, aBitmap );
+                                aGraphic = BitmapEx( aBitmap, pVDev->GetBitmap( aPt, aSize ) );
                             }
                             else
                                 aGraphic = rGraphic.GetBitmapEx();
@@ -283,13 +283,13 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileNam
                 {
                     if( pMtfSize_100TH_MM && ( rGraphic.GetType() != GRAPHIC_BITMAP ) )
                     {
-                        VirtualDevice   aVDev;
-                        const Size      aSize( aVDev.LogicToPixel( *pMtfSize_100TH_MM, MAP_100TH_MM ) );
+                        ScopedVclPtr< VirtualDevice > pVDev(new VirtualDevice());
+                        const Size      aSize( pVDev->LogicToPixel( *pMtfSize_100TH_MM, MAP_100TH_MM ) );
 
-                        if( aVDev.SetOutputSizePixel( aSize ) )
+                        if( pVDev->SetOutputSizePixel( aSize ) )
                         {
-                            rGraphic.Draw( &aVDev, Point(), aSize );
-                            aGraphic =  aVDev.GetBitmap( Point(), aSize );
+                            rGraphic.Draw( pVDev.get(), Point(), aSize );
+                            aGraphic = pVDev->GetBitmap( Point(), aSize );
                         }
                         else
                             aGraphic = rGraphic.GetBitmap();
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index 0518bdd..cecfc7c 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -140,7 +140,7 @@ const GraphicObject& XOBitmap::GetGraphicObject() const
 
 void XOBitmap::Bitmap2Array()
 {
-    VirtualDevice   aVD;
+    ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
     bool            bPixelColor = false;
     const Bitmap    aBitmap( GetBitmap() );
     const sal_uInt16    nLines = 8; // type dependent
@@ -148,23 +148,23 @@ void XOBitmap::Bitmap2Array()
     if( !pPixelArray )
         pPixelArray = new sal_uInt16[ nLines * nLines ];
 
-    aVD.SetOutputSizePixel( aBitmap.GetSizePixel() );
-    aVD.DrawBitmap( Point(), aBitmap );
-    aPixelColor = aBckgrColor = aVD.GetPixel( Point() );
+    pVDev->SetOutputSizePixel( aBitmap.GetSizePixel() );
+    pVDev->DrawBitmap( Point(), aBitmap );
+    aPixelColor = aBckgrColor = pVDev->GetPixel( Point() );
 
     // create array and determine foreground and background color
     for( sal_uInt16 i = 0; i < nLines; i++ )
     {
         for( sal_uInt16 j = 0; j < nLines; j++ )
         {
-            if ( aVD.GetPixel( Point( j, i ) ) == aBckgrColor )
+            if ( pVDev->GetPixel( Point( j, i ) ) == aBckgrColor )
                 *( pPixelArray + j + i * nLines ) = 0;
             else
             {
                 *( pPixelArray + j + i * nLines ) = 1;
                 if( !bPixelColor )
                 {
-                    aPixelColor = aVD.GetPixel( Point( j, i ) );
+                    aPixelColor = pVDev->GetPixel( Point( j, i ) );
                     bPixelColor = true;
                 }
             }
@@ -175,13 +175,13 @@ void XOBitmap::Bitmap2Array()
 /// convert array, fore- and background color into a bitmap
 void XOBitmap::Array2Bitmap()
 {
-    VirtualDevice   aVD;
-    sal_uInt16          nLines = 8; // type dependent
+    ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
+    sal_uInt16 nLines = 8; // type dependent
 
     if( !pPixelArray )
         return;
 
-    aVD.SetOutputSizePixel( Size( nLines, nLines ) );
+    pVDev->SetOutputSizePixel( Size( nLines, nLines ) );
 
     // create bitmap
     for( sal_uInt16 i = 0; i < nLines; i++ )
@@ -189,13 +189,13 @@ void XOBitmap::Array2Bitmap()
         for( sal_uInt16 j = 0; j < nLines; j++ )
         {
             if( *( pPixelArray + j + i * nLines ) == 0 )
-                aVD.DrawPixel( Point( j, i ), aBckgrColor );
+                pVDev->DrawPixel( Point( j, i ), aBckgrColor );
             else
-                aVD.DrawPixel( Point( j, i ), aPixelColor );
+                pVDev->DrawPixel( Point( j, i ), aPixelColor );
         }
     }
 
-    aGraphicObject = GraphicObject( aVD.GetBitmap( Point(), Size( nLines, nLines ) ) );
+    aGraphicObject = GraphicObject( pVDev->GetBitmap( Point(), Size( nLines, nLines ) ) );
     bGraphicDirty = false;
 }
 
diff --git a/svx/source/xoutdev/xtabdash.cxx b/svx/source/xoutdev/xtabdash.cxx
index 129490a..07d02a1 100644
--- a/svx/source/xoutdev/xtabdash.cxx
+++ b/svx/source/xoutdev/xtabdash.cxx
@@ -135,11 +135,11 @@ Bitmap XDashList::ImpCreateBitmapForXDash(const XDash* pDash)
             aStrokeAttribute));
 
     // prepare VirtualDevice
-    VirtualDevice aVirtualDevice;
+    ScopedVclPtr< VirtualDevice > pVirtualDevice(new VirtualDevice());
     const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
 
-    aVirtualDevice.SetOutputSizePixel(aSize);
-    aVirtualDevice.SetDrawMode(rStyleSettings.GetHighContrastMode()
+    pVirtualDevice->SetOutputSizePixel(aSize);
+    pVirtualDevice->SetDrawMode(rStyleSettings.GetHighContrastMode()
         ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
         : DRAWMODE_DEFAULT);
 
@@ -150,17 +150,17 @@ Bitmap XDashList::ImpCreateBitmapForXDash(const XDash* pDash)
         static const Color aW(COL_WHITE);
         static const Color aG(0xef, 0xef, 0xef);
 
-        aVirtualDevice.DrawCheckered(aNull, aSize, nLen, aW, aG);
+        pVirtualDevice->DrawCheckered(aNull, aSize, nLen, aW, aG);
     }
     else
     {
-        aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor());
-        aVirtualDevice.Erase();
+        pVirtualDevice->SetBackground(rStyleSettings.GetFieldColor());
+        pVirtualDevice->Erase();
     }
 
     // create processor and draw primitives
     boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
-        aVirtualDevice,
+        *pVirtualDevice.get(),
         aNewViewInformation2D));
 
     if(pProcessor2D)
@@ -172,7 +172,7 @@ Bitmap XDashList::ImpCreateBitmapForXDash(const XDash* pDash)
     }
 
     // get result bitmap and scale
-    Bitmap aRetval(aVirtualDevice.GetBitmap(Point(0, 0), aVirtualDevice.GetOutputSizePixel()));
+    Bitmap aRetval(pVirtualDevice->GetBitmap(Point(0, 0), pVirtualDevice->GetOutputSizePixel()));
 
     if(1 != nFactor)
     {
diff --git a/svx/source/xoutdev/xtabgrdt.cxx b/svx/source/xoutdev/xtabgrdt.cxx
index f25a215..5607659 100644
--- a/svx/source/xoutdev/xtabgrdt.cxx
+++ b/svx/source/xoutdev/xtabgrdt.cxx
@@ -181,17 +181,17 @@ Bitmap XGradientList::CreateBitmapForUI( long nIndex )
                 aBlack));
 
         // prepare VirtualDevice
-        VirtualDevice aVirtualDevice;
+        ScopedVclPtr< VirtualDevice > pVirtualDevice(new VirtualDevice());
         const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
 
-        aVirtualDevice.SetOutputSizePixel(rSize);
-        aVirtualDevice.SetDrawMode(rStyleSettings.GetHighContrastMode()
+        pVirtualDevice->SetOutputSizePixel(rSize);
+        pVirtualDevice->SetDrawMode(rStyleSettings.GetHighContrastMode()
             ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
             : DRAWMODE_DEFAULT);
 
         // create processor and draw primitives
         boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
-            aVirtualDevice,
+            *pVirtualDevice.get(),
             aNewViewInformation2D));
 
         if(pProcessor2D)
@@ -206,7 +206,7 @@ Bitmap XGradientList::CreateBitmapForUI( long nIndex )
         }
 
         // get result bitmap and scale
-        aRetval = aVirtualDevice.GetBitmap(Point(0, 0), aVirtualDevice.GetOutputSizePixel());
+        aRetval = pVirtualDevice->GetBitmap(Point(0, 0), pVirtualDevice->GetOutputSizePixel());
     }
 
     return aRetval;
diff --git a/svx/source/xoutdev/xtabhtch.cxx b/svx/source/xoutdev/xtabhtch.cxx
index ba73c5c..5553476 100644
--- a/svx/source/xoutdev/xtabhtch.cxx
+++ b/svx/source/xoutdev/xtabhtch.cxx
@@ -142,11 +142,11 @@ Bitmap XHatchList::CreateBitmapForUI( long nIndex )
                 aBlack));
 
         // prepare VirtualDevice
-        VirtualDevice aVirtualDevice;
+        ScopedVclPtr< VirtualDevice > pVirtualDevice(new VirtualDevice());
         const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
 
-        aVirtualDevice.SetOutputSizePixel(rSize);
-        aVirtualDevice.SetDrawMode(rStyleSettings.GetHighContrastMode()
+        pVirtualDevice->SetOutputSizePixel(rSize);
+        pVirtualDevice->SetDrawMode(rStyleSettings.GetHighContrastMode()
             ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
             : DRAWMODE_DEFAULT);
 
@@ -156,17 +156,17 @@ Bitmap XHatchList::CreateBitmapForUI( long nIndex )
             static const sal_uInt32 nLen(8);
             static const Color aW(COL_WHITE);
             static const Color aG(0xef, 0xef, 0xef);
-            aVirtualDevice.DrawCheckered(aNull, rSize, nLen, aW, aG);
+            pVirtualDevice->DrawCheckered(aNull, rSize, nLen, aW, aG);
         }
         else
         {
-            aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor());
-            aVirtualDevice.Erase();
+            pVirtualDevice->SetBackground(rStyleSettings.GetFieldColor());
+            pVirtualDevice->Erase();
         }
 
         // create processor and draw primitives
         boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
-            aVirtualDevice,
+            *pVirtualDevice.get(),
             aNewViewInformation2D));
 
         if(pProcessor2D)
@@ -180,7 +180,7 @@ Bitmap XHatchList::CreateBitmapForUI( long nIndex )
         }
 
         // get result bitmap and scale
-        aRetval = aVirtualDevice.GetBitmap(Point(0, 0), aVirtualDevice.GetOutputSizePixel());
+        aRetval = pVirtualDevice->GetBitmap(Point(0, 0), pVirtualDevice->GetOutputSizePixel());
     }
 
     return aRetval;
diff --git a/svx/source/xoutdev/xtablend.cxx b/svx/source/xoutdev/xtablend.cxx
index cd4dae3..1c5b8a8 100644
--- a/svx/source/xoutdev/xtablend.cxx
+++ b/svx/source/xoutdev/xtablend.cxx
@@ -125,11 +125,11 @@ Bitmap XLineEndList::CreateBitmapForUI( long nIndex )
                 aLineStartEndAttribute));
 
         // prepare VirtualDevice
-        VirtualDevice aVirtualDevice;
+        ScopedVclPtr< VirtualDevice > pVirtualDevice(new VirtualDevice());
         const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
 
-        aVirtualDevice.SetOutputSizePixel(aSize);
-        aVirtualDevice.SetDrawMode(rStyleSettings.GetHighContrastMode()
+        pVirtualDevice->SetOutputSizePixel(aSize);
+        pVirtualDevice->SetDrawMode(rStyleSettings.GetHighContrastMode()
             ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
             : DRAWMODE_DEFAULT);
 
@@ -139,17 +139,17 @@ Bitmap XLineEndList::CreateBitmapForUI( long nIndex )
             static const sal_uInt32 nLen(8);
             static const Color aW(COL_WHITE);
             static const Color aG(0xef, 0xef, 0xef);
-            aVirtualDevice.DrawCheckered(aNull, aSize, nLen, aW, aG);
+            pVirtualDevice->DrawCheckered(aNull, aSize, nLen, aW, aG);
         }
         else
         {
-            aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor());
-            aVirtualDevice.Erase();
+            pVirtualDevice->SetBackground(rStyleSettings.GetFieldColor());
+            pVirtualDevice->Erase();
         }
 
         // create processor and draw primitives
         boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
-            aVirtualDevice,
+            *pVirtualDevice.get(),
             aNewViewInformation2D));
 
         if(pProcessor2D)
@@ -161,7 +161,7 @@ Bitmap XLineEndList::CreateBitmapForUI( long nIndex )
         }
 
         // get result bitmap and scale
-        aRetval = aVirtualDevice.GetBitmap(Point(0, 0), aVirtualDevice.GetOutputSizePixel());
+        aRetval = pVirtualDevice->GetBitmap(Point(0, 0), pVirtualDevice->GetOutputSizePixel());
     }
 
     return aRetval;
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 7ad04e5..610d963 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -125,12 +125,12 @@ class SW_DLLPUBLIC SwViewShell : public sw::Ring<SwViewShell>
     SwRect        maInvalidRect;
 
     SfxViewShell *mpSfxViewShell;
-    SwViewShellImp    *mpImp;             // Core-internals of SwViewShell.
-                                    // The pointer is never 0.
+    SwViewShellImp *mpImp;           // Core-internals of SwViewShell.
+                                     // The pointer is never 0.
 
-    VclPtr<::vcl::Window> mpWin;             ///< = 0 during printing or pdf export
-    OutputDevice *mpOut;              ///< Window, Printer, VirtDev, ...
-    OutputDevice* mpTmpRef;           // Temporariy reference device. Is used
+    VclPtr<::vcl::Window> mpWin;     ///< = 0 during printing or pdf export
+    VclPtr<OutputDevice>  mpOut;     ///< Window, Printer, VirtDev, ...
+    VclPtr<OutputDevice>  mpTmpRef;  // Temporariy reference device. Is used
                                      // during (printer depending) prospect
                                      // and page preview printing
                                      // (because a scaling has to be set at
@@ -161,7 +161,7 @@ class SW_DLLPUBLIC SwViewShell : public sw::Ring<SwViewShell>
     bool mbInConstructor:1;
 
     SdrPaintWindow*         mpTargetPaintWindow;
-    OutputDevice*           mpBufferedOut;
+    VclPtr<OutputDevice>    mpBufferedOut;
 
     SwRootFrmPtr            mpLayout;
 
@@ -236,7 +236,7 @@ public:
     // #i72754# set of Pre/PostPaints with lock counter and initial target OutDev
 protected:
     std::stack<vcl::Region> mPrePostPaintRegions; // acts also as a lock counter (empty == not locked)
-    OutputDevice*           mpPrePostOutDev;
+    VclPtr<OutputDevice>    mpPrePostOutDev;
     MapMode                 maPrePostMapMode;
 public:
     void PrePaint();
diff --git a/sw/qa/tiledrendering/tiledrendering.cxx b/sw/qa/tiledrendering/tiledrendering.cxx
index dfedd6b..c89d6f4 100644
--- a/sw/qa/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/tiledrendering/tiledrendering.cxx
@@ -131,13 +131,13 @@ IMPL_LINK ( TiledRenderingDialog, RenderHdl, Button *, EMPTYARG )
         // SystemGraphicsData aData;
         // [setup the aData]
         // VirtualDevice aDevice(&aData, [color depth]);
-        VirtualDevice aDevice;
+        ScopedVclPtr< VirtualDevice > pDevice(new VirtualDevice());
 
         // paint to it
-        pViewShell->PaintTile(aDevice, contextWidth, contextHeight, tilePosX, tilePosY, tileWidth, tileHeight);
+        pViewShell->PaintTile(*pDevice.get(), contextWidth, contextHeight, tilePosX, tilePosY, tileWidth, tileHeight);
 
         // copy the aDevice content to mpImage
-        Bitmap aBitmap(aDevice.GetBitmap(aDevice.PixelToLogic(Point(0,0)), aDevice.PixelToLogic(Size(contextWidth, contextHeight))));
+        Bitmap aBitmap(pDevice->GetBitmap(aDevice->PixelToLogic(Point(0,0)), pDevice->PixelToLogic(Size(contextWidth, contextHeight))));
         mpImage->SetImage(Image(aBitmap));
 
         // update the dialog size
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index 0e36a90..91ac529 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -1239,15 +1239,15 @@ bool SwFEShell::GetDrawObjGraphic( SotClipboardFormatId nFmt, Graphic& rGrf ) co
                             Point aPt;
                             GetGrfSize( aSz );
 
-                            VirtualDevice aVirtDev;
-                            aVirtDev.EnableOutput( false );
+                            ScopedVclPtr< VirtualDevice > pVirtDev(new VirtualDevice());
+                            pVirtDev->EnableOutput( false );
 
                             MapMode aTmp( GetWin()->GetMapMode() );
                             aTmp.SetOrigin( aPt );
-                            aVirtDev.SetMapMode( aTmp );
+                            pVirtDev->SetMapMode( aTmp );
 
                             GDIMetaFile aMtf;
-                            aMtf.Record( &aVirtDev );
+                            aMtf.Record( pVirtDev.get() );
                             aGrf.Draw( &aVirtDev, aPt, aSz );
                             aMtf.Stop();
                             aMtf.SetPrefMapMode( aTmp );
@@ -1266,14 +1266,14 @@ bool SwFEShell::GetDrawObjGraphic( SotClipboardFormatId nFmt, Graphic& rGrf ) co
                         // Otherwise it could happen that for vector graphics
                         // many MB's of memory are allocated.
                         const Size aSz( FindFlyFrm()->Prt().SSize() );
-                        VirtualDevice aVirtDev( *GetWin() );
+                        ScopedVclPtr< VirtualDevice > pVirtDev(new VirtualDevice(*GetWin()));
 
                         MapMode aTmp( MAP_TWIP );
-                        aVirtDev.SetMapMode( aTmp );
-                        if( aVirtDev.SetOutputSize( aSz ) )
+                        pVirtDev->SetMapMode( aTmp );
+                        if( pVirtDev->SetOutputSize( aSz ) )
                         {
-                            aGrf.Draw( &aVirtDev, Point(), aSz );
-                            rGrf = aVirtDev.GetBitmap( Point(), aSz );
+                            aGrf.Draw( pVirtDev.get(), Point(), aSz );
+                            rGrf = pVirtDev->GetBitmap( Point(), aSz );
                         }
                         else
                         {
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 2f129a3..00ce384 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -7640,21 +7640,21 @@ Graphic SwFlyFrmFmt::MakeGraphic( ImageMap* pMap )
         SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pFirst);
 
         OutputDevice *pOld = pSh->GetOut();
-        VirtualDevice aDev( *pOld );
-        aDev.EnableOutput( false );
+        ScopedVclPtr< VirtualDevice > pDev( new VirtualDevice( *pOld ) );
+        pDev->EnableOutput( false );
 
         GDIMetaFile aMet;
         MapMode aMap( pOld->GetMapMode().GetMapUnit() );
-        aDev.SetMapMode( aMap );
+        pDev->SetMapMode( aMap );
         aMet.SetPrefMapMode( aMap );
 
         ::SwCalcPixStatics( pSh->GetOut() );
         aMet.SetPrefSize( pFly->Frm().SSize() );
 
-        aMet.Record( &aDev );
-        aDev.SetLineColor();
-        aDev.SetFillColor();
-        aDev.SetFont( pOld->GetFont() );
+        aMet.Record( pDev.get() );
+        pDev->SetLineColor();
+        pDev->SetFillColor();
+        pDev->SetFont( pOld->GetFont() );
 
         //Enlarge the rectangle if needed, so the border is painted too.
         SwRect aOut( pFly->Frm() );
diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx
index 5fdaf05..cd7bd85 100644
--- a/sw/source/core/view/vnew.cxx
+++ b/sw/source/core/view/vnew.cxx
@@ -371,7 +371,7 @@ SwViewShell::~SwViewShell()
         }
     }
 
-    delete mpTmpRef;
+    mpTmpRef.disposeAndClear();
     delete mpAccOptions;
 }
 
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index 355ef9b..2d3db2b 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -726,9 +726,9 @@ void SwWW8WrGrf::WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rGrfNd,
             {
                 case GRAPHIC_BITMAP:        // Bitmap -> play in Metafile
                     {
-                        VirtualDevice aVirt;
-                        aMeta.Record(&aVirt);
-                        aVirt.DrawBitmap( Point( 0,0 ), rGrf.GetBitmap() );
+                        ScopedVclPtr< VirtualDevice > pVirt(new VirtualDevice());
+                        aMeta.Record(pVirt.get());
+                        pVirt->DrawBitmap( Point( 0,0 ), rGrf.GetBitmap() );
                         aMeta.Stop();
                         aMeta.WindStart();
                         aMeta.SetPrefMapMode( rGrf.GetPrefMapMode());
@@ -854,9 +854,9 @@ void SwWW8WrGrf::WriteGrfForBullet(SvStream& rStrm, const Graphic &rGrf, sal_uIn
         {
             case GRAPHIC_BITMAP:        // Bitmap -> in Metafile abspielen
             {
-                VirtualDevice aVirt;
-                aMeta.Record(&aVirt);
-                aVirt.DrawBitmap( Point( 0,0 ), rGrf.GetBitmap() );
+                ScopedVclPtr< VirtualDevice > pVirt(new VirtualDevice());
+                aMeta.Record(pVirt.get());
+                pVirt->DrawBitmap( Point( 0,0 ), rGrf.GetBitmap() );
                 aMeta.Stop();
                 aMeta.WindStart();
                 aMeta.SetPrefMapMode( rGrf.GetPrefMapMode());
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 23daa29..508d38f 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -945,7 +945,8 @@ public:
         BitmapEx AlphaRecovery(OutputDevice &rDev, Point aPt, BitmapEx &aSrc)
         {
             // Compositing onto 2x colors beyond our control
-            VirtualDevice aWhite, aBlack;
+            ScopedVclPtr< VirtualDevice > aWhite(new VirtualDevice());
+            ScopedVclPtr< VirtualDevice > aBlack(new VirtualDevice());
             aWhite.SetOutputSizePixel(aSrc.GetSizePixel());
             aWhite.SetBackground(Wallpaper(COL_WHITE));
             aWhite.Erase();
@@ -1503,7 +1504,7 @@ public:
         DrawWallpaper(aWholeSize, aWallpaper);
         Pop();
 
-        VirtualDevice aDev(*this);
+        ScopedVclPtr< VirtualDevice > aDev(new VirtualDevice(*this));
         aDev.EnableRTL(IsRTLEnabled());
         aDev.SetOutputSizePixel(aExclude.GetSize());
 
commit 7a2e0a335593bcd04caf5ba3fd7a9b0e2d933567
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Mar 19 13:56:13 2015 +0000

    ImplSVGDIData didn't dispose its contents previously; clobber it for now.
    
    Change-Id: I71c877773cbdabe10f617d1d3d7141ebd6d93923

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index fc285cd..d881a8e 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -153,6 +153,8 @@ struct ImplSVAppData
 
 struct ImplSVGDIData
 {
+    ~ImplSVGDIData();
+
     VclPtr<OutputDevice>    mpFirstWinGraphics;             // First OutputDevice with a Frame Graphics
     VclPtr<OutputDevice>    mpLastWinGraphics;              // Last OutputDevice with a Frame Graphics
     VclPtr<OutputDevice>    mpFirstVirGraphics;             // First OutputDevice with a VirtualDevice Graphics
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 887d082..bd33350 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -88,6 +88,14 @@ ImplSVData::ImplSVData()
     maNWFData.maMenuBarHighlightTextColor = Color( COL_TRANSPARENT );
 }
 
+ImplSVGDIData::~ImplSVGDIData()
+{
+    // FIXME: deliberately leak any remaining OutputDevice
+    // until we have their pGraphics reference counted, doing
+    // any disposes so late in shutdown is rather unsafe.
+    memset( this, 0, sizeof( ImplSVGDIData ) );
+}
+
 void ImplDeInitSVData()
 {
     ImplSVData* pSVData = ImplGetSVData();
commit 2177201e655767f6f15e9b44aedf7a4f99d2994a
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Mar 19 13:56:03 2015 +0000

    fix VirtualDevice unit test.
    
    Change-Id: I7a1f95ae1d8577114634c62aa89d3c7e1fde62c1

diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 6ee3593..4b1a446 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -32,17 +32,17 @@ public:
 
 void VclOutdevTest::testVirtualDevice()
 {
-    VirtualDevice aVDev;
-    aVDev.SetOutputSizePixel(Size(32,32));
-    aVDev.SetBackground(Wallpaper(COL_WHITE));
-    aVDev.Erase();
-    aVDev.DrawPixel(Point(1,2),COL_BLUE);
-    aVDev.DrawPixel(Point(31,30),COL_RED);
-
-    Size aSize = aVDev.GetOutputSizePixel();
+    ScopedVclPtr<VirtualDevice> pVDev( new VirtualDevice() );
+    pVDev->SetOutputSizePixel(Size(32,32));
+    pVDev->SetBackground(Wallpaper(COL_WHITE));
+    pVDev->Erase();
+    pVDev->DrawPixel(Point(1,2),COL_BLUE);
+    pVDev->DrawPixel(Point(31,30),COL_RED);
+
+    Size aSize = pVDev->GetOutputSizePixel();
     CPPUNIT_ASSERT(aSize == Size(32,32));
 
-    Bitmap aBmp = aVDev.GetBitmap(Point(),aSize);
+    Bitmap aBmp = pVDev->GetBitmap(Point(),aSize);
 
 #if 0
     OUString rFileName("/tmp/foo-unx.png");
@@ -56,12 +56,12 @@ void VclOutdevTest::testVirtualDevice()
     }
 #endif
 
-    CPPUNIT_ASSERT_EQUAL(COL_WHITE, aVDev.GetPixel(Point(0,0)).GetColor());
+    CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(0,0)).GetColor());
 #if defined LINUX //TODO: various failures on Mac and Windows tinderboxes
-    CPPUNIT_ASSERT_EQUAL(COL_BLUE, aVDev.GetPixel(Point(1,2)).GetColor());
-    CPPUNIT_ASSERT_EQUAL(COL_RED, aVDev.GetPixel(Point(31,30)).GetColor());
+    CPPUNIT_ASSERT_EQUAL(COL_BLUE, pVDev->GetPixel(Point(1,2)).GetColor());
+    CPPUNIT_ASSERT_EQUAL(COL_RED, pVDev->GetPixel(Point(31,30)).GetColor());
 #endif
-    CPPUNIT_ASSERT_EQUAL(COL_WHITE, aVDev.GetPixel(Point(30,31)).GetColor());
+    CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(30,31)).GetColor());
 
     // Gotcha: y and x swap for BitmapReadAccess: deep joy.
     Bitmap::ScopedReadAccess pAcc(aBmp);
commit a83de85dad1c296188a24ca046f483381deb0a61
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Mar 19 13:14:32 2015 +0000

    remove un-necessary type punning.
    
    Change-Id: I4f05929daa8b78b309d8a0498a2bb3246af9e18a

diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx
index a71c7d6..bc6bd4a 100644
--- a/vcl/source/outdev/outdevstate.cxx
+++ b/vcl/source/outdev/outdevstate.cxx
@@ -641,6 +641,7 @@ void OutputDevice::InitFillColor()
 void OutputDevice::ImplReleaseFonts()
 {
     mpGraphics->ReleaseFonts();
+
     mbNewFont = true;
     mbInitFont = true;
 
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 5628302..62a92f4 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -2738,8 +2738,8 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector,
     if (pSalLayout == 0)
         return false;
     long nWidth = pSalLayout->GetTextWidth();
-    long nHeight = ((OutputDevice*)&aVDev)->mpFontEntry->mnLineHeight + ((OutputDevice*)&aVDev)->mnEmphasisAscent
-        + ((OutputDevice*)&aVDev)->mnEmphasisDescent;
+    long nHeight = aVDev->mpFontEntry->mnLineHeight + aVDev->mnEmphasisAscent +
+                   aVDev->mnEmphasisDescent;
     pSalLayout->Release();
 
     if( !nWidth || !nHeight )
@@ -2788,8 +2788,8 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector,
             // draw glyph into virtual device
             aVDev->Erase();
             pSalLayout->DrawBase() += aOffset;
-            pSalLayout->DrawBase() += Point( ((OutputDevice*)&aVDev)->mnTextOffX, ((OutputDevice*)&aVDev)->mnTextOffY );
-            pSalLayout->DrawText( *((OutputDevice*)&aVDev)->mpGraphics );
+            pSalLayout->DrawBase() += Point( aVDev->mnTextOffX, aVDev->mnTextOffY );
+            pSalLayout->DrawText( *aVDev->mpGraphics );
             pSalLayout->Release();
 
             // convert character image into outline
commit 3a091f8ca2f20d44c32ef954e23f664256686997
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Mar 19 13:13:47 2015 +0000

    Unwind VCLObject bits for OutputDevice derivatives.
    
    Change-Id: I1abdf0a6d43029fb29e5cbc6c3f788aa98f55a1f

diff --git a/canvas/source/vcl/backbuffer.cxx b/canvas/source/vcl/backbuffer.cxx
index 73d6320..216b5eb 100644
--- a/canvas/source/vcl/backbuffer.cxx
+++ b/canvas/source/vcl/backbuffer.cxx
@@ -43,14 +43,20 @@ namespace vclcanvas
         }
     }
 
+    BackBuffer::~BackBuffer()
+    {
+        SolarMutexGuard aGuard;
+        maVDev.disposeAndClear();
+    }
+
     OutputDevice& BackBuffer::getOutDev()
     {
-        return maVDev.get();
+        return *maVDev.get();
     }
 
     const OutputDevice& BackBuffer::getOutDev() const
     {
-        return maVDev.get();
+        return *maVDev.get();
     }
 
     void BackBuffer::setSize( const ::Size& rNewSize )
diff --git a/canvas/source/vcl/backbuffer.hxx b/canvas/source/vcl/backbuffer.hxx
index 0fea559..479f4dd 100644
--- a/canvas/source/vcl/backbuffer.hxx
+++ b/canvas/source/vcl/backbuffer.hxx
@@ -43,6 +43,7 @@ namespace vclcanvas
          */
         BackBuffer( const OutputDevice& rRefDevice,
                     bool                bMonochromeBuffer=false );
+        ~BackBuffer();
 
         virtual OutputDevice&       getOutDev() SAL_OVERRIDE;
         virtual const OutputDevice& getOutDev() const SAL_OVERRIDE;
@@ -50,7 +51,7 @@ namespace vclcanvas
         void setSize( const ::Size& rNewSize );
 
     private:
-        ::canvas::vcltools::VCLObject<VirtualDevice>    maVDev;
+        VclPtr< VirtualDevice > maVDev;
     };
 
     typedef ::boost::shared_ptr< BackBuffer > BackBufferSharedPtr;
diff --git a/canvas/source/vcl/spritecanvashelper.cxx b/canvas/source/vcl/spritecanvashelper.cxx
index 6829505..8855dd5 100644
--- a/canvas/source/vcl/spritecanvashelper.cxx
+++ b/canvas/source/vcl/spritecanvashelper.cxx
@@ -189,6 +189,12 @@ namespace vclcanvas
 #endif
     }
 
+    SpriteCanvasHelper::~SpriteCanvasHelper()
+    {
+        SolarMutexGuard aGuard;
+        maVDev.disposeAndClear();
+    }
+
     void SpriteCanvasHelper::init( const OutDevProviderSharedPtr& rOutDev,
                                    SpriteCanvas&                  rOwningSpriteCanvas,
                                    ::canvas::SpriteRedrawManager& rManager,
diff --git a/canvas/source/vcl/spritecanvashelper.hxx b/canvas/source/vcl/spritecanvashelper.hxx
index dc165d4..0396217 100644
--- a/canvas/source/vcl/spritecanvashelper.hxx
+++ b/canvas/source/vcl/spritecanvashelper.hxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
 
+#include <vcl/vclptr.hxx>
 #include <vcl/virdev.hxx>
 
 #include <canvas/spriteredrawmanager.hxx>
@@ -40,6 +41,7 @@ namespace vclcanvas
     {
     public:
         SpriteCanvasHelper();
+        ~SpriteCanvasHelper()
 
         void init( const OutDevProviderSharedPtr& rOutDev,
                    SpriteCanvas&                  rOwningSpriteCanvas,
@@ -150,7 +152,7 @@ namespace vclcanvas
             Typically, sprites will be composited in the background,
             before pushing them to screen. This happens here.
          */
-        ::canvas::vcltools::VCLObject< VirtualDevice >  maVDev;
+        VclPtr< VirtualDevice > maVDev;
 
         /// For the frame counter timings
         ::canvas::tools::ElapsedTime                    maLastUpdate;
commit b5f08b336af03b78035d24114e78b7fdb98b8dce
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Mar 19 13:12:53 2015 +0000

    remove erroneous new disposeAndClear.
    
    Change-Id: Ib593f05447a8a657649ef83febb4ef0e5b6476dd

diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index fffd6a8..2af9470 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -497,7 +497,6 @@ 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;
commit 4ce5a6e2d51e40c13d8578efe05bd014382586d7
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Mar 19 12:12:46 2015 +0000

    compile fixes.
    
    Change-Id: I210c71c1a7236d286256a498f3f4f28f4185d052

diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx
index c273d2d..ffb8f4f 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -144,10 +144,8 @@ void DrawDocShell::SetPrinter(SfxPrinter *pNewPrinter)
             pView->SdrEndTextEdit();
     }
 
-    if ( mpPrinter && mbOwnPrinter && (mpPrinter != pNewPrinter) )
-    {
+    if ( mpPrinter && mbOwnPrinter && (mpPrinter.get() != pNewPrinter) )
         mpPrinter.disposeAndClear();
-    }
 
     mpPrinter = pNewPrinter;
     mbOwnPrinter = true;
@@ -221,7 +219,7 @@ void DrawDocShell::UpdateRefDevice()
                 // as a fall-back.
                 DBG_ASSERT(false, "DrawDocShell::UpdateRefDevice(): Unexpected printer layout mode");
 
-                pRefDevice = mpPrinter;
+                pRefDevice = mpPrinter.get();
                 break;
         }
         mpDoc->SetRefDevice( pRefDevice.get() );
commit 820576af4fd6441a752742b43d804e9837839925
Author: Noel Grandin <noel at peralex.com>
Date:   Thu Mar 19 13:54:12 2015 +0200

    start wrapping OutputDevice in VclPtr
    
    Change-Id: If3ecbb0599b50d50ce6b3997ca7892200c332ffe

diff --git a/canvas/source/vcl/bitmapbackbuffer.hxx b/canvas/source/vcl/bitmapbackbuffer.hxx
index c3f2a27..b518679 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<BitmapEx> maBitmap;
-        mutable VirtualDevice*                  mpVDev; // created only on demand
+        mutable VclPtr<VirtualDevice>           mpVDev; // created only on demand
 
         const OutputDevice&                     mrRefDevice;
 
diff --git a/canvas/source/vcl/impltools.hxx b/canvas/source/vcl/impltools.hxx
index 0594955..c294efd 100644
--- a/canvas/source/vcl/impltools.hxx
+++ b/canvas/source/vcl/impltools.hxx
@@ -158,7 +158,7 @@ namespace vclcanvas
                 }
             }
 
-            OutputDevice*       mpOutDev;
+            VclPtr<OutputDevice> mpOutDev;
             const bool          mbMappingWasEnabled;
             const sal_uInt16    mnAntiAliasing;
         };
diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx
index edc3a6e..3f38946 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<VirtualDevice> 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 fa91a85..74a9505 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<VirtualDevice> 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 d0eba20..fd55c1d 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<VirtualDevice> _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 b764e02..bb84b29 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<VirtualDevice> 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 ecf3bb2..1f6ee8d 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<VirtualDevice> aVirtualDevice(new VirtualDevice(*Application::GetDefaultDevice()));
+            ScopedVclPtr<VirtualDevice> 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 9196259..d34403d 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<VirtualDevice>               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 efa41c8..4c22ca4 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<VirtualDevice> > 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 02aa3c0..0ba7311 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<VirtualDevice>               mpContent;
+        VclPtr<VirtualDevice>               mpMask;
+        VclPtr<VirtualDevice>               mpAlpha;
         Rectangle                           maDestPixel;
 
     public:
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index 2b2c0b8..935b0b5 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<VirtualDevice> 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<VirtualDevice> 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 70de6a1..a527bb2 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.hxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.hxx
@@ -26,6 +26,7 @@
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <basegfx/color/bcolormodifier.hxx>
 #include <svtools/optionsdrawinglayer.hxx>
+#include <vcl/vclptr.hxx>
 
 
 // predefines
@@ -70,7 +71,7 @@ namespace drawinglayer
         {
         protected:
             // the destination OutDev
-            OutputDevice*                                           mpOutputDevice;
+            VclPtr<OutputDevice>                                    mpOutputDevice;
 
             // the modifiedColorPrimitive stack
             basegfx::BColorModifierStack                            maBColorModifierStack;
diff --git a/drawinglayer/source/tools/converters.cxx b/drawinglayer/source/tools/converters.cxx
index 188bfa9..e06356c 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<VirtualDevice> 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 21bdec0..d795c0f 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<VirtualDevice> 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<sal_Int32>& rList )
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index ac5db16..8e2dcb9 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<VirtualDevice> 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 e93edd4..da7e918 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<OutputDevice> 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 b973e64..b00cdce 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -29,6 +29,7 @@
 #include <tools/color.hxx>
 #include <tools/contnr.hxx>
 #include <vcl/graph.hxx>
+#include <vcl/outdev.hxx>
 #include <tools/link.hxx>
 #include <rsc/rscsfx.hxx>
 #include <editeng/editengdllapi.h>
@@ -475,7 +476,7 @@ struct EDITENG_DLLPUBLIC PaintFirstLineInfo
     long mnBaseLineY;
     const Point& mrOrigin;
     short mnOrientation;
-    OutputDevice* mpOutDev;
+    VclPtr<OutputDevice> 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 b115065..bfda380 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<VirtualDevice>   aVirDev;
     Size            aTxtSize;
     Color           aColor;
     Color           maPaintCol;
diff --git a/include/svtools/ctrltool.hxx b/include/svtools/ctrltool.hxx
index 23f07b0..3e51740 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<OutputDevice>    mpDev;
+    VclPtr<OutputDevice>    mpDev2;
     boost::ptr_vector<ImplFontListNameInfo> 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 c30062b..62d430a 100644
--- a/include/svtools/prnsetup.hxx
+++ b/include/svtools/prnsetup.hxx
@@ -47,9 +47,9 @@ private:
     VclPtr<FixedText>      m_pFiType;
     VclPtr<FixedText>      m_pFiLocation;
     VclPtr<FixedText>      m_pFiComment;
-    AutoTimer       maStatusTimer;
-    Printer*        mpPrinter;
-    Printer*        mpTempPrinter;
+    AutoTimer              maStatusTimer;
+    VclPtr<Printer>        mpPrinter;
+    VclPtr<Printer>        mpTempPrinter;
 
     SVT_DLLPRIVATE void         ImplSetInfo();
 
diff --git a/include/svtools/ruler.hxx b/include/svtools/ruler.hxx
index 9f2ba57..2f458c1 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<VirtualDevice>   maVirDev;
     MapMode         maMapMode;
     long            mnBorderOff;
     long            mnWinOff;
diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx
index 35f5b4a..a6a8e5e 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<VirtualDevice>   maVirDev;
     Timer           maTimer;
     ValueItemList   mItemList;
     ValueSetItemPtr mpNoneItem;
diff --git a/include/toolkit/awt/vclxgraphics.hxx b/include/toolkit/awt/vclxgraphics.hxx
index 627b675..89a568f 100644
--- a/include/toolkit/awt/vclxgraphics.hxx
+++ b/include/toolkit/awt/vclxgraphics.hxx
@@ -31,6 +31,7 @@
 #include <vcl/font.hxx>
 #include <tools/color.hxx>
 #include <vcl/vclenum.hxx>
+#include <vcl/vclptr.hxx>
 
 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<OutputDevice> mpOutputDevice;
     vcl::Font       maFont;
     Color           maTextColor;
     Color           maTextFillColor;
diff --git a/include/vcl/animate.hxx b/include/vcl/animate.hxx
index e966e3f..17d62a1 100644
--- a/include/vcl/animate.hxx
+++ b/include/vcl/animate.hxx
@@ -23,6 +23,7 @@
 #include <vcl/dllapi.h>
 #include <vcl/timer.hxx>
 #include <vcl/bitmapex.hxx>
+#include <vcl/vclptr.hxx>
 
 #define ANIMATION_TIMEOUT_ON_CLICK 2147483647L
 
@@ -108,17 +109,13 @@ struct AInfo
     Point           aLastSavePoint;
     Point           aStartOrg;
     Size            aStartSize;
-    OutputDevice*   pOutDev;
+    VclPtr<OutputDevice>   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 4094f69..2de96a5 100644
--- a/include/vcl/decoview.hxx
+++ b/include/vcl/decoview.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_VCL_DECOVIEW_HXX
 
 #include <vcl/dllapi.h>
+#include <vcl/vclptr.hxx>
 #include <rsc/rsc-vcl-shared-types.hxx>
 
 class Rectangle;
@@ -70,7 +71,7 @@ class OutputDevice;
 class VCL_DLLPUBLIC DecorationView
 {
 private:
-    OutputDevice*       mpOutDev;
+    VclPtr<OutputDevice>  mpOutDev;
 
 public:
     DecorationView(OutputDevice* pOutDev);
diff --git a/include/vcl/event.hxx b/include/vcl/event.hxx
index 22361a6..da38cfa 100644
--- a/include/vcl/event.hxx
+++ b/include/vcl/event.hxx
@@ -27,9 +27,9 @@
 #include <vcl/cmdevt.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/vclptr.hxx>
+#include <vcl/outdev.hxx>
 
 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<OutputDevice> mpOutDev;
     Rectangle           maOutRect;
     sal_uInt16          mnItemId;
     sal_uInt16          mnStyle;
diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx
index 05ab48a..e860dda4 100644
--- a/include/vcl/gdimtf.hxx
+++ b/include/vcl/gdimtf.hxx
@@ -25,6 +25,7 @@
 #include <tools/link.hxx>
 #include <vcl/mapmod.hxx>
 #include <vcl/bitmap.hxx>
+#include <vcl/vclptr.hxx>
 #include <vector>
 
 class OutputDevice;
@@ -80,7 +81,7 @@ private:
     Link            aHookHdlLink;
     GDIMetaFile*    pPrev;
     GDIMetaFile*    pNext;
-    OutputDevice*   pOutDev;
+    VclPtr<OutputDevice> pOutDev;
     bool            bPause;
     bool            bRecord;
     bool            bUseCanvas;
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index e53fc65..b9d542f 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<OutputDevice>    mpPrevGraphics;     ///< Previous output device in list
+    mutable VclPtr<OutputDevice>    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<VirtualDevice>           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 bf7ea47..be18fd0 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<Printer>             mpPrev;
+    VclPtr<Printer>             mpNext;
+    VclPtr<VirtualDevice>       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 5df2098..46161b5 100644
--- a/include/vcl/texteng.hxx
+++ b/include/vcl/texteng.hxx
@@ -20,6 +20,7 @@
 #define INCLUDED_VCL_TEXTENG_HXX
 
 #include <vcl/dllapi.h>
+#include <vcl/vclptr.hxx>
 
 class TextDoc;
 class TextView;
@@ -91,7 +92,7 @@ class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster
 private:
     TextDoc*            mpDoc;
     TEParaPortions*     mpTEParaPortions;
-    OutputDevice*       mpRefDev;
+    VclPtr<OutputDevice> mpRefDev;
 
     TextViews*          mpViews;
     TextView*           mpActiveView;
diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index 88f9fb6..3720a19 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<VirtualDevice>  mpPrev;
+    VclPtr<VirtualDevice>  mpNext;
     sal_uInt16          mnBitCount;
     bool                mbScreenComp;
     sal_Int8            mnAlphaDepth;
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 5dcfb35..0ee581a 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 c17497f..e5a8445 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<VirtualDevice>   pDDDev;
+    VclPtr<VirtualDevice>   pDDBufDev;
+    VclPtr<VirtualDevice>   pDDTempDev;
+    VclPtr<VirtualDevice>   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 0217577..2216348 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 );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list