[Libreoffice-commits] core.git: Branch 'feature/vclptr' - 7 commits - basctl/source chart2/source dbaccess/source extensions/source forms/source include/toolkit include/vcl reportdesign/source sd/source sfx2/source starmath/source svx/source sw/inc sw/source vcl/generic vcl/osx vcl/qa vcl/source

Michael Meeks michael.meeks at collabora.com
Fri Apr 10 03:27:12 PDT 2015


 basctl/source/basicide/basicrenderable.cxx               |    8 +-
 basctl/source/basicide/basicrenderable.hxx               |    2 
 chart2/source/controller/main/ShapeToolbarController.cxx |    2 
 dbaccess/source/ui/browser/brwview.cxx                   |    2 
 dbaccess/source/ui/browser/genericcontroller.cxx         |    2 
 dbaccess/source/ui/browser/sbagrid.cxx                   |    6 -
 dbaccess/source/ui/control/toolboxcontroller.cxx         |    6 -
 dbaccess/source/ui/uno/ColumnPeer.cxx                    |   11 +-
 extensions/source/propctrlr/browserline.cxx              |    2 
 extensions/source/propctrlr/propcontroller.cxx           |    2 
 forms/source/richtext/richtextcontrol.cxx                |   12 +--
 forms/source/solar/component/navbarcontrol.cxx           |    8 +-
 include/toolkit/awt/vclxprinter.hxx                      |    4 -
 include/vcl/oldprintadaptor.hxx                          |    2 
 include/vcl/print.hxx                                    |    6 -
 include/vcl/virdev.hxx                                   |    1 
 reportdesign/source/ui/misc/statusbarcontroller.cxx      |    2 
 reportdesign/source/ui/misc/toolboxcontroller.cxx        |    2 
 sd/source/ui/slideshow/slideshowimpl.cxx                 |    3 
 sd/source/ui/unoidl/unomodel.cxx                         |    4 -
 sd/source/ui/view/DocumentRenderer.cxx                   |    5 -
 sfx2/source/dialog/backingcomp.cxx                       |    2 
 sfx2/source/view/viewprn.cxx                             |   28 +++----
 starmath/source/unomodel.cxx                             |    4 -
 svx/source/dialog/srchdlg.cxx                            |    2 
 svx/source/fmcomp/fmgridif.cxx                           |   57 +++++++--------
 sw/inc/printdata.hxx                                     |    2 
 sw/source/core/view/printdata.cxx                        |    8 +-
 sw/source/uibase/uno/unotxdoc.cxx                        |   16 ++--
 vcl/generic/print/genprnpsp.cxx                          |    2 
 vcl/osx/salprn.cxx                                       |    2 
 vcl/qa/cppunit/lifecycle.cxx                             |    8 ++
 vcl/source/filter/wmf/winmtf.cxx                         |   40 +++++-----
 vcl/source/gdi/oldprintadaptor.cxx                       |    6 -
 vcl/source/gdi/print3.cxx                                |   10 +-
 vcl/source/gdi/virdev.cxx                                |    8 ++
 vcl/source/outdev/outdev.cxx                             |    9 +-
 vcl/source/window/printdlg.cxx                           |    8 +-
 38 files changed, 161 insertions(+), 143 deletions(-)

New commits:
commit 683cb12163803af2888b17ee4902e319c8bc49b4
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Mar 16 21:50:14 2015 +0000

    fix thinko in starmath; time to sleep.
    
    Change-Id: I6846e56062fdde394e4039de7cde42b0560f34b3

diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 5ce26b5..b2c6933 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -1023,8 +1023,8 @@ void SAL_CALL SmModel::render(
     if (xRenderDevice.is())
     {
         VCLXDevice*   pDevice = VCLXDevice::GetImplementation( xRenderDevice );
-        VclRef< OutputDevice> pOut = pDevice ? pDevice->GetOutputDevice()
-                                             : VclRef< OutputDevice >();
+        VclPtr< OutputDevice> pOut = pDevice ? pDevice->GetOutputDevice()
+                                             : VclPtr< OutputDevice >();
         if (!pOut)
             throw RuntimeException();
 
commit 359cbefc23d6283f32ca428c98de8aec4a773fa2
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Mar 16 21:46:08 2015 +0000

    more toolkit API adaptations.
    
    Change-Id: I55e3153bf38af376fe367d575ceb19f5b4405e1c

diff --git a/reportdesign/source/ui/misc/statusbarcontroller.cxx b/reportdesign/source/ui/misc/statusbarcontroller.cxx
index cbc9afa..8646cb3 100644
--- a/reportdesign/source/ui/misc/statusbarcontroller.cxx
+++ b/reportdesign/source/ui/misc/statusbarcontroller.cxx
@@ -86,7 +86,7 @@ void SAL_CALL OStatusbarController::initialize( const Sequence< Any >& _rArgumen
     SolarMutexGuard aSolarMutexGuard;
     ::osl::MutexGuard aGuard(m_aMutex);
 
-    StatusBar* pStatusBar = static_cast<StatusBar*>(VCLUnoHelper::GetWindow(m_xParentWindow));
+    VclPtr< StatusBar > pStatusBar = static_cast<StatusBar*>(VCLUnoHelper::GetWindow(m_xParentWindow).get());
     if ( pStatusBar )
     {
         const sal_uInt16 nCount = pStatusBar->GetItemCount();
diff --git a/reportdesign/source/ui/misc/toolboxcontroller.cxx b/reportdesign/source/ui/misc/toolboxcontroller.cxx
index cb83281..d2b5ad8 100644
--- a/reportdesign/source/ui/misc/toolboxcontroller.cxx
+++ b/reportdesign/source/ui/misc/toolboxcontroller.cxx
@@ -127,7 +127,7 @@ void SAL_CALL OToolboxController::initialize( const Sequence< Any >& _rArguments
     SolarMutexGuard aSolarMutexGuard;
     ::osl::MutexGuard aGuard(m_aMutex);
 
-    ToolBox*    pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+    VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()).get());
     if ( pToolBox )
     {
         const sal_uInt16 nCount = pToolBox->GetItemCount();
diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx
index 22a4e84..20b2df7 100644
--- a/sd/source/ui/view/DocumentRenderer.cxx
+++ b/sd/source/ui/view/DocumentRenderer.cxx
@@ -1201,8 +1201,9 @@ public:
         if (aDev >>= xRenderDevice)
         {
             VCLXDevice* pDevice = VCLXDevice::GetImplementation(xRenderDevice);
-            OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
-            mpPrinter = dynamic_cast<Printer*>(pOut);
+            VclPtr< OutputDevice > pOut = pDevice ? pDevice->GetOutputDevice()
+                                                  : VclPtr< OutputDevice >();
+            mpPrinter = dynamic_cast<Printer*>(pOut.get());
             Size aPageSizePixel = mpPrinter ? mpPrinter->GetPaperSizePixel() : Size();
             if( aPageSizePixel != maPrinterPageSizePixel )
             {
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 4ade3f8..5ce26b5 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -1023,8 +1023,8 @@ void SAL_CALL SmModel::render(
     if (xRenderDevice.is())
     {
         VCLXDevice*   pDevice = VCLXDevice::GetImplementation( xRenderDevice );
-        OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
-
+        VclRef< OutputDevice> pOut = pDevice ? pDevice->GetOutputDevice()
+                                             : VclRef< OutputDevice >();
         if (!pOut)
             throw RuntimeException();
 
diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx
index eed52d0..8f66b85 100644
--- a/sw/inc/printdata.hxx
+++ b/sw/inc/printdata.hxx
@@ -172,7 +172,7 @@ public:
 
 class SwPrintUIOptions : public vcl::PrinterOptionsHelper
 {
-    OutputDevice* m_pLast;
+    VclPtr< OutputDevice > m_pLast;
     const SwPrintData & m_rDefaultPrintData;
 
 public:
diff --git a/sw/source/core/view/printdata.cxx b/sw/source/core/view/printdata.cxx
index f549dda..ba2a0d5 100644
--- a/sw/source/core/view/printdata.cxx
+++ b/sw/source/core/view/printdata.cxx
@@ -158,7 +158,6 @@ SwPrintUIOptions::SwPrintUIOptions(
     bool bHasSelection,
     bool bHasPostIts,
     const SwPrintData &rDefaultPrintData ) :
-    m_pLast( NULL ),
     m_rDefaultPrintData( rDefaultPrintData )
 {
     ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) );
@@ -478,7 +477,7 @@ bool SwPrintUIOptions::processPropertiesAndCheckFormat( const uno::Sequence< bea
         if (pDevice)
             pOut = pDevice->GetOutputDevice();
     }
-    bChanged = bChanged || (pOut != m_pLast);
+    bChanged = bChanged || (pOut.get() != m_pLast.get());
     if( pOut )
         m_pLast = pOut;
 
commit ad194534994a50f691c4ea15123b215cb93cc802
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Mar 16 21:32:18 2015 +0000

    sw, sd: more toolkit API cleanup.
    
    Change-Id: I2015f517695682f17fe5c03a8df0171a427717bf

diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx
index 3f87111..aaf704e 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -3343,7 +3343,8 @@ void PresentationSettingsEx::SetPropertyValue( const OUString& rProperty, const
         Reference< XWindow > xWindow;
         if( rValue >>= xWindow )
         {
-            mpParentWindow = xWindow.is() ? VCLUnoHelper::GetWindow( xWindow ) : 0;
+            mpParentWindow = xWindow.is() ? VCLUnoHelper::GetWindow( xWindow )
+                                          : VclPtr<vcl::Window>();
             return;
         }
     }
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index e2ab4f8..f62fc04 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -1879,8 +1879,8 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r
 
         if( xRenderDevice.is() && nPageNumber && ( nPageNumber <= mpDoc->GetSdPageCount( ePageKind ) ) )
         {
-            VCLXDevice*     pDevice = VCLXDevice::GetImplementation( xRenderDevice );
-            OutputDevice*   pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
+            VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
+            VclPtr< OutputDevice> pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >();
 
             if( pOut )
             {
diff --git a/sw/source/core/view/printdata.cxx b/sw/source/core/view/printdata.cxx
index f0c11fe..f549dda 100644
--- a/sw/source/core/view/printdata.cxx
+++ b/sw/source/core/view/printdata.cxx
@@ -471,11 +471,12 @@ bool SwPrintUIOptions::processPropertiesAndCheckFormat( const uno::Sequence< bea
     uno::Any aVal( getValue( "RenderDevice" ) );
     aVal >>= xRenderDevice;
 
-    OutputDevice* pOut = 0;
+    VclPtr< OutputDevice > pOut;
     if (xRenderDevice.is())
     {
         VCLXDevice*     pDevice = VCLXDevice::GetImplementation( xRenderDevice );
-        pOut = pDevice ? pDevice->GetOutputDevice() : 0;
+        if (pDevice)
+            pOut = pDevice->GetOutputDevice();
     }
     bChanged = bChanged || (pOut != m_pLast);
     if( pOut )
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 5feadbf..685260f 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -2320,9 +2320,9 @@ Any SAL_CALL SwXTextDocument::getPropertyDefault( const OUString& rPropertyName
     return aAny;
 }
 
-static OutputDevice * lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptions )
+static VclPtr< OutputDevice > lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptions )
 {
-    OutputDevice *pOut = 0;
+    VclPtr< OutputDevice > pOut;
 
     uno::Any aAny( rPrintUIOptions.getValue( "RenderDevice" ));
     uno::Reference< awt::XDevice >  xRenderDevice;
@@ -2330,7 +2330,7 @@ static OutputDevice * lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptio
     if (xRenderDevice.is())
     {
         VCLXDevice*     pDevice = VCLXDevice::GetImplementation( xRenderDevice );
-        pOut = pDevice ? pDevice->GetOutputDevice() : 0;
+        pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >();
     }
 
     return pOut;
@@ -2519,7 +2519,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
     if (bIsSwSrcView)
     {
         SwSrcView& rSwSrcView = dynamic_cast<SwSrcView&>(*pView);
-        OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
+        VclPtr< OutputDevice> pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
         nRet = rSwSrcView.PrintSource( pOutDev, 1 /* dummy */, true /* get page count only */ );
     }
     else
@@ -2634,7 +2634,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
             const sal_Int16 nPostItMode = (sal_Int16) m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", 0 );
             if (nPostItMode != POSTITS_NONE)
             {
-                OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
+                VclPtr< OutputDevice > pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
                 m_pRenderData->CreatePostItData( pDoc, pViewShell->GetViewOptions(), pOutDev );
             }
 
@@ -2758,7 +2758,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
             // Sometimes 'getRenderer' is only called to get "ExtraPrintUIOptions", in this
             // case we won't get an OutputDevice here, but then the caller also has no need
             // for the correct PageSisze right now...
-            Printer *pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions ));
+            VclPtr< Printer > pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions ).get());
             if (pPrinter)
             {
                 // HTML source view and prospect adapt to the printer's paper size
@@ -2976,7 +2976,7 @@ void SAL_CALL SwXTextDocument::render(
             if (bIsSwSrcView)
             {
                 SwSrcView& rSwSrcView = dynamic_cast<SwSrcView&>(*pView);
-                OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
+                VclPtr< OutputDevice > pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
                 rSwSrcView.PrintSource(pOutDev, nRenderer + 1, false);
             }
             else
@@ -2998,7 +2998,7 @@ void SAL_CALL SwXTextDocument::render(
                 }
 
                 // get output device to use
-                OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions );
+                VclPtr< OutputDevice > pOut = lcl_GetOutputDevice( *m_pPrintUIOptions );
 
                 if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions())
                 {
commit 29e8c9ca3167b1366bd3b455df64ace5aea75bc1
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Mar 16 17:46:20 2015 +0000

    basctl, forms, svx: cleanup for new VclPtr API.
    
    Change-Id: I3bfd7933d2cddf707662d10e9366e0c82f33d276

diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx
index 8a36a56..7281417 100644
--- a/basctl/source/basicide/basicrenderable.cxx
+++ b/basctl/source/basicide/basicrenderable.cxx
@@ -86,7 +86,7 @@ VclPtr< Printer > Renderable::getPrinter()
     if( aValue >>= xRenderDevice )
     {
         VCLXDevice* pDevice = VCLXDevice::GetImplementation(xRenderDevice);
-        VclPtr< OutputDevice > pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >;
+        VclPtr< OutputDevice > pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >();
         pPrinter = dynamic_cast<Printer*>(pOut.get());
     }
     return pPrinter;
diff --git a/basctl/source/basicide/basicrenderable.hxx b/basctl/source/basicide/basicrenderable.hxx
index db96dfc..dd60f16 100644
--- a/basctl/source/basicide/basicrenderable.hxx
+++ b/basctl/source/basicide/basicrenderable.hxx
@@ -36,7 +36,7 @@ class Renderable :
     VclPtr<BaseWindow>  mpWindow;
     osl::Mutex          maMutex;
 
-    Printer* getPrinter();
+    VclPtr<Printer> getPrinter();
 public:
     Renderable (BaseWindow*);
     virtual ~Renderable();
diff --git a/forms/source/richtext/richtextcontrol.cxx b/forms/source/richtext/richtextcontrol.cxx
index 7377389..66b27de 100644
--- a/forms/source/richtext/richtextcontrol.cxx
+++ b/forms/source/richtext/richtextcontrol.cxx
@@ -314,7 +314,7 @@ namespace frm
     {
         {
             SolarMutexGuard aGuard;
-            VclPtr< RichTextControl > pRichTextControl = GetAs< RichTextControl* >();
+            VclPtr< RichTextControl > pRichTextControl = GetAs< RichTextControl >();
 
             if ( pRichTextControl )
             {
@@ -340,7 +340,7 @@ namespace frm
     {
         SolarMutexGuard aGuard;
 
-        RichTextControl* pControl = static_cast< RichTextControl* >( GetWindow() );
+        VclPtr< RichTextControl > pControl = GetAs< RichTextControl >();
         if ( !pControl )
             return;
 
@@ -375,7 +375,7 @@ namespace frm
 
         if ( _rPropertyName == PROPERTY_BACKGROUNDCOLOR )
         {
-            RichTextControl* pControl = static_cast< RichTextControl* >( GetWindow() );
+            VclPtr< RichTextControl > pControl = GetAs< RichTextControl >();
             if ( !_rValue.hasValue() )
             {
                 pControl->SetBackgroundColor( );
@@ -401,7 +401,7 @@ namespace frm
         }
         else if ( _rPropertyName == PROPERTY_READONLY )
         {
-            RichTextControl* pControl = static_cast< RichTextControl* >( GetWindow() );
+            VclPtr< RichTextControl > pControl = GetAs< RichTextControl >();
             bool bReadOnly( pControl->IsReadOnly() );
             OSL_VERIFY( _rValue >>= bReadOnly );
             pControl->SetReadOnly( bReadOnly );
@@ -417,7 +417,7 @@ namespace frm
         }
         else if ( _rPropertyName == PROPERTY_HIDEINACTIVESELECTION )
         {
-            VclPtr< RichTextControl > pRichTextControl = GetAs< RichTextControl* >();
+            VclPtr< RichTextControl > pRichTextControl = GetAs< RichTextControl >();
             bool bHide = pRichTextControl->GetHideInactiveSelection();
             OSL_VERIFY( _rValue >>= bHide );
             pRichTextControl->SetHideInactiveSelection( bHide );
@@ -469,7 +469,7 @@ namespace frm
 
     ORichTextPeer::SingleAttributeDispatcher ORichTextPeer::implCreateDispatcher( SfxSlotId _nSlotId, const ::com::sun::star::util::URL& _rURL )
     {
-        VclPtr< RichTextControl > pRichTextControl = GetAs< RichTextControl* >();
+        VclPtr< RichTextControl > pRichTextControl = GetAs< RichTextControl >();
         OSL_PRECOND( pRichTextControl, "ORichTextPeer::implCreateDispatcher: invalid window!" );
         if ( !pRichTextControl )
             return SingleAttributeDispatcher( NULL );
diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx
index 87965d9..7150ef2 100644
--- a/svx/source/fmcomp/fmgridif.cxx
+++ b/svx/source/fmcomp/fmgridif.cxx
@@ -1398,7 +1398,7 @@ void FmXGridPeer::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeE
         // this should not be (deadlock) critical, as by definition, every component should release
         // any own mutexes before notifying
 
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     if (!pGrid)
         return;
 
@@ -1518,7 +1518,7 @@ void FmXGridPeer::removeUpdateListener(const Reference< XUpdateListener >& l) th
 
 sal_Bool FmXGridPeer::commit() throw( RuntimeException, std::exception )
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     if (!m_xCursor.is() || !pGrid)
         return sal_True;
 
@@ -1541,7 +1541,7 @@ sal_Bool FmXGridPeer::commit() throw( RuntimeException, std::exception )
 
 void FmXGridPeer::cursorMoved(const EventObject& _rEvent) throw( RuntimeException, std::exception )
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     // we are not interested in move to insert row only in the resetted event
     // which is fired after positioning an the insert row
     if (pGrid && pGrid->IsOpen() && !::comphelper::getBOOL(Reference< XPropertySet > (_rEvent.Source, UNO_QUERY)->getPropertyValue(FM_PROP_ISNEW)))
@@ -1551,7 +1551,7 @@ void FmXGridPeer::cursorMoved(const EventObject& _rEvent) throw( RuntimeExceptio
 
 void FmXGridPeer::rowChanged(const EventObject& _rEvent) throw( RuntimeException, std::exception )
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     if (pGrid && pGrid->IsOpen())
     {
         if (m_xCursor->rowUpdated() && !pGrid->IsCurrentAppending())
@@ -1654,7 +1654,7 @@ void FmXGridPeer::setColumns(const Reference< XIndexContainer >& Columns) throw(
 {
     SolarMutexGuard aGuard;
 
-    FmGridControl* pGrid = static_cast< FmGridControl* >( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
 
     if (m_xColumns.is())
     {
@@ -1770,7 +1770,7 @@ void FmXGridPeer::elementReplaced(const ContainerEvent& evt) throw( RuntimeExcep
 {
     SolarMutexGuard aGuard;
 
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
 
     // Handle Column beruecksichtigen
     if (!pGrid || !m_xColumns.is() || pGrid->IsInColumnMove())
@@ -1825,7 +1825,7 @@ void FmXGridPeer::elementRemoved(const ContainerEvent& evt) throw( RuntimeExcept
 {
     SolarMutexGuard aGuard;
 
-    FmGridControl* pGrid    = static_cast<FmGridControl*>(GetWindow());
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
 
     // Handle Column beruecksichtigen
     if (!pGrid || !m_xColumns.is() || pGrid->IsInColumnMove() || m_xColumns->getCount() == ((sal_Int32)pGrid->GetModelColCount()))
@@ -1842,7 +1842,7 @@ void FmXGridPeer::setProperty( const OUString& PropertyName, const Any& Value) t
 {
     SolarMutexGuard aGuard;
 
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
 
     bool bVoid = !Value.hasValue();
 
@@ -2255,14 +2255,14 @@ void SAL_CALL FmXGridPeer::removeGridControlListener( const Reference< XGridCont
 
 sal_Int16 FmXGridPeer::getCurrentColumnPosition() throw( RuntimeException, std::exception )
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     return pGrid ? pGrid->GetViewColumnPos(pGrid->GetCurColumnId()) : -1;
 }
 
 
 void FmXGridPeer::setCurrentColumnPosition(sal_Int16 nPos) throw( RuntimeException, std::exception )
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     if (pGrid)
         pGrid->GoToColumnId(pGrid->GetColumnIdFromViewPos(nPos));
 }
@@ -2272,7 +2272,7 @@ void FmXGridPeer::selectionChanged(const EventObject& evt) throw( RuntimeExcepti
 {
     SolarMutexGuard aGuard;
 
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     if (pGrid)
     {
         Reference< ::com::sun::star::view::XSelectionSupplier >  xSelSupplier(evt.Source, UNO_QUERY);
@@ -2340,7 +2340,7 @@ Reference< XEnumeration >  FmXGridPeer::createEnumeration() throw( RuntimeExcept
 
 sal_Int32 FmXGridPeer::getCount() throw( RuntimeException, std::exception )
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     if (pGrid)
         return pGrid->GetViewColCount();
     else
@@ -2350,7 +2350,7 @@ sal_Int32 FmXGridPeer::getCount() throw( RuntimeException, std::exception )
 
 Any FmXGridPeer::getByIndex(sal_Int32 _nIndex) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception )
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     if (_nIndex < 0 ||
         _nIndex >= getCount() || !pGrid)
         throw IndexOutOfBoundsException();
@@ -2429,7 +2429,7 @@ sal_Bool FmXGridPeer::supportsMode(const OUString& Mode) throw( RuntimeException
 
 void FmXGridPeer::columnVisible(DbGridColumn* pColumn)
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
 
     sal_Int32 _nIndex = pGrid->GetModelColumnPos(pColumn->GetId());
     Reference< ::com::sun::star::awt::XControl >  xControl(pColumn->GetCell());
@@ -2444,7 +2444,7 @@ void FmXGridPeer::columnVisible(DbGridColumn* pColumn)
 
 void FmXGridPeer::columnHidden(DbGridColumn* pColumn)
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
 
     sal_Int32 _nIndex = pGrid->GetModelColumnPos(pColumn->GetId());
     Reference< ::com::sun::star::awt::XControl >  xControl(pColumn->GetCell());
@@ -2599,7 +2599,7 @@ void FmXGridPeer::statusChanged(const ::com::sun::star::frame::FeatureStateEvent
         {
             DBG_ASSERT(m_pDispatchers[i] == Event.Source, "FmXGridPeer::statusChanged : the event source is a little bit suspect !");
             m_pStateCache[i] = Event.IsEnabled;
-            FmGridControl* pGrid = static_cast<FmGridControl*>( GetWindow() );
+            VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
             if (*pSlots != SID_FM_RECORD_UNDO)
                 pGrid->GetNavigationBar().InvalidateState(*pSlots);
             break;
@@ -2621,8 +2621,7 @@ sal_Bool SAL_CALL FmXGridPeer::select( const Any& _rSelection ) throw (IllegalAr
     if ( !( _rSelection >>= aBookmarks ) )
         throw IllegalArgumentException();
 
-    FmGridControl* pVclControl = static_cast<FmGridControl*>(GetWindow());
-    return pVclControl->selectBookmarks(aBookmarks);
+    return GetAs< FmGridControl >()->selectBookmarks(aBookmarks);
 
     // TODO:
     // speaking strictly, we would have to adjust our model, as our ColumnSelection may have changed.
@@ -2635,7 +2634,7 @@ sal_Bool SAL_CALL FmXGridPeer::select( const Any& _rSelection ) throw (IllegalAr
 
 Any SAL_CALL FmXGridPeer::getSelection(  ) throw (RuntimeException, std::exception)
 {
-    FmGridControl* pVclControl = static_cast<FmGridControl*>(GetWindow());
+    VclPtr< FmGridControl > pVclControl = GetAs< FmGridControl >();
     Sequence< Any > aSelectionBookmarks = pVclControl->getSelectionBookmarks();
     return makeAny(aSelectionBookmarks);
 }
commit 65741289ea32fe642af179b732398c1c3e41911e
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Mar 16 17:28:03 2015 +0000

    cleanup Printer VclRef pieces.
    
    Change-Id: Ib47b2ec3cb54e374675981ad929856f43987418f

diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx
index ee5ed4b..8a36a56 100644
--- a/basctl/source/basicide/basicrenderable.cxx
+++ b/basctl/source/basicide/basicrenderable.cxx
@@ -77,17 +77,17 @@ Renderable::~Renderable()
 {
 }
 
-Printer* Renderable::getPrinter()
+VclPtr< Printer > Renderable::getPrinter()
 {
-    Printer* pPrinter = NULL;
+    VclPtr< Printer > pPrinter;
     Any aValue( getValue( "RenderDevice" ) );
     Reference<awt::XDevice> xRenderDevice;
 
     if( aValue >>= xRenderDevice )
     {
         VCLXDevice* pDevice = VCLXDevice::GetImplementation(xRenderDevice);
-        OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
-        pPrinter = dynamic_cast<Printer*>(pOut);
+        VclPtr< OutputDevice > pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >;
+        pPrinter = dynamic_cast<Printer*>(pOut.get());
     }
     return pPrinter;
 }
diff --git a/chart2/source/controller/main/ShapeToolbarController.cxx b/chart2/source/controller/main/ShapeToolbarController.cxx
index 46c7cda..999c9ba 100644
--- a/chart2/source/controller/main/ShapeToolbarController.cxx
+++ b/chart2/source/controller/main/ShapeToolbarController.cxx
@@ -105,7 +105,7 @@ void ShapeToolbarController::initialize( const Sequence< uno::Any >& rArguments
     SolarMutexGuard aSolarMutexGuard;
     ::osl::MutexGuard aGuard( m_aMutex );
 
-    ToolBox* pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) );
+    VclPtr< ToolBox > pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ).get() );
     if ( pToolBox )
     {
         const sal_uInt16 nCount = pToolBox->GetItemCount();
diff --git a/dbaccess/source/ui/browser/brwview.cxx b/dbaccess/source/ui/browser/brwview.cxx
index 07db066..59585c5 100644
--- a/dbaccess/source/ui/browser/brwview.cxx
+++ b/dbaccess/source/ui/browser/brwview.cxx
@@ -264,7 +264,7 @@ SbaGridControl* UnoDataBrowserView::getVclControl() const
                 UnoDataBrowserView* pTHIS = const_cast<UnoDataBrowserView*>(this);
                 if ( pPeer )
                 {
-                    m_pVclControl = static_cast<SbaGridControl*>(pPeer->GetWindow());
+                    m_pVclControl = static_cast<SbaGridControl*>(pPeer->GetWindow().get());
                     pTHIS->startComponentListening(Reference<XComponent>(VCLUnoHelper::GetInterface(m_pVclControl),UNO_QUERY));
                 }
             }
diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx
index 7b129ee..64522f2 100644
--- a/dbaccess/source/ui/browser/genericcontroller.cxx
+++ b/dbaccess/source/ui/browser/genericcontroller.cxx
@@ -291,7 +291,7 @@ void SAL_CALL OGenericUnoController::initialize( const Sequence< Any >& aArgumen
 
         xParent = xFrame->getContainerWindow();
         VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(xParent);
-        vcl::Window* pParentWin = pParentComponent ? pParentComponent->GetWindow() : NULL;
+        VclPtr< vcl::Window > pParentWin = pParentComponent ? pParentComponent->GetWindow() : VclPtr< vcl::Window >();
         if (!pParentWin)
         {
             throw IllegalArgumentException("Parent window is null", *this, 1 );
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
index 9b9d8c8..030d38e 100644
--- a/dbaccess/source/ui/browser/sbagrid.cxx
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -309,7 +309,7 @@ void SAL_CALL SbaXGridPeer::dispose(void) throw( RuntimeException, std::exceptio
 
 void SbaXGridPeer::NotifyStatusChanged(const ::com::sun::star::util::URL& _rUrl, const Reference< ::com::sun::star::frame::XStatusListener > & xControl)
 {
-    SbaGridControl* pGrid = static_cast<SbaGridControl*>(GetWindow());
+    VclPtr< SbaGridControl > pGrid = GetAs< SbaGridControl >();
     if (!pGrid)
         return;
 
@@ -361,7 +361,7 @@ Reference< ::com::sun::star::frame::XDispatch >  SAL_CALL SbaXGridPeer::queryDis
 
 IMPL_LINK( SbaXGridPeer, OnDispatchEvent, void*, /*NOTINTERESTEDIN*/ )
 {
-    SbaGridControl* pGrid = static_cast< SbaGridControl* >( GetWindow() );
+    VclPtr< SbaGridControl > pGrid = GetAs< SbaGridControl >();
     if ( pGrid )    // if this fails, we were disposing before arriving here
     {
         if ( Application::GetMainThreadIdentifier() != ::osl::Thread::getCurrentIdentifier() )
@@ -398,7 +398,7 @@ SbaXGridPeer::DispatchType SbaXGridPeer::classifyDispatchURL( const URL& _rURL )
 
 void SAL_CALL SbaXGridPeer::dispatch(const URL& aURL, const Sequence< PropertyValue >& aArgs) throw( RuntimeException, std::exception )
 {
-    SbaGridControl* pGrid = static_cast<SbaGridControl*>(GetWindow());
+    VclPtr< SbaGridControl > pGrid = GetAs< SbaGridControl >();
     if (!pGrid)
         return;
 
diff --git a/dbaccess/source/ui/control/toolboxcontroller.cxx b/dbaccess/source/ui/control/toolboxcontroller.cxx
index ca97d79..079e4a5 100644
--- a/dbaccess/source/ui/control/toolboxcontroller.cxx
+++ b/dbaccess/source/ui/control/toolboxcontroller.cxx
@@ -169,7 +169,7 @@ namespace dbaui
                     {
                         m_aCommandURL = aFind->first;
 
-                        ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+                        VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()).get());
                         lcl_copy(pMenu.get(),nItemId,i,pToolBox,m_nToolBoxId, m_aCommandURL);
                         break;
                     }
@@ -228,7 +228,7 @@ namespace dbaui
         SolarMutexGuard aSolarMutexGuard;
         ::osl::MutexGuard aGuard(m_aMutex);
 
-        ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+        VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()).get());
         ::std::unique_ptr<PopupMenu> pMenu = getMenu();
 
         sal_uInt16 nSelected = pMenu->Execute(pToolBox, pToolBox->GetItemRect( m_nToolBoxId ),POPUPMENU_EXECUTE_DOWN);
diff --git a/dbaccess/source/ui/uno/ColumnPeer.cxx b/dbaccess/source/ui/uno/ColumnPeer.cxx
index 1422c62..723f103 100644
--- a/dbaccess/source/ui/uno/ColumnPeer.cxx
+++ b/dbaccess/source/ui/uno/ColumnPeer.cxx
@@ -46,19 +46,16 @@ OColumnPeer::OColumnPeer(vcl::Window* _pParent,const Reference<XComponentContext
 void OColumnPeer::setEditWidth(sal_Int32 _nWidth)
 {
     SolarMutexGuard aGuard;
-
-    OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() );
+    VclPtr<OColumnControlWindow> pFieldControl = GetAs<OColumnControlWindow>();
     if ( pFieldControl )
-    {
         pFieldControl->setEditWidth(_nWidth);
-    }
 }
 
 void OColumnPeer::setColumn(const Reference< XPropertySet>& _xColumn)
 {
     SolarMutexGuard aGuard;
 
-    OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() );
+    VclPtr<OColumnControlWindow> pFieldControl = GetAs<OColumnControlWindow>();
     if ( pFieldControl )
     {
         if ( m_pActFieldDescr )
@@ -105,7 +102,7 @@ void OColumnPeer::setColumn(const Reference< XPropertySet>& _xColumn)
 void OColumnPeer::setConnection(const Reference< XConnection>& _xCon)
 {
     SolarMutexGuard aGuard;
-    OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() );
+    VclPtr<OColumnControlWindow> pFieldControl = GetAs<OColumnControlWindow>();
     if ( pFieldControl )
         pFieldControl->setConnection(_xCon);
 }
@@ -131,7 +128,7 @@ void OColumnPeer::setProperty( const OUString& _rPropertyName, const Any& Value)
 Any OColumnPeer::getProperty( const OUString& _rPropertyName ) throw( RuntimeException, std::exception )
 {
     Any aProp;
-    OFieldDescControl* pFieldControl = static_cast<OFieldDescControl*>( GetWindow() );
+    VclPtr< OFieldDescControl > pFieldControl = GetAs< OFieldDescControl >();
     if (pFieldControl && _rPropertyName == PROPERTY_COLUMN)
     {
         aProp <<= m_xColumn;
diff --git a/extensions/source/propctrlr/browserline.cxx b/extensions/source/propctrlr/browserline.cxx
index ccc5b54..9a84905 100644
--- a/extensions/source/propctrlr/browserline.cxx
+++ b/extensions/source/propctrlr/browserline.cxx
@@ -109,7 +109,7 @@ namespace pcr
     void OBrowserLine::setControl( const Reference< XPropertyControl >& _rxControl )
     {
         m_xControl = _rxControl;
-        m_pControlWindow = m_xControl.is() ? VCLUnoHelper::GetWindow( _rxControl->getControlWindow() ) : NULL;
+        m_pControlWindow = m_xControl.is() ? VCLUnoHelper::GetWindow( _rxControl->getControlWindow() ) : VclPtr<vcl::Window>();
         DBG_ASSERT( m_pControlWindow, "OBrowserLine::setControl: setting NULL controls/windows is not allowed!" );
 
         if ( m_pControlWindow )
diff --git a/extensions/source/propctrlr/propcontroller.cxx b/extensions/source/propctrlr/propcontroller.cxx
index 95786ad..66cea9ec 100644
--- a/extensions/source/propctrlr/propcontroller.cxx
+++ b/extensions/source/propctrlr/propcontroller.cxx
@@ -375,7 +375,7 @@ namespace pcr
         // announcement is responsible for calling setComponent, too.
         Reference< XWindow > xContainerWindow = m_xFrame->getContainerWindow();
         VCLXWindow* pContainerWindow = VCLXWindow::GetImplementation(xContainerWindow);
-        vcl::Window* pParentWin = pContainerWindow ? pContainerWindow->GetWindow() : NULL;
+        VclPtr<vcl::Window> pParentWin = pContainerWindow ? pContainerWindow->GetWindow() : VclPtr<vcl::Window>();
         if (!pParentWin)
             throw RuntimeException("The frame is invalid. Unable to extract the container window.",*this);
 
diff --git a/forms/source/richtext/richtextcontrol.cxx b/forms/source/richtext/richtextcontrol.cxx
index 39a29a2..7377389 100644
--- a/forms/source/richtext/richtextcontrol.cxx
+++ b/forms/source/richtext/richtextcontrol.cxx
@@ -314,7 +314,7 @@ namespace frm
     {
         {
             SolarMutexGuard aGuard;
-            RichTextControl* pRichTextControl = static_cast< RichTextControl* >( GetWindow() );
+            VclPtr< RichTextControl > pRichTextControl = GetAs< RichTextControl* >();
 
             if ( pRichTextControl )
             {
@@ -417,7 +417,7 @@ namespace frm
         }
         else if ( _rPropertyName == PROPERTY_HIDEINACTIVESELECTION )
         {
-            RichTextControl* pRichTextControl = static_cast< RichTextControl* >( GetWindow() );
+            VclPtr< RichTextControl > pRichTextControl = GetAs< RichTextControl* >();
             bool bHide = pRichTextControl->GetHideInactiveSelection();
             OSL_VERIFY( _rValue >>= bHide );
             pRichTextControl->SetHideInactiveSelection( bHide );
@@ -469,7 +469,7 @@ namespace frm
 
     ORichTextPeer::SingleAttributeDispatcher ORichTextPeer::implCreateDispatcher( SfxSlotId _nSlotId, const ::com::sun::star::util::URL& _rURL )
     {
-        RichTextControl* pRichTextControl = static_cast< RichTextControl* >( GetWindow() );
+        VclPtr< RichTextControl > pRichTextControl = GetAs< RichTextControl* >();
         OSL_PRECOND( pRichTextControl, "ORichTextPeer::implCreateDispatcher: invalid window!" );
         if ( !pRichTextControl )
             return SingleAttributeDispatcher( NULL );
diff --git a/forms/source/solar/component/navbarcontrol.cxx b/forms/source/solar/component/navbarcontrol.cxx
index 3f2afea..695aadc 100644
--- a/forms/source/solar/component/navbarcontrol.cxx
+++ b/forms/source/solar/component/navbarcontrol.cxx
@@ -275,7 +275,7 @@ namespace frm
     {
         SolarMutexGuard aGuard;
 
-        NavigationToolBar* pNavBar = static_cast< NavigationToolBar* >( GetWindow() );
+        VclPtr< NavigationToolBar > pNavBar = GetAs< NavigationToolBar >();
         if ( !pNavBar )
         {
             VCLXWindow::setProperty( _rPropertyName, _rValue );
@@ -356,7 +356,7 @@ namespace frm
         SolarMutexGuard aGuard;
 
         Any aReturn;
-        NavigationToolBar* pNavBar = static_cast< NavigationToolBar* >( GetWindow() );
+        VclPtr< NavigationToolBar > pNavBar = GetAs< NavigationToolBar >();
 
         if ( _rPropertyName == PROPERTY_BACKGROUNDCOLOR )
         {
@@ -408,7 +408,7 @@ namespace frm
     void ONavigationBarPeer::featureStateChanged( sal_Int16 _nFeatureId, bool _bEnabled )
     {
         // enable this button on the toolbox
-        NavigationToolBar* pNavBar = static_cast< NavigationToolBar* >( GetWindow() );
+        VclPtr< NavigationToolBar > pNavBar = GetAs< NavigationToolBar >();
         if ( pNavBar )
         {
             pNavBar->enableFeature( _nFeatureId, _bEnabled );
@@ -436,7 +436,7 @@ namespace frm
     void ONavigationBarPeer::allFeatureStatesChanged( )
     {
         // force the control to update it's states
-        NavigationToolBar* pNavBar = static_cast< NavigationToolBar* >( GetWindow() );
+        VclPtr< NavigationToolBar > pNavBar = GetAs< NavigationToolBar >();
         if ( pNavBar )
             pNavBar->setDispatcher( this );
 
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index 7e2c709..9c5c98f 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -2307,7 +2307,7 @@ static vcl::Window* lcl_GetSearchLabelWindow()
         return 0;
     css::uno::Reference< css::awt::XWindow > xWindow(
             xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
-    ToolBox* pToolBox = static_cast<ToolBox*>( VCLUnoHelper::GetWindow(xWindow) );
+    VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>( VCLUnoHelper::GetWindow(xWindow).get() );
     for (size_t i = 0; pToolBox && i < pToolBox->GetItemCount(); ++i)
         if (pToolBox->GetItemCommand(i) == ".uno:SearchLabel")
             return pToolBox->GetItemWindow(i);
diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx
index f7a258d..87965d9 100644
--- a/svx/source/fmcomp/fmgridif.cxx
+++ b/svx/source/fmcomp/fmgridif.cxx
@@ -1251,7 +1251,7 @@ Sequence< sal_Bool > SAL_CALL FmXGridPeer::queryFieldDataType( const Type& xType
 
     Reference< XIndexContainer >  xColumns = getColumns();
 
-    FmGridControl* pGrid = static_cast<FmGridControl*>(GetWindow());
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     sal_Int32 nColumns = pGrid->GetViewColCount();
 
     DbGridColumns aColumns = pGrid->GetColumns();
@@ -1305,7 +1305,7 @@ Sequence< sal_Bool > SAL_CALL FmXGridPeer::queryFieldDataType( const Type& xType
 
 Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type& xType ) throw(RuntimeException, std::exception)
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>(GetWindow());
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     DBG_ASSERT(pGrid && pGrid->IsOpen(), "FmXGridPeer::queryFieldData : have no valid grid window !");
     if (!pGrid || !pGrid->IsOpen())
         return Sequence< Any>();
@@ -1737,7 +1737,7 @@ void FmXGridPeer::elementInserted(const ContainerEvent& evt) throw( RuntimeExcep
 {
     SolarMutexGuard aGuard;
 
-    FmGridControl* pGrid = static_cast<FmGridControl*>(GetWindow());
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     // Handle Column beruecksichtigen
     if (!pGrid || !m_xColumns.is() || pGrid->IsInColumnMove() || m_xColumns->getCount() == ((sal_Int32)pGrid->GetModelColCount()))
         return;
@@ -2056,7 +2056,7 @@ Any FmXGridPeer::getProperty( const OUString& _rPropertyName ) throw( RuntimeExc
     Any aProp;
     if (GetWindow())
     {
-        FmGridControl* pGrid = static_cast<FmGridControl*>(GetWindow());
+        VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
         vcl::Window* pDataWindow  = &pGrid->GetDataWindow();
 
         if ( _rPropertyName == FM_PROP_NAME )
@@ -2192,7 +2192,7 @@ void FmXGridPeer::stopCursorListening()
 
 void FmXGridPeer::updateGrid(const Reference< XRowSet >& _rxCursor)
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>(GetWindow());
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     if (pGrid)
         pGrid->setDataSource(_rxCursor);
 }
@@ -2206,7 +2206,7 @@ Reference< XRowSet >  FmXGridPeer::getRowSet() throw( RuntimeException, std::exc
 
 void FmXGridPeer::setRowSet(const Reference< XRowSet >& _rDatabaseCursor) throw( RuntimeException, std::exception )
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>(GetWindow());
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     if (!pGrid || !m_xColumns.is() || !m_xColumns->getCount())
         return;
     // unregister all listeners
@@ -2383,7 +2383,7 @@ void FmXGridPeer::setMode(const OUString& Mode) throw( NoSupportException, Runti
 
     m_aMode = Mode;
 
-    FmGridControl* pGrid = static_cast<FmGridControl*>(GetWindow());
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     if ( Mode == "FilterMode" )
         pGrid->SetFilterMode(true);
     else
@@ -2459,7 +2459,7 @@ void FmXGridPeer::columnHidden(DbGridColumn* pColumn)
 
 void FmXGridPeer::draw( sal_Int32 x, sal_Int32 y ) throw( RuntimeException, std::exception )
 {
-    FmGridControl* pGrid = static_cast<FmGridControl*>(GetWindow());
+    VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     sal_Int32 nOldFlags = pGrid->GetBrowserFlags();
     pGrid->SetBrowserFlags(nOldFlags | EBBF_NOROWPICTURE);
 
@@ -2657,7 +2657,7 @@ void FmXGridPeer::resetted(const EventObject& rEvent) throw( RuntimeException, s
 {
     if (m_xColumns == rEvent.Source)
     {   // my model was reset -> refresh the grid content
-        FmGridControl* pGrid = static_cast<FmGridControl*>(GetWindow());
+        VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
         if (!pGrid)
             return;
         SolarMutexGuard aGuard;
@@ -2667,7 +2667,7 @@ void FmXGridPeer::resetted(const EventObject& rEvent) throw( RuntimeException, s
     else if (m_xCursor == rEvent.Source)
     {
         SolarMutexGuard aGuard;
-        FmGridControl* pGrid = static_cast<FmGridControl*>(GetWindow());
+        VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
         if (pGrid && pGrid->IsOpen())
             pGrid->positioned(rEvent);
     }
commit a13007adddadf7f5c7b503d6732cf11f3e62e619
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Mar 16 17:27:11 2015 +0000

    vcl: fix virtual device lifecycle.
    
    Also remove an over-optimistic assert & ref-holding in dispose piece.
    
    Change-Id: I6ce6abb666c8143502fc450a26e1ba2aac787455

diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index 06dbae6..88f9fb6 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -118,6 +118,7 @@ public:
                                       sal_uInt16 nBitCount);
 
     virtual             ~VirtualDevice();
+    virtual void        dispose() SAL_OVERRIDE;
 
     virtual void        EnableRTL( bool bEnable = true ) SAL_OVERRIDE;
 
diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx
index 04a4719..8be94a5 100644
--- a/vcl/qa/cppunit/lifecycle.cxx
+++ b/vcl/qa/cppunit/lifecycle.cxx
@@ -15,6 +15,7 @@
 #include <vcl/edit.hxx>
 #include <vcl/combobox.hxx>
 #include <vcl/field.hxx>
+#include <vcl/virdev.hxx>
 
 class LifecycleTest : public test::BootstrapFixture
 {
@@ -24,6 +25,7 @@ public:
     LifecycleTest() : BootstrapFixture(true, false) {}
 
     void testCast();
+    void testVirtualDevice();
     void testMultiDispose();
     void testIsolatedWidgets();
     void testParentedWidgets();
@@ -31,6 +33,7 @@ public:
 
     CPPUNIT_TEST_SUITE(LifecycleTest);
     CPPUNIT_TEST(testCast);
+    CPPUNIT_TEST(testVirtualDevice);
     CPPUNIT_TEST(testMultiDispose);
     CPPUNIT_TEST(testIsolatedWidgets);
     CPPUNIT_TEST(testParentedWidgets);
@@ -52,6 +55,11 @@ void LifecycleTest::testCast()
 //    VclPtr<PushButton> xButton2(xWindow);
 }
 
+void LifecycleTest::testVirtualDevice()
+{
+    VclPtr<VirtualDevice> pVDev = new VirtualDevice();
+}
+
 void LifecycleTest::testMultiDispose()
 {
     VclPtr<WorkWindow> xWin(new WorkWindow((vcl::Window *)NULL,
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index 72c20cb..1e807f1 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -236,12 +236,12 @@ WinMtfFontStyle::WinMtfFontStyle( LOGFONTW& rFont )
     {
         // #i117968# VirtualDevice is not thread safe, but filter is used in multithreading
         SolarMutexGuard aGuard;
-        VirtualDevice aVDev;
+        VclPtr<VirtualDevice> pVDev = new VirtualDevice();
 
         // converting the cell height into a font height
         aFont.SetSize( aFontSize );
-        aVDev.SetFont( aFont );
-        FontMetric aMetric( aVDev.GetFontMetric() );
+        pVDev->SetFont( aFont );
+        FontMetric aMetric( pVDev->GetFontMetric() );
         long nHeight = aMetric.GetAscent() + aMetric.GetDescent();
         if (nHeight)
         {
@@ -1448,20 +1448,20 @@ void WinMtfOutput::DrawText( Point& rPosition, OUString& rText, long* pDXArry, b
     {
         // #i117968# VirtualDevice is not thread safe, but filter is used in multithreading
         SolarMutexGuard aGuard;
-        VirtualDevice aVDev;
+        VclPtr<VirtualDevice> pVDev = new VirtualDevice();
 
         sal_Int32 nTextWidth;
-        aVDev.SetMapMode( MapMode( MAP_100TH_MM ) );
-        aVDev.SetFont( maFont );
+        pVDev->SetMapMode( MapMode( MAP_100TH_MM ) );
+        pVDev->SetFont( maFont );
         if( pDXArry )
         {
             sal_uInt32 nLen = rText.getLength();
-            nTextWidth = aVDev.GetTextWidth( OUString(rText[ nLen - 1 ]) );
+            nTextWidth = pVDev->GetTextWidth( OUString(rText[ nLen - 1 ]) );
             if( nLen > 1 )
                 nTextWidth += pDXArry[ nLen - 2 ];
         }
         else
-            nTextWidth = aVDev.GetTextWidth( rText );
+            nTextWidth = pVDev->GetTextWidth( rText );
 
         if( mnTextAlign & TA_UPDATECP )
             rPosition = maActPos;
@@ -1497,12 +1497,12 @@ void WinMtfOutput::DrawText( Point& rPosition, OUString& rText, long* pDXArry, b
         {
             // #i117968# VirtualDevice is not thread safe, but filter is used in multithreading
             SolarMutexGuard aGuard;
-            VirtualDevice aVDev;
+            VclPtr<VirtualDevice> pVDev = new VirtualDevice();
 
             pDX = new long[ rText.getLength() ];
-            aVDev.SetMapMode( MAP_100TH_MM );
-            aVDev.SetFont( maLatestFont );
-            aVDev.GetTextArray( rText, pDX, 0, rText.getLength());
+            pVDev->SetMapMode( MAP_100TH_MM );
+            pVDev->SetFont( maLatestFont );
+            pVDev->GetTextArray( rText, pDX, 0, rText.getLength());
         }
         mpGDIMetaFile->AddAction( new MetaTextArrayAction( rPosition, rText, pDX, 0, rText.getLength() ) );
         if ( !pDXArry )     // this means we have created our own array
@@ -1516,26 +1516,26 @@ void WinMtfOutput::ImplDrawBitmap( const Point& rPos, const Size& rSize, const B
     BitmapEx aBmpEx( rBitmap );
     if ( mbComplexClip )
     {
-        VirtualDevice aVDev;
+        VclPtr<VirtualDevice> pVDev = new VirtualDevice();
         MapMode aMapMode( MAP_100TH_MM );
         aMapMode.SetOrigin( Point( -rPos.X(), -rPos.Y() ) );
-        const Size aOutputSizePixel( aVDev.LogicToPixel( rSize, aMapMode ) );
+        const Size aOutputSizePixel( pVDev->LogicToPixel( rSize, aMapMode ) );
         const Size aSizePixel( rBitmap.GetSizePixel() );
         if ( aOutputSizePixel.Width() && aOutputSizePixel.Height() )
         {
             aMapMode.SetScaleX( Fraction( aSizePixel.Width(), aOutputSizePixel.Width() ) );
             aMapMode.SetScaleY( Fraction( aSizePixel.Height(), aOutputSizePixel.Height() ) );
         }
-        aVDev.SetMapMode( aMapMode );
-        aVDev.SetOutputSizePixel( aSizePixel );
-        aVDev.SetFillColor( Color( COL_BLACK ) );
+        pVDev->SetMapMode( aMapMode );
+        pVDev->SetOutputSizePixel( aSizePixel );
+        pVDev->SetFillColor( Color( COL_BLACK ) );
         const tools::PolyPolygon aClip( aClipPath.getClipPath() );
-        aVDev.DrawPolyPolygon( aClip );
+        pVDev->DrawPolyPolygon( aClip );
         const Point aEmptyPoint;
 
         // #i50672# Extract whole VDev content (to match size of rBitmap)
-        aVDev.EnableMapMode( false );
-        Bitmap aMask( aVDev.GetBitmap( aEmptyPoint, aSizePixel ).CreateMask( Color( COL_WHITE ) ) );
+        pVDev->EnableMapMode( false );
+        Bitmap aMask( pVDev->GetBitmap( aEmptyPoint, aSizePixel ).CreateMask( Color( COL_WHITE ) ) );
 
         if ( aBmpEx.IsTransparent() )
         {
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index eec2fa9..b8ce392 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -255,6 +255,12 @@ VirtualDevice::VirtualDevice(const SystemGraphicsData *pData, const Size &rSize,
 VirtualDevice::~VirtualDevice()
 {
     SAL_INFO( "vcl.gdi", "VirtualDevice::~VirtualDevice()" );
+    disposeOnce();
+}
+
+void VirtualDevice::dispose()
+{
+    SAL_INFO( "vcl.gdi", "VirtualDevice::dispose()" );
 
     ImplSVData* pSVData = ImplGetSVData();
 
@@ -272,6 +278,8 @@ VirtualDevice::~VirtualDevice()
         mpNext->mpPrev = mpPrev;
     else
         pSVData->maGDIData.mpLastVirDev = mpPrev;
+
+    OutputDevice::dispose();
 }
 
 bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index 5d59ee1..d39a76d 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -82,6 +82,7 @@ namespace {
 // Begin initializer and accessor public functions
 
 OutputDevice::OutputDevice() :
+    mnRefCnt(0),
     maRegion(true),
     maFillColor( COL_WHITE ),
     maTextLineColor( COL_TRANSPARENT ),
@@ -179,6 +180,8 @@ OutputDevice::OutputDevice() :
     // #i75163#
     mpOutDevData->mpViewTransform   = NULL;
     mpOutDevData->mpInverseViewTransform = NULL;
+
+    mbDisposed = false;
 }
 
 OutputDevice::~OutputDevice()
@@ -194,10 +197,10 @@ void OutputDevice::disposeOnce()
 
     // catch badness where our OutputDevice sub-class was not
     // wrapped safely in a VclPtr cosily.
-    assert( mnRefCnt > 0 );
+    // FIXME: as/when we make our destructors all protected,
+    // we should introduce this assert:
+    //    assert( mnRefCnt > 0 );
 
-    // hold a ref in case something unusual happens during dispose.
-    VclPtr<OutputDevice> aRef(this);
     dispose();
 }
 
commit efa40d415046d377b293fea14a4a3c3fd1bf0129
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Mar 16 15:24:04 2015 +0000

    vclptr: switch printers away from boost_shared.
    
    Also continue to move to extended toolkit/ API.
    
    Change-Id: Ibd4337b014ee096c84d0ad4435e2c5de1b258afe

diff --git a/dbaccess/source/ui/control/toolboxcontroller.cxx b/dbaccess/source/ui/control/toolboxcontroller.cxx
index cb6d306..ca97d79 100644
--- a/dbaccess/source/ui/control/toolboxcontroller.cxx
+++ b/dbaccess/source/ui/control/toolboxcontroller.cxx
@@ -131,7 +131,7 @@ namespace dbaui
         for (; aIter != aEnd; ++aIter)
             addStatusListener(aIter->first);
 
-        ToolBox*    pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+        VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()).get());
         if ( pToolBox )
         {
             sal_uInt16 nCount = pToolBox->GetItemCount();
diff --git a/include/toolkit/awt/vclxprinter.hxx b/include/toolkit/awt/vclxprinter.hxx
index 892cc4c..2c20ccd 100644
--- a/include/toolkit/awt/vclxprinter.hxx
+++ b/include/toolkit/awt/vclxprinter.hxx
@@ -57,11 +57,11 @@ class VCLXPrinterPropertySet    :public VCLXPrinterPropertySet_Base
                                 ,public ::cppu::OPropertySetHelper
 {
 protected:
-    std::shared_ptr<Printer>                      mxPrinter;
+    VclPtr<Printer>             mpPrinter;
     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice >  mxPrnDevice;
 
     sal_Int16                   mnOrientation;
-    bool                    mbHorizontal;
+    bool                        mbHorizontal;
 public:
     VCLXPrinterPropertySet( const OUString& rPrinterName );
     virtual ~VCLXPrinterPropertySet();
diff --git a/include/vcl/oldprintadaptor.hxx b/include/vcl/oldprintadaptor.hxx
index 72d1163..987b58f 100644
--- a/include/vcl/oldprintadaptor.hxx
+++ b/include/vcl/oldprintadaptor.hxx
@@ -29,7 +29,7 @@ namespace vcl
     {
         ImplOldStyleAdaptorData*    mpData;
     public:
-        OldStylePrintAdaptor(const std::shared_ptr<Printer>&);
+        OldStylePrintAdaptor( const VclPtr< Printer >& );
         virtual ~OldStylePrintAdaptor();
 
         void StartPage();
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index d749769..bf7ea47 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -426,7 +426,7 @@ class VCL_DLLPUBLIC PrinterController
 {
     ImplPrinterControllerData* mpImplData;
 protected:
-    PrinterController( const std::shared_ptr<Printer>& );
+    PrinterController( const VclPtr<Printer>& );
 public:
     enum NupOrderType
     { LRTB, TBLR, TBRL, RLTB };
@@ -469,7 +469,7 @@ public:
 
     virtual ~PrinterController();
 
-    const std::shared_ptr<Printer>& getPrinter() const;
+    const VclPtr<Printer>& getPrinter() const;
     /* for implementations: get current job properties as changed by e.g. print dialog
        this gets the current set of properties initially told to Printer::PrintJob
 
@@ -550,7 +550,7 @@ public:
     SAL_DLLPRIVATE PageSize getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false );
     VCL_PLUGIN_PUBLIC PageSize getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache = false );
     VCL_PLUGIN_PUBLIC void printFilteredPage( int i_nPage );
-    SAL_DLLPRIVATE void setPrinter( const std::shared_ptr<Printer>& );
+    SAL_DLLPRIVATE void setPrinter( const VclPtr<Printer>& );
     SAL_DLLPRIVATE void setOptionChangeHdl( const Link& );
     VCL_PLUGIN_PUBLIC void createProgressDialog();
     VCL_PLUGIN_PUBLIC bool isProgressCanceled() const;
diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx
index fdc4f1c..ff6b506 100644
--- a/sfx2/source/dialog/backingcomp.cxx
+++ b/sfx2/source/dialog/backingcomp.cxx
@@ -431,7 +431,7 @@ void SAL_CALL BackingComp::attachFrame( /*IN*/ const css::uno::Reference< css::f
     }
 
     // inform BackingWindow about frame
-    BackingWindow* pBack = dynamic_cast<BackingWindow*>(pWindow );
+    BackingWindow* pBack = dynamic_cast<BackingWindow*>(pWindow.get());
     if( pBack )
         pBack->setOwningFrame( m_xFrame );
 
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index d30b5ee..4b6e56d 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -59,7 +59,7 @@ class SfxPrinterController : public vcl::PrinterController, public SfxListener
     Any                                     maCompleteSelection;
     Any                                     maSelection;
     Reference< view::XRenderable >          mxRenderable;
-    mutable Printer*                        mpLastPrinter;
+    mutable VclPtr<Printer>                 mpLastPrinter;
     mutable Reference<awt::XDevice>         mxDevice;
     SfxViewShell*                           mpViewShell;
     SfxObjectShell*                         mpObjectShell;
@@ -74,7 +74,7 @@ class SfxPrinterController : public vcl::PrinterController, public SfxListener
     const Any& getSelectionObject() const;
 
 public:
-    SfxPrinterController( const std::shared_ptr<Printer>& i_rPrinter,
+    SfxPrinterController( const VclPtr<Printer>& i_rPrinter,
                           const Any& i_rComplete,
                           const Any& i_rSelection,
                           const Any& i_rViewProp,
@@ -94,7 +94,7 @@ public:
     virtual void jobFinished( com::sun::star::view::PrintableState ) SAL_OVERRIDE;
 };
 
-SfxPrinterController::SfxPrinterController( const std::shared_ptr<Printer>& i_rPrinter,
+SfxPrinterController::SfxPrinterController( const VclPtr<Printer>& i_rPrinter,
                                             const Any& i_rComplete,
                                             const Any& i_rSelection,
                                             const Any& i_rViewProp,
@@ -204,12 +204,12 @@ const Any& SfxPrinterController::getSelectionObject() const
 
 Sequence< beans::PropertyValue > SfxPrinterController::getMergedOptions() const
 {
-    std::shared_ptr<Printer> xPrinter(getPrinter());
-    if (xPrinter.get() != mpLastPrinter)
+    VclPtr<Printer> xPrinter( getPrinter() );
+    if( xPrinter.get() != mpLastPrinter )
     {
         mpLastPrinter = xPrinter.get();
         VCLXDevice* pXDevice = new VCLXDevice();
-        pXDevice->SetOutputDevicePtr( mpLastPrinter );
+        pXDevice->SetOutputDevice( mpLastPrinter );
         mxDevice = Reference< awt::XDevice >( pXDevice );
     }
 
@@ -224,8 +224,8 @@ Sequence< beans::PropertyValue > SfxPrinterController::getMergedOptions() const
 int SfxPrinterController::getPageCount() const
 {
     int nPages = 0;
-    std::shared_ptr<Printer> xPrinter(getPrinter());
-    if (mxRenderable.is() && xPrinter)
+    VclPtr<Printer> xPrinter( getPrinter() );
+    if( mxRenderable.is() && pPrinter )
     {
         Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() );
         try
@@ -244,7 +244,7 @@ int SfxPrinterController::getPageCount() const
 
 Sequence< beans::PropertyValue > SfxPrinterController::getPageParameters( int i_nPage ) const
 {
-    std::shared_ptr<Printer> xPrinter(getPrinter());
+    VclPtr<Printer> xPrinter( getPrinter() );
     Sequence< beans::PropertyValue > aResult;
 
     if (mxRenderable.is() && xPrinter)
@@ -269,8 +269,8 @@ Sequence< beans::PropertyValue > SfxPrinterController::getPageParameters( int i_
 
 void SfxPrinterController::printPage( int i_nPage ) const
 {
-    std::shared_ptr<Printer> xPrinter(getPrinter());
-    if (mxRenderable.is() && xPrinter)
+    VclPtr<Printer> xPrinter( getPrinter() );
+    if( mxRenderable.is() && pPrinter )
     {
         Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() );
         try
@@ -451,8 +451,8 @@ IMPL_LINK_NOARG(SfxDialogExecutor_Impl, Execute)
         return 0;
 
     // Create Dialog
-    boost::scoped_ptr<SfxPrintOptionsDialog> pDlg(new SfxPrintOptionsDialog( static_cast<vcl::Window*>(_pSetupParent),
-                                                             _pViewSh, _pOptions ));
+    VclPtr<SfxPrintOptionsDialog> pDlg(new SfxPrintOptionsDialog( static_cast<vcl::Window*>(_pSetupParent),
+                                                                  _pViewSh, _pOptions ));
     if ( _bHelpDisabled )
         pDlg->DisableHelp();
     if ( pDlg->Execute() == RET_OK )
@@ -582,7 +582,7 @@ void SfxViewShell::StartPrint( const uno::Sequence < beans::PropertyValue >& rPr
         aSelection <<= GetObjectShell()->GetModel();
     Any aComplete( makeAny( GetObjectShell()->GetModel() ) );
     Any aViewProp( makeAny( xController ) );
-    std::shared_ptr<Printer> aPrt;
+    VclPtr<Printer> aPrt;
 
     const beans::PropertyValue* pVal = rProps.getConstArray();
     for( sal_Int32 i = 0; i < rProps.getLength(); i++ )
diff --git a/vcl/generic/print/genprnpsp.cxx b/vcl/generic/print/genprnpsp.cxx
index 62a4bdd..1977e2d 100644
--- a/vcl/generic/print/genprnpsp.cxx
+++ b/vcl/generic/print/genprnpsp.cxx
@@ -1079,7 +1079,7 @@ bool PspSalPrinter::StartJob( const OUString* i_pFileName, const OUString& i_rJo
 
     std::shared_ptr<vcl::PDFWriter> xWriter;
     std::vector< PDFPrintFile > aPDFFiles;
-    std::shared_ptr<Printer> xPrinter(i_rController.getPrinter());
+    VclPtr<Printer> xPrinter( i_rController.getPrinter() );
     int nAllPages = i_rController.getFilteredPageCount();
     i_rController.createProgressDialog();
     bool bAborted = false;
diff --git a/vcl/osx/salprn.cxx b/vcl/osx/salprn.cxx
index 0becb85..ed631b0 100644
--- a/vcl/osx/salprn.cxx
+++ b/vcl/osx/salprn.cxx
@@ -448,7 +448,7 @@ bool AquaSalInfoPrinter::StartJob( const OUString* i_pFileName,
             // information (e.g. brochure printing scales to the found paper size)
             // also SetPaperSizeUser has the advantage that we can share a
             // platform independent paper matching algorithm
-            std::shared_ptr<Printer> pPrinter( i_rController.getPrinter() );
+            VclPtr<Printer> pPrinter( i_rController.getPrinter() );
             pPrinter->SetMapMode( MapMode( MAP_100TH_MM ) );
             pPrinter->SetPaperSizeUser( aCurSize, true );
 
diff --git a/vcl/source/gdi/oldprintadaptor.cxx b/vcl/source/gdi/oldprintadaptor.cxx
index b1485a9..b71d9dd 100644
--- a/vcl/source/gdi/oldprintadaptor.cxx
+++ b/vcl/source/gdi/oldprintadaptor.cxx
@@ -44,8 +44,8 @@ using namespace com::sun::star;
 using namespace com::sun::star::uno;
 using namespace com::sun::star::beans;
 
-OldStylePrintAdaptor::OldStylePrintAdaptor(const std::shared_ptr< Printer >& i_xPrinter)
-    : PrinterController(i_xPrinter)
+OldStylePrintAdaptor::OldStylePrintAdaptor( const VclPtr< Printer >& i_xPrinter )
+    : PrinterController( i_xPrinter )
     , mpData( new ImplOldStyleAdaptorData() )
 {
 }
@@ -64,7 +64,7 @@ void OldStylePrintAdaptor::StartPage()
     getPrinter()->SetConnectMetaFile( &mpData->maPages.back().maPage );
 
     // copy state into metafile
-    std::shared_ptr<Printer> xPrinter(getPrinter());
+    VclPtr<Printer> xPrinter( getPrinter() );
     xPrinter->SetMapMode(xPrinter->GetMapMode());
     xPrinter->SetFont(xPrinter->GetFont());
     xPrinter->SetDrawMode(xPrinter->GetDrawMode());
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 9821154..c6d33e0 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -140,7 +140,7 @@ public:
     typedef std::unordered_map< OUString, ControlDependency, OUStringHash > ControlDependencyMap;
     typedef std::unordered_map< OUString, Sequence< sal_Bool >, OUStringHash > ChoiceDisableMap;
 
-    std::shared_ptr<Printer>                                    mxPrinter;
+    VclPtr< Printer >                                           mxPrinter;
     Sequence< PropertyValue >                                   maUIOptions;
     std::vector< PropertyValue >                                maUIProperties;
     std::vector< bool >                                         maUIPropertyEnabled;
@@ -206,7 +206,7 @@ public:
     void resetPaperToLastConfigured();
 };
 
-PrinterController::PrinterController(const std::shared_ptr<Printer>& i_xPrinter)
+PrinterController::PrinterController( const VclPtr<Printer>& i_xPrinter )
     : mpImplData( new ImplPrinterControllerData )
 {
     mpImplData->mxPrinter = i_xPrinter;
@@ -319,7 +319,7 @@ void Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
     if (!xController->getPrinter())
     {
         OUString aPrinterName( i_rInitSetup.GetPrinterName() );
-        std::shared_ptr<Printer> xPrinter(std::make_shared<Printer>(aPrinterName));
+        VclPtr<Printer> xPrinter( new Printer( aPrinterName ) );
         xPrinter->SetJobSetup(i_rInitSetup);
         xController->setPrinter(xPrinter);
     }
@@ -770,12 +770,12 @@ void PrinterController::setJobState( view::PrintableState i_eState )
     mpImplData->meJobState = i_eState;
 }
 
-const std::shared_ptr<Printer>& PrinterController::getPrinter() const
+const VclPtr<Printer>& PrinterController::getPrinter() const
 {
     return mpImplData->mxPrinter;
 }
 
-void PrinterController::setPrinter(const std::shared_ptr<Printer>& i_rPrinter)
+void PrinterController::setPrinter( const VclPtr<Printer>& i_rPrinter )
 {
     mpImplData->mxPrinter = i_rPrinter;
     setValue( OUString( "Name" ),
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 096f26f..d9c89f0 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -623,13 +623,13 @@ PrintDialog::PrintDialog( vcl::Window* i_pParent, const std::shared_ptr<PrinterC
         if( maJobPage.mpPrinters->GetEntryPos( aValue ) != LISTBOX_ENTRY_NOTFOUND )
         {
             maJobPage.mpPrinters->SelectEntry( aValue );
-            maPController->setPrinter(std::make_shared<Printer>(aValue));
+            maPController->setPrinter( VclPtr<Printer>( new Printer( aValue ) ) );
         }
         else
         {
             // fall back to default printer
             maJobPage.mpPrinters->SelectEntry( Printer::GetDefaultPrinterName() );
-            maPController->setPrinter(std::make_shared<Printer>(Printer::GetDefaultPrinterName()));
+            maPController->setPrinter( VclPtr<Printer>( new Printer( Printer::GetDefaultPrinterName() ) ) );
         }
     }
     // not printing to file
@@ -1327,7 +1327,7 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache )
     {
         const MapMode aMapMode( MAP_100TH_MM );
         GDIMetaFile aMtf;
-        std::shared_ptr<Printer> aPrt(maPController->getPrinter());
+        VclPtr<Printer> aPrt( maPController->getPrinter() );
         if( nPages > 0 )
         {
             PrinterController::PageSize aPageSize =
@@ -1520,7 +1520,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox )
     {
         OUString aNewPrinter( pBox->GetSelectEntry() );
         // set new printer
-        maPController->setPrinter(std::make_shared<Printer>(aNewPrinter));
+        maPController->setPrinter( VclPtr<Printer>( new Printer( aNewPrinter ) ) );
         maPController->resetPrinterOptions( maOptionsPage.mpToFileBox->IsChecked() );
         // update text fields
         updatePrinterText();


More information about the Libreoffice-commits mailing list