[Libreoffice-commits] core.git: sc/inc sc/qa sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Jan 10 10:22:51 UTC 2019
sc/inc/compiler.hxx | 4 -
sc/inc/documentimport.hxx | 2
sc/inc/formulacell.hxx | 8 +--
sc/inc/tokenarray.hxx | 2
sc/qa/unit/helper/qahelper.cxx | 3 -
sc/qa/unit/helper/qahelper.hxx | 2
sc/qa/unit/ucalc_formula.cxx | 7 ---
sc/source/core/data/column4.cxx | 8 +--
sc/source/core/data/conditio.cxx | 8 +--
sc/source/core/data/documentimport.cxx | 4 -
sc/source/core/data/formulacell.cxx | 56 +++++++++++-------------
sc/source/core/data/simpleformulacalc.cxx | 2
sc/source/core/tool/compiler.cxx | 16 +++---
sc/source/core/tool/rangenam.cxx | 5 --
sc/source/core/tool/sharedformula.cxx | 2
sc/source/core/tool/token.cxx | 4 -
sc/source/filter/excel/excform.cxx | 2
sc/source/filter/excel/impop.cxx | 4 -
sc/source/filter/excel/xeformula.cxx | 2
sc/source/filter/excel/xipivot.cxx | 2
sc/source/filter/ftools/sharedformulagroups.cxx | 4 -
sc/source/filter/inc/sharedformulagroups.hxx | 2
sc/source/filter/lotus/lotimpop.cxx | 2
sc/source/filter/lotus/op.cxx | 4 -
sc/source/filter/oox/formulabuffer.cxx | 8 +--
sc/source/filter/oox/revisionfragment.cxx | 5 +-
sc/source/filter/oox/worksheethelper.cxx | 6 +-
sc/source/filter/orcus/interface.cxx | 4 -
sc/source/filter/qpro/qpro.cxx | 2
sc/source/filter/xcl97/XclImpChangeTrack.cxx | 2
sc/source/filter/xml/xmlcelli.cxx | 4 -
sc/source/filter/xml/xmlcondformat.cxx | 8 +--
sc/source/ui/docshell/docfunc.cxx | 5 --
sc/source/ui/namedlg/namedefdlg.cxx | 4 -
sc/source/ui/namedlg/namedlg.cxx | 4 -
sc/source/ui/unoobj/tokenuno.cxx | 3 -
sc/source/ui/view/viewfunc.cxx | 4 -
37 files changed, 101 insertions(+), 113 deletions(-)
New commits:
commit 60a66bd57d17a2f72fbf852faf1eaad87eac6dec
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jan 9 14:00:48 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jan 10 11:22:25 2019 +0100
pass ScTokenArray around by unique_ptr
Change-Id: I611554b1c4cbc506dbfc32748e9f14c9e8eb5156
Reviewed-on: https://gerrit.libreoffice.org/66022
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 3186f973152b..d2500a7e0440 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -449,8 +449,8 @@ public:
* @return heap allocated token array object. The caller <i>must</i>
* manage the life cycle of this object.
*/
- ScTokenArray* CompileString( const OUString& rFormula );
- ScTokenArray* CompileString( const OUString& rFormula, const OUString& rFormulaNmsp );
+ std::unique_ptr<ScTokenArray> CompileString( const OUString& rFormula );
+ std::unique_ptr<ScTokenArray> CompileString( const OUString& rFormula, const OUString& rFormulaNmsp );
const ScAddress& GetPos() const { return aPos; }
void MoveRelWrap();
diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx
index 02e425449176..7680f7880dae 100644
--- a/sc/inc/documentimport.hxx
+++ b/sc/inc/documentimport.hxx
@@ -104,7 +104,7 @@ public:
const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGrammar,
const OUString& rResult );
- void setFormulaCell(const ScAddress& rPos, ScTokenArray* pArray);
+ void setFormulaCell(const ScAddress& rPos, std::unique_ptr<ScTokenArray> pArray);
void setFormulaCell(const ScAddress& rPos, ScFormulaCell* pCell);
void setMatrixCells(
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index f344b46034da..b6959c74d6cd 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -60,7 +60,7 @@ public:
mutable size_t mnRefCount;
- ScTokenArray* mpCode;
+ std::unique_ptr<ScTokenArray> mpCode;
ScFormulaCell *mpTopCell;
SCROW mnLength; // How many of these do we have ?
sal_Int32 mnWeight;
@@ -77,7 +77,7 @@ public:
~ScFormulaCellGroup();
void setCode( const ScTokenArray& rCode );
- void setCode( ScTokenArray* pCode );
+ void setCode( std::unique_ptr<ScTokenArray> pCode );
void compileCode(
ScDocument& rDoc, const ScAddress& rPos, formula::FormulaGrammar::Grammar eGram );
@@ -181,7 +181,7 @@ public:
* formula cell being constructed. The caller <i>must not</i> pass a NULL
* token array pointer.
*/
- ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, ScTokenArray* pArray,
+ ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos, std::unique_ptr<ScTokenArray> pArray,
const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT,
ScMatrixMode cMatInd = ScMatrixMode::NONE );
@@ -340,7 +340,7 @@ public:
ScTokenArray* GetCode() { return pCode;}
const ScTokenArray* GetCode() const { return pCode;}
- void SetCode( ScTokenArray* pNew );
+ void SetCode( std::unique_ptr<ScTokenArray> pNew );
bool IsRunning() const { return bRunning;}
void SetRunning( bool bVal );
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 1e747e8b5dcc..dca885713b01 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -67,7 +67,7 @@ public:
bool EqualTokens( const ScTokenArray* pArr2 ) const;
virtual void Clear() override;
- ScTokenArray* Clone() const; /// True copy!
+ std::unique_ptr<ScTokenArray> Clone() const; /// True copy!
void GenHash();
size_t GetHash() const { return mnHashValue;}
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index c8d9bfdfc655..cc23c7a207f5 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -30,6 +30,7 @@
#include <sfx2/docfile.hxx>
#include <unotools/tempfile.hxx>
#include <scitems.hxx>
+#include <tokenarray.hxx>
#include <orcus/csv_parser.hpp>
@@ -477,7 +478,7 @@ bool checkFormulaPositions(
return true;
}
-ScTokenArray* compileFormula(
+std::unique_ptr<ScTokenArray> compileFormula(
ScDocument* pDoc, const OUString& rFormula,
formula::FormulaGrammar::Grammar eGram )
{
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index 11a19d618d3e..671b3bdcad1b 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -134,7 +134,7 @@ SCQAHELPER_DLLPUBLIC bool checkFormulaPosition(ScDocument& rDoc, const ScAddress
SCQAHELPER_DLLPUBLIC bool checkFormulaPositions(
ScDocument& rDoc, SCTAB nTab, SCCOL nCol, const SCROW* pRows, size_t nRowCount);
-SCQAHELPER_DLLPUBLIC ScTokenArray* compileFormula(
+SCQAHELPER_DLLPUBLIC std::unique_ptr<ScTokenArray> compileFormula(
ScDocument* pDoc, const OUString& rFormula,
formula::FormulaGrammar::Grammar eGram = formula::FormulaGrammar::GRAM_NATIVE );
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index fc505c281c18..9577a8fe1fab 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1003,11 +1003,8 @@ void Test::testFormulaCompiler()
for (size_t i = 0; i < SAL_N_ELEMENTS(aTests); ++i)
{
- std::unique_ptr<ScTokenArray> pArray;
- {
- pArray.reset(compileFormula(m_pDoc, OUString::createFromAscii(aTests[i].pInput), aTests[i].eInputGram));
- CPPUNIT_ASSERT_MESSAGE("Token array shouldn't be NULL!", pArray);
- }
+ std::unique_ptr<ScTokenArray> pArray = compileFormula(m_pDoc, OUString::createFromAscii(aTests[i].pInput), aTests[i].eInputGram);
+ CPPUNIT_ASSERT_MESSAGE("Token array shouldn't be NULL!", pArray);
OUString aFormula = toString(*m_pDoc, ScAddress(), *pArray, aTests[i].eOutputGram);
CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(aTests[i].pOutput), aFormula);
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index b324b2a2d928..d21d52f4029c 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -897,10 +897,10 @@ public:
// Create a new token array from the hybrid formula string, and
// set it to the group.
ScCompiler aComp(mrCompileFormulaCxt, pTop->aPos);
- ScTokenArray* pNewCode = aComp.CompileString(aFormula);
+ std::unique_ptr<ScTokenArray> pNewCode = aComp.CompileString(aFormula);
ScFormulaCellGroupRef xGroup = pTop->GetCellGroup();
assert(xGroup);
- xGroup->setCode(pNewCode);
+ xGroup->setCode(std::move(pNewCode));
xGroup->compileCode(*mpDoc, pTop->aPos, mpDoc->GetGrammar());
// Propagate the new token array to all formula cells in the group.
@@ -924,14 +924,14 @@ public:
{
// Create token array from formula string.
ScCompiler aComp(mrCompileFormulaCxt, pCell->aPos);
- ScTokenArray* pNewCode = aComp.CompileString(aFormula);
+ std::unique_ptr<ScTokenArray> pNewCode = aComp.CompileString(aFormula);
// Generate RPN tokens.
ScCompiler aComp2(mpDoc, pCell->aPos, *pNewCode, formula::FormulaGrammar::GRAM_UNSPECIFIED,
true, pCell->GetMatrixFlag() != ScMatrixMode::NONE);
aComp2.CompileTokenArray();
- pCell->SetCode(pNewCode);
+ pCell->SetCode(std::move(pNewCode));
pCell->StartListeningTo(mrStartListenCxt);
pCell->SetDirty();
}
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index cb00a2329924..e4c669052467 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -224,9 +224,9 @@ ScConditionEntry::ScConditionEntry( ScDocument* pDocument, const ScConditionEntr
{
// Real copy of the formulas (for Ref Undo)
if (r.pFormula1)
- pFormula1.reset( r.pFormula1->Clone() );
+ pFormula1 = r.pFormula1->Clone();
if (r.pFormula2)
- pFormula2.reset( r.pFormula2->Clone() );
+ pFormula2 = r.pFormula2->Clone();
// Formula cells are created at IsValid
// TODO: But not in the Clipboard! So interpret beforehand!
@@ -352,7 +352,7 @@ void ScConditionEntry::Compile( const OUString& rExpr1, const OUString& rExpr2,
}
else
{
- pFormula1.reset( aComp.CompileString( rExpr1, rExprNmsp1 ) );
+ pFormula1 = aComp.CompileString( rExpr1, rExprNmsp1 );
SimplifyCompiledFormula( pFormula1, nVal1, bIsStr1, aStrVal1 );
bRelRef1 = lcl_HasRelRef( mpDoc, pFormula1.get() );
}
@@ -371,7 +371,7 @@ void ScConditionEntry::Compile( const OUString& rExpr1, const OUString& rExpr2,
}
else
{
- pFormula2.reset( aComp.CompileString( rExpr2, rExprNmsp2 ) );
+ pFormula2 = aComp.CompileString( rExpr2, rExprNmsp2 );
SimplifyCompiledFormula( pFormula2, nVal2, bIsStr2, aStrVal2 );
bRelRef2 = lcl_HasRelRef( mpDoc, pFormula2.get() );
}
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 41f004107a8d..c5d1be2dfdc6 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -331,7 +331,7 @@ void ScDocumentImport::setFormulaCell(
rCells.set(pBlockPos->miCellPos, rPos.Row(), pFC.release());
}
-void ScDocumentImport::setFormulaCell(const ScAddress& rPos, ScTokenArray* pArray)
+void ScDocumentImport::setFormulaCell(const ScAddress& rPos, std::unique_ptr<ScTokenArray> pArray)
{
ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
if (!pTab)
@@ -343,7 +343,7 @@ void ScDocumentImport::setFormulaCell(const ScAddress& rPos, ScTokenArray* pArra
return;
std::unique_ptr<ScFormulaCell> pFC =
- o3tl::make_unique<ScFormulaCell>(&mpImpl->mrDoc, rPos, pArray);
+ o3tl::make_unique<ScFormulaCell>(&mpImpl->mrDoc, rPos, std::move(pArray));
mpImpl->mrDoc.CheckLinkFormulaNeedingCheck( *pFC->GetCode());
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 83da566d4b4b..900bd2e71990 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -516,7 +516,6 @@ struct ScFormulaCellGroup::Impl
ScFormulaCellGroup::ScFormulaCellGroup() :
mpImpl(new Impl),
mnRefCount(0),
- mpCode(nullptr),
mpTopCell(nullptr),
mnLength(0),
mnWeight(0),
@@ -530,21 +529,18 @@ ScFormulaCellGroup::ScFormulaCellGroup() :
ScFormulaCellGroup::~ScFormulaCellGroup()
{
- delete mpCode;
}
void ScFormulaCellGroup::setCode( const ScTokenArray& rCode )
{
- delete mpCode;
mpCode = rCode.Clone();
mbInvariant = mpCode->IsInvariant();
mpCode->GenHash();
}
-void ScFormulaCellGroup::setCode( ScTokenArray* pCode )
+void ScFormulaCellGroup::setCode( std::unique_ptr<ScTokenArray> pCode )
{
- delete mpCode;
- mpCode = pCode; // takes ownership of the token array.
+ mpCode = std::move(pCode); // takes ownership of the token array.
mpCode->Finalize(); // Reduce memory usage if needed.
mbInvariant = mpCode->IsInvariant();
mpCode->GenHash();
@@ -667,7 +663,7 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos,
}
ScFormulaCell::ScFormulaCell(
- ScDocument* pDoc, const ScAddress& rPos, ScTokenArray* pArray,
+ ScDocument* pDoc, const ScAddress& rPos, std::unique_ptr<ScTokenArray> pArray,
const FormulaGrammar::Grammar eGrammar, ScMatrixMode cMatInd ) :
bDirty( true ),
bTableOpDirty( false ),
@@ -687,7 +683,7 @@ ScFormulaCell::ScFormulaCell(
nSeenInIteration(0),
nFormatType ( SvNumFormatType::NUMBER ),
eTempGrammar( eGrammar),
- pCode(pArray),
+ pCode(pArray.release()),
pDocument( pDoc ),
pPrevious(nullptr),
pNext(nullptr),
@@ -695,7 +691,7 @@ ScFormulaCell::ScFormulaCell(
pNextTrack(nullptr),
aPos(rPos)
{
- assert(pArray); // Never pass a NULL pointer here.
+ assert(pCode); // Never pass a NULL pointer here.
pCode->Finalize(); // Reduce memory usage if needed.
@@ -788,7 +784,7 @@ ScFormulaCell::ScFormulaCell(
nSeenInIteration(0),
nFormatType(xGroup->mnFormatType),
eTempGrammar( eGrammar),
- pCode(xGroup->mpCode ? xGroup->mpCode : new ScTokenArray),
+ pCode(xGroup->mpCode ? xGroup->mpCode.get() : new ScTokenArray),
pDocument( pDoc ),
pPrevious(nullptr),
pNext(nullptr),
@@ -828,7 +824,7 @@ ScFormulaCell::ScFormulaCell(const ScFormulaCell& rCell, ScDocument& rDoc, const
pNextTrack(nullptr),
aPos(rPos)
{
- pCode = rCell.pCode->Clone();
+ pCode = rCell.pCode->Clone().release();
// set back any errors and recompile
// not in the Clipboard - it must keep the received error flag
@@ -1129,7 +1125,7 @@ void ScFormulaCell::Compile( const OUString& rFormula, bool bNoListening,
pCode->Clear();
ScTokenArray* pCodeOld = pCode;
ScCompiler aComp( pDocument, aPos, eGrammar);
- pCode = aComp.CompileString( rFormula );
+ pCode = aComp.CompileString( rFormula ).release();
delete pCodeOld;
if( pCode->GetCodeError() == FormulaError::NONE )
{
@@ -1163,7 +1159,7 @@ void ScFormulaCell::Compile(
pCode->Clear();
ScTokenArray* pCodeOld = pCode;
ScCompiler aComp(rCxt, aPos);
- pCode = aComp.CompileString( rFormula );
+ pCode = aComp.CompileString( rFormula ).release();
delete pCodeOld;
if( pCode->GetCodeError() == FormulaError::NONE )
{
@@ -1339,7 +1335,7 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr
if (bDoCompile)
{
ScTokenArray* pCodeOld = pCode;
- pCode = aComp.CompileString( aFormula, aFormulaNmsp );
+ pCode = aComp.CompileString( aFormula, aFormulaNmsp ).release();
delete pCodeOld;
if( pCode->GetCodeError() == FormulaError::NONE )
@@ -3232,7 +3228,7 @@ bool ScFormulaCell::UpdateReferenceOnShift(
std::unique_ptr<ScTokenArray> pOldCode;
if (pUndoDoc)
- pOldCode.reset(pCode->Clone());
+ pOldCode = pCode->Clone();
bool bValChanged = false;
bool bRefModified = false;
@@ -3361,7 +3357,7 @@ bool ScFormulaCell::UpdateReferenceOnMove(
bool bCellStateChanged = false;
std::unique_ptr<ScTokenArray> pOldCode;
if (pUndoDoc)
- pOldCode.reset(pCode->Clone());
+ pOldCode = pCode->Clone();
bool bValChanged = false;
bool bRefModified = false;
@@ -3485,7 +3481,7 @@ bool ScFormulaCell::UpdateReferenceOnCopy(
std::unique_ptr<ScTokenArray> pOldCode;
if (pUndoDoc)
- pOldCode.reset(pCode->Clone());
+ pOldCode = pCode->Clone();
if (bOnRefMove)
// Cell may reference itself, e.g. ocColumn, ocRow without parameter
@@ -3764,7 +3760,9 @@ void ScFormulaCell::UpdateTranspose( const ScRange& rSource, const ScAddress& rD
bPosChanged = true;
}
- ScTokenArray* pOld = pUndoDoc ? pCode->Clone() : nullptr;
+ std::unique_ptr<ScTokenArray> pOld;
+ if (pUndoDoc)
+ pOld = pCode->Clone();
bool bRefChanged = false;
formula::FormulaTokenArrayPlainIterator aIter(*pCode);
@@ -3808,8 +3806,6 @@ void ScFormulaCell::UpdateTranspose( const ScRange& rSource, const ScAddress& rD
}
else
StartListeningTo( pDocument ); // Listener as previous
-
- delete pOld;
}
void ScFormulaCell::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY )
@@ -3886,11 +3882,11 @@ void ScFormulaCell::SetChanged(bool b)
bChanged = b;
}
-void ScFormulaCell::SetCode( ScTokenArray* pNew )
+void ScFormulaCell::SetCode( std::unique_ptr<ScTokenArray> pNew )
{
assert(!mxGroup); // Don't call this if it's shared.
delete pCode;
- pCode = pNew; // takes ownership.
+ pCode = pNew.release(); // takes ownership.
}
void ScFormulaCell::SetRunning( bool bVal )
@@ -3948,7 +3944,7 @@ ScFormulaCellGroupRef ScFormulaCell::CreateCellGroup( SCROW nLen, bool bInvarian
mxGroup->mpTopCell = this;
mxGroup->mbInvariant = bInvariant;
mxGroup->mnLength = nLen;
- mxGroup->mpCode = pCode; // Move this to the shared location.
+ mxGroup->mpCode.reset(pCode); // Move this to the shared location.
return mxGroup;
}
@@ -3958,7 +3954,7 @@ void ScFormulaCell::SetCellGroup( const ScFormulaCellGroupRef &xRef )
{
// Make this cell a non-grouped cell.
if (mxGroup)
- pCode = mxGroup->mpCode->Clone();
+ pCode = mxGroup->mpCode->Clone().release();
mxGroup = xRef;
return;
@@ -3970,7 +3966,7 @@ void ScFormulaCell::SetCellGroup( const ScFormulaCellGroupRef &xRef )
delete pCode;
mxGroup = xRef;
- pCode = mxGroup->mpCode;
+ pCode = mxGroup->mpCode.get();
mxGroup->mnWeight = 0; // invalidate
}
@@ -4836,7 +4832,7 @@ bool ScFormulaCell::InterpretFormulaGroupOpenCL(sc::FormulaLogger::GroupScope& a
xGroup->mpTopCell->aPos.IncRow(nOffset);
xGroup->mbInvariant = mxGroup->mbInvariant;
xGroup->mnLength = nCurChunkSize;
- xGroup->mpCode = mxGroup->mpCode;
+ xGroup->mpCode.reset( mxGroup->mpCode.get() );
}
ScTokenArray aCode;
@@ -4868,7 +4864,7 @@ bool ScFormulaCell::InterpretFormulaGroupOpenCL(sc::FormulaLogger::GroupScope& a
{
mxGroup->mpTopCell->aPos = aOrigPos;
xGroup->mpTopCell = nullptr;
- xGroup->mpCode = nullptr;
+ xGroup->mpCode.release();
}
aScope.addMessage("group token conversion failed");
@@ -5268,12 +5264,12 @@ sal_Int32 ScFormulaCell::GetWeight() const
ScTokenArray* ScFormulaCell::GetSharedCode()
{
- return mxGroup ? mxGroup->mpCode : nullptr;
+ return mxGroup ? mxGroup->mpCode.get() : nullptr;
}
const ScTokenArray* ScFormulaCell::GetSharedCode() const
{
- return mxGroup ? mxGroup->mpCode : nullptr;
+ return mxGroup ? mxGroup->mpCode.get() : nullptr;
}
void ScFormulaCell::SyncSharedCode()
@@ -5282,7 +5278,7 @@ void ScFormulaCell::SyncSharedCode()
// Not a shared formula cell.
return;
- pCode = mxGroup->mpCode;
+ pCode = mxGroup->mpCode.get();
}
#if DUMP_COLUMN_STORAGE
diff --git a/sc/source/core/data/simpleformulacalc.cxx b/sc/source/core/data/simpleformulacalc.cxx
index 3ed2c173f3c6..f32f77a2ab0e 100644
--- a/sc/source/core/data/simpleformulacalc.cxx
+++ b/sc/source/core/data/simpleformulacalc.cxx
@@ -30,7 +30,7 @@ ScSimpleFormulaCalculator::ScSimpleFormulaCalculator( ScDocument* pDoc, const Sc
{
// compile already here
ScCompiler aComp(mpDoc, maAddr, eGram, true, bMatrixFormula);
- mpCode.reset(aComp.CompileString(rFormula));
+ mpCode = aComp.CompileString(rFormula);
if(mpCode->GetCodeError() == FormulaError::NONE && mpCode->GetLen())
aComp.CompileTokenArray();
}
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 58cdd1b7ad92..bad18be255ff 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4383,7 +4383,7 @@ public:
}
-ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
+std::unique_ptr<ScTokenArray> ScCompiler::CompileString( const OUString& rFormula )
{
OSL_ENSURE( meGrammar != FormulaGrammar::GRAM_EXTERNAL, "ScCompiler::CompileString - unexpected grammar GRAM_EXTERNAL" );
if( meGrammar == FormulaGrammar::GRAM_EXTERNAL )
@@ -4680,9 +4680,9 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
delete [] pFunctionStack;
// remember pArr, in case a subsequent CompileTokenArray() is executed.
- ScTokenArray* pNew = new ScTokenArray( aArr );
+ std::unique_ptr<ScTokenArray> pNew(new ScTokenArray( aArr ));
pNew->GenHash();
- pArr = pNew;
+ pArr = pNew.get();
maArrIterator = FormulaTokenArrayPlainIterator(*pArr);
if (!maExternalFiles.empty())
@@ -4697,7 +4697,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
return pNew;
}
-ScTokenArray* ScCompiler::CompileString( const OUString& rFormula, const OUString& rFormulaNmsp )
+std::unique_ptr<ScTokenArray> ScCompiler::CompileString( const OUString& rFormula, const OUString& rFormulaNmsp )
{
OSL_ENSURE( (GetGrammar() == FormulaGrammar::GRAM_EXTERNAL) || rFormulaNmsp.isEmpty(),
"ScCompiler::CompileString - unexpected formula namespace for internal grammar" );
@@ -4712,8 +4712,8 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula, const OUStrin
if( ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, aTokenSeq ) )
{
// remember pArr, in case a subsequent CompileTokenArray() is executed.
- ScTokenArray* pNew = new ScTokenArray( aTokenArray );
- pArr = pNew;
+ std::unique_ptr<ScTokenArray> pNew(new ScTokenArray( aTokenArray ));
+ pArr = pNew.get();
maArrIterator = FormulaTokenArrayPlainIterator(*pArr);
return pNew;
}
@@ -4760,7 +4760,7 @@ bool ScCompiler::HandleRange()
pNew->AddOpCode( ocClose );
PushTokenArray( pNew, true );
}
- pNew = pRangeData->GetCode()->Clone();
+ pNew = pRangeData->GetCode()->Clone().release();
pNew->SetFromRangeName( true );
PushTokenArray( pNew, true );
if( pRangeData->HasReferences() )
@@ -4826,7 +4826,7 @@ bool ScCompiler::HandleExternalReference(const FormulaToken& _aToken)
return true;
}
- ScTokenArray* pNew = xNew->Clone();
+ ScTokenArray* pNew = xNew->Clone().release();
PushTokenArray( pNew, true);
if (FormulaTokenArrayPlainIterator(*pNew).GetNextReference() != nullptr)
{
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 750cbdc9cca1..83196eb736d9 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -126,7 +126,7 @@ ScRangeData::ScRangeData( ScDocument* pDok,
ScRangeData::ScRangeData(const ScRangeData& rScRangeData, ScDocument* pDocument, const ScAddress* pPos) :
aName (rScRangeData.aName),
aUpperName (rScRangeData.aUpperName),
- pCode (rScRangeData.pCode ? rScRangeData.pCode->Clone() : new ScTokenArray()), // make real copy (not copy-ctor)
+ pCode (rScRangeData.pCode ? rScRangeData.pCode->Clone().release() : new ScTokenArray()), // make real copy (not copy-ctor)
aPos (pPos ? *pPos : rScRangeData.aPos),
eType (rScRangeData.eType),
pDoc (pDocument ? pDocument : rScRangeData.pDoc),
@@ -154,8 +154,7 @@ void ScRangeData::CompileRangeData( const OUString& rSymbol, bool bSetError )
ScCompiler aComp( pDoc, aPos, eTempGrammar );
if (bSetError)
aComp.SetExtendedErrorDetection( ScCompiler::EXTENDED_ERROR_DETECTION_NAME_NO_BREAK);
- ScTokenArray* pNewCode = aComp.CompileString( rSymbol );
- pCode.reset(pNewCode);
+ pCode = aComp.CompileString( rSymbol );
pCode->SetFromRangeName(true);
if( pCode->GetCodeError() == FormulaError::NONE )
{
diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx
index 6d53cb9fa513..7a917b1e83d5 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -371,7 +371,7 @@ void SharedFormulaUtil::startListeningAsGroup( sc::StartListeningContext& rCxt,
rDoc.SetDetectiveDirty(true);
ScFormulaCellGroupRef xGroup = rTopCell.GetCellGroup();
- const ScTokenArray* pCode = xGroup->mpCode;
+ const ScTokenArray* pCode = xGroup->mpCode.get();
assert(pCode == rTopCell.GetCode());
if (pCode->IsRecalcModeAlways())
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 250500b10693..c1fb5e2e9de6 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1904,9 +1904,9 @@ void ScTokenArray::Clear()
FormulaTokenArray::Clear();
}
-ScTokenArray* ScTokenArray::Clone() const
+std::unique_ptr<ScTokenArray> ScTokenArray::Clone() const
{
- ScTokenArray* p = new ScTokenArray();
+ std::unique_ptr<ScTokenArray> p(new ScTokenArray());
p->nLen = nLen;
p->nRPN = nRPN;
p->nMode = nMode;
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index 3162e5efb3d0..ad1bef84d7f9 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -154,7 +154,7 @@ void ImportExcel::Formula(
if (pResult)
{
- pCell = new ScFormulaCell(&rDoc.getDoc(), aScPos, pResult.release());
+ pCell = new ScFormulaCell(&rDoc.getDoc(), aScPos, std::move(pResult));
pCell->GetCode()->WrapReference(aScPos, EXC_MAXCOL8, EXC_MAXROW8);
rDoc.getDoc().CheckLinkFormulaNeedingCheck( *pCell->GetCode());
rDoc.getDoc().EnsureTable(aScPos.Tab());
diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index 854b503cee64..98d600eacc71 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -363,7 +363,7 @@ void ImportExcel::ReadBoolErr()
double fValue;
std::unique_ptr<ScTokenArray> pScTokArr = ErrorToFormula( nType != EXC_BOOLERR_BOOL, nValue, fValue );
ScFormulaCell* pCell = pScTokArr
- ? new ScFormulaCell(pD, aScPos, pScTokArr.release())
+ ? new ScFormulaCell(pD, aScPos, std::move(pScTokArr))
: new ScFormulaCell(pD, aScPos);
pCell->SetHybridDouble( fValue );
GetDocImport().setFormulaCell(aScPos, pCell);
@@ -844,7 +844,7 @@ void ImportExcel::Shrfmla()
ScDocumentImport& rDoc = GetDocImport();
- ScFormulaCell* pCell = new ScFormulaCell(pD, aPos, pResult.release());
+ ScFormulaCell* pCell = new ScFormulaCell(pD, aPos, std::move(pResult));
pCell->GetCode()->WrapReference(aPos, EXC_MAXCOL8, EXC_MAXROW8);
rDoc.getDoc().CheckLinkFormulaNeedingCheck( *pCell->GetCode());
rDoc.getDoc().EnsureTable(aPos.Tab());
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index 3477419f5b59..5c337fd3ddae 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -594,7 +594,7 @@ void XclExpFmlaCompImpl::Init( XclFormulaType eType, const ScTokenArray& rScTokA
if (mxData->mbOk)
{
// clone the passed token array, convert references relative to current cell position
- mxData->mxOwnScTokArr.reset( rScTokArr.Clone() );
+ mxData->mxOwnScTokArr = rScTokArr.Clone();
ScCompiler::MoveRelWrap( *mxData->mxOwnScTokArr, &GetDocRef(), *pScBasePos, MAXCOL, MAXROW );
// don't remember pScBasePos in mxData->mpScBasePos, shared formulas use real relative refs
}
diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index 1df8ca751fdf..b3448485b0a8 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -119,7 +119,7 @@ void XclImpPCItem::WriteToSource( XclImpRoot& rRoot, const ScAddress& rScPos ) c
std::unique_ptr<ScTokenArray> pScTokArr = rRoot.GetOldFmlaConverter().GetBoolErr(
XclTools::ErrorToEnum( fValue, true, nErrCode ) );
ScFormulaCell* pCell = pScTokArr
- ? new ScFormulaCell(&rDoc.getDoc(), rScPos, pScTokArr.release())
+ ? new ScFormulaCell(&rDoc.getDoc(), rScPos, std::move(pScTokArr))
: new ScFormulaCell(&rDoc.getDoc(), rScPos);
pCell->SetHybridDouble( fValue );
rDoc.setFormulaCell(rScPos, pCell);
diff --git a/sc/source/filter/ftools/sharedformulagroups.cxx b/sc/source/filter/ftools/sharedformulagroups.cxx
index 73d74e9d66a3..6844e9bf3181 100644
--- a/sc/source/filter/ftools/sharedformulagroups.cxx
+++ b/sc/source/filter/ftools/sharedformulagroups.cxx
@@ -13,9 +13,9 @@
namespace sc {
-void SharedFormulaGroups::set( size_t nSharedId, ScTokenArray* pArray )
+void SharedFormulaGroups::set( size_t nSharedId, std::unique_ptr<ScTokenArray> pArray )
{
- m_Store.insert(std::make_pair(nSharedId, std::unique_ptr<ScTokenArray>(pArray)));
+ m_Store.insert(std::make_pair(nSharedId, std::move(pArray)));
}
const ScTokenArray* SharedFormulaGroups::get( size_t nSharedId ) const
diff --git a/sc/source/filter/inc/sharedformulagroups.hxx b/sc/source/filter/inc/sharedformulagroups.hxx
index 547a9610f471..745b5b14bdfa 100644
--- a/sc/source/filter/inc/sharedformulagroups.hxx
+++ b/sc/source/filter/inc/sharedformulagroups.hxx
@@ -23,7 +23,7 @@ private:
StoreType m_Store;
public:
- void set( size_t nSharedId, ScTokenArray* pArray );
+ void set( size_t nSharedId, std::unique_ptr<ScTokenArray> pArray );
const ScTokenArray* get( size_t nSharedId ) const;
};
diff --git a/sc/source/filter/lotus/lotimpop.cxx b/sc/source/filter/lotus/lotimpop.cxx
index 4926d39d1ee7..89885e7678d7 100644
--- a/sc/source/filter/lotus/lotimpop.cxx
+++ b/sc/source/filter/lotus/lotimpop.cxx
@@ -278,7 +278,7 @@ void ImportLotus::Formulacell( sal_uInt16 n )
if (!aConv.good())
return;
- ScFormulaCell* pCell = pErg ? new ScFormulaCell(pD, aAddr, pErg.release()) : new ScFormulaCell(pD, aAddr);
+ ScFormulaCell* pCell = pErg ? new ScFormulaCell(pD, aAddr, std::move(pErg)) : new ScFormulaCell(pD, aAddr);
pCell->AddRecalcMode( ScRecalcMode::ONLOAD_ONCE );
pD->EnsureTable(aAddr.Tab());
pD->SetFormulaCell(aAddr, pCell);
diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx
index 32186e5a4dcd..63a408eb0644 100644
--- a/sc/source/filter/lotus/op.cxx
+++ b/sc/source/filter/lotus/op.cxx
@@ -158,7 +158,7 @@ void OP_Formula(LotusContext &rContext, SvStream& r, sal_uInt16 /*n*/)
if (ValidColRow(nCol, nRow))
{
- ScFormulaCell* pCell = new ScFormulaCell(rContext.pLotusRoot->pDoc, aAddress, pResult.release());
+ ScFormulaCell* pCell = new ScFormulaCell(rContext.pLotusRoot->pDoc, aAddress, std::move(pResult));
pCell->AddRecalcMode( ScRecalcMode::ONLOAD_ONCE );
rContext.pDoc->EnsureTable(0);
rContext.pDoc->SetFormulaCell(ScAddress(nCol, nRow, 0), pCell);
@@ -416,7 +416,7 @@ void OP_Formula123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
if (ValidColRow(nCol, nRow) && nTab <= rContext.pDoc->GetMaxTableNumber())
{
- ScFormulaCell* pCell = new ScFormulaCell(rContext.pLotusRoot->pDoc, aAddress, pResult.release());
+ ScFormulaCell* pCell = new ScFormulaCell(rContext.pLotusRoot->pDoc, aAddress, std::move(pResult));
pCell->AddRecalcMode( ScRecalcMode::ONLOAD_ONCE );
rContext.pDoc->EnsureTable(nTab);
rContext.pDoc->SetFormulaCell(ScAddress(nCol,nRow,nTab), pCell);
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 1ce45b0b7720..ab7aaecc87bd 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -117,11 +117,11 @@ void applySharedFormulas(
ScCompiler aComp(&rDoc.getDoc(), aPos, formula::FormulaGrammar::GRAM_OOXML, true, false);
aComp.SetNumberFormatter(&rFormatter);
- ScTokenArray* pArray = aComp.CompileString(rTokenStr);
+ std::unique_ptr<ScTokenArray> pArray = aComp.CompileString(rTokenStr);
if (pArray)
{
aComp.CompileTokenArray(); // Generate RPN tokens.
- aGroups.set(nId, pArray);
+ aGroups.set(nId, std::move(pArray));
}
}
}
@@ -222,13 +222,13 @@ void applyCellFormulas(
ScCompiler aCompiler(&rDoc.getDoc(), aPos, formula::FormulaGrammar::GRAM_OOXML, true, false);
aCompiler.SetNumberFormatter(&rFormatter);
aCompiler.SetExternalLinks(rExternalLinks);
- ScTokenArray* pCode = aCompiler.CompileString(rItem.maTokenStr);
+ std::unique_ptr<ScTokenArray> pCode = aCompiler.CompileString(rItem.maTokenStr);
if (!pCode)
continue;
aCompiler.CompileTokenArray(); // Generate RPN tokens.
- ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, pCode);
+ ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, std::move(pCode));
rDoc.setFormulaCell(aPos, pCell);
rCache.store(aPos, pCell);
}
diff --git a/sc/source/filter/oox/revisionfragment.cxx b/sc/source/filter/oox/revisionfragment.cxx
index bc1c58d48121..58d27a43f758 100644
--- a/sc/source/filter/oox/revisionfragment.cxx
+++ b/sc/source/filter/oox/revisionfragment.cxx
@@ -29,6 +29,7 @@
#include <formulacell.hxx>
#include <chgviset.hxx>
#include <richstringcontext.hxx>
+#include <tokenarray.hxx>
#include <com/sun/star/util/DateTime.hpp>
@@ -118,11 +119,11 @@ protected:
// formula string
ScDocument& rDoc = getScDocument();
ScCompiler aComp(&rDoc, mrPos, formula::FormulaGrammar::GRAM_OOXML);
- ScTokenArray* pArray = aComp.CompileString(rChars);
+ std::unique_ptr<ScTokenArray> pArray = aComp.CompileString(rChars);
if (!pArray)
break;
- mrCellValue.set(new ScFormulaCell(&rDoc, mrPos, pArray));
+ mrCellValue.set(new ScFormulaCell(&rDoc, mrPos, std::move(pArray)));
}
break;
default:
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index 42bc0a397277..64c05c9442cd 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -1543,9 +1543,9 @@ void WorksheetHelper::putRichString( const ScAddress& rAddress, const RichString
void WorksheetHelper::putFormulaTokens( const ScAddress& rAddress, const ApiTokenSequence& rTokens )
{
ScDocumentImport& rDoc = getDocImport();
- ScTokenArray aTokenArray;
- ScTokenConversion::ConvertToTokenArray(rDoc.getDoc(), aTokenArray, rTokens);
- rDoc.setFormulaCell(rAddress, new ScTokenArray(aTokenArray));
+ std::unique_ptr<ScTokenArray> pTokenArray(new ScTokenArray);
+ ScTokenConversion::ConvertToTokenArray(rDoc.getDoc(), *pTokenArray, rTokens);
+ rDoc.setFormulaCell(rAddress, std::move(pTokenArray));
}
void WorksheetHelper::initializeWorksheetImport()
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index b43abd99e799..e484666ee768 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -973,12 +973,12 @@ void ScOrcusFormula::commit()
// Compile the formula expression into tokens.
ScCompiler aComp(&mrSheet.getDoc().getDoc(), aPos, meGrammar);
- ScTokenArray* pArray = aComp.CompileString(maFormula);
+ std::unique_ptr<ScTokenArray> pArray = aComp.CompileString(maFormula);
if (!pArray)
// Tokenization failed.
return;
- rGroups.set(mnSharedFormulaIndex, pArray);
+ rGroups.set(mnSharedFormulaIndex, std::move(pArray));
}
rFactory.pushSharedFormulaToken(aPos, mnSharedFormulaIndex);
}
diff --git a/sc/source/filter/qpro/qpro.cxx b/sc/source/filter/qpro/qpro.cxx
index c6bca203eb21..27bde38f9d51 100644
--- a/sc/source/filter/qpro/qpro.cxx
+++ b/sc/source/filter/qpro/qpro.cxx
@@ -118,7 +118,7 @@ ErrCode ScQProReader::readSheet( SCTAB nTab, ScDocument* pDoc, ScQProStyle *pSty
eRet = SCERR_IMPORT_FORMAT;
else
{
- ScFormulaCell* pFormula = new ScFormulaCell(pDoc, aAddr, pArray.release());
+ ScFormulaCell* pFormula = new ScFormulaCell(pDoc, aAddr, std::move(pArray));
nStyle = nStyle >> 3;
pFormula->AddRecalcMode( ScRecalcMode::ONLOAD_ONCE );
pStyle->SetFormat( pDoc, nCol, nRow, nTab, nStyle );
diff --git a/sc/source/filter/xcl97/XclImpChangeTrack.cxx b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
index 5ad6ccca9559..d932d27417dc 100644
--- a/sc/source/filter/xcl97/XclImpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
@@ -272,7 +272,7 @@ void XclImpChangeTrack::ReadCell(
if( pStrm->IsValid() && pTokenArray )
{
rCell.meType = CELLTYPE_FORMULA;
- rCell.mpFormula = new ScFormulaCell(&GetDocRef(), rPosition, pTokenArray.release());
+ rCell.mpFormula = new ScFormulaCell(&GetDocRef(), rPosition, std::move(pTokenArray));
}
}
break;
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 0e1bac59a14a..aded39006850 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1366,7 +1366,7 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos )
if ( !aText.isEmpty() )
{
// temporary formula string as string tokens
- ScTokenArray *pCode = new ScTokenArray();
+ std::unique_ptr<ScTokenArray> pCode(new ScTokenArray());
// Check the special case of a single error constant without leading
// '=' and create an error formula cell without tokens.
@@ -1395,7 +1395,7 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos )
}
}
- ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, pCode, eGrammar, ScMatrixMode::NONE);
+ ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, std::move(pCode), eGrammar, ScMatrixMode::NONE);
SetFormulaCell(pNewCell);
rDoc.setFormulaCell(rCellPos, pNewCell);
}
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index 86bc2b7ef53b..cc326dd621e7 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -238,7 +238,7 @@ void SAL_CALL ScXMLConditionalFormatContext::endFastElement( sal_Int32 /*nElemen
bool bEligibleForCache = true;
bool bSingleRelativeReference = false;
ScSingleRefData aOffsetForSingleRelRef;
- const ScTokenArray* pTokens = nullptr;
+ std::unique_ptr<ScTokenArray> pTokens;
for (size_t nFormatEntryIx = 0; nFormatEntryIx < pFormat->size(); ++nFormatEntryIx)
{
auto pFormatEntry = pFormat->GetEntry(nFormatEntryIx);
@@ -259,7 +259,7 @@ void SAL_CALL ScXMLConditionalFormatContext::endFastElement( sal_Int32 /*nElemen
ScCompiler aComp( pDoc, aSrcPos );
aComp.SetGrammar( formula::FormulaGrammar::GRAM_ODFF );
pTokens = aComp.CompileString( pCondFormatEntry->GetExpression(aSrcPos, 0), "" );
- if (HasRelRefIgnoringSheet0Relative( pDoc, pTokens ))
+ if (HasRelRefIgnoringSheet0Relative( pDoc, pTokens.get() ))
{
// In general not eligible, but some might be. We handle one very special case: When the
// conditional format has one entry, the reference position is the first cell of the
@@ -268,7 +268,7 @@ void SAL_CALL ScXMLConditionalFormatContext::endFastElement( sal_Int32 /*nElemen
if (pFormat->size() == 1 &&
pFormat->GetRange().size() == 1 &&
pFormat->GetRange()[0].aStart == aSrcPos &&
- HasOneSingleFullyRelativeReference( pTokens, aOffsetForSingleRelRef ))
+ HasOneSingleFullyRelativeReference( pTokens.get(), aOffsetForSingleRelRef ))
{
bSingleRelativeReference = true;
}
@@ -358,7 +358,7 @@ void SAL_CALL ScXMLConditionalFormatContext::endFastElement( sal_Int32 /*nElemen
}
mrParent.maCache[nIndexOfOldest].mpFormat = pInsertedFormat;
mrParent.maCache[nIndexOfOldest].mbSingleRelativeReference = bSingleRelativeReference;
- mrParent.maCache[nIndexOfOldest].mpTokens.reset(pTokens);
+ mrParent.maCache[nIndexOfOldest].mpTokens = std::move(pTokens);
mrParent.maCache[nIndexOfOldest].mnAge = 0;
}
}
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index f9c24d171cd3..ef9fe0137e6a 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4227,10 +4227,9 @@ bool ScDocFunc::EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark,
else if (bEnglish)
{
ScCompiler aComp( &rDoc, rRange.aStart, eGrammar);
- ScTokenArray* pCode = aComp.CompileString( rString );
+ std::unique_ptr<ScTokenArray> pCode = aComp.CompileString( rString );
rDoc.InsertMatrixFormula( nStartCol, nStartRow, nEndCol, nEndRow,
- aMark, EMPTY_OUSTRING, pCode, eGrammar);
- delete pCode;
+ aMark, EMPTY_OUSTRING, pCode.get(), eGrammar);
}
else
rDoc.InsertMatrixFormula( nStartCol, nStartRow, nEndCol, nEndRow,
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index ddf42b027741..166afb6d6b26 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -123,16 +123,14 @@ void ScNameDefDlg::CancelPushed()
bool ScNameDefDlg::IsFormulaValid()
{
ScCompiler aComp( mpDoc, maCursorPos, mpDoc->GetGrammar());
- ScTokenArray* pCode = aComp.CompileString(m_pEdRange->GetText());
+ std::unique_ptr<ScTokenArray> pCode = aComp.CompileString(m_pEdRange->GetText());
if (pCode->GetCodeError() != FormulaError::NONE)
{
//TODO: info message
- delete pCode;
return false;
}
else
{
- delete pCode;
return true;
}
}
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index ac5afcb728de..65da204874c0 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -294,16 +294,14 @@ bool ScNameDlg::IsNameValid()
bool ScNameDlg::IsFormulaValid()
{
ScCompiler aComp( mpDoc, maCursorPos, mpDoc->GetGrammar());
- ScTokenArray* pCode = aComp.CompileString(m_pEdAssign->GetText());
+ std::unique_ptr<ScTokenArray> pCode = aComp.CompileString(m_pEdAssign->GetText());
if (pCode->GetCodeError() != FormulaError::NONE)
{
m_pFtInfo->SetControlBackground(GetSettings().GetStyleSettings().GetHighlightColor());
- delete pCode;
return false;
}
else
{
- delete pCode;
return true;
}
}
diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx
index 41186b65c4aa..78df3e9d606d 100644
--- a/sc/source/ui/unoobj/tokenuno.cxx
+++ b/sc/source/ui/unoobj/tokenuno.cxx
@@ -139,9 +139,8 @@ uno::Sequence<sheet::FormulaToken> SAL_CALL ScFormulaParserObj::parseFormula(
ScCompiler aCompiler( &rDoc, aRefPos, rDoc.GetGrammar());
SetCompilerFlags( aCompiler );
- ScTokenArray* pCode = aCompiler.CompileString( aFormula );
+ std::unique_ptr<ScTokenArray> pCode = aCompiler.CompileString( aFormula );
ScTokenConversion::ConvertToTokenSequence( rDoc, aRet, *pCode );
- delete pCode;
}
return aRet;
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 45fb81483c4b..c4660d854115 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -416,11 +416,11 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
{
bAgain = false;
bool bAddEqual = false;
- ScTokenArray* pArrFirst = pArr = aComp.CompileString( aFormula );
+ ScTokenArray* pArrFirst = pArr = aComp.CompileString( aFormula ).release();
bool bCorrected = aComp.IsCorrected();
if ( bCorrected )
{ // try to parse with first parser-correction
- pArr = aComp.CompileString( aComp.GetCorrectedFormula() );
+ pArr = aComp.CompileString( aComp.GetCorrectedFormula() ).release();
}
if ( pArr->GetCodeError() == FormulaError::NONE )
{
More information about the Libreoffice-commits
mailing list