[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Wed Mar 20 11:42:14 PDT 2013
sc/inc/column.hxx | 1 +
sc/inc/document.hxx | 1 +
sc/inc/table.hxx | 3 ++-
sc/inc/tokenarray.hxx | 2 +-
sc/source/core/data/column3.cxx | 12 ++++++++++++
sc/source/core/data/document.cxx | 7 +++++++
sc/source/core/data/table2.cxx | 10 +++++++++-
sc/source/ui/docshell/docfunc.cxx | 6 +++---
sc/source/ui/inc/undocell.hxx | 4 ++--
sc/source/ui/undo/undocell.cxx | 8 ++++----
10 files changed, 42 insertions(+), 12 deletions(-)
New commits:
commit e7ce8e8ccb1c4b7f8b8c2b4311e7747cff751bff
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Mar 20 14:43:53 2013 -0400
Let's use ScTokenArray instead of ScFormulaCell.
Because we may move away from ScFormulaCell too.
Change-Id: Iafafe3c864efa73330fb8ecbb713caa903e23db5
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 558b83f..edfa5f4 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 6d00287..22fdec6 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 b87ecfe..84b5e0c 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 2449074..32a266d 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 469c818..e914344 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 15fe129..e798256 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 e73a8e9..aab3235 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 5cc714a..90482fb 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 799ef4d..a99f05e 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 13319d8..e7fb68a 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:
;
More information about the Libreoffice-commits
mailing list