diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2022-02-03 15:29:49 +0100 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2022-02-05 12:21:31 +0100 |
commit | 1c949e29e8a589bb8430e6fb2e5855dbb722b82a (patch) | |
tree | 89f282fc565c4bbba4107ddda5c59f4e8aabb931 /wizards | |
parent | 33d70d68aa67d567e9b18fa5947b86df6e378f32 (diff) |
ScriptForge - (SF_Calc) fix range parsing error when leading $
When sheet name contains
- a leading $
- surrounding single quotes
an error message was errorneously displayed to the user.
Corrected in the SF_Calc._ParseAddress() function
Correction on master:
https://git.libreoffice.org/core/+/de03a5ca23ddb09a55014f9d79ebcd6df54503bb%5E%21
Change-Id: I588c07132b9d98a3351f03e3e876ef81812d2f04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129426
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/source/sfdocuments/SF_Calc.xba | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/wizards/source/sfdocuments/SF_Calc.xba b/wizards/source/sfdocuments/SF_Calc.xba index e5b35e4afa12..78c17689d92a 100644 --- a/wizards/source/sfdocuments/SF_Calc.xba +++ b/wizards/source/sfdocuments/SF_Calc.xba @@ -3533,6 +3533,7 @@ Private Function _ParseAddress(ByVal psAddress As String) As Object ''' CALCADDRESSERROR ' Address could not be parsed to a valid address Dim oAddress As Object ' Return value +Dim sAddress As String ' Alias of psAddress Dim lStart As Long ' Position of found regex Dim sSheet As String ' Sheet component Dim sRange As String ' Range component @@ -3565,20 +3566,22 @@ Dim oSelect As Object ' Current selection .RawAddress = psAddress Set .XSpreadSheet = Nothing : Set .XCellRange = Nothing + ' Remove leading '$' + If Left(psAddress, 1) = "$" Then sAddress = Mid(psAddress, 2) Else sAddress = psAddress ' Split in sheet and range components - Check presence of surrounding single quotes or dot - If Left(psAddress, 1) = "'" Then + If Left(sAddress, 1) = "'" Then lStart = 1 - sSheet = ScriptForge.SF_String.FindRegex(psAddress, "^'[^\[\]*?:\/\\]+'") + sSheet = ScriptForge.SF_String.FindRegex(sAddress, "^'[^\[\]*?:\/\\]+'") If lStart = 0 Then GoTo CatchAddress ' Invalid sheet name - If Len(psAddress) > Len(sSheet) + 1 Then - If Mid(psAddress, Len(sSheet) + 1, 1) = "." then sRange = Mid(psAddress, Len(sSheet) + 2) + If Len(sAddress) > Len(sSheet) + 1 Then + If Mid(sAddress, Len(sSheet) + 1, 1) = "." then sRange = Mid(sAddress, Len(sSheet) + 2) End If sSheet = Replace(Replace(sSheet, "$", ""), "'", "") - ElseIf InStr(psAddress, ".") > 0 Then - sSheet = Replace(Split(psAddress, ".")(0), "$", "") - sRange = Replace(Split(psAddress, ".")(1), "$", "") + ElseIf InStr(sAddress, ".") > 0 Then + sSheet = Replace(Split(sAddress, ".")(0), "$", "") + sRange = Replace(Split(sAddress, ".")(1), "$", "") Else - sSheet = psAddress + sSheet = sAddress End If ' Resolve sheet part: either a document named range, or the active sheet or a real sheet |