connectivity: fix return column type "DataType::SQLNULL"
[LibreOffice.git] / wizards / source / sfdocuments / SF_Writer.xba
blob4acdd5c750f02632e105e29bfd53580c82d9f68d
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_Writer" 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_Writer
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_Writer module is focused on :
30 &apos;&apos;&apos; TBD
31 &apos;&apos;&apos;
32 &apos;&apos;&apos; The current module is closely related to the &quot;UI&quot; service of the ScriptForge library
33 &apos;&apos;&apos;
34 &apos;&apos;&apos; Service invocation examples:
35 &apos;&apos;&apos; 1) From the UI service
36 &apos;&apos;&apos; Dim ui As Object, oDoc As Object
37 &apos;&apos;&apos; Set ui = CreateScriptService(&quot;UI&quot;)
38 &apos;&apos;&apos; Set oDoc = ui.CreateDocument(&quot;Writer&quot;, ...)
39 &apos;&apos;&apos; &apos; or Set oDoc = ui.OpenDocument(&quot;C:\Me\MyFile.odt&quot;)
40 &apos;&apos;&apos; 2) Directly if the document is already opened
41 &apos;&apos;&apos; Dim oDoc As Object
42 &apos;&apos;&apos; Set oDoc = CreateScriptService(&quot;SFDocuments.Writer&quot;, &quot;Untitled 1&quot;) &apos; Default = ActiveWindow
43 &apos;&apos;&apos; &apos; or Set oDoc = CreateScriptService(&quot;SFDocuments.Writer&quot;, &quot;Untitled 1&quot;) &apos; Untitled 1 is presumed a Writer document
44 &apos;&apos;&apos; &apos; The substring &quot;SFDocuments.&quot; in the service name is optional
45 &apos;&apos;&apos;
46 &apos;&apos;&apos; Definitions:
47 &apos;&apos;&apos; TBD
48 &apos;&apos;&apos;
49 &apos;&apos;&apos; Detailed user documentation:
50 &apos;&apos;&apos; https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/SF_Writer.html?DbPAR=BASIC
51 &apos;&apos;&apos;
52 &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;
54 REM ================================================================== EXCEPTIONS
56 Private Const WRITERFORMNOTFOUNDERROR = &quot;WRITERFORMNOTFOUNDERROR&quot;
58 REM ============================================================= PRIVATE MEMBERS
60 Private [Me] As Object
61 Private [_Parent] As Object
62 Private [_Super] As Object &apos; Document superclass, which the current instance is a subclass of
63 Private ObjectType As String &apos; Must be WRITER
64 Private ServiceName As String
66 &apos; Window component
67 Private _Component As Object &apos; com.sun.star.lang.XComponent
69 REM ============================================================ MODULE CONSTANTS
71 REM ====================================================== CONSTRUCTOR/DESTRUCTOR
73 REM -----------------------------------------------------------------------------
74 Private Sub Class_Initialize()
75 Set [Me] = Nothing
76 Set [_Parent] = Nothing
77 Set [_Super] = Nothing
78 ObjectType = &quot;WRITER&quot;
79 ServiceName = &quot;SFDocuments.Writer&quot;
80 Set _Component = Nothing
81 End Sub &apos; SFDocuments.SF_Writer Constructor
83 REM -----------------------------------------------------------------------------
84 Private Sub Class_Terminate()
85 Call Class_Initialize()
86 End Sub &apos; SFDocuments.SF_Writer Destructor
88 REM -----------------------------------------------------------------------------
89 Public Function Dispose() As Variant
90 If Not IsNull([_Super]) Then Set [_Super] = [_Super].Dispose()
91 Call Class_Terminate()
92 Set Dispose = Nothing
93 End Function &apos; SFDocuments.SF_Writer Explicit Destructor
95 REM ================================================================== PROPERTIES
97 REM ===================================================================== METHODS
99 REM -----------------------------------------------------------------------------
100 Public Function Forms(Optional ByVal Form As Variant) As Variant
101 &apos;&apos;&apos; Return either
102 &apos;&apos;&apos; - the list of the Forms contained in the form document
103 &apos;&apos;&apos; - a SFDocuments.Form object based on its name or its index
104 &apos;&apos;&apos; Args:
105 &apos;&apos;&apos; Form: a form stored in the document given by its name or its index
106 &apos;&apos;&apos; When absent, the list of available forms is returned
107 &apos;&apos;&apos; To get the first (unique ?) form stored in the form document, set Form = 0
108 &apos;&apos;&apos; Exceptions:
109 &apos;&apos;&apos; WRITERFORMNOTFOUNDERROR Form not found
110 &apos;&apos;&apos; Returns:
111 &apos;&apos;&apos; A zero-based array of strings if Form is absent
112 &apos;&apos;&apos; An instance of the SF_Form class if Form exists
113 &apos;&apos;&apos; Example:
114 &apos;&apos;&apos; Dim myForm As Object, myList As Variant
115 &apos;&apos;&apos; myList = oDoc.Forms()
116 &apos;&apos;&apos; Set myForm = oDoc.Forms(&quot;myForm&quot;)
118 Dim oForm As Object &apos; The new Form class instance
119 Dim oMainForm As Object &apos; com.sun.star.comp.sdb.Content
120 Dim oXForm As Object &apos; com.sun.star.form.XForm
121 Dim vFormNames As Variant &apos; Array of form names
122 Dim oForms As Object &apos; Forms collection
123 Const cstDrawPage = 0 &apos; Only 1 drawpage in a Writer document
125 Const cstThisSub = &quot;SFDocuments.Writer.Forms&quot;
126 Const cstSubArgs = &quot;[Form=&quot;&quot;&quot;&quot;]&quot;
128 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
130 Check:
131 If IsMissing(Form) Or IsEmpty(Form) Then Form = &quot;&quot;
132 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
133 If Not _IsStillAlive() Then GoTo Finally
134 If Not ScriptForge.SF_Utils._Validate(Form, &quot;Form&quot;, Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally
135 End If
137 Try:
138 &apos; Start from the document component and go down to forms
139 Set oForms = _Component.DrawPages(cstDrawPage).Forms
140 vFormNames = oForms.getElementNames()
142 If Len(Form) = 0 Then &apos; Return the list of valid form names
143 Forms = vFormNames
144 Else
145 If VarType(Form) = V_STRING Then &apos; Find the form by name
146 If Not ScriptForge.SF_Array.Contains(vFormNames, Form, CaseSensitive := True) Then GoTo CatchNotFound
147 Set oXForm = oForms.getByName(Form)
148 Else &apos; Find the form by index
149 If Form &lt; 0 Or Form &gt;= oForms.Count Then GoTo CatchNotFound
150 Set oXForm = oForms.getByIndex(Form)
151 End If
152 &apos; Create the new Form class instance
153 Set oForm = SF_Register._NewForm(oXForm)
154 With oForm
155 Set .[_Parent] = [Me]
156 ._FormType = ISDOCFORM
157 Set ._Component = _Component
158 ._Initialize()
159 End With
160 Set Forms = oForm
161 End If
163 Finally:
164 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
165 Exit Function
166 Catch:
167 GoTo Finally
168 CatchNotFound:
169 ScriptForge.SF_Exception.RaiseFatal(WRITERFORMNOTFOUNDERROR, Form, _FileIdent())
170 End Function &apos; SFDocuments.SF_Writer.Forms
172 REM -----------------------------------------------------------------------------
173 Public Function GetProperty(Optional ByVal PropertyName As Variant _
174 , Optional ObjectName As Variant _
175 ) As Variant
176 &apos;&apos;&apos; Return the actual value of the given property
177 &apos;&apos;&apos; Args:
178 &apos;&apos;&apos; PropertyName: the name of the property as a string
179 &apos;&apos;&apos; ObjectName: a sheet or range name
180 &apos;&apos;&apos; Returns:
181 &apos;&apos;&apos; The actual value of the property
182 &apos;&apos;&apos; Exceptions:
183 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
185 Const cstThisSub = &quot;SFDocuments.Writer.GetProperty&quot;
186 Const cstSubArgs = &quot;&quot;
188 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
189 GetProperty = Null
191 Check:
192 If IsMissing(ObjectName) Or IsEmpty(ObjectName) Then ObjectName = &quot;&quot;
193 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
194 If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
195 If Not ScriptForge.SF_Utils._Validate(ObjectName, &quot;ObjectName&quot;, V_STRING) Then GoTo Catch
196 End If
198 Try:
199 &apos; Superclass or subclass property ?
200 If ScriptForge.SF_Array.Contains([_Super].Properties(), PropertyName) Then
201 GetProperty = [_Super].GetProperty(PropertyName)
202 ElseIf Len(ObjectName) = 0 Then
203 GetProperty = _PropertyGet(PropertyName)
204 Else
205 GetProperty = _PropertyGet(PropertyName, ObjectName)
206 End If
208 Finally:
209 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
210 Exit Function
211 Catch:
212 GoTo Finally
213 End Function &apos; SFDocuments.SF_Writer.GetProperty
215 REM -----------------------------------------------------------------------------
216 Public Function Methods() As Variant
217 &apos;&apos;&apos; Return the list of public methods of the Writer service as an array
219 Methods = Array( _
220 &quot;Activate&quot; _
221 , &quot;CloseDocument&quot; _
222 , &quot;ExportAsPDF&quot; _
223 , &quot;Forms&quot; _
224 , &quot;PrintOut&quot; _
225 , &quot;RunCommand&quot; _
226 , &quot;Save&quot; _
227 , &quot;SaveAs&quot; _
228 , &quot;SaveCopyAs&quot; _
229 , &quot;SetPrinter&quot; _
232 End Function &apos; SFDocuments.SF_Writer.Methods
234 REM -----------------------------------------------------------------------------
235 Public Function PrintOut(Optional ByVal Pages As Variant _
236 , Optional ByVal Copies As Variant _
237 , Optional ByVal PrintBackground As Variant _
238 , Optional ByVal PrintBlankPages As Variant _
239 , Optional ByVal PrintEvenPages As Variant _
240 , Optional ByVal PrintOddPages As Variant _
241 , Optional ByVal PrintImages As Variant _
242 ) As Boolean
243 &apos;&apos;&apos; Send the content of the document to the printer.
244 &apos;&apos;&apos; The printer might be defined previously by default, by the user or by the SetPrinter() method
245 &apos;&apos;&apos; Args:
246 &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
247 &apos;&apos;&apos; Copies: the number of copies
248 &apos;&apos;&apos; PrintBackground: print the background image when True (default)
249 &apos;&apos;&apos; PrintBlankPages: when False (default), omit empty pages
250 &apos;&apos;&apos; PrintEvenPages: print the left pages when True (default)
251 &apos;&apos;&apos; PrintOddPages: print the right pages when True (default)
252 &apos;&apos;&apos; PrintImages: print the graphic objects when True (default)
253 &apos;&apos;&apos; Returns:
254 &apos;&apos;&apos; True when successful
255 &apos;&apos;&apos; Examples:
256 &apos;&apos;&apos; oDoc.PrintOut(&quot;1-4;10;15-18&quot;, Copies := 2, PrintImages := False)
258 Dim bPrint As Boolean &apos; Return value
259 Dim vPrintOptions As Variant &apos; com.sun.star.text.DocumentSettings
261 Const cstThisSub = &quot;SFDocuments.Writer.PrintOut&quot;
262 Const cstSubArgs = &quot;[Pages=&quot;&quot;&quot;&quot;], [Copies=1], [PrintBackground=True], [PrintBlankPages=False], [PrintEvenPages=True]&quot; _
263 &amp; &quot;, [PrintOddPages=True], [PrintImages=True]&quot;
265 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
266 bPrint = False
268 Check:
269 If IsMissing(Pages) Or IsEmpty(Pages) Then Pages = &quot;&quot;
270 If IsMissing(Copies) Or IsEmpty(Copies) Then Copies = 1
271 If IsMissing(PrintBackground) Or IsEmpty(PrintBackground) Then PrintBackground = True
272 If IsMissing(PrintBlankPages) Or IsEmpty(PrintBlankPages) Then PrintBlankPages = False
273 If IsMissing(PrintEvenPages) Or IsEmpty(PrintEvenPages) Then PrintEvenPages = True
274 If IsMissing(PrintOddPages) Or IsEmpty(PrintOddPages) Then PrintOddPages = True
275 If IsMissing(PrintImages) Or IsEmpty(PrintImages) Then PrintImages = True
277 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
278 If Not _IsStillAlive() Then GoTo Finally
279 If Not ScriptForge.SF_Utils._Validate(Pages, &quot;Pages&quot;, V_STRING) Then GoTo Finally
280 If Not ScriptForge.SF_Utils._Validate(Copies, &quot;Copies&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
281 If Not ScriptForge.SF_Utils._Validate(PrintBackground, &quot;PrintBackground&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
282 If Not ScriptForge.SF_Utils._Validate(PrintBlankPages, &quot;PrintBlankPages&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
283 If Not ScriptForge.SF_Utils._Validate(PrintEvenPages, &quot;PrintEvenPages&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
284 If Not ScriptForge.SF_Utils._Validate(PrintOddPages, &quot;PrintOddPages&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
285 If Not ScriptForge.SF_Utils._Validate(PrintImages, &quot;PrintImages&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
286 End If
288 Try:
289 vPrintOptions = _Component.createInstance(&quot;com.sun.star.text.DocumentSettings&quot;)
290 With vPrintOptions
291 .PrintPageBackground = PrintBackground
292 .PrintEmptyPages = PrintBlankPages
293 .PrintLeftPages = PrintEvenPages
294 .PrintRightPages = PrintOddPages
295 .PrintGraphics = PrintImages
296 .PrintDrawings = PrintImages
297 End With
299 bPrint = [_Super].PrintOut(Pages, Copies, _Component)
301 Finally:
302 PrintOut = bPrint
303 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
304 Exit Function
305 Catch:
306 GoTo Finally
307 End Function &apos; SFDocuments.SF_Writer.PrintOut
309 REM -----------------------------------------------------------------------------
310 Public Function Properties() As Variant
311 &apos;&apos;&apos; Return the list or properties of the Writer class as an array
313 Properties = Array( _
314 &quot;CustomProperties&quot; _
315 , &quot;Description&quot; _
316 , &quot;DocumentProperties&quot; _
317 , &quot;DocumentType&quot; _
318 , &quot;IsBase&quot; _
319 , &quot;IsCalc&quot; _
320 , &quot;IsDraw&quot; _
321 , &quot;IsImpress&quot; _
322 , &quot;IsMath&quot; _
323 , &quot;IsWriter&quot; _
324 , &quot;Keywords&quot; _
325 , &quot;Readonly&quot; _
326 , &quot;Subject&quot; _
327 , &quot;Title&quot; _
328 , &quot;XComponent&quot; _
331 End Function &apos; SFDocuments.SF_Writer.Properties
333 REM -----------------------------------------------------------------------------
334 Private Function SetProperty(Optional ByVal psProperty As String _
335 , Optional ByVal pvValue As Variant _
336 ) As Boolean
337 &apos;&apos;&apos; Set the new value of the named property
338 &apos;&apos;&apos; Args:
339 &apos;&apos;&apos; psProperty: the name of the property
340 &apos;&apos;&apos; pvValue: the new value of the given property
341 &apos;&apos;&apos; Returns:
342 &apos;&apos;&apos; True if successful
344 Dim bSet As Boolean &apos; Return value
345 Static oSession As Object &apos; Alias of SF_Session
346 Dim cstThisSub As String
347 Const cstSubArgs = &quot;Value&quot;
349 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
350 bSet = False
352 cstThisSub = &quot;SFDocuments.Writer.set&quot; &amp; psProperty
353 If IsMissing(pvValue) Then pvValue = Empty
354 &apos;ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) &apos; Validation done in Property Lets
356 If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
357 bSet = True
358 Select Case UCase(psProperty)
359 Case UCase(&quot;CustomProperties&quot;)
360 CustomProperties = pvValue
361 Case UCase(&quot;Description&quot;)
362 Description = pvValue
363 Case UCase(&quot;Keywords&quot;)
364 Keywords = pvValue
365 Case UCase(&quot;Subject&quot;)
366 Subject = pvValue
367 Case UCase(&quot;Title&quot;)
368 Title = pvValue
369 Case Else
370 bSet = False
371 End Select
373 Finally:
374 SetProperty = bSet
375 &apos;ScriptForge.SF_Utils._ExitFunction(cstThisSub)
376 Exit Function
377 Catch:
378 GoTo Finally
379 End Function &apos; SFDocuments.SF_Writer.SetProperty
381 REM ======================================================= SUPERCLASS PROPERTIES
383 REM -----------------------------------------------------------------------------
384 Property Get CustomProperties() As Variant
385 CustomProperties = [_Super].GetProperty(&quot;CustomProperties&quot;)
386 End Property &apos; SFDocuments.SF_Writer.CustomProperties
388 REM -----------------------------------------------------------------------------
389 Property Let CustomProperties(Optional ByVal pvCustomProperties As Variant)
390 [_Super].CustomProperties = pvCustomProperties
391 End Property &apos; SFDocuments.SF_Writer.CustomProperties
393 REM -----------------------------------------------------------------------------
394 Property Get Description() As Variant
395 Description = [_Super].GetProperty(&quot;Description&quot;)
396 End Property &apos; SFDocuments.SF_Writer.Description
398 REM -----------------------------------------------------------------------------
399 Property Let Description(Optional ByVal pvDescription As Variant)
400 [_Super].Description = pvDescription
401 End Property &apos; SFDocuments.SF_Writer.Description
403 REM -----------------------------------------------------------------------------
404 Property Get DocumentProperties() As Variant
405 DocumentProperties = [_Super].GetProperty(&quot;DocumentProperties&quot;)
406 End Property &apos; SFDocuments.SF_Writer.DocumentProperties
408 REM -----------------------------------------------------------------------------
409 Property Get DocumentType() As String
410 DocumentType = [_Super].GetProperty(&quot;DocumentType&quot;)
411 End Property &apos; SFDocuments.SF_Writer.DocumentType
413 REM -----------------------------------------------------------------------------
414 Property Get IsBase() As Boolean
415 IsBase = [_Super].GetProperty(&quot;IsBase&quot;)
416 End Property &apos; SFDocuments.SF_Writer.IsBase
418 REM -----------------------------------------------------------------------------
419 Property Get IsCalc() As Boolean
420 IsCalc = [_Super].GetProperty(&quot;IsCalc&quot;)
421 End Property &apos; SFDocuments.SF_Writer.IsCalc
423 REM -----------------------------------------------------------------------------
424 Property Get IsDraw() As Boolean
425 IsDraw = [_Super].GetProperty(&quot;IsDraw&quot;)
426 End Property &apos; SFDocuments.SF_Writer.IsDraw
428 REM -----------------------------------------------------------------------------
429 Property Get IsImpress() As Boolean
430 IsImpress = [_Super].GetProperty(&quot;IsImpress&quot;)
431 End Property &apos; SFDocuments.SF_Writer.IsImpress
433 REM -----------------------------------------------------------------------------
434 Property Get IsMath() As Boolean
435 IsMath = [_Super].GetProperty(&quot;IsMath&quot;)
436 End Property &apos; SFDocuments.SF_Writer.IsMath
438 REM -----------------------------------------------------------------------------
439 Property Get IsWriter() As Boolean
440 IsWriter = [_Super].GetProperty(&quot;IsWriter&quot;)
441 End Property &apos; SFDocuments.SF_Writer.IsWriter
443 REM -----------------------------------------------------------------------------
444 Property Get Keywords() As Variant
445 Keywords = [_Super].GetProperty(&quot;Keywords&quot;)
446 End Property &apos; SFDocuments.SF_Writer.Keywords
448 REM -----------------------------------------------------------------------------
449 Property Let Keywords(Optional ByVal pvKeywords As Variant)
450 [_Super].Keywords = pvKeywords
451 End Property &apos; SFDocuments.SF_Writer.Keywords
453 REM -----------------------------------------------------------------------------
454 Property Get Readonly() As Variant
455 Readonly = [_Super].GetProperty(&quot;Readonly&quot;)
456 End Property &apos; SFDocuments.SF_Writer.Readonly
458 REM -----------------------------------------------------------------------------
459 Property Get Subject() As Variant
460 Subject = [_Super].GetProperty(&quot;Subject&quot;)
461 End Property &apos; SFDocuments.SF_Writer.Subject
463 REM -----------------------------------------------------------------------------
464 Property Let Subject(Optional ByVal pvSubject As Variant)
465 [_Super].Subject = pvSubject
466 End Property &apos; SFDocuments.SF_Writer.Subject
468 REM -----------------------------------------------------------------------------
469 Property Get Title() As Variant
470 Title = [_Super].GetProperty(&quot;Title&quot;)
471 End Property &apos; SFDocuments.SF_Writer.Title
473 REM -----------------------------------------------------------------------------
474 Property Let Title(Optional ByVal pvTitle As Variant)
475 [_Super].Title = pvTitle
476 End Property &apos; SFDocuments.SF_Writer.Title
478 REM -----------------------------------------------------------------------------
479 Property Get XComponent() As Variant
480 XComponent = [_Super].GetProperty(&quot;XComponent&quot;)
481 End Property &apos; SFDocuments.SF_Writer.XComponent
483 REM ========================================================== SUPERCLASS METHODS
485 REM -----------------------------------------------------------------------------
486 Public Function Activate() As Boolean
487 Activate = [_Super].Activate()
488 End Function &apos; SFDocuments.SF_Writer.Activate
490 REM -----------------------------------------------------------------------------
491 Public Function CloseDocument(Optional ByVal SaveAsk As Variant) As Boolean
492 CloseDocument = [_Super].CloseDocument(SaveAsk)
493 End Function &apos; SFDocuments.SF_Writer.CloseDocument
495 REM -----------------------------------------------------------------------------
496 Public Function ExportAsPDF(Optional ByVal FileName As Variant _
497 , Optional ByVal Overwrite As Variant _
498 , Optional ByVal Pages As Variant _
499 , Optional ByVal Password As Variant _
500 , Optional ByVal Watermark As Variant _
501 ) As Boolean
502 ExportAsPDF = [_Super].ExportAsPDF(FileName, Overwrite, Pages, Password, Watermark)
503 End Function &apos; SFDocuments.SF_Writer.ExportAsPDF
505 REM -----------------------------------------------------------------------------
506 Public Sub RunCommand(Optional ByVal Command As Variant)
507 [_Super].RunCommand(Command)
508 End Sub &apos; SFDocuments.SF_Writer.RunCommand
510 REM -----------------------------------------------------------------------------
511 Public Function Save() As Boolean
512 Save = [_Super].Save()
513 End Function &apos; SFDocuments.SF_Writer.Save
515 REM -----------------------------------------------------------------------------
516 Public Function SaveAs(Optional ByVal FileName As Variant _
517 , Optional ByVal Overwrite As Variant _
518 , Optional ByVal Password As Variant _
519 , Optional ByVal FilterName As Variant _
520 , Optional ByVal FilterOptions As Variant _
521 ) As Boolean
522 SaveAs = [_Super].SaveAs(FileName, Overwrite, Password, FilterName, FilterOptions)
523 End Function &apos; SFDocuments.SF_Writer.SaveAs
525 REM -----------------------------------------------------------------------------
526 Public Function SaveCopyAs(Optional ByVal FileName As Variant _
527 , Optional ByVal Overwrite As Variant _
528 , Optional ByVal Password As Variant _
529 , Optional ByVal FilterName As Variant _
530 , Optional ByVal FilterOptions As Variant _
531 ) As Boolean
532 SaveCopyAs = [_Super].SaveCopyAs(FileName, Overwrite, Password, FilterName, FilterOptions)
533 End Function &apos; SFDocuments.SF_Writer.SaveCopyAs
535 REM -----------------------------------------------------------------------------
536 Public Function SetPrinter(Optional ByVal Printer As Variant _
537 , Optional ByVal Orientation As Variant _
538 , Optional ByVal PaperFormat As Variant _
539 ) As Boolean
540 SetPrinter = [_Super].SetPrinter(Printer, Orientation, PaperFormat)
541 End Function &apos; SFDocuments.SF_Writer.SetPrinter
543 REM =========================================================== PRIVATE FUNCTIONS
545 REM -----------------------------------------------------------------------------
546 Private Function _FileIdent() As String
547 &apos;&apos;&apos; Returns a file identification from the information that is currently available
548 &apos;&apos;&apos; Useful e.g. for display in error messages
550 _FileIdent = [_Super]._FileIdent()
552 End Function &apos; SFDocuments.SF_Writer._FileIdent
554 REM -----------------------------------------------------------------------------
555 Private Function _IsStillAlive(Optional ByVal pbForUpdate As Boolean _
556 , Optional ByVal pbError As Boolean _
557 ) As Boolean
558 &apos;&apos;&apos; Returns True if the document has not been closed manually or incidentally since the last use
559 &apos;&apos;&apos; If dead the actual instance is disposed. The execution is cancelled when pbError = True (default)
560 &apos;&apos;&apos; Args:
561 &apos;&apos;&apos; pbForUpdate: if True (default = False), check additionally if document is open for editing
562 &apos;&apos;&apos; pbError: if True (default), raise a fatal error
564 Dim bAlive As Boolean &apos; Return value
566 If IsMissing(pbForUpdate) Then pbForUpdate = False
567 If IsMissing(pbError) Then pbError = True
569 Try:
570 bAlive = [_Super]._IsStillAlive(pbForUpdate, pbError)
572 Finally:
573 _IsStillAlive = bAlive
574 Exit Function
575 End Function &apos; SFDocuments.SF_Writer._IsStillAlive
577 REM -----------------------------------------------------------------------------
578 Private Function _PropertyGet(Optional ByVal psProperty As String _
579 , Optional ByVal pvArg As Variant _
580 ) As Variant
581 &apos;&apos;&apos; Return the value of the named property
582 &apos;&apos;&apos; Args:
583 &apos;&apos;&apos; psProperty: the name of the property
585 Dim cstThisSub As String
586 Const cstSubArgs = &quot;&quot;
588 _PropertyGet = False
590 cstThisSub = &quot;SFDocuments.Writer.get&quot; &amp; psProperty
591 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
592 If Not _IsStillAlive() Then GoTo Finally
594 Select Case psProperty
595 Case Else
596 _PropertyGet = Null
597 End Select
599 Finally:
600 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
601 Exit Function
602 End Function &apos; SFDocuments.SF_Writer._PropertyGet
604 REM -----------------------------------------------------------------------------
605 Private Function _Repr() As String
606 &apos;&apos;&apos; Convert the SF_Writer instance to a readable string, typically for debugging purposes (DebugPrint ...)
607 &apos;&apos;&apos; Args:
608 &apos;&apos;&apos; Return:
609 &apos;&apos;&apos; &quot;[DOCUMENT]: Type/File&quot;
611 _Repr = &quot;[Writer]: &quot; &amp; [_Super]._FileIdent()
613 End Function &apos; SFDocuments.SF_Writer._Repr
615 REM ============================================ END OF SFDOCUMENTS.SF_WRITER
616 </script:module>