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
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 "charttest.hxx"
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/chart2/CurveStyle.hpp>
#include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/chart/XChartData.hpp>
#include <com/sun/star/chart2/XInternalDataProvider.hpp>
#include <com/sun/star/chart/XChartDataArray.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
#include <com/sun/star/chart/MissingValueTreatment.hpp>
#include <com/sun/star/chart2/TickmarkStyle.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/util/Color.hpp>
class Chart2ImportTest : public ChartTest
{
public:
void Fdo60083();
void testSteppedLines();
void testErrorBarRange();
void testErrorBarFormatting();
void testODSChartSeries();
void testXLSXChartSeries();
void testXLSChartSeries();
void testODTChartSeries();
void testDOCChartSeries();
void testDOCXChartSeries();
void testDOCXChartValuesSize();
void testPPTXChartSeries();
void testPPTXSparseChartSeries();
/**
* Original data contains 3 series but 2 of them are hidden. For now, we
* detect and skip those hidden series on import (since we don't support
* hidden columns for internal data table yet).
*/
void testPPTXHiddenDataSeries();
void testPPTXPercentageNumberFormats();
void testPPTXStackedNonStackedYAxis();
void testPPTChartSeries();
void testODPChartSeries();
void testBnc864396();
void testBnc882383();
void testBnc889755();
void testSimpleStrictXLSX();
void testDelayedCellImport(); // chart range referencing content on later sheets
void testFlatODSStackedColumnChart();
void testFdo78080();
void testFdo54361();
void testFdo54361_1();
void testTdf86624(); // manually placed legends
void testTdf106217();
void testAutoBackgroundXLSX();
void testChartAreaStyleBackgroundXLSX();
void testAxisTextRotationXLSX();
// void testTextCanOverlapXLSX(); // TODO : temporarily disabled.
void testNumberFormatsXLSX();
void testTransparentBackground(OUString const & filename);
// below are OOXML default value tests for cases
// where we fixed the handling of MSO 2007 vs OOXML
void testAutoTitleDelDefaultValue2007XLSX();
void testAutoTitleDelDefaultValue2013XLSX();
void testDispBlanksAsDefaultValue2007XLSX();
void testDispBlanksAsDefaultValue2013XLSX();
void testSmoothDefaultValue2007XLSX();
void testSmoothDefaultValue2013XLSX();
void testTrendlineDefaultValue2007XLSX();
void testTrendlineDefaultValue2013XLSX();
void testVaryColorDefaultValues2007XLSX();
void testVaryColorDefaultValues2013XLSX();
void testPlotVisOnlyDefaultValue2013XLSX();
void testRAngAxDefaultValue2013XLSX();
void testMajorTickMarksDefaultValue2013XLSX();
void testMinorTickMarksDefaultValue2013XLSX();
void testAxisTitleDefaultRotationXLSX();
void testSecondaryAxisTitleDefaultRotationXLSX();
void testAxisTitleRotationXLSX();
void testTdf90510(); // Pie chart label placement settings(XLS)
void testInternalDataProvider();
CPPUNIT_TEST_SUITE(Chart2ImportTest);
CPPUNIT_TEST(Fdo60083);
CPPUNIT_TEST(testSteppedLines);
CPPUNIT_TEST(testErrorBarRange);
CPPUNIT_TEST(testErrorBarFormatting);
CPPUNIT_TEST(testODSChartSeries);
CPPUNIT_TEST(testXLSXChartSeries);
CPPUNIT_TEST(testXLSChartSeries);
CPPUNIT_TEST(testODTChartSeries);
CPPUNIT_TEST(testDOCChartSeries);
CPPUNIT_TEST(testDOCXChartSeries);
CPPUNIT_TEST(testDOCXChartValuesSize);
CPPUNIT_TEST(testPPTChartSeries);
CPPUNIT_TEST(testPPTXChartSeries);
CPPUNIT_TEST(testPPTXSparseChartSeries);
CPPUNIT_TEST(testPPTXHiddenDataSeries);
CPPUNIT_TEST(testPPTXPercentageNumberFormats);
CPPUNIT_TEST(testPPTXStackedNonStackedYAxis);
CPPUNIT_TEST(testODPChartSeries);
CPPUNIT_TEST(testBnc864396);
CPPUNIT_TEST(testBnc882383);
CPPUNIT_TEST(testBnc889755);
CPPUNIT_TEST(testSimpleStrictXLSX);
CPPUNIT_TEST(testDelayedCellImport);
CPPUNIT_TEST(testFlatODSStackedColumnChart);
CPPUNIT_TEST(testFdo78080);
CPPUNIT_TEST(testFdo54361);
CPPUNIT_TEST(testFdo54361_1);
CPPUNIT_TEST(testTdf86624);
CPPUNIT_TEST(testTdf106217);
CPPUNIT_TEST(testAutoBackgroundXLSX);
CPPUNIT_TEST(testChartAreaStyleBackgroundXLSX);
CPPUNIT_TEST(testAxisTextRotationXLSX);
// CPPUNIT_TEST(testTextCanOverlapXLSX); // TODO : temporarily disabled.
CPPUNIT_TEST(testNumberFormatsXLSX);
CPPUNIT_TEST(testAutoTitleDelDefaultValue2007XLSX);
CPPUNIT_TEST(testAutoTitleDelDefaultValue2013XLSX);
CPPUNIT_TEST(testDispBlanksAsDefaultValue2007XLSX);
CPPUNIT_TEST(testDispBlanksAsDefaultValue2013XLSX);
CPPUNIT_TEST(testSmoothDefaultValue2007XLSX);
CPPUNIT_TEST(testSmoothDefaultValue2013XLSX);
CPPUNIT_TEST(testTrendlineDefaultValue2007XLSX);
CPPUNIT_TEST(testTrendlineDefaultValue2013XLSX);
CPPUNIT_TEST(testVaryColorDefaultValues2007XLSX);
CPPUNIT_TEST(testVaryColorDefaultValues2013XLSX);
CPPUNIT_TEST(testPlotVisOnlyDefaultValue2013XLSX);
CPPUNIT_TEST(testRAngAxDefaultValue2013XLSX);
CPPUNIT_TEST(testMajorTickMarksDefaultValue2013XLSX);
CPPUNIT_TEST(testMinorTickMarksDefaultValue2013XLSX);
CPPUNIT_TEST(testAxisTitleDefaultRotationXLSX);
CPPUNIT_TEST(testSecondaryAxisTitleDefaultRotationXLSX);
CPPUNIT_TEST(testAxisTitleRotationXLSX);
CPPUNIT_TEST(testTdf90510);
CPPUNIT_TEST(testInternalDataProvider);
CPPUNIT_TEST_SUITE_END();
private:
};
// error bar import
// split method up into smaller chunks for more detailed tests
void Chart2ImportTest::Fdo60083()
{
load("/chart2/qa/extras/data/ods/", "fdo60083.ods");
uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
CPPUNIT_ASSERT(xChartDoc.is());
Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
CPPUNIT_ASSERT( xDataSeries.is() );
Reference< beans::XPropertySet > xPropSet( xDataSeries, UNO_QUERY_THROW );
CPPUNIT_ASSERT( xPropSet.is() );
// test that y error bars are there
Reference< beans::XPropertySet > xErrorBarYProps;
xPropSet->getPropertyValue(CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarYProps;
CPPUNIT_ASSERT(xErrorBarYProps.is());
{
sal_Int32 nErrorBarStyle;
CPPUNIT_ASSERT(
xErrorBarYProps->getPropertyValue("ErrorBarStyle")
>>= nErrorBarStyle);
CPPUNIT_ASSERT_EQUAL(
static_cast<sal_Int32>(chart::ErrorBarStyle::RELATIVE),
nErrorBarStyle);
double nVal = 0.0;
CPPUNIT_ASSERT(
xErrorBarYProps->getPropertyValue("PositiveError") >>= nVal);
CPPUNIT_ASSERT_DOUBLES_EQUAL(5.0, nVal, 1e-8);
CPPUNIT_ASSERT(
xErrorBarYProps->getPropertyValue("NegativeError") >>= nVal);
CPPUNIT_ASSERT_DOUBLES_EQUAL(5.0, nVal, 1e-8);
bool bVal;
CPPUNIT_ASSERT(
xErrorBarYProps->getPropertyValue("ShowPositiveError") >>= bVal);
CPPUNIT_ASSERT_EQUAL(bVal, true);
CPPUNIT_ASSERT(
xErrorBarYProps->getPropertyValue("ShowNegativeError") >>= bVal);
CPPUNIT_ASSERT_EQUAL(bVal, true);
}
// test that x error bars are not imported
Reference< beans::XPropertySet > xErrorBarXProps;
xPropSet->getPropertyValue(CHART_UNONAME_ERRORBAR_X) >>= xErrorBarXProps;
CPPUNIT_ASSERT(!xErrorBarXProps.is());
}
void Chart2ImportTest::testErrorBarRange()
{
load("/chart2/qa/extras/data/ods/", "error_bar_range.ods");
uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
CPPUNIT_ASSERT(xChartDoc.is());
Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
CPPUNIT_ASSERT( xDataSeries.is() );
Reference< beans::XPropertySet > xPropSet( xDataSeries, UNO_QUERY_THROW );
CPPUNIT_ASSERT( xPropSet.is() );
// test that y error bars are there
Reference< beans::XPropertySet > xErrorBarYProps;
xPropSet->getPropertyValue(CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarYProps;
CPPUNIT_ASSERT(xErrorBarYProps.is());
sal_Int32 nErrorBarStyle;
CPPUNIT_ASSERT(
xErrorBarYProps->getPropertyValue("ErrorBarStyle")
>>= nErrorBarStyle);
CPPUNIT_ASSERT_EQUAL(
static_cast<sal_Int32>(chart::ErrorBarStyle::FROM_DATA),
nErrorBarStyle);
OUString aRangePos;
CPPUNIT_ASSERT(xErrorBarYProps->getPropertyValue("ErrorBarRangePositive") >>= aRangePos);
CPPUNIT_ASSERT_EQUAL(aRangePos, OUString("$Sheet1.$C$2:$C$4"));
}
void Chart2ImportTest::testErrorBarFormatting()
{
load("/chart2/qa/extras/data/ods/", "error_bar_properties.ods");
uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
CPPUNIT_ASSERT(xChartDoc.is());
Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
CPPUNIT_ASSERT( xDataSeries.is() );
Reference< beans::XPropertySet > xPropSet( xDataSeries, UNO_QUERY_THROW );
CPPUNIT_ASSERT( xPropSet.is() );
// test that y error bars are there
Reference< beans::XPropertySet > xErrorBarYProps;
xPropSet->getPropertyValue(CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarYProps;
CPPUNIT_ASSERT(xErrorBarYProps.is());
util::Color aColor(0);
xErrorBarYProps->getPropertyValue("LineColor") >>= aColor;
sal_uInt32 nColorValue = aColor;
CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xff3333), nColorValue);
}
// stepped line interpolation
void Chart2ImportTest::testSteppedLines()
{
const sal_Int32 MAXSHEET = 14;
chart2::CurveStyle curveStyle[] = {
chart2::CurveStyle_LINES,
chart2::CurveStyle_CUBIC_SPLINES,
chart2::CurveStyle_B_SPLINES,
chart2::CurveStyle_STEP_START,
chart2::CurveStyle_STEP_END,
chart2::CurveStyle_STEP_CENTER_X,
chart2::CurveStyle_STEP_CENTER_Y,
chart2::CurveStyle_LINES,
chart2::CurveStyle_CUBIC_SPLINES,
chart2::CurveStyle_B_SPLINES,
chart2::CurveStyle_STEP_START,
chart2::CurveStyle_STEP_END,
chart2::CurveStyle_STEP_CENTER_X,
chart2::CurveStyle_STEP_CENTER_Y
};
load("/chart2/qa/extras/data/ods/", "stepped_lines.ods");
for(sal_Int32 nSheet = 0; nSheet < MAXSHEET; ++nSheet)
{
uno::Reference< chart2::XChartDocument > xChart2Doc = getChartDocFromSheet( nSheet, mxComponent );
CPPUNIT_ASSERT(xChart2Doc.is());
Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChart2Doc, 0 );
CPPUNIT_ASSERT(xChartType.is());
Reference< beans::XPropertySet > xPropSet( xChartType, UNO_QUERY );
CPPUNIT_ASSERT(xPropSet.is());
chart2::CurveStyle eCurveStyle;
xPropSet->getPropertyValue("CurveStyle") >>= eCurveStyle;
CPPUNIT_ASSERT_EQUAL(eCurveStyle, curveStyle[nSheet]);
}
}
uno::Sequence < OUString > getChartColumnDescriptions( uno::Reference< chart::XChartDocument > const & xChart1Doc)
{
CPPUNIT_ASSERT(xChart1Doc.is());
uno::Reference< chart::XChartDataArray > xChartData ( xChart1Doc->getData(), UNO_QUERY_THROW);
CPPUNIT_ASSERT(xChartData.is());
uno::Sequence < OUString > seriesList = xChartData->getColumnDescriptions();
return seriesList;
}
void Chart2ImportTest::testODSChartSeries()
{
load("/chart2/qa/extras/data/ods/", "chart.ods");
uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW);
uno::Sequence < OUString > seriesList = getChartColumnDescriptions( xChart1Doc);
CPPUNIT_ASSERT_EQUAL(OUString("Col 1"), seriesList[0]);
CPPUNIT_ASSERT_EQUAL(OUString("Col2"), seriesList[1]);
CPPUNIT_ASSERT_EQUAL(OUString("Col 33"), seriesList[2]);
}
void Chart2ImportTest::testXLSXChartSeries()
{
load("/chart2/qa/extras/data/xlsx/", "chart.xlsx");
uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW);
uno::Sequence < OUString > seriesList = getChartColumnDescriptions(xChart1Doc );
CPPUNIT_ASSERT_EQUAL(OUString("Col 1"), seriesList[0]);
CPPUNIT_ASSERT_EQUAL(OUString("Col2"), seriesList[1]);
CPPUNIT_ASSERT_EQUAL(OUString("Col 33"), seriesList[2]);
}
void Chart2ImportTest::testXLSChartSeries()
{
load("/chart2/qa/extras/data/xls/", "chart.xls");
uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW);
uno::Sequence < OUString > seriesList = getChartColumnDescriptions(xChart1Doc );
CPPUNIT_ASSERT_EQUAL(OUString("Col 1"), seriesList[0]);
CPPUNIT_ASSERT_EQUAL(OUString("Col 2"), seriesList[1]);
CPPUNIT_ASSERT_EQUAL(OUString("Col 3"), seriesList[2]);
}
void Chart2ImportTest::testODTChartSeries()
{
load("/chart2/qa/extras/data/odt/", "chart.odt");
uno::Sequence< OUString > seriesList = getWriterChartColumnDescriptions(mxComponent);
CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
}
void Chart2ImportTest::testDOCChartSeries()
{
load("/chart2/qa/extras/data/doc/", "chart.doc");
uno::Sequence< OUString > seriesList = getWriterChartColumnDescriptions(mxComponent);
CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
}
void Chart2ImportTest::testDOCXChartSeries()
{
load("/chart2/qa/extras/data/docx/", "chart.docx");
Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
CPPUNIT_ASSERT(xCT.is());
std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
CPPUNIT_ASSERT_EQUAL(OUString("Series 1"), aLabels[0][0].get<OUString>());
CPPUNIT_ASSERT_EQUAL(OUString("Series 2"), aLabels[1][0].get<OUString>());
CPPUNIT_ASSERT_EQUAL(OUString("Series 3"), aLabels[2][0].get<OUString>());
}
void Chart2ImportTest::testDOCXChartValuesSize()
{
load( "/chart2/qa/extras/data/docx/", "bubblechart.docx" );
Reference<chart2::XChartDocument> xChartDoc( getChartDocFromWriter(0), uno::UNO_QUERY );
CPPUNIT_ASSERT( xChartDoc.is() );
uno::Reference< chart::XChartDataArray > xDataArray( xChartDoc->getDataProvider(), UNO_QUERY_THROW );
Sequence<OUString> aColumnDesc = xDataArray->getColumnDescriptions();
// Number of columns = 3 (Y-values, X-values and bubble sizes).
// Without the fix there would only be 2 columns (no bubble sizes).
CPPUNIT_ASSERT_EQUAL_MESSAGE( "There must be 3 columns and descriptions", static_cast<sal_Int32>(3), aColumnDesc.getLength() );
Sequence<Sequence<double>> aData = xDataArray->getData();
CPPUNIT_ASSERT_EQUAL_MESSAGE( "There must be exactly 3 data points", static_cast<sal_Int32>(3), aData.getLength() );
std::vector<std::vector<double>> aExpected = { { 2.7, 0.7, 10.0 }, { 3.2, 1.8, 4.0 }, { 0.8, 2.6, 8.0 } };
for ( sal_Int32 nRowIdx = 0; nRowIdx < 3; ++nRowIdx )
for( sal_Int32 nColIdx = 0; nColIdx < 3; ++nColIdx )
CPPUNIT_ASSERT_DOUBLES_EQUAL( aExpected[nRowIdx][nColIdx], aData[nRowIdx][nColIdx], 1e-1 );
}
void Chart2ImportTest::testPPTChartSeries()
{
//test chart series names for ppt
uno::Sequence < OUString > seriesList = getImpressChartColumnDescriptions("/chart2/qa/extras/data/ppt/", "chart.ppt");
CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
}
void Chart2ImportTest::testPPTXChartSeries()
{
//test chart series names for pptx
load("/chart2/qa/extras/data/pptx/", "chart.pptx");
Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
CPPUNIT_ASSERT(xCT.is());
std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), aLabels[0][0].get<OUString>());
CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), aLabels[1][0].get<OUString>());
CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), aLabels[2][0].get<OUString>());
}
void Chart2ImportTest::testPPTXSparseChartSeries()
{
//test chart series sparse data for pptx
load("/chart2/qa/extras/data/pptx/", "sparse-chart.pptx");
Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
CPPUNIT_ASSERT(xCT.is());
std::vector<std::vector<double> > aValues = getDataSeriesYValuesFromChartType(xCT);
CPPUNIT_ASSERT_EQUAL(size_t(2), aValues.size());
CPPUNIT_ASSERT( rtl::math::isNan( aValues[0][0] ) );
CPPUNIT_ASSERT_EQUAL(2.5, aValues[0][1]);
CPPUNIT_ASSERT_EQUAL(3.5, aValues[0][2]);
CPPUNIT_ASSERT( rtl::math::isNan( aValues[0][3] ) );
CPPUNIT_ASSERT_EQUAL(-2.4, aValues[1][0]);
CPPUNIT_ASSERT( rtl::math::isNan( aValues[1][1] ) );
CPPUNIT_ASSERT( rtl::math::isNan( aValues[1][2] ) );
CPPUNIT_ASSERT_EQUAL(-2.8, aValues[1][3]);
}
void Chart2ImportTest::testPPTXHiddenDataSeries()
{
load("/chart2/qa/extras/data/pptx/", "stacked-bar-chart-hidden-series.pptx");
Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xChartDoc.is());
// "Automatic" chart background fill in pptx should be loaded as no fill.
Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
CPPUNIT_ASSERT(xPropSet.is());
drawing::FillStyle eStyle = xPropSet->getPropertyValue("FillStyle").get<drawing::FillStyle>();
CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in pptx should be loaded as no fill (transparent).",
drawing::FillStyle_NONE, eStyle);
Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0);
CPPUNIT_ASSERT(xCT.is());
// There should be only one data series present.
std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT);
CPPUNIT_ASSERT_EQUAL(size_t(1), aLabels.size());
CPPUNIT_ASSERT_EQUAL(OUString("Series 3"), aLabels[0][0].get<OUString>());
// Test the internal data.
CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider());
Reference<chart2::XInternalDataProvider> xInternalProvider(xChartDoc->getDataProvider(), uno::UNO_QUERY);
CPPUNIT_ASSERT(xInternalProvider.is());
Reference<chart::XComplexDescriptionAccess> xDescAccess(xInternalProvider, uno::UNO_QUERY);
CPPUNIT_ASSERT(xDescAccess.is());
// Get the category labels.
Sequence<Sequence<OUString> > aCategories = xDescAccess->getComplexRowDescriptions();
CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aCategories.getLength());
CPPUNIT_ASSERT_EQUAL(OUString("Category 1"), aCategories[0][0]);
CPPUNIT_ASSERT_EQUAL(OUString("Category 2"), aCategories[1][0]);
CPPUNIT_ASSERT_EQUAL(OUString("Category 3"), aCategories[2][0]);
CPPUNIT_ASSERT_EQUAL(OUString("Category 4"), aCategories[3][0]);
}
void Chart2ImportTest::testPPTXPercentageNumberFormats()
{
load("/chart2/qa/extras/data/pptx/", "percentage-number-formats.pptx");
// 1st chart
Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xChartDoc.is());
uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
CPPUNIT_ASSERT(xDataSeries.is());
uno::Reference<beans::XPropertySet> xPropertySet;
chart2::DataPointLabel aLabel;
sal_Int32 nNumberFormat;
const sal_Int32 nPercentFormatSimple = getNumberFormat(xChartDoc, "0%");
const sal_Int32 nPercentFormatDecimal = getNumberFormat(xChartDoc, "0.00%");
xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_QUERY_THROW);
xPropertySet->getPropertyValue("Label") >>= aLabel;
CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber);
CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
CPPUNIT_ASSERT_EQUAL(nPercentFormatSimple, nNumberFormat);
xPropertySet.set(xDataSeries->getDataPointByIndex(1), uno::UNO_QUERY_THROW);
xPropertySet->getPropertyValue("Label") >>= aLabel;
CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber);
CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
CPPUNIT_ASSERT_EQUAL(nPercentFormatDecimal, nNumberFormat);
xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_QUERY_THROW);
xPropertySet->getPropertyValue("Label") >>= aLabel;
CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumber);
CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
CPPUNIT_ASSERT_EQUAL(nPercentFormatSimple, nNumberFormat);
xPropertySet.set(xDataSeries->getDataPointByIndex(3), uno::UNO_QUERY_THROW);
xPropertySet->getPropertyValue("Label") >>= aLabel;
CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumber);
CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
CPPUNIT_ASSERT_EQUAL(nPercentFormatDecimal, nNumberFormat);
// 2nd chart
xChartDoc.set(getChartDocFromDrawImpress(1, 0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
CPPUNIT_ASSERT(xYAxis.is());
Reference<beans::XPropertySet> xPS(xYAxis, uno::UNO_QUERY_THROW);
bool bLinkNumberFormatToSource = true;
bool bSuccess = xPS->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", bSuccess && !bLinkNumberFormatToSource);
// FIXME: This should be in fact "0.00%".
// see TODO in oox/source/drawingml/chart/modelbase.cxx
const sal_Int32 nPercentFormatDecimalShort = getNumberFormat(xChartDoc, "0.0%");
nNumberFormat = getNumberFormatFromAxis(xYAxis);
CPPUNIT_ASSERT_EQUAL(nPercentFormatDecimalShort, nNumberFormat);
sal_Int16 nType = getNumberFormatType(xChartDoc, nNumberFormat);
CPPUNIT_ASSERT_MESSAGE("Y axis should be a percent format.", (nType & util::NumberFormat::PERCENT));
}
void Chart2ImportTest::testPPTXStackedNonStackedYAxis()
{
load("/chart2/qa/extras/data/pptx/", "stacked-non-stacked-mix-y-axis.pptx");
// 1st chart is a normal stacked column.
Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW);
OUString aTitle = getTitleString(xTitled);
CPPUNIT_ASSERT_EQUAL(OUString("Stacked"), aTitle);
// Get the Y-axis.
Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
CPPUNIT_ASSERT(xYAxis.is());
sal_Int32 nNumberFormat = getNumberFormatFromAxis(xYAxis);
sal_Int16 nType = getNumberFormatType(xChartDoc, nNumberFormat);
CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType & util::NumberFormat::NUMBER));
CPPUNIT_ASSERT_MESSAGE("Y axis should NOT be a percent format.", !(nType & util::NumberFormat::PERCENT));
// 2nd chart is a percent-stacked column.
xChartDoc.set(getChartDocFromDrawImpress(1, 0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xChartDoc.is());
xTitled.set(xChartDoc, uno::UNO_QUERY_THROW);
aTitle = getTitleString(xTitled);
CPPUNIT_ASSERT_EQUAL(OUString("100% Stacked"), aTitle);
// Get the Y-axis.
xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
CPPUNIT_ASSERT(xYAxis.is());
// Get the number format of the Y-axis.
nNumberFormat = getNumberFormatFromAxis(xYAxis);
nType = getNumberFormatType(xChartDoc, nNumberFormat);
CPPUNIT_ASSERT_MESSAGE("Y axis should be a percent format.", (nType & util::NumberFormat::PERCENT));
// 3rd chart is a mixture of normal-stacked column with a percent-stacked
// area chart series. Excel in this case sets the Y-axis to be
// non-percent axis and we should do the same for interoperability.
xChartDoc.set(getChartDocFromDrawImpress(2, 0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xChartDoc.is());
xTitled.set(xChartDoc, uno::UNO_QUERY_THROW);
aTitle = getTitleString(xTitled);
CPPUNIT_ASSERT_EQUAL(OUString("Stacked column mixed with 100% stacked area"), aTitle);
// Get the Y-axis.
xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
CPPUNIT_ASSERT(xYAxis.is());
// Get the number format of the Y-axis.
nNumberFormat = getNumberFormatFromAxis(xYAxis);
nType = getNumberFormatType(xChartDoc, nNumberFormat);
CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType & util::NumberFormat::NUMBER));
CPPUNIT_ASSERT_MESSAGE("Y axis should NOT be a percent format.", !(nType & util::NumberFormat::PERCENT));
}
void Chart2ImportTest::testODPChartSeries()
{
//test chart series names for odp
uno::Sequence < OUString > seriesList = getImpressChartColumnDescriptions("/chart2/qa/extras/data/odp/", "chart.odp");
CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
}
void Chart2ImportTest::testBnc864396()
{
uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromImpress("/chart2/qa/extras/data/pptx/", "bnc864396.pptx"), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider());
uno::Reference< chart2::XInternalDataProvider > xDataProvider( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
uno::Reference< chart::XChartDataArray > xChartDataArray(xDataProvider, uno::UNO_QUERY_THROW);
uno::Sequence< OUString > aRowLabels = xChartDataArray->getRowDescriptions();
for(sal_Int32 i = 0; i < aRowLabels.getLength(); ++i)
{
OUString aExpected = "cat" + OUString::number(i+1);
CPPUNIT_ASSERT_EQUAL(aExpected, aRowLabels[i]);
}
}
void Chart2ImportTest::testBnc889755()
{
load("/chart2/qa/extras/data/pptx/", "bnc889755.pptx");
uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 6), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT(xChartDoc.is());
CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider());
uno::Reference< chart2::XInternalDataProvider > xDataProvider( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
uno::Reference< chart::XChartDataArray > xChartDataArray(xDataProvider, uno::UNO_QUERY_THROW);
uno::Sequence< OUString > aRowLabels = xChartDataArray->getRowDescriptions();
CPPUNIT_ASSERT_EQUAL( aRowLabels.getLength(), sal_Int32(16) );
CPPUNIT_ASSERT_EQUAL(OUString("Oct-12"), aRowLabels[0]);
CPPUNIT_ASSERT_EQUAL(OUString("Nov-12"), aRowLabels[1]);
CPPUNIT_ASSERT_EQUAL(OUString("Dec-12"), aRowLabels[2]);
CPPUNIT_ASSERT_EQUAL(OUString("Jan-13"), aRowLabels[3]);
CPPUNIT_ASSERT_EQUAL(OUString("Feb-13"), aRowLabels[4]);
CPPUNIT_ASSERT_EQUAL(OUString("Mar-13"), aRowLabels[5]);
CPPUNIT_ASSERT_EQUAL(OUString("Apr-13"), aRowLabels[6]);
CPPUNIT_ASSERT_EQUAL(OUString("May-13"), aRowLabels[7]);
CPPUNIT_ASSERT_EQUAL(OUString("Jun-13"), aRowLabels[8]);
CPPUNIT_ASSERT_EQUAL(OUString("Jul-13"), aRowLabels[9]);
CPPUNIT_ASSERT_EQUAL(OUString("Aug-13"), aRowLabels[10]);
CPPUNIT_ASSERT_EQUAL(OUString("Sep-13"), aRowLabels[11]);
CPPUNIT_ASSERT_EQUAL(OUString("Oct-13"), aRowLabels[12]);
CPPUNIT_ASSERT_EQUAL(OUString("Nov-13"), aRowLabels[13]);
CPPUNIT_ASSERT_EQUAL(OUString("Dec-13"), aRowLabels[14]);
CPPUNIT_ASSERT_EQUAL(OUString("Jan-14"), aRowLabels[15]);
}
void Chart2ImportTest::testBnc882383()
{
load("/chart2/qa/extras/data/pptx/", "bnc882383.pptx");
uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY_THROW);
uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
CPPUNIT_ASSERT(xDataSeries.is());
uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_QUERY_THROW);
OUString sGradientName;
xPropertySet->getPropertyValue("GradientName") >>= sGradientName;
CPPUNIT_ASSERT(!sGradientName.isEmpty());
}
void Chart2ImportTest::testSimpleStrictXLSX()
{
load("/chart2/qa/extras/data/xlsx/", "strict_chart.xlsx");
uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
CPPUNIT_ASSERT(xChartDoc.is());
Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
CPPUNIT_ASSERT(xDataSeries.is());
}
void Chart2ImportTest::testDelayedCellImport()
{
load("/chart2/qa/extras/data/xlsx/", "fdo70609.xlsx");
uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
Reference< chart2::data::XDataSequence > xDataSeq =
getDataSequenceFromDocByRole(xChartDoc, "values-x");
OUString aRange = xDataSeq->getSourceRangeRepresentation();
CPPUNIT_ASSERT_EQUAL(OUString("$Sheet2.$C$5:$C$9"), aRange);
}
void Chart2ImportTest::testFlatODSStackedColumnChart()
{
load("/chart2/qa/extras/data/fods/", "stacked-column-chart.fods");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc, 0);
CPPUNIT_ASSERT(xChartType.is());
Reference<chart2::XDataSeriesContainer> xDSCont(xChartType, UNO_QUERY);
CPPUNIT_ASSERT(xDSCont.is());
Sequence<Reference<chart2::XDataSeries> > aSeriesSeq = xDSCont->getDataSeries();
// The stacked column chart should consist of 5 data series.
CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aSeriesSeq.getLength());
}
void Chart2ImportTest::testFdo78080()
{
load("/chart2/qa/extras/data/xlsx/", "fdo78080.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW);
Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
CPPUNIT_ASSERT(!xTitle.is());
}
void Chart2ImportTest::testTdf86624()
{
load("/chart2/qa/extras/data/ods/", "tdf86624.ods");
uno::Reference< chart2::XChartDocument > xChart2Doc = getChartDocFromSheet(0, mxComponent);
uno::Reference< chart::XChartDocument > xChartDoc (xChart2Doc, uno::UNO_QUERY);
uno::Reference<drawing::XShape> xLegend = xChartDoc->getLegend();
awt::Point aPos = xLegend->getPosition();
CPPUNIT_ASSERT(aPos.X > 5000); // real value for me is above 8000 but before bug fix is below 1000
CPPUNIT_ASSERT(aPos.Y > 4000); // real value for ms is above 7000
}
void Chart2ImportTest::testTdf106217()
{
load("/chart2/qa/extras/data/pptx/", "tdf106217.pptx");
uno::Reference< chart::XChartDocument > xChartDoc = getChartDocFromDrawImpress(0, 0);
CPPUNIT_ASSERT(xChartDoc.is());
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
uno::Reference<drawing::XShape> xCircle(xDrawPage->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT(xCircle.is());
uno::Reference<container::XNamed> xNamedShape(xCircle, uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(xNamedShape->getName(), OUString("Oval 1"));
awt::Point aPosition = xCircle->getPosition();
CPPUNIT_ASSERT_EQUAL(aPosition.X, sal_Int32(6870));
CPPUNIT_ASSERT_EQUAL(aPosition.Y, sal_Int32(7261));
awt::Size aSize = xCircle->getSize();
CPPUNIT_ASSERT_EQUAL(aSize.Width, sal_Int32(2701));
CPPUNIT_ASSERT_EQUAL(aSize.Height, sal_Int32(2700));
}
void Chart2ImportTest::testTransparentBackground(OUString const & filename)
{
load("/chart2/qa/extras/data/xlsx/", filename);
uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
uno::Reference< chart::XChartDocument > xChart2Doc (xChartDoc, uno::UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChart2Doc.is());
Reference< beans::XPropertySet > xPropSet( xChart2Doc->getArea(), uno::UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE("failed to get Area", xPropSet.is());
css::drawing::FillStyle aStyle;
xPropSet -> getPropertyValue("FillStyle") >>= aStyle;
CPPUNIT_ASSERT_EQUAL_MESSAGE("Background needs to be with solid fill style", css::drawing::FillStyle_SOLID, aStyle);
}
// 2 test methods here so that tearDown() can dispose the document
void Chart2ImportTest::testFdo54361()
{
testTransparentBackground("fdo54361.xlsx");
}
void Chart2ImportTest::testFdo54361_1()
{
testTransparentBackground("fdo54361-1.xlsx");
}
void Chart2ImportTest::testAutoBackgroundXLSX()
{
load("/chart2/qa/extras/data/xlsx/", "chart-auto-background.xlsx");
uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
// "Automatic" chart background fill in xlsx should be loaded as solid white.
Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
CPPUNIT_ASSERT(xPropSet.is());
drawing::FillStyle eStyle = xPropSet->getPropertyValue("FillStyle").get<drawing::FillStyle>();
sal_Int32 nColor = xPropSet->getPropertyValue("FillColor").get<sal_Int32>();
CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid fill.",
drawing::FillStyle_SOLID, eStyle);
CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid white.",
sal_Int32(0x00FFFFFF), sal_Int32(nColor & 0x00FFFFFF)); // highest 2 bytes are transparency which we ignore here.
}
void Chart2ImportTest::testChartAreaStyleBackgroundXLSX()
{
load("/chart2/qa/extras/data/xlsx/", "chart-area-style-background.xlsx");
uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
// "Automatic" chart background fill in xlsx should be loaded as solid white.
Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
CPPUNIT_ASSERT(xPropSet.is());
drawing::FillStyle eStyle = xPropSet->getPropertyValue("FillStyle").get<drawing::FillStyle>();
sal_Int32 nColor = xPropSet->getPropertyValue("FillColor").get<sal_Int32>();
CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid fill.",
drawing::FillStyle_SOLID, eStyle);
CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chart background fill in xlsx should be loaded as solid white.",
sal_Int32(0), nColor);
}
void Chart2ImportTest::testAxisTextRotationXLSX()
{
load("/chart2/qa/extras/data/xlsx/", "axis-label-rotation.xlsx");
uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
CPPUNIT_ASSERT(xYAxis.is());
Reference<beans::XPropertySet> xPS(xYAxis, uno::UNO_QUERY_THROW);
double nRotation = 0;
bool bSuccess = xPS->getPropertyValue("TextRotation") >>= nRotation;
CPPUNIT_ASSERT(bSuccess);
CPPUNIT_ASSERT_DOUBLES_EQUAL(90, nRotation, 1e-10);
}
/* TODO : temporarily disabled.
void Chart2ImportTest::testTextCanOverlapXLSX()
{
// fdo#84647 : To check textoverlap value is imported correctly.
load("/chart2/qa/extras/data/xlsx/", "chart-text-can-overlap.xlsx");
uno::Reference< chart::XDiagram > mxDiagram;
uno::Reference< beans::XPropertySet > xAxisProp;
bool bTextCanOverlap = false;
uno::Reference< chart::XChartDocument > xChartDoc ( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW);
CPPUNIT_ASSERT(xChartDoc.is());
mxDiagram.set(xChartDoc->getDiagram());
CPPUNIT_ASSERT(mxDiagram.is());
uno::Reference< chart::XAxisXSupplier > xAxisXSupp( mxDiagram, uno::UNO_QUERY );
CPPUNIT_ASSERT(xAxisXSupp.is());
xAxisProp = xAxisXSupp->getXAxis();
xAxisProp->getPropertyValue("TextCanOverlap") >>= bTextCanOverlap;
// Expected value of 'TextCanOverlap' is true
CPPUNIT_ASSERT(bTextCanOverlap);
}
*/
void Chart2ImportTest::testNumberFormatsXLSX()
{
load("/chart2/qa/extras/data/xlsx/", "number-formats.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
CPPUNIT_ASSERT(xDataSeries.is());
uno::Reference<beans::XPropertySet> xPropertySet;
chart2::DataPointLabel aLabel;
sal_Int32 nNumberFormat;
bool bLinkNumberFormatToSource = false;
const sal_Int32 nChartDataNumberFormat = getNumberFormat(
xChartDoc, "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"??_);_(@_)");
xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_QUERY_THROW);
xPropertySet->getPropertyValue("Label") >>= aLabel;
CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber);
CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat);
bool bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
CPPUNIT_ASSERT_EQUAL(false, bSuccess);
bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource);
xPropertySet.set(xDataSeries->getDataPointByIndex(1), uno::UNO_QUERY_THROW);
xPropertySet->getPropertyValue("Label") >>= aLabel;
CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber);
CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumberInPercent);
xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat);
bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
CPPUNIT_ASSERT_EQUAL(false, bSuccess);
bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource);
xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_QUERY_THROW);
xPropertySet->getPropertyValue("Label") >>= aLabel;
CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumber);
CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat);
bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
CPPUNIT_ASSERT_EQUAL(false, bSuccess);
bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource);
}
void Chart2ImportTest::testAutoTitleDelDefaultValue2007XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "autotitledel_2007.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW);
OUString aTitle = getTitleString(xTitled);
CPPUNIT_ASSERT_MESSAGE("autoTitleDel default value is false in MSO 2007 documents",
!aTitle.isEmpty());
}
void Chart2ImportTest::testAutoTitleDelDefaultValue2013XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "autotitledel_2013.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW);
uno::Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
CPPUNIT_ASSERT_MESSAGE("autoTitleDel default value is true in the OOXML spec",
!xTitle.is());
}
void Chart2ImportTest::testDispBlanksAsDefaultValue2007XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "dispBlanksAs_2007.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
Reference<beans::XPropertySet> xDiagram(xChartDoc->getFirstDiagram(), UNO_QUERY);
CPPUNIT_ASSERT(xDiagram.is());
uno::Any aAny = xDiagram->getPropertyValue("MissingValueTreatment");
sal_Int32 nMissingValueTreatment = -2;
CPPUNIT_ASSERT(aAny >>= nMissingValueTreatment);
CPPUNIT_ASSERT_EQUAL(chart::MissingValueTreatment::LEAVE_GAP, nMissingValueTreatment);
}
void Chart2ImportTest::testDispBlanksAsDefaultValue2013XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "dispBlanksAs_2013.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
Reference<beans::XPropertySet> xDiagram(xChartDoc->getFirstDiagram(), UNO_QUERY);
CPPUNIT_ASSERT(xDiagram.is());
uno::Any aAny = xDiagram->getPropertyValue("MissingValueTreatment");
sal_Int32 nMissingValueTreatment = -2;
CPPUNIT_ASSERT(aAny >>= nMissingValueTreatment);
CPPUNIT_ASSERT_EQUAL(chart::MissingValueTreatment::USE_ZERO, nMissingValueTreatment);
}
void Chart2ImportTest::testSmoothDefaultValue2007XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "smoothed_series2007.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
CPPUNIT_ASSERT(xChartDoc.is());
Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, 0 );
CPPUNIT_ASSERT(xChartType.is());
Reference< beans::XPropertySet > xPropSet( xChartType, UNO_QUERY );
CPPUNIT_ASSERT(xPropSet.is());
chart2::CurveStyle eCurveStyle;
xPropSet->getPropertyValue("CurveStyle") >>= eCurveStyle;
CPPUNIT_ASSERT_EQUAL(eCurveStyle, chart2::CurveStyle_LINES);
}
void Chart2ImportTest::testSmoothDefaultValue2013XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "smoothed_series.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
CPPUNIT_ASSERT(xChartDoc.is());
Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, 0 );
CPPUNIT_ASSERT(xChartType.is());
Reference< beans::XPropertySet > xPropSet( xChartType, UNO_QUERY );
CPPUNIT_ASSERT(xPropSet.is());
chart2::CurveStyle eCurveStyle;
xPropSet->getPropertyValue("CurveStyle") >>= eCurveStyle;
CPPUNIT_ASSERT(eCurveStyle != chart2::CurveStyle_LINES);
}
void Chart2ImportTest::testTrendlineDefaultValue2007XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "trendline2007.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
CPPUNIT_ASSERT(xDataSeries.is());
Reference<chart2::XRegressionCurveContainer> xRegressionCurveContainer(xDataSeries, UNO_QUERY_THROW);
Sequence< Reference<chart2::XRegressionCurve> > xRegressionCurveSequence = xRegressionCurveContainer->getRegressionCurves();
CPPUNIT_ASSERT_EQUAL((sal_Int32) 1, xRegressionCurveSequence.getLength());
Reference<chart2::XRegressionCurve> xCurve = xRegressionCurveSequence[0];
Reference<beans::XPropertySet> xPropSet(xCurve->getEquationProperties(), uno::UNO_QUERY_THROW);
uno::Any aAny = xPropSet->getPropertyValue("ShowEquation");
bool bShowEquation = true;
CPPUNIT_ASSERT(aAny >>= bShowEquation);
CPPUNIT_ASSERT(!bShowEquation);
aAny = xPropSet->getPropertyValue("ShowCorrelationCoefficient");
bool bShowCorrelation = true;
CPPUNIT_ASSERT(aAny >>= bShowCorrelation);
CPPUNIT_ASSERT(!bShowCorrelation);
}
void Chart2ImportTest::testTrendlineDefaultValue2013XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "trendline.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
CPPUNIT_ASSERT(xDataSeries.is());
Reference<chart2::XRegressionCurveContainer> xRegressionCurveContainer(xDataSeries, UNO_QUERY_THROW);
Sequence< Reference<chart2::XRegressionCurve> > xRegressionCurveSequence = xRegressionCurveContainer->getRegressionCurves();
CPPUNIT_ASSERT_EQUAL((sal_Int32) 1, xRegressionCurveSequence.getLength());
Reference<chart2::XRegressionCurve> xCurve = xRegressionCurveSequence[0];
Reference<beans::XPropertySet> xPropSet(xCurve->getEquationProperties(), uno::UNO_QUERY_THROW);
uno::Any aAny = xPropSet->getPropertyValue("ShowEquation");
bool bShowEquation = false;
CPPUNIT_ASSERT(aAny >>= bShowEquation);
CPPUNIT_ASSERT(bShowEquation);
aAny = xPropSet->getPropertyValue("ShowCorrelationCoefficient");
bool bShowCorrelation = false;
CPPUNIT_ASSERT(aAny >>= bShowCorrelation);
CPPUNIT_ASSERT(bShowCorrelation);
}
void Chart2ImportTest::testVaryColorDefaultValues2007XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "vary_color2007.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
CPPUNIT_ASSERT(xDataSeries.is());
Reference<beans::XPropertySet> xPropSet(xDataSeries, uno::UNO_QUERY_THROW);
uno::Any aAny = xPropSet->getPropertyValue("VaryColorsByPoint");
bool bVaryColor = true;
CPPUNIT_ASSERT(aAny >>= bVaryColor);
CPPUNIT_ASSERT(!bVaryColor);
}
void Chart2ImportTest::testVaryColorDefaultValues2013XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "vary_color.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
CPPUNIT_ASSERT(xDataSeries.is());
Reference<beans::XPropertySet> xPropSet(xDataSeries, uno::UNO_QUERY_THROW);
uno::Any aAny = xPropSet->getPropertyValue("VaryColorsByPoint");
bool bVaryColor = false;
CPPUNIT_ASSERT(aAny >>= bVaryColor);
CPPUNIT_ASSERT(bVaryColor);
}
void Chart2ImportTest::testPlotVisOnlyDefaultValue2013XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "plotVisOnly.xlsx");
uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChart1Doc.is());
Reference<beans::XPropertySet> xPropSet(xChart1Doc->getDiagram(), uno::UNO_QUERY_THROW);
uno::Any aAny = xPropSet->getPropertyValue("IncludeHiddenCells");
CPPUNIT_ASSERT(aAny.hasValue());
bool bShowHiddenValues = true;
CPPUNIT_ASSERT(aAny >>= bShowHiddenValues);
CPPUNIT_ASSERT(!bShowHiddenValues);
}
void Chart2ImportTest::testRAngAxDefaultValue2013XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "rAngAx.xlsx");
uno::Reference< chart::XChartDocument > xChart1Doc ( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChart1Doc.is());
Reference<beans::XPropertySet> xPropSet(xChart1Doc->getDiagram(), uno::UNO_QUERY_THROW);
uno::Any aAny = xPropSet->getPropertyValue("RightAngledAxes");
CPPUNIT_ASSERT(aAny.hasValue());
bool bRightAngleAxes = false;
CPPUNIT_ASSERT(aAny >>= bRightAngleAxes);
CPPUNIT_ASSERT(bRightAngleAxes);
}
void Chart2ImportTest::testMajorTickMarksDefaultValue2013XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "majorTickMark.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
Reference<chart2::XAxis> xXAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
CPPUNIT_ASSERT(xXAxis.is());
Reference<beans::XPropertySet> xPropSet(xXAxis, uno::UNO_QUERY_THROW);
uno::Any aAny = xPropSet->getPropertyValue("MajorTickmarks");
sal_Int32 nMajorTickmarks = chart2::TickmarkStyle::NONE;
CPPUNIT_ASSERT(aAny.hasValue());
CPPUNIT_ASSERT(aAny >>= nMajorTickmarks);
CPPUNIT_ASSERT_EQUAL(chart2::TickmarkStyle::INNER | chart2::TickmarkStyle::OUTER, nMajorTickmarks);
}
void Chart2ImportTest::testMinorTickMarksDefaultValue2013XLSX()
{
load("/chart2/qa/extras/data/xlsx/", "minorTickMark.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
Reference<chart2::XAxis> xXAxis = getAxisFromDoc(xChartDoc, 0, 0, 0);
CPPUNIT_ASSERT(xXAxis.is());
Reference<beans::XPropertySet> xPropSet(xXAxis, uno::UNO_QUERY_THROW);
uno::Any aAny = xPropSet->getPropertyValue("MinorTickmarks");
sal_Int32 nMajorTickmarks = chart2::TickmarkStyle::NONE;
CPPUNIT_ASSERT(aAny.hasValue());
CPPUNIT_ASSERT(aAny >>= nMajorTickmarks);
CPPUNIT_ASSERT_EQUAL(chart2::TickmarkStyle::INNER | chart2::TickmarkStyle::OUTER, nMajorTickmarks);
}
void Chart2ImportTest::testAxisTitleDefaultRotationXLSX()
{
load("/chart2/qa/extras/data/xlsx/", "axis_title_default_rotation.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
CPPUNIT_ASSERT(xYAxis.is());
Reference<chart2::XTitled> xTitled(xYAxis, uno::UNO_QUERY_THROW);
Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
CPPUNIT_ASSERT(xTitle.is());
Reference<beans::XPropertySet> xPropSet(xTitle, uno::UNO_QUERY_THROW);
uno::Any aAny = xPropSet->getPropertyValue("TextRotation");
double nRotation = 0;
CPPUNIT_ASSERT(aAny >>= nRotation);
CPPUNIT_ASSERT_EQUAL(90.0, nRotation);
}
void Chart2ImportTest::testSecondaryAxisTitleDefaultRotationXLSX()
{
load("/chart2/qa/extras/data/xlsx/", "secondary_axis_title_default_rotation.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 1);
CPPUNIT_ASSERT(xYAxis.is());
Reference<chart2::XTitled> xTitled(xYAxis, uno::UNO_QUERY_THROW);
Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
CPPUNIT_ASSERT(xTitle.is());
Reference<beans::XPropertySet> xPropSet(xTitle, uno::UNO_QUERY_THROW);
uno::Any aAny = xPropSet->getPropertyValue("TextRotation");
double nRotation = 0;
CPPUNIT_ASSERT(aAny >>= nRotation);
CPPUNIT_ASSERT_EQUAL(90.0, nRotation);
}
void Chart2ImportTest::testAxisTitleRotationXLSX()
{
load("/chart2/qa/extras/data/xlsx/", "axis_title_rotated.xlsx");
Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
{
Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
CPPUNIT_ASSERT(xYAxis.is());
Reference<chart2::XTitled> xTitled(xYAxis, uno::UNO_QUERY_THROW);
Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
CPPUNIT_ASSERT(xTitle.is());
Reference<beans::XPropertySet> xPropSet(xTitle, uno::UNO_QUERY_THROW);
uno::Any aAny = xPropSet->getPropertyValue("TextRotation");
double nRotation = 0;
CPPUNIT_ASSERT(aAny >>= nRotation);
CPPUNIT_ASSERT_EQUAL(340.0, nRotation);
}
{
Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 1);
CPPUNIT_ASSERT(xYAxis.is());
Reference<chart2::XTitled> xTitled(xYAxis, uno::UNO_QUERY_THROW);
Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
CPPUNIT_ASSERT(xTitle.is());
Reference<beans::XPropertySet> xPropSet(xTitle, uno::UNO_QUERY_THROW);
uno::Any aAny = xPropSet->getPropertyValue("TextRotation");
double nRotation = 0;
CPPUNIT_ASSERT(aAny >>= nRotation);
CPPUNIT_ASSERT_EQUAL(270.0, nRotation);
}
}
void Chart2ImportTest::testInternalDataProvider() {
uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromImpress("/chart2/qa/extras/data/odp/", "chart.odp"), uno::UNO_QUERY_THROW);
const uno::Reference< chart2::data::XDataProvider >& rxDataProvider = xChartDoc->getDataProvider();
// Parse 42 array
Reference<chart2::data::XDataSequence> xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;42;42;42}");
Sequence<Any> xSequence = xDataSeq->getData();
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[0]);
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[1]);
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[2]);
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[3]);
// Parse empty first and last
xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{\"\";42;42;\"\"}");
xSequence = xDataSeq->getData();
CPPUNIT_ASSERT( rtl::math::isNan( *static_cast<const double*>(xSequence[0].getValue())));
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[1]);
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[2]);
CPPUNIT_ASSERT( rtl::math::isNan( *static_cast<const double*>(xSequence[3].getValue())));
// Parse empty middle
xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"\";\"\";42}");
xSequence = xDataSeq->getData();
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[0]);
CPPUNIT_ASSERT( rtl::math::isNan( *static_cast<const double*>(xSequence[1].getValue())) );
CPPUNIT_ASSERT( rtl::math::isNan( *static_cast<const double*>(xSequence[2].getValue())) );
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[3]);
// Parse mixed types, numeric only role
xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"hello\";0;\"world\"}");
xSequence = xDataSeq->getData();
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[0]);
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[1]);
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[2]);
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[3]);
// Parse mixed types, mixed role
xDataSeq = rxDataProvider->createDataSequenceByValueArray("categories", "{42;\"hello\";0;\"world\"}");
xSequence = xDataSeq->getData();
CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("42")), xSequence[0]);
CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("hello")), xSequence[1]);
CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("0")), xSequence[2]);
CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("world")), xSequence[3]);
}
void Chart2ImportTest::testTdf90510()
{
load("/chart2/qa/extras/data/xls/", "piechart_outside.xls");
uno::Reference< chart::XChartDocument > xChart1Doc( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW );
CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart1Doc.is() );
Reference<beans::XPropertySet> xPropSet( xChart1Doc->getDiagram()->getDataPointProperties( 0, 0 ), uno::UNO_QUERY_THROW );
uno::Any aAny = xPropSet->getPropertyValue( "LabelPlacement" );
CPPUNIT_ASSERT( aAny.hasValue() );
sal_Int32 nLabelPlacement = 0;
CPPUNIT_ASSERT( aAny >>= nLabelPlacement );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data labels should be placed outside", chart::DataLabelPlacement::OUTSIDE, nLabelPlacement );
}
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|