summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-03-20 14:43:53 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-03-22 21:49:17 -0400
commit76c0e26b2d2906ca2199e4294d7433533c78f8e3 (patch)
tree14464fd71fca02fe52facc61ad6b8c8878acc103
parent8aac68741b17a1d161137b12c78d47c8b3e91c68 (diff)
Let's use ScTokenArray instead of ScFormulaCell.
Because we may move away from ScFormulaCell too. Change-Id: Iafafe3c864efa73330fb8ecbb713caa903e23db5
-rw-r--r--sc/inc/column.hxx1
-rw-r--r--sc/inc/document.hxx1
-rw-r--r--sc/inc/table.hxx3
-rw-r--r--sc/inc/tokenarray.hxx2
-rw-r--r--sc/source/core/data/column3.cxx12
-rw-r--r--sc/source/core/data/document.cxx7
-rw-r--r--sc/source/core/data/table2.cxx10
-rw-r--r--sc/source/ui/docshell/docfunc.cxx6
-rw-r--r--sc/source/ui/inc/undocell.hxx4
-rw-r--r--sc/source/ui/undo/undocell.cxx8
10 files changed, 42 insertions, 12 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 558b83f3bdef..edfa5f4c2401 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -273,6 +273,7 @@ public:
double GetValue( SCROW nRow ) const;
const EditTextObject* GetEditText( SCROW nRow ) const;
void GetFormula( SCROW nRow, rtl::OUString& rFormula ) const;
+ const ScTokenArray* GetFormula( SCROW nRow ) const;
CellType GetCellType( SCROW nRow ) const;
SCSIZE GetCellCount() const;
sal_uInt32 GetWeightedCount() const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 6d0028782967..22fdec68c79e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -820,6 +820,7 @@ public:
SC_DLLPUBLIC void GetNumberFormatInfo( short& nType, sal_uLong& nIndex,
const ScAddress& rPos, const ScBaseCell* pCell ) const;
void GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rFormula ) const;
+ const ScTokenArray* GetFormula( const ScAddress& rPos ) const;
SC_DLLPUBLIC void GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab, rtl::OUString& rFormula ) const;
SC_DLLPUBLIC void GetCellType( SCCOL nCol, SCROW nRow, SCTAB nTab, CellType& rCellType ) const;
SC_DLLPUBLIC CellType GetCellType( const ScAddress& rPos ) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index b87ecfe39e7a..84b5e0c285b8 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -324,7 +324,8 @@ public:
}
double GetValue( SCCOL nCol, SCROW nRow ) const;
const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const;
- void GetFormula( SCCOL nCol, SCROW nRow, rtl::OUString& rFormula );
+ void GetFormula( SCCOL nCol, SCROW nRow, rtl::OUString& rFormula ) const;
+ const ScTokenArray* GetFormula( SCCOL nCol, SCROW nRow ) const;
CellType GetCellType( const ScAddress& rPos ) const
{
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 2449074532c5..32a266d91fc7 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -44,7 +44,7 @@ public:
ScTokenArray();
/// Assignment with references to ScToken entries (not copied!)
ScTokenArray( const ScTokenArray& );
- virtual ~ScTokenArray();
+ virtual ~ScTokenArray();
ScTokenArray* Clone() const; /// True copy!
void GenHash();
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 469c818bd490..e9143447152c 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1823,6 +1823,18 @@ void ScColumn::GetFormula( SCROW nRow, rtl::OUString& rFormula ) const
rFormula = rtl::OUString();
}
+const ScTokenArray* ScColumn::GetFormula( SCROW nRow ) const
+{
+ SCSIZE nIndex;
+ if (!Search(nRow, nIndex))
+ return NULL;
+
+ const ScBaseCell* pCell = maItems[nIndex].pCell;
+ if (pCell->GetCellType() != CELLTYPE_FORMULA)
+ return NULL;
+
+ return static_cast<const ScFormulaCell*>(pCell)->GetCode();
+}
CellType ScColumn::GetCellType( SCROW nRow ) const
{
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 15fe129cb2f3..e7982561b7e2 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3242,6 +3242,13 @@ void ScDocument::GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rFormul
rFormula = aString;
}
+const ScTokenArray* ScDocument::GetFormula( const ScAddress& rPos ) const
+{
+ if (!TableExists(rPos.Tab()))
+ return NULL;
+
+ return maTabs[rPos.Tab()]->GetFormula(rPos.Col(), rPos.Row());
+}
CellType ScDocument::GetCellType( const ScAddress& rPos ) const
{
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index e73a8e94b80a..aab3235d1abf 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1400,7 +1400,7 @@ const EditTextObject* ScTable::GetEditText( SCCOL nCol, SCROW nRow ) const
return aCol[nCol].GetEditText(nRow);
}
-void ScTable::GetFormula( SCCOL nCol, SCROW nRow, rtl::OUString& rFormula )
+void ScTable::GetFormula( SCCOL nCol, SCROW nRow, rtl::OUString& rFormula ) const
{
if (ValidColRow(nCol,nRow))
aCol[nCol].GetFormula( nRow, rFormula );
@@ -1408,6 +1408,14 @@ void ScTable::GetFormula( SCCOL nCol, SCROW nRow, rtl::OUString& rFormula )
rFormula = rtl::OUString();
}
+const ScTokenArray* ScTable::GetFormula( SCCOL nCol, SCROW nRow ) const
+{
+ if (!ValidColRow(nCol, nRow))
+ return NULL;
+
+ return aCol[nCol].GetFormula(nRow);
+}
+
ScNotes* ScTable::GetNotes()
{
return &maNotes;
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 5cc714af7a8b..90482fbaeed8 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -847,9 +847,9 @@ bool ScDocFunc::SetValueCell( const ScAddress& rPos, double fVal, bool bInteract
break;
case CELLTYPE_FORMULA:
{
- const ScFormulaCell* pFCell = static_cast<const ScFormulaCell*>(pDoc->GetCell(rPos));
- if (pFCell)
- pUndoMgr->AddUndoAction(new ScUndoSetCell(&rDocShell, rPos, *pFCell, fVal));
+ const ScTokenArray* pTokens = pDoc->GetFormula(rPos);
+ if (pTokens)
+ pUndoMgr->AddUndoAction(new ScUndoSetCell(&rDocShell, rPos, *pTokens, fVal));
}
break;
default:
diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx
index 799ef4d460fe..a99f05e63cd5 100644
--- a/sc/source/ui/inc/undocell.hxx
+++ b/sc/source/ui/inc/undocell.hxx
@@ -168,14 +168,14 @@ public:
double mfValue;
OUString* mpString;
EditTextObject* mpEditText;
- ScFormulaCell* mpFormulaCell;
+ ScTokenArray* mpFormula;
};
Value();
Value( double fValue );
Value( const OUString& rString );
Value( const EditTextObject& rEditText );
- Value( const ScFormulaCell& rFormula );
+ Value( const ScTokenArray& rFormula );
Value( const Value& r );
~Value();
};
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 13319d8b04cf..e7fb68a6ef4b 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -502,7 +502,7 @@ ScUndoSetCell::Value::Value() : meType(CELLTYPE_NONE), mfValue(0.0) {}
ScUndoSetCell::Value::Value( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {}
ScUndoSetCell::Value::Value( const OUString& rString ) : meType(CELLTYPE_STRING), mpString(new OUString(rString)) {}
ScUndoSetCell::Value::Value( const EditTextObject& rEditText ) : meType(CELLTYPE_EDIT), mpEditText(rEditText.Clone()) {}
-ScUndoSetCell::Value::Value( const ScFormulaCell& rFormula ) : meType(CELLTYPE_FORMULA), mpFormulaCell(rFormula.Clone()) {}
+ScUndoSetCell::Value::Value( const ScTokenArray& rFormula ) : meType(CELLTYPE_FORMULA), mpFormula(rFormula.Clone()) {}
ScUndoSetCell::Value::Value( const Value& r ) : meType(r.meType), mfValue(r.mfValue)
{
@@ -515,7 +515,7 @@ ScUndoSetCell::Value::Value( const Value& r ) : meType(r.meType), mfValue(r.mfVa
mpEditText = r.mpEditText->Clone();
break;
case CELLTYPE_FORMULA:
- mpFormulaCell = r.mpFormulaCell->Clone();
+ mpFormula = r.mpFormula->Clone();
default:
;
}
@@ -531,7 +531,7 @@ ScUndoSetCell::Value::~Value()
case CELLTYPE_EDIT:
delete mpEditText;
case CELLTYPE_FORMULA:
- mpFormulaCell->Delete();
+ delete mpFormula;
default:
;
}
@@ -594,7 +594,7 @@ void ScUndoSetCell::SetValue( const Value& rVal )
pDoc->SetEditText(maPos, rVal.mpEditText->Clone());
break;
case CELLTYPE_FORMULA:
- pDoc->SetFormula(maPos, *rVal.mpFormulaCell->GetCode());
+ pDoc->SetFormula(maPos, *rVal.mpFormula);
break;
default:
;