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 =======================================================================================================================
14 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
15 ''' SF_FormDocument
16 ''' ===============
18 ''' The SFDocuments library gathers a number of methods and properties making easy
19 ''' managing and manipulating LibreOffice documents
21 ''' Some methods are generic for all types of documents: they are combined in the SF_Document module.
22 ''' Specific properties and methods are implemented in the concerned subclass(es) SF_Calc, SF_Writer, SF_Base, ...
24 ''' To workaround the absence of class inheritance in LibreOffice Basic, some redundancy is necessary
25 ''' Each subclass MUST implement also the generic methods and properties, even if they only call
26 ''' the parent methods and properties.
27 ''' They should also duplicate some generic private members as a subset of their own set of members
29 ''' The SF_FormDocument module is focused on :
30 ''' The orchestration of Base form documents (aka Base Forms, but this is confusing)
31 ''' and the identification of and the access to their controls.
32 ''' Form documents are always contained in a Base document.
33 ''' They should not be confused with Writer documents containing forms,
34 ''' even if it is easy to convert the former to the latter.
36 ''' The current module is closely related to
37 ''' the
"Base
" service of the current library
38 ''' the
"Database
" service of the SFDatabases library
40 ''' A form document may be opened either:
41 ''' via code or user interface from the Base file welcome page
42 ''' via code only, without having its Base container opened first
43 ''' The Base document remains hidden but the user might be prompted about the macro execution mode
44 ''' In any mode, a form document can be opened only in
1 single copy
46 ''' Service invocation examples:
47 ''' 1) From the Base service
48 ''' Dim oBase As Object, oFormDoc As Object
49 ''' ' oBase is presumed to represent an open Base document
50 ''' Set oFormDoc = oBade.OpenFormDocument(
"Folder1/Form1
")
51 ''' 2) Directly without making the Base document visible
52 ''' Dim oDatabase As Object, oFormDoc As Object
53 ''' Set oDatabase = CreateScriptService(
"SFDatabases.Database
",
".../myFile.odb
", ReadOnly := False)
54 ''' ' The substring
"SFDatabases.
" in the service name is optional
55 ''' Set oFormDoc = oDatabase.OpenFormDocument(
"Folder1/Form1
")
57 ''' Definitions:
58 ''' None
60 ''' Detailed user documentation:
61 ''' https://help.libreoffice.org/latest/en-US/text/sbasic/shared/
03/sf_formdocument.html?DbPAR=BASIC
63 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
65 REM ================================================================== EXCEPTIONS
67 Private Const BASEFORMNOTFOUNDERROR =
"BASEFORMNOTFOUNDERROR
"
69 REM ============================================================= PRIVATE MEMBERS
71 Private [Me] As Object
72 Private [_Parent] As Object
' Unused
73 Private [_Super] As Object
' Document superclass, which the current instance is a subclass of
74 Private ObjectType As String
' Must be FormDocument
75 Private ServiceName As String
78 Private _Component As Object
' com.sun.star.lang.XComponent
79 Private _BaseComponent As Object
' com.sun.star.comp.dba.ODatabaseDocument
80 Private _FormDocument As Object
' com.sun.star.comp.sdb.Content
82 ' Form document description
83 Private _PersistentName As String
' Typically Objxx
84 Private _HierarchicalName As String
85 Private _DataSource As Object
' com.sun.star.sdbc.XDataSource
86 Private _User As String
' Credentials
87 Private _Password As String
89 REM ============================================================ MODULE CONSTANTS
91 Const ISBASEFORM =
3 ' Form is stored in a Form document
93 REM ====================================================== CONSTRUCTOR/DESTRUCTOR
95 REM -----------------------------------------------------------------------------
96 Private Sub Class_Initialize()
98 Set [_Parent] = Nothing
99 Set [_Super] = Nothing
100 ObjectType =
"FormDocument
"
101 ServiceName =
"SFDocuments.FormDocument
"
102 Set _Component = Nothing
103 Set _BaseComponent = Nothing
104 Set _FormDocument = Nothing
105 Set _DataSource = Nothing
106 _PersistentName =
""
107 _HierarchicalName =
""
108 End Sub
' SFDocuments.SF_FormDocument Constructor
110 REM -----------------------------------------------------------------------------
111 Private Sub Class_Terminate()
112 Call Class_Initialize()
113 End Sub
' SFDocuments.SF_FormDocument Destructor
115 REM -----------------------------------------------------------------------------
116 Public Function Dispose() As Variant
117 If Not IsNull([_Super]) Then Set [_Super] = [_Super].Dispose()
118 Call Class_Terminate()
119 Set Dispose = Nothing
120 End Function
' SFDocuments.SF_FormDocument Explicit Destructor
122 REM ================================================================== PROPERTIES
124 REM ===================================================================== METHODS
126 REM -----------------------------------------------------------------------------
127 Public Function CloseDocument() As Boolean
128 ''' Close the form document and dispose the actual instance
129 ''' Args:
130 ''' Returns:
131 ''' True if closure is successful
132 ''' Example:
133 ''' myFormDoc.CloseDocument()
135 Dim bClose As Boolean
' Return value
136 Dim oContainer As Object
' com.sun.star.awt.XWindow
137 Const cstThisSub =
"SFDocuments.FormDocument.CloseDocument
"
138 Const cstSubArgs =
""
140 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
144 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
145 If Not _IsStillAlive() Then GoTo Finally
148 _FormDocument.close()
153 CloseDocument = bClose
154 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
158 End Function
' SFDocuments.SF_FormDocument.CloseDocument
160 REM -----------------------------------------------------------------------------
161 Public Function Forms(Optional ByVal Form As Variant) As Variant
162 ''' Return either
163 ''' - the list of the Forms contained in the form document
164 ''' - a SFDocuments.Form object based on its name or its index
165 ''' Args:
166 ''' Form: a form stored in the document given by its name or its index
167 ''' When absent, the list of available forms is returned
168 ''' To get the first (unique ?) form stored in the form document, set Form =
0
169 ''' Exceptions:
170 ''' BASEFORMNOTFOUNDERROR Form not found
171 ''' Returns:
172 ''' A zero-based array of strings if Form is absent
173 ''' An instance of the SF_Form class if Form exists
174 ''' Example:
175 ''' Dim myForm As Object, myList As Variant
176 ''' myList = oDoc.Forms()
177 ''' Set myForm = oDoc.Forms(
"myForm
")
179 Dim oForm As Object
' The new Form class instance
180 Dim oMainForm As Object
' com.sun.star.comp.sdb.Content
181 Dim oXForm As Object
' com.sun.star.form.XForm
182 Dim vFormNames As Variant
' Array of form names
183 Dim oForms As Object
' Forms collection
184 Const cstDrawPage =
0 ' Only
1 drawpage in a FormDocument document
186 Const cstThisSub =
"SFDocuments.FormDocument.Forms
"
187 Const cstSubArgs =
"[Form=
""""]
"
189 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
192 If IsMissing(Form) Or IsEmpty(Form) Then Form =
""
193 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
194 If Not _IsStillAlive() Then GoTo Finally
195 If Not ScriptForge.SF_Utils._Validate(Form,
"Form
", Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally
199 ' Start from the document component and go down to forms
200 Set oForms = _Component.DrawPages(cstDrawPage).Forms
201 vFormNames = oForms.getElementNames()
203 If Len(Form) =
0 Then
' Return the list of valid form names
206 If VarType(Form) = V_STRING Then
' Find the form by name
207 If Not ScriptForge.SF_Array.Contains(vFormNames, Form, CaseSensitive := True) Then GoTo CatchNotFound
208 Set oXForm = oForms.getByName(Form)
209 Else
' Find the form by index
210 If Form
< 0 Or Form
>= oForms.Count Then GoTo CatchNotFound
211 Set oXForm = oForms.getByIndex(Form)
213 ' Create the new Form class instance
214 Set oForm = SF_Register._NewForm(oXForm)
216 Set .[_Parent] = [Me]
217 ._FormType = ISBASEFORM
218 Set ._Component = _Component
219 Set ._BaseComponent = _BaseComponent
220 ._FormDocumentName = _HierarchicalName
221 ._FormDocument = _FormDocument
228 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
233 ScriptForge.SF_Exception.RaiseFatal(BASEFORMNOTFOUNDERROR, Form, _FileIdent())
234 End Function
' SFDocuments.SF_FormDocument.Forms
236 REM -----------------------------------------------------------------------------
237 Public Function GetDatabase(Optional ByVal User As Variant _
238 , Optional ByVal Password As Variant _
240 ''' Returns a Database instance (service = SFDatabases.Database) giving access
241 ''' to the execution of SQL commands on the database defined and/or stored in
242 ''' the actual form document
243 ''' Args:
244 ''' User, Password: the login parameters as strings. Defaults =
""
245 ''' Returns:
246 ''' A SFDatabases.Database instance or Nothing
247 ''' Example:
248 ''' Dim myDb As Object
249 ''' Set myDb = oFormDoc.GetDatabase()
251 Dim oDatabase As Object
' Return value
252 Const cstThisSub =
"SFDocuments.FormDocument.GetDatabase
"
253 Const cstSubArgs =
"[User=
""""], [Password=
""""]
"
255 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
256 Set oDatabase = Nothing
259 If IsMissing(User) Or IsEmpty(User) Then User =
""
260 If IsMissing(Password) Or IsEmpty(Password) Then Password =
""
261 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
262 If Not _IsStillAlive(False) Then GoTo Finally
263 If Not ScriptForge.SF_Utils._Validate(User,
"User
", V_STRING) Then GoTo Finally
264 If Not ScriptForge.SF_Utils._Validate(Password,
"Password
", V_STRING) Then GoTo Finally
268 If IsNull(_DataSource) Then GoTo CatchConnect
269 Set oDatabase = ScriptForge.SF_Services.CreateScriptService(
"SFDatabases.DatabaseFromDocument
" _
270 , _DataSource, Iif(User =
"", _User, User), Iif(Password =
"", _Password,
""))
271 If IsNull(oDatabase) Then GoTo CatchConnect
272 oDatabase._Location = _DataSource.Name
275 Set GetDatabase = oDatabase
276 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
281 ScriptForge.SF_Exception.RaiseFatal(DBCONNECTERROR,
"User
", User,
"Password
", Password, [_Super]._FileIdent())
283 End Function
' SFDocuments.SF_FormDocument.GetDatabase
285 REM -----------------------------------------------------------------------------
286 Public Function GetProperty(Optional ByVal PropertyName As Variant _
287 , Optional ObjectName As Variant _
289 ''' Return the actual value of the given property
290 ''' Args:
291 ''' PropertyName: the name of the property as a string
292 ''' ObjectName: a sheet or range name
293 ''' Returns:
294 ''' The actual value of the property
295 ''' Exceptions:
296 ''' ARGUMENTERROR The property does not exist
298 Const cstThisSub =
"SFDocuments.FormDocument.GetProperty
"
299 Const cstSubArgs =
""
301 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
305 If IsMissing(ObjectName) Or IsEmpty(ObjectName) Then ObjectName =
""
306 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
307 If Not ScriptForge.SF_Utils._Validate(PropertyName,
"PropertyName
", V_STRING, Properties()) Then GoTo Catch
308 If Not ScriptForge.SF_Utils._Validate(ObjectName,
"ObjectName
", V_STRING) Then GoTo Catch
312 ' Superclass or subclass property ?
313 If ScriptForge.SF_Array.Contains([_Super].Properties(), PropertyName) Then
314 GetProperty = [_Super].GetProperty(PropertyName)
315 ElseIf Len(ObjectName) =
0 Then
316 GetProperty = _PropertyGet(PropertyName)
318 GetProperty = _PropertyGet(PropertyName, ObjectName)
322 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
326 End Function
' SFDocuments.SF_FormDocument.GetProperty
328 REM -----------------------------------------------------------------------------
329 Public Function Methods() As Variant
330 ''' Return the list of public methods of the FormDocument service as an array
333 "CloseDocument
" _
334 ,
"Forms
" _
335 ,
"PrintOut
" _
338 End Function
' SFDocuments.SF_FormDocument.Methods
340 REM -----------------------------------------------------------------------------
341 Public Function PrintOut(Optional ByVal Pages As Variant _
342 , Optional ByVal Copies As Variant _
343 , Optional ByVal PrintBackground As Variant _
344 , Optional ByVal PrintBlankPages As Variant _
345 , Optional ByVal PrintEvenPages As Variant _
346 , Optional ByVal PrintOddPages As Variant _
347 , Optional ByVal PrintImages As Variant _
349 ''' Send the content of the document to the printer.
350 ''' The printer might be defined previously by default, by the user or by the SetPrinter() method
351 ''' Args:
352 ''' Pages: the pages to print as a string, like in the user interface. Example:
"1-
4;
10;
15-
18". Default = all pages
353 ''' Copies: the number of copies
354 ''' PrintBackground: print the background image when True (default)
355 ''' PrintBlankPages: when False (default), omit empty pages
356 ''' PrintEvenPages: print the left pages when True (default)
357 ''' PrintOddPages: print the right pages when True (default)
358 ''' PrintImages: print the graphic objects when True (default)
359 ''' Returns:
360 ''' True when successful
361 ''' Examples:
362 ''' oDoc.PrintOut(
"1-
4;
10;
15-
18", Copies :=
2, PrintImages := False)
364 Dim bPrint As Boolean
' Return value
365 Dim vPrintOptions As Variant
' com.sun.star.text.DocumentSettings
367 Const cstThisSub =
"SFDocuments.FormDocument.PrintOut
"
368 Const cstSubArgs =
"[Pages=
""""], [Copies=
1], [PrintBackground=True], [PrintBlankPages=False], [PrintEvenPages=True]
" _
369 & ", [PrintOddPages=True], [PrintImages=True]
"
371 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
375 If IsMissing(Pages) Or IsEmpty(Pages) Then Pages =
""
376 If IsMissing(Copies) Or IsEmpty(Copies) Then Copies =
1
377 If IsMissing(PrintBackground) Or IsEmpty(PrintBackground) Then PrintBackground = True
378 If IsMissing(PrintBlankPages) Or IsEmpty(PrintBlankPages) Then PrintBlankPages = False
379 If IsMissing(PrintEvenPages) Or IsEmpty(PrintEvenPages) Then PrintEvenPages = True
380 If IsMissing(PrintOddPages) Or IsEmpty(PrintOddPages) Then PrintOddPages = True
381 If IsMissing(PrintImages) Or IsEmpty(PrintImages) Then PrintImages = True
383 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
384 If Not _IsStillAlive() Then GoTo Finally
385 If Not ScriptForge.SF_Utils._Validate(Pages,
"Pages
", V_STRING) Then GoTo Finally
386 If Not ScriptForge.SF_Utils._Validate(Copies,
"Copies
", ScriptForge.V_NUMERIC) Then GoTo Finally
387 If Not ScriptForge.SF_Utils._Validate(PrintBackground,
"PrintBackground
", ScriptForge.V_BOOLEAN) Then GoTo Finally
388 If Not ScriptForge.SF_Utils._Validate(PrintBlankPages,
"PrintBlankPages
", ScriptForge.V_BOOLEAN) Then GoTo Finally
389 If Not ScriptForge.SF_Utils._Validate(PrintEvenPages,
"PrintEvenPages
", ScriptForge.V_BOOLEAN) Then GoTo Finally
390 If Not ScriptForge.SF_Utils._Validate(PrintOddPages,
"PrintOddPages
", ScriptForge.V_BOOLEAN) Then GoTo Finally
391 If Not ScriptForge.SF_Utils._Validate(PrintImages,
"PrintImages
", ScriptForge.V_BOOLEAN) Then GoTo Finally
395 vPrintOptions = _Component.createInstance(
"com.sun.star.text.DocumentSettings
")
397 .PrintPageBackground = PrintBackground
398 .PrintEmptyPages = PrintBlankPages
399 .PrintLeftPages = PrintEvenPages
400 .PrintRightPages = PrintOddPages
401 .PrintGraphics = PrintImages
402 .PrintDrawings = PrintImages
405 bPrint = [_Super].PrintOut(Pages, Copies, _Component)
409 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
413 End Function
' SFDocuments.SF_FormDocument.PrintOut
415 REM -----------------------------------------------------------------------------
416 Public Function Properties() As Variant
417 ''' Return the list or properties of the FormDocument class as an array
419 Properties = Array( _
420 "DocumentType
" _
421 ,
"IsBase
" _
422 ,
"IsCalc
" _
423 ,
"IsDraw
" _
424 ,
"IsFormDocument
" _
425 ,
"IsImpress
" _
426 ,
"IsMath
" _
427 ,
"Readonly
" _
428 ,
"XComponent
" _
431 End Function
' SFDocuments.SF_FormDocument.Properties
433 REM ======================================================= SUPERCLASS PROPERTIES
435 REM -----------------------------------------------------------------------------
436 Property Get IsBase() As Boolean
437 IsBase = [_Super].GetProperty(
"IsBase
")
438 End Property
' SFDocuments.SF_FormDocument.IsBase
440 REM -----------------------------------------------------------------------------
441 Property Get IsCalc() As Boolean
442 IsCalc = [_Super].GetProperty(
"IsCalc
")
443 End Property
' SFDocuments.SF_FormDocument.IsCalc
445 REM -----------------------------------------------------------------------------
446 Property Get IsDraw() As Boolean
447 IsDraw = [_Super].GetProperty(
"IsDraw
")
448 End Property
' SFDocuments.SF_FormDocument.IsDraw
450 REM -----------------------------------------------------------------------------
451 Property Get IsFormDocument() As Boolean
452 IsFormDocument = [_Super].GetProperty(
"IsFormDocument
")
453 End Property
' SFDocuments.SF_Writer.IsFormDocument
455 REM -----------------------------------------------------------------------------
456 Property Get IsImpress() As Boolean
457 IsImpress = [_Super].GetProperty(
"IsImpress
")
458 End Property
' SFDocuments.SF_FormDocument.IsImpress
460 REM -----------------------------------------------------------------------------
461 Property Get IsMath() As Boolean
462 IsMath = [_Super].GetProperty(
"IsMath
")
463 End Property
' SFDocuments.SF_FormDocument.IsMath
465 REM -----------------------------------------------------------------------------
466 Property Get Readonly() As Variant
467 Readonly = [_Super].GetProperty(
"Readonly
")
468 End Property
' SFDocuments.SF_FormDocument.Readonly
470 REM -----------------------------------------------------------------------------
471 Property Get XComponent() As Variant
472 XComponent = [_Super].GetProperty(
"XComponent
")
473 End Property
' SFDocuments.SF_FormDocument.XComponent
475 REM ========================================================== SUPERCLASS METHODS
477 REM -----------------------------------------------------------------------------
478 Public Function Activate() As Boolean
479 Activate = [_Super].Activate()
480 End Function
' SFDocuments.SF_FormDocument.Activate
482 REM -----------------------------------------------------------------------------
483 Public Function CreateMenu(Optional ByVal MenuHeader As Variant _
484 , Optional ByVal Before As Variant _
485 , Optional ByVal SubmenuChar As Variant _
487 Set CreateMenu = [_Super].CreateMenu(MenuHeader, Before, SubmenuChar)
488 End Function
' SFDocuments.SF_FormDocument.CreateMenu
490 REM -----------------------------------------------------------------------------
491 Public Sub Echo(Optional ByVal EchoOn As Variant _
492 , Optional ByVal Hourglass As Variant _
494 [_Super].Echo(EchoOn, Hourglass)
495 End Sub
' SFDocuments.SF_FormDocument.Echo
497 REM -----------------------------------------------------------------------------
498 Public Function ExportAsPDF(Optional ByVal FileName As Variant _
499 , Optional ByVal Overwrite As Variant _
500 , Optional ByVal Pages As Variant _
501 , Optional ByVal Password As Variant _
502 , Optional ByVal Watermark As Variant _
504 ExportAsPDF = [_Super].ExportAsPDF(FileName, Overwrite, Pages, Password, Watermark)
505 End Function
' SFDocuments.SF_FormDocument.ExportAsPDF
507 REM -----------------------------------------------------------------------------
508 Public Function RemoveMenu(Optional ByVal MenuHeader As Variant) As Boolean
509 RemoveMenu = [_Super].RemoveMenu(MenuHeader)
510 End Function
' SFDocuments.SF_FormDocument.RemoveMenu
512 REM -----------------------------------------------------------------------------
513 Public Sub RunCommand(Optional ByVal Command As Variant _
514 , ParamArray Args As Variant _
516 [_Super].RunCommand(Command, Args)
517 End Sub
' SFDocuments.SF_FormDocument.RunCommand
519 REM -----------------------------------------------------------------------------
520 Public Function SaveCopyAs(Optional ByVal FileName As Variant _
521 , Optional ByVal Overwrite As Variant _
522 , Optional ByVal Password As Variant _
523 , Optional ByVal FilterName As Variant _
524 , Optional ByVal FilterOptions As Variant _
526 SaveCopyAs = [_Super].SaveCopyAs(FileName, Overwrite, Password, FilterName, FilterOptions)
527 End Function
' SFDocuments.SF_FormDocument.SaveCopyAs
529 REM -----------------------------------------------------------------------------
530 Public Function SetPrinter(Optional ByVal Printer As Variant _
531 , Optional ByVal Orientation As Variant _
532 , Optional ByVal PaperFormat As Variant _
534 SetPrinter = [_Super].SetPrinter(Printer, Orientation, PaperFormat)
535 End Function
' SFDocuments.SF_FormDocument.SetPrinter
537 REM -----------------------------------------------------------------------------
538 Public Function Toolbars(Optional ByVal ToolbarName As Variant) As Variant
539 Toolbars = [_Super].Toolbars(ToolbarName)
540 End Function
' SFDocuments.SF_FormDocument.Toolbars
542 REM =========================================================== PRIVATE FUNCTIONS
544 REM -----------------------------------------------------------------------------
545 Private Function _FileIdent() As String
546 ''' Returns a file identification from the information that is currently available
547 ''' Useful e.g. for display in error messages
549 _FileIdent = [_Super]._FileIdent()
551 End Function
' SFDocuments.SF_FormDocument._FileIdent
553 REM -----------------------------------------------------------------------------
554 Public Sub _Initialize()
555 ''' Achieve the creation of a SF_Form instance
556 ''' - the database file
557 ''' - the database connection
558 ''' the internal and external names
560 Dim oBase As Object
' A temporary Base instance
562 On Local Error GoTo Catch
565 ' Base file where form document is stored
566 Set _BaseComponent = _Component.Parent
568 ' Connection arguments
569 Set _DataSource = _BaseComponent.DataSource
572 _Password = .Password
575 ' External and internal names
576 _PersistentName = ScriptForge.SF_Utils._GetPropertyValue(_Component.Args,
"HierarchicalDocumentName
")
577 Set oBase = New SF_Base
' Only to be able to call the _FindByPersistentName() method
579 Set _FormDocument = ._FindByPersistentName(_BaseComponent.getFormDocuments(), _PersistentName)
580 _HierarchicalName = _FormDocument.HierarchicalName
581 Set oBase = .Dispose()
587 On Local Error GoTo
0
589 End Sub
' SFDocuments.SF_FormDocument._Initialize
591 REM -----------------------------------------------------------------------------
592 Private Function _IsStillAlive(Optional ByVal pbForUpdate As Boolean _
593 , Optional ByVal pbError As Boolean _
595 ''' Returns True if the document has not been closed manually or incidentally since the last use
596 ''' If dead the actual instance is disposed. The execution is cancelled when pbError = True (default)
597 ''' Args:
598 ''' pbForUpdate: if True (default = False), check additionally if document is open for editing
599 ''' pbError: if True (default), raise a fatal error
601 Dim bAlive As Boolean
' Return value
603 If IsMissing(pbForUpdate) Then pbForUpdate = False
604 If IsMissing(pbError) Then pbError = True
607 bAlive = [_Super]._IsStillAlive(pbForUpdate, pbError)
610 _IsStillAlive = bAlive
612 End Function
' SFDocuments.SF_FormDocument._IsStillAlive
614 REM -----------------------------------------------------------------------------
615 Private Function _PropertyGet(Optional ByVal psProperty As String _
616 , Optional ByVal pvArg As Variant _
618 ''' Return the value of the named property
619 ''' Args:
620 ''' psProperty: the name of the property
622 Dim cstThisSub As String
623 Const cstSubArgs =
""
627 cstThisSub =
"SFDocuments.FormDocument.get
" & psProperty
628 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
629 If Not _IsStillAlive() Then GoTo Finally
631 Select Case psProperty
637 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
639 End Function
' SFDocuments.SF_FormDocument._PropertyGet
641 REM -----------------------------------------------------------------------------
642 Private Function _Repr() As String
643 ''' Convert the SF_FormDocument instance to a readable string, typically for debugging purposes (DebugPrint ...)
644 ''' Args:
645 ''' Return:
646 ''' "[DOCUMENT]: Type/File
"
648 _Repr =
"[FormDocument]:
" & [_Super]._FileIdent()
650 End Function
' SFDocuments.SF_FormDocument._Repr
652 REM ============================================ END OF SFDOCUMENTS.SF_FORMDOCUMENT