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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "sdmodeltestbase.hxx"
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/awt/TextAlign.hpp>
#include <com/sun/star/style/VerticalAlignment.hpp>
#include <com/sun/star/awt/ScrollBarOrientation.hpp>
#include <com/sun/star/awt/VisualEffect.hpp>
#include <com/sun/star/awt/ImagePosition.hpp>
#include <com/sun/star/awt/ImageScaleMode.hpp>
#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/awt/FontSlant.hpp>
#include <com/sun/star/awt/FontUnderline.hpp>
#include <com/sun/star/awt/FontStrikeout.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
class SdActiveXControlsTest: public SdModelTestBase
{
public:
void testBackgroundColor();
void testLabelProperties();
void testTextBoxProperties();
void testSpinButtonProperties();
void testCommandButtonProperties();
void testScrollBarProperties();
void testCheckBoxProperties();
void testOptionButtonProperties();
void testComboBoxProperties();
void testListBoxProperties();
void testToggleButtonProperties();
void testPictureProperties();
void testFontProperties();
CPPUNIT_TEST_SUITE(SdActiveXControlsTest);
CPPUNIT_TEST(testBackgroundColor);
CPPUNIT_TEST(testLabelProperties);
CPPUNIT_TEST(testTextBoxProperties);
CPPUNIT_TEST(testSpinButtonProperties);
CPPUNIT_TEST(testCommandButtonProperties);
CPPUNIT_TEST(testScrollBarProperties);
CPPUNIT_TEST(testCheckBoxProperties);
CPPUNIT_TEST(testOptionButtonProperties);
CPPUNIT_TEST(testComboBoxProperties);
CPPUNIT_TEST(testListBoxProperties);
CPPUNIT_TEST(testToggleButtonProperties);
CPPUNIT_TEST(testPictureProperties);
CPPUNIT_TEST(testFontProperties);
CPPUNIT_TEST_SUITE_END();
};
void SdActiveXControlsTest::testBackgroundColor()
{
// Check whether all system colors are imported correctly
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/control_background_color.pptx"), PPTX);
const std::vector<Color> vBackgroundColors =
{
0xD4D0C8, // Scroll Bars
0x004E98, // Desktop
0x0054E3, // Active Title Bar
0x7A96DF, // Inactive Title Bar
0xFFFFFF, // Menu Bar
0xFFFFFF, // Window Background
0x000000, // Window Frame
0x000000, // Menu Text
0x000000, // Window Text
0xFFFFFF, // Active Title Bar Text
0xD4D0C8, // Active Border
0xD4D0C8, // Inactive Border
0x808080, // Application Workspace
0x316AC5, // Highlight
0xFFFFFF, // Highlight Text
0xECE9D8, // Button Face
0xACA899, // Button Shadow
0xACA899, // Disabled Text
0x000000, // Button Text
0xD8E4F8, // Inactive Title Bar Text
0xFFFFFF, // Button Highlight
0x716F64, // Button Dark Shadow
0xF1EFE2, // Button Light Shadow
0x000000, // Tooltip Text
0xFFFFE1, // Tooltip
0xFF0000, // Custom red color
};
for (size_t i = 0; i < vBackgroundColors.size(); ++i)
{
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(i, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
Color nColor;
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
OString sMessage = "The wrong control's index is: " + OString::number(i);
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), vBackgroundColors[i], nColor);
}
xDocShRef->DoClose();
}
void SdActiveXControlsTest::testLabelProperties()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/activex_label.pptx"), PPTX);
// First control has default properties
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
OUString sLabel;
xPropertySet->getPropertyValue("Label") >>= sLabel;
CPPUNIT_ASSERT_EQUAL(OUString("Label1"), sLabel);
bool bEnabled;
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(true, bEnabled);
bool bMultiLine;
xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
CPPUNIT_ASSERT_EQUAL(true, bMultiLine);
Color nColor;
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_WHITE, nColor);
sal_Int16 nBorderStyle;
xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nBorderStyle);
sal_Int16 nAlign;
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
style::VerticalAlignment eAlign;
xPropertySet->getPropertyValue("VerticalAlign") >>= eAlign;
CPPUNIT_ASSERT_EQUAL(style::VerticalAlignment_TOP, eAlign);
// Second control has custom properties
xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Label") >>= sLabel;
CPPUNIT_ASSERT_EQUAL(OUString("Custom Label"), sLabel);
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(false, bEnabled);
xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xE0E0E0), nColor);
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0x0000FF), nColor);
xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nBorderStyle);
Color nBorderColor;
xPropertySet->getPropertyValue("BorderColor") >>= nBorderColor;
CPPUNIT_ASSERT_EQUAL(Color(0x00FF00), nBorderColor);
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
xPropertySet->getPropertyValue("VerticalAlign") >>= eAlign;
CPPUNIT_ASSERT_EQUAL(style::VerticalAlignment_TOP, eAlign);
// Third control has transparent background
xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("BackgroundColor") >>= nColor);
xDocShRef->DoClose();
}
void SdActiveXControlsTest::testTextBoxProperties()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/activex_textbox.pptx"), PPTX);
// First control has default properties
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
OUString sText;
xPropertySet->getPropertyValue("Text") >>= sText;
CPPUNIT_ASSERT_EQUAL(OUString(), sText);
bool bEnabled;
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(true, bEnabled);
bool bMultiLine;
xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
Color nColor;
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_WHITE, nColor);
sal_Int16 nBorderStyle;
xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nBorderStyle);
sal_Int16 nAlign;
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
style::VerticalAlignment eAlign;
CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("VerticalAlign") >>= eAlign);
bool bHideSelection;
xPropertySet->getPropertyValue("HideInactiveSelection") >>= bHideSelection;
CPPUNIT_ASSERT_EQUAL(true, bHideSelection);
sal_Int16 nMaxLength;
xPropertySet->getPropertyValue("MaxTextLen") >>= nMaxLength;
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nMaxLength);
sal_Int16 nEchoChar;
xPropertySet->getPropertyValue("EchoChar") >>= nEchoChar;
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nEchoChar);
bool bHScroll;
xPropertySet->getPropertyValue("HScroll") >>= bHScroll;
CPPUNIT_ASSERT_EQUAL(false, bHScroll);
bool bVScroll;
xPropertySet->getPropertyValue("VScroll") >>= bVScroll;
CPPUNIT_ASSERT_EQUAL(false, bVScroll);
bool bReadOnly;
xPropertySet->getPropertyValue("ReadOnly") >>= bReadOnly;
CPPUNIT_ASSERT_EQUAL(false, bReadOnly);
// Second control has custom properties
xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Text") >>= sText;
CPPUNIT_ASSERT_EQUAL(OUString("Some Text"), sText);
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(false, bEnabled);
// These textfields are not multilines in the pptx testfile
xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0x404040), nColor);
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0x00C000), nColor);
xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nBorderStyle);
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("VerticalAlign") >>= eAlign);
xPropertySet->getPropertyValue("HideInactiveSelection") >>= bHideSelection;
CPPUNIT_ASSERT_EQUAL(false, bHideSelection);
xPropertySet->getPropertyValue("MaxTextLen") >>= nMaxLength;
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), nMaxLength);
xPropertySet->getPropertyValue("EchoChar") >>= nEchoChar;
CPPUNIT_ASSERT_EQUAL(sal_Int16('x'), nEchoChar);
xPropertySet->getPropertyValue("HScroll") >>= bHScroll;
CPPUNIT_ASSERT_EQUAL(true, bHScroll);
xPropertySet->getPropertyValue("VScroll") >>= bVScroll;
CPPUNIT_ASSERT_EQUAL(false, bVScroll);
xPropertySet->getPropertyValue("ReadOnly") >>= bReadOnly;
CPPUNIT_ASSERT_EQUAL(true, bReadOnly);
// Third shape has some other custom properties
xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
// Transparent background
CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("BackgroundColor") >>= nColor);
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT), nAlign);
xPropertySet->getPropertyValue("HScroll") >>= bHScroll;
CPPUNIT_ASSERT_EQUAL(false, bHScroll);
xPropertySet->getPropertyValue("VScroll") >>= bVScroll;
CPPUNIT_ASSERT_EQUAL(true, bVScroll);
// Fourth shape has both scroll bar
xControlShape.set(getShapeFromPage(3, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("HScroll") >>= bHScroll;
CPPUNIT_ASSERT_EQUAL(true, bHScroll);
xPropertySet->getPropertyValue("VScroll") >>= bVScroll;
CPPUNIT_ASSERT_EQUAL(true, bVScroll);
xDocShRef->DoClose();
}
void SdActiveXControlsTest::testSpinButtonProperties()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/activex_spinbutton.pptx"), PPTX);
// First control has default properties
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
bool bEnabled;
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(true, bEnabled);
Color nColor;
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xECE9D8), nColor);
sal_Int32 nMax;
xPropertySet->getPropertyValue("SpinValueMax") >>= nMax;
CPPUNIT_ASSERT_EQUAL(sal_Int32(100), nMax);
sal_Int32 nMin;
xPropertySet->getPropertyValue("SpinValueMin") >>= nMin;
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nMin);
sal_Int32 nIncrement;
xPropertySet->getPropertyValue("SpinIncrement") >>= nIncrement;
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nIncrement);
bool bRepeat;
xPropertySet->getPropertyValue("Repeat") >>= bRepeat;
CPPUNIT_ASSERT_EQUAL(true, bRepeat);
sal_Int32 nDelay;
xPropertySet->getPropertyValue("RepeatDelay") >>= nDelay;
CPPUNIT_ASSERT_EQUAL(sal_Int32(50), nDelay);
Color nArrowColor;
xPropertySet->getPropertyValue("SymbolColor") >>= nArrowColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nArrowColor);
sal_Int32 nOrientation;
xPropertySet->getPropertyValue("Orientation") >>= nOrientation;
CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::HORIZONTAL), nOrientation);
sal_Int32 nSpinValue;
xPropertySet->getPropertyValue("SpinValue") >>= nSpinValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nSpinValue);
// Second control has custom properties
xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(false, bEnabled);
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xFFFF00), nColor);
xPropertySet->getPropertyValue("SpinValueMax") >>= nMax;
CPPUNIT_ASSERT_EQUAL(sal_Int32(320), nMax);
xPropertySet->getPropertyValue("SpinValueMin") >>= nMin;
CPPUNIT_ASSERT_EQUAL(sal_Int32(123), nMin);
xPropertySet->getPropertyValue("SpinIncrement") >>= nIncrement;
CPPUNIT_ASSERT_EQUAL(sal_Int32(5), nIncrement);
xPropertySet->getPropertyValue("Repeat") >>= bRepeat;
CPPUNIT_ASSERT_EQUAL(true, bRepeat);
xPropertySet->getPropertyValue("RepeatDelay") >>= nDelay;
CPPUNIT_ASSERT_EQUAL(sal_Int32(123), nDelay);
xPropertySet->getPropertyValue("SymbolColor") >>= nArrowColor;
CPPUNIT_ASSERT_EQUAL(Color(0x00FF00), nArrowColor);
xPropertySet->getPropertyValue("Orientation") >>= nOrientation;
CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::VERTICAL), nOrientation);
xPropertySet->getPropertyValue("SpinValue") >>= nSpinValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(123), nSpinValue);
// Third control has horizontal orientation
xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Orientation") >>= nOrientation;
CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::HORIZONTAL), nOrientation);
xDocShRef->DoClose();
}
void SdActiveXControlsTest::testCommandButtonProperties()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/activex_commandbutton.pptx"), PPTX);
// First control has default properties
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
OUString sLabel;
xPropertySet->getPropertyValue("Label") >>= sLabel;
CPPUNIT_ASSERT_EQUAL(OUString("CommandButton1"), sLabel);
bool bEnabled;
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(true, bEnabled);
bool bMultiLine;
xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
Color nColor;
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xECE9D8), nColor);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
bool bFocusOnClick;
xPropertySet->getPropertyValue("FocusOnClick") >>= bFocusOnClick;
CPPUNIT_ASSERT_EQUAL(true, bFocusOnClick);
bool bRepeat;
xPropertySet->getPropertyValue("Repeat") >>= bRepeat;
CPPUNIT_ASSERT_EQUAL(false, bRepeat);
// Second control has custom properties
xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Label") >>= sLabel;
CPPUNIT_ASSERT_EQUAL(OUString("Custom Caption"), sLabel);
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(false, bEnabled);
xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
CPPUNIT_ASSERT_EQUAL(true, bMultiLine);
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0x0000FF), nColor);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xFFFF80), nColor);
xPropertySet->getPropertyValue("FocusOnClick") >>= bFocusOnClick;
CPPUNIT_ASSERT_EQUAL(false, bFocusOnClick);
xPropertySet->getPropertyValue("Repeat") >>= bRepeat;
CPPUNIT_ASSERT_EQUAL(false, bRepeat);
// Third shape has some other custom properties
xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
// Transparent background
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_WHITE, nColor);
xDocShRef->DoClose();
}
void SdActiveXControlsTest::testScrollBarProperties()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/activex_scrollbar.pptx"), PPTX);
// First control has default properties
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
bool bEnabled;
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(true, bEnabled);
Color nColor;
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xECE9D8), nColor);
xPropertySet->getPropertyValue("SymbolColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
sal_Int32 nDelay;
xPropertySet->getPropertyValue("RepeatDelay") >>= nDelay;
CPPUNIT_ASSERT_EQUAL(sal_Int32(50), nDelay);
sal_Int16 nBorderStyle;
xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nBorderStyle);
sal_Int32 nVisibleSize;
xPropertySet->getPropertyValue("VisibleSize") >>= nVisibleSize;
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nVisibleSize);
sal_Int32 nScrollValueMin;
xPropertySet->getPropertyValue("ScrollValueMin") >>= nScrollValueMin;
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nScrollValueMin);
sal_Int32 nScrollValueMax;
xPropertySet->getPropertyValue("ScrollValueMax") >>= nScrollValueMax;
CPPUNIT_ASSERT_EQUAL(sal_Int32(32767), nScrollValueMax);
sal_Int32 nScrollValue;
xPropertySet->getPropertyValue("DefaultScrollValue") >>= nScrollValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nScrollValue);
sal_Int32 nLineIncrement;
xPropertySet->getPropertyValue("LineIncrement") >>= nLineIncrement;
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nLineIncrement);
sal_Int32 nBlockIncrement;
xPropertySet->getPropertyValue("BlockIncrement") >>= nBlockIncrement;
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nBlockIncrement);
sal_Int32 nOrientation;
xPropertySet->getPropertyValue("Orientation") >>= nOrientation;
CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::VERTICAL), nOrientation);
// Second control has custom properties
xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(false, bEnabled);
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0x00FFFF), nColor);
xPropertySet->getPropertyValue("SymbolColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), nColor);
xPropertySet->getPropertyValue("RepeatDelay") >>= nDelay;
CPPUNIT_ASSERT_EQUAL(sal_Int32(230), nDelay);
xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nBorderStyle);
xPropertySet->getPropertyValue("VisibleSize") >>= nVisibleSize;
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nVisibleSize);
xPropertySet->getPropertyValue("ScrollValueMin") >>= nScrollValueMin;
CPPUNIT_ASSERT_EQUAL(sal_Int32(123), nScrollValueMin);
xPropertySet->getPropertyValue("ScrollValueMax") >>= nScrollValueMax;
CPPUNIT_ASSERT_EQUAL(sal_Int32(1234567), nScrollValueMax);
xPropertySet->getPropertyValue("DefaultScrollValue") >>= nScrollValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(125), nScrollValue);
xPropertySet->getPropertyValue("LineIncrement") >>= nLineIncrement;
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nLineIncrement);
xPropertySet->getPropertyValue("BlockIncrement") >>= nBlockIncrement;
CPPUNIT_ASSERT_EQUAL(sal_Int32(4), nBlockIncrement);
xPropertySet->getPropertyValue("Orientation") >>= nOrientation;
CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::VERTICAL), nOrientation);
// Third shape has some other custom properties
xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Orientation") >>= nOrientation;
CPPUNIT_ASSERT_EQUAL(sal_Int32(awt::ScrollBarOrientation::HORIZONTAL), nOrientation);
xPropertySet->getPropertyValue("VisibleSize") >>= nVisibleSize;
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nVisibleSize);
xDocShRef->DoClose();
}
void SdActiveXControlsTest::testCheckBoxProperties()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/activex_checkbox.pptx"), PPTX);
// First control has default properties
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
OUString sLabel;
xPropertySet->getPropertyValue("Label") >>= sLabel;
CPPUNIT_ASSERT_EQUAL(OUString("CheckBox1"), sLabel);
bool bEnabled;
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(true, bEnabled);
Color nColor;
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_WHITE, nColor);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
bool bMultiLine;
xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
CPPUNIT_ASSERT_EQUAL(true, bMultiLine);
sal_Int16 nVisualEffect;
xPropertySet->getPropertyValue("VisualEffect") >>= nVisualEffect;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::VisualEffect::LOOK3D), nVisualEffect);
bool bTriState;
xPropertySet->getPropertyValue("TriState") >>= bTriState;
CPPUNIT_ASSERT_EQUAL(false, bTriState);
sal_Int16 nState;
xPropertySet->getPropertyValue("State") >>= nState;
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState);
sal_Int16 nAlign;
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
// Second control has custom properties
xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Label") >>= sLabel;
CPPUNIT_ASSERT_EQUAL(OUString("Custom Caption"), sLabel);
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(false, bEnabled);
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), nColor);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xFF80FF), nColor);
xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
xPropertySet->getPropertyValue("VisualEffect") >>= nVisualEffect;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::VisualEffect::FLAT), nVisualEffect);
xPropertySet->getPropertyValue("TriState") >>= bTriState;
CPPUNIT_ASSERT_EQUAL(true, bTriState);
xPropertySet->getPropertyValue("State") >>= nState;
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nState);
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
// Third shape has some other custom properties
xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("TriState") >>= bTriState;
CPPUNIT_ASSERT_EQUAL(true, bTriState);
xPropertySet->getPropertyValue("State") >>= nState;
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nState);
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT), nAlign);
// Transparent background
CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("BackgroundColor") >>= nColor);
xDocShRef->DoClose();
}
void SdActiveXControlsTest::testOptionButtonProperties()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/activex_optionbutton.pptx"), PPTX);
// First control has default properties
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
OUString sLabel;
xPropertySet->getPropertyValue("Label") >>= sLabel;
CPPUNIT_ASSERT_EQUAL(OUString("OptionButton1"), sLabel);
bool bEnabled;
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(true, bEnabled);
Color nColor;
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_WHITE, nColor);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
bool bMultiLine;
xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
CPPUNIT_ASSERT_EQUAL(true, bMultiLine);
sal_Int16 nVisualEffect;
xPropertySet->getPropertyValue("VisualEffect") >>= nVisualEffect;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::VisualEffect::LOOK3D), nVisualEffect);
sal_Int16 nState;
xPropertySet->getPropertyValue("State") >>= nState;
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState);
sal_Int16 nAlign;
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
// Second control has custom properties
xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Label") >>= sLabel;
CPPUNIT_ASSERT_EQUAL(OUString("Custom Caption"), sLabel);
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(false, bEnabled);
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0x00FFFF), nColor);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), nColor);
xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
xPropertySet->getPropertyValue("VisualEffect") >>= nVisualEffect;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::VisualEffect::FLAT), nVisualEffect);
xPropertySet->getPropertyValue("State") >>= nState;
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nState);
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
// Third shape has some other custom properties
xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("State") >>= nState;
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState); // TriState / undefined imported as unchecked
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT), nAlign);
// Transparent background
CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("BackgroundColor") >>= nColor);
xDocShRef->DoClose();
}
void SdActiveXControlsTest::testComboBoxProperties()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/activex_combobox.pptx"), PPTX);
// First control has default properties
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
bool bEnabled;
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(true, bEnabled);
Color nColor;
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_WHITE, nColor);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
bool bAutocomplete;
xPropertySet->getPropertyValue("Autocomplete") >>= bAutocomplete;
CPPUNIT_ASSERT_EQUAL(true, bAutocomplete);
sal_Int16 nBorderStyle;
xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nBorderStyle);
Color nBorderColor;
xPropertySet->getPropertyValue("BorderColor") >>= nBorderColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nBorderColor);
bool bDropdown;
xPropertySet->getPropertyValue("Dropdown") >>= bDropdown;
CPPUNIT_ASSERT_EQUAL(true, bDropdown);
bool bHideInactiveSelection;
xPropertySet->getPropertyValue("HideInactiveSelection") >>= bHideInactiveSelection;
CPPUNIT_ASSERT_EQUAL(true, bHideInactiveSelection);
sal_Int16 nLineCount;
xPropertySet->getPropertyValue("LineCount") >>= nLineCount;
CPPUNIT_ASSERT_EQUAL(sal_Int16(8), nLineCount);
sal_Int16 nMaxTextLen;
xPropertySet->getPropertyValue("MaxTextLen") >>= nMaxTextLen;
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nMaxTextLen);
bool bReadOnly;
xPropertySet->getPropertyValue("ReadOnly") >>= bReadOnly;
CPPUNIT_ASSERT_EQUAL(false, bReadOnly);
sal_Int16 nAlign;
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
// Second control has custom properties
xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(false, bEnabled);
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0x800000), nColor);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_WHITE, nColor);
xPropertySet->getPropertyValue("Autocomplete") >>= bAutocomplete;
CPPUNIT_ASSERT_EQUAL(true, bAutocomplete);
xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nBorderStyle);
xPropertySet->getPropertyValue("BorderColor") >>= nBorderColor;
CPPUNIT_ASSERT_EQUAL(Color(0x404040), nBorderColor);
xPropertySet->getPropertyValue("Dropdown") >>= bDropdown;
CPPUNIT_ASSERT_EQUAL(true, bDropdown);
xPropertySet->getPropertyValue("HideInactiveSelection") >>= bHideInactiveSelection;
CPPUNIT_ASSERT_EQUAL(false, bHideInactiveSelection);
xPropertySet->getPropertyValue("LineCount") >>= nLineCount;
CPPUNIT_ASSERT_EQUAL(sal_Int16(12), nLineCount);
xPropertySet->getPropertyValue("MaxTextLen") >>= nMaxTextLen;
CPPUNIT_ASSERT_EQUAL(sal_Int16(130), nMaxTextLen);
xPropertySet->getPropertyValue("ReadOnly") >>= bReadOnly;
CPPUNIT_ASSERT_EQUAL(false, bReadOnly); // Bogus, should be true (tdf#111417)
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
// Third shape has some other custom properties
xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Autocomplete") >>= bAutocomplete;
CPPUNIT_ASSERT_EQUAL(false, bAutocomplete);
xPropertySet->getPropertyValue("Dropdown") >>= bDropdown;
CPPUNIT_ASSERT_EQUAL(false, bDropdown);
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT), nAlign);
// Transparent background
CPPUNIT_ASSERT_EQUAL(false, xPropertySet->getPropertyValue("BackgroundColor") >>= nColor);
xDocShRef->DoClose();
}
void SdActiveXControlsTest::testListBoxProperties()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/activex_listbox.pptx"), PPTX);
// First control has default properties
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
bool bEnabled;
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(true, bEnabled);
Color nColor;
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_WHITE, nColor);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
sal_Int16 nBorderStyle;
xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nBorderStyle);
Color nBorderColor;
xPropertySet->getPropertyValue("BorderColor") >>= nBorderColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nBorderColor);
bool bDropdown;
xPropertySet->getPropertyValue("Dropdown") >>= bDropdown;
CPPUNIT_ASSERT_EQUAL(false, bDropdown);
bool bMultiSelection;
xPropertySet->getPropertyValue("MultiSelection") >>= bMultiSelection;
CPPUNIT_ASSERT_EQUAL(false, bMultiSelection);
sal_Int16 nLineCount;
xPropertySet->getPropertyValue("LineCount") >>= nLineCount;
CPPUNIT_ASSERT_EQUAL(sal_Int16(5), nLineCount);
bool bReadOnly;
xPropertySet->getPropertyValue("ReadOnly") >>= bReadOnly;
CPPUNIT_ASSERT_EQUAL(false, bReadOnly);
sal_Int16 nAlign;
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
// Second control has custom properties
xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(false, bEnabled);
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xFFFF00), nColor);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), nColor);
xPropertySet->getPropertyValue("Border") >>= nBorderStyle;
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nBorderStyle);
xPropertySet->getPropertyValue("BorderColor") >>= nBorderColor;
CPPUNIT_ASSERT_EQUAL(Color(0xFF00FF), nBorderColor);
xPropertySet->getPropertyValue("MultiSelection") >>= bMultiSelection;
CPPUNIT_ASSERT_EQUAL(true, bMultiSelection);
xPropertySet->getPropertyValue("ReadOnly") >>= bReadOnly;
CPPUNIT_ASSERT_EQUAL(false, bReadOnly); // Bogus, should be true (tdf#111417)
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
// Third shape has some other custom properties
xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("MultiSelection") >>= bMultiSelection;
CPPUNIT_ASSERT_EQUAL(true, bMultiSelection);
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT), nAlign);
xDocShRef->DoClose();
}
void SdActiveXControlsTest::testToggleButtonProperties()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/activex_togglebutton.pptx"), PPTX);
// First control has default properties
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
OUString sLabel;
xPropertySet->getPropertyValue("Label") >>= sLabel;
CPPUNIT_ASSERT_EQUAL(OUString("ToggleButton1"), sLabel);
bool bEnabled;
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(true, bEnabled);
bool bMultiLine;
xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
CPPUNIT_ASSERT_EQUAL(true, bMultiLine);
Color nColor;
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xECE9D8), nColor);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
bool bToggle;
xPropertySet->getPropertyValue("Toggle") >>= bToggle;
CPPUNIT_ASSERT_EQUAL(true, bToggle);
sal_Int16 nState;
xPropertySet->getPropertyValue("State") >>= nState;
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState);
sal_Int16 nAlign;
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::CENTER), nAlign);
// Second control has custom properties
xControlShape.set(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("Label") >>= sLabel;
CPPUNIT_ASSERT_EQUAL(OUString("Custom Caption"), sLabel);
xPropertySet->getPropertyValue("Enabled") >>= bEnabled;
CPPUNIT_ASSERT_EQUAL(false, bEnabled);
xPropertySet->getPropertyValue("MultiLine") >>= bMultiLine;
CPPUNIT_ASSERT_EQUAL(false, bMultiLine);
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xFF80FF), nColor);
xPropertySet->getPropertyValue("TextColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0x808080), nColor);
xPropertySet->getPropertyValue("Toggle") >>= bToggle;
CPPUNIT_ASSERT_EQUAL(true, bToggle);
xPropertySet->getPropertyValue("State") >>= nState;
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nState);
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::LEFT), nAlign);
// Third shape has some other custom properties
xControlShape.set(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY_THROW);
xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("State") >>= nState;
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nState); // Undefined state
xPropertySet->getPropertyValue("Align") >>= nAlign;
CPPUNIT_ASSERT_EQUAL(sal_Int16(awt::TextAlign::RIGHT), nAlign);
// Transparent background
xPropertySet->getPropertyValue("BackgroundColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_WHITE, nColor);
xDocShRef->DoClose();
}
void SdActiveXControlsTest::testPictureProperties()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/activex_picture.pptx"), PPTX);
// Different controls has different image positioning
// Command buttons here with icons
const std::vector<sal_Int16> vImagePositions =
{
awt::ImagePosition::AboveCenter,
awt::ImagePosition::LeftTop,
awt::ImagePosition::LeftCenter,
awt::ImagePosition::LeftBottom,
awt::ImagePosition::RightTop,
awt::ImagePosition::RightCenter,
awt::ImagePosition::RightBottom,
awt::ImagePosition::AboveLeft,
awt::ImagePosition::AboveRight,
awt::ImagePosition::BelowLeft,
awt::ImagePosition::BelowCenter,
awt::ImagePosition::BelowRight,
awt::ImagePosition::Centered,
};
for (size_t i = 0; i < vImagePositions.size(); ++i)
{
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(i, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
uno::Reference<graphic::XGraphic> xGraphic;
xPropertySet->getPropertyValue("Graphic") >>= xGraphic;
CPPUNIT_ASSERT(xGraphic.is());
sal_Int16 nColor;
xPropertySet->getPropertyValue("ImagePosition") >>= nColor;
OString sMessage = "The wrong control's index is: " + OString::number(i);
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), vImagePositions[i], nColor);
}
// Picture controls with different properties
for (size_t i = 0; i < 4; ++i)
{
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(vImagePositions.size() + i, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
OString sMessage = "The wrong control's index is: " + OString::number(i);
uno::Reference<graphic::XGraphic> xGraphic;
xPropertySet->getPropertyValue("Graphic") >>= xGraphic;
if (i == 0) // First control has no image specified
CPPUNIT_ASSERT_MESSAGE(sMessage.getStr(), !xGraphic.is());
else
CPPUNIT_ASSERT_MESSAGE(sMessage.getStr(), xGraphic.is());
sal_Int16 nScaleMode;
xPropertySet->getPropertyValue("ScaleMode") >>= nScaleMode;
if (i == 2) // Stretch mode
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), awt::ImageScaleMode::ANISOTROPIC, nScaleMode);
else if (i == 3) // Zoom mode
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), awt::ImageScaleMode::ISOTROPIC, nScaleMode);
else // Clip mode
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), awt::ImageScaleMode::NONE, nScaleMode);
}
// Note: LO picture control does not support tiled image and also image positioning
// When there is no scaling picture positioned to center.
xDocShRef->DoClose();
}
void SdActiveXControlsTest::testFontProperties()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/activex_fontproperties.pptx"), PPTX);
// Different controls has different font properties
for (size_t i = 0; i < 8; ++i)
{
uno::Reference< drawing::XControlShape > xControlShape(getShapeFromPage(i, 0, xDocShRef), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
OString sMessage = "The wrong control's index is: " + OString::number(i);
OUString sFontName;
xPropertySet->getPropertyValue("FontName") >>= sFontName;
if (i == 4 || i == 5)
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), OUString("Times New Roman"), sFontName);
else
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), OUString("Arial"), sFontName);
float fFontWeight;
xPropertySet->getPropertyValue("FontWeight") >>= fFontWeight;
if (i == 2 || i == 4)
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), awt::FontWeight::BOLD, fFontWeight);
else
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), awt::FontWeight::NORMAL, fFontWeight);
sal_Int16 nFontSlant;
xPropertySet->getPropertyValue("FontSlant") >>= nFontSlant;
if (i == 3 || i == 4)
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), sal_Int16(awt::FontSlant_ITALIC), nFontSlant);
else
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), sal_Int16(awt::FontSlant_NONE), nFontSlant);
sal_Int16 nFontUnderline;
xPropertySet->getPropertyValue("FontUnderline") >>= nFontUnderline;
if (i == 7)
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), sal_Int16(awt::FontUnderline::SINGLE), nFontUnderline);
else
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), sal_Int16(awt::FontUnderline::NONE), nFontUnderline);
sal_Int16 nFontStrikeout;
xPropertySet->getPropertyValue("FontStrikeout") >>= nFontStrikeout;
if (i == 6 || i == 7)
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), sal_Int16(awt::FontStrikeout::SINGLE), nFontStrikeout);
else
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), sal_Int16(awt::FontStrikeout::NONE), nFontStrikeout);
float fFontHeight;
xPropertySet->getPropertyValue("FontHeight") >>= fFontHeight;
if (i == 1)
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), 24.0f, fFontHeight);
else
CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), 14.0f, fFontHeight);
}
xDocShRef->DoClose();
}
CPPUNIT_TEST_SUITE_REGISTRATION(SdActiveXControlsTest);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|