From 7d1b01070c330d45212cd69ea692b2263c23c2a6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 2 Jun 2016 14:53:50 +0200 Subject: remove some manual ref counting in svx and xmloff Change-Id: Ica0b6ff8ff7fa9e65cd758160d6e3ea7110ebb46 Reviewed-on: https://gerrit.libreoffice.org/25824 Tested-by: Jenkins Reviewed-by: Noel Grandin --- xmloff/source/core/xmlimp.cxx | 15 ++++----------- xmloff/source/draw/sdxmlexp.cxx | 35 +++++------------------------------ xmloff/source/draw/sdxmlexp_impl.hxx | 10 +++++----- xmloff/source/draw/shapeimport.cxx | 29 +++++------------------------ 4 files changed, 19 insertions(+), 70 deletions(-) (limited to 'xmloff') 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 mpSdPropHdlFactory; + rtl::Reference mpPropertySetMapper; + rtl::Reference 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; -- cgit