Kaydet (Commit) c2d59ec2 authored tarafından Noel Grandin's avatar Noel Grandin

use unique_ptr in ScXMLImportWrapper

Change-Id: I98e29a832509f4ea0453f92ccd6fb274e39b5afc
Reviewed-on: https://gerrit.libreoffice.org/65956
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst bcbcfa79
......@@ -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:
......
......@@ -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: */
......@@ -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.
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment