[Libreoffice-commits] .: formula/inc formula/source sc/inc sc/source
Eike Rathke
erack at kemper.freedesktop.org
Tue Aug 23 16:39:55 PDT 2011
formula/inc/formula/token.hxx | 5 +++-
formula/source/core/api/token.cxx | 21 ++++++++++++++----
sc/inc/token.hxx | 18 ---------------
sc/source/core/data/cell.cxx | 4 +--
sc/source/core/tool/compiler.cxx | 4 +--
sc/source/core/tool/token.cxx | 40 +----------------------------------
sc/source/filter/excel/xeformula.cxx | 2 -
sc/source/ui/unoobj/tokenuno.cxx | 2 -
8 files changed, 29 insertions(+), 67 deletions(-)
New commits:
commit fcac4e3eb4df6dcd4d6f6955a5d369262bcd1ea4
Author: Eike Rathke <erack at erack.de>
Date: Wed Aug 24 01:39:19 2011 +0200
replace ScNameToken with proper FormulaIndexToken
diff --git a/formula/inc/formula/token.hxx b/formula/inc/formula/token.hxx
index 41b68ef..738caa1 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 8703fd8..57469d3 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 cec672f..90c9dfb 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 4d030cc..d2700c0 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 ab91807..8d1ad64 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 e9c4e67..c34a1ac 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 a3ab112..86acbc4 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 2e6658b..a963834 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;
More information about the Libreoffice-commits
mailing list