-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLibreOfficeWriter_Images.au3
2474 lines (2152 loc) · 168 KB
/
LibreOfficeWriter_Images.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
;~ #Tidy_Parameters=/sf
#include-once
; Main LibreOffice Includes
#include "LibreOffice_Constants.au3"
; Common includes for Writer
#include "LibreOfficeWriter_Constants.au3"
#include "LibreOfficeWriter_Helper.au3"
#include "LibreOfficeWriter_Internal.au3"
; Other includes for Writer
#include "LibreOfficeWriter_Doc.au3"
#include "LibreOfficeWriter_Page.au3"
; #INDEX# =======================================================================================================================
; Title .........: LibreOffice UDF
; AutoIt Version : v3.3.16.1
; Description ...: Provides basic functionality through AutoIt for Inserting and Modifying Images in L.O. Writer.
; Author(s) .....: donnyh13, mLipok
; Dll ...........:
;
; ===============================================================================================================================
; #CURRENT# =====================================================================================================================
; _LOWriter_ImageAreaColor
; _LOWriter_ImageAreaFillStyle
; _LOWriter_ImageAreaGradient
; _LOWriter_ImageAreaTransparency
; _LOWriter_ImageAreaTransparencyGradient
; _LOWriter_ImageBorderColor
; _LOWriter_ImageBorderPadding
; _LOWriter_ImageBorderStyle
; _LOWriter_ImageBorderWidth
; _LOWriter_ImageColorAdjust
; _LOWriter_ImageCrop
; _LOWriter_ImageDelete
; _LOWriter_ImageExists
; _LOWriter_ImageGetAnchor
; _LOWriter_ImageGetObjByName
; _LOWriter_ImageHyperlink
; _LOWriter_ImageInsert
; _LOWriter_ImageModify
; _LOWriter_ImageOptions
; _LOWriter_ImageOptionsName
; _LOWriter_ImageReplace
; _LOWriter_ImagesGetNames
; _LOWriter_ImageShadow
; _LOWriter_ImageSize
; _LOWriter_ImageTransparency
; _LOWriter_ImageTypePosition
; _LOWriter_ImageTypeSize
; _LOWriter_ImageWrap
; _LOWriter_ImageWrapOptions
; ===============================================================================================================================
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ImageAreaColor
; Description ...: Set or Retrieve background color settings for an Image.
; Syntax ........: _LOWriter_ImageAreaColor(ByRef $oImage[, $iBackColor = Null[, $bBackTransparent = Null]])
; Parameters ....: $oImage - [in/out] an object. A Image object returned by a previous _LOWriter_ImageInsert, or _LOWriter_ImageGetObjByName function.
; $iBackColor - [optional] an integer value (-1-16777215). Default is Null. The color to make the background. 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".
; $bBackTransparent - [optional] a boolean value. Default is Null. If True, the background color is transparent.
; Return values .: Success: 1 or Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oImage not an Object.
; @Error 1 @Extended 2 Return 0 = $iBackColor not an integer, less than -1, or greater than 16777215.
; @Error 1 @Extended 3 Return 0 = $bBackTransparent not a Boolean.
; --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 $iBackColor
; | 2 = Error setting $bBackTransparent
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 2 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current settings.
; If transparency is set, it can cause strange values to be displayed for Background color.
; Call any optional parameter with Null keyword to skip it.
; Related .......: _LOWriter_ImageInsert, _LOWriter_ImageGetObjByName, _LOWriter_ConvertColorFromLong, _LOWriter_ConvertColorToLong
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ImageAreaColor(ByRef $oImage, $iBackColor = Null, $bBackTransparent = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0, $iOldTransparency
Local $avColor[2]
If Not IsObj($oImage) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_VarsAreNull($iBackColor, $bBackTransparent) Then
__LOWriter_ArrayFill($avColor, __LOWriter_ColorRemoveAlpha($oImage.BackColor()), $oImage.BackTransparent())
Return SetError($__LO_STATUS_SUCCESS, 1, $avColor)
EndIf
If ($iBackColor <> Null) Then
If Not __LOWriter_IntIsBetween($iBackColor, $LOW_COLOR_OFF, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$iOldTransparency = $oImage.FillTransparence()
If Not IsInt($iOldTransparency) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
$oImage.BackColor = $iBackColor
$iError = ($oImage.BackColor() = $iBackColor) ? ($iError) : (BitOR($iError, 1))
$oImage.FillTransparence = $iOldTransparency
EndIf
If ($bBackTransparent <> Null) Then
If Not IsBool($bBackTransparent) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oImage.BackTransparent = $bBackTransparent
$iError = ($oImage.BackTransparent() = $bBackTransparent) ? ($iError) : (BitOR($iError, 2))
EndIf
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_ImageAreaColor
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ImageAreaFillStyle
; Description ...: Retrieve what kind of background fill is active, if any.
; Syntax ........: _LOWriter_ImageAreaFillStyle(ByRef $oImage)
; Parameters ....: $oImage - [in/out] an object. A Image object returned by a previous _LOWriter_ImageInsert, or _LOWriter_ImageGetObjByName 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 = $oImage 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_ImageAreaFillStyle(ByRef $oImage)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iFillStyle
If Not IsObj($oImage) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
$iFillStyle = $oImage.FillStyle()
If Not IsInt($iFillStyle) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
Return SetError($__LO_STATUS_SUCCESS, 0, $iFillStyle)
EndFunc ;==>_LOWriter_ImageAreaFillStyle
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ImageAreaGradient
; Description ...: Modify or retrieve the settings for an Image Background color Gradient.
; Syntax ........: _LOWriter_ImageAreaGradient(ByRef $oDoc, ByRef $oImage[, $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.
; $oImage - [in/out] an object. A Image object returned by a previous _LOWriter_ImageInsert, or _LOWriter_ImageGetObjByName function.
; $sGradientName - [optional] a string value. Default is Null. A Preset Gradient Name. See Constants, $LOW_GRAD_NAME_* as defined in LibreOfficeWriter_Constants.au3. See remarks.
; $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. Specifies the number of steps of change color. 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 you want 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 = $oImage 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_ImageInsert, _LOWriter_ImageGetObjByName, _LOWriter_ConvertColorFromLong, _LOWriter_ConvertColorToLong
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ImageAreaGradient(ByRef $oDoc, ByRef $oImage, $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
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oImage) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$tStyleGradient = $oImage.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, $oImage.FillGradientName(), $tStyleGradient.Style(), _
$oImage.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 ($oImage.FillStyle() <> $LOW_AREA_FILL_STYLE_GRADIENT) Then $oImage.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, $oImage, $tStyleGradient, $sGradientName)
$iError = ($oImage.FillGradientName() = $sGradientName) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($iType <> Null) Then
If ($iType = $LOW_GRAD_TYPE_OFF) Then ;Turn Off Gradient
$oImage.FillStyle = $LOW_AREA_FILL_STYLE_OFF
$oImage.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)
$oImage.FillGradientStepCount = $iIncrement
$tStyleGradient.StepCount = $iIncrement ; Must set both of these in order for it to take effect.
$iError = ($oImage.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 ($oImage.FillGradientName() = "") Then
$sGradName = __LOWriter_GradientNameInsert($oDoc, $tStyleGradient)
If @error > 0 Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 3, 0)
$oImage.FillGradientName = $sGradName
If ($oImage.FillGradientName <> $sGradName) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 4, 0)
EndIf
$oImage.FillGradient = $tStyleGradient
;Error checking
$iError = ($iType = Null) ? ($iError) : (($oImage.FillGradient.Style() = $iType) ? ($iError) : (BitOR($iError, 2)))
$iError = ($iXCenter = Null) ? ($iError) : (($oImage.FillGradient.XOffset() = $iXCenter) ? ($iError) : (BitOR($iError, 8)))
$iError = ($iYCenter = Null) ? ($iError) : (($oImage.FillGradient.YOffset() = $iYCenter) ? ($iError) : (BitOR($iError, 16)))
$iError = ($iAngle = Null) ? ($iError) : ((($oImage.FillGradient.Angle() / 10) = $iAngle) ? ($iError) : (BitOR($iError, 32)))
$iError = ($iTransitionStart = Null) ? ($iError) : (($oImage.FillGradient.Border() = $iTransitionStart) ? ($iError) : (BitOR($iError, 64)))
$iError = ($iFromColor = Null) ? ($iError) : (($oImage.FillGradient.StartColor() = $iFromColor) ? ($iError) : (BitOR($iError, 128)))
$iError = ($iToColor = Null) ? ($iError) : (($oImage.FillGradient.EndColor() = $iToColor) ? ($iError) : (BitOR($iError, 256)))
$iError = ($iFromIntense = Null) ? ($iError) : (($oImage.FillGradient.StartIntensity() = $iFromIntense) ? ($iError) : (BitOR($iError, 512)))
$iError = ($iToIntense = Null) ? ($iError) : (($oImage.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_ImageAreaGradient
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ImageAreaTransparency
; Description ...: Modify or retrieve Transparency settings for an Image's background color.
; Syntax ........: _LOWriter_ImageAreaTransparency(ByRef $oImage[, $iTransparency = Null])
; Parameters ....: $oImage - [in/out] an object. A Image object returned by a previous _LOWriter_ImageInsert, or _LOWriter_ImageGetObjByName 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 = $oImage not an Object.
; @Error 1 @Extended 2 Return 0 = $iTransparency not an Integer, less than 0, or greater than 100.
; --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 .......: _LOWriter_ImageInsert, _LOWriter_ImageGetObjByName
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ImageAreaTransparency(ByRef $oImage, $iTransparency = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
If Not IsObj($oImage) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_VarsAreNull($iTransparency) Then Return SetError($__LO_STATUS_SUCCESS, 1, $oImage.FillTransparence())
If Not __LOWriter_IntIsBetween($iTransparency, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oImage.FillTransparenceGradientName = "" ;Turn of Gradient if it is on, else settings wont be applied.
$oImage.FillTransparence = $iTransparency
$iError = ($oImage.FillTransparence() = $iTransparency) ? ($iError) : (BitOR($iError, 1))
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_ImageAreaTransparency
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ImageAreaTransparencyGradient
; Description ...: Modify or retrieve the Image's background transparency gradient settings.
; Syntax ........: _LOWriter_ImageAreaTransparencyGradient(ByRef $oDoc, ByRef $oImage[, $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 _LOWriter_DocOpen, _LOWriter_DocConnect, or _LOWriter_DocCreate function.
; $oImage - [in/out] an object. A Image object returned by a previous _LOWriter_ImageInsert, or _LOWriter_ImageGetObjByName function.
; $iType - [optional] an integer value (-1-5). Default is Null. The type of transparency gradient that you want to apply. See Constants, $LOW_GRAD_TYPE_* as defined in LibreOfficeWriter_Constants.au3. Set to $LOW_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 = $oImage not an Object.
; @Error 1 @Extended 3 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 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.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Error retrieving "FillTransparenceGradient" Object.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve ColorStops Array.
; @Error 3 @Extended 3 Return 0 = Error creating Transparency Gradient Name.
; @Error 3 @Extended 4 Return 0 = Error setting Transparency 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 $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 .......: _LOWriter_ImageInsert, _LOWriter_ImageGetObjByName
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ImageAreaTransparencyGradient(ByRef $oDoc, ByRef $oImage, $iType = Null, $iXCenter = Null, $iYCenter = Null, $iAngle = Null, $iTransitionStart = Null, $iStart = Null, $iEnd = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $tStyleGradient, $tColorStop, $tStopColor
Local $iError = 0
Local $sTGradName
Local $aiTransparent[7]
Local $atColorStop
Local $fValue
If Not IsObj($oDoc) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If Not IsObj($oImage) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$tStyleGradient = $oImage.FillTransparenceGradient()
If Not IsObj($tStyleGradient) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 1, 0)
If __LOWriter_VarsAreNull($iType, $iXCenter, $iYCenter, $iAngle, $iTransitionStart, $iStart, $iEnd) Then
__LOWriter_ArrayFill($aiTransparent, $tStyleGradient.Style(), $tStyleGradient.XOffset(), $tStyleGradient.YOffset(), _
($tStyleGradient.Angle() / 10), $tStyleGradient.Border(), __LOWriter_TransparencyGradientConvert(Null, $tStyleGradient.StartColor()), _
__LOWriter_TransparencyGradientConvert(Null, $tStyleGradient.EndColor())) ;Angle is set in thousands
Return SetError($__LO_STATUS_SUCCESS, 1, $aiTransparent)
EndIf
If ($iType <> Null) Then
If ($iType = $LOW_GRAD_TYPE_OFF) Then ;Turn Off Gradient
$oImage.FillTransparenceGradientName = ""
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, 3, 0)
$tStyleGradient.Style = $iType
EndIf
If ($iXCenter <> Null) Then
If Not __LOWriter_IntIsBetween($iXCenter, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$tStyleGradient.XOffset = $iXCenter
EndIf
If ($iYCenter <> Null) Then
If Not __LOWriter_IntIsBetween($iYCenter, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$tStyleGradient.YOffset = $iYCenter
EndIf
If ($iAngle <> Null) Then
If Not __LOWriter_IntIsBetween($iAngle, 0, 359) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 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, 7, 0)
$tStyleGradient.Border = $iTransitionStart
EndIf
If ($iStart <> Null) Then
If Not __LOWriter_IntIsBetween($iStart, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0)
$tStyleGradient.StartColor = __LOWriter_TransparencyGradientConvert($iStart)
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 "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
$tStyleGradient.ColorStops = $atColorStop
EndIf
EndIf
If ($iEnd <> Null) Then
If Not __LOWriter_IntIsBetween($iEnd, 0, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 9, 0)
$tStyleGradient.EndColor = __LOWriter_TransparencyGradientConvert($iEnd)
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] ; 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
$tStyleGradient.ColorStops = $atColorStop
EndIf
EndIf
If ($oImage.FillTransparenceGradientName() = "") Then
$sTGradName = __LOWriter_TransparencyGradientNameInsert($oDoc, $tStyleGradient)
If @error > 0 Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 3, 0)
$oImage.FillTransparenceGradientName = $sTGradName
If ($oImage.FillTransparenceGradientName <> $sTGradName) Then Return SetError($__LO_STATUS_PROCESSING_ERROR, 4, 0)
EndIf
$oImage.FillTransparenceGradient = $tStyleGradient
$iError = ($iType = Null) ? ($iError) : (($oImage.FillTransparenceGradient.Style() = $iType) ? ($iError) : (BitOR($iError, 1)))
$iError = ($iXCenter = Null) ? ($iError) : (($oImage.FillTransparenceGradient.XOffset() = $iXCenter) ? ($iError) : (BitOR($iError, 2)))
$iError = ($iYCenter = Null) ? ($iError) : (($oImage.FillTransparenceGradient.YOffset() = $iYCenter) ? ($iError) : (BitOR($iError, 4)))
$iError = ($iAngle = Null) ? ($iError) : ((($oImage.FillTransparenceGradient.Angle() / 10) = $iAngle) ? ($iError) : (BitOR($iError, 8)))
$iError = ($iTransitionStart = Null) ? ($iError) : (($oImage.FillTransparenceGradient.Border() = $iTransitionStart) ? ($iError) : (BitOR($iError, 16)))
$iError = ($iStart = Null) ? ($iError) : (($oImage.FillTransparenceGradient.StartColor() = __LOWriter_TransparencyGradientConvert($iStart)) ? ($iError) : (BitOR($iError, 32)))
$iError = ($iEnd = Null) ? ($iError) : (($oImage.FillTransparenceGradient.EndColor() = __LOWriter_TransparencyGradientConvert($iEnd)) ? ($iError) : (BitOR($iError, 64)))
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_ImageAreaTransparencyGradient
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ImageBorderColor
; Description ...: Set or retrieve the Image Border Line Color. Libre Office Version 3.4 and Up.
; Syntax ........: _LOWriter_ImageBorderColor(ByRef $oImage[, $iTop = Null[, $iBottom = Null[, $iLeft = Null[, $iRight = Null]]]])
; Parameters ....: $oImage - [in/out] an object. A Image object returned by a previous _LOWriter_ImageInsert, or _LOWriter_ImageGetObjByName function.
; $iTop - [optional] an integer value (0-16777215). Default is Null. Set the Top Border Line Color of the Image in Long Color code format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; $iBottom - [optional] an integer value (0-16777215). Default is Null. Set the Bottom Border Line Color of the Image in Long Color code format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; $iLeft - [optional] an integer value (0-16777215). Default is Null. Set the Left Border Line Color of the Image in Long Color code format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; $iRight - [optional] an integer value (0-16777215). Default is Null. Set the Right Border Line Color of the Image in Long Color code format. Can be a custom value, or one of the constants, $LOW_COLOR_* as defined in LibreOfficeWriter_Constants.au3.
; Return values .: Success: 1 or Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oImage not an Object.
; @Error 1 @Extended 2 Return 0 = $iTop not an integer, or set to less than 0, or greater than 16,777,215.
; @Error 1 @Extended 3 Return 0 = $iBottom not an integer, or set to less than 0, or greater than 16,777,215.
; @Error 1 @Extended 4 Return 0 = $iLeft not an integer, or set to less than 0, or greater than 16,777,215.
; @Error 1 @Extended 5 Return 0 = $iRight not an integer, or set to less than 0, or greater than 16,777,215.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error Creating Object "com.sun.star.table.BorderLine2"
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Internal command error. More than one set to True. UDF Must be fixed.
; --Property Setting Errors--
; @Error 4 @Extended 1 Return 0 = Cannot set Top Border Color when Top Border width not set.
; @Error 4 @Extended 2 Return 0 = Cannot set Bottom Border Color when Bottom Border width not set.
; @Error 4 @Extended 3 Return 0 = Cannot set Left Border Color when Left Border width not set.
; @Error 4 @Extended 4 Return 0 = Cannot set Right Border Color when Right Border width not set.
; --Version Related Errors--
; @Error 7 @Extended 1 Return 0 = Current Libre Office version lower than 3.4.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 4 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Border Width must be set first to be able to set Border Style and Color.
; Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current settings.
; Call any optional parameter with Null keyword to skip it.
; Related .......: _LOWriter_ImageInsert, _LOWriter_ImageGetObjByName, _LOWriter_ConvertColorFromLong, _LOWriter_ConvertColorToLong, _LOWriter_ImageBorderWidth, _LOWriter_ImageBorderStyle, _LOWriter_ImageBorderPadding
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ImageBorderColor(ByRef $oImage, $iTop = Null, $iBottom = Null, $iLeft = Null, $iRight = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $vReturn
If Not IsObj($oImage) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If ($iTop <> Null) And Not __LOWriter_IntIsBetween($iTop, $LOW_COLOR_BLACK, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If ($iBottom <> Null) And Not __LOWriter_IntIsBetween($iBottom, $LOW_COLOR_BLACK, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If ($iLeft <> Null) And Not __LOWriter_IntIsBetween($iLeft, $LOW_COLOR_BLACK, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
If ($iRight <> Null) And Not __LOWriter_IntIsBetween($iRight, $LOW_COLOR_BLACK, $LOW_COLOR_WHITE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$vReturn = __LOWriter_Border($oImage, False, False, True, $iTop, $iBottom, $iLeft, $iRight)
Return SetError(@error, @extended, $vReturn)
EndFunc ;==>_LOWriter_ImageBorderColor
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ImageBorderPadding
; Description ...: Set or retrieve the Image Border Padding settings.
; Syntax ........: _LOWriter_ImageBorderPadding(ByRef $oImage[, $iAll = Null[, $iTop = Null[, $iBottom = Null[, $iLeft = Null[, $iRight = Null]]]]])
; Parameters ....: $oImage - [in/out] an object. A Image object returned by a previous _LOWriter_ImageInsert, or _LOWriter_ImageGetObjByName function.
; $iAll - [optional] an integer value. Default is Null. Set all four padding distances to one distance in Micrometers (uM).
; $iTop - [optional] an integer value. Default is Null. Set the Top Distance between the Border and Image in Micrometers(uM).
; $iBottom - [optional] an integer value. Default is Null. Set the Bottom Distance between the Border and Image in Micrometers(uM).
; $iLeft - [optional] an integer value. Default is Null. Set the Left Distance between the Border and Image in Micrometers(uM).
; $iRight - [optional] an integer value. Default is Null. Set the Right Distance between the Border and Image in Micrometers(uM).
; Return values .: Success: 1 or Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oImage not an Object.
; @Error 1 @Extended 2 Return 0 = $iAll not an Integer.
; @Error 1 @Extended 3 Return 0 = $iTop not an Integer.
; @Error 1 @Extended 4 Return 0 = $iBottom not an Integer.
; @Error 1 @Extended 5 Return 0 = $Left not an Integer.
; @Error 1 @Extended 6 Return 0 = $iRight not an Integer.
; --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 $iAll border distance
; | 2 = Error setting $iTop border distance
; | 4 = Error setting $iBottom border distance
; | 8 = Error setting $iLeft border distance
; | 16 = Error setting $iRight border distance
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 5 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current settings.
; Call any optional parameter with Null keyword to skip it.
; Related .......: _LOWriter_ImageInsert, _LOWriter_ImageGetObjByName, _LOWriter_ConvertFromMicrometer, _LOWriter_ConvertToMicrometer, _LOWriter_ImageBorderWidth, _LOWriter_ImageBorderStyle, _LOWriter_ImageBorderColor
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ImageBorderPadding(ByRef $oImage, $iAll = Null, $iTop = Null, $iBottom = Null, $iLeft = Null, $iRight = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local $aiBPadding[5]
If Not IsObj($oImage) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_VarsAreNull($iAll, $iTop, $iBottom, $iLeft, $iRight) Then
__LOWriter_ArrayFill($aiBPadding, $oImage.BorderDistance(), $oImage.TopBorderDistance(), _
$oImage.BottomBorderDistance(), $oImage.LeftBorderDistance(), $oImage.RightBorderDistance())
Return SetError($__LO_STATUS_SUCCESS, 1, $aiBPadding)
EndIf
If ($iAll <> Null) Then
If Not __LOWriter_IntIsBetween($iAll, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oImage.BorderDistance = $iAll
$iError = (__LOWriter_IntIsBetween($oImage.BorderDistance(), $iAll - 1, $iAll + 1)) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($iTop <> Null) Then
If Not __LOWriter_IntIsBetween($iTop, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oImage.TopBorderDistance = $iTop
$iError = (__LOWriter_IntIsBetween($oImage.TopBorderDistance(), $iTop - 1, $iTop + 1)) ? ($iError) : (BitOR($iError, 2))
EndIf
If ($iBottom <> Null) Then
If Not __LOWriter_IntIsBetween($iBottom, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oImage.BottomBorderDistance = $iBottom
$iError = (__LOWriter_IntIsBetween($oImage.BottomBorderDistance(), $iBottom - 1, $iBottom + 1)) ? ($iError) : (BitOR($iError, 4))
EndIf
If ($iLeft <> Null) Then
If Not __LOWriter_IntIsBetween($iLeft, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oImage.LeftBorderDistance = $iLeft
$iError = (__LOWriter_IntIsBetween($oImage.LeftBorderDistance(), $iLeft - 1, $iLeft + 1)) ? ($iError) : (BitOR($iError, 8))
EndIf
If ($iRight <> Null) Then
If Not __LOWriter_IntIsBetween($iRight, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$oImage.RightBorderDistance = $iRight
$iError = (__LOWriter_IntIsBetween($oImage.RightBorderDistance(), $iRight - 1, $iRight + 1)) ? ($iError) : (BitOR($iError, 16))
EndIf
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_ImageBorderPadding
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ImageBorderStyle
; Description ...: Set or Retrieve the Image Border Line style. Libre Office Version 3.4 and Up.
; Syntax ........: _LOWriter_ImageBorderStyle(ByRef $oImage[, $iTop = Null[, $iBottom = Null[, $iLeft = Null[, $iRight = Null]]]])
; Parameters ....: $oImage - [in/out] an object. A Image object returned by a previous _LOWriter_ImageInsert, or _LOWriter_ImageGetObjByName function.
; $iTop - [optional] an integer value (0x7FFF,0-17). Default is Null. Set the Top Border Line Style of the Image using one of the line style constants, $LOW_BORDERSTYLE_* as defined in LibreOfficeWriter_Constants.au3.
; $iBottom - [optional] an integer value (0x7FFF,0-17). Default is Null. Set the Bottom Border Line Style of the Image using one of the line style constants, $LOW_BORDERSTYLE_* as defined in LibreOfficeWriter_Constants.au3.
; $iLeft - [optional] an integer value (0x7FFF,0-17). Default is Null. Set the Left Border Line Style of the Image using one of the line style constants, $LOW_BORDERSTYLE_* as defined in LibreOfficeWriter_Constants.au3.
; $iRight - [optional] an integer value (0x7FFF,0-17). Default is Null. Set the Right Border Line Style of the Image using one of the line style constants, $LOW_BORDERSTYLE_* as defined in LibreOfficeWriter_Constants.au3.
; Return values .: Success: 1 or Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oImage not an Object.
; @Error 1 @Extended 2 Return 0 = $iTop not an integer, or set to higher than 17, and not equal to 0x7FFF, or less than 0.
; @Error 1 @Extended 3 Return 0 = $iBottom not an integer, or set to higher than 17, and not equal to 0x7FFF, or less than 0.
; @Error 1 @Extended 4 Return 0 = $iLeft not an integer, or set to higher than 17, and not equal to 0x7FFF, or less than 0.
; @Error 1 @Extended 5 Return 0 = $iRight not an integer, or set to higher than 17, and not equal to 0x7FFF, or less than 0.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error Creating Object "com.sun.star.table.BorderLine2"
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Internal command error. More than one set to True. UDF Must be fixed.
; --Property Setting Errors--
; @Error 4 @Extended 1 Return 0 = Cannot set Top Border Style when Top Border width not set.
; @Error 4 @Extended 2 Return 0 = Cannot set Bottom Border Style when Bottom Border width not set.
; @Error 4 @Extended 3 Return 0 = Cannot set Left Border Style when Left Border width not set.
; @Error 4 @Extended 4 Return 0 = Cannot set Right Border Style when Right Border width not set.
; --Version Related Errors--
; @Error 7 @Extended 1 Return 0 = Current Libre Office version lower than 3.4.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 4 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: Border Width must be set first to be able to set Border Style and Color.
; Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current settings.
; Call any optional parameter with Null keyword to skip it.
; Related .......: _LOWriter_ImageInsert, _LOWriter_ImageGetObjByName, _LOWriter_ImageBorderWidth, _LOWriter_ImageBorderColor, _LOWriter_ImageBorderPadding
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ImageBorderStyle(ByRef $oImage, $iTop = Null, $iBottom = Null, $iLeft = Null, $iRight = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $vReturn
If Not IsObj($oImage) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If ($iTop <> Null) And Not __LOWriter_IntIsBetween($iTop, $LOW_BORDERSTYLE_SOLID, $LOW_BORDERSTYLE_DASH_DOT_DOT, "", $LOW_BORDERSTYLE_NONE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If ($iBottom <> Null) And Not __LOWriter_IntIsBetween($iBottom, $LOW_BORDERSTYLE_SOLID, $LOW_BORDERSTYLE_DASH_DOT_DOT, "", $LOW_BORDERSTYLE_NONE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If ($iLeft <> Null) And Not __LOWriter_IntIsBetween($iLeft, $LOW_BORDERSTYLE_SOLID, $LOW_BORDERSTYLE_DASH_DOT_DOT, "", $LOW_BORDERSTYLE_NONE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
If ($iRight <> Null) And Not __LOWriter_IntIsBetween($iRight, $LOW_BORDERSTYLE_SOLID, $LOW_BORDERSTYLE_DASH_DOT_DOT, "", $LOW_BORDERSTYLE_NONE) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$vReturn = __LOWriter_Border($oImage, False, True, False, $iTop, $iBottom, $iLeft, $iRight)
Return SetError(@error, @extended, $vReturn)
EndFunc ;==>_LOWriter_ImageBorderStyle
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ImageBorderWidth
; Description ...: Set or Retrieve the Image Border Line Width. Libre Office Version 3.4 and Up.
; Syntax ........: _LOWriter_ImageBorderWidth(ByRef $oImage[, $iTop = Null[, $iBottom = Null[, $iLeft = Null[, $iRight = Null]]]])
; Parameters ....: $oImage - [in/out] an object. A Image object returned by a previous _LOWriter_ImageInsert, or _LOWriter_ImageGetObjByName function.
; $iTop - [optional] an integer value. Default is Null. Set the Top Border Line width of the Image in Micrometers. Can be a custom value, or one of the constants, $LOW_BORDERWIDTH_* as defined in LibreOfficeWriter_Constants.au3.
; $iBottom - [optional] an integer value. Default is Null. Set the Bottom Border Line Width of the Image in Micrometers. Can be a custom value, or one of the constants, $LOW_BORDERWIDTH_* as defined in LibreOfficeWriter_Constants.au3.
; $iLeft - [optional] an integer value. Default is Null. Set the Left Border Line width of the Image in Micrometers. Can be a custom value, or one of the constants, $LOW_BORDERWIDTH_* as defined in LibreOfficeWriter_Constants.au3.
; $iRight - [optional] an integer value. Default is Null. Set the Right Border Line Width of the Image in Micrometers. Can be a custom value, or one of the constants, $LOW_BORDERWIDTH_* as defined in LibreOfficeWriter_Constants.au3.
; Return values .: Success: 1 or Array.
; Failure: 0 and sets the @Error and @Extended flags to non-zero.
; --Input Errors--
; @Error 1 @Extended 1 Return 0 = $oImage not an Object.
; @Error 1 @Extended 2 Return 0 = $iTop not an integer, or less than 0.
; @Error 1 @Extended 3 Return 0 = $iBottom not an integer, or less than 0.
; @Error 1 @Extended 4 Return 0 = $iLeft not an integer, or less than 0.
; @Error 1 @Extended 5 Return 0 = $iRight not an integer, or less than 0.
; --Initialization Errors--
; @Error 2 @Extended 1 Return 0 = Error Creating Object "com.sun.star.table.BorderLine2"
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Internal command error. More than one set to True. UDF Must be fixed.
; --Version Related Errors--
; @Error 7 @Extended 1 Return 0 = Current Libre Office version lower than 3.4.
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 4 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: To "Turn Off" Borders, set Width to 0
; Call this function with only the required parameters (or with all other parameters set to Null keyword), to get the current settings.
; Call any optional parameter with Null keyword to skip it.
; Related .......: _LOWriter_ImageInsert, _LOWriter_ImageGetObjByName, _LOWriter_ConvertFromMicrometer, _LOWriter_ConvertToMicrometer, _LOWriter_ImageBorderStyle, _LOWriter_ImageBorderColor, _LOWriter_ImageBorderPadding
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ImageBorderWidth(ByRef $oImage, $iTop = Null, $iBottom = Null, $iLeft = Null, $iRight = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $vReturn
If Not IsObj($oImage) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If ($iTop <> Null) And Not __LOWriter_IntIsBetween($iTop, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
If ($iBottom <> Null) And Not __LOWriter_IntIsBetween($iBottom, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
If ($iLeft <> Null) And Not __LOWriter_IntIsBetween($iLeft, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
If ($iRight <> Null) And Not __LOWriter_IntIsBetween($iRight, 0) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$vReturn = __LOWriter_Border($oImage, True, False, False, $iTop, $iBottom, $iLeft, $iRight)
Return SetError(@error, @extended, $vReturn)
EndFunc ;==>_LOWriter_ImageBorderWidth
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ImageColorAdjust
; Description ...: Set or retrieve Image color adjustment settings.
; Syntax ........: _LOWriter_ImageColorAdjust(ByRef $oImage[, $iRed = Null[, $iGreen = Null[, $iBlue = Null[, $iBrightness = Null[, $iContrast = Null[, $nGamma = Null[, $iColorMode = Null[, $bInvert = Null]]]]]]]])
; Parameters ....: $oImage - [in/out] an object. A Image object returned by a previous _LOWriter_ImageInsert, or _LOWriter_ImageGetObjByName function.
; $iRed - [optional] an integer value (-100-100). Default is Null. Changes the display of the Red color channel. As a percentage.
; $iGreen - [optional] an integer value (-100-100). Default is Null. Changes the display of the Green color channel. As a percentage.
; $iBlue - [optional] an integer value (-100-100). Default is Null. Changes the display of the Blue color channel. As a percentage.
; $iBrightness - [optional] an integer value (-100-100). Default is Null. Adjust the brightness of the graphic.
; $iContrast - [optional] an integer value (-100-100). Default is Null. Adjust the contrast of the graphic.
; $nGamma - [optional] a general number value (0.1-10). Default is Null. Set the gamma value of the graphic.
; $iColorMode - [optional] an integer value (0-3). Default is Null. Set the color mode of the graphic. See constants, $LOW_COLORMODE_* as defined in LibreOfficeWriter_Constants.au3
; $bInvert - [optional] a boolean value. Default is Null. If true, the graphic is displayed in inverted colors. See remarks.
; 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 = $oImage not an Object.
; @Error 1 @Extended 2 Return 0 = $iRed not an integer, less than -100, or greater than 100.
; @Error 1 @Extended 3 Return 0 = $iGreen not an integer, less than -100, or greater than 100.
; @Error 1 @Extended 4 Return 0 = $iBlue not an integer, less than -100, or greater than 100.
; @Error 1 @Extended 5 Return 0 = $iBrightness not an integer, less than -100, or greater than 100.
; @Error 1 @Extended 6 Return 0 = $iContrast not an integer, less than -100, or greater than 100.
; @Error 1 @Extended 7 Return 0 = $nGamma not a number, less than 0.1, or greater than 10.
; @Error 1 @Extended 8 Return 0 = $iColorMode not an integer, less than 0, or greater than 3. See constants, $LOW_COLORMODE_* as defined in LibreOfficeWriter_Constants.au3
; @Error 1 @Extended 9 Return 0 = $bInvert not a boolean.
; --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 $iRed
; | 2 = Error setting $iGreen
; | 4 = Error setting $iBlue
; | 8 = Error setting $iBrightness
; | 16 = Error setting $iContrast
; | 32 = Error setting $nGamma
; | 64 = Error setting $iColorMode
; | 128 = Error setting $bInvert
; --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 8 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: $bInvert is glitchy to set. The current setting will always be returned as false if set by the user. Setting inverted using this function can be difficult to remove by the user.
; 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_ImageInsert, _LOWriter_ImageGetObjByName
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _LOWriter_ImageColorAdjust(ByRef $oImage, $iRed = Null, $iGreen = Null, $iBlue = Null, $iBrightness = Null, $iContrast = Null, $nGamma = Null, $iColorMode = Null, $bInvert = Null)
Local $oCOM_ErrorHandler = ObjEvent("AutoIt.Error", __LOWriter_InternalComErrorHandler)
#forceref $oCOM_ErrorHandler
Local $iError = 0
Local $avImage[8]
If Not IsObj($oImage) Then Return SetError($__LO_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_VarsAreNull($iRed, $iGreen, $iBlue, $iBrightness, $iContrast, $nGamma, $iColorMode, $bInvert) Then
__LOWriter_ArrayFill($avImage, $oImage.AdjustRed(), $oImage.AdjustGreen(), $oImage.AdjustBlue(), $oImage.AdjustLuminance(), _
$oImage.AdjustContrast(), $oImage.Gamma(), $oImage.GraphicColorMode(), $oImage.GraphicIsInverted())
Return SetError($__LO_STATUS_SUCCESS, 1, $avImage)
EndIf
If ($iRed <> Null) Then
If Not __LOWriter_IntIsBetween($iRed, -100, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 2, 0)
$oImage.AdjustRed = $iRed
$iError = ($oImage.AdjustRed() = $iRed) ? ($iError) : (BitOR($iError, 1))
EndIf
If ($iGreen <> Null) Then
If Not __LOWriter_IntIsBetween($iGreen, -100, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 3, 0)
$oImage.AdjustGreen = $iGreen
$iError = ($oImage.AdjustGreen() = $iGreen) ? ($iError) : (BitOR($iError, 2))
EndIf
If ($iBlue <> Null) Then
If Not __LOWriter_IntIsBetween($iBlue, -100, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 4, 0)
$oImage.AdjustBlue = $iBlue
$iError = ($oImage.AdjustBlue() = $iBlue) ? ($iError) : (BitOR($iError, 4))
EndIf
If ($iBrightness <> Null) Then
If Not __LOWriter_IntIsBetween($iBrightness, -100, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 5, 0)
$oImage.AdjustLuminance = $iBrightness
$iError = ($oImage.AdjustLuminance() = $iBrightness) ? ($iError) : (BitOR($iError, 8))
EndIf
If ($iContrast <> Null) Then
If Not __LOWriter_IntIsBetween($iContrast, -100, 100) Then Return SetError($__LO_STATUS_INPUT_ERROR, 6, 0)
$oImage.AdjustContrast = $iContrast
$iError = ($oImage.AdjustContrast() = $iContrast) ? ($iError) : (BitOR($iError, 16))
EndIf
; Min 0.1, Max 10
If ($nGamma <> Null) Then
If Not __LOWriter_NumIsBetween($nGamma, 0.1, 10) Then Return SetError($__LO_STATUS_INPUT_ERROR, 7, 0)
$oImage.Gamma = $nGamma
$iError = ($oImage.Gamma() = $nGamma) ? ($iError) : (BitOR($iError, 32))
EndIf
If ($iColorMode <> Null) Then
If Not __LOWriter_IntIsBetween($iColorMode, $LOW_COLORMODE_STANDARD, $LOW_COLORMODE_WATERMARK) Then Return SetError($__LO_STATUS_INPUT_ERROR, 8, 0)
$oImage.GraphicColorMode = $iColorMode
$iError = ($oImage.GraphicColorMode() = $iColorMode) ? ($iError) : (BitOR($iError, 64))
EndIf
If ($bInvert <> Null) Then
If Not IsBool($bInvert) Then Return SetError($__LO_STATUS_INPUT_ERROR, 9, 0)
$oImage.GraphicIsInverted = $bInvert
$iError = ($oImage.GraphicIsInverted() = $bInvert) ? ($iError) : (BitOR($iError, 128))
EndIf
Return ($iError > 0) ? (SetError($__LO_STATUS_PROP_SETTING_ERROR, $iError, 0)) : (SetError($__LO_STATUS_SUCCESS, 0, 1))
EndFunc ;==>_LOWriter_ImageColorAdjust
; #FUNCTION# ====================================================================================================================
; Name ..........: _LOWriter_ImageCrop
; Description ...: Set or retrieve Image crop settings.
; Syntax ........: _LOWriter_ImageCrop(ByRef $oImage[, $iLeft = Null[, $iRight = Null[, $iTop = Null[, $iBottom = Null[, $bKeepScale = Null]]]]])
; Parameters ....: $oImage - [in/out] an object. A Image object returned by a previous _LOWriter_ImageInsert, or _LOWriter_ImageGetObjByName function.
; $iLeft - [optional] an integer value. Default is Null. The amount in Micrometers (uM) to either extend the background of the image, (negative numbers), or to crop, (positive numbers) from the Left side.
; $iRight - [optional] an integer value. Default is Null. The amount in Micrometers (uM) to either extend the background of the image, (negative numbers), or to crop, (positive numbers) from the Right side.
; $iTop - [optional] an integer value. Default is Null. The amount in Micrometers (uM) to either extend the background of the image, (negative numbers), or to crop, (positive numbers) from the Top side.
; $iBottom - [optional] an integer value. Default is Null. The amount in Micrometers (uM) to either extend the background of the image, (negative numbers), or to crop, (positive numbers) from the Bottom side.
; $bKeepScale - [optional] a boolean value. Default is Null. If True, crop amounts are removed or added to the image, while keeping the scaling. If False, crop values are removed or added while retaining the image size. See remarks. This setting is internally static, you do not need to set this each call for as long as the script life, unless you wish to change the value. Default static setting is true.
; 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 = $oImage not an Object.
; @Error 1 @Extended 2 Return 0 = $bKeepScale not a Boolean.
; @Error 1 @Extended 3 Return 0 = $iLeft not an integer.
; @Error 1 @Extended 4 Return 0 = $iRight not an integer.
; @Error 1 @Extended 5 Return 0 = $iTop not an integer.
; @Error 1 @Extended 6 Return 0 = $iBottom not an integer.
; --Processing Errors--
; @Error 3 @Extended 1 Return 0 = Failed to retrieve the image Crop structure.
; @Error 3 @Extended 2 Return 0 = Failed to retrieve the image Size structure.
; --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 $iLeft
; | 2 = Error setting $iRight
; | 4 = Error setting $iTop
; | 8 = Error setting $iBottom
; --Success--
; @Error 0 @Extended 0 Return 1 = Success. Settings were successfully set.
; @Error 0 @Extended 1 Return Array = Success. All optional parameters were set to Null, returning current settings in a 5 Element Array with values in order of function parameters.
; Author ........: donnyh13
; Modified ......:
; Remarks .......: There is no literal setting for $bKeepScale in Libre Office's settings, so I have made an internal static setting in this function to behave the same as Libre Office. When you retrieve the current settings for an image, the return for $bKeepScale will be my internal static value, and NOT the current LibreOffice setting.
; Maximum crop values are based on page width. You cannot exceed the size of the page, nor crop too much of the image away.
; 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_ImageInsert, _LOWriter_ImageGetObjByName, _LOWriter_ConvertToMicrometer, _LOWriter_ConvertFromMicrometer
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================