diff options
45 files changed, 292 insertions, 429 deletions
diff --git a/comphelper/source/misc/accessiblewrapper.cxx b/comphelper/source/misc/accessiblewrapper.cxx index e106b9dd14e1..41fb4f540fed 100644 --- a/comphelper/source/misc/accessiblewrapper.cxx +++ b/comphelper/source/misc/accessiblewrapper.cxx @@ -347,18 +347,15 @@ namespace comphelper ,m_xInnerContext( _rxInnerAccessibleContext ) ,m_xOwningAccessible( _rxOwningAccessible ) ,m_xParentAccessible( _rxParentAccessible ) - ,m_pChildMapper( nullptr ) - { // initialize the mapper for our children - m_pChildMapper = new OWrappedAccessibleChildrenManager( getComponentContext() ); - m_pChildMapper->acquire(); - + ,m_xChildMapper( new OWrappedAccessibleChildrenManager( getComponentContext() ) ) + { // determine if we're allowed to cache children Reference< XAccessibleStateSet > xStates( m_xInnerContext->getAccessibleStateSet( ) ); OSL_ENSURE( xStates.is(), "OAccessibleContextWrapperHelper::OAccessibleContextWrapperHelper: no inner state set!" ); - m_pChildMapper->setTransientChildren( !xStates.is() || xStates->contains( AccessibleStateType::MANAGES_DESCENDANTS) ); + m_xChildMapper->setTransientChildren( !xStates.is() || xStates->contains( AccessibleStateType::MANAGES_DESCENDANTS) ); - m_pChildMapper->setOwningAccessible( m_xOwningAccessible ); + m_xChildMapper->setOwningAccessible( m_xOwningAccessible ); } @@ -383,9 +380,6 @@ namespace comphelper OAccessibleContextWrapperHelper::~OAccessibleContextWrapperHelper( ) { OSL_ENSURE( m_rBHelper.bDisposed, "OAccessibleContextWrapperHelper::~OAccessibleContextWrapperHelper: you should ensure (in your dtor) that the object is disposed!" ); - - m_pChildMapper->release(); - m_pChildMapper = nullptr; } @@ -411,7 +405,7 @@ namespace comphelper { // get the child of the wrapped component Reference< XAccessible > xInnerChild = m_xInnerContext->getAccessibleChild( i ); - return m_pChildMapper->getAccessibleWrapperFor( xInnerChild ); + return m_xChildMapper->getAccessibleWrapperFor( xInnerChild ); } @@ -446,10 +440,10 @@ namespace comphelper // translate the event queryInterface( cppu::UnoType<XInterface>::get() ) >>= aTranslatedEvent.Source; - m_pChildMapper->translateAccessibleEvent( _rEvent, aTranslatedEvent ); + m_xChildMapper->translateAccessibleEvent( _rEvent, aTranslatedEvent ); // see if any of these notifications affect our child manager - m_pChildMapper->handleChildNotification( _rEvent ); + m_xChildMapper->handleChildNotification( _rEvent ); if ( aTranslatedEvent.NewValue == m_xInner ) aTranslatedEvent.NewValue = makeAny(aTranslatedEvent.Source); @@ -472,7 +466,7 @@ namespace comphelper xBroadcaster->removeAccessibleEventListener( this ); // dispose the child cache/map - m_pChildMapper->dispose(); + m_xChildMapper->dispose(); // let the base class dispose the inner component OComponentProxyAggregationHelper::dispose(); diff --git a/connectivity/source/drivers/dbase/DIndexIter.cxx b/connectivity/source/drivers/dbase/DIndexIter.cxx index 3c0318b4c36f..3f072f8172d1 100644 --- a/connectivity/source/drivers/dbase/DIndexIter.cxx +++ b/connectivity/source/drivers/dbase/DIndexIter.cxx @@ -30,7 +30,6 @@ using namespace connectivity::file; OIndexIterator::~OIndexIterator() { - m_pIndex->release(); } @@ -51,7 +50,7 @@ sal_uInt32 OIndexIterator::Find(bool bFirst) if (bFirst) { - m_aRoot = m_pIndex->getRoot(); + m_aRoot = m_xIndex->getRoot(); m_aCurLeaf.Clear(); } @@ -62,7 +61,7 @@ sal_uInt32 OIndexIterator::Find(bool bFirst) { ONDXPage* pPage = m_aRoot; while (pPage && !pPage->IsLeaf()) - pPage = pPage->GetChild(m_pIndex); + pPage = pPage->GetChild(m_xIndex.get()); m_aCurLeaf = pPage; m_nCurNode = NODE_NOTFOUND; @@ -108,8 +107,8 @@ ONDXKey* OIndexIterator::GetFirstKey(ONDXPage* pPage, const OOperand& rKey) if (!pPage->IsLeaf()) { // descend further - ONDXPagePtr aPage = (i==0) ? pPage->GetChild(m_pIndex) - : ((*pPage)[i-1]).GetChild(m_pIndex, pPage); + ONDXPagePtr aPage = (i==0) ? pPage->GetChild(m_xIndex.get()) + : ((*pPage)[i-1]).GetChild(m_xIndex.get(), pPage); pFoundKey = aPage.Is() ? GetFirstKey(aPage, rKey) : nullptr; } else if (i == pPage->Count()) @@ -144,7 +143,7 @@ sal_uInt32 OIndexIterator::GetCompare(bool bFirst) case SQLFilterOperator::LESS: case SQLFilterOperator::LESS_EQUAL: while (pPage && !pPage->IsLeaf()) - pPage = pPage->GetChild(m_pIndex); + pPage = pPage->GetChild(m_xIndex.get()); m_aCurLeaf = pPage; m_nCurNode = NODE_NOTFOUND; @@ -206,7 +205,7 @@ sal_uInt32 OIndexIterator::GetLike(bool bFirst) ONDXPage* pPage = m_aRoot; while (pPage && !pPage->IsLeaf()) - pPage = pPage->GetChild(m_pIndex); + pPage = pPage->GetChild(m_xIndex.get()); m_aCurLeaf = pPage; m_nCurNode = NODE_NOTFOUND; @@ -225,7 +224,7 @@ sal_uInt32 OIndexIterator::GetNull(bool bFirst) { ONDXPage* pPage = m_aRoot; while (pPage && !pPage->IsLeaf()) - pPage = pPage->GetChild(m_pIndex); + pPage = pPage->GetChild(m_xIndex.get()); m_aCurLeaf = pPage; m_nCurNode = NODE_NOTFOUND; @@ -274,7 +273,7 @@ ONDXKey* OIndexIterator::GetNextKey() sal_uInt16 nPos = pParentPage->Search(pPage); if (nPos != pParentPage->Count() - 1) { // page found - pPage = (*pParentPage)[nPos+1].GetChild(m_pIndex,pParentPage); + pPage = (*pParentPage)[nPos+1].GetChild(m_xIndex.get(),pParentPage); break; } } @@ -283,7 +282,7 @@ ONDXKey* OIndexIterator::GetNextKey() // now go on with leaf while (pPage && !pPage->IsLeaf()) - pPage = pPage->GetChild(m_pIndex); + pPage = pPage->GetChild(m_xIndex.get()); m_aCurLeaf = pPage; m_nCurNode = 0; diff --git a/connectivity/source/drivers/mork/MConnection.cxx b/connectivity/source/drivers/mork/MConnection.cxx index 301aa7b8000d..d0caa2e98b33 100644 --- a/connectivity/source/drivers/mork/MConnection.cxx +++ b/connectivity/source/drivers/mork/MConnection.cxx @@ -40,10 +40,9 @@ static const int defaultScope = 0x80; OConnection::OConnection(MorkDriver* _pDriver) :OSubComponent<OConnection, OConnection_BASE>(static_cast<cppu::OWeakObject*>(_pDriver), this) - ,m_pDriver(_pDriver) + ,m_xDriver(_pDriver) ,m_aColumnAlias( _pDriver->getFactory() ) { - m_pDriver->acquire(); m_pBook = new MorkParser(); m_pHistory = new MorkParser(); } @@ -52,8 +51,6 @@ OConnection::~OConnection() { if(!isClosed()) close(); - m_pDriver->release(); - m_pDriver = nullptr; delete m_pBook; delete m_pHistory; } @@ -112,7 +109,7 @@ void OConnection::construct(const OUString& url,const Sequence< PropertyValue >& // production? if (unittestIndex == -1) { - OUString path = m_pDriver->getProfilePath(); + OUString path = m_xDriver->getProfilePath(); SAL_INFO("connectivity.mork", "ProfilePath: " << path); abook = path + "/abook.mab"; history = path + "/history.mab"; diff --git a/connectivity/source/drivers/mork/MConnection.hxx b/connectivity/source/drivers/mork/MConnection.hxx index e87c01b5fe44..125908fd9d62 100644 --- a/connectivity/source/drivers/mork/MConnection.hxx +++ b/connectivity/source/drivers/mork/MConnection.hxx @@ -37,8 +37,8 @@ namespace connectivity // Data attributes - MorkDriver* m_pDriver; // Pointer to the owning - // driver object + rtl::Reference<MorkDriver> m_xDriver; // Pointer to the owning + // driver object OColumnAlias m_aColumnAlias; // Mork Parser (abook) MorkParser* m_pBook; @@ -52,7 +52,7 @@ namespace connectivity explicit OConnection(MorkDriver* const driver); virtual ~OConnection(); - MorkDriver* getDriver() {return m_pDriver;}; + const rtl::Reference<MorkDriver>& getDriver() {return m_xDriver;}; MorkParser* getMorkParser(const OString& t) {return t == "CollectedAddressBook" ? m_pHistory : m_pBook;}; // OComponentHelper diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx index a8e81b5a9785..35f5d3366cb6 100644 --- a/connectivity/source/drivers/postgresql/pq_connection.cxx +++ b/connectivity/source/drivers/postgresql/pq_connection.cxx @@ -96,28 +96,24 @@ namespace pq_sdbc_driver // Helper class for statement lifetime management class ClosableReference : public cppu::WeakImplHelper< css::uno::XReference > { - Connection *m_conn; + rtl::Reference<Connection> m_conn; ::rtl::ByteSequence m_id; public: ClosableReference( const ::rtl::ByteSequence & id , Connection *that ) : m_conn( that ), m_id( id ) { - that->acquire(); } virtual ~ClosableReference() { - if( m_conn ) - m_conn->release(); } virtual void SAL_CALL dispose() throw (std::exception) override { - if( m_conn ) + if( m_conn.is() ) { m_conn->removeFromWeakMap(m_id); - m_conn->release(); - m_conn = nullptr; + m_conn.clear(); } } }; diff --git a/connectivity/source/inc/dbase/DIndexIter.hxx b/connectivity/source/inc/dbase/DIndexIter.hxx index 0b70f96e0c25..141b4bed83ba 100644 --- a/connectivity/source/inc/dbase/DIndexIter.hxx +++ b/connectivity/source/inc/dbase/DIndexIter.hxx @@ -36,7 +36,7 @@ namespace connectivity protected: file::OBoolOperator* m_pOperator; const file::OOperand* m_pOperand; - ODbaseIndex* m_pIndex; + rtl::Reference<ODbaseIndex> m_xIndex; ONDXPagePtr m_aRoot, m_aCurLeaf; sal_uInt16 m_nCurNode; @@ -57,10 +57,9 @@ namespace connectivity const file::OOperand* pOper) :m_pOperator(pOp) ,m_pOperand(pOper) - ,m_pIndex(pInd) + ,m_xIndex(pInd) ,m_nCurNode(NODE_NOTFOUND) { - pInd->acquire(); } virtual ~OIndexIterator(); diff --git a/editeng/source/xml/editsource.hxx b/editeng/source/xml/editsource.hxx index 4b49838448ad..a22728f34e4b 100644 --- a/editeng/source/xml/editsource.hxx +++ b/editeng/source/xml/editsource.hxx @@ -38,7 +38,7 @@ public: private: explicit SvxEditEngineSource( SvxEditEngineSourceImpl* pImpl ); - SvxEditEngineSourceImpl* mpImpl; + rtl::Reference<SvxEditEngineSourceImpl> mxImpl; }; #endif diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx index a291f76964af..348aa2e73eb7 100644 --- a/editeng/source/xml/xmltxtexp.cxx +++ b/editeng/source/xml/xmltxtexp.cxx @@ -59,28 +59,22 @@ using namespace cppu; class SvxEditEngineSourceImpl; -class SvxEditEngineSourceImpl +class SvxEditEngineSourceImpl : public salhelper::SimpleReferenceObject { private: - oslInterlockedCount maRefCount; - EditEngine* mpEditEngine; SvxTextForwarder* mpTextForwarder; - ~SvxEditEngineSourceImpl(); + virtual ~SvxEditEngineSourceImpl(); public: explicit SvxEditEngineSourceImpl( EditEngine* pEditEngine ); - void SAL_CALL acquire(); - void SAL_CALL release(); - SvxTextForwarder* GetTextForwarder(); }; SvxEditEngineSourceImpl::SvxEditEngineSourceImpl( EditEngine* pEditEngine ) -: maRefCount(0), - mpEditEngine( pEditEngine ), +: mpEditEngine( pEditEngine ), mpTextForwarder(nullptr) { } @@ -90,17 +84,6 @@ SvxEditEngineSourceImpl::~SvxEditEngineSourceImpl() delete mpTextForwarder; } -void SAL_CALL SvxEditEngineSourceImpl::acquire() -{ - osl_atomic_increment( &maRefCount ); -} - -void SAL_CALL SvxEditEngineSourceImpl::release() -{ - if( ! osl_atomic_decrement( &maRefCount ) ) - delete this; -} - SvxTextForwarder* SvxEditEngineSourceImpl::GetTextForwarder() { if (!mpTextForwarder) @@ -111,30 +94,27 @@ SvxTextForwarder* SvxEditEngineSourceImpl::GetTextForwarder() // SvxTextEditSource SvxEditEngineSource::SvxEditEngineSource( EditEngine* pEditEngine ) + : mxImpl( new SvxEditEngineSourceImpl( pEditEngine ) ) { - mpImpl = new SvxEditEngineSourceImpl( pEditEngine ); - mpImpl->acquire(); } SvxEditEngineSource::SvxEditEngineSource( SvxEditEngineSourceImpl* pImpl ) + : mxImpl(pImpl) { - mpImpl = pImpl; - mpImpl->acquire(); } SvxEditEngineSource::~SvxEditEngineSource() { - mpImpl->release(); } SvxEditSource* SvxEditEngineSource::Clone() const { - return new SvxEditEngineSource( mpImpl ); + return new SvxEditEngineSource( mxImpl.get() ); } SvxTextForwarder* SvxEditEngineSource::GetTextForwarder() { - return mpImpl->GetTextForwarder(); + return mxImpl->GetTextForwarder(); } diff --git a/extensions/source/bibliography/framectr.cxx b/extensions/source/bibliography/framectr.cxx index df541538dee4..6da8c22c8a1e 100644 --- a/extensions/source/bibliography/framectr.cxx +++ b/extensions/source/bibliography/framectr.cxx @@ -176,15 +176,13 @@ BibFrameController_Impl::BibFrameController_Impl( const uno::Reference< awt::XWi { bDisposing=false; bHierarchical=true; - pImp = new BibFrameCtrl_Impl; - pImp->pController = this; - pImp->acquire(); + mxImpl = new BibFrameCtrl_Impl; + mxImpl->pController = this; } BibFrameController_Impl::~BibFrameController_Impl() { - pImp->pController = nullptr; - pImp->release(); + mxImpl->pController = nullptr; delete pDatMan; if(pBibMod) CloseBibModul(pBibMod); @@ -211,7 +209,7 @@ css::uno::Sequence< OUString > SAL_CALL BibFrameController_Impl::getSupportedSer void BibFrameController_Impl::attachFrame( const uno::Reference< XFrame > & xArg ) throw (css::uno::RuntimeException, std::exception) { xFrame = xArg; - xFrame->addFrameActionListener( pImp ); + xFrame->addFrameActionListener( mxImpl.get() ); } sal_Bool BibFrameController_Impl::attachModel( const uno::Reference< XModel > & /*xModel*/ ) throw (css::uno::RuntimeException, std::exception) @@ -222,9 +220,9 @@ sal_Bool BibFrameController_Impl::attachModel( const uno::Reference< XModel > & sal_Bool BibFrameController_Impl::suspend( sal_Bool bSuspend ) throw (css::uno::RuntimeException, std::exception) { if ( bSuspend ) - getFrame()->removeFrameActionListener( pImp ); + getFrame()->removeFrameActionListener( mxImpl.get() ); else - getFrame()->addFrameActionListener( pImp ); + getFrame()->addFrameActionListener( mxImpl.get() ); return true; } @@ -252,7 +250,7 @@ void BibFrameController_Impl::dispose() throw (css::uno::RuntimeException, std:: bDisposing = true; lang::EventObject aObject; aObject.Source = static_cast<XController*>(this); - pImp->aLC.disposeAndClear(aObject); + mxImpl->aLC.disposeAndClear(aObject); m_xDatMan = nullptr; pDatMan = nullptr; aStatusListeners.clear(); @@ -260,12 +258,12 @@ void BibFrameController_Impl::dispose() throw (css::uno::RuntimeException, std:: void BibFrameController_Impl::addEventListener( const uno::Reference< lang::XEventListener > & aListener ) throw (css::uno::RuntimeException, std::exception) { - pImp->aLC.addInterface( cppu::UnoType<lang::XEventListener>::get(), aListener ); + mxImpl->aLC.addInterface( cppu::UnoType<lang::XEventListener>::get(), aListener ); } void BibFrameController_Impl::removeEventListener( const uno::Reference< lang::XEventListener > & aListener ) throw (css::uno::RuntimeException, std::exception) { - pImp->aLC.removeInterface( cppu::UnoType<lang::XEventListener>::get(), aListener ); + mxImpl->aLC.removeInterface( cppu::UnoType<lang::XEventListener>::get(), aListener ); } uno::Reference< frame::XDispatch > BibFrameController_Impl::queryDispatch( const util::URL& aURL, const OUString& /*aTarget*/, sal_Int32 /*nSearchFlags*/ ) throw (css::uno::RuntimeException, std::exception) @@ -556,7 +554,7 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen bLeft = xCursor->isLast() && nCount > 1; bRight= !xCursor->isLast(); // ask for confirmation - Reference< frame::XController > xCtrl = pImp->pController; + Reference< frame::XController > xCtrl = mxImpl->pController; Reference< form::XConfirmDeleteListener > xConfirm(pDatMan->GetFormController(),UNO_QUERY); if (xConfirm.is()) { diff --git a/extensions/source/bibliography/framectr.hxx b/extensions/source/bibliography/framectr.hxx index feb94c37c383..a68b4b933dfe 100644 --- a/extensions/source/bibliography/framectr.hxx +++ b/extensions/source/bibliography/framectr.hxx @@ -60,7 +60,7 @@ class BibFrameController_Impl : public cppu::WeakImplHelper < > { friend class BibFrameCtrl_Impl; - BibFrameCtrl_Impl* pImp; + rtl::Reference<BibFrameCtrl_Impl> mxImpl; BibStatusDispatchArr aStatusListeners; css::uno::Reference< css::awt::XWindow > xWindow; css::uno::Reference< css::frame::XFrame > xFrame; diff --git a/framework/Library_fwi.mk b/framework/Library_fwi.mk index 5e829635723d..8435b9df474e 100644 --- a/framework/Library_fwi.mk +++ b/framework/Library_fwi.mk @@ -41,6 +41,7 @@ $(eval $(call gb_Library_use_libraries,fwi,\ cppuhelper \ i18nlangtag \ sal \ + salhelper \ svl \ svt \ tk \ diff --git a/framework/source/fwe/dispatch/interaction.cxx b/framework/source/fwe/dispatch/interaction.cxx index a9b36bb4be67..e0c3b9e7662f 100644 --- a/framework/source/fwe/dispatch/interaction.cxx +++ b/framework/source/fwe/dispatch/interaction.cxx @@ -156,17 +156,20 @@ css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > } RequestFilterSelect::RequestFilterSelect( const OUString& sURL ) - : pImpl( new RequestFilterSelect_Impl( sURL )) -{} + : mxImpl(new RequestFilterSelect_Impl( sURL )) +{ +} -RequestFilterSelect::~RequestFilterSelect() {} +RequestFilterSelect::~RequestFilterSelect() +{ +} // return abort state of interaction // If it is true, return value of method "getFilter()" will be unspecified then! bool RequestFilterSelect::isAbort() const { - return pImpl->isAbort(); + return mxImpl->isAbort(); } // return user selected filter @@ -174,12 +177,12 @@ bool RequestFilterSelect::isAbort() const OUString RequestFilterSelect::getFilter() const { - return pImpl->getFilter(); + return mxImpl->getFilter(); } uno::Reference < task::XInteractionRequest > RequestFilterSelect::GetRequest() { - return uno::Reference < task::XInteractionRequest > (pImpl.get()); + return mxImpl.get(); } class InteractionRequest_Impl : public ::cppu::WeakImplHelper< css::task::XInteractionRequest > diff --git a/include/comphelper/accessiblewrapper.hxx b/include/comphelper/accessiblewrapper.hxx index 3b808724f933..f1efb09c8ca0 100644 --- a/include/comphelper/accessiblewrapper.hxx +++ b/include/comphelper/accessiblewrapper.hxx @@ -40,6 +40,7 @@ #include <comphelper/accessibleeventnotifier.hxx> #include <comphelper/stl_types.hxx> #include <comphelper/comphelperdllapi.h> +#include <rtl/ref.hxx> namespace comphelper @@ -156,7 +157,7 @@ namespace comphelper css::uno::Reference< css::accessibility::XAccessible > m_xParentAccessible; - OWrappedAccessibleChildrenManager* m_pChildMapper; // for mapping children from our inner context to our callers + rtl::Reference<OWrappedAccessibleChildrenManager> m_xChildMapper; // for mapping children from our inner context to our callers protected: /** ctor diff --git a/include/framework/interaction.hxx b/include/framework/interaction.hxx index 6858a044df81..7f9389fadaa6 100644 --- a/include/framework/interaction.hxx +++ b/include/framework/interaction.hxx @@ -32,6 +32,7 @@ #include <rtl/ref.hxx> #include <rtl/ustring.hxx> +#include <rtl/ref.hxx> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <framework/fwedllapi.h> @@ -61,7 +62,7 @@ namespace framework{ class RequestFilterSelect_Impl; class FWE_DLLPUBLIC RequestFilterSelect { - rtl::Reference<RequestFilterSelect_Impl> pImpl; + rtl::Reference<RequestFilterSelect_Impl> mxImpl; public: RequestFilterSelect( const OUString& sURL ); diff --git a/include/sfx2/brokenpackageint.hxx b/include/sfx2/brokenpackageint.hxx index 68cb33022608..64f624696bb3 100644 --- a/include/sfx2/brokenpackageint.hxx +++ b/include/sfx2/brokenpackageint.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SFX2_BROKENPACKAGEINT_HXX #include <sal/config.h> +#include <rtl/ref.hxx> #include <sfx2/dllapi.h> #include <com/sun/star/document/BrokenPackageRequest.hpp> #include <com/sun/star/task/XInteractionApprove.hpp> @@ -29,10 +30,12 @@ class RequestPackageReparation_Impl; class SFX2_DLLPUBLIC RequestPackageReparation { - RequestPackageReparation_Impl* pImp; + rtl::Reference<RequestPackageReparation_Impl> mxImpl; public: RequestPackageReparation( const OUString& aName ); ~RequestPackageReparation(); + RequestPackageReparation( const RequestPackageReparation&) = delete; + RequestPackageReparation& operator=( const RequestPackageReparation&) = delete; bool isApproved(); css::uno::Reference < css::task::XInteractionRequest > GetRequest(); }; @@ -40,10 +43,12 @@ public: class NotifyBrokenPackage_Impl; class SFX2_DLLPUBLIC NotifyBrokenPackage { - NotifyBrokenPackage_Impl* pImp; + rtl::Reference<NotifyBrokenPackage_Impl> mxImpl; public: NotifyBrokenPackage( const OUString& aName ); ~NotifyBrokenPackage(); + NotifyBrokenPackage( const NotifyBrokenPackage&) = delete; + NotifyBrokenPackage& operator=( const NotifyBrokenPackage&) = delete; css::uno::Reference < css::task::XInteractionRequest > GetRequest(); }; diff --git a/include/ucbhelper/proxydecider.hxx b/include/ucbhelper/proxydecider.hxx index aa19d483fcc9..0ee4400a1392 100644 --- a/include/ucbhelper/proxydecider.hxx +++ b/include/ucbhelper/proxydecider.hxx @@ -21,6 +21,7 @@ #define INCLUDED_UCBHELPER_PROXYDECIDER_HXX #include <rtl/ustring.hxx> +#include <rtl/ref.hxx> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/XComponentContext.hpp> #include <ucbhelper/ucbhelperdllapi.h> @@ -127,7 +128,7 @@ public: sal_Int32 nPort ) const; private: - proxydecider_impl::InternetProxyDecider_Impl * m_pImpl; + rtl::Reference<proxydecider_impl::InternetProxyDecider_Impl> m_xImpl; }; } // namespace ucbhelper diff --git a/reportdesign/inc/RptModel.hxx b/reportdesign/inc/RptModel.hxx index b37ed16fdec3..5992d21fcd78 100644 --- a/reportdesign/inc/RptModel.hxx +++ b/reportdesign/inc/RptModel.hxx @@ -43,7 +43,7 @@ class REPORTDESIGN_DLLPUBLIC OReportModel : public SdrModel friend class OReportPage; private: - OXUndoEnvironment* m_pUndoEnv; + rtl::Reference<OXUndoEnvironment> m_xUndoEnv; ::dbaui::DBSubComponentController* m_pController; ::reportdesign::OReportDefinition* m_pReportDefinition; @@ -63,7 +63,7 @@ public: /** @returns the numbering type that is used to format page fields in drawing shapes */ virtual SvxNumType GetPageNumType() const override; - OXUndoEnvironment& GetUndoEnv() { return *m_pUndoEnv;} + OXUndoEnvironment& GetUndoEnv() { return *m_xUndoEnv.get();} void SetModified(bool _bModified); inline dbaui::DBSubComponentController* getController() const { return m_pController; } diff --git a/reportdesign/source/core/sdr/RptModel.cxx b/reportdesign/source/core/sdr/RptModel.cxx index f4d66d113386..0358ecf64a77 100644 --- a/reportdesign/source/core/sdr/RptModel.cxx +++ b/reportdesign/source/core/sdr/RptModel.cxx @@ -50,8 +50,7 @@ OReportModel::OReportModel(::reportdesign::OReportDefinition* _pReportDefinition ,m_pController(nullptr) ,m_pReportDefinition(_pReportDefinition) { - m_pUndoEnv = new OXUndoEnvironment(*this); - m_pUndoEnv->acquire(); + m_xUndoEnv = new OXUndoEnvironment(*this); SetSdrUndoFactory(new OReportUndoFactory); } @@ -59,16 +58,15 @@ OReportModel::OReportModel(::reportdesign::OReportDefinition* _pReportDefinition OReportModel::~OReportModel() { detachController(); - m_pUndoEnv->release(); } void OReportModel::detachController() { m_pReportDefinition = nullptr; m_pController = nullptr; - m_pUndoEnv->EndListening( *this ); + m_xUndoEnv->EndListening( *this ); ClearUndoBuffer(); - m_pUndoEnv->Clear(OXUndoEnvironment::Accessor()); + m_xUndoEnv->Clear(OXUndoEnvironment::Accessor()); } SdrPage* OReportModel::AllocPage(bool /*bMasterPage*/) @@ -102,7 +100,7 @@ OReportPage* OReportModel::createNewPage(const uno::Reference< report::XSection SolarMutexGuard aSolarGuard; OReportPage* pPage = new OReportPage( *this ,_xSection); InsertPage(pPage); - m_pUndoEnv->AddSection(_xSection); + m_xUndoEnv->AddSection(_xSection); return pPage; } diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx index cbaebc7514a9..69a0bc6ea934 100644 --- a/sc/inc/datauno.hxx +++ b/sc/inc/datauno.hxx @@ -44,6 +44,7 @@ #include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/util/XRefreshable.hpp> #include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> #include <svl/itemprop.hxx> #include <svl/lstner.hxx> @@ -222,7 +223,7 @@ public: class ScRangeSubTotalDescriptor : public ScSubTotalDescriptorBase { private: - ScDatabaseRangeObj* pParent; + rtl::Reference<ScDatabaseRangeObj> mxParent; public: ScRangeSubTotalDescriptor(ScDatabaseRangeObj* pPar); @@ -435,7 +436,7 @@ public: class ScRangeFilterDescriptor : public ScFilterDescriptorBase { private: - ScDatabaseRangeObj* pParent; + rtl::Reference<ScDatabaseRangeObj> mxParent; public: ScRangeFilterDescriptor(ScDocShell* pDocSh, ScDatabaseRangeObj* pPar); @@ -451,7 +452,7 @@ public: class ScDataPilotFilterDescriptor : public ScFilterDescriptorBase { private: - ScDataPilotDescriptorBase* pParent; + rtl::Reference<ScDataPilotDescriptorBase> mxParent; public: ScDataPilotFilterDescriptor(ScDocShell* pDocSh, ScDataPilotDescriptorBase* pPar); diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx index 035ba282ef9d..e3ea1d3479e8 100644 --- a/sc/inc/dptabsrc.hxx +++ b/sc/inc/dptabsrc.hxx @@ -307,7 +307,7 @@ class ScDPDimension : public cppu::WeakImplHelper< { ScDPSource* pSource; long nDim; // dimension index (== column ID) - ScDPHierarchies* pHierarchies; + rtl::Reference<ScDPHierarchies> mxHierarchies; long nUsedHier; sal_uInt16 nFunction; // enum GeneralFunction OUString aName; // if empty, take from source @@ -459,7 +459,7 @@ private: ScDPSource* pSource; long nDim; long nHier; - ScDPLevels* pLevels; + rtl::Reference<ScDPLevels> mxLevels; public: ScDPHierarchy( ScDPSource* pSrc, long nD, long nH ); @@ -539,7 +539,7 @@ private: long nDim; long nHier; long nLev; - ScDPMembers* pMembers; + rtl::Reference<ScDPMembers> mxMembers; css::uno::Sequence<css::sheet::GeneralFunction> aSubTotals; css::sheet::DataPilotFieldSortInfo aSortInfo; // stored user settings css::sheet::DataPilotFieldAutoShowInfo aAutoShowInfo; // stored user settings diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index c652cf2af303..ce48a82446cb 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -1333,7 +1333,6 @@ ScDPDimension* ScDPDimensions::getByIndex(long nIndex) const ScDPDimension::ScDPDimension( ScDPSource* pSrc, long nD ) : pSource( pSrc ), nDim( nD ), - pHierarchies( nullptr ), nUsedHier( 0 ), nFunction( SUBTOTAL_FUNC_SUM ), // sum is default mpLayoutName(nullptr), @@ -1350,20 +1349,16 @@ ScDPDimension::~ScDPDimension() { //TODO: release pSource - if ( pHierarchies ) - pHierarchies->release(); // ref-counted - delete pSelectedData; } ScDPHierarchies* ScDPDimension::GetHierarchiesObject() { - if (!pHierarchies) + if (!mxHierarchies.is()) { - pHierarchies = new ScDPHierarchies( pSource, nDim ); - pHierarchies->acquire(); // ref-counted + mxHierarchies = new ScDPHierarchies( pSource, nDim ); } - return pHierarchies; + return mxHierarchies.get(); } const OUString* ScDPDimension::GetLayoutName() const @@ -1790,8 +1785,7 @@ ScDPHierarchy* ScDPHierarchies::getByIndex(long nIndex) const ScDPHierarchy::ScDPHierarchy( ScDPSource* pSrc, long nD, long nH ) : pSource( pSrc ), nDim( nD ), - nHier( nH ), - pLevels( nullptr ) + nHier( nH ) { //TODO: hold pSource } @@ -1799,19 +1793,15 @@ ScDPHierarchy::ScDPHierarchy( ScDPSource* pSrc, long nD, long nH ) : ScDPHierarchy::~ScDPHierarchy() { //TODO: release pSource - - if (pLevels) - pLevels->release(); // ref-counted } ScDPLevels* ScDPHierarchy::GetLevelsObject() { - if (!pLevels) + if (!mxLevels.is()) { - pLevels = new ScDPLevels( pSource, nDim, nHier ); - pLevels->acquire(); // ref-counted + mxLevels = new ScDPLevels( pSource, nDim, nHier ); } - return pLevels; + return mxLevels.get(); } uno::Reference<container::XNameAccess> SAL_CALL ScDPHierarchy::getLevels() @@ -1997,7 +1987,6 @@ ScDPLevel::ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL ) : nDim( nD ), nHier( nH ), nLev( nL ), - pMembers( nullptr ), aSortInfo( EMPTY_OUSTRING, true, sheet::DataPilotFieldSortMode::NAME ), // default: sort by name nSortMeasure( 0 ), nAutoMeasure( 0 ), @@ -2012,9 +2001,6 @@ ScDPLevel::ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL ) : ScDPLevel::~ScDPLevel() { //TODO: release pSource - - if ( pMembers ) - pMembers->release(); // ref-counted } void ScDPLevel::EvaluateSortOrder() @@ -2081,12 +2067,11 @@ void ScDPLevel::SetEnableLayout(bool bSet) ScDPMembers* ScDPLevel::GetMembersObject() { - if (!pMembers) + if (!mxMembers.is()) { - pMembers = new ScDPMembers( pSource, nDim, nHier, nLev ); - pMembers->acquire(); // ref-counted + mxMembers = new ScDPMembers( pSource, nDim, nHier, nLev ); } - return pMembers; + return mxMembers.get(); } uno::Reference<container::XNameAccess> SAL_CALL ScDPLevel::getMembers() throw(uno::RuntimeException, std::exception) diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index ee4d1ec01480..2709e613240b 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -113,7 +113,6 @@ void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet ) ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) : SfxShell(pData->GetViewShell()), pViewData(pData), - pClipEvtLstnr(nullptr), bPastePossible(false) { SetPool( pViewData->GetScDrawView()->GetDefaultAttr().GetPool() ); @@ -133,15 +132,13 @@ ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) : ScDrawTextObjectBar::~ScDrawTextObjectBar() { - if ( pClipEvtLstnr ) + if ( mxClipEvtLstnr.is() ) { - pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false ); + mxClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false ); // The listener may just now be waiting for the SolarMutex and call the link // afterwards, in spite of RemoveListener. So the link has to be reset, too. - pClipEvtLstnr->ClearCallbackLink(); - - pClipEvtLstnr->release(); + mxClipEvtLstnr->ClearCallbackLink(); } } @@ -492,13 +489,12 @@ void ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet ) return; } - if ( !pClipEvtLstnr ) + if ( !mxClipEvtLstnr.is() ) { // create listener - pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) ); - pClipEvtLstnr->acquire(); + mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) ); vcl::Window* pWin = pViewData->GetActiveWin(); - pClipEvtLstnr->AddRemoveListener( pWin, true ); + mxClipEvtLstnr->AddRemoveListener( pWin, true ); // get initial state TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) ); diff --git a/sc/source/ui/inc/drtxtob.hxx b/sc/source/ui/inc/drtxtob.hxx index 09c1d94d4bfa..5bd5c362386c 100644 --- a/sc/source/ui/inc/drtxtob.hxx +++ b/sc/source/ui/inc/drtxtob.hxx @@ -35,7 +35,7 @@ class TransferableClipboardListener; class ScDrawTextObjectBar : public SfxShell { ScViewData* pViewData; - TransferableClipboardListener* pClipEvtLstnr; + rtl::Reference<TransferableClipboardListener> mxClipEvtLstnr; bool bPastePossible; DECL_LINK_TYPED( ClipboardChanged, TransferableDataHelper*, void ); diff --git a/sc/source/ui/inc/editsh.hxx b/sc/source/ui/inc/editsh.hxx index 85d5fdfc1ccf..037268746b63 100644 --- a/sc/source/ui/inc/editsh.hxx +++ b/sc/source/ui/inc/editsh.hxx @@ -39,7 +39,7 @@ class ScEditShell : public SfxShell private: EditView* pEditView; ScViewData* pViewData; - TransferableClipboardListener* pClipEvtLstnr; + rtl::Reference<TransferableClipboardListener> mxClipEvtLstnr; bool bPastePossible; bool bIsInsertMode; diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index bad58331f6a6..dc3f64485b30 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -806,28 +806,24 @@ void ScSubTotalDescriptor::SetParam( const ScSubTotalParam& rNew ) } ScRangeSubTotalDescriptor::ScRangeSubTotalDescriptor(ScDatabaseRangeObj* pPar) : - pParent(pPar) + mxParent(pPar) { - if (pParent) - pParent->acquire(); } ScRangeSubTotalDescriptor::~ScRangeSubTotalDescriptor() { - if (pParent) - pParent->release(); } void ScRangeSubTotalDescriptor::GetData( ScSubTotalParam& rParam ) const { - if (pParent) - pParent->GetSubTotalParam( rParam ); + if (mxParent.is()) + mxParent->GetSubTotalParam( rParam ); } void ScRangeSubTotalDescriptor::PutData( const ScSubTotalParam& rParam ) { - if (pParent) - pParent->SetSubTotalParam( rParam ); + if (mxParent.is()) + mxParent->SetSubTotalParam( rParam ); } ScConsolidationDescriptor::ScConsolidationDescriptor() @@ -1544,49 +1540,41 @@ void ScFilterDescriptor::SetParam( const ScQueryParam& rNew ) ScRangeFilterDescriptor::ScRangeFilterDescriptor(ScDocShell* pDocShell, ScDatabaseRangeObj* pPar) : ScFilterDescriptorBase(pDocShell), - pParent(pPar) + mxParent(pPar) { - if (pParent) - pParent->acquire(); } ScRangeFilterDescriptor::~ScRangeFilterDescriptor() { - if (pParent) - pParent->release(); } void ScRangeFilterDescriptor::GetData( ScQueryParam& rParam ) const { - if (pParent) - pParent->GetQueryParam( rParam ); + if (mxParent.is()) + mxParent->GetQueryParam( rParam ); } void ScRangeFilterDescriptor::PutData( const ScQueryParam& rParam ) { - if (pParent) - pParent->SetQueryParam( rParam ); + if (mxParent.is()) + mxParent->SetQueryParam( rParam ); } ScDataPilotFilterDescriptor::ScDataPilotFilterDescriptor(ScDocShell* pDocShell, ScDataPilotDescriptorBase* pPar) : ScFilterDescriptorBase(pDocShell), - pParent(pPar) + mxParent(pPar) { - if (pParent) - pParent->acquire(); } ScDataPilotFilterDescriptor::~ScDataPilotFilterDescriptor() { - if (pParent) - pParent->release(); } void ScDataPilotFilterDescriptor::GetData( ScQueryParam& rParam ) const { - if (pParent) + if (mxParent.is()) { - ScDPObject* pDPObj = pParent->GetDPObject(); + ScDPObject* pDPObj = mxParent->GetDPObject(); if (pDPObj && pDPObj->IsSheetData()) rParam = pDPObj->GetSheetDesc()->GetQueryParam(); } @@ -1594,17 +1582,17 @@ void ScDataPilotFilterDescriptor::GetData( ScQueryParam& rParam ) const void ScDataPilotFilterDescriptor::PutData( const ScQueryParam& rParam ) { - if (pParent) + if (mxParent.is()) { - ScDPObject* pDPObj = pParent->GetDPObject(); + ScDPObject* pDPObj = mxParent->GetDPObject(); if (pDPObj) { - ScSheetSourceDesc aSheetDesc(&pParent->GetDocShell()->GetDocument()); + ScSheetSourceDesc aSheetDesc(&mxParent->GetDocShell()->GetDocument()); if (pDPObj->IsSheetData()) aSheetDesc = *pDPObj->GetSheetDesc(); aSheetDesc.SetQueryParam(rParam); pDPObj->SetSheetDesc(aSheetDesc); - pParent->SetDPObject(pDPObj); + mxParent->SetDPObject(pDPObj); } } } diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index 92f211e13d71..622989308f44 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -93,7 +93,6 @@ void ScEditShell::InitInterface_Impl() ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) : pEditView (pView), pViewData (pData), - pClipEvtLstnr (nullptr), bPastePossible (false), bIsInsertMode (true) { @@ -105,15 +104,13 @@ ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) : ScEditShell::~ScEditShell() { - if ( pClipEvtLstnr ) + if ( mxClipEvtLstnr.is() ) { - pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false ); + mxClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false ); // The listener may just now be waiting for the SolarMutex and call the link // afterwards, in spite of RemoveListener. So the link has to be reset, too. - pClipEvtLstnr->ClearCallbackLink(); - - pClipEvtLstnr->release(); + mxClipEvtLstnr->ClearCallbackLink(); } } @@ -809,13 +806,12 @@ IMPL_LINK_TYPED( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHe void ScEditShell::GetClipState( SfxItemSet& rSet ) { - if ( !pClipEvtLstnr ) + if ( !mxClipEvtLstnr.is() ) { // create listener - pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) ); - pClipEvtLstnr->acquire(); + mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) ); vcl::Window* pWin = pViewData->GetActiveWin(); - pClipEvtLstnr->AddRemoveListener( pWin, true ); + mxClipEvtLstnr->AddRemoveListener( pWin, true ); // get initial state TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) ); diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index b96a0e2bfd6f..0195f3b7459e 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -446,7 +446,7 @@ private: css::uno::Reference< css::scanner::XScannerManager2 > mxScannerManager; css::uno::Reference< css::lang::XEventListener > mxScannerListener; - TransferableClipboardListener* mpClipEvtLstnr; + rtl::Reference<TransferableClipboardListener> mxClipEvtLstnr; bool mbPastePossible; virtual void Notify (SfxBroadcaster& rBC, const SfxHint& rHint) override; diff --git a/sd/source/ui/inc/OutlineViewShell.hxx b/sd/source/ui/inc/OutlineViewShell.hxx index b57bc50151fa..79b03f9b0d36 100644 --- a/sd/source/ui/inc/OutlineViewShell.hxx +++ b/sd/source/ui/inc/OutlineViewShell.hxx @@ -152,7 +152,7 @@ private: void ShowSlideShow(SfxRequest& rReq); OutlineView* pOlView; SdPage* pLastPage; // For efficient processing of the preview - TransferableClipboardListener* pClipEvtLstnr; + rtl::Reference<TransferableClipboardListener> mxClipEvtLstnr; bool bPastePossible; bool mbInitialized; diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index c75417cbb9bf..5f322592be8b 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -604,7 +604,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) SfxItemState::DEFAULT == rSet.GetItemState( SID_PASTE_UNFORMATTED ) || SfxItemState::DEFAULT == rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) ) { - if ( !mpClipEvtLstnr ) + if ( !mxClipEvtLstnr.is() ) { // avoid clipboard initialization for // read-only presentation views (workaround for NT4.0 @@ -612,9 +612,8 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) if( dynamic_cast< const PresentationViewShell *>( this ) == nullptr ) { // create listener - mpClipEvtLstnr = new TransferableClipboardListener( LINK( this, DrawViewShell, ClipboardChanged ) ); - mpClipEvtLstnr->acquire(); - mpClipEvtLstnr->AddRemoveListener( GetActiveWindow(), true ); + mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, DrawViewShell, ClipboardChanged ) ); + mxClipEvtLstnr->AddRemoveListener( GetActiveWindow(), true ); // get initial state TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) ); diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx index c356a19e3689..561ca6f899df 100644 --- a/sd/source/ui/view/drviewsa.cxx +++ b/sd/source/ui/view/drviewsa.cxx @@ -177,11 +177,11 @@ DrawViewShell::~DrawViewShell() } } - if ( mpClipEvtLstnr ) + if ( mxClipEvtLstnr.is() ) { - mpClipEvtLstnr->AddRemoveListener( GetActiveWindow(), false ); - mpClipEvtLstnr->ClearCallbackLink(); // prevent callback if another thread is waiting - mpClipEvtLstnr->release(); + mxClipEvtLstnr->AddRemoveListener( GetActiveWindow(), false ); + mxClipEvtLstnr->ClearCallbackLink(); // prevent callback if another thread is waiting + mxClipEvtLstnr.clear(); } delete mpDrawView; @@ -201,7 +201,7 @@ void DrawViewShell::Construct(DrawDocShell* pDocSh, PageKind eInitialPageKind) mpActualPage = nullptr; mbMousePosFreezed = false; mbReadOnly = GetDocSh()->IsReadOnly(); - mpClipEvtLstnr = nullptr; + mxClipEvtLstnr.clear(); mbPastePossible = false; mbIsLayerModeActive = false; diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx index 23922b525621..f0708bec378d 100644 --- a/sd/source/ui/view/outlnvsh.cxx +++ b/sd/source/ui/view/outlnvsh.cxx @@ -190,7 +190,6 @@ OutlineViewShell::OutlineViewShell ( : ViewShell(pFrame, pParentWindow, rViewShellBase), pOlView(nullptr), pLastPage( nullptr ), - pClipEvtLstnr(nullptr), bPastePossible(false), mbInitialized(false) @@ -219,11 +218,10 @@ OutlineViewShell::~OutlineViewShell() mpFrameView->Disconnect(); - if ( pClipEvtLstnr ) + if ( mxClipEvtLstnr.is() ) { - pClipEvtLstnr->AddRemoveListener( GetActiveWindow(), false ); - pClipEvtLstnr->ClearCallbackLink(); // prevent callback if another thread is waiting - pClipEvtLstnr->release(); + mxClipEvtLstnr->AddRemoveListener( GetActiveWindow(), false ); + mxClipEvtLstnr->ClearCallbackLink(); // prevent callback if another thread is waiting } } @@ -881,12 +879,11 @@ void OutlineViewShell::GetMenuState( SfxItemSet &rSet ) if( SfxItemState::DEFAULT == rSet.GetItemState( SID_PASTE ) ) { - if ( !pClipEvtLstnr ) + if ( !mxClipEvtLstnr.is() ) { // create listener - pClipEvtLstnr = new TransferableClipboardListener( LINK( this, OutlineViewShell, ClipboardChanged ) ); - pClipEvtLstnr->acquire(); - pClipEvtLstnr->AddRemoveListener( GetActiveWindow(), true ); + mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, OutlineViewShell, ClipboardChanged ) ); + mxClipEvtLstnr->AddRemoveListener( GetActiveWindow(), true ); // get initial state TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) ); diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 6e7158a9d4c6..ea74addbe48c 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -1751,24 +1751,22 @@ uno::Sequence< uno::Reference< task::XInteractionContinuation > > } RequestPackageReparation::RequestPackageReparation( const OUString& aName ) + : mxImpl(new RequestPackageReparation_Impl( aName )) { - pImp = new RequestPackageReparation_Impl( aName ); - pImp->acquire(); } RequestPackageReparation::~RequestPackageReparation() { - pImp->release(); } bool RequestPackageReparation::isApproved() { - return pImp->isApproved(); + return mxImpl->isApproved(); } css::uno::Reference < task::XInteractionRequest > RequestPackageReparation::GetRequest() { - return css::uno::Reference < task::XInteractionRequest >(pImp); + return mxImpl.get(); } @@ -1810,19 +1808,17 @@ uno::Sequence< uno::Reference< task::XInteractionContinuation > > } NotifyBrokenPackage::NotifyBrokenPackage( const OUString& aName ) + : mxImpl(new NotifyBrokenPackage_Impl( aName )) { - pImp = new NotifyBrokenPackage_Impl( aName ); - pImp->acquire(); } NotifyBrokenPackage::~NotifyBrokenPackage() { - pImp->release(); } css::uno::Reference < task::XInteractionRequest > NotifyBrokenPackage::GetRequest() { - return css::uno::Reference < task::XInteractionRequest >(pImp); + return mxImpl.get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/stoc/source/defaultregistry/defaultregistry.cxx b/stoc/source/defaultregistry/defaultregistry.cxx index 5637d55f439f..45dc8482291a 100644 --- a/stoc/source/defaultregistry/defaultregistry.cxx +++ b/stoc/source/defaultregistry/defaultregistry.cxx @@ -139,7 +139,7 @@ protected: OUString m_name; sal_uInt32 m_state; - NestedRegistryImpl* m_pRegistry; + rtl::Reference<NestedRegistryImpl> m_xRegistry; Reference<XRegistryKey> m_localKey; Reference<XRegistryKey> m_defaultKey; }; @@ -148,10 +148,8 @@ protected: NestedKeyImpl::NestedKeyImpl( NestedRegistryImpl* pDefaultRegistry, Reference<XRegistryKey>& localKey, Reference<XRegistryKey>& defaultKey ) - : m_pRegistry(pDefaultRegistry) + : m_xRegistry(pDefaultRegistry) { - m_pRegistry->acquire(); - m_localKey = localKey; m_defaultKey = defaultKey; @@ -164,16 +162,14 @@ NestedKeyImpl::NestedKeyImpl( NestedRegistryImpl* pDefaultRegistry, m_name = m_defaultKey->getKeyName(); } - m_state = m_pRegistry->m_state; + m_state = m_xRegistry->m_state; } NestedKeyImpl::NestedKeyImpl( const OUString& rKeyName, NestedKeyImpl* pKey) - : m_pRegistry(pKey->m_pRegistry) + : m_xRegistry(pKey->m_xRegistry) { - m_pRegistry->acquire(); - if (pKey->m_localKey.is() && pKey->m_localKey->isValid()) { m_localKey = pKey->m_localKey->openKey(rKeyName); @@ -192,23 +188,21 @@ NestedKeyImpl::NestedKeyImpl( const OUString& rKeyName, m_name = m_defaultKey->getKeyName(); } - m_state = m_pRegistry->m_state; + m_state = m_xRegistry->m_state; } NestedKeyImpl::~NestedKeyImpl() { - if ( m_pRegistry ) - m_pRegistry->release(); } void NestedKeyImpl::computeChanges() { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( m_state != m_pRegistry->m_state ) + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); + if ( m_state != m_xRegistry->m_state ) { - Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey()); + Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey()); Reference<XRegistryKey> tmpKey = rootKey->openKey(m_name); @@ -217,7 +211,7 @@ void NestedKeyImpl::computeChanges() m_localKey = rootKey->openKey(m_name); } - m_state = m_pRegistry->m_state; + m_state = m_xRegistry->m_state; } } @@ -228,7 +222,7 @@ OUString NestedKeyImpl::computeName(const OUString& name) { OUString resLocalName, resDefaultName; - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); try { if ( m_localKey.is() && m_localKey->isValid() ) @@ -240,10 +234,10 @@ OUString NestedKeyImpl::computeName(const OUString& name) return m_defaultKey->getResolvedName(name); } - if ( !resLocalName.isEmpty() && m_pRegistry->m_defaultReg->isValid() ) + if ( !resLocalName.isEmpty() && m_xRegistry->m_defaultReg->isValid() ) { - Reference<XRegistryKey> localRoot(m_pRegistry->m_localReg->getRootKey()); - Reference<XRegistryKey> defaultRoot(m_pRegistry->m_defaultReg->getRootKey()); + Reference<XRegistryKey> localRoot(m_xRegistry->m_localReg->getRootKey()); + Reference<XRegistryKey> defaultRoot(m_xRegistry->m_defaultReg->getRootKey()); resDefaultName = defaultRoot->getResolvedName(resLocalName); @@ -271,7 +265,7 @@ OUString NestedKeyImpl::computeName(const OUString& name) OUString SAL_CALL NestedKeyImpl::getKeyName() throw(RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); return m_name; } @@ -279,7 +273,7 @@ OUString SAL_CALL NestedKeyImpl::getKeyName() throw(RuntimeException, std::excep sal_Bool SAL_CALL NestedKeyImpl::isReadOnly( ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -291,7 +285,7 @@ sal_Bool SAL_CALL NestedKeyImpl::isReadOnly( ) sal_Bool SAL_CALL NestedKeyImpl::isValid( ) throw(RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); return ((m_localKey.is() && m_localKey->isValid()) || (m_defaultKey.is() && m_defaultKey->isValid()) ); } @@ -300,7 +294,7 @@ sal_Bool SAL_CALL NestedKeyImpl::isValid( ) throw(RuntimeException, std::except RegistryKeyType SAL_CALL NestedKeyImpl::getKeyType( const OUString& rKeyName ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -319,7 +313,7 @@ RegistryKeyType SAL_CALL NestedKeyImpl::getKeyType( const OUString& rKeyName ) RegistryValueType SAL_CALL NestedKeyImpl::getValueType( ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -338,7 +332,7 @@ RegistryValueType SAL_CALL NestedKeyImpl::getValueType( ) sal_Int32 SAL_CALL NestedKeyImpl::getLongValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -359,7 +353,7 @@ sal_Int32 SAL_CALL NestedKeyImpl::getLongValue( ) void SAL_CALL NestedKeyImpl::setLongValue( sal_Int32 value ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -368,10 +362,10 @@ void SAL_CALL NestedKeyImpl::setLongValue( sal_Int32 value ) } else if ( m_defaultKey.is() && m_defaultKey->isValid() ) { - Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey()); + Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey()); m_localKey = rootKey->createKey(m_name); m_localKey->setLongValue(value); - m_state = m_pRegistry->m_state++; + m_state = m_xRegistry->m_state++; } else { @@ -383,7 +377,7 @@ void SAL_CALL NestedKeyImpl::setLongValue( sal_Int32 value ) Sequence< sal_Int32 > SAL_CALL NestedKeyImpl::getLongListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -404,7 +398,7 @@ Sequence< sal_Int32 > SAL_CALL NestedKeyImpl::getLongListValue( ) void SAL_CALL NestedKeyImpl::setLongListValue( const Sequence< sal_Int32 >& seqValue ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -413,10 +407,10 @@ void SAL_CALL NestedKeyImpl::setLongListValue( const Sequence< sal_Int32 >& seqV } else if ( m_defaultKey.is() && m_defaultKey->isValid() ) { - Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey()); + Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey()); m_localKey = rootKey->createKey(m_name); m_localKey->setLongListValue(seqValue); - m_state = m_pRegistry->m_state++; + m_state = m_xRegistry->m_state++; } else { @@ -428,7 +422,7 @@ void SAL_CALL NestedKeyImpl::setLongListValue( const Sequence< sal_Int32 >& seqV OUString SAL_CALL NestedKeyImpl::getAsciiValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -449,7 +443,7 @@ OUString SAL_CALL NestedKeyImpl::getAsciiValue( ) void SAL_CALL NestedKeyImpl::setAsciiValue( const OUString& value ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -458,10 +452,10 @@ void SAL_CALL NestedKeyImpl::setAsciiValue( const OUString& value ) } else if ( m_defaultKey.is() && m_defaultKey->isValid() ) { - Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey()); + Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey()); m_localKey = rootKey->createKey(m_name); m_localKey->setAsciiValue(value); - m_state = m_pRegistry->m_state++; + m_state = m_xRegistry->m_state++; } else { @@ -473,7 +467,7 @@ void SAL_CALL NestedKeyImpl::setAsciiValue( const OUString& value ) Sequence< OUString > SAL_CALL NestedKeyImpl::getAsciiListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -494,7 +488,7 @@ Sequence< OUString > SAL_CALL NestedKeyImpl::getAsciiListValue( ) void SAL_CALL NestedKeyImpl::setAsciiListValue( const Sequence< OUString >& seqValue ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -503,10 +497,10 @@ void SAL_CALL NestedKeyImpl::setAsciiListValue( const Sequence< OUString >& seqV } else if ( m_defaultKey.is() && m_defaultKey->isValid() ) { - Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey()); + Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey()); m_localKey = rootKey->createKey(m_name); m_localKey->setAsciiListValue(seqValue); - m_state = m_pRegistry->m_state++; + m_state = m_xRegistry->m_state++; } else { @@ -518,7 +512,7 @@ void SAL_CALL NestedKeyImpl::setAsciiListValue( const Sequence< OUString >& seqV OUString SAL_CALL NestedKeyImpl::getStringValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -539,7 +533,7 @@ OUString SAL_CALL NestedKeyImpl::getStringValue( ) void SAL_CALL NestedKeyImpl::setStringValue( const OUString& value ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -548,10 +542,10 @@ void SAL_CALL NestedKeyImpl::setStringValue( const OUString& value ) } else if ( m_defaultKey.is() && m_defaultKey->isValid() ) { - Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey()); + Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey()); m_localKey = rootKey->createKey(m_name); m_localKey->setStringValue(value); - m_state = m_pRegistry->m_state++; + m_state = m_xRegistry->m_state++; } else { @@ -563,7 +557,7 @@ void SAL_CALL NestedKeyImpl::setStringValue( const OUString& value ) Sequence< OUString > SAL_CALL NestedKeyImpl::getStringListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -584,7 +578,7 @@ Sequence< OUString > SAL_CALL NestedKeyImpl::getStringListValue( ) void SAL_CALL NestedKeyImpl::setStringListValue( const Sequence< OUString >& seqValue ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -593,10 +587,10 @@ void SAL_CALL NestedKeyImpl::setStringListValue( const Sequence< OUString >& seq } else if ( m_defaultKey.is() && m_defaultKey->isValid() ) { - Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey()); + Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey()); m_localKey = rootKey->createKey(m_name); m_localKey->setStringListValue(seqValue); - m_state = m_pRegistry->m_state++; + m_state = m_xRegistry->m_state++; } else { @@ -608,7 +602,7 @@ void SAL_CALL NestedKeyImpl::setStringListValue( const Sequence< OUString >& seq Sequence< sal_Int8 > SAL_CALL NestedKeyImpl::getBinaryValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -629,7 +623,7 @@ Sequence< sal_Int8 > SAL_CALL NestedKeyImpl::getBinaryValue( ) void SAL_CALL NestedKeyImpl::setBinaryValue( const Sequence< sal_Int8 >& value ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); computeChanges(); if ( m_localKey.is() && m_localKey->isValid() ) @@ -638,10 +632,10 @@ void SAL_CALL NestedKeyImpl::setBinaryValue( const Sequence< sal_Int8 >& value ) } else if ( m_defaultKey.is() && m_defaultKey->isValid() ) { - Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey()); + Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey()); m_localKey = rootKey->createKey(m_name); m_localKey->setBinaryValue(value); - m_state = m_pRegistry->m_state++; + m_state = m_xRegistry->m_state++; } else { @@ -653,7 +647,7 @@ void SAL_CALL NestedKeyImpl::setBinaryValue( const Sequence< sal_Int8 >& value ) Reference< XRegistryKey > SAL_CALL NestedKeyImpl::openKey( const OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); if ( !m_localKey.is() && !m_defaultKey.is() ) { throw InvalidRegistryException(); @@ -668,16 +662,16 @@ Reference< XRegistryKey > SAL_CALL NestedKeyImpl::openKey( const OUString& aKeyN if ( m_localKey.is() && m_localKey->isValid() ) { - localKey = m_pRegistry->m_localReg->getRootKey()->openKey(resolvedName); + localKey = m_xRegistry->m_localReg->getRootKey()->openKey(resolvedName); } if ( m_defaultKey.is() && m_defaultKey->isValid() ) { - defaultKey = m_pRegistry->m_defaultReg->getRootKey()->openKey(resolvedName); + defaultKey = m_xRegistry->m_defaultReg->getRootKey()->openKey(resolvedName); } if ( localKey.is() || defaultKey.is() ) { - return static_cast<XRegistryKey*>(new NestedKeyImpl(m_pRegistry, localKey, defaultKey)); + return static_cast<XRegistryKey*>(new NestedKeyImpl(m_xRegistry.get(), localKey, defaultKey)); } else { @@ -689,7 +683,7 @@ Reference< XRegistryKey > SAL_CALL NestedKeyImpl::openKey( const OUString& aKeyN Reference< XRegistryKey > SAL_CALL NestedKeyImpl::createKey( const OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); if ( (!m_localKey.is() && !m_defaultKey.is()) || (m_localKey.is() && m_localKey->isReadOnly()) ) { @@ -705,17 +699,17 @@ Reference< XRegistryKey > SAL_CALL NestedKeyImpl::createKey( const OUString& aKe { Reference<XRegistryKey> localKey, defaultKey; - localKey = m_pRegistry->m_localReg->getRootKey()->createKey(resolvedName); + localKey = m_xRegistry->m_localReg->getRootKey()->createKey(resolvedName); if ( localKey.is() ) { if ( m_defaultKey.is() && m_defaultKey->isValid() ) { - defaultKey = m_pRegistry->m_defaultReg->getRootKey()->openKey(resolvedName); + defaultKey = m_xRegistry->m_defaultReg->getRootKey()->openKey(resolvedName); } - m_state = m_pRegistry->m_state++; + m_state = m_xRegistry->m_state++; - return (static_cast<XRegistryKey*>(new NestedKeyImpl(m_pRegistry, localKey, defaultKey))); + return (static_cast<XRegistryKey*>(new NestedKeyImpl(m_xRegistry.get(), localKey, defaultKey))); } } else @@ -724,18 +718,18 @@ Reference< XRegistryKey > SAL_CALL NestedKeyImpl::createKey( const OUString& aKe if ( m_defaultKey.is() && m_defaultKey->isValid() ) { - Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey()); + Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey()); m_localKey = rootKey->createKey(m_name); - localKey = m_pRegistry->m_localReg->getRootKey()->createKey(resolvedName); + localKey = m_xRegistry->m_localReg->getRootKey()->createKey(resolvedName); if ( localKey.is() ) { - defaultKey = m_pRegistry->m_defaultReg->getRootKey()->openKey(resolvedName); + defaultKey = m_xRegistry->m_defaultReg->getRootKey()->openKey(resolvedName); - m_state = m_pRegistry->m_state++; + m_state = m_xRegistry->m_state++; - return (static_cast<XRegistryKey*>(new NestedKeyImpl(m_pRegistry, localKey, defaultKey))); + return (static_cast<XRegistryKey*>(new NestedKeyImpl(m_xRegistry.get(), localKey, defaultKey))); } } } @@ -747,7 +741,7 @@ Reference< XRegistryKey > SAL_CALL NestedKeyImpl::createKey( const OUString& aKe void SAL_CALL NestedKeyImpl::closeKey( ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); if ( m_localKey.is() && m_localKey->isValid() ) { m_localKey->closeKey(); @@ -762,7 +756,7 @@ void SAL_CALL NestedKeyImpl::closeKey( ) void SAL_CALL NestedKeyImpl::deleteKey( const OUString& rKeyName ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); if ( m_localKey.is() && m_localKey->isValid() && !m_localKey->isReadOnly() ) { @@ -773,7 +767,7 @@ void SAL_CALL NestedKeyImpl::deleteKey( const OUString& rKeyName ) throw InvalidRegistryException(); } - m_pRegistry->m_localReg->getRootKey()->deleteKey(resolvedName); + m_xRegistry->m_localReg->getRootKey()->deleteKey(resolvedName); } else { @@ -785,7 +779,7 @@ void SAL_CALL NestedKeyImpl::deleteKey( const OUString& rKeyName ) Sequence< Reference< XRegistryKey > > SAL_CALL NestedKeyImpl::openKeys( ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); if ( !m_localKey.is() && !m_defaultKey.is() ) { throw InvalidRegistryException(); @@ -864,7 +858,7 @@ Sequence< Reference< XRegistryKey > > SAL_CALL NestedKeyImpl::openKeys( ) Sequence< OUString > SAL_CALL NestedKeyImpl::getKeyNames( ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); if ( !m_localKey.is() && !m_defaultKey.is() ) { throw InvalidRegistryException(); @@ -930,7 +924,7 @@ Sequence< OUString > SAL_CALL NestedKeyImpl::getKeyNames( ) sal_Bool SAL_CALL NestedKeyImpl::createLink( const OUString& aLinkName, const OUString& aLinkTarget ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); bool isCreated = false; if ( !m_localKey.is() && !m_defaultKey.is() ) @@ -965,21 +959,21 @@ sal_Bool SAL_CALL NestedKeyImpl::createLink( const OUString& aLinkName, const OU if ( m_localKey.is() && m_localKey->isValid() ) { - isCreated = m_pRegistry->m_localReg->getRootKey()->createLink(resolvedName, aLinkTarget); + isCreated = m_xRegistry->m_localReg->getRootKey()->createLink(resolvedName, aLinkTarget); } else { if ( m_defaultKey.is() && m_defaultKey->isValid() ) { - Reference<XRegistryKey> rootKey(m_pRegistry->m_localReg->getRootKey()); + Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey()); m_localKey = rootKey->createKey(m_name); - isCreated = m_pRegistry->m_localReg->getRootKey()->createLink(resolvedName, aLinkTarget); + isCreated = m_xRegistry->m_localReg->getRootKey()->createLink(resolvedName, aLinkTarget); } } if ( isCreated ) - m_state = m_pRegistry->m_state++; + m_state = m_xRegistry->m_state++; return isCreated; } @@ -988,7 +982,7 @@ sal_Bool SAL_CALL NestedKeyImpl::createLink( const OUString& aLinkName, const OU void SAL_CALL NestedKeyImpl::deleteLink( const OUString& rLinkName ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); if ( !m_localKey.is() && !m_defaultKey.is() ) { throw InvalidRegistryException(); @@ -1022,7 +1016,7 @@ void SAL_CALL NestedKeyImpl::deleteLink( const OUString& rLinkName ) if ( m_localKey.is() && m_localKey->isValid() && !m_localKey->isReadOnly() ) { - m_pRegistry->m_localReg->getRootKey()->deleteLink(resolvedName); + m_xRegistry->m_localReg->getRootKey()->deleteLink(resolvedName); } else { @@ -1034,7 +1028,7 @@ void SAL_CALL NestedKeyImpl::deleteLink( const OUString& rLinkName ) OUString SAL_CALL NestedKeyImpl::getLinkTarget( const OUString& rLinkName ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); if ( !m_localKey.is() && !m_defaultKey.is() ) { throw InvalidRegistryException(); @@ -1070,7 +1064,7 @@ OUString SAL_CALL NestedKeyImpl::getLinkTarget( const OUString& rLinkName ) { try { - linkTarget = m_pRegistry->m_localReg->getRootKey()->getLinkTarget(resolvedName); + linkTarget = m_xRegistry->m_localReg->getRootKey()->getLinkTarget(resolvedName); return linkTarget; } catch(InvalidRegistryException& ) @@ -1079,7 +1073,7 @@ OUString SAL_CALL NestedKeyImpl::getLinkTarget( const OUString& rLinkName ) } if ( m_defaultKey.is() && m_defaultKey->isValid() ) - linkTarget = m_pRegistry->m_defaultReg->getRootKey()->getLinkTarget(resolvedName); + linkTarget = m_xRegistry->m_defaultReg->getRootKey()->getLinkTarget(resolvedName); return linkTarget; } @@ -1088,7 +1082,7 @@ OUString SAL_CALL NestedKeyImpl::getLinkTarget( const OUString& rLinkName ) OUString SAL_CALL NestedKeyImpl::getResolvedName( const OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException, std::exception) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); + Guard< Mutex > aGuard( m_xRegistry->m_mutex ); if ( !m_localKey.is() && !m_defaultKey.is() ) { throw InvalidRegistryException(); diff --git a/svtools/source/inc/unoiface.hxx b/svtools/source/inc/unoiface.hxx index bbe2f6a17243..7b9bc25f96b8 100644 --- a/svtools/source/inc/unoiface.hxx +++ b/svtools/source/inc/unoiface.hxx @@ -170,7 +170,7 @@ public: class SVTXFormattedField : public VCLXSpinField { protected: - SvNumberFormatsSupplierObj* m_pCurrentSupplier; + rtl::Reference<SvNumberFormatsSupplierObj> m_xCurrentSupplier; bool bIsStandardSupplier; sal_Int32 nKeyToSetDelayed; diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx index 595106ee2f7c..0e14c9a78375 100644 --- a/svtools/source/uno/unoiface.cxx +++ b/svtools/source/uno/unoiface.cxx @@ -810,8 +810,7 @@ void VCLXFileControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) SVTXFormattedField::SVTXFormattedField() - :m_pCurrentSupplier(nullptr) - ,bIsStandardSupplier(true) + :bIsStandardSupplier(true) ,nKeyToSetDelayed(-1) { } @@ -819,11 +818,6 @@ SVTXFormattedField::SVTXFormattedField() SVTXFormattedField::~SVTXFormattedField() { - if (m_pCurrentSupplier) - { - m_pCurrentSupplier->release(); - m_pCurrentSupplier = nullptr; - } } @@ -1029,7 +1023,7 @@ css::uno::Any SVTXFormattedField::getProperty( const OUString& PropertyName ) th css::uno::Reference< css::util::XNumberFormatsSupplier > SVTXFormattedField::getFormatsSupplier() const { - return css::uno::Reference< css::util::XNumberFormatsSupplier > (m_pCurrentSupplier); + return m_xCurrentSupplier.get(); } css::uno::Any SVTXFormattedField::convertEffectiveValue(const css::uno::Any& rValue) @@ -1317,15 +1311,12 @@ void SVTXFormattedField::setFormatsSupplier(const css::uno::Reference< css::util if (!pNew) return; // TODO : how to process ? - if (m_pCurrentSupplier) - m_pCurrentSupplier->release(); - m_pCurrentSupplier = pNew; - m_pCurrentSupplier->acquire(); + m_xCurrentSupplier = pNew; if (pField) { // save the actual value css::uno::Any aCurrent = GetValue(); - pField->SetFormatter(m_pCurrentSupplier->GetNumberFormatter(), false); + pField->SetFormatter(m_xCurrentSupplier->GetNumberFormatter(), false); if (nKeyToSetDelayed != -1) { pField->SetFormatKey(nKeyToSetDelayed); diff --git a/svtools/source/uno/unoimap.cxx b/svtools/source/uno/unoimap.cxx index 8dee26a8741b..b7652417d041 100644 --- a/svtools/source/uno/unoimap.cxx +++ b/svtools/source/uno/unoimap.cxx @@ -79,7 +79,7 @@ public: IMapObject* createIMapObject() const; - SvMacroTableEventDescriptor* mpEvents; + rtl::Reference<SvMacroTableEventDescriptor> mxEvents; // overriden helpers from PropertySetHelper virtual void _setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException ) override; @@ -186,8 +186,7 @@ SvUnoImageMapObject::SvUnoImageMapObject( sal_uInt16 nType, const SvEventDescrip , mbIsActive( true ) , mnRadius( 0 ) { - mpEvents = new SvMacroTableEventDescriptor( pSupportedMacroItems ); - mpEvents->acquire(); + mxEvents = new SvMacroTableEventDescriptor( pSupportedMacroItems ); } SvUnoImageMapObject::SvUnoImageMapObject( const IMapObject& rMapObject, const SvEventDescription* pSupportedMacroItems ) @@ -243,13 +242,11 @@ SvUnoImageMapObject::SvUnoImageMapObject( const IMapObject& rMapObject, const Sv } } - mpEvents = new SvMacroTableEventDescriptor( rMapObject.GetMacroTable(), pSupportedMacroItems ); - mpEvents->acquire(); + mxEvents = new SvMacroTableEventDescriptor( rMapObject.GetMacroTable(), pSupportedMacroItems ); } SvUnoImageMapObject::~SvUnoImageMapObject() throw() { - mpEvents->release(); } IMapObject* SvUnoImageMapObject::createIMapObject() const @@ -297,7 +294,7 @@ IMapObject* SvUnoImageMapObject::createIMapObject() const } SvxMacroTableDtor aMacroTable; - mpEvents->copyMacrosIntoTable(aMacroTable); + mxEvents->copyMacrosIntoTable(aMacroTable); pNewIMapObject->SetMacroTable( aMacroTable ); return pNewIMapObject; @@ -512,9 +509,7 @@ void SvUnoImageMapObject::_getPropertyValues( const PropertyMapEntry** ppEntries Reference< XNameReplace > SAL_CALL SvUnoImageMapObject::getEvents() throw( RuntimeException, std::exception ) { - // try weak reference first - Reference< XNameReplace > xEvents( mpEvents ); - return xEvents; + return mxEvents.get(); } diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index 8effd55325b8..c6d48778b1b0 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -197,7 +197,7 @@ class DisposeListenerGridBridge : public FmXDisposeListener { osl::Mutex m_aMutex; DbGridControl& m_rParent; - FmXDisposeMultiplexer* m_pRealListener; + rtl::Reference<FmXDisposeMultiplexer> m_xRealListener; public: DisposeListenerGridBridge( DbGridControl& _rParent, const Reference< XComponent >& _rxObject); @@ -209,25 +209,20 @@ public: DisposeListenerGridBridge::DisposeListenerGridBridge(DbGridControl& _rParent, const Reference< XComponent >& _rxObject) :FmXDisposeListener(m_aMutex) ,m_rParent(_rParent) - ,m_pRealListener(nullptr) { if (_rxObject.is()) { - m_pRealListener = new FmXDisposeMultiplexer(this, _rxObject); - m_pRealListener->acquire(); + m_xRealListener = new FmXDisposeMultiplexer(this, _rxObject); } } DisposeListenerGridBridge::~DisposeListenerGridBridge() { - if (m_pRealListener) + if (m_xRealListener.is()) { - m_pRealListener->dispose(); - m_pRealListener->release(); - m_pRealListener = nullptr; + m_xRealListener->dispose(); } - } static const sal_uInt16 ControlMap[] = diff --git a/ucbhelper/source/client/proxydecider.cxx b/ucbhelper/source/client/proxydecider.cxx index 5c04d7910794..8b7630b9db17 100644 --- a/ucbhelper/source/client/proxydecider.cxx +++ b/ucbhelper/source/client/proxydecider.cxx @@ -772,19 +772,15 @@ void InternetProxyDecider_Impl::setNoProxyList( InternetProxyDecider::InternetProxyDecider( const uno::Reference< uno::XComponentContext>& rxContext ) -: m_pImpl( new proxydecider_impl::InternetProxyDecider_Impl( rxContext ) ) +: m_xImpl( new proxydecider_impl::InternetProxyDecider_Impl( rxContext ) ) { - m_pImpl->acquire(); } InternetProxyDecider::~InternetProxyDecider() { // Break circular reference between config listener and notifier. - m_pImpl->dispose(); - - // Let him go... - m_pImpl->release(); + m_xImpl->dispose(); } @@ -792,7 +788,7 @@ bool InternetProxyDecider::shouldUseProxy( const OUString & rProtocol, const OUString & rHost, sal_Int32 nPort ) const { - const InternetProxyServer & rData = m_pImpl->getProxy( rProtocol, + const InternetProxyServer & rData = m_xImpl->getProxy( rProtocol, rHost, nPort ); return !rData.aName.isEmpty(); @@ -804,7 +800,7 @@ const InternetProxyServer & InternetProxyDecider::getProxy( const OUString & rHost, sal_Int32 nPort ) const { - return m_pImpl->getProxy( rProtocol, rHost, nPort ); + return m_xImpl->getProxy( rProtocol, rHost, nPort ); } } // namespace ucbhelper diff --git a/xmloff/source/draw/animationexport.cxx b/xmloff/source/draw/animationexport.cxx index b9180575fe73..9be390ed7a5a 100644 --- a/xmloff/source/draw/animationexport.cxx +++ b/xmloff/source/draw/animationexport.cxx @@ -531,7 +531,7 @@ private: SvXMLExport& mrExport; Reference< XInterface > mxExport; Reference< XPropertySet > mxPageProps; - XMLSdPropHdlFactory* mpSdPropHdlFactory; + rtl::Reference<XMLSdPropHdlFactory> mxSdPropHdlFactory; }; AnimationsExporterImpl::AnimationsExporterImpl( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps ) @@ -548,19 +548,11 @@ AnimationsExporterImpl::AnimationsExporterImpl( SvXMLExport& rExport, const Refe OSL_FAIL( "xmloff::AnimationsExporterImpl::AnimationsExporterImpl(), RuntimeException caught!" ); } - mpSdPropHdlFactory = new XMLSdPropHdlFactory( mrExport.GetModel(), mrExport ); - // set lock to avoid deletion - mpSdPropHdlFactory->acquire(); + mxSdPropHdlFactory = new XMLSdPropHdlFactory( mrExport.GetModel(), mrExport ); } AnimationsExporterImpl::~AnimationsExporterImpl() { - // cleanup factory, decrease refcount. Should lead to destruction. - if(mpSdPropHdlFactory) - { - mpSdPropHdlFactory->release(); - mpSdPropHdlFactory = nullptr; - } } void AnimationsExporterImpl::exportTransitionNode() @@ -1524,7 +1516,7 @@ void AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName, OUString } //const XMLPropertyHandler* pHandler = static_cast<SdXMLExport*>(&mrExport)->GetSdPropHdlFactory()->GetPropertyHandler( nType ); - const XMLPropertyHandler* pHandler = mpSdPropHdlFactory->GetPropertyHandler( nType ); + const XMLPropertyHandler* pHandler = mxSdPropHdlFactory->GetPropertyHandler( nType ); if( pHandler ) { OUString aString; diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx b/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx index 736afd5a6829..7ef444abaeae 100644 --- a/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx +++ b/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx @@ -43,23 +43,15 @@ namespace xmlscript BasicElementBase::BasicElementBase( const OUString& rLocalName, const Reference< xml::input::XAttributes >& xAttributes, BasicElementBase* pParent, BasicImport* pImport ) - :m_pImport( pImport ) - ,m_pParent( pParent ) + :m_xImport( pImport ) + ,m_xParent( pParent ) ,m_aLocalName( rLocalName ) ,m_xAttributes( xAttributes ) { - if ( m_pImport ) - m_pImport->acquire(); - if ( m_pParent ) - m_pParent->acquire(); } BasicElementBase::~BasicElementBase() { - if ( m_pImport ) - m_pImport->release(); - if ( m_pParent ) - m_pParent->release(); } bool BasicElementBase::getBoolAttr( bool* pRet, const OUString& rAttrName, @@ -95,7 +87,7 @@ namespace xmlscript Reference< xml::input::XElement > BasicElementBase::getParent() throw (RuntimeException, std::exception) { - return static_cast< xml::input::XElement* >( m_pParent ); + return m_xParent.get(); } OUString BasicElementBase::getLocalName() @@ -108,8 +100,8 @@ namespace xmlscript throw (RuntimeException, std::exception) { sal_Int32 nId = -1; - if ( m_pImport ) - nId = m_pImport->XMLNS_UID; + if ( m_xImport.is() ) + nId = m_xImport->XMLNS_UID; return nId; } @@ -168,7 +160,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const { Reference< xml::input::XElement > xElement; - if ( nUid != m_pImport->XMLNS_UID ) + if ( nUid != m_xImport->XMLNS_UID ) { throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() ); } @@ -176,12 +168,12 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const { if ( xAttributes.is() ) { - OUString aName = xAttributes->getValueByUidName( m_pImport->XMLNS_UID, "name" ); + OUString aName = xAttributes->getValueByUidName( m_xImport->XMLNS_UID, "name" ); - OUString aStorageURL = xAttributes->getValueByUidName(m_pImport->XMLNS_XLINK_UID, "href" ); + OUString aStorageURL = xAttributes->getValueByUidName(m_xImport->XMLNS_XLINK_UID, "href" ); bool bReadOnly = false; - getBoolAttr( &bReadOnly,"readonly", xAttributes, m_pImport->XMLNS_UID ); + getBoolAttr( &bReadOnly,"readonly", xAttributes, m_xImport->XMLNS_UID ); if ( m_xLibContainer.is() ) { @@ -190,7 +182,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const Reference< container::XNameAccess > xLib( m_xLibContainer->createLibraryLink( aName, aStorageURL, bReadOnly ) ); if ( xLib.is() ) - xElement.set( new BasicElementBase( rLocalName, xAttributes, this, m_pImport ) ); + xElement.set( new BasicElementBase( rLocalName, xAttributes, this, m_xImport.get() ) ); } catch ( const container::ElementExistException& e ) { @@ -209,10 +201,10 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const if ( xAttributes.is() ) { - OUString aName = xAttributes->getValueByUidName( m_pImport->XMLNS_UID, "name" ); + OUString aName = xAttributes->getValueByUidName( m_xImport->XMLNS_UID, "name" ); bool bReadOnly = false; - getBoolAttr( &bReadOnly, "readonly", xAttributes, m_pImport->XMLNS_UID ); + getBoolAttr( &bReadOnly, "readonly", xAttributes, m_xImport->XMLNS_UID ); if ( m_xLibContainer.is() ) { @@ -230,7 +222,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const } if ( xLib.is() ) - xElement.set( new BasicEmbeddedLibraryElement( rLocalName, xAttributes, this, m_pImport, m_xLibContainer, aName, bReadOnly ) ); + xElement.set( new BasicEmbeddedLibraryElement( rLocalName, xAttributes, this, m_xImport.get(), m_xLibContainer, aName, bReadOnly ) ); } catch ( const lang::IllegalArgumentException& e ) { @@ -284,7 +276,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const { Reference< xml::input::XElement > xElement; - if ( nUid != m_pImport->XMLNS_UID ) + if ( nUid != m_xImport->XMLNS_UID ) { throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() ); } @@ -292,10 +284,10 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const { if ( xAttributes.is() ) { - OUString aName = xAttributes->getValueByUidName(m_pImport->XMLNS_UID, "name" ); + OUString aName = xAttributes->getValueByUidName(m_xImport->XMLNS_UID, "name" ); if ( m_xLib.is() && !aName.isEmpty() ) - xElement.set( new BasicModuleElement( rLocalName, xAttributes, this, m_pImport, m_xLib, aName ) ); + xElement.set( new BasicModuleElement( rLocalName, xAttributes, this, m_xImport.get(), m_xLib, aName ) ); } } else @@ -336,7 +328,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const Reference< xml::input::XElement > xElement; - if ( nUid != m_pImport->XMLNS_UID ) + if ( nUid != m_xImport->XMLNS_UID ) { throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() ); } @@ -347,7 +339,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const if ( xAttributes.is() ) { if ( m_xLib.is() && !m_aName.isEmpty() ) - xElement.set( new BasicSourceCodeElement( rLocalName, xAttributes, this, m_pImport, m_xLib, m_aName ) ); + xElement.set( new BasicSourceCodeElement( rLocalName, xAttributes, this, m_xImport.get(), m_xLib, m_aName ) ); } } else diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx b/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx index 0eecb0dd1cd3..41219d7fb4c0 100644 --- a/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx +++ b/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx @@ -29,6 +29,7 @@ #include <cppuhelper/implbase.hxx> #include <osl/mutex.hxx> #include <rtl/ustrbuf.hxx> +#include <rtl/ref.hxx> namespace xmlscript { @@ -43,8 +44,8 @@ namespace xmlscript class BasicElementBase : public BasicElementBase_BASE { protected: - BasicImport* m_pImport; - BasicElementBase* m_pParent; + rtl::Reference<BasicImport> m_xImport; + rtl::Reference<BasicElementBase> m_xParent; OUString m_aLocalName; css::uno::Reference< css::xml::input::XAttributes > m_xAttributes; diff --git a/xmlscript/source/xmllib_imexp/imp_share.hxx b/xmlscript/source/xmllib_imexp/imp_share.hxx index a28fb2f7cd33..bf69df696386 100644 --- a/xmlscript/source/xmllib_imexp/imp_share.hxx +++ b/xmlscript/source/xmllib_imexp/imp_share.hxx @@ -32,6 +32,7 @@ #include <com/sun/star/awt/FontDescriptor.hpp> #include <com/sun/star/xml/input/XRoot.hpp> +#include <rtl/ref.hxx> #include <vector> @@ -155,8 +156,8 @@ class LibElementBase : public ::cppu::WeakImplHelper< css::xml::input::XElement > { protected: - LibraryImport * _pImport; - LibElementBase * _pParent; + rtl::Reference<LibraryImport> mxImport; + rtl::Reference<LibElementBase> mxParent; OUString _aLocalName; css::uno::Reference< css::xml::input::XAttributes > _xAttributes; diff --git a/xmlscript/source/xmllib_imexp/xmllib_import.cxx b/xmlscript/source/xmllib_imexp/xmllib_import.cxx index 891919228d08..c81edf6f36c0 100644 --- a/xmlscript/source/xmllib_imexp/xmllib_import.cxx +++ b/xmlscript/source/xmllib_imexp/xmllib_import.cxx @@ -33,7 +33,7 @@ namespace xmlscript Reference< xml::input::XElement > LibElementBase::getParent() throw (RuntimeException, std::exception) { - return static_cast< xml::input::XElement * >( _pParent ); + return mxParent.get(); } OUString LibElementBase::getLocalName() @@ -45,7 +45,7 @@ OUString LibElementBase::getLocalName() sal_Int32 LibElementBase::getUid() throw (RuntimeException, std::exception) { - return _pImport->XMLNS_LIBRARY_UID; + return mxImport->XMLNS_LIBRARY_UID; } Reference< xml::input::XAttributes > LibElementBase::getAttributes() @@ -88,28 +88,15 @@ LibElementBase::LibElementBase( OUString const & rLocalName, Reference< xml::input::XAttributes > const & xAttributes, LibElementBase * pParent, LibraryImport * pImport ) - : _pImport( pImport ) - , _pParent( pParent ) + : mxImport( pImport ) + , mxParent( pParent ) , _aLocalName( rLocalName ) , _xAttributes( xAttributes ) { - _pImport->acquire(); - - if (_pParent) - { - _pParent->acquire(); - } } LibElementBase::~LibElementBase() { - _pImport->release(); - - if (_pParent) - { - _pParent->release(); - } - SAL_INFO("xmlscript.xmllib", "LibElementBase::~LibElementBase(): " << _aLocalName ); } @@ -182,7 +169,7 @@ Reference< xml::input::XElement > LibrariesElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException, std::exception) { - if (_pImport->XMLNS_LIBRARY_UID != nUid) + if (mxImport->XMLNS_LIBRARY_UID != nUid) { throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() ); } @@ -192,14 +179,14 @@ Reference< xml::input::XElement > LibrariesElement::startChildElement( LibDescriptor aDesc; aDesc.bLink = aDesc.bReadOnly = aDesc.bPasswordProtected = aDesc.bPreload = false; - aDesc.aName = xAttributes->getValueByUidName(_pImport->XMLNS_LIBRARY_UID, "name" ); - aDesc.aStorageURL = xAttributes->getValueByUidName( _pImport->XMLNS_XLINK_UID, "href" ); - getBoolAttr(&aDesc.bLink, "link", xAttributes, _pImport->XMLNS_LIBRARY_UID ); - getBoolAttr(&aDesc.bReadOnly, "readonly", xAttributes, _pImport->XMLNS_LIBRARY_UID ); - getBoolAttr(&aDesc.bPasswordProtected, "passwordprotected", xAttributes, _pImport->XMLNS_LIBRARY_UID ); + aDesc.aName = xAttributes->getValueByUidName(mxImport->XMLNS_LIBRARY_UID, "name" ); + aDesc.aStorageURL = xAttributes->getValueByUidName( mxImport->XMLNS_XLINK_UID, "href" ); + getBoolAttr(&aDesc.bLink, "link", xAttributes, mxImport->XMLNS_LIBRARY_UID ); + getBoolAttr(&aDesc.bReadOnly, "readonly", xAttributes, mxImport->XMLNS_LIBRARY_UID ); + getBoolAttr(&aDesc.bPasswordProtected, "passwordprotected", xAttributes, mxImport->XMLNS_LIBRARY_UID ); mLibDescriptors.push_back( aDesc ); - return new LibraryElement( rLocalName, xAttributes, this, _pImport ); + return new LibraryElement( rLocalName, xAttributes, this, mxImport.get() ); } else { @@ -210,13 +197,13 @@ Reference< xml::input::XElement > LibrariesElement::startChildElement( void LibrariesElement::endElement() throw (xml::sax::SAXException, RuntimeException, std::exception) { - sal_Int32 nLibCount = _pImport->mpLibArray->mnLibCount = (sal_Int32)mLibDescriptors.size(); - _pImport->mpLibArray->mpLibs = new LibDescriptor[ nLibCount ]; + sal_Int32 nLibCount = mxImport->mpLibArray->mnLibCount = (sal_Int32)mLibDescriptors.size(); + mxImport->mpLibArray->mpLibs = new LibDescriptor[ nLibCount ]; for( sal_Int32 i = 0 ; i < nLibCount ; i++ ) { const LibDescriptor& rLib = mLibDescriptors[i]; - _pImport->mpLibArray->mpLibs[i] = rLib; + mxImport->mpLibArray->mpLibs[i] = rLib; } } @@ -226,18 +213,18 @@ Reference< xml::input::XElement > LibraryElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException, std::exception) { - if (_pImport->XMLNS_LIBRARY_UID != nUid) + if (mxImport->XMLNS_LIBRARY_UID != nUid) { throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() ); } // library else if ( rLocalName == "element" ) { - OUString aValue( xAttributes->getValueByUidName(_pImport->XMLNS_LIBRARY_UID, "name" ) ); + OUString aValue( xAttributes->getValueByUidName(mxImport->XMLNS_LIBRARY_UID, "name" ) ); if (!aValue.isEmpty()) mElements.push_back( aValue ); - return new LibElementBase( rLocalName, xAttributes, this, _pImport ); + return new LibElementBase( rLocalName, xAttributes, this, mxImport.get() ); } else { @@ -254,9 +241,9 @@ void LibraryElement::endElement() for( sal_Int32 i = 0 ; i < nElementCount ; i++ ) pElementNames[i] = mElements[i]; - LibDescriptor* pLib = _pImport->mpLibDesc; + LibDescriptor* pLib = mxImport->mpLibDesc; if( !pLib ) - pLib = &static_cast< LibrariesElement* >( _pParent )->mLibDescriptors.back(); + pLib = &static_cast< LibrariesElement* >( mxParent.get() )->mLibDescriptors.back(); pLib->aElementNames = aElementNames; } diff --git a/xmlscript/source/xmlmod_imexp/imp_share.hxx b/xmlscript/source/xmlmod_imexp/imp_share.hxx index 05ca0944ce04..6a1bede592fb 100644 --- a/xmlscript/source/xmlmod_imexp/imp_share.hxx +++ b/xmlscript/source/xmlmod_imexp/imp_share.hxx @@ -24,6 +24,7 @@ #include <cppuhelper/implbase.hxx> #include <rtl/ustrbuf.hxx> +#include <rtl/ref.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XNameContainer.hpp> @@ -85,8 +86,8 @@ class ModuleElement : public ::cppu::WeakImplHelper< css::xml::input::XElement > { protected: - ModuleImport * _pImport; - ModuleElement * _pParent; + rtl::Reference<ModuleImport> mxImport; + rtl::Reference<ModuleElement> mxParent; OUString _aLocalName; css::uno::Reference< css::xml::input::XAttributes > _xAttributes; diff --git a/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx b/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx index f724ff7593ba..e9f9869ef6cf 100644 --- a/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx +++ b/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx @@ -33,7 +33,7 @@ namespace xmlscript Reference< xml::input::XElement > ModuleElement::getParent() throw (RuntimeException, std::exception) { - return static_cast< xml::input::XElement * >( _pParent ); + return mxParent.get(); } OUString ModuleElement::getLocalName() throw (RuntimeException, std::exception) @@ -43,7 +43,7 @@ OUString ModuleElement::getLocalName() sal_Int32 ModuleElement::getUid() throw (RuntimeException, std::exception) { - return _pImport->XMLNS_SCRIPT_UID; + return mxImport->XMLNS_SCRIPT_UID; } Reference< xml::input::XAttributes > ModuleElement::getAttributes() throw (RuntimeException, std::exception) @@ -73,7 +73,7 @@ void ModuleElement::processingInstruction( void ModuleElement::endElement() throw (xml::sax::SAXException, RuntimeException, std::exception) { - _pImport->mrModuleDesc.aCode = _strBuffer.makeStringAndClear(); + mxImport->mrModuleDesc.aCode = _strBuffer.makeStringAndClear(); } Reference< xml::input::XElement > ModuleElement::startChildElement( @@ -88,28 +88,15 @@ ModuleElement::ModuleElement( OUString const & rLocalName, Reference< xml::input::XAttributes > const & xAttributes, ModuleElement * pParent, ModuleImport * pImport ) - : _pImport( pImport ) - , _pParent( pParent ) + : mxImport( pImport ) + , mxParent( pParent ) , _aLocalName( rLocalName ) , _xAttributes( xAttributes ) { - _pImport->acquire(); - - if (_pParent) - { - _pParent->acquire(); - } } ModuleElement::~ModuleElement() { - _pImport->release(); - - if (_pParent) - { - _pParent->release(); - } - SAL_INFO("xmlscript.xmlmod", "ModuleElement::~ModuleElement(): " << _aLocalName ); } |