diff options
43 files changed, 188 insertions, 330 deletions
diff --git a/include/svx/AccessibleControlShape.hxx b/include/svx/AccessibleControlShape.hxx index c419d22c1282..d2c2ec05c6b5 100644 --- a/include/svx/AccessibleControlShape.hxx +++ b/include/svx/AccessibleControlShape.hxx @@ -183,7 +183,7 @@ private: css::uno::Reference< css::lang::XComponent > m_xControlContextComponent; // cached interface of our aggregate - ::comphelper::OWrappedAccessibleChildrenManager* + rtl::Reference<::comphelper::OWrappedAccessibleChildrenManager> m_pChildManager; bool m_bListeningForName : 1; // are we currently listening for changes of the "Name" property? diff --git a/include/svx/dlgctrl.hxx b/include/svx/dlgctrl.hxx index 45d600c84bf2..2e6aa4c72aed 100644 --- a/include/svx/dlgctrl.hxx +++ b/include/svx/dlgctrl.hxx @@ -78,7 +78,7 @@ private: SVX_DLLPRIVATE void Resize_Impl(); protected: - SvxRectCtlAccessibleContext* pAccContext; + rtl::Reference<SvxRectCtlAccessibleContext> pAccContext; sal_uInt16 nBorderWidth; sal_uInt16 nRadius; Size aSize; diff --git a/include/svx/fmshell.hxx b/include/svx/fmshell.hxx index 8f4d656397fc..38b8c341fcfe 100644 --- a/include/svx/fmshell.hxx +++ b/include/svx/fmshell.hxx @@ -71,7 +71,7 @@ class SVX_DLLPUBLIC FmFormShell : public SfxShell friend class FmFormView; friend class FmXFormShell; - FmXFormShell* m_pImpl; + rtl::Reference<FmXFormShell> m_pImpl; FmFormView* m_pFormView; FmFormModel* m_pFormModel; @@ -113,7 +113,7 @@ public: FmFormView* GetFormView() const { return m_pFormView; } FmFormModel* GetFormModel() const { return m_pFormModel; } FmFormPage* GetCurPage() const; - FmXFormShell* GetImpl() const {return m_pImpl;}; + FmXFormShell* GetImpl() const {return m_pImpl.get();}; bool PrepareClose(bool bUI = true); diff --git a/include/svx/fmtools.hxx b/include/svx/fmtools.hxx index bd7696a4049c..e122243d4ac2 100644 --- a/include/svx/fmtools.hxx +++ b/include/svx/fmtools.hxx @@ -62,6 +62,7 @@ #include <com/sun/star/util/XNumberFormatter.hpp> #include <com/sun/star/util/XNumberFormats.hpp> +#include <rtl/ref.hxx> #include <tools/wintypes.hxx> #include <cppuhelper/weakref.hxx> #include <comphelper/uno3.hxx> @@ -156,11 +157,11 @@ class SAL_WARN_UNUSED FmXDisposeListener { friend class FmXDisposeMultiplexer; - FmXDisposeMultiplexer* m_pAdapter; + rtl::Reference<FmXDisposeMultiplexer> m_pAdapter; ::osl::Mutex& m_rMutex; public: - FmXDisposeListener(::osl::Mutex& _rMutex) : m_pAdapter(nullptr), m_rMutex(_rMutex) { } + FmXDisposeListener(::osl::Mutex& _rMutex) : m_rMutex(_rMutex) { } virtual ~FmXDisposeListener(); virtual void disposing(const css::lang::EventObject& _rEvent, sal_Int16 _nId) throw( css::uno::RuntimeException ) = 0; diff --git a/include/svx/fmview.hxx b/include/svx/fmview.hxx index dff8ce80cb68..ed6e2644e9a0 100644 --- a/include/svx/fmview.hxx +++ b/include/svx/fmview.hxx @@ -55,7 +55,7 @@ namespace com { namespace sun { namespace star { namespace form { class SVX_DLLPUBLIC FmFormView : public E3dView { - FmXFormView* pImpl; + rtl::Reference<FmXFormView> pImpl; FmFormShell* pFormShell; void Init(); @@ -130,7 +130,7 @@ public: SVX_DLLPRIVATE void ChangeDesignMode(bool bDesign); - SVX_DLLPRIVATE FmXFormView* GetImpl() const { return pImpl; } + SVX_DLLPRIVATE FmXFormView* GetImpl() const { return pImpl.get(); } SVX_DLLPRIVATE FmFormShell* GetFormShell() const { return pFormShell; } struct FormShellAccess { friend class FmFormShell; private: FormShellAccess() { } }; diff --git a/include/svx/graphctl.hxx b/include/svx/graphctl.hxx index cf44b1cf63ac..3416a351a0b8 100644 --- a/include/svx/graphctl.hxx +++ b/include/svx/graphctl.hxx @@ -55,7 +55,7 @@ class SVX_DLLPUBLIC GraphCtrl : public Control DECL_LINK_TYPED( UpdateHdl, Idle*, void ); - SvxGraphCtrlAccessibleContext* mpAccContext; + rtl::Reference<SvxGraphCtrlAccessibleContext> mpAccContext; protected: diff --git a/include/svx/gridctrl.hxx b/include/svx/gridctrl.hxx index d23b7d0c5578..2f3c409a546a 100644 --- a/include/svx/gridctrl.hxx +++ b/include/svx/gridctrl.hxx @@ -237,7 +237,7 @@ private: // if we modify the row for the new record, we automatically insert a "new new row". // But if somebody else inserts a new record into the data source, we have to do the same. // For that reason we have to listen to some properties of our data source. - ::comphelper::OPropertyChangeMultiplexer* m_pDataSourcePropMultiplexer; + rtl::Reference<::comphelper::OPropertyChangeMultiplexer> m_pDataSourcePropMultiplexer; FmXGridSourcePropListener* m_pDataSourcePropListener; css::uno::Reference< css::sdb::XRowsChangeListener> m_xRowSetListener; // get notification when rows were changed diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx index d90671311e76..65889f4569eb 100644 --- a/include/svx/svdmodel.hxx +++ b/include/svx/svdmodel.hxx @@ -220,7 +220,7 @@ private: public: sal_uInt16 nStarDrawPreviewMasterPageNum; - SvxForbiddenCharactersTable* mpForbiddenCharactersTable; + rtl::Reference<SvxForbiddenCharactersTable> mpForbiddenCharactersTable; SdrSwapGraphicsMode nSwapGraphicsMode; SdrOutlinerCache* mpOutlinerCache; @@ -567,7 +567,7 @@ public: void setLock( bool bLock ); void SetForbiddenCharsTable( const rtl::Reference<SvxForbiddenCharactersTable>& xForbiddenChars ); - rtl::Reference<SvxForbiddenCharactersTable> GetForbiddenCharsTable() const { return mpForbiddenCharactersTable;} + const rtl::Reference<SvxForbiddenCharactersTable>& GetForbiddenCharsTable() const { return mpForbiddenCharactersTable;} void SetCharCompressType( sal_uInt16 nType ); sal_uInt16 GetCharCompressType() const { return mnCharCompressType; } diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx index 5747e2bf3dde..e561f6d8e600 100644 --- a/include/svx/svdotable.hxx +++ b/include/svx/svdotable.hxx @@ -303,7 +303,7 @@ private: Rectangle maLogicRect; private: - SdrTableObjImpl* mpImpl; + rtl::Reference<SdrTableObjImpl> mpImpl; }; diff --git a/include/svx/unoshtxt.hxx b/include/svx/unoshtxt.hxx index 50d8cf8e80ed..f9163141b9f9 100644 --- a/include/svx/unoshtxt.hxx +++ b/include/svx/unoshtxt.hxx @@ -52,7 +52,8 @@ public: The window is necessary, since our views can display on multiple windows */ SvxTextEditSource( SdrObject& rObj, SdrText* pText, SdrView& rView, const vcl::Window& rViewWindow ); - + SvxTextEditSource(const SvxTextEditSource&) = delete; + SvxTextEditSource& operator=(const SvxTextEditSource&) = delete; virtual ~SvxTextEditSource(); virtual SvxEditSource* Clone() const override; @@ -83,7 +84,7 @@ public: private: SVX_DLLPRIVATE SvxTextEditSource( SvxTextEditSourceImpl* pImpl ); - SvxTextEditSourceImpl* mpImpl; + rtl::Reference<SvxTextEditSourceImpl> mpImpl; }; #endif diff --git a/include/xmloff/shapeimport.hxx b/include/xmloff/shapeimport.hxx index aa4a7b4765f6..db54f5cb1ebd 100644 --- a/include/xmloff/shapeimport.hxx +++ b/include/xmloff/shapeimport.hxx @@ -270,9 +270,9 @@ class XMLOFF_DLLPUBLIC XMLShapeImportHelper : public salhelper::SimpleReferenceO XMLShapeImportPageContextImpl* mpPageContext; // PropertySetMappers and factory - XMLSdPropHdlFactory* mpSdPropHdlFactory; - SvXMLImportPropertyMapper* mpPropertySetMapper; - SvXMLImportPropertyMapper* mpPresPagePropsMapper; + rtl::Reference<XMLSdPropHdlFactory> mpSdPropHdlFactory; + rtl::Reference<SvXMLImportPropertyMapper> mpPropertySetMapper; + rtl::Reference<SvXMLImportPropertyMapper> mpPresPagePropsMapper; // contexts for Style and AutoStyle import SvXMLStylesContext* mpStylesContext; @@ -341,8 +341,8 @@ public: void SetAutoStylesContext(SvXMLStylesContext* pNew); // get factories and mappers - SvXMLImportPropertyMapper* GetPropertySetMapper() const { return mpPropertySetMapper; } - SvXMLImportPropertyMapper* GetPresPagePropsMapper() const { return mpPresPagePropsMapper; } + SvXMLImportPropertyMapper* GetPropertySetMapper() const { return mpPropertySetMapper.get(); } + SvXMLImportPropertyMapper* GetPresPagePropsMapper() const { return mpPresPagePropsMapper.get(); } // this function is called whenever the implementation classes like to add this new // shape to the given XShapes. @@ -409,7 +409,7 @@ public: /** queries the capability of the current model to create presentation shapes */ bool IsPresentationShapesSupported(); - XMLSdPropHdlFactory* GetSdPropHdlFactory() const { return mpSdPropHdlFactory; } + XMLSdPropHdlFactory* GetSdPropHdlFactory() const { return mpSdPropHdlFactory.get(); } const rtl::Reference< XMLTableImport >& GetShapeTableImport(); }; diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx index 2261e4759d67..7827177518fc 100644 --- a/include/xmloff/xmlimp.hxx +++ b/include/xmloff/xmlimp.hxx @@ -151,7 +151,7 @@ class XMLOFF_DLLPUBLIC SvXMLImport : public ::cppu::WeakImplHelper7< ProgressBarHelper *mpProgressBarHelper; XMLEventImportHelper *mpEventImportHelper; XMLErrors *mpXMLErrors; - StyleMap *mpStyleMap; + rtl::Reference<StyleMap> mpStyleMap; OUString msPackageProtocol; SAL_DLLPRIVATE void InitCtor_(); diff --git a/svx/source/accessibility/AccessibleControlShape.cxx b/svx/source/accessibility/AccessibleControlShape.cxx index 6891b3707b68..a71dfe66b787 100644 --- a/svx/source/accessibility/AccessibleControlShape.cxx +++ b/svx/source/accessibility/AccessibleControlShape.cxx @@ -117,7 +117,6 @@ AccessibleControlShape::AccessibleControlShape ( , m_bWaitingForControl( false ) { m_pChildManager = new comphelper::OWrappedAccessibleChildrenManager( comphelper::getProcessComponentContext() ); - m_pChildManager->acquire(); osl_atomic_increment( &m_refCount ); { @@ -128,8 +127,7 @@ AccessibleControlShape::AccessibleControlShape ( AccessibleControlShape::~AccessibleControlShape() { - m_pChildManager->release(); - m_pChildManager = nullptr; + m_pChildManager.clear(); if ( m_xControlContextProxy.is() ) m_xControlContextProxy->setDelegator( nullptr ); diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index 786c4534ff34..9ac13bbf7e6d 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -70,7 +70,6 @@ Bitmap& SvxRectCtl::GetRectBitmap() SvxRectCtl::SvxRectCtl(vcl::Window* pParent, RECT_POINT eRpt, sal_uInt16 nBorder, sal_uInt16 nCircle) : Control(pParent, WB_BORDER | WB_TABSTOP) - , pAccContext(nullptr) , nBorderWidth(nBorder) , nRadius(nCircle) , eDefRP(eRpt) @@ -110,8 +109,7 @@ void SvxRectCtl::dispose() { delete pBitmap; - if( pAccContext ) - pAccContext->release(); + pAccContext.clear(); Control::dispose(); } @@ -567,7 +565,7 @@ void SvxRectCtl::GetFocus() // Send the accessible focused event Control::GetFocus(); // Send accessibility event. - if(pAccContext) + if(pAccContext.is()) { pAccContext->FireChildFocus(GetActualRP()); } @@ -652,7 +650,7 @@ void SvxRectCtl::SetActualRP( RECT_POINT eNewRP ) Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) ); // notify accessibility object about change - if( pAccContext ) + if( pAccContext.is() ) pAccContext->selectChild( eNewRP /* MT, bFireFocus */ ); } @@ -718,11 +716,10 @@ Reference< XAccessible > SvxRectCtl::CreateAccessible() if( xAccParent.is() ) { pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this ); - pAccContext->acquire(); SetActualRP( GetActualRP() ); - return pAccContext; + return pAccContext.get(); } else return Reference< XAccessible >(); diff --git a/svx/source/dialog/graphctl.cxx b/svx/source/dialog/graphctl.cxx index fac0708ce3fe..05a687f88a63 100644 --- a/svx/source/dialog/graphctl.cxx +++ b/svx/source/dialog/graphctl.cxx @@ -64,7 +64,6 @@ GraphCtrl::GraphCtrl( vcl::Window* pParent, WinBits nStyle ) : bEditMode ( false ), bSdrMode ( false ), bAnim ( false ), - mpAccContext ( nullptr ), pModel ( nullptr ), pView ( nullptr ) { @@ -93,10 +92,10 @@ void GraphCtrl::dispose() { aUpdateIdle.Stop(); - if( mpAccContext ) + if( mpAccContext.is() ) { mpAccContext->disposing(); - mpAccContext->release(); + mpAccContext.clear(); } delete pView; pView = nullptr; @@ -166,7 +165,7 @@ void GraphCtrl::InitSdrModel() pView->SetBufferedOverlayAllowed(true); // Tell the accessibility object about the changes. - if (mpAccContext != nullptr) + if (mpAccContext.is()) mpAccContext->setModelAndView (pModel, pView); } @@ -769,12 +768,11 @@ css::uno::Reference< css::accessibility::XAccessible > GraphCtrl::CreateAccessib xAccParent.is() ) { mpAccContext = new SvxGraphCtrlAccessibleContext( xAccParent, *this ); - mpAccContext->acquire(); } } } - return mpAccContext; + return mpAccContext.get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index b14cdd18e14a..d83fb06879e2 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -226,7 +226,6 @@ void DbGridColumn::CreateControl(sal_Int32 _nFieldPos, const Reference< css::bea m_pCell = new FmXEditCell( this, *pCellControl ); } } - m_pCell->acquire(); m_pCell->init(); impl_toggleScriptManager_nothrow( true ); @@ -262,9 +261,9 @@ void DbGridColumn::impl_toggleScriptManager_nothrow( bool _bAttach ) void DbGridColumn::UpdateFromField(const DbGridRow* pRow, const Reference< XNumberFormatter >& xFormatter) { - if (FmXFilterCell* pCell = dynamic_cast<FmXFilterCell*>(m_pCell)) + if (FmXFilterCell* pCell = dynamic_cast<FmXFilterCell*>(m_pCell.get())) pCell->Update(); - else if (pRow && pRow->IsValid() && m_nFieldPos >= 0 && m_pCell && pRow->HasField(m_nFieldPos)) + else if (pRow && pRow->IsValid() && m_nFieldPos >= 0 && m_pCell.is() && pRow->HasField(m_nFieldPos)) { dynamic_cast<FmXDataCell&>(*m_pCell).UpdateFromField( pRow->GetField( m_nFieldPos ).getColumn(), xFormatter ); } @@ -273,13 +272,13 @@ void DbGridColumn::UpdateFromField(const DbGridRow* pRow, const Reference< XNumb bool DbGridColumn::Commit() { bool bResult = true; - if (!m_bInSave && m_pCell) + if (!m_bInSave && m_pCell.is()) { m_bInSave = true; bResult = m_pCell->Commit(); // store the data into the model - FmXDataCell* pDataCell = dynamic_cast<FmXDataCell*>( m_pCell ); + FmXDataCell* pDataCell = dynamic_cast<FmXDataCell*>( m_pCell.get() ); if (bResult && pDataCell) { Reference< css::form::XBoundComponent > xComp(m_xModel, UNO_QUERY); @@ -300,25 +299,24 @@ DbGridColumn::~DbGridColumn() void DbGridColumn::setModel(const css::uno::Reference< css::beans::XPropertySet >& _xModel) { - if ( m_pCell ) + if ( m_pCell.is() ) impl_toggleScriptManager_nothrow( false ); m_xModel = _xModel; - if ( m_pCell ) + if ( m_pCell.is() ) impl_toggleScriptManager_nothrow( true ); } void DbGridColumn::Clear() { - if ( m_pCell ) + if ( m_pCell.is() ) { impl_toggleScriptManager_nothrow( false ); m_pCell->dispose(); - m_pCell->release(); - m_pCell = nullptr; + m_pCell.clear(); } m_xController = nullptr; @@ -370,7 +368,7 @@ sal_Int16 DbGridColumn::SetAlignment(sal_Int16 _nAlign) } m_nAlign = _nAlign; - if (m_pCell && m_pCell->isAlignedController()) + if (m_pCell.is() && m_pCell->isAlignedController()) m_pCell->AlignControl(m_nAlign); return m_nAlign; @@ -411,7 +409,7 @@ void DbGridColumn::setLock(bool _bLock) OUString DbGridColumn::GetCellText(const DbGridRow* pRow, const Reference< XNumberFormatter >& xFormatter) const { OUString aText; - if (m_pCell && dynamic_cast<const FmXFilterCell*>( m_pCell) != nullptr) + if (m_pCell.is() && dynamic_cast<const FmXFilterCell*>( m_pCell.get() ) != nullptr) return aText; if (!pRow || !pRow->IsValid()) @@ -429,7 +427,7 @@ OUString DbGridColumn::GetCellText(const Reference< css::sdb::XColumn >& xField, OUString aText; if (xField.is()) { - FmXTextCell* pTextCell = dynamic_cast<FmXTextCell*>( m_pCell ); + FmXTextCell* pTextCell = dynamic_cast<FmXTextCell*>( m_pCell.get() ); if (pTextCell) aText = pTextCell->GetText(xField, xFormatter); else if (m_bObject) @@ -459,7 +457,7 @@ void DbGridColumn::Paint(OutputDevice& rDev, bool bEnabled = ( rDev.GetOutDevType() != OUTDEV_WINDOW ) || ( static_cast< vcl::Window& >( rDev ).IsEnabled() ); - FmXDataCell* pDataCell = dynamic_cast<FmXDataCell*>( m_pCell ); + FmXDataCell* pDataCell = dynamic_cast<FmXDataCell*>( m_pCell.get() ); if (pDataCell) { if (!pRow || !pRow->IsValid()) @@ -495,7 +493,7 @@ void DbGridColumn::Paint(OutputDevice& rDev, pDataCell->PaintFieldToCell(rDev, rRect, pRow->GetField( m_nFieldPos ).getColumn(), xFormatter); } } - else if (!m_pCell) + else if (!m_pCell.is()) { if (!pRow || !pRow->IsValid()) { @@ -513,14 +511,14 @@ void DbGridColumn::Paint(OutputDevice& rDev, rDev.DrawText(rRect, OUString(OBJECTTEXT), nStyle); } } - else if ( dynamic_cast<const FmXFilterCell*>( m_pCell) != nullptr ) - static_cast< FmXFilterCell* >( m_pCell )->PaintCell( rDev, rRect ); + else if ( dynamic_cast<const FmXFilterCell*>( m_pCell.get() ) != nullptr ) + static_cast< FmXFilterCell* >( m_pCell.get() )->PaintCell( rDev, rRect ); } void DbGridColumn::ImplInitWindow( vcl::Window& rParent, const InitWindowFacet _eInitWhat ) { - if ( m_pCell ) + if ( m_pCell.is() ) m_pCell->ImplInitWindow( rParent, _eInitWhat ); } @@ -530,8 +528,6 @@ void DbGridColumn::ImplInitWindow( vcl::Window& rParent, const InitWindowFacet _ DbCellControl::DbCellControl( DbGridColumn& _rColumn ) :OPropertyChangeListener(m_aMutex) - ,m_pModelChangeBroadcaster(nullptr) - ,m_pFieldChangeBroadcaster(nullptr) ,m_bTransparent( false ) ,m_bAlignedController( true ) ,m_bAccessingValueProperty( false ) @@ -544,7 +540,6 @@ DbCellControl::DbCellControl( DbGridColumn& _rColumn ) { // if our model's format key changes we want to propagate the new value to our windows m_pModelChangeBroadcaster = new ::comphelper::OPropertyChangeMultiplexer(this, Reference< css::beans::XPropertySet > (_rColumn.getModel(), UNO_QUERY)); - m_pModelChangeBroadcaster->acquire(); // be listener for some common properties implDoPropertyListening( FM_PROP_READONLY, false ); @@ -570,7 +565,6 @@ DbCellControl::DbCellControl( DbGridColumn& _rColumn ) if ( xField.is() ) { m_pFieldChangeBroadcaster = new ::comphelper::OPropertyChangeMultiplexer(this, xField); - m_pFieldChangeBroadcaster->acquire(); m_pFieldChangeBroadcaster->addProperty( FM_PROP_ISREADONLY ); } } @@ -613,13 +607,12 @@ void DbCellControl::doPropertyListening(const OUString& _rPropertyName) implDoPropertyListening( _rPropertyName ); } -static void lcl_clearBroadCaster(::comphelper::OPropertyChangeMultiplexer*& _pBroadcaster) +static void lcl_clearBroadCaster(rtl::Reference<::comphelper::OPropertyChangeMultiplexer>& _pBroadcaster) { - if ( _pBroadcaster ) + if ( _pBroadcaster.is() ) { _pBroadcaster->dispose(); - _pBroadcaster->release(); - _pBroadcaster = nullptr; + _pBroadcaster.clear(); // no delete, this is done implicitly } } diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index c6d48778b1b0..a6043a6a91c6 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -129,7 +129,7 @@ class GridFieldValueListener : protected ::comphelper::OPropertyChangeListener { osl::Mutex m_aMutex; DbGridControl& m_rParent; - ::comphelper::OPropertyChangeMultiplexer* m_pRealListener; + rtl::Reference<::comphelper::OPropertyChangeMultiplexer> m_pRealListener; sal_uInt16 m_nId; sal_Int16 m_nSuspended; bool m_bDisposed : 1; @@ -149,7 +149,6 @@ public: GridFieldValueListener::GridFieldValueListener(DbGridControl& _rParent, const Reference< XPropertySet >& _rField, sal_uInt16 _nId) :OPropertyChangeListener(m_aMutex) ,m_rParent(_rParent) - ,m_pRealListener(nullptr) ,m_nId(_nId) ,m_nSuspended(0) ,m_bDisposed(false) @@ -158,7 +157,6 @@ GridFieldValueListener::GridFieldValueListener(DbGridControl& _rParent, const Re { m_pRealListener = new ::comphelper::OPropertyChangeMultiplexer(this, _rField); m_pRealListener->addProperty(FM_PROP_VALUE); - m_pRealListener->acquire(); } } @@ -178,15 +176,14 @@ void GridFieldValueListener::dispose() { if (m_bDisposed) { - DBG_ASSERT(m_pRealListener == nullptr, "GridFieldValueListener::dispose : inconsistent !"); + DBG_ASSERT(m_pRealListener.get() == nullptr, "GridFieldValueListener::dispose : inconsistent !"); return; } - if (m_pRealListener) + if (m_pRealListener.is()) { m_pRealListener->dispose(); - m_pRealListener->release(); - m_pRealListener = nullptr; + m_pRealListener.clear(); } m_bDisposed = true; @@ -947,7 +944,6 @@ DbGridControl::DbGridControl( ,m_xContext(_rxContext) ,m_aBar(VclPtr<DbGridControl::NavigationBar>::Create(this)) ,m_nAsynAdjustEvent(nullptr) - ,m_pDataSourcePropMultiplexer(nullptr) ,m_pDataSourcePropListener(nullptr) ,m_pFieldListeners(nullptr) ,m_pCursorDisposeListener(nullptr) @@ -1031,12 +1027,11 @@ void DbGridControl::dispose() if (m_nDeleteEvent) Application::RemoveUserEvent(m_nDeleteEvent); - if (m_pDataSourcePropMultiplexer) + if (m_pDataSourcePropMultiplexer.is()) { m_pDataSourcePropMultiplexer->dispose(); - m_pDataSourcePropMultiplexer->release(); // this should delete the multiplexer + m_pDataSourcePropMultiplexer.clear(); // this should delete the multiplexer delete m_pDataSourcePropListener; - m_pDataSourcePropMultiplexer = nullptr; m_pDataSourcePropListener = nullptr; } m_xRowSetListener.clear(); @@ -1426,12 +1421,11 @@ void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, sal_uInt if (!_xCursor.is() && !m_pDataCursor) return; - if (m_pDataSourcePropMultiplexer) + if (m_pDataSourcePropMultiplexer.is()) { m_pDataSourcePropMultiplexer->dispose(); - m_pDataSourcePropMultiplexer->release(); // this should delete the multiplexer + m_pDataSourcePropMultiplexer.clear(); // this should delete the multiplexer delete m_pDataSourcePropListener; - m_pDataSourcePropMultiplexer = nullptr; m_pDataSourcePropListener = nullptr; } m_xRowSetListener.clear(); @@ -1508,7 +1502,6 @@ void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, sal_uInt { m_pDataSourcePropListener = new FmXGridSourcePropListener(this); m_pDataSourcePropMultiplexer = new ::comphelper::OPropertyChangeMultiplexer(m_pDataSourcePropListener, m_pDataCursor->getPropertySet() ); - m_pDataSourcePropMultiplexer->acquire(); m_pDataSourcePropMultiplexer->addProperty(FM_PROP_ISMODIFIED); m_pDataSourcePropMultiplexer->addProperty(FM_PROP_ISNEW); } diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index d6f9d201f665..7c1f1ee9924d 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -490,7 +490,6 @@ void SAL_CALL FmFilterAdapter::disjunctiveTermAdded( const FilterEvent& Event ) FmFilterModel::FmFilterModel() :FmParentData(nullptr, OUString()) ,OSQLParserClient(comphelper::getProcessComponentContext()) - ,m_pAdapter(nullptr) ,m_pCurrentItems(nullptr) { } @@ -509,11 +508,10 @@ void FmFilterModel::Clear() Broadcast( aClearedHint ); // lose endings - if (m_pAdapter) + if (m_pAdapter.is()) { m_pAdapter->dispose(); - m_pAdapter->release(); - m_pAdapter= nullptr; + m_pAdapter.clear(); } m_pCurrentItems = nullptr; @@ -551,7 +549,6 @@ void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, const // Listening for TextChanges m_pAdapter = new FmFilterAdapter(this, xControllers); - m_pAdapter->acquire(); SetCurrentController(xCurrent); EnsureEmptyFilterRows( *this ); diff --git a/svx/source/form/fmshell.cxx b/svx/source/form/fmshell.cxx index 7eb32e2fd976..e710f0f931a0 100644 --- a/svx/source/form/fmshell.cxx +++ b/svx/source/form/fmshell.cxx @@ -211,7 +211,6 @@ FmFormShell::FmFormShell( SfxViewShell* _pParent, FmFormView* pView ) ,m_bDesignMode( true ) ,m_bHasForms(false) { - m_pImpl->acquire(); SetPool( &SfxGetpApp()->GetPool() ); SetName( "Form" ); @@ -225,8 +224,6 @@ FmFormShell::~FmFormShell() SetView( nullptr ); m_pImpl->dispose(); - m_pImpl->release(); - m_pImpl = nullptr; } diff --git a/svx/source/form/fmsrcimp.cxx b/svx/source/form/fmsrcimp.cxx index 2e6ab8ed47a1..914872bf484a 100644 --- a/svx/source/form/fmsrcimp.cxx +++ b/svx/source/form/fmsrcimp.cxx @@ -217,14 +217,12 @@ bool FmSearchEngine::MoveCursor() else if (m_xSearchCursor.isFirst()) { - FmRecordCountListener* prclListener = new FmRecordCountListener(m_xSearchCursor); - prclListener->acquire(); + rtl::Reference<FmRecordCountListener> prclListener = new FmRecordCountListener(m_xSearchCursor); prclListener->SetPropChangeHandler(LINK(this, FmSearchEngine, OnNewRecordCount)); m_xSearchCursor.last(); prclListener->DisConnect(); - prclListener->release(); } else m_xSearchCursor.previous(); diff --git a/svx/source/form/fmtools.cxx b/svx/source/form/fmtools.cxx index bfd316e5a94e..4eb8d38fc2c7 100644 --- a/svx/source/form/fmtools.cxx +++ b/svx/source/form/fmtools.cxx @@ -283,19 +283,8 @@ FmXDisposeListener::~FmXDisposeListener() void FmXDisposeListener::setAdapter(FmXDisposeMultiplexer* pAdapter) { - if (m_pAdapter) - { - ::osl::MutexGuard aGuard(m_rMutex); - m_pAdapter->release(); - m_pAdapter = nullptr; - } - - if (pAdapter) - { - ::osl::MutexGuard aGuard(m_rMutex); - m_pAdapter = pAdapter; - m_pAdapter->acquire(); - } + ::osl::MutexGuard aGuard(m_rMutex); + m_pAdapter = pAdapter; } diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx index 7762f8bed226..f40e773cda69 100644 --- a/svx/source/form/fmview.cxx +++ b/svx/source/form/fmview.cxx @@ -90,8 +90,6 @@ void FmFormView::Init() { pFormShell = nullptr; pImpl = new FmXFormView(this); - pImpl->acquire(); - // Model setzen SdrModel* pModel = GetModel(); @@ -138,8 +136,6 @@ FmFormView::~FmFormView() pFormShell->SetView( nullptr ); pImpl->notifyViewDying(); - pImpl->release(); - pImpl = nullptr; } @@ -163,7 +159,7 @@ void FmFormView::MarkListHasChanged() pImpl->m_pMarkedGrid = nullptr; if ( pImpl->m_xWindow.is() ) { - pImpl->m_xWindow->removeFocusListener(pImpl); + pImpl->m_xWindow->removeFocusListener(pImpl.get()); pImpl->m_xWindow = nullptr; } SetMoveOutside(false); @@ -500,7 +496,7 @@ bool FmFormView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) pImpl->m_pMarkedGrid = pObj; pImpl->m_xWindow = xWindow; // add as listener to get notified when ESC will be pressed inside the grid - pImpl->m_xWindow->addFocusListener(pImpl); + pImpl->m_xWindow->addFocusListener(pImpl.get()); SetMoveOutside(true); //OLMRefreshAllIAOManagers(); xWindow->setFocus(); diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx index 20602fdcd128..1ace5b93fe11 100644 --- a/svx/source/form/formcontroller.cxx +++ b/svx/source/form/formcontroller.cxx @@ -4165,21 +4165,17 @@ Reference< XDispatchProviderInterceptor > FormController::createInterceptor(con OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); #ifdef DBG_UTIL // check if we already have a interceptor for the given object - for ( Interceptors::const_iterator aIter = m_aControlDispatchInterceptors.begin(); - aIter != m_aControlDispatchInterceptors.end(); - ++aIter - ) + for ( const auto & it : m_aControlDispatchInterceptors ) { - if ((*aIter)->getIntercepted() == _xInterception) + if (it->getIntercepted() == _xInterception) OSL_FAIL("FormController::createInterceptor : we already do intercept this objects dispatches !"); } #endif - DispatchInterceptionMultiplexer* pInterceptor = new DispatchInterceptionMultiplexer( _xInterception, this ); - pInterceptor->acquire(); - m_aControlDispatchInterceptors.insert( m_aControlDispatchInterceptors.end(), pInterceptor ); + rtl::Reference<DispatchInterceptionMultiplexer> pInterceptor(new DispatchInterceptionMultiplexer( _xInterception, this )); + m_aControlDispatchInterceptors.push_back( pInterceptor ); - return pInterceptor; + return pInterceptor.get(); } @@ -4208,28 +4204,20 @@ void FormController::deleteInterceptor(const Reference< XDispatchProviderInterce { OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); // search the interceptor responsible for the given object - Interceptors::const_iterator aEnd = m_aControlDispatchInterceptors.end(); - Interceptors::iterator aIter; - for ( aIter = m_aControlDispatchInterceptors.begin(); + const auto aEnd = m_aControlDispatchInterceptors.end(); + for ( auto aIter = m_aControlDispatchInterceptors.begin(); aIter != aEnd; ++aIter ) { - if ((*aIter)->getIntercepted() == _xInterception) - break; - } - if (aIter == aEnd) - { - return; + if ((*aIter)->getIntercepted() == _xInterception) { + // log off the interception from its interception object + (*aIter)->dispose(); + // remove the interceptor from our array + m_aControlDispatchInterceptors.erase(aIter); + return; + } } - - // log off the interception from its interception object - DispatchInterceptionMultiplexer* pInterceptorImpl = *aIter; - pInterceptorImpl->dispose(); - pInterceptorImpl->release(); - - // remove the interceptor from our array - m_aControlDispatchInterceptors.erase(aIter); } diff --git a/svx/source/form/formcontrolling.cxx b/svx/source/form/formcontrolling.cxx index 8255ccc5dfd3..06172a19821e 100644 --- a/svx/source/form/formcontrolling.cxx +++ b/svx/source/form/formcontrolling.cxx @@ -190,14 +190,12 @@ namespace svx ControllerFeatures::ControllerFeatures( IControllerFeatureInvalidation* _pInvalidationCallback ) :m_pInvalidationCallback( _pInvalidationCallback ) - ,m_pImpl( nullptr ) { } ControllerFeatures::ControllerFeatures( const Reference< XFormController >& _rxController, IControllerFeatureInvalidation* _pInvalidationCallback ) :m_pInvalidationCallback( _pInvalidationCallback ) - ,m_pImpl( nullptr ) { assign( _rxController ); } @@ -207,7 +205,6 @@ namespace svx { dispose(); m_pImpl = new FormControllerHelper( _rxController, m_pInvalidationCallback ); - m_pImpl->acquire(); } @@ -219,11 +216,10 @@ namespace svx void ControllerFeatures::dispose() { - if ( m_pImpl ) + if ( m_pImpl.is() ) { m_pImpl->dispose(); - m_pImpl->release(); - m_pImpl = nullptr; + m_pImpl.clear(); } } diff --git a/svx/source/form/navigatortreemodel.cxx b/svx/source/form/navigatortreemodel.cxx index ada3cf9a33f8..fbfbeb6bd8f4 100644 --- a/svx/source/form/navigatortreemodel.cxx +++ b/svx/source/form/navigatortreemodel.cxx @@ -193,7 +193,6 @@ namespace svxform ,m_aNormalImages( _rNormalImages ) { m_pPropChangeList = new OFormComponentObserver(this); - m_pPropChangeList->acquire(); m_pRootList = new FmEntryDataList(); } @@ -215,7 +214,6 @@ namespace svxform Clear(); delete m_pRootList; m_pPropChangeList->ReleaseModel(); - m_pPropChangeList->release(); } @@ -232,7 +230,7 @@ namespace svxform { Reference< css::form::XForms > xForms( GetForms()); if(xForms.is()) - xForms->removeContainerListener(static_cast<XContainerListener*>(m_pPropChangeList)); + xForms->removeContainerListener(m_pPropChangeList.get()); // delete RootList @@ -325,7 +323,7 @@ namespace svxform // register as PropertyChangeListener Reference< XPropertySet > xSet(xElement, UNO_QUERY); if( xSet.is() ) - xSet->addPropertyChangeListener( FM_PROP_NAME, m_pPropChangeList ); + xSet->addPropertyChangeListener( FM_PROP_NAME, m_pPropChangeList.get() ); // Remove data from model @@ -333,7 +331,7 @@ namespace svxform { Reference< XContainer > xContainer(xElement, UNO_QUERY); if (xContainer.is()) - xContainer->addContainerListener(static_cast<XContainerListener*>(m_pPropChangeList)); + xContainer->addContainerListener(m_pPropChangeList.get()); } if (pFolder) @@ -466,11 +464,11 @@ namespace svxform // unregister as PropertyChangeListener Reference< XPropertySet > xSet( pFormData->GetPropertySet() ); if ( xSet.is() ) - xSet->removePropertyChangeListener( FM_PROP_NAME, m_pPropChangeList ); + xSet->removePropertyChangeListener( FM_PROP_NAME, m_pPropChangeList.get() ); Reference< XContainer > xContainer( pFormData->GetContainer() ); if (xContainer.is()) - xContainer->removeContainerListener(static_cast<XContainerListener*>(m_pPropChangeList)); + xContainer->removeContainerListener(m_pPropChangeList.get()); } @@ -485,7 +483,7 @@ namespace svxform // unregister as PropertyChangeListener Reference< XPropertySet > xSet( pControlData->GetPropertySet() ); if (xSet.is()) - xSet->removePropertyChangeListener( FM_PROP_NAME, m_pPropChangeList); + xSet->removePropertyChangeListener( FM_PROP_NAME, m_pPropChangeList.get()); } @@ -835,7 +833,7 @@ namespace svxform Clear(); if (xForms.is()) { - xForms->addContainerListener(static_cast<XContainerListener*>(m_pPropChangeList)); + xForms->addContainerListener(m_pPropChangeList.get()); FillBranch(nullptr); diff --git a/svx/source/form/tabwin.cxx b/svx/source/form/tabwin.cxx index c9adc54a864c..e9b06b34a04c 100644 --- a/svx/source/form/tabwin.cxx +++ b/svx/source/form/tabwin.cxx @@ -172,7 +172,6 @@ FmFieldWin::FmFieldWin(SfxBindings* _pBindings, SfxChildWindow* _pMgr, vcl::Wind ,SfxControllerItem(SID_FM_FIELDS_CONTROL, *_pBindings) ,::comphelper::OPropertyChangeListener(m_aMutex) ,m_nObjectType(0) - ,m_pChangeListener(nullptr) { SetHelpId( HID_FIELD_SEL_WIN ); @@ -191,11 +190,10 @@ FmFieldWin::~FmFieldWin() void FmFieldWin::dispose() { - if (m_pChangeListener) + if (m_pChangeListener.is()) { m_pChangeListener->dispose(); - m_pChangeListener->release(); - // delete m_pChangeListener; + m_pChangeListener.clear(); } pListBox.disposeAndClear(); ::SfxControllerItem::dispose(); @@ -358,13 +356,12 @@ void FmFieldWin::UpdateContent(const css::uno::Reference< css::form::XForm > & x } // listen for changes at ControlSource in PropertySet - if (m_pChangeListener) + if (m_pChangeListener.is()) { m_pChangeListener->dispose(); - m_pChangeListener->release(); + m_pChangeListener.clear(); } m_pChangeListener = new ::comphelper::OPropertyChangeMultiplexer(this, xSet); - m_pChangeListener->acquire(); m_pChangeListener->addProperty(FM_PROP_DATASOURCE); m_pChangeListener->addProperty(FM_PROP_COMMAND); m_pChangeListener->addProperty(FM_PROP_COMMANDTYPE); diff --git a/svx/source/inc/filtnav.hxx b/svx/source/inc/filtnav.hxx index 66906efc0663..afc6f0b760d1 100644 --- a/svx/source/inc/filtnav.hxx +++ b/svx/source/inc/filtnav.hxx @@ -156,7 +156,7 @@ class FmFilterModel : public FmParentData css::uno::Reference< css::container::XIndexAccess > m_xControllers; css::uno::Reference< css::form::runtime::XFormController > m_xController; - FmFilterAdapter* m_pAdapter; + rtl::Reference<FmFilterAdapter> m_pAdapter; FmFilterItems* m_pCurrentItems; public: diff --git a/svx/source/inc/fmexpl.hxx b/svx/source/inc/fmexpl.hxx index 1059b262b8b5..5b5486af54fe 100644 --- a/svx/source/inc/fmexpl.hxx +++ b/svx/source/inc/fmexpl.hxx @@ -334,7 +334,7 @@ namespace svxform FmFormShell* m_pFormShell; FmFormPage* m_pFormPage; FmFormModel* m_pFormModel; - OFormComponentObserver* m_pPropChangeList; + rtl::Reference<OFormComponentObserver> m_pPropChangeList; ImageList m_aNormalImages; diff --git a/svx/source/inc/formcontroller.hxx b/svx/source/inc/formcontroller.hxx index 1e1e611a474d..64802ad16f7f 100644 --- a/svx/source/inc/formcontroller.hxx +++ b/svx/source/inc/formcontroller.hxx @@ -75,6 +75,7 @@ #include <comphelper/proparrhlp.hxx> #include <cppuhelper/propshlp.hxx> #include <comphelper/interfacecontainer2.hxx> +#include <rtl/ref.hxx> #include <vcl/timer.hxx> #include <vcl/idle.hxx> @@ -203,8 +204,7 @@ namespace svxform // as we want to intercept dispatches of _all_ controls we're responsible for, and an object implementing // the css::frame::XDispatchProviderInterceptor interface can intercept only _one_ objects dispatches, we need a helper class - typedef std::vector<DispatchInterceptionMultiplexer*> Interceptors; - Interceptors m_aControlDispatchInterceptors; + std::vector<rtl::Reference<DispatchInterceptionMultiplexer>> m_aControlDispatchInterceptors; public: FormController( const css::uno::Reference< css::uno::XComponentContext > & _rxORB ); diff --git a/svx/source/inc/formcontrolling.hxx b/svx/source/inc/formcontrolling.hxx index a24aab1acfb2..8b0a824dc9c7 100644 --- a/svx/source/inc/formcontrolling.hxx +++ b/svx/source/inc/formcontrolling.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/sdb/XSQLErrorListener.hpp> #include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> #include <vector> @@ -72,7 +73,7 @@ namespace svx { protected: IControllerFeatureInvalidation* m_pInvalidationCallback; // necessary as long as m_pImpl is not yet constructed - FormControllerHelper* m_pImpl; + rtl::Reference<FormControllerHelper> m_pImpl; public: /** standard ctor @@ -116,8 +117,8 @@ namespace svx void dispose(); // access to the instance which implements the functionality. Not to be used when not assigned - inline const FormControllerHelper* operator->() const { return m_pImpl; } - inline FormControllerHelper* operator->() { return m_pImpl; } + inline const FormControllerHelper* operator->() const { return m_pImpl.get(); } + inline FormControllerHelper* operator->() { return m_pImpl.get(); } }; diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx index a9c0ae74af9f..26b632a5eeee 100644 --- a/svx/source/inc/gridcell.hxx +++ b/svx/source/inc/gridcell.hxx @@ -71,7 +71,7 @@ class DbGridColumn ::svt::CellControllerRef m_xController; // Struktur zum Verwalten der Controls fuer eine Spalte // diese wird von der DbBrowseBox auf die jeweiligen Zellen // einer Spalte positioniert - FmXGridCell* m_pCell; + rtl::Reference<FmXGridCell> m_pCell; protected: DbGridControl& m_rParent; @@ -134,7 +134,7 @@ public: const ::svt::CellControllerRef& GetController() const {return m_bLocked ? s_xEmptyController : m_xController;} const css::uno::Reference< css::beans::XPropertySet >& GetField() const {return m_xField;} DbGridControl& GetParent() const {return m_rParent;} - FmXGridCell* GetCell() const {return m_pCell;} + FmXGridCell* GetCell() const {return m_pCell.get();} css::uno::Reference< css::sdb::XColumn > GetCurrentFieldValue() const; @@ -200,8 +200,8 @@ class DbCellControl ,public ::comphelper::OPropertyChangeListener { private: - ::comphelper::OPropertyChangeMultiplexer* m_pModelChangeBroadcaster; - ::comphelper::OPropertyChangeMultiplexer* m_pFieldChangeBroadcaster; + rtl::Reference<::comphelper::OPropertyChangeMultiplexer> m_pModelChangeBroadcaster; + rtl::Reference<::comphelper::OPropertyChangeMultiplexer> m_pFieldChangeBroadcaster; private: bool m_bTransparent : 1; diff --git a/svx/source/inc/tabwin.hxx b/svx/source/inc/tabwin.hxx index e042fc746040..2774ccbc035b 100644 --- a/svx/source/inc/tabwin.hxx +++ b/svx/source/inc/tabwin.hxx @@ -74,7 +74,7 @@ class FmFieldWin :public SfxFloatingWindow m_aObjectName; sal_Int32 m_nObjectType; - ::comphelper::OPropertyChangeMultiplexer* m_pChangeListener; + rtl::Reference<::comphelper::OPropertyChangeMultiplexer> m_pChangeListener; public: FmFieldWin(SfxBindings *pBindings, diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index 8f0beef843f9..b654568ec920 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -311,8 +311,7 @@ SdrModel::~SdrModel() SfxItemPool::Free(pOutlPool); } - if( mpForbiddenCharactersTable ) - mpForbiddenCharactersTable->release(); + mpForbiddenCharactersTable.clear(); delete mpNumberFormatter; @@ -1905,13 +1904,7 @@ void SdrModel::MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSe void SdrModel::SetForbiddenCharsTable( const rtl::Reference<SvxForbiddenCharactersTable>& xForbiddenChars ) { - if( mpForbiddenCharactersTable ) - mpForbiddenCharactersTable->release(); - - mpForbiddenCharactersTable = xForbiddenChars.get(); - - if( mpForbiddenCharactersTable ) - mpForbiddenCharactersTable->acquire(); + mpForbiddenCharactersTable = xForbiddenChars; ImpSetOutlinerDefaults( pDrawOutliner ); ImpSetOutlinerDefaults( pHitTestOutliner ); diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 2ea9c8abe954..8c707110e513 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -758,7 +758,6 @@ void SdrTableObj::init( sal_Int32 nColumns, sal_Int32 nRows ) bClosedObj = true; mpImpl = new SdrTableObjImpl; - mpImpl->acquire(); mpImpl->init( this, nColumns, nRows ); } @@ -766,7 +765,6 @@ void SdrTableObj::init( sal_Int32 nColumns, sal_Int32 nRows ) SdrTableObj::~SdrTableObj() { mpImpl->dispose(); - mpImpl->release(); } @@ -864,7 +862,7 @@ CellPos SdrTableObj::getDownCell( const CellPos& rPos, bool bEdgeTravel ) const CellPos SdrTableObj::getPreviousCell( const CellPos& rPos, bool bEdgeTravel ) const { CellPos aPos( rPos ); - if( mpImpl ) + if( mpImpl.is() ) { CellRef xCell( mpImpl->getCell( aPos ) ); if( xCell.is() && xCell->isMerged() ) @@ -891,7 +889,7 @@ CellPos SdrTableObj::getPreviousCell( const CellPos& rPos, bool bEdgeTravel ) co CellPos SdrTableObj::getNextCell( const CellPos& rPos, bool bEdgeTravel ) const { CellPos aPos( rPos ); - if( mpImpl ) + if( mpImpl.is() ) { CellRef xCell( mpImpl->getCell( aPos ) ); if( xCell.is() ) @@ -933,7 +931,7 @@ CellPos SdrTableObj::getNextCell( const CellPos& rPos, bool bEdgeTravel ) const CellPos SdrTableObj::getPreviousRow( const CellPos& rPos, bool bEdgeTravel ) const { CellPos aPos( rPos ); - if( mpImpl ) + if( mpImpl.is() ) { CellRef xCell( mpImpl->getCell( aPos ) ); if( xCell.is() ) @@ -963,7 +961,7 @@ CellPos SdrTableObj::getNextRow( const CellPos& rPos, bool bEdgeTravel ) const { CellPos aPos( rPos ); - if( mpImpl ) + if( mpImpl.is() ) { CellRef xCell( mpImpl->getCell( rPos ) ); if( xCell.is() ) @@ -1004,7 +1002,7 @@ CellPos SdrTableObj::getNextRow( const CellPos& rPos, bool bEdgeTravel ) const const TableStyleSettings& SdrTableObj::getTableStyleSettings() const { - if( mpImpl ) + if( mpImpl.is()) { return mpImpl->maTableStyle; } @@ -1018,7 +1016,7 @@ const TableStyleSettings& SdrTableObj::getTableStyleSettings() const void SdrTableObj::setTableStyleSettings( const TableStyleSettings& rStyle ) { - if( mpImpl ) + if( mpImpl.is() ) { mpImpl->maTableStyle = rStyle; mpImpl->update(); @@ -1028,7 +1026,7 @@ void SdrTableObj::setTableStyleSettings( const TableStyleSettings& rStyle ) TableHitKind SdrTableObj::CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_Int32& rnY ) const { - if( !mpImpl || !mpImpl->mxTable.is() ) + if( !mpImpl.is() || !mpImpl->mxTable.is() ) return SDRTABLEHIT_NONE; rnX = 0; @@ -1155,7 +1153,7 @@ const SfxItemSet& SdrTableObj::GetActiveCellItemSet() const void SdrTableObj::setTableStyle( const Reference< XIndexAccess >& xTableStyle ) { - if( mpImpl && (mpImpl->mxTableStyle != xTableStyle) ) + if( mpImpl.is() && (mpImpl->mxTableStyle != xTableStyle) ) { mpImpl->disconnectTableStyle(); mpImpl->mxTableStyle = xTableStyle; @@ -1167,7 +1165,7 @@ void SdrTableObj::setTableStyle( const Reference< XIndexAccess >& xTableStyle ) const Reference< XIndexAccess >& SdrTableObj::getTableStyle() const { - if( mpImpl ) + if( mpImpl.is() ) { return mpImpl->mxTableStyle; } @@ -1227,7 +1225,7 @@ sal_Int32 SdrTableObj::getTextCount() const /** changes the current active text */ void SdrTableObj::setActiveText( sal_Int32 nIndex ) { - if( mpImpl && mpImpl->mxTable.is() ) + if( mpImpl.is() && mpImpl->mxTable.is() ) { const sal_Int32 nColCount = mpImpl->mxTable->getColumnCount(); if( nColCount ) @@ -1243,7 +1241,7 @@ void SdrTableObj::setActiveText( sal_Int32 nIndex ) /** returns the index of the text that contains the given point or -1 */ sal_Int32 SdrTableObj::CheckTextHit(const Point& rPnt) const { - if( mpImpl && mpImpl->mxTable.is() ) + if( mpImpl.is() && mpImpl->mxTable.is() ) { CellPos aPos; if( CheckTableHit( rPnt, aPos.mnCol, aPos.mnRow ) == SDRTABLEHIT_CELLTEXTAREA ) @@ -1255,7 +1253,7 @@ sal_Int32 SdrTableObj::CheckTextHit(const Point& rPnt) const SdrOutliner* SdrTableObj::GetCellTextEditOutliner( const Cell& rCell ) const { - if( mpImpl && (mpImpl->getCell( mpImpl->maEditPos ).get() == &rCell) ) + if( mpImpl.is() && (mpImpl->getCell( mpImpl->maEditPos ).get() == &rCell) ) return pEdtOutl; else return nullptr; @@ -1263,7 +1261,7 @@ SdrOutliner* SdrTableObj::GetCellTextEditOutliner( const Cell& rCell ) const const TableLayouter& SdrTableObj::getTableLayouter() const { - assert(mpImpl && mpImpl->mpLayouter && "getTableLayouter() error: no mpImpl or mpLayouter (!)"); + assert(mpImpl.is() && mpImpl->mpLayouter && "getTableLayouter() error: no mpImpl or mpLayouter (!)"); return *(mpImpl->mpLayouter); } @@ -1284,13 +1282,13 @@ bool SdrTableObj::HasText() const bool SdrTableObj::IsTextEditActive( const CellPos& rPos ) { - return pEdtOutl && mpImpl && (rPos == mpImpl->maEditPos); + return pEdtOutl && mpImpl.is() && (rPos == mpImpl->maEditPos); } void SdrTableObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus ) { - if( (pEditStatus->GetStatusWord() & EditStatusFlags::TEXTHEIGHTCHANGED) && mpImpl && mpImpl->mpLayouter ) + if( (pEditStatus->GetStatusWord() & EditStatusFlags::TEXTHEIGHTCHANGED) && mpImpl.is() && mpImpl->mpLayouter ) { Rectangle aRect0( maRect ); maRect = maLogicRect; @@ -1349,7 +1347,7 @@ void SdrTableObj::SetModel(SdrModel* pNewModel) { SdrTextObj::SetModel(pNewModel); - if( mpImpl ) + if( mpImpl.is() ) { mpImpl->SetModel( pOldModel, pNewModel ); @@ -1365,14 +1363,14 @@ void SdrTableObj::SetModel(SdrModel* pNewModel) void SdrTableObj::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText, Rectangle* pAnchorRect, bool bLineWidth ) const { - if( mpImpl ) + if( mpImpl.is() ) TakeTextRect( mpImpl->maEditPos, rOutliner, rTextRect, bNoEditText, pAnchorRect, bLineWidth ); } void SdrTableObj::TakeTextRect( const CellPos& rPos, SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText, Rectangle* pAnchorRect, bool /*bLineWidth*/ ) const { - if( !mpImpl ) + if( !mpImpl.is()) return; CellRef xCell( mpImpl->getCell( rPos ) ); @@ -1454,7 +1452,7 @@ void SdrTableObj::TakeTextRect( const CellPos& rPos, SdrOutliner& rOutliner, Rec const CellRef& SdrTableObj::getActiveCell() const { - if( mpImpl ) + if( mpImpl.is() ) { if( !mpImpl->mxActiveCell.is() ) { @@ -1473,13 +1471,13 @@ const CellRef& SdrTableObj::getActiveCell() const sal_Int32 SdrTableObj::getColumnCount() const { - return mpImpl ? mpImpl->getColumnCount() : 0; + return mpImpl.is() ? mpImpl->getColumnCount() : 0; } void SdrTableObj::setActiveCell( const CellPos& rPos ) { - if( mpImpl && mpImpl->mxTable.is() ) try + if( mpImpl.is() && mpImpl->mxTable.is() ) try { mpImpl->mxActiveCell.set( dynamic_cast< Cell* >( mpImpl->mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ).get() ) ); if( mpImpl->mxActiveCell.is() && mpImpl->mxActiveCell->isMerged() ) @@ -1509,7 +1507,7 @@ void SdrTableObj::getActiveCellPos( CellPos& rPos ) const void SdrTableObj::getCellBounds( const CellPos& rPos, ::Rectangle& rCellRect ) { - if( mpImpl ) + if( mpImpl.is() ) { CellRef xCell( mpImpl->getCell( rPos ) ); if( xCell.is() ) @@ -1520,7 +1518,7 @@ void SdrTableObj::getCellBounds( const CellPos& rPos, ::Rectangle& rCellRect ) void SdrTableObj::TakeTextAnchorRect(Rectangle& rAnchorRect) const { - if( mpImpl ) + if( mpImpl.is() ) TakeTextAnchorRect( mpImpl->maEditPos, rAnchorRect ); } @@ -1529,7 +1527,7 @@ void SdrTableObj::TakeTextAnchorRect( const CellPos& rPos, Rectangle& rAnchorRec { Rectangle aAnkRect(maRect); - if( mpImpl ) + if( mpImpl.is() ) { CellRef xCell( mpImpl->getCell( rPos ) ); if( xCell.is() ) @@ -1543,7 +1541,7 @@ void SdrTableObj::TakeTextAnchorRect( const CellPos& rPos, Rectangle& rAnchorRec void SdrTableObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const { - if( mpImpl ) + if( mpImpl.is() ) TakeTextEditArea( mpImpl->maEditPos, pPaperMin, pPaperMax, pViewInit, pViewMin ); } @@ -1671,7 +1669,7 @@ SdrTableObj& SdrTableObj::operator=(const SdrTableObj& rObj) // call parent SdrObject::operator=(rObj); - TableModelNotifyGuard aGuard( mpImpl ? mpImpl->mxTable.get() : nullptr ); + TableModelNotifyGuard aGuard( mpImpl.is() ? mpImpl->mxTable.get() : nullptr ); maLogicRect = rObj.maLogicRect; maRect = rObj.maRect; @@ -1685,8 +1683,7 @@ SdrTableObj& SdrTableObj::operator=(const SdrTableObj& rObj) bNoMirror = rObj.bNoMirror; bDisableAutoWidthOnDragging = rObj.bDisableAutoWidthOnDragging; - if (mpImpl && rObj.mpImpl) - *mpImpl = *rObj.mpImpl; + *mpImpl = *rObj.mpImpl; return *this; } @@ -1891,7 +1888,7 @@ void SdrTableObj::NbcMove(const Size& rSiz) { MoveRect(maLogicRect,rSiz); SdrTextObj::NbcMove( rSiz ); - if( mpImpl ) + if( mpImpl.is() ) mpImpl->UpdateCells( maRect ); } @@ -1928,7 +1925,7 @@ bool SdrTableObj::AdjustTextFrameWidthAndHeight() bool SdrTableObj::AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHeight, bool bWidth) const { - if((pModel == nullptr) || rR.IsEmpty() || !mpImpl || !mpImpl->mxTable.is() ) + if((pModel == nullptr) || rR.IsEmpty() || !mpImpl.is() || !mpImpl->mxTable.is() ) return false; Rectangle aRectangle( rR ); @@ -2392,7 +2389,7 @@ void SdrTableObj::RestGeoData(const SdrObjGeoData& rGeo) SdrTextObj::RestGeoData (rGeo); - if( mpImpl ) + if( mpImpl.is() ) mpImpl->LayoutTable(maRect, false, false); ActionChanged(); } @@ -2458,7 +2455,7 @@ SdrTableObj* SdrTableObj::CloneRange( const CellPos& rStart, const CellPos& rEnd void SdrTableObj::DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColumn ) { - if( mpImpl && mpImpl->mpLayouter ) + if( mpImpl.is() && mpImpl->mpLayouter ) { TableModelNotifyGuard aGuard( mpImpl->mxTable.get() ); mpImpl->mpLayouter->DistributeColumns( maRect, nFirstColumn, nLastColumn ); @@ -2468,7 +2465,7 @@ void SdrTableObj::DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColu void SdrTableObj::DistributeRows( sal_Int32 nFirstRow, sal_Int32 nLastRow ) { - if( mpImpl && mpImpl->mpLayouter ) + if( mpImpl.is() && mpImpl->mpLayouter ) { TableModelNotifyGuard aGuard( mpImpl->mxTable.get() ); mpImpl->mpLayouter->DistributeRows( maRect, nFirstRow, nLastRow ); @@ -2478,7 +2475,7 @@ void SdrTableObj::DistributeRows( sal_Int32 nFirstRow, sal_Int32 nLastRow ) void SdrTableObj::SetChanged() { - if( mpImpl ) + if( mpImpl.is() ) { mpImpl->LayoutTable( maRect, false, false ); } @@ -2489,14 +2486,14 @@ void SdrTableObj::SetChanged() void SdrTableObj::uno_lock() { - if( mpImpl && mpImpl->mxTable.is() ) + if( mpImpl.is() && mpImpl->mxTable.is() ) mpImpl->mxTable->lockBroadcasts(); } void SdrTableObj::uno_unlock() { - if( mpImpl && mpImpl->mxTable.is() ) + if( mpImpl.is() && mpImpl->mxTable.is() ) mpImpl->mxTable->unlockBroadcasts(); } diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx index a6ef500eaaca..8d1d38265d73 100644 --- a/svx/source/unodraw/unoshtxt.cxx +++ b/svx/source/unodraw/unoshtxt.cxx @@ -1006,35 +1006,31 @@ IMPL_LINK_TYPED(SvxTextEditSourceImpl, NotifyHdl, EENotify&, rNotify, void) SvxTextEditSource::SvxTextEditSource( SdrObject* pObject, SdrText* pText ) { mpImpl = new SvxTextEditSourceImpl( pObject, pText ); - mpImpl->acquire(); } SvxTextEditSource::SvxTextEditSource( SdrObject& rObj, SdrText* pText, SdrView& rView, const vcl::Window& rWindow ) { mpImpl = new SvxTextEditSourceImpl( rObj, pText, rView, rWindow ); - mpImpl->acquire(); } SvxTextEditSource::SvxTextEditSource( SvxTextEditSourceImpl* pImpl ) { mpImpl = pImpl; - mpImpl->acquire(); } SvxTextEditSource::~SvxTextEditSource() { ::SolarMutexGuard aGuard; - - mpImpl->release(); + mpImpl.clear(); } SvxEditSource* SvxTextEditSource::Clone() const { - return new SvxTextEditSource( mpImpl ); + return new SvxTextEditSource( mpImpl.get() ); } diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx index 96ba17f5726a..6e020edbb07e 100644 --- a/ucb/source/core/ucbstore.cxx +++ b/ucb/source/core/ucbstore.cxx @@ -28,6 +28,7 @@ #include <unordered_map> #include <osl/diagnose.h> #include <rtl/ustrbuf.hxx> +#include <rtl/ref.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <comphelper/interfacecontainer2.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> @@ -1063,8 +1064,8 @@ typedef OMultiTypeInterfaceContainerHelperVar<OUString> PropertyListeners_Impl; struct PersistentPropertySet_Impl { - PropertySetRegistry* m_pCreator; - PropertySetInfo_Impl* m_pInfo; + rtl::Reference<PropertySetRegistry> m_pCreator; + rtl::Reference<PropertySetInfo_Impl> m_pInfo; OUString m_aKey; OUString m_aFullKey; osl::Mutex m_aMutex; @@ -1078,16 +1079,10 @@ struct PersistentPropertySet_Impl m_pDisposeEventListeners( nullptr ), m_pPropSetChangeListeners( nullptr ), m_pPropertyChangeListeners( nullptr ) { - m_pCreator->acquire(); } ~PersistentPropertySet_Impl() { - m_pCreator->release(); - - if ( m_pInfo ) - m_pInfo->release(); - delete m_pDisposeEventListeners; delete m_pPropSetChangeListeners; delete m_pPropertyChangeListeners; @@ -1189,13 +1184,11 @@ Reference< XPropertySetInfo > SAL_CALL PersistentPropertySet::getPropertySetInfo { osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); - PropertySetInfo_Impl*& rpInfo = m_pImpl->m_pInfo; - if ( !rpInfo ) + if ( !m_pImpl->m_pInfo.is() ) { - rpInfo = new PropertySetInfo_Impl( this ); - rpInfo->acquire(); + m_pImpl->m_pInfo = new PropertySetInfo_Impl( this ); } - return Reference< XPropertySetInfo >( rpInfo ); + return Reference< XPropertySetInfo >( m_pImpl->m_pInfo.get() ); } @@ -1410,7 +1403,7 @@ void SAL_CALL PersistentPropertySet::removeVetoableChangeListener( Reference< XPropertySetRegistry > SAL_CALL PersistentPropertySet::getRegistry() throw( RuntimeException, std::exception ) { - return Reference< XPropertySetRegistry >( m_pImpl->m_pCreator ); + return Reference< XPropertySetRegistry >( m_pImpl->m_pCreator.get() ); } @@ -1549,7 +1542,7 @@ void SAL_CALL PersistentPropertySet::addProperty( xBatch->commitChanges(); // Property set info is invalid. - if ( m_pImpl->m_pInfo ) + if ( m_pImpl->m_pInfo.is() ) m_pImpl->m_pInfo->reset(); // Notify propertyset info change listeners. @@ -1717,7 +1710,7 @@ void SAL_CALL PersistentPropertySet::removeProperty( const OUString& Name ) xBatch->commitChanges(); // Property set info is invalid. - if ( m_pImpl->m_pInfo ) + if ( m_pImpl->m_pInfo.is() ) m_pImpl->m_pInfo->reset(); // Notify propertyset info change listeners. diff --git a/ucb/source/sorter/sortresult.cxx b/ucb/source/sorter/sortresult.cxx index 95d9c9728d97..4931621581f5 100644 --- a/ucb/source/sorter/sortresult.cxx +++ b/ucb/source/sorter/sortresult.cxx @@ -124,7 +124,6 @@ SortedResultSet::SortedResultSet( Reference< XResultSet > aResult ) mpDisposeEventListeners = nullptr; mpPropChangeListeners = nullptr; mpVetoChangeListeners = nullptr; - mpPropSetInfo = nullptr; mxOriginal = aResult; mpSortInfo = nullptr; @@ -153,8 +152,7 @@ SortedResultSet::~SortedResultSet() mpSortInfo = nullptr; - if ( mpPropSetInfo ) - mpPropSetInfo->release(); + mpPropSetInfo.clear(); delete mpPropChangeListeners; delete mpVetoChangeListeners; @@ -830,13 +828,12 @@ SortedResultSet::getPropertySetInfo() throw( RuntimeException, std::exception ) { osl::Guard< osl::Mutex > aGuard( maMutex ); - if ( !mpPropSetInfo ) + if ( !mpPropSetInfo.is() ) { mpPropSetInfo = new SRSPropertySetInfo(); - mpPropSetInfo->acquire(); } - return Reference< XPropertySetInfo >( mpPropSetInfo ); + return Reference< XPropertySetInfo >( mpPropSetInfo.get() ); } diff --git a/ucb/source/sorter/sortresult.hxx b/ucb/source/sorter/sortresult.hxx index 9ee45c55a245..21a5fe6e6671 100644 --- a/ucb/source/sorter/sortresult.hxx +++ b/ucb/source/sorter/sortresult.hxx @@ -35,6 +35,7 @@ #include <com/sun/star/ucb/XAnyCompareFactory.hpp> #include <com/sun/star/ucb/ListAction.hpp> #include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> #include <deque> namespace comphelper { @@ -126,7 +127,7 @@ class SortedResultSet: public cppu::WeakImplHelper < css::uno::Reference < css::sdbc::XResultSet > mxOriginal; css::uno::Reference < css::sdbc::XResultSet > mxOther; - SRSPropertySetInfo* mpPropSetInfo; + rtl::Reference<SRSPropertySetInfo> mpPropSetInfo; SortInfo* mpSortInfo; osl::Mutex maMutex; SortedEntryList maS2O; // maps the sorted entries to the original ones diff --git a/unotools/source/misc/eventlisteneradapter.cxx b/unotools/source/misc/eventlisteneradapter.cxx index 9eaa1bdf3e45..f33811a463a6 100644 --- a/unotools/source/misc/eventlisteneradapter.cxx +++ b/unotools/source/misc/eventlisteneradapter.cxx @@ -24,6 +24,7 @@ #include <unotools/eventlisteneradapter.hxx> #include <osl/diagnose.h> #include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> namespace utl { @@ -92,7 +93,7 @@ namespace utl struct OEventListenerAdapterImpl { public: - ::std::vector< void* > aListeners; + std::vector< rtl::Reference<OEventListenerImpl> > aListeners; }; //= OEventListenerAdapter @@ -112,32 +113,26 @@ namespace utl if ( m_pImpl->aListeners.empty() ) return; - ::std::vector< void* >::iterator dispose = m_pImpl->aListeners.begin(); + auto it = m_pImpl->aListeners.begin(); do { - OEventListenerImpl* pListenerImpl = static_cast< OEventListenerImpl* >( *dispose ); + rtl::Reference<OEventListenerImpl>& pListenerImpl = *it; if ( pListenerImpl->getComponent().get() == _rxComp.get() ) { pListenerImpl->dispose(); - pListenerImpl->release(); - dispose = m_pImpl->aListeners.erase( dispose ); + it = m_pImpl->aListeners.erase( it ); } else - ++dispose; + ++it; } - while ( dispose != m_pImpl->aListeners.end() ); + while ( it != m_pImpl->aListeners.end() ); } void OEventListenerAdapter::stopAllComponentListening( ) { - for ( ::std::vector< void* >::const_iterator aDisposeLoop = m_pImpl->aListeners.begin(); - aDisposeLoop != m_pImpl->aListeners.end(); - ++aDisposeLoop - ) + for ( const auto & i : m_pImpl->aListeners ) { - OEventListenerImpl* pListenerImpl = static_cast< OEventListenerImpl* >(*aDisposeLoop); - pListenerImpl->dispose(); - pListenerImpl->release(); + i->dispose(); } m_pImpl->aListeners.clear(); } @@ -151,7 +146,6 @@ namespace utl } OEventListenerImpl* pListenerImpl = new OEventListenerImpl(this, _rxComp); - pListenerImpl->acquire(); m_pImpl->aListeners.push_back(pListenerImpl); } diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 3b702cd7afd9..dae07e65baca 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -430,7 +430,6 @@ SvXMLImport::SvXMLImport( mpProgressBarHelper( nullptr ), mpEventImportHelper( nullptr ), mpXMLErrors( nullptr ), - mpStyleMap(nullptr), mnImportFlags( nImportFlags ), mnErrorFlags(SvXMLErrorFlags::NO), mbIsFormsSupported( true ), @@ -618,11 +617,7 @@ void SAL_CALL SvXMLImport::endDocument() Reference< lang::XComponent > xComp( mxEmbeddedResolver, UNO_QUERY ); xComp->dispose(); } - if( mpStyleMap ) - { - mpStyleMap->release(); - mpStyleMap = nullptr; - } + mpStyleMap.clear(); if ( mpXMLErrors != nullptr ) { @@ -1008,7 +1003,6 @@ void SAL_CALL SvXMLImport::initialize( const uno::Sequence< uno::Any >& aArgumen if( pSMap ) { mpStyleMap = pSMap; - mpStyleMap->acquire(); } } OUString sBaseURI; @@ -1405,10 +1399,9 @@ void SvXMLImport::AddStyleDisplayName( sal_uInt16 nFamily, const OUString& rName, const OUString& rDisplayName ) { - if( !mpStyleMap ) + if( !mpStyleMap.is() ) { mpStyleMap = new StyleMap; - mpStyleMap->acquire(); if( mxImportInfo.is() ) { OUString sPrivateData( "PrivateData" ); @@ -1418,7 +1411,7 @@ void SvXMLImport::AddStyleDisplayName( sal_uInt16 nFamily, xPropertySetInfo->hasPropertyByName(sPrivateData) ) { Reference < XInterface > xIfc( - static_cast< XUnoTunnel *>( mpStyleMap ) ); + static_cast< XUnoTunnel *>( mpStyleMap.get() ) ); mxImportInfo->setPropertyValue( sPrivateData, Any(xIfc) ); } } @@ -1437,7 +1430,7 @@ OUString SvXMLImport::GetStyleDisplayName( sal_uInt16 nFamily, const OUString& rName ) const { OUString sName( rName ); - if( mpStyleMap && !rName.isEmpty() ) + if( mpStyleMap.is() && !rName.isEmpty() ) { StyleMap::key_type aKey( nFamily, rName ); StyleMap::const_iterator aIter = mpStyleMap->find( aKey ); diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index d25d18b069cd..f9f9d521c645 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -402,9 +402,6 @@ SdXMLExport::SdXMLExport( mpNotesPageMasterUsageList(new ImpXMLEXPPageMasterList()), mpHandoutPageMaster(nullptr), mpAutoLayoutInfoList(new ImpXMLAutoLayoutInfoList()), - mpSdPropHdlFactory(nullptr), - mpPropertySetMapper(nullptr), - mpPresPagePropsMapper(nullptr), mbIsDraw(bIsDraw), msPageLayoutNames( "PageLayoutNames" ) { @@ -422,30 +419,20 @@ void SAL_CALL SdXMLExport::setSourceDocument( const Reference< lang::XComponent // prepare factory parts mpSdPropHdlFactory = new XMLSdPropHdlFactory( GetModel(), *this ); - // set lock to avoid deletion - mpSdPropHdlFactory->acquire(); - - // build one ref - const rtl::Reference< XMLPropertyHandlerFactory > aFactoryRef = mpSdPropHdlFactory; - // construct PropertySetMapper - rtl::Reference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( aFactoryRef, true); + rtl::Reference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( mpSdPropHdlFactory.get(), true); // get or create text paragraph export GetTextParagraphExport(); mpPropertySetMapper = new XMLShapeExportPropertyMapper( xMapper, *this ); - // set lock to avoid deletion - mpPropertySetMapper->acquire(); // chain text attributes mpPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(*this)); // construct PresPagePropsMapper - xMapper = new XMLPropertySetMapper(aXMLSDPresPageProps, aFactoryRef, true); + xMapper = new XMLPropertySetMapper(aXMLSDPresPageProps, mpSdPropHdlFactory.get(), true); mpPresPagePropsMapper = new XMLPageExportPropertyMapper( xMapper, *this ); - // set lock to avoid deletion - mpPresPagePropsMapper->acquire(); // add family name GetAutoStylePool()->AddFamily( @@ -654,25 +641,13 @@ sal_uInt32 SdXMLExport::ImpRecursiveObjectCount(const Reference< drawing::XShape SdXMLExport::~SdXMLExport() { // cleanup factory, decrease refcount. Should lead to destruction. - if(mpSdPropHdlFactory) - { - mpSdPropHdlFactory->release(); - mpSdPropHdlFactory = nullptr; - } + mpSdPropHdlFactory.clear(); // cleanup mapper, decrease refcount. Should lead to destruction. - if(mpPropertySetMapper) - { - mpPropertySetMapper->release(); - mpPropertySetMapper = nullptr; - } + mpPropertySetMapper.clear(); // cleanup presPage mapper, decrease refcount. Should lead to destruction. - if(mpPresPagePropsMapper) - { - mpPresPagePropsMapper->release(); - mpPresPagePropsMapper = nullptr; - } + mpPresPagePropsMapper.clear(); // clear evtl. temporary page master infos if(mpPageMasterUsageList) diff --git a/xmloff/source/draw/sdxmlexp_impl.hxx b/xmloff/source/draw/sdxmlexp_impl.hxx index 06be6229f9d4..a69bddebc506 100644 --- a/xmloff/source/draw/sdxmlexp_impl.hxx +++ b/xmloff/source/draw/sdxmlexp_impl.hxx @@ -106,9 +106,9 @@ class SdXMLExport : public SvXMLExport HeaderFooterPageSettingsImpl maHandoutPageHeaderFooterSettings; - XMLSdPropHdlFactory* mpSdPropHdlFactory; - XMLShapeExportPropertyMapper* mpPropertySetMapper; - XMLPageExportPropertyMapper* mpPresPagePropsMapper; + rtl::Reference<XMLSdPropHdlFactory> mpSdPropHdlFactory; + rtl::Reference<XMLShapeExportPropertyMapper> mpPropertySetMapper; + rtl::Reference<XMLPageExportPropertyMapper> mpPresPagePropsMapper; SdXMLFormatMap maUsedDateStyles; // this is a vector with the used formatings for date fields SdXMLFormatMap maUsedTimeStyles; // this is a vector with the used formatings for time fields @@ -171,8 +171,8 @@ public: virtual void SAL_CALL setSourceDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) throw(css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) override; // get factories and mappers - XMLShapeExportPropertyMapper* GetPropertySetMapper() const { return mpPropertySetMapper; } - XMLPageExportPropertyMapper* GetPresPagePropsMapper() const { return mpPresPagePropsMapper; } + XMLShapeExportPropertyMapper* GetPropertySetMapper() const { return mpPropertySetMapper.get(); } + XMLPageExportPropertyMapper* GetPresPagePropsMapper() const { return mpPresPagePropsMapper.get(); } bool IsDraw() const { return mbIsDraw; } bool IsImpress() const { return !mbIsDraw; } diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx index 8608197a73ec..39326381933e 100644 --- a/xmloff/source/draw/shapeimport.cxx +++ b/xmloff/source/draw/shapeimport.cxx @@ -137,14 +137,9 @@ XMLShapeImportHelper::XMLShapeImportHelper( mpSdPropHdlFactory = new XMLSdPropHdlFactory( rModel, rImporter ); - // set lock to avoid deletion - mpSdPropHdlFactory->acquire(); - // construct PropertySetMapper - rtl::Reference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper(mpSdPropHdlFactory, false); + rtl::Reference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper(mpSdPropHdlFactory.get(), false); mpPropertySetMapper = new SvXMLImportPropertyMapper( xMapper, rImporter ); - // set lock to avoid deletion - mpPropertySetMapper->acquire(); if( pExtMapper ) { @@ -157,10 +152,8 @@ XMLShapeImportHelper::XMLShapeImportHelper( mpPropertySetMapper->ChainImportMapper(XMLTextImportHelper::CreateParaDefaultExtPropMapper(rImporter)); // construct PresPagePropsMapper - xMapper = new XMLPropertySetMapper(aXMLSDPresPageProps, mpSdPropHdlFactory, false); + xMapper = new XMLPropertySetMapper(aXMLSDPresPageProps, mpSdPropHdlFactory.get(), false); mpPresPagePropsMapper = new SvXMLImportPropertyMapper( xMapper, rImporter ); - // set lock to avoid deletion - mpPresPagePropsMapper->acquire(); uno::Reference< lang::XServiceInfo > xInfo( rImporter.GetModel(), uno::UNO_QUERY ); const OUString aSName( "com.sun.star.presentation.PresentationDocument" ); @@ -172,25 +165,13 @@ XMLShapeImportHelper::~XMLShapeImportHelper() DBG_ASSERT( mpImpl->maConnections.empty(), "XMLShapeImportHelper::restoreConnections() was not called!" ); // cleanup factory, decrease refcount. Should lead to destruction. - if(mpSdPropHdlFactory) - { - mpSdPropHdlFactory->release(); - mpSdPropHdlFactory = nullptr; - } + mpSdPropHdlFactory.clear(); // cleanup mapper, decrease refcount. Should lead to destruction. - if(mpPropertySetMapper) - { - mpPropertySetMapper->release(); - mpPropertySetMapper = nullptr; - } + mpPropertySetMapper.clear(); // cleanup presPage mapper, decrease refcount. Should lead to destruction. - if(mpPresPagePropsMapper) - { - mpPresPagePropsMapper->release(); - mpPresPagePropsMapper = nullptr; - } + mpPresPagePropsMapper.clear(); delete mpGroupShapeElemTokenMap; delete mpFrameShapeElemTokenMap; |