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
|
/* -*- 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 <sal/config.h>
#include <test/bootstrapfixture.hxx>
#include <test/xmltesttools.hxx>
#include <comphelper/seqstream.hxx>
#include <com/sun/star/graphic/SvgTools.hpp>
#include <com/sun/star/graphic/XPrimitive2D.hpp>
#include <drawinglayer/primitive2d/Tools.hxx>
#include <drawinglayer/tools/primitive2dxmldump.hxx>
#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
#include <memory>
#include <string_view>
namespace
{
using namespace css;
using namespace css::uno;
using namespace css::io;
using namespace css::graphic;
using drawinglayer::primitive2d::Primitive2DSequence;
using drawinglayer::primitive2d::Primitive2DContainer;
using drawinglayer::primitive2d::Primitive2DReference;
class Test : public test::BootstrapFixture, public XmlTestTools
{
void checkRectPrimitive(Primitive2DSequence const & rPrimitive);
void testStyles();
void testSymbol();
void testTdf87309();
void testFontsizeKeywords();
void testFontsizePercentage();
void testFontsizeRelative();
void testMarkerOrient();
void testMarkerInCssStyle();
void testTextXmlSpace();
void testTdf45771();
void testTdf97941();
void testTdf104339();
void testTdf85770();
void testTdf79163();
void testTdf97542_1();
void testTdf97542_2();
void testTdf97543();
void testRGBColor();
void testRGBAColor();
void testNoneColor();
void testTdf97936();
void testTdf149893();
void testShapeWithClipPathAndCssStyle();
void testClipPathAndParentStyle();
void testClipPathAndStyle();
void testClipPathUsingClipPath();
void testClipRule();
void testi125329();
void testMaskingPath07b();
void test123926();
void test47446();
void test47446b();
void testTdf103888();
void testMaskText();
void testTdf99994();
void testTdf99115();
void testTdf101237();
void testTdf94765();
void testBehaviourWhenWidthAndHeightIsOrIsNotSet();
void testTdf97663();
void testTdf149880();
void testCssClassRedefinition();
void testTspanFillOpacity();
Primitive2DSequence parseSvg(std::u16string_view aSource);
public:
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testStyles);
CPPUNIT_TEST(testSymbol);
CPPUNIT_TEST(testTdf87309);
CPPUNIT_TEST(testFontsizeKeywords);
CPPUNIT_TEST(testFontsizePercentage);
CPPUNIT_TEST(testFontsizeRelative);
CPPUNIT_TEST(testMarkerOrient);
CPPUNIT_TEST(testMarkerInCssStyle);
CPPUNIT_TEST(testTextXmlSpace);
CPPUNIT_TEST(testTdf45771);
CPPUNIT_TEST(testTdf97941);
CPPUNIT_TEST(testTdf104339);
CPPUNIT_TEST(testTdf85770);
CPPUNIT_TEST(testTdf79163);
CPPUNIT_TEST(testTdf97542_1);
CPPUNIT_TEST(testTdf97542_2);
CPPUNIT_TEST(testTdf97543);
CPPUNIT_TEST(testRGBColor);
CPPUNIT_TEST(testRGBAColor);
CPPUNIT_TEST(testNoneColor);
CPPUNIT_TEST(testTdf97936);
CPPUNIT_TEST(testTdf149893);
CPPUNIT_TEST(testShapeWithClipPathAndCssStyle);
CPPUNIT_TEST(testClipPathAndParentStyle);
CPPUNIT_TEST(testClipPathAndStyle);
CPPUNIT_TEST(testClipPathUsingClipPath);
CPPUNIT_TEST(testClipRule);
CPPUNIT_TEST(testi125329);
CPPUNIT_TEST(testMaskingPath07b);
CPPUNIT_TEST(test123926);
CPPUNIT_TEST(test47446);
CPPUNIT_TEST(test47446b);
CPPUNIT_TEST(testTdf103888);
CPPUNIT_TEST(testMaskText);
CPPUNIT_TEST(testTdf99994);
CPPUNIT_TEST(testTdf99115);
CPPUNIT_TEST(testTdf101237);
CPPUNIT_TEST(testTdf94765);
CPPUNIT_TEST(testBehaviourWhenWidthAndHeightIsOrIsNotSet);
CPPUNIT_TEST(testTdf97663);
CPPUNIT_TEST(testTdf149880);
CPPUNIT_TEST(testCssClassRedefinition);
CPPUNIT_TEST(testTspanFillOpacity);
CPPUNIT_TEST_SUITE_END();
};
Primitive2DSequence Test::parseSvg(std::u16string_view aSource)
{
const Reference<XSvgParser> xSvgParser = SvgTools::create(m_xContext);
OUString aUrl = m_directories.getURLFromSrc(aSource);
OUString aPath = m_directories.getPathFromSrc(aSource);
SvFileStream aFileStream(aUrl, StreamMode::READ);
std::size_t nSize = aFileStream.remainingSize();
std::unique_ptr<sal_Int8[]> pBuffer(new sal_Int8[nSize + 1]);
aFileStream.ReadBytes(pBuffer.get(), nSize);
pBuffer[nSize] = 0;
Sequence<sal_Int8> aData(pBuffer.get(), nSize + 1);
Reference<XInputStream> aInputStream(new comphelper::SequenceInputStream(aData));
return xSvgParser->getDecomposition(aInputStream, aPath);
}
void Test::checkRectPrimitive(Primitive2DSequence const & rPrimitive)
{
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(rPrimitive));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#00cc00"); // rect background color
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "height", "100"); // rect background height
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "width", "100"); // rect background width
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "minx", "10");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "miny", "10");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxx", "110");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxy", "110");
assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#ff0000"); // rect stroke color
assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "3"); // rect stroke width
}
bool arePrimitive2DSequencesEqual(const Primitive2DSequence& rA, const Primitive2DSequence& rB)
{
return std::equal(rA.begin(), rA.end(), rB.begin(), rB.end(),
[](const css::uno::Reference<css::graphic::XPrimitive2D>& a,
const css::uno::Reference<css::graphic::XPrimitive2D>& b)
{
return drawinglayer::primitive2d::arePrimitive2DReferencesEqual(a, b);
});
}
// Attributes for an object (like rect as in this case) can be defined
// in different ways (directly with xml attributes, or with CSS styles),
// however the end result should be the same.
void Test::testStyles()
{
Primitive2DSequence aSequenceRect = parseSvg(u"/svgio/qa/cppunit/data/Rect.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceRect.getLength()));
checkRectPrimitive(aSequenceRect);
Primitive2DSequence aSequenceRectWithStyle = parseSvg(u"/svgio/qa/cppunit/data/RectWithStyles.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceRectWithStyle.getLength()));
checkRectPrimitive(aSequenceRectWithStyle);
Primitive2DSequence aSequenceRectWithParentStyle = parseSvg(u"/svgio/qa/cppunit/data/RectWithParentStyles.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceRectWithParentStyle.getLength()));
checkRectPrimitive(aSequenceRectWithParentStyle);
Primitive2DSequence aSequenceRectWithStylesByGroup = parseSvg(u"/svgio/qa/cppunit/data/RectWithStylesByGroup.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceRectWithStylesByGroup.getLength()));
checkRectPrimitive(aSequenceRectWithStylesByGroup);
CPPUNIT_ASSERT(arePrimitive2DSequencesEqual(aSequenceRect, aSequenceRectWithStyle));
CPPUNIT_ASSERT(arePrimitive2DSequencesEqual(aSequenceRect, aSequenceRectWithParentStyle));
CPPUNIT_ASSERT(arePrimitive2DSequencesEqual(aSequenceRect, aSequenceRectWithStylesByGroup));
}
void Test::testSymbol()
{
Primitive2DSequence aSequenceTdf87309 = parseSvg(u"/svgio/qa/cppunit/data/symbol.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf87309.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf87309);
CPPUNIT_ASSERT (pDocument);
// tdf#126330: Without the fix in place, this test would have failed with
// - Expected: 1
// - Actual : 2
// number of nodes is incorrect
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#00d000");
}
void Test::testTdf87309()
{
Primitive2DSequence aSequenceTdf87309 = parseSvg(u"/svgio/qa/cppunit/data/tdf87309.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf87309.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf87309);
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#000000");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "height", "100");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "width", "100");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "minx", "10");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "miny", "10");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxx", "110");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxy", "110");
}
void Test::testFontsizeKeywords()
{
Primitive2DSequence aSequenceFontsizeKeywords = parseSvg(u"/svgio/qa/cppunit/data/FontsizeKeywords.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceFontsizeKeywords.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceFontsizeKeywords);
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#000000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "9");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Times New Roman");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "fontcolor", "#ffffff");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "11");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "familyname", "Times New Roman");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "fontcolor", "#ffd700");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "height", "13");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "familyname", "Times New Roman");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "fontcolor", "#ff0000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "height", "16");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "familyname", "Times New Roman");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "fontcolor", "#ffff00");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "height", "19");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "familyname", "Times New Roman");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "fontcolor", "#0000ff");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "height", "23");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "familyname", "Times New Roman");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "fontcolor", "#008000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "height", "27");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "familyname", "Times New Roman");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "fontcolor", "#ff7f50");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "height", "13");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "familyname", "Times New Roman");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "fontcolor", "#ffc0cb");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "height", "19");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "familyname", "Times New Roman");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[10]", "fontcolor", "#fffff0");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[10]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[10]", "height", "16");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "familyname", "Times New Roman");
}
void Test::testFontsizePercentage()
{
//Check when font-size uses percentage and defined globally
Primitive2DSequence aSequenceFontsizePercentage = parseSvg(u"/svgio/qa/cppunit/data/FontsizePercentage.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceFontsizePercentage.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceFontsizePercentage);
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#000000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "16");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Times New Roman");
}
void Test::testFontsizeRelative()
{
//Check when font-size uses relative units (em,ex) and it's based on its parent's font-size
Primitive2DSequence aSequenceFontsizeRelative = parseSvg(u"/svgio/qa/cppunit/data/FontsizeRelative.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceFontsizeRelative.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceFontsizeRelative);
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#000000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "50");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "serif");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "fontcolor", "#000000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "50");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "familyname", "serif");
}
void Test::testMarkerOrient()
{
Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/MarkerOrient.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy11", "0");
assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy12", "0");
assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy13", "7");
assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy21", "0");
assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy22", "0");
assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy23", "13");
assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy31", "0");
assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy32", "0");
assertXPath(pDocument, "/primitive2D/transform/transform[1]", "xy33", "1");
assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy11", "0");
assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy12", "0");
assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy13", "87");
assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy21", "0");
assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy22", "0");
assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy23", "87");
assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy31", "0");
assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy32", "0");
assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy33", "1");
}
void Test::testMarkerInCssStyle()
{
Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/markerInCssStyle.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
CPPUNIT_ASSERT (pDocument);
// Without the fix in place, this test would have failed with
// - Expected: 20
// - Actual : 0
assertXPath(pDocument, "/primitive2D/transform/transform/polypolygonstroke/line", 20);
assertXPath(pDocument, "/primitive2D/transform/transform[1]/polypolygonstroke/line", "color", "#008000");
assertXPath(pDocument, "/primitive2D/transform/transform[1]/polypolygonstroke/line", "width", "1");
assertXPath(pDocument, "/primitive2D/transform/transform[1]/polypolygonstroke/line", "linejoin", "Miter");
assertXPath(pDocument, "/primitive2D/transform/transform[1]/polypolygonstroke/line", "miterangle", "28");
assertXPath(pDocument, "/primitive2D/transform/transform[1]/polypolygonstroke/line", "linecap", "BUTT");
}
void Test::testTextXmlSpace()
{
//Check tspan fontsize when using relative units
Primitive2DSequence aSequenceTdf97941 = parseSvg(u"/svgio/qa/cppunit/data/textXmlSpace.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf97941.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf97941);
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[1]", "text", "a b");
assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[2]", "text", "a b");
assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[3]", "text", "a b");
assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[4]", "text", "ab");
assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[5]", "text", " a b ");
assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[6]", "text", "a b");
assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[7]", "text", "a b");
assertXPath(pDocument, "/primitive2D/transform/mask/textsimpleportion[8]", "text", "a b");
}
void Test::testTdf45771()
{
//Check text fontsize when using relative units
Primitive2DSequence aSequenceTdf45771 = parseSvg(u"/svgio/qa/cppunit/data/tdf45771.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf45771.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf45771);
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#000000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "32");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Times New Roman");
}
void Test::testTdf97941()
{
//Check tspan fontsize when using relative units
Primitive2DSequence aSequenceTdf97941 = parseSvg(u"/svgio/qa/cppunit/data/tdf97941.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf97941.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf97941);
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#000000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "Sample");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "48");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Times New Roman");
}
void Test::testTdf104339()
{
Primitive2DSequence aSequenceTdf104339 = parseSvg(u"/svgio/qa/cppunit/data/tdf104339.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf104339.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf104339);
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/transform/transform/transform/transform/polypolygoncolor", "color", "#000000");
}
void Test::testTdf85770()
{
Primitive2DSequence aSequenceTdf85770 = parseSvg(u"/svgio/qa/cppunit/data/tdf85770.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf85770.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf85770));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#000000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "Start Middle End");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "11");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Times New Roman");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "fontcolor", "#000000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "Start");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "11");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "familyname", "Times New Roman");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "fontcolor", "#000000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", "End");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "height", "11");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "familyname", "Times New Roman");
}
void Test::testTdf79163()
{
//Check Opacity
Primitive2DSequence aSequenceTdf79163 = parseSvg(u"/svgio/qa/cppunit/data/tdf79163.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf79163.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf79163));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/unifiedtransparence", "transparence", "50");
}
void Test::testTdf97542_1()
{
Primitive2DSequence aSequenceTdf97542_1 = parseSvg(u"/svgio/qa/cppunit/data/tdf97542_1.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf97542_1.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97542_1));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/objectinfo/textsimpleportion", "fontcolor", "#ffff00");
assertXPath(pDocument, "/primitive2D/transform/objectinfo/textsimpleportion", "text", "Text");
assertXPath(pDocument, "/primitive2D/transform/objectinfo/textsimpleportion", "height", "48");
assertXPath(pDocument, "/primitive2D/transform/objectinfo/textsimpleportion", "familyname", "serif");
}
void Test::testTdf97542_2()
{
Primitive2DSequence aSequenceTdf97542_2 = parseSvg(u"/svgio/qa/cppunit/data/tdf97542_2.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf97542_2.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97542_2));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient", "startx", "1");
assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient", "starty", "1");
assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient/focalx", 0);
assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient/focaly", 0);
assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient", "radius", "3");
assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient", "spreadmethod", "pad");
assertXPath(pDocument, "/primitive2D/transform/objectinfo/svgradialgradient", "opacity", "1");
}
void Test::testTdf97543()
{
// check visibility="inherit"
Primitive2DSequence aSequenceTdf97543 = parseSvg(u"/svgio/qa/cppunit/data/tdf97543.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf97543.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97543));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#00cc00");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "height", "100");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "width", "100");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "minx", "10");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "miny", "10");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxx", "110");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxy", "110");
}
void Test::testRGBColor()
{
Primitive2DSequence aSequenceRGBColor = parseSvg(u"/svgio/qa/cppunit/data/RGBColor.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceRGBColor.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceRGBColor));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#646464");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "height", "100");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "width", "100");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "minx", "10");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "miny", "10");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxx", "110");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor/polypolygon", "maxy", "110");
}
void Test::testRGBAColor()
{
Primitive2DSequence aSequenceRGBAColor = parseSvg(u"/svgio/qa/cppunit/data/RGBAColor.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceRGBAColor.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceRGBAColor));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/unifiedtransparence", "transparence", "50");
}
void Test::testNoneColor()
{
Primitive2DSequence aSequenceRGBAColor = parseSvg(u"/svgio/qa/cppunit/data/noneColor.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceRGBAColor.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceRGBAColor));
CPPUNIT_ASSERT (pDocument);
//No polypolygoncolor exists
assertXPath(pDocument, "/primitive2D/transform/mask/polypolygoncolor", 0);
assertXPath(pDocument, "/primitive2D/transform/mask/polypolygonstroke/line", "color", "#000000");
assertXPath(pDocument, "/primitive2D/transform/mask/polypolygonstroke/line", "width", "3");
}
void Test::testTdf97936()
{
// check that both rectangles are rendered in the viewBox
Primitive2DSequence aSequenceTdf97936 = parseSvg(u"/svgio/qa/cppunit/data/tdf97936.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf97936.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97936));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "height", "50");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "width", "50");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "minx", "70");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "miny", "50");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "maxx", "120");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]/polypolygon", "maxy", "100");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "height", "50");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "width", "50");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "minx", "10");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "miny", "50");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "maxx", "60");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]/polypolygon", "maxy", "100");
}
void Test::testTdf149893()
{
Primitive2DSequence aSequenceClipPathAndParentStyle = parseSvg(u"/svgio/qa/cppunit/data/tdf149893.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceClipPathAndParentStyle.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndParentStyle));
CPPUNIT_ASSERT (pDocument);
// Without the fix in place, this test would have failed with
// - Expected: #008000
// - Actual : #000000
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#008000");
}
void Test::testShapeWithClipPathAndCssStyle()
{
// tdf#97539: Check there is a mask and 3 polygons
Primitive2DSequence aSequenceClipPathAndStyle = parseSvg(u"/svgio/qa/cppunit/data/ShapeWithClipPathAndCssStyle.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceClipPathAndStyle.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndStyle));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/mask/polypolygon/polygon", 2);
assertXPath(pDocument, "/primitive2D/transform/mask/polypolygoncolor/polypolygon/polygon", 1);
}
void Test::testClipPathAndParentStyle()
{
//Check that fill color, stroke color and stroke-width are inherited from use element
//when the element is within a clipPath element
Primitive2DSequence aSequenceClipPathAndParentStyle = parseSvg(u"/svgio/qa/cppunit/data/ClipPathAndParentStyle.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceClipPathAndParentStyle.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndParentStyle));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#ff0000");
assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#000000");
assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "5");
}
void Test::testClipPathAndStyle()
{
//Check that fill color, stroke color and stroke-width are inherited from use element
//when the element is within a clipPath element
Primitive2DSequence aSequenceClipPathAndStyle = parseSvg(u"/svgio/qa/cppunit/data/ClipPathAndStyle.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceClipPathAndStyle.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndStyle));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#ccccff");
assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#0000cc");
assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "2");
}
void Test::testClipPathUsingClipPath()
{
Primitive2DSequence aSequenceClipPathAndStyle = parseSvg(u"/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceClipPathAndStyle.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndStyle));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/mask/polypolygon/polygon/point", 20);
assertXPath(pDocument, "/primitive2D/transform/mask/mask/polypolygon/polygon/point", 13);
}
void Test::testClipRule()
{
Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/ClipRule.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence));
CPPUNIT_ASSERT (pDocument);
// Without the place in place, this test would have failed with
// - Expected: 5
// - Actual : 10
assertXPath(pDocument, "/primitive2D/transform/mask[1]/polypolygon/polygon/point", 5);
assertXPath(pDocument, "/primitive2D/transform/mask[1]/polypolygoncolor", "color", "#0000ff");
assertXPath(pDocument, "/primitive2D/transform/mask[1]/polypolygoncolor/polypolygon/polygon/point", 5);
assertXPath(pDocument, "/primitive2D/transform/mask[2]/polypolygon/polygon/point", 5);
assertXPath(pDocument, "/primitive2D/transform/mask[2]/polypolygoncolor", "color", "#ff0000");
assertXPath(pDocument, "/primitive2D/transform/mask[2]/polypolygoncolor/polypolygon/polygon/point", 5);
}
void Test::testi125329()
{
//Check style inherit from * css element
Primitive2DSequence aSequencei125329 = parseSvg(u"/svgio/qa/cppunit/data/i125329.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequencei125329.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequencei125329));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor", "color", "#c0c0c0"); // rect background color
assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "height", "30"); // rect background height
assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "width", "50"); // rect background width
assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "minx", "15");
assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "miny", "15");
assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "maxx", "65");
assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "maxy", "45");
assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygonstroke/line", "color", "#008000"); // rect stroke color
assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygonstroke/line", "width", "1"); // rect stroke width
}
void Test::testMaskingPath07b()
{
//For the time being, check that masking-path-07-b.svg can be imported and it doesn't hang on loading
//it used to hang after d5649ae7b76278cb3155f951d6327157c7c92b65
Primitive2DSequence aSequenceMaskingPath07b = parseSvg(u"/svgio/qa/cppunit/data/masking-path-07-b.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceMaskingPath07b.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceMaskingPath07b));
CPPUNIT_ASSERT (pDocument);
}
void Test::test123926()
{
Primitive2DSequence aSequence123926 = parseSvg(u"/svgio/qa/cppunit/data/tdf123926.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence123926.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence123926));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/transform/transform/unifiedtransparence/polypolygoncolor", "color", "#7cb5ec");
}
void Test::test47446()
{
//Check that marker's fill attribute is black is not set
Primitive2DSequence aSequence47446 = parseSvg(u"/svgio/qa/cppunit/data/47446.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence47446.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence47446));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/transform/transform/polypolygoncolor", "color", "#000000");
}
void Test::test47446b()
{
//Check that marker's fill attribute is inherit from def
Primitive2DSequence aSequence47446b = parseSvg(u"/svgio/qa/cppunit/data/47446b.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence47446b.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence47446b));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/transform/transform/polypolygoncolor", "color", "#ffff00");
}
void Test::testTdf103888()
{
Primitive2DSequence aSequenceMaskText = parseSvg(u"/svgio/qa/cppunit/data/tdf103888.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceMaskText.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceMaskText));
CPPUNIT_ASSERT (pDocument);
// Without the fix in place, this test would have failed here with number of nodes is incorrect
assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion[1]", "text", "Her");
assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion[2]", "text", "vor");
assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion[3]", "text", "hebung");
}
void Test::testMaskText()
{
//Check that mask is applied on text
Primitive2DSequence aSequenceMaskText = parseSvg(u"/svgio/qa/cppunit/data/maskText.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceMaskText.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceMaskText));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor", "color", "#000000");
assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion", "fontcolor", "#ffffff");
assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion", "text", "Black White");
assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion", "height", "26");
assertXPath(pDocument, "/primitive2D/transform/transform/textsimpleportion", "familyname", "Times New Roman");
}
void Test::testTdf99994()
{
//Check text fontsize when using relative units
Primitive2DSequence aSequenceTdf99994 = parseSvg(u"/svgio/qa/cppunit/data/tdf99994.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf99994.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf99994));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#0000ff");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "16");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "test");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Sans");
}
void Test::testTdf99115()
{
//Check that styles are resolved correctly where there is a * css selector
Primitive2DSequence aSequenceTdf99115 = parseSvg(u"/svgio/qa/cppunit/data/tdf99115.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf99115.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf99115) );
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "red 1");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#ff0000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "18");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "red 2");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "fontcolor", "#ff0000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "18");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", "red 3");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "fontcolor", "#ff0000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "height", "18");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "text", "blue 4");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "fontcolor", "#0000ff");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "height", "18");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "text", "blue 5");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "fontcolor", "#0000ff");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "height", "18");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "text", "blue 6");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "fontcolor", "#0000ff");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "height", "18");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "text", "green 7");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "fontcolor", "#008000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "height", "18");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "text", "green 8");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "fontcolor", "#008000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "height", "18");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "text", "green 9");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "fontcolor", "#008000");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "height", "18");
}
void Test::testTdf101237()
{
//Check that fill color, stroke color and stroke-width are inherited from use element
//when the element is within a clipPath element
Primitive2DSequence aSequenceTdf101237 = parseSvg(u"/svgio/qa/cppunit/data/tdf101237.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf101237.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf101237));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#ff0000");
assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#000000");
assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "5");
}
void Test::testTdf94765()
{
Primitive2DSequence aSequenceTdf94765 = parseSvg(u"/svgio/qa/cppunit/data/tdf94765.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf94765.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf94765));
CPPUNIT_ASSERT (pDocument);
//Check that both rectangles use the gradient as fill
assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[1]", "startx", "1");
assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[1]", "starty", "1");
assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[1]", "endx", "2");
assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[1]", "endy", "1");
assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[2]", "startx", "0");
assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[2]", "starty", "0");
assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[2]", "endx", "0");
assertXPath(pDocument, "/primitive2D/transform/transform/svglineargradient[2]", "endy", "0");
}
void Test::testBehaviourWhenWidthAndHeightIsOrIsNotSet()
{
// This test checks the behaviour when width and height attributes
// are and are not set. In both cases the result must be the same,
// however if the width / height are set, then the size of the image
// is enforced, but this isn't really possible in LibreOffice (or
// maybe we could lock the size in this case).
// The behaviour in browsers is that when a SVG image has width / height
// attributes set, then the image is shown with that size, but if it
// isn't set then it is shown as scalable image which is the size of
// the container.
{
const Primitive2DSequence aSequence = parseSvg(u"svgio/qa/cppunit/data/Drawing_WithWidthHeight.svg");
CPPUNIT_ASSERT(aSequence.hasElements());
geometry::RealRectangle2D aRealRect;
basegfx::B2DRange aRange;
uno::Sequence<beans::PropertyValue> aViewParameters;
for (css::uno::Reference<css::graphic::XPrimitive2D> const & xReference : aSequence)
{
if (xReference.is())
{
aRealRect = xReference->getRange(aViewParameters);
aRange.expand(basegfx::B2DRange(aRealRect.X1, aRealRect.Y1, aRealRect.X2, aRealRect.Y2));
}
}
double fWidth = (aRange.getWidth() / 2540.0) * 96.0;
double fHeight = (aRange.getHeight() / 2540.0) * 96.0;
CPPUNIT_ASSERT_DOUBLES_EQUAL(11.0, fWidth, 1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL(11.0, fHeight, 1E-12);
}
{
const Primitive2DSequence aSequence = parseSvg(u"svgio/qa/cppunit/data/Drawing_NoWidthHeight.svg");
CPPUNIT_ASSERT(aSequence.hasElements());
geometry::RealRectangle2D aRealRect;
basegfx::B2DRange aRange;
uno::Sequence<beans::PropertyValue> aViewParameters;
for (css::uno::Reference<css::graphic::XPrimitive2D> const & xReference : aSequence)
{
if (xReference.is())
{
aRealRect = xReference->getRange(aViewParameters);
aRange.expand(basegfx::B2DRange(aRealRect.X1, aRealRect.Y1, aRealRect.X2, aRealRect.Y2));
}
}
double fWidth = (aRange.getWidth() / 2540.0) * 96.0;
double fHeight = (aRange.getHeight() / 2540.0) * 96.0;
CPPUNIT_ASSERT_DOUBLES_EQUAL(11.0, fWidth, 1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL(11.0, fHeight, 1E-12);
}
}
void Test::testTdf97663()
{
Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/em_units.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence));
CPPUNIT_ASSERT (pDocument);
// tdf#97663: Without the fix in place, this test would have failed with
// - Expected: 236
// - Actual : 204
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", "236");
}
void Test::testTdf149880()
{
Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf149880.svg");
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence));
CPPUNIT_ASSERT (pDocument);
// Without the fix in place, this test would have failed with
// - Expected: 1
// - Actual : 0
// - In <>, XPath '/primitive2D/transform/mask/unhandled' number of nodes is incorrect
assertXPath(pDocument,
"/primitive2D/transform/mask/unhandled", "id", "PATTERNFILL");
assertXPath(pDocument,
"/primitive2D/transform/mask/unhandled/mask/transform/transform/bitmap", 28);
}
void Test::testCssClassRedefinition()
{
// Tests for svg css class redefinition behavior
// Example:
// .c1 {fill:#00ff00}
// .c1 {font-family:Sans}
// .c1 {fill:#ff0000}
// Expected result is .c1 {font-family:Sans; fill:#ff0000} because
// the second redefinition appends attributes to the class and the
// third redefinition replaces the already existing
// attribute in the original definition
Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/CssClassRedefinition.svg");
drawinglayer::Primitive2dXmlDump dumper;
xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence));
CPPUNIT_ASSERT (pDocument);
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "test");
assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#ff0000");
assertXPath(
pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Open Symbol");
}
void Test::testTspanFillOpacity()
{
// Given an SVG file with <tspan fill-opacity="0.30">:
std::u16string_view aPath = u"/svgio/qa/cppunit/data/tspan-fill-opacity.svg";
// When rendering that SVG:
Primitive2DSequence aSequence = parseSvg(aPath);
// Then make sure that the text portion is wrapped in a transparency primitive with the correct
// transparency value:
drawinglayer::Primitive2dXmlDump aDumper;
xmlDocUniquePtr pDocument = aDumper.dumpAndParse(Primitive2DContainer(aSequence));
sal_Int32 nTransparence = getXPath(pDocument, "//textsimpleportion[@text='hello']/parent::unifiedtransparence", "transparence").toInt32();
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1
// - Actual : 0
// - XPath '//textsimpleportion[@text='hello']/parent::unifiedtransparence' number of nodes is incorrect
// i.e. the relevant <textsimpleportion> had no <unifiedtransparence> parent, the text was not
// semi-transparent.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(70), nTransparence);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|