From cf06c0135d44b8f553940d0fabe03918d61d8a8f Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Wed, 18 Mar 2015 20:52:22 +0000 Subject: start of unwinding reference OutputDevice & Printer lifecycle. Change-Id: I066337f46a3c39d1eaba5e7a1f4e1278816a0b27 --- sw/source/core/doc/DocumentDeviceManager.cxx | 22 +++++++++++----------- sw/source/core/inc/DocumentDeviceManager.hxx | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/DocumentDeviceManager.cxx b/sw/source/core/doc/DocumentDeviceManager.cxx index f2f751779ff9..5d38a936b13a 100644 --- a/sw/source/core/doc/DocumentDeviceManager.cxx +++ b/sw/source/core/doc/DocumentDeviceManager.cxx @@ -55,8 +55,8 @@ DocumentDeviceManager::DocumentDeviceManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwd SfxPrinter* DocumentDeviceManager::getPrinter(/*[in]*/ bool bCreate ) const { SfxPrinter* pRet = 0; - if ( !bCreate || mpPrt ) - pRet = mpPrt; + if ( !bCreate || mpPrt ) + pRet = mpPrt; else pRet = &CreatePrinter_(); @@ -65,10 +65,10 @@ SfxPrinter* DocumentDeviceManager::getPrinter(/*[in]*/ bool bCreate ) const void DocumentDeviceManager::setPrinter(/*[in]*/ SfxPrinter *pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged ) { - if ( pP != mpPrt ) + if ( pP != mpPrt ) { if ( bDeleteOld ) - delete mpPrt; + mpPrt.disposeAndClear(); mpPrt = pP; // our printer should always use TWIP. Don't rely on this being set in SwViewShell::InitPrt, there @@ -78,7 +78,7 @@ void DocumentDeviceManager::setPrinter(/*[in]*/ SfxPrinter *pP,/*[in]*/ bool bDe { MapMode aMapMode( mpPrt->GetMapMode() ); aMapMode.SetMapUnit( MAP_TWIP ); - mpPrt->SetMapMode( aMapMode ); + mpPrt->SetMapMode( aMapMode ); } if ( m_rDoc.getIDocumentDrawModelAccess().GetDrawModel() && !m_rDoc.GetDocumentSettingManager().get( DocumentSettingId::USE_VIRTUAL_DEVICE ) ) @@ -105,10 +105,10 @@ VirtualDevice* DocumentDeviceManager::getVirtualDevice(/*[in]*/ bool bCreate ) c void DocumentDeviceManager::setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool ) { - if ( mpVirDev != pVd ) + if ( mpVirDev.get() != pVd ) { if ( bDeleteOld ) - delete mpVirDev; + mpVirDev.disposeAndClear(); mpVirDev = pVd; if ( m_rDoc.getIDocumentDrawModelAccess().GetDrawModel() && m_rDoc.GetDocumentSettingManager().get( DocumentSettingId::USE_VIRTUAL_DEVICE ) ) @@ -193,7 +193,7 @@ void DocumentDeviceManager::setJobsetup(/*[in]*/ const JobSetup &rJobSetup ) } } else - delete mpPrt, mpPrt = 0; + mpPrt.disposeAndClear(); } if( !mpPrt ) @@ -247,8 +247,8 @@ void DocumentDeviceManager::setPrintData(/*[in]*/ const SwPrintData& rPrtData ) DocumentDeviceManager::~DocumentDeviceManager() { delete mpPrtData; - delete mpVirDev; - DELETEZ( mpPrt ); + mpVirDev.disposeAndClear(); + mpPrt.disposeAndClear(); } VirtualDevice& DocumentDeviceManager::CreateVirtualDevice_() const @@ -292,7 +292,7 @@ SfxPrinter& DocumentDeviceManager::CreatePrinter_() const SfxPrinter* pNewPrt = new SfxPrinter( pSet ); const_cast(this)->setPrinter( pNewPrt, true, true ); - return *mpPrt; + return *mpPrt.get(); } void DocumentDeviceManager::PrtDataChanged() diff --git a/sw/source/core/inc/DocumentDeviceManager.hxx b/sw/source/core/inc/DocumentDeviceManager.hxx index 1440b63897b6..f388b4d8d273 100644 --- a/sw/source/core/inc/DocumentDeviceManager.hxx +++ b/sw/source/core/inc/DocumentDeviceManager.hxx @@ -22,7 +22,7 @@ #include #include #include - +#include class SwDoc; class SfxPrinter; @@ -72,8 +72,8 @@ private: invalidations and notifications. */ SwDoc& m_rDoc; - SfxPrinter* mpPrt; - VirtualDevice* mpVirDev; + VclPtr mpPrt; + VclPtr mpVirDev; SwPrintData* mpPrtData; }; -- cgit