diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-07-29 17:51:14 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-07-30 23:50:01 -0400 |
commit | 1fdc310b57af7dfdb97fe336ce9a2e4d579af3f2 (patch) | |
tree | ec5ad1c108c3f83b0cc9da937e2e561dfefc6532 /sc/source/core/data | |
parent | f77c9d5b3cb65d9c2e2417f60bec1113feac50e1 (diff) |
More on getting named range update to work.
Change-Id: Id3f2ffe6d91ae43d799182b3744a839be5e1baf6
Diffstat (limited to 'sc/source/core/data')
-rw-r--r-- | sc/source/core/data/documen3.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 15 | ||||
-rw-r--r-- | sc/source/core/data/refupdatecontext.cxx | 37 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 4 |
4 files changed, 48 insertions, 12 deletions
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index c9254bc0ce3b..d8b7530c69f0 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -975,7 +975,7 @@ sal_Int64 ScDocument::GetNewUnoId() } void ScDocument::UpdateReference( - const sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc, bool bIncludeDraw, bool bUpdateNoteCaptionPos ) + sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc, bool bIncludeDraw, bool bUpdateNoteCaptionPos ) { if (!ValidRange(rCxt.maRange)) return; @@ -1006,7 +1006,7 @@ void ScDocument::UpdateReference( xRowNameRanges->UpdateReference( eUpdateRefMode, this, aRange, nDx, nDy, nDz ); pDBCollection->UpdateReference( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz ); if (pRangeName) - pRangeName->UpdateReference(rCxt, false); + pRangeName->UpdateReference(rCxt, -1); if ( pDPCollection ) pDPCollection->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz ); UpdateChartRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz ); diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 11388e8eddf3..c6c567fad847 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2269,6 +2269,7 @@ bool ScFormulaCell::UpdateReferenceOnShift( bool bValChanged = false; bool bRefModified = false; bool bRefSizeChanged = false; + bool bRecompile = bCompile; if (bHasRefs) { @@ -2276,6 +2277,8 @@ bool ScFormulaCell::UpdateReferenceOnShift( sc::RefUpdateResult aRes = pCode->AdjustReferenceOnShift(rCxt, aOldPos); bRefModified = aRes.mbReferenceModified; bValChanged = aRes.mbValueChanged; + if (aRes.mbNameModified) + bRecompile = true; } if (bValChanged || bRefModified) @@ -2285,7 +2288,6 @@ bool ScFormulaCell::UpdateReferenceOnShift( // Cell may reference itself, e.g. ocColumn, ocRow without parameter bOnRefMove = (bValChanged || (aPos != aOldPos)); - bool bColRowNameCompile = false; bool bHasRelName = false; bool bNewListening = false; bool bInDeleteUndo = false; @@ -2294,8 +2296,8 @@ bool ScFormulaCell::UpdateReferenceOnShift( { // Upon Insert ColRowNames have to be recompiled in case the // insertion occurs right in front of the range. - if (bHasColRowNames) - bColRowNameCompile = checkCompileColRowName(rCxt, *pDocument, *pCode, aOldPos, aPos, bValChanged); + if (bHasColRowNames && !bRecompile) + bRecompile = checkCompileColRowName(rCxt, *pDocument, *pCode, aOldPos, aPos, bValChanged); ScChangeTrack* pChangeTrack = pDocument->GetChangeTrack(); bInDeleteUndo = (pChangeTrack && pChangeTrack->IsInDeleteUndo()); @@ -2304,7 +2306,7 @@ bool ScFormulaCell::UpdateReferenceOnShift( bHasRelName = HasRelNameReference(); // Reference changed and new listening needed? // Except in Insert/Delete without specialties. - bNewListening = (bRefModified || bColRowNameCompile + bNewListening = (bRefModified || bRecompile || (bValChanged && (bInDeleteUndo || bRefSizeChanged)) || bHasRelName); if ( bNewListening ) @@ -2312,12 +2314,13 @@ bool ScFormulaCell::UpdateReferenceOnShift( } // NeedDirty for changes except for Copy and Move/Insert without RelNames - bool bNeedDirty = (bValChanged || bColRowNameCompile || bOnRefMove); + bool bNeedDirty = (bValChanged || bRecompile || bOnRefMove); if (pUndoDoc && (bValChanged || bOnRefMove)) setOldCodeToUndo(pUndoDoc, aUndoPos, pOldCode.get(), eTempGrammar, cMatrixFlag); - if ( (bCompile = (bCompile || bColRowNameCompile)) != 0 ) + bCompile |= bRecompile; + if (bCompile) { CompileTokenArray( bNewListening ); // no Listening bNeedDirty = true; diff --git a/sc/source/core/data/refupdatecontext.cxx b/sc/source/core/data/refupdatecontext.cxx index 67e12420cff7..25ffceb55b82 100644 --- a/sc/source/core/data/refupdatecontext.cxx +++ b/sc/source/core/data/refupdatecontext.cxx @@ -24,9 +24,42 @@ bool RefUpdateContext::isDeleted() const return (meMode == URM_INSDEL) && (mnColDelta < 0 || mnRowDelta < 0 || mnTabDelta < 0); } -RefUpdateResult::RefUpdateResult() : mbValueChanged(false), mbReferenceModified(false) {} +void RefUpdateContext::setUpdatedName(SCTAB nTab, sal_uInt16 nIndex) +{ + UpdatedNamesType::iterator it = maUpdatedNames.find(nTab); + if (it == maUpdatedNames.end()) + { + // Insert a new container for this sheet index. + NameIndicesType aIndices; + std::pair<UpdatedNamesType::iterator,bool> r = + maUpdatedNames.insert(UpdatedNamesType::value_type(nTab, aIndices)); + + if (!r.second) + // Insertion failed for whatever reason. + return; + + it = r.first; + } + + NameIndicesType& rIndices = it->second; + rIndices.insert(nIndex); +} + +bool RefUpdateContext::isNameUpdated(SCTAB nTab, sal_uInt16 nIndex) const +{ + UpdatedNamesType::const_iterator it = maUpdatedNames.find(nTab); + if (it == maUpdatedNames.end()) + return false; + + const NameIndicesType& rIndices = it->second; + return rIndices.count(nIndex) > 0; +} + +RefUpdateResult::RefUpdateResult() : mbValueChanged(false), mbReferenceModified(false), mbNameModified(false) {} RefUpdateResult::RefUpdateResult(const RefUpdateResult& r) : - mbValueChanged(r.mbValueChanged), mbReferenceModified(r.mbReferenceModified) {} + mbValueChanged(r.mbValueChanged), + mbReferenceModified(r.mbReferenceModified), + mbNameModified(r.mbNameModified) {} } diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 86e8d1b2bd25..f74c09f51709 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1448,7 +1448,7 @@ void ScTable::UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nR } void ScTable::UpdateReference( - const sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc, bool bIncludeDraw, bool bUpdateNoteCaptionPos ) + sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc, bool bIncludeDraw, bool bUpdateNoteCaptionPos ) { bool bUpdated = false; SCCOL i; @@ -1475,7 +1475,7 @@ void ScTable::UpdateReference( // Named expressions need to be updated before formulas acessing them. if (mpRangeName) - mpRangeName->UpdateReference(rCxt, true); + mpRangeName->UpdateReference(rCxt, nTab); for ( ; i<=iMax; i++) bUpdated |= aCol[i].UpdateReference(rCxt, pUndoDoc); |