summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source')
-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
6 files changed, 37 insertions, 10 deletions
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:
;