diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-06-27 11:29:46 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-06-27 15:50:07 -0400 |
commit | bac886b75f3ce94178ba1751fc85cd4f2c5a9d0f (patch) | |
tree | 80e6f10d93bbb1b5e70c743ee1026f66a0778842 | |
parent | cfc732b858befd0f9102cb0161e9afde424dcecf (diff) |
ScColumn::UpdateReference to take ScRange as a parameter.
To reduce the number of parameters by 5. Also add *some* description
of this method esp what the range means when updating formula references.
Change-Id: Iccde58d6ecde6f0c09c111cf9b4f551ce392effb
-rw-r--r-- | sc/inc/column.hxx | 25 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 27 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 8 |
3 files changed, 36 insertions, 24 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 1c04e5d6947f..d38762ac6ffa 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -308,10 +308,27 @@ public: void ResetChanged( SCROW nStartRow, SCROW nEndRow ); - bool UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, - SCCOL nCol2, SCROW nRow2, SCTAB nTab2, - SCsCOL nDx, SCsROW nDy, SCsTAB nDz, - ScDocument* pUndoDoc = NULL ); + /** + * Update reference addresses in formula cell in response to mass cell + * movement. + * + * @param eUpdateRefMode update mode - insert/delete, copy, move, + * reorder... + * @param rRange range of cells that are about to be moved or copied. + * (TODO: find out what this range means for the reorder + * mode). + * @param nDx moved by how many cells in the column direction. + * @param nDy moved by how many cells in the row direction. + * @param nDz moved by how many sheets in the sheet direction. + * @param pUndoDoc undo document instance. + * + * @return true if reference of at least one formula cell has been + * updated, false otherwise. + */ + bool UpdateReference( + UpdateRefMode eUpdateRefMode, const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz, + ScDocument* pUndoDoc = NULL ); + void UpdateInsertTab(SCTAB nInsPos, SCTAB nNewSheets = 1); void UpdateInsertTabOnlyCells(SCTAB nInsPos, SCTAB nNewSheets = 1); void UpdateDeleteTab(SCTAB nDelPos, bool bIsMove, ScColumn* pRefUndo = NULL, SCTAB nSheets = 1); diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 8c53a69f91f0..9f75ad8ad445 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1992,9 +1992,8 @@ void ScColumn::CopyScenarioFrom( const ScColumn& rSrcCol ) // UpdateUsed not needed, already done in TestCopyScenario (obsolete comment ?) SCsTAB nDz = nTab - rSrcCol.nTab; - UpdateReference(URM_COPY, nCol, nStart, nTab, - nCol, nEnd, nTab, - 0, 0, nDz, NULL); + UpdateReference( + URM_COPY, ScRange(nCol, nStart, nTab, nCol, nEnd, nTab), 0, 0, nDz, NULL); UpdateCompile(); } @@ -2023,9 +2022,9 @@ void ScColumn::CopyScenarioTo( ScColumn& rDestCol ) const // UpdateUsed not needed, is already done in TestCopyScenario (obsolete comment ?) SCsTAB nDz = rDestCol.nTab - nTab; - rDestCol.UpdateReference(URM_COPY, rDestCol.nCol, nStart, rDestCol.nTab, - rDestCol.nCol, nEnd, rDestCol.nTab, - 0, 0, nDz, NULL); + rDestCol.UpdateReference( + URM_COPY, ScRange(rDestCol.nCol, nStart, rDestCol.nTab, rDestCol.nCol, nEnd, rDestCol.nTab), + 0, 0, nDz, NULL); rDestCol.UpdateCompile(); } @@ -2221,21 +2220,19 @@ public: } -bool ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, - SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCsCOL nDx, SCsROW nDy, SCsTAB nDz, - ScDocument* pUndoDoc ) +bool ScColumn::UpdateReference( + UpdateRefMode eUpdateRefMode, const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz, + ScDocument* pUndoDoc ) { - ScRange aRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); - if (eUpdateRefMode == URM_COPY) { - UpdateRefOnCopy aHandler(aRange, nDx, nDy, nDz, pUndoDoc); - FormulaCellsUndecided(nRow1, nRow2); - sc::ProcessBlock(maCells.begin(), maCells, aHandler, nRow1, nRow2); + UpdateRefOnCopy aHandler(rRange, nDx, nDy, nDz, pUndoDoc); + FormulaCellsUndecided(rRange.aStart.Row(), rRange.aEnd.Row()); + sc::ProcessBlock(maCells.begin(), maCells, aHandler, rRange.aStart.Row(), rRange.aEnd.Row()); return aHandler.isUpdated(); } - UpdateRefOnNonCopy aHandler(nCol, nTab, aRange, nDx, nDy, nDz, eUpdateRefMode, pUndoDoc); + UpdateRefOnNonCopy aHandler(nCol, nTab, rRange, nDx, nDy, nDz, eUpdateRefMode, pUndoDoc); FormulaCellsUndecided(0, MAXROW); sc::ProcessFormula(maCells, aHandler); return aHandler.isUpdated(); diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index be6f4ae6330b..2d90fa904ec6 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1463,16 +1463,14 @@ void ScTable::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW iMax = MAXCOL; } + ScRange aRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); + // Named expressions need to be updated before formulas acessing them. if (mpRangeName) - { - ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );; mpRangeName->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz, true ); - } for ( ; i<=iMax; i++) - bUpdated |= aCol[i].UpdateReference( - eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, pUndoDoc ); + bUpdated |= aCol[i].UpdateReference(eUpdateRefMode, aRange, nDx, nDy, nDz, pUndoDoc); if ( bIncludeDraw ) UpdateDrawRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, bUpdateNoteCaptionPos ); |