diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-21 17:25:37 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-22 21:49:22 -0400 |
commit | 07bd80e7d94d90be0bc8059e98eade6b3ca2b6c6 (patch) | |
tree | 144856af2a24d8f3155015dcbaa9bbf7f94a2cb4 /sc/source/ui/undo | |
parent | f357687b8c5aba3679143af891014e4fba5dc936 (diff) |
Add assign() and commit() methods to make it easier to use this class.
Change-Id: Ia9c2fe3fea3dfeef0410e8c430d5953a66b0cba1
Diffstat (limited to 'sc/source/ui/undo')
-rw-r--r-- | sc/source/ui/undo/undocell.cxx | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 77156242112b..171a7587f0a7 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -71,6 +71,11 @@ ScUndoCellValue::ScUndoCellValue( const ScUndoCellValue& r ) : meType(r.meType), ScUndoCellValue::~ScUndoCellValue() { + clear(); +} + +void ScUndoCellValue::clear() +{ switch (meType) { case CELLTYPE_STRING: @@ -85,6 +90,59 @@ ScUndoCellValue::~ScUndoCellValue() default: ; } + + // Reset to empty value. + meType = CELLTYPE_NONE; + mfValue = 0.0; +} + +void ScUndoCellValue::assign( const ScDocument& rDoc, const ScAddress& rPos ) +{ + clear(); + + meType = rDoc.GetCellType(rPos); + switch (meType) + { + case CELLTYPE_STRING: + mpString = new OUString(rDoc.GetString(rPos)); + break; + case CELLTYPE_EDIT: + mpEditText = rDoc.GetEditText(rPos)->Clone(); + break; + case CELLTYPE_VALUE: + mfValue = rDoc.GetValue(rPos); + break; + case CELLTYPE_FORMULA: + mpFormula = rDoc.GetFormulaCell(rPos)->Clone(); + break; + default: + meType = CELLTYPE_NONE; // reset to empty. + } +} + +void ScUndoCellValue::commit( ScDocument& rDoc, const ScAddress& rPos ) +{ + switch (meType) + { + case CELLTYPE_STRING: + { + ScSetStringParam aParam; + aParam.setTextInput(); + rDoc.SetString(rPos, *mpString, &aParam); + } + break; + case CELLTYPE_EDIT: + rDoc.SetEditText(rPos, mpEditText->Clone()); + break; + case CELLTYPE_VALUE: + rDoc.SetValue(rPos, mfValue); + break; + case CELLTYPE_FORMULA: + rDoc.SetFormulaCell(rPos, mpFormula->Clone()); + break; + default: + rDoc.SetEmptyCell(rPos); + } } TYPEINIT1(ScUndoCursorAttr, ScSimpleUndo); |