-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLibreOfficeWriter_Field.au3
5768 lines (4961 loc) · 386 KB
/
LibreOfficeWriter_Field.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
;~ #Tidy_Parameters=/sf
#include-once
; Main LibreOffice Includes
#include "LibreOffice_Constants.au3"
; Common includes for Writer
#include "LibreOfficeWriter_Constants.au3"
#include "LibreOfficeWriter_Helper.au3"
#include "LibreOfficeWriter_Internal.au3"
; Other includes for Writer
#include "LibreOfficeWriter_Doc.au3"
; #INDEX# =======================================================================================================================
; Title .........: LibreOffice UDF
; AutoIt Version : v3.3.16.1
; Description ...: Provides basic functionality through AutoIt for Inserting and Modifying L.O. Writer Fields.
; Author(s) .....: donnyh13, mLipok
; Dll ...........:
;
; ===============================================================================================================================
; #CURRENT# =====================================================================================================================
; _LOWriter_FieldAuthorInsert
; _LOWriter_FieldAuthorModify
; _LOWriter_FieldChapterInsert
; _LOWriter_FieldChapterModify
; _LOWriter_FieldCombCharInsert
; _LOWriter_FieldCombCharModify
; _LOWriter_FieldCommentInsert
; _LOWriter_FieldCommentModify
; _LOWriter_FieldCondTextInsert
; _LOWriter_FieldCondTextModify
; _LOWriter_FieldCurrentDisplayGet
; _LOWriter_FieldDateTimeInsert
; _LOWriter_FieldDateTimeModify
; _LOWriter_FieldDelete
; _LOWriter_FieldDocInfoCommentsInsert
; _LOWriter_FieldDocInfoCommentsModify
; _LOWriter_FieldDocInfoCreateAuthInsert
; _LOWriter_FieldDocInfoCreateAuthModify
; _LOWriter_FieldDocInfoCreateDateTimeInsert
; _LOWriter_FieldDocInfoCreateDateTimeModify
; _LOWriter_FieldDocInfoEditTimeInsert
; _LOWriter_FieldDocInfoEditTimeModify
; _LOWriter_FieldDocInfoKeywordsInsert
; _LOWriter_FieldDocInfoKeywordsModify
; _LOWriter_FieldDocInfoModAuthInsert
; _LOWriter_FieldDocInfoModAuthModify
; _LOWriter_FieldDocInfoModDateTimeInsert
; _LOWriter_FieldDocInfoModDateTimeModify
; _LOWriter_FieldDocInfoPrintAuthInsert
; _LOWriter_FieldDocInfoPrintAuthModify
; _LOWriter_FieldDocInfoPrintDateTimeInsert
; _LOWriter_FieldDocInfoPrintDateTimeModify
; _LOWriter_FieldDocInfoRevNumInsert
; _LOWriter_FieldDocInfoRevNumModify
; _LOWriter_FieldDocInfoSubjectInsert
; _LOWriter_FieldDocInfoSubjectModify
; _LOWriter_FieldDocInfoTitleInsert
; _LOWriter_FieldDocInfoTitleModify
; _LOWriter_FieldFileNameInsert
; _LOWriter_FieldFileNameModify
; _LOWriter_FieldFuncHiddenParInsert
; _LOWriter_FieldFuncHiddenParModify
; _LOWriter_FieldFuncHiddenTextInsert
; _LOWriter_FieldFuncHiddenTextModify
; _LOWriter_FieldFuncInputInsert
; _LOWriter_FieldFuncInputModify
; _LOWriter_FieldFuncPlaceholderInsert
; _LOWriter_FieldFuncPlaceholderModify
; _LOWriter_FieldGetAnchor
; _LOWriter_FieldInputListInsert
; _LOWriter_FieldInputListModify
; _LOWriter_FieldPageNumberInsert
; _LOWriter_FieldPageNumberModify
; _LOWriter_FieldRefBookMarkInsert
; _LOWriter_FieldRefBookMarkModify
; _LOWriter_FieldRefEndnoteInsert
; _LOWriter_FieldRefEndnoteModify
; _LOWriter_FieldRefFootnoteInsert
; _LOWriter_FieldRefFootnoteModify
; _LOWriter_FieldRefGetType
; _LOWriter_FieldRefInsert
; _LOWriter_FieldRefMarkDelete
; _LOWriter_FieldRefMarkGetAnchor
; _LOWriter_FieldRefMarkList
; _LOWriter_FieldRefMarkSet
; _LOWriter_FieldRefModify
; _LOWriter_FieldsAdvGetList
; _LOWriter_FieldsDocInfoGetList
; _LOWriter_FieldSenderInsert
; _LOWriter_FieldSenderModify
; _LOWriter_FieldSetVarInsert
; _LOWriter_FieldSetVarMasterCreate
; _LOWriter_FieldSetVarMasterDelete
; _LOWriter_FieldSetVarMasterExists
; _LOWriter_FieldSetVarMasterFieldsGetList
; _LOWriter_FieldSetVarMasterGetObj
; _LOWriter_FieldSetVarMastersGetNames
; _LOWriter_FieldSetVarModify
; _LOWriter_FieldsGetList
; _LOWriter_FieldShowVarInsert
; _LOWriter_FieldShowVarModify
; _LOWriter_FieldStatCountInsert
; _LOWriter_FieldStatCountModify
; _LOWriter_FieldStatTemplateInsert
; _LOWriter_FieldStatTemplateModify
; _LOWriter_FieldUpdate
; _LOWriter_FieldVarSetPageInsert
; _LOWriter_FieldVarSetPageModify
; _LOWriter_FieldVarShowPageInsert
; _LOWriter_FieldVarShowPageModify
; ===============================================================================================================================
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldAuthorInsert
; Description ...: Insert a Author Field.
; Syntax ........: _LOWriter_FieldAuthorInsert(ByRef $oDoc, ByRef $oCursor[, $bOverwrite = False[, $bIsFixed = Null[, $sAuthor = Null[, $bFullName = Null]]]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oCursor - [in/out] an object. A Cursor Object returned from any Cursor Object creation Or retrieval function. Cannot be a Table Cursor.
; $bOverwrite - [optional] a boolean value. Default is False. If True, any content selected by the cursor will be overwritten. If False, content will be inserted to the left of any selection.
; $bIsFixed - [optional] a boolean value. Default is Null. If True, the value is static, that is, the value does not update if the source changes or all fields are updated.
; $sAuthor - [optional] a string value. Default is Null. The Author Name to insert. Note, $bIsFixed must be set to True for this value to stay the same as set.
; $bFullName - [optional] a boolean value. Default is Null. If True, displays the full name. Else Initials. For a Fixed custom name, this does nothing.
; Return values .: Success: Object.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $oCursor not an Object.
; @Error 1 @Extended 3 Return 0 = $oCursor is a Table Cursor, and is not supported.
; @Error 1 @Extended 4 Return 0 = $bOverwrite not a Boolean.
; @Error 1 @Extended 5 Return 0 = $bIsFixed not a Boolean.
; @Error 1 @Extended 6 Return 0 = $sAuthor not a String.
; @Error 1 @Extended 7 Return 0 = $bFullName not a Boolean.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error creating "com.sun.star.text.TextField.Author" Object.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Successfully inserted Author field, returning Author Field Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_FieldAuthorModify, _LOWriter_DocGetViewCursor, _LOWriter_DocCreateTextCursor, _LOWriter_CellCreateTextCursor, _LOWriter_FrameCreateTextCursor, _LOWriter_DocHeaderGetTextCursor, _LOWriter_DocFooterGetTextCursor, _LOWriter_EndnoteGetTextCursor, _LOWriter_FootnoteGetTextCursor
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldAuthorInsert(ByRef $oDoc, ByRef $oCursor, $bOverwrite = False, $bIsFixed = Null, $sAuthor = Null, $bFullName = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oAuthField
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oCursor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If (__LOWriter_Internal_CursorGetType($oCursor) = $LOW_CURTYPE_TABLE_CURSOR) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsBool($bOverwrite) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oAuthField = $oDoc.createInstance("com.sun.star.text.TextField.Author")
If Not IsObj($oAuthField) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
If ($bIsFixed <> Null) Then
If Not IsBool($bIsFixed) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oAuthField.IsFixed = $bIsFixed
EndIf
If ($sAuthor <> Null) Then
If Not IsString($sAuthor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$oAuthField.Content = $sAuthor
EndIf
If ($bFullName <> Null) Then
If Not IsBool($bFullName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
$oAuthField.FullName = $bFullName
EndIf
$oCursor.Text.insertTextContent($oCursor, $oAuthField, $bOverwrite)
If ($sAuthor <> Null) Then ; Sometimes Author Disappears upon Insertion, make a check to re-set the Author value.
If $oAuthField.Content <> $sAuthor And ($oAuthField.IsFixed() = True) Then $oAuthField.Content = $sAuthor
EndIf
If ($oAuthField.IsFixed() = False) Then $oAuthField.Update()
Return SetError($__LO_STATUS_SUCCESS, 0, $oAuthField)
EndFunc ;==>_LOWriter_FieldAuthorInsert
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldAuthorModify
; Description ...: Set or Retrieve a Author Field's settings.
; Syntax ........: _LOWriter_FieldAuthorModify(ByRef $oAuthField[, $bIsFixed = Null[, $sAuthor = Null[, $bFullName = Null]]])
; Parameters ....: $oAuthField - [in/out] an object. A Author field Object from _LOWriter_FieldAuthorInsert, or _LOWriter_FieldsGetList function.
; $bIsFixed - [optional] a boolean value. Default is Null. If True, the value is static, that is, the value does not update if the source changes or all fields are updated.
; $sAuthor - [optional] a string value. Default is Null. The Author Name to insert. Note, $bIsFixed must be set to True for this value to stay the same as set.
; $bFullName - [optional] a boolean value. Default is Null. If True, displays the full name. Else Initials.
; Return values .: Success: 1 or Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oAuthField not an Object.
; @Error 1 @Extended 2 Return 0 = $bIsFixed not a Boolean.
; @Error 1 @Extended 3 Return 0 = $sAuthor not a String.
; @Error 1 @Extended 4 Return 0 = $bFullName not a Boolean.
; --Property Setting Errors--
; @Error 4 @Extended ? Return 0 = Some settings were not successfully set. Use BitAND to test @Extended for the following values:
; | 1 = Error setting $bIsFixed
; | 2 = Error setting $sAuthor
; | 4 = Error setting $bFullName
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 3 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current settings.
; Call any optional parameter with Null keyword to skip it.
; Related .......: _LOWriter_FieldAuthorInsert, _LOWriter_FieldsGetList
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldAuthorModify(ByRef $oAuthField, $bIsFixed = Null, $sAuthor = Null, $bFullName = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local $avAuth[3]
If Not IsObj($oAuthField) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_VarsAreNull($bIsFixed, $sAuthor, $bFullName) Then
__LOWriter_ArrayFill($avAuth, $oAuthField.IsFIxed(), $oAuthField.Content(), $oAuthField.FullName())
Return SetError($__LO_STATUS_SUCCESS, 1, $avAuth)
EndIf
If ($bIsFixed <> Null) Then
If Not IsBool($bIsFixed) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oAuthField.IsFIxed = $bIsFixed
$iError = ($oAuthField.IsFIxed() = $bIsFixed) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($sAuthor <> Null) Then
If Not IsString($sAuthor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oAuthField.Content = $sAuthor
$iError = ($oAuthField.Content() = $sAuthor) ? ($iError) : (BitOR($iError, 2))
EndIf
If ($bFullName <> Null) Then
If Not IsBool($bFullName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oAuthField.FullName = $bFullName
$iError = ($oAuthField.FullName() = $bFullName) ? ($iError) : (BitOR($iError, 4))
EndIf
$oAuthField.Update()
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_FieldAuthorModify
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldChapterInsert
; Description ...: Insert a Chapter Field.
; Syntax ........: _LOWriter_FieldChapterInsert(ByRef $oDoc, ByRef $oCursor[, $bOverwrite = False[, $iChapFrmt = Null[, $iLevel = Null]]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oCursor - [in/out] an object. A Cursor Object returned from any Cursor Object creation Or retrieval function. Cannot be a Table Cursor.
; $bOverwrite - [optional] a boolean value. Default is False. If True, any content selected by the cursor will be overwritten. If False, content will be inserted to the left of any selection.
; $iChapFrmt - [optional] an integer value (0-4). Default is Null. The Display format for the Chapter Field. See Constants, $LOW_FIELD_CHAP_FRMT_* as defined in LibreOfficeWriter_Constants.au3.
; $iLevel - [optional] an integer value (1-10). Default is Null. The Chapter level to display.
; Return values .: Success: Object.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $oCursor not an Object.
; @Error 1 @Extended 3 Return 0 = $oCursor is a Table Cursor, and is not supported.
; @Error 1 @Extended 4 Return 0 = $bOverwrite not a Boolean.
; @Error 1 @Extended 5 Return 0 = $iChapFrmt not an integer, less than 0, or greater than 4. See Constants, $LOW_FIELD_CHAP_FRMT_* as defined in LibreOfficeWriter_Constants.au3.
; @Error 1 @Extended 6 Return 0 = $iLevel not an Integer, less than 1, or greater than 10.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error creating "com.sun.star.text.TextField.Chapter" Object.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Successfully inserted Chapter field, returning Chapter Field Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_FieldChapterModify, _LOWriter_DocGetViewCursor, _LOWriter_DocCreateTextCursor, _LOWriter_CellCreateTextCursor, _LOWriter_FrameCreateTextCursor, _LOWriter_DocHeaderGetTextCursor, _LOWriter_DocFooterGetTextCursor, _LOWriter_EndnoteGetTextCursor, _LOWriter_FootnoteGetTextCursor
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldChapterInsert(ByRef $oDoc, ByRef $oCursor, $bOverwrite = False, $iChapFrmt = Null, $iLevel = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oChapField
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oCursor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If (__LOWriter_Internal_CursorGetType($oCursor) = $LOW_CURTYPE_TABLE_CURSOR) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsBool($bOverwrite) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oChapField = $oDoc.createInstance("com.sun.star.text.TextField.Chapter")
If Not IsObj($oChapField) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
If ($iChapFrmt <> Null) Then
If Not __LOWriter_IntIsBetween($iChapFrmt, $LOW_FIELD_CHAP_FRMT_NAME, $LOW_FIELD_CHAP_FRMT_DIGIT) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oChapField.ChapterFormat = $iChapFrmt
EndIf
If ($iLevel <> Null) Then
If Not __LOWriter_IntIsBetween($iLevel, 1, 10) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$oChapField.Level = ($iLevel - 1) ; Level is 0 Based
EndIf
$oCursor.Text.insertTextContent($oCursor, $oChapField, $bOverwrite)
$oChapField.Update()
Return SetError($__LO_STATUS_SUCCESS, 0, $oChapField)
EndFunc ;==>_LOWriter_FieldChapterInsert
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldChapterModify
; Description ...: Set or Retrieve a Chapter Field's settings.
; Syntax ........: _LOWriter_FieldChapterModify(ByRef $oChapField[, $iChapFrmt = Null[, $iLevel = Null]])
; Parameters ....: $oChapField - [in/out] an object. A Chapter field Object from a previous_LOWriter_FieldChapterInsert, or _LOWriter_FieldsGetList function.
; $iChapFrmt - [optional] an integer value (0-4). Default is Null. The Display format for the Chapter Field. See Constants, $LOW_FIELD_CHAP_FRMT_* as defined in LibreOfficeWriter_Constants.au3.
; $iLevel - [optional] an integer value (1-10). Default is Null. The Chapter level to display.
; Return values .: Success: 1 or Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oChapField not an Object.
; @Error 1 @Extended 2 Return 0 = $iChapFrmt not an integer, less than 0, or greater than 4. See Constants, $LOW_FIELD_CHAP_FRMT_* as defined in LibreOfficeWriter_Constants.au3.
; @Error 1 @Extended 3 Return 0 = $iLevel not an Integer, less than 1, or greater than 10.
; --Property Setting Errors--
; @Error 4 @Extended ? Return 0 = Some settings were not successfully set. Use BitAND to test @Extended for the following values:
; | 1 = Error setting $iChapFrmt
; | 2 = Error setting $iLevel
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 2 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current settings.
; Call any optional parameter with Null keyword to skip it.
; Related .......: _LOWriter_FieldChapterInsert, _LOWriter_FieldsGetList
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldChapterModify(ByRef $oChapField, $iChapFrmt = Null, $iLevel = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local $aiChap[2]
If Not IsObj($oChapField) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_VarsAreNull($iChapFrmt, $iLevel) Then
__LOWriter_ArrayFill($aiChap, $oChapField.ChapterFormat(), ($oChapField.Level() + 1)) ; Level is 0 Based -- Add 1 to make it like L.O. UI
Return SetError($__LO_STATUS_SUCCESS, 1, $aiChap)
EndIf
If ($iChapFrmt <> Null) Then
If Not __LOWriter_IntIsBetween($iChapFrmt, $LOW_FIELD_CHAP_FRMT_NAME, $LOW_FIELD_CHAP_FRMT_DIGIT) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oChapField.ChapterFormat = $iChapFrmt
$iError = ($oChapField.ChapterFormat() = $iChapFrmt) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($iLevel <> Null) Then
If Not __LOWriter_IntIsBetween($iLevel, 1, 10) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oChapField.Level = ($iLevel - 1) ; Level is 0 Based
$iError = ($oChapField.Level() = ($iLevel - 1)) ? ($iError) : (BitOR($iError, 2))
EndIf
$oChapField.Update()
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_FieldChapterModify
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldCombCharInsert
; Description ...: Insert a Combined Character Field.
; Syntax ........: _LOWriter_FieldCombCharInsert(ByRef $oDoc, ByRef $oCursor[, $bOverwrite = False[, $sCharacters = Null]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oCursor - [in/out] an object. A Cursor Object returned from any Cursor Object creation Or retrieval function. Cannot be a Table Cursor.
; $bOverwrite - [optional] a boolean value. Default is False. If True, any content selected by the cursor will be overwritten. If False, content will be inserted to the left of any selection.
; $sCharacters - [optional] a string value. Default is Null. The Characters to insert in a combined character field. Max 6 character String Length.
; Return values .: Success: Object.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $oCursor not an Object.
; @Error 1 @Extended 3 Return 0 = $oCursor is a Table Cursor, and is not supported.
; @Error 1 @Extended 4 Return 0 = $bOverwrite not a Boolean.
; @Error 1 @Extended 5 Return 0 = $sCharacters not a String.
; @Error 1 @Extended 6 Return 0 = $sCharacters longer than 6 characters.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error creating "com.sun.star.text.TextField.CombinedCharacters" Object.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Successfully inserted Combined Character field, returning Combined Character Field Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_FieldCombCharModify, _LOWriter_DocGetViewCursor, _LOWriter_DocCreateTextCursor, _LOWriter_CellCreateTextCursor, _LOWriter_FrameCreateTextCursor, _LOWriter_DocHeaderGetTextCursor, _LOWriter_DocFooterGetTextCursor, _LOWriter_EndnoteGetTextCursor, _LOWriter_FootnoteGetTextCursor
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldCombCharInsert(ByRef $oDoc, ByRef $oCursor, $bOverwrite = False, $sCharacters = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oCombCharField
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oCursor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If (__LOWriter_Internal_CursorGetType($oCursor) = $LOW_CURTYPE_TABLE_CURSOR) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsBool($bOverwrite) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oCombCharField = $oDoc.createInstance("com.sun.star.text.TextField.CombinedCharacters")
If Not IsObj($oCombCharField) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
If ($sCharacters <> Null) Then
If Not IsString($sCharacters) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
If (StringLen($sCharacters) > 6) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$oCombCharField.Content = $sCharacters
EndIf
$oCursor.Text.insertTextContent($oCursor, $oCombCharField, $bOverwrite)
$oCombCharField.Update()
Return SetError($__LO_STATUS_SUCCESS, 0, $oCombCharField)
EndFunc ;==>_LOWriter_FieldCombCharInsert
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldCombCharModify
; Description ...: Set or Retrieve a Combined Character Field's settings.
; Syntax ........: _LOWriter_FieldCombCharModify(ByRef $oCombCharField[, $sCharacters = Null])
; Parameters ....: $oCombCharField - [in/out] an object. A Combined Character field Object from a previous _LOWriter_FieldCombCharInsert, or _LOWriter_FieldsGetList( function.
; $sCharacters - [optional] a string value. Default is Null. The Characters to insert in a combined character field. Max 6 character String Length.
; Return values .: Success: 1 or String.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $sCharacters not a String.
; @Error 1 @Extended 3 Return 0 = String called in $sCharacters longer than 6 characters.
; --Property Setting Errors--
; @Error 4 @Extended ? Return 0 = Some settings were not successfully set. Use BitAND to test @Extended for the following values:
; | 1 = Error setting $sCharacters
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return String = Success. All optional parameters were set to Null, returning current Combined Characters value.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current settings.
; Call any optional parameter with Null keyword to skip it.
; Related .......: _LOWriter_FieldCombCharInsert, _LOWriter_FieldsGetList
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldCombCharModify(ByRef $oCombCharField, $sCharacters = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
If Not IsObj($oCombCharField) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_VarsAreNull($sCharacters) Then Return SetError($__LO_STATUS_SUCCESS, 1, $oCombCharField.Content())
If Not IsString($sCharacters) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If (StringLen($sCharacters) > 6) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oCombCharField.Content = $sCharacters
$iError = ($oCombCharField.Content() = $sCharacters) ? ($iError) : (BitOR($iError, 1))
$oCombCharField.Update()
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_FieldCombCharModify
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldCommentInsert
; Description ...: Insert a Comment field into a document at a cursor's position.
; Syntax ........: _LOWriter_FieldCommentInsert(ByRef $oDoc, ByRef $oCursor[, $bOverwrite = False[, $sContent = Null[, $sAuthor = Null[, $tDateStruct = Null[, $sInitials = Null[, $sName = Null[, $bResolved = Null]]]]]]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oCursor - [in/out] an object. A Cursor Object returned from any Cursor Object creation Or retrieval function. Cannot be a Table Cursor.
; $bOverwrite - [optional] a boolean value. Default is False. If True, any content selected by the cursor will be overwritten. If False, content will be inserted to the left of any selection.
; $sContent - [optional] a string value. Default is Null. The content of the comment.
; $sAuthor - [optional] a string value. Default is Null. The author of the comment.
; $tDateStruct - [optional] a dll struct value. Default is Null. The date to display for the comment, created previously by _LOWriter_DateStructCreate. If left as Null, the current date is used.
; $sInitials - [optional] a string value. Default is Null. The Initials of the creator. Libre Office version 4.0 and up only.
; $sName - [optional] a string value. Default is Null. The name of the creator. Libre Office version 4.0 and up only.
; $bResolved - [optional] a boolean value. Default is Null. If True, the comment is marked as resolved.
; Return values .: Success: Object.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $oCursor not an Object.
; @Error 1 @Extended 3 Return 0 = $oCursor is a Table Cursor, and is not supported.
; @Error 1 @Extended 4 Return 0 = $bOverwrite not a Boolean.
; @Error 1 @Extended 5 Return 0 = $sContent not a String.
; @Error 1 @Extended 6 Return 0 = $sAuthor not a String.
; @Error 1 @Extended 7 Return 0 = $tDateStruct not an Object.
; @Error 1 @Extended 8 Return 0 = $sInitials not a String.
; @Error 1 @Extended 9 Return 0 = $sName not a String.
; @Error 1 @Extended 10 Return 0 = $bResolved not a Boolean.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error creating "com.sun.star.text.TextField.Annotation" Object.
; --Version Related Errors--
; @Error 7 @Extended 1 Return 0 = Current Libre Office Version lower than 4.0.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Successfully inserted comment field, returning Comment Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_FieldCommentModify, _LOWriter_DocGetViewCursor, _LOWriter_DocCreateTextCursor, _LOWriter_CellCreateTextCursor, _LOWriter_FrameCreateTextCursor, _LOWriter_DocHeaderGetTextCursor, _LOWriter_DocFooterGetTextCursor, _LOWriter_EndnoteGetTextCursor, _LOWriter_FootnoteGetTextCursor, _LOWriter_DateStructCreate _LOWriter_DateStructModify
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldCommentInsert(ByRef $oDoc, ByRef $oCursor, $bOverwrite = False, $sContent = Null, $sAuthor = Null, $tDateStruct = Null, $sInitials = Null, $sName = Null, $bResolved = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oCommentField
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oCursor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If (__LOWriter_Internal_CursorGetType($oCursor) = $LOW_CURTYPE_TABLE_CURSOR) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsBool($bOverwrite) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oCommentField = $oDoc.createInstance("com.sun.star.text.TextField.Annotation")
If Not IsObj($oCommentField) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
If ($sContent <> Null) Then
If Not IsString($sContent) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oCommentField.Content = $sContent
Else
$oCommentField.Content = " " ;If Content is Blank, Comment/Annotation will disappear.
EndIf
If ($sAuthor <> Null) Then
If Not IsString($sAuthor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$oCommentField.Author = $sAuthor
EndIf
If ($tDateStruct <> Null) Then
If Not IsObj($tDateStruct) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
$oCommentField.DateTimeValue = $tDateStruct
Else
$oCommentField.DateTimeValue = _LOWriter_DateStructCreate()
EndIf
If ($sInitials <> Null) Then
If Not IsString($sInitials) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0)
If Not __LOWriter_VersionCheck(4.0) Then Return SetError($__LO_STATUS_VER_ERROR, 1, 0)
$oCommentField.Initials = $sInitials
EndIf
If ($sName <> Null) Then
If Not IsString($sName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 9, 0)
If Not __LOWriter_VersionCheck(4.0) Then Return SetError($__LO_STATUS_VER_ERROR, 1, 0)
$oCommentField.Name = $sName
EndIf
If ($bResolved <> Null) Then
If Not IsBool($bResolved) Then Return SetError($__LO_STATUS_INPUT_ERROR, 10, 0)
$oCommentField.Resolved = $bResolved
EndIf
$oCursor.Text.insertTextContent($oCursor, $oCommentField, $bOverwrite)
$oCommentField.Update()
Return SetError($__LO_STATUS_SUCCESS, 0, $oCommentField)
EndFunc ;==>_LOWriter_FieldCommentInsert
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldCommentModify
; Description ...: Set or retrieve Comment settings.
; Syntax ........: _LOWriter_FieldCommentModify(ByRef $oDoc, ByRef $oCommentField[, $sContent = Null[, $sAuthor = Null[, $tDateStruct = Null[, $sInitials = Null[, $sName = Null[, $bResolved = Null]]]]]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oCommentField - [in/out] an object. A Comment field Object from a previous _LOWriter_FieldCommentInsert, or _LOWriter_FieldsGetList function.
; $sContent - [optional] a string value. Default is Null. The content of the comment.
; $sAuthor - [optional] a string value. Default is Null. The author of the comment.
; $tDateStruct - [optional] a dll struct value. Default is Null. The date to display for the comment, created previously by _LOWriter_DateStructCreate.
; $sInitials - [optional] a string value. Default is Null. The Initials of the creator. Libre Office version 4.0 and up only.
; $sName - [optional] a string value. Default is Null. The name of the creator. Libre Office version 4.0 and up only.
; $bResolved - [optional] a boolean value. Default is Null. If True, the comment is marked as resolved.
; Return values .: Success: 1 or Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $oCommentField not an Object.
; @Error 1 @Extended 3 Return 0 = $sContent not a String.
; @Error 1 @Extended 4 Return 0 = $sAuthor not a String.
; @Error 1 @Extended 5 Return 0 = $tDateStruct not an Object.
; @Error 1 @Extended 6 Return 0 = $sInitials not a String.
; @Error 1 @Extended 7 Return 0 = $sName not a String.
; @Error 1 @Extended 8 Return 0 = $bResolved not a Boolean.
; --Version Related Errors--
; @Error 7 @Extended 1 Return 0 = Current Libre Office Version lower than 4.0.
; --Property Setting Errors--
; @Error 4 @Extended ? Return 0 = Some settings were not successfully set. Use BitAND to test @Extended for the following values:
; | 1 = Error setting $sContent
; | 2 = Error setting $sAuthor
; | 4 = Error setting $tDateStruct
; | 8 = Error setting $sInitials
; | 16 = Error setting $sName
; | 32 = Error setting $bResolved
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 4 Element Array If L.O. version is less than 4.0, else a 6 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current settings.
; Call any optional parameter with Null keyword to skip it.
; Related .......: _LOWriter_FieldCommentInsert, _LOWriter_FieldsGetList, _LOWriter_DateStructCreate _LOWriter_DateStructModify
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldCommentModify(ByRef $oDoc, ByRef $oCommentField, $sContent = Null, $sAuthor = Null, $tDateStruct = Null, $sInitials = Null, $sName = Null, $bResolved = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local $avAnnot[4]
Local $bRefresh = False
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oCommentField) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If __LOWriter_VarsAreNull($sContent, $sAuthor, $tDateStruct, $sInitials, $sName, $bResolved) Then
If __LOWriter_VersionCheck(4.0) Then
__LOWriter_ArrayFill($avAnnot, $oCommentField.Content(), $oCommentField.Author(), $oCommentField.DateTimeValue(), $oCommentField.Initials(), _
$oCommentField.Name(), $oCommentField.Resolved())
Else
__LOWriter_ArrayFill($avAnnot, $oCommentField.Content(), $oCommentField.Author(), $oCommentField.DateTimeValue(), $oCommentField.Resolved())
EndIf
Return SetError($__LO_STATUS_SUCCESS, 1, $avAnnot)
EndIf
If ($sContent <> Null) Then
If Not IsString($sContent) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oCommentField.Content = $sContent
$iError = ($oCommentField.Content() = $sContent) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($sAuthor <> Null) Then
If Not IsString($sAuthor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oCommentField.Author = $sAuthor
$iError = ($oCommentField.Author() = $sAuthor) ? ($iError) : (BitOR($iError, 2))
EndIf
If ($tDateStruct <> Null) Then
If Not IsObj($tDateStruct) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oCommentField.DateTimeValue = $tDateStruct
$iError = (__LOWriter_DateStructCompare($oCommentField.DateTimeValue(), $tDateStruct)) ? ($iError) : (BitOR($iError, 4))
$bRefresh = True
EndIf
If ($sInitials <> Null) Then
If Not IsString($sInitials) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
If Not __LOWriter_VersionCheck(4.0) Then Return SetError($__LO_STATUS_VER_ERROR, 1, 0)
$oCommentField.Initials = $sInitials
$iError = ($oCommentField.Initials() = $sInitials) ? ($iError) : (BitOR($iError, 8))
EndIf
If ($sName <> Null) Then
If Not IsString($sName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
If Not __LOWriter_VersionCheck(4.0) Then Return SetError($__LO_STATUS_VER_ERROR, 1, 0)
$oCommentField.Name = $sName
$iError = ($oCommentField.Name = $sName) ? ($iError) : (BitOR($iError, 16))
EndIf
If ($bResolved <> Null) Then
If Not IsBool($bResolved) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0)
$oCommentField.Resolved = $bResolved
$iError = ($oCommentField.Resolved() = $bResolved) ? ($iError) : (BitOR($iError, 32))
$bRefresh = True
EndIf
If ($bRefresh = True) Then _
$oDoc.Text.createTextCursorByRange($oCommentField.Anchor()).Text.insertTextContent($oCommentField.Anchor(), $oCommentField, True)
$oCommentField.Update()
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_FieldCommentModify
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldCondTextInsert
; Description ...: Insert a Conditional Text Field.
; Syntax ........: _LOWriter_FieldCondTextInsert(ByRef $oDoc, ByRef $oCursor[, $bOverwrite = False[, $sCondition = Null[, $sThen = Null[, $sElse = Null]]]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oCursor - [in/out] an object. A Cursor Object returned from any Cursor Object creation Or retrieval function. Cannot be a Table Cursor.
; $bOverwrite - [optional] a boolean value. Default is False. If True, any content selected by the cursor will be overwritten. If False, content will be inserted to the left of any selection.
; $sCondition - [optional] a string value. Default is Null. The condition to test.
; $sThen - [optional] a string value. Default is Null. The text to display if the condition is True.
; $sElse - [optional] a string value. Default is Null. The text to display if the condition is False.
; Return values .: Success: Object.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $oCursor not an Object.
; @Error 1 @Extended 3 Return 0 = $oCursor is a Table Cursor, and is not supported.
; @Error 1 @Extended 4 Return 0 = $bOverwrite not a Boolean.
; @Error 1 @Extended 5 Return 0 = $sCondition not a String.
; @Error 1 @Extended 6 Return 0 = $sThen not a String.
; @Error 1 @Extended 7 Return 0 = $sElse not a String.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error creating "com.sun.star.text.TextField.ConditionalText" Object.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Successfully inserted a Conditional Text field, returning the Conditional Text Field Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_FieldCondTextModify, _LOWriter_DocGetViewCursor, _LOWriter_DocCreateTextCursor, _LOWriter_CellCreateTextCursor, _LOWriter_FrameCreateTextCursor, _LOWriter_DocHeaderGetTextCursor, _LOWriter_DocFooterGetTextCursor, _LOWriter_EndnoteGetTextCursor, _LOWriter_FootnoteGetTextCursor
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldCondTextInsert(ByRef $oDoc, ByRef $oCursor, $bOverwrite = False, $sCondition = Null, $sThen = Null, $sElse = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oCondTextField
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oCursor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If (__LOWriter_Internal_CursorGetType($oCursor) = $LOW_CURTYPE_TABLE_CURSOR) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsBool($bOverwrite) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oCondTextField = $oDoc.createInstance("com.sun.star.text.TextField.ConditionalText")
If Not IsObj($oCondTextField) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
If ($sCondition <> Null) Then
If Not IsString($sCondition) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oCondTextField.Condition = $sCondition
EndIf
If ($sThen <> Null) Then
If Not IsString($sThen) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$oCondTextField.TrueContent = $sThen
EndIf
If ($sElse <> Null) Then
If Not IsString($sElse) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
$oCondTextField.FalseContent = $sElse
EndIf
$oCursor.Text.insertTextContent($oCursor, $oCondTextField, $bOverwrite)
$oCondTextField.Update()
Return SetError($__LO_STATUS_SUCCESS, 0, $oCondTextField)
EndFunc ;==>_LOWriter_FieldCondTextInsert
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldCondTextModify
; Description ...: Set or Retrieve a Conditional Text Field's settings.
; Syntax ........: _LOWriter_FieldCondTextModify(ByRef $oCondTextField[, $sCondition = Null[, $sThen = Null[, $sElse = Null]]])
; Parameters ....: $oCondTextField - [in/out] an object. A Conditional Text field Object from a previous _LOWriter_FieldCondTextInsert, or _LOWriter_FieldsGetList function.
; $sCondition - [optional] a string value. Default is Null. The condition to test.
; $sThen - [optional] a string value. Default is Null. The text to display if the condition is True.
; $sElse - [optional] a string value. Default is Null. The text to display if the condition is False.
; Return values .: Success: 1 or Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $sCondition not a String.
; @Error 1 @Extended 3 Return 0 = $sThen not a String.
; @Error 1 @Extended 4 Return 0 = $sElse not a String.
; --Property Setting Errors--
; @Error 4 @Extended ? Return 0 = Some settings were not successfully set. Use BitAND to test @Extended for the following values:
; | 1 = Error setting $sCondition
; | 2 = Error setting $sThen
; | 4 = Error setting $sElse
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 4 Element Array with values in order of function parameters, with an additional parameter in the last element to indicate if the condition is evaluated as True or not.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current settings.
; Call any optional parameter with Null keyword to skip it.
; Related .......: _LOWriter_FieldCondTextInsert, _LOWriter_FieldsGetList
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldCondTextModify(ByRef $oCondTextField, $sCondition = Null, $sThen = Null, $sElse = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local $avCond[4]
If Not IsObj($oCondTextField) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_VarsAreNull($sCondition, $sThen, $sElse) Then
__LOWriter_ArrayFill($avCond, $oCondTextField.Condition(), $oCondTextField.TrueContent(), $oCondTextField.FalseContent(), _
($oCondTextField.IsConditionTrue()) ? (False) : (True)) ; IsConditionTrue is Backwards.
Return SetError($__LO_STATUS_SUCCESS, 1, $avCond)
EndIf
If ($sCondition <> Null) Then
If Not IsString($sCondition) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oCondTextField.Condition = $sCondition
$iError = ($oCondTextField.Condition() = $sCondition) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($sThen <> Null) Then
If Not IsString($sThen) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oCondTextField.TrueContent = $sThen
$iError = ($oCondTextField.TrueContent() = $sThen) ? ($iError) : (BitOR($iError, 2))
EndIf
If ($sElse <> Null) Then
If Not IsString($sElse) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oCondTextField.FalseContent = $sElse
$iError = ($oCondTextField.FalseContent() = $sElse) ? ($iError) : (BitOR($iError, 4))
EndIf
$oCondTextField.Update()
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_FieldCondTextModify
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldCurrentDisplayGet
; Description ...: Retrieve the current data displayed by a field.
; Syntax ........: _LOWriter_FieldCurrentDisplayGet(ByRef $oField)
; Parameters ....: $oField - [in/out] an object. A Field Object returned from a previous insert, _LOWriter_FieldsGetList, _LOWriter_FieldsDocInfoGetList function.
; Return values .: Success: String
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oField not an Object.
; --Success--
; @Error 0 @Extended 0 Return String = Success. Returning current Field display content in String format.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: A Comment Field will return an empty string, use the Comment Field function to retrieve the current comment content. A DocInfoComments field will work with this function however.
; This will work for most Fields, but not all. Check and see which will work and which wont.
; Related .......: _LOWriter_FieldsGetList, _LOWriter_FieldsAdvGetList, _LOWriter_FieldsDocInfoGetList
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldCurrentDisplayGet(ByRef $oField)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $sPresentation
If Not IsObj($oField) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If ($oField.supportsService("com.sun.star.text.textfield.ConditionalText")) Then ; Conditional Text Fields don't update "CurrentPresentation" setting,
; so acquire the current display based on whether the condition is true or not.
$sPresentation = ($oField.IsConditionTrue() = False) ? ($oField.TrueContent()) : ($oField.FalseContent())
Else
$sPresentation = $oField.CurrentPresentation()
EndIf
Return SetError($__LO_STATUS_SUCCESS, 0, $sPresentation)
EndFunc ;==>_LOWriter_FieldCurrentDisplayGet
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldDateTimeInsert
; Description ...: Insert a Date and/or Time Field.
; Syntax ........: _LOWriter_FieldDateTimeInsert(ByRef $oDoc, ByRef $oCursor[, $bOverwrite = False[, $bIsFixed = Null[, $tDateStruct = Null[, $bIsDate = Null[, $iOffset = Null[, $iDateFormatKey = Null]]]]]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oCursor - [in/out] an object. A Cursor Object returned from any Cursor Object creation Or retrieval function. Cannot be a Table Cursor.
; $bOverwrite - [optional] a boolean value. Default is False. If True, any content selected by the cursor will be overwritten. If False, content will be inserted to the left of any selection.
; $bIsFixed - [optional] a boolean value. Default is Null. If True, the value is static, that is, the value does not update if the source changes or all fields are updated.
; $tDateStruct - [optional] a dll struct value. Default is Null. The date to display for the comment, created previously by _LOWriter_DateStructCreate.
; $bIsDate - [optional] a boolean value. Default is Null. If True, the field is considered as containing a Date, $iOffset will be evaluated in Days. Else if False, Field will be considered as containing a Time, $iOffset will be evaluated in minutes.
; $iOffset - [optional] an integer value. Default is Null. The offset to apply to the date, either in Minutes or Days, depending on the current $bIsDate setting.
; $iDateFormatKey - [optional] an integer value. Default is Null. A Date or Time Format Key returned from a previous _LOWriter_DateFormatKeyCreate or _LOWriter_DateFormatKeyList function.
; Return values .: Success: Object.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $oCursor not an Object.
; @Error 1 @Extended 3 Return 0 = $oCursor is a Table Cursor, and is not supported.
; @Error 1 @Extended 4 Return 0 = $bOverwrite not a Boolean.
; @Error 1 @Extended 5 Return 0 = $bIsFixed not a Boolean.
; @Error 1 @Extended 6 Return 0 = $tDateStruct not an Object.
; @Error 1 @Extended 7 Return 0 = $bIsDate not a Boolean.
; @Error 1 @Extended 8 Return 0 = $iOffset not an Integer.
; @Error 1 @Extended 9 Return 0 = $iDateFormatKey not an Integer.
; @Error 1 @Extended 10 Return 0 = $iDateFormatKey not found in current Document.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error creating "com.sun.star.text.TextField.DateTime" Object.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Successfully inserted Date/Time field, returning Date/Time Field Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_FieldDateTimeModify, _LOWriter_DocGetViewCursor, _LOWriter_DocCreateTextCursor, _LOWriter_CellCreateTextCursor, _LOWriter_FrameCreateTextCursor, _LOWriter_DocHeaderGetTextCursor, _LOWriter_DocFooterGetTextCursor, _LOWriter_EndnoteGetTextCursor, _LOWriter_FootnoteGetTextCursor, _LOWriter_DateStructCreate, _LOWriter_DateStructModify
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldDateTimeInsert(ByRef $oDoc, ByRef $oCursor, $bOverwrite = False, $bIsFixed = Null, $tDateStruct = Null, $bIsDate = Null, $iOffset = Null, $iDateFormatKey = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oDateTimeField
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oCursor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If (__LOWriter_Internal_CursorGetType($oCursor) = $LOW_CURTYPE_TABLE_CURSOR) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsBool($bOverwrite) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oDateTimeField = $oDoc.createInstance("com.sun.star.text.TextField.DateTime")
If Not IsObj($oDateTimeField) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
If ($bIsFixed <> Null) Then
If Not IsBool($bIsFixed) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oDateTimeField.IsFixed = $bIsFixed
EndIf
If ($tDateStruct <> Null) Then
If Not IsObj($tDateStruct) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$oDateTimeField.DateTimeValue = $tDateStruct
EndIf
If ($bIsDate <> Null) Then
If Not IsBool($bIsDate) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
$oDateTimeField.IsDate = $bIsDate
EndIf
If ($iOffset <> Null) Then
If Not IsInt($iOffset) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0)
$oDateTimeField.Adjust = ($oDateTimeField.IsDate() = True) ? (Int((1440 * $iOffset))) : ($iOffset)
; If IsDate = True, Then Calculate number of minutes in a day (1440) times number of days to off set the Date/ Value,
; else, just set it to Number of minutes called.
EndIf
If ($iDateFormatKey <> Null) Then
If Not IsInt($iDateFormatKey) Then Return SetError($__LO_STATUS_INPUT_ERROR, 9, 0)
If Not _LOWriter_DateFormatKeyExists($oDoc, $iDateFormatKey) Then Return SetError($__LO_STATUS_INPUT_ERROR, 10, 0)
$oDateTimeField.NumberFormat = $iDateFormatKey
EndIf
$oCursor.Text.insertTextContent($oCursor, $oDateTimeField, $bOverwrite)
If ($tDateStruct <> Null) Then ; Sometimes Content Disappears upon Insertion, make a check to re-set the Content value.
If (__LOWriter_DateStructCompare($oDateTimeField.DateTimeValue(), $tDateStruct) = False) And ($oDateTimeField.IsFixed() = True) Then $oDateTimeField.DateTimeValue = $tDateStruct
EndIf
If ($oDateTimeField.IsFixed() = False) Then $oDateTimeField.Update()
Return SetError($__LO_STATUS_SUCCESS, 0, $oDateTimeField)
EndFunc ;==>_LOWriter_FieldDateTimeInsert
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_FieldDateTimeModify
; Description ...: Set or Retrieve a Date/Time Field's settings.
; Syntax ........: _LOWriter_FieldDateTimeModify(ByRef $oDoc, ByRef $oDateTimeField[, $bIsFixed = Null[, $tDateStruct = Null[, $bIsDate = Null[, $iOffset = Null[, $iDateFormatKey = Null]]]]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oDateTimeField - [in/out] an object. A Date/Time field Object from a previous _LOWriter_FieldDateTimeInsert, or _LOWriter_FieldsGetList function.
; $bIsFixed - [optional] a boolean value. Default is Null. If True, the value is static, that is, the value does not update if the source changes or all fields are updated.
; $tDateStruct - [optional] a dll struct value. Default is Null. The date to display for the comment, created previously by _LOWriter_DateStructCreate.
; $bIsDate - [optional] a boolean value. Default is Null. If True, the field is considered as containing a Date, $iOffset will be evaluated in Days. Else False, Field will be considered as containing a Time, $iOffset will be evaluated in minutes.
; $iOffset - [optional] an integer value. Default is Null. The offset to apply to the date, either in Minutes or Days, depending on the current $bIsDate setting.
; $iDateFormatKey - [optional] an integer value. Default is Null. A Date or Time Format Key returned from a previous _LOWriter_DateFormatKeyCreate or _LOWriter_DateFormatKeyList function.
; Return values .: Success: 1 or Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oDoc not an Object.
; @Error 1 @Extended 2 Return 0 = $oDateTimeField not an Object.
; @Error 1 @Extended 3 Return 0 = $bIsFixed not a Boolean.
; @Error 1 @Extended 4 Return 0 = $tDateStruct not an Object.
; @Error 1 @Extended 5 Return 0 = $bIsDate not a Boolean.
; @Error 1 @Extended 6 Return 0 = $iOffset not an Integer.
; @Error 1 @Extended 7 Return 0 = $iDateFormatKey not an Integer.
; @Error 1 @Extended 8 Return 0 = $iDateFormatKey not found in current Document.
; --Property Setting Errors--
; @Error 4 @Extended ? Return 0 = Some settings were not successfully set. Use BitAND to test @Extended for the following values:
; | 1 = Error setting $bIsFixed
; | 2 = Error setting $tDateStruct
; | 4 = Error setting $bIsDate
; | 8 = Error setting $iOffset
; | 16 = Error setting $iDateFormatKey
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 5 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current settings.
; Call any optional parameter with Null keyword to skip it.
; Related .......: _LOWriter_FieldDateTimeInsert, _LOWriter_FieldsGetList, _LOWriter_DateStructCreate, _LOWriter_DateStructModify
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_FieldDateTimeModify(ByRef $oDoc, ByRef $oDateTimeField, $bIsFixed = Null, $tDateStruct = Null, $bIsDate = Null, $iOffset = Null, $iDateFormatKey = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0, $iNumberFormat
Local $avDateTime[5]
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oDateTimeField) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If __LOWriter_VarsAreNull($bIsFixed, $tDateStruct, $bIsDate, $iOffset, $iDateFormatKey) Then