[Libreoffice-commits] core.git: Branch 'feature/vclref' - compilerplugins/clang sd/source starmath/source sw/source

Noel Grandin noel at peralex.com
Fri Mar 20 05:59:55 PDT 2015


 compilerplugins/clang/vclwidgets.cxx                   |    2 
 sd/source/filter/eppt/pptx-text.cxx                    |    2 
 sd/source/ui/app/sdxfer.cxx                            |    2 
 sd/source/ui/inc/PreviewRenderer.hxx                   |    2 
 sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx     |    2 
 sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx |    2 
 sd/source/ui/view/DocumentRenderer.cxx                 |   10 +--
 sd/source/ui/view/drawview.cxx                         |    5 -
 starmath/source/unomodel.cxx                           |    4 -
 sw/source/core/inc/fntcache.hxx                        |    1 
 sw/source/core/text/itratr.cxx                         |    2 
 sw/source/core/txtnode/fntcache.cxx                    |   10 +--
 sw/source/core/view/viewsh.cxx                         |   20 +++---
 sw/source/ui/chrdlg/drpcps.cxx                         |    4 -
 sw/source/ui/config/optpage.cxx                        |    4 -
 sw/source/ui/dbui/mmoutputpage.cxx                     |    4 -
 sw/source/ui/envelp/labprt.cxx                         |    2 
 sw/source/ui/misc/outline.cxx                          |    2 
 sw/source/ui/table/tautofmt.cxx                        |   50 ++++++++---------
 sw/source/uibase/inc/swruler.hxx                       |    2 
 sw/source/uibase/misc/swruler.cxx                      |   38 ++++++------
 sw/source/uibase/uno/SwXDocumentSettings.cxx           |    8 +-
 22 files changed, 90 insertions(+), 88 deletions(-)

New commits:
commit ad890a5c2e25d8f71868f14825b9c73b5c6da87b
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Mar 20 14:59:22 2015 +0200

    wrap more stuff in VclPtr
    
    Change-Id: I2f0d8a4fe426d8ee1ac55a05ae8dd0b44f9aab2b

diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx
index 092770d..2c171d0 100644
--- a/compilerplugins/clang/vclwidgets.cxx
+++ b/compilerplugins/clang/vclwidgets.cxx
@@ -82,6 +82,8 @@ bool containsWindowSubclass(const Type* pType0);
 bool containsWindowSubclass(const QualType& qType) {
     if (startsWith(qType.getAsString(), "VclPtr"))
         return false;
+    if (startsWith(qType.getAsString(), "const VclPtr"))
+        return false;
     if (startsWith(qType.getAsString(), "class VclPtr"))
         return false;
     if (startsWith(qType.getAsString(), "const class VclPtr"))
diff --git a/sd/source/filter/eppt/pptx-text.cxx b/sd/source/filter/eppt/pptx-text.cxx
index 86bf44b..cacfcb6 100644
--- a/sd/source/filter/eppt/pptx-text.cxx
+++ b/sd/source/filter/eppt/pptx-text.cxx
@@ -1396,7 +1396,7 @@ void FontCollectionEntry::ImplInit( const OUString& rName )
 
 FontCollection::~FontCollection()
 {
-    delete pVDev;
+    pVDev.disposeAndClear();
     xPPTBreakIter = NULL;
 }
 
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index dda4f74..406fd1e 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -141,7 +141,7 @@ SdTransferable::~SdTransferable()
     delete mpBookmark;
     delete mpImageMap;
 
-    delete mpVDev;
+    mpVDev.disposeAndClear();
     delete mpObjDesc;
 
     //call explicitly at end of dtor to be covered by above SolarMutex
diff --git a/sd/source/ui/inc/PreviewRenderer.hxx b/sd/source/ui/inc/PreviewRenderer.hxx
index 5159184..0333ee0 100644
--- a/sd/source/ui/inc/PreviewRenderer.hxx
+++ b/sd/source/ui/inc/PreviewRenderer.hxx
@@ -126,7 +126,7 @@ protected:
     virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) SAL_OVERRIDE;
 
 private:
-    ::std::unique_ptr<VirtualDevice> mpPreviewDevice;
+    ScopedVclPtr<VirtualDevice> mpPreviewDevice;
     ::std::unique_ptr<DrawView> mpView;
     DrawDocShell* mpDocShellOfView;
     const Color maFrameColor;
diff --git a/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx b/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx
index 90156c5..7dde1cb 100644
--- a/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx
+++ b/sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx
@@ -75,7 +75,7 @@ private:
     VclPtr<sd::Window> mpTargetWindow;
     class LayerContainer;
     ::boost::scoped_ptr<LayerContainer> mpLayers;
-    ::boost::scoped_ptr<VirtualDevice> mpBackBuffer;
+    ScopedVclPtr<VirtualDevice> mpBackBuffer;
     MapMode maSavedMapMode;
 
     void RepaintRectangle (const Rectangle& rRepaintRectangle);
diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
index bb1d48e..1ac2ac0 100644
--- a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
+++ b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
@@ -160,7 +160,7 @@ Bitmap PageObjectPainter::CreateMarkedPreview (
     const BitmapEx& rOverlay,
     const OutputDevice* pReferenceDevice) const
 {
-    ::boost::scoped_ptr<VirtualDevice> pDevice;
+    ScopedVclPtr<VirtualDevice> pDevice;
     if (pReferenceDevice != NULL)
         pDevice.reset(new VirtualDevice(*pReferenceDevice));
     else
diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx
index 738ee95..b08f253 100644
--- a/sd/source/ui/view/DocumentRenderer.cxx
+++ b/sd/source/ui/view/DocumentRenderer.cxx
@@ -250,7 +250,7 @@ namespace {
     {
     public:
         PrintInfo (
-            const Printer* pPrinter,
+            Printer* pPrinter,
             const bool bPrintMarkedOnly)
             : mpPrinter(pPrinter),
               mnDrawMode(DRAWMODE_DEFAULT),
@@ -263,7 +263,7 @@ namespace {
               mbPrintMarkedOnly(bPrintMarkedOnly)
         {}
 
-        const Printer* mpPrinter;
+        const VclPtr<Printer> mpPrinter;
         sal_uLong mnDrawMode;
         OUString msTimeDate;
         OUString msPageString;
@@ -1332,7 +1332,7 @@ private:
     SfxObjectShellRef mxObjectShell; // destroying mpPrintView
     ViewShellBase& mrBase;
     bool mbIsDisposed;
-    Printer* mpPrinter;
+    VclPtr<Printer> mpPrinter;
     Size maPrinterPageSizePixel;
     ::boost::scoped_ptr<PrintOptions> mpOptions;
     ::std::vector< ::boost::shared_ptr< ::sd::PrinterPage> > maPrinterPages;
@@ -1420,7 +1420,7 @@ private:
 
         PrintInfo aInfo (mpPrinter, mpOptions->IsPrintMarkedOnly());
 
-        if (aInfo.mpPrinter!=NULL && pShell!=NULL)
+        if (aInfo.mpPrinter!=nullptr && pShell!=NULL)
         {
 
             MapMode aMap (aInfo.mpPrinter->GetMapMode());
@@ -1877,7 +1877,7 @@ private:
         const PageKind ePageKind,
         PrintInfo& rInfo)
     {
-        OSL_ASSERT(rInfo.mpPrinter != NULL);
+        OSL_ASSERT(rInfo.mpPrinter != nullptr);
 
         // Fill in page kind specific data.
         SdDrawDocument* pDocument = mrBase.GetMainViewShell()->GetDoc();
diff --git a/sd/source/ui/view/drawview.cxx b/sd/source/ui/view/drawview.cxx
index b2b2d782..05b2fc6 100644
--- a/sd/source/ui/view/drawview.cxx
+++ b/sd/source/ui/view/drawview.cxx
@@ -91,7 +91,7 @@ DrawView::DrawView( DrawDocShell* pDocSh, OutputDevice* pOutDev, DrawViewShell*
 
 DrawView::~DrawView()
 {
-    delete mpVDev;
+    mpVDev.disposeAndClear();
 }
 
 /**
@@ -459,8 +459,7 @@ void DrawView::CompleteRedraw(OutputDevice* pOutDev, const vcl::Region& rReg, sd
 {
     if( mpVDev )
     {
-        delete mpVDev;
-        mpVDev = NULL;
+        mpVDev.disposeAndClear();
     }
 
     bool bStandardPaint = true;
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 444aa6d..2cee1b3 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -621,11 +621,11 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any*
                         {
                             if ( !sPrinterName.isEmpty() )
                             {
-                                SfxPrinter *pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
+                                VclPtr<SfxPrinter> pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
                                 if (pNewPrinter->IsKnown())
                                     pDocSh->SetPrinter ( pNewPrinter );
                                 else
-                                    delete pNewPrinter;
+                                    pNewPrinter.disposeAndClear();
                             }
                         }
                         else
diff --git a/sw/source/core/inc/fntcache.hxx b/sw/source/core/inc/fntcache.hxx
index 28e4ffb..4790652 100644
--- a/sw/source/core/inc/fntcache.hxx
+++ b/sw/source/core/inc/fntcache.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SW_SOURCE_CORE_INC_FNTCACHE_HXX
 
 #include <vcl/font.hxx>
+#include <vcl/vclptr.hxx>
 #include <tools/mempool.hxx>
 #include "swtypes.hxx"
 #include "swcache.hxx"
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 58062ee..1c5cd17 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -339,7 +339,7 @@ sal_Int32 SwAttrIter::GetNextAttr( ) const
 class SwMinMaxArgs
 {
 public:
-    OutputDevice* pOut;
+    VclPtr<OutputDevice> pOut;
     SwViewShell const * pSh;
     sal_uLong &rMin;
     sal_uLong &rMax;
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index c504100..4e8ca04 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -67,7 +67,7 @@ Color *pWaveCol = 0;
 
 long SwFntObj::nPixWidth;
 MapMode* SwFntObj::pPixMap = NULL;
-OutputDevice* SwFntObj::pPixOut = NULL;
+VclPtr<OutputDevice> SwFntObj::pPixOut;
 
 namespace
 {
@@ -1377,7 +1377,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
         if ( pPrinter )
         {
             // pTmpFont has already been set as current font for rInf.GetOut()
-            if ( pPrinter != rInf.GetpOut() || pTmpFont != pPrtFont )
+            if ( pPrinter.get() != rInf.GetpOut() || pTmpFont != pPrtFont )
             {
                 if( !pPrtFont->IsSameInstance( pPrinter->GetFont() ) )
                     pPrinter->SetFont( *pPrtFont );
@@ -1862,7 +1862,7 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
 
     // This is the part used e.g., for cursor travelling
     // See condition for DrawText or DrawTextArray (bDirectPrint)
-    if ( pPrinter && pPrinter != rInf.GetpOut() )
+    if ( pPrinter && pPrinter.get() != rInf.GetpOut() )
     {
         if( !pPrtFont->IsSameInstance( pPrinter->GetFont() ) )
             pPrinter->SetFont(*pPrtFont);
@@ -2222,7 +2222,7 @@ SwFntAccess::SwFntAccess( const void* &rMagic,
                               ( !pFntObj->pPrinter || pFntObj->pPrinter == pOut ) ) )
             pFntObj = pFntCache->Next( pFntObj );
 
-        if( pFntObj && pFntObj->pPrinter != pOut )
+        if( pFntObj && pFntObj->pPrinter.get() != pOut )
         {
             // found one without printer, let's see if there is one with
             // the same printer as well
@@ -2247,7 +2247,7 @@ SwFntAccess::SwFntAccess( const void* &rMagic,
         else  // Font has been found, so we lock it.
         {
             pFntObj->Lock();
-            if (pFntObj->pPrinter != pOut) // if no printer is known by now
+            if (pFntObj->pPrinter.get() != pOut) // if no printer is known by now
             {
                 OSL_ENSURE( !pFntObj->pPrinter, "SwFntAccess: Printer Changed" );
                 pFntObj->CreatePrtFont( *pOut );
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index e0b2674..466f2433 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -304,7 +304,7 @@ void SwViewShell::ImplEndAction( const bool bIdleEnd )
 
                 pRegion->Compress();
 
-                VirtualDevice *pVout = 0;
+                VclPtr<VirtualDevice> pVout;
                 while ( !pRegion->empty() )
                 {
                     SwRect aRect( pRegion->back() );
@@ -357,7 +357,7 @@ void SwViewShell::ImplEndAction( const bool bIdleEnd )
                             aMapMode.SetOrigin( aOrigin );
                             pVout->SetMapMode( aMapMode );
 
-                            mpOut = pVout;
+                            mpOut = pVout.get();
                             if ( bPaintsFromSystem )
                                 PaintDesktop( aRect );
                             pCurrentLayout->Paint( aRect );
@@ -390,7 +390,7 @@ void SwViewShell::ImplEndAction( const bool bIdleEnd )
                     lcl_PaintTransparentFormControls(*this, aRect); // i#107365
                 }
 
-                delete pVout;
+                pVout.disposeAndClear();
                 delete pRegion;
                 Imp()->DelRegion();
             }
@@ -443,7 +443,7 @@ void SwViewShell::ImplUnlockPaint( bool bVirDev )
         if ( (bInSizeNotify || bVirDev ) && VisArea().HasArea() )
         {
             //Refresh with virtual device to avoid flickering.
-            VirtualDevice *pVout = new VirtualDevice( *mpOut );
+            VclPtr<VirtualDevice> pVout = new VirtualDevice( *mpOut );
             pVout->SetMapMode( mpOut->GetMapMode() );
             Size aSize( VisArea().SSize() );
             aSize.Width() += 20;
@@ -462,7 +462,7 @@ void SwViewShell::ImplUnlockPaint( bool bVirDev )
                 DLPrePaint2(aRepaintRegion);
 
                 OutputDevice *pOld = mpOut;
-                mpOut = pVout;
+                mpOut = pVout.get();
                 Paint( VisArea().SVRect() );
                 mpOut = pOld;
                 mpOut->DrawOutDev( VisArea().Pos(), aSize,
@@ -479,7 +479,7 @@ void SwViewShell::ImplUnlockPaint( bool bVirDev )
                 GetWin()->EnablePaint( true );
                 GetWin()->Invalidate( INVALIDATE_CHILDREN );
             }
-            delete pVout;
+            pVout.disposeAndClear();
         }
         else
         {
@@ -1176,7 +1176,7 @@ bool SwViewShell::SmoothScroll( long lXDiff, long lYDiff, const Rectangle *pRect
 
         //create virtual device and set.
         const Size aPixSz = GetWin()->PixelToLogic(Size(1,1));
-        VirtualDevice *pVout = new VirtualDevice( *GetWin() );
+        VclPtr<VirtualDevice> pVout = new VirtualDevice( *GetWin() );
         pVout->SetLineColor( GetWin()->GetLineColor() );
         pVout->SetFillColor( GetWin()->GetFillColor() );
         MapMode aMapMode( GetWin()->GetMapMode() );
@@ -1208,7 +1208,7 @@ bool SwViewShell::SmoothScroll( long lXDiff, long lYDiff, const Rectangle *pRect
             aMapMode.SetOrigin( aPt );
             pVout->SetMapMode( aMapMode );
             OutputDevice *pOld = mpOut;
-            mpOut = pVout;
+            mpOut = pVout.get();
 
             {
                 // #i75172# To get a clean repaint, a new ObjectContact is needed here. Without, the
@@ -1353,14 +1353,14 @@ bool SwViewShell::SmoothScroll( long lXDiff, long lYDiff, const Rectangle *pRect
                         --mnLockPaint;
                 }
             }
-            delete pVout;
+            pVout.disposeAndClear();
             GetWin()->Update();
             if ( !Imp()->bStopSmooth )
                 --mnLockPaint;
             SetFirstVisPageInvalid();
             return true;
         }
-        delete pVout;
+        pVout.disposeAndClear();
     }
 #endif
 
diff --git a/sw/source/ui/chrdlg/drpcps.cxx b/sw/source/ui/chrdlg/drpcps.cxx
index a3261c0..e347ca5 100644
--- a/sw/source/ui/chrdlg/drpcps.cxx
+++ b/sw/source/ui/chrdlg/drpcps.cxx
@@ -72,7 +72,7 @@ class SwDropCapsPict : public Control
     long            mnLineH;
     long            mnTextH;
     sal_uInt16      mnDistance;
-    Printer*        mpPrinter;
+    VclPtr<Printer> mpPrinter;
     bool            mbDelPrinter;
     /// The _ScriptInfo structure holds information on where we change from one
     /// script to another.
@@ -209,7 +209,7 @@ SwDropCapsPict::~SwDropCapsPict()
 void SwDropCapsPict::dispose()
 {
      if( mbDelPrinter )
-         delete mpPrinter;
+         mpPrinter.disposeAndClear();
      mpPage.disposeAndClear();
      Control::dispose();
 }
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index cdfd754..b64fb60 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -644,7 +644,7 @@ void SwStdFontTabPage::dispose()
     delete pFontList;
     if (bDeletePrinter)
     {
-        delete pPrt;
+        pPrt.disposeAndClear();
     }
     pLabelFT.disposeAndClear();
     pStandardBox.disposeAndClear();
@@ -840,7 +840,7 @@ void SwStdFontTabPage::Reset( const SfxItemSet* rSet)
 
     if (bDeletePrinter)
     {
-        delete pPrt;
+        pPrt.disposeAndClear();
     }
 
     if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_PRINTER, false, &pItem))
diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx
index 43df55f..4e29af3 100644
--- a/sw/source/ui/dbui/mmoutputpage.cxx
+++ b/sw/source/ui/dbui/mmoutputpage.cxx
@@ -312,7 +312,7 @@ SwMailMergeOutputPage::~SwMailMergeOutputPage()
 
 void SwMailMergeOutputPage::dispose()
 {
-    delete m_pTempPrinter;
+    m_pTempPrinter.disposeAndClear();
     m_pSaveStartDocRB.disposeAndClear();
     m_pSaveMergedDocRB.disposeAndClear();
     m_pPrintRB.disposeAndClear();
@@ -848,7 +848,7 @@ IMPL_LINK(SwMailMergeOutputPage, PrinterChangeHdl_Impl, ListBox*, pBox)
                 if( (m_pTempPrinter->GetName() != pInfo->GetPrinterName()) ||
                      (m_pTempPrinter->GetDriverName() != pInfo->GetDriver()) )
                 {
-                    delete m_pTempPrinter;
+                    m_pTempPrinter.disposeAndClear();
                     m_pTempPrinter = new Printer( *pInfo );
                 }
             }
diff --git a/sw/source/ui/envelp/labprt.cxx b/sw/source/ui/envelp/labprt.cxx
index d018db5..5f460ee 100644
--- a/sw/source/ui/envelp/labprt.cxx
+++ b/sw/source/ui/envelp/labprt.cxx
@@ -67,7 +67,7 @@ SwLabPrtPage::~SwLabPrtPage()
 
 void SwLabPrtPage::dispose()
 {
-    delete pPrinter;
+    pPrinter.disposeAndClear();
     m_pPageButton.disposeAndClear();
     m_pSingleButton.disposeAndClear();
     m_pSingleGrid.disposeAndClear();
diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx
index 3416710..38e5903 100644
--- a/sw/source/ui/misc/outline.cxx
+++ b/sw/source/ui/misc/outline.cxx
@@ -931,7 +931,7 @@ void NumberingPreview::Paint( const Rectangle& /*rRect*/ )
 {
     const Size aSize(PixelToLogic(GetOutputSizePixel()));
 
-    boost::scoped_ptr<VirtualDevice> pVDev(new VirtualDevice(*this));
+    ScopedVclPtr<VirtualDevice> pVDev(new VirtualDevice(*this));
     pVDev->SetMapMode(GetMapMode());
     pVDev->SetOutputSize( aSize );
 
diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx
index e3fbc07..4098ed0 100644
--- a/sw/source/ui/table/tautofmt.cxx
+++ b/sw/source/ui/table/tautofmt.cxx
@@ -61,7 +61,7 @@ protected:
 
 private:
     SwTableAutoFmt          aCurData;
-    VirtualDevice           aVD;
+    ScopedVclPtr<VirtualDevice> aVD;
     SvtScriptedTextHelper   aScriptedText;
     svx::frame::Array       maArray;            /// Implementation to draw the frame borders.
     bool                    bFitWidth;
@@ -517,8 +517,8 @@ IMPL_LINK_NOARG_INLINE_END(SwAutoFormatDlg, OkHdl)
 AutoFmtPreview::AutoFmtPreview(vcl::Window* pParent, WinBits nStyle) :
         Window          ( pParent, nStyle ),
         aCurData        ( OUString() ),
-        aVD             ( *this ),
-        aScriptedText   ( aVD ),
+        aVD             ( new VirtualDevice(*this) ),
+        aScriptedText   ( *aVD.get() ),
         bFitWidth       ( false ),
         mbRTL           ( false ),
         aStrJan         ( SW_RES( STR_JAN ) ),
@@ -796,11 +796,11 @@ void AutoFmtPreview::DrawBackground()
         {
             SvxBrushItem aBrushItem( aCurData.GetBoxFmt( GetFormatIndex( nCol, nRow ) ).GetBackground() );
 
-            aVD.Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
-            aVD.SetLineColor();
-            aVD.SetFillColor( aBrushItem.GetColor() );
-            aVD.DrawRect( maArray.GetCellRect( nCol, nRow ) );
-            aVD.Pop();
+            aVD->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
+            aVD->SetLineColor();
+            aVD->SetFillColor( aBrushItem.GetColor() );
+            aVD->DrawRect( maArray.GetCellRect( nCol, nRow ) );
+            aVD->Pop();
         }
     }
 }
@@ -816,7 +816,7 @@ void AutoFmtPreview::PaintCells()
 
     // 3) border
     if ( aCurData.IsFrame() )
-        maArray.DrawArray( aVD );
+        maArray.DrawArray( *aVD.get() );
 }
 
 void AutoFmtPreview::Init()
@@ -885,9 +885,9 @@ void AutoFmtPreview::NotifyChange( const SwTableAutoFmt& rNewData )
 
 void AutoFmtPreview::DoPaint( const Rectangle& /*rRect*/ )
 {
-    sal_uInt32 nOldDrawMode = aVD.GetDrawMode();
+    sal_uInt32 nOldDrawMode = aVD->GetDrawMode();
     if( GetSettings().GetStyleSettings().GetHighContrastMode() )
-        aVD.SetDrawMode( DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
+        aVD->SetDrawMode( DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
 
     Bitmap  thePreview;
     Point   aCenterPos;
@@ -895,36 +895,36 @@ void AutoFmtPreview::DoPaint( const Rectangle& /*rRect*/ )
     Color   oldColor;
     vcl::Font aFont;
 
-    aFont = aVD.GetFont();
+    aFont = aVD->GetFont();
     aFont.SetTransparent( true );
 
-    aVD.SetFont          ( aFont );
-    aVD.SetLineColor     ();
+    aVD->SetFont          ( aFont );
+    aVD->SetLineColor     ();
     const Color& rWinColor = GetSettings().GetStyleSettings().GetWindowColor();
-    aVD.SetBackground    ( Wallpaper(rWinColor) );
-    aVD.SetFillColor     ( rWinColor );
-    aVD.SetOutputSizePixel  ( aPrvSize );
+    aVD->SetBackground    ( Wallpaper(rWinColor) );
+    aVD->SetFillColor     ( rWinColor );
+    aVD->SetOutputSizePixel  ( aPrvSize );
 
     // Draw cells on virtual device
     // and save the result
     PaintCells();
-    thePreview = aVD.GetBitmap( Point(0,0), aPrvSize );
+    thePreview = aVD->GetBitmap( Point(0,0), aPrvSize );
 
     // Draw the Frame and center the preview:
     // (virtual Device for window output)
-    aVD.SetOutputSizePixel( theWndSize );
-    oldColor = aVD.GetLineColor();
-    aVD.SetLineColor();
-    aVD.DrawRect( Rectangle( Point(0,0), theWndSize ) );
+    aVD->SetOutputSizePixel( theWndSize );
+    oldColor = aVD->GetLineColor();
+    aVD->SetLineColor();
+    aVD->DrawRect( Rectangle( Point(0,0), theWndSize ) );
     SetLineColor( oldColor );
     aCenterPos  = Point( (theWndSize.Width()  - aPrvSize.Width() ) / 2,
                          (theWndSize.Height() - aPrvSize.Height()) / 2 );
-    aVD.DrawBitmap( aCenterPos, thePreview );
+    aVD->DrawBitmap( aCenterPos, thePreview );
 
     // Output in the preview window:
-    DrawBitmap( Point(0,0), aVD.GetBitmap( Point(0,0), theWndSize ) );
+    DrawBitmap( Point(0,0), aVD->GetBitmap( Point(0,0), theWndSize ) );
 
-    aVD.SetDrawMode( nOldDrawMode );
+    aVD->SetDrawMode( nOldDrawMode );
 }
 
 void AutoFmtPreview::Paint( const Rectangle& rRect )
diff --git a/sw/source/uibase/inc/swruler.hxx b/sw/source/uibase/inc/swruler.hxx
index 6d24690..7e57c2a 100644
--- a/sw/source/uibase/inc/swruler.hxx
+++ b/sw/source/uibase/inc/swruler.hxx
@@ -48,7 +48,7 @@ protected:
     bool        mbIsHighlighted; //< If comment control is highlighted (mouse is over it)
     Timer       maFadeTimer;     //< Timer for high/'low'light fading
     int         mnFadeRate;      //< From 0 to 100. 0 means not highlighted.
-    VirtualDevice maVirDev;      //< VirtualDevice of this window. Just for convenience.
+    ScopedVclPtr<VirtualDevice> maVirDev;      //< VirtualDevice of this window. Just for convenience.
 
     /**
      * Callback function to handle a mouse button down event.
diff --git a/sw/source/uibase/misc/swruler.cxx b/sw/source/uibase/misc/swruler.cxx
index ae33ad7..ccfed08 100644
--- a/sw/source/uibase/misc/swruler.cxx
+++ b/sw/source/uibase/misc/swruler.cxx
@@ -41,7 +41,7 @@ SwCommentRuler::SwCommentRuler( SwViewShell* pViewSh, vcl::Window* pParent, SwEd
 , mpSwWin(pWin)
 , mbIsHighlighted(false)
 , mnFadeRate(0)
-, maVirDev( *this )
+, maVirDev( new VirtualDevice(*this) )
 {
     // Set fading timeout: 5 x 40ms = 200ms
     maFadeTimer.SetTimeout(40);
@@ -75,25 +75,25 @@ void SwCommentRuler::DrawCommentControl()
     bool bIsCollapsed = ! mpViewShell->GetPostItMgr()->ShowNotes();
 
     Rectangle aControlRect = GetCommentControlRegion();
-    maVirDev.SetOutputSizePixel( aControlRect.GetSize() );
+    maVirDev->SetOutputSizePixel( aControlRect.GetSize() );
 
     // Paint comment control background
     // TODO Check if these are best colors to be used
     Color aBgColor = GetFadedColor( rStyleSettings.GetDarkShadowColor(), rStyleSettings.GetWorkspaceColor() );
-    maVirDev.SetFillColor( aBgColor );
+    maVirDev->SetFillColor( aBgColor );
 
     if ( mbIsHighlighted || !bIsCollapsed )
     {
         // Draw borders
-        maVirDev.SetLineColor( rStyleSettings.GetShadowColor() );
+        maVirDev->SetLineColor( rStyleSettings.GetShadowColor() );
     }
     else
     {
         // No borders
-        maVirDev.SetLineColor();
+        maVirDev->SetLineColor();
     }
 
-    maVirDev.DrawRect( Rectangle( Point(), aControlRect.GetSize() ) );
+    maVirDev->DrawRect( Rectangle( Point(), aControlRect.GetSize() ) );
 
     // Label and arrow tip
     OUString aLabel( SW_RESSTR ( STR_COMMENTS_LABEL ) );
@@ -142,9 +142,9 @@ void SwCommentRuler::DrawCommentControl()
 
     // Draw label
     Color aTextColor = GetFadedColor( rStyleSettings.GetButtonTextColor(), rStyleSettings.GetDarkShadowColor() );
-    maVirDev.SetTextColor( aTextColor );
+    maVirDev->SetTextColor( aTextColor );
     // FIXME Expected font size?
-    maVirDev.DrawText( aLabelPos, aLabel );
+    maVirDev->DrawText( aLabelPos, aLabel );
 
     // Draw arrow
     // FIXME consistence of button colors. http://opengrok.libreoffice.org/xref/core/vcl/source/control/button.cxx#785
@@ -152,26 +152,26 @@ void SwCommentRuler::DrawCommentControl()
     ImplDrawArrow ( aArrowPos.X(), aArrowPos.Y(), aArrowColor, bArrowToRight );
 
     // Blit comment control
-    DrawOutDev( aControlRect.TopLeft(), aControlRect.GetSize(), Point(), aControlRect.GetSize(), maVirDev );
+    DrawOutDev( aControlRect.TopLeft(), aControlRect.GetSize(), Point(), aControlRect.GetSize(), *maVirDev.get() );
 }
 
 void SwCommentRuler::ImplDrawArrow(long nX, long nY, const Color& rColor, bool bPointRight)
 {
-    maVirDev.SetLineColor();
-    maVirDev.SetFillColor( rColor );
+    maVirDev->SetLineColor();
+    maVirDev->SetFillColor( rColor );
     if ( bPointRight )
     {
-        maVirDev.DrawRect( Rectangle( nX+0, nY+0, nX+0, nY+6 ) );
-        maVirDev.DrawRect( Rectangle( nX+1, nY+1, nX+1, nY+5 ) );
-        maVirDev.DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
-        maVirDev.DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
+        maVirDev->DrawRect( Rectangle( nX+0, nY+0, nX+0, nY+6 ) );
+        maVirDev->DrawRect( Rectangle( nX+1, nY+1, nX+1, nY+5 ) );
+        maVirDev->DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
+        maVirDev->DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
     }
     else
     {
-        maVirDev.DrawRect( Rectangle( nX+0, nY+3, nX+0, nY+3 ) );
-        maVirDev.DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
-        maVirDev.DrawRect( Rectangle( nX+2, nY+1, nX+2, nY+5 ) );
-        maVirDev.DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+6 ) );
+        maVirDev->DrawRect( Rectangle( nX+0, nY+3, nX+0, nY+3 ) );
+        maVirDev->DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
+        maVirDev->DrawRect( Rectangle( nX+2, nY+1, nX+2, nY+5 ) );
+        maVirDev->DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+6 ) );
     }
 }
 
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 799cf3b..dfd2cb1 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -388,7 +388,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
                     SfxPrinter* pPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( true );
                     if ( OUString ( pPrinter->GetName()) != sPrinterName )
                     {
-                        SfxPrinter *pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
+                        VclPtr<SfxPrinter> pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
                         if( pNewPrinter->IsKnown() )
                         {
                             // set printer only once; in _postSetValues
@@ -396,7 +396,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
                         }
                         else
                         {
-                            delete pNewPrinter;
+                            pNewPrinter.disposeAndClear();
                         }
                     }
                 }
@@ -428,7 +428,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
                     SfxPrinter *pPrinter = SfxPrinter::Create ( aStream, pItemSet );
 
                     // set printer only once; in _postSetValues
-                    delete mpPrinter;
+                    mpPrinter.disposeAndClear();
                     mpPrinter = pPrinter;
                 }
             }
@@ -826,7 +826,7 @@ void SwXDocumentSettings::_postSetValues ()
         throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
 {
     // set printer only once, namely here!
-    if( mpPrinter != NULL )
+    if( mpPrinter != nullptr )
     {
         // #i86352# the printer is also used as container for options by sfx
         // when setting a printer it should have decent default options


More information about the Libreoffice-commits mailing list