diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-21 19:50:03 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-22 21:49:22 -0400 |
commit | 14afe7b9b057e5bbd68d41573884c8a85761712d (patch) | |
tree | 97758b002922bc7095e2dc2f9b32943fa127d139 /sc/source/ui/undo | |
parent | 07bd80e7d94d90be0bc8059e98eade6b3ca2b6c6 (diff) |
Move ScCellValue into its own header/source files.
This can be used outside the undo code, like change tracking code.
Change-Id: Iad936acef0dacbd19d8c179da4713b1cdc7f9c84
Diffstat (limited to 'sc/source/ui/undo')
-rw-r--r-- | sc/source/ui/undo/undocell.cxx | 106 |
1 files changed, 3 insertions, 103 deletions
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 171a7587f0a7..574ddba62cc4 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -45,106 +45,6 @@ using ::boost::shared_ptr; -ScUndoCellValue::ScUndoCellValue() : meType(CELLTYPE_NONE), mfValue(0.0) {} -ScUndoCellValue::ScUndoCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {} -ScUndoCellValue::ScUndoCellValue( const OUString& rString ) : meType(CELLTYPE_STRING), mpString(new OUString(rString)) {} -ScUndoCellValue::ScUndoCellValue( const EditTextObject& rEditText ) : meType(CELLTYPE_EDIT), mpEditText(rEditText.Clone()) {} -ScUndoCellValue::ScUndoCellValue( const ScFormulaCell& rFormula ) : meType(CELLTYPE_FORMULA), mpFormula(rFormula.Clone()) {} - -ScUndoCellValue::ScUndoCellValue( const ScUndoCellValue& r ) : meType(r.meType), mfValue(r.mfValue) -{ - switch (r.meType) - { - case CELLTYPE_STRING: - mpString = new OUString(*r.mpString); - break; - case CELLTYPE_EDIT: - mpEditText = r.mpEditText->Clone(); - break; - case CELLTYPE_FORMULA: - mpFormula = r.mpFormula->Clone(); - break; - default: - ; - } -} - -ScUndoCellValue::~ScUndoCellValue() -{ - clear(); -} - -void ScUndoCellValue::clear() -{ - switch (meType) - { - case CELLTYPE_STRING: - delete mpString; - break; - case CELLTYPE_EDIT: - delete mpEditText; - break; - case CELLTYPE_FORMULA: - mpFormula->Delete(); - break; - 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); TYPEINIT1(ScUndoEnterData, ScSimpleUndo); TYPEINIT1(ScUndoEnterValue, ScSimpleUndo); @@ -515,10 +415,10 @@ sal_Bool ScUndoEnterValue::CanRepeat(SfxRepeatTarget& /* rTarget */) const return false; } -ScUndoSetCell::ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScUndoCellValue& rNewVal ) : +ScUndoSetCell::ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rNewVal ) : ScSimpleUndo(pDocSh), maPos(rPos), maNewValue(rNewVal) {} -ScUndoSetCell::ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScUndoCellValue& rOldVal, const ScUndoCellValue& rNewVal ) : +ScUndoSetCell::ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rOldVal, const ScCellValue& rNewVal ) : ScSimpleUndo(pDocSh), maPos(rPos), maOldValue(rOldVal), maNewValue(rNewVal) {} ScUndoSetCell::~ScUndoSetCell() {} @@ -554,7 +454,7 @@ OUString ScUndoSetCell::GetComment() const return ScGlobal::GetRscString(STR_UNDO_ENTERDATA); // "Input" } -void ScUndoSetCell::SetValue( const ScUndoCellValue& rVal ) +void ScUndoSetCell::SetValue( const ScCellValue& rVal ) { ScDocument* pDoc = pDocShell->GetDocument(); |