diff options
-rw-r--r-- | sc/source/core/data/column.cxx | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 9ff510ccb133..99d2626b38a9 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -2116,6 +2116,16 @@ class UpdateRefOnNonCopy : std::unary_function<sc::FormulaGroupEntry, void> ScDocument* mpUndoDoc; bool mbUpdated; + void recompileTokenArray( ScFormulaCell& rTopCell ) + { + // We need to re-compile the token array when a range name is + // modified, to correctly reflect the new references in the + // name. + ScCompiler aComp(&mpCxt->mrDoc, rTopCell.aPos, *rTopCell.GetCode()); + aComp.SetGrammar(mpCxt->mrDoc.GetGrammar()); + aComp.CompileTokenArray(); + } + void updateRefOnShift( sc::FormulaGroupEntry& rGroup ) { if (!rGroup.mbShared) @@ -2149,7 +2159,10 @@ class UpdateRefOnNonCopy : std::unary_function<sc::FormulaGroupEntry, void> aRes.mbValueChanged = true; } - if (aRes.mbReferenceModified) + if (aRes.mbNameModified) + recompileTokenArray(*pTop); + + if (aRes.mbReferenceModified || aRes.mbNameModified) { sc::StartListeningContext aStartCxt(mpCxt->mrDoc); sc::EndListeningContext aEndCxt(mpCxt->mrDoc, pOldCode.get()); @@ -2221,14 +2234,7 @@ class UpdateRefOnNonCopy : std::unary_function<sc::FormulaGroupEntry, void> sc::AutoCalcSwitch(mpCxt->mrDoc, false); if (aRes.mbNameModified) - { - // We need to re-compile the token array when a range name is - // modified, to correctly reflect the new references in the - // name. - ScCompiler aComp(&mpCxt->mrDoc, aPos, *pCode); - aComp.SetGrammar(mpCxt->mrDoc.GetGrammar()); - aComp.CompileTokenArray(); - } + recompileTokenArray(*pTop); // Perform end-listening, start-listening, and dirtying on all // formula cells in the group. |