diff options
-rw-r--r-- | sc/source/core/tool/token.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 75f8bc0d9587..794782796f56 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -2939,6 +2939,19 @@ bool adjustDoubleRefInName( ScComplexRefData& rRef, const sc::RefUpdateContext& rCxt, const ScAddress& rPos ) { bool bRefChanged = false; + if (rCxt.mnRowDelta > 0 && rCxt.mrDoc.IsExpandRefs() && !rRef.Ref1.IsRowRel() && !rRef.Ref2.IsRowRel()) + { + // Check and see if we should expand the range at the top. + ScRange aSelectedRange = getSelectedRange(rCxt); + ScRange aAbs = rRef.toAbs(rPos); + if (aSelectedRange.Intersects(aAbs)) + { + // Selection intersects the referenced range. Only expand the + // bottom position. + rRef.Ref2.IncRow(rCxt.mnRowDelta); + return true; + } + } if (adjustSingleRefInName(rRef.Ref1, rCxt, rPos)) bRefChanged = true; @@ -2994,6 +3007,19 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceInName( aRes.mbReferenceModified = true; } } + else if (rCxt.mnRowDelta > 0 && rCxt.mrDoc.IsExpandRefs()) + { + // Check if we could expand range reference by the bottom + // edge. For named expressions, we only expand absolute + // references. + if (!rRef.Ref1.IsRowRel() && !rRef.Ref2.IsRowRel() && aAbs.aEnd.Row()+1 == rCxt.maRange.aStart.Row()) + { + // Expand by the bottom edge. + rRef.Ref2.IncRow(rCxt.mnRowDelta); + aRes.mbReferenceModified = true; + } + + } } break; default: |