summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2016-12-24 16:27:22 +0100
committerJean-Pierre Ledure <jp@ledure.be>2017-01-12 11:40:49 +0100
commit92608b890928b6d10931f4aad3385bb87284181d (patch)
tree8fc002080d7cb1beee902d7cead925d1aece28a0 /wizards
parent9017bcc76bd27b97c065dacf511f7fcdfe3060cb (diff)
Access2Base - Addition of Module object
New Module Basic module New AllModules() collection in Application module Extension of regex to backward searches Change-Id: Id58f3b29d08e9f0b73e192cfc0c2a99988e73fcf
Diffstat (limited to 'wizards')
-rwxr-xr-x[-rw-r--r--]wizards/Package_access2base.mk1
-rw-r--r--wizards/source/access2base/Application.xba160
-rw-r--r--wizards/source/access2base/Collect.xba4
-rw-r--r--wizards/source/access2base/Dialog.xba7
-rw-r--r--wizards/source/access2base/L10N.xba6
-rw-r--r--wizards/source/access2base/Module.xba720
-rw-r--r--wizards/source/access2base/Root_.xba9
-rw-r--r--wizards/source/access2base/Test.xba4
-rw-r--r--wizards/source/access2base/Utils.xba44
-rw-r--r--wizards/source/access2base/acConstants.xba19
-rw-r--r--wizards/source/access2base/script.xlb1
11 files changed, 951 insertions, 24 deletions
diff --git a/wizards/Package_access2base.mk b/wizards/Package_access2base.mk
index 3a60e10f3479..bf019c29e77a 100644..100755
--- a/wizards/Package_access2base.mk
+++ b/wizards/Package_access2base.mk
@@ -40,6 +40,7 @@ $(eval $(call gb_Package_add_files,wizards_basicsrvaccess2base,$(LIBO_SHARE_FOLD
Form.xba \
L10N.xba \
Methods.xba \
+ Module.xba \
OptionGroup.xba \
PropertiesGet.xba \
PropertiesSet.xba \
diff --git a/wizards/source/access2base/Application.xba b/wizards/source/access2base/Application.xba
index 19a872007f9f..037d54b5091e 100644
--- a/wizards/source/access2base/Application.xba
+++ b/wizards/source/access2base/Application.xba
@@ -45,6 +45,7 @@ Global Const ERRSQLSTATEMENT = 1523
Global Const ERROBJECTNOTFOUND = 1524
Global Const ERROPENOBJECT = 1525
Global Const ERRCLOSEOBJECT = 1526
+Global Const ERRMETHOD = 1527
Global Const ERRACTION = 1528
Global Const ERRSENDMAIL = 1529
Global Const ERRFORMYETOPEN = 1530
@@ -74,6 +75,8 @@ Global Const ERRSUBFORMNOTFOUND = 1553
Global Const ERRWINDOW = 1554
Global Const ERRCOMPATIBILITY = 1555
Global Const ERRPRECISION = 1556
+Global Const ERRMODULENOTFOUND = 1557
+Global Const ERRPROCEDURENOTFOUND = 1558
REM -----------------------------------------------------------------------------------------------------------------------
Global Const DBCONNECTBASE = 1 &apos; Connection from Base document (OpenConnection)
@@ -94,6 +97,7 @@ Global Const DBMS_SQLITE = 8
REM -----------------------------------------------------------------------------------------------------------------------
Global Const COLLALLDIALOGS = &quot;ALLDIALOGS&quot;
Global Const COLLALLFORMS = &quot;ALLFORMS&quot;
+Global Const COLLALLMODULES = &quot;ALLMODULES&quot;
Global Const COLLCOMMANDBARS = &quot;COMMANDBARS&quot;
Global Const COLLCOMMANDBARCONTROLS = &quot;COMMANDBARCONTROLS&quot;
Global Const COLLCONTROLS = &quot;CONTROLS&quot;
@@ -116,6 +120,7 @@ Global Const OBJDIALOG = &quot;DIALOG&quot;
Global Const OBJEVENT = &quot;EVENT&quot;
Global Const OBJFIELD = &quot;FIELD&quot;
Global Const OBJFORM = &quot;FORM&quot;
+Global Const OBJMODULE = &quot;MODULE&quot;
Global Const OBJOPTIONGROUP = &quot;OPTIONGROUP&quot;
Global Const OBJPROPERTY = &quot;PROPERTY&quot;
Global Const OBJQUERYDEF = &quot;QUERYDEF&quot;
@@ -160,6 +165,10 @@ Global Const CTLPARENTISGRID = &quot;GRID&quot;
Global Const CTLPARENTISGROUP = &quot;OPTIONGROUP&quot;
REM -----------------------------------------------------------------------------------------------------------------------
+Global Const MODDOCUMENT = &quot;DOCUMENT&quot;
+Global Const MODGLOBAL = &quot;GLOBAL&quot;
+
+REM -----------------------------------------------------------------------------------------------------------------------
Type DocContainer
Document As Object &apos; com.sun.star.comp.dba.ODatabaseDocument or SwXTextDocument or ScModelObj
Active As Boolean
@@ -205,9 +214,11 @@ Const cstSepar = &quot;!&quot;
Set oMacLibraries = DialogLibraries
vMacLibraries = oMacLibraries.getElementNames()
&apos;Remove Access2Base from the list
- For i = 0 To UBound(vMacLibraries)
- If Left(vMacLibraries(i), 11) = &quot;Access2Base&quot; Then vMacLibraries(i) = &quot;&quot;
- Next i
+ If _A2B_.ExcludeA2B Then
+ For i = 0 To UBound(vMacLibraries)
+ If Left(vMacLibraries(i), 11) = &quot;Access2Base&quot; Then vMacLibraries(i) = &quot;&quot;
+ Next i
+ End If
vMacLibraries = Utils._TrimArray(vMacLibraries)
If UBound(vDocLibraries) + UBound(vMacLibraries) &lt; 0 Then &apos; No library
@@ -394,6 +405,149 @@ Error_Function:
End Function &apos; AllForms V0.9.0
REM -----------------------------------------------------------------------------------------------------------------------
+Public Function AllModules(ByVal Optional pvIndex As Variant, ByVal Optional pbAllModules As Boolean) As Variant
+&apos; Return either a Collection or a Module object
+&apos; The modules are selected only if library is loaded
+&apos; (UNPUBLISHED) pbAllModules = False collects only the modules located in the currently open document
+
+ If _ErrorHandler() Then On Local Error Goto Error_Function
+Const cstThisSub = &quot;AllModules&quot;
+ Utils._SetCalledSub(cstThisSub)
+
+Dim iMode As Integer, vModules() As Variant, i As Integer, j As Integer, iCount As Integer
+Dim oMacLibraries As Object, vAllModules As Variant, oLibrary As Object, vNames() As Variant, bFound As Boolean
+Dim sScript As String, sLibrary As String, oDocLibraries As Object, sStorage As String
+Dim vLibraries() As Variant, vMacLibraries() As Variant, vDocLibraries() As Variant, oDocMacLib As Object
+Const cstCount = 0, cstByIndex = 1, cstByName = 2
+Const cstDot = &quot;.&quot;
+
+ If IsMissing(pvIndex) Then
+ iMode = cstCount
+ Else
+ If Not Utils._CheckArgument(pvIndex, 1, Utils._AddNumeric(vbString)) Then Goto Exit_Function
+ If VarType(pvIndex) = vbString Then
+ iMode = cstByName
+ &apos; Dtermine full name STORAGE.LIBRARY.MODULE
+ vNames = Split(pvIndex, cstDot)
+ If UBound(vNames) = 2 Then
+ ElseIf UBound(vNames) = 1 Then
+ pvIndex = MODDOCUMENT &amp; cstDot &amp; pvIndex
+ ElseIf UBound(vNames) = 0 Then
+ pvIndex = MODDOCUMENT &amp; cstDot &amp; &quot;STANDARD&quot; &amp; cstDot &amp; pvIndex
+ Else
+ GoTo Trace_Not_Found
+ End If
+ Else
+ iMode = cstByIndex
+ End If
+ End If
+
+ If IsMissing(pbAllModules) Then pbAllModules = True
+ If Not Utils._CheckArgument(pbAllModules, 2, vbBoolean) Then Goto Exit_Function
+
+ Set vAllModules = Nothing
+
+ Set oDocLibraries = ThisComponent.BasicLibraries
+ vDocLibraries = oDocLibraries.getElementNames()
+ If pbAllModules Then
+ Set oMacLibraries = GlobalScope.BasicLibraries
+ vMacLibraries = oMacLibraries.getElementNames()
+ &apos;Remove Access2Base from the list
+ If _A2B_.ExcludeA2B Then
+ For i = 0 To UBound(vMacLibraries)
+ If Left(vMacLibraries(i), 11) = &quot;Access2Base&quot; Then vMacLibraries(i) = &quot;&quot;
+ Next i
+ End If
+ vMacLibraries = Utils._TrimArray(vMacLibraries)
+ End If
+
+ If UBound(vDocLibraries) + UBound(vMacLibraries) &lt; 0 Then &apos; No library
+ Set vAllModules = New Collect
+ vAllModules._CollType = COLLALLMODULES
+ vAllModules._ParentType = OBJAPPLICATION
+ vAllModules._ParentName = &quot;&quot;
+ vAllModules._Count = 0
+ Goto Exit_Function
+ End If
+
+ iCount = 0
+ For i = 0 To UBound(vDocLibraries) + UBound(vMacLibraries) + 1
+ bFound = False
+ If i &lt;= UBound(vDocLibraries) Then
+ sLibrary = vDocLibraries(i)
+ sStorage = MODDOCUMENT
+ Set oDocMacLib = oDocLibraries
+ &apos; Sometimes library not loaded as should ??
+ If Not oDocMacLib.IsLibraryLoaded(sLibrary) Then oDocMacLib.loadLibrary(sLibrary)
+ Else
+ sLibrary = vMacLibraries(i - UBound(vDocLibraries) - 1)
+ sStorage = MODGLOBAL
+ Set oDocMacLib = oMacLibraries
+ End If
+ If oDocMacLib.IsLibraryLoaded(sLibrary) Then
+ Set oLibrary = oDocMacLib.getByName(sLibrary)
+ If oLibrary.hasElements() Then
+ vModules = oLibrary.getElementNames()
+ Select Case iMode
+ Case cstCount
+ iCount = iCount + UBound(vModules) + 1
+ Case cstByIndex, cstByName
+ For j = 0 To UBound(vModules)
+ If iMode = cstByIndex Then
+ If pvIndex = iCount Then bFound = True
+ iCount = iCount + 1
+ Else
+ If UCase(pvIndex) = UCase(sStorage &amp; cstDot &amp; sLibrary &amp; cstDot &amp; vModules(j)) Then bFound = True
+ End If
+ If bFound Then
+ sScript = oLibrary.getByName(vModules(j)) &apos; Initiate Module object
+ iCount = i
+ Exit For
+ End If
+ Next j
+ End Select
+ End If
+ End If
+ If bFound Then Exit For
+ Next i
+
+ If iMode = cstCount Then
+ Set vAllModules = New Collect
+ vAllModules._CollType = COLLALLMODULES
+ vAllModules._ParentType = OBJAPPLICATION
+ vAllModules._ParentName = &quot;&quot;
+ vAllModules._Count = iCount
+ Else
+ If Not bFound Then
+ If iMode = cstByIndex Then Goto Trace_Error_Index Else Goto Trace_Not_Found
+ End If
+ Set vAllModules = New Module
+ vAllModules._Name = vModules(j)
+ vAllModules._LibraryName = sLibrary
+ Set vAllModules._Library = oLibrary
+ vAllModules._Storage = sStorage
+ vAllModules._Script = sScript
+ vAllModules._Initialize()
+ End If
+
+Exit_Function:
+ Set AllModules = vAllModules
+ Utils._ResetCalledSub(cstThisSub)
+ Exit Function
+Trace_Not_Found:
+ TraceError(TRACEFATAL, ERRMODULENOTFOUND, Utils._CalledSub(), 0, , pvIndex)
+ Goto Exit_Function
+Trace_Error_Index:
+ TraceError(TRACEFATAL, ERRCOLLECTION, Utils._CalledSub(), 0, 1)
+ Set vModules = Nothing
+ Goto Exit_Function
+Error_Function:
+ TraceError(TRACEABORT, Err, cstThisSub, Erl)
+ Set vModules = Nothing
+ GoTo Exit_Function
+End Function &apos; AllModules V1.7.0
+
+REM -----------------------------------------------------------------------------------------------------------------------
Public Sub CloseConnection ()
&apos; Close all connections established by current document to free memory.
diff --git a/wizards/source/access2base/Collect.xba b/wizards/source/access2base/Collect.xba
index ad33cc77a810..d0adbe0a52c4 100644
--- a/wizards/source/access2base/Collect.xba
+++ b/wizards/source/access2base/Collect.xba
@@ -10,7 +10,7 @@ Option ClassModule
Option Explicit
-REM MODULE NAME &lt;&gt; COLLECTION (seems a reserved name ?)
+REM MODULE NAME &lt;&gt; COLLECTION (is a reserved name for ... collections)
REM -----------------------------------------------------------------------------------------------------------------------
REM --- CLASS ROOT FIELDS ---
@@ -77,6 +77,8 @@ Dim vNames() As Variant, oProperty As Object
Set Item = Application.AllDialogs(pvItem)
Case COLLALLFORMS
Set Item = Application.AllForms(pvItem)
+ Case COLLALLMODULES
+ Set Item = Application.AllModules(pvItem)
Case COLLCOMMANDBARS
Set Item = Application.CommandBars(pvItem)
Case COLLCOMMANDBARCONTROLS
diff --git a/wizards/source/access2base/Dialog.xba b/wizards/source/access2base/Dialog.xba
index 9d633cda14cb..0fafbd9daaa9 100644
--- a/wizards/source/access2base/Dialog.xba
+++ b/wizards/source/access2base/Dialog.xba
@@ -14,7 +14,7 @@ REM ----------------------------------------------------------------------------
REM --- CLASS ROOT FIELDS ---
REM -----------------------------------------------------------------------------------------------------------------------
-Private _Type As String &apos; Must be FORM
+Private _Type As String &apos; Must be DIALOG
Private _Name As String
Private _Shortcut As String
Private _Dialog As Object &apos; com.sun.star.io.XInputStreamProvider
@@ -199,7 +199,11 @@ Public Function Properties(ByVal Optional pvIndex As Variant) As Variant
&apos; a Collection object if pvIndex absent
&apos; a Property object otherwise
+Const cstThisSub = &quot;Dialog.Properties&quot;
+ Utils._SetCalledSub(cstThisSub)
+
Dim vProperty As Variant, vPropertiesList() As Variant, sObject As String
+
vPropertiesList = _PropertiesList()
sObject = Utils._PCase(_Type)
If IsMissing(pvIndex) Then
@@ -211,6 +215,7 @@ Dim vProperty As Variant, vPropertiesList() As Variant, sObject As String
Exit_Function:
Set Properties = vProperty
+ Utils._ResetCalledSub(cstThisSub)
Exit Function
End Function &apos; Properties
diff --git a/wizards/source/access2base/L10N.xba b/wizards/source/access2base/L10N.xba
index 77827795963f..f6e6d8fb2a82 100644
--- a/wizards/source/access2base/L10N.xba
+++ b/wizards/source/access2base/L10N.xba
@@ -80,6 +80,8 @@ Dim sLocal As String
Case &quot;ERR&quot; &amp; ERRWINDOW : sLocal = &quot;Current window is not a document&quot;
Case &quot;ERR&quot; &amp; ERRCOMPATIBILITY : sLocal = &quot;Field &apos;%0&apos; could not be converted due to incompatibility of field types between the respective database systems&quot;
Case &quot;ERR&quot; &amp; ERRPRECISION : sLocal = &quot;Field &apos;%0&apos; could not be loaded in record #%1 due to capacity shortage&quot;
+ Case &quot;ERR&quot; &amp; ERRMODULENOTFOUND : sLocal = &quot;Module &apos;%0&apos; not found in the currently loaded libraries&quot;
+ Case &quot;ERR&quot; &amp; ERRPROCEDURENOTFOUND : sLocal = &quot;Procedure &apos;%0&apos; not found in module &apos;%1&apos;&quot;
&apos;----------------------------------------------------------------------------------------------------------------------
Case &quot;OBJECT&quot; : sLocal = &quot;Object&quot;
Case &quot;TABLE&quot; : sLocal = &quot;Table&quot;
@@ -191,6 +193,8 @@ Dim sLocal As String
Case &quot;ERR&quot; &amp; ERRWINDOW : sLocal = &quot;La fenêtre courante n&apos;est pas un document&quot;
Case &quot;ERR&quot; &amp; ERRCOMPATIBILITY : sLocal = &quot;Le champ &apos;%0&apos; n&apos;a pas pu être converti à cause d&apos;une incompatibilité entre les types de champs supportés par les systèmes de bases de données respectifs&quot;
Case &quot;ERR&quot; &amp; ERRPRECISION : sLocal = &quot;Le champ &apos;%0&apos; n&apos;a pas pu être chargé dans l&apos;enregistrement #%1 par manque de capacité&quot;
+ Case &quot;ERR&quot; &amp; ERRMODULENOTFOUND : sLocal = &quot;Le module &apos;%0&apos; est introuvable dans les librairies chargées actuellement&quot;
+ Case &quot;ERR&quot; &amp; ERRPROCEDURENOTFOUND : sLocal = &quot;La procédure &apos;%0&apos; est introuvable dans le module &apos;%1&apos;&quot;
&apos;----------------------------------------------------------------------------------------------------------------------
Case &quot;OBJECT&quot; : sLocal = &quot;Objet&quot;
Case &quot;TABLE&quot; : sLocal = &quot;Table&quot;
@@ -305,6 +309,8 @@ Dim sLocal As String
Case &quot;ERR&quot; &amp; ERRWINDOW : sLocal = &quot;La ventana actual no es un documento&quot;
Case &quot;ERR&quot; &amp; ERRCOMPATIBILITY : sLocal = &quot;El campo &apos;%0&apos; no se ha convertido debido a una incompatibilidad de los tipos de campo soportados entre las dos bases de datos&quot;
Case &quot;ERR&quot; &amp; ERRPRECISION : sLocal = &quot;El campo &apos;%0&apos; no se ha cargado en el registro #%1 por falta de capacidad&quot;
+ Case &quot;ERR&quot; &amp; ERRMODULENOTFOUND : sLocal = &quot;Module &apos;%0&apos; not found in the currently loaded libraries&quot;
+ Case &quot;ERR&quot; &amp; ERRPROCEDURENOTFOUND : sLocal = &quot;Procedure &apos;%0&apos; not found in module &apos;%1&apos;&quot;
&apos;----------------------------------------------------------------------------------------------------------------------
Case &quot;OBJECT&quot; : sLocal = &quot;Objeto&quot;
Case &quot;TABLE&quot; : sLocal = &quot;Tabla&quot;
diff --git a/wizards/source/access2base/Module.xba b/wizards/source/access2base/Module.xba
new file mode 100644
index 000000000000..64eea2f102c9
--- /dev/null
+++ b/wizards/source/access2base/Module.xba
@@ -0,0 +1,720 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module" script:language="StarBasic">REM =======================================================================================================================
+REM === The Access2Base library is a part of the LibreOffice project. ===
+REM === Full documentation is available on http://www.access2base.com ===
+REM =======================================================================================================================
+
+Option Compatible
+Option ClassModule
+
+Option Explicit
+
+REM -----------------------------------------------------------------------------------------------------------------------
+REM --- CLASS ROOT FIELDS ---
+REM -----------------------------------------------------------------------------------------------------------------------
+
+Private _Type As String &apos; Must be MODULE
+Private _Name As String
+Private _Library As Object &apos; com.sun.star.container.XNameAccess
+Private _LibraryName As String
+Private _Storage As String &apos; GLOBAL or DOCUMENT
+Private _Script As String &apos; Full script (string with vbLf&apos;s)
+Private _Lines As Variant &apos; Array of script lines
+Private _CountOfLines As Long
+Private _ProcsParsed As Boolean &apos; To test before use of proc arrays
+Private _ProcNames() As Variant &apos; All procedure names
+Private _ProcDecPositions() As Variant &apos; All procedure declarations
+Private _ProcEndPositions() As Variant &apos; All end procedure statements
+Private _ProcTypes() As Variant &apos; One of the vbext_pk_* constants
+
+REM -----------------------------------------------------------------------------------------------------------------------
+REM --- CONSTRUCTORS / DESTRUCTORS ---
+REM -----------------------------------------------------------------------------------------------------------------------
+Private Sub Class_Initialize()
+ _Type = OBJMODULE
+ _Name = &quot;&quot;
+ Set _Library = Nothing
+ _LibraryName = &quot;&quot;
+ _Storage = &quot;&quot;
+ _Script = &quot;&quot;
+ _Lines = Array()
+ _CountOfLines = 0
+ _ProcsParsed = False
+ _ProcNames = Array()
+ _ProcDecPositions = Array()
+ _ProcEndPositions = Array()
+End Sub &apos; Constructor
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Private Sub Class_Terminate()
+ On Local Error Resume Next
+ Call Class_Initialize()
+End Sub &apos; Destructor
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Public Sub Dispose()
+ Call Class_Terminate()
+End Sub &apos; Explicit destructor
+
+REM -----------------------------------------------------------------------------------------------------------------------
+REM --- CLASS GET/LET/SET PROPERTIES ---
+REM -----------------------------------------------------------------------------------------------------------------------
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Property Get CountOfDeclarationLines() As Long
+ CountOfDeclarationLines = _PropertyGet(&quot;CountOfDeclarationLines&quot;)
+End Property &apos; CountOfDeclarationLines (get)
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Property Get CountOfLines() As Long
+ CountOfLines = _PropertyGet(&quot;CountOfLines&quot;)
+End Property &apos; CountOfLines (get)
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Property Get Name() As String
+ Name = _PropertyGet(&quot;Name&quot;)
+End Property &apos; Name (get)
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Property Get ObjectType() As String
+ ObjectType = _PropertyGet(&quot;ObjectType&quot;)
+End Property &apos; ObjectType (get)
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Public Function Lines(Optional ByVal pvLine As Variant, Optional ByVal pvNumLines As Variant) As String
+&apos; Returns a string containing the contents of a specified line or lines in a standard module or a class module
+
+Const cstThisSub = &quot;Module.Lines&quot;
+ Utils._SetCalledSub(cstThisSub)
+
+Dim sLines As String, lLine As Long
+ sLines = &quot;&quot;
+
+ If IsMissing(pvLine) Or IsMissing(pvNumLines) Then Call _TraceArguments()
+ If Not Utils._CheckArgument(pvLine, 1, _AddNumeric()) Then GoTo Exit_Function
+ If Not Utils._CheckArgument(pvNumLines, 1, _AddNumeric()) Then GoTo Exit_Function
+
+ lLine = pvLine
+ Do While lLine &lt; _CountOfLines And lLine &lt; pvLine + pvNumLines
+ sLines = sLines &amp; _Lines(lLine - 1) &amp; vbLf
+ lLine = lLine + 1
+ Loop
+ If Len(sLines) &gt; 0 Then sLines = Left(sLines, Len(sLines) - 1)
+
+Exit_Function:
+ Lines = sLines
+ Utils._ResetCalledSub(cstThisSub)
+ Exit Function
+End Function &apos; Lines
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Public Function ProcBodyLine(Optional ByVal pvProc As Variant, Optional ByVal pvProcType As Variant) As Long
+&apos; Return the number of the line at which the body of a specified procedure begins
+
+Const cstThisSub = &quot;Module.ProcBodyLine&quot;
+ Utils._SetCalledSub(cstThisSub)
+
+Dim iIndex As Integer
+
+ If IsMissing(pvProc) Or IsMissing(pvProcType) Then Call _TraceArguments()
+ If Not Utils._CheckArgument(pvProc, 1, vbString) Then GoTo Exit_Function
+ If Not Utils._CheckArgument(pvProcType, 2, _AddNumeric()) Then GoTo Exit_Function
+
+ iIndex = _FindProcIndex(pvProc, pvProcType)
+ If iIndex &gt;= 0 Then ProcBodyLine = _LineOfPosition(_ProcDecPositions(iIndex)) Else ProcBodyLine = iIndex
+
+Exit_Function:
+ Utils._ResetCalledSub(cstThisSub)
+ Exit Function
+End Function &apos; ProcBodyline
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Public Function ProcCountLines(Optional ByVal pvProc As Variant, Optional ByVal pvProcType As Variant) As Long
+&apos; Return the number of lines in the specified procedure
+
+Const cstThisSub = &quot;Module.ProcCountLines&quot;
+ Utils._SetCalledSub(cstThisSub)
+
+Dim iIndex As Integer, lStart As Long, lEnd As Long
+
+ If IsMissing(pvProc) Or IsMissing(pvProcType) Then Call _TraceArguments()
+ If Not Utils._CheckArgument(pvProc, 1, vbString) Then GoTo Exit_Function
+ If Not Utils._CheckArgument(pvProcType, 2, _AddNumeric()) Then GoTo Exit_Function
+
+ iIndex = _FindProcIndex(pvProc, pvProcType)
+ lStart = ProcStartLine(pvProc, pvProcType)
+ lEnd = _LineOfPosition(_ProcEndPositions(iIndex))
+ ProcCountLines = lEnd - lStart + 1
+
+Exit_Function:
+ Utils._ResetCalledSub(cstThisSub)
+ Exit Function
+End Function &apos; ProcCountLines
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Public Function ProcOfLine(Optional ByVal pvLine As Variant, Optional ByRef pvProcType As Variant) As String
+&apos; Return the name and type of the procedure containing line pvLine
+
+Const cstThisSub = &quot;Module.ProcOfLine&quot;
+ Utils._SetCalledSub(cstThisSub)
+
+Dim sProcedure As String, iProc As Integer, lLineDec As Long, lLineEnd As Long
+
+ If IsMissing(pvLine) Or IsMissing(pvProcType) Then Call _TraceArguments()
+ If Not Utils._CheckArgument(pvLine, 1, _AddNumeric()) Then GoTo Exit_Function
+ If Not Utils._CheckArgument(pvProcType, 2, _AddNumeric()) Then GoTo Exit_Function
+
+ If Not _ProcsParsed Then _ParseProcs()
+
+ sProcedure = &quot;&quot;
+ For iProc = 0 To UBound(_ProcNames)
+ lLineEnd = _LineOfPosition(_ProcEndPositions(iProc))
+ If pvLine &lt;= lLineEnd Then
+ lLineDec = _LineOfPosition(_ProcDecPositions(iProc))
+ If pvLine &lt; lLineDec Then &apos; Line between 2 procedures
+ sProcedure = &quot;&quot;
+ Else
+ sProcedure = _ProcNames(iProc)
+ pvProcType = _ProcTypes(iProc)
+ End If
+ Exit For
+ End If
+ Next iProc
+
+Exit_Function:
+ ProcOfLine = sProcedure
+ Utils._ResetCalledSub(cstThisSub)
+ Exit Function
+End Function &apos; ProcOfline
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Public Function ProcStartLine(Optional ByVal pvProc As Variant, Optional ByVal pvProcType As Variant) As Long
+&apos; Return the number of the line at which the specified procedure begins
+
+Const cstThisSub = &quot;Module.ProcStartLine&quot;
+ Utils._SetCalledSub(cstThisSub)
+
+Dim lLine As Long, lIndex As Long, sLine As String
+
+ If IsMissing(pvProc) Or IsMissing(pvProcType) Then Call _TraceArguments()
+ If Not Utils._CheckArgument(pvProc, 1, vbString) Then GoTo Exit_Function
+ If Not Utils._CheckArgument(pvProcType, 2, _AddNumeric()) Then GoTo Exit_Function
+
+ lLine = ProcBodyLine(pvProc, pvProcType)
+ &apos; Search baclIndexward for comment lines
+ lIndex = lLine - 1
+ Do While lIndex &gt; 0
+ sLine = _Trim(_Lines(lIndex - 1))
+ If UCase(Left(sLine, 4)) = &quot;REM &quot; Or Left(sLine, 1) = &quot;&apos;&quot; Then
+ lLine = lIndex
+ Else
+ Exit Do
+ End If
+ lIndex = lIndex - 1
+ Loop
+
+ ProcStartLine = lLine
+
+Exit_Function:
+ Utils._ResetCalledSub(cstThisSub)
+ Exit Function
+End Function &apos; ProcStartLine
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Public Function Properties(ByVal Optional pvIndex As Variant) As Variant
+&apos; Return
+&apos; a Collection object if pvIndex absent
+&apos; a Property object otherwiseREM -----------------------------------------------------------------------------------------------------------------------
+
+
+Const cstThisSub = &quot;Module.Properties&quot;
+ Utils._SetCalledSub(cstThisSub)
+
+Dim vProperty As Variant, vPropertiesList() As Variant, sObject As String
+
+ vPropertiesList = _PropertiesList()
+ sObject = Utils._PCase(_Type)
+ If IsMissing(pvIndex) Then
+ vProperty = PropertiesGet._Properties(sObject, _Name, vPropertiesList)
+ Else
+ vProperty = PropertiesGet._Properties(sObject, _Name, vPropertiesList, pvIndex)
+ vProperty._Value = _PropertyGet(vPropertiesList(pvIndex))
+ End If
+
+Exit_Function:
+ Set Properties = vProperty
+ Utils._ResetCalledSub(cstThisSub)
+ Exit Function
+End Function &apos; Properties
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Property Get pType() As String
+ pType = _PropertyGet(&quot;Type&quot;)
+End Property &apos; Type (get)
+
+REM -----------------------------------------------------------------------------------------------------------------------
+REM --- CLASS METHODS ---
+REM -----------------------------------------------------------------------------------------------------------------------
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Public Function Find(Optional ByVal pvTarget As Variant _
+ , Optional ByRef pvStartLine As Variant _
+ , Optional ByRef pvStartColumn As Variant _
+ , Optional ByRef pvEndLine As Variant _
+ , Optional ByRef pvEndColumn As Variant _
+ , Optional ByVal pvWholeWord As Boolean _
+ , Optional ByVal pvMatchCase As Boolean _
+ , Optional ByVal pvPatternSearch As Boolean _
+ ) As Boolean
+&apos; Finds specified text in the module
+&apos; xxLine and xxColumn arguments are mainly to return the position of the found string
+&apos; If they are initialized but nonsense, the function returns False
+
+Const cstThisSub = &quot;Module.Find&quot;
+ Utils._SetCalledSub(cstThisSub)
+ If _ErrorHandler() Then On Local Error Goto Error_Function
+
+Dim bFound As Boolean, lPosition As Long, lStartLine As Long, lStartColumn As Long, lStartPosition As Long
+Dim lEndLine As Long, lEndColumn As Long, lEndPosition As Long
+Dim sMatch As String, vOptions As Variant, sPattern As String
+Dim i As Integer, sSpecChar As String
+
+Const cstSpecialCharacters = &quot;\[^$.|?*+()&quot;
+
+ bFound = False
+
+ If IsMissing(pvTarget) Or IsMissing(pvStartLine) Or IsMissing(pvStartColumn) Or IsMissing(pvEndLine) Or IsMissing(pvEndColumn) Then Call _TraceArguments()
+ If Not Utils._CheckArgument(pvTarget, 1, vbString) Then GoTo Exit_Function
+ If Len(pvTarget) = 0 Then GoTo Exit_Function
+ If Not IsEmpty(pvStartLine) Then
+ If Not Utils._CheckArgument(pvStartLine, 2, _AddNumeric()) Then GoTo Exit_Function
+ End If
+ If Not IsEmpty(pvStartColumn) Then
+ If Not Utils._CheckArgument(pvStartColumn, 3, _AddNumeric()) Then GoTo Exit_Function
+ End If
+ If Not IsEmpty(pvEndLine) Then
+ If Not Utils._CheckArgument(pvEndLine, 4, _AddNumeric()) Then GoTo Exit_Function
+ End If
+ If Not IsEmpty(pvEndColumn) Then
+ If Not Utils._CheckArgument(pvEndColumn, 5, _AddNumeric()) Then GoTo Exit_Function
+ End If
+ If IsMissing(pvWholeWord) Then pvWholeWord = False
+ If Not Utils._CheckArgument(pvWholeWord, 6, vbBoolean) Then GoTo Exit_Function
+ If IsMissing(pvMatchCase) Then pvMatchCase = False
+ If Not Utils._CheckArgument(pvMatchCase, 7, vbBoolean) Then GoTo Exit_Function
+ If IsMissing(pvPatternSearch) Then pvPatternSearch = False
+ If Not Utils._CheckArgument(pvPatternSearch, 8, vbBoolean) Then GoTo Exit_Function
+
+ &apos; Initialize starting values
+ If IsEmpty(pvStartLine) Then lStartLine = 1 Else lStartLine = pvStartLine
+ If lStartLine &lt;= 0 Or lStartLine &gt; UBound(_Lines) + 1 Then GoTo Exit_Function
+ If IsEmpty(pvStartColumn) Then lStartColumn = 1 Else lStartColumn = pvStartColumn
+ If lStartColumn &lt;= 0 Then GoTo Exit_Function
+ If lStartColumn &gt; 1 And lStartColumn &gt; Len(_Lines(lStartLine + 1)) Then GoTo Exit_Function
+ lStartPosition = _PositionOfLine(lStartline) + lStartColumn - 1
+ If IsEmpty(pvEndLine) Then lEndLine = UBound(_Lines) + 1 Else lEndLine = pvEndLine
+ If lEndLine &lt; lStartLine Or lEndLine &gt; UBound(_Lines) + 1 Then GoTo Exit_Function
+ If IsEmpty(pvEndColumn) Then lEndColumn = Len(_Lines(lEndLine - 1)) Else lEndColumn = pvEndColumn
+ If lEndColumn &lt; 0 Then GoTo Exit_Function
+ If lEndColumn = 0 Then lEndColumn = 1
+ If lEndColumn &gt; Len(_Lines(lEndLine - 1)) + 1 Then GoTo Exit_Function
+ lEndPosition = _PositionOfLine(lEndline) + lEndColumn - 1
+
+ If pvMatchCase Then
+ Set vOptions = _A2B_.SearchOptions
+ vOptions.transliterateFlags = 0
+ End If
+
+ &apos; Define pattern to search for
+ sPattern = pvTarget
+ &apos; Protect special characters in regular expressions
+ For i = 1 To Len(cstSpecialCharacters)
+ sSpecChar = Mid(cstSpecialCharacters, i, 1)
+ sPattern = Replace(sPattern, sSpecChar, &quot;\&quot; &amp; sSpecChar)
+ Next i
+ If pvPatternSearch Then sPattern = Replace(Replace(sPattern, &quot;\*&quot;, &quot;.*&quot;), &quot;\?&quot;, &quot;.&quot;)
+ If pvWholeWord Then sPattern = &quot;\b&quot; &amp; sPattern &amp; &quot;\b&quot;
+
+ lPosition = lStartPosition
+ sMatch = Utils._RegexSearch(_Script, sPattern, lPosition)
+ &apos; Re-establish default options for later searches
+ If pvMatchCase Then vOptions.transliterateFlags = com.sun.star.i18n.TransliterationModules.IGNORE_CASE
+
+ &apos; Found within requested bounds ?
+ If sMatch &lt;&gt; &quot;&quot; And lPosition &gt;= lStartPosition And lPosition &lt;= lEndPosition Then
+ pvStartLine = _LineOfPosition(lPosition)
+ pvStartColumn = lPosition - _PositionOfLine(pvStartLine) + 1
+ pvEndLine = _LineOfPosition(lPosition + Len(sMatch) - 1)
+ If pvEndLine &gt; pvStartLine Then
+ pvEndColumn = lPosition + Len(sMatch) - 1 - _PositionOfLine(pvEndLine)
+ Else
+ pvEndColumn = pvStartColumn + Len(sMatch) - 1
+ End If
+ bFound = True
+ End If
+
+Exit_Function:
+ Find = bFound
+ Utils._ResetCalledSub(cstThisSub)
+ Exit Function
+Error_Function:
+ TraceError(TRACEABORT, Err, &quot;Module.Find&quot;, Erl)
+ bFound = False
+ GoTo Exit_Function
+End Function &apos; Find
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Public Function getProperty(Optional ByVal pvProperty As Variant) As Variant
+&apos; Return property value of psProperty property nameREM -----------------------------------------------------------------------------------------------------------------------
+
+
+Const cstThisSub = &quot;Module.Properties&quot;
+
+ Utils._SetCalledSub(cstThisSub)
+ If IsMissing(pvProperty) Then Call _TraceArguments()
+ getProperty = _PropertyGet(pvProperty)
+ Utils._ResetCalledSub(cstThisSub)
+
+End Function &apos; getProperty
+
+REM --------------------------------Mid(a._Script, iCtl, 25)---------------------------------------------------------------------------------------
+Public Function hasProperty(ByVal Optional pvProperty As Variant) As Boolean
+&apos; Return True if object has a valid property called pvProperty (case-insensitive comparison !)
+
+Const cstThisSub = &quot;Module.hasProperty&quot;
+
+ Utils._SetCalledSub(cstThisSub)
+ If IsMissing(pvProperty) Then hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList()) Else hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList(), pvProperty)
+ Utils._ResetCalledSub(cstThisSub)
+ Exit Function
+
+End Function &apos; hasProperty
+
+REM -----------------------------------------------------------------------------------------------------------------------
+REM --- PRIVATE FUNCTIONS ---
+REM -----------------------------------------------------------------------------------------------------------------------
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Private Function _BeginStatement(ByVal plStart As Long) As Long
+&apos; Return the position in _Script of the beginning of the current statement as defined by plStart
+
+Dim sProc As String, iProc As Integer, iType As Integer
+Dim lPosition As Long, lPrevious As Long, sFind As String
+
+ sProc = ProcOfLine(_LineOfPosition(plStart), iType)
+ iProc = _FindProcIndex(sProc, iType)
+ If iProc &lt; 0 Then lPosition = 1 Else lPosition = _ProcDecPositions(iProc)
+
+ sFind = &quot;Any&quot;
+ Do While lPosition &lt; plStart And sFind &lt;&gt; &quot;&quot;
+ lPrevious = lPosition
+ sFind = _FindPattern(&quot;%^\w&quot;, lPosition)
+ If sFind = &quot;&quot; Then Exit Do
+ Loop
+
+ _BeginStatement = lPrevious
+
+End Function &apos; _EndStatement
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Private Function _EndStatement(ByVal plStart As Long) As Long
+&apos; Return the position in _Script of the end of the current statement as defined by plStart
+&apos; plStart is assumed not to be in the middle of a comment or a string
+
+Dim sMatch As String, lPosition As Long
+ lPosition = plStart
+ sMatch = _FindPattern(&quot;%$&quot;, lPosition)
+ _EndStatement = lPosition
+
+End Function &apos; _EndStatement
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Private Function _FindPattern(ByVal psPattern As Variant, Optional ByRef plStart As Long) As String
+&apos; Find first occurrence of any of the patterns in |-delimited string psPattern
+&apos; Special escapes
+&apos; - for word breaks: &quot;%B&quot; (f.i. for searching &quot;END%BFUNCTION&quot;)
+&apos; - for statement start: &quot;%^&quot; (f.i. for searching &quot;%^END%BFUNCTION&quot;). Necessarily first 2 characters of pattern
+&apos; - for statement end: &quot;%$&quot;. Pattern should not contain anything else
+&apos; If quoted string searched, pattern should start and end with a double quote
+&apos; Return &quot;&quot; if none found, otherwise returns the matching string
+&apos; plStart = start position of _Script to search (starts at 1)
+&apos; In output plStart contains the first position of the matching string or is left unchanged
+&apos; To search again the same or another pattern =&gt; plStart = plStart + Len(matching string)
+&apos; Comments and strings are skipped
+
+&apos; Common patterns
+Const cstComment = &quot;(&apos;|\bREM\b)[^\n]*$&quot;
+Const cstString = &quot;&quot;&quot;[^&quot;&quot;]*&quot;&quot;&quot;
+Const cstBeginStatement = &quot;(^|:|\bthen\b|\belse\b|\n)[ \t]*&quot;
+Const cstEndStatement = &quot;[ \t]*($|:|\bthen\b|\belse\b|\n)&quot;
+Const cstContinuation = &quot;[ \t]_\n&quot;
+Const cstWordBreak = &quot;\b[ \t]+(_\n[ \t]*)?\b&quot;
+Const cstAlt = &quot;|&quot;
+
+Dim sRegex As String, lStart As Long, bContinue As Boolean, sMatch As String
+Dim bEndStatement As Boolean, bQuote As Boolean
+
+ If psPattern = &quot;%$&quot; Then
+ sRegex = cstEndStatement
+ Else
+ sRegex = psPattern
+ If Left(psPattern, 2) = &quot;%^&quot; Then sRegex = cstBeginStatement &amp; Right(sRegex, Len(sregex) - 2)
+ sregex = Replace(sregex, &quot;%B&quot;, cstWordBreak)
+ End If
+ &apos; Add all to ignore patterns to regex. If pattern = quoted string do not add cstString
+ If Len(psPattern) &gt; 2 And Left(psPattern, 1) = &quot;&quot;&quot;&quot; And Right(psPattern, 1) = &quot;&quot;&quot;&quot; Then
+ bQuote = True
+ sRegex = sRegex &amp; cstAlt &amp; cstComment &amp; cstAlt &amp; cstContinuation
+ Else
+ bQuote = False
+ sRegex = sRegex &amp; cstAlt &amp; cstComment &amp; cstAlt &amp; cstString &amp; cstAlt &amp; cstContinuation
+ End If
+
+ If IsMissing(plStart) Then plStart = 1
+ lStart = plStart
+
+ bContinue = True
+ Do While bContinue
+ bEndStatement = False
+ sMatch = Utils._RegexSearch(_Script, sRegex, lStart)
+ Select Case True
+ Case sMatch = &quot;&quot;
+ bContinue = False
+ Case Left(sMatch, 1) = &quot;&apos;&quot;
+ bEndStatement = True
+ Case Left(sMatch, 1) = &quot;&quot;&quot;&quot;
+ If bQuote Then
+ plStart = lStart
+ bContinue = False
+ End If
+ Case Left(smatch, 1) = &quot;:&quot; Or Left(sMatch, 1) = vbLf
+ If psPattern = &quot;%$&quot; Then
+ bEndStatement = True
+ Else
+ bContinue = False
+ plStart = lStart + 1
+ sMatch = Right(sMatch, Len(sMatch) - 1)
+ End If
+ Case UCase(Left(sMatch, 3)) = &quot;REM&quot;
+ bEndStatement = True
+ Case UCase(Left(sMatch, 4)) = &quot;THEN&quot; Or UCase(Left(sMatch, 4)) = &quot;ELSE&quot;
+ If psPattern = &quot;%$&quot; Then
+ bEndStatement = True
+ Else
+ bContinue = False
+ plStart = lStart + 4
+ sMatch = Right(sMatch, Len(sMatch) - 4)
+ End If
+ Case sMatch = &quot; _&quot; &amp; vbLf
+ Case Else &apos; Found
+ plStart = lStart
+ bContinue = False
+ End Select
+ If bEndStatement And psPattern = &quot;%$&quot; Then
+ bContinue = False
+ plStart = lStart - 1
+ sMatch = &quot;&quot;
+ End If
+ lStart = lStart + Len(sMatch)
+ Loop
+
+ _FindPattern = sMatch
+
+End Function &apos; _FindPattern
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Private Function _FindProcIndex(ByVal psProc As String, ByVal piType As Integer) As Integer
+&apos; Return index of entry in _Procnames corresponding with pvProc
+
+Dim i As Integer, iIndex As Integer
+
+ If Not _ProcsParsed Then _ParseProcs
+
+ iIndex = -1
+ For i = 0 To UBound(_ProcNames)
+ If UCase(psProc) = UCase(_ProcNames(i)) And piType = _ProcTypes(i) Then
+ iIndex = i
+ Exit For
+ End If
+ Next i
+ If iIndex &lt; 0 Then TraceError(TRACEFATAL, ERRPROCEDURENOTFOUND, Utils._CalledSub(), 0, , Array(psProc, _Name))
+
+Exit_Function:
+ _FindProcIndex = iIndex
+ Exit Function
+End Function &apos; _FindProcIndex
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Public Sub _Initialize()
+
+ _Script = Replace(_Script, vbCr, &quot;&quot;)
+ _Lines = Split(_Script, vbLf)
+ _CountOfLines = UBound(_Lines) + 1
+
+End Sub &apos; _Initialize
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Private Function _LineOfPosition(ByVal plPosition) As Long
+&apos; Return the line number of a position in _Script
+
+Dim lLine As Long, lLength As Long
+ &apos; Start counting from start or end depending on how close position is
+ If plPosition &lt;= Len(_Script) / 2 Then
+ lLength = 0
+ For lLine = 0 To UBound(_Lines)
+ lLength = lLength + Len(_Lines(lLine)) + 1 &apos; + 1 for line feed
+ If lLength &gt;= plPosition Then
+ _LineOfPosition = lLine + 1
+ Exit Function
+ End If
+ Next lLine
+ Else
+ If Right(_Script, 1) = vbLf Then lLength = Len(_Script) + 1 Else lLength = Len(_Script)
+ For lLine = UBound(_Lines) To 0 Step -1
+ lLength = lLength - Len(_Lines(lLine)) - 1 &apos; - 1 for line feed
+ If lLength &lt;= plPosition Then
+ _LineOfPosition = lLine + 1
+ Exit Function
+ End If
+ Next lLine
+ End If
+
+End Function &apos; _LineOfPosition
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Private Sub _ParseProcs()
+&apos; Fills the Proc arrays: name, start and end position
+&apos; Executed at first request needing this processing
+
+Dim lPosition As Long, iProc As Integer, sDecProc As String, sEndProc As String, sNameProc As String, sType As String
+Const cstDeclaration = &quot;%^(private%B|public%B)?\b(property%Bget|property%Blet|property%Bset|function|sub)\b&quot;
+Const cstEnd = &quot;%^end%B(property|function|sub)\b&quot;
+Const cstName = &quot;\w*&quot; &apos;&quot;[A-Za-z_][A-Za-z_0-9]*&quot;
+
+ If _ProcsParsed Then Exit Sub &apos; Do not redo if already done
+ _ProcNames = Array()
+ _ProcDecPositions = Array()
+ _ProcEndPositions = Array()
+ _ProcTypes = Array()
+
+ lPosition = 1
+ iProc = -1
+ sDecProc = &quot;???&quot;
+ Do While sDecProc &lt;&gt; &quot;&quot;
+ &apos; Identify Function/Sub declaration string
+ sDecProc = _FindPattern(cstDeclaration, lPosition)
+ If sDecProc &lt;&gt; &quot;&quot; Then
+ iProc = iProc + 1
+ ReDim Preserve _ProcNames(0 To iProc)
+ ReDim Preserve _ProcDecPositions(0 To iProc)
+ ReDim Preserve _ProcEndPositions(0 To iProc)
+ ReDim Preserve _ProcTypes(0 To iProc)
+ _ProcDecpositions(iProc) = lPosition
+ lPosition = lPosition + Len(sDecProc)
+ &apos; Identify procedure type
+ Select Case True
+ Case InStr(UCase(sDecProc), &quot;FUNCTION&quot;) &gt; 0 : _ProcTypes(iProc) = vbext_pk_Proc
+ Case InStr(UCase(sDecProc), &quot;SUB&quot;) &gt; 0 : _ProcTypes(iProc) = vbext_pk_Proc
+ Case InStr(UCase(sDecProc), &quot;GET&quot;) &gt; 0 : _ProcTypes(iProc) = vbext_pk_Get
+ Case InStr(UCase(sDecProc), &quot;LET&quot;) &gt; 0 : _ProcTypes(iProc) = vbext_pk_Let
+ Case InStr(UCase(sDecProc), &quot;SET&quot;) &gt; 0 : _ProcTypes(iProc) = vbext_pk_Set
+ End Select
+ &apos; Identify name of Function/Sub
+ sNameProc = _FindPattern(cstName, lPosition)
+ If sNameProc = &quot;&quot; Then Exit Do &apos; Should never happen
+ _ProcNames(iProc) = sNameProc
+ lPosition = lPosition + Len(sNameProc)
+ &apos; Identify End statement
+ sEndProc = _FindPattern(cstEnd, lPosition)
+ If sEndProc = &quot;&quot; Then Exit Do &apos; Should never happen
+ _ProcEndPositions(iProc) = lPosition
+ lPosition = lPosition + Len(sEndProc)
+ End If
+ Loop
+
+ _ProcsParsed = True
+
+End Sub
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Private Function _PositionOfLine(ByVal plLine) As Long
+&apos; Return the position of the first character of the given line in _Script
+
+Dim lLine As Long, lPosition As Long
+ &apos; Start counting from start or end depending on how close line is
+ If plLine &lt;= (UBound(_Lines) + 1) / 2 Then
+ lPosition = 0
+ For lLine = 0 To plLine - 1
+ lPosition = lPosition + 1 &apos; + 1 for line feed
+ If lLine &lt; plLine - 1 Then lPosition = lPosition + Len(_Lines(lLine))
+ Next lLine
+ Else
+ lPosition = Len(_Script) + 2 &apos; Anticipate an ending null-string and a line feed
+ For lLine = UBound(_Lines) To plLine - 1 Step -1
+ lPosition = lPosition - Len(_Lines(lLine)) - 1 &apos; - 1 for line feed
+ Next lLine
+ End If
+
+ _PositionOfLine = lPosition
+
+End Function &apos; _LineOfPosition
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Private Function _PropertiesList() As Variant
+
+ _PropertiesList = Array(&quot;CountOfDeclarationLines&quot;, &quot;CountOfLines&quot;, &quot;Name&quot;, &quot;ObjectType&quot;, &quot;Type&quot;)
+
+End Function &apos; _PropertiesList
+
+REM -----------------------------------------------------------------------------------------------------------------------
+Private Function _PropertyGet(ByVal psProperty As String) As Variant
+&apos; Return property value of the psProperty property name
+
+Dim cstThisSub As String
+Const cstDot = &quot;.&quot;
+
+Dim sText As String
+
+ If _ErrorHandler() Then On Local Error Goto Error_Function
+ cstThisSub = &quot;Module.get&quot; &amp; psProperty
+ Utils._SetCalledSub(cstThisSub)
+ _PropertyGet = Null
+
+ Select Case UCase(psProperty)
+ Case UCase(&quot;CountOfDeclarationLines&quot;)
+ If Not _ProcsParsed Then _ParseProcs()
+ If UBound(_ProcNames) &gt;= 0 Then
+ _PropertyGet = ProcStartLine(_ProcNames(0), _ProcTypes(0)) - 1
+ Else
+ _PropertyGet = _CountOfLines
+ End If
+ Case UCase(&quot;CountOfLines&quot;)
+ _PropertyGet = _CountOfLines
+ Case UCase(&quot;Name&quot;)
+ _PropertyGet = _Storage &amp; cstDot &amp; _LibraryName &amp; cstDot &amp; _Name
+ Case UCase(&quot;ObjectType&quot;)
+ _PropertyGet = _Type
+ Case UCase(&quot;Type&quot;)
+ &apos; Find option statement before any procedure declaration
+ sText = _FindPattern(&quot;%^option%Bclassmodule\b|\bfunction\b|\bsub\b|\bproperty\b&quot;)
+ If UCase(Left(sText, 6)) = &quot;OPTION&quot; Then _PropertyGet = acClassModule Else _PropertyGet = acStandardModule
+ Case Else
+ Goto Trace_Error
+ End Select
+
+Exit_Function:
+ Utils._ResetCalledSub(cstThisSub)
+ Exit Function
+Trace_Error:
+ TraceError(TRACEFATAL, ERRPROPERTY, Utils._CalledSub(), 0, 1, psProperty)
+ _PropertyGet = Nothing
+ Goto Exit_Function
+Error_Function:
+ TraceError(TRACEABORT, Err, &quot;Module._PropertyGet&quot;, Erl)
+ _PropertyGet = Null
+ GoTo Exit_Function
+End Function &apos; _PropertyGet
+
+
+</script:module> \ No newline at end of file
diff --git a/wizards/source/access2base/Root_.xba b/wizards/source/access2base/Root_.xba
index 42475c927d70..01f50923b6cd 100644
--- a/wizards/source/access2base/Root_.xba
+++ b/wizards/source/access2base/Root_.xba
@@ -29,7 +29,9 @@ Private DebugPrintShort As Boolean
Private Introspection As Object &apos; com.sun.star.beans.Introspection
Private VersionNumber As String &apos; Actual Access2Base version number
Private Locale As String
+Private ExcludeA2B As Boolean
Private TextSearch As Object
+Private SearchOptions As Variant
Private FindRecord As Object
Private StatusBar As Object
Private Dialogs As Object &apos; Collection
@@ -51,8 +53,15 @@ Dim vCurrentDoc() As Variant
CalledSub = &quot;&quot;
DebugPrintShort = True
Locale = L10N._GetLocale()
+ ExcludeA2B = True
Set Introspection = CreateUnoService(&quot;com.sun.star.beans.Introspection&quot;)
Set TextSearch = CreateUnoService(&quot;com.sun.star.util.TextSearch&quot;)
+ SearchOptions = New com.sun.star.util.SearchOptions
+ With SearchOptions
+ .algorithmType = com.sun.star.util.SearchAlgorithms.REGEXP
+ .searchFlag = 0
+ .transliterateFlags = com.sun.star.i18n.TransliterationModules.IGNORE_CASE
+ End With
Set FindRecord = Nothing
Set StatusBar = Nothing
Set Dialogs = New Collection
diff --git a/wizards/source/access2base/Test.xba b/wizards/source/access2base/Test.xba
index b69d93f36a2c..bada74473061 100644
--- a/wizards/source/access2base/Test.xba
+++ b/wizards/source/access2base/Test.xba
@@ -4,6 +4,10 @@
&apos;Option Compatible
Sub Main
+Dim a, b()
+ _ErrorHandler(False)
+ TraceConsole()
+ exit sub
End Sub
</script:module> \ No newline at end of file
diff --git a/wizards/source/access2base/Utils.xba b/wizards/source/access2base/Utils.xba
index 6028df496253..668507867369 100644
--- a/wizards/source/access2base/Utils.xba
+++ b/wizards/source/access2base/Utils.xba
@@ -913,9 +913,10 @@ Error_Function:
End Function &apos; _ReadFileIntoArray V1.4.0
REM -----------------------------------------------------------------------------------------------------------------------
-Function _RegexSearch(ByRef psString As String _
+Public Function _RegexSearch(ByRef psString As String _
, ByVal psRegex As String _
, Optional ByRef plStart As Long _
+ , Optional ByVal bForward As Boolean _
) As String
&apos; Search is not case-sensitive
&apos; Return &quot;&quot; if regex not found, otherwise returns the matching string
@@ -924,26 +925,35 @@ Function _RegexSearch(ByRef psString As String _
&apos; To search again the same or another pattern =&gt; plStart = plStart + Len(matching string)
Dim oTextSearch As Object
-Dim vOptions As New com.sun.star.util.SearchOptions, vResult As Object
-Dim lEnd As Long
+Dim vOptions As Variant &apos;com.sun.star.util.SearchOptions
+Dim lEnd As Long, vResult As Object
_RegexSearch = &quot;&quot;
Set oTextSearch = _A2B_.TextSearch &apos; UNO XTextSearch service
- With vOptions
- .algorithmType = com.sun.star.util.SearchAlgorithms.REGEXP
- .searchFlag = 0
- .searchString = psRegex &apos; Pattern to be searched
- .transliterateFlags = com.sun.star.i18n.TransliterationModules.IGNORE_CASE
- End With
+ vOptions = _A2B_.SearchOptions
+ vOptions.searchString = psRegex &apos; Pattern to be searched
oTextSearch.setOptions(vOptions)
If IsMissing(plStart) Then plStart = 1
- If plStart &lt;= 0 Then Exit Function
- lEnd = Len(psString)
- vResult = oTextSearch.searchForward(psString, plStart - 1, lEnd)
+ If plStart &lt;= 0 Or plStart &gt; Len(psString) Then Exit Function
+ If IsMissing(bForWard) Then bForward = True
+ If bForward Then
+ lEnd = Len(psString)
+ vResult = oTextSearch.searchForward(psString, plStart - 1, lEnd)
+ Else
+ lEnd = 1
+ vResult = oTextSearch.searchForward(psString, plStart, lEnd - 1)
+ End If
With vResult
If .subRegExpressions &gt;= 1 Then
- plStart = .startOffset(0) + 1
- lEnd = .endOffset(0) + 1
+ &apos; http://www.openoffice.org/api/docs/common/ref/com/sun/star/util/SearchResult.html
+ Select Case bForward
+ Case True
+ plStart = .startOffset(0) + 1
+ lEnd = .endOffset(0) + 1
+ Case False
+ plStart = .endOffset(0) + 1
+ lEnd = .startOffset(0)
+ End Select
_RegexSearch = Mid(psString, plStart, lEnd - plStart)
Else
plStart = 0
@@ -953,7 +963,7 @@ Dim lEnd As Long
End Function
REM -----------------------------------------------------------------------------------------------------------------------
-Function _RegisterEventScript(poObject As Object _
+Public Function _RegisterEventScript(poObject As Object _
, ByVal psEvent As String _
, ByVal psListener As String _
, ByVal psScriptCode As String _
@@ -1061,12 +1071,12 @@ End Function &apos; Surround
REM -----------------------------------------------------------------------------------------------------------------------
Public Function _Trim(ByVal psString As String) As String
-&apos; Remove leading and trailing spaces, remove surrounding square brackets
+&apos; Remove leading and trailing spaces, remove surrounding square brackets, replace tabs by spaces
Const cstSquareOpen = &quot;[&quot;
Const cstSquareClose = &quot;]&quot;
Dim sTrim As String
- sTrim = Trim(psString)
+ sTrim = Trim(Replace(psString, vbTab, &quot; &quot;))
_Trim = sTrim
If Len(sTrim) &lt;= 2 Then Exit Function
diff --git a/wizards/source/access2base/acConstants.xba b/wizards/source/access2base/acConstants.xba
index a7dcda83879b..e382996b22fc 100644
--- a/wizards/source/access2base/acConstants.xba
+++ b/wizards/source/access2base/acConstants.xba
@@ -385,11 +385,26 @@ Global Const msoBarTypeFloater = 12 &apos; Floating window
Global Const msoControlButton = 1 &apos; Command button
Global Const msoControlPopup = 10 &apos; Popup, submenu
-REM New Line
+REM New Lines
REM -----------------------------------------------------------------
+Public Function vbCr() As String : vbCr = Chr(13) : End Function
+Public Function vbLf() As String : vbLf = Chr(10) : End Function
Public Function vbNewLine() As String
Const cstWindows = 1
- If GetGuiType() = cstWindows Then vbNewLine = Chr(13) &amp; Chr(10) Else vbNewLine = Chr(10)
+ If GetGuiType() = cstWindows Then vbNewLine = vbCR &amp; vbLF Else vbNewLine = vbLF
End Function &apos; vbNewLine V1.4.0
+Public Function vbTab() As String : vbTab = Chr(9) : End Function
+
+REM Module types
+REM -----------------------------------------------------------------
+Global Const acClassModule = 1
+Global Const acStandardModule = 0
+
+REM (Module) procedure types
+REM -----------------------------------------------------------------
+Global Const vbext_pk_Get = 1 &apos; A Property Get procedure
+Global Const vbext_pk_Let = 2 &apos; A Property Let procedure
+Global Const vbext_pk_Proc = 0 &apos; A Sub or Function procedure
+Global Const vbext_pk_Set = 3 &apos; A Property Set procedure
</script:module> \ No newline at end of file
diff --git a/wizards/source/access2base/script.xlb b/wizards/source/access2base/script.xlb
index 67000bc90bfa..a3e5c7820694 100644
--- a/wizards/source/access2base/script.xlb
+++ b/wizards/source/access2base/script.xlb
@@ -30,4 +30,5 @@
<library:element library:name="UtilProperty"/>
<library:element library:name="CommandBar"/>
<library:element library:name="CommandBarControl"/>
+ <library:element library:name="Module"/>
</library:library> \ No newline at end of file