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
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
|
/* -*- 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 <test/unoapixml_test.hxx>
#include <com/sun/star/text/ControlCharacter.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
using namespace ::com::sun::star;
namespace
{
/// Covers ooox/source/export/ fixes.
class Test : public UnoApiXmlTest
{
public:
Test()
: UnoApiXmlTest("/oox/qa/unit/data/")
{
}
};
CPPUNIT_TEST_FIXTURE(Test, testPolylineConnectorPosition)
{
// Given a document with a group shape and therein a polyline and a connector.
loadFromFile(u"tdf141786_PolylineConnectorInGroup.odt");
// When saving that to DOCX:
save("Office Open XML Text");
// Then make sure polyline and connector have the correct position.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// For child elements of groups in Writer the position has to be adapted to be relative
// to group instead of being relative to anchor. That was missing for polyline and
// connector.
// Polyline: Without fix it would have failed with expected: 0, actual: 1800360
assertXPath(pXmlDoc, "//wpg:wgp/wps:wsp[1]/wps:spPr/a:xfrm/a:off"_ostr, "x"_ostr, "0");
// ... failed with expected: 509400, actual: 1229400
assertXPath(pXmlDoc, "//wpg:wgp/wps:wsp[1]/wps:spPr/a:xfrm/a:off"_ostr, "y"_ostr, "509400");
// Connector: Without fix it would have failed with expected: 763200, actual: 2563560
assertXPath(pXmlDoc, "//wpg:wgp/wps:wsp[3]/wps:spPr/a:xfrm/a:off"_ostr, "x"_ostr, "763200");
// ... failed with expected: 0, actual: 720000
assertXPath(pXmlDoc, "//wpg:wgp/wps:wsp[3]/wps:spPr/a:xfrm/a:off"_ostr, "y"_ostr, "0");
// Polyline and connector were shifted 1800360EMU right, 720000EMU down.
}
CPPUNIT_TEST_FIXTURE(Test, testRotatedShapePosition)
{
// Given a document with a group shape and therein a rotated custom shape.
loadFromFile(u"tdf141786_RotatedShapeInGroup.odt");
// FIXME: validation error in OOXML export: Errors: 3
skipValidation();
// When saving that to DOCX:
save("Office Open XML Text");
// Then make sure the rotated child shape has the correct position.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// For a group itself and for shapes outside of groups, the position calculation is done in
// DocxSdrExport. For child elements of groups it has to be done in
// DrawingML::WriteShapeTransformation(), but was missing.
// Without fix it would have failed with expected: 469440, actual: 92160
// The shape was about 1cm shifted up and partly outside its group.
assertXPath(pXmlDoc, "//wpg:wgp/wps:wsp[1]/wps:spPr/a:xfrm/a:off"_ostr, "y"_ostr, "469440");
}
CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControlOdt)
{
loadFromFile(u"tdf141786_RotatedShapeInGroup.odt");
dispatchCommand(mxComponent, ".uno:TrackChanges", {});
dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
save("Office Open XML Text");
// validate(maTempFile.GetFileName(), test::OOXML); // Enable when unrelated errors are fixed.
}
CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControlDocx)
{
{
loadFromFile(u"dml-groupshape-polygon.docx");
// Without TrackChanges, inserting the Checkbox works just fine
// when exporting to docx.
dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
save("Office Open XML Text");
// validate(maTempFile.GetFileName(), test::OOXML); // Enable when unrelated errors are fixed.
}
{
loadFromFile(u"dml-groupshape-polygon.docx");
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XText> xText = xTextDocument->getText();
uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor();
// With TrackChanges, the Checkbox causes an assertion in the sax serializer,
// in void sax_fastparser::FastSaxSerializer::endFastElement(sal_Int32).
// Element == maMarkStack.top()->m_DebugStartedElements.back()
// sax/source/tools/fastserializer.cxx#402
dispatchCommand(mxComponent, ".uno:TrackChanges", {});
xText->insertControlCharacter(xCursor, text::ControlCharacter::PARAGRAPH_BREAK, false);
dispatchCommand(mxComponent, ".uno:InsertCheckboxContentControl", {});
// Loading should not show the "corrupted" dialog, which would assert.
saveAndReload("Office Open XML Text");
// Now that we loaded it successfully, delete the controls,
// still with change-tracking enabled, and save.
dispatchCommand(mxComponent, ".uno:SelectAll", {});
dispatchCommand(mxComponent, ".uno:Delete", {});
// Loading should not show the "corrupted" dialog, which would assert.
saveAndReload("Office Open XML Text");
// validate(maTempFile.GetFileName(), test::OOXML); // Enable when unrelated errors are fixed.
}
}
CPPUNIT_TEST_FIXTURE(Test, testDmlGroupshapePolygon)
{
// Given a document with a group shape, containing a single polygon child shape:
loadFromFile(u"dml-groupshape-polygon.docx");
// FIXME: validation error in OOXML export: Errors: 9
skipValidation();
// When saving that to DOCX:
save("Office Open XML Text");
// Then make sure that the group shape, the group shape's child size and the child shape's size
// match:
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
assertXPath(pXmlDoc, "//wpg:grpSpPr/a:xfrm/a:ext"_ostr, "cx"_ostr, "5328360");
// Without the accompanying fix in place, this test would have failed, the <a:chExt> element was
// not written.
assertXPath(pXmlDoc, "//wpg:grpSpPr/a:xfrm/a:chExt"_ostr, "cx"_ostr, "5328360");
assertXPath(pXmlDoc, "//wps:spPr/a:xfrm/a:ext"_ostr, "cx"_ostr, "5328360");
}
CPPUNIT_TEST_FIXTURE(Test, testCustomShapeArrowExport)
{
// Given a document with a few different kinds of arrow shapes in it:
loadFromFile(u"tdf142602_CustomShapeArrows.odt");
// FIXME: validation error in OOXML export: Errors: 11
skipValidation();
// When saving that to DOCX:
save("Office Open XML Text");
// Then the shapes should retain their correct control values.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// Without the fix the output OOXML would have no <a:prstGeom> tags in it.
// Right arrow
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom"_ostr,
"prst"_ostr, "rightArrow");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]"_ostr,
"fmla"_ostr, "val 50000");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]"_ostr,
"fmla"_ostr, "val 46321");
// Left arrow
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom"_ostr,
"prst"_ostr, "leftArrow");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]"_ostr,
"fmla"_ostr, "val 50000");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]"_ostr,
"fmla"_ostr, "val 52939");
// Down arrow
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom"_ostr,
"prst"_ostr, "downArrow");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]"_ostr,
"fmla"_ostr, "val 50000");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]"_ostr,
"fmla"_ostr, "val 59399");
// Up arrow
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom"_ostr,
"prst"_ostr, "upArrow");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]"_ostr,
"fmla"_ostr, "val 50000");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]"_ostr,
"fmla"_ostr, "val 63885");
// Left-right arrow
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[5]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom"_ostr,
"prst"_ostr, "leftRightArrow");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[5]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]"_ostr,
"fmla"_ostr, "val 50000");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[5]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]"_ostr,
"fmla"_ostr, "val 53522");
// Up-down arrow
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[6]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom"_ostr,
"prst"_ostr, "upDownArrow");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[6]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]"_ostr,
"fmla"_ostr, "val 50000");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[6]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]"_ostr,
"fmla"_ostr, "val 62743");
// Right arrow callout
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[7]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom"_ostr,
"prst"_ostr, "rightArrowCallout");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[7]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]"_ostr,
"fmla"_ostr, "val 25002");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[7]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]"_ostr,
"fmla"_ostr, "val 25000");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[7]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[3]"_ostr,
"fmla"_ostr, "val 25052");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[7]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[4]"_ostr,
"fmla"_ostr, "val 66667");
// Left arrow callout
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[8]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom"_ostr,
"prst"_ostr, "leftArrowCallout");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[8]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]"_ostr,
"fmla"_ostr, "val 25002");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[8]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]"_ostr,
"fmla"_ostr, "val 25000");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[8]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[3]"_ostr,
"fmla"_ostr, "val 25057");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[8]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[4]"_ostr,
"fmla"_ostr, "val 66673");
// Down arrow callout
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[9]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom"_ostr,
"prst"_ostr, "downArrowCallout");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[9]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]"_ostr,
"fmla"_ostr, "val 29415");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[9]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]"_ostr,
"fmla"_ostr, "val 29413");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[9]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[3]"_ostr,
"fmla"_ostr, "val 16667");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[9]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[4]"_ostr,
"fmla"_ostr, "val 66667");
// Up arrow callout
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[10]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom"_ostr,
"prst"_ostr, "upArrowCallout");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[10]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]"_ostr,
"fmla"_ostr, "val 31033");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[10]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]"_ostr,
"fmla"_ostr, "val 31030");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[10]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[3]"_ostr,
"fmla"_ostr, "val 16667");
assertXPath(pXmlDoc,
"//w:r/mc:AlternateContent[10]/mc:Choice/w:drawing/wp:anchor/a:graphic/"
"a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[4]"_ostr,
"fmla"_ostr, "val 66660");
}
CPPUNIT_TEST_FIXTURE(Test, testCameraRevolutionGrabBag)
{
// Given a PPTX file that contains camera revolution (rotation around z axis) applied shapes
loadFromFile(u"camera-rotation-revolution-nonwps.pptx");
// When saving that document:
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// Then make sure the revolution is exported without a problem:
// First shape textbox:
assertXPath(pXmlDoc, "//p:sp[1]/p:spPr/a:scene3d/a:camera/a:rot"_ostr, "rev"_ostr, "5400000");
// Second shape rectangle:
assertXPath(pXmlDoc, "//p:sp[2]/p:spPr/a:scene3d/a:camera/a:rot"_ostr, "rev"_ostr, "18300000");
// Make sure Shape3DProperties don't leak under txBody
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 0
// - Actual : 1
// - In <>, XPath '//p:sp[1]/p:txBody/a:bodyPr/a:scene3d/a:camera/a:rot' number of nodes is incorrect
assertXPath(pXmlDoc, "//p:sp[1]/p:txBody/a:bodyPr/a:scene3d/a:camera/a:rot"_ostr, 0);
assertXPath(pXmlDoc, "//p:sp[2]/p:txBody/a:bodyPr/a:scene3d/a:camera/a:rot"_ostr, 0);
}
CPPUNIT_TEST_FIXTURE(Test, testReferToTheme)
{
// Given a PPTX file that contains references to a theme:
loadFromFile(u"refer-to-theme.pptx");
// When saving that document:
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// Then make sure the shape text color is a scheme color:
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1
// - Actual : 0
// - XPath '//p:sp/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr' number of nodes is incorrect
// i.e. the <a:schemeClr> element was not written.
assertXPath(pXmlDoc, "//p:sp[1]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr"_ostr,
"val"_ostr, "accent1");
assertXPath(pXmlDoc, "//p:sp[1]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumMod"_ostr,
0);
assertXPath(pXmlDoc, "//p:sp[1]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumOff"_ostr,
0);
// Second shape: lighter color:
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1
// - Actual : 0
// - XPath '//p:sp[2]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr' number of nodes is incorrect
// i.e. the effects case did not write scheme colors.
assertXPath(pXmlDoc, "//p:sp[2]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr"_ostr,
"val"_ostr, "accent1");
assertXPath(pXmlDoc, "//p:sp[2]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumMod"_ostr,
"val"_ostr, "40000");
assertXPath(pXmlDoc, "//p:sp[2]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumOff"_ostr,
"val"_ostr, "60000");
// Third shape, darker color:
assertXPath(pXmlDoc, "//p:sp[3]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr"_ostr,
"val"_ostr, "accent1");
assertXPath(pXmlDoc, "//p:sp[3]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumMod"_ostr,
"val"_ostr, "75000");
assertXPath(pXmlDoc, "//p:sp[3]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumOff"_ostr,
0);
}
CPPUNIT_TEST_FIXTURE(Test, testThemeColor_ShapeFill)
{
// Given an ODP file that contains references to a theme for shape fill:
loadFromFile(u"ReferenceShapeFill.fodp");
// When saving that document:
save("Impress Office Open XML");
// Then make sure the shape fill color is a scheme color.
// Note that this was already working from PPTX files via grab-bags,
//so this test intentionally uses an ODP file as input.
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDoc, "//p:sp[1]/p:spPr/a:solidFill/a:schemeClr"_ostr, "val"_ostr, "accent6");
assertXPath(pXmlDoc, "//p:sp[1]/p:spPr/a:solidFill/a:schemeClr/a:lumMod"_ostr, "val"_ostr,
"75000");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf146690_endParagraphRunPropertiesNewLinesTextSize)
{
// Given a PPTX file that contains references to a theme:
loadFromFile(u"endParaRPr-newline-textsize.pptx");
// When saving that document:
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// Make sure the text size is exported correctly:
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 500
// - Actual : 1800
// i.e. the endParaRPr 'size' wasn't exported correctly
assertXPath(pXmlDoc, "//p:sp[1]/p:txBody/a:p[1]/a:endParaRPr"_ostr, "sz"_ostr, "500");
assertXPath(pXmlDoc, "//p:sp[1]/p:txBody/a:p[2]/a:endParaRPr"_ostr, "sz"_ostr, "500");
assertXPath(pXmlDoc, "//p:sp[1]/p:txBody/a:p[3]/a:endParaRPr"_ostr, "sz"_ostr, "500");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf147978_endsubpath)
{
// Given an odp file that contains a non-primitive custom shape with command N
loadFromFile(u"tdf147978_endsubpath.odp");
// When saving that document:
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// Then make sure the pathLst has two child elements,
// Without the accompanying fix in place, only one element a:path was exported.
assertXPathChildren(pXmlDoc, "//a:pathLst"_ostr, 2);
// and make sure first path with no stroke, second with no fill
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]"_ostr, "stroke"_ostr, "0");
assertXPath(pXmlDoc, "//a:pathLst/a:path[2]"_ostr, "fill"_ostr, "none");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf147978_commandA)
{
// Given an odp file that contains a non-primitive custom shape with command N
loadFromFile(u"tdf147978_enhancedPath_commandA.odp");
// When saving that document:
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// Then make sure the path has a child element arcTo. Prior to the fix that part of the curve was
// not exported at all. In odp it is a command A. Such does not exist in OOXML and is therefore
// exported as a:lnTo followed by a:arcTo
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:lnTo"_ostr, 2);
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo"_ostr, 1);
// And assert its attribute values
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo"_ostr, "wR"_ostr, "7200");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo"_ostr, "hR"_ostr, "5400");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo"_ostr, "stAng"_ostr, "7719588");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo"_ostr, "swAng"_ostr, "-5799266");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf147978_commandT)
{
// The odp file contains a non-primitive custom shape with commands MTZ
loadFromFile(u"tdf147978_enhancedPath_commandT.odp");
// Export to pptx had only exported the command M and has used a wrong path size
save("Impress Office Open XML");
// Verify the markup:
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// File has draw:viewBox="0 0 216 216"
assertXPath(pXmlDoc, "//a:pathLst/a:path"_ostr, "w"_ostr, "216");
assertXPath(pXmlDoc, "//a:pathLst/a:path"_ostr, "h"_ostr, "216");
// Command T is exported as lnTo followed by arcTo.
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:moveTo"_ostr, 1);
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:lnTo"_ostr, 1);
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo"_ostr, 1);
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:close"_ostr, 1);
// And assert its values
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:moveTo/a:pt"_ostr, "x"_ostr, "108");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:moveTo/a:pt"_ostr, "y"_ostr, "162");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:lnTo/a:pt"_ostr, "x"_ostr, "138");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:lnTo/a:pt"_ostr, "y"_ostr, "110");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo"_ostr, "wR"_ostr, "108");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo"_ostr, "hR"_ostr, "54");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo"_ostr, "stAng"_ostr, "18000000");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo"_ostr, "swAng"_ostr, "18000000");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf147978_commandXY)
{
// The odp file contains a non-primitive custom shapes with commands XY
loadFromFile(u"tdf147978_enhancedPath_commandXY.odp");
// Export to pptx had dropped commands X and Y.
save("Impress Office Open XML");
// Verify the markup:
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// File has draw:viewBox="0 0 10 10"
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]"_ostr, "w"_ostr, "10");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]"_ostr, "h"_ostr, "10");
// Shape has M 0 5 Y 5 0 10 5 5 10 F Y 0 5 N M 10 10 X 0 0
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]/a:moveTo/a:pt"_ostr, "x"_ostr, "0");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]/a:moveTo/a:pt"_ostr, "y"_ostr, "5");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]/a:arcTo[1]"_ostr, "wR"_ostr, "5");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]/a:arcTo[1]"_ostr, "hR"_ostr, "5");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]/a:arcTo[1]"_ostr, "stAng"_ostr, "10800000");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]/a:arcTo[1]"_ostr, "swAng"_ostr, "5400000");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]/a:arcTo[2]"_ostr, "stAng"_ostr, "16200000");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]/a:arcTo[2]"_ostr, "swAng"_ostr, "5400000");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]/a:arcTo[3]"_ostr, "stAng"_ostr, "0");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]/a:arcTo[3]"_ostr, "swAng"_ostr, "5400000");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]/a:arcTo[4]"_ostr, "stAng"_ostr, "0");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]/a:arcTo[4]"_ostr, "swAng"_ostr, "-5400000");
assertXPath(pXmlDoc, "//a:pathLst/a:path[2]/a:moveTo/a:pt"_ostr, "x"_ostr, "10");
assertXPath(pXmlDoc, "//a:pathLst/a:path[2]/a:moveTo/a:pt"_ostr, "y"_ostr, "10");
assertXPath(pXmlDoc, "//a:pathLst/a:path[2]/a:arcTo"_ostr, "wR"_ostr, "10");
assertXPath(pXmlDoc, "//a:pathLst/a:path[2]/a:arcTo"_ostr, "hR"_ostr, "10");
assertXPath(pXmlDoc, "//a:pathLst/a:path[2]/a:arcTo"_ostr, "stAng"_ostr, "5400000");
assertXPath(pXmlDoc, "//a:pathLst/a:path[2]/a:arcTo"_ostr, "swAng"_ostr, "5400000");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf147978_commandHIJK)
{
// The odp file contains a non-primitive custom shapes with commands H,I,J,K
loadFromFile(u"tdf147978_enhancedPath_commandHIJK.odp");
// Export to pptx had dropped commands X and Y.
save("Impress Office Open XML");
// Verify the markup:
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// File has draw:viewBox="0 0 80 80"
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]"_ostr, "w"_ostr, "80");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]"_ostr, "h"_ostr, "80");
// File uses from back to front J (lighten), I (lightenLess), normal fill, K (darkenLess),
// H (darken). New feature, old versions did not export these at all.
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]"_ostr, "fill"_ostr, "lighten");
assertXPath(pXmlDoc, "//a:pathLst/a:path[2]"_ostr, "fill"_ostr, "lightenLess");
assertXPathNoAttribute(pXmlDoc, "//a:pathLst/a:path[3]"_ostr, "fill"_ostr);
assertXPath(pXmlDoc, "//a:pathLst/a:path[4]"_ostr, "fill"_ostr, "darkenLess");
assertXPath(pXmlDoc, "//a:pathLst/a:path[5]"_ostr, "fill"_ostr, "darken");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf147978_subpath)
{
// The odp file contains a non-primitive custom shapes with commands H,I,J,K
loadFromFile(u"tdf147978_enhancedPath_subpath.pptx");
// Export to pptx had dropped the subpaths.
save("Impress Office Open XML");
// Verify the markup:
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// File should have four subpaths with increasing path size
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]"_ostr, "w"_ostr, "10");
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]"_ostr, "h"_ostr, "10");
assertXPath(pXmlDoc, "//a:pathLst/a:path[2]"_ostr, "w"_ostr, "20");
assertXPath(pXmlDoc, "//a:pathLst/a:path[2]"_ostr, "h"_ostr, "20");
assertXPath(pXmlDoc, "//a:pathLst/a:path[3]"_ostr, "w"_ostr, "40");
assertXPath(pXmlDoc, "//a:pathLst/a:path[3]"_ostr, "h"_ostr, "40");
assertXPath(pXmlDoc, "//a:pathLst/a:path[4]"_ostr, "w"_ostr, "80");
assertXPath(pXmlDoc, "//a:pathLst/a:path[4]"_ostr, "h"_ostr, "80");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf100391TextAreaRect)
{
// The document has a custom shape of type "non-primitive" to trigger the custGeom export
loadFromFile(u"tdf100391_TextAreaRect.odp");
// When saving to PPTX the textarea rect was set to default instead of using the actual area
save("Impress Office Open XML");
// Verify the markup. Without fix the values were l="l", t="t", r="r", b="b"
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDoc, "//a:custGeom/a:rect"_ostr, "l"_ostr, "textAreaLeft");
assertXPath(pXmlDoc, "//a:custGeom/a:rect"_ostr, "t"_ostr, "textAreaTop");
assertXPath(pXmlDoc, "//a:custGeom/a:rect"_ostr, "r"_ostr, "textAreaRight");
assertXPath(pXmlDoc, "//a:custGeom/a:rect"_ostr, "b"_ostr, "textAreaBottom");
// The values are calculated in guides, for example
assertXPath(pXmlDoc, "//a:custGeom/a:gdLst/a:gd[1]"_ostr, "name"_ostr, "textAreaLeft");
assertXPath(pXmlDoc, "//a:custGeom/a:gdLst/a:gd[1]"_ostr, "fmla"_ostr, "*/ 1440000 w 2880000");
// The test reflects the state of Apr 2022. It needs to be adapted when export of handles and
// guides is implemented.
}
CPPUNIT_TEST_FIXTURE(Test, testTdf109169_OctagonBevel)
{
// The odp file contains an "Octagon Bevel" shape. Such has shading not in commands H,I,J,K
// but shading is generated in ctor of EnhancedCustomShape2d from the Type value.
loadFromFile(u"tdf109169_OctagonBevel.odt");
// FIXME: validation error in OOXML export: Errors: 1
skipValidation();
// Export to docx had not written a:fill or a:stroke attributes at all.
save("Office Open XML Text");
// Verify the markup:
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// File should have six subpaths, one with stroke and five with fill
assertXPath(pXmlDoc, "//a:pathLst/a:path[1]"_ostr, "stroke"_ostr, "0");
assertXPath(pXmlDoc, "//a:pathLst/a:path[2]"_ostr, "fill"_ostr, "darkenLess");
assertXPath(pXmlDoc, "//a:pathLst/a:path[3]"_ostr, "fill"_ostr, "darken");
assertXPath(pXmlDoc, "//a:pathLst/a:path[4]"_ostr, "fill"_ostr, "darken");
assertXPath(pXmlDoc, "//a:pathLst/a:path[5]"_ostr, "fill"_ostr, "lightenLess");
assertXPath(pXmlDoc, "//a:pathLst/a:path[6]"_ostr, "fill"_ostr, "lighten");
}
CPPUNIT_TEST_FIXTURE(Test, testFaultyPathCommandsAWT)
{
// The odp file contains shapes whose path starts with command A, W, T or L. That is a faulty
// path. LO is tolerant and renders it so that is makes a moveTo to the start point of the arc or
// the end of the line respectively. Export to OOXML does the same now and writes a moveTo
// instead of the normally used lnTo. If a lnTo is written, MS Office shows nothing of the shape.
loadFromFile(u"FaultyPathStart.odp");
save("Impress Office Open XML");
// Verify the markup:
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// First child of a:path should be a moveTo in all four shapes.
assertXPath(pXmlDoc, "//p:spTree/p:sp[1]/p:spPr/a:custGeom/a:pathLst/a:path/a:moveTo"_ostr);
assertXPath(pXmlDoc, "//p:spTree/p:sp[2]/p:spPr/a:custGeom/a:pathLst/a:path/a:moveTo"_ostr);
assertXPath(pXmlDoc, "//p:spTree/p:sp[3]/p:spPr/a:custGeom/a:pathLst/a:path/a:moveTo"_ostr);
assertXPath(pXmlDoc, "//p:spTree/p:sp[4]/p:spPr/a:custGeom/a:pathLst/a:path/a:moveTo"_ostr);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf148784StretchXY)
{
// The document has a custom shapes of type "non-primitive" to trigger the custGeom export.
// They use formulas with 'right' and 'bottom'.
// When saving to PPTX the attributes stretchpoint-x and stretchpoint-y were not considered. The
// line at right and bottom edge were positioned inside as if the shape had a square size.
loadFromFile(u"tdf148784_StretchXY.odp");
save("Impress Office Open XML");
// Verify the markup.
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// x-position of last segment should be same as path width. It was 21600 without fix.
sal_Int32 nWidth
= getXPathContent(pXmlDoc, "//p:spTree/p:sp[1]/p:spPr/a:custGeom/a:pathLst/a:path/@w"_ostr)
.toInt32();
sal_Int32 nPosX
= getXPathContent(
pXmlDoc,
"//p:spTree/p:sp[1]/p:spPr/a:custGeom/a:pathLst/a:path/a:moveTo[4]/a:pt/@x"_ostr)
.toInt32();
CPPUNIT_ASSERT_EQUAL_MESSAGE("StretchX", nWidth, nPosX);
// y-position of last segment should be same as path height. It was 21600 without fix.
sal_Int32 nHeight
= getXPathContent(pXmlDoc, "//p:spTree/p:sp[2]/p:spPr/a:custGeom/a:pathLst/a:path/@h"_ostr)
.toInt32();
sal_Int32 nPosY
= getXPathContent(
pXmlDoc,
"//p:spTree/p:sp[2]/p:spPr/a:custGeom/a:pathLst/a:path/a:moveTo[4]/a:pt/@y"_ostr)
.toInt32();
CPPUNIT_ASSERT_EQUAL_MESSAGE("StretchY", nHeight, nPosY);
// The test reflects the state of Apr 2022. It needs to be adapted when export of handles and
// guides is implemented.
}
CPPUNIT_TEST_FIXTURE(Test, testTdf148784StretchCommandQ)
{
// The document has a custom shapes of type "non-primitive" to trigger the custGeom export.
// They use formulas with 'right' and 'bottom'.
// When saving to PPTX the attributes stretchpoint-x and stretchpoint-y were not considered.
// That results in wrong arcs on the right or bottom side of the shape.
loadFromFile(u"tdf148784_StretchCommandQ.odp");
save("Impress Office Open XML");
// Verify the markup.
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// x-position of second quadBezTo control should be same as path width. It was 21600 without fix.
sal_Int32 nWidth
= getXPathContent(pXmlDoc, "//p:spTree/p:sp[1]/p:spPr/a:custGeom/a:pathLst/a:path/@w"_ostr)
.toInt32();
sal_Int32 nPosX
= getXPathContent(
pXmlDoc,
"//p:spTree/p:sp[1]/p:spPr/a:custGeom/a:pathLst/a:path/a:quadBezTo[2]/a:pt/@x"_ostr)
.toInt32();
CPPUNIT_ASSERT_EQUAL_MESSAGE("StretchX", nWidth, nPosX);
// y-position of third quadBezTo control should be same as path height. It was 21600 without fix.
sal_Int32 nHeight
= getXPathContent(pXmlDoc, "//p:spTree/p:sp[2]/p:spPr/a:custGeom/a:pathLst/a:path/@h"_ostr)
.toInt32();
sal_Int32 nPosY
= getXPathContent(
pXmlDoc,
"//p:spTree/p:sp[2]/p:spPr/a:custGeom/a:pathLst/a:path/a:quadBezTo[3]/a:pt/@y"_ostr)
.toInt32();
CPPUNIT_ASSERT_EQUAL_MESSAGE("StretchY", nHeight, nPosY);
// The test reflects the state of Apr 2022. It needs to be adapted when export of handles and
// guides is implemented.
}
CPPUNIT_TEST_FIXTURE(Test, testTdf148784StretchCommandVW)
{
// The document has a custom shapes of type "non-primitive" to trigger the custGeom export.
// It should not need adaption when export of handles and guides is implemented because it
// has only fixed values in the path.
// When saving to PPTX the attributes stretchpoint-x and stretchpoint-y were not considered.
// That results in circles instead of ellipses.
loadFromFile(u"tdf148784_StretchCommandVW.odp");
save("Impress Office Open XML");
// Verify the markup.
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// wR of first ArcTo in first shape should be same as path width/2. It was 10800 without fix.
sal_Int32 nHalfWidth
= getXPathContent(pXmlDoc, "//p:spTree/p:sp[1]/p:spPr/a:custGeom/a:pathLst/a:path/@w"_ostr)
.toInt32()
/ 2;
sal_Int32 nWR
= getXPathContent(
pXmlDoc, "//p:spTree/p:sp[1]/p:spPr/a:custGeom/a:pathLst/a:path/a:arcTo[1]/@wR"_ostr)
.toInt32();
CPPUNIT_ASSERT_EQUAL_MESSAGE("StretchX", nHalfWidth, nWR);
// hR of first ArcTo in second shape should be same as path height /2. It was 10800 without fix.
sal_Int32 nHalfHeight
= getXPathContent(pXmlDoc, "//p:spTree/p:sp[2]/p:spPr/a:custGeom/a:pathLst/a:path/@h"_ostr)
.toInt32()
/ 2;
sal_Int32 nHR
= getXPathContent(
pXmlDoc, "//p:spTree/p:sp[2]/p:spPr/a:custGeom/a:pathLst/a:path/a:arcTo[1]/@hR"_ostr)
.toInt32();
CPPUNIT_ASSERT_EQUAL_MESSAGE("StretchY", nHalfHeight, nHR);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf149551VertPadding)
{
// The document has shape[1] with attribute vert="vert270" and shape[2] with vert="vert". The text
// has paddings lIns="720000"=2cm, tIns="360000"=1cm, rIns="0" and bIns="0".
// After load and save the paddings were rotated and a 90deg text rotation was added.
loadFromFile(u"tdf149551_vert_and_padding.pptx");
save("Impress Office Open XML");
// Verify the markup. The values must be the same as in the original file.
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
for (sal_Int32 i = 1; i <= 2; i++)
{
OString sElement = "//p:spTree/p:sp[" + OString::number(i) + "]/p:txBody/a:bodyPr";
assertXPath(pXmlDoc, sElement, "lIns"_ostr, "720000");
assertXPath(pXmlDoc, sElement, "tIns"_ostr, "360000");
assertXPath(pXmlDoc, sElement, "rIns"_ostr, "0");
assertXPath(pXmlDoc, sElement, "bIns"_ostr, "0");
assertXPathNoAttribute(pXmlDoc, sElement, "rot"_ostr);
}
}
CPPUNIT_TEST_FIXTURE(Test, testTdf149538upright)
{
// The document has a shape with attribute upright="1" in the bodyPr element. On import it is
// emulated by rotating the text area rectangle. On export there should be an upright="1"
// attribute but no 'rot' attribute. Without the fix the 'rot' attribute with values from
// the emulation was written out.
loadFromFile(u"tdf149538_upright.pptx");
save("Impress Office Open XML");
// Verify the markup. The values must be the same as in the original file.
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDoc, "//p:spTree/p:sp/p:txBody/a:bodyPr"_ostr, "upright"_ostr, "1");
assertXPathNoAttribute(pXmlDoc, "//p:spTree/p:sp/p:txBody/a:bodyPr"_ostr, "rot"_ostr);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf151008VertAnchor)
{
loadFromFile(u"tdf151008_eaVertAnchor.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// The order of the shapes in the file is by name "Right", "Center", "Left", "RightMiddle",
// "CenterMiddle" and "LeftMiddle". I access the shapes here by index, because the XPath is
// easier then.
// As of Sep 2022 LibreOffice does not write the default anchorCtr="0"
// Right
assertXPath(pXmlDoc, "//p:spTree/p:sp[1]/p:txBody/a:bodyPr"_ostr, "anchor"_ostr, "t");
assertXPathNoAttribute(pXmlDoc, "//p:spTree/p:sp[1]/p:txBody/a:bodyPr"_ostr, "anchorCtr"_ostr);
// Center
assertXPath(pXmlDoc, "//p:spTree/p:sp[2]/p:txBody/a:bodyPr"_ostr, "anchor"_ostr, "ctr");
assertXPathNoAttribute(pXmlDoc, "//p:spTree/p:sp[2]/p:txBody/a:bodyPr"_ostr, "anchorCtr"_ostr);
// Left
assertXPath(pXmlDoc, "//p:spTree/p:sp[3]/p:txBody/a:bodyPr"_ostr, "anchor"_ostr, "b");
assertXPathNoAttribute(pXmlDoc, "//p:spTree/p:sp[3]/p:txBody/a:bodyPr"_ostr, "anchorCtr"_ostr);
// RightMiddle
assertXPath(pXmlDoc, "//p:spTree/p:sp[4]/p:txBody/a:bodyPr"_ostr, "anchor"_ostr, "t");
assertXPath(pXmlDoc, "//p:spTree/p:sp[4]/p:txBody/a:bodyPr"_ostr, "anchorCtr"_ostr, "1");
// CenterMiddle
assertXPath(pXmlDoc, "//p:spTree/p:sp[5]/p:txBody/a:bodyPr"_ostr, "anchor"_ostr, "ctr");
assertXPath(pXmlDoc, "//p:spTree/p:sp[5]/p:txBody/a:bodyPr"_ostr, "anchorCtr"_ostr, "1");
// LeftMiddle
assertXPath(pXmlDoc, "//p:spTree/p:sp[6]/p:txBody/a:bodyPr"_ostr, "anchor"_ostr, "b");
assertXPath(pXmlDoc, "//p:spTree/p:sp[6]/p:txBody/a:bodyPr"_ostr, "anchorCtr"_ostr, "1");
}
CPPUNIT_TEST_FIXTURE(Test, testFontworkBitmapFill)
{
// The document has a Fontwork shape with bitmap fill.
loadFromFile(u"tdf128568_FontworkBitmapFill.odt");
// FIXME: validation error in OOXML export: Errors: 1
// Attribute ID is not allowed in element v:shape
skipValidation();
// Saving that to DOCX:
save("Office Open XML Text");
// Make sure it is exported to VML and has no txbxContent but a textpath element. Without fix it
// was exported as DML 'abc transform', but that is not able to use bitmap fill in Word.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
assertXPath(pXmlDoc, "//mc:alternateContent"_ostr, 0);
assertXPath(pXmlDoc, "//v:shape/v:textbox/v:txbxContent"_ostr, 0);
assertXPath(pXmlDoc, "//v:shape/v:textpath"_ostr, 1);
// Without fix the bitmap was referenced by v:imagedata element. But that produces a picture
// in Word not a WordArt shape. Instead a v:fill has to be used.
assertXPath(pXmlDoc, "//v:shape/v:imagedata"_ostr, 0);
assertXPath(pXmlDoc, "//v:shape/v:fill"_ostr, 1);
assertXPath(pXmlDoc, "//v:shape/v:fill[@r:id]"_ostr, 1);
// The fill is set to 'stretched' in LO, that is type="frame" in VML. That was not implemented
// in VML export.
assertXPath(pXmlDoc, "//v:shape/v:fill"_ostr, "type"_ostr, "frame");
}
CPPUNIT_TEST_FIXTURE(Test, testFontworkFontProperties)
{
// The document has five Fontwork shapes. They have bitmap fill and thus are exported to VML.
// They differ in font properties e.g. font weight and character spacing.
loadFromFile(u"tdf128568_FontworkFontProperties.odt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Make sure the style attribute of the textpath element has the needed items. Without fix only
// font-family and font-size were written.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
OUString sStyle;
// bold
sStyle = getXPath(pXmlDoc, "(//v:shape)[1]/v:textpath"_ostr, "style"_ostr);
CPPUNIT_ASSERT(sStyle.indexOf("font-weight:bold") > -1);
// italic
sStyle = getXPath(pXmlDoc, "(//v:shape)[2]/v:textpath"_ostr, "style"_ostr);
CPPUNIT_ASSERT(sStyle.indexOf("font-style:italic") > -1);
// character spacing 'very loose', 150 * 655, see escherex.cxx
sStyle = getXPath(pXmlDoc, "(//v:shape)[3]/v:textpath"_ostr, "style"_ostr);
CPPUNIT_ASSERT(sStyle.indexOf("v-text-spacing:98250f") > -1);
// character spacing 'tight', 90 * 655, see escherex.cxx
sStyle = getXPath(pXmlDoc, "(//v:shape)[4]/v:textpath"_ostr, "style"_ostr);
CPPUNIT_ASSERT(sStyle.indexOf("v-text-spacing:58950f") > -1);
// same letter heights
sStyle = getXPath(pXmlDoc, "(//v:shape)[5]/v:textpath"_ostr, "style"_ostr);
CPPUNIT_ASSERT(sStyle.indexOf("v-same-letter-heights:t") > -1);
}
CPPUNIT_TEST_FIXTURE(Test, testVMLFontworkSlantUp)
{
// The document has a Fontwork shape type 'textSlantUp' (172). When exporting to docx, Word does
// not recognize its markup as preset WordArt, because the used markup differs from what Word
// expects for this type of shape. As a result Word saves the shape as having custom geometry
// and such is not understand by LibreOffice.
loadFromFile(u"tdf153296_VML_export_SlantUp.odt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Examine the saved markup. I could identify the following two problems to hinder Word from
// accepting the markup. There might exist more problems.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// Make sure a <v:path> element exists and has an o:connecttype attribute
assertXPath(pXmlDoc, "//v:shapetype/v:path"_ostr, 1);
assertXPath(pXmlDoc, "//v:shapetype/v:path[@o:connecttype]"_ostr, 1);
// Make sure the handle position is written without reference to a formula
OUString sPosition = getXPath(pXmlDoc, "//v:h"_ostr, "position"_ostr);
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), sPosition.indexOf("@"));
CPPUNIT_ASSERT_EQUAL(OUString("topLeft,#0"), sPosition);
}
CPPUNIT_TEST_FIXTURE(Test, testVMLFontworkArchUp)
{
// The document has a Fontwork shape type 'textArchUp' (172). When exporting to docx, the shape
// was not exported as VML Fontwork but as a rectangle.
loadFromFile(u"tdf153296_VML_export_ArchUpCurve.odt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Examine the saved markup.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// Make sure there is no <v:rect> element
assertXPath(pXmlDoc, "//v:rect"_ostr, 0);
// ..., but a <v:shapetype> element with <v:textpath> subelement
assertXPath(pXmlDoc, "//v:shapetype/v:textpath"_ostr, 1);
}
CPPUNIT_TEST_FIXTURE(Test, testVMLAdjustmentExport)
{
// The document has a Fontwork shape type 'textCirclePour' (150). When exporting to docx, the
// adjustment values were not exported at all.
loadFromFile(u"tdf153246_VML_export_Fontwork_Adjustment.odt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Examine the saved markup.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// Make sure an "adj" attribute exists
assertXPath(pXmlDoc, "//v:shape[@adj]"_ostr, 1);
// ... and has the correct values
OUString sAdjustments = getXPath(pXmlDoc, "//v:shape"_ostr, "adj"_ostr);
sal_Int32 nTokenStart = 0;
OUString sAngle = sAdjustments.getToken(0, ',', nTokenStart);
CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(-7341733), sAngle.toInt32(), 2);
OUString sRadius = sAdjustments.copy(nTokenStart);
CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(5296), sRadius.toInt32(), 2);
}
CPPUNIT_TEST_FIXTURE(Test, testFontworkDirectColor)
{
// The document has a Fontwork shape with fill #2e8b57 plus 60% transparency and line color
// #ff7f50 with 20% transparency. When exporting to docx, line color was not exported at all
// and fill color was replaced with character color.
loadFromFile(u"tdf51195_Fontwork_DirectColor.odt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Examine the saved markup.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
static constexpr OString sElement = "//w:txbxContent/w:p/w:r/w:rPr/"_ostr;
// Make sure the fallback in <w:color> has correct value.
assertXPath(pXmlDoc, sElement + "w:color", "val"_ostr, "2E8B57");
// ... and <w14:textOutline> exists and has correct values.
assertXPath(pXmlDoc, sElement + "w14:textOutline", 1);
assertXPath(pXmlDoc, sElement + "w14:textOutline/w14:solidFill/w14:srgbClr", "val"_ostr,
"ff7f50");
assertXPath(pXmlDoc, sElement + "w14:textOutline/w14:solidFill/w14:srgbClr/w14:alpha",
"val"_ostr, "20000");
assertXPath(pXmlDoc, sElement + "w14:textOutline/w14:round", 1);
// ... and w14:textFill exists and has correct values.
assertXPath(pXmlDoc, sElement + "w14:textFill", 1);
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:solidFill/w14:srgbClr", "val"_ostr, "2e8b57");
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:solidFill/w14:srgbClr/w14:alpha", "val"_ostr,
"60000");
}
CPPUNIT_TEST_FIXTURE(Test, testFontworkThemeColor)
{
// The document has a Fontwork shape with fill theme color 'lt2' and 50% darker, and a Fontwork
// shape with theme color 'dk2' and 40% lighter. When exporting to docx, fill color was not
// exported as theme color at all, and it was replaced with character color.
loadFromFile(u"tdf51195_Fontwork_ThemeColor.fodt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Examine the saved markup.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// shape with 'darker'
OString sElement = "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/"
"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r/"
"w:rPr/"_ostr;
// Make sure the fallback in <w:color> has correct values
assertXPath(pXmlDoc, sElement + "w:color", "val"_ostr, "948A54");
assertXPath(pXmlDoc, sElement + "w:color", "themeColor"_ostr, "light2");
assertXPath(pXmlDoc, sElement + "w:color", "themeShade"_ostr, "80");
// ... and w14:textFill exists and has correct values.
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:solidFill/w14:schemeClr", "val"_ostr, "bg2");
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:solidFill/w14:schemeClr/w14:lumMod",
"val"_ostr, "50000");
// shape with 'lighter'
sElement = "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent[2]/mc:Choice/w:drawing/wp:anchor/"
"a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r/w:rPr/"_ostr;
// Make sure the fallback in <w:color> has correct values
assertXPath(pXmlDoc, sElement + "w:color", "val"_ostr, "558ED5");
assertXPath(pXmlDoc, sElement + "w:color", "themeColor"_ostr, "dark2");
assertXPath(pXmlDoc, sElement + "w:color", "themeTint"_ostr, "99");
// ... and w14:textFill exists and has correct values.
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:solidFill/w14:schemeClr", "val"_ostr, "tx2");
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:solidFill/w14:schemeClr/w14:lumMod",
"val"_ostr, "60000");
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:solidFill/w14:schemeClr/w14:lumOff",
"val"_ostr, "40000");
}
CPPUNIT_TEST_FIXTURE(Test, testFontworkDistance)
{
// LO ignores 'Spacing to Borders' of the 'Text Attributes' for Fontwork shapes. Word interprets
// them. Make sure we force them to zero on export to docx, otherwise Word might wrap the text.
loadFromFile(u"tdf51195_Fontwork_Distance.odt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Examine the saved markup.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
assertXPathAttrs(pXmlDoc,
"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:bodyPr"_ostr,
{ { "lIns", "0" }, { "rIns", "0" }, { "tIns", "0" }, { "bIns", "0" } });
}
CPPUNIT_TEST_FIXTURE(Test, testFontworkLinGradientRGBColor)
{
// The document has a Fontwork shape with UI settings: linear gradient fill with angle 330deg,
// start color #ffff00 (Yellow) with 'Intensity' 80%, end color #4682B4 (Steel Blue), Transition
// Start 25% and solid transparency 30%.
// Without fix the gradient was not exported at all.
loadFromFile(u"tdf51195_Fontwork_linearGradient.fodt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Examine the saved markup.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// path to shape text run properties
OString sElement = "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r/"
"w:rPr/"_ostr;
// Make sure w14:textFill and w14:gradFill elements exist with child elements
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:gsLst", 1);
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:gsLst/w14:gs", 3);
// 330deg gradient rotation = 120deg color transition direction
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:lin", "ang"_ostr, "7200000");
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:lin", "scaled"_ostr, "0");
// Make sure the color stops have correct position and color
// The 'intensity' property in the UI has a different algorithm than the 'lumMod' attribute in
// OOXML. Therefore it cannot be exported as 'lumMod' but need to be incorporated into the color.
sElement += "w14:textFill/w14:gradFill/w14:gsLst/";
assertXPath(pXmlDoc, sElement + "w14:gs[1]", "pos"_ostr, "0");
assertXPath(pXmlDoc, sElement + "w14:gs[1]/w14:srgbClr", "val"_ostr, "cccc00");
assertXPath(pXmlDoc, sElement + "w14:gs[1]/w14:srgbClr/w14:alpha", "val"_ostr, "30000");
assertXPath(pXmlDoc, sElement + "w14:gs[2]", "pos"_ostr, "25000");
assertXPath(pXmlDoc, sElement + "w14:gs[2]/w14:srgbClr", "val"_ostr, "cccc00");
assertXPath(pXmlDoc, sElement + "w14:gs[2]/w14:srgbClr/w14:alpha", "val"_ostr, "30000");
assertXPath(pXmlDoc, sElement + "w14:gs[3]", "pos"_ostr, "100000");
assertXPath(pXmlDoc, sElement + "w14:gs[3]/w14:srgbClr", "val"_ostr, "4682b4");
assertXPath(pXmlDoc, sElement + "w14:gs[3]/w14:srgbClr/w14:alpha", "val"_ostr, "30000");
}
CPPUNIT_TEST_FIXTURE(Test, testFontworkAxialGradientTransparency)
{
// The document has a Fontwork shape with UI settings: solid fill theme color Accent3 25% darker,
// Transparency gradient Type Axial with Angle 160deg, Transition start 40%,
// Start value 5%, End value 90%
// Without fix the gradient was not exported at all.
loadFromFile(u"tdf51195_Fontwork_axialGradient.fodt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Examine the saved markup.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// path to shape text run properties
OString sElement = "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r/"
"w:rPr/"_ostr;
// Make sure w14:textFill and w14:gradFill elements exist with child elements
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:gsLst", 1);
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:gsLst/w14:gs", 3);
// 160deg gradient rotation = 290deg (360deg-160deg+90deg) color transition direction
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:lin", "ang"_ostr, "17400000");
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:lin", "scaled"_ostr, "0");
// Make sure the color stops have correct position and color
sElement += "w14:textFill/w14:gradFill/w14:gsLst/";
// gradient is in transparency, color is always the same.
for (char ch = '1'; ch <= '3'; ++ch)
{
assertXPath(pXmlDoc, sElement + "w14:gs[" + OStringChar(ch) + "]/w14:schemeClr", "val"_ostr,
"accent3");
assertXPath(pXmlDoc, sElement + "w14:gs[" + OStringChar(ch) + "]/w14:schemeClr/w14:lumMod",
"val"_ostr, "75000");
}
// transparency values are not exactly like in UI because converting through rgb-color.
// border 40% in UI means 20% on each side.
assertXPath(pXmlDoc, sElement + "w14:gs[1]", "pos"_ostr, "20000");
assertXPath(pXmlDoc, sElement + "w14:gs[1]/w14:schemeClr/w14:alpha", "val"_ostr, "89800");
assertXPath(pXmlDoc, sElement + "w14:gs[2]", "pos"_ostr, "50000");
assertXPath(pXmlDoc, sElement + "w14:gs[2]/w14:schemeClr/w14:alpha", "val"_ostr, "4710");
assertXPath(pXmlDoc, sElement + "w14:gs[3]", "pos"_ostr, "80000");
assertXPath(pXmlDoc, sElement + "w14:gs[3]/w14:schemeClr/w14:alpha", "val"_ostr, "89800");
}
CPPUNIT_TEST_FIXTURE(Test, testFontworkRadialGradient)
{
// The document has a Fontwork shape with UI settings: gradient fill, Type radial,
// From Color #40E0D0, To Color #FF0000, Center x|y 75%|20%, no transparency
// Transition start 10%
// Without fix the gradient was not exported at all.
loadFromFile(u"tdf51195_Fontwork_radialGradient.fodt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Examine the saved markup.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// path to shape text run properties
OString sElement = "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r/"
"w:rPr/"_ostr;
// Make sure w14:textFill and w14:gradFill elements exist with child elements
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:gsLst", 1);
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:gsLst/w14:gs", 3);
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:path", "path"_ostr, "circle");
assertXPathAttrs(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:path/w14:fillToRect",
{ { "l", "75000" }, { "t", "20000" }, { "r", "25000" }, { "b", "80000" } });
// Make sure the color stops have correct position and color
// The first stop is duplicated to force Word to render the gradient same as LO.
sElement += "w14:textFill/w14:gradFill/w14:gsLst/";
assertXPath(pXmlDoc, sElement + "w14:gs[1]", "pos"_ostr, "0");
assertXPath(pXmlDoc, sElement + "w14:gs[1]/w14:srgbClr", "val"_ostr, "ff0000");
assertXPath(pXmlDoc, sElement + "w14:gs[2]", "pos"_ostr, "0");
assertXPath(pXmlDoc, sElement + "w14:gs[2]/w14:srgbClr", "val"_ostr, "ff0000");
assertXPath(pXmlDoc, sElement + "w14:gs[3]", "pos"_ostr, "90000");
assertXPath(pXmlDoc, sElement + "w14:gs[3]/w14:srgbClr", "val"_ostr, "40e0d0");
}
CPPUNIT_TEST_FIXTURE(Test, testFontworkEllipticalGradient)
{
// The document has a Fontwork shape with UI settings: solid fill, Color #00008B (deep blue),
// transparency gradient type Ellipsoid, Center x|y 50%|50%, Transition Start 50%,
// Start 70%, End 0%.
// Without fix the gradient was not exported at all.
loadFromFile(u"tdf51195_Fontwork_ellipticalGradient.fodt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Examine the saved markup.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// path to shape text run properties
OString sElement = "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r/"
"w:rPr/"_ostr;
// Make sure w14:textFill and w14:gradFill elements exist with child elements
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:gsLst", 1);
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:gsLst/w14:gs", 3);
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:path", "path"_ostr, "circle");
assertXPathAttrs(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:path/w14:fillToRect",
{ { "l", "50000" }, { "t", "50000" }, { "r", "50000" }, { "b", "50000" } });
// Make sure the color stops have correct position and color
// transparency values are not exactly like in UI because converting through rgb-color.
sElement += "w14:textFill/w14:gradFill/w14:gsLst/";
assertXPath(pXmlDoc, sElement + "w14:gs[1]", "pos"_ostr, "0");
assertXPath(pXmlDoc, sElement + "w14:gs[1]/w14:srgbClr", "val"_ostr, "00008b");
// stop is duplicated to force Word to same rendering as LO does.
assertXPath(pXmlDoc, sElement + "w14:gs[2]", "pos"_ostr, "0");
assertXPath(pXmlDoc, sElement + "w14:gs[2]/w14:srgbClr", "val"_ostr, "00008b");
assertXPath(pXmlDoc, sElement + "w14:gs[3]", "pos"_ostr, "50000");
assertXPath(pXmlDoc, sElement + "w14:gs[3]/w14:srgbClr", "val"_ostr, "00008b");
assertXPath(pXmlDoc, sElement + "w14:gs[3]/w14:srgbClr/w14:alpha", "val"_ostr, "69800");
}
CPPUNIT_TEST_FIXTURE(Test, testFontworkSquareGradient)
{
// The document has a Fontwork shape with UI settings: gradient fill Type "Square (Quadratic)",
// From Color #4963ef 40%, To Color #ffff6e 90%, Center x|y 100%|50%,
// no transparency
// Without fix the gradient was not exported at all.
loadFromFile(u"tdf51195_Fontwork_squareGradient.fodt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Examine the saved markup.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// path to shape text run properties
OString sElement = "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r/"
"w:rPr/"_ostr;
// Make sure w14:textFill and w14:gradFill elements exist with child elements
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:gsLst", 1);
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:gsLst/w14:gs", 3);
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:path", "path"_ostr, "rect");
assertXPathAttrs(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:path/w14:fillToRect",
{ { "l", "100000" }, { "t", "50000" }, { "r", "0" }, { "b", "50000" } });
// Make sure the color stops have correct position and color
// The 'intensity' property in the UI has a different algorithm than the 'lumMod' attribute in
// OOXML. Therefore it cannot be exported as 'lumMod' but need to be incorporated into the color.
sElement += "w14:textFill/w14:gradFill/w14:gsLst/";
assertXPath(pXmlDoc, sElement + "w14:gs[1]", "pos"_ostr, "0");
assertXPath(pXmlDoc, sElement + "w14:gs[1]/w14:srgbClr", "val"_ostr, "e6e663");
assertXPath(pXmlDoc, sElement + "w14:gs[2]", "pos"_ostr, "0");
assertXPath(pXmlDoc, sElement + "w14:gs[2]/w14:srgbClr", "val"_ostr, "e6e663");
assertXPath(pXmlDoc, sElement + "w14:gs[3]", "pos"_ostr, "100000");
assertXPath(pXmlDoc, sElement + "w14:gs[3]/w14:srgbClr", "val"_ostr, "1d4860");
}
CPPUNIT_TEST_FIXTURE(Test, testFontworkRectGradient)
{
// The document has a Fontwork shape with UI settings: solid color theme Accent 4 60% lighter,
// transparency gradient Type "Rectangular", Center x|y 50%|50%, Transition start 10%,
// Start value 70%, End value 5%.
// Without fix the gradient was not exported at all.
loadFromFile(u"tdf51195_Fontwork_rectGradient.fodt");
// FIXME: tdf#153183 validation error in OOXML export: Errors: 1
// Attribute 'ID' is not allowed to appear in element 'v:shape'.
skipValidation();
// Save to DOCX:
save("Office Open XML Text");
// Examine the saved markup.
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
// path to shape text run properties
OString sElement = "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r/"
"w:rPr/"_ostr;
// Make sure w14:textFill and w14:gradFill elements exist with child elements
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:gsLst", 1);
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:gsLst/w14:gs", 3);
assertXPath(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:path", "path"_ostr, "rect");
assertXPathAttrs(pXmlDoc, sElement + "w14:textFill/w14:gradFill/w14:path/w14:fillToRect",
{ { "l", "50000" }, { "t", "50000" }, { "r", "50000" }, { "b", "50000" } });
// Make sure the color stops have correct position and color
// transparency values are not exactly like in UI because converting through rgb-color.
sElement += "w14:textFill/w14:gradFill/w14:gsLst/";
assertXPath(pXmlDoc, sElement + "w14:gs[1]", "pos"_ostr, "0");
assertXPath(pXmlDoc, sElement + "w14:gs[1]/w14:schemeClr", "val"_ostr, "accent4");
assertXPath(pXmlDoc, sElement + "w14:gs[1]/w14:schemeClr/w14:lumMod", "val"_ostr, "40000");
assertXPath(pXmlDoc, sElement + "w14:gs[1]/w14:schemeClr/w14:lumOff", "val"_ostr, "60000");
assertXPath(pXmlDoc, sElement + "w14:gs[1]/w14:schemeClr/w14:alpha", "val"_ostr, "4710");
// The first stop is duplicated to force Word to render the gradient same as LO.
assertXPath(pXmlDoc, sElement + "w14:gs[2]", "pos"_ostr, "0");
assertXPath(pXmlDoc, sElement + "w14:gs[2]/w14:schemeClr", "val"_ostr, "accent4");
assertXPath(pXmlDoc, sElement + "w14:gs[2]/w14:schemeClr/w14:lumMod", "val"_ostr, "40000");
assertXPath(pXmlDoc, sElement + "w14:gs[2]/w14:schemeClr/w14:lumOff", "val"_ostr, "60000");
assertXPath(pXmlDoc, sElement + "w14:gs[2]/w14:schemeClr/w14:alpha", "val"_ostr, "4710");
assertXPath(pXmlDoc, sElement + "w14:gs[3]", "pos"_ostr, "90000");
assertXPath(pXmlDoc, sElement + "w14:gs[3]/w14:schemeClr", "val"_ostr, "accent4");
assertXPath(pXmlDoc, sElement + "w14:gs[3]/w14:schemeClr/w14:lumMod", "val"_ostr, "40000");
assertXPath(pXmlDoc, sElement + "w14:gs[3]/w14:schemeClr/w14:lumOff", "val"_ostr, "60000");
assertXPath(pXmlDoc, sElement + "w14:gs[3]/w14:schemeClr/w14:alpha", "val"_ostr, "69800");
}
CPPUNIT_TEST_FIXTURE(Test, testThemeColorTransparency)
{
// The document has first a Fontwork shape with solid fill theme color with transparency and
// outline transparency and second a textbox with character transparency.
// Without fix the transparency was not written to file.
loadFromFile(u"tdf139618_ThemeColorTransparency.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
// Make sure a:alpha is written for line color and for fill color.
// Make sure fill color is a schemeClr.
OString sElement = "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:p/a:r/a:rPr/"_ostr;
assertXPath(pXmlDoc, sElement + "a:ln/a:solidFill/a:srgbClr/a:alpha", "val"_ostr, "25000");
assertXPath(pXmlDoc, sElement + "a:solidFill/a:schemeClr", "val"_ostr, "accent1");
assertXPath(pXmlDoc, sElement + "a:solidFill/a:schemeClr/a:lumMod", "val"_ostr, "60000");
assertXPath(pXmlDoc, sElement + "a:solidFill/a:schemeClr/a:lumOff", "val"_ostr, "40000");
assertXPath(pXmlDoc, sElement + "a:solidFill/a:schemeClr/a:alpha", "val"_ostr, "35000");
// Make sure a:alpha is written for characters and fill color is a schemeClr.
sElement = "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p/a:r/a:rPr/"_ostr;
assertXPath(pXmlDoc, sElement + "a:solidFill/a:schemeClr", "val"_ostr, "accent4");
assertXPath(pXmlDoc, sElement + "a:solidFill/a:schemeClr/a:lumMod", "val"_ostr, "75000");
assertXPath(pXmlDoc, sElement + "a:solidFill/a:schemeClr/a:alpha", "val"_ostr, "20000");
}
CPPUNIT_TEST_FIXTURE(Test, testThemeFontTypeface)
{
// Saving the document had produced a file which PowerPoint wants to repair. The mandatory
// attribute 'typeface' was missing in the <a:ea> elements.
loadFromFile(u"tdf155412_typeface.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDoc = parseExport("ppt/theme/theme1.xml");
// Make sure typeface is written.
OString sElement = "/a:theme/a:themeElements/a:fontScheme/"_ostr;
assertXPath(pXmlDoc, sElement + "a:majorFont/a:ea", "typeface"_ostr, "");
assertXPath(pXmlDoc, sElement + "a:minorFont/a:ea", "typeface"_ostr, "");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf157289CircularArrowExport)
{
// The document has a custom shape of type "circular-arrow". Such uses a B command where
// the ellipse bounding box is defined by bottom-right vertex first and then top-left vertex.
// When saving to PPTX this had resulted in negative radii for the ellipse.
loadFromFile(u"tdf157289_circularArrow_export.fodp");
save("Impress Office Open XML");
// Verify the markup. Both wR and hR must be positive.
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo[1]"_ostr, "wR"_ostr, "6750");
assertXPath(pXmlDoc, "//a:pathLst/a:path/a:arcTo[1]"_ostr, "hR"_ostr, "6750");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf134401_ExportAutoGrowToTextWordWrap)
{
// pptx doesn't have autoGrowWidth and autoGrowHeight, but it does have TextWordWrap
// which is similar. If autoGrowWidth and autoGrowHeight are set in the document,
// then they are exported to pptx as TextWordWrap = "none".
loadFromFile(u"tdf134401_ExportAutoGrowToTextWordWrap.odp");
save("Impress Office Open XML");
// There are 2 shapes in the test file.
// The 1. shape is without autoGrowWidth/Height.
// The 2. shape is with autoGrowWidth/Height.
// Check if wrap="none" is exported for shape 2, but no wrap is exported for shape 1.
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
assertXPathNoAttribute(pXmlDoc, "//p:sp[1]/p:txBody/a:bodyPr"_ostr, "wrap"_ostr);
assertXPath(pXmlDoc, "//p:sp[2]/p:txBody/a:bodyPr"_ostr, "wrap"_ostr, "none");
}
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|