diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-08 10:32:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-08 11:16:37 +0100 |
commit | c2d59ec2832c8b51568e73e9314ab9c82f1f5b7b (patch) | |
tree | b3dea7e4b3f5e3800b6a2f0ab3910b5f96e4f68c /sc | |
parent | bcbcfa7927c575ddb1379b3cd8ef1b2df709ba66 (diff) |
use unique_ptr in ScXMLImportWrapper
Change-Id: I98e29a832509f4ea0453f92ccd6fb274e39b5afc
Reviewed-on: https://gerrit.libreoffice.org/65956
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/xmlwrap.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.hxx | 7 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlwrap.cxx | 10 |
4 files changed, 14 insertions, 11 deletions
diff --git a/sc/inc/xmlwrap.hxx b/sc/inc/xmlwrap.hxx index caa351515273..b03a6c249797 100644 --- a/sc/inc/xmlwrap.hxx +++ b/sc/inc/xmlwrap.hxx @@ -79,7 +79,7 @@ class ScXMLImportWrapper const css::uno::Sequence<css::beans::PropertyValue>& aDescriptor, const OUString& sName, const OUString& sMediaType, const OUString& sComponentName, const css::uno::Sequence<css::uno::Any>& aArgs, - ScMySharedData*& pSharedData); + std::unique_ptr<ScMySharedData>& pSharedData); public: diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index fc61bd6c8487..d3d882d8c4d1 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -343,7 +343,6 @@ ScXMLExport::ScXMLExport( rContext, implementationName, XML_SPREADSHEET, nExportFlag ), pDoc(nullptr), nSourceStreamPos(0), - pSharedData(nullptr), aTableStyles(), pCurrentCell(nullptr), nOpenRow(-1), @@ -489,7 +488,7 @@ void ScXMLExport::CollectSharedData(SCTAB& nTableCount, sal_Int32& nShapesCount) nTableCount = xIndex->getCount(); if (!pSharedData) - pSharedData = new ScMySharedData(nTableCount); + pSharedData.reset(new ScMySharedData(nTableCount)); pCellStyles->AddNewTable(nTableCount - 1); @@ -5417,4 +5416,7 @@ void ScXMLExport::DisposingModel() xCurrentTable = nullptr; } +void ScXMLExport::SetSharedData(std::unique_ptr<ScMySharedData> pTemp) { pSharedData = std::move(pTemp); } + +std::unique_ptr<ScMySharedData> ScXMLExport::ReleaseSharedData() { return std::move(pSharedData); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx index 560177ab46f3..3a97a7d07e70 100644 --- a/sc/source/filter/xml/xmlexprt.hxx +++ b/sc/source/filter/xml/xmlexprt.hxx @@ -94,7 +94,7 @@ class ScXMLExport : public SvXMLExport std::unique_ptr<XMLNumberFormatAttributesExportHelper> pNumberFormatAttributesExportHelper; typedef std::unordered_map<sal_Int32, sal_Int32> NumberFormatIndexMap; NumberFormatIndexMap aNumFmtIndexMap; - ScMySharedData* pSharedData; + std::unique_ptr<ScMySharedData> pSharedData; std::unique_ptr<ScColumnStyles> pColumnStyles; std::unique_ptr<ScRowStyles> pRowStyles; std::unique_ptr<ScFormatRangeStyles> pCellStyles; @@ -253,8 +253,9 @@ public: virtual void exportAnnotationMeta( const css::uno::Reference < css::drawing::XShape >& xShape) override; - void SetSharedData(ScMySharedData* pTemp) { pSharedData = pTemp; } - ScMySharedData* GetSharedData() { return pSharedData; } + void SetSharedData(std::unique_ptr<ScMySharedData> pTemp); + ScMySharedData* GetSharedData() { return pSharedData.get(); } + std::unique_ptr<ScMySharedData> ReleaseSharedData(); XMLNumberFormatAttributesExportHelper* GetNumberFormatAttributesExportHelper(); // Export the document. diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx index a81f7fb6475e..36f6b7f1cf1e 100644 --- a/sc/source/filter/xml/xmlwrap.cxx +++ b/sc/source/filter/xml/xmlwrap.cxx @@ -614,7 +614,7 @@ bool ScXMLImportWrapper::ExportToComponent(const uno::Reference<uno::XComponentC const uno::Reference<frame::XModel>& xModel, const uno::Reference<xml::sax::XWriter>& xWriter, const uno::Sequence<beans::PropertyValue>& aDescriptor, const OUString& sName, const OUString& sMediaType, const OUString& sComponentName, - const uno::Sequence<uno::Any>& aArgs, ScMySharedData*& pSharedData) + const uno::Sequence<uno::Any>& aArgs, std::unique_ptr<ScMySharedData>& pSharedData) { bool bRet(false); uno::Reference<io::XOutputStream> xOut; @@ -667,7 +667,7 @@ bool ScXMLImportWrapper::ExportToComponent(const uno::Reference<uno::XComponentC if ( xFilter.is() ) { ScXMLExport* pExport = static_cast<ScXMLExport*>(SvXMLExport::getImplementation(xFilter)); - pExport->SetSharedData(pSharedData); + pExport->SetSharedData(std::move(pSharedData)); // if there are sheets to copy, get the source stream if ( sName == "content.xml" && lcl_HasValidStream(rDoc) && ( pExport->getExportFlags() & SvXMLExportFlags::OASIS ) ) @@ -715,7 +715,7 @@ bool ScXMLImportWrapper::ExportToComponent(const uno::Reference<uno::XComponentC else bRet = xFilter->filter( aDescriptor ); - pSharedData = pExport->GetSharedData(); + pSharedData = pExport->ReleaseSharedData(); } return bRet; @@ -817,7 +817,7 @@ bool ScXMLImportWrapper::Export(bool bStylesOnly) bool bStylesRet (false); bool bDocRet(false); bool bSettingsRet(false); - ScMySharedData* pSharedData = nullptr; + std::unique_ptr<ScMySharedData> pSharedData; bool bOasis = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 ); @@ -956,7 +956,7 @@ bool ScXMLImportWrapper::Export(bool bStylesOnly) SAL_INFO( "sc.filter", "settings export end" ); } - delete pSharedData; + pSharedData.reset(); if (xStatusIndicator.is()) xStatusIndicator->end(); |