diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-07-17 22:16:01 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-07-24 23:29:28 -0400 |
commit | 8254e575586c2fb37e211956f8c44f36c22395c0 (patch) | |
tree | e840652e26e246a15d3c4c30a27a2f4f2e87e6ad /sc | |
parent | 5d82820c5fc552ba6dfba6817ed955a47ef01d06 (diff) |
Remove duplicated code blocks.
Change-Id: Id540cf0b2884d4bbff80be11139ff3621bbb8c4d
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 69 |
1 files changed, 21 insertions, 48 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index aa0360053bd3..dc6570b3b2ab 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2202,6 +2202,24 @@ bool checkCompileColRowName( return false; } +void setOldCodeToUndo( + ScDocument* pUndoDoc, const ScAddress& aUndoPos, ScTokenArray* pOldCode, FormulaGrammar::Grammar eTempGrammar, sal_uInt8 cMatrixFlag) +{ + // Copy the cell to aUndoPos, which is its current position in the document, + // so this works when UpdateReference is called before moving the cells + // (InsertCells/DeleteCells - aPos is changed above) as well as when UpdateReference + // is called after moving the cells (MoveBlock/PasteFromClip - aOldPos is changed). + + // If there is already a formula cell in the undo document, don't overwrite it, + // the first (oldest) is the important cell. + if (pUndoDoc->GetCellType(aUndoPos) == CELLTYPE_FORMULA) + return; + + ScFormulaCell* pFCell = new ScFormulaCell(pUndoDoc, aUndoPos, pOldCode, eTempGrammar, cMatrixFlag); + pFCell->SetResultToken(NULL); // to recognize it as changed later (Cut/Paste!) + pUndoDoc->SetFormulaCell(aUndoPos, pFCell); +} + } bool ScFormulaCell::UpdateReferenceOnShift( @@ -2313,22 +2331,7 @@ bool ScFormulaCell::UpdateReferenceOnShift( bNeedDirty = true; if (pUndoDoc && (bValChanged || pSharedCode || bOnRefMove)) - { - // Copy the cell to aUndoPos, which is its current position in the document, - // so this works when UpdateReference is called before moving the cells - // (InsertCells/DeleteCells - aPos is changed above) as well as when UpdateReference - // is called after moving the cells (MoveBlock/PasteFromClip - aOldPos is changed). - - // If there is already a formula cell in the undo document, don't overwrite it, - // the first (oldest) is the important cell. - if ( pUndoDoc->GetCellType( aUndoPos ) != CELLTYPE_FORMULA ) - { - ScFormulaCell* pFCell = new ScFormulaCell( pUndoDoc, aUndoPos, - pOldCode.get(), eTempGrammar, cMatrixFlag ); - pFCell->aResult.SetToken( NULL); // to recognize it as changed later (Cut/Paste!) - pUndoDoc->SetFormulaCell(aUndoPos, pFCell); - } - } + setOldCodeToUndo(pUndoDoc, aUndoPos, pOldCode.get(), eTempGrammar, cMatrixFlag); bValChanged = false; @@ -2487,22 +2490,7 @@ bool ScFormulaCell::UpdateReferenceOnMove( bNeedDirty = true; if (pUndoDoc && (bValChanged || pSharedCode || bOnRefMove)) - { - // Copy the cell to aUndoPos, which is its current position in the document, - // so this works when UpdateReference is called before moving the cells - // (InsertCells/DeleteCells - aPos is changed above) as well as when UpdateReference - // is called after moving the cells (MoveBlock/PasteFromClip - aOldPos is changed). - - // If there is already a formula cell in the undo document, don't overwrite it, - // the first (oldest) is the important cell. - if ( pUndoDoc->GetCellType( aUndoPos ) != CELLTYPE_FORMULA ) - { - ScFormulaCell* pFCell = new ScFormulaCell( pUndoDoc, aUndoPos, - pOldCode.get(), eTempGrammar, cMatrixFlag ); - pFCell->aResult.SetToken( NULL); // to recognize it as changed later (Cut/Paste!) - pUndoDoc->SetFormulaCell(aUndoPos, pFCell); - } - } + setOldCodeToUndo(pUndoDoc, aUndoPos, pOldCode.get(), eTempGrammar, cMatrixFlag); bValChanged = false; @@ -2650,22 +2638,7 @@ bool ScFormulaCell::UpdateReferenceOnCopy( bNeedDirty = true; if (pUndoDoc && (bValChanged || pSharedCode || bOnRefMove)) - { - // Copy the cell to aUndoPos, which is its current position in the document, - // so this works when UpdateReference is called before moving the cells - // (InsertCells/DeleteCells - aPos is changed above) as well as when UpdateReference - // is called after moving the cells (MoveBlock/PasteFromClip - aOldPos is changed). - - // If there is already a formula cell in the undo document, don't overwrite it, - // the first (oldest) is the important cell. - if ( pUndoDoc->GetCellType( aUndoPos ) != CELLTYPE_FORMULA ) - { - ScFormulaCell* pFCell = new ScFormulaCell( pUndoDoc, aUndoPos, - pOldCode.get(), eTempGrammar, cMatrixFlag ); - pFCell->aResult.SetToken( NULL); // to recognize it as changed later (Cut/Paste!) - pUndoDoc->SetFormulaCell(aUndoPos, pFCell); - } - } + setOldCodeToUndo(pUndoDoc, aUndoPos, pOldCode.get(), eTempGrammar, cMatrixFlag); bValChanged = false; |