sc/source/core/tool/rangeutl.cxx | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
New commits: commit fde3b0e07eaf86ed4e16326de323f79db706e8f2 Author: Eike Rathke <er...@redhat.com> AuthorDate: Mon Mar 29 21:04:04 2021 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Tue Mar 30 00:39:36 2021 +0200 Sheet names can contain parentheses and blanks ... so search for the very first occurrence of " (" and not the last, and also not any ")" but it has to be the last character in the Name Box UI representation of sheet-local scope names so check just that. Change-Id: I0b63688432f891ee779e3e32017def78b021e470 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113327 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx index 1a7467fbb0ec..18473e0a3d5f 100644 --- a/sc/source/core/tool/rangeutl.cxx +++ b/sc/source/core/tool/rangeutl.cxx @@ -239,6 +239,9 @@ bool ScRangeUtil::MakeRangeFromName ( ScAddress::Details const & rDetails ) { bool bResult = false; + if (rName.isEmpty()) + return bResult; + SCTAB nTab = 0; SCCOL nColStart = 0; SCCOL nColEnd = 0; @@ -247,22 +250,27 @@ bool ScRangeUtil::MakeRangeFromName ( if( eScope==RUTL_NAMES ) { - //first handle ui names like local1 (Sheet1), which point to a local range name OUString aName(rName); - sal_Int32 nEndPos = aName.lastIndexOf(')'); - sal_Int32 nStartPos = aName.lastIndexOf(" ("); SCTAB nTable = nCurTab; - if (nEndPos != -1 && nStartPos != -1) + + // First handle UI names like "local1 (Sheet1)", which point to a local + // range name. + const sal_Int32 nEndPos = aName.getLength() - 1; + if (rName[nEndPos] == ')') { - OUString aSheetName = aName.copy(nStartPos+2, nEndPos-nStartPos-2); - if (rDoc.GetTable(aSheetName, nTable)) + const sal_Int32 nStartPos = aName.indexOf(" ("); + if (nStartPos != -1) { - aName = aName.copy(0, nStartPos); + OUString aSheetName = aName.copy(nStartPos+2, nEndPos-nStartPos-2); + if (rDoc.GetTable(aSheetName, nTable)) + { + aName = aName.copy(0, nStartPos); + } + else + nTable = nCurTab; } - else - nTable = nCurTab; } - //then check for local range names + // Then check for local range names. ScRangeName* pRangeNames = rDoc.GetRangeName( nTable ); ScRangeData* pData = nullptr; aName = ScGlobal::getCharClassPtr()->uppercase(aName); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits