sd/source/ui/unoidl/unolayer.cxx | 36 +++++++++++++++++------------------- sd/source/ui/unoidl/unolayer.hxx | 9 ++++----- 2 files changed, 21 insertions(+), 24 deletions(-)
New commits: commit 8a87bf1b693fe44ffdc3b773ee0244bbf1bdeda3 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Wed Jan 25 13:30:07 2017 +0200 use rtl::Reference in SdLayer instead of storing both a raw pointer and an uno::Reference Change-Id: Id608c50cb4cb3a7cf7ad972303a3c5f9fc8e79b0 diff --git a/sd/source/ui/unoidl/unolayer.cxx b/sd/source/ui/unoidl/unolayer.cxx index d40cd0c..3b287a5 100644 --- a/sd/source/ui/unoidl/unolayer.cxx +++ b/sd/source/ui/unoidl/unolayer.cxx @@ -133,8 +133,7 @@ OUString SdLayer::convertToExternalName( const OUString& rName ) } SdLayer::SdLayer( SdLayerManager* pLayerManager_, SdrLayer* pSdrLayer_ ) throw() -: pLayerManager(pLayerManager_) -, mxLayerManager(pLayerManager_) +: mxLayerManager(pLayerManager_) , pLayer(pSdrLayer_) , pPropSet(ImplGetSdLayerPropertySet()) { @@ -181,7 +180,7 @@ void SAL_CALL SdLayer::setPropertyValue( const OUString& aPropertyName, const un { SolarMutexGuard aGuard; - if(pLayer == nullptr || pLayerManager == nullptr) + if(pLayer == nullptr || mxLayerManager == nullptr) throw lang::DisposedException(); const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMapEntry(aPropertyName); @@ -210,7 +209,7 @@ void SAL_CALL SdLayer::setPropertyValue( const OUString& aPropertyName, const un throw lang::IllegalArgumentException(); pLayer->SetName(SdLayer::convertToInternalName( aName ) ); - pLayerManager->UpdateLayerView(); + mxLayerManager->UpdateLayerView(); break; } @@ -238,8 +237,8 @@ void SAL_CALL SdLayer::setPropertyValue( const OUString& aPropertyName, const un throw beans::UnknownPropertyException( aPropertyName, static_cast<cppu::OWeakObject*>(this)); } - if( pLayerManager->GetDocShell() ) - pLayerManager->GetDocShell()->SetModified(); + if( mxLayerManager->GetDocShell() ) + mxLayerManager->GetDocShell()->SetModified(); } uno::Any SAL_CALL SdLayer::getPropertyValue( const OUString& PropertyName ) @@ -247,7 +246,7 @@ uno::Any SAL_CALL SdLayer::getPropertyValue( const OUString& PropertyName ) { SolarMutexGuard aGuard; - if(pLayer == nullptr || pLayerManager == nullptr) + if(pLayer == nullptr || mxLayerManager == nullptr) throw lang::DisposedException(); const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMapEntry(PropertyName); @@ -291,10 +290,10 @@ void SAL_CALL SdLayer::removeVetoableChangeListener( const OUString& , const uno bool SdLayer::get( LayerAttribute what ) throw() { - if(pLayer&&pLayerManager) + if(pLayer && mxLayerManager.is()) { // Try 1. is an arbitrary page open? - ::sd::View *pView = pLayerManager->GetView(); + ::sd::View *pView = mxLayerManager->GetView(); SdrPageView* pSdrPageView = nullptr; if(pView) pSdrPageView = pView->GetSdrPageView(); @@ -311,9 +310,9 @@ bool SdLayer::get( LayerAttribute what ) throw() } // Try 2. get info from FrameView - if(pLayerManager->GetDocShell()) + if(mxLayerManager->GetDocShell()) { - ::sd::FrameView *pFrameView = pLayerManager->GetDocShell()->GetFrameView(); + ::sd::FrameView *pFrameView = mxLayerManager->GetDocShell()->GetFrameView(); if(pFrameView) switch(what) { @@ -328,10 +327,10 @@ bool SdLayer::get( LayerAttribute what ) throw() void SdLayer::set( LayerAttribute what, bool flag ) throw() { - if(pLayer&&pLayerManager) + if(pLayer && mxLayerManager.is()) { // Try 1. is an arbitrary page open? - ::sd::View *pView = pLayerManager->GetView(); + ::sd::View *pView = mxLayerManager->GetView(); SdrPageView* pSdrPageView = nullptr; if(pView) pSdrPageView = pView->GetSdrPageView(); @@ -351,9 +350,9 @@ void SdLayer::set( LayerAttribute what, bool flag ) throw() } // Try 2. get info from FrameView - if(pLayerManager->GetDocShell()) + if(mxLayerManager->GetDocShell()) { - ::sd::FrameView *pFrameView = pLayerManager->GetDocShell()->GetFrameView(); + ::sd::FrameView *pFrameView = mxLayerManager->GetDocShell()->GetFrameView(); if(pFrameView) { @@ -392,10 +391,10 @@ uno::Reference<uno::XInterface> SAL_CALL SdLayer::getParent() { SolarMutexGuard aGuard; - if( pLayerManager == nullptr ) + if( !mxLayerManager.is() ) throw lang::DisposedException(); - return uno::Reference<uno::XInterface> (mxLayerManager, uno::UNO_QUERY); + return uno::Reference<uno::XInterface> (static_cast<cppu::OWeakObject*>(mxLayerManager.get()), uno::UNO_QUERY); } void SAL_CALL SdLayer::setParent (const uno::Reference<uno::XInterface >& ) @@ -408,8 +407,7 @@ void SAL_CALL SdLayer::setParent (const uno::Reference<uno::XInterface >& ) // XComponent void SAL_CALL SdLayer::dispose( ) throw (uno::RuntimeException, std::exception) { - pLayerManager = nullptr; - mxLayerManager = nullptr; + mxLayerManager.clear(); pLayer = nullptr; } diff --git a/sd/source/ui/unoidl/unolayer.hxx b/sd/source/ui/unoidl/unolayer.hxx index 99ba616..1228376 100644 --- a/sd/source/ui/unoidl/unolayer.hxx +++ b/sd/source/ui/unoidl/unolayer.hxx @@ -25,6 +25,7 @@ #include <cppuhelper/implbase.hxx> #include <comphelper/servicehelper.hxx> +#include <rtl/ref.hxx> #include <unomodel.hxx> @@ -91,11 +92,9 @@ public: virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) throw (css::lang::NoSupportException, css::uno::RuntimeException, std::exception) override; private: - SdLayerManager* pLayerManager; - css::uno::Reference< css::drawing::XLayerManager > mxLayerManager; - - SdrLayer* pLayer; - const SvxItemPropertySet* pPropSet; + rtl::Reference<SdLayerManager> mxLayerManager; + SdrLayer* pLayer; + const SvxItemPropertySet* pPropSet; bool get( LayerAttribute what ) throw(); void set( LayerAttribute what, bool flag ) throw(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits