-
Notifications
You must be signed in to change notification settings - Fork 1
/
LibreOfficeWriter_Table.au3
2043 lines (1838 loc) · 148 KB
/
LibreOfficeWriter_Table.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_Page.au3"
; #INDEX# =======================================================================================================================
; Title .........: LibreOffice UDF
; AutoIt Version : v3.3.16.1
; Description ...: Provides basic functionality through AutoIt for Creating, Modifying, and Inserting Tables in L.O. Writer.
; Author(s) .....: donnyh13, mLipok
; Dll ...........:
;
; ===============================================================================================================================
; #CURRENT# =====================================================================================================================
; _LOWriter_TableBorderColor
; _LOWriter_TableBorderPadding
; _LOWriter_TableBorderStyle
; _LOWriter_TableBorderWidth
; _LOWriter_TableBreak
; _LOWriter_TableCellsGetNames
; _LOWriter_TableColor
; _LOWriter_TableColumnDelete
; _LOWriter_TableColumnGetCount
; _LOWriter_TableColumnInsert
; _LOWriter_TableCreate
; _LOWriter_TableCreateCursor
; _LOWriter_TableCursor
; _LOWriter_TableDelete
; _LOWriter_TableExists
; _LOWriter_TableGetCellObjByCursor
; _LOWriter_TableGetCellObjByName
; _LOWriter_TableGetCellObjByPosition
; _LOWriter_TableGetData
; _LOWriter_TableGetObjByCursor
; _LOWriter_TableGetObjByName
; _LOWriter_TableInsert
; _LOWriter_TableMargin
; _LOWriter_TableProperties
; _LOWriter_TableRowColor
; _LOWriter_TableRowDelete
; _LOWriter_TableRowGetCount
; _LOWriter_TableRowInsert
; _LOWriter_TableRowProperty
; _LOWriter_TableSetData
; _LOWriter_TablesGetNames
; _LOWriter_TableShadow
; _LOWriter_TableWidth
; ===============================================================================================================================
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableBorderColor
; Description ...: Set and Retrieve the Table Border Line Color. Libre Office Version 3.6 and Up.
; Syntax ........: _LOWriter_TableBorderColor(ByRef $oTable[, $iTop = Null[, $iBottom = Null[, $iLeft = Null[, $iRight = Null[, $iVert = Null[, $iHori = Null]]]]]])
; Parameters ....: $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; $iTop - [optional] an integer value (0-16777215). Default is Null. Set the Top Border Line Color of the Table in Long Color code format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; $iBottom - [optional] an integer value (0-16777215). Default is Null. Set the Bottom Border Line Color of the Table in Long Color code format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; $iLeft - [optional] an integer value (0-16777215). Default is Null. Set the Left Border Line Color of the Table in Long Color code format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; $iRight - [optional] an integer value (0-16777215). Default is Null. Set the Right Border Line Color of the Table in Long Color code format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; $iVert - [optional] an integer value (0-16777215). Default is Null. Set the Vertical Border Line Color of the Table in Long Color code format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; $iHori - [optional] an integer value (0-16777215). Default is Null. Set the Horizontal Border Line Color of the Table in Long Color code format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; 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 = $oTable not an Object.
; @Error 1 @Extended 2 Return 0 = $iTop not an integer, or set to less than 0, or greater than 16,777,215.
; @Error 1 @Extended 3 Return 0 = $iBottom not an integer, or set to less than 0, or greater than 16,777,215.
; @Error 1 @Extended 4 Return 0 = $iLeft not an integer, or set to less than 0, or greater than 16,777,215.
; @Error 1 @Extended 5 Return 0 = $iRight not an integer, or set to less than 0, or greater than 16,777,215.
; @Error 1 @Extended 6 Return 0 = $iVert not an integer, or set to less than 0, or greater than 16,777,215.
; @Error 1 @Extended 7 Return 0 = $iHori not an integer, or set to less than 0, or greater than 16,777,215.
; @Error 1 @Extended 8 Return 0 = Table called in $oTable is a Table that has not been inserted into the document yet.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error Creating Object "com.sun.star.table.BorderLine2"
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Internal command error. More than one set to True. UDF Must be fixed.
; @Error 3 @Extended 2 Return 0 = Error retrieving Object "TableBorder2".
; --Property Setting Errors--
; @Error 4 @Extended 1 Return 0 = Cannot set Top Border Color when Top Border width not set.
; @Error 4 @Extended 2 Return 0 = Cannot set Bottom Border Color when Bottom Border width not set.
; @Error 4 @Extended 3 Return 0 = Cannot set Left Border Color when Left Border width not set.
; @Error 4 @Extended 4 Return 0 = Cannot set Right Border Color when Right Border width not set.
; @Error 4 @Extended 5 Return 0 = Cannot set Vertical Border Color when Vertical Border width not set.
; @Error 4 @Extended 6 Return 0 = Cannot set Horizontal Border Color when Horizontal Border width not set.
; --Version Related Errors--
; @Error 7 @Extended 1 Return 0 = Current Libre Office version lower than 3.6.
; --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 6 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Border Width must be set first to be able to set Border Style and Color.
; 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.
; Error values for Initialization and Processing, are passed from the internal border setting function.
; Related .......: _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName, _LOWriter_ConvertColorFromLong, _LOWriter_ConvertColorToLong, _LOWriter_TableBorderWidth, _LOWriter_TableBorderStyle, _LOWriter_TableBorderPadding
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableBorderColor(ByRef $oTable, $iTop = Null, $iBottom = Null, $iLeft = Null, $iRight = Null, $iVert = Null, $iHori = Null)
Local $vReturn
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If ($iTop <> Null) And Not __LOWriter_IntIsBetween($iTop, $LOW_COLOR_BLACK, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If ($iBottom <> Null) And Not __LOWriter_IntIsBetween($iBottom, $LOW_COLOR_BLACK, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If ($iLeft <> Null) And Not __LOWriter_IntIsBetween($iLeft, $LOW_COLOR_BLACK, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
If ($iRight <> Null) And Not __LOWriter_IntIsBetween($iRight, $LOW_COLOR_BLACK, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
If ($iVert <> Null) And Not __LOWriter_IntIsBetween($iVert, $LOW_COLOR_BLACK, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
If ($iHori <> Null) And Not __LOWriter_IntIsBetween($iHori, $LOW_COLOR_BLACK, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
If Not __LOWriter_IsTableInDoc($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0) ; Table not in document.
$vReturn = __LOWriter_TableBorder($oTable, False, False, True, $iTop, $iBottom, $iLeft, $iRight, $iVert, $iHori)
Return SetError(@error, @extended, $vReturn)
EndFunc ;==>_LOWriter_TableBorderColor
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableBorderPadding
; Description ...: Set or retrieve the Border Padding (spacing between the Table text and border) settings.
; Syntax ........: _LOWriter_TableBorderPadding(ByRef $oTable[, $iTop = Null[, $iBottom = Null[, $iLeft = Null[, $iRight = Null]]]])
; Parameters ....: $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; $iTop - [optional] an integer value. Default is Null. Set the Top Distance between the Border and Table contents in Micrometers(uM).
; $iBottom - [optional] an integer value. Default is Null. Set the Bottom Distance between the Border and Table contents in Micrometers(uM).
; $iLeft - [optional] an integer value. Default is Null. Set the Left Distance between the Border and Table contents in Micrometers(uM).
; $iRight - [optional] an integer value. Default is Null. Set the Right Distance between the Border and Table contents in Micrometers(uM).
; 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 = $oTable not an Object.
; @Error 1 @Extended 2 Return 0 = $oTable not inserted in Document.
; @Error 1 @Extended 3 Return 0 = $iTop not an Integer.
; @Error 1 @Extended 4 Return 0 = $iBottom not an Integer.
; @Error 1 @Extended 5 Return 0 = $Left not an Integer.
; @Error 1 @Extended 6 Return 0 = $iRight not an Integer.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Error retrieving TableBorderDistances Object.
; @Error 3 @Extended 2 Return 0 = Error retrieving TableBorderDistances Object for Error checking.
; --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 $iTop border distance
; | 2 = Error setting $iBottom border distance
; | 4 = Error setting $iLeft border distance
; | 8 = Error setting $iRight border distance
; --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.
; 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_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName, _LOWriter_ConvertFromMicrometer, _LOWriter_ConvertToMicrometer, _LOWriter_TableBorderWidth, _LOWriter_TableBorderStyle, _LOWriter_TableBorderColor
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableBorderPadding(ByRef $oTable, $iTop = Null, $iBottom = Null, $iLeft = Null, $iRight = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local $tBD
Local $aiBPadding[4]
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not __LOWriter_IsTableInDoc($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If __LOWriter_VarsAreNull($iTop, $iBottom, $iLeft, $iRight) Then
__LOWriter_ArrayFill($aiBPadding, $oTable.TableBorderDistances.TopDistance(), $oTable.TableBorderDistances.BottomDistance(), _
$oTable.TableBorderDistances.LeftDistance(), $oTable.TableBorderDistances.RightDistance())
Return SetError($__LO_STATUS_SUCCESS, 1, $aiBPadding)
EndIf
$tBD = $oTable.TableBorderDistances()
If Not IsObj($tBD) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If ($iTop <> Null) Then
If Not __LOWriter_IntIsBetween($iTop, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$tBD.TopDistance = $iTop
EndIf
If ($iBottom <> Null) Then
If Not __LOWriter_IntIsBetween($iBottom, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$tBD.BottomDistance = $iBottom
EndIf
If ($iLeft <> Null) Then
If Not __LOWriter_IntIsBetween($iLeft, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$tBD.LeftDistance = $iLeft
EndIf
If ($iRight <> Null) Then
If Not __LOWriter_IntIsBetween($iRight, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$tBD.RightDistance = $iRight
EndIf
$oTable.TableBorderDistances = $tBD
; Error Checking.
$tBD = $oTable.TableBorderDistances()
If Not IsObj($tBD) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
$iError = ($iTop = Null) ? ($iError) : ((__LOWriter_IntIsBetween($tBD.TopDistance(), $iTop - 1, $iTop + 1)) ? ($iError) : (BitOR($iError, 1)))
$iError = ($iBottom = Null) ? ($iError) : ((__LOWriter_IntIsBetween($tBD.BottomDistance(), $iBottom - 1, $iBottom + 1)) ? ($iError) : (BitOR($iError, 2)))
$iError = ($iLeft = Null) ? ($iError) : ((__LOWriter_IntIsBetween($tBD.LeftDistance(), $iLeft - 1, $iLeft + 1)) ? ($iError) : (BitOR($iError, 4)))
$iError = ($iRight = Null) ? ($iError) : ((__LOWriter_IntIsBetween($tBD.RightDistance(), $iRight - 1, $iRight + 1)) ? ($iError) : (BitOR($iError, 8)))
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_TableBorderPadding
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableBorderStyle
; Description ...: Set and Retrieve the Table Border Line style. Libre Office Version 3.6 and Up.
; Syntax ........: _LOWriter_TableBorderStyle(ByRef $oTable[, $iTop = Null[, $iBottom = Null[, $iLeft = Null[, $iRight = Null[, $iVert = Null[, $iHori = Null]]]]]])
; Parameters ....: $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; $iTop - [optional] an integer value (0x7FFF,0-17). Default is Null. Set the Top Border Line Style of the Table using one of the line style constants, $LOW_BORDERSTYLE_* as defined in LibreOfficeWriter_Constants.au3.
; $iBottom - [optional] an integer value (0x7FFF,0-17). Default is Null. Set the Bottom Border Line Style of the Table using one of the line style constants, $LOW_BORDERSTYLE_* as defined in LibreOfficeWriter_Constants.au3.
; $iLeft - [optional] an integer value (0x7FFF,0-17). Default is Null. Set the Left Border Line Style of the Table using one of the line style constants, $LOW_BORDERSTYLE_* as defined in LibreOfficeWriter_Constants.au3.
; $iRight - [optional] an integer value (0x7FFF,0-17). Default is Null. Set the Right Border Line Style of the Table using one of the line style constants, $LOW_BORDERSTYLE_* as defined in LibreOfficeWriter_Constants.au3.
; $iVert - [optional] an integer value (0x7FFF,0-17). Default is Null. Set the internal Vertical Border Line Styles of the Table using one of the line style constants, $LOW_BORDERSTYLE_* as defined in LibreOfficeWriter_Constants.au3.
; $iHori - [optional] an integer value (0x7FFF,0-17). Default is Null. Set the internal Horizontal Border Line Styles of the Table using one of the line style constants, $LOW_BORDERSTYLE_* as defined in LibreOfficeWriter_Constants.au3.
; 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 = $oTable not an Object.
; @Error 1 @Extended 2 Return 0 = $iTop not an integer, or set to higher than 17, and not equal to 0x7FFF, or less than 0.
; @Error 1 @Extended 3 Return 0 = $iBottom not an integer, or set to higher than 17, and not equal to 0x7FFF, or less than 0.
; @Error 1 @Extended 4 Return 0 = $iLeft not an integer, or set to higher than 17, and not equal to 0x7FFF, or less than 0.
; @Error 1 @Extended 5 Return 0 = $iRight not an integer, or set to higher than 17, and not equal to 0x7FFF, or less than 0.
; @Error 1 @Extended 6 Return 0 = $iVert not an integer, or set to higher than 17, and not equal to 0x7FFF, or less than 0.
; @Error 1 @Extended 7 Return 0 = $iHori not an integer, or set to higher than 17, and not equal to 0x7FFF, or less than 0.
; @Error 1 @Extended 8 Return 0 = $oTable references a Table that has not been inserted into the document yet.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error Creating Object "com.sun.star.table.BorderLine2"
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Internal command error. More than one set to True. UDF Must be fixed.
; @Error 3 @Extended 2 Return 0 = Error retrieving Object "TableBorder2".
; --Property Setting Errors--
; @Error 4 @Extended 1 Return 0 = Cannot set Top Border Style when Top Border width not set.
; @Error 4 @Extended 2 Return 0 = Cannot set Bottom Border Style when Bottom Border width not set.
; @Error 4 @Extended 3 Return 0 = Cannot set Left Border Style when Left Border width not set.
; @Error 4 @Extended 4 Return 0 = Cannot set Right Border Style when Right Border width not set.
; @Error 4 @Extended 5 Return 0 = Cannot set Vertical Border Style when Vertical Border width not set.
; @Error 4 @Extended 6 Return 0 = Cannot set Horizontal Border Style when Horizontal Border width not set.
; --Version Related Errors--
; @Error 7 @Extended 1 Return 0 = Current Libre Office version lower than 3.6.
; --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 6 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Border Width must be set first to be able to set Border Style and Color.
; 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.
; Error values for Initialization and Processing are passed from the internal border setting function.
; Related .......: _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName, _LOWriter_TableBorderWidth, _LOWriter_TableBorderColor, _LOWriter_TableBorderPadding
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableBorderStyle(ByRef $oTable, $iTop = Null, $iBottom = Null, $iLeft = Null, $iRight = Null, $iVert = Null, $iHori = Null)
Local $vReturn
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If ($iTop <> Null) And Not __LOWriter_IntIsBetween($iTop, $LOW_BORDERSTYLE_SOLID, $LOW_BORDERSTYLE_DASH_DOT_DOT, "", $LOW_BORDERSTYLE_NONE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If ($iBottom <> Null) And Not __LOWriter_IntIsBetween($iBottom, $LOW_BORDERSTYLE_SOLID, $LOW_BORDERSTYLE_DASH_DOT_DOT, "", $LOW_BORDERSTYLE_NONE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If ($iLeft <> Null) And Not __LOWriter_IntIsBetween($iLeft, $LOW_BORDERSTYLE_SOLID, $LOW_BORDERSTYLE_DASH_DOT_DOT, "", $LOW_BORDERSTYLE_NONE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
If ($iRight <> Null) And Not __LOWriter_IntIsBetween($iRight, $LOW_BORDERSTYLE_SOLID, $LOW_BORDERSTYLE_DASH_DOT_DOT, "", $LOW_BORDERSTYLE_NONE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
If ($iVert <> Null) And Not __LOWriter_IntIsBetween($iVert, $LOW_BORDERSTYLE_SOLID, $LOW_BORDERSTYLE_DASH_DOT_DOT, "", $LOW_BORDERSTYLE_NONE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
If ($iHori <> Null) And Not __LOWriter_IntIsBetween($iHori, $LOW_BORDERSTYLE_SOLID, $LOW_BORDERSTYLE_DASH_DOT_DOT, "", $LOW_BORDERSTYLE_NONE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
If Not __LOWriter_IsTableInDoc($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0) ; Table not in document.
$vReturn = __LOWriter_TableBorder($oTable, False, True, False, $iTop, $iBottom, $iLeft, $iRight, $iVert, $iHori)
Return SetError(@error, @extended, $vReturn)
EndFunc ;==>_LOWriter_TableBorderStyle
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableBorderWidth
; Description ...: Set and Retrieve the Table Border Line Width. Libre Office Version 3.6 and Up.
; Syntax ........: _LOWriter_TableBorderWidth(ByRef $oTable[, $iTop = Null[, $iBottom = Null[, $iLeft = Null[, $iRight = Null[, $iVert = Null[, $iHori = Null]]]]]])
; Parameters ....: $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; $iTop - [optional] an integer value. Default is Null. Set the Top Border Line width of the Table in Micrometers. Can be a custom value, or one of the constants, $LOW_BORDERWIDTH_* as defined in LibreOfficeWriter_Constants.au3.
; $iBottom - [optional] an integer value. Default is Null. Set the Bottom Border Line Width of the Table in Micrometers. Can be a custom value, or one of the constants, $LOW_BORDERWIDTH_* as defined in LibreOfficeWriter_Constants.au3.
; $iLeft - [optional] an integer value. Default is Null. Set the Left Border Line width of the Table in Micrometers. Can be a custom value, or one of the constants, $LOW_BORDERWIDTH_* as defined in LibreOfficeWriter_Constants.au3.
; $iRight - [optional] an integer value. Default is Null. Set the Right Border Line Width of the Table in Micrometers. Can be a custom value, or one of the constants, $LOW_BORDERWIDTH_* as defined in LibreOfficeWriter_Constants.au3.
; $iVert - [optional] an integer value. Default is Null. Set the Internal Vertical Border Line width of the Table in Micrometers. Can be a custom value, or one of the constants, $LOW_BORDERWIDTH_* as defined in LibreOfficeWriter_Constants.au3.
; $iHori - [optional] an integer value. Default is Null. Set the Internal Horizontal Border Line width of the Table in Micrometers. Can be a custom value, or one of the constants, $LOW_BORDERWIDTH_* as defined in LibreOfficeWriter_Constants.au3.
; 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 = $oTable not an Object.
; @Error 1 @Extended 2 Return 0 = $iTop not an integer, or less than 0.
; @Error 1 @Extended 3 Return 0 = $iBottom not an integer, or less than 0.
; @Error 1 @Extended 4 Return 0 = $iLeft not an integer, or less than 0.
; @Error 1 @Extended 5 Return 0 = $iRight not an integer, or less than 0.
; @Error 1 @Extended 6 Return 0 = $iVert not an integer, or less than 0.
; @Error 1 @Extended 7 Return 0 = $iHori not an integer, or less than 0.
; @Error 1 @Extended 8 Return 0 = Table called in $oTable is a Table that has not been inserted into the document yet.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error Creating Object "com.sun.star.table.BorderLine2"
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Internal command error. More than one set to True. UDF Must be fixed.
; @Error 3 @Extended 2 Return 0 = Error retrieving Object "TableBorder2".
; --Version Related Errors--
; @Error 7 @Extended 1 Return 0 = Current Libre Office version lower than 3.6.
; --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 6 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: To "Turn Off" Borders, set them to 0
; 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.
; Error values for Initialization and Processing, are passed from the internal border setting function.
; Related .......: _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName, _LOWriter_ConvertFromMicrometer, _LOWriter_ConvertToMicrometer, _LOWriter_TableBorderStyle, _LOWriter_TableBorderColor, _LOWriter_TableBorderPadding
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableBorderWidth(ByRef $oTable, $iTop = Null, $iBottom = Null, $iLeft = Null, $iRight = Null, $iVert = Null, $iHori = Null)
Local $vReturn
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If ($iTop <> Null) And Not __LOWriter_IntIsBetween($iTop, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If ($iBottom <> Null) And Not __LOWriter_IntIsBetween($iBottom, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If ($iLeft <> Null) And Not __LOWriter_IntIsBetween($iLeft, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
If ($iRight <> Null) And Not __LOWriter_IntIsBetween($iRight, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
If ($iVert <> Null) And Not __LOWriter_IntIsBetween($iVert, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
If ($iHori <> Null) And Not __LOWriter_IntIsBetween($iHori, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
If Not __LOWriter_IsTableInDoc($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0) ; Table not in document.
$vReturn = __LOWriter_TableBorder($oTable, True, False, False, $iTop, $iBottom, $iLeft, $iRight, $iVert, $iHori)
Return SetError(@error, @extended, $vReturn)
EndFunc ;==>_LOWriter_TableBorderWidth
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableBreak
; Description ...: Set or retrieve the Paragraph break settings for before or after the Table.
; Syntax ........: _LOWriter_TableBreak(ByRef $oDoc, ByRef $oTable[, $iBreakType = Null[, $sPageStyle = Null[, $iPgNumOffSet = Null]]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; $iBreakType - [optional] an integer value (0-6). Default is Null. The Type of break to insert, see constants, $LOW_BREAK_* as defined in LibreOfficeWriter_Constants.au3.
; $sPageStyle - [optional] a string value. Default is Null. The New Page Style to begin with after the paragraph break. If Set, to remove the break you must set this to "".
; $iPgNumOffSet - [optional] an integer value. Default is Null. If a page break property is set at the table, this property contains the new value for the page number.
; 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 = $oTable not an Object
; @Error 1 @Extended 3 Return 0 = $iBreakType not an Integer, less than 0, or Greater than 6. See Constants, $LOW_BREAK_* as defined in LibreOfficeWriter_Constants.au3.
; @Error 1 @Extended 4 Return 0 = $sPageStyle not a String.
; @Error 1 @Extended 5 Return 0 = $sPageStyle not found in current document.
; @Error 1 @Extended 6 Return 0 = $iPgNumOffSet not an Integer or less than 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 $iBreakType
; | 2 = Error setting $sPageStyle
; | 4 = Error setting $iPgNumOffSet
; --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 .......: Break Type must be set before Page Style will be able to be set, and page style needs set before $iPgNumOffSet can be set.
; LibreOffice doesn't directly show in its User interface options for Break type constants #3 and #6 (Column both) and (Page both), but doesn't throw an error when being set to either one, so they are included here, though I'm not sure if they will work correctly.
; 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_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName, _LOWriter_PageStylesGetNames
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableBreak(ByRef $oDoc, ByRef $oTable, $iBreakType = Null, $sPageStyle = Null, $iPgNumOffSet = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local $avBreaks[3]
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If __LOWriter_VarsAreNull($iBreakType, $sPageStyle, $iPgNumOffSet) Then
__LOWriter_ArrayFill($avBreaks, $oTable.BreakType(), $oTable.PageDescName(), $oTable.PageNumberOffset())
Return SetError($__LO_STATUS_SUCCESS, 1, $avBreaks)
EndIf
If ($iBreakType <> Null) Then
If Not __LOWriter_IntIsBetween($iBreakType, 0, 6) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oTable.BreakType = $iBreakType
$iError = ($oTable.BreakType() = $iBreakType) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($sPageStyle <> Null) Then
If Not IsString($sPageStyle) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
If ($sPageStyle <> "") And Not _LOWriter_PageStyleExists($oDoc, $sPageStyle) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oTable.PageDescName = $sPageStyle
$iError = ($oTable.PageDescName() = $sPageStyle) ? ($iError) : (BitOR($iError, 2))
EndIf
If ($iPgNumOffSet <> Null) Then
If Not __LOWriter_IntIsBetween($iPgNumOffSet, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$oTable.PageNumberOffset = $iPgNumOffSet
$iError = ($oTable.PageNumberOffset() = $iPgNumOffSet) ? ($iError) : (BitOR($iError, 4))
EndIf
Return ($iError = 0) ? (SetError($__LO_STATUS_SUCCESS, 0, 1)) : (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) ; error setting Properties.
EndFunc ;==>_LOWriter_TableBreak
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableCellsGetNames
; Description ...: Retrieve an array of all Cell names from a Table.
; Syntax ........: _LOWriter_TableCellsGetNames(ByRef $oTable)
; Parameters ....: $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; Return values .: Success: Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oTable not an Object.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Array of Cell Names.
; --Success--
; @Error 0 @Extended ? Return Array = Array of Cell names. @Extended set to number of names returned in the array.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableCellsGetNames(ByRef $oTable)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $asCellNames
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0) ; Not an Object.
$asCellNames = $oTable.getCellNames()
If Not IsArray($asCellNames) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0) ; failed to get array of names.
Return SetError($__LO_STATUS_SUCCESS, UBound($asCellNames), $asCellNames)
EndFunc ;==>_LOWriter_TableCellsGetNames
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableColor
; Description ...: Set and retrieve the Background color settings of a Table.
; Syntax ........: _LOWriter_TableColor(ByRef $oTable[, $iBackColor = Null[, $bBackTransparent = Null]])
; Parameters ....: $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; $iBackColor - [optional] an integer value (-1-16777215). Default is Null. The Table background color, as a Long Integer. See Remarks. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3. Set to $LOW_COLOR_OFF(-1) for no background color.
; $bBackTransparent - [optional] a boolean value. Default is Null. If True, the background color is transparent.
; 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 = $oTable not an Object.
; @Error 1 @Extended 2 Return 0 = $iBackColor not an Integer, or less than -1, or higher than 16777215.
; @Error 1 @Extended 3 Return 0 = $bBackTransparent 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 $iBackColor
; | 2 = Error setting $bBackTransparent
; --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_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName, _LOWriter_ConvertColorFromLong, _LOWriter_ConvertColorToLong
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableColor(ByRef $oTable, $iBackColor = Null, $bBackTransparent = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local $avColor[2]
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_VarsAreNull($iBackColor, $bBackTransparent) Then
__LOWriter_ArrayFill($avColor, $oTable.BackColor(), $oTable.BackTransparent())
Return SetError($__LO_STATUS_SUCCESS, 1, $avColor)
EndIf
If ($iBackColor <> Null) Then
If Not __LOWriter_IntIsBetween($iBackColor, $LOW_COLOR_OFF, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oTable.BackColor = $iBackColor
$iError = ($oTable.BackColor() = $iBackColor) ? ($iError) : (BitOR($iError, 1)) ; Error setting color.
EndIf
If ($bBackTransparent <> Null) Then
If Not IsBool($bBackTransparent) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oTable.BackTransparent = $bBackTransparent
$iError = ($oTable.BackTransparent() = $bBackTransparent) ? ($iError) : (BitOR($iError, 2)) ; Error setting BackTransparent.
EndIf
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_TableColor
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableColumnDelete
; Description ...: Delete a column from a Text Table.
; Syntax ........: _LOWriter_TableColumnDelete(ByRef $oTable, $iColumn[, $iCount = 1])
; Parameters ....: $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; $iColumn - an integer value. The Column to delete.
; $iCount - [optional] an integer value. Default is 1. Number of columns to delete starting at the column called in $iColumn and moving right.
; Return values .: Success: Integer
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oTable not an Object.
; @Error 1 @Extended 2 Return 0 = Table called in $oTable not inserted into Document yet.
; @Error 1 @Extended 3 Return 0 = $iColumn not an integer, or set to less than 0.
; @Error 1 @Extended 4 Return 0 = $iCount not an Integer, or set to less than 1.
; @Error 1 @Extended 5 Return 0 = Requested column higher than number of columns contained in table.
; --Success--
; @Error 0 @Extended ? Return 1 = Full amount of columns deleted. @Extended set to total columns deleted.
; @Error 0 @Extended ? Return 2 = $iCount higher than amount of columns contained in Table; deleted all columns from $iColumn over. @Extended set to total columns deleted.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: LibreOffice counts columns and Rows starting at 0. So to delete the first column in a Table you would set $iColumn to 0.
; If you attempt to delete more columns than are present all columns from $iColumn over will be deleted.
; If you delete all columns starting from column 0, the entire Table is deleted.
; Related .......: _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName, _LOWriter_TableColumnGetCount
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableColumnDelete(ByRef $oTable, $iColumn, $iCount = 1)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iColumnCount, $iReturn = 0
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not __LOWriter_IsTableInDoc($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0) ; can't delete columns if Table not in doc.
If Not IsInt($iColumn) Or ($iColumn < 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsInt($iCount) Or ($iCount < 1) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$iColumnCount = $oTable.getColumns.getCount()
If ($iColumnCount <= $iColumn) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0) ; Requested column out of bounds.
$iCount = ($iCount > ($iColumnCount - $iColumn)) ? ($iColumnCount - $iColumn) : ($iCount)
$iReturn = ($iCount > ($iColumnCount - $iColumn)) ? (2) : (1) ;Return 1 if full amount deleted else 2 if only partial.
$oTable.getColumns.removeByIndex($iColumn, $iCount)
Return SetError($__LO_STATUS_SUCCESS, $iCount, $iReturn)
EndFunc ;==>_LOWriter_TableColumnDelete
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableColumnGetCount
; Description ...: Retrieves the number of Columns in a table.
; Syntax ........: _LOWriter_TableColumnGetCount(ByRef $oTable)
; Parameters ....: $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; Return values .: Success: Integer
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oTable not an Object.
; @Error 1 @Extended 2 Return 0 = Table called in $oTable not inserted into document yet.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Column count.
; --Success--
; @Error 0 @Extended 0 Return Integer = Returning Column Count as an Integer.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableColumnGetCount(ByRef $oTable)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iColumnSize = 0
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0) ; Not an Object.
If Not __LOWriter_IsTableInDoc($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0) ; can't get columns/rows if Table not in doc.
$iColumnSize = $oTable.getColumns.getCount()
If ($iColumnSize = 0) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0) ; Failed to retrieve column count.
Return $iColumnSize
EndFunc ;==>_LOWriter_TableColumnGetCount
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableColumnInsert
; Description ...: Insert a column into a Text Table
; Syntax ........: _LOWriter_TableColumnInsert(ByRef $oTable, $iCount[, $iColumn = -1])
; Parameters ....: $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; $iCount - an integer value. Number of columns to insert.
; $iColumn - [optional] an integer value. Default is -1. The column to insert columns after. See Remarks.
; Return values .: Success: 1.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oTable not an Object.
; @Error 1 @Extended 2 Return 0 = Table called in $oTable not inserted into Document yet.
; @Error 1 @Extended 3 Return 0 = $iCount not an Integer, or set to less than 1.
; @Error 1 @Extended 4 Return 0 = $iColumn not an integer, or set to less than -1.
; @Error 1 @Extended 5 Return 0 = Column called in $iColumn higher than number of columns contained in table.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to insert columns.
; --Success--
; @Error 0 @Extended 0 Return 1 = Successfully inserted the number of desired columns.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: If you do not set $iColumn, the new columns will be placed at the end of the Table.
; LibreOffice counts the Table columns/Rows starting at 0. The columns are placed behind the desired column when inserted.
; To insert a column at the left most of the Table you would set $iColumn to 0. To insert columns at the Right of a table you would set $iColumn to one higher than the last column. e.g. a Table containing 3 columns, would be numbered as follows: 0(first-Column), 1(second-Column), 2(third-Column), to insert columns at the very Right of the columns, you would set $iColumn to 3.
; Related .......: _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName, _LOWriter_TableColumnGetCount
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableColumnInsert(ByRef $oTable, $iCount, $iColumn = -1)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iColumnCount
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not __LOWriter_IsTableInDoc($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0) ; can't insert columns if Table not in doc.
If Not IsInt($iCount) Or ($iCount < 1) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsInt($iColumn) Or ($iColumn < -1) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$iColumnCount = $oTable.getColumns.getCount()
If ($iColumnCount < $iColumn) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0) ; Requested column out of bounds.
$iColumn = ($iColumn <= -1) ? ($iColumnCount) : ($iColumn)
$oTable.getColumns.insertByIndex($iColumn, $iCount)
Return ($oTable.getColumns.getCount() = ($iColumnCount + $iCount)) ? (SetError($__LO_STATUS_SUCCESS, 0, 1)) : (SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0))
EndFunc ;==>_LOWriter_TableColumnInsert
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableCreate
; Description ...: Create a Text Table to insert into a document.
; Syntax ........: _LOWriter_TableCreate(ByRef $oDoc[, $iRows = 3[, $iColumns = 2[, $bSplit = Null[, $iBackColor = Null[, $sTableName = ""]]]]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $iRows - [optional] an integer value. Default is 3. The number of rows to create the table with.
; $iColumns - [optional] an integer value. Default is 2. The number of columns to create the table with.
; $bSplit - [optional] a boolean value. Default is Null. If False, the table will not split across two pages.
; $iBackColor - [optional] an integer value (-1-16777215). Default is Null. The Table background color as a Long Integer. See Remarks. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3. Set to $LOW_COLOR_OFF (-1) for no background color.
; $sTableName - [optional] a string value. Default is "". The table name. See Remarks.
; 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 = $iRows not an integer, or less than 1.
; @Error 1 @Extended 3 Return 0 = $iColumns not an integer, or less than 1.
; @Error 1 @Extended 4 Return 0 = $bSplit not a Boolean, or not set to Null.
; @Error 1 @Extended 5 Return 0 = $iBackColor not an integer, Or set to less than -1 or higher than 16777215, or not set to Null
; @Error 1 @Extended 6 Return 0 = $sTableName not a String.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failure Creating Object com.sun.star.text.TextTable.
; --Success--
; @Error 0 @Extended 0 Return Object = Successfully created a Table Object. The Object is returned for later insertion into the document.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: This function only creates a Table Object. You must insert it into the document using _LOWriter_TableInsert. You can preset some properties using _LOWriter_TableProperties, before inserting, or set them after inserting.
; Some properties can only be set on already inserted Tables.
; Call any optional parameter with Null keyword to skip it.
; The Table Name may change upon inserting it into the document if there is a table already named the same, (e.g. TableName becomes TableName1).
; Related .......: _LOWriter_TableInsert, _LOWriter_ConvertColorFromLong, _LOWriter_ConvertColorToLong
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableCreate(ByRef $oDoc, $iRows = 3, $iColumns = 2, $bSplit = Null, $iBackColor = Null, $sTableName = "")
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oTable
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsInt($iRows) Or ($iRows < 1) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If Not IsInt($iColumns) Or ($iColumns < 1) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oTable = $oDoc.createInstance("com.sun.star.text.TextTable")
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$oTable.initialize($iRows, $iColumns)
If ($bSplit <> Null) Then
If Not IsBool($bSplit) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oTable.Split = $bSplit
EndIf
If ($iBackColor <> Null) Then
If Not __LOWriter_IntIsBetween($iBackColor, $LOW_COLOR_OFF, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oTable.BackColor = $iBackColor
$oTable.BackTransparent = False
EndIf
If ($sTableName <> "") Then
If Not IsString($sTableName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$oTable.setName($sTableName)
EndIf
Return SetError($__LO_STATUS_SUCCESS, 0, $oTable)
EndFunc ;==>_LOWriter_TableCreate
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableCreateCursor
; Description ...: Retrieve a Table Cursor for modifying Text-Table properties.
; Syntax ........: _LOWriter_TableCreateCursor(ByRef $oDoc, ByRef $oTable[, $sCellName = ""[, $oCursor = Null]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function. See remarks.
; $sCellName - [optional] a string value. Default is "". The Table Cell name to create a Text Table Cursor in. See Remarks.
; $oCursor - [optional] an object. Default is Null. A Cursor Object returned from any Cursor Object creation or retrieval functions. See Remarks.
; 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 = $oTable and $oCursor not Objects.
; @Error 1 @Extended 3 Return 0 = $oTable and $oCursor both Objects.
; @Error 1 @Extended 4 Return 0 = $sCellName not a String.
; @Error 1 @Extended 5 Return 0 = $oCursor not in a Table.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Failed to create Cursor by Cell Name or by first Cell name in Table.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failure retrieving Table by Table Name from Cursor.
; @Error 3 @Extended 2 Return 0 = Failure retrieving list of Table Cell Names.
; --Success--
; @Error 0 @Extended 0 Return Object = Success, TableCursor object was created successfully. Returning Table Cursor Object for further Table manipulation functions.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: $oTable can be either set to a Table object, or Null Keyword with $oCursor set to a Cursor object, $oCursor can be either set to a cursor object currently located in a Table (such as a ViewCursor)/ or a TextCursor located in a table. $sCellName can be left blank, which will place the TextTableCursor at the first cell (Typically "A1") if $oTable is called with an Object, else if $oCursor is used, the cell the cursor is currently located in is used.
; Related .......: _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName, _LOWriter_TableCellsGetNames, _LOWriter_DocGetViewCursor, _LOWriter_DocCreateTextCursor
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableCreateCursor(ByRef $oDoc, ByRef $oTable, $sCellName = "", $oCursor = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oTableCursor
Local $asCells
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oTable) And Not IsObj($oCursor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If IsObj($oTable) And IsObj($oCursor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsString($sCellName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
If IsObj($oCursor) Then
Switch __LOWriter_Internal_CursorGetDataType($oDoc, $oCursor)
Case $LOW_CURDATA_CELL ; Transform to TextTableCursor
$oTable = $oDoc.TextTables.getByName($oCursor.TextTable.Name)
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$sCellName = ($sCellName = "") ? ($oCursor.Cell.CellName) : ($sCellName)
Case Else
Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0) ; Wrong Cursor Data Type
EndSwitch
EndIf
If ($sCellName = "") Then ; If cell name undefined, get first cell.
$asCells = $oTable.getCellNames()
If Not IsArray($asCells) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0) ; no cells
$sCellName = $asCells[0]
EndIf
$oTableCursor = $oTable.createCursorByCellName($sCellName)
If Not IsObj($oTableCursor) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, $oTableCursor)
EndFunc ;==>_LOWriter_TableCreateCursor
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableCursor
; Description ...: Commands related to a Table Cursor.
; Syntax ........: _LOWriter_TableCursor(ByRef $oCursor[, $sGoToCellByName = Null[, $bSelect = False[, $bMergeRange = Null[, $iSplitRangeInto = Null[, $bSplitRangeHori = False]]]]])
; Parameters ....: $oCursor - [in/out] an object. A Table Cursor Object returned from a _LOWriter_TableCreateCursor function.
; $sGoToCellByName - [optional] a string value. Default is Null. Move the cursor to the cell with the specified name, Case Sensitive; See also $bSelect.
; $bSelect - [optional] a boolean value. Default is False. If True, selection is expanded when moving to a specific cell with $sGoToCellByName.
; $bMergeRange - [optional] a boolean value. Default is Null. Merge the selected range of cells.
; $iSplitRangeInto - [optional] an integer value. Default is Null. Create n new cells in each cell selected by the cursor. See also $bSplitRangeHori.
; $bSplitRangeHori - [optional] a boolean value. Default is False. If True, splits the selected cell or cell range horizontally, else, False for vertically.
; Return values .: Success: 1
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oCursor not an Object.
; @Error 1 @Extended 2 Return 0 = $oCursor not a Table Cursor.
; @Error 1 @Extended 3 Return 0 = $sGoToCellByName not a String.
; @Error 1 @Extended 4 Return 0 = $bSelect not a Boolean.
; @Error 1 @Extended 5 Return 0 = $iSplitRangeInto not an Integer or less than 1.
; @Error 1 @Extended 6 Return 0 = $bSplitRangeHori not a Boolean.
; --Processing Errors--
; @Error 3 @Extended ? Return 0 = Some commands were not successfully completed. Use BitAND to test @Extended for the following values:
; | 1 = Failed while processing $sGoToCellByName.
; | 2 = Failed while processing $bMergeRange.
; | 4 = Failed while processing $iSplitRangeInto.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Command was successfully completed.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_TableCreateCursor, _LOWriter_CursorMove, _LOWriter_TableCellsGetNames
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableCursor(ByRef $oCursor, $sGoToCellByName = Null, $bSelect = False, $bMergeRange = Null, $iSplitRangeInto = Null, $bSplitRangeHori = False)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $vReturn
Local $iError = 0
If Not IsObj($oCursor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If ((__LOWriter_Internal_CursorGetType($oCursor)) <> $LOW_CURTYPE_TABLE_CURSOR) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If ($sGoToCellByName <> Null) Then
If Not IsString($sGoToCellByName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsBool($bSelect) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$vReturn = $oCursor.gotoCellByName($sGoToCellByName, $bSelect)
$iError = ($vReturn = True) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($bMergeRange = True) Then
$vReturn = $oCursor.mergeRange()
$iError = ($vReturn = True) ? ($iError) : (BitOR($iError, 2))
EndIf
If ($iSplitRangeInto <> Null) Then
If Not __LOWriter_IntIsBetween($iSplitRangeInto, 1) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
If Not IsBool($bSplitRangeHori) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$vReturn = $oCursor.splitRange($iSplitRangeInto, $bSplitRangeHori)
$iError = ($vReturn = True) ? ($iError) : (BitOR($iError, 4, 0))
EndIf
Return ($iError > 0) ? (SetError($__LO_STATUS_PROCESSING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_TableCursor
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableDelete
; Description ...: Delete a table from the document.
; Syntax ........: _LOWriter_TableDelete(ByRef $oDoc, ByRef $oTable)
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; Return values .: Success: 1.
; 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 = $oTable not an Object.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Table called in $oTable not already inserted in the document.
; @Error 3 @Extended 2 Return 0 = Table by same name still contained in the document after deletion attempt.
; --Success--
; @Error 0 @Extended 0 Return 1 = Table was successfully deleted.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableDelete(ByRef $oDoc, ByRef $oTable)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $sTableName
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$sTableName = $oTable.getName()
If Not ($oDoc.TextTables.hasByName($sTableName)) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0) ; Document doesn't contain Table named this yet.
$oTable.dispose()
If ($oDoc.TextTables.hasByName($sTableName)) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0) ; Document still contains Table named the same.
Return SetError($__LO_STATUS_SUCCESS, 0, 1)
EndFunc ;==>_LOWriter_TableDelete
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableExists
; Description ...: Check if a Document contains a Table with the specified name.
; Syntax ........: _LOWriter_TableExists(ByRef $oDoc, $sTableName)
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or_LOWriter_DocCreate function.
; $sTableName - a string value. The Table name to search for.
; Return values .: Success: Boolean
; 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 = $sTableName not a String.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Error retrieving Text Tables Object.
; --Success--
; @Error 0 @Extended 0 Return Boolean = Success. If a table was found matching $sTableName, True is returned, else False.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_TableGetObjByName
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableExists(ByRef $oDoc, $sTableName)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oTables
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsString($sTableName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oTables = $oDoc.TextTables()
If Not IsObj($oTables) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If ($oTables.hasByName($sTableName)) Then Return SetError($__LO_STATUS_SUCCESS, 1, True)
Return SetError($__LO_STATUS_SUCCESS, 0, False) ; No matches
EndFunc ;==>_LOWriter_TableExists
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableGetCellObjByCursor
; Description ...: Retrieve a single Cell Object or a Cell Range by Cursor.
; Syntax ........: _LOWriter_TableGetCellObjByCursor(ByRef $oDoc, ByRef $oTable, ByRef $oCursor)
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; $oCursor - [in/out] an object. A Cursor Object returned from any Cursor Object creation or retrieval functions.
; 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 = $oTable not an Object.
; @Error 1 @Extended 3 Return 0 = $oCursor not an Object.
; @Error 1 @Extended 4 Return 0 = Table called in $oTable references a Table not currently inserted in the document.
; @Error 1 @Extended 5 Return 0 = $oCursor is not currently located inside of a Table Cell.
; @Error 1 @Extended 6 Return 0 = $oCursor unknown cursor type.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failure Retrieving Cell Object
; --Success--
; @Error 0 @Extended 0 Return Object = A Cell object or a Cell Range.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: This function will accept a Table Cursor, a ViewCursor, or a Text Cursor.
; A TableCursor and ViewCursor can retrieve the single cell they are located in, or a range of cells that have been selected by them.
; A TextCursor can only retrieve the single cell it is located in.
; Related .......: _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName, _LOWriter_DocGetViewCursor, _LOWriter_DocCreateTextCursor
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_TableGetCellObjByCursor(ByRef $oDoc, ByRef $oTable, ByRef $oCursor)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iCursorType, $iCursorDataType
Local $oCell, $oSelection
Local $sCellRange
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If Not IsObj($oCursor) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not __LOWriter_IsTableInDoc($oTable) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$iCursorType = __LOWriter_Internal_CursorGetType($oCursor)
Switch $iCursorType
Case $LOW_CURTYPE_TABLE_CURSOR
$sCellRange = $oCursor.getRangeName()
$oCell = (StringInStr($sCellRange, ":")) ? ($oTable.getCellRangeByName($sCellRange)) : ($oTable.getCellByName($sCellRange))
Case $LOW_CURTYPE_TEXT_CURSOR
$iCursorDataType = __LOWriter_Internal_CursorGetDataType($oDoc, $oCursor)
If Not ($iCursorDataType = $LOW_CURDATA_CELL) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0) ; Cursor not in a Table cell.
$oCell = $oTable.getCellByName($oCursor.Cell.CellName)
Case $LOW_CURTYPE_VIEW_CURSOR
$oSelection = $oDoc.CurrentSelection()
If ($oSelection.ImplementationName() = "SwXTextTableCursor") Then
$oCell = $oTable.getCellRangeByName($oSelection.getRangeName())
Else
$iCursorDataType = __LOWriter_Internal_CursorGetDataType($oDoc, $oCursor)
If Not ($iCursorDataType = $LOW_CURDATA_CELL) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0) ; Cursor not in a Table cell.
$oCell = $oTable.getCellByName($oCursor.Cell.CellName)
EndIf
Case Else
Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0) ; Unknown cursor type.
EndSwitch
If Not IsObj($oCell) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
Return $oCell
EndFunc ;==>_LOWriter_TableGetCellObjByCursor
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_TableGetCellObjByName
; Description ...: Retrieve a Cell Object or a Cell range by Cell name.
; Syntax ........: _LOWriter_TableGetCellObjByName(ByRef $oTable, $sCellName[, $sToCellName = $sCellName])
; Parameters ....: $oTable - [in/out] an object. A Table Object returned by a previous _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, or _LOWriter_TableGetObjByName function.
; $sCellName - a string value. A Cell Name. Note: Case Sensitive. See remarks.
; $sToCellName - [optional] a string value. Default is $sCellName. The Cell name to end the Cell Range. Note: Case Sensitive.
; Return values .: Success: Object.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oTable is not an Object.
; @Error 1 @Extended 2 Return 0 = $sCellName not a String.
; @Error 1 @Extended 3 Return 0 = $sToCellName not a String.
; @Error 1 @Extended 4 Return 0 = Table called in $oTable references a Table not currently inserted in the document.
; @Error 1 @Extended 5 Return 0 = Table does not contain the Requested Cell name as called in $sCellName.
; @Error 1 @Extended 6 Return 0 = Table does not contain the Requested Cell name as called in $sToCellName.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Cell Object.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. A Cell object or a Cell Range Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Cell names are Case Sensitive. LibreOffice first goes from A to Z, and then a to z and then AA to ZZ etc.
; $sCellName can contain a Cell name that is located after $sToCellName in the Table.
; If $sToCellName is left blank, a cell object is returned instead of a Cell Range.
; Related .......: _LOWriter_TableInsert, _LOWriter_TableGetObjByCursor, _LOWriter_TableGetObjByName, _LOWriter_TableCellsGetNames