diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-09-03 20:34:32 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-04 14:00:43 +0200 |
commit | 10d86d8526126956758501604f1bd2e3fe102076 (patch) | |
tree | 58f8e587589eb1a1790133fdef4614ed19749e8d | |
parent | 5f0a01ce47133de31a7f8e43d8ef5e9851a7ceb7 (diff) |
no need to allocate ScMyNamedExpression with unique_ptr
Change-Id: I853aee13d3afc25e7e1ec1aa0d1a41dba7de0fb2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121623
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sc/source/filter/xml/xmlimprt.cxx | 17 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.hxx | 8 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlnexpi.cxx | 39 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlnexpi.hxx | 6 |
4 files changed, 34 insertions, 36 deletions
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 69f7313c58ae..4c70da01c1ec 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -570,9 +570,8 @@ bool ScXMLImport::GetValidation(const OUString& sName, ScMyImportValidation& aVa return false; } -void ScXMLImport::AddNamedExpression(SCTAB nTab, ScMyNamedExpression* pNamedExp) +void ScXMLImport::AddNamedExpression(SCTAB nTab, ScMyNamedExpression aNamedExp) { - ::std::unique_ptr<ScMyNamedExpression> p(pNamedExp); SheetNamedExpMap::iterator itr = m_SheetNamedExpressions.find(nTab); if (itr == m_SheetNamedExpressions.end()) { @@ -586,7 +585,7 @@ void ScXMLImport::AddNamedExpression(SCTAB nTab, ScMyNamedExpression* pNamedExp) itr = r.first; } ScMyNamedExpressions& r = itr->second; - r.push_back(std::move(p)); + r.push_back(std::move(aNamedExp)); } ScXMLChangeTrackingImportHelper* ScXMLImport::GetChangeTrackingImportHelper() @@ -1265,11 +1264,11 @@ public: RangeNameInserter(ScDocument& rDoc, ScRangeName& rRangeName) : mrDoc(rDoc), mrRangeName(rRangeName) {} - void operator() (const std::unique_ptr<ScMyNamedExpression>& p) const + void operator() (const ScMyNamedExpression& p) const { using namespace formula; - const OUString& aType = p->sRangeType; + const OUString& aType = p.sRangeType; sal_uInt32 nUnoType = ScXMLImport::GetRangeType(aType); ScRangeData::Type nNewType = ScRangeData::Type::Name; @@ -1282,16 +1281,16 @@ public: ScAddress aPos; sal_Int32 nOffset = 0; bool bSuccess = ScRangeStringConverter::GetAddressFromString( - aPos, p->sBaseCellAddress, mrDoc, FormulaGrammar::CONV_OOO, nOffset); + aPos, p.sBaseCellAddress, mrDoc, FormulaGrammar::CONV_OOO, nOffset); if (bSuccess) { - OUString aContent = p->sContent; - if (!p->bIsExpression) + OUString aContent = p.sContent; + if (!p.bIsExpression) ScXMLConverter::ConvertCellRangeAddress(aContent); ScRangeData* pData = new ScRangeData( - mrDoc, p->sName, aContent, aPos, nNewType, p->eGrammar); + mrDoc, p.sName, aContent, aPos, nNewType, p.eGrammar); mrRangeName.insert(pData); } } diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index 71c385f50023..596f8b5c5972 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -73,7 +73,7 @@ struct ScMyNamedExpression bool bIsExpression; }; -typedef ::std::list<std::unique_ptr<ScMyNamedExpression>> ScMyNamedExpressions; +typedef ::std::list<ScMyNamedExpression> ScMyNamedExpressions; struct ScMyLabelRange { @@ -223,12 +223,12 @@ public: sc::PivotTableSources& GetPivotTableSources(); - void AddNamedExpression(ScMyNamedExpression* pMyNamedExpression) + void AddNamedExpression(ScMyNamedExpression aMyNamedExpression) { - m_aMyNamedExpressions.push_back(std::unique_ptr<ScMyNamedExpression>(pMyNamedExpression)); + m_aMyNamedExpressions.push_back(std::move(aMyNamedExpression)); } - void AddNamedExpression(SCTAB nTab, ScMyNamedExpression* pNamedExp); + void AddNamedExpression(SCTAB nTab, ScMyNamedExpression aNamedExp); void AddLabelRange(std::unique_ptr<const ScMyLabelRange> pMyLabelRange) { diff --git a/sc/source/filter/xml/xmlnexpi.cxx b/sc/source/filter/xml/xmlnexpi.cxx index 3d4286985d61..0f07ea5defa6 100644 --- a/sc/source/filter/xml/xmlnexpi.cxx +++ b/sc/source/filter/xml/xmlnexpi.cxx @@ -29,18 +29,17 @@ using namespace xmloff::token; ScXMLNamedExpressionsContext::GlobalInserter::GlobalInserter(ScXMLImport& rImport) : mrImport(rImport) {} -void ScXMLNamedExpressionsContext::GlobalInserter::insert(ScMyNamedExpression* pExp) +void ScXMLNamedExpressionsContext::GlobalInserter::insert(ScMyNamedExpression aExp) { - if (pExp) - mrImport.AddNamedExpression(pExp); + mrImport.AddNamedExpression(std::move(aExp)); } ScXMLNamedExpressionsContext::SheetLocalInserter::SheetLocalInserter(ScXMLImport& rImport, SCTAB nTab) : mrImport(rImport), mnTab(nTab) {} -void ScXMLNamedExpressionsContext::SheetLocalInserter::insert(ScMyNamedExpression* pExp) +void ScXMLNamedExpressionsContext::SheetLocalInserter::insert(ScMyNamedExpression aExp) { - mrImport.AddNamedExpression(mnTab, pExp); + mrImport.AddNamedExpression(mnTab, std::move(aExp)); } ScXMLNamedExpressionsContext::ScXMLNamedExpressionsContext( @@ -88,10 +87,10 @@ ScXMLNamedRangeContext::ScXMLNamedRangeContext( if (!pInserter) return; - ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression); + ScMyNamedExpression aNamedExpression; // A simple table:cell-range-address is not a formula expression, stored // without [] brackets but with dot, .A1 - pNamedExpression->eGrammar = formula::FormulaGrammar::mergeToGrammar( + aNamedExpression.eGrammar = formula::FormulaGrammar::mergeToGrammar( GetScImport().GetDocument()->GetStorageGrammar(), formula::FormulaGrammar::CONV_OOO); @@ -102,22 +101,22 @@ ScXMLNamedRangeContext::ScXMLNamedRangeContext( switch (aIter.getToken()) { case XML_ELEMENT( TABLE, XML_NAME ): - pNamedExpression->sName = aIter.toString(); + aNamedExpression.sName = aIter.toString(); break; case XML_ELEMENT( TABLE, XML_CELL_RANGE_ADDRESS ): - pNamedExpression->sContent = aIter.toString(); + aNamedExpression.sContent = aIter.toString(); break; case XML_ELEMENT( TABLE, XML_BASE_CELL_ADDRESS ): - pNamedExpression->sBaseCellAddress = aIter.toString(); + aNamedExpression.sBaseCellAddress = aIter.toString(); break; case XML_ELEMENT( TABLE, XML_RANGE_USABLE_AS ): - pNamedExpression->sRangeType = aIter.toString(); + aNamedExpression.sRangeType = aIter.toString(); break; } } } - pNamedExpression->bIsExpression = false; - pInserter->insert(pNamedExpression); + aNamedExpression.bIsExpression = false; + pInserter->insert(std::move(aNamedExpression)); } ScXMLNamedRangeContext::~ScXMLNamedRangeContext() @@ -133,7 +132,7 @@ ScXMLNamedExpressionContext::ScXMLNamedExpressionContext( if (!pInserter) return; - ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression); + ScMyNamedExpression aNamedExpression; if ( rAttrList.is() ) { @@ -142,21 +141,21 @@ ScXMLNamedExpressionContext::ScXMLNamedExpressionContext( switch (aIter.getToken()) { case XML_ELEMENT( TABLE, XML_NAME ): - pNamedExpression->sName = aIter.toString(); + aNamedExpression.sName = aIter.toString(); break; case XML_ELEMENT( TABLE, XML_EXPRESSION ): GetScImport().ExtractFormulaNamespaceGrammar( - pNamedExpression->sContent, pNamedExpression->sContentNmsp, - pNamedExpression->eGrammar, aIter.toString() ); + aNamedExpression.sContent, aNamedExpression.sContentNmsp, + aNamedExpression.eGrammar, aIter.toString() ); break; case XML_ELEMENT( TABLE, XML_BASE_CELL_ADDRESS ): - pNamedExpression->sBaseCellAddress = aIter.toString(); + aNamedExpression.sBaseCellAddress = aIter.toString(); break; } } } - pNamedExpression->bIsExpression = true; - pInserter->insert(pNamedExpression); + aNamedExpression.bIsExpression = true; + pInserter->insert(std::move(aNamedExpression)); } ScXMLNamedExpressionContext::~ScXMLNamedExpressionContext() diff --git a/sc/source/filter/xml/xmlnexpi.hxx b/sc/source/filter/xml/xmlnexpi.hxx index d4b2d983ff0f..1d53f174c32e 100644 --- a/sc/source/filter/xml/xmlnexpi.hxx +++ b/sc/source/filter/xml/xmlnexpi.hxx @@ -35,7 +35,7 @@ public: { public: virtual ~Inserter() {} - virtual void insert(ScMyNamedExpression* pExp) = 0; + virtual void insert(ScMyNamedExpression aExp) = 0; }; /** @@ -46,7 +46,7 @@ public: { public: explicit GlobalInserter(ScXMLImport& rImport); - virtual void insert(ScMyNamedExpression* pExp) override; + virtual void insert(ScMyNamedExpression aExp) override; private: ScXMLImport& mrImport; }; @@ -60,7 +60,7 @@ public: { public: SheetLocalInserter(ScXMLImport& rImport, SCTAB nTab); - virtual void insert(ScMyNamedExpression* pExp) override; + virtual void insert(ScMyNamedExpression aExp) override; private: ScXMLImport& mrImport; SCTAB mnTab; |