calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / wizards / source / sfdocuments / SF_Writer.xba
blobeded35de9a96e13b829fd20742d3fa05a3508c77
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;Forms&quot; _
221 , &quot;PrintOut&quot; _
224 End Function &apos; SFDocuments.SF_Writer.Methods
226 REM -----------------------------------------------------------------------------
227 Public Function PrintOut(Optional ByVal Pages As Variant _
228 , Optional ByVal Copies As Variant _
229 , Optional ByVal PrintBackground As Variant _
230 , Optional ByVal PrintBlankPages As Variant _
231 , Optional ByVal PrintEvenPages As Variant _
232 , Optional ByVal PrintOddPages As Variant _
233 , Optional ByVal PrintImages As Variant _
234 ) As Boolean
235 &apos;&apos;&apos; Send the content of the document to the printer.
236 &apos;&apos;&apos; The printer might be defined previously by default, by the user or by the SetPrinter() method
237 &apos;&apos;&apos; Args:
238 &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
239 &apos;&apos;&apos; Copies: the number of copies
240 &apos;&apos;&apos; PrintBackground: print the background image when True (default)
241 &apos;&apos;&apos; PrintBlankPages: when False (default), omit empty pages
242 &apos;&apos;&apos; PrintEvenPages: print the left pages when True (default)
243 &apos;&apos;&apos; PrintOddPages: print the right pages when True (default)
244 &apos;&apos;&apos; PrintImages: print the graphic objects when True (default)
245 &apos;&apos;&apos; Returns:
246 &apos;&apos;&apos; True when successful
247 &apos;&apos;&apos; Examples:
248 &apos;&apos;&apos; oDoc.PrintOut(&quot;1-4;10;15-18&quot;, Copies := 2, PrintImages := False)
250 Dim bPrint As Boolean &apos; Return value
251 Dim vPrintOptions As Variant &apos; com.sun.star.text.DocumentSettings
253 Const cstThisSub = &quot;SFDocuments.Writer.PrintOut&quot;
254 Const cstSubArgs = &quot;[Pages=&quot;&quot;&quot;&quot;], [Copies=1], [PrintBackground=True], [PrintBlankPages=False], [PrintEvenPages=True]&quot; _
255 &amp; &quot;, [PrintOddPages=True], [PrintImages=True]&quot;
257 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
258 bPrint = False
260 Check:
261 If IsMissing(Pages) Or IsEmpty(Pages) Then Pages = &quot;&quot;
262 If IsMissing(Copies) Or IsEmpty(Copies) Then Copies = 1
263 If IsMissing(PrintBackground) Or IsEmpty(PrintBackground) Then PrintBackground = True
264 If IsMissing(PrintBlankPages) Or IsEmpty(PrintBlankPages) Then PrintBlankPages = False
265 If IsMissing(PrintEvenPages) Or IsEmpty(PrintEvenPages) Then PrintEvenPages = True
266 If IsMissing(PrintOddPages) Or IsEmpty(PrintOddPages) Then PrintOddPages = True
267 If IsMissing(PrintImages) Or IsEmpty(PrintImages) Then PrintImages = True
269 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
270 If Not _IsStillAlive() Then GoTo Finally
271 If Not ScriptForge.SF_Utils._Validate(Pages, &quot;Pages&quot;, V_STRING) Then GoTo Finally
272 If Not ScriptForge.SF_Utils._Validate(Copies, &quot;Copies&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
273 If Not ScriptForge.SF_Utils._Validate(PrintBackground, &quot;PrintBackground&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
274 If Not ScriptForge.SF_Utils._Validate(PrintBlankPages, &quot;PrintBlankPages&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
275 If Not ScriptForge.SF_Utils._Validate(PrintEvenPages, &quot;PrintEvenPages&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
276 If Not ScriptForge.SF_Utils._Validate(PrintOddPages, &quot;PrintOddPages&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
277 If Not ScriptForge.SF_Utils._Validate(PrintImages, &quot;PrintImages&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
278 End If
280 Try:
281 vPrintOptions = _Component.createInstance(&quot;com.sun.star.text.DocumentSettings&quot;)
282 With vPrintOptions
283 .PrintPageBackground = PrintBackground
284 .PrintEmptyPages = PrintBlankPages
285 .PrintLeftPages = PrintEvenPages
286 .PrintRightPages = PrintOddPages
287 .PrintGraphics = PrintImages
288 .PrintDrawings = PrintImages
289 End With
291 bPrint = [_Super].PrintOut(Pages, Copies, _Component)
293 Finally:
294 PrintOut = bPrint
295 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
296 Exit Function
297 Catch:
298 GoTo Finally
299 End Function &apos; SFDocuments.SF_Writer.PrintOut
301 REM -----------------------------------------------------------------------------
302 Public Function Properties() As Variant
303 &apos;&apos;&apos; Return the list or properties of the Writer class as an array
305 Properties = Array( _
306 &quot;CustomProperties&quot; _
307 , &quot;Description&quot; _
308 , &quot;DocumentProperties&quot; _
309 , &quot;DocumentType&quot; _
310 , &quot;ExportFilters&quot; _
311 , &quot;ImportFilters&quot; _
312 , &quot;IsBase&quot; _
313 , &quot;IsCalc&quot; _
314 , &quot;IsDraw&quot; _
315 , &quot;IsImpress&quot; _
316 , &quot;IsMath&quot; _
317 , &quot;IsWriter&quot; _
318 , &quot;Keywords&quot; _
319 , &quot;Readonly&quot; _
320 , &quot;Subject&quot; _
321 , &quot;Title&quot; _
322 , &quot;XComponent&quot; _
325 End Function &apos; SFDocuments.SF_Writer.Properties
327 REM -----------------------------------------------------------------------------
328 Private Function SetProperty(Optional ByVal psProperty As String _
329 , Optional ByVal pvValue As Variant _
330 ) As Boolean
331 &apos;&apos;&apos; Set the new value of the named property
332 &apos;&apos;&apos; Args:
333 &apos;&apos;&apos; psProperty: the name of the property
334 &apos;&apos;&apos; pvValue: the new value of the given property
335 &apos;&apos;&apos; Returns:
336 &apos;&apos;&apos; True if successful
338 Dim bSet As Boolean &apos; Return value
339 Static oSession As Object &apos; Alias of SF_Session
340 Dim cstThisSub As String
341 Const cstSubArgs = &quot;Value&quot;
343 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
344 bSet = False
346 cstThisSub = &quot;SFDocuments.Writer.set&quot; &amp; psProperty
347 If IsMissing(pvValue) Then pvValue = Empty
348 &apos;ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) &apos; Validation done in Property Lets
350 If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
351 bSet = True
352 Select Case UCase(psProperty)
353 Case UCase(&quot;CustomProperties&quot;)
354 CustomProperties = pvValue
355 Case UCase(&quot;Description&quot;)
356 Description = pvValue
357 Case UCase(&quot;Keywords&quot;)
358 Keywords = pvValue
359 Case UCase(&quot;Subject&quot;)
360 Subject = pvValue
361 Case UCase(&quot;Title&quot;)
362 Title = pvValue
363 Case Else
364 bSet = False
365 End Select
367 Finally:
368 SetProperty = bSet
369 &apos;ScriptForge.SF_Utils._ExitFunction(cstThisSub)
370 Exit Function
371 Catch:
372 GoTo Finally
373 End Function &apos; SFDocuments.SF_Writer.SetProperty
375 REM ======================================================= SUPERCLASS PROPERTIES
377 REM -----------------------------------------------------------------------------
378 Property Get CustomProperties() As Variant
379 CustomProperties = [_Super].GetProperty(&quot;CustomProperties&quot;)
380 End Property &apos; SFDocuments.SF_Writer.CustomProperties
382 REM -----------------------------------------------------------------------------
383 Property Let CustomProperties(Optional ByVal pvCustomProperties As Variant)
384 [_Super].CustomProperties = pvCustomProperties
385 End Property &apos; SFDocuments.SF_Writer.CustomProperties
387 REM -----------------------------------------------------------------------------
388 Property Get Description() As Variant
389 Description = [_Super].GetProperty(&quot;Description&quot;)
390 End Property &apos; SFDocuments.SF_Writer.Description
392 REM -----------------------------------------------------------------------------
393 Property Let Description(Optional ByVal pvDescription As Variant)
394 [_Super].Description = pvDescription
395 End Property &apos; SFDocuments.SF_Writer.Description
397 REM -----------------------------------------------------------------------------
398 Property Get DocumentProperties() As Variant
399 DocumentProperties = [_Super].GetProperty(&quot;DocumentProperties&quot;)
400 End Property &apos; SFDocuments.SF_Writer.DocumentProperties
402 REM -----------------------------------------------------------------------------
403 Property Get DocumentType() As String
404 DocumentType = [_Super].GetProperty(&quot;DocumentType&quot;)
405 End Property &apos; SFDocuments.SF_Writer.DocumentType
407 REM -----------------------------------------------------------------------------
408 Property Get ExportFilters() As Variant
409 ExportFilters = [_Super].GetProperty(&quot;ExportFilters&quot;)
410 End Property &apos; SFDocuments.SF_Writer.ExportFilters
412 REM -----------------------------------------------------------------------------
413 Property Get ImportFilters() As Variant
414 ImportFilters = [_Super].GetProperty(&quot;ImportFilters&quot;)
415 End Property &apos; SFDocuments.SF_Writer.ImportFilters
417 REM -----------------------------------------------------------------------------
418 Property Get IsBase() As Boolean
419 IsBase = [_Super].GetProperty(&quot;IsBase&quot;)
420 End Property &apos; SFDocuments.SF_Writer.IsBase
422 REM -----------------------------------------------------------------------------
423 Property Get IsCalc() As Boolean
424 IsCalc = [_Super].GetProperty(&quot;IsCalc&quot;)
425 End Property &apos; SFDocuments.SF_Writer.IsCalc
427 REM -----------------------------------------------------------------------------
428 Property Get IsDraw() As Boolean
429 IsDraw = [_Super].GetProperty(&quot;IsDraw&quot;)
430 End Property &apos; SFDocuments.SF_Writer.IsDraw
432 REM -----------------------------------------------------------------------------
433 Property Get IsImpress() As Boolean
434 IsImpress = [_Super].GetProperty(&quot;IsImpress&quot;)
435 End Property &apos; SFDocuments.SF_Writer.IsImpress
437 REM -----------------------------------------------------------------------------
438 Property Get IsMath() As Boolean
439 IsMath = [_Super].GetProperty(&quot;IsMath&quot;)
440 End Property &apos; SFDocuments.SF_Writer.IsMath
442 REM -----------------------------------------------------------------------------
443 Property Get IsWriter() As Boolean
444 IsWriter = [_Super].GetProperty(&quot;IsWriter&quot;)
445 End Property &apos; SFDocuments.SF_Writer.IsWriter
447 REM -----------------------------------------------------------------------------
448 Property Get Keywords() As Variant
449 Keywords = [_Super].GetProperty(&quot;Keywords&quot;)
450 End Property &apos; SFDocuments.SF_Writer.Keywords
452 REM -----------------------------------------------------------------------------
453 Property Let Keywords(Optional ByVal pvKeywords As Variant)
454 [_Super].Keywords = pvKeywords
455 End Property &apos; SFDocuments.SF_Writer.Keywords
457 REM -----------------------------------------------------------------------------
458 Property Get Readonly() As Variant
459 Readonly = [_Super].GetProperty(&quot;Readonly&quot;)
460 End Property &apos; SFDocuments.SF_Writer.Readonly
462 REM -----------------------------------------------------------------------------
463 Property Get Subject() As Variant
464 Subject = [_Super].GetProperty(&quot;Subject&quot;)
465 End Property &apos; SFDocuments.SF_Writer.Subject
467 REM -----------------------------------------------------------------------------
468 Property Let Subject(Optional ByVal pvSubject As Variant)
469 [_Super].Subject = pvSubject
470 End Property &apos; SFDocuments.SF_Writer.Subject
472 REM -----------------------------------------------------------------------------
473 Property Get Title() As Variant
474 Title = [_Super].GetProperty(&quot;Title&quot;)
475 End Property &apos; SFDocuments.SF_Writer.Title
477 REM -----------------------------------------------------------------------------
478 Property Let Title(Optional ByVal pvTitle As Variant)
479 [_Super].Title = pvTitle
480 End Property &apos; SFDocuments.SF_Writer.Title
482 REM -----------------------------------------------------------------------------
483 Property Get XComponent() As Variant
484 XComponent = [_Super].GetProperty(&quot;XComponent&quot;)
485 End Property &apos; SFDocuments.SF_Writer.XComponent
487 REM ========================================================== SUPERCLASS METHODS
489 REM -----------------------------------------------------------------------------
490 Public Function Activate() As Boolean
491 Activate = [_Super].Activate()
492 End Function &apos; SFDocuments.SF_Writer.Activate
494 REM -----------------------------------------------------------------------------
495 Public Function CloseDocument(Optional ByVal SaveAsk As Variant) As Boolean
496 CloseDocument = [_Super].CloseDocument(SaveAsk)
497 End Function &apos; SFDocuments.SF_Writer.CloseDocument
499 REM -----------------------------------------------------------------------------
500 Public Function CreateMenu(Optional ByVal MenuHeader As Variant _
501 , Optional ByVal Before As Variant _
502 , Optional ByVal SubmenuChar As Variant _
503 ) As Object
504 Set CreateMenu = [_Super].CreateMenu(MenuHeader, Before, SubmenuChar)
505 End Function &apos; SFDocuments.SF_Writer.CreateMenu
507 REM -----------------------------------------------------------------------------
508 Public Function ExportAsPDF(Optional ByVal FileName As Variant _
509 , Optional ByVal Overwrite As Variant _
510 , Optional ByVal Pages As Variant _
511 , Optional ByVal Password As Variant _
512 , Optional ByVal Watermark As Variant _
513 ) As Boolean
514 ExportAsPDF = [_Super].ExportAsPDF(FileName, Overwrite, Pages, Password, Watermark)
515 End Function &apos; SFDocuments.SF_Writer.ExportAsPDF
517 REM -----------------------------------------------------------------------------
518 Public Function RemoveMenu(Optional ByVal MenuHeader As Variant) As Boolean
519 RemoveMenu = [_Super].RemoveMenu(MenuHeader)
520 End Function &apos; SFDocuments.SF_Writer.RemoveMenu
522 REM -----------------------------------------------------------------------------
523 Public Sub RunCommand(Optional ByVal Command As Variant _
524 , ParamArray Args As Variant _
526 [_Super].RunCommand(Command, Args)
527 End Sub &apos; SFDocuments.SF_Writer.RunCommand
529 REM -----------------------------------------------------------------------------
530 Public Function Save() As Boolean
531 Save = [_Super].Save()
532 End Function &apos; SFDocuments.SF_Writer.Save
534 REM -----------------------------------------------------------------------------
535 Public Function SaveAs(Optional ByVal FileName As Variant _
536 , Optional ByVal Overwrite As Variant _
537 , Optional ByVal Password As Variant _
538 , Optional ByVal FilterName As Variant _
539 , Optional ByVal FilterOptions As Variant _
540 ) As Boolean
541 SaveAs = [_Super].SaveAs(FileName, Overwrite, Password, FilterName, FilterOptions)
542 End Function &apos; SFDocuments.SF_Writer.SaveAs
544 REM -----------------------------------------------------------------------------
545 Public Function SaveCopyAs(Optional ByVal FileName As Variant _
546 , Optional ByVal Overwrite As Variant _
547 , Optional ByVal Password As Variant _
548 , Optional ByVal FilterName As Variant _
549 , Optional ByVal FilterOptions As Variant _
550 ) As Boolean
551 SaveCopyAs = [_Super].SaveCopyAs(FileName, Overwrite, Password, FilterName, FilterOptions)
552 End Function &apos; SFDocuments.SF_Writer.SaveCopyAs
554 REM -----------------------------------------------------------------------------
555 Public Function SetPrinter(Optional ByVal Printer As Variant _
556 , Optional ByVal Orientation As Variant _
557 , Optional ByVal PaperFormat As Variant _
558 ) As Boolean
559 SetPrinter = [_Super].SetPrinter(Printer, Orientation, PaperFormat)
560 End Function &apos; SFDocuments.SF_Writer.SetPrinter
562 REM =========================================================== PRIVATE FUNCTIONS
564 REM -----------------------------------------------------------------------------
565 Private Function _FileIdent() As String
566 &apos;&apos;&apos; Returns a file identification from the information that is currently available
567 &apos;&apos;&apos; Useful e.g. for display in error messages
569 _FileIdent = [_Super]._FileIdent()
571 End Function &apos; SFDocuments.SF_Writer._FileIdent
573 REM -----------------------------------------------------------------------------
574 Private Function _IsStillAlive(Optional ByVal pbForUpdate As Boolean _
575 , Optional ByVal pbError As Boolean _
576 ) As Boolean
577 &apos;&apos;&apos; Returns True if the document has not been closed manually or incidentally since the last use
578 &apos;&apos;&apos; If dead the actual instance is disposed. The execution is cancelled when pbError = True (default)
579 &apos;&apos;&apos; Args:
580 &apos;&apos;&apos; pbForUpdate: if True (default = False), check additionally if document is open for editing
581 &apos;&apos;&apos; pbError: if True (default), raise a fatal error
583 Dim bAlive As Boolean &apos; Return value
585 If IsMissing(pbForUpdate) Then pbForUpdate = False
586 If IsMissing(pbError) Then pbError = True
588 Try:
589 bAlive = [_Super]._IsStillAlive(pbForUpdate, pbError)
591 Finally:
592 _IsStillAlive = bAlive
593 Exit Function
594 End Function &apos; SFDocuments.SF_Writer._IsStillAlive
596 REM -----------------------------------------------------------------------------
597 Private Function _PropertyGet(Optional ByVal psProperty As String _
598 , Optional ByVal pvArg As Variant _
599 ) As Variant
600 &apos;&apos;&apos; Return the value of the named property
601 &apos;&apos;&apos; Args:
602 &apos;&apos;&apos; psProperty: the name of the property
604 Dim cstThisSub As String
605 Const cstSubArgs = &quot;&quot;
607 _PropertyGet = False
609 cstThisSub = &quot;SFDocuments.Writer.get&quot; &amp; psProperty
610 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
611 If Not _IsStillAlive() Then GoTo Finally
613 Select Case psProperty
614 Case Else
615 _PropertyGet = Null
616 End Select
618 Finally:
619 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
620 Exit Function
621 End Function &apos; SFDocuments.SF_Writer._PropertyGet
623 REM -----------------------------------------------------------------------------
624 Private Function _Repr() As String
625 &apos;&apos;&apos; Convert the SF_Writer instance to a readable string, typically for debugging purposes (DebugPrint ...)
626 &apos;&apos;&apos; Args:
627 &apos;&apos;&apos; Return:
628 &apos;&apos;&apos; &quot;[DOCUMENT]: Type/File&quot;
630 _Repr = &quot;[Writer]: &quot; &amp; [_Super]._FileIdent()
632 End Function &apos; SFDocuments.SF_Writer._Repr
634 REM ============================================ END OF SFDOCUMENTS.SF_WRITER
635 </script:module>