[Libreoffice-commits] core.git: sc/inc sc/source
Eike Rathke
erack at redhat.com
Fri Mar 18 13:37:26 UTC 2016
sc/inc/compiler.hxx | 1 +
sc/source/core/tool/compiler.cxx | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+)
New commits:
commit cf56d2449c27130ae40dc940ddcdb13de1128b7f
Author: Eike Rathke <erack at redhat.com>
Date: Fri Mar 18 14:07:55 2016 +0100
adjust other-sheet-local relative sheet references, tdf#96915
... so they still point to the same sheet as if used on the original
local sheet.
Change-Id: Id40378deaf70c1645bfa52ea28aa39775d16aec5
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index e1887aa..a037023 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -324,6 +324,7 @@ private:
bool IsBoolean( const OUString& );
void AutoCorrectParsedSymbol();
+ void AdjustSheetLocalNameRelReferences( SCTAB nDelta );
void SetRelNameReference();
/** Obtain range data for ocName token, global or sheet local.
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index c57f192..15b1939 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4462,6 +4462,14 @@ bool ScCompiler::HandleRange()
PushTokenArray( pNew, true );
if( pRangeData->HasReferences() )
{
+ // Relative sheet references in sheet-local named expressions
+ // shall still point to the same sheet as if used on the
+ // original sheet, not shifted to the current position where
+ // they are used.
+ SCTAB nSheetTab = mpToken->GetSheet();
+ if (nSheetTab >= 0 && nSheetTab != aPos.Tab())
+ AdjustSheetLocalNameRelReferences( nSheetTab - aPos.Tab());
+
SetRelNameReference();
MoveRelWrap(pRangeData->GetMaxCol(), pRangeData->GetMaxRow());
}
@@ -4526,6 +4534,23 @@ bool ScCompiler::HandleExternalReference(const FormulaToken& _aToken)
return true;
}
+void ScCompiler::AdjustSheetLocalNameRelReferences( SCTAB nDelta )
+{
+ pArr->Reset();
+ for (formula::FormulaToken* t = pArr->GetNextReference(); t; t = pArr->GetNextReference())
+ {
+ ScSingleRefData& rRef1 = *t->GetSingleRef();
+ if (rRef1.IsTabRel())
+ rRef1.IncTab( nDelta);
+ if ( t->GetType() == svDoubleRef )
+ {
+ ScSingleRefData& rRef2 = t->GetDoubleRef()->Ref2;
+ if (rRef2.IsTabRel())
+ rRef2.IncTab( nDelta);
+ }
+ }
+}
+
// reference of named range with relative references
void ScCompiler::SetRelNameReference()
More information about the Libreoffice-commits
mailing list