basctl/source/basicide/basicrenderable.cxx | 8 +-- 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 | 6 +- 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 sfx2/source/dialog/backingcomp.cxx | 2 sfx2/source/view/viewprn.cxx | 22 ++++---- svx/source/dialog/srchdlg.cxx | 2 svx/source/fmcomp/fmgridif.cxx | 20 +++---- 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 | 4 - vcl/source/gdi/print3.cxx | 10 +-- vcl/source/gdi/virdev.cxx | 8 +++ vcl/source/outdev/outdev.cxx | 9 ++- vcl/source/window/printdlg.cxx | 8 +-- 28 files changed, 111 insertions(+), 94 deletions(-)
New commits: commit e9e208b0ad8dcf92299d00ebc69f23d4cd80bdb6 Author: Michael Meeks <michael.me...@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 013807e..04b372d 100644 --- a/basctl/source/basicide/basicrenderable.cxx +++ b/basctl/source/basicide/basicrenderable.cxx @@ -75,17 +75,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 ec0df94..7de5623 100644 --- a/chart2/source/controller/main/ShapeToolbarController.cxx +++ b/chart2/source/controller/main/ShapeToolbarController.cxx @@ -109,7 +109,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 720cc6f..7b0ba7b 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 940a5d6..81cf9c6 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 0823681..86877fc 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 2c82f13..4fd1961 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 90eab6f..50a72a0 100644 --- a/forms/source/richtext/richtextcontrol.cxx +++ b/forms/source/richtext/richtextcontrol.cxx @@ -339,7 +339,7 @@ namespace frm { { SolarMutexGuard aGuard; - RichTextControl* pRichTextControl = static_cast< RichTextControl* >( GetWindow() ); + VclPtr< RichTextControl > pRichTextControl = GetAs< RichTextControl* >(); if ( pRichTextControl ) { @@ -442,7 +442,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 ); @@ -494,7 +494,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 8e6b4d4..6d6c218 100644 --- a/forms/source/solar/component/navbarcontrol.cxx +++ b/forms/source/solar/component/navbarcontrol.cxx @@ -292,7 +292,7 @@ namespace frm { SolarMutexGuard aGuard; - NavigationToolBar* pNavBar = static_cast< NavigationToolBar* >( GetWindow() ); + VclPtr< NavigationToolBar > pNavBar = GetAs< NavigationToolBar >(); if ( !pNavBar ) { VCLXWindow::setProperty( _rPropertyName, _rValue ); @@ -373,7 +373,7 @@ namespace frm SolarMutexGuard aGuard; Any aReturn; - NavigationToolBar* pNavBar = static_cast< NavigationToolBar* >( GetWindow() ); + VclPtr< NavigationToolBar > pNavBar = GetAs< NavigationToolBar >(); if ( _rPropertyName == PROPERTY_BACKGROUNDCOLOR ) { @@ -425,7 +425,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 ); @@ -453,7 +453,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 793da1a..ca67bf4 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -2304,7 +2304,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 5fb30f0..149b418 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>(); @@ -1738,7 +1738,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; @@ -2057,7 +2057,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 ) @@ -2193,7 +2193,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); } @@ -2207,7 +2207,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 @@ -2384,7 +2384,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 @@ -2460,7 +2460,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); @@ -2658,7 +2658,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; @@ -2668,7 +2668,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 02233a99d3696883a3bfe606b9f945e3deb4d4ef Author: Michael Meeks <michael.me...@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 b6361bf..938eca6 100644 --- a/include/vcl/virdev.hxx +++ b/include/vcl/virdev.hxx @@ -120,6 +120,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 e15f2e0..ce43576 100644 --- a/vcl/source/filter/wmf/winmtf.cxx +++ b/vcl/source/filter/wmf/winmtf.cxx @@ -230,12 +230,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) { @@ -1436,20 +1436,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; @@ -1485,12 +1485,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 @@ -1504,26 +1504,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 7436b10..fd04aec 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -80,6 +80,7 @@ namespace { // Begin initializer and accessor public functions OutputDevice::OutputDevice() : + mnRefCnt(0), maRegion(true), maFillColor( COL_WHITE ), maTextLineColor( COL_TRANSPARENT ), @@ -177,6 +178,8 @@ OutputDevice::OutputDevice() : // #i75163# mpOutDevData->mpViewTransform = NULL; mpOutDevData->mpInverseViewTransform = NULL; + + mbDisposed = false; } OutputDevice::~OutputDevice() @@ -192,10 +195,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 41f6596d3b4fe24e09ba273e4b6eefe5daf45dbb Author: Michael Meeks <michael.me...@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 434c47a..877d07d 100644 --- a/include/toolkit/awt/vclxprinter.hxx +++ b/include/toolkit/awt/vclxprinter.hxx @@ -56,11 +56,11 @@ class VCLXPrinterPropertySet :public VCLXPrinterPropertySet_Base ,public ::cppu::OPropertySetHelper { protected: - boost::shared_ptr<Printer> mpPrinter; + 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 fe71548..987b58f 100644 --- a/include/vcl/oldprintadaptor.hxx +++ b/include/vcl/oldprintadaptor.hxx @@ -29,7 +29,7 @@ namespace vcl { ImplOldStyleAdaptorData* mpData; public: - OldStylePrintAdaptor( const boost::shared_ptr< Printer >& ); + OldStylePrintAdaptor( const VclPtr< Printer >& ); virtual ~OldStylePrintAdaptor(); void StartPage(); diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx index 99d781e..756cb27 100644 --- a/include/vcl/print.hxx +++ b/include/vcl/print.hxx @@ -419,7 +419,7 @@ class VCL_DLLPUBLIC PrinterController { ImplPrinterControllerData* mpImplData; protected: - PrinterController( const boost::shared_ptr<Printer>& ); + PrinterController( const VclPtr<Printer>& ); public: enum NupOrderType { LRTB, TBLR, TBRL, RLTB }; @@ -462,7 +462,7 @@ public: virtual ~PrinterController(); - const boost::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 @@ -543,7 +543,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 boost::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 27f9516..70af3d6 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 bfe2825..3b51d0d 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 boost::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 boost::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 { - boost::shared_ptr<Printer> pPrinter( getPrinter() ); + VclPtr<Printer> pPrinter( getPrinter() ); if( pPrinter.get() != mpLastPrinter ) { mpLastPrinter = pPrinter.get(); VCLXDevice* pXDevice = new VCLXDevice(); - pXDevice->SetOutputDevicePtr( mpLastPrinter ); + pXDevice->SetOutputDevice( mpLastPrinter ); mxDevice = Reference< awt::XDevice >( pXDevice ); } @@ -224,7 +224,7 @@ Sequence< beans::PropertyValue > SfxPrinterController::getMergedOptions() const int SfxPrinterController::getPageCount() const { int nPages = 0; - boost::shared_ptr<Printer> pPrinter( getPrinter() ); + VclPtr<Printer> pPrinter( getPrinter() ); if( mxRenderable.is() && pPrinter ) { Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() ); @@ -244,7 +244,7 @@ int SfxPrinterController::getPageCount() const Sequence< beans::PropertyValue > SfxPrinterController::getPageParameters( int i_nPage ) const { - boost::shared_ptr<Printer> pPrinter( getPrinter() ); + VclPtr<Printer> pPrinter( getPrinter() ); Sequence< beans::PropertyValue > aResult; if( mxRenderable.is() && pPrinter ) @@ -269,7 +269,7 @@ Sequence< beans::PropertyValue > SfxPrinterController::getPageParameters( int i_ void SfxPrinterController::printPage( int i_nPage ) const { - boost::shared_ptr<Printer> pPrinter( getPrinter() ); + VclPtr<Printer> pPrinter( getPrinter() ); if( mxRenderable.is() && pPrinter ) { Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() ); @@ -453,8 +453,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::ExecPrint( const uno::Sequence < beans::PropertyValue >& rPro aSelection <<= GetObjectShell()->GetModel(); Any aComplete( makeAny( GetObjectShell()->GetModel() ) ); Any aViewProp( makeAny( xController ) ); - boost::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 7107f84..2e7901a 100644 --- a/vcl/generic/print/genprnpsp.cxx +++ b/vcl/generic/print/genprnpsp.cxx @@ -1078,7 +1078,7 @@ bool PspSalPrinter::StartJob( const OUString* i_pFileName, const OUString& i_rJo boost::shared_ptr<vcl::PDFWriter> pWriter; std::vector< PDFPrintFile > aPDFFiles; - boost::shared_ptr<Printer> pPrinter( i_rController.getPrinter() ); + VclPtr<Printer> pPrinter( 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 f8fe422..6cf40d1 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 - boost::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 3270f75..ea2cd61 100644 --- a/vcl/source/gdi/oldprintadaptor.cxx +++ b/vcl/source/gdi/oldprintadaptor.cxx @@ -44,7 +44,7 @@ using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::beans; -OldStylePrintAdaptor::OldStylePrintAdaptor( const boost::shared_ptr< Printer >& i_pPrinter ) +OldStylePrintAdaptor::OldStylePrintAdaptor( const VclPtr< Printer >& i_pPrinter ) : PrinterController( i_pPrinter ) , mpData( new ImplOldStyleAdaptorData() ) { @@ -64,7 +64,7 @@ void OldStylePrintAdaptor::StartPage() getPrinter()->SetConnectMetaFile( &mpData->maPages.back().maPage ); // copy state into metafile - boost::shared_ptr<Printer> pPrinter( getPrinter() ); + VclPtr<Printer> pPrinter( getPrinter() ); pPrinter->SetMapMode( pPrinter->GetMapMode() ); pPrinter->SetFont( pPrinter->GetFont() ); pPrinter->SetDrawMode( pPrinter->GetDrawMode() ); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 609dfd2..dc341bf 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -140,7 +140,7 @@ public: typedef boost::unordered_map< OUString, ControlDependency, OUStringHash > ControlDependencyMap; typedef boost::unordered_map< OUString, Sequence< sal_Bool >, OUStringHash > ChoiceDisableMap; - boost::shared_ptr<Printer> mpPrinter; + VclPtr< Printer > mpPrinter; Sequence< PropertyValue > maUIOptions; std::vector< PropertyValue > maUIProperties; std::vector< bool > maUIPropertyEnabled; @@ -206,7 +206,7 @@ public: void resetPaperToLastConfigured(); }; -PrinterController::PrinterController( const boost::shared_ptr<Printer>& i_pPrinter ) +PrinterController::PrinterController( const VclPtr<Printer>& i_pPrinter ) : mpImplData( new ImplPrinterControllerData ) { mpImplData->mpPrinter = i_pPrinter; @@ -326,7 +326,7 @@ void Printer::ImplPrintJob( const boost::shared_ptr<PrinterController>& i_pContr if( ! pController->getPrinter() ) { OUString aPrinterName( i_rInitSetup.GetPrinterName() ); - boost::shared_ptr<Printer> pPrinter( new Printer( aPrinterName ) ); + VclPtr<Printer> pPrinter( new Printer( aPrinterName ) ); pPrinter->SetJobSetup( i_rInitSetup ); pController->setPrinter( pPrinter ); } @@ -763,12 +763,12 @@ void PrinterController::setJobState( view::PrintableState i_eState ) mpImplData->meJobState = i_eState; } -const boost::shared_ptr<Printer>& PrinterController::getPrinter() const +const VclPtr<Printer>& PrinterController::getPrinter() const { return mpImplData->mpPrinter; } -void PrinterController::setPrinter( const boost::shared_ptr<Printer>& i_rPrinter ) +void PrinterController::setPrinter( const VclPtr<Printer>& i_rPrinter ) { mpImplData->mpPrinter = i_rPrinter; setValue( OUString( "Name" ), diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index f6cd596..0d4d895 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -631,13 +631,13 @@ PrintDialog::PrintDialog( vcl::Window* i_pParent, const boost::shared_ptr<Printe if( maJobPage.mpPrinters->GetEntryPos( aValue ) != LISTBOX_ENTRY_NOTFOUND ) { maJobPage.mpPrinters->SelectEntry( aValue ); - maPController->setPrinter( boost::shared_ptr<Printer>( new Printer( aValue ) ) ); + maPController->setPrinter( VclPtr<Printer>( new Printer( aValue ) ) ); } else { // fall back to default printer maJobPage.mpPrinters->SelectEntry( Printer::GetDefaultPrinterName() ); - maPController->setPrinter( boost::shared_ptr<Printer>( new Printer( Printer::GetDefaultPrinterName() ) ) ); + maPController->setPrinter( VclPtr<Printer>( new Printer( Printer::GetDefaultPrinterName() ) ) ); } } // not printing to file @@ -1337,7 +1337,7 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) { const MapMode aMapMode( MAP_100TH_MM ); GDIMetaFile aMtf; - boost::shared_ptr<Printer> aPrt( maPController->getPrinter() ); + VclPtr<Printer> aPrt( maPController->getPrinter() ); if( nPages > 0 ) { PrinterController::PageSize aPageSize = @@ -1530,7 +1530,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) { OUString aNewPrinter( pBox->GetSelectEntry() ); // set new printer - maPController->setPrinter( boost::shared_ptr<Printer>( new Printer( aNewPrinter ) ) ); + maPController->setPrinter( VclPtr<Printer>( new Printer( aNewPrinter ) ) ); maPController->resetPrinterOptions( maOptionsPage.mpToFileBox->IsChecked() ); // update text fields updatePrinterText(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits