sc/inc/compiler.hxx | 2 sc/source/core/data/formulacell.cxx | 74 +++---------------- sc/source/core/tool/compiler.cxx | 135 +++++++++--------------------------- 3 files changed, 51 insertions(+), 160 deletions(-)
New commits: commit 05bad95ef4e9a501397e492c6ff11707f9908676 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Jul 17 23:19:16 2013 -0400 Remove the current shared formula bits. I'll re-implement this from scratch. Change-Id: Ib3a80266a89afc0dd581fcf1e1c37790498205e4 diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx index 0ab4c68..5cc2498 100644 --- a/sc/inc/compiler.hxx +++ b/sc/inc/compiler.hxx @@ -446,7 +446,7 @@ public: SCsCOL nDx, SCsROW nDy, SCsTAB nDz, bool& rChanged, bool bSharedFormula = false, bool bLocal = false); - ScRangeData* UpdateReference( UpdateRefMode eUpdateRefMode, + void UpdateReference( UpdateRefMode eUpdateRefMode, const ScAddress& rOldPos, const ScRange&, SCsCOL nDx, SCsROW nDy, SCsTAB nDz, bool& rChanged, bool& rRefSizeChanged ); diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 08ea44b..1bafd7b 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2264,7 +2264,6 @@ bool ScFormulaCell::UpdateReferenceOnShift( if (pUndoDoc) pOldCode.reset(pCode->Clone()); - ScRangeData* pSharedCode = NULL; bool bValChanged = false; bool bRangeModified = false; // any range, not only shared formula bool bRefSizeChanged = false; @@ -2274,7 +2273,7 @@ bool ScFormulaCell::UpdateReferenceOnShift( // Update cell or range references. ScCompiler aComp(pDocument, aPos, *pCode); aComp.SetGrammar(pDocument->GetGrammar()); - pSharedCode = aComp.UpdateReference( + aComp.UpdateReference( URM_INSDEL, aPos, rCxt.maRange, rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta, bValChanged, bRefSizeChanged); bRangeModified = aComp.HasModifiedRange(); @@ -2305,7 +2304,7 @@ bool ScFormulaCell::UpdateReferenceOnShift( bHasRelName = HasRelNameReference(); // Reference changed and new listening needed? // Except in Insert/Delete without specialties. - bNewListening = (bRangeModified || pSharedCode || bColRowNameCompile + bNewListening = (bRangeModified || bColRowNameCompile || (bValChanged && (bInDeleteUndo || bRefSizeChanged)) || bHasRelName); if ( bNewListening ) @@ -2314,30 +2313,15 @@ bool ScFormulaCell::UpdateReferenceOnShift( bool bNeedDirty = false; // NeedDirty for changes except for Copy and Move/Insert without RelNames - if (bRangeModified || pSharedCode || bColRowNameCompile || + if (bRangeModified || bColRowNameCompile || (bValChanged && (bHasRelName || bInDeleteUndo || bRefSizeChanged)) || bOnRefMove) bNeedDirty = true; - if (pUndoDoc && (bValChanged || pSharedCode || bOnRefMove)) + if (pUndoDoc && (bValChanged || bOnRefMove)) setOldCodeToUndo(pUndoDoc, aUndoPos, pOldCode.get(), eTempGrammar, cMatrixFlag); bValChanged = false; - if ( pSharedCode ) - { // Replace shared formula with own formula - pDocument->RemoveFromFormulaTree( this ); // update formula count - delete pCode; - pCode = pSharedCode->GetCode()->Clone(); - // #i18937# #i110008# call MoveRelWrap, but with the old position - ScCompiler::MoveRelWrap(*pCode, pDocument, aPos, pSharedCode->GetMaxCol(), pSharedCode->GetMaxRow()); - ScCompiler aComp2(pDocument, aPos, *pCode); - aComp2.SetGrammar(pDocument->GetGrammar()); - aComp2.UpdateSharedFormulaReference( - URM_INSDEL, aPos, rCxt.maRange, rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta); - bValChanged = true; - bNeedDirty = true; - } - if ( ( bCompile = (bCompile || bValChanged || bRangeModified || bColRowNameCompile) ) != 0 ) { CompileTokenArray( bNewListening ); // no Listening @@ -2357,7 +2341,7 @@ bool ScFormulaCell::UpdateReferenceOnShift( } } - if ( bNeedDirty && (!bHasRelName || pSharedCode) ) + if (bNeedDirty && !bHasRelName) { // Cut off references, invalid or similar? sc::AutoCalcSwitch(*pDocument, false); SetDirty(); @@ -2409,7 +2393,6 @@ bool ScFormulaCell::UpdateReferenceOnMove( if (pUndoDoc) pOldCode.reset(pCode->Clone()); - ScRangeData* pSharedCode = NULL; bool bValChanged = false; bool bRangeModified = false; // any range, not only shared formula bool bRefSizeChanged = false; @@ -2419,7 +2402,7 @@ bool ScFormulaCell::UpdateReferenceOnMove( // Update cell or range references. ScCompiler aComp(pDocument, aPos, *pCode); aComp.SetGrammar(pDocument->GetGrammar()); - pSharedCode = aComp.UpdateReference( + aComp.UpdateReference( URM_MOVE, aOldPos, rCxt.maRange, rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta, bValChanged, bRefSizeChanged); @@ -2451,7 +2434,7 @@ bool ScFormulaCell::UpdateReferenceOnMove( bHasRelName = HasRelNameReference(); // Reference changed and new listening needed? // Except in Insert/Delete without specialties. - bNewListening = (bRangeModified || pSharedCode || bColRowNameCompile + bNewListening = (bRangeModified || bColRowNameCompile || bValChanged || bHasRelName) // #i36299# Don't duplicate action during cut&paste / drag&drop // on a cell in the range moved, start/end listeners is done @@ -2464,30 +2447,15 @@ bool ScFormulaCell::UpdateReferenceOnMove( bool bNeedDirty = false; // NeedDirty for changes except for Copy and Move/Insert without RelNames - if ( bRangeModified || pSharedCode || bColRowNameCompile || + if ( bRangeModified || bColRowNameCompile || (bValChanged && bHasRelName && (bHasRelName || bInDeleteUndo || bRefSizeChanged)) || bOnRefMove) bNeedDirty = true; - if (pUndoDoc && (bValChanged || pSharedCode || bOnRefMove)) + if (pUndoDoc && (bValChanged || bOnRefMove)) setOldCodeToUndo(pUndoDoc, aUndoPos, pOldCode.get(), eTempGrammar, cMatrixFlag); bValChanged = false; - if ( pSharedCode ) - { // Replace shared formula with own formula - pDocument->RemoveFromFormulaTree( this ); // update formula count - delete pCode; - pCode = pSharedCode->GetCode()->Clone(); - // #i18937# #i110008# call MoveRelWrap, but with the old position - ScCompiler::MoveRelWrap(*pCode, pDocument, aOldPos, pSharedCode->GetMaxCol(), pSharedCode->GetMaxRow()); - ScCompiler aComp2(pDocument, aPos, *pCode); - aComp2.SetGrammar(pDocument->GetGrammar()); - aComp2.UpdateSharedFormulaReference(URM_MOVE, aOldPos, rCxt.maRange, - rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta ); - bValChanged = true; - bNeedDirty = true; - } - if ( ( bCompile = (bCompile || bValChanged || bRangeModified || bColRowNameCompile) ) != 0 ) { CompileTokenArray( bNewListening ); // no Listening @@ -2550,7 +2518,6 @@ bool ScFormulaCell::UpdateReferenceOnCopy( if (pUndoDoc) pOldCode.reset(pCode->Clone()); - ScRangeData* pSharedCode = NULL; bool bValChanged = false; bool bRangeModified = false; // any range, not only shared formula bool bRefSizeChanged = false; @@ -2560,7 +2527,7 @@ bool ScFormulaCell::UpdateReferenceOnCopy( // Update cell or range references. ScCompiler aComp(pDocument, aPos, *pCode); aComp.SetGrammar(pDocument->GetGrammar()); - pSharedCode = aComp.UpdateReference( + aComp.UpdateReference( URM_COPY, aOldPos, rCxt.maRange, rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta, bValChanged, bRefSizeChanged); bRangeModified = aComp.HasModifiedRange(); @@ -2592,7 +2559,7 @@ bool ScFormulaCell::UpdateReferenceOnCopy( // Reference changed and new listening needed? // Except in Insert/Delete without specialties. bNewListening = - (bRangeModified || pSharedCode || bColRowNameCompile || (bValChanged && (bInDeleteUndo || bRefSizeChanged))); + (bRangeModified || bColRowNameCompile || (bValChanged && (bInDeleteUndo || bRefSizeChanged))); if ( bNewListening ) EndListeningTo(pDocument, pOldCode.get(), aOldPos); @@ -2600,29 +2567,14 @@ bool ScFormulaCell::UpdateReferenceOnCopy( bool bNeedDirty = false; // NeedDirty for changes except for Copy and Move/Insert without RelNames - if ( bRangeModified || pSharedCode || bColRowNameCompile || bOnRefMove) + if ( bRangeModified || bColRowNameCompile || bOnRefMove) bNeedDirty = true; - if (pUndoDoc && (bValChanged || pSharedCode || bOnRefMove)) + if (pUndoDoc && (bValChanged || bOnRefMove)) setOldCodeToUndo(pUndoDoc, aUndoPos, pOldCode.get(), eTempGrammar, cMatrixFlag); bValChanged = false; - if ( pSharedCode ) - { // Replace shared formula with own formula - pDocument->RemoveFromFormulaTree( this ); // update formula count - delete pCode; - pCode = pSharedCode->GetCode()->Clone(); - // #i18937# #i110008# call MoveRelWrap, but with the old position - ScCompiler::MoveRelWrap(*pCode, pDocument, aOldPos, pSharedCode->GetMaxCol(), pSharedCode->GetMaxRow()); - ScCompiler aComp2(pDocument, aPos, *pCode); - aComp2.SetGrammar(pDocument->GetGrammar()); - aComp2.UpdateSharedFormulaReference( - URM_COPY, aOldPos, rCxt.maRange, rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta); - bValChanged = true; - bNeedDirty = true; - } - if ( ( bCompile = (bCompile || bValChanged || bRangeModified || bColRowNameCompile) ) != 0 ) { CompileTokenArray( bNewListening ); // no Listening diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 494ed65..0f4f484 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -4183,7 +4183,7 @@ void ScCompiler::MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc, const ScAddr } } -ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode, +void ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode, const ScAddress& rOldPos, const ScRange& r, SCsCOL nDx, SCsROW nDy, SCsTAB nDz, bool& rChanged, bool& rRefSizeChanged ) @@ -4218,113 +4218,54 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode, } } } - // Check for SharedFormulas. - ScRangeData* pSharedCode = NULL; - pArr->Reset(); - for( FormulaToken* j = pArr->GetNextName(); j && !pSharedCode; - j = pArr->GetNextName() ) - { - if( j->GetOpCode() == ocName ) - { - ScRangeData* pName = GetRangeData( *j); - if (pName && pName->HasType(RT_SHARED)) - pSharedCode = pName; - } - } - // Check SharedFormulas for wraps. - if (pSharedCode) - { - ScRangeData* pName = pSharedCode; - pSharedCode = NULL; - pArr->Reset(); - for( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()); t && !pSharedCode; - t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) - { - bool bRelName = (t->GetType() == svSingleRef ? - t->GetSingleRef().IsRelName() : - (t->GetDoubleRef().Ref1.IsRelName() || - t->GetDoubleRef().Ref2.IsRelName())); - if (bRelName) - { - bool bValid = false; - if (t->GetType() == svSingleRef) - { - ScAddress aAbs = t->GetSingleRef().toAbs(rOldPos); - bValid = ValidAddress(aAbs); - } - else - { - ScRange aAbs = t->GetDoubleRef().toAbs(rOldPos); - bValid = ValidRange(aAbs); - } - // If the reference isn't valid, copying the formula - // wrapped it. Replace SharedFormula. - if (!bValid) - { - pSharedCode = pName; - rChanged = true; - } - } - } - } - return pSharedCode; + return; } - ScRangeData* pSharedCode = NULL; ScToken* t; pArr->Reset(); while( (t = static_cast<ScToken*>(pArr->GetNextReferenceOrName())) != NULL ) { - if( t->GetOpCode() == ocName ) - { - ScRangeData* pName = GetRangeData( *t); - if (pName && pName->HasType(RT_SHAREDMOD)) - { - pSharedCode = pName; // maybe need a replacement of shared with own code - rChanged = true; - } - } - else if( t->GetType() != svIndex ) // it may be a DB area!!! + if (t->GetType() == svIndex) + continue; + + switch (t->GetType()) { - switch (t->GetType()) + case svExternalSingleRef: + case svExternalDoubleRef: + // External references never change their positioning + // nor point to parts that will be removed or expanded. + // In fact, calling ScRefUpdate::Update() for URM_MOVE + // may have negative side effects. Simply adapt + // relative references to the new position. + break; + case svSingleRef: { - case svExternalSingleRef: - case svExternalDoubleRef: - // External references never change their positioning - // nor point to parts that will be removed or expanded. - // In fact, calling ScRefUpdate::Update() for URM_MOVE - // may have negative side effects. Simply adapt - // relative references to the new position. - break; - case svSingleRef: + SingleDoubleRefModifier aRefMod(t->GetSingleRef()); + ScComplexRefData& rRef = aRefMod.Ref(); + ScRange aRefRange = rRef.toAbs(rOldPos); + if (ScRefUpdate::Update(pDoc, eUpdateRefMode, aPos, r, nDx, nDy, nDz, rRef, aRefRange) != UR_NOTHING) { - SingleDoubleRefModifier aRefMod(t->GetSingleRef()); - ScComplexRefData& rRef = aRefMod.Ref(); - ScRange aRefRange = rRef.toAbs(rOldPos); - if (ScRefUpdate::Update(pDoc, eUpdateRefMode, aPos, r, nDx, nDy, nDz, rRef, aRefRange) != UR_NOTHING) - { - rRef.SetRange(aRefRange, rOldPos); - rChanged = true; - } + rRef.SetRange(aRefRange, rOldPos); + rChanged = true; } - break; - default: + } + break; + default: + { + ScComplexRefData& rRef = t->GetDoubleRef(); + ScRange aRefRange = rRef.toAbs(rOldPos); + SCCOL nCols = aRefRange.aEnd.Col() - aRefRange.aStart.Col(); + SCROW nRows = aRefRange.aEnd.Row() - aRefRange.aStart.Row(); + SCTAB nTabs = aRefRange.aEnd.Tab() - aRefRange.aStart.Tab(); + if (ScRefUpdate::Update(pDoc, eUpdateRefMode, aPos, r, nDx, nDy, nDz, rRef, aRefRange) != UR_NOTHING) { - ScComplexRefData& rRef = t->GetDoubleRef(); - ScRange aRefRange = rRef.toAbs(rOldPos); - SCCOL nCols = aRefRange.aEnd.Col() - aRefRange.aStart.Col(); - SCROW nRows = aRefRange.aEnd.Row() - aRefRange.aStart.Row(); - SCTAB nTabs = aRefRange.aEnd.Tab() - aRefRange.aStart.Tab(); - if (ScRefUpdate::Update(pDoc, eUpdateRefMode, aPos, r, nDx, nDy, nDz, rRef, aRefRange) != UR_NOTHING) - { - rRef.SetRange(aRefRange, rOldPos); - rChanged = true; - if (aRefRange.aEnd.Col() - aRefRange.aStart.Col() != nCols || - aRefRange.aEnd.Row() - aRefRange.aStart.Row() != nRows || - aRefRange.aEnd.Tab() - aRefRange.aStart.Tab() != nTabs) - rRefSizeChanged = true; - } + rRef.SetRange(aRefRange, rOldPos); + rChanged = true; + if (aRefRange.aEnd.Col() - aRefRange.aStart.Col() != nCols || + aRefRange.aEnd.Row() - aRefRange.aStart.Row() != nRows || + aRefRange.aEnd.Tab() - aRefRange.aStart.Tab() != nTabs) + rRefSizeChanged = true; } } } @@ -4374,8 +4315,6 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode, } } } - - return pSharedCode; } bool ScCompiler::UpdateNameReference(UpdateRefMode eUpdateRefMode, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits