This is an automated email from the ASF dual-hosted git repository.
mseidel pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/trunk by this push:
new a422f770cb pre-commit auto whitespace clean up for vbs files (#388)
a422f770cb is described below
commit a422f770cbbc03bbe7dddc4a28380f80375a0390
Author: John Bampton <[email protected]>
AuthorDate: Sat Jul 19 01:00:51 2025 +1000
pre-commit auto whitespace clean up for vbs files (#388)
Enforce 2 hooks for vbs files
---
.pre-commit-config.yaml | 4 +-
.../src/driver_docs/DocAnalysisRunMacro.vbs | 149 ++++++++++-----------
main/odk/examples/OLE/vbscript/WriterDemo.vbs | 32 ++---
3 files changed, 92 insertions(+), 93 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 11475cfbf7..7e4e42dd30 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -33,12 +33,12 @@ repos:
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: end-of-file-fixer
- files:
(m|M)akefile$|\.(asp|bat|c|cl|common|cxx|dxp|el|h|hrc|hxx|idl|in|ini|java|m|md|mk|mm|mod|pas|php|pl|pm|py|rc|rdf|sh|xba|xcs|xdl|xhp|xmi|xml|xsd|xslt?|ya?ml)$|^ext_libraries/.*$|^test/.*$
+ files:
(m|M)akefile$|\.(asp|bat|c|cl|common|cxx|dxp|el|h|hrc|hxx|idl|in|ini|java|m|md|mk|mm|mod|pas|php|pl|pm|py|rc|rdf|sh|vbs|xba|xcs|xdl|xhp|xmi|xml|xsd|xslt?|ya?ml)$|^ext_libraries/.*$|^test/.*$
- id: fix-byte-order-marker
- id: mixed-line-ending
files:
^main/.*\.(c|h)xx$|^main/.*\.java$|\.(asp|c|cl|common|dxp|el|h|hrc|idl|in|ini|m|md|mk|mm|mod|pas|php|pl|pm|py|rc|rdf|sh|xba|xcs|xdl|xhp|xmi|xsd|xslt?|ya?ml)$|^main/accessibility/.*$|^main/afms/.*$|^main/animations/.*$|^main/apache-commons/.*$|^test/testgui/.*$
- id: trailing-whitespace
- files:
(m|M)akefile$|\.(asp|bat|c|cl|common|dxp|el|hrc|hxx|idl|in|ini|m|mk|mm|mod|pas|php|pl|pm|py|rc|rdf|sh|xba|xcs|xdl|xhp|xmi|xsd|ya?ml)$
+ files:
(m|M)akefile$|\.(asp|bat|c|cl|common|dxp|el|hrc|hxx|idl|in|ini|m|mk|mm|mod|pas|php|pl|pm|py|rc|rdf|sh|vbs|xba|xcs|xdl|xhp|xmi|xsd|ya?ml)$
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
diff --git a/main/migrationanalysis/src/driver_docs/DocAnalysisRunMacro.vbs
b/main/migrationanalysis/src/driver_docs/DocAnalysisRunMacro.vbs
index 5093c3678a..00743cae93 100644
--- a/main/migrationanalysis/src/driver_docs/DocAnalysisRunMacro.vbs
+++ b/main/migrationanalysis/src/driver_docs/DocAnalysisRunMacro.vbs
@@ -7,9 +7,9 @@
' to you under the Apache License, Version 2.0 (the
' "License"); you may not use this file except in compliance
' with the License. You may obtain a copy of the License at
-'
+'
' http://www.apache.org/licenses/LICENSE-2.0
-'
+'
' Unless required by applicable law or agreed to in writing,
' software distributed under the License is distributed on an
' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -28,13 +28,13 @@ Const CDA_APPNAME_WORD = "Word"
Const CDA_APPNAME_EXCEL = "Excel"
Const CDA_APPNAME_POWERPOINT = "PowerPoint"
-Dim daWrd
-Dim daDoc
-Dim daXl
+Dim daWrd
+Dim daDoc
+Dim daXl
Dim daWb
Dim daPP
Dim daPres
-Dim daWshShell
+Dim daWshShell
Dim daFso
Dim daTitle
@@ -47,29 +47,29 @@ set daWshShell = Wscript.CreateObject("Wscript.Shell")
'##### Run Macro FUNCTIONS ######
-'######################
+'######################
Sub DASetTitle(newTitle)
daTitle = newTitle
End Sub
-'######################
+'######################
Sub DAsetupWrdServer
-
+
On Error Resume Next
Set daWrd = wscript.CreateObject("Word.Application")
If Err.Number <> 0 Then
- DAErrMsg "Failed to create Word Automation server: " & vbLf & vbLf &
"Error: " _
- & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
+ DAErrMsg "Failed to create Word Automation server: " & vbLf & vbLf &
"Error: " _
+ & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
FinalExit
End If
End Sub
-'######################
+'######################
Sub DAOpenWrdDriver(driver)
Dim sWordDriverDocPath
-
+
On Error Resume Next
daWrd.Visible = False
@@ -78,20 +78,20 @@ sWordDriverDocPath = daFso.GetAbsolutePathName(driver)
'DAdiagMsg "sWordDriverDocPath : " & sWordDriverDocPath , CDIAG_STD_DELAY
If Not daFso.FileExists(sWordDriverDocPath) Then
- DAErrMsg "Driver doc does not exist: " & sWordDriverDocPath,
CDA_ERR_STD_DELAY
+ DAErrMsg "Driver doc does not exist: " & sWordDriverDocPath,
CDA_ERR_STD_DELAY
FinalExit
End If
Set daDoc = daWrd.Documents.Open(sWordDriverDocPath)
If Err.Number <> 0 Then
- DAErrMsg "Failed to open driver doc: " & vbLf & sWordDriverDocPath &
vbLf & vbLf & "Error: " _
- & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
+ DAErrMsg "Failed to open driver doc: " & vbLf & sWordDriverDocPath &
vbLf & vbLf & "Error: " _
+ & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
FinalExit
End If
End Sub
-'######################
+'######################
Function DArunWrdDriver(driver, macro)
On Error Resume Next
@@ -100,34 +100,34 @@ DArunWrdDriver = True
daWrd.Run ("AnalysisTool." & macro)
If Err.Number <> 0 Then
DAErrMsg "Failed to run macro: " & macro & vbLf & vbLf & "Error: " _
- & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
+ & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
DArunWrdDriver = False
End If
End Function
-'######################
+'######################
Sub DAsaveWrdDriver(saveDriver)
'DAdiagMsg "saveDriver : " & saveDriver , CDIAG_STD_DELAY
'DAdiagMsg "Abs(saveDriver) : " & daFso.GetAbsolutePathName( saveDriver) ,
CDIAG_STD_DELAY
daDoc.SaveAs daFso.GetAbsolutePathName( saveDriver)
End Sub
-'######################
+'######################
Sub DAsetupExcelServer
-
+
On Error Resume Next
Set daXl = wscript.CreateObject("Excel.Application")
If Err.Number <> 0 Then
- DAErrMsg "Failed to create Excel Automation server: " & vbLf & vbLf &
"Error: " _
- & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
+ DAErrMsg "Failed to create Excel Automation server: " & vbLf & vbLf &
"Error: " _
+ & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
FinalExit
End If
End Sub
-'######################
+'######################
Sub DAOpenExcelDriver(driver)
Dim sExcelDriverDocPath
@@ -137,20 +137,20 @@ Sub DAOpenExcelDriver(driver)
'# Open driver doc
sExcelDriverDocPath = daFso.GetAbsolutePathName(driver)
If Not daFso.FileExists(sExcelDriverDocPath) Then
- DAErrMsg "Driver doc does not exist: " & sExcelDriverDocPath,
CDA_ERR_STD_DELAY
+ DAErrMsg "Driver doc does not exist: " & sExcelDriverDocPath,
CDA_ERR_STD_DELAY
FinalExit
End If
Set daWb = daXl.Workbooks.Open(sExcelDriverDocPath)
If Err.Number <> 0 Then
- DAErrMsg "Failed to open driver doc: " & vbLf & sExcelDriverDocPath &
vbLf & vbLf & "Error: " _
- & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
+ DAErrMsg "Failed to open driver doc: " & vbLf & sExcelDriverDocPath &
vbLf & vbLf & "Error: " _
+ & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
FinalExit
End If
End Sub
-'######################
+'######################
Function DArunExcelDriver(driver, macro)
On Error Resume Next
@@ -159,13 +159,13 @@ DArunExcelDriver = True
daXl.Run ("AnalysisTool." & macro)
If Err.Number <> 0 Then
DAErrMsg "Failed to run macro: " & macro & vbLf & vbLf & "Error: " _
- & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
+ & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
DArunExcelDriver = False
End If
End Function
-'######################
+'######################
Sub DAsaveExcelDriver(saveDriver)
'# Not overwriting - Excel hangs, need to remove file first
if daFso.FileExists(daFso.GetAbsolutePathName(saveDriver)) Then
@@ -174,45 +174,45 @@ Sub DAsaveExcelDriver(saveDriver)
daWb.SaveAs daFso.GetAbsolutePathName(saveDriver)
End Sub
-'######################
+'######################
Sub DAsetupPPServer
-
+
On Error Resume Next
Set daPP = wscript.CreateObject("PowerPoint.Application")
If Err.Number <> 0 Then
- DAErrMsg "Failed to create PowerPoint Automation server: " & vbLf &
vbLf & "Error: " _
- & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
+ DAErrMsg "Failed to create PowerPoint Automation server: " & vbLf &
vbLf & "Error: " _
+ & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
FinalExit
End If
End Sub
-'######################
+'######################
Sub DAOpenPPDriver(driver)
Dim sPPDriverDocPath
-
+
On Error Resume Next
'# Open driver doc
sPPDriverDocPath = daFso.GetAbsolutePathName(driver)
If Not daFso.FileExists(sPPDriverDocPath ) Then
- DAErrMsg "Driver doc does not exist: " & sPPDriverDocPath,
CDA_ERR_STD_DELAY
+ DAErrMsg "Driver doc does not exist: " & sPPDriverDocPath,
CDA_ERR_STD_DELAY
FinalExit
End If
'## MS: KB Article 155073 ##
'# PPT7: OLE Automation Error Using Open Method
-'# MUST show the PowerPoint application window at least once before calling
the Application.Presentations.Open method
+'# MUST show the PowerPoint application window at least once before calling
the Application.Presentations.Open method
daPP.Visible = True
daPP.WindowState = 2 'Minimize PowerPoint
daPP.Presentations.Open sPPDriverDocPath
If Err.Number <> 0 Then
- DAErrMsg "Failed to open driver doc: " & vbLf & sPPDriverDocPath & vbLf
& vbLf & "Error: " _
- & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
+ DAErrMsg "Failed to open driver doc: " & vbLf & sPPDriverDocPath & vbLf
& vbLf & "Error: " _
+ & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
FinalExit
End If
@@ -220,7 +220,7 @@ set daPres = daPP.Presentations(1)
End Sub
-'######################
+'######################
Function DArunPPDriver(driver, macro)
On Error Resume Next
@@ -229,67 +229,67 @@ DArunPPDriver = True
daPP.Run (daFso.GetFileName(driver) & "!" & macro)
If Err.Number <> 0 Then
DAErrMsg "Failed to run macro: " & macro & vbLf & vbLf & "Error: " _
- & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
+ & CStr(Err.Number) & " " & Err.Description, CDA_ERR_STD_DELAY
DArunPPDriver = False
End If
End Function
-'######################
+'######################
Sub DAsavePPDriver(saveDriver)
daPres.SaveAs daFso.GetAbsolutePathName(saveDriver)
End Sub
-'######################
+'######################
Sub DACloseApps()
'# Quit apps
On Error Resume Next
- If Not daWrd Is Nothing Then
+ If Not daWrd Is Nothing Then
daDoc.Close wdDoNotSaveChanges
daWrd.Quit
End If
- If Not daXl Is Nothing Then
+ If Not daXl Is Nothing Then
daWb.Close False
daXl.Quit
End If
If Not daPP Is Nothing Then
- daPres.Close
+ daPres.Close
daPP.Quit
- End If
-
+ End If
+
Set daDoc = Nothing
Set daWb = Nothing
Set daPres = Nothing
-
+
Set daWrd = Nothing
Set daXl = Nothing
Set daPP = Nothing
End Sub
-'######################
+'######################
Sub DACleanUp()
'# Quit apps
On Error Resume Next
-
+
DACloseApps
-
+
Set daFso = Nothing
Set daWshShell = Nothing
End Sub
-'######################
+'######################
Sub DAdiagMsg( msg, delay)
'# WSHShell.echo: Popup if run with Wscript.exe, command line output if
run with Cscript.exe
WScript.Echo msg
- 'WSHShell.popup msg, delay, daTitle, 64
+ 'WSHShell.popup msg, delay, daTitle, 64
End Sub
-'######################
+'######################
Sub DAErrMsg( msg, delay)
daWshShell.Popup msg, delay, daTitle, 16
@@ -297,13 +297,13 @@ Sub DAErrMsg( msg, delay)
End Sub
-'######################
+'######################
Sub DAVerifyAnalysisIni()
if daFso.FileExists(daFso.GetAbsolutePathName(".\" & CDA_ANALYSIS_INI))
Then Exit Sub
DAErrMsg CDA_ANALYSIS_INI & " does not exist. " & vbLf & vbLf & _
"You need to create it manually or use the DocAnalysisWizard to
create one for you." & vbLf & _
- "Once this is done you can rerun the Document Analysis command
line.", CDA_ERR_STD_DELAY
+ "Once this is done you can rerun the Document Analysis command
line.", CDA_ERR_STD_DELAY
FinalExit
End Sub
@@ -315,10 +315,10 @@ Sub DAExportFile(fileName, projectFile, app_name)
'# Setup App Specific VB Project
Set myProject = DAgetProject(fileName, projectFile, app_name)
-
- Dim myComponent
+
+ Dim myComponent
Set myComponent = myProject.VBComponents(projectFile)
- If Err.Number <> 0 Then
+ If Err.Number <> 0 Then
DAErrMsg "Missing Project File [" & projectFile & "] - Path:" & vbLf &
vbLf & fileName, CERR_STD_DELAY
Set myComponent = Nothing
Set myProject = Nothing
@@ -326,7 +326,7 @@ Sub DAExportFile(fileName, projectFile, app_name)
End If
myProject.VBComponents(projectFile).Export fileName
- If Err.Number <> 0 Then
+ If Err.Number <> 0 Then
DAErrMsg "Error exporting Project File [" & projectFile & "] - Path:" &
vbLf & vbLf & fileName, CERR_STD_DELAY
Set myComponent = Nothing
Set myProject = Nothing
@@ -358,9 +358,9 @@ Sub DAImportFile(fileName, projectFile, app_name)
End If
'#If module not there need to clear out of index error
- Err.Clear
+ Err.Clear
- If Not daFso.FileExists(fileName) Then
+ If Not daFso.FileExists(fileName) Then
DAErrMsg "Missing File " & fileName, CERR_STD_DELAY
Set myComponent = Nothing
Set myProject = Nothing
@@ -389,15 +389,15 @@ Sub DARemoveModule(fileName, projectFile, app_name)
'# Setup App Specific VB Project
Set myProject = DAgetProject(fileName, projectFile, app_name)
-
+
'# Check if module already exists raise error
Dim myComponent
Set myComponent = myProject.VBComponents(projectFile)
myProject.VBComponents.Remove myComponent
-
- If Err.Number <> 0 Then
+
+ If Err.Number <> 0 Then
DAErrMsg "Error removing Project File [" & projectFile & "] - Path:" &
vbLf & vbLf & fileName, CERR_STD_DELAY
Set myComponent = Nothing
Set myProject = Nothing
@@ -412,17 +412,17 @@ End Sub
Function DAgetProject(fileName, projectFile, app_name)
On Error Resume Next
- If app_name = CDA_APPNAME_WORD Then
- Set DAgetProject = daWrd.ActiveDocument.VBProject
-
+ If app_name = CDA_APPNAME_WORD Then
+ Set DAgetProject = daWrd.ActiveDocument.VBProject
+
ElseIf app_name = CDA_APPNAME_EXCEL Then
- Set DAgetProject = daXl.ActiveWorkbook.VBProject
-
+ Set DAgetProject = daXl.ActiveWorkbook.VBProject
+
ElseIf app_name = CDA_APPNAME_POWERPOINT Then
- Set DAgetProject = daPP.ActivePresentation.VBProject
+ Set DAgetProject = daPP.ActivePresentation.VBProject
End If
- If Err.Number <> 0 Then
+ If Err.Number <> 0 Then
DAErrMsg "Cannot access VBProject for Project File [" & projectFile &
"] - Path:" & vbLf & vbLf & fileName, _
CERR_STD_DELAY
Set DAgetProject = Nothing
@@ -430,4 +430,3 @@ Function DAgetProject(fileName, projectFile, app_name)
End If
End Function
-
diff --git a/main/odk/examples/OLE/vbscript/WriterDemo.vbs
b/main/odk/examples/OLE/vbscript/WriterDemo.vbs
index 71d011e4f1..284e6b1ff6 100644
--- a/main/odk/examples/OLE/vbscript/WriterDemo.vbs
+++ b/main/odk/examples/OLE/vbscript/WriterDemo.vbs
@@ -2,7 +2,7 @@
'*
'* The Contents of this file are made available subject to the terms of
'* the BSD license.
-'*
+'*
'* Copyright 2000, 2010 Oracle and/or its affiliates.
'* All rights reserved.
'*
@@ -29,7 +29,7 @@
'* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
'* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
'* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-'*
+'*
'*************************************************************************
'The service manager is always the starting point
@@ -43,7 +43,7 @@ Set objCoreReflection=
objServiceManager.createInstance("com.sun.star.reflection
Set objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")
'Open a new empty writer document
-Dim args()
+Dim args()
Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter",
"_blank", 0, args)
'Create a text object
@@ -54,7 +54,7 @@ Set objCursor= objText.createTextCursor
'Inserting some Text
objText.insertString objCursor, "The first line in the newly created text
document." & vbLf, false
-
+
'Inserting a second line
objText.insertString objCursor, "Now we're in the second line", false
@@ -78,7 +78,7 @@ objRow.setPropertyValue "BackTransparent", false
objRow.setPropertyValue "BackColor", 6710932
'Fill the first table row
-insertIntoCell "A1","FirstColumn", objTable
+insertIntoCell "A1","FirstColumn", objTable
insertIntoCell "B1","SecondColumn", objTable
insertIntoCell "C1","ThirdColumn", objTable
insertIntoCell "D1","SUM", objTable
@@ -87,17 +87,17 @@ objTable.getCellByName("A2").setValue 22.5
objTable.getCellByName("B2").setValue 5615.3
objTable.getCellByName("C2").setValue -2315.7
objTable.getCellByName("D2").setFormula"sum <A2:C2>"
-
+
objTable.getCellByName("A3").setValue 21.5
objTable.getCellByName("B3").setValue 615.3
objTable.getCellByName("C3").setValue -315.7
objTable.getCellByName("D3").setFormula "sum <A3:C3>"
-
+
objTable.getCellByName("A4").setValue 121.5
objTable.getCellByName("B4").setValue -615.3
objTable.getCellByName("C4").setValue 415.7
objTable.getCellByName("D4").setFormula "sum <A4:C4>"
-
+
'Change the CharColor and add a Shadow
objCursor.setPropertyValue "CharColor", 255
objCursor.setPropertyValue "CharShadowed", true
@@ -110,8 +110,8 @@ objText.insertControlCharacter objCursor, 0 , false
objText.insertString objCursor, " This is a colored Text - blue with shadow" &
vbLf, false
'Create a paragraph break ( ControlCharacter::PARAGRAPH_BREAK).
-objText.insertControlCharacter objCursor, 0, false
-
+objText.insertControlCharacter objCursor, 0, false
+
'Create a TextFrame.
Set objTextFrame= objDocument.createInstance("com.sun.star.text.TextFrame")
@@ -133,12 +133,12 @@ Set objFrameText= objTextFrame.getText
'Create a cursor object
Set objFrameTextCursor= objFrameText.createTextCursor
-
+
'Inserting some Text
objFrameText.insertString objFrameTextCursor, "The first line in the newly
created text frame.", _
- false
+ false
objFrameText.insertString objFrameTextCursor, _
- vbLf & "With this second line the height of the
frame raises.", false
+ vbLf & "With this second line the height of the
frame raises.", false
'Create a paragraph break
'The second argument is a
com::sun::star::text::ControlCharacter::PARAGRAPH_BREAK constant
@@ -149,15 +149,15 @@ objCursor.setPropertyValue "CharColor", 65536
objCursor.setPropertyValue "CharShadowed", false
'Insert another string
-objText.insertString objCursor, " That's all for now !!", false
+objText.insertString objCursor, " That's all for now !!", false
On Error Resume Next
If Err Then
MsgBox "An error occurred"
-End If
+End If
-Sub insertIntoCell( strCellName, strText, objTable)
+Sub insertIntoCell( strCellName, strText, objTable)
Set objCellText= objTable.getCellByName( strCellName)
Set objCellCursor= objCellText.createTextCursor
objCellCursor.setPropertyValue "CharColor",16777215