summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@erack.de>2011-08-24 01:39:19 +0200
committerEike Rathke <erack@erack.de>2011-08-24 01:39:43 +0200
commitfcac4e3eb4df6dcd4d6f6955a5d369262bcd1ea4 (patch)
tree2b48f9ffe8469737fe4ee297c0ffe1c83f228881
parent326494b71ce56488760d42c245df745deb713b16 (diff)
replace ScNameToken with proper FormulaIndexToken
-rw-r--r--formula/inc/formula/token.hxx5
-rw-r--r--formula/source/core/api/token.cxx21
-rw-r--r--sc/inc/token.hxx18
-rw-r--r--sc/source/core/data/cell.cxx4
-rw-r--r--sc/source/core/tool/compiler.cxx4
-rw-r--r--sc/source/core/tool/token.cxx40
-rw-r--r--sc/source/filter/excel/xeformula.cxx2
-rw-r--r--sc/source/ui/unoobj/tokenuno.cxx2
8 files changed, 29 insertions, 67 deletions
diff --git a/formula/inc/formula/token.hxx b/formula/inc/formula/token.hxx
index 41b68effe6e0..738caa1a63dd 100644
--- a/formula/inc/formula/token.hxx
+++ b/formula/inc/formula/token.hxx
@@ -150,6 +150,8 @@ public:
virtual const String& GetString() const;
virtual sal_uInt16 GetIndex() const;
virtual void SetIndex( sal_uInt16 n );
+ virtual bool IsGlobal() const;
+ virtual void SetGlobal( bool b );
virtual short* GetJump() const;
virtual const String& GetExternal() const;
virtual FormulaToken* GetFAPOrigToken() const;
@@ -311,8 +313,9 @@ public:
virtual FormulaToken* Clone() const { return new FormulaIndexToken(*this); }
virtual sal_uInt16 GetIndex() const;
- virtual sal_uInt8 GetByte() const;
virtual void SetIndex( sal_uInt16 n );
+ virtual bool IsGlobal() const;
+ virtual void SetGlobal( bool b );
virtual bool operator==( const FormulaToken& rToken ) const;
};
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 8703fd8ba5fc..57469d334d89 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -212,6 +212,17 @@ void FormulaToken::SetIndex( sal_uInt16 )
DBG_ERRORFILE( "FormulaToken::SetIndex: virtual dummy called" );
}
+bool FormulaToken::IsGlobal() const
+{
+ DBG_ERRORFILE( "FormulaToken::IsGlobal: virtual dummy called" );
+ return true;
+}
+
+void FormulaToken::SetGlobal( bool )
+{
+ DBG_ERRORFILE( "FormulaToken::SetGlobal: virtual dummy called" );
+}
+
short* FormulaToken::GetJump() const
{
DBG_ERRORFILE( "FormulaToken::GetJump: virtual dummy called" );
@@ -1346,12 +1357,14 @@ bool FormulaStringOpToken::operator==( const FormulaToken& r ) const
return FormulaByteToken::operator==( r ) && aString == r.GetString();
}
-sal_uInt16 FormulaIndexToken::GetIndex() const { return nIndex; }
-sal_uInt8 FormulaIndexToken::GetByte() const {return static_cast<sal_uInt8>(mbGlobal); }
-void FormulaIndexToken::SetIndex( sal_uInt16 n ) { nIndex = n; }
+sal_uInt16 FormulaIndexToken::GetIndex() const { return nIndex; }
+void FormulaIndexToken::SetIndex( sal_uInt16 n ) { nIndex = n; }
+bool FormulaIndexToken::IsGlobal() const { return mbGlobal; }
+void FormulaIndexToken::SetGlobal( bool b ) { mbGlobal = b; }
bool FormulaIndexToken::operator==( const FormulaToken& r ) const
{
- return FormulaToken::operator==( r ) && nIndex == r.GetIndex();
+ return FormulaToken::operator==( r ) && nIndex == r.GetIndex() &&
+ mbGlobal == r.IsGlobal();
}
const String& FormulaExternalToken::GetExternal() const { return aExternal; }
sal_uInt8 FormulaExternalToken::GetByte() const { return nByte; }
diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index cec672fddb95..90c9dfbc48ac 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -236,24 +236,6 @@ public:
virtual FormulaToken* Clone() const { return new ScExternalDoubleRefToken(*this); }
};
-class ScNameToken : public ScToken
-{
-private:
- sal_uInt16 mnIndex;
- bool mbGlobal; // true = global, false = local
-private:
- ScNameToken(); // disabled
-public:
- ScNameToken(sal_uInt16 nIndex, bool bGlobal, OpCode eOpCode = ocName);
- ScNameToken(const ScNameToken& r);
- virtual ~ScNameToken();
- virtual sal_uInt8 GetByte() const;
- virtual void SetByte(sal_uInt8 aGlobal);
- virtual sal_uInt16 GetIndex() const;
- virtual bool operator==( const formula::FormulaToken& rToken ) const;
- virtual FormulaToken* Clone() const { return new ScNameToken(*this); }
-};
-
class ScExternalNameToken : public ScToken
{
private:
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 4d030ccd6aea..d2700c09adb3 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -133,7 +133,7 @@ ScBaseCell* lclCloneCell( const ScBaseCell& rSrcCell, ScDocument& rDestDoc, cons
void adjustRangeName(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldDoc, const ScAddress& aNewPos, const ScAddress& aOldPos)
{
- bool bOldGlobal = static_cast<bool>(pToken->GetByte());
+ bool bOldGlobal = pToken->IsGlobal();
SCTAB aOldTab = aOldPos.Tab();
rtl::OUString aRangeName;
int nOldIndex = pToken->GetIndex();
@@ -183,7 +183,7 @@ void adjustRangeName(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOl
}
sal_Int32 nIndex = pRangeData->GetIndex();
pToken->SetIndex(nIndex);
- pToken->SetByte(bNewGlobal);
+ pToken->SetGlobal(bNewGlobal);
}
void adjustDBRange(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldDoc)
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index ab918071e09e..8d1ad64e4742 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3979,7 +3979,7 @@ bool ScCompiler::HandleRange()
{
ScRangeData* pRangeData = NULL;
- bool bGlobal = pToken->GetByte();
+ bool bGlobal = pToken->IsGlobal();
if (bGlobal)
// global named range.
pRangeData = pDoc->GetRangeName()->findByIndex( pToken->GetIndex() );
@@ -5157,7 +5157,7 @@ void ScCompiler::CreateStringFromIndex(rtl::OUStringBuffer& rBuffer,FormulaToken
{
case ocName:
{
- bool bGlobal = _pTokenP->GetByte();
+ bool bGlobal = _pTokenP->IsGlobal();
ScRangeData* pData = NULL;
if (bGlobal)
// global named range.
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index e9c4e67b718c..c34a1ac9d801 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -388,7 +388,7 @@ FormulaToken* ScRawToken::CreateToken() const
IF_NOT_OPCODE_ERROR( ocPush, ScMatrixToken);
return new ScMatrixToken( pMat );
case svIndex :
- return new ScNameToken(name.nIndex, name.bGlobal, eOp);
+ return new FormulaIndexToken( eOp, name.nIndex, name.bGlobal);
case svExternalSingleRef:
{
String aTabName(extref.cTabName);
@@ -959,42 +959,6 @@ bool ScExternalDoubleRefToken::operator ==( const FormulaToken& r ) const
// ============================================================================
-ScNameToken::ScNameToken(sal_uInt16 nIndex, bool bGlobal, OpCode eOpCode) :
- ScToken(svIndex, eOpCode), mnIndex(nIndex), mbGlobal(bGlobal) {}
-
-ScNameToken::ScNameToken(const ScNameToken& r) :
- ScToken(r), mnIndex(r.mnIndex), mbGlobal(r.mbGlobal) {}
-
-ScNameToken::~ScNameToken() {}
-
-sal_uInt8 ScNameToken::GetByte() const
-{
- return static_cast<sal_uInt8>(mbGlobal);
-}
-
-void ScNameToken::SetByte(sal_uInt8 aGlobal)
-{
- mbGlobal = static_cast<bool>(aGlobal);
-}
-
-sal_uInt16 ScNameToken::GetIndex() const
-{
- return mnIndex;
-}
-
-bool ScNameToken::operator==( const FormulaToken& r ) const
-{
- if ( !FormulaToken::operator==(r) )
- return false;
-
- if (mbGlobal != static_cast<bool>(r.GetByte()))
- return false;
-
- return mnIndex == r.GetIndex();
-}
-
-// ============================================================================
-
ScExternalNameToken::ScExternalNameToken( sal_uInt16 nFileId, const String& rName ) :
ScToken( svExternalName, ocPush),
mnFileId(nFileId),
@@ -1637,7 +1601,7 @@ FormulaToken* ScTokenArray::AddMatrix( const ScMatrixRef& p )
FormulaToken* ScTokenArray::AddRangeName( sal_uInt16 n, bool bGlobal )
{
- return Add(new ScNameToken(n, bGlobal));
+ return Add( new FormulaIndexToken( ocName, n, bGlobal));
}
FormulaToken* ScTokenArray::AddExternalName( sal_uInt16 nFileId, const String& rName )
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index a3ab112d4525..86acbc47da38 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -2053,7 +2053,7 @@ void XclExpFmlaCompImpl::ProcessExternalRangeRef( const XclExpScToken& rTokData
void XclExpFmlaCompImpl::ProcessDefinedName( const XclExpScToken& rTokData )
{
SCTAB nTab = SCTAB_GLOBAL;
- bool bGlobal = static_cast<bool>(rTokData.mpScToken->GetByte());
+ bool bGlobal = rTokData.mpScToken->IsGlobal();
if (!bGlobal && mxData->mpScBasePos)
nTab = mxData->mpScBasePos->Tab();
diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx
index 2e6658b2b57f..a963834ca09a 100644
--- a/sc/source/ui/unoobj/tokenuno.cxx
+++ b/sc/source/ui/unoobj/tokenuno.cxx
@@ -399,7 +399,7 @@ bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc,
{
sheet::NameToken aNameToken;
aNameToken.Index = static_cast<sal_Int32>( rToken.GetIndex() );
- aNameToken.Global = static_cast<sal_Bool>( rToken.GetByte() );
+ aNameToken.Global = static_cast<sal_Bool>( rToken.IsGlobal() );
rAPI.Data <<= aNameToken;
}
break;