-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLibreOfficeCalc_Comments.au3
2367 lines (1987 loc) · 149 KB
/
LibreOfficeCalc_Comments.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 Calc
#include "LibreOfficeCalc_Constants.au3"
#include "LibreOfficeCalc_Helper.au3"
; #INDEX# =======================================================================================================================
; Title .........: LibreOffice UDF
; AutoIt Version : v3.3.16.1
; Description ...: Provides basic functionality through AutoIt for Creating, Modifying, Removing, etc. L.O. Calc document Cell Comments.
; Author(s) .....: donnyh13, mLipok
; Dll ...........:
;
; ===============================================================================================================================
; #CURRENT# =====================================================================================================================
; _LOCalc_CommentAdd
; _LOCalc_CommentAreaColor
; _LOCalc_CommentAreaFillStyle
; _LOCalc_CommentAreaGradient
; _LOCalc_CommentAreaShadow
; _LOCalc_CommentAreaTransparency
; _LOCalc_CommentAreaTransparencyGradient
; _LOCalc_CommentCallout
; _LOCalc_CommentCreateTextCursor
; _LOCalc_CommentDelete
; _LOCalc_CommentGetCell
; _LOCalc_CommentGetLastEdit
; _LOCalc_CommentGetObjByCell
; _LOCalc_CommentGetObjByIndex
; _LOCalc_CommentLineArrowStyles
; _LOCalc_CommentLineProperties
; _LOCalc_CommentPosition
; _LOCalc_CommentRotate
; _LOCalc_CommentsGetCount
; _LOCalc_CommentsGetList
; _LOCalc_CommentSize
; _LOCalc_CommentText
; _LOCalc_CommentTextAnchor
; _LOCalc_CommentTextAnimation
; _LOCalc_CommentTextColumns
; _LOCalc_CommentTextSettings
; _LOCalc_CommentVisible
; ===============================================================================================================================
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_CommentAdd
; Description ...: Add a comment to a cell.
; Syntax ........: _LOCalc_CommentAdd(ByRef $oCell, $sText)
; Parameters ....: $oCell - [in/out] an object. A Cell object returned by a previous _LOCalc_RangeGetCellByName, or _LOCalc_RangeGetCellByPosition function.
; $sText - a string value. The initial text of the Comment. Cannot be empty.
; Return values .: Success: Object
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oCell not an Object.
; @Error 1 @Extended 2 Return 0 = $oCell not a Cell Object.
; @Error 1 @Extended 3 Return 0 = $sText not a String or string is empty.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Annotations Object.
; @Error 3 @Extended 2 Return 0 = Called Cell already contains a Comment.
; @Error 3 @Extended 3 Return 0 = Failed to retrieve Cell Address.
; @Error 3 @Extended 4 Return 0 = Failed to retrieve new Comment Object.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Returning newly inserted Comment's Object.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOCalc_CommentDelete
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_CommentAdd(ByRef $oCell, $sText)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $tAddress
Local $oAnnotations, $oAnnotation
If Not IsObj($oCell) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not $oCell.SupportsService("com.sun.star.sheet.SheetCell") Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If Not IsString($sText) Or ($sText = "") Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oAnnotations = $oCell.Spreadsheet.Annotations()
If Not IsObj($oAnnotations) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$oAnnotation = __LOCalc_CommentGetObjByCell($oCell)
If IsObj($oAnnotation) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
$tAddress = $oCell.CellAddress()
If Not IsObj($tAddress) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 3, 0)
$oAnnotations.insertNew($tAddress, $sText)
$oAnnotation = __LOCalc_CommentGetObjByCell($oCell)
If @error Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 4, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, $oAnnotation)
EndFunc ;==>_LOCalc_CommentAdd
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_CommentAreaColor
; Description ...: Set or Retrieve the Comment's background color.
; Syntax ........: _LOCalc_CommentAreaColor(ByRef $oComment[, $iColor = Null])
; Parameters ....: $oComment - [in/out] an object. A Comment object returned by a previous _LOCalc_CommentsGetList, _LOCalc_CommentGetObjByCell, or _LOCalc_CommentGetObjByIndex function.
; $iColor - [optional] an integer value (0-16777215). Default is Null. The color for the background of the comment, set in Long Color Integer format. Can be a custom value, or one of the constants, $LOC_COLOR_* as defined in LibreOfficeCalc_Constants.au3.
; 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 = $oComment not an Object.
; @Error 1 @Extended 2 Return 0 = $iColor not an Integer, less than 0 or greater than 16777215.
; --Property Setting Errors--
; @Error 4 @Extended ? Return 0 = Some settings were not successfully set. Use BitAND to test @Extended for 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 setting as an Integer value.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current setting.
; Related .......: _LOCalc_ConvertColorFromLong, _LOCalc_ConvertColorToLong
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_CommentAreaColor(ByRef $oComment, $iColor = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oAnnotationShape
If Not IsObj($oComment) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$oAnnotationShape = $oComment.AnnotationShape()
If Not IsObj($oAnnotationShape) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If ($iColor = Null) Then Return SetError($__LO_STATUS_SUCCESS, 1, $oAnnotationShape.FillColor())
If Not __LOCalc_IntIsBetween($iColor, $LOC_COLOR_BLACK, $LOC_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oAnnotationShape.FillStyle = $LOC_AREA_FILL_STYLE_SOLID
$oAnnotationShape.FillColor = $iColor
If ($oAnnotationShape.FillColor() <> $iColor) Then Return SetError($__LO_STATUS_PROP_SETTING_ERROR, 1, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, 1)
EndFunc ;==>_LOCalc_CommentAreaColor
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_CommentAreaFillStyle
; Description ...: Retrieve what kind of background fill is active, if any.
; Syntax ........: _LOCalc_CommentAreaFillStyle(ByRef $oComment)
; Parameters ....: $oComment - [in/out] an object. A Comment object returned by a previous _LOCalc_CommentsGetList, _LOCalc_CommentGetObjByCell, or _LOCalc_CommentGetObjByIndex 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 = $oComment 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 $LOC_AREA_FILL_STYLE_* as defined in LibreOfficeCalc_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 _LOCalc_CommentAreaFillStyle(ByRef $oComment)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iFillStyle
If Not IsObj($oComment) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$iFillStyle = $oComment.AnnotationShape.FillStyle()
If Not IsInt($iFillStyle) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, $iFillStyle)
EndFunc ;==>_LOCalc_CommentAreaFillStyle
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_CommentAreaGradient
; Description ...: Modify or retrieve the settings for Comment Background color Gradient.
; Syntax ........: _LOCalc_CommentAreaGradient(ByRef $oComment[, $sGradientName = Null[, $iType = Null[, $iIncrement = Null[, $iXCenter = Null[, $iYCenter = Null[, $iAngle = Null[, $iTransitionStart = Null[, $iFromColor = Null[, $iToColor = Null[, $iFromIntense = Null[, $iToIntense = Null]]]]]]]]]]])
; Parameters ....: $oComment - [in/out] an object. A Comment object returned by a previous _LOCalc_CommentsGetList, _LOCalc_CommentGetObjByCell, or _LOCalc_CommentGetObjByIndex function.
; $sGradientName - [optional] a string value. Default is Null. A Preset Gradient Name. See remarks. See constants, $LOC_GRAD_NAME_* as defined in LibreOfficeCalc_Constants.au3.
; $iType - [optional] an integer value (-1-5). Default is Null. The gradient type to apply. See Constants, $LOC_GRAD_TYPE_* as defined in LibreOfficeCalc_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, $LOC_COLOR_* as defined in LibreOfficeCalc_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, $LOC_COLOR_* as defined in LibreOfficeCalc_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 = $oComment not an Object.
; @Error 1 @Extended 2 Return 0 = $sGradientName not a String.
; @Error 1 @Extended 3 Return 0 = $iType not an Integer, less than -1, or greater than 5. See Constants, $LOC_GRAD_TYPE_* as defined in LibreOfficeCalc_Constants.au3.
; @Error 1 @Extended 4 Return 0 = $iIncrement not an Integer, less than 3, but not 0, or greater than 256.
; @Error 1 @Extended 5 Return 0 = $iXCenter not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 6 Return 0 = $iYCenter not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 7 Return 0 = $iAngle not an Integer, less than 0, or greater than 359.
; @Error 1 @Extended 8 Return 0 = $iTransitionStart not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 9 Return 0 = $iFromColor not an Integer, less than 0, or greater than 16777215.
; @Error 1 @Extended 10 Return 0 = $iToColor not an Integer, less than 0, or greater than 16777215.
; @Error 1 @Extended 11 Return 0 = $iFromIntense not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 12 Return 0 = $iToIntense not an Integer, less than 0, or greater than 100.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error retrieving "FillGradient" Object.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Error retrieving Annotation Shape Object.
; @Error 3 @Extended 2 Return 0 = Error retrieving Color Stop Array for "From" color
; @Error 3 @Extended 3 Return 0 = Error retrieving Color Stop Array for "To" color
; --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 .......: _LOCalc_ConvertColorFromLong, _LOCalc_ConvertColorToLong
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_CommentAreaGradient(ByRef $oComment, $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", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oAnnotationShape
Local $tStyleGradient, $tColorStop, $tStopColor
Local $iError = 0
Local $nRed, $nGreen, $nBlue
Local $atColorStop
Local $avGradient[11]
If Not IsObj($oComment) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$oAnnotationShape = $oComment.AnnotationShape()
If Not IsObj($oAnnotationShape) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$tStyleGradient = $oAnnotationShape.FillGradient()
If Not IsObj($tStyleGradient) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
If __LOCalc_VarsAreNull($sGradientName, $iType, $iIncrement, $iXCenter, $iYCenter, $iAngle, $iTransitionStart, $iFromColor, $iToColor, $iFromIntense, $iToIntense) Then
__LOCalc_ArrayFill($avGradient, $oAnnotationShape.FillGradientName(), $tStyleGradient.Style(), _
$oAnnotationShape.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 ($oAnnotationShape.FillStyle() <> $LOC_AREA_FILL_STYLE_GRADIENT) Then $oAnnotationShape.FillStyle = $LOC_AREA_FILL_STYLE_GRADIENT
If ($sGradientName <> Null) Then
If Not IsString($sGradientName) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oAnnotationShape.FillGradientName = $sGradientName
$iError = ($oAnnotationShape.FillGradientName() = $sGradientName) ? ($iError) : (BitOR($iError, 1))
$tStyleGradient = $oAnnotationShape.FillGradient()
If Not IsObj($tStyleGradient) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
EndIf
If ($iType <> Null) Then
If ($iType = $LOC_GRAD_TYPE_OFF) Then ; Turn Off Gradient
$oAnnotationShape.FillStyle = $LOC_AREA_FILL_STYLE_OFF
$oAnnotationShape.FillGradientName = ""
Return SetError($__LO_STATUS_SUCCESS, 0, 2)
EndIf
If Not __LOCalc_IntIsBetween($iType, $LOC_GRAD_TYPE_LINEAR, $LOC_GRAD_TYPE_RECT) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$tStyleGradient.Style = $iType
EndIf
If ($iIncrement <> Null) Then
If Not __LOCalc_IntIsBetween($iIncrement, 3, 256, "", 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oAnnotationShape.FillGradientStepCount = $iIncrement
$tStyleGradient.StepCount = $iIncrement ; Must set both of these in order for it to take effect.
$iError = ($oAnnotationShape.FillGradientStepCount() = $iIncrement) ? ($iError) : (BitOR($iError, 4))
EndIf
If ($iXCenter <> Null) Then
If Not __LOCalc_IntIsBetween($iXCenter, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$tStyleGradient.XOffset = $iXCenter
EndIf
If ($iYCenter <> Null) Then
If Not __LOCalc_IntIsBetween($iYCenter, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$tStyleGradient.YOffset = $iYCenter
EndIf
If ($iAngle <> Null) Then
If Not __LOCalc_IntIsBetween($iAngle, 0, 359) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
$tStyleGradient.Angle = ($iAngle * 10) ; Angle is set in thousands
EndIf
If ($iTransitionStart <> Null) Then
If Not __LOCalc_IntIsBetween($iTransitionStart, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0)
$tStyleGradient.Border = $iTransitionStart
EndIf
If ($iFromColor <> Null) Then
If Not __LOCalc_IntIsBetween($iFromColor, $LOC_COLOR_BLACK, $LOC_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 9, 0)
$tStyleGradient.StartColor = $iFromColor
If __LOCalc_VersionCheck(7.6) Then
$nRed = (BitAND(BitShift($iFromColor, 16), 0xff) / 255)
$nGreen = (BitAND(BitShift($iFromColor, 8), 0xff) / 255)
$nBlue = (BitAND($iFromColor, 0xff) / 255)
$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 = $nRed
$tStopColor.Green = $nGreen
$tStopColor.Blue = $nBlue
$tColorStop.StopColor = $tStopColor
$atColorStop[0] = $tColorStop
$tStyleGradient.ColorStops = $atColorStop
EndIf
EndIf
If ($iToColor <> Null) Then
If Not __LOCalc_IntIsBetween($iToColor, $LOC_COLOR_BLACK, $LOC_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 10, 0)
$tStyleGradient.EndColor = $iToColor
If __LOCalc_VersionCheck(7.6) Then
$nRed = (BitAND(BitShift($iToColor, 16), 0xff) / 255)
$nGreen = (BitAND(BitShift($iToColor, 8), 0xff) / 255)
$nBlue = (BitAND($iToColor, 0xff) / 255)
$atColorStop = $tStyleGradient.ColorStops()
If Not IsArray($atColorStop) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 3, 0)
$tColorStop = $atColorStop[UBound($atColorStop) - 1] ; Last StopOffset is the "To Color" Value.
$tStopColor = $tColorStop.StopColor()
$tStopColor.Red = $nRed
$tStopColor.Green = $nGreen
$tStopColor.Blue = $nBlue
$tColorStop.StopColor = $tStopColor
$atColorStop[UBound($atColorStop) - 1] = $tColorStop
$tStyleGradient.ColorStops = $atColorStop
EndIf
EndIf
If ($iFromIntense <> Null) Then
If Not __LOCalc_IntIsBetween($iFromIntense, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 11, 0)
$tStyleGradient.StartIntensity = $iFromIntense
EndIf
If ($iToIntense <> Null) Then
If Not __LOCalc_IntIsBetween($iToIntense, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 12, 0)
$tStyleGradient.EndIntensity = $iToIntense
EndIf
$oAnnotationShape.FillGradient = $tStyleGradient
; Error checking
$iError = ($iType = Null) ? $iError : ($oAnnotationShape.FillGradient.Style() = $iType) ? ($iError) : (BitOR($iError, 2))
$iError = ($iXCenter = Null) ? $iError : ($oAnnotationShape.FillGradient.XOffset() = $iXCenter) ? ($iError) : (BitOR($iError, 8))
$iError = ($iYCenter = Null) ? $iError : ($oAnnotationShape.FillGradient.YOffset() = $iYCenter) ? ($iError) : (BitOR($iError, 16))
$iError = ($iAngle = Null) ? $iError : (($oAnnotationShape.FillGradient.Angle() / 10) = $iAngle) ? ($iError) : (BitOR($iError, 32))
$iError = ($iTransitionStart = Null) ? $iError : ($oAnnotationShape.FillGradient.Border() = $iTransitionStart) ? ($iError) : (BitOR($iError, 64))
$iError = ($iFromColor = Null) ? $iError : ($oAnnotationShape.FillGradient.StartColor() = $iFromColor) ? ($iError) : (BitOR($iError, 128))
$iError = ($iToColor = Null) ? $iError : ($oAnnotationShape.FillGradient.EndColor() = $iToColor) ? ($iError) : (BitOR($iError, 256))
$iError = ($iFromIntense = Null) ? $iError : ($oAnnotationShape.FillGradient.StartIntensity() = $iFromIntense) ? ($iError) : (BitOR($iError, 512))
$iError = ($iToIntense = Null) ? $iError : ($oAnnotationShape.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 ;==>_LOCalc_CommentAreaGradient
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_CommentAreaShadow
; Description ...: Set or Retrieve the shadow settings for a Comment.
; Syntax ........: _LOCalc_CommentAreaShadow(ByRef $oComment[, $bShadow = Null[, $iColor = Null[, $iDistance = Null[, $iTransparency = Null[, $iBlur = Null[, $iLocation = Null]]]]]])
; Parameters ....: $oComment - [in/out] an object. A Comment object returned by a previous _LOCalc_CommentsGetList, _LOCalc_CommentGetObjByCell, or _LOCalc_CommentGetObjByIndex function.
; $bShadow - [optional] a boolean value. Default is Null. If True, a Shadow is present for the Comment.
; $iColor - [optional] an integer value (0-16777215). Default is Null. The Shadow color, set in Long Integer format, can be a custom value, or one of the constants, $LOC_COLOR_* as defined in LibreOfficeCalc_Constants.au3.
; $iDistance - [optional] an integer value. Default is Null. The distance of the Shadow from the Comment box, set in Micrometers.
; $iTransparency - [optional] an integer value (0-100). Default is Null. The percentage of Shadow transparency. 100% means completely transparent.
; $iBlur - [optional] an integer value (0-150). Default is Null. The amount of blur applied to the Shadow, set in Printer's Points.
; $iLocation - [optional] an integer value (0-8). Default is Null. The Location of the Shadow, must be one of the Constants, $LOC_COMMENT_SHADOW_* as defined in LibreOfficeCalc_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 = $oComment not an Object.
; @Error 1 @Extended 2 Return 0 = $bShadow not a Boolean.
; @Error 1 @Extended 3 Return 0 = $iColor not an Integer, less than 0, or greater than 16777215.
; @Error 1 @Extended 4 Return 0 = $iDistance not an Integer, or less than 0.
; @Error 1 @Extended 5 Return 0 = $iTransparency not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 6 Return 0 = $iBlur not an Integer, less than 0, or greater than 150 Printer's Points (0-5292 Micrometers).
; @Error 1 @Extended 7 Return 0 = $iLocation not an Integer, less than 0, or greater than 8. See Constants, $LOC_COMMENT_SHADOW_* as defined in LibreOfficeCalc_Constants.au3.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Annotation Shape Object.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve current Distance and Location Values.
; @Error 3 @Extended 3 Return 0 = Failed to modify Distance property.
; @Error 3 @Extended 4 Return 0 = Failed to modify Location property.
; --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 $bShadow
; | 2 = Error setting $iColor
; | 4 = Error setting $iDistance
; | 8 = Error setting $iTransparency
; | 16 = Error setting $iBlur
; | 32 = Error setting $iLocation
; --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 .......: 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.
; LibreOffice may change the shadow distance +/- a Micrometer.
; Presently only location settings applying the Shadow to the bottom, right, or bottom-right corners of the Comment visually work, both in LibreOffice and using this function. Though it still can be set to the other locations.
; Related .......: _LOCalc_ConvertColorFromLong, _LOCalc_ConvertColorToLong, _LOCalc_ConvertFromMicrometer, _LOCalc_ConvertToMicrometer
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_CommentAreaShadow(ByRef $oComment, $bShadow = Null, $iColor = Null, $iDistance = Null, $iTransparency = Null, $iBlur = Null, $iLocation = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oAnnotationShape
Local $iError = 0, $iInternalLocation, $iInternalDistance
Local $avShadow[6]
If Not IsObj($oComment) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$oAnnotationShape = $oComment.AnnotationShape()
If Not IsObj($oAnnotationShape) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If __LOCalc_VarsAreNull($bShadow, $iColor, $iDistance, $iTransparency, $iBlur, $iLocation) Then
$iInternalDistance = __LOCalc_CommentAreaShadowModify($oAnnotationShape)
$iInternalLocation = @extended
If @error Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
__LOCalc_ArrayFill($avShadow, $oAnnotationShape.Shadow(), $oAnnotationShape.ShadowColor(), $iInternalDistance, $oAnnotationShape.ShadowTransparence(), _
__LOCalc_UnitConvert($oAnnotationShape.ShadowBlur(), $__LOCONST_CONVERT_UM_PT), $iInternalLocation)
Return SetError($__LO_STATUS_SUCCESS, 1, $avShadow)
EndIf
If ($bShadow <> Null) Then
If Not IsBool($bShadow) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oAnnotationShape.Shadow = $bShadow
$iError = ($oAnnotationShape.Shadow() = $bShadow) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($iColor <> Null) Then
If Not __LOCalc_IntIsBetween($iColor, $LOC_COLOR_BLACK, $LOC_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oAnnotationShape.ShadowColor = $iColor
$iError = ($oAnnotationShape.ShadowColor() = $iColor) ? ($iError) : (BitOR($iError, 2))
EndIf
If ($iDistance <> Null) Then
If Not __LOCalc_IntIsBetween($iDistance, 0, $iDistance) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
__LOCalc_CommentAreaShadowModify($oAnnotationShape, Null, $iDistance)
If (@error = $__LO_STATUS_PROP_SETTING_ERROR) Then
$iError = BitOR($iError, 4)
ElseIf @error Then
Return SetError($__LO_STATUS_PROCESSING_ERROR, 3, 0)
EndIf
EndIf
If ($iTransparency <> Null) Then
If Not __LOCalc_IntIsBetween($iTransparency, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oAnnotationShape.ShadowTransparence = $iTransparency
$iError = ($oAnnotationShape.ShadowTransparence = $iTransparency) ? ($iError) : (BitOR($iError, 8))
EndIf
If ($iBlur <> Null) Then
If Not __LOCalc_IntIsBetween($iBlur, 0, 150) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0) ; 0 - 5292 max Micrometers.
$oAnnotationShape.ShadowBlur = __LOCalc_UnitConvert($iBlur, $__LOCONST_CONVERT_PT_UM)
$iError = ($oAnnotationShape.ShadowBlur() = __LOCalc_UnitConvert($iBlur, $__LOCONST_CONVERT_PT_UM)) ? ($iError) : (BitOR($iError, 16))
EndIf
If ($iLocation <> Null) Then
If Not __LOCalc_IntIsBetween($iLocation, $LOC_COMMENT_SHADOW_TOP_LEFT, $LOC_COMMENT_SHADOW_BOTTOM_RIGHT) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
__LOCalc_CommentAreaShadowModify($oAnnotationShape, $iLocation)
If (@error = $__LO_STATUS_PROP_SETTING_ERROR) Then
$iError = BitOR($iError, 32)
ElseIf @error Then
Return SetError($__LO_STATUS_PROCESSING_ERROR, 4, 0)
EndIf
EndIf
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOCalc_CommentAreaShadow
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_CommentAreaTransparency
; Description ...: Set or retrieve Transparency settings for a Comment.
; Syntax ........: _LOCalc_CommentAreaTransparency(ByRef $oComment[, $iTransparency = Null])
; Parameters ....: $oComment - [in/out] an object. A Comment object returned by a previous _LOCalc_CommentsGetList, _LOCalc_CommentGetObjByCell, or _LOCalc_CommentGetObjByIndex function.
; $iTransparency - [optional] an integer value (0-100). Default is Null. The color transparency. 0% is fully opaque and 100% is fully transparent.
; Return values .: Success: Integer.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oComment not an Object.
; @Error 1 @Extended 2 Return 0 = $iTransparency not an Integer, less than 0, or greater than 100.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Annotation Shape Object.
; --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 $iTransparency
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings have been successfully set.
; @Error 0 @Extended 1 Return Integer = Success. All optional parameters were set to Null, returning current setting for Transparency in integer format.
; 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 .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_CommentAreaTransparency(ByRef $oComment, $iTransparency = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local $oAnnotationShape
If Not IsObj($oComment) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$oAnnotationShape = $oComment.AnnotationShape()
If Not IsObj($oAnnotationShape) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If __LOCalc_VarsAreNull($iTransparency) Then Return SetError($__LO_STATUS_SUCCESS, 1, $oAnnotationShape.FillTransparence())
If Not __LOCalc_IntIsBetween($iTransparency, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oAnnotationShape.FillTransparenceGradientName = "" ;Turn off Gradient if it is on, else settings wont be applied.
$oAnnotationShape.FillTransparence = $iTransparency
$iError = ($oAnnotationShape.FillTransparence() = $iTransparency) ? ($iError) : (BitOR($iError, 1))
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOCalc_CommentAreaTransparency
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_CommentAreaTransparencyGradient
; Description ...: Set or retrieve the Comment transparency gradient settings.
; Syntax ........: _LOCalc_CommentAreaTransparencyGradient(ByRef $oDoc, ByRef $oComment[, $iType = Null[, $iXCenter = Null[, $iYCenter = Null[, $iAngle = Null[, $iTransitionStart = Null[, $iStart = Null[, $iEnd = Null]]]]]]])
; Parameters ....: $oDoc - [in/out] an object. A Document object returned by a previous _LOCalc_DocOpen, _LOCalc_DocConnect, or _LOCalc_DocCreate function.
; $oComment - [in/out] an object. A Comment object returned by a previous _LOCalc_CommentsGetList, _LOCalc_CommentGetObjByCell, or _LOCalc_CommentGetObjByIndex function.
; $iType - [optional] an integer value (-1-5). Default is Null. The type of transparency gradient to apply. See Constants, $LOC_GRAD_TYPE_* as defined in LibreOfficeCalc_Constants.au3. Set to $LOC_GRAD_TYPE_OFF to turn Transparency Gradient off.
; $iXCenter - [optional] an integer value (0-100). Default is Null. The horizontal offset for the gradient. 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. 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 you want to adjust the transparent area of the gradient. Set in percentage.
; $iStart - [optional] an integer value (0-100). Default is Null. The transparency value for the beginning point of the gradient, where 0% is fully opaque and 100% is fully transparent.
; $iEnd - [optional] an integer value (0-100). Default is Null. The transparency value for the endpoint of the gradient, where 0% is fully opaque and 100% is fully transparent.
; 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 = $oComment not an Object.
; @Error 1 @Extended 3 Return 0 = $iType Not an Integer, less than -1, or greater than 5, see constants, $LOC_GRAD_TYPE_* as defined in LibreOfficeCalc_Constants.au3.
; @Error 1 @Extended 4 Return 0 = $iXCenter Not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 5 Return 0 = $iYCenter Not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 6 Return 0 = $iAngle Not an Integer, less than 0, or greater than 359.
; @Error 1 @Extended 7 Return 0 = $iTransitionStart Not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 8 Return 0 = $iStart Not an Integer, less than 0, or greater than 100.
; @Error 1 @Extended 9 Return 0 = $iEnd Not an Integer, less than 0, or greater than 100.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error retrieving "FillTransparenceGradient" Object.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Annotation Shape Object.
; @Error 3 @Extended 2 Return 0 = Error retrieving Color Stop Array for "From" color
; @Error 3 @Extended 3 Return 0 = Error retrieving Color Stop Array for "To" color
; --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 $iType
; | 2 = Error setting $iXCenter
; | 4 = Error setting $iYCenter
; | 8 = Error setting $iAngle
; | 16 = Error setting $iTransitionStart
; | 32 = Error setting $iStart
; | 64 = Error setting $iEnd
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings have been successfully set.
; @Error 0 @Extended 0 Return 2 = Success. Transparency 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 7 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 .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_CommentAreaTransparencyGradient(ByRef $oDoc, ByRef $oComment, $iType = Null, $iXCenter = Null, $iYCenter = Null, $iAngle = Null, $iTransitionStart = Null, $iStart = Null, $iEnd = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $tGradient, $tColorStop, $tStopColor
Local $sTGradName
Local $iError = 0
Local $aiTransparent[7]
Local $atColorStop
Local $oAnnotationShape
Local $fValue
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oComment) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oAnnotationShape = $oComment.AnnotationShape()
If Not IsObj($oAnnotationShape) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$tGradient = $oAnnotationShape.FillTransparenceGradient()
If Not IsObj($tGradient) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
If __LOCalc_VarsAreNull($iType, $iXCenter, $iYCenter, $iAngle, $iTransitionStart, $iStart, $iEnd) Then
__LOCalc_ArrayFill($aiTransparent, $tGradient.Style(), $tGradient.XOffset(), $tGradient.YOffset(), _
($tGradient.Angle() / 10), $tGradient.Border(), __LOCalc_TransparencyGradientConvert(Null, $tGradient.StartColor()), _
__LOCalc_TransparencyGradientConvert(Null, $tGradient.EndColor())) ; Angle is set in thousands
Return SetError($__LO_STATUS_SUCCESS, 1, $aiTransparent)
EndIf
If ($iType <> Null) Then
If ($iType = $LOC_GRAD_TYPE_OFF) Then ; Turn Off Gradient
$oAnnotationShape.FillTransparenceGradientName = ""
Return SetError($__LO_STATUS_SUCCESS, 0, 2)
EndIf
If Not __LOCalc_IntIsBetween($iType, $LOC_GRAD_TYPE_LINEAR, $LOC_GRAD_TYPE_RECT) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$tGradient.Style = $iType
EndIf
If ($iXCenter <> Null) Then
If Not __LOCalc_IntIsBetween($iXCenter, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$tGradient.XOffset = $iXCenter
EndIf
If ($iYCenter <> Null) Then
If Not __LOCalc_IntIsBetween($iYCenter, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$tGradient.YOffset = $iYCenter
EndIf
If ($iAngle <> Null) Then
If Not __LOCalc_IntIsBetween($iAngle, 0, 359) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$tGradient.Angle = ($iAngle * 10) ; Angle is set in thousands
EndIf
If ($iTransitionStart <> Null) Then
If Not __LOCalc_IntIsBetween($iTransitionStart, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
$tGradient.Border = $iTransitionStart
EndIf
If ($iStart <> Null) Then
If Not __LOCalc_IntIsBetween($iStart, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0)
$tGradient.StartColor = __LOCalc_TransparencyGradientConvert($iStart)
If __LOCalc_VersionCheck(7.6) Then
$atColorStop = $tGradient.ColorStops()
If Not IsArray($atColorStop) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
$tColorStop = $atColorStop[0] ; StopOffset 0 is the "Start" Value.
$tStopColor = $tColorStop.StopColor()
$fValue = $iStart / 100 ; Value is a decimal percentage value.
$tStopColor.Red = $fValue
$tStopColor.Green = $fValue
$tStopColor.Blue = $fValue
$tColorStop.StopColor = $tStopColor
$atColorStop[0] = $tColorStop
$tGradient.ColorStops = $atColorStop
EndIf
EndIf
If ($iEnd <> Null) Then
If Not __LOCalc_IntIsBetween($iEnd, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 9, 0)
$tGradient.EndColor = __LOCalc_TransparencyGradientConvert($iEnd)
If __LOCalc_VersionCheck(7.6) Then
$atColorStop = $tGradient.ColorStops()
If Not IsArray($atColorStop) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
$tColorStop = $atColorStop[UBound($atColorStop) - 1] ; StopOffset 0 is the "End" Value.
$tStopColor = $tColorStop.StopColor()
$fValue = $iEnd / 100 ; Value is a decimal percentage value.
$tStopColor.Red = $fValue
$tStopColor.Green = $fValue
$tStopColor.Blue = $fValue
$tColorStop.StopColor = $tStopColor
$atColorStop[UBound($atColorStop) - 1] = $tColorStop
$tGradient.ColorStops = $atColorStop
EndIf
EndIf
If ($oAnnotationShape.FillTransparenceGradientName() = "") Then
$sTGradName = __LOCalc_TransparencyGradientNameInsert($oDoc, $tGradient)
If @error > 0 Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$oAnnotationShape.FillTransparenceGradientName = $sTGradName
If ($oAnnotationShape.FillTransparenceGradientName <> $sTGradName) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
EndIf
$oAnnotationShape.FillTransparenceGradient = $tGradient
$iError = ($iType = Null) ? ($iError) : (($oAnnotationShape.FillTransparenceGradient.Style() = $iType) ? ($iError) : (BitOR($iError, 1)))
$iError = ($iXCenter = Null) ? ($iError) : (($oAnnotationShape.FillTransparenceGradient.XOffset() = $iXCenter) ? ($iError) : (BitOR($iError, 2)))
$iError = ($iYCenter = Null) ? ($iError) : (($oAnnotationShape.FillTransparenceGradient.YOffset() = $iYCenter) ? ($iError) : (BitOR($iError, 4)))
$iError = ($iAngle = Null) ? ($iError) : ((($oAnnotationShape.FillTransparenceGradient.Angle() / 10) = $iAngle) ? ($iError) : (BitOR($iError, 8)))
$iError = ($iTransitionStart = Null) ? ($iError) : (($oAnnotationShape.FillTransparenceGradient.Border() = $iTransitionStart) ? ($iError) : (BitOR($iError, 16)))
$iError = ($iStart = Null) ? ($iError) : (($oAnnotationShape.FillTransparenceGradient.StartColor() = __LOCalc_TransparencyGradientConvert($iStart)) ? ($iError) : (BitOR($iError, 32)))
$iError = ($iEnd = Null) ? ($iError) : (($oAnnotationShape.FillTransparenceGradient.EndColor() = __LOCalc_TransparencyGradientConvert($iEnd)) ? ($iError) : (BitOR($iError, 64)))
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOCalc_CommentAreaTransparencyGradient
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_CommentCallout
; Description ...: Set or Retrieve Comment Callout settings.
; Syntax ........: _LOCalc_CommentCallout(ByRef $oComment[, $iCalloutStyle = Null[, $iSpacing = Null[, $iExtension = Null[, $iExtendBy = Null[, $bOptimal = Null[, $iLength = Null]]]]]])
; Parameters ....: $oComment - [in/out] an object. A Comment object returned by a previous _LOCalc_CommentsGetList, _LOCalc_CommentGetObjByCell, or _LOCalc_CommentGetObjByIndex function.
; $iCalloutStyle - [optional] an integer value (0-2). Default is Null. The Style of Callout connector line. See Constants $LOC_COMMENT_CALLOUT_STYLE_* as defined in LibreOfficeCalc_Constants.au3.
; $iSpacing - [optional] an integer value (0-240005). Default is Null. The amount of space between the Callout connector line end and the comment box, in Micrometers.
; $iExtension - [optional] an integer value (0-4). Default is Null. The position to extend the Callout line from. See Constants $LOC_COMMENT_CALLOUT_EXT_* as defined in LibreOfficeCalc_Constants.au3.
; $iExtendBy - [optional] an integer value (0-240005;0,5000,10000). Default is Null. The length to extend the Callout line, in Micrometers, or the alignment of the line depending on the current setting of $iExtension. See remarks. See Constants $LOC_COMMENT_CALLOUT_EXT_ALIGN_HORI_*, or $LOC_COMMENT_CALLOUT_EXT_ALIGN_VERT_* as defined in LibreOfficeCalc_Constants.au3.
; $bOptimal - [optional] a boolean value. Default is Null. If True a angled line will be used optimally.
; $iLength - [optional] an integer value (0-240005). Default is Null. The length of the callout line, in Micrometers.
; 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 = $oComment not an Object.
; @Error 1 @Extended 2 Return 0 = $iCalloutStyle not an Integer, less than 0 or greater than 2. See Constants $LOC_COMMENT_CALLOUT_STYLE_* as defined in LibreOfficeCalc_Constants.au3.
; @Error 1 @Extended 3 Return 0 = $iSpacing not an Integer, less than 0 or greater than 240,005 Micrometers.
; @Error 1 @Extended 4 Return 0 = $iExtension not an Integer, less than 0 or greater than 4. See Constants $LOC_COMMENT_CALLOUT_EXT_* as defined in LibreOfficeCalc_Constants.au3.
; @Error 1 @Extended 5 Return 0 = $iExtendBy not an Integer, not equal to 0, 5,000, or 10,000. See Constants $LOC_COMMENT_CALLOUT_EXT_ALIGN_HORI_*, as defined in LibreOfficeCalc_Constants.au3.
; @Error 1 @Extended 6 Return 0 = $iExtendBy not an Integer, not equal to 0, 5,000, or 10,000. See Constants $LOC_COMMENT_CALLOUT_EXT_ALIGN_VERT_* as defined in LibreOfficeCalc_Constants.au3.
; @Error 1 @Extended 7 Return 0 = $iExtendBy not an Integer, less than 0 or greater than 240,005 Micrometers.
; @Error 1 @Extended 8 Return 0 = $bOptimal not a Boolean.
; @Error 1 @Extended 9 Return 0 = $iLength not an Integer, less than 0 or greater than 240,005 Micrometers.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Annotation Shape Object.
; --Property Setting Errors--
; @Error 4 @Extended ? Return 0 = Some settings were not successfully set. Use BitAND to test @Extended for following values:
; | 1 = Error setting $iCalloutStyle
; | 2 = Error setting $iSpacing
; | 4 = Error setting $iExtension
; | 8 = Error setting $iExtendBy
; | 16 = Error setting $bOptimal
; | 32 = Error setting $iLength
; --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 .......: If $iExtension is set to $LOC_COMMENT_CALLOUT_EXT_HORI, or $LOC_COMMENT_CALLOUT_EXT_VERT, $iExtendBy will be set to the alignment value of either constants $LOC_COMMENT_CALLOUT_EXT_ALIGN_HORI_*, or $LOC_COMMENT_CALLOUT_EXT_ALIGN_VERT_*.
; If $iExtension is set to $LOC_COMMENT_CALLOUT_EXT_OPTIMAL, $LOC_COMMENT_CALLOUT_EXT_FROM_LEFT, or $LOC_COMMENT_CALLOUT_EXT_FROM_TOP, $iExtendBy will be set to the length to extend the Callout line from the Comment box, in Micrometers.
; If $iCalloutStyle is not set to $LOC_COMMENT_CALLOUT_STYLE_ANGLED_CONNECTOR, both $bOptimal and $iLength, are not used/unavailable for setting.
; 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 .......: _LOCalc_ConvertFromMicrometer, _LOCalc_ConvertToMicrometer
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_CommentCallout(ByRef $oComment, $iCalloutStyle = Null, $iSpacing = Null, $iExtension = Null, $iExtendBy = Null, $bOptimal = Null, $iLength = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oAnnotationShape
Local $iError = 0
Local $aiCallout[6]
If Not IsObj($oComment) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$oAnnotationShape = $oComment.AnnotationShape()
If Not IsObj($oAnnotationShape) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If __LOCalc_VarsAreNull($iCalloutStyle, $iSpacing, $iExtension, $iExtendBy, $bOptimal, $iLength) Then
__LOCalc_ArrayFill($aiCallout, $oAnnotationShape.CaptionType(), $oAnnotationShape.CaptionGap(), $oAnnotationShape.CaptionEscapeDirection(), _
(($oAnnotationShape.CaptionIsEscapeRelative) ? ($oAnnotationShape.CaptionEscapeRelative()) : ($oAnnotationShape.CaptionEscapeAbsolute())), _
$oAnnotationShape.CaptionIsFitLineLength(), $oAnnotationShape.CaptionLineLength())
Return SetError($__LO_STATUS_SUCCESS, 1, $aiCallout)
EndIf
If ($iCalloutStyle <> Null) Then
If Not __LOCalc_IntIsBetween($iCalloutStyle, $LOC_COMMENT_CALLOUT_STYLE_STRAIGHT, $LOC_COMMENT_CALLOUT_STYLE_ANGLED_CONNECTOR) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oAnnotationShape.CaptionType = $iCalloutStyle
$iError = ($oAnnotationShape.CaptionType() = $iCalloutStyle) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($iSpacing <> Null) Then
If Not __LOCalc_IntIsBetween($iSpacing, 0, 240005) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oAnnotationShape.CaptionGap = $iSpacing
$iError = ($oAnnotationShape.CaptionGap() = $iSpacing) ? ($iError) : (BitOR($iError, 2))
EndIf
If ($iExtension <> Null) Then
If Not __LOCalc_IntIsBetween($iExtension, $LOC_COMMENT_CALLOUT_EXT_HORI, $LOC_COMMENT_CALLOUT_EXT_FROM_TOP) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
If __LOCalc_IntIsBetween($iExtension, $LOC_COMMENT_CALLOUT_EXT_OPTIMAL, $LOC_COMMENT_CALLOUT_EXT_FROM_TOP) Then
If ($oAnnotationShape.CaptionIsEscapeRelative() = True) Then
$oAnnotationShape.CaptionIsEscapeRelative = False
$oAnnotationShape.CaptionEscapeAbsolute = 0
EndIf
Switch $iExtension
Case $LOC_COMMENT_CALLOUT_EXT_OPTIMAL
$oAnnotationShape.CaptionEscapeDirection = $iExtension
$iError = ($oAnnotationShape.CaptionEscapeDirection() = $iExtension) ? ($iError) : (BitOR($iError, 4))
Case $LOC_COMMENT_CALLOUT_EXT_FROM_LEFT ; From Left, is the same as Vertical setting with different CaptionIsEscapeRelative
$oAnnotationShape.CaptionEscapeDirection = $LOC_COMMENT_CALLOUT_EXT_VERT
$iError = ($oAnnotationShape.CaptionEscapeDirection() = $LOC_COMMENT_CALLOUT_EXT_VERT) ? ($iError) : (BitOR($iError, 4))
Case $LOC_COMMENT_CALLOUT_EXT_FROM_TOP ; From Top, is the same as Horizontal setting with different CaptionIsEscapeRelative
$oAnnotationShape.CaptionEscapeDirection = $LOC_COMMENT_CALLOUT_EXT_HORI
$iError = ($oAnnotationShape.CaptionEscapeDirection() = $LOC_COMMENT_CALLOUT_EXT_HORI) ? ($iError) : (BitOR($iError, 4))
EndSwitch
Else
If ($oAnnotationShape.CaptionIsEscapeRelative() = False) Then
$oAnnotationShape.CaptionIsEscapeRelative = True
$oAnnotationShape.CaptionEscapeRelative = (($iExtension = $LOC_COMMENT_CALLOUT_EXT_HORI) ? ($LOC_COMMENT_CALLOUT_EXT_ALIGN_HORI_TOP) : ($LOC_COMMENT_CALLOUT_EXT_ALIGN_VERT_LEFT))
EndIf
$oAnnotationShape.CaptionEscapeDirection = $iExtension
$iError = ($oAnnotationShape.CaptionEscapeDirection() = $iExtension) ? ($iError) : (BitOR($iError, 4))
EndIf
EndIf
If ($iExtendBy <> Null) Then
If ($oAnnotationShape.CaptionIsEscapeRelative() = True) Then
If ($oAnnotationShape.CaptionEscapeDirection() = $LOC_COMMENT_CALLOUT_EXT_HORI) Then
If Not __LOCalc_IntIsBetween($iExtendBy, $LOC_COMMENT_CALLOUT_EXT_ALIGN_HORI_TOP, $LOC_COMMENT_CALLOUT_EXT_ALIGN_HORI_TOP, "", String($LOC_COMMENT_CALLOUT_EXT_ALIGN_HORI_MIDDLE & ":" & $LOC_COMMENT_CALLOUT_EXT_ALIGN_HORI_BOTTOM)) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
Else
If Not __LOCalc_IntIsBetween($iExtendBy, $LOC_COMMENT_CALLOUT_EXT_ALIGN_VERT_LEFT, $LOC_COMMENT_CALLOUT_EXT_ALIGN_VERT_LEFT, "", String($LOC_COMMENT_CALLOUT_EXT_ALIGN_VERT_CENTER & ":" & $LOC_COMMENT_CALLOUT_EXT_ALIGN_VERT_RIGHT)) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
EndIf
$oAnnotationShape.CaptionEscapeRelative = $iExtendBy
$iError = ($oAnnotationShape.CaptionEscapeRelative() = $iExtendBy) ? ($iError) : (BitOR($iError, 8))
Else
If Not __LOCalc_IntIsBetween($iExtendBy, 0, 240005) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
$oAnnotationShape.CaptionEscapeAbsolute = $iExtendBy
$iError = ($oAnnotationShape.CaptionEscapeAbsolute() = $iExtendBy) ? ($iError) : (BitOR($iError, 8))
EndIf
EndIf
If ($bOptimal <> Null) Then
If Not IsBool($bOptimal) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0)
$oAnnotationShape.CaptionIsFitLineLength = $bOptimal
$iError = ($oAnnotationShape.CaptionIsFitLineLength() = $bOptimal) ? ($iError) : (BitOR($iError, 16))
EndIf
If ($iLength <> Null) Then
If Not __LOCalc_IntIsBetween($iLength, 0, 240005) Then Return SetError($__LO_STATUS_INPUT_ERROR, 9, 0)
$oAnnotationShape.CaptionLineLength = $iLength
$iError = ($oAnnotationShape.CaptionLineLength() = $iLength) ? ($iError) : (BitOR($iError, 32))
EndIf
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOCalc_CommentCallout
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_CommentCreateTextCursor
; Description ...: Create a Text Cursor in a Comment.
; Syntax ........: _LOCalc_CommentCreateTextCursor(ByRef $oComment[, $bAtEnd = True])
; Parameters ....: $oComment - [in/out] an object. A Comment object returned by a previous _LOCalc_CommentsGetList, _LOCalc_CommentGetObjByCell, or _LOCalc_CommentGetObjByIndex function.
; $bAtEnd - [optional] a boolean value. Default is True. If True, The Text Cursor will be created at the end of any Text Content present.
; Return values .: Success: Object
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oComment not an Object.
; @Error 1 @Extended 2 Return 0 = $bAtEnd not a Boolean.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Failed to create a Text Cursor.
; --Success--
; @Error 0 @Extended 0 Return Object = Success. Returning newly created Text Cursor.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_CommentCreateTextCursor(ByRef $oComment, $bAtEnd = True)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oTextCursor
If Not IsObj($oComment) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsBool($bAtEnd) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oTextCursor = $oComment.Text.createTextCursor()
If Not IsObj($oTextCursor) Then Return SetError($__LO_STATUS_INIT_ERROR, 1, 0)
If $bAtEnd Then
$oTextCursor.gotoEnd(False)
Else
$oTextCursor.gotoStart(False)
EndIf
Return SetError($__LO_STATUS_SUCCESS, 0, $oTextCursor)
EndFunc ;==>_LOCalc_CommentCreateTextCursor
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOCalc_CommentDelete
; Description ...: Delete a comment from a Cell.
; Syntax ........: _LOCalc_CommentDelete(ByRef $oComment)
; Parameters ....: $oComment - [in/out] an object. A Comment object returned by a previous _LOCalc_CommentsGetList, _LOCalc_CommentGetObjByCell, or _LOCalc_CommentGetObjByIndex 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 = $oComment not an Object.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve Parent Cell Object.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve Annotations Object.
; @Error 3 @Extended 3 Return 0 = Failed to retrieve Comment's Index number.
; @Error 3 @Extended 4 Return 0 = Failed to delete Comment.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Comment was successfully deleted.
; Author ........: donnyh13
; Modified ......:
; Remarks .......:
; Related .......: _LOCalc_CommentAdd, _LOCalc_CommentGetObjByCell, _LOCalc_CommentGetObjByIndex, _LOCalc_CommentsGetList
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOCalc_CommentDelete(ByRef $oComment)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOCalc_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $oAnnotations, $oCell
Local $iIndex
If Not IsObj($oComment) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$oCell = $oComment.Parent()
If Not IsObj($oCell) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$oAnnotations = $oCell.Spreadsheet.Annotations()
If Not IsObj($oAnnotations) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 2, 0)
$iIndex = __LOCalc_CommentGetObjByCell($oCell, True)
If @error Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 3, 0)
$oAnnotations.removeByIndex($iIndex)
__LOCalc_CommentGetObjByCell($oCell, True)
If (@error = 0) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 4, 0) ; Comment still exists.