sc/inc/column.hxx | 25 +++++++++++++++++++++---- sc/source/core/data/column.cxx | 27 ++++++++++++--------------- sc/source/core/data/table1.cxx | 8 +++----- 3 files changed, 36 insertions(+), 24 deletions(-)
New commits: commit e51a3433290912a1d491f3fac8109edbae98986b Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Thu Jun 27 11:29:46 2013 -0400 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 diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index c0dea00..fce1348 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -301,10 +301,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 26edaa9..1a00a15 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 be6f4ae..2d90fa9 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 ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits