Kaydet (Commit) bac886b7 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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
üst cfc732b8
......@@ -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);
......
......@@ -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();
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment