sc/source/core/data/column.cxx         |   12 ++++++------
 sc/source/core/data/documen4.cxx       |    4 ++--
 sc/source/core/data/documentimport.cxx |    8 ++++----
 sc/source/core/tool/rangenam.cxx       |    4 ++--
 sc/source/filter/excel/xename.cxx      |    8 ++++----
 5 files changed, 18 insertions(+), 18 deletions(-)

New commits:
commit be86e93d9b880bf63555f8ee4d11690aa6d130b2
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon May 30 16:25:41 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon May 30 19:18:02 2022 +0200

    these ScTokenArray can be stack allocated
    
    Change-Id: I53d370bf6bc5133b7279e569516fc5a0a5ede1b8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135135
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 57451b19f305..06bbe0cf3e70 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2079,7 +2079,7 @@ class UpdateRefOnNonCopy
         ScFormulaCell** ppEnd = pp + rGroup.mnLength;
         ScFormulaCell* pTop = *pp;
         ScTokenArray* pCode = pTop->GetCode();
-        std::unique_ptr<ScTokenArray> pOldCode(pCode->Clone());
+        ScTokenArray aOldCode(pCode->CloneValue());
         ScAddress aOldPos = pTop->aPos;
 
         // Run this before the position gets updated.
@@ -2124,7 +2124,7 @@ class UpdateRefOnNonCopy
 
         if (aRes.mbReferenceModified || aRes.mbNameModified || bGroupShifted)
         {
-            sc::EndListeningContext aEndCxt(mpCxt->mrDoc, pOldCode.get());
+            sc::EndListeningContext aEndCxt(mpCxt->mrDoc, &aOldCode);
             aEndCxt.setPositionDelta(
                 ScAddress(-mpCxt->mnColDelta, -mpCxt->mnRowDelta, 
-mpCxt->mnTabDelta));
 
@@ -2137,7 +2137,7 @@ class UpdateRefOnNonCopy
 
             mbUpdated = true;
 
-            fillUndoDoc(aOldPos, rGroup.mnLength, *pOldCode);
+            fillUndoDoc(aOldPos, rGroup.mnLength, aOldCode);
         }
 
         if (aRes.mbValueChanged)
@@ -2164,7 +2164,7 @@ class UpdateRefOnNonCopy
         ScFormulaCell** ppEnd = pp + rGroup.mnLength;
         ScFormulaCell* pTop = *pp;
         ScTokenArray* pCode = pTop->GetCode();
-        std::unique_ptr<ScTokenArray> pOldCode(pCode->Clone());
+        ScTokenArray aOldCode(pCode->CloneValue());
 
         ScAddress aPos = pTop->aPos;
         ScAddress aOldPos = aPos;
@@ -2211,7 +2211,7 @@ class UpdateRefOnNonCopy
         auto pPosSet = 
std::make_shared<sc::ColumnBlockPositionSet>(mpCxt->mrDoc);
 
         sc::StartListeningContext aStartCxt(mpCxt->mrDoc, pPosSet);
-        sc::EndListeningContext aEndCxt(mpCxt->mrDoc, pPosSet, pOldCode.get());
+        sc::EndListeningContext aEndCxt(mpCxt->mrDoc, pPosSet, &aOldCode);
 
         aEndCxt.setPositionDelta(
             ScAddress(-mpCxt->mnColDelta, -mpCxt->mnRowDelta, 
-mpCxt->mnTabDelta));
@@ -2229,7 +2229,7 @@ class UpdateRefOnNonCopy
         // Move from clipboard is Cut&Paste, then do not copy the original
         // positions' formula cells to the Undo document.
         if (!mbClipboardSource || !bCellMoved)
-            fillUndoDoc(aOldPos, rGroup.mnLength, *pOldCode);
+            fillUndoDoc(aOldPos, rGroup.mnLength, aOldCode);
     }
 
     void fillUndoDoc( const ScAddress& rOldPos, SCROW nLength, const 
ScTokenArray& rOldCode )
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index dff8e71c7373..93e5918a31e6 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -352,8 +352,8 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW 
nRow1,
                 // Reference in each cell must point to the origin cell 
relative to the current cell.
                 aRefData.SetAddress(GetSheetLimits(), aBasePos, aPos);
                 *t->GetSingleRef() = aRefData;
-                std::unique_ptr<ScTokenArray> pTokArr(aArr.Clone());
-                pCell = new ScFormulaCell(*this, aPos, *pTokArr, eGram, 
ScMatrixMode::Reference);
+                ScTokenArray aTokArr(aArr.CloneValue());
+                pCell = new ScFormulaCell(*this, aPos, aTokArr, eGram, 
ScMatrixMode::Reference);
                 pTab->SetFormulaCell(nCol, nRow, pCell);
             }
         }
diff --git a/sc/source/core/data/documentimport.cxx 
b/sc/source/core/data/documentimport.cxx
index 87a14416925b..68b02a0e7666 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -441,8 +441,8 @@ void ScDocumentImport::setMatrixCells(
         // Reference in each cell must point to the origin cell relative to 
the current cell.
         aRefData.SetAddress(mpImpl->mrDoc.GetSheetLimits(), rBasePos, aPos);
         *t->GetSingleRef() = aRefData;
-        std::unique_ptr<ScTokenArray> pTokArr(aArr.Clone());
-        pCell = new ScFormulaCell(mpImpl->mrDoc, aPos, *pTokArr, eGram, 
ScMatrixMode::Reference);
+        ScTokenArray aTokArr(aArr.CloneValue());
+        pCell = new ScFormulaCell(mpImpl->mrDoc, aPos, aTokArr, eGram, 
ScMatrixMode::Reference);
         pBlockPos->miCellPos =
             rCells.set(pBlockPos->miCellPos, aPos.Row(), pCell);
     }
@@ -461,8 +461,8 @@ void ScDocumentImport::setMatrixCells(
             aPos.SetRow(nRow);
             aRefData.SetAddress(mpImpl->mrDoc.GetSheetLimits(), rBasePos, 
aPos);
             *t->GetSingleRef() = aRefData;
-            std::unique_ptr<ScTokenArray> pTokArr(aArr.Clone());
-            pCell = new ScFormulaCell(mpImpl->mrDoc, aPos, *pTokArr, eGram, 
ScMatrixMode::Reference);
+            ScTokenArray aTokArr(aArr.CloneValue());
+            pCell = new ScFormulaCell(mpImpl->mrDoc, aPos, aTokArr, eGram, 
ScMatrixMode::Reference);
             pBlockPos->miCellPos =
                 rColCells.set(pBlockPos->miCellPos, aPos.Row(), pCell);
         }
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index e5eb52c2b181..66cdf2b74c9e 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -258,8 +258,8 @@ OUString ScRangeData::GetSymbol( const ScAddress& rPos, 
const FormulaGrammar::Gr
 
 void ScRangeData::UpdateSymbol( OUStringBuffer& rBuffer, const ScAddress& rPos 
)
 {
-    std::unique_ptr<ScTokenArray> pTemp( pCode->Clone() );
-    ScCompiler aComp(rDoc, rPos, *pTemp, 
formula::FormulaGrammar::GRAM_DEFAULT);
+    ScTokenArray aTemp( pCode->CloneValue() );
+    ScCompiler aComp(rDoc, rPos, aTemp, formula::FormulaGrammar::GRAM_DEFAULT);
     aComp.MoveRelWrap();
     aComp.CreateStringFromTokenArray( rBuffer );
 }
diff --git a/sc/source/filter/excel/xename.cxx 
b/sc/source/filter/excel/xename.cxx
index 4bf336a16d09..3b6cc061f627 100644
--- a/sc/source/filter/excel/xename.cxx
+++ b/sc/source/filter/excel/xename.cxx
@@ -635,13 +635,13 @@ sal_uInt16 XclExpNameManagerImpl::CreateName( SCTAB nTab, 
const ScRangeData& rRa
         if ( rRangeData.HasType( ScRangeData::Type::AbsPos ) || 
rRangeData.HasType( ScRangeData::Type::AbsArea ) )
         {
             // Don't modify the actual document; use a temporary copy to 
create the export formulas.
-            std::unique_ptr<ScTokenArray> pTokenCopy( pScTokArr->Clone() );
-            lcl_EnsureAbs3DToken(nTab, pTokenCopy->FirstToken());
+            ScTokenArray aTokenCopy( pScTokArr->CloneValue() );
+            lcl_EnsureAbs3DToken(nTab, aTokenCopy.FirstToken());
 
-            xTokArr = GetFormulaCompiler().CreateFormula(EXC_FMLATYPE_NAME, 
*pTokenCopy);
+            xTokArr = GetFormulaCompiler().CreateFormula(EXC_FMLATYPE_NAME, 
aTokenCopy);
             if ( GetOutput() != EXC_OUTPUT_BINARY )
             {
-                ScCompiler aComp(GetDoc(), rRangeData.GetPos(), *pTokenCopy,
+                ScCompiler aComp(GetDoc(), rRangeData.GetPos(), aTokenCopy,
                                  formula::FormulaGrammar::GRAM_OOXML);
                 aComp.CreateStringFromTokenArray( sSymbol );
             }

Reply via email to