diff options
author | Eike Rathke <erack@redhat.com> | 2021-10-12 13:56:09 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2021-10-12 17:44:18 +0200 |
commit | 57f09e6f3cfdd9ad4e1673df14e6ee550d402743 (patch) | |
tree | d0a617bdc7d4506f702697cd063da6ac33e17569 /sc/source | |
parent | c90cb1b3c265c1f81e614e47652fe24137d7928c (diff) |
Resolves: tdf#145077 Use position for jumping to named relative references
For named ranges with relative references construct the resulting
cell range reference to be selected according to the current cell
cursor position, same as in Manage Names and as they would result
if used in a formula expression on that position.
Change-Id: I8362c3e38086337ad90aa84cc7c13f284b41d9fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123450
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/rangeutl.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh3.cxx | 6 |
2 files changed, 15 insertions, 7 deletions
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx index 34541e590f09..fd660a8a23a1 100644 --- a/sc/source/core/tool/rangeutl.cxx +++ b/sc/source/core/tool/rangeutl.cxx @@ -236,7 +236,8 @@ bool ScRangeUtil::MakeRangeFromName ( SCTAB nCurTab, ScRange& rRange, RutlNameScope eScope, - ScAddress::Details const & rDetails ) + ScAddress::Details const & rDetails, + bool bUseDetailsPos ) { bool bResult = false; if (rName.isEmpty()) @@ -292,9 +293,16 @@ bool ScRangeUtil::MakeRangeFromName ( ScRefAddress aStartPos; ScRefAddress aEndPos; - // tdf#138646 - consider the current grammar and address convention of the document - pData->GetSymbol(aStrArea, - FormulaGrammar::mergeToGrammar(rDoc.GetGrammar(), rDetails.eConv)); + // tdf#138646: use the current grammar of the document and passed + // address convention. + // tdf#145077: create range string according to current cell cursor + // position if expression has relative references and details say so. + if (bUseDetailsPos) + pData->GetSymbol( aStrArea, ScAddress( rDetails.nCol, rDetails.nRow, nCurTab), + FormulaGrammar::mergeToGrammar(rDoc.GetGrammar(), rDetails.eConv)); + else + pData->GetSymbol( aStrArea, + FormulaGrammar::mergeToGrammar(rDoc.GetGrammar(), rDetails.eConv)); if ( IsAbsArea( aStrArea, rDoc, nTable, nullptr, &aStartPos, &aEndPos, rDetails ) ) diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index 03e8dd4f9593..2fa44e4233b4 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -374,9 +374,9 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) else { const RutlNameScope eScope = (bForceGlobalName ? RUTL_NAMES_GLOBAL : RUTL_NAMES); - formula::FormulaGrammar::AddressConvention eConv = rDoc.GetAddressConvention(); - if( ScRangeUtil::MakeRangeFromName( aAddress, rDoc, nTab, aScRange, eScope, eConv ) || - ScRangeUtil::MakeRangeFromName( aAddress, rDoc, nTab, aScRange, RUTL_DBASE, eConv ) ) + ScAddress::Details aDetails( rDoc.GetAddressConvention(), rViewData.GetCurY(), rViewData.GetCurX()); + if (ScRangeUtil::MakeRangeFromName( aAddress, rDoc, nTab, aScRange, eScope, aDetails, true) || + ScRangeUtil::MakeRangeFromName( aAddress, rDoc, nTab, aScRange, RUTL_DBASE, aDetails, true)) { nResult |= ScRefFlags::VALID; if( aScRange.aStart.Tab() != nTab ) |