diff options
-rw-r--r-- | sc/inc/compiler.hxx | 4 | ||||
-rw-r--r-- | sc/inc/token.hxx | 25 | ||||
-rw-r--r-- | sc/source/core/tool/token.cxx | 22 |
3 files changed, 42 insertions, 9 deletions
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx index acfdad69fcdb..298e341f8cd7 100644 --- a/sc/inc/compiler.hxx +++ b/sc/inc/compiler.hxx @@ -26,6 +26,7 @@ #include "scdllapi.h" #include "global.hxx" #include "refdata.hxx" +#include "token.hxx" #include <formula/token.hxx> #include <formula/grammar.hxx> #include <unotools/charclass.hxx> @@ -137,7 +138,8 @@ public: sal_uInt16 nIndex; } name; struct { - sal_uInt16 nIndex; + sal_uInt16 nIndex; + ScTableRefToken::Item eItem; } table; struct { rtl_uString* mpData; diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx index 8d0d3338f8ec..5564a200d257 100644 --- a/sc/inc/token.hxx +++ b/sc/inc/token.hxx @@ -211,17 +211,34 @@ public: /** Special token to remember details of ocTableRef "structured references". */ class ScTableRefToken : public formula::FormulaToken { - sal_uInt16 mnIndex; ///< index into table / database range collection - - ScTableRefToken(); // disabled public: - ScTableRefToken( sal_uInt16 nIndex ); + + enum Item + { + ALL = 0, + HEADERS = 1, + DATA = 2, + TOTALS = 4, + THIS_ROW = 8 + }; + + ScTableRefToken( sal_uInt16 nIndex, Item eItem ); ScTableRefToken( const ScTableRefToken& r ); virtual ~ScTableRefToken(); virtual sal_uInt16 GetIndex() const SAL_OVERRIDE; virtual bool operator==( const formula::FormulaToken& rToken ) const SAL_OVERRIDE; virtual FormulaToken* Clone() const SAL_OVERRIDE { return new ScTableRefToken(*this); } + + Item GetItem() const; + +private: + + sal_uInt16 mnIndex; ///< index into table / database range collection + Item meItem; + + ScTableRefToken(); // disabled + }; // Only created from within the interpreter, no conversion from ScRawToken, diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 96e3b58e8d65..b38c3708600a 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -329,7 +329,7 @@ FormulaToken* ScRawToken::CreateToken() const return new ScMatrixToken( pMat ); case svIndex : if (eOp == ocTableRef) - return new ScTableRefToken( table.nIndex); + return new ScTableRefToken( table.nIndex, table.eItem); else return new FormulaIndexToken( eOp, name.nIndex, name.bGlobal); case svExternalSingleRef: @@ -828,15 +828,17 @@ bool ScExternalNameToken::operator==( const FormulaToken& r ) const return maName.getData() == r.GetString().getData(); } -ScTableRefToken::ScTableRefToken( sal_uInt16 nIndex ) : +ScTableRefToken::ScTableRefToken( sal_uInt16 nIndex, ScTableRefToken::Item eItem ) : FormulaToken( svIndex, ocTableRef), - mnIndex(nIndex) + mnIndex(nIndex), + meItem(eItem) { } ScTableRefToken::ScTableRefToken( const ScTableRefToken& r ) : FormulaToken(r), - mnIndex(r.mnIndex) + mnIndex(r.mnIndex), + meItem(r.meItem) { } @@ -847,6 +849,11 @@ sal_uInt16 ScTableRefToken::GetIndex() const return mnIndex; } +ScTableRefToken::Item ScTableRefToken::GetItem() const +{ + return meItem; +} + bool ScTableRefToken::operator==( const FormulaToken& r ) const { if ( !FormulaToken::operator==(r) ) @@ -855,6 +862,13 @@ bool ScTableRefToken::operator==( const FormulaToken& r ) const if (mnIndex != r.GetIndex()) return false; + const ScTableRefToken* p = dynamic_cast<const ScTableRefToken*>(&r); + if (!p) + return false; + + if (meItem != p->GetItem()) + return false; + return true; } |