-
Notifications
You must be signed in to change notification settings - Fork 1
/
LibreOfficeWriter_Shapes.au3
3107 lines (2524 loc) · 190 KB
/
LibreOfficeWriter_Shapes.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_Internal.au3"
; #INDEX# =======================================================================================================================
; Title .........: LibreOffice UDF
; AutoIt Version : v3.3.16.1
; Description ...: Provides basic functionality through AutoIt for Creating, Modifying, and Inserting shapes in L.O. Writer.
; Author(s) .....: donnyh13, mLipok
; Dll ...........:
;
; ===============================================================================================================================
; #CURRENT# =====================================================================================================================
; _LOWriter_ShapeAreaColor
; _LOWriter_ShapeAreaFillStyle
; _LOWriter_ShapeAreaGradient
; _LOWriter_ShapeDelete
; _LOWriter_ShapeExists
; _LOWriter_ShapeGetAnchor
; _LOWriter_ShapeGetObjByName
; _LOWriter_ShapeGetType
; _LOWriter_ShapeInsert
; _LOWriter_ShapeLineArrowStyles
; _LOWriter_ShapeLineProperties
; _LOWriter_ShapeName
; _LOWriter_ShapePointsAdd
; _LOWriter_ShapePointsGetCount
; _LOWriter_ShapePointsModify
; _LOWriter_ShapePointsRemove
; _LOWriter_ShapePosition
; _LOWriter_ShapeRotateSlant
; _LOWriter_ShapesGetNames
; _LOWriter_ShapeTextBox
; _LOWriter_ShapeTransparency
; _LOWriter_ShapeTransparencyGradient
; _LOWriter_ShapeTypePosition
; _LOWriter_ShapeTypeSize
; _LOWriter_ShapeWrap
; _LOWriter_ShapeWrapOptions
; ===============================================================================================================================
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ShapeAreaColor
; Description ...: Set or Retrieve the Fill color settings for a Shape.
; Syntax ........: _LOWriter_ShapeAreaColor(ByRef $oShape[, $iColor = Null])
; Parameters ....: $oShape - [in/out] an object. A Shape object returned by a previous _LOWriter_ShapeInsert, or _LOWriter_ShapeGetObjByName function.
; $iColor - [optional] an integer value (-1-16777215). Default is Null. The Fill color. Set in Long integer format. 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 "None".
; Return values .: Success: 1 or Integer.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oShape not an Object.
; @Error 1 @Extended 2 Return 0 = $iColor not an integer, less than -1, or greater than 16777215.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve old Transparency value.
; --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 $iColor
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Integer = Success. All optional parameters were set to Null, returning current Fill color as an integer.
; 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.
; Related .......: _LOWriter_ShapeInsert, _LOWriter_ShapeGetObjByName, _LOWriter_ConvertColorFromLong, _LOWriter_ConvertColorToLong
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ShapeAreaColor(ByRef $oShape, $iColor = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0, $iOldTransparency
If Not IsObj($oShape) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
; If $iColor is Null, and Fill Style is set to solid, then return current color value, else return LOW_COLOR_OFF.
If ($iColor = Null) Then Return SetError($__LO_STATUS_SUCCESS, 1, ($oShape.FillStyle() = $LOW_AREA_FILL_STYLE_SOLID) ? (__LOWriter_ColorRemoveAlpha($oShape.FillColor())) : ($LOW_COLOR_OFF))
If Not __LOWriter_IntIsBetween($iColor, $LOW_COLOR_OFF, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If ($iColor = $LOW_COLOR_OFF) Then
$oShape.FillStyle = $LOW_AREA_FILL_STYLE_OFF
Else
$iOldTransparency = $oShape.FillTransparence()
If Not IsInt($iOldTransparency) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$oShape.FillStyle = $LOW_AREA_FILL_STYLE_SOLID
$oShape.FillColor = $iColor
$iError = ($oShape.FillColor() = $iColor) ? ($iError) : (BitOR($iError, 1))
$oShape.FillTransparence = $iOldTransparency
EndIf
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_ShapeAreaColor
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ShapeAreaFillStyle
; Description ...: Retrieve what kind of background fill is active, if any.
; Syntax ........: _LOWriter_ShapeAreaFillStyle(ByRef $oShape)
; Parameters ....: $oShape - [in/out] an object. A Shape object returned by previous _LOWriter_ShapeInsert, or _LOWriter_ShapeGetObjByName 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 = $oShape not an Object.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve current Fill Style.
; --Success--
; @Error 0 @Extended 0 Return Integer = Success. Returning current background fill style. Return will be one of the constants $LOW_AREA_FILL_STYLE_* as defined in LibreOfficeWriter_Constants.au3.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: This function is to help determine if a Gradient background, or a solid color background is currently active.
; This is useful because, if a Gradient is active, the solid color value is still present, and thus it would not be possible to determine which function should be used to retrieve the current values for, whether the Color function, or the Gradient function.
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ShapeAreaFillStyle(ByRef $oShape)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iFillStyle
If Not IsObj($oShape) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$iFillStyle = $oShape.FillStyle()
If Not IsInt($iFillStyle) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, $iFillStyle)
EndFunc ;==>_LOWriter_ShapeAreaFillStyle
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ShapeAreaGradient
; Description ...: Modify or retrieve the settings for Shape Background color Gradient.
; Syntax ........: _LOWriter_ShapeAreaGradient(ByRef $oDoc, ByRef $oShape[, $sGradientName = Null[, $iType = Null[, $iIncrement = Null[, $iXCenter = Null[, $iYCenter = Null[, $iAngle = Null[, $iTransitionStart = Null[, $iFromColor = Null[, $iToColor = Null[, $iFromIntense = Null[, $iToIntense = Null]]]]]]]]]]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oShape - [in/out] an object. A Shape object returned by a previous _LOWriter_ShapeInsert, or _LOWriter_ShapeGetObjByName function.
; $sGradientName - [optional] a string value. Default is Null. A Preset Gradient Name. See remarks. See constants, $LOW_GRAD_NAME_* as defined in LibreOfficeWriter_Constants.au3.
; $iType - [optional] an integer value (-1-5). Default is Null. The gradient type to apply. See Constants, $LOW_GRAD_TYPE_* as defined in LibreOfficeWriter_Constants.au3.
; $iIncrement - [optional] an integer value (0, 3-256). Default is Null. The number of steps of color change. 0 = Automatic.
; $iXCenter - [optional] an integer value (0-100). Default is Null. The horizontal offset for the gradient, where 0% corresponds to the current horizontal location of the endpoint color in the gradient. The endpoint color is the color that is selected in the "To Color" setting. Set in percentage. $iType must be other than "Linear", or "Axial".
; $iYCenter - [optional] an integer value (0-100). Default is Null. The vertical offset for the gradient, where 0% corresponds to the current vertical location of the endpoint color in the gradient. The endpoint color is the color that is selected in the "To Color" Setting. Set in percentage. $iType must be other than "Linear", or "Axial".
; $iAngle - [optional] an integer value (0-359). Default is Null. The rotation angle for the gradient. Set in degrees. $iType must be other than "Radial".
; $iTransitionStart - [optional] an integer value (0-100). Default is Null. The amount by which to adjust the transparent area of the gradient. Set in percentage.
; $iFromColor - [optional] an integer value (0-16777215). Default is Null. A color for the beginning point of the gradient, set in Long Color Integer format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; $iToColor - [optional] an integer value (0-16777215). Default is Null. A color for the endpoint of the gradient, set in Long Color Integer format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; $iFromIntense - [optional] an integer value (0-100). Default is Null. Enter the intensity for the color in the "From Color", where 0% corresponds to black, and 100 % to the selected color.
; $iToIntense - [optional] an integer value (0-100). Default is Null. Enter the intensity for the color in the "To Color", where 0% corresponds to black, and 100 % to the selected color.
; Return values .: Success: Integer 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 = $oShape not an Object.
; @Error 1 @Extended 3 Return 0 = $sGradientName not a String.
; @Error 1 @Extended 4 Return 0 = $iType not an Integer, less than -1, or greater than 5. See Constants, $LOW_GRAD_TYPE_* as defined in LibreOfficeWriter_Constants.au3.
; @Error 1 @Extended 5 Return 0 = $iIncrement not an Integer, less than 3, but not 0, or greater than 256.
; @Error 1 @Extended 6 Return 0 = $iXCenter not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 7 Return 0 = $iYCenter not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 8 Return 0 = $iAngle not an Integer, less than 0, or greater than 359.
; @Error 1 @Extended 9 Return 0 = $iTransitionStart not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 10 Return 0 = $iFromColor not an Integer, less than 0, or greater than 16777215.
; @Error 1 @Extended 11 Return 0 = $iToColor not an Integer, less than 0, or greater than 16777215.
; @Error 1 @Extended 12 Return 0 = $iFromIntense not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 13 Return 0 = $iToIntense not an Integer, less than 0, or greater than 100.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Error retrieving "FillGradient" Object.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve ColorStops Array.
; @Error 3 @Extended 3 Return 0 = Error creating Gradient Name.
; @Error 3 @Extended 4 Return 0 = Error setting Gradient Name.
; --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 $sGradientName
; | 2 = Error setting $iType
; | 4 = Error setting $iIncrement
; | 8 = Error setting $iXCenter
; | 16 = Error setting $iYCenter
; | 32 = Error setting $iAngle
; | 64 = Error setting $iTransitionStart
; | 128 = Error setting $iFromColor
; | 256 = Error setting $iToColor
; | 512 = Error setting $iFromIntense
; | 1024 = Error setting $iToIntense
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings have been successfully set.
; @Error 0 @Extended 0 Return 2 = Success. Gradient has been successfully turned off.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 11 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.
; Gradient Name has no use other than for applying a pre-existing preset gradient.
; Related .......: _LOWriter_ShapeInsert, _LOWriter_ShapeGetObjByName, _LOWriter_ConvertColorFromLong, _LOWriter_ConvertColorToLong
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ShapeAreaGradient(ByRef $oDoc, ByRef $oShape, $sGradientName = Null, $iType = Null, $iIncrement = Null, $iXCenter = Null, $iYCenter = Null, $iAngle = Null, $iTransitionStart = Null, $iFromColor = Null, $iToColor = Null, $iFromIntense = Null, $iToIntense = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $tStyleGradient, $tColorStop, $tStopColor
Local $iError = 0
Local $avGradient[11]
Local $sGradName
Local $atColorStop[0]
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oShape) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$tStyleGradient = $oShape.FillGradient()
If Not IsObj($tStyleGradient) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If __LOWriter_VarsAreNull($sGradientName, $iType, $iIncrement, $iXCenter, $iYCenter, $iAngle, $iTransitionStart, $iFromColor, $iToColor, $iFromIntense, $iToIntense) Then
__LOWriter_ArrayFill($avGradient, $oShape.FillGradientName(), $tStyleGradient.Style(), _
$oShape.FillGradientStepCount(), $tStyleGradient.XOffset(), $tStyleGradient.YOffset(), ($tStyleGradient.Angle() / 10), _
$tStyleGradient.Border(), $tStyleGradient.StartColor(), $tStyleGradient.EndColor(), $tStyleGradient.StartIntensity(), _
$tStyleGradient.EndIntensity()) ; Angle is set in thousands
Return SetError($__LO_STATUS_SUCCESS, 1, $avGradient)
EndIf
If ($oShape.FillStyle() <> $LOW_AREA_FILL_STYLE_GRADIENT) Then $oShape.FillStyle = $LOW_AREA_FILL_STYLE_GRADIENT
If ($sGradientName <> Null) Then
If Not IsString($sGradientName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
__LOWriter_GradientPresets($oDoc, $oShape, $tStyleGradient, $sGradientName)
$iError = ($oShape.FillGradientName() = $sGradientName) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($iType <> Null) Then
If ($iType = $LOW_GRAD_TYPE_OFF) Then ; Turn Off Gradient
$oShape.FillStyle = $LOW_AREA_FILL_STYLE_OFF
$oShape.FillGradientName = ""
Return SetError($__LO_STATUS_SUCCESS, 0, 2)
EndIf
If Not __LOWriter_IntIsBetween($iType, $LOW_GRAD_TYPE_LINEAR, $LOW_GRAD_TYPE_RECT) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$tStyleGradient.Style = $iType
EndIf
If ($iIncrement <> Null) Then
If Not __LOWriter_IntIsBetween($iIncrement, 3, 256, "", 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oShape.FillGradientStepCount = $iIncrement
$tStyleGradient.StepCount = $iIncrement ; Must set both of these in order for it to take effect.
$iError = ($oShape.FillGradientStepCount() = $iIncrement) ? ($iError) : (BitOR($iError, 4))
EndIf
If ($iXCenter <> Null) Then
If Not __LOWriter_IntIsBetween($iXCenter, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$tStyleGradient.XOffset = $iXCenter
EndIf
If ($iYCenter <> Null) Then
If Not __LOWriter_IntIsBetween($iYCenter, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
$tStyleGradient.YOffset = $iYCenter
EndIf
If ($iAngle <> Null) Then
If Not __LOWriter_IntIsBetween($iAngle, 0, 359) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0)
$tStyleGradient.Angle = ($iAngle * 10) ; Angle is set in thousands
EndIf
If ($iTransitionStart <> Null) Then
If Not __LOWriter_IntIsBetween($iTransitionStart, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 9, 0)
$tStyleGradient.Border = $iTransitionStart
EndIf
If ($iFromColor <> Null) Then
If Not __LOWriter_IntIsBetween($iFromColor, $LOW_COLOR_BLACK, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 10, 0)
$tStyleGradient.StartColor = $iFromColor
If __LOWriter_VersionCheck(7.6) Then
$atColorStop = $tStyleGradient.ColorStops()
If Not IsArray($atColorStop) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
$tColorStop = $atColorStop[0] ; StopOffset 0 is the "From Color" Value.
$tStopColor = $tColorStop.StopColor()
$tStopColor.Red = (BitAND(BitShift($iFromColor, 16), 0xff) / 255)
$tStopColor.Green = (BitAND(BitShift($iFromColor, 8), 0xff) / 255)
$tStopColor.Blue = (BitAND($iFromColor, 0xff) / 255)
$tColorStop.StopColor = $tStopColor
$atColorStop[0] = $tColorStop
$tStyleGradient.ColorStops = $atColorStop
EndIf
EndIf
If ($iToColor <> Null) Then
If Not __LOWriter_IntIsBetween($iToColor, $LOW_COLOR_BLACK, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 11, 0)
$tStyleGradient.EndColor = $iToColor
If __LOWriter_VersionCheck(7.6) Then
$atColorStop = $tStyleGradient.ColorStops()
If Not IsArray($atColorStop) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
$tColorStop = $atColorStop[UBound($atColorStop) - 1] ; Last StopOffset is the "To Color" Value.
$tStopColor = $tColorStop.StopColor()
$tStopColor.Red = (BitAND(BitShift($iToColor, 16), 0xff) / 255)
$tStopColor.Green = (BitAND(BitShift($iToColor, 8), 0xff) / 255)
$tStopColor.Blue = (BitAND($iToColor, 0xff) / 255)
$tColorStop.StopColor = $tStopColor
$atColorStop[UBound($atColorStop) - 1] = $tColorStop
$tStyleGradient.ColorStops = $atColorStop
EndIf
EndIf
If ($iFromIntense <> Null) Then
If Not __LOWriter_IntIsBetween($iFromIntense, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 12, 0)
$tStyleGradient.StartIntensity = $iFromIntense
EndIf
If ($iToIntense <> Null) Then
If Not __LOWriter_IntIsBetween($iToIntense, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 13, 0)
$tStyleGradient.EndIntensity = $iToIntense
EndIf
If ($oShape.FillGradientName() = "") Then
$sGradName = __LOWriter_GradientNameInsert($oDoc, $tStyleGradient)
If @error > 0 Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 3, 0)
$oShape.FillGradientName = $sGradName
If ($oShape.FillGradientName <> $sGradName) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 4, 0)
EndIf
$oShape.FillGradient = $tStyleGradient
; Error checking
$iError = ($iType = Null) ? $iError : ($oShape.FillGradient.Style() = $iType) ? ($iError) : (BitOR($iError, 2))
$iError = ($iXCenter = Null) ? $iError : ($oShape.FillGradient.XOffset() = $iXCenter) ? ($iError) : (BitOR($iError, 8))
$iError = ($iYCenter = Null) ? $iError : ($oShape.FillGradient.YOffset() = $iYCenter) ? ($iError) : (BitOR($iError, 16))
$iError = ($iAngle = Null) ? $iError : (($oShape.FillGradient.Angle() / 10) = $iAngle) ? ($iError) : (BitOR($iError, 32))
$iError = ($iTransitionStart = Null) ? $iError : ($oShape.FillGradient.Border() = $iTransitionStart) ? ($iError) : (BitOR($iError, 64))
$iError = ($iFromColor = Null) ? $iError : ($oShape.FillGradient.StartColor() = $iFromColor) ? ($iError) : (BitOR($iError, 128))
$iError = ($iToColor = Null) ? $iError : ($oShape.FillGradient.EndColor() = $iToColor) ? ($iError) : (BitOR($iError, 256))
$iError = ($iFromIntense = Null) ? $iError : ($oShape.FillGradient.StartIntensity() = $iFromIntense) ? ($iError) : (BitOR($iError, 512))
$iError = ($iToIntense = Null) ? $iError : ($oShape.FillGradient.EndIntensity() = $iToIntense) ? ($iError) : (BitOR($iError, 1024))
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_ShapeAreaGradient
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ShapeDelete
; Description ...: Delete a Shape.
; Syntax ........: _LOWriter_ShapeDelete(ByRef $oDoc, $oShape)
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oShape - an object. A Shape object returned by a previous _LOWriter_ShapeInsert, or _LOWriter_ShapeGetObjByName 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 = $oShape not an Object.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Shape's name.
; @Error 3 @Extended 2 Return 0 = Shape with the same name still exists in document after deletion attempt.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Shape was successfully deleted.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_ShapeInsert, _LOWriter_ShapeGetObjByName
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ShapeDelete(ByRef $oDoc, $oShape)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $sShapeName
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oShape) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$sShapeName = $oShape.Name()
If Not IsString($sShapeName) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$oDoc.getDrawPage().remove($oShape)
Return (_LOWriter_ShapeExists($oDoc, $sShapeName)) ? (SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_ShapeDelete
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ShapeExists
; Description ...: Check if a Document contains a Shape with the specified name.
; Syntax ........: _LOWriter_ShapeExists(ByRef $oDoc, $sShapeName)
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $sShapeName - a string value. The Shape 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 = $sShapeName not a String.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Error retrieving Draw Page Object.
; --Success--
; @Error 0 @Extended 0 Return Boolean = Success. If a Shape was found matching $sShapeName, True is returned, else False.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_ShapeGetObjByName
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ShapeExists(ByRef $oDoc, $sShapeName)
Local $oShapes
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsString($sShapeName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oShapes = $oDoc.DrawPage()
If Not IsObj($oShapes) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If $oShapes.hasElements() Then
For $i = 0 To $oShapes.getCount() - 1
If ($oShapes.getByIndex($i).Name() = $sShapeName) Then Return SetError($__LO_STATUS_SUCCESS, 0, True)
Sleep((IsInt($i / $__LOWCONST_SLEEP_DIV) ? (10) : (0)))
Next
EndIf
Return SetError($__LO_STATUS_SUCCESS, 0, False) ;No matches
EndFunc ;==>_LOWriter_ShapeExists
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ShapeGetAnchor
; Description ...: Create a Text Cursor at the Shape Anchor position.
; Syntax ........: _LOWriter_ShapeGetAnchor(ByRef $oShape)
; Parameters ....: $oShape - [in/out] an object. A Shape object returned by a previous _LOWriter_ShapeInsert, or _LOWriter_ShapeGetObjByName 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 = $oShape not an Object.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Failed to retrieve Shape anchor Object.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Successfully returned the Shape Anchor.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_ShapeInsert, _LOWriter_ShapeGetObjByName
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ShapeGetAnchor(ByRef $oShape)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oAnchor
If Not IsObj($oShape) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$oAnchor = $oShape.Anchor.Text.createTextCursorByRange($oShape.Anchor())
If Not IsObj($oAnchor) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, $oAnchor)
EndFunc ;==>_LOWriter_ShapeGetAnchor
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ShapeGetObjByName
; Description ...: Retrieve a Shape Object, for later Shape related functions.
; Syntax ........: _LOWriter_ShapeGetObjByName(ByRef $oDoc, $sShapeName)
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $sShapeName - a string value. The Shape name to retrieve the object for.
; 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 = $sShapeName not a String.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Draw Page Object.
; @Error 3 @Extended 2 Return 0 = Shape requested in $sShapeName not found in document.
; --Success--
; @Error 0 @Extended 0 Return Object = Success, Returning the requested Shape Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOWriter_ShapesGetNames
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ShapeGetObjByName(ByRef $oDoc, $sShapeName)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oShapes
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsString($sShapeName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oShapes = $oDoc.DrawPage()
If Not IsObj($oShapes) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If $oShapes.hasElements() Then
For $i = 0 To $oShapes.getCount() - 1
If ($oShapes.getByIndex($i).Name() = $sShapeName) Then Return SetError($__LO_STATUS_SUCCESS, 2, $oShapes.getByIndex($i))
Sleep((IsInt($i / $__LOWCONST_SLEEP_DIV) ? (10) : (0)))
Next
EndIf
Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0) ;Shape not found
EndFunc ;==>_LOWriter_ShapeGetObjByName
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ShapeGetType
; Description ...: Return the Shape's Type corresponding to the constants $LOW_SHAPE_TYPE_*
; Syntax ........: _LOWriter_ShapeGetType(ByRef $oShape)
; Parameters ....: $oShape - [in/out] an object. A Shape object returned by a previous _LOWriter_ShapeInsert, or _LOWriter_ShapeGetObjByName 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 = $oShape not an Object.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve CustomShapeGeometry Array.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve CustomShapeGeometry "Type" value.
; @Error 3 @Extended 3 Return 0 = Failed to determine CustomShape's type.
; @Error 3 @Extended 4 Return 0 = Failed to identify what type of "com.sun.star.drawing.EllipseShape" called shape is.
; @Error 3 @Extended 5 Return 0 = Called Shape is a unknown shape type.
; --Success--
; @Error 0 @Extended 1 Return Integer = Success. Shape is a Custom Shape Type. Returning appropriate Constant for shape type if successfully identified, else -1 if identification failed. See Remarks #1. See Constants, $LOW_SHAPE_TYPE_* as defined in LibreOfficeWriter_Constants.au3
; @Error 0 @Extended 2 Return Integer = Success. Shape is a *_BASIC_CIRCLE_SEGMENT or *_BASIC_ARC Type Shape. Returning appropriate Constant, See Constants, $LOW_SHAPE_TYPE_* as defined in LibreOfficeWriter_Constants.au3
; @Error 0 @Extended 3 Return Integer = Success. Shape is a *_LINE_CURVE or *_LINE_FREEFORM_LINE Type Shape. Returning $LOW_SHAPE_TYPE_LINE_CURVE Constant Value. See Remarks #2.
; @Error 0 @Extended 4 Return Integer = Success. Shape is a *_LINE_CURVE_FILLED or *_LINE_FREEFORM_LINE_FILLED Type Shape. Returning $LOW_SHAPE_TYPE_LINE_CURVE_FILLED Constant Value. See Remarks #2.
; @Error 0 @Extended 5 Return Integer = Success. Shape is a *_LINE_LINE Type Shape. Returning $LOW_SHAPE_TYPE_LINE_LINE Constant Value.
; @Error 0 @Extended 6 Return Integer = Success. Shape is a *_LINE_POLYGON, *_LINE_POLYGON_45 or *_LINE_POLYGON_45_FILLED Type Shape. Returning $LOW_SHAPE_TYPE_LINE_POLYGON Constant Value. See Remarks #2.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: #1 Some shapes are not implemented, or not fully implemented into LibreOffice for automation, consequently they do not have appropriate type names as of yet. Many have simply ambiguous names, such as "non-primitive".
; Because of this the following Custom shape types cannot be identified, and this function will return -1:
; $LOW_SHAPE_TYPE_ARROWS_ARROW_CALLOUT_UP_RIGHT, known as "mso-spt100".
; $LOW_SHAPE_TYPE_ARROWS_ARROW_CORNER_RIGHT, known as "non-primitive", should be "corner-right-arrow".
; $LOW_SHAPE_TYPE_ARROWS_ARROW_RIGHT_OR_LEFT, known as "non-primitive", should be "split-arrow".
; $LOW_SHAPE_TYPE_ARROWS_ARROW_S_SHAPED, known as "non-primitive", should be "s-sharped-arrow".
; $LOW_SHAPE_TYPE_ARROWS_ARROW_SPLIT, known as "non-primitive", should be "split-arrow".
; $LOW_SHAPE_TYPE_ARROWS_ARROW_STRIPED_RIGHT, known as "mso-spt100", should be "striped-right-arrow".
; $LOW_SHAPE_TYPE_ARROWS_ARROW_UP_RIGHT, known as "mso-spt89", should be "up-right-arrow-callout".
; $LOW_SHAPE_TYPE_ARROWS_ARROW_UP_RIGHT_DOWN, known as "mso-spt100", should be "up-right-down-arrow".
; $LOW_SHAPE_TYPE_BASIC_CIRCLE_PIE, known as "mso-spt100", should be "circle-pie".
; $LOW_SHAPE_TYPE_STARS_6_POINT, known as "non-primitive", should be "star6".
; $LOW_SHAPE_TYPE_STARS_6_POINT_CONCAVE, known as "non-primitive", should be "concave-star6".
; $LOW_SHAPE_TYPE_STARS_12_POINT, known as "non-primitive", should be "star12".
; $LOW_SHAPE_TYPE_STARS_SIGNET, known as "non-primitive", should be "signet".
; $LOW_SHAPE_TYPE_SYMBOL_CLOUD, known as "non-primitive", should be "cloud"?
; $LOW_SHAPE_TYPE_SYMBOL_FLOWER, known as "non-primitive", should be "flower"?
; $LOW_SHAPE_TYPE_SYMBOL_LIGHTNING, known as "non-primitive", should be "lightning".
; #2 The following Shapes implement the same type names, and are consequently indistinguishable:
; $LOW_SHAPE_TYPE_BASIC_CIRCLE, $LOW_SHAPE_TYPE_BASIC_ELLIPSE (The Value of $LOW_SHAPE_TYPE_BASIC_CIRCLE is returned for either one.)
; $LOW_SHAPE_TYPE_BASIC_SQUARE, $LOW_SHAPE_TYPE_BASIC_RECTANGLE (The Value of $LOW_SHAPE_TYPE_BASIC_SQUARE is returned for either one.)
; $LOW_SHAPE_TYPE_BASIC_SQUARE_ROUNDED, $LOW_SHAPE_TYPE_BASIC_RECTANGLE_ROUNDED (The Value of $LOW_SHAPE_TYPE_BASIC_SQUARE_ROUNDED is returned for either one.)
; $LOW_SHAPE_TYPE_LINE_CURVE, $LOW_SHAPE_TYPE_LINE_FREEFORM_LINE (The Value of $LOW_SHAPE_TYPE_LINE_CURVE is returned for either one.)
; $LOW_SHAPE_TYPE_LINE_CURVE_FILLED, $LOW_SHAPE_TYPE_LINE_FREEFORM_LINE_FILLED (The Value of $LOW_SHAPE_TYPE_LINE_CURVE_FILLED is returned for either one.)
; $LOW_SHAPE_TYPE_LINE_POLYGON, $LOW_SHAPE_TYPE_LINE_POLYGON_45, $LOW_SHAPE_TYPE_LINE_POLYGON_45_FILLED (The Value of $LOW_SHAPE_TYPE_LINE_POLYGON is returned for any of these.)
; The following Shapes have strange names that may change in the future, but currently are able to be identified:
; $LOW_SHAPE_TYPE_STARS_DOORPLATE, known as, "mso-spt21", should be "doorplate"
; $LOW_SHAPE_TYPE_SYMBOL_BEVEL_DIAMOND, known as, "col-502ad400", should be ??
; $LOW_SHAPE_TYPE_SYMBOL_BEVEL_OCTAGON, known as, "col-60da8460", should be ??
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ShapeGetType(ByRef $oShape)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $atCusShapeGeo[0]
Local Const $iCircleKind_CUT = 2 ; a circle with a cut connected by a line.
Local Const $iCircleKind_ARC = 3 ; a circle with an open cut.
Local $sType
Local $iReturn
If Not IsObj($oShape) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
Switch $oShape.ShapeType()
Case "com.sun.star.drawing.CustomShape"
$atCusShapeGeo = $oShape.CustomShapeGeometry()
If Not IsArray($atCusShapeGeo) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
For $i = 0 To UBound($atCusShapeGeo) - 1
If ($atCusShapeGeo[$i].Name() = "Type") Then
$sType = $atCusShapeGeo[$i].Value()
If Not IsString($sType) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
ExitLoop
EndIf
Sleep((IsInt($i / $__LOWCONST_SLEEP_DIV)) ? (10) : (0))
Next
$iReturn = __LOWriter_Shape_GetCustomType($sType)
If @error Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 3, 0)
Return SetError($__LO_STATUS_SUCCESS, 1, $iReturn)
Case "com.sun.star.drawing.EllipseShape"
If ($oShape.CircleKind() = $iCircleKind_CUT) Then ; Circle Segment = CircleKind_CUT(2), Arc = CircleKind_ARC(3)
Return SetError($__LO_STATUS_SUCCESS, 2, $LOW_SHAPE_TYPE_BASIC_CIRCLE_SEGMENT)
ElseIf ($oShape.CircleKind() = $iCircleKind_ARC) Then
Return SetError($__LO_STATUS_SUCCESS, 2, $LOW_SHAPE_TYPE_BASIC_ARC)
Else
Return SetError($__LO_STATUS_PROCESSING_ERROR, 4, 0)
EndIf
Case "com.sun.star.drawing.OpenBezierShape"
;~ $LOW_SHAPE_TYPE_LINE_CURVE ; No way to differentiate between these??
;~ $LOW_SHAPE_TYPE_LINE_FREEFORM_LINE
Return SetError($__LO_STATUS_SUCCESS, 3, $LOW_SHAPE_TYPE_LINE_CURVE)
Case "com.sun.star.drawing.ClosedBezierShape"
;~ $LOW_SHAPE_TYPE_LINE_CURVE_FILLED ; No way to differentiate between these??
;~ $LOW_SHAPE_TYPE_LINE_FREEFORM_LINE_FILLED
Return SetError($__LO_STATUS_SUCCESS, 4, $LOW_SHAPE_TYPE_LINE_CURVE_FILLED)
Case "com.sun.star.drawing.LineShape"
Return SetError($__LO_STATUS_SUCCESS, 5, $LOW_SHAPE_TYPE_LINE_LINE)
Case "com.sun.star.drawing.PolyPolygonShape"
Return SetError($__LO_STATUS_SUCCESS, 6, $LOW_SHAPE_TYPE_LINE_POLYGON)
;~ $LOW_SHAPE_TYPE_LINE_POLYGON ; No way to differentiate between these??
;~ $LOW_SHAPE_TYPE_LINE_POLYGON_45
;~ $LOW_SHAPE_TYPE_LINE_POLYGON_45_FILLED
Case Else
Return SetError($__LO_STATUS_PROCESSING_ERROR, 5, 0) ; Unknown shape type.
EndSwitch
EndFunc ;==>_LOWriter_ShapeGetType
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ShapeInsert
; Description ...: Insert a shape into a document.
; Syntax ........: _LOWriter_ShapeInsert(ByRef $oDoc, ByRef $oCursor, $iShapeType, $iWidth, $iHeight)
; 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 functions. See Remarks.
; $iShapeType - an integer value (0-122). The Type of shape to create. See remarks. See $LOW_SHAPE_TYPE_* as defined in LibreOfficeWriter_Constants.au3
; $iWidth - an integer value. The Shape's Width in Micrometers. Note, for Lines, Width is the length of the line
; $iHeight - an integer value. The Shape's Height in Micrometers. Note, for Lines, Height is the amount the line goes below the point of insertion.
; 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 = $iShapeType not an Integer, less than 0, or greater than 122. See $LOW_SHAPE_TYPE_* as defined in LibreOfficeWriter_Constants.au3
; @Error 1 @Extended 4 Return 0 = $iWidth not an Integer.
; @Error 1 @Extended 5 Return 0 = $iHeight not an Integer.
; @Error 1 @Extended 6 Return 0 = Cursor called in $oCursor is a Table Cursor, and cannot be used.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Failed to create requested Shape.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to determine Cursor type.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve CustomShapeGeometry Array of Structures.
; @Error 3 @Extended 3 Return 0 = Failed to retrieve PolyPolygonBezier Structure.
; @Error 3 @Extended 4 Return 0 = Failed to retrieve the Position Structure.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. The Shape was successfully inserted. Returning the Shape's Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: $oCursor cannot be a Table Cursor.
; Line Shapes, such as Curves etc., may not be smoothly curved. This is due to my lack of understanding of setting Point type settings. You will need to manually select the individual points and set the Point type in L.O. UI.
; Polygon and Polygon 45 degree are the same shape internally, one only allows you to draw the lines at 45 degree angles in L.O. UI.
; The following shapes are not implemented into LibreOffice as of L.O. Version 7.3.4.2 for automation, and thus will not work:
; $LOW_SHAPE_TYPE_ARROWS_ARROW_S_SHAPED, $LOW_SHAPE_TYPE_ARROWS_ARROW_SPLIT, $LOW_SHAPE_TYPE_ARROWS_ARROW_RIGHT_OR_LEFT, $LOW_SHAPE_TYPE_ARROWS_ARROW_CORNER_RIGHT, $LOW_SHAPE_TYPE_ARROWS_ARROW_UP_RIGHT_DOWN, $LOW_SHAPE_TYPE_ARROWS_ARROW_CALLOUT_UP_RIGHT
; $LOW_SHAPE_TYPE_BASIC_CIRCLE_PIE, $LOW_SHAPE_TYPE_BASIC_FRAME
; $LOW_SHAPE_TYPE_STARS_6_POINT, $LOW_SHAPE_TYPE_STARS_12_POINT, $LOW_SHAPE_TYPE_STARS_SIGNET, $LOW_SHAPE_TYPE_STARS_6_POINT_CONCAVE
; $LOW_SHAPE_TYPE_SYMBOL_CLOUD, $LOW_SHAPE_TYPE_SYMBOL_FLOWER, $LOW_SHAPE_TYPE_SYMBOL_PUZZLE, $LOW_SHAPE_TYPE_SYMBOL_BEVEL_OCTAGON, $LOW_SHAPE_TYPE_SYMBOL_BEVEL_DIAMOND
; Inserting any of the above shapes will still show successful, but the shape will be invisible, and could cause the document to crash.
; The following shape is visually different from the manually inserted one in L.O. 7.3.4.2:
; $LOW_SHAPE_TYPE_SYMBOL_LIGHTNING
; Related .......: _LOWriter_ConvertFromMicrometer, _LOWriter_ConvertToMicrometer
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ShapeInsert(ByRef $oDoc, ByRef $oCursor, $iShapeType, $iWidth, $iHeight)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iCursorType
Local $oShape
Local $tPos, $tPolyCoords
Local $atCusShapeGeo
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 Not __LOWriter_IntIsBetween($iShapeType, $LOW_SHAPE_TYPE_ARROWS_ARROW_4_WAY, $LOW_SHAPE_TYPE_SYMBOL_PUZZLE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If Not IsInt($iWidth) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
If Not IsInt($iHeight) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$iCursorType = __LOWriter_Internal_CursorGetType($oCursor)
If @error > 0 Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If ($iCursorType = $LOW_CURTYPE_TABLE_CURSOR) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
Switch $iShapeType
Case $LOW_SHAPE_TYPE_ARROWS_ARROW_4_WAY To $LOW_SHAPE_TYPE_ARROWS_PENTAGON ; Create an Arrow Shape.
$oShape = __LOWriter_Shape_CreateArrow($oDoc, $iWidth, $iHeight, $iShapeType)
If @error Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
$atCusShapeGeo = $oShape.CustomShapeGeometry() ; Backup the CustomShapeGeometry property, as it is generally lost upon insertion.
If Not IsArray($atCusShapeGeo) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
Case $LOW_SHAPE_TYPE_BASIC_ARC To $LOW_SHAPE_TYPE_BASIC_TRIANGLE_RIGHT ; Create a Basic Shape.
$oShape = __LOWriter_Shape_CreateBasic($oDoc, $iWidth, $iHeight, $iShapeType)
If @error Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
If ($iShapeType <> $LOW_SHAPE_TYPE_BASIC_CIRCLE_SEGMENT) And ($iShapeType <> $LOW_SHAPE_TYPE_BASIC_ARC) Then ; Arc and Circle Segment shapes are different from the rest, and don't have CustomShapeGeometry property.
$atCusShapeGeo = $oShape.CustomShapeGeometry() ; Backup the CustomShapeGeometry property, as it is generally lost upon insertion.
If Not IsArray($atCusShapeGeo) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
EndIf
Case $LOW_SHAPE_TYPE_CALLOUT_CLOUD To $LOW_SHAPE_TYPE_CALLOUT_ROUND ; Create a Callout Shape.
$oShape = __LOWriter_Shape_CreateCallout($oDoc, $iWidth, $iHeight, $iShapeType)
If @error Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
$atCusShapeGeo = $oShape.CustomShapeGeometry() ; Backup the CustomShapeGeometry property, as it is generally lost upon insertion.
If Not IsArray($atCusShapeGeo) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
Case $LOW_SHAPE_TYPE_FLOWCHART_CARD To $LOW_SHAPE_TYPE_FLOWCHART_TERMINATOR ; Create a Flowchart Shape.
$oShape = __LOWriter_Shape_CreateFlowchart($oDoc, $iWidth, $iHeight, $iShapeType)
If @error Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
$atCusShapeGeo = $oShape.CustomShapeGeometry() ; Backup the CustomShapeGeometry property, as it is generally lost upon insertion.
If Not IsArray($atCusShapeGeo) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
Case $LOW_SHAPE_TYPE_LINE_CURVE To $LOW_SHAPE_TYPE_LINE_POLYGON_45_FILLED ; Create a Line Shape.
$oShape = __LOWriter_Shape_CreateLine($oDoc, $iWidth, $iHeight, $iShapeType)
If @error Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
$tPolyCoords = $oShape.PolyPolygonBezier()
If Not IsObj($tPolyCoords) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 3, 0)
Case $LOW_SHAPE_TYPE_STARS_4_POINT To $LOW_SHAPE_TYPE_STARS_SIGNET ; Create a Star or Banner Shape.
$oShape = __LOWriter_Shape_CreateStars($oDoc, $iWidth, $iHeight, $iShapeType)
If @error Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
$atCusShapeGeo = $oShape.CustomShapeGeometry() ; Backup the CustomShapeGeometry property, as it is generally lost upon insertion.
If Not IsArray($atCusShapeGeo) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
Case $LOW_SHAPE_TYPE_SYMBOL_BEVEL_DIAMOND To $LOW_SHAPE_TYPE_SYMBOL_PUZZLE ; Create a Symbol Shape.
$oShape = __LOWriter_Shape_CreateSymbol($oDoc, $iWidth, $iHeight, $iShapeType)
If @error Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
$atCusShapeGeo = $oShape.CustomShapeGeometry() ; Backup the CustomShapeGeometry property, as it is generally lost upon insertion.
If Not IsArray($atCusShapeGeo) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
EndSwitch
$tPos = $oShape.Position() ; Backup the position, as it is generally lost upon insertion.
If Not IsObj($tPos) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 4, 0)
$oCursor.Text.insertTextContent($oCursor, $oShape, False)
$oShape.AnchorType = $LOW_ANCHOR_AT_PARAGRAPH
If IsObj($tPolyCoords) Then
$oShape.PolyPolygonBezier = $tPolyCoords ; If shape used the PolyPolygonBezier property, re-Set it after insertion.
ElseIf IsArray($atCusShapeGeo) Then
$oShape.CustomShapeGeometry = $atCusShapeGeo ; If shape used the CustomSHapeGeometry property, re-Set it after insertion.
EndIf
$oShape.Position = $tPos ; re-Set the position after insertion.
If ($oShape.ShapeType() = "com.sun.star.drawing.CustomShape") Then
; Settings for TextBox use.
$oShape.TextMinimumFrameWidth = $iWidth
$oShape.TextMinimumFrameHeight = $iHeight
$oShape.TextVerticalAdjust = $LOW_ALIGN_VERT_MIDDLE
$oShape.TextWrap = $LOW_WRAP_MODE_THROUGH
$oShape.TextAutoGrowHeight = False
$oShape.TextAutoGrowWidth = False
EndIf
Return SetError($__LO_STATUS_SUCCESS, 0, $oShape)
EndFunc ;==>_LOWriter_ShapeInsert
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ShapeLineArrowStyles
; Description ...: Set or Retrieve Shape Line Start and End Arrow Style settings.
; Syntax ........: _LOWriter_ShapeLineArrowStyles(ByRef $oShape[, $vStartStyle = Null[, $iStartWidth = Null[, $bStartCenter = Null[, $bSync = Null[, $vEndStyle = Null[, $iEndWidth = Null[, $bEndCenter = Null]]]]]]])
; Parameters ....: $oShape - [in/out] an object. A Shape object returned by a previous _LOWriter_ShapeInsert, or _LOWriter_ShapeGetObjByName function.
; $vStartStyle - [optional] a variant value (0-32, or String). Default is Null. The Arrow head to apply to the start of the line. Can be a Custom Arrowhead name, or one of the constants, $LOW_SHAPE_LINE_ARROW_TYPE_* as defined in LibreOfficeWriter_Constants.au3. See remarks.
; $iStartWidth - [optional] an integer value (0-5004). Default is Null. The Width of the Starting Arrowhead, in Micrometers.
; $bStartCenter - [optional] a boolean value. Default is Null. If True, Places the center of the Start arrowhead on the endpoint of the line.
; $bSync - [optional] a boolean value. Default is Null. If True, Synchronizes the Start Arrowhead settings with the end Arrowhead settings. See remarks.
; $vEndStyle - [optional] a variant value (0-32, or String). Default is Null. The Arrow head to apply to the end of the line. Can be a Custom Arrowhead name, or one of the constants, $LOW_SHAPE_LINE_ARROW_TYPE_* as defined in LibreOfficeWriter_Constants.au3. See remarks.
; $iEndWidth - [optional] an integer value (0-5004). Default is Null. The Width of the Ending Arrowhead, in Micrometers.
; $bEndCenter - [optional] a boolean value. Default is Null. If True, Places the center of the End arrowhead on the endpoint of the line.
; Return values .: Success: Integer or Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oShape not an Object.
; @Error 1 @Extended 2 Return 0 = $vStartStyle not a String, and not an Integer.
; @Error 1 @Extended 3 Return 0 = $vStartStyle is an Integer, but less than 0, or greater than 32. See constants $LOW_SHAPE_LINE_ARROW_TYPE_* as defined in LibreOfficeWriter_Constants.au3.
; @Error 1 @Extended 4 Return 0 = $iStartWidth not an Integer, less than 0, or greater than 5004.
; @Error 1 @Extended 5 Return 0 = $bStartCenter not a Boolean.
; @Error 1 @Extended 6 Return 0 = $bSync not a Boolean.
; @Error 1 @Extended 7 Return 0 = $vEndStyle not a String, and not an Integer.
; @Error 1 @Extended 8 Return 0 = $vSEndStyle is an Integer, but less than 0, or greater than 32. See constants $LOW_SHAPE_LINE_ARROW_TYPE_* as defined in LibreOfficeWriter_Constants.au3.
; @Error 1 @Extended 9 Return 0 = $iEndWidth not an Integer, less than 0, or greater than 5004.
; @Error 1 @Extended 10 Return 0 = $bEndCenter not a Boolean.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to convert Constant to Arrowhead name.
; --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 $vStartStyle
; | 2 = Error setting $iStartWidth
; | 4 = Error setting $bStartCenter
; | 8 = Error setting $bSync
; | 16 = Error setting $vEndStyle
; | 32 = Error setting $iEndWidth
; | 64 = Error setting $bEndCenter
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings have been successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 7 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Libre Office has no setting for $bSync, so I have made a manual version of it in this function. It only accepts True, and must be called with True each time you want it to synchronize.
; When retrieving the current settings, $bSync will be a Boolean value of whether the Start Arrowhead settings are currently equal to the End Arrowhead setting values.
; Both $vStartStyle and $vEndStyle accept a String or an Integer because there is the possibility of a custom Arrowhead being available the user may want to use.
; When retrieving the current settings, both $vStartStyle and $vEndStyle could be either an integer or a String. It will be a String if the current Arrowhead is a custom Arrowhead, else an Integer, corresponding to one of the constants, $LOW_SHAPE_LINE_ARROW_TYPE_* as defined in LibreOfficeWriter_Constants.au3.
; 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 .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ShapeLineArrowStyles(ByRef $oShape, $vStartStyle = Null, $iStartWidth = Null, $bStartCenter = Null, $bSync = Null, $vEndStyle = Null, $iEndWidth = Null, $bEndCenter = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local $avArrow[7]
Local $sStartStyle, $sEndStyle
If Not IsObj($oShape) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_VarsAreNull($vStartStyle, $iStartWidth, $bStartCenter, $bSync, $vEndStyle, $iEndWidth, $bEndCenter) Then
__LOWriter_ArrayFill($avArrow, __LOWriter_ShapeArrowStyleName(Null, $oShape.LineStartName()), $oShape.LineStartWidth(), $oShape.LineStartCenter(), _
((($oShape.LineStartName() = $oShape.LineEndName()) And ($oShape.LineStartWidth() = $oShape.LineEndWidth()) And ($oShape.LineStartCenter() = $oShape.LineEndCenter())) ? (True) : (False)), _ ; See if Start and End are the same.
__LOWriter_ShapeArrowStyleName(Null, $oShape.LineEndName()), $oShape.LineEndWidth(), $oShape.LineEndCenter())
Return SetError($__LO_STATUS_SUCCESS, 1, $avArrow)
EndIf
If ($vStartStyle <> Null) Then
If Not IsString($vStartStyle) And Not IsInt($vStartStyle) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If IsInt($vStartStyle) Then
If Not __LOWriter_IntIsBetween($vStartStyle, $LOW_SHAPE_LINE_ARROW_TYPE_NONE, $LOW_SHAPE_LINE_ARROW_TYPE_CF_ZERO_MANY) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$sStartStyle = __LOWriter_ShapeArrowStyleName($vStartStyle)
If @error Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
Else
$sStartStyle = $vStartStyle
EndIf
$oShape.LineStartName = $sStartStyle
$iError = ($oShape.LineStartName() = $sStartStyle) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($iStartWidth <> Null) Then
If Not __LOWriter_IntIsBetween($iStartWidth, 0, 5004) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oShape.LineStartWidth = $iStartWidth
$iError = (__LOWriter_IntIsBetween($oShape.LineStartWidth(), $iStartWidth - 1, $iStartWidth + 1)) ? ($iError) : (BitOR($iError, 2))
EndIf
If ($bStartCenter <> Null) Then
If Not IsBool($bStartCenter) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oShape.LineStartCenter = $bStartCenter
$iError = ($oShape.LineStartCenter() = $bStartCenter) ? ($iError) : (BitOR($iError, 4))
EndIf
If ($bSync <> Null) Then
If Not IsBool($bSync) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
If ($bSync = True) Then
$oShape.LineEndName = $oShape.LineStartName()
$oShape.LineEndWidth = $oShape.LineStartWidth()
$oShape.LineEndCenter = $oShape.LineStartCenter()
$iError = (($oShape.LineStartName() = $oShape.LineEndName()) And _
($oShape.LineStartWidth() = $oShape.LineEndWidth()) And _
($oShape.LineStartCenter() = $oShape.LineEndCenter())) ? ($iError) : (BitOR($iError, 8))
EndIf
EndIf
If ($vEndStyle <> Null) Then
If Not IsString($vEndStyle) And Not IsInt($vEndStyle) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
If IsInt($vEndStyle) Then
If Not __LOWriter_IntIsBetween($vEndStyle, $LOW_SHAPE_LINE_ARROW_TYPE_NONE, $LOW_SHAPE_LINE_ARROW_TYPE_CF_ZERO_MANY) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0)
$sEndStyle = __LOWriter_ShapeArrowStyleName($vEndStyle)
If @error Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
Else
$sEndStyle = $vEndStyle
EndIf
$oShape.LineEndName = $sEndStyle
$iError = ($oShape.LineEndName() = $sEndStyle) ? ($iError) : (BitOR($iError, 16))
EndIf
If ($iEndWidth <> Null) Then
If Not __LOWriter_IntIsBetween($iEndWidth, 0, 5004) Then Return SetError($__LO_STATUS_INPUT_ERROR, 9, 0)
$oShape.LineEndWidth = $iEndWidth
$iError = (__LOWriter_IntIsBetween($oShape.LineEndWidth(), $iEndWidth - 1, $iEndWidth + 1)) ? ($iError) : (BitOR($iError, 32))
EndIf
If ($bEndCenter <> Null) Then
If Not IsBool($bEndCenter) Then Return SetError($__LO_STATUS_INPUT_ERROR, 10, 0)
$oShape.LineEndCenter = $bEndCenter
$iError = ($oShape.LineEndCenter() = $bEndCenter) ? ($iError) : (BitOR($iError, 64))
EndIf
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_ShapeLineArrowStyles
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ShapeLineProperties
; Description ...: Set or Retrieve Shape Line settings.
; Syntax ........: _LOWriter_ShapeLineProperties(ByRef $oShape[, $vStyle = Null[, $iColor = Null[, $iWidth = Null[, $iTransparency = Null[, $iCornerStyle = Null[, $iCapStyle = Null]]]]]])
; Parameters ....: $oShape - [in/out] an object. A Shape object returned by a previous _LOWriter_ShapeInsert, or _LOWriter_ShapeGetObjByName function.
; $vStyle - [optional] a variant value (0-31, or String). Default is Null. The Line Style to use. Can be a Custom Line Style name, or one of the constants, $LOW_SHAPE_LINE_STYLE_* as defined in LibreOfficeWriter_Constants.au3. See remarks.
; $iColor - [optional] an integer value (0-16777215). Default is Null. The Line color, set in Long integer format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; $iWidth - [optional] an integer value (0-5004). Default is Null. The line Width, set in Micrometers.
; $iTransparency - [optional] an integer value (0-100). Default is Null. The Line transparency percentage. 100% = fully transparent.
; $iCornerStyle - [optional] an integer value (0,2-4). Default is Null. The Line Corner Style. See Constants $LOW_SHAPE_LINE_JOINT_* as defined in LibreOfficeWriter_Constants.au3
; $iCapStyle - [optional] an integer value (0-2). Default is Null. The Line Cap Style. See Constants $LOW_SHAPE_LINE_CAP_* as defined in LibreOfficeWriter_Constants.au3
; Return values .: Success: Integer or Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oShape not an Object.
; @Error 1 @Extended 2 Return 0 = $vStyle not a String, and not an Integer.
; @Error 1 @Extended 3 Return 0 = $vStyle is an Integer, but less than 0, or greater than 31. See constants $LOW_SHAPE_LINE_STYLE_* as defined in LibreOfficeWriter_Constants.au3.
; @Error 1 @Extended 4 Return 0 = $iColor not an Integer, less than 0, or greater than 16777215.
; @Error 1 @Extended 5 Return 0 = $iWidth not an Integer, less than 0, or greater than 5004.
; @Error 1 @Extended 6 Return 0 = $iTransparency not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 7 Return 0 = $iCornerStyle not an Integer, not equal to 0, equal to 1, not equal to 2 or greater than 4. See Constants $LOW_SHAPE_LINE_JOINT_* as defined in LibreOfficeWriter_Constants.au3
; @Error 1 @Extended 8 Return 0 = $iCapStyle is an Integer, but less than 0, or greater than 2. See constants $LOW_SHAPE_LINE_CAP_* as defined in LibreOfficeWriter_Constants.au3.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to convert Constant to Line Style name.
; --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 $vStyle
; | 2 = Error setting $iColor
; | 4 = Error setting $iWidth
; | 8 = Error setting $iTransparency
; | 16 = Error setting $iCornerStyle
; | 32 = Error setting $iCapStyle
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings have been 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 .......: $vStyle accepts a String or an Integer because there is the possibility of a custom Line Style being available that the user may want to use.
; When retrieving the current settings, $vStyle could be either an integer or a String. It will be a String if the current Line Style is a custom Line Style, else an Integer, corresponding to one of the constants, $LOW_SHAPE_LINE_STYLE_* as defined in LibreOfficeWriter_Constants.au3.
; 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_ShapeInsert, _LOWriter_ShapeGetObjByName, _LOWriter_ConvertColorFromLong, _LOWriter_ConvertColorToLong
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ShapeLineProperties(ByRef $oShape, $vStyle = Null, $iColor = Null, $iWidth = Null, $iTransparency = Null, $iCornerStyle = Null, $iCapStyle = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local Const $__LOW_SHAPE_LINE_STYLE_NONE = 0, $__LOW_SHAPE_LINE_STYLE_SOLID = 1, $__LOW_SHAPE_LINE_STYLE_DASH = 2
Local $avLine[6]
Local $sStyle
Local $vReturn
If Not IsObj($oShape) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_VarsAreNull($vStyle, $iColor, $iWidth, $iTransparency, $iCornerStyle, $iCapStyle) Then
Switch $oShape.LineStyle()
Case $__LOW_SHAPE_LINE_STYLE_NONE
$vReturn = $LOW_SHAPE_LINE_STYLE_NONE