From de03a5ca23ddb09a55014f9d79ebcd6df54503bb Mon Sep 17 00:00:00 2001 From: Jean-Pierre Ledure Date: Thu, 3 Feb 2022 11:49:46 +0100 Subject: 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 Change-Id: I8abd4908a4c92bd6e569b95be58ab21e16ffc169 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129408 Tested-by: Jean-Pierre Ledure Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure --- wizards/source/sfdocuments/SF_Calc.xba | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'wizards') diff --git a/wizards/source/sfdocuments/SF_Calc.xba b/wizards/source/sfdocuments/SF_Calc.xba index 29b22f4b0ed0..8c9ab301370f 100644 --- a/wizards/source/sfdocuments/SF_Calc.xba +++ b/wizards/source/sfdocuments/SF_Calc.xba @@ -3550,6 +3550,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 @@ -3582,20 +3583,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 -- cgit