wizards/source/scriptforge/SF_Dictionary.xba |    8 +++---
 wizards/source/scriptforge/SF_UI.xba         |   36 ++++++++++++---------------
 wizards/source/sfdatabases/SF_Database.xba   |   12 +++++----
 wizards/source/sfdocuments/SF_Document.xba   |   16 ++++++------
 4 files changed, 36 insertions(+), 36 deletions(-)

New commits:
commit c2aa474465eb8156b0ce384bc64ba6298d2b61be
Author:     Jean-Pierre Ledure <j...@ledure.be>
AuthorDate: Sun Oct 6 16:00:38 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Oct 8 15:22:45 2024 +0200

    ScriptForge Fix tdf#163219 With blocks
    
    Reference:
      https://bugs.documentfoundation.org/show_bug.cgi?id=163219#c7
    
    Everywhere the With block variable is defined
    or redefined inside the With block, the Basic
    code has been reviewed.
    
    Found in
      SFDatabases/SF_Database.xba/SetTransactionMode()
      SFDocuments/SF_Document.xba/Styles()
      ScriptForge/SF_Dictionary.xba/ImportFromPropertyValues()
      ScriptForge/SF_UI.xba/SetStatusBar()
      ScriptForge/SF_UI.xba/ShowProgressBar()
    
    Most changes consist in isolating the With block
    variable before the With block itself.
    
    No functional change.
    
    This solution is a workaround for the bug.
    IT DOES NOT SOLVE THE ROOT CAUSE.
    
    Change-Id: I48af29d3d9c8b1e36ef5a85c8cfe28f9639ae483
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174560
    Reviewed-by: Jean-Pierre Ledure <j...@ledure.be>
    Tested-by: Jenkins
    (cherry picked from commit 0b6afed3b85b6599ecbd7e5ac97b080d3ffbbfbf)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174665

diff --git a/wizards/source/scriptforge/SF_Dictionary.xba 
b/wizards/source/scriptforge/SF_Dictionary.xba
index 22ada5148e2a..d6c0bc3346e2 100644
--- a/wizards/source/scriptforge/SF_Dictionary.xba
+++ b/wizards/source/scriptforge/SF_Dictionary.xba
@@ -583,8 +583,8 @@ Check:
 
 Try:
        If Not IsArray(PropertyValues) Then PropertyValues = 
Array(PropertyValues)
-       With oPropertyValue
-               For Each oPropertyValue In PropertyValues
+       For Each oPropertyValue In PropertyValues
+               With oPropertyValue
                        If Overwrite Then bExists = Exists(.Name) Else bExists 
= False
                        If SF_Session.UnoObjectType(oPropertyValue) = 
&quot;com.sun.star.beans.PropertyValue&quot; Then
                                If IsUnoStruct(.Value) Then
@@ -604,8 +604,8 @@ Try:
                                        Add(.Name, vItem)       &apos;  Key 
controls are done in Add
                                End If
                        End If
-               Next oPropertyValue
-       End With
+               End With
+       Next oPropertyValue
        bImport = True
 
 Finally:
diff --git a/wizards/source/scriptforge/SF_UI.xba 
b/wizards/source/scriptforge/SF_UI.xba
index 3bde6c22e4ac..3fda3e3c72be 100644
--- a/wizards/source/scriptforge/SF_UI.xba
+++ b/wizards/source/scriptforge/SF_UI.xba
@@ -1078,21 +1078,19 @@ Check:
 
 Try:
        Set oStatusbar = _SF_.Statusbar
-       With oStatusbar
-               If IsNull(oStatusbar) Then              &apos;  Initial call
-                       Set oComp = StarDesktop.CurrentComponent
-                       If Not IsNull(oComp) Then
-                               Set oControl = Nothing
-                               If SF_Session.HasUnoProperty(oComp, 
&quot;CurrentController&quot;) Then Set oControl = oComp.CurrentController
-                               If Not IsNull(oControl) Then
-                                       If SF_Session.HasUnoMethod(oControl, 
&quot;getStatusIndicator&quot;) Then oStatusbar = oControl.getStatusIndicator()
-                               End If
-                       End If
-                       If Not IsNull(oStatusbar) Then
-                               .start(&quot;&quot;, 100)
+       If IsNull(oStatusbar) Then              &apos;  Initial call
+               Set oComp = StarDesktop.CurrentComponent
+               If Not IsNull(oComp) Then
+                       Set oControl = Nothing
+                       If SF_Session.HasUnoProperty(oComp, 
&quot;CurrentController&quot;) Then Set oControl = oComp.CurrentController
+                       If Not IsNull(oControl) Then
+                               If SF_Session.HasUnoMethod(oControl, 
&quot;getStatusIndicator&quot;) Then oStatusbar = oControl.getStatusIndicator()
                        End If
                End If
-               If Not IsNull(oStatusbar) Then
+               If Not IsNull(oStatusbar) Then oStatusBar.start(&quot;&quot;, 
100)
+       End If
+       If Not IsNull(oStatusbar) Then
+               With oStatusbar
                        If Len(Text) = 0 And Percentage = -1 Then
                                .end()
                                Set oStatusbar = Nothing
@@ -1100,8 +1098,8 @@ Try:
                                If Len(Text) &gt; 0 Then .setText(Text)
                                If Percentage &gt;= 0 And Percentage &lt;= 100 
Then .setValue(Percentage)
                        End If
-               End If
-       End With
+               End With
+       End If
 
 Finally:
        Set _SF_.Statusbar = oStatusbar
@@ -1160,11 +1158,11 @@ Try:
                Set oFixedText = .ProgressBarText
                Set oProgressBar = .ProgressBarBar
        End With
-       With oDialog
-               bFirstCall = ( IsNull(oDialog) )
-               If Not bFirstCall Then bFirstCall = Not ._IsStillAlive(False)   
&apos;  False to not raise an error
-               If bFirstCall Then Set oDialog = 
CreateScriptService(&quot;SFDialogs.Dialog&quot;, &quot;GlobalScope&quot;, 
&quot;ScriptForge&quot;, &quot;dlgProgress&quot;, _Context)
 
+       bFirstCall = ( IsNull(oDialog) )
+       If Not bFirstCall Then bFirstCall = Not oDialog._IsStillAlive(False)    
&apos;  False to not raise an error
+       If bFirstCall Then Set oDialog = 
CreateScriptService(&quot;SFDialogs.Dialog&quot;, &quot;GlobalScope&quot;, 
&quot;ScriptForge&quot;, &quot;dlgProgress&quot;, _Context)
+       With oDialog
                If Not IsNull(oDialog) Then
                        If Len(Title) = 0 And Len(Text) = 0 And Percentage = -1 
Then
                                Set oDialog = .Dispose()
diff --git a/wizards/source/sfdatabases/SF_Database.xba 
b/wizards/source/sfdatabases/SF_Database.xba
index ff0eafc5b783..8e234108a580 100644
--- a/wizards/source/sfdatabases/SF_Database.xba
+++ b/wizards/source/sfdatabases/SF_Database.xba
@@ -938,10 +938,10 @@ Check:
        If _ReadOnly Then GoTo Catch_ReadOnly
 
 Try:
-       With _Connection
-               bCommit = ( TransactionMode &gt; 
com.sun.star.sdbc.TransactionIsolation.NONE )
-               &apos;  Replace the existing connection
-               If Not IsNull(_Connection) Then
+       bCommit = ( TransactionMode &gt; 
com.sun.star.sdbc.TransactionIsolation.NONE )
+       &apos;  Replace the existing connection
+       If Not IsNull(_Connection) Then
+               With _Connection
                        If .AutoCommit And bCommit Then
                                _CloseConnection()
                                Set _Connection = 
_DataSource.getIsolatedConnection(_User, _Password)
@@ -949,9 +949,11 @@ Try:
                                _CloseConnection()
                                Set _Connection = 
_DataSource.getConnection(_User, _Password)
                        End If
-               End If
+               End With
+       End If
 
                &apos;  Set the transaction mode
+       With _Connection
                If bCommit Then
                        .SetTransactionIsolation(CLng(TransactionMode))
                        .setAutoCommit(Not bCommit)
diff --git a/wizards/source/sfdocuments/SF_Document.xba 
b/wizards/source/sfdocuments/SF_Document.xba
index 43e143f30a59..491f5dacb2c0 100644
--- a/wizards/source/sfdocuments/SF_Document.xba
+++ b/wizards/source/sfdocuments/SF_Document.xba
@@ -1550,10 +1550,10 @@ Try:
                vStyles = oFamily.getElementNames()
                &apos;  Scan the list and retain those passing the filter
                For i = 0 To UBound(vStyles)
-                       With oStyle
-                               sStyle = vStyles(i)
-                               Set oStyle = _GetStyle(oFamily, sStyle)
-                               If Not IsNull(oStyle) Then
+                       sStyle = vStyles(i)
+                       Set oStyle = _GetStyle(oFamily, sStyle)
+                       If Not IsNull(oStyle) Then
+                               With oStyle
                                        &apos;  Pattern ?
                                        bValid = ( Len(NamePattern) = 0 )
                                        If Not bValid Then bValid = 
ScriptForge.SF_String.IsLike(.DisplayName, NamePattern, CaseSensitive := True)
@@ -1570,10 +1570,10 @@ Try:
                                        &apos;  Category ?
                                        If bValid And Len(Category) &gt; 0 Then 
bValid = ( UCase(Category) = .Category )
                                        If bValid Then vStyles(i) = 
.DisplayName Else vStyles(i) = &quot;&quot;
-                               Else
-                                       vStyles(i) = &quot;&quot;
-                               End If
-                       End With
+                               End With
+                       Else
+                               vStyles(i) = &quot;&quot;
+                       End If
                Next i
                &apos;  Reject when not valid
                vStyles = ScriptForge.SF_Array.TrimArray(vStyles)

Reply via email to