sc/source/core/data/formulacell.cxx | 32 ++++++++++++-------------------- sc/source/core/inc/refupdat.hxx | 6 ++---- sc/source/core/tool/rangenam.cxx | 6 +++++- sc/source/core/tool/refupdat.cxx | 24 ++++++++++++++---------- 4 files changed, 33 insertions(+), 35 deletions(-)
New commits: commit b46ba50bd76ef9f0b861ff50abca2a098cae0578 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Tue Jul 16 14:25:47 2013 -0400 UpdateTranspose() without calling CalcAbsIfRel(). Change-Id: Iddef01a82017ba75c50ed82a54f6ee25fe0df901 diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index bf3782e..5b7f8bf 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2631,17 +2631,13 @@ void ScFormulaCell::UpdateTranspose( const ScRange& rSource, const ScAddress& rD } else if( t->GetType() != svIndex ) { - t->CalcAbsIfRel( aOldPos ); - bool bMod; - { // Own scope for SingleDoubleRefModifier dtor if SingleRef - SingleDoubleRefModifier aMod( *t ); - ScComplexRefData& rRef = aMod.Ref(); - bMod = (ScRefUpdate::UpdateTranspose( pDocument, rSource, - rDest, rRef ) != UR_NOTHING || bPosChanged); - } - if ( bMod ) + SingleDoubleRefModifier aMod(*t); + ScComplexRefData& rRef = aMod.Ref(); + ScRange aAbs = rRef.toAbs(aOldPos); + bool bMod = (ScRefUpdate::UpdateTranspose(pDocument, rSource, rDest, aAbs) != UR_NOTHING || bPosChanged); + if (bMod) { - t->CalcRelFromAbs( aPos ); + rRef.SetRange(aAbs, aPos); // based on the new anchor position. bRefChanged = true; } } @@ -2658,16 +2654,12 @@ void ScFormulaCell::UpdateTranspose( const ScRange& rSource, const ScAddress& rD { if( t->GetType() != svIndex ) { - t->CalcAbsIfRel( aOldPos ); - bool bMod; - { // Own scope for SingleDoubleRefModifier dtor if SingleRef - SingleDoubleRefModifier aMod( *t ); - ScComplexRefData& rRef = aMod.Ref(); - bMod = (ScRefUpdate::UpdateTranspose( pDocument, rSource, - rDest, rRef ) != UR_NOTHING || bPosChanged); - } - if ( bMod ) - t->CalcRelFromAbs( aPos ); + SingleDoubleRefModifier aMod(*t); + ScComplexRefData& rRef = aMod.Ref(); + ScRange aAbs = rRef.toAbs(aOldPos); + bool bMod = (ScRefUpdate::UpdateTranspose(pDocument, rSource, rDest, aAbs) != UR_NOTHING || bPosChanged); + if (bMod) + rRef.SetRange(aAbs, aPos); // based on the new anchor position. } } } diff --git a/sc/source/core/inc/refupdat.hxx b/sc/source/core/inc/refupdat.hxx index 58b4cc9..a5f688d 100644 --- a/sc/source/core/inc/refupdat.hxx +++ b/sc/source/core/inc/refupdat.hxx @@ -73,10 +73,8 @@ public: static void MoveRelWrap( ScDocument* pDoc, const ScAddress& rPos, SCCOL nMaxCol, SCROW nMaxRow, ScComplexRefData& rRef ); - /// Before calling, the absolute references must be up-to-date! - static ScRefUpdateRes UpdateTranspose( ScDocument* pDoc, - const ScRange& rSource, const ScAddress& rDest, - ScComplexRefData& rRef ); + static ScRefUpdateRes UpdateTranspose( + ScDocument* pDoc, const ScRange& rSource, const ScAddress& rDest, ScRange& rRef ); static void DoTranspose( SCsCOL& rCol, SCsROW& rRow, SCsTAB& rTab, ScDocument* pDoc, const ScRange& rSource, const ScAddress& rDest ); diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx index 42662ae..75e79ec 100644 --- a/sc/source/core/tool/rangenam.cxx +++ b/sc/source/core/tool/rangenam.cxx @@ -317,8 +317,12 @@ void ScRangeData::UpdateTranspose( const ScRange& rSource, const ScAddress& rDes (!rRef.Ref2.IsColRel() && !rRef.Ref2.IsRowRel() && (!rRef.Ref2.IsFlag3D() || !rRef.Ref2.IsTabRel())))) { - if ( ScRefUpdate::UpdateTranspose( pDoc, rSource, rDest, rRef ) != UR_NOTHING ) + ScRange aAbs = rRef.toAbs(aPos); + if (ScRefUpdate::UpdateTranspose(pDoc, rSource, rDest, aAbs) != UR_NOTHING) + { + rRef.SetRange(aAbs, aPos); bChanged = true; + } } } } diff --git a/sc/source/core/tool/refupdat.cxx b/sc/source/core/tool/refupdat.cxx index 4541768..df0b0a4 100644 --- a/sc/source/core/tool/refupdat.cxx +++ b/sc/source/core/tool/refupdat.cxx @@ -866,18 +866,22 @@ void ScRefUpdate::DoTranspose( SCsCOL& rCol, SCsROW& rRow, SCsTAB& rTab, static_cast<SCsCOLROW>(nRelX)); } - -ScRefUpdateRes ScRefUpdate::UpdateTranspose( ScDocument* pDoc, - const ScRange& rSource, const ScAddress& rDest, - ScComplexRefData& rRef ) +ScRefUpdateRes ScRefUpdate::UpdateTranspose( + ScDocument* pDoc, const ScRange& rSource, const ScAddress& rDest, ScRange& rRef ) { ScRefUpdateRes eRet = UR_NOTHING; - if ( rRef.Ref1.nCol >= rSource.aStart.Col() && rRef.Ref2.nCol <= rSource.aEnd.Col() && - rRef.Ref1.nRow >= rSource.aStart.Row() && rRef.Ref2.nRow <= rSource.aEnd.Row() && - rRef.Ref1.nTab >= rSource.aStart.Tab() && rRef.Ref2.nTab <= rSource.aEnd.Tab() ) - { - DoTranspose( rRef.Ref1.nCol, rRef.Ref1.nRow, rRef.Ref1.nTab, pDoc, rSource, rDest ); - DoTranspose( rRef.Ref2.nCol, rRef.Ref2.nRow, rRef.Ref2.nTab, pDoc, rSource, rDest ); + if (rRef.aStart.Col() >= rSource.aStart.Col() && rRef.aEnd.Col() <= rSource.aEnd.Col() && + rRef.aStart.Row() >= rSource.aStart.Row() && rRef.aEnd.Row() <= rSource.aEnd.Row() && + rRef.aStart.Tab() >= rSource.aStart.Tab() && rRef.aEnd.Tab() <= rSource.aEnd.Tab()) + { + // Source range contains the reference range. + SCCOL nCol1 = rRef.aStart.Col(), nCol2 = rRef.aEnd.Col(); + SCROW nRow1 = rRef.aStart.Row(), nRow2 = rRef.aEnd.Row(); + SCTAB nTab1 = rRef.aStart.Tab(), nTab2 = rRef.aEnd.Tab(); + DoTranspose(nCol1, nRow1, nTab1, pDoc, rSource, rDest); + DoTranspose(nCol2, nRow2, nTab2, pDoc, rSource, rDest); + rRef.aStart = ScAddress(nCol1, nRow1, nTab1); + rRef.aEnd = ScAddress(nCol2, nRow2, nTab2); eRet = UR_UPDATED; } return eRet; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits