tdf#164434 Correct SvgSymbolNode SVG import
[LibreOffice.git] / wizards / source / sfdocuments / SF_FormDocument.xba
blob6f055ff359eff418bb146009a112e5d8be237434
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <script:module xmlns:script="http://openoffice.org/2000/script" script:name="SF_FormDocument" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
4 REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
5 REM === The SFDocuments library is one of the associated libraries. ===
6 REM === Full documentation is available on https://help.libreoffice.org/ ===
7 REM =======================================================================================================================
9 Option Compatible
10 Option ClassModule
12 Option Explicit
14 &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
15 &apos;&apos;&apos; SF_FormDocument
16 &apos;&apos;&apos; ===============
17 &apos;&apos;&apos;
18 &apos;&apos;&apos; The SFDocuments library gathers a number of methods and properties making easy
19 &apos;&apos;&apos; managing and manipulating LibreOffice documents
20 &apos;&apos;&apos;
21 &apos;&apos;&apos; Some methods are generic for all types of documents: they are combined in the SF_Document module.
22 &apos;&apos;&apos; Specific properties and methods are implemented in the concerned subclass(es) SF_Calc, SF_Writer, SF_Base, ...
23 &apos;&apos;&apos;
24 &apos;&apos;&apos; To workaround the absence of class inheritance in LibreOffice Basic, some redundancy is necessary
25 &apos;&apos;&apos; Each subclass MUST implement also the generic methods and properties, even if they only call
26 &apos;&apos;&apos; the parent methods and properties.
27 &apos;&apos;&apos; They should also duplicate some generic private members as a subset of their own set of members
28 &apos;&apos;&apos;
29 &apos;&apos;&apos; The SF_FormDocument module is focused on :
30 &apos;&apos;&apos; The orchestration of Base form documents (aka Base Forms, but this is confusing)
31 &apos;&apos;&apos; and the identification of and the access to their controls.
32 &apos;&apos;&apos; Form documents are always contained in a Base document.
33 &apos;&apos;&apos; They should not be confused with Writer documents containing forms,
34 &apos;&apos;&apos; even if it is easy to convert the former to the latter.
35 &apos;&apos;&apos;
36 &apos;&apos;&apos; The current module is closely related to
37 &apos;&apos;&apos; the &quot;Base&quot; service of the current library
38 &apos;&apos;&apos; the &quot;Database&quot; service of the SFDatabases library
39 &apos;&apos;&apos;
40 &apos;&apos;&apos; A form document may be opened either:
41 &apos;&apos;&apos; via code or user interface from the Base file welcome page
42 &apos;&apos;&apos; via code only, without having its Base container opened first
43 &apos;&apos;&apos; The Base document remains hidden but the user might be prompted about the macro execution mode
44 &apos;&apos;&apos; In any mode, a form document can be opened only in 1 single copy
45 &apos;&apos;&apos;
46 &apos;&apos;&apos; Service invocation examples:
47 &apos;&apos;&apos; 1) From the Base service
48 &apos;&apos;&apos; Dim oBase As Object, oFormDoc As Object
49 &apos;&apos;&apos; &apos; oBase is presumed to represent an open Base document
50 &apos;&apos;&apos; Set oFormDoc = oBade.OpenFormDocument(&quot;Folder1/Form1&quot;)
51 &apos;&apos;&apos; 2) Directly without making the Base document visible
52 &apos;&apos;&apos; Dim oDatabase As Object, oFormDoc As Object
53 &apos;&apos;&apos; Set oDatabase = CreateScriptService(&quot;SFDatabases.Database&quot;, &quot;.../myFile.odb&quot;, ReadOnly := False)
54 &apos;&apos;&apos; &apos; The substring &quot;SFDatabases.&quot; in the service name is optional
55 &apos;&apos;&apos; Set oFormDoc = oDatabase.OpenFormDocument(&quot;Folder1/Form1&quot;)
56 &apos;&apos;&apos;
57 &apos;&apos;&apos; Definitions:
58 &apos;&apos;&apos; None
59 &apos;&apos;&apos;
60 &apos;&apos;&apos; Detailed user documentation:
61 &apos;&apos;&apos; https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_formdocument.html?DbPAR=BASIC
62 &apos;&apos;&apos;
63 &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
65 REM ================================================================== EXCEPTIONS
67 Private Const BASEFORMNOTFOUNDERROR = &quot;BASEFORMNOTFOUNDERROR&quot;
68 Private Const DBCONNECTERROR = &quot;DBCONNECTERROR&quot;
70 REM ============================================================= PRIVATE MEMBERS
72 Private [Me] As Object
73 Private [_Parent] As Object &apos; Unused
74 Private [_Super] As Object &apos; Document superclass, which the current instance is a subclass of
75 Private ObjectType As String &apos; Must be FormDocument
76 Private ServiceName As String
78 &apos; Components
79 Private _Component As Object &apos; com.sun.star.lang.XComponent
80 Private _BaseComponent As Object &apos; com.sun.star.comp.dba.ODatabaseDocument
81 Private _FormDocument As Object &apos; com.sun.star.comp.sdb.Content
83 &apos; Form document description
84 Private _PersistentName As String &apos; Typically Objxx
85 Private _HierarchicalName As String
86 Private _DataSource As Object &apos; com.sun.star.sdbc.XDataSource
87 Private _User As String &apos; Credentials
88 Private _Password As String
90 REM ============================================================ MODULE CONSTANTS
92 Const ISBASEFORM = 3 &apos; Form is stored in a Form document
94 REM ====================================================== CONSTRUCTOR/DESTRUCTOR
96 REM -----------------------------------------------------------------------------
97 Private Sub Class_Initialize()
98 Set [Me] = Nothing
99 Set [_Parent] = Nothing
100 Set [_Super] = Nothing
101 ObjectType = &quot;FormDocument&quot;
102 ServiceName = &quot;SFDocuments.FormDocument&quot;
103 Set _Component = Nothing
104 Set _BaseComponent = Nothing
105 Set _FormDocument = Nothing
106 Set _DataSource = Nothing
107 _PersistentName = &quot;&quot;
108 _HierarchicalName = &quot;&quot;
109 End Sub &apos; SFDocuments.SF_FormDocument Constructor
111 REM -----------------------------------------------------------------------------
112 Private Sub Class_Terminate()
113 Call Class_Initialize()
114 End Sub &apos; SFDocuments.SF_FormDocument Destructor
116 REM -----------------------------------------------------------------------------
117 Public Function Dispose() As Variant
118 If Not IsNull([_Super]) Then Set [_Super] = [_Super].Dispose()
119 Call Class_Terminate()
120 Set Dispose = Nothing
121 End Function &apos; SFDocuments.SF_FormDocument Explicit Destructor
123 REM ================================================================== PROPERTIES
125 REM ===================================================================== METHODS
127 REM -----------------------------------------------------------------------------
128 Public Function CloseDocument() As Boolean
129 &apos;&apos;&apos; Close the form document and dispose the actual instance
130 &apos;&apos;&apos; Args:
131 &apos;&apos;&apos; Returns:
132 &apos;&apos;&apos; True if closure is successful
133 &apos;&apos;&apos; Example:
134 &apos;&apos;&apos; myFormDoc.CloseDocument()
136 Dim bClose As Boolean &apos; Return value
137 Dim oContainer As Object &apos; com.sun.star.awt.XWindow
138 Const cstThisSub = &quot;SFDocuments.FormDocument.CloseDocument&quot;
139 Const cstSubArgs = &quot;&quot;
141 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
142 bClose = False
144 Check:
145 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
146 If Not _IsStillAlive() Then GoTo Finally
147 End If
148 Try:
149 _FormDocument.close()
150 Dispose()
151 bClose = True
153 Finally:
154 CloseDocument = bClose
155 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
156 Exit Function
157 Catch:
158 GoTo Finally
159 End Function &apos; SFDocuments.SF_FormDocument.CloseDocument
161 REM -----------------------------------------------------------------------------
162 Public Function Forms(Optional ByVal Form As Variant) As Variant
163 &apos;&apos;&apos; Return either
164 &apos;&apos;&apos; - the list of the Forms contained in the form document
165 &apos;&apos;&apos; - a SFDocuments.Form object based on its name or its index
166 &apos;&apos;&apos; Args:
167 &apos;&apos;&apos; Form: a form stored in the document given by its name or its index
168 &apos;&apos;&apos; When absent, the list of available forms is returned
169 &apos;&apos;&apos; To get the first (unique ?) form stored in the form document, set Form = 0
170 &apos;&apos;&apos; Exceptions:
171 &apos;&apos;&apos; BASEFORMNOTFOUNDERROR Form not found
172 &apos;&apos;&apos; Returns:
173 &apos;&apos;&apos; A zero-based array of strings if Form is absent
174 &apos;&apos;&apos; An instance of the SF_Form class if Form exists
175 &apos;&apos;&apos; Example:
176 &apos;&apos;&apos; Dim myForm As Object, myList As Variant
177 &apos;&apos;&apos; myList = oDoc.Forms()
178 &apos;&apos;&apos; Set myForm = oDoc.Forms(&quot;myForm&quot;)
180 Dim oForm As Object &apos; The new Form class instance
181 Dim oMainForm As Object &apos; com.sun.star.comp.sdb.Content
182 Dim oXForm As Object &apos; com.sun.star.form.XForm
183 Dim vFormNames As Variant &apos; Array of form names
184 Dim oForms As Object &apos; Forms collection
185 Const cstDrawPage = 0 &apos; Only 1 drawpage in a FormDocument document
187 Const cstThisSub = &quot;SFDocuments.FormDocument.Forms&quot;
188 Const cstSubArgs = &quot;[Form=&quot;&quot;&quot;&quot;]&quot;
190 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
192 Check:
193 If IsMissing(Form) Or IsEmpty(Form) Then Form = &quot;&quot;
194 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
195 If Not _IsStillAlive() Then GoTo Finally
196 If Not ScriptForge.SF_Utils._Validate(Form, &quot;Form&quot;, Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally
197 End If
199 Try:
200 &apos; Start from the document component and go down to forms
201 Set oForms = _Component.DrawPages(cstDrawPage).Forms
202 vFormNames = oForms.getElementNames()
204 If Len(Form) = 0 Then &apos; Return the list of valid form names
205 Forms = vFormNames
206 Else
207 If VarType(Form) = V_STRING Then &apos; Find the form by name
208 If Not ScriptForge.SF_Array.Contains(vFormNames, Form, CaseSensitive := True) Then GoTo CatchNotFound
209 Set oXForm = oForms.getByName(Form)
210 Else &apos; Find the form by index
211 If Form &lt; 0 Or Form &gt;= oForms.Count Then GoTo CatchNotFound
212 Set oXForm = oForms.getByIndex(Form)
213 End If
214 &apos; Create the new Form class instance
215 Set oForm = SF_Register._NewForm(oXForm)
216 With oForm
217 Set .[_Parent] = [Me]
218 ._FormType = ISBASEFORM
219 Set ._Component = _Component
220 Set ._BaseComponent = _BaseComponent
221 ._FormDocumentName = _HierarchicalName
222 ._FormDocument = _FormDocument
223 ._Initialize()
224 End With
225 Set Forms = oForm
226 End If
228 Finally:
229 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
230 Exit Function
231 Catch:
232 GoTo Finally
233 CatchNotFound:
234 ScriptForge.SF_Exception.RaiseFatal(BASEFORMNOTFOUNDERROR, Form, _FileIdent())
235 End Function &apos; SFDocuments.SF_FormDocument.Forms
237 REM -----------------------------------------------------------------------------
238 Public Function GetDatabase(Optional ByVal User As Variant _
239 , Optional ByVal Password As Variant _
240 ) As Object
241 &apos;&apos;&apos; Returns a Database instance (service = SFDatabases.Database) giving access
242 &apos;&apos;&apos; to the execution of SQL commands on the database defined and/or stored in
243 &apos;&apos;&apos; the actual form document
244 &apos;&apos;&apos; Args:
245 &apos;&apos;&apos; User, Password: the login parameters as strings. Defaults = &quot;&quot;
246 &apos;&apos;&apos; Returns:
247 &apos;&apos;&apos; A SFDatabases.Database instance or Nothing
248 &apos;&apos;&apos; Exceptions:
249 &apos;&apos;&apos; DBCONNECTERROR The database could not be connected, credentials are probably wrong
250 &apos;&apos;&apos; Example:
251 &apos;&apos;&apos; Dim myDb As Object
252 &apos;&apos;&apos; Set myDb = oFormDoc.GetDatabase()
254 Dim oDatabase As Object &apos; Return value
255 Const cstThisSub = &quot;SFDocuments.FormDocument.GetDatabase&quot;
256 Const cstSubArgs = &quot;[User=&quot;&quot;&quot;&quot;], [Password=&quot;&quot;&quot;&quot;]&quot;
258 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
259 Set oDatabase = Nothing
261 Check:
262 If IsMissing(User) Or IsEmpty(User) Then User = &quot;&quot;
263 If IsMissing(Password) Or IsEmpty(Password) Then Password = &quot;&quot;
264 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
265 If Not _IsStillAlive(False) Then GoTo Finally
266 If Not ScriptForge.SF_Utils._Validate(User, &quot;User&quot;, V_STRING) Then GoTo Finally
267 If Not ScriptForge.SF_Utils._Validate(Password, &quot;Password&quot;, V_STRING) Then GoTo Finally
268 End If
270 Try:
271 If IsNull(_DataSource) Then GoTo CatchConnect
272 Set oDatabase = ScriptForge.SF_Services.CreateScriptService(&quot;SFDatabases.DatabaseFromDocument&quot; _
273 , _DataSource, Iif(User = &quot;&quot;, _User, User), Iif(Password = &quot;&quot;, _Password, Password))
274 If IsNull(oDatabase) Then GoTo CatchConnect
275 oDatabase._Location = _DataSource.Name
277 Finally:
278 Set GetDatabase = oDatabase
279 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
280 Exit Function
281 Catch:
282 GoTo Finally
283 CatchConnect:
284 ScriptForge.SF_Exception.RaiseFatal(DBCONNECTERROR, &quot;User&quot;, User, &quot;Password&quot;, Password, [_Super]._FileIdent())
285 GoTo Finally
286 End Function &apos; SFDocuments.SF_FormDocument.GetDatabase
288 REM -----------------------------------------------------------------------------
289 Public Function GetProperty(Optional ByVal PropertyName As Variant _
290 , Optional ObjectName As Variant _
291 ) As Variant
292 &apos;&apos;&apos; Return the actual value of the given property
293 &apos;&apos;&apos; Args:
294 &apos;&apos;&apos; PropertyName: the name of the property as a string
295 &apos;&apos;&apos; ObjectName: a sheet or range name
296 &apos;&apos;&apos; Returns:
297 &apos;&apos;&apos; The actual value of the property
298 &apos;&apos;&apos; Exceptions:
299 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
301 Const cstThisSub = &quot;SFDocuments.FormDocument.GetProperty&quot;
302 Const cstSubArgs = &quot;&quot;
304 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
305 GetProperty = Null
307 Check:
308 If IsMissing(ObjectName) Or IsEmpty(ObjectName) Then ObjectName = &quot;&quot;
309 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
310 If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
311 If Not ScriptForge.SF_Utils._Validate(ObjectName, &quot;ObjectName&quot;, V_STRING) Then GoTo Catch
312 End If
314 Try:
315 &apos; Superclass or subclass property ?
316 If ScriptForge.SF_Array.Contains([_Super].Properties(), PropertyName) Then
317 GetProperty = [_Super].GetProperty(PropertyName)
318 ElseIf Len(ObjectName) = 0 Then
319 GetProperty = _PropertyGet(PropertyName)
320 Else
321 GetProperty = _PropertyGet(PropertyName, ObjectName)
322 End If
324 Finally:
325 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
326 Exit Function
327 Catch:
328 GoTo Finally
329 End Function &apos; SFDocuments.SF_FormDocument.GetProperty
331 REM -----------------------------------------------------------------------------
332 Public Function Methods() As Variant
333 &apos;&apos;&apos; Return the list of public methods of the FormDocument service as an array
335 Methods = Array( _
336 &quot;CloseDocument&quot; _
337 , &quot;Forms&quot; _
338 , &quot;GetDatabase&quot; _
339 , &quot;PrintOut&quot; _
342 End Function &apos; SFDocuments.SF_FormDocument.Methods
344 REM -----------------------------------------------------------------------------
345 Public Function PrintOut(Optional ByVal Pages As Variant _
346 , Optional ByVal Copies As Variant _
347 , Optional ByVal PrintBackground As Variant _
348 , Optional ByVal PrintBlankPages As Variant _
349 , Optional ByVal PrintEvenPages As Variant _
350 , Optional ByVal PrintOddPages As Variant _
351 , Optional ByVal PrintImages As Variant _
352 ) As Boolean
353 &apos;&apos;&apos; Send the content of the document to the printer.
354 &apos;&apos;&apos; The printer might be defined previously by default, by the user or by the SetPrinter() method
355 &apos;&apos;&apos; Args:
356 &apos;&apos;&apos; Pages: the pages to print as a string, like in the user interface. Example: &quot;1-4;10;15-18&quot;. Default = all pages
357 &apos;&apos;&apos; Copies: the number of copies
358 &apos;&apos;&apos; PrintBackground: print the background image when True (default)
359 &apos;&apos;&apos; PrintBlankPages: when False (default), omit empty pages
360 &apos;&apos;&apos; PrintEvenPages: print the left pages when True (default)
361 &apos;&apos;&apos; PrintOddPages: print the right pages when True (default)
362 &apos;&apos;&apos; PrintImages: print the graphic objects when True (default)
363 &apos;&apos;&apos; Returns:
364 &apos;&apos;&apos; True when successful
365 &apos;&apos;&apos; Examples:
366 &apos;&apos;&apos; oDoc.PrintOut(&quot;1-4;10;15-18&quot;, Copies := 2, PrintImages := False)
368 Dim bPrint As Boolean &apos; Return value
369 Dim vPrintOptions As Variant &apos; com.sun.star.text.DocumentSettings
371 Const cstThisSub = &quot;SFDocuments.FormDocument.PrintOut&quot;
372 Const cstSubArgs = &quot;[Pages=&quot;&quot;&quot;&quot;], [Copies=1], [PrintBackground=True], [PrintBlankPages=False], [PrintEvenPages=True]&quot; _
373 &amp; &quot;, [PrintOddPages=True], [PrintImages=True]&quot;
375 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
376 bPrint = False
378 Check:
379 If IsMissing(Pages) Or IsEmpty(Pages) Then Pages = &quot;&quot;
380 If IsMissing(Copies) Or IsEmpty(Copies) Then Copies = 1
381 If IsMissing(PrintBackground) Or IsEmpty(PrintBackground) Then PrintBackground = True
382 If IsMissing(PrintBlankPages) Or IsEmpty(PrintBlankPages) Then PrintBlankPages = False
383 If IsMissing(PrintEvenPages) Or IsEmpty(PrintEvenPages) Then PrintEvenPages = True
384 If IsMissing(PrintOddPages) Or IsEmpty(PrintOddPages) Then PrintOddPages = True
385 If IsMissing(PrintImages) Or IsEmpty(PrintImages) Then PrintImages = True
387 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
388 If Not _IsStillAlive() Then GoTo Finally
389 If Not ScriptForge.SF_Utils._Validate(Pages, &quot;Pages&quot;, V_STRING) Then GoTo Finally
390 If Not ScriptForge.SF_Utils._Validate(Copies, &quot;Copies&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
391 If Not ScriptForge.SF_Utils._Validate(PrintBackground, &quot;PrintBackground&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
392 If Not ScriptForge.SF_Utils._Validate(PrintBlankPages, &quot;PrintBlankPages&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
393 If Not ScriptForge.SF_Utils._Validate(PrintEvenPages, &quot;PrintEvenPages&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
394 If Not ScriptForge.SF_Utils._Validate(PrintOddPages, &quot;PrintOddPages&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
395 If Not ScriptForge.SF_Utils._Validate(PrintImages, &quot;PrintImages&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
396 End If
398 Try:
399 vPrintOptions = _Component.createInstance(&quot;com.sun.star.text.DocumentSettings&quot;)
400 With vPrintOptions
401 .PrintPageBackground = PrintBackground
402 .PrintEmptyPages = PrintBlankPages
403 .PrintLeftPages = PrintEvenPages
404 .PrintRightPages = PrintOddPages
405 .PrintGraphics = PrintImages
406 .PrintDrawings = PrintImages
407 End With
409 bPrint = [_Super].PrintOut(Pages, Copies, _Component)
411 Finally:
412 PrintOut = bPrint
413 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
414 Exit Function
415 Catch:
416 GoTo Finally
417 End Function &apos; SFDocuments.SF_FormDocument.PrintOut
419 REM -----------------------------------------------------------------------------
420 Public Function Properties() As Variant
421 &apos;&apos;&apos; Return the list or properties of the FormDocument class as an array
423 Properties = Array( _
424 &quot;DocumentType&quot; _
425 , &quot;FileSystem&quot; _
426 , &quot;IsAlive&quot; _
427 , &quot;IsBase&quot; _
428 , &quot;IsCalc&quot; _
429 , &quot;IsDraw&quot; _
430 , &quot;IsFormDocument&quot; _
431 , &quot;IsImpress&quot; _
432 , &quot;IsMath&quot; _
433 , &quot;Readonly&quot; _
434 , &quot;StyleFamilies&quot; _
435 , &quot;XComponent&quot; _
436 , &quot;XDocumentSettings&quot; _
439 End Function &apos; SFDocuments.SF_FormDocument.Properties
441 REM ======================================================= SUPERCLASS PROPERTIES
443 REM -----------------------------------------------------------------------------
444 Property Get FileSystem() As String
445 FileSystem = [_Super].GetProperty(&quot;FileSystem&quot;)
446 End Property &apos; SFDocuments.SF_FormDocument.FileSystem
448 REM -----------------------------------------------------------------------------
449 Property Get IsAlive() As Boolean
450 IsAlive = [_Super].GetProperty(&quot;IsAlive&quot;)
451 End Property &apos; SFDocuments.SF_FormDocument.IsAlive
453 REM -----------------------------------------------------------------------------
454 Property Get IsBase() As Boolean
455 IsBase = [_Super].GetProperty(&quot;IsBase&quot;)
456 End Property &apos; SFDocuments.SF_FormDocument.IsBase
458 REM -----------------------------------------------------------------------------
459 Property Get IsCalc() As Boolean
460 IsCalc = [_Super].GetProperty(&quot;IsCalc&quot;)
461 End Property &apos; SFDocuments.SF_FormDocument.IsCalc
463 REM -----------------------------------------------------------------------------
464 Property Get IsDraw() As Boolean
465 IsDraw = [_Super].GetProperty(&quot;IsDraw&quot;)
466 End Property &apos; SFDocuments.SF_FormDocument.IsDraw
468 REM -----------------------------------------------------------------------------
469 Property Get IsFormDocument() As Boolean
470 IsFormDocument = [_Super].GetProperty(&quot;IsFormDocument&quot;)
471 End Property &apos; SFDocuments.SF_Writer.IsFormDocument
473 REM -----------------------------------------------------------------------------
474 Property Get IsImpress() As Boolean
475 IsImpress = [_Super].GetProperty(&quot;IsImpress&quot;)
476 End Property &apos; SFDocuments.SF_FormDocument.IsImpress
478 REM -----------------------------------------------------------------------------
479 Property Get IsMath() As Boolean
480 IsMath = [_Super].GetProperty(&quot;IsMath&quot;)
481 End Property &apos; SFDocuments.SF_FormDocument.IsMath
483 REM -----------------------------------------------------------------------------
484 Property Get Readonly() As Variant
485 Readonly = [_Super].GetProperty(&quot;Readonly&quot;)
486 End Property &apos; SFDocuments.SF_FormDocument.Readonly
488 REM -----------------------------------------------------------------------------
489 Property Get StyleFamilies() As Variant
490 StyleFamilies = [_Super].GetProperty(&quot;StyleFamilies&quot;)
491 End Property &apos; SFDocuments.SF_FormDocument.StyleFamilies
493 REM -----------------------------------------------------------------------------
494 Property Get XComponent() As Variant
495 XComponent = [_Super].GetProperty(&quot;XComponent&quot;)
496 End Property &apos; SFDocuments.SF_FormDocument.XComponent
498 REM -----------------------------------------------------------------------------
499 Property Get XDocumentSettings() As Variant
500 XDocumentSettings = [_Super].GetProperty(&quot;XDocumentSettings&quot;)
501 End Property &apos; SFDocuments.SF_FormDocument.XDocumentSettings
503 REM ========================================================== SUPERCLASS METHODS
505 REM -----------------------------------------------------------------------------
506 Public Function Activate() As Boolean
507 Activate = [_Super].Activate()
508 End Function &apos; SFDocuments.SF_FormDocument.Activate
510 REM -----------------------------------------------------------------------------
511 Public Function ContextMenus(Optional ByVal ContextMenuName As Variant _
512 , Optional ByVal SubmenuChar As Variant _
513 ) As Variant
514 ContextMenus = [_Super].ContextMenus(ContextMenuName, SubmenuChar)
515 End Function &apos; SFDocuments.SF_FormDocument.ContextMenus
517 REM -----------------------------------------------------------------------------
518 Public Function CreateMenu(Optional ByVal MenuHeader As Variant _
519 , Optional ByVal Before As Variant _
520 , Optional ByVal SubmenuChar As Variant _
521 ) As Object
522 Set CreateMenu = [_Super].CreateMenu(MenuHeader, Before, SubmenuChar)
523 End Function &apos; SFDocuments.SF_FormDocument.CreateMenu
525 REM -----------------------------------------------------------------------------
526 Public Sub Echo(Optional ByVal EchoOn As Variant _
527 , Optional ByVal Hourglass As Variant _
529 [_Super].Echo(EchoOn, Hourglass)
530 End Sub &apos; SFDocuments.SF_FormDocument.Echo
532 REM -----------------------------------------------------------------------------
533 Public Function ExportAsPDF(Optional ByVal FileName As Variant _
534 , Optional ByVal Overwrite As Variant _
535 , Optional ByVal Pages As Variant _
536 , Optional ByVal Password As Variant _
537 , Optional ByVal Watermark As Variant _
538 ) As Boolean
539 ExportAsPDF = [_Super].ExportAsPDF(FileName, Overwrite, Pages, Password, Watermark)
540 End Function &apos; SFDocuments.SF_FormDocument.ExportAsPDF
542 REM -----------------------------------------------------------------------------
543 Public Function RemoveMenu(Optional ByVal MenuHeader As Variant) As Boolean
544 RemoveMenu = [_Super].RemoveMenu(MenuHeader)
545 End Function &apos; SFDocuments.SF_FormDocument.RemoveMenu
547 REM -----------------------------------------------------------------------------
548 Public Sub RunCommand(Optional ByVal Command As Variant _
549 , ParamArray Args As Variant _
551 [_Super].RunCommand(Command, Args)
552 End Sub &apos; SFDocuments.SF_FormDocument.RunCommand
554 REM -----------------------------------------------------------------------------
555 Public Function SaveCopyAs(Optional ByVal FileName As Variant _
556 , Optional ByVal Overwrite As Variant _
557 , Optional ByVal Password As Variant _
558 , Optional ByVal FilterName As Variant _
559 , Optional ByVal FilterOptions As Variant _
560 ) As Boolean
561 SaveCopyAs = [_Super].SaveCopyAs(FileName, Overwrite, Password, FilterName, FilterOptions)
562 End Function &apos; SFDocuments.SF_FormDocument.SaveCopyAs
564 REM -----------------------------------------------------------------------------
565 Public Function SetPrinter(Optional ByVal Printer As Variant _
566 , Optional ByVal Orientation As Variant _
567 , Optional ByVal PaperFormat As Variant _
568 ) As Boolean
569 SetPrinter = [_Super].SetPrinter(Printer, Orientation, PaperFormat)
570 End Function &apos; SFDocuments.SF_FormDocument.SetPrinter
572 REM -----------------------------------------------------------------------------
573 Public Function Styles(Optional ByVal Family As Variant _
574 , Optional ByVal NamePattern As variant _
575 , Optional ByVal Used As variant _
576 , Optional ByVal UserDefined As Variant _
577 , Optional ByVal ParentStyle As Variant _
578 , Optional ByVal Category As Variant _
579 ) As Variant
580 Styles = [_Super].Styles(Family, NamePattern, Used, UserDefined, ParentStyle, Category)
581 End Function &apos; SFDocuments.SF_FormDocument.Styles
583 REM -----------------------------------------------------------------------------
584 Public Function Toolbars(Optional ByVal ToolbarName As Variant) As Variant
585 Toolbars = [_Super].Toolbars(ToolbarName)
586 End Function &apos; SFDocuments.SF_FormDocument.Toolbars
588 REM -----------------------------------------------------------------------------
589 Public Function XStyle(Optional ByVal Family As Variant _
590 , Optional ByVal StyleName As variant _
591 ) As Object
592 Set XStyle = [_Super].XStyle(Family, StyleName)
593 End Function &apos; SFDocuments.SF_FormDocument.XStyle
595 REM =========================================================== PRIVATE FUNCTIONS
597 REM -----------------------------------------------------------------------------
598 Private Function _FileIdent() As String
599 &apos;&apos;&apos; Returns a file identification from the information that is currently available
600 &apos;&apos;&apos; Useful e.g. for display in error messages
602 _FileIdent = [_Super]._FileIdent()
604 End Function &apos; SFDocuments.SF_FormDocument._FileIdent
606 REM -----------------------------------------------------------------------------
607 Public Sub _Initialize()
608 &apos;&apos;&apos; Achieve the creation of a SF_Form instance
609 &apos;&apos;&apos; - the database file
610 &apos;&apos;&apos; - the database connection
611 &apos;&apos;&apos; the internal and external names
613 Dim oBase As Object &apos; A temporary Base instance
615 On Local Error GoTo Catch
617 Try:
618 &apos; Base file where form document is stored
619 Set _BaseComponent = _Component.Parent
621 &apos; Connection arguments
622 Set _DataSource = _BaseComponent.DataSource
623 With _DataSource
624 _User = .User
625 _Password = .Password
626 End With
628 &apos; External and internal names
629 _PersistentName = ScriptForge.SF_Utils._GetPropertyValue(_Component.Args, &quot;HierarchicalDocumentName&quot;)
630 Set oBase = New SF_Base &apos; Only to be able to call the _FindByPersistentName() method
631 With oBase
632 Set _FormDocument = ._FindByPersistentName(_BaseComponent.getFormDocuments(), _PersistentName)
633 _HierarchicalName = _FormDocument.HierarchicalName
634 Set oBase = .Dispose()
635 End With
637 Finally:
638 Exit Sub
639 Catch:
640 On Local Error GoTo 0
641 GoTo Finally
642 End Sub &apos; SFDocuments.SF_FormDocument._Initialize
644 REM -----------------------------------------------------------------------------
645 Private Function _IsStillAlive(Optional ByVal pbForUpdate As Boolean _
646 , Optional ByVal pbError As Boolean _
647 ) As Boolean
648 &apos;&apos;&apos; Returns True if the document has not been closed manually or incidentally since the last use
649 &apos;&apos;&apos; If dead the actual instance is disposed. The execution is cancelled when pbError = True (default)
650 &apos;&apos;&apos; Args:
651 &apos;&apos;&apos; pbForUpdate: if True (default = False), check additionally if document is open for editing
652 &apos;&apos;&apos; pbError: if True (default), raise a fatal error
654 Dim bAlive As Boolean &apos; Return value
656 If IsMissing(pbForUpdate) Then pbForUpdate = False
657 If IsMissing(pbError) Then pbError = True
659 Try:
660 bAlive = [_Super]._IsStillAlive(pbForUpdate, pbError)
662 Finally:
663 _IsStillAlive = bAlive
664 Exit Function
665 End Function &apos; SFDocuments.SF_FormDocument._IsStillAlive
667 REM -----------------------------------------------------------------------------
668 Private Function _PropertyGet(Optional ByVal psProperty As String _
669 , Optional ByVal pvArg As Variant _
670 ) As Variant
671 &apos;&apos;&apos; Return the value of the named property
672 &apos;&apos;&apos; Args:
673 &apos;&apos;&apos; psProperty: the name of the property
675 Dim cstThisSub As String
676 Const cstSubArgs = &quot;&quot;
678 _PropertyGet = False
680 cstThisSub = &quot;SFDocuments.FormDocument.get&quot; &amp; psProperty
681 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
682 If Not _IsStillAlive() Then GoTo Finally
684 Select Case psProperty
685 Case Else
686 _PropertyGet = Null
687 End Select
689 Finally:
690 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
691 Exit Function
692 End Function &apos; SFDocuments.SF_FormDocument._PropertyGet
694 REM -----------------------------------------------------------------------------
695 Private Function _Repr() As String
696 &apos;&apos;&apos; Convert the SF_FormDocument instance to a readable string, typically for debugging purposes (DebugPrint ...)
697 &apos;&apos;&apos; Args:
698 &apos;&apos;&apos; Return:
699 &apos;&apos;&apos; &quot;[DOCUMENT]: Type/File&quot;
701 _Repr = &quot;[FormDocument]: &quot; &amp; [_Super]._FileIdent()
703 End Function &apos; SFDocuments.SF_FormDocument._Repr
705 REM ============================================ END OF SFDOCUMENTS.SF_FORMDOCUMENT
706 </script:module>