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
"
68 Private Const DBCONNECTERROR =
"DBCONNECTERROR
"
70 REM ============================================================= PRIVATE MEMBERS
72 Private [Me] As Object
73 Private [_Parent] As Object
' Unused
74 Private [_Super] As Object
' Document superclass, which the current instance is a subclass of
75 Private ObjectType As String
' Must be FormDocument
76 Private ServiceName As String
79 Private _Component As Object
' com.sun.star.lang.XComponent
80 Private _BaseComponent As Object
' com.sun.star.comp.dba.ODatabaseDocument
81 Private _FormDocument As Object
' com.sun.star.comp.sdb.Content
83 ' Form document description
84 Private _PersistentName As String
' Typically Objxx
85 Private _HierarchicalName As String
86 Private _DataSource As Object
' com.sun.star.sdbc.XDataSource
87 Private _User As String
' Credentials
88 Private _Password As String
90 REM ============================================================ MODULE CONSTANTS
92 Const ISBASEFORM =
3 ' Form is stored in a Form document
94 REM ====================================================== CONSTRUCTOR/DESTRUCTOR
96 REM -----------------------------------------------------------------------------
97 Private Sub Class_Initialize()
99 Set [_Parent] = Nothing
100 Set [_Super] = Nothing
101 ObjectType =
"FormDocument
"
102 ServiceName =
"SFDocuments.FormDocument
"
103 Set _Component = Nothing
104 Set _BaseComponent = Nothing
105 Set _FormDocument = Nothing
106 Set _DataSource = Nothing
107 _PersistentName =
""
108 _HierarchicalName =
""
109 End Sub
' SFDocuments.SF_FormDocument Constructor
111 REM -----------------------------------------------------------------------------
112 Private Sub Class_Terminate()
113 Call Class_Initialize()
114 End Sub
' 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
' SFDocuments.SF_FormDocument Explicit Destructor
123 REM ================================================================== PROPERTIES
125 REM ===================================================================== METHODS
127 REM -----------------------------------------------------------------------------
128 Public Function CloseDocument() As Boolean
129 ''' Close the form document and dispose the actual instance
130 ''' Args:
131 ''' Returns:
132 ''' True if closure is successful
133 ''' Example:
134 ''' myFormDoc.CloseDocument()
136 Dim bClose As Boolean
' Return value
137 Dim oContainer As Object
' com.sun.star.awt.XWindow
138 Const cstThisSub =
"SFDocuments.FormDocument.CloseDocument
"
139 Const cstSubArgs =
""
141 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
145 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
146 If Not _IsStillAlive() Then GoTo Finally
149 _FormDocument.close()
154 CloseDocument = bClose
155 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
159 End Function
' SFDocuments.SF_FormDocument.CloseDocument
161 REM -----------------------------------------------------------------------------
162 Public Function Forms(Optional ByVal Form As Variant) As Variant
163 ''' Return either
164 ''' - the list of the Forms contained in the form document
165 ''' - a SFDocuments.Form object based on its name or its index
166 ''' Args:
167 ''' Form: a form stored in the document given by its name or its index
168 ''' When absent, the list of available forms is returned
169 ''' To get the first (unique ?) form stored in the form document, set Form =
0
170 ''' Exceptions:
171 ''' BASEFORMNOTFOUNDERROR Form not found
172 ''' Returns:
173 ''' A zero-based array of strings if Form is absent
174 ''' An instance of the SF_Form class if Form exists
175 ''' Example:
176 ''' Dim myForm As Object, myList As Variant
177 ''' myList = oDoc.Forms()
178 ''' Set myForm = oDoc.Forms(
"myForm
")
180 Dim oForm As Object
' The new Form class instance
181 Dim oMainForm As Object
' com.sun.star.comp.sdb.Content
182 Dim oXForm As Object
' com.sun.star.form.XForm
183 Dim vFormNames As Variant
' Array of form names
184 Dim oForms As Object
' Forms collection
185 Const cstDrawPage =
0 ' Only
1 drawpage in a FormDocument document
187 Const cstThisSub =
"SFDocuments.FormDocument.Forms
"
188 Const cstSubArgs =
"[Form=
""""]
"
190 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
193 If IsMissing(Form) Or IsEmpty(Form) Then Form =
""
194 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
195 If Not _IsStillAlive() Then GoTo Finally
196 If Not ScriptForge.SF_Utils._Validate(Form,
"Form
", Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally
200 ' 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
' Return the list of valid form names
207 If VarType(Form) = V_STRING Then
' 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
' Find the form by index
211 If Form
< 0 Or Form
>= oForms.Count Then GoTo CatchNotFound
212 Set oXForm = oForms.getByIndex(Form)
214 ' Create the new Form class instance
215 Set oForm = SF_Register._NewForm(oXForm)
217 Set .[_Parent] = [Me]
218 ._FormType = ISBASEFORM
219 Set ._Component = _Component
220 Set ._BaseComponent = _BaseComponent
221 ._FormDocumentName = _HierarchicalName
222 ._FormDocument = _FormDocument
229 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
234 ScriptForge.SF_Exception.RaiseFatal(BASEFORMNOTFOUNDERROR, Form, _FileIdent())
235 End Function
' SFDocuments.SF_FormDocument.Forms
237 REM -----------------------------------------------------------------------------
238 Public Function GetDatabase(Optional ByVal User As Variant _
239 , Optional ByVal Password As Variant _
241 ''' Returns a Database instance (service = SFDatabases.Database) giving access
242 ''' to the execution of SQL commands on the database defined and/or stored in
243 ''' the actual form document
244 ''' Args:
245 ''' User, Password: the login parameters as strings. Defaults =
""
246 ''' Returns:
247 ''' A SFDatabases.Database instance or Nothing
248 ''' Exceptions:
249 ''' DBCONNECTERROR The database could not be connected, credentials are probably wrong
250 ''' Example:
251 ''' Dim myDb As Object
252 ''' Set myDb = oFormDoc.GetDatabase()
254 Dim oDatabase As Object
' Return value
255 Const cstThisSub =
"SFDocuments.FormDocument.GetDatabase
"
256 Const cstSubArgs =
"[User=
""""], [Password=
""""]
"
258 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
259 Set oDatabase = Nothing
262 If IsMissing(User) Or IsEmpty(User) Then User =
""
263 If IsMissing(Password) Or IsEmpty(Password) Then Password =
""
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,
"User
", V_STRING) Then GoTo Finally
267 If Not ScriptForge.SF_Utils._Validate(Password,
"Password
", V_STRING) Then GoTo Finally
271 If IsNull(_DataSource) Then GoTo CatchConnect
272 Set oDatabase = ScriptForge.SF_Services.CreateScriptService(
"SFDatabases.DatabaseFromDocument
" _
273 , _DataSource, Iif(User =
"", _User, User), Iif(Password =
"", _Password, Password))
274 If IsNull(oDatabase) Then GoTo CatchConnect
275 oDatabase._Location = _DataSource.Name
278 Set GetDatabase = oDatabase
279 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
284 ScriptForge.SF_Exception.RaiseFatal(DBCONNECTERROR,
"User
", User,
"Password
", Password, [_Super]._FileIdent())
286 End Function
' SFDocuments.SF_FormDocument.GetDatabase
288 REM -----------------------------------------------------------------------------
289 Public Function GetProperty(Optional ByVal PropertyName As Variant _
290 , Optional ObjectName As Variant _
292 ''' Return the actual value of the given property
293 ''' Args:
294 ''' PropertyName: the name of the property as a string
295 ''' ObjectName: a sheet or range name
296 ''' Returns:
297 ''' The actual value of the property
298 ''' Exceptions:
299 ''' ARGUMENTERROR The property does not exist
301 Const cstThisSub =
"SFDocuments.FormDocument.GetProperty
"
302 Const cstSubArgs =
""
304 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
308 If IsMissing(ObjectName) Or IsEmpty(ObjectName) Then ObjectName =
""
309 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
310 If Not ScriptForge.SF_Utils._Validate(PropertyName,
"PropertyName
", V_STRING, Properties()) Then GoTo Catch
311 If Not ScriptForge.SF_Utils._Validate(ObjectName,
"ObjectName
", V_STRING) Then GoTo Catch
315 ' 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)
321 GetProperty = _PropertyGet(PropertyName, ObjectName)
325 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
329 End Function
' SFDocuments.SF_FormDocument.GetProperty
331 REM -----------------------------------------------------------------------------
332 Public Function Methods() As Variant
333 ''' Return the list of public methods of the FormDocument service as an array
336 "CloseDocument
" _
337 ,
"Forms
" _
338 ,
"GetDatabase
" _
339 ,
"PrintOut
" _
342 End Function
' 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 _
353 ''' Send the content of the document to the printer.
354 ''' The printer might be defined previously by default, by the user or by the SetPrinter() method
355 ''' Args:
356 ''' Pages: the pages to print as a string, like in the user interface. Example:
"1-
4;
10;
15-
18". Default = all pages
357 ''' Copies: the number of copies
358 ''' PrintBackground: print the background image when True (default)
359 ''' PrintBlankPages: when False (default), omit empty pages
360 ''' PrintEvenPages: print the left pages when True (default)
361 ''' PrintOddPages: print the right pages when True (default)
362 ''' PrintImages: print the graphic objects when True (default)
363 ''' Returns:
364 ''' True when successful
365 ''' Examples:
366 ''' oDoc.PrintOut(
"1-
4;
10;
15-
18", Copies :=
2, PrintImages := False)
368 Dim bPrint As Boolean
' Return value
369 Dim vPrintOptions As Variant
' com.sun.star.text.DocumentSettings
371 Const cstThisSub =
"SFDocuments.FormDocument.PrintOut
"
372 Const cstSubArgs =
"[Pages=
""""], [Copies=
1], [PrintBackground=True], [PrintBlankPages=False], [PrintEvenPages=True]
" _
373 & ", [PrintOddPages=True], [PrintImages=True]
"
375 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
379 If IsMissing(Pages) Or IsEmpty(Pages) Then Pages =
""
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,
"Pages
", V_STRING) Then GoTo Finally
390 If Not ScriptForge.SF_Utils._Validate(Copies,
"Copies
", ScriptForge.V_NUMERIC) Then GoTo Finally
391 If Not ScriptForge.SF_Utils._Validate(PrintBackground,
"PrintBackground
", ScriptForge.V_BOOLEAN) Then GoTo Finally
392 If Not ScriptForge.SF_Utils._Validate(PrintBlankPages,
"PrintBlankPages
", ScriptForge.V_BOOLEAN) Then GoTo Finally
393 If Not ScriptForge.SF_Utils._Validate(PrintEvenPages,
"PrintEvenPages
", ScriptForge.V_BOOLEAN) Then GoTo Finally
394 If Not ScriptForge.SF_Utils._Validate(PrintOddPages,
"PrintOddPages
", ScriptForge.V_BOOLEAN) Then GoTo Finally
395 If Not ScriptForge.SF_Utils._Validate(PrintImages,
"PrintImages
", ScriptForge.V_BOOLEAN) Then GoTo Finally
399 vPrintOptions = _Component.createInstance(
"com.sun.star.text.DocumentSettings
")
401 .PrintPageBackground = PrintBackground
402 .PrintEmptyPages = PrintBlankPages
403 .PrintLeftPages = PrintEvenPages
404 .PrintRightPages = PrintOddPages
405 .PrintGraphics = PrintImages
406 .PrintDrawings = PrintImages
409 bPrint = [_Super].PrintOut(Pages, Copies, _Component)
413 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
417 End Function
' SFDocuments.SF_FormDocument.PrintOut
419 REM -----------------------------------------------------------------------------
420 Public Function Properties() As Variant
421 ''' Return the list or properties of the FormDocument class as an array
423 Properties = Array( _
424 "DocumentType
" _
425 ,
"FileSystem
" _
426 ,
"IsAlive
" _
427 ,
"IsBase
" _
428 ,
"IsCalc
" _
429 ,
"IsDraw
" _
430 ,
"IsFormDocument
" _
431 ,
"IsImpress
" _
432 ,
"IsMath
" _
433 ,
"Readonly
" _
434 ,
"StyleFamilies
" _
435 ,
"XComponent
" _
436 ,
"XDocumentSettings
" _
439 End Function
' SFDocuments.SF_FormDocument.Properties
441 REM ======================================================= SUPERCLASS PROPERTIES
443 REM -----------------------------------------------------------------------------
444 Property Get FileSystem() As String
445 FileSystem = [_Super].GetProperty(
"FileSystem
")
446 End Property
' SFDocuments.SF_FormDocument.FileSystem
448 REM -----------------------------------------------------------------------------
449 Property Get IsAlive() As Boolean
450 IsAlive = [_Super].GetProperty(
"IsAlive
")
451 End Property
' SFDocuments.SF_FormDocument.IsAlive
453 REM -----------------------------------------------------------------------------
454 Property Get IsBase() As Boolean
455 IsBase = [_Super].GetProperty(
"IsBase
")
456 End Property
' SFDocuments.SF_FormDocument.IsBase
458 REM -----------------------------------------------------------------------------
459 Property Get IsCalc() As Boolean
460 IsCalc = [_Super].GetProperty(
"IsCalc
")
461 End Property
' SFDocuments.SF_FormDocument.IsCalc
463 REM -----------------------------------------------------------------------------
464 Property Get IsDraw() As Boolean
465 IsDraw = [_Super].GetProperty(
"IsDraw
")
466 End Property
' SFDocuments.SF_FormDocument.IsDraw
468 REM -----------------------------------------------------------------------------
469 Property Get IsFormDocument() As Boolean
470 IsFormDocument = [_Super].GetProperty(
"IsFormDocument
")
471 End Property
' SFDocuments.SF_Writer.IsFormDocument
473 REM -----------------------------------------------------------------------------
474 Property Get IsImpress() As Boolean
475 IsImpress = [_Super].GetProperty(
"IsImpress
")
476 End Property
' SFDocuments.SF_FormDocument.IsImpress
478 REM -----------------------------------------------------------------------------
479 Property Get IsMath() As Boolean
480 IsMath = [_Super].GetProperty(
"IsMath
")
481 End Property
' SFDocuments.SF_FormDocument.IsMath
483 REM -----------------------------------------------------------------------------
484 Property Get Readonly() As Variant
485 Readonly = [_Super].GetProperty(
"Readonly
")
486 End Property
' SFDocuments.SF_FormDocument.Readonly
488 REM -----------------------------------------------------------------------------
489 Property Get StyleFamilies() As Variant
490 StyleFamilies = [_Super].GetProperty(
"StyleFamilies
")
491 End Property
' SFDocuments.SF_FormDocument.StyleFamilies
493 REM -----------------------------------------------------------------------------
494 Property Get XComponent() As Variant
495 XComponent = [_Super].GetProperty(
"XComponent
")
496 End Property
' SFDocuments.SF_FormDocument.XComponent
498 REM -----------------------------------------------------------------------------
499 Property Get XDocumentSettings() As Variant
500 XDocumentSettings = [_Super].GetProperty(
"XDocumentSettings
")
501 End Property
' SFDocuments.SF_FormDocument.XDocumentSettings
503 REM ========================================================== SUPERCLASS METHODS
505 REM -----------------------------------------------------------------------------
506 Public Function Activate() As Boolean
507 Activate = [_Super].Activate()
508 End Function
' SFDocuments.SF_FormDocument.Activate
510 REM -----------------------------------------------------------------------------
511 Public Function ContextMenus(Optional ByVal ContextMenuName As Variant _
512 , Optional ByVal SubmenuChar As Variant _
514 ContextMenus = [_Super].ContextMenus(ContextMenuName, SubmenuChar)
515 End Function
' 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 _
522 Set CreateMenu = [_Super].CreateMenu(MenuHeader, Before, SubmenuChar)
523 End Function
' 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
' 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 _
539 ExportAsPDF = [_Super].ExportAsPDF(FileName, Overwrite, Pages, Password, Watermark)
540 End Function
' 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
' 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
' 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 _
561 SaveCopyAs = [_Super].SaveCopyAs(FileName, Overwrite, Password, FilterName, FilterOptions)
562 End Function
' 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 _
569 SetPrinter = [_Super].SetPrinter(Printer, Orientation, PaperFormat)
570 End Function
' 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 _
580 Styles = [_Super].Styles(Family, NamePattern, Used, UserDefined, ParentStyle, Category)
581 End Function
' 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
' SFDocuments.SF_FormDocument.Toolbars
588 REM -----------------------------------------------------------------------------
589 Public Function XStyle(Optional ByVal Family As Variant _
590 , Optional ByVal StyleName As variant _
592 Set XStyle = [_Super].XStyle(Family, StyleName)
593 End Function
' SFDocuments.SF_FormDocument.XStyle
595 REM =========================================================== PRIVATE FUNCTIONS
597 REM -----------------------------------------------------------------------------
598 Private Function _FileIdent() As String
599 ''' Returns a file identification from the information that is currently available
600 ''' Useful e.g. for display in error messages
602 _FileIdent = [_Super]._FileIdent()
604 End Function
' SFDocuments.SF_FormDocument._FileIdent
606 REM -----------------------------------------------------------------------------
607 Public Sub _Initialize()
608 ''' Achieve the creation of a SF_Form instance
609 ''' - the database file
610 ''' - the database connection
611 ''' the internal and external names
613 Dim oBase As Object
' A temporary Base instance
615 On Local Error GoTo Catch
618 ' Base file where form document is stored
619 Set _BaseComponent = _Component.Parent
621 ' Connection arguments
622 Set _DataSource = _BaseComponent.DataSource
625 _Password = .Password
628 ' External and internal names
629 _PersistentName = ScriptForge.SF_Utils._GetPropertyValue(_Component.Args,
"HierarchicalDocumentName
")
630 Set oBase = New SF_Base
' Only to be able to call the _FindByPersistentName() method
632 Set _FormDocument = ._FindByPersistentName(_BaseComponent.getFormDocuments(), _PersistentName)
633 _HierarchicalName = _FormDocument.HierarchicalName
634 Set oBase = .Dispose()
640 On Local Error GoTo
0
642 End Sub
' SFDocuments.SF_FormDocument._Initialize
644 REM -----------------------------------------------------------------------------
645 Private Function _IsStillAlive(Optional ByVal pbForUpdate As Boolean _
646 , Optional ByVal pbError As Boolean _
648 ''' Returns True if the document has not been closed manually or incidentally since the last use
649 ''' If dead the actual instance is disposed. The execution is cancelled when pbError = True (default)
650 ''' Args:
651 ''' pbForUpdate: if True (default = False), check additionally if document is open for editing
652 ''' pbError: if True (default), raise a fatal error
654 Dim bAlive As Boolean
' Return value
656 If IsMissing(pbForUpdate) Then pbForUpdate = False
657 If IsMissing(pbError) Then pbError = True
660 bAlive = [_Super]._IsStillAlive(pbForUpdate, pbError)
663 _IsStillAlive = bAlive
665 End Function
' SFDocuments.SF_FormDocument._IsStillAlive
667 REM -----------------------------------------------------------------------------
668 Private Function _PropertyGet(Optional ByVal psProperty As String _
669 , Optional ByVal pvArg As Variant _
671 ''' Return the value of the named property
672 ''' Args:
673 ''' psProperty: the name of the property
675 Dim cstThisSub As String
676 Const cstSubArgs =
""
680 cstThisSub =
"SFDocuments.FormDocument.get
" & psProperty
681 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
682 If Not _IsStillAlive() Then GoTo Finally
684 Select Case psProperty
690 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
692 End Function
' SFDocuments.SF_FormDocument._PropertyGet
694 REM -----------------------------------------------------------------------------
695 Private Function _Repr() As String
696 ''' Convert the SF_FormDocument instance to a readable string, typically for debugging purposes (DebugPrint ...)
697 ''' Args:
698 ''' Return:
699 ''' "[DOCUMENT]: Type/File
"
701 _Repr =
"[FormDocument]:
" & [_Super]._FileIdent()
703 End Function
' SFDocuments.SF_FormDocument._Repr
705 REM ============================================ END OF SFDOCUMENTS.SF_FORMDOCUMENT