diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-10-22 18:58:57 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-10-23 09:30:10 +0200 |
commit | 2e363d1135ede20e2560df4eff27c080bc7e782e (patch) | |
tree | 9d5b9728020c7974adbe5e247d3c12a92dbf58c3 /sc | |
parent | d9a782be7ba158ce21ecce1fe53a7517bb6c5a28 (diff) |
Remove ScToken from the formula::FormulaToken hierarchy
...to keep UBSan from complaining about illegal downcasts from FormulaToken to
ScToken (which were practically harmless, given that ScToken did not add any
data members).
Change-Id: I8fdc026eec363442cc4b720b71d65c972b4a4446
Diffstat (limited to 'sc')
37 files changed, 356 insertions, 419 deletions
diff --git a/sc/inc/formulaiter.hxx b/sc/inc/formulaiter.hxx index ae6880e358bf..75ec9e7d87c9 100644 --- a/sc/inc/formulaiter.hxx +++ b/sc/inc/formulaiter.hxx @@ -24,7 +24,7 @@ class ScTokenArray; class ScFormulaCell; -class ScToken; +namespace formula { class FormulaToken; } /** * Iterator for references in a formula cell. @@ -37,7 +37,7 @@ private: public: ScDetectiveRefIter( ScFormulaCell* pCell ); bool GetNextRef( ScRange& rRange ); - ScToken* GetNextRefToken(); + formula::FormulaToken* GetNextRefToken(); }; #endif diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index b4758502393e..143caf8a9c5d 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -639,7 +639,7 @@ public: static ScUnitConverter* GetUnitConverter(); - /// strchr() functionality on unicode, as long as we need it for ScToken etc. + /// strchr() functionality on unicode, as long as we need it for FormulaToken etc. static const sal_Unicode* UnicodeStrChr( const sal_Unicode* pStr, sal_Unicode c ); static inline sal_Unicode ToUpperAlpha( sal_Unicode c ) diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx index 4176f1ab63ac..77f8a7f40ae2 100644 --- a/sc/inc/token.hxx +++ b/sc/inc/token.hxx @@ -45,25 +45,8 @@ class ScJumpMatrix; typedef ::std::vector< ScComplexRefData > ScRefList; -class SC_DLLPUBLIC ScToken : public formula::FormulaToken -{ -private: - // not implemented, prevent usage - ScToken(); - ScToken& operator=( const ScToken& ); - -protected: - - ScToken( formula::StackVar eTypeP,OpCode e = ocPush ) : formula::FormulaToken(eTypeP,e) {} - ScToken( const ScToken& r ): formula::FormulaToken(r) {} - -public: - - virtual ~ScToken(); -}; - #if DEBUG_FORMULA_COMPILER -void DumpToken(ScToken const & rToken); +void DumpToken(formula::FormulaToken const & rToken); #endif /** If rTok1 and rTok2 both are SingleRef or DoubleRef tokens, extend/merge @@ -80,25 +63,25 @@ void DumpToken(ScToken const & rToken); */ formula::FormulaTokenRef extendRangeReference( formula::FormulaToken & rTok1, formula::FormulaToken & rTok2, const ScAddress & rPos, bool bReuseDoubleRef ); -inline void intrusive_ptr_add_ref(const ScToken* p) +inline void intrusive_ptr_add_ref(const formula::FormulaToken* p) { p->IncRef(); } -inline void intrusive_ptr_release(const ScToken* p) +inline void intrusive_ptr_release(const formula::FormulaToken* p) { p->DecRef(); } -class ScSingleRefToken : public ScToken +class ScSingleRefToken : public formula::FormulaToken { private: ScSingleRefData aSingleRef; public: ScSingleRefToken( const ScSingleRefData& r, OpCode e = ocPush ) : - ScToken( formula::svSingleRef, e ), aSingleRef( r ) {} + FormulaToken( formula::svSingleRef, e ), aSingleRef( r ) {} ScSingleRefToken( const ScSingleRefToken& r ) : - ScToken( r ), aSingleRef( r.aSingleRef ) {} + FormulaToken( r ), aSingleRef( r.aSingleRef ) {} virtual const ScSingleRefData* GetSingleRef() const SAL_OVERRIDE; virtual ScSingleRefData* GetSingleRef() SAL_OVERRIDE; virtual bool TextEqual( const formula::FormulaToken& rToken ) const SAL_OVERRIDE; @@ -108,21 +91,21 @@ public: DECL_FIXEDMEMPOOL_NEWDEL( ScSingleRefToken ); }; -class ScDoubleRefToken : public ScToken +class ScDoubleRefToken : public formula::FormulaToken { private: ScComplexRefData aDoubleRef; public: ScDoubleRefToken( const ScComplexRefData& r, OpCode e = ocPush ) : - ScToken( formula::svDoubleRef, e ), aDoubleRef( r ) {} + FormulaToken( formula::svDoubleRef, e ), aDoubleRef( r ) {} ScDoubleRefToken( const ScSingleRefData& r, OpCode e = ocPush ) : - ScToken( formula::svDoubleRef, e ) + FormulaToken( formula::svDoubleRef, e ) { aDoubleRef.Ref1 = r; aDoubleRef.Ref2 = r; } ScDoubleRefToken( const ScDoubleRefToken& r ) : - ScToken( r ), aDoubleRef( r.aDoubleRef ) {} + FormulaToken( r ), aDoubleRef( r.aDoubleRef ) {} virtual const ScSingleRefData* GetSingleRef() const SAL_OVERRIDE; virtual ScSingleRefData* GetSingleRef() SAL_OVERRIDE; virtual const ScComplexRefData* GetDoubleRef() const SAL_OVERRIDE; @@ -136,7 +119,7 @@ public: DECL_FIXEDMEMPOOL_NEWDEL( ScDoubleRefToken ); }; -class ScMatrixToken : public ScToken +class ScMatrixToken : public formula::FormulaToken { private: ScMatrixRef pMatrix; @@ -155,7 +138,7 @@ public: * both the values in matrix form, and the range address the matrix * represents. */ -class ScMatrixRangeToken : public ScToken +class ScMatrixRangeToken : public formula::FormulaToken { ScMatrixRef mpMatrix; ScComplexRefData maRef; @@ -173,7 +156,7 @@ public: virtual FormulaToken* Clone() const SAL_OVERRIDE; }; -class ScExternalSingleRefToken : public ScToken +class ScExternalSingleRefToken : public formula::FormulaToken { sal_uInt16 mnFileId; svl::SharedString maTabName; @@ -193,7 +176,7 @@ public: virtual FormulaToken* Clone() const SAL_OVERRIDE { return new ScExternalSingleRefToken(*this); } }; -class ScExternalDoubleRefToken : public ScToken +class ScExternalDoubleRefToken : public formula::FormulaToken { sal_uInt16 mnFileId; svl::SharedString maTabName; // name of the first sheet @@ -217,7 +200,7 @@ public: virtual FormulaToken* Clone() const SAL_OVERRIDE { return new ScExternalDoubleRefToken(*this); } }; -class ScExternalNameToken : public ScToken +class ScExternalNameToken : public formula::FormulaToken { sal_uInt16 mnFileId; svl::SharedString maName; @@ -236,15 +219,15 @@ public: // Only created from within the interpreter, no conversion from ScRawToken, // never added to ScTokenArray! -class ScJumpMatrixToken : public ScToken +class ScJumpMatrixToken : public formula::FormulaToken { private: ScJumpMatrix* pJumpMatrix; public: ScJumpMatrixToken( ScJumpMatrix* p ) : - ScToken( formula::svJumpMatrix ), pJumpMatrix( p ) {} + FormulaToken( formula::svJumpMatrix ), pJumpMatrix( p ) {} ScJumpMatrixToken( const ScJumpMatrixToken& r ) : - ScToken( r ), pJumpMatrix( r.pJumpMatrix ) {} + FormulaToken( r ), pJumpMatrix( r.pJumpMatrix ) {} virtual ~ScJumpMatrixToken(); virtual ScJumpMatrix* GetJumpMatrix() const SAL_OVERRIDE; virtual bool operator==( const formula::FormulaToken& rToken ) const SAL_OVERRIDE; @@ -253,32 +236,32 @@ public: // Only created from within the interpreter, no conversion from ScRawToken, // never added to ScTokenArray! -class ScRefListToken : public ScToken +class ScRefListToken : public formula::FormulaToken { private: ScRefList aRefList; public: ScRefListToken() : - ScToken( formula::svRefList ) {} + FormulaToken( formula::svRefList ) {} ScRefListToken( const ScRefListToken & r ) : - ScToken( r ), aRefList( r.aRefList ) {} + FormulaToken( r ), aRefList( r.aRefList ) {} virtual const ScRefList* GetRefList() const SAL_OVERRIDE; virtual ScRefList* GetRefList() SAL_OVERRIDE; virtual bool operator==( const formula::FormulaToken& rToken ) const SAL_OVERRIDE; virtual FormulaToken* Clone() const SAL_OVERRIDE { return new ScRefListToken(*this); } }; -class SC_DLLPUBLIC ScEmptyCellToken : public ScToken +class SC_DLLPUBLIC ScEmptyCellToken : public formula::FormulaToken { bool bInherited :1; bool bDisplayedAsString :1; public: explicit ScEmptyCellToken( bool bInheritedP, bool bDisplayAsString ) : - ScToken( formula::svEmptyCell ), + FormulaToken( formula::svEmptyCell ), bInherited( bInheritedP ), bDisplayedAsString( bDisplayAsString ) {} ScEmptyCellToken( const ScEmptyCellToken& r ) : - ScToken( r ), + FormulaToken( r ), bInherited( r.bInherited ), bDisplayedAsString( r.bDisplayedAsString ) {} bool IsInherited() const { return bInherited; } @@ -290,10 +273,10 @@ public: }; /** Transports the result from the interpreter to the formula cell. */ -class SC_DLLPUBLIC ScMatrixCellResultToken : public ScToken +class SC_DLLPUBLIC ScMatrixCellResultToken : public formula::FormulaToken { // No non-const access implemented, silence down unxsols4 complaining about - // the public GetMatrix() hiding the one from ScToken. + // the public GetMatrix() hiding the one from FormulaToken. virtual ScMatrix* GetMatrix() SAL_OVERRIDE; protected: @@ -366,7 +349,7 @@ public: void ResetResult(); }; -class SC_DLLPUBLIC ScHybridCellToken : public ScToken +class SC_DLLPUBLIC ScHybridCellToken : public formula::FormulaToken { private: double mfDouble; @@ -397,7 +380,7 @@ class SingleDoubleRefModifier SingleDoubleRefModifier& operator=( const SingleDoubleRefModifier& ); public: - SingleDoubleRefModifier( ScToken& rT ) + SingleDoubleRefModifier( formula::FormulaToken& rT ) { formula::StackVar eType = rT.GetType(); if ( eType == formula::svSingleRef || eType == formula::svExternalSingleRef ) @@ -433,7 +416,7 @@ public: const ScSingleRefData& Ref1; const ScSingleRefData& Ref2; - SingleDoubleRefProvider( const ScToken& r ) + SingleDoubleRefProvider( const formula::FormulaToken& r ) : Ref1( *r.GetSingleRef() ), Ref2( (r.GetType() == formula::svDoubleRef || r.GetType() == formula::svExternalDoubleRef) ? diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx index 97623647f9d2..84f43128516f 100644 --- a/sc/inc/tokenarray.hxx +++ b/sc/inc/tokenarray.hxx @@ -54,7 +54,7 @@ class SC_DLLPUBLIC ScTokenArray : public formula::FormulaTokenArray public: ScTokenArray(); - /// Assignment with references to ScToken entries (not copied!) + /// Assignment with references to FormulaToken entries (not copied!) ScTokenArray( const ScTokenArray& ); virtual ~ScTokenArray(); ScTokenArray* Clone() const; /// True copy! @@ -112,7 +112,7 @@ public: /// Assign XML string placeholder to the array void AssignXMLString( const OUString &rText, const OUString &rFormulaNmsp ); - /// Assignment with references to ScToken entries (not copied!) + /// Assignment with references to FormulaToken entries (not copied!) ScTokenArray& operator=( const ScTokenArray& ); /// Make 3D references point to old referenced position even if relative diff --git a/sc/inc/types.hxx b/sc/inc/types.hxx index d40b2a5e110e..e483b1eff98e 100644 --- a/sc/inc/types.hxx +++ b/sc/inc/types.hxx @@ -32,8 +32,8 @@ typedef sal_Int32 SCsCOLROW; typedef ::boost::intrusive_ptr<ScMatrix> ScMatrixRef; typedef ::boost::intrusive_ptr<const ScMatrix> ScConstMatrixRef; -class ScToken; -typedef ::boost::intrusive_ptr<ScToken> ScTokenRef; +namespace formula { class FormulaToken; } +typedef ::boost::intrusive_ptr<formula::FormulaToken> ScTokenRef; typedef sal_uInt8 ScMatValType; const ScMatValType SC_MATVAL_VALUE = 0x00; diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 7258326a7375..0c081c13dc69 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1242,7 +1242,7 @@ bool broadcasterShifted(const ScDocument& rDoc, const ScAddress& rFrom, const Sc return true; } -ScToken* getSingleRefToken(ScDocument& rDoc, const ScAddress& rPos) +formula::FormulaToken* getSingleRefToken(ScDocument& rDoc, const ScAddress& rPos) { ScFormulaCell* pFC = rDoc.GetFormulaCell(rPos); if (!pFC) @@ -1258,7 +1258,7 @@ ScToken* getSingleRefToken(ScDocument& rDoc, const ScAddress& rPos) return NULL; } - ScToken* pToken = static_cast<ScToken*>(pTokens->First()); + formula::FormulaToken* pToken = pTokens->First(); if (!pToken || pToken->GetType() != formula::svSingleRef) { cerr << "Not a single reference token." << endl; @@ -1270,7 +1270,7 @@ ScToken* getSingleRefToken(ScDocument& rDoc, const ScAddress& rPos) bool checkRelativeRefToken(ScDocument& rDoc, const ScAddress& rPos, SCsCOL nRelCol, SCsROW nRelRow) { - ScToken* pToken = getSingleRefToken(rDoc, rPos); + formula::FormulaToken* pToken = getSingleRefToken(rDoc, rPos); if (!pToken) return false; @@ -1292,7 +1292,7 @@ bool checkRelativeRefToken(ScDocument& rDoc, const ScAddress& rPos, SCsCOL nRelC bool checkDeletedRefToken(ScDocument& rDoc, const ScAddress& rPos) { - ScToken* pToken = getSingleRefToken(rDoc, rPos); + formula::FormulaToken* pToken = getSingleRefToken(rDoc, rPos); if (!pToken) return false; diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index e4e1a12d9b69..16d55771f9d7 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -874,7 +874,7 @@ void Test::testSharedFormulasDeleteColumns() CPPUNIT_ASSERT(pCode && pCode->GetLen() == 1); const FormulaToken* pToken = pCode->GetArray()[0]; CPPUNIT_ASSERT(pToken->GetType() == svSingleRef); - const ScSingleRefData* pSRef = static_cast<const ScToken*>(pToken)->GetSingleRef(); + const ScSingleRefData* pSRef = pToken->GetSingleRef(); CPPUNIT_ASSERT(pSRef->IsColDeleted()); CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pSRef->toAbs(ScAddress(1,0,0)).Row()); diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 809c186717d0..b915e25b13af 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -48,8 +48,8 @@ ScFormulaListener::ScFormulaListener(ScFormulaCell* pCell): void ScFormulaListener::startListening(ScTokenArray* pArr, const ScAddress& rPos) { pArr->Reset(); - ScToken* t; - while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL ) + formula::FormulaToken* t; + while ( ( t = pArr->GetNextReferenceRPN() ) != NULL ) { switch (t->GetType()) { diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index f9a979606b15..0cfbaa12edc7 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -89,7 +89,7 @@ static bool lcl_HasRelRef( ScDocument* pDoc, ScTokenArray* pFormula, sal_uInt16 { case svDoubleRef: { - ScSingleRefData& rRef2 = static_cast<ScToken*>(t)->GetDoubleRef()->Ref2; + ScSingleRefData& rRef2 = t->GetDoubleRef()->Ref2; if ( rRef2.IsColRel() || rRef2.IsRowRel() || rRef2.IsTabRel() ) return true; } @@ -97,7 +97,7 @@ static bool lcl_HasRelRef( ScDocument* pDoc, ScTokenArray* pFormula, sal_uInt16 case svSingleRef: { - ScSingleRefData& rRef1 = *static_cast<ScToken*>(t)->GetSingleRef(); + ScSingleRefData& rRef1 = *t->GetSingleRef(); if ( rRef1.IsColRel() || rRef1.IsRowRel() || rRef1.IsTabRel() ) return true; } @@ -1359,8 +1359,8 @@ void ScConditionEntry::SourceChanged( const ScAddress& rChanged ) if (pFormula) { pFormula->Reset(); - ScToken* t; - while ( ( t = static_cast<ScToken*>(pFormula->GetNextReference()) ) != NULL ) + formula::FormulaToken* t; + while ( ( t = pFormula->GetNextReference() ) != NULL ) { SingleDoubleRefProvider aProv( *t ); if ( aProv.Ref1.IsColRel() || aProv.Ref1.IsRowRel() || aProv.Ref1.IsTabRel() || @@ -1449,8 +1449,8 @@ ScAddress ScConditionEntry::GetValidSrcPos() const if (pFormula) { pFormula->Reset(); - ScToken* t; - while ( ( t = static_cast<ScToken*>(pFormula->GetNextReference()) ) != NULL ) + formula::FormulaToken* t; + while ( ( t = pFormula->GetNextReference() ) != NULL ) { ScSingleRefData& rRef1 = *t->GetSingleRef(); ScAddress aAbs = rRef1.toAbs(aSrcPos); diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 14493e9887fd..4b36b65f939f 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -307,7 +307,7 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1, aRefData.SetAddress(aBasePos, aBasePos); ScTokenArray aArr; // consists only of one single reference token. - ScToken* t = static_cast<ScToken*>(aArr.AddMatrixSingleReference( aRefData)); + formula::FormulaToken* t = aArr.AddMatrixSingleReference( aRefData); itr = rMark.begin(); for (; itr != itrEnd && *itr < nMax; ++itr) @@ -438,7 +438,7 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera namespace { -bool setCacheTableReferenced(ScToken& rToken, ScExternalRefManager& rRefMgr, const ScAddress& rPos) +bool setCacheTableReferenced(formula::FormulaToken& rToken, ScExternalRefManager& rRefMgr, const ScAddress& rPos) { switch (rToken.GetType()) { @@ -473,9 +473,9 @@ bool ScDocument::MarkUsedExternalReferences( ScTokenArray& rArr, const ScAddress ScExternalRefManager* pRefMgr = NULL; rArr.Reset(); - ScToken* t = NULL; + formula::FormulaToken* t = NULL; bool bAllMarked = false; - while (!bAllMarked && (t = static_cast<ScToken*>(rArr.GetNextReferenceOrName())) != NULL) + while (!bAllMarked && (t = rArr.GetNextReferenceOrName()) != NULL) { if (t->IsExternalRef()) { @@ -493,7 +493,7 @@ bool ScDocument::MarkUsedExternalReferences( ScTokenArray& rArr, const ScAddress continue; ScTokenArray* pArray = pRangeData->GetCode(); - for (t = static_cast<ScToken*>(pArray->First()); t; t = static_cast<ScToken*>(pArray->Next())) + for (t = pArray->First(); t; t = pArray->Next()) { if (!t->IsExternalRef()) continue; diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx index a336e71f711e..ed46752bdfa1 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -322,7 +322,7 @@ void ScDocumentImport::setMatrixCells( aRefData.SetAddress(rBasePos, rBasePos); ScTokenArray aArr; // consists only of one single reference token. - ScToken* t = static_cast<ScToken*>(aArr.AddMatrixSingleReference(aRefData)); + formula::FormulaToken* t = aArr.AddMatrixSingleReference(aRefData); ScAddress aPos = rBasePos; for (SCROW nRow = rRange.aStart.Row()+1; nRow <= rRange.aEnd.Row(); ++nRow) diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index f1fea0e5e194..6e4492348c68 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -134,11 +134,11 @@ lcl_checkRangeDimensions( static bool lcl_checkRangeDimensions( const ScAddress& rPos, - const deque<ScToken*>::const_iterator aBegin, - const deque<ScToken*>::const_iterator aEnd, + const deque<formula::FormulaToken*>::const_iterator aBegin, + const deque<formula::FormulaToken*>::const_iterator aEnd, bool& bCol, bool& bRow, bool& bTab) { - deque<ScToken*>::const_iterator aCur(aBegin); + deque<formula::FormulaToken*>::const_iterator aCur(aBegin); ++aCur; const SingleDoubleRefProvider aRef(**aBegin); bool bOk(false); @@ -164,7 +164,7 @@ lcl_checkRangeDimensions( return false; } -class LessByReference : std::binary_function<const ScToken*, const ScToken*, bool> +class LessByReference : std::binary_function<const formula::FormulaToken*, const formula::FormulaToken*, bool> { ScAddress maPos; DimensionSelector maFunc; @@ -172,7 +172,7 @@ public: LessByReference(const ScAddress& rPos, const DimensionSelector& rFunc) : maPos(rPos), maFunc(rFunc) {} - bool operator() (const ScToken* pRef1, const ScToken* pRef2) + bool operator() (const formula::FormulaToken* pRef1, const formula::FormulaToken* pRef2) { const SingleDoubleRefProvider aRef1(*pRef1); const SingleDoubleRefProvider aRef2(*pRef2); @@ -185,7 +185,7 @@ public: * denoted by token p1. Dimension, in which the comparison takes place, is * given by maFunc. */ -class AdjacentByReference : std::binary_function<const ScToken*, const ScToken*, bool> +class AdjacentByReference : std::binary_function<const formula::FormulaToken*, const formula::FormulaToken*, bool> { ScAddress maPos; DimensionSelector maFunc; @@ -193,7 +193,7 @@ public: AdjacentByReference(const ScAddress& rPos, DimensionSelector aFunc) : maPos(rPos), maFunc(aFunc) {} - bool operator() (const ScToken* p1, const ScToken* p2) + bool operator() (const formula::FormulaToken* p1, const formula::FormulaToken* p2) { const SingleDoubleRefProvider aRef1(*p1); const SingleDoubleRefProvider aRef2(*p2); @@ -203,9 +203,9 @@ public: static bool lcl_checkIfAdjacent( - const ScAddress& rPos, const deque<ScToken*>& rReferences, const DimensionSelector aWhich) + const ScAddress& rPos, const deque<formula::FormulaToken*>& rReferences, const DimensionSelector aWhich) { - typedef deque<ScToken*>::const_iterator Iter; + typedef deque<formula::FormulaToken*>::const_iterator Iter; Iter aBegin(rReferences.begin()); Iter aEnd(rReferences.end()); Iter aBegin1(aBegin); @@ -215,7 +215,7 @@ lcl_checkIfAdjacent( static void lcl_fillRangeFromRefList( - const ScAddress& aPos, const deque<ScToken*>& rReferences, ScRange& rRange) + const ScAddress& aPos, const deque<formula::FormulaToken*>& rReferences, ScRange& rRange) { const ScSingleRefData aStart( SingleDoubleRefProvider(*rReferences.front()).Ref1); @@ -227,7 +227,7 @@ lcl_fillRangeFromRefList( static bool lcl_refListFormsOneRange( - const ScAddress& rPos, deque<ScToken*>& rReferences, + const ScAddress& rPos, deque<formula::FormulaToken*>& rReferences, ScRange& rRange) { if (rReferences.size() == 1) @@ -278,7 +278,7 @@ bool lcl_isReference(const FormulaToken& rToken) rToken.GetType() == svDoubleRef; } -void adjustRangeName(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldDoc, const ScAddress& aNewPos, const ScAddress& aOldPos) +void adjustRangeName(formula::FormulaToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldDoc, const ScAddress& aNewPos, const ScAddress& aOldPos) { bool bOldGlobal = pToken->IsGlobal(); SCTAB aOldTab = aOldPos.Tab(); @@ -352,7 +352,7 @@ void adjustRangeName(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOl pToken->SetGlobal(bNewGlobal); } -void adjustDBRange(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldDoc) +void adjustDBRange(formula::FormulaToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldDoc) { ScDBCollection* pOldDBCollection = pOldDoc->GetDBCollection(); if (!pOldDBCollection) @@ -736,8 +736,8 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, cons { if (!pDocument->IsClipboardSource() || aPos.Tab() != rCell.aPos.Tab()) { - ScToken* pToken = NULL; - while((pToken = static_cast<ScToken*>(pCode->GetNextName()))!= NULL) + formula::FormulaToken* pToken = NULL; + while((pToken = pCode->GetNextName())!= NULL) { OpCode eOpCode = pToken->GetOpCode(); if (eOpCode == ocName) @@ -762,8 +762,8 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, cons if( !bCompile ) { // Name references with references and ColRowNames pCode->Reset(); - ScToken* t; - while ( ( t = static_cast<ScToken*>(pCode->GetNextReferenceOrName()) ) != NULL && !bCompile ) + formula::FormulaToken* t; + while ( ( t = pCode->GetNextReferenceOrName() ) != NULL && !bCompile ) { if ( t->IsExternalRef() ) { @@ -858,7 +858,7 @@ void ScFormulaCell::GetFormula( OUStringBuffer& rBuffer, { // Reference to another cell that contains a matrix formula. pCode->Reset(); - ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); + formula::FormulaToken* p = pCode->GetNextReferenceRPN(); if( p ) { /* FIXME: original GetFormula() code obtained @@ -922,7 +922,7 @@ OUString ScFormulaCell::GetFormula( sc::CompileFormulaContext& rCxt ) const { // Reference to another cell that contains a matrix formula. pCode->Reset(); - ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); + formula::FormulaToken* p = pCode->GetNextReferenceRPN(); if( p ) { /* FIXME: original GetFormula() code obtained @@ -972,7 +972,7 @@ void ScFormulaCell::GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows ) const ScMatrix* pMat = NULL; if (!pCode->GetCodeError() && aResult.GetType() == svMatrixCell && - ((pMat = static_cast<const ScToken*>(aResult.GetToken().get())->GetMatrix()) != 0)) + ((pMat = aResult.GetToken().get()->GetMatrix()) != 0)) pMat->GetDimensions( rCols, rRows ); else { @@ -2334,7 +2334,7 @@ bool ScFormulaCell::GetMatrixOrigin( ScAddress& rPos ) const case MM_REFERENCE : { pCode->Reset(); - ScToken* t = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); + formula::FormulaToken* t = pCode->GetNextReferenceRPN(); if( t ) { ScSingleRefData& rRef = *t->GetSingleRef(); @@ -2542,7 +2542,7 @@ sc::FormulaResultValue ScFormulaCell::GetResult() const bool ScFormulaCell::HasOneReference( ScRange& r ) const { pCode->Reset(); - ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); + formula::FormulaToken* p = pCode->GetNextReferenceRPN(); if( p && !pCode->GetNextReferenceRPN() ) // only one! { SingleDoubleRefProvider aProv( *p ); @@ -2573,13 +2573,12 @@ ScFormulaCell::HasRefListExpressibleAsOneReference(ScRange& rRange) const pCode->Reset(); // Get first reference, if any - ScToken* const pFirstReference( - dynamic_cast<ScToken*>(pCode->GetNextReferenceRPN())); + formula::FormulaToken* const pFirstReference(pCode->GetNextReferenceRPN()); if (pFirstReference) { // Collect all consecutive references, starting by the one // already found - std::deque<ScToken*> aReferences; + std::deque<formula::FormulaToken*> aReferences; aReferences.push_back(pFirstReference); FormulaToken* pToken(pCode->NextRPN()); FormulaToken* pFunction(0); @@ -2587,7 +2586,7 @@ ScFormulaCell::HasRefListExpressibleAsOneReference(ScRange& rRange) const { if (lcl_isReference(*pToken)) { - aReferences.push_back(dynamic_cast<ScToken*>(pToken)); + aReferences.push_back(pToken); pToken = pCode->NextRPN(); } else @@ -2611,8 +2610,8 @@ ScFormulaCell::HasRefListExpressibleAsOneReference(ScRange& rRange) const bool ScFormulaCell::HasRelNameReference() const { pCode->Reset(); - ScToken* t; - while ( ( t = static_cast<ScToken*>(pCode->GetNextReferenceRPN()) ) != NULL ) + formula::FormulaToken* t; + while ( ( t = pCode->GetNextReferenceRPN() ) != NULL ) { if ( t->GetSingleRef()->IsRelName() || (t->GetType() == formula::svDoubleRef && @@ -2658,11 +2657,11 @@ bool checkCompileColRowName( if (rCxt.mnColDelta <= 0 && rCxt.mnRowDelta <= 0) return false; - ScToken* t; + formula::FormulaToken* t; ScRangePairList* pColList = rDoc.GetColNameRanges(); ScRangePairList* pRowList = rDoc.GetRowNameRanges(); rCode.Reset(); - while ((t = static_cast<ScToken*>(rCode.GetNextColRowName())) != NULL) + while ((t = rCode.GetNextColRowName()) != NULL) { ScSingleRefData& rRef = *t->GetSingleRef(); if (rCxt.mnRowDelta > 0 && rRef.IsColRel()) @@ -2706,8 +2705,8 @@ bool checkCompileColRowName( return true; rCode.Reset(); - const ScToken* t = static_cast<const ScToken*>(rCode.GetNextColRowName()); - for (; t; t = static_cast<const ScToken*>(rCode.GetNextColRowName())) + const formula::FormulaToken* t = rCode.GetNextColRowName(); + for (; t; t = rCode.GetNextColRowName()) { const ScSingleRefData& rRef = *t->GetSingleRef(); ScAddress aAbs = rRef.toAbs(aPos); @@ -3192,7 +3191,7 @@ void ScFormulaCell::UpdateInsertTabAbs(SCTAB nTable) return; pCode->Reset(); - ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); + formula::FormulaToken* p = pCode->GetNextReferenceRPN(); while (p) { ScSingleRefData& rRef1 = *p->GetSingleRef(); @@ -3204,7 +3203,7 @@ void ScFormulaCell::UpdateInsertTabAbs(SCTAB nTable) if (!rRef2.IsTabRel() && nTable <= rRef2.Tab()) rRef2.IncTab(1); } - p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); + p = pCode->GetNextReferenceRPN(); } } @@ -3219,7 +3218,7 @@ bool ScFormulaCell::TestTabRefAbs(SCTAB nTable) bool bRet = false; pCode->Reset(); - ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); + formula::FormulaToken* p = pCode->GetNextReferenceRPN(); while (p) { ScSingleRefData& rRef1 = *p->GetSingleRef(); @@ -3241,7 +3240,7 @@ bool ScFormulaCell::TestTabRefAbs(SCTAB nTable) rRef2.SetAbsTab(aPos.Tab()); } } - p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); + p = pCode->GetNextReferenceRPN(); } return bRet; } @@ -3260,8 +3259,8 @@ void ScFormulaCell::TransposeReference() { bool bFound = false; pCode->Reset(); - ScToken* t; - while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) + formula::FormulaToken* t; + while ( ( t = pCode->GetNextReference() ) != NULL ) { ScSingleRefData& rRef1 = *t->GetSingleRef(); if ( rRef1.IsColRel() && rRef1.IsRowRel() ) @@ -3317,10 +3316,10 @@ void ScFormulaCell::UpdateTranspose( const ScRange& rSource, const ScAddress& rD ScTokenArray* pOld = pUndoDoc ? pCode->Clone() : NULL; bool bRefChanged = false; - ScToken* t; + formula::FormulaToken* t; pCode->Reset(); - while( (t = static_cast<ScToken*>(pCode->GetNextReferenceOrName())) != NULL ) + while( (t = pCode->GetNextReferenceOrName()) != NULL ) { if( t->GetOpCode() == ocName ) { @@ -3371,10 +3370,10 @@ void ScFormulaCell::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY EndListeningTo( pDocument ); bool bRefChanged = false; - ScToken* t; + formula::FormulaToken* t; pCode->Reset(); - while( (t = static_cast<ScToken*>(pCode->GetNextReferenceOrName())) != NULL ) + while( (t = pCode->GetNextReferenceOrName()) != NULL ) { if( t->GetOpCode() == ocName ) { @@ -3554,8 +3553,8 @@ ScFormulaCell::CompareState ScFormulaCell::CompareByTokenArray( ScFormulaCell& r // check we are basically the same function for ( sal_uInt16 i = 0; i < nThisLen; i++ ) { - ScToken *pThisTok = static_cast<ScToken*>( pThis[i] ); - ScToken *pOtherTok = static_cast<ScToken*>( pOther[i] ); + formula::FormulaToken *pThisTok = pThis[i]; + formula::FormulaToken *pOtherTok = pOther[i]; if ( pThisTok->GetType() != pOtherTok->GetType() || pThisTok->GetOpCode() != pOtherTok->GetOpCode() || @@ -3708,12 +3707,11 @@ bool ScFormulaCell::InterpretInvariantFormulaGroup() pCode->Reset(); for (const formula::FormulaToken* p = pCode->First(); p; p = pCode->Next()) { - const ScToken* pToken = static_cast<const ScToken*>(p); - switch (pToken->GetType()) + switch (p->GetType()) { case svSingleRef: { - ScSingleRefData aRef = *pToken->GetSingleRef(); + ScSingleRefData aRef = *p->GetSingleRef(); ScAddress aRefPos = aRef.toAbs(aPos); formula::FormulaTokenRef pNewToken = pDocument->ResolveStaticReference(aRefPos); if (!pNewToken) @@ -3724,7 +3722,7 @@ bool ScFormulaCell::InterpretInvariantFormulaGroup() break; case svDoubleRef: { - ScComplexRefData aRef = *pToken->GetDoubleRef(); + ScComplexRefData aRef = *p->GetDoubleRef(); ScRange aRefRange = aRef.toAbs(aPos); formula::FormulaTokenRef pNewToken = pDocument->ResolveStaticReference(aRefRange); if (!pNewToken) @@ -3734,7 +3732,7 @@ bool ScFormulaCell::InterpretInvariantFormulaGroup() } break; default: - aCode.AddToken(*pToken); + aCode.AddToken(*p); } } @@ -3776,7 +3774,7 @@ bool ScFormulaCell::InterpretInvariantFormulaGroup() namespace { void startListeningArea( - ScFormulaCell* pCell, ScDocument& rDoc, const ScAddress& rPos, const ScToken& rToken) + ScFormulaCell* pCell, ScDocument& rDoc, const ScAddress& rPos, const formula::FormulaToken& rToken) { const ScSingleRefData& rRef1 = *rToken.GetSingleRef(); const ScSingleRefData& rRef2 = *rToken.GetSingleRef2(); @@ -3815,8 +3813,8 @@ void ScFormulaCell::StartListeningTo( ScDocument* pDoc ) } pArr->Reset(); - ScToken* t; - while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL ) + formula::FormulaToken* t; + while ( ( t = pArr->GetNextReferenceRPN() ) != NULL ) { switch (t->GetType()) { @@ -3853,8 +3851,8 @@ void ScFormulaCell::StartListeningTo( sc::StartListeningContext& rCxt ) } pArr->Reset(); - ScToken* t; - while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL ) + formula::FormulaToken* t; + while ( ( t = pArr->GetNextReferenceRPN() ) != NULL ) { switch (t->GetType()) { @@ -3878,7 +3876,7 @@ void ScFormulaCell::StartListeningTo( sc::StartListeningContext& rCxt ) namespace { void endListeningArea( - ScFormulaCell* pCell, ScDocument& rDoc, const ScAddress& rPos, const ScToken& rToken) + ScFormulaCell* pCell, ScDocument& rDoc, const ScAddress& rPos, const formula::FormulaToken& rToken) { const ScSingleRefData& rRef1 = *rToken.GetSingleRef(); const ScSingleRefData& rRef2 = *rToken.GetSingleRef2(); @@ -3923,8 +3921,8 @@ void ScFormulaCell::EndListeningTo( ScDocument* pDoc, ScTokenArray* pArr, aCellPos = aPos; } pArr->Reset(); - ScToken* t; - while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL ) + formula::FormulaToken* t; + while ( ( t = pArr->GetNextReferenceRPN() ) != NULL ) { switch (t->GetType()) { @@ -3963,8 +3961,8 @@ void ScFormulaCell::EndListeningTo( sc::EndListeningContext& rCxt ) } pArr->Reset(); - ScToken* t; - while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL ) + formula::FormulaToken* t; + while ( ( t = pArr->GetNextReferenceRPN() ) != NULL ) { switch (t->GetType()) { diff --git a/sc/source/core/data/formulaiter.cxx b/sc/source/core/data/formulaiter.cxx index e5454931872a..e17da0769f54 100644 --- a/sc/source/core/data/formulaiter.cxx +++ b/sc/source/core/data/formulaiter.cxx @@ -32,7 +32,7 @@ ScDetectiveRefIter::ScDetectiveRefIter( ScFormulaCell* pCell ) aPos = pCell->aPos; } -static bool lcl_ScDetectiveRefIter_SkipRef( ScToken* p, const ScAddress& rPos ) +static bool lcl_ScDetectiveRefIter_SkipRef( formula::FormulaToken* p, const ScAddress& rPos ) { ScSingleRefData& rRef1 = *p->GetSingleRef(); ScAddress aAbs1 = rRef1.toAbs(rPos); @@ -51,7 +51,7 @@ static bool lcl_ScDetectiveRefIter_SkipRef( ScToken* p, const ScAddress& rPos ) bool ScDetectiveRefIter::GetNextRef( ScRange& rRange ) { bool bRet = false; - ScToken* p = GetNextRefToken(); + formula::FormulaToken* p = GetNextRefToken(); if( p ) { SingleDoubleRefProvider aProv( *p ); @@ -63,12 +63,12 @@ bool ScDetectiveRefIter::GetNextRef( ScRange& rRange ) return bRet; } -ScToken* ScDetectiveRefIter::GetNextRefToken() +formula::FormulaToken* ScDetectiveRefIter::GetNextRefToken() { - ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); + formula::FormulaToken* p = pCode->GetNextReferenceRPN(); while (p && lcl_ScDetectiveRefIter_SkipRef(p, aPos)) { - p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); + p = pCode->GetNextReferenceRPN(); } return p; } diff --git a/sc/source/core/data/grouptokenconverter.cxx b/sc/source/core/data/grouptokenconverter.cxx index 06eb18a33453..bfb6de359c54 100644 --- a/sc/source/core/data/grouptokenconverter.cxx +++ b/sc/source/core/data/grouptokenconverter.cxx @@ -96,13 +96,12 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode) // vector reference token. Note: we only care about relative vs // absolute reference state for row directions. - const ScToken* pToken = static_cast<const ScToken*>(p); SCROW nLen = mrCell.GetCellGroup()->mnLength; - switch (pToken->GetType()) + switch (p->GetType()) { case svSingleRef: { - ScSingleRefData aRef = *pToken->GetSingleRef(); + ScSingleRefData aRef = *p->GetSingleRef(); ScAddress aRefPos = aRef.toAbs(mrPos); if (aRef.IsRowRel()) { @@ -141,7 +140,7 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode) break; case svDoubleRef: { - ScComplexRefData aRef = *pToken->GetDoubleRef(); + ScComplexRefData aRef = *p->GetDoubleRef(); ScRange aAbs = aRef.toAbs(mrPos); // Check for self reference. @@ -228,7 +227,7 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode) } break; default: - mrGroupTokens.AddToken(*pToken); + mrGroupTokens.AddToken(*p); } } diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index b760be31fe0c..96798f0c07c5 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -682,8 +682,8 @@ bool ScValidationData::GetSelectionFromFormula( ScTokenArray* pArr = (ScTokenArray*) &rTokArr; pArr->Reset(); - ScToken* t = NULL; - if (pArr->GetLen() == 1 && (t = static_cast<ScToken*>(pArr->GetNextReferenceOrName())) != NULL) + formula::FormulaToken* t = NULL; + if (pArr->GetLen() == 1 && (t = pArr->GetNextReferenceOrName()) != NULL) { if (t->GetOpCode() == ocDBArea) { diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index dc7de338040e..ed6c171e3362 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -46,7 +46,7 @@ struct ScQueryEntry; struct ScSingleRefData; struct ScComplexRefData; -class ScToken; +namespace formula { class FormulaToken; } class ScJumpMatrix; struct ScRefCellValue; @@ -156,7 +156,7 @@ private: svl::SharedStringPool& mrStrPool; formula::FormulaTokenRef xResult; ScJumpMatrix* pJumpMatrix; // currently active array condition, if any - ScTokenMatrixMap* pTokenMatrixMap; // map ScToken* to formula::FormulaTokenRef if in array condition + ScTokenMatrixMap* pTokenMatrixMap; // map FormulaToken* to formula::FormulaTokenRef if in array condition ScFormulaCell* pMyFormulaCell; // the cell of this formula expression SvNumberFormatter* pFormatter; @@ -289,7 +289,7 @@ void DoubleRefToRange( const ScComplexRefData&, ScRange&, bool bDontCheckForTabl */ void PopDoubleRef( ScRange & rRange, short & rParam, size_t & rRefInList ); void PopDoubleRef( ScRange&, bool bDontCheckForTableOp = false ); -void DoubleRefToVars( const ScToken* p, +void DoubleRefToVars( const formula::FormulaToken* p, SCCOL& rCol1, SCROW &rRow1, SCTAB& rTab1, SCCOL& rCol2, SCROW &rRow2, SCTAB& rTab2, bool bDontCheckForTableOp = false ); diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index 6b62040b6241..f078fa2a341b 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -1881,7 +1881,7 @@ void ScChangeActionContent::PutValueToDoc( } } -static void lcl_InvalidateReference( ScToken& rTok, const ScBigAddress& rPos ) +static void lcl_InvalidateReference( formula::FormulaToken& rTok, const ScBigAddress& rPos ) { ScSingleRefData& rRef1 = *rTok.GetSingleRef(); if ( rPos.Col() < 0 || MAXCOL < rPos.Col() ) @@ -2015,24 +2015,24 @@ void ScChangeActionContent::UpdateReference( const ScChangeTrack* pTrack, const ScBigAddress& rPos = aBigRange.aStart; if ( bOldFormula ) { - ScToken* t; + formula::FormulaToken* t; ScTokenArray* pArr = maOldCell.mpFormula->GetCode(); pArr->Reset(); - while ( ( t = static_cast<ScToken*>(pArr->GetNextReference()) ) != NULL ) + while ( ( t = pArr->GetNextReference() ) != NULL ) lcl_InvalidateReference( *t, rPos ); pArr->Reset(); - while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL ) + while ( ( t = pArr->GetNextReferenceRPN() ) != NULL ) lcl_InvalidateReference( *t, rPos ); } if ( bNewFormula ) { - ScToken* t; + formula::FormulaToken* t; ScTokenArray* pArr = maNewCell.mpFormula->GetCode(); pArr->Reset(); - while ( ( t = static_cast<ScToken*>(pArr->GetNextReference()) ) != NULL ) + while ( ( t = pArr->GetNextReference() ) != NULL ) lcl_InvalidateReference( *t, rPos ); pArr->Reset(); - while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL ) + while ( ( t = pArr->GetNextReferenceRPN() ) != NULL ) lcl_InvalidateReference( *t, rPos ); } } diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index e27ed3ef12bb..6e738d577c46 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -4048,8 +4048,8 @@ bool ScCompiler::HandleExternalReference(const FormulaToken& _aToken) void ScCompiler::SetRelNameReference() { pArr->Reset(); - for( ScToken* t = static_cast<ScToken*>(pArr->GetNextReference()); t; - t = static_cast<ScToken*>(pArr->GetNextReference()) ) + for( formula::FormulaToken* t = pArr->GetNextReference(); t; + t = pArr->GetNextReference() ) { ScSingleRefData& rRef1 = *t->GetSingleRef(); if ( rRef1.IsColRel() || rRef1.IsRowRel() || rRef1.IsTabRel() ) @@ -4068,8 +4068,8 @@ void ScCompiler::SetRelNameReference() void ScCompiler::MoveRelWrap( SCCOL nMaxCol, SCROW nMaxRow ) { pArr->Reset(); - for( ScToken* t = static_cast<ScToken*>(pArr->GetNextReference()); t; - t = static_cast<ScToken*>(pArr->GetNextReference()) ) + for( formula::FormulaToken* t = pArr->GetNextReference(); t; + t = pArr->GetNextReference() ) { if ( t->GetType() == svSingleRef || t->GetType() == svExternalSingleRef ) ScRefUpdate::MoveRelWrap( pDoc, aPos, nMaxCol, nMaxRow, SingleDoubleRefModifier( *t->GetSingleRef() ).Ref() ); @@ -4084,8 +4084,8 @@ void ScCompiler::MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc, const ScAddr SCCOL nMaxCol, SCROW nMaxRow ) { rArr.Reset(); - for( ScToken* t = static_cast<ScToken*>(rArr.GetNextReference()); t; - t = static_cast<ScToken*>(rArr.GetNextReference()) ) + for( formula::FormulaToken* t = rArr.GetNextReference(); t; + t = rArr.GetNextReference() ) { if ( t->GetType() == svSingleRef || t->GetType() == svExternalSingleRef ) ScRefUpdate::MoveRelWrap( pDoc, rPos, nMaxCol, nMaxRow, SingleDoubleRefModifier( *t->GetSingleRef() ).Ref() ); @@ -4134,7 +4134,7 @@ void ScCompiler::CreateStringFromExternal(OUStringBuffer& rBuffer, FormulaToken* case svExternalSingleRef: pConv->makeExternalRefStr( rBuffer, GetPos(), nFileId, *pFileName, t->GetString().getString(), - *static_cast<ScToken*>(t)->GetSingleRef()); + *t->GetSingleRef()); break; case svExternalDoubleRef: { @@ -4145,7 +4145,7 @@ void ScCompiler::CreateStringFromExternal(OUStringBuffer& rBuffer, FormulaToken* pConv->makeExternalRefStr( rBuffer, GetPos(), nFileId, *pFileName, aTabNames, t->GetString().getString(), - *static_cast<ScToken*>(t)->GetDoubleRef()); + *t->GetDoubleRef()); } break; default: @@ -4158,7 +4158,7 @@ void ScCompiler::CreateStringFromExternal(OUStringBuffer& rBuffer, FormulaToken* void ScCompiler::CreateStringFromMatrix( OUStringBuffer& rBuffer, FormulaToken* pTokenP) const { - const ScMatrix* pMatrix = static_cast<ScToken*>(pTokenP)->GetMatrix(); + const ScMatrix* pMatrix = pTokenP->GetMatrix(); SCSIZE nC, nMaxC, nR, nMaxR; pMatrix->GetDimensions( nMaxC, nMaxR); @@ -4204,7 +4204,7 @@ void ScCompiler::CreateStringFromSingleRef(OUStringBuffer& rBuffer,FormulaToken* { OUString aErrRef = GetCurrentOpCodeMap()->getSymbol(ocErrRef); const OpCode eOp = _pTokenP->GetOpCode(); - const ScSingleRefData& rRef = *static_cast<const ScToken*>(_pTokenP)->GetSingleRef(); + const ScSingleRefData& rRef = *_pTokenP->GetSingleRef(); ScComplexRefData aRef; aRef.Ref1 = aRef.Ref2 = rRef; if ( eOp == ocColRowName ) @@ -4232,7 +4232,7 @@ void ScCompiler::CreateStringFromDoubleRef(OUStringBuffer& rBuffer,FormulaToken* { OUString aErrRef = GetCurrentOpCodeMap()->getSymbol(ocErrRef); pConv->makeRefStr(rBuffer, meGrammar, aPos, aErrRef, GetSetupTabNames(), - *static_cast<ScToken*>(_pTokenP)->GetDoubleRef(), false); + *_pTokenP->GetDoubleRef(), false); } void ScCompiler::CreateStringFromIndex(OUStringBuffer& rBuffer,FormulaToken* _pTokenP) const @@ -4325,7 +4325,7 @@ void ScCompiler::fillAddInToken(::std::vector< ::com::sun::star::sheet::FormulaO bool ScCompiler::HandleSingleRef() { - ScSingleRefData& rRef = *static_cast<ScToken*>(mpToken.get())->GetSingleRef(); + ScSingleRefData& rRef = *mpToken.get()->GetSingleRef(); ScAddress aAbs = rRef.toAbs(aPos); if (!ValidAddress(aAbs)) { diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx index 3ec81f0ece1e..835220f78013 100644 --- a/sc/source/core/tool/detfunc.cxx +++ b/sc/source/core/tool/detfunc.cxx @@ -1367,9 +1367,9 @@ void ScDetectiveFunc::GetAllPreds(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW n ScFormulaCell* pFCell = aIter.getFormulaCell(); ScDetectiveRefIter aRefIter(pFCell); - for (ScToken* p = aRefIter.GetNextRefToken(); p; p = aRefIter.GetNextRefToken()) + for (formula::FormulaToken* p = aRefIter.GetNextRefToken(); p; p = aRefIter.GetNextRefToken()) { - ScTokenRef pRef(static_cast<ScToken*>(p->Clone())); + ScTokenRef pRef(p->Clone()); ScRefTokenHelper::join(rRefTokens, pRef, aIter.GetPos()); } } @@ -1390,10 +1390,10 @@ void ScDetectiveFunc::GetAllSuccs(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW n ScFormulaCell* pFCell = aIter.getFormulaCell(); ScDetectiveRefIter aRefIter(pFCell); - for (ScToken* p = aRefIter.GetNextRefToken(); p; p = aRefIter.GetNextRefToken()) + for (formula::FormulaToken* p = aRefIter.GetNextRefToken(); p; p = aRefIter.GetNextRefToken()) { const ScAddress& aPos = aIter.GetPos(); - ScTokenRef pRef(static_cast<ScToken*>(p->Clone())); + ScTokenRef pRef(p->Clone()); if (ScRefTokenHelper::intersects(aSrcRange, pRef, aPos)) { // This address is absolute. diff --git a/sc/source/core/tool/formularesult.cxx b/sc/source/core/tool/formularesult.cxx index 983da5daaccd..cf790c8b176a 100644 --- a/sc/source/core/tool/formularesult.cxx +++ b/sc/source/core/tool/formularesult.cxx @@ -478,7 +478,7 @@ svl::SharedString ScFormulaResult::GetString() const ScConstMatrixRef ScFormulaResult::GetMatrix() const { if (GetType() == formula::svMatrixCell) - return static_cast<const ScToken*>(mpToken)->GetMatrix(); + return mpToken->GetMatrix(); return NULL; } diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 53f922d2ae31..016a02674fb4 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -524,7 +524,7 @@ static void lcl_AdjustJumpMatrix( ScJumpMatrix* pJumpM, SCSIZE nParmCols, SCSIZE bool ScInterpreter::JumpMatrix( short nStackLevel ) { - pJumpMatrix = static_cast<ScToken*>(pStack[sp-nStackLevel])->GetJumpMatrix(); + pJumpMatrix = pStack[sp-nStackLevel]->GetJumpMatrix(); bool bHasResMat = pJumpMatrix->HasResultMatrix(); SCSIZE nC, nR; if ( nStackLevel == 2 ) @@ -2471,7 +2471,7 @@ void ScInterpreter::ScIsRef() { FormulaTokenRef x = PopToken(); if ( !nGlobalError ) - nRes = !static_cast<ScToken*>(x.get())->GetRefList()->empty(); + nRes = !x.get()->GetRefList()->empty(); } break; default: @@ -7369,7 +7369,7 @@ void ScInterpreter::ScIndex() else nRow = 0; if (GetStackType() == svRefList) - nAreaCount = (sp ? static_cast<ScToken*>(pStack[sp-1])->GetRefList()->size() : 0); + nAreaCount = (sp ? pStack[sp-1]->GetRefList()->size() : 0); else nAreaCount = 1; // one reference or array or whatever if (nAreaCount == 0 || (size_t)nArea > nAreaCount) @@ -7497,7 +7497,7 @@ void ScInterpreter::ScIndex() return; } ScRange aRange( ScAddress::UNINITIALIZED); - DoubleRefToRange( (*(static_cast<ScToken*>(xRef.get())->GetRefList()))[nArea-1], aRange); + DoubleRefToRange( (*(xRef.get()->GetRefList()))[nArea-1], aRange); aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); if ( nParamCount == 2 && nRow1 == nRow2 ) bRowArray = true; @@ -7576,22 +7576,22 @@ void ScInterpreter::ScAreas() case svSingleRef: { FormulaTokenRef xT = PopToken(); - ValidateRef( *static_cast<ScToken*>(xT.get())->GetSingleRef()); + ValidateRef( *xT.get()->GetSingleRef()); ++nCount; } break; case svDoubleRef: { FormulaTokenRef xT = PopToken(); - ValidateRef( *static_cast<ScToken*>(xT.get())->GetDoubleRef()); + ValidateRef( *xT.get()->GetDoubleRef()); ++nCount; } break; case svRefList: { FormulaTokenRef xT = PopToken(); - ValidateRef( *(static_cast<ScToken*>(xT.get())->GetRefList())); - nCount += static_cast<ScToken*>(xT.get())->GetRefList()->size(); + ValidateRef( *(xT.get()->GetRefList())); + nCount += xT.get()->GetRefList()->size(); } break; default: @@ -8250,7 +8250,7 @@ void ScInterpreter::ScErrorType() nErr = nGlobalError; else { - const ScRefList* pRefList = static_cast<ScToken*>(x.get())->GetRefList(); + const ScRefList* pRefList = x.get()->GetRefList(); size_t n = pRefList->size(); if (!n) nErr = errNoRef; diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 6674bb870933..8fa70fb230e2 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -1938,14 +1938,14 @@ void ScInterpreter::ScIntersect() return; } - ScToken* x1 = static_cast<ScToken*>(p1st.get()); - ScToken* x2 = static_cast<ScToken*>(p2nd.get()); + formula::FormulaToken* x1 = p1st.get(); + formula::FormulaToken* x2 = p2nd.get(); if (sv1 == svRefList || sv2 == svRefList) { // Now this is a bit nasty but it simplifies things, and having // intersections with lists isn't too common, if at all.. // Convert a reference to list. - ScToken* xt[2] = { x1, x2 }; + formula::FormulaToken* xt[2] = { x1, x2 }; StackVar sv[2] = { sv1, sv2 }; for (size_t i=0; i<2; ++i) { @@ -2011,7 +2011,7 @@ void ScInterpreter::ScIntersect() } else { - ScToken* pt[2] = { x1, x2 }; + formula::FormulaToken* pt[2] = { x1, x2 }; StackVar sv[2] = { sv1, sv2 }; SCCOL nC1[2], nC2[2]; SCROW nR1[2], nR2[2]; @@ -2100,8 +2100,8 @@ void ScInterpreter::ScUnionFunc() return; } - ScToken* x1 = static_cast<ScToken*>(p1st.get()); - ScToken* x2 = static_cast<ScToken*>(p2nd.get()); + formula::FormulaToken* x1 = p1st.get(); + formula::FormulaToken* x2 = p2nd.get(); ScTokenRef xRes; // Append to an existing RefList if there is one. @@ -2118,7 +2118,7 @@ void ScInterpreter::ScUnionFunc() else xRes = new ScRefListToken; ScRefList* pRes = xRes->GetRefList(); - ScToken* pt[2] = { x1, x2 }; + formula::FormulaToken* pt[2] = { x1, x2 }; StackVar sv[2] = { sv1, sv2 }; for (size_t i=0; i<2; ++i) { diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 4bb62c454a84..e1eeb71ff601 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -885,7 +885,7 @@ void ScInterpreter::PushWithoutError( FormulaToken& r ) maxsp = sp + 1; else pStack[ sp ]->DecRef(); - pStack[ sp ] = (ScToken*) &r; + pStack[ sp ] = &r; ++sp; } } @@ -1171,7 +1171,7 @@ void ScInterpreter::PopSingleRef(SCCOL& rCol, SCROW &rRow, SCTAB& rTab) nGlobalError = p->GetError(); break; case svSingleRef: - SingleRefToVars( *static_cast<ScToken*>(p)->GetSingleRef(), rCol, rRow, rTab); + SingleRefToVars( *p->GetSingleRef(), rCol, rRow, rTab); if ( !pDok->aTableOpList.empty() ) ReplaceCell( rCol, rRow, rTab ); break; @@ -1199,7 +1199,7 @@ void ScInterpreter::PopSingleRef( ScAddress& rAdr ) SCCOL nCol; SCROW nRow; SCTAB nTab; - SingleRefToVars( *static_cast<ScToken*>(p)->GetSingleRef(), nCol, nRow, nTab); + SingleRefToVars( *p->GetSingleRef(), nCol, nRow, nTab); rAdr.Set( nCol, nRow, nTab ); if ( !pDok->aTableOpList.empty() ) ReplaceCell( rAdr ); @@ -1213,7 +1213,7 @@ void ScInterpreter::PopSingleRef( ScAddress& rAdr ) SetError( errUnknownStackVariable); } -void ScInterpreter::DoubleRefToVars( const ScToken* p, +void ScInterpreter::DoubleRefToVars( const formula::FormulaToken* p, SCCOL& rCol1, SCROW &rRow1, SCTAB& rTab1, SCCOL& rCol2, SCROW &rRow2, SCTAB& rTab2, bool bDontCheckForTableOp ) @@ -1284,7 +1284,7 @@ void ScInterpreter::PopDoubleRef(SCCOL& rCol1, SCROW &rRow1, SCTAB& rTab1, nGlobalError = p->GetError(); break; case svDoubleRef: - DoubleRefToVars( static_cast<ScToken*>(p), rCol1, rRow1, rTab1, rCol2, rRow2, rTab2, + DoubleRefToVars( p, rCol1, rRow1, rTab1, rCol2, rRow2, rTab2, bDontCheckForTableOp); break; default: @@ -1317,19 +1317,18 @@ void ScInterpreter::PopDoubleRef( ScRange & rRange, short & rParam, size_t & rRe if (sp) { formula::FormulaToken* pToken = pStack[ sp-1 ]; - ScToken* p = static_cast<ScToken*>(pToken); switch (pToken->GetType()) { case svError: - nGlobalError = p->GetError(); + nGlobalError = pToken->GetError(); break; case svDoubleRef: --sp; - DoubleRefToRange( *p->GetDoubleRef(), rRange); + DoubleRefToRange( *pToken->GetDoubleRef(), rRange); break; case svRefList: { - const ScRefList* pList = p->GetRefList(); + const ScRefList* pList = pToken->GetRefList(); if (rRefInList < pList->size()) { DoubleRefToRange( (*pList)[rRefInList], rRange); @@ -1369,7 +1368,7 @@ void ScInterpreter::PopDoubleRef( ScRange& rRange, bool bDontCheckForTableOp ) nGlobalError = p->GetError(); break; case svDoubleRef: - DoubleRefToRange( *static_cast<ScToken*>(p)->GetDoubleRef(), rRange, bDontCheckForTableOp); + DoubleRefToRange( *p->GetDoubleRef(), rRange, bDontCheckForTableOp); break; default: SetError( errIllegalParameter); @@ -1405,7 +1404,7 @@ void ScInterpreter::PopExternalSingleRef(sal_uInt16& rFileId, OUString& rTabName rFileId = p->GetIndex(); rTabName = p->GetString().getString(); - rRef = *static_cast<ScToken*>(p)->GetSingleRef(); + rRef = *p->GetSingleRef(); } void ScInterpreter::PopExternalSingleRef(ScExternalRefCache::TokenRef& rToken, ScExternalRefCache::CellFormat* pFmt) @@ -1481,7 +1480,7 @@ void ScInterpreter::PopExternalDoubleRef(sal_uInt16& rFileId, OUString& rTabName rFileId = p->GetIndex(); rTabName = p->GetString().getString(); - rRef = *static_cast<ScToken*>(p)->GetDoubleRef(); + rRef = *p->GetDoubleRef(); } void ScInterpreter::PopExternalDoubleRef(ScExternalRefCache::TokenArrayRef& rArray) @@ -1508,7 +1507,7 @@ void ScInterpreter::PopExternalDoubleRef(ScMatrixRef& rMat) // For now, we only support single range data for external // references, which means the array should only contain a // single matrix token. - ScToken* p = static_cast<ScToken*>(pArray->First()); + formula::FormulaToken* p = pArray->First(); if (!p || p->GetType() != svMatrix) SetError( errIllegalParameter); else @@ -1547,7 +1546,7 @@ void ScInterpreter::GetExternalDoubleRef( return; } - ScToken* pToken = static_cast<ScToken*>(pArray->First()); + formula::FormulaToken* pToken = pArray->First(); if (pToken->GetType() != svMatrix) { SetError(errIllegalArgument); @@ -1635,7 +1634,7 @@ bool ScInterpreter::ConvertMatrixParameters() if ( ScParameterClassification::GetParameterType( pCur, nParams - i) == ScParameterClassification::Value ) { // only if single value expected - ScMatrixRef pMat = static_cast<ScToken*>(p)->GetMatrix(); + ScMatrixRef pMat = p->GetMatrix(); if ( !pMat ) SetError( errUnknownVariable); else @@ -1660,7 +1659,7 @@ bool ScInterpreter::ConvertMatrixParameters() SCCOL nCol1, nCol2; SCROW nRow1, nRow2; SCTAB nTab1, nTab2; - DoubleRefToVars( static_cast<const ScToken*>( p), nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); + DoubleRefToVars( p, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); // Make sure the map exists, created if not. GetTokenMatrixMap(); ScMatrixRef pMat = CreateMatrixFromDoubleRef( p, @@ -1674,7 +1673,7 @@ bool ScInterpreter::ConvertMatrixParameters() if ( nJumpRows < static_cast<SCSIZE>(nRow2 - nRow1 + 1) ) nJumpRows = static_cast<SCSIZE>(nRow2 - nRow1 + 1); } - ScToken* pNew = new ScMatrixToken( pMat); + formula::FormulaToken* pNew = new ScMatrixToken( pMat); pNew->IncRef(); pStack[ sp - i ] = pNew; p->DecRef(); // p may be dead now! @@ -1690,20 +1689,20 @@ bool ScInterpreter::ConvertMatrixParameters() { sal_uInt16 nFileId = p->GetIndex(); OUString aTabName = p->GetString().getString(); - const ScComplexRefData& rRef = *static_cast<ScToken*>(p)->GetDoubleRef(); + const ScComplexRefData& rRef = *p->GetDoubleRef(); ScExternalRefCache::TokenArrayRef pArray; GetExternalDoubleRef(nFileId, aTabName, rRef, pArray); if (nGlobalError) break; - ScToken* pTemp = static_cast<ScToken*>(pArray->First()); + formula::FormulaToken* pTemp = pArray->First(); if (!pTemp) break; ScMatrixRef pMat = pTemp->GetMatrix(); if (pMat) { - ScToken* pNew = new ScMatrixToken( pMat); + formula::FormulaToken* pNew = new ScMatrixToken( pMat); pNew->IncRef(); pStack[ sp - i ] = pNew; p->DecRef(); // p may be dead now! @@ -1778,7 +1777,7 @@ ScMatrixRef ScInterpreter::PopMatrix() break; case svMatrix: { - ScMatrix* pMat = static_cast<ScToken*>(p)->GetMatrix(); + ScMatrix* pMat = p->GetMatrix(); if ( pMat ) pMat->SetErrorInterpreter( this); else @@ -1805,14 +1804,13 @@ sc::RangeMatrix ScInterpreter::PopRangeMatrix() { --sp; FormulaToken* p = pStack[sp]; - ScToken* p2 = static_cast<ScToken*>(p); - aRet.mpMat = p2->GetMatrix(); + aRet.mpMat = p->GetMatrix(); if (aRet.mpMat) { aRet.mpMat->SetErrorInterpreter(this); - if (p2->GetByte() == MATRIX_TOKEN_HAS_RANGE) + if (p->GetByte() == MATRIX_TOKEN_HAS_RANGE) { - const ScComplexRefData& rRef = *p2->GetDoubleRef(); + const ScComplexRefData& rRef = *p->GetDoubleRef(); if (!rRef.Ref1.IsColRel() && !rRef.Ref1.IsRowRel() && !rRef.Ref2.IsColRel() && !rRef.Ref2.IsRowRel()) { aRet.mnCol1 = rRef.Ref1.Col(); @@ -3579,7 +3577,7 @@ void ScInterpreter::ScDBArea() void ScInterpreter::ScColRowNameAuto() { - ScComplexRefData aRefData( *static_cast<const ScToken*>(pCur)->GetDoubleRef() ); + ScComplexRefData aRefData( *pCur->GetDoubleRef() ); ScRange aAbs = aRefData.toAbs(aPos); if (!ValidRange(aAbs)) { @@ -4500,7 +4498,7 @@ StackVar ScInterpreter::Interpret() if (eType == svMatrix) // Results are immutable in case they would be reused as input for new // interpreters. - static_cast<ScToken*>(xResult.get())->GetMatrix()->SetImmutable( true); + xResult.get()->GetMatrix()->SetImmutable( true); return eType; } diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index 9c2800900910..f8733614c095 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -358,7 +358,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken if (pTokenMatrixMap && ((aIter = pTokenMatrixMap->find( pToken)) != pTokenMatrixMap->end())) { - return static_cast<ScToken*>((*aIter).second.get())->GetMatrix(); + return (*aIter).second.get()->GetMatrix(); } ScMatrixRef pMat = GetNewMat( nMatCols, nMatRows, true); @@ -406,7 +406,7 @@ ScMatrixRef ScInterpreter::GetMatrix() SCCOL nCol1, nCol2; SCROW nRow1, nRow2; SCTAB nTab1, nTab2; - const ScToken* p = sp ? static_cast<const ScToken*>(pStack[sp-1]) : NULL; + const formula::FormulaToken* p = sp ? pStack[sp-1] : NULL; PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); pMat = CreateMatrixFromDoubleRef( p, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx index e770110ec3c5..768fe7085837 100644 --- a/sc/source/core/tool/rangenam.cxx +++ b/sc/source/core/tool/rangenam.cxx @@ -217,9 +217,9 @@ void ScRangeData::GuessPosition() SCsROW nMinRow = 0; SCsTAB nMinTab = 0; - ScToken* t; + formula::FormulaToken* t; pCode->Reset(); - while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) + while ( ( t = pCode->GetNextReference() ) != NULL ) { ScSingleRefData& rRef1 = *t->GetSingleRef(); if ( rRef1.IsColRel() && rRef1.Col() < nMinCol ) @@ -282,10 +282,10 @@ void ScRangeData::UpdateTranspose( const ScRange& rSource, const ScAddress& rDes { bool bChanged = false; - ScToken* t; + formula::FormulaToken* t; pCode->Reset(); - while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) + while ( ( t = pCode->GetNextReference() ) != NULL ) { if( t->GetType() != svIndex ) { @@ -314,10 +314,10 @@ void ScRangeData::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY ) { bool bChanged = false; - ScToken* t; + formula::FormulaToken* t; pCode->Reset(); - while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) + while ( ( t = pCode->GetNextReference() ) != NULL ) { if( t->GetType() != svIndex ) { @@ -539,9 +539,9 @@ void ScRangeData::ValidateTabRefs() SCTAB nMinTab = aPos.Tab(); SCTAB nMaxTab = nMinTab; - ScToken* t; + formula::FormulaToken* t; pCode->Reset(); - while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) + while ( ( t = pCode->GetNextReference() ) != NULL ) { ScSingleRefData& rRef1 = *t->GetSingleRef(); ScAddress aAbs = rRef1.toAbs(aPos); @@ -577,7 +577,7 @@ void ScRangeData::ValidateTabRefs() aPos.SetTab( aPos.Tab() - nMove ); pCode->Reset(); - while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL ) + while ( ( t = pCode->GetNextReference() ) != NULL ) { switch (t->GetType()) { diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx index a26ab0de5762..04070f29225f 100644 --- a/sc/source/core/tool/reftokenhelper.cxx +++ b/sc/source/core/tool/reftokenhelper.cxx @@ -80,8 +80,7 @@ void ScRefTokenHelper::compileRangeRepresentation( { case svSingleRef: { - const ScToken* pT = static_cast<const ScToken*>(p); - const ScSingleRefData& rRef = *pT->GetSingleRef(); + const ScSingleRefData& rRef = *p->GetSingleRef(); if (!rRef.Valid()) bFailure = true; else if (bOnly3DRef && !rRef.IsFlag3D()) @@ -90,8 +89,7 @@ void ScRefTokenHelper::compileRangeRepresentation( break; case svDoubleRef: { - const ScToken* pT = static_cast<const ScToken*>(p); - const ScComplexRefData& rRef = *pT->GetDoubleRef(); + const ScComplexRefData& rRef = *p->GetDoubleRef(); if (!rRef.Valid()) bFailure = true; else if (bOnly3DRef && !rRef.Ref1.IsFlag3D()) @@ -100,15 +98,13 @@ void ScRefTokenHelper::compileRangeRepresentation( break; case svExternalSingleRef: { - const ScToken* pT = static_cast<const ScToken*>(p); - if (!pT->GetSingleRef()->ValidExternal()) + if (!p->GetSingleRef()->ValidExternal()) bFailure = true; } break; case svExternalDoubleRef: { - const ScToken* pT = static_cast<const ScToken*>(p); - if (!pT->GetDoubleRef()->ValidExternal()) + if (!p->GetDoubleRef()->ValidExternal()) bFailure = true; } break; @@ -121,8 +117,7 @@ void ScRefTokenHelper::compileRangeRepresentation( break; } if (!bFailure) - rRefTokens.push_back( - ScTokenRef(static_cast<ScToken*>(p->Clone()))); + rRefTokens.push_back(ScTokenRef(p->Clone())); } if (bFailure) diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 46cf5ed0aff7..6cea8ff1c603 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -449,12 +449,6 @@ void ScRawToken::Delete() } } -// --- class ScToken -------------------------------------------------------- - -ScToken::~ScToken() -{ -} - namespace { // TextEqual: if same formula entered (for optimization in sort) @@ -495,7 +489,7 @@ bool checkTextEqual( const FormulaToken& _rToken1, const FormulaToken& _rToken2 } #if DEBUG_FORMULA_COMPILER -void DumpToken(ScToken const & rToken) +void DumpToken(formula::FormulaToken const & rToken) { switch (rToken.GetType()) { case svSingleRef: @@ -507,7 +501,22 @@ void DumpToken(ScToken const & rToken) rToken.GetDoubleRef()->Dump(1); break; default: - cout << "-- ScToken (base class)" << endl; + cout << "-- FormulaToken" << endl; + cout << " opcode: " << rToken.GetOpCode() << endl; + cout << " type: " << static_cast<int>(rToken.GetType()) << endl; + switch (rToken.GetType()) + { + case svDouble: + cout << " value: " << rToken.GetDouble() << endl; + break; + case svString: + cout << " string: " + << OUStringToOString(rToken.GetString().getString(), RTL_TEXTENCODING_UTF8).getStr() + << endl; + break; + default: + ; + } break; } } @@ -525,9 +534,6 @@ FormulaTokenRef extendRangeReference( FormulaToken & rTok1, FormulaToken & rTok2 ((sv2 = rTok2.GetType()) != svSingleRef && sv2 != svDoubleRef && sv2 != svRefList)) return NULL; - ScToken *p1 = static_cast<ScToken*>(&rTok1); - ScToken *p2 = static_cast<ScToken*>(&rTok2); - ScTokenRef xRes; bool bExternal = (sv1 == svExternalSingleRef); if ((sv1 == svSingleRef || bExternal) && sv2 == svSingleRef) @@ -553,16 +559,16 @@ FormulaTokenRef extendRangeReference( FormulaToken & rTok1, FormulaToken & rTok2 * merged here. For Xcl syntax already parse an external range * reference entirely, cumbersome. */ - const ScSingleRefData& rRef2 = *p2->GetSingleRef(); + const ScSingleRefData& rRef2 = *rTok2.GetSingleRef(); if (bExternal && rRef2.IsFlag3D()) return NULL; ScComplexRefData aRef; - aRef.Ref1 = aRef.Ref2 = *p1->GetSingleRef(); + aRef.Ref1 = aRef.Ref2 = *rTok1.GetSingleRef(); aRef.Ref2.SetFlag3D( false); aRef.Extend( rRef2, rPos); if (bExternal) - xRes = new ScExternalDoubleRefToken( p1->GetIndex(), p1->GetString(), aRef); + xRes = new ScExternalDoubleRefToken( rTok1.GetIndex(), rTok1.GetString(), aRef); else xRes = new ScDoubleRefToken( aRef); } @@ -572,18 +578,18 @@ FormulaTokenRef extendRangeReference( FormulaToken & rTok1, FormulaToken & rTok2 const ScRefList* pRefList = NULL; if (sv1 == svDoubleRef) { - xRes = (bReuseDoubleRef && p1->GetRef() == 1 ? p1 : static_cast<ScToken*>(p1->Clone())); + xRes = (bReuseDoubleRef && rTok1.GetRef() == 1 ? &rTok1 : rTok1.Clone()); sv1 = svUnknown; // mark as handled } else if (sv2 == svDoubleRef) { - xRes = (bReuseDoubleRef && p2->GetRef() == 1 ? p2 : static_cast<ScToken*>(p2->Clone())); + xRes = (bReuseDoubleRef && rTok2.GetRef() == 1 ? &rTok2 : rTok2.Clone()); sv2 = svUnknown; // mark as handled } else if (sv1 == svRefList) - pRefList = p1->GetRefList(); + pRefList = rTok1.GetRefList(); else if (sv2 == svRefList) - pRefList = p2->GetRefList(); + pRefList = rTok2.GetRefList(); if (pRefList) { if (!pRefList->size()) @@ -595,7 +601,7 @@ FormulaTokenRef extendRangeReference( FormulaToken & rTok1, FormulaToken & rTok2 if (!xRes) return NULL; // shouldn't happen.. StackVar sv[2] = { sv1, sv2 }; - ScToken* pt[2] = { p1, p2 }; + formula::FormulaToken* pt[2] = { &rTok1, &rTok2 }; ScComplexRefData& rRef = *xRes->GetDoubleRef(); for (size_t i=0; i<2; ++i) { @@ -650,7 +656,7 @@ bool ScSingleRefToken::TextEqual( const FormulaToken& _rToken ) const } bool ScSingleRefToken::operator==( const FormulaToken& r ) const { - return FormulaToken::operator==( r ) && aSingleRef == *static_cast<const ScToken&>(r).GetSingleRef(); + return FormulaToken::operator==( r ) && aSingleRef == *r.GetSingleRef(); } const ScSingleRefData* ScDoubleRefToken::GetSingleRef() const { return &aDoubleRef.Ref1; } @@ -665,40 +671,40 @@ bool ScDoubleRefToken::TextEqual( const FormulaToken& _rToken ) const } bool ScDoubleRefToken::operator==( const FormulaToken& r ) const { - return FormulaToken::operator==( r ) && aDoubleRef == *static_cast<const ScToken&>(r).GetDoubleRef(); + return FormulaToken::operator==( r ) && aDoubleRef == *r.GetDoubleRef(); } const ScRefList* ScRefListToken::GetRefList() const { return &aRefList; } ScRefList* ScRefListToken::GetRefList() { return &aRefList; } bool ScRefListToken::operator==( const FormulaToken& r ) const { - return FormulaToken::operator==( r ) && &aRefList == static_cast<const ScToken&>(r).GetRefList(); + return FormulaToken::operator==( r ) && &aRefList == r.GetRefList(); } ScMatrixToken::ScMatrixToken( const ScMatrixRef& p ) : - ScToken(formula::svMatrix), pMatrix(p) {} + FormulaToken(formula::svMatrix), pMatrix(p) {} ScMatrixToken::ScMatrixToken( const ScMatrixToken& r ) : - ScToken(r), pMatrix(r.pMatrix) {} + FormulaToken(r), pMatrix(r.pMatrix) {} const ScMatrix* ScMatrixToken::GetMatrix() const { return pMatrix.get(); } ScMatrix* ScMatrixToken::GetMatrix() { return pMatrix.get(); } bool ScMatrixToken::operator==( const FormulaToken& r ) const { - return FormulaToken::operator==( r ) && pMatrix == static_cast<const ScToken&>(r).GetMatrix(); + return FormulaToken::operator==( r ) && pMatrix == r.GetMatrix(); } ScMatrixRangeToken::ScMatrixRangeToken( const ScMatrixRef& p, const ScComplexRefData& rRef ) : - ScToken(formula::svMatrix), mpMatrix(p), maRef(rRef) {} + FormulaToken(formula::svMatrix), mpMatrix(p), maRef(rRef) {} ScMatrixRangeToken::ScMatrixRangeToken( const sc::RangeMatrix& rMat ) : - ScToken(formula::svMatrix), mpMatrix(rMat.mpMat) + FormulaToken(formula::svMatrix), mpMatrix(rMat.mpMat) { maRef.InitRange(rMat.mnCol1, rMat.mnRow1, rMat.mnTab1, rMat.mnCol2, rMat.mnRow2, rMat.mnTab2); } ScMatrixRangeToken::ScMatrixRangeToken( const ScMatrixRangeToken& r ) : - ScToken(r), mpMatrix(r.mpMatrix), maRef(r.maRef) {} + FormulaToken(r), mpMatrix(r.mpMatrix), maRef(r.maRef) {} sal_uInt8 ScMatrixRangeToken::GetByte() const { @@ -727,7 +733,7 @@ ScComplexRefData* ScMatrixRangeToken::GetDoubleRef() bool ScMatrixRangeToken::operator==( const FormulaToken& r ) const { - return FormulaToken::operator==(r) && mpMatrix == static_cast<const ScToken&>(r).GetMatrix(); + return FormulaToken::operator==(r) && mpMatrix == r.GetMatrix(); } FormulaToken* ScMatrixRangeToken::Clone() const @@ -736,7 +742,7 @@ FormulaToken* ScMatrixRangeToken::Clone() const } ScExternalSingleRefToken::ScExternalSingleRefToken( sal_uInt16 nFileId, const svl::SharedString& rTabName, const ScSingleRefData& r ) : - ScToken( svExternalSingleRef, ocPush), + FormulaToken( svExternalSingleRef, ocPush), mnFileId(nFileId), maTabName(rTabName), maSingleRef(r) @@ -744,7 +750,7 @@ ScExternalSingleRefToken::ScExternalSingleRefToken( sal_uInt16 nFileId, const sv } ScExternalSingleRefToken::ScExternalSingleRefToken( const ScExternalSingleRefToken& r ) : - ScToken(r), + FormulaToken(r), mnFileId(r.mnFileId), maTabName(r.maTabName), maSingleRef(r.maSingleRef) @@ -786,11 +792,11 @@ bool ScExternalSingleRefToken::operator ==( const FormulaToken& r ) const if (maTabName != r.GetString()) return false; - return maSingleRef == *static_cast<const ScToken&>(r).GetSingleRef(); + return maSingleRef == *r.GetSingleRef(); } ScExternalDoubleRefToken::ScExternalDoubleRefToken( sal_uInt16 nFileId, const svl::SharedString& rTabName, const ScComplexRefData& r ) : - ScToken( svExternalDoubleRef, ocPush), + FormulaToken( svExternalDoubleRef, ocPush), mnFileId(nFileId), maTabName(rTabName), maDoubleRef(r) @@ -798,7 +804,7 @@ ScExternalDoubleRefToken::ScExternalDoubleRefToken( sal_uInt16 nFileId, const sv } ScExternalDoubleRefToken::ScExternalDoubleRefToken( const ScExternalDoubleRefToken& r ) : - ScToken(r), + FormulaToken(r), mnFileId(r.mnFileId), maTabName(r.maTabName), maDoubleRef(r.maDoubleRef) @@ -851,7 +857,7 @@ ScComplexRefData* ScExternalDoubleRefToken::GetDoubleRef() bool ScExternalDoubleRefToken::operator ==( const FormulaToken& r ) const { - if (!ScToken::operator==(r)) + if (!FormulaToken::operator==(r)) return false; if (mnFileId != r.GetIndex()) @@ -860,18 +866,18 @@ bool ScExternalDoubleRefToken::operator ==( const FormulaToken& r ) const if (maTabName != r.GetString()) return false; - return maDoubleRef == *static_cast<const ScToken&>(r).GetDoubleRef(); + return maDoubleRef == *r.GetDoubleRef(); } ScExternalNameToken::ScExternalNameToken( sal_uInt16 nFileId, const svl::SharedString& rName ) : - ScToken( svExternalName, ocPush), + FormulaToken( svExternalName, ocPush), mnFileId(nFileId), maName(rName) { } ScExternalNameToken::ScExternalNameToken( const ScExternalNameToken& r ) : - ScToken(r), + FormulaToken(r), mnFileId(r.mnFileId), maName(r.maName) { @@ -903,7 +909,7 @@ bool ScExternalNameToken::operator==( const FormulaToken& r ) const ScJumpMatrix* ScJumpMatrixToken::GetJumpMatrix() const { return pJumpMatrix; } bool ScJumpMatrixToken::operator==( const FormulaToken& r ) const { - return FormulaToken::operator==( r ) && pJumpMatrix == static_cast<const ScToken&>(r).GetJumpMatrix(); + return FormulaToken::operator==( r ) && pJumpMatrix == r.GetJumpMatrix(); } ScJumpMatrixToken::~ScJumpMatrixToken() { @@ -925,10 +931,10 @@ bool ScEmptyCellToken::operator==( const FormulaToken& r ) const } ScMatrixCellResultToken::ScMatrixCellResultToken( const ScConstMatrixRef& pMat, formula::FormulaToken* pUL ) : - ScToken(formula::svMatrixCell), xMatrix(pMat), xUpperLeft(pUL) {} + FormulaToken(formula::svMatrixCell), xMatrix(pMat), xUpperLeft(pUL) {} ScMatrixCellResultToken::ScMatrixCellResultToken( const ScMatrixCellResultToken& r ) : - ScToken(r), xMatrix(r.xMatrix), xUpperLeft(r.xUpperLeft) {} + FormulaToken(r), xMatrix(r.xMatrix), xUpperLeft(r.xUpperLeft) {} double ScMatrixCellResultToken::GetDouble() const { return xUpperLeft->GetDouble(); } @@ -1004,7 +1010,7 @@ void ScMatrixFormulaCellToken::Assign( const formula::FormulaToken& r ) if (r.GetType() == svMatrix) { xUpperLeft = NULL; - xMatrix = static_cast<const ScToken&>(r).GetMatrix(); + xMatrix = r.GetMatrix(); } else { @@ -1046,7 +1052,7 @@ void ScMatrixFormulaCellToken::ResetResult() ScHybridCellToken::ScHybridCellToken( double f, const svl::SharedString & rStr, const OUString & rFormula ) : - ScToken( formula::svHybridCell ), + FormulaToken( formula::svHybridCell ), mfDouble( f ), maString( rStr ), maFormula( rFormula ) { @@ -1496,11 +1502,11 @@ void ScTokenArray::GenHash() size_t nHash = 1; OpCode eOp; StackVar eType; - const ScToken* p; + const formula::FormulaToken* p; sal_uInt16 n = std::min<sal_uInt16>(nLen, 20); for (sal_uInt16 i = 0; i < n; ++i) { - p = static_cast<const ScToken*>(pCode[i]); + p = pCode[i]; eOp = p->GetOpCode(); if (eOp == ocPush) { @@ -1570,8 +1576,7 @@ bool ScTokenArray::IsInvariant() const case svSingleRef: case svExternalSingleRef: { - const ScToken* pT = static_cast<const ScToken*>(*p); - const ScSingleRefData& rRef = *pT->GetSingleRef(); + const ScSingleRefData& rRef = *(*p)->GetSingleRef(); if (rRef.IsRowRel()) return false; } @@ -1579,8 +1584,7 @@ bool ScTokenArray::IsInvariant() const case svDoubleRef: case svExternalDoubleRef: { - const ScToken* pT = static_cast<const ScToken*>(*p); - const ScComplexRefData& rRef = *pT->GetDoubleRef(); + const ScComplexRefData& rRef = *(*p)->GetDoubleRef(); if (rRef.Ref1.IsRowRel() || rRef.Ref2.IsRowRel()) return false; } @@ -1646,7 +1650,7 @@ ScTokenArray* ScTokenArray::Clone() const if( nLen ) { pp = p->pCode = new FormulaToken*[ nLen ]; - memcpy( pp, pCode, nLen * sizeof( ScToken* ) ); + memcpy( pp, pCode, nLen * sizeof( formula::FormulaToken* ) ); for( sal_uInt16 i = 0; i < nLen; i++, pp++ ) { *pp = (*pp)->Clone(); @@ -1656,7 +1660,7 @@ ScTokenArray* ScTokenArray::Clone() const if( nRPN ) { pp = p->pRPN = new FormulaToken*[ nRPN ]; - memcpy( pp, pRPN, nRPN * sizeof( ScToken* ) ); + memcpy( pp, pRPN, nRPN * sizeof( formula::FormulaToken* ) ); for( sal_uInt16 i = 0; i < nRPN; i++, pp++ ) { FormulaToken* t = *pp; @@ -2020,7 +2024,7 @@ bool ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend, { case svSingleRef : { - ScSingleRefData& rRef = *static_cast<ScToken*>(p)->GetSingleRef(); + ScSingleRefData& rRef = *p->GetSingleRef(); ScAddress aAbs = rRef.toAbs(rPos); switch ( eDir ) { @@ -2057,7 +2061,7 @@ bool ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend, break; case svDoubleRef : { - ScComplexRefData& rRef = *static_cast<ScToken*>(p)->GetDoubleRef(); + ScComplexRefData& rRef = *p->GetDoubleRef(); ScRange aAbs = rRef.toAbs(rPos); switch ( eDir ) { @@ -2114,9 +2118,9 @@ void ScTokenArray::ReadjustRelative3DReferences( const ScAddress& rOldPos, { case svDoubleRef : { - ScSingleRefData& rRef2 = *static_cast<ScToken*>(pCode[j])->GetSingleRef2(); + ScSingleRefData& rRef2 = *pCode[j]->GetSingleRef2(); // Also adjust if the reference is of the form Sheet1.A2:A3 - if ( rRef2.IsFlag3D() || static_cast<ScToken*>(pCode[j])->GetSingleRef()->IsFlag3D() ) + if ( rRef2.IsFlag3D() || pCode[j]->GetSingleRef()->IsFlag3D() ) { ScAddress aAbs = rRef2.toAbs(rOldPos); rRef2.SetAddress(aAbs, rNewPos); @@ -2125,7 +2129,7 @@ void ScTokenArray::ReadjustRelative3DReferences( const ScAddress& rOldPos, //! fallthru case svSingleRef : { - ScSingleRefData& rRef1 = *static_cast<ScToken*>(pCode[j])->GetSingleRef(); + ScSingleRefData& rRef1 = *pCode[j]->GetSingleRef(); if ( rRef1.IsFlag3D() ) { ScAddress aAbs = rRef1.toAbs(rOldPos); @@ -2135,14 +2139,14 @@ void ScTokenArray::ReadjustRelative3DReferences( const ScAddress& rOldPos, break; case svExternalDoubleRef : { - ScSingleRefData& rRef2 = *static_cast<ScToken*>(pCode[j])->GetSingleRef2(); + ScSingleRefData& rRef2 = *pCode[j]->GetSingleRef2(); ScAddress aAbs = rRef2.toAbs(rOldPos); rRef2.SetAddress(aAbs, rNewPos); } //! fallthru case svExternalSingleRef : { - ScSingleRefData& rRef1 = *static_cast<ScToken*>(pCode[j])->GetSingleRef(); + ScSingleRefData& rRef1 = *pCode[j]->GetSingleRef(); ScAddress aAbs = rRef1.toAbs(rOldPos); rRef1.SetAddress(aAbs, rNewPos); } @@ -2172,7 +2176,7 @@ bool IsInCopyRange( const ScRange& rRange, const ScDocument* pClipDoc ) return rClipParam.maRanges.In(rRange); } -bool SkipReference(ScToken* pToken, const ScAddress& rPos, const ScDocument* pOldDoc, bool bRangeName, bool bCheckCopyArea) +bool SkipReference(formula::FormulaToken* pToken, const ScAddress& rPos, const ScDocument* pOldDoc, bool bRangeName, bool bCheckCopyArea) { ScRange aRange; @@ -2233,10 +2237,10 @@ void ScTokenArray::ReadjustAbsolute3DReferences( const ScDocument* pOldDoc, cons { case svDoubleRef : { - if (SkipReference(static_cast<ScToken*>(pCode[j]), rPos, pOldDoc, bRangeName, true)) + if (SkipReference(pCode[j], rPos, pOldDoc, bRangeName, true)) continue; - ScComplexRefData& rRef = *static_cast<ScToken*>(pCode[j])->GetDoubleRef(); + ScComplexRefData& rRef = *pCode[j]->GetDoubleRef(); ScSingleRefData& rRef2 = rRef.Ref2; ScSingleRefData& rRef1 = rRef.Ref1; @@ -2254,10 +2258,10 @@ void ScTokenArray::ReadjustAbsolute3DReferences( const ScDocument* pOldDoc, cons break; case svSingleRef : { - if (SkipReference(static_cast<ScToken*>(pCode[j]), rPos, pOldDoc, bRangeName, true)) + if (SkipReference(pCode[j], rPos, pOldDoc, bRangeName, true)) continue; - ScSingleRefData& rRef = *static_cast<ScToken*>(pCode[j])->GetSingleRef(); + ScSingleRefData& rRef = *pCode[j]->GetSingleRef(); if ( rRef.IsFlag3D() && !rRef.IsTabRel() ) { @@ -2288,10 +2292,10 @@ void ScTokenArray::AdjustAbsoluteRefs( const ScDocument* pOldDoc, const ScAddres { case svDoubleRef : { - if (!SkipReference(static_cast<ScToken*>(pCode[j]), rOldPos, pOldDoc, false, bCheckCopyRange)) + if (!SkipReference(pCode[j], rOldPos, pOldDoc, false, bCheckCopyRange)) continue; - ScComplexRefData& rRef = *static_cast<ScToken*>(pCode[j])->GetDoubleRef(); + ScComplexRefData& rRef = *pCode[j]->GetDoubleRef(); ScSingleRefData& rRef2 = rRef.Ref2; ScSingleRefData& rRef1 = rRef.Ref1; @@ -2304,10 +2308,10 @@ void ScTokenArray::AdjustAbsoluteRefs( const ScDocument* pOldDoc, const ScAddres break; case svSingleRef : { - if (!SkipReference(static_cast<ScToken*>(pCode[j]), rOldPos, pOldDoc, false, bCheckCopyRange)) + if (!SkipReference(pCode[j], rOldPos, pOldDoc, false, bCheckCopyRange)) continue; - ScSingleRefData& rRef = *static_cast<ScToken*>(pCode[j])->GetSingleRef(); + ScSingleRefData& rRef = *pCode[j]->GetSingleRef(); // for range names only adjust if all parts are absolute if (!bRangeName || !(rRef.IsColRel() || rRef.IsRowRel() || rRef.IsTabRel())) @@ -2562,7 +2566,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); ScAddress aAbs = rRef.toAbs(rOldPos); @@ -2597,7 +2601,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); ScRange aAbs = rRef.toAbs(rOldPos); @@ -2663,7 +2667,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon { // For external reference, just reset the reference with // respect to the new cell position. - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); ScAddress aAbs = rRef.toAbs(rOldPos); rRef.SetAddress(aAbs, aNewPos); @@ -2672,7 +2676,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon case svExternalDoubleRef: { // Same as above. - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); ScRange aAbs = rRef.toAbs(rOldPos); rRef.SetRange(aAbs, aNewPos); @@ -2716,7 +2720,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove( { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); ScAddress aAbs = rRef.toAbs(rOldPos); if (aOldRange.In(aAbs)) @@ -2732,7 +2736,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove( break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); ScRange aAbs = rRef.toAbs(rOldPos); if (aOldRange.In(aAbs)) @@ -2775,7 +2779,7 @@ sc::RefUpdateResult ScTokenArray::MoveReference( const ScAddress& rPos, const sc { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); ScAddress aAbs = rRef.toAbs(rPos); if (aOldRange.In(aAbs)) @@ -2789,7 +2793,7 @@ sc::RefUpdateResult ScTokenArray::MoveReference( const ScAddress& rPos, const sc break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); ScRange aAbs = rRef.toAbs(rPos); if (aOldRange.In(aAbs)) @@ -2826,7 +2830,7 @@ void ScTokenArray::MoveReferenceColReorder( { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); ScAddress aAbs = rRef.toAbs(rPos); @@ -2846,7 +2850,7 @@ void ScTokenArray::MoveReferenceColReorder( break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); ScRange aAbs = rRef.toAbs(rPos); @@ -2889,7 +2893,7 @@ void ScTokenArray::MoveReferenceRowReorder( const ScAddress& rPos, SCTAB nTab, S { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); ScAddress aAbs = rRef.toAbs(rPos); @@ -2909,7 +2913,7 @@ void ScTokenArray::MoveReferenceRowReorder( const ScAddress& rPos, SCTAB nTab, S break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); ScRange aAbs = rRef.toAbs(rPos); @@ -3038,7 +3042,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceInName( { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); if (adjustSingleRefInName(rRef, rCxt, rPos)) aRes.mbReferenceModified = true; @@ -3046,7 +3050,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceInName( break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); ScRange aAbs = rRef.toAbs(rPos); if (rCxt.maRange.In(aAbs)) @@ -3156,7 +3160,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceInMovedName( const sc::RefUpdat { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); if (rRef.IsColRel() || rRef.IsRowRel() || rRef.IsTabRel()) continue; @@ -3173,7 +3177,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceInMovedName( const sc::RefUpdat break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); if (rRef.Ref1.IsColRel() || rRef.Ref1.IsRowRel() || rRef.Ref1.IsTabRel() || rRef.Ref2.IsColRel() || rRef.Ref2.IsRowRel() || rRef.Ref2.IsTabRel()) @@ -3262,7 +3266,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnDeletedTab( sc::RefUpdateDele { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); if (adjustSingleRefOnDeletedTab(rRef, rCxt.mnDeletePos, rCxt.mnSheets, rOldPos, aNewPos)) aRes.mbReferenceModified = true; @@ -3270,7 +3274,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnDeletedTab( sc::RefUpdateDele break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); if (adjustSingleRefOnDeletedTab(rRef.Ref1, rCxt.mnDeletePos, rCxt.mnSheets, rOldPos, aNewPos)) aRes.mbReferenceModified = true; @@ -3306,7 +3310,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnInsertedTab( sc::RefUpdateIns { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); if (adjustSingleRefOnInsertedTab(rRef, rCxt.mnInsertPos, rCxt.mnSheets, rOldPos, aNewPos)) aRes.mbReferenceModified = true; @@ -3314,7 +3318,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnInsertedTab( sc::RefUpdateIns break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); if (adjustSingleRefOnInsertedTab(rRef.Ref1, rCxt.mnInsertPos, rCxt.mnSheets, rOldPos, aNewPos)) aRes.mbReferenceModified = true; @@ -3367,7 +3371,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMovedTab( sc::RefUpdateMoveTa { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); ScAddress aAbs = rRef.toAbs(rOldPos); if (adjustTabOnMove(aAbs, rCxt)) @@ -3377,7 +3381,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMovedTab( sc::RefUpdateMoveTa break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); ScRange aAbs = rRef.toAbs(rOldPos); if (adjustTabOnMove(aAbs.aStart, rCxt)) @@ -3412,7 +3416,7 @@ void ScTokenArray::AdjustReferenceOnMovedOrigin( const ScAddress& rOldPos, const case svSingleRef: case svExternalSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); ScAddress aAbs = rRef.toAbs(rOldPos); rRef.SetAddress(aAbs, rNewPos); @@ -3421,7 +3425,7 @@ void ScTokenArray::AdjustReferenceOnMovedOrigin( const ScAddress& rOldPos, const case svDoubleRef: case svExternalDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); ScRange aAbs = rRef.toAbs(rOldPos); rRef.SetRange(aAbs, rNewPos); @@ -3460,14 +3464,14 @@ void ScTokenArray::ClearTabDeleted( const ScAddress& rPos, SCTAB nStartTab, SCTA { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); clearTabDeletedFlag(rRef, rPos, nStartTab, nEndTab); } break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); clearTabDeletedFlag(rRef.Ref1, rPos, nStartTab, nEndTab); clearTabDeletedFlag(rRef.Ref2, rPos, nStartTab, nEndTab); @@ -3557,13 +3561,13 @@ void ScTokenArray::CheckRelativeReferenceBounds( { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; checkBounds(rCxt, rPos, nGroupLen, *pToken->GetSingleRef(), rBounds); } break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; const ScComplexRefData& rRef = *pToken->GetDoubleRef(); checkBounds(rCxt, rPos, nGroupLen, rRef.Ref1, rBounds); checkBounds(rCxt, rPos, nGroupLen, rRef.Ref2, rBounds); @@ -3586,14 +3590,14 @@ void ScTokenArray::CheckRelativeReferenceBounds( { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; const ScSingleRefData& rRef = *pToken->GetSingleRef(); checkBounds(rPos, nGroupLen, rRange, rRef, rBounds); } break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; const ScComplexRefData& rRef = *pToken->GetDoubleRef(); checkBounds(rPos, nGroupLen, rRange, rRef.Ref1, rBounds); checkBounds(rPos, nGroupLen, rRange, rRef.Ref2, rBounds); @@ -3650,7 +3654,7 @@ void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, cons break; case svExternalSingleRef: rCxt.mpRefConv->makeExternalRefStr( - rBuf, rPos, nFileId, aFileName, aTabName, *static_cast<const ScToken&>(rToken).GetSingleRef()); + rBuf, rPos, nFileId, aFileName, aTabName, *rToken.GetSingleRef()); break; case svExternalDoubleRef: { @@ -3662,7 +3666,7 @@ void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, cons rCxt.mpRefConv->makeExternalRefStr( rBuf, rPos, nFileId, aFileName, it->second, aTabName, - *static_cast<const ScToken&>(rToken).GetDoubleRef()); + *rToken.GetDoubleRef()); } break; default: @@ -3695,7 +3699,7 @@ void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, cons { if (rCxt.mpRefConv) { - const ScSingleRefData& rRef = *static_cast<const ScToken&>(rToken).GetSingleRef(); + const ScSingleRefData& rRef = *rToken.GetSingleRef(); ScComplexRefData aRef; aRef.Ref1 = rRef; aRef.Ref2 = rRef; @@ -3709,7 +3713,7 @@ void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, cons { if (rCxt.mpRefConv) { - const ScComplexRefData& rRef = *static_cast<const ScToken&>(rToken).GetDoubleRef(); + const ScComplexRefData& rRef = *rToken.GetDoubleRef(); rCxt.mpRefConv->makeRefStr(rBuf, rCxt.meGram, rPos, rCxt.maErrRef, rCxt.maTabNames, rRef, false); } else @@ -3718,7 +3722,7 @@ void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, cons break; case svMatrix: { - const ScMatrix* pMat = static_cast<const ScToken&>(rToken).GetMatrix(); + const ScMatrix* pMat = rToken.GetMatrix(); if (!pMat) return; @@ -3941,7 +3945,7 @@ void ScTokenArray::WrapReference( const ScAddress& rPos, SCCOL nMaxCol, SCROW nM { case svSingleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScSingleRefData& rRef = *pToken->GetSingleRef(); ScAddress aAbs = rRef.toAbs(rPos); wrapAddress(aAbs, nMaxCol, nMaxRow); @@ -3950,7 +3954,7 @@ void ScTokenArray::WrapReference( const ScAddress& rPos, SCCOL nMaxCol, SCROW nM break; case svDoubleRef: { - ScToken* pToken = static_cast<ScToken*>(*p); + formula::FormulaToken* pToken = *p; ScComplexRefData& rRef = *pToken->GetDoubleRef(); ScRange aAbs = rRef.toAbs(rPos); wrapAddress(aAbs.aStart, nMaxCol, nMaxRow); @@ -3967,58 +3971,18 @@ void ScTokenArray::WrapReference( const ScAddress& rPos, SCCOL nMaxCol, SCROW nM #if DEBUG_FORMULA_COMPILER -namespace { - -void dumpFormulaToken( const FormulaToken& rToken ) -{ - cout << "-- FormulaToken" << endl; - cout << " opcode: " << rToken.GetOpCode() << endl; - cout << " type: " << static_cast<int>(rToken.GetType()) << endl; - switch (rToken.GetType()) - { - case svDouble: - cout << " value: " << rToken.GetDouble() << endl; - break; - case svString: - cout << " string: " - << OUStringToOString(rToken.GetString().getString(), RTL_TEXTENCODING_UTF8).getStr() - << endl; - break; - default: - ; - } -} - -} - void ScTokenArray::Dump() const { cout << "+++ Normal Tokens +++" << endl; for (sal_uInt16 i = 0; i < nLen; ++i) { - const FormulaToken* pToken = pCode[i]; - const ScToken* p = dynamic_cast<const ScToken*>(pToken); - if (!p) - { - dumpFormulaToken(*pToken); - continue; - } - - DumpToken(*p); + DumpToken(*pCode[i]); } cout << "+++ RPN Tokens +++" << endl; for (sal_uInt16 i = 0; i < nRPN; ++i) { - const FormulaToken* pToken = pRPN[i]; - const ScToken* p = dynamic_cast<const ScToken*>(pToken); - if (!p) - { - dumpFormulaToken(*pToken); - continue; - } - - DumpToken(*p); + DumpToken(*pRPN[i]); } } #endif diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx index b64285a932ec..305067872e7a 100644 --- a/sc/source/filter/excel/xechart.cxx +++ b/sc/source/filter/excel/xechart.cxx @@ -922,7 +922,7 @@ sal_uInt16 XclExpChSourceLink::ConvertDataSequence( Reference< XDataSequence > x case ::formula::svExternalDoubleRef: { // split 3-dimensional ranges into single sheets - const ScComplexRefData& rComplexRef = *static_cast< const ScToken* >( pToken )->GetDoubleRef(); + const ScComplexRefData& rComplexRef = *pToken->GetDoubleRef(); ScAddress aAbs1 = rComplexRef.Ref1.toAbs(ScAddress()); ScAddress aAbs2 = rComplexRef.Ref2.toAbs(ScAddress()); for (SCsTAB nScTab = aAbs1.Tab(); nScTab <= aAbs2.Tab(); ++nScTab) diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx index a64a6354bea3..214d979e991e 100644 --- a/sc/source/filter/excel/xeformula.cxx +++ b/sc/source/filter/excel/xeformula.cxx @@ -1258,7 +1258,7 @@ void XclExpFmlaCompImpl::ProcessExternal( const XclExpScToken& rTokData ) void XclExpFmlaCompImpl::ProcessMatrix( const XclExpScToken& rTokData ) { - const ScMatrix* pMatrix = static_cast< const ScToken* >( rTokData.mpScToken )->GetMatrix(); + const ScMatrix* pMatrix = rTokData.mpScToken->GetMatrix(); if( pMatrix && mxData->mrCfg.mbAllowArrays ) { SCSIZE nScCols, nScRows; @@ -1901,7 +1901,7 @@ void XclExpFmlaCompImpl::ProcessCellRef( const XclExpScToken& rTokData ) { // get the Excel address components, adjust internal data in aRefData bool bNatLangRef = (meBiff == EXC_BIFF8) && mxData->mpScBasePos && (rTokData.GetOpCode() == ocColRowName); - ScSingleRefData aRefData = *static_cast< const ScToken* >( rTokData.mpScToken )->GetSingleRef(); + ScSingleRefData aRefData = *rTokData.mpScToken->GetSingleRef(); XclAddress aXclPos( ScAddress::UNINITIALIZED ); ConvertRefData( aRefData, aXclPos, bNatLangRef, false, false ); @@ -1958,7 +1958,7 @@ void XclExpFmlaCompImpl::ProcessCellRef( const XclExpScToken& rTokData ) void XclExpFmlaCompImpl::ProcessRangeRef( const XclExpScToken& rTokData ) { // get the Excel address components, adjust internal data in aRefData - ScComplexRefData aRefData = *static_cast< const ScToken* >( rTokData.mpScToken )->GetDoubleRef(); + ScComplexRefData aRefData = *rTokData.mpScToken->GetDoubleRef(); XclRange aXclRange( ScAddress::UNINITIALIZED ); ConvertRefData( aRefData, aXclRange, false ); @@ -2005,7 +2005,7 @@ void XclExpFmlaCompImpl::ProcessExternalCellRef( const XclExpScToken& rTokData ) if( mxData->mpLinkMgr ) { // get the Excel address components, adjust internal data in aRefData - ScSingleRefData aRefData = *static_cast< const ScToken* >( rTokData.mpScToken )->GetSingleRef(); + ScSingleRefData aRefData = *rTokData.mpScToken->GetSingleRef(); XclAddress aXclPos( ScAddress::UNINITIALIZED ); ConvertRefData( aRefData, aXclPos, false, false, false ); @@ -2041,7 +2041,7 @@ void XclExpFmlaCompImpl::ProcessExternalRangeRef( const XclExpScToken& rTokData if( mxData->mpLinkMgr ) { // get the Excel address components, adjust internal data in aRefData - ScComplexRefData aRefData = *static_cast< const ScToken* >( rTokData.mpScToken )->GetDoubleRef(); + ScComplexRefData aRefData = *rTokData.mpScToken->GetDoubleRef(); XclRange aXclRange( ScAddress::UNINITIALIZED ); ConvertRefData( aRefData, aXclRange, false ); @@ -2127,14 +2127,14 @@ void XclExpFmlaCompImpl::ProcessExternalName( const XclExpScToken& rTokData ) { case svExternalSingleRef: { - ScSingleRefData aRefData = *static_cast< ScToken* >( pScToken )->GetSingleRef(); + ScSingleRefData aRefData = *pScToken->GetSingleRef(); mxData->mpLinkMgr->StoreCell( nFileId, pScToken->GetString().getString(), aRefData.toAbs(*mxData->mpScBasePos)); } break; case svExternalDoubleRef: { - ScComplexRefData aRefData = *static_cast< ScToken* >( pScToken )->GetDoubleRef(); + ScComplexRefData aRefData = *pScToken->GetDoubleRef(); mxData->mpLinkMgr->StoreCellRange( nFileId, pScToken->GetString().getString(), aRefData.toAbs(*mxData->mpScBasePos)); } diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx index e9ff858420ad..bd34008f0967 100644 --- a/sc/source/filter/excel/xelink.cxx +++ b/sc/source/filter/excel/xelink.cxx @@ -969,7 +969,7 @@ void XclExpExtName::WriteAddData( XclExpStream& rStrm ) if (mpArray->GetLen() != 1) break; - const ScToken* p = static_cast<const ScToken*>(mpArray->First()); + const formula::FormulaToken* p = mpArray->First(); if (!p->IsExternalRef()) break; diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index f9c84583c2bd..97a31c693eb1 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -156,7 +156,7 @@ XclExpArrayRef XclExpArrayBuffer::FindArray( const ScTokenArray& rScTokArr, cons // not a matrix reference token. return xRec; - const ScSingleRefData& rRef = *static_cast<const ScToken*>(pToken)->GetSingleRef(); + const ScSingleRefData& rRef = *pToken->GetSingleRef(); ScAddress aAbsPos = rRef.toAbs(rBasePos); XclExpArrayMap::const_iterator it = maRecMap.find(aAbsPos); @@ -212,7 +212,7 @@ bool XclExpShrfmlaBuffer::IsValidTokenArray( const ScTokenArray& rArray ) const { case svSingleRef: { - const ScSingleRefData& rRefData = *static_cast<const ScToken*>(p)->GetSingleRef(); + const ScSingleRefData& rRefData = *p->GetSingleRef(); if (!GetFormulaCompiler().IsRef2D(rRefData)) // Excel's shared formula cannot include 3D reference. return false; @@ -220,7 +220,7 @@ bool XclExpShrfmlaBuffer::IsValidTokenArray( const ScTokenArray& rArray ) const break; case svDoubleRef: { - const ScComplexRefData& rRefData = *static_cast<const ScToken*>(p)->GetDoubleRef(); + const ScComplexRefData& rRefData = *p->GetDoubleRef(); if (!GetFormulaCompiler().IsRef2D(rRefData)) // Excel's shared formula cannot include 3D reference. return false; diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx index ad0836f9d4c1..b40f61ae773c 100644 --- a/sc/source/filter/excel/xichart.cxx +++ b/sc/source/filter/excel/xichart.cxx @@ -780,7 +780,7 @@ sal_uInt16 XclImpChSourceLink::GetCellCount() const case ::formula::svExternalDoubleRef: { // cell range - const ScComplexRefData& rComplexRef = *static_cast< const ScToken* >( pToken )->GetDoubleRef(); + const ScComplexRefData& rComplexRef = *pToken->GetDoubleRef(); ScAddress aAbs1 = rComplexRef.Ref1.toAbs(ScAddress()); ScAddress aAbs2 = rComplexRef.Ref2.toAbs(ScAddress()); sal_uInt32 nTabs = static_cast<sal_uInt32>(aAbs2.Tab() - aAbs1.Tab() + 1); @@ -882,7 +882,7 @@ void XclImpChSourceLink::FillSourceLink( ::std::vector< ScTokenRef >& rTokens ) mxTokenArray->Reset(); for (FormulaToken* p = mxTokenArray->First(); p; p = mxTokenArray->Next()) { - ScTokenRef pToken(static_cast<ScToken*>(p->Clone())); + ScTokenRef pToken(p->Clone()); if (ScRefTokenHelper::isRef(pToken)) // This is a reference token. Store it. ScRefTokenHelper::join(rTokens, pToken, ScAddress()); diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index d345fa240683..d50b163e8d4d 100644 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -884,7 +884,7 @@ inline bool lclGetAddress( ScAddress& rAddress, const FormulaToken& rToken, cons bool bIsSingleRef = (eOpCode == ocPush) && (rToken.GetType() == svSingleRef); if( bIsSingleRef ) { - const ScSingleRefData& rRef = *static_cast<const ScToken&>(rToken).GetSingleRef(); + const ScSingleRefData& rRef = *rToken.GetSingleRef(); rAddress = rRef.toAbs(rPos); bIsSingleRef = !rRef.IsDeleted(); } diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index ec3ecf116ca4..47f4682d985e 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -205,8 +205,8 @@ bool hasRefsToSrcDoc(ScRangeData& rData, sal_uInt16 nFileId) return false; pArray->Reset(); - ScToken* p = static_cast<ScToken*>(pArray->GetNextReference()); - for (; p; p = static_cast<ScToken*>(pArray->GetNextReference())) + formula::FormulaToken* p = pArray->GetNextReference(); + for (; p; p = pArray->GetNextReference()) { if (!p->IsExternalRef()) continue; @@ -2185,20 +2185,20 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokensFromSr { case svSingleRef: { - const ScSingleRefData& rRef = *static_cast<const ScToken*>(pToken)->GetSingleRef(); + const ScSingleRefData& rRef = *pToken->GetSingleRef(); OUString aTabName; pSrcDoc->GetName(rRef.Tab(), aTabName); - ScExternalSingleRefToken aNewToken(nFileId, aTabName, *static_cast<const ScToken*>(pToken)->GetSingleRef()); + ScExternalSingleRefToken aNewToken(nFileId, aTabName, *pToken->GetSingleRef()); pNew->AddToken(aNewToken); bTokenAdded = true; } break; case svDoubleRef: { - const ScSingleRefData& rRef = *static_cast<const ScToken*>(pToken)->GetSingleRef(); + const ScSingleRefData& rRef = *pToken->GetSingleRef(); OUString aTabName; pSrcDoc->GetName(rRef.Tab(), aTabName); - ScExternalDoubleRefToken aNewToken(nFileId, aTabName, *static_cast<const ScToken*>(pToken)->GetDoubleRef()); + ScExternalDoubleRefToken aNewToken(nFileId, aTabName, *pToken->GetDoubleRef()); pNew->AddToken(aNewToken); bTokenAdded = true; } diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx index 3e182f8ad1d9..3de5d0532c12 100644 --- a/sc/source/ui/miscdlgs/anyrefdg.cxx +++ b/sc/source/ui/miscdlgs/anyrefdg.cxx @@ -196,7 +196,7 @@ void ScFormulaReferenceHelper::ShowFormulaReference(const OUString& rStr) pTabViewShell->ClearHighlightRanges(); pScTokA->Reset(); - const ScToken* pToken = static_cast<const ScToken*>(pScTokA->GetNextReference()); + const formula::FormulaToken* pToken = pScTokA->GetNextReference(); sal_uInt16 nIndex=0; @@ -222,7 +222,7 @@ void ScFormulaReferenceHelper::ShowFormulaReference(const OUString& rStr) pTabViewShell->AddHighlightRange(aRange, aColName); } - pToken = static_cast<const ScToken*>(pScTokA->GetNextReference()); + pToken = pScTokA->GetNextReference(); } } } diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index b083634ed971..15495c4c77d6 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -197,7 +197,7 @@ vector<ScTokenRef>* TokenTable::getColRanges(SCCOL nCol) const if (!p) continue; - ScTokenRef pCopy(static_cast<ScToken*>(p->Clone())); + ScTokenRef pCopy(p->Clone()); ScRefTokenHelper::join(*pTokens, pCopy, ScAddress()); } return pTokens.release(); @@ -218,7 +218,7 @@ vector<ScTokenRef>* TokenTable::getRowRanges(SCROW nRow) const if (!p) continue; - ScTokenRef p2(static_cast<ScToken*>(p->Clone())); + ScTokenRef p2(p->Clone()); ScRefTokenHelper::join(*pTokens, p2, ScAddress()); } return pTokens.release(); @@ -234,7 +234,7 @@ vector<ScTokenRef>* TokenTable::getAllRanges() const if (!p) continue; - ScTokenRef p2(static_cast<ScToken*>(p->Clone())); + ScTokenRef p2(p->Clone()); ScRefTokenHelper::join(*pTokens, p2, ScAddress()); } return pTokens.release(); @@ -310,7 +310,7 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount, StackVar eType = pToken->GetType(); if( eType==svExternal || eType==svExternalSingleRef || eType==svExternalDoubleRef || eType==svExternalName ) bExternal = true;//lllll todo correct? - ScTokenRef pSharedToken(static_cast<ScToken*>(pToken->Clone())); + ScTokenRef pSharedToken(pToken->Clone()); ScRefTokenHelper::getRangeFromToken(aRange, pSharedToken, ScAddress(), bExternal); SCCOL nCol1=0, nCol2=0; SCROW nRow1=0, nRow2=0; @@ -2216,7 +2216,7 @@ ScChart2DataProvider::createDataSequenceByFormulaTokens( case svExternalSingleRef: case svExternalDoubleRef: { - ScTokenRef pNew(static_cast<ScToken*>(p->Clone())); + ScTokenRef pNew(p->Clone()); aRefTokens.push_back(pNew); } break; @@ -2706,7 +2706,7 @@ sal_Int32 ScChart2DataSequence::FillCacheFromExternalRef(const ScTokenRef& pToke continue; } - const ScMatrix* pMat = static_cast<ScToken*>(p)->GetMatrix(); + const ScMatrix* pMat = p->GetMatrix(); SCSIZE nCSize, nRSize; pMat->GetDimensions(nCSize, nRSize); for (SCSIZE nC = 0; nC < nCSize; ++nC) @@ -3353,7 +3353,7 @@ uno::Reference< util::XCloneable > SAL_CALL ScChart2DataSequence::createClone() vector<ScTokenRef>::const_iterator itr = m_pTokens->begin(), itrEnd = m_pTokens->end(); for (; itr != itrEnd; ++itr) { - ScTokenRef p(static_cast<ScToken*>((*itr)->Clone())); + ScTokenRef p((*itr)->Clone()); pTokensNew->push_back(p); } } @@ -3521,7 +3521,7 @@ uno::Any SAL_CALL ScChart2DataSequence::getPropertyValue(const OUString& rProper bool bHasStringLabel = false; if (m_pTokens->size() == 1) { - const ScToken& rToken = *(*m_pTokens)[0]; + const formula::FormulaToken& rToken = *(*m_pTokens)[0]; bHasStringLabel = rToken.GetType() == formula::svString; } aRet <<= bHasStringLabel; diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx index b82383d1cbd9..207d69a15e43 100644 --- a/sc/source/ui/unoobj/tokenuno.cxx +++ b/sc/source/ui/unoobj/tokenuno.cxx @@ -408,15 +408,15 @@ bool ScTokenConversion::ConvertToTokenSequence( const ScDocument& rDoc, case svSingleRef: { sheet::SingleReference aSingleRef; - lcl_SingleRefToApi( aSingleRef, *static_cast<const ScToken&>(rToken).GetSingleRef() ); + lcl_SingleRefToApi( aSingleRef, *rToken.GetSingleRef() ); rAPI.Data <<= aSingleRef; } break; case formula::svDoubleRef: { sheet::ComplexReference aCompRef; - lcl_SingleRefToApi( aCompRef.Reference1, *static_cast<const ScToken&>(rToken).GetSingleRef() ); - lcl_SingleRefToApi( aCompRef.Reference2, *static_cast<const ScToken&>(rToken).GetSingleRef2() ); + lcl_SingleRefToApi( aCompRef.Reference1, *rToken.GetSingleRef() ); + lcl_SingleRefToApi( aCompRef.Reference2, *rToken.GetSingleRef2() ); rAPI.Data <<= aCompRef; } break; @@ -429,13 +429,13 @@ bool ScTokenConversion::ConvertToTokenSequence( const ScDocument& rDoc, } break; case svMatrix: - if (!ScRangeToSequence::FillMixedArray( rAPI.Data, static_cast<const ScToken&>(rToken).GetMatrix(), true)) + if (!ScRangeToSequence::FillMixedArray( rAPI.Data, rToken.GetMatrix(), true)) rAPI.Data.clear(); break; case svExternalSingleRef: { sheet::SingleReference aSingleRef; - lcl_ExternalRefToApi( aSingleRef, *static_cast<const ScToken&>(rToken).GetSingleRef() ); + lcl_ExternalRefToApi( aSingleRef, *rToken.GetSingleRef() ); size_t nCacheId; rDoc.GetExternalRefManager()->getCacheTable( rToken.GetIndex(), rToken.GetString().getString(), false, &nCacheId); @@ -450,8 +450,8 @@ bool ScTokenConversion::ConvertToTokenSequence( const ScDocument& rDoc, case svExternalDoubleRef: { sheet::ComplexReference aComplRef; - lcl_ExternalRefToApi( aComplRef.Reference1, *static_cast<const ScToken&>(rToken).GetSingleRef() ); - lcl_ExternalRefToApi( aComplRef.Reference2, *static_cast<const ScToken&>(rToken).GetSingleRef2() ); + lcl_ExternalRefToApi( aComplRef.Reference1, *rToken.GetSingleRef() ); + lcl_ExternalRefToApi( aComplRef.Reference2, *rToken.GetSingleRef2() ); size_t nCacheId; rDoc.GetExternalRefManager()->getCacheTable( rToken.GetIndex(), rToken.GetString().getString(), false, &nCacheId); @@ -459,7 +459,7 @@ bool ScTokenConversion::ConvertToTokenSequence( const ScDocument& rDoc, // NOTE: This assumes that cached sheets are in consecutive order! aComplRef.Reference2.Sheet = aComplRef.Reference1.Sheet + - (static_cast<const ScToken&>(rToken).GetSingleRef2()->Tab() - static_cast<const ScToken&>(rToken).GetSingleRef()->Tab()); + (rToken.GetSingleRef2()->Tab() - rToken.GetSingleRef()->Tab()); sheet::ExternalReference aExtRef; aExtRef.Index = rToken.GetIndex(); aExtRef.Reference <<= aComplRef; |