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
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
|
/* -*- 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <config_global.h>
#include <sal/log.hxx>
#include <unotools/mediadescriptor.hxx>
#include <filter/msfilter/util.hxx>
#include <oox/core/xmlfilterbase.hxx>
#include <oox/export/shapes.hxx>
#include <oox/export/utils.hxx>
#include <oox/token/namespaces.hxx>
#include <oox/token/relationship.hxx>
#include <oox/token/tokens.hxx>
#include <cstdio>
#include <initializer_list>
#include <com/sun/star/awt/CharSet.hpp>
#include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/awt/FontSlant.hpp>
#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/awt/FontUnderline.hpp>
#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/beans/PropertyValues.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/BitmapMode.hpp>
#include <com/sun/star/drawing/ConnectorType.hpp>
#include <com/sun/star/drawing/LineDash.hpp>
#include <com/sun/star/drawing/LineJoint.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
#include <com/sun/star/embed/EmbedStates.hpp>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <com/sun/star/embed/XEmbedPersist.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <com/sun/star/text/XSimpleText.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextField.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/table/XTable.hpp>
#include <com/sun/star/table/XColumnRowRange.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/table/XMergeableCell.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <tools/stream.hxx>
#include <tools/globname.hxx>
#include <comphelper/classids.hxx>
#include <comphelper/propertysequence.hxx>
#include <comphelper/storagehelper.hxx>
#include <sot/exchange.hxx>
#include <utility>
#include <vcl/cvtgrf.hxx>
#include <unotools/fontcvt.hxx>
#include <vcl/graph.hxx>
#include <vcl/outdev.hxx>
#include <vcl/GraphicObject.hxx>
#include <rtl/strbuf.hxx>
#include <sfx2/app.hxx>
#include <svl/languageoptions.hxx>
#include <filter/msfilter/escherex.hxx>
#include <svx/svdoashp.hxx>
#include <svx/svdoole2.hxx>
#include <editeng/svxenum.hxx>
#include <svx/unoapi.hxx>
#include <oox/export/chartexport.hxx>
#include <oox/mathml/export.hxx>
using namespace ::css;
using namespace ::css::beans;
using namespace ::css::uno;
using namespace ::css::drawing;
using namespace ::css::i18n;
using namespace ::css::table;
using namespace ::css::container;
using namespace ::css::document;
using namespace ::css::text;
using ::css::io::XOutputStream;
using ::css::chart2::XChartDocument;
using ::css::frame::XModel;
using ::oox::core::XmlFilterBase;
using ::sax_fastparser::FSHelperPtr;
#define IDS(x) OString(OStringLiteral(#x " ") + OString::number( mnShapeIdMax++ )).getStr()
namespace oox {
static void lcl_ConvertProgID(OUString const& rProgID,
OUString & o_rMediaType, OUString & o_rRelationType, OUString & o_rFileExtension)
{
if (rProgID == "Excel.Sheet.12")
{
o_rMediaType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
o_rFileExtension = "xlsx";
}
else if (rProgID.startsWith("Excel.SheetBinaryMacroEnabled.12") )
{
o_rMediaType = "application/vnd.ms-excel.sheet.binary.macroEnabled.12";
o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
o_rFileExtension = "xlsb";
}
else if (rProgID.startsWith("Excel.SheetMacroEnabled.12"))
{
o_rMediaType = "application/vnd.ms-excel.sheet.macroEnabled.12";
o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
o_rFileExtension = "xlsm";
}
else if (rProgID.startsWith("Excel.Sheet"))
{
o_rMediaType = "application/vnd.ms-excel";
o_rRelationType = oox::getRelationship(Relationship::OLEOBJECT);
o_rFileExtension = "xls";
}
else if (rProgID == "PowerPoint.Show.12")
{
o_rMediaType = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
o_rFileExtension = "pptx";
}
else if (rProgID == "PowerPoint.ShowMacroEnabled.12")
{
o_rMediaType = "application/vnd.ms-powerpoint.presentation.macroEnabled.12";
o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
o_rFileExtension = "pptm";
}
else if (rProgID.startsWith("PowerPoint.Show"))
{
o_rMediaType = "application/vnd.ms-powerpoint";
o_rRelationType = oox::getRelationship(Relationship::OLEOBJECT);
o_rFileExtension = "ppt";
}
else if (rProgID.startsWith("PowerPoint.Slide.12"))
{
o_rMediaType = "application/vnd.openxmlformats-officedocument.presentationml.slide";
o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
o_rFileExtension = "sldx";
}
else if (rProgID == "PowerPoint.SlideMacroEnabled.12")
{
o_rMediaType = "application/vnd.ms-powerpoint.slide.macroEnabled.12";
o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
o_rFileExtension = "sldm";
}
else if (rProgID == "Word.DocumentMacroEnabled.12")
{
o_rMediaType = "application/vnd.ms-word.document.macroEnabled.12";
o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
o_rFileExtension = "docm";
}
else if (rProgID == "Word.Document.12")
{
o_rMediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
o_rFileExtension = "docx";
}
else if (rProgID == "Word.Document.8")
{
o_rMediaType = "application/msword";
o_rRelationType = oox::getRelationship(Relationship::OLEOBJECT);
o_rFileExtension = "doc";
}
else if (rProgID == "Excel.Chart.8")
{
o_rMediaType = "application/vnd.ms-excel";
o_rRelationType = oox::getRelationship(Relationship::OLEOBJECT);
o_rFileExtension = "xls";
}
else if (rProgID == "AcroExch.Document.11")
{
o_rMediaType = "application/pdf";
o_rRelationType = oox::getRelationship(Relationship::OLEOBJECT);
o_rFileExtension = "pdf";
}
else
{
o_rMediaType = "application/vnd.openxmlformats-officedocument.oleObject";
o_rRelationType = oox::getRelationship(Relationship::OLEOBJECT);
o_rFileExtension = "bin";
}
}
static uno::Reference<io::XInputStream> lcl_StoreOwnAsOOXML(
uno::Reference<uno::XComponentContext> const& xContext,
uno::Reference<embed::XEmbeddedObject> const& xObj,
char const*& o_rpProgID,
OUString & o_rMediaType, OUString & o_rRelationType, OUString & o_rSuffix)
{
static struct {
struct {
sal_uInt32 n1;
sal_uInt16 n2, n3;
sal_uInt8 b8, b9, b10, b11, b12, b13, b14, b15;
} ClassId;
char const* pFilterName;
char const* pMediaType;
char const* pProgID;
char const* pSuffix;
} const s_Mapping[] = {
{ {SO3_SW_CLASSID_60}, "MS Word 2007 XML", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word.Document.12", "docx" },
{ {SO3_SC_CLASSID_60}, "Calc MS Excel 2007 XML", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel.Sheet.12", "xlsx" },
{ {SO3_SIMPRESS_CLASSID_60}, "Impress MS PowerPoint 2007 XML", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "PowerPoint.Show.12", "pptx" },
// FIXME: Draw does not appear to have a MSO format export filter?
// { {SO3_SDRAW_CLASSID}, "", "", "", "" },
{ {SO3_SCH_CLASSID_60}, "unused", "", "", "" },
{ {SO3_SM_CLASSID_60}, "unused", "", "", "" },
};
const char * pFilterName(nullptr);
SvGlobalName const classId(xObj->getClassID());
for (auto & i : s_Mapping)
{
auto const& rId(i.ClassId);
SvGlobalName const temp(rId.n1, rId.n2, rId.n3, rId.b8, rId.b9, rId.b10, rId.b11, rId.b12, rId.b13, rId.b14, rId.b15);
if (temp == classId)
{
assert(SvGlobalName(SO3_SCH_CLASSID_60) != classId); // chart should be written elsewhere!
assert(SvGlobalName(SO3_SM_CLASSID_60) != classId); // formula should be written elsewhere!
pFilterName = i.pFilterName;
o_rMediaType = OUString::createFromAscii(i.pMediaType);
o_rpProgID = i.pProgID;
o_rSuffix = OUString::createFromAscii(i.pSuffix);
o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
break;
}
}
if (!pFilterName)
{
SAL_WARN("oox.shape", "oox::GetOLEObjectStream: unknown ClassId " << classId.GetHexName());
return nullptr;
}
if (embed::EmbedStates::LOADED == xObj->getCurrentState())
{
xObj->changeState(embed::EmbedStates::RUNNING);
}
// use a temp stream - while it would work to store directly to a
// fragment stream, an error during export means we'd have to delete it
uno::Reference<io::XStream> const xTempStream(
xContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.comp.MemoryStream", xContext),
uno::UNO_QUERY_THROW);
uno::Sequence<beans::PropertyValue> args( comphelper::InitPropertySequence({
{ "OutputStream", Any(xTempStream->getOutputStream()) },
{ "FilterName", Any(OUString::createFromAscii(pFilterName)) }
}));
uno::Reference<frame::XStorable> xStorable(xObj->getComponent(), uno::UNO_QUERY);
try
{
xStorable->storeToURL("private:stream", args);
}
catch (uno::Exception const& e)
{
SAL_WARN("oox.shape", "oox::GetOLEObjectStream: " << e);
return nullptr;
}
xTempStream->getOutputStream()->closeOutput();
return xTempStream->getInputStream();
}
uno::Reference<io::XInputStream> GetOLEObjectStream(
uno::Reference<uno::XComponentContext> const& xContext,
uno::Reference<embed::XEmbeddedObject> const& xObj,
OUString const& i_rProgID,
OUString & o_rMediaType,
OUString & o_rRelationType,
OUString & o_rSuffix,
const char *& o_rpProgID)
{
uno::Reference<io::XInputStream> xInStream;
try
{
uno::Reference<document::XStorageBasedDocument> const xParent(
uno::Reference<container::XChild>(xObj, uno::UNO_QUERY_THROW)->getParent(),
uno::UNO_QUERY_THROW);
uno::Reference<embed::XStorage> const xParentStorage(xParent->getDocumentStorage());
OUString const entryName(
uno::Reference<embed::XEmbedPersist>(xObj, uno::UNO_QUERY_THROW)->getEntryName());
if (xParentStorage->isStreamElement(entryName))
{
lcl_ConvertProgID(i_rProgID, o_rMediaType, o_rRelationType, o_rSuffix);
xInStream = xParentStorage->cloneStreamElement(entryName)->getInputStream();
// TODO: make it possible to take the sMediaType from the stream
}
else // the object is ODF - either the whole document is
{ // ODF, or the OLE was edited so it was converted to ODF
xInStream = lcl_StoreOwnAsOOXML(xContext, xObj,
o_rpProgID, o_rMediaType, o_rRelationType, o_rSuffix);
}
}
catch (uno::Exception const& e)
{
SAL_WARN("oox.shape", "oox::GetOLEObjectStream: " << e);
}
return xInStream;
}
} // namespace oox
namespace oox { namespace drawingml {
URLTransformer::~URLTransformer()
{
}
OUString URLTransformer::getTransformedString(const OUString& rString) const
{
return rString;
}
bool URLTransformer::isExternalURL(const OUString& /*rURL*/) const
{
return true;
}
#define GETA(propName) \
GetProperty( rXPropSet, #propName)
#define GETAD(propName) \
( GetPropertyAndState( rXPropSet, rXPropState, #propName, eState ) && eState == beans::PropertyState_DIRECT_VALUE )
#define GET(variable, propName) \
if ( GETA(propName) ) \
mAny >>= variable;
ShapeExport::ShapeExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, ShapeHashMap* pShapeMap, XmlFilterBase* pFB, DocumentType eDocumentType, DMLTextExport* pTextExport )
: DrawingML( std::move(pFS), pFB, eDocumentType, pTextExport )
, m_nEmbeddedObjects(0)
, mnShapeIdMax( 1 )
, mnPictureIdMax( 1 )
, mnXmlNamespace( nXmlNamespace )
, maMapModeSrc( MapUnit::Map100thMM )
, maMapModeDest( MapUnit::MapInch, Point(), Fraction( 1, 576 ), Fraction( 1, 576 ) )
, mpShapeMap( pShapeMap ? pShapeMap : &maShapeMap )
{
mpURLTransformer.reset(new URLTransformer);
}
void ShapeExport::SetURLTranslator(const std::shared_ptr<URLTransformer>& pTransformer)
{
mpURLTransformer = pTransformer;
}
awt::Size ShapeExport::MapSize( const awt::Size& rSize ) const
{
Size aRetSize( OutputDevice::LogicToLogic( Size( rSize.Width, rSize.Height ), maMapModeSrc, maMapModeDest ) );
if ( !aRetSize.Width() )
aRetSize.AdjustWidth( 1 );
if ( !aRetSize.Height() )
aRetSize.AdjustHeight( 1 );
return awt::Size( aRetSize.Width(), aRetSize.Height() );
}
bool ShapeExport::NonEmptyText( const Reference< XInterface >& xIface )
{
Reference< XPropertySet > xPropSet( xIface, UNO_QUERY );
if( xPropSet.is() )
{
Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
if ( xPropSetInfo.is() )
{
if ( xPropSetInfo->hasPropertyByName( "IsEmptyPresentationObject" ) )
{
bool bIsEmptyPresObj = false;
if ( xPropSet->getPropertyValue( "IsEmptyPresentationObject" ) >>= bIsEmptyPresObj )
{
SAL_INFO("oox.shape", "empty presentation object " << bIsEmptyPresObj << " , props:");
if( bIsEmptyPresObj )
return true;
}
}
if ( xPropSetInfo->hasPropertyByName( "IsPresentationObject" ) )
{
bool bIsPresObj = false;
if ( xPropSet->getPropertyValue( "IsPresentationObject" ) >>= bIsPresObj )
{
SAL_INFO("oox.shape", "presentation object " << bIsPresObj << ", props:");
if( bIsPresObj )
return true;
}
}
}
}
Reference< XSimpleText > xText( xIface, UNO_QUERY );
if( xText.is() )
return xText->getString().getLength();
return false;
}
ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& xShape, bool bClosed )
{
SAL_INFO("oox.shape", "write polypolygon shape");
FSHelperPtr pFS = GetFS();
pFS->startElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp), FSEND );
tools::PolyPolygon aPolyPolygon = EscherPropertyContainer::GetPolyPolygon( xShape );
tools::Rectangle aRect( aPolyPolygon.GetBoundRect() );
#if OSL_DEBUG_LEVEL > 0
awt::Size size = MapSize( awt::Size( aRect.GetWidth(), aRect.GetHeight() ) );
SAL_INFO("oox.shape", "poly count " << aPolyPolygon.Count());
SAL_INFO("oox.shape", "size: " << size.Width << " x " << size.Height);
#endif
// non visual shape properties
if (GetDocumentType() != DOCUMENT_DOCX)
{
pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( GetNewShapeID( xShape ) ),
XML_name, IDS( Freeform ),
FSEND );
}
pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
if (GetDocumentType() != DOCUMENT_DOCX)
{
WriteNonVisualProperties( xShape );
pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
}
// visual shape properties
pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
WriteTransformation( aRect, XML_a );
WritePolyPolygon( aPolyPolygon );
Reference< XPropertySet > xProps( xShape, UNO_QUERY );
if( xProps.is() ) {
if( bClosed )
WriteFill( xProps );
WriteOutline( xProps );
}
pFS->endElementNS( mnXmlNamespace, XML_spPr );
// write text
WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp) );
return *this;
}
ShapeExport& ShapeExport::WriteClosedPolyPolygonShape( const Reference< XShape >& xShape )
{
return WritePolyPolygonShape( xShape, true );
}
ShapeExport& ShapeExport::WriteOpenPolyPolygonShape( const Reference< XShape >& xShape )
{
return WritePolyPolygonShape( xShape, false );
}
ShapeExport& ShapeExport::WriteGroupShape(const uno::Reference<drawing::XShape>& xShape)
{
FSHelperPtr pFS = GetFS();
sal_Int32 nGroupShapeToken = XML_grpSp;
if (GetDocumentType() == DOCUMENT_DOCX)
{
if (!m_xParent.is())
nGroupShapeToken = XML_wgp; // toplevel
else
mnXmlNamespace = XML_wpg;
}
pFS->startElementNS(mnXmlNamespace, nGroupShapeToken, FSEND);
// non visual properties
if (GetDocumentType() != DOCUMENT_DOCX)
{
pFS->startElementNS(mnXmlNamespace, XML_nvGrpSpPr, FSEND);
pFS->singleElementNS(mnXmlNamespace, XML_cNvPr,
XML_id, I32S(GetNewShapeID(xShape)),
XML_name, IDS(Group),
FSEND);
pFS->singleElementNS(mnXmlNamespace, XML_cNvGrpSpPr, FSEND);
WriteNonVisualProperties(xShape );
pFS->endElementNS(mnXmlNamespace, XML_nvGrpSpPr);
}
else
pFS->singleElementNS(mnXmlNamespace, XML_cNvGrpSpPr, FSEND);
// visual properties
pFS->startElementNS(mnXmlNamespace, XML_grpSpPr, FSEND);
WriteShapeTransformation(xShape, XML_a, false, false, true);
pFS->endElementNS(mnXmlNamespace, XML_grpSpPr);
uno::Reference<drawing::XShapes> xGroupShape(xShape, uno::UNO_QUERY_THROW);
uno::Reference<drawing::XShape> xParent = m_xParent;
m_xParent = xShape;
for (sal_Int32 i = 0; i < xGroupShape->getCount(); ++i)
{
uno::Reference<drawing::XShape> xChild(xGroupShape->getByIndex(i), uno::UNO_QUERY_THROW);
sal_Int32 nSavedNamespace = mnXmlNamespace;
uno::Reference<lang::XServiceInfo> xServiceInfo(xChild, uno::UNO_QUERY_THROW);
if (GetDocumentType() == DOCUMENT_DOCX)
{
if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
mnXmlNamespace = XML_pic;
else
mnXmlNamespace = XML_wps;
}
WriteShape(xChild);
mnXmlNamespace = nSavedNamespace;
}
m_xParent = xParent;
pFS->endElementNS(mnXmlNamespace, nGroupShapeToken);
return *this;
}
static bool lcl_IsOnBlacklist(OUString const & rShapeType)
{
static const std::initializer_list<OUStringLiteral> vBlacklist = {
"block-arc",
"rectangle",
"ellipse",
"ring",
"can",
"cube",
"paper",
"frame",
"smiley",
"sun",
"flower",
"bracket-pair",
"brace-pair",
"col-60da8460",
"col-502ad400",
"quad-bevel",
"round-rectangular-callout",
"rectangular-callout",
"round-callout",
"cloud-callout",
"line-callout-1",
"line-callout-2",
"line-callout-3",
"paper",
"vertical-scroll",
"horizontal-scroll",
"mso-spt34",
"mso-spt75",
"mso-spt164",
"mso-spt180",
"flowchart-process",
"flowchart-alternate-process",
"flowchart-decision",
"flowchart-data",
"flowchart-predefined-process",
"flowchart-internal-storage",
"flowchart-document",
"flowchart-multidocument",
"flowchart-terminator",
"flowchart-preparation",
"flowchart-manual-input",
"flowchart-manual-operation",
"flowchart-connector",
"flowchart-off-page-connector",
"flowchart-card",
"flowchart-punched-tape",
"flowchart-summing-junction",
"flowchart-or",
"flowchart-collate",
"flowchart-sort",
"flowchart-extract",
"flowchart-merge",
"flowchart-stored-data",
"flowchart-delay",
"flowchart-sequential-access",
"flowchart-magnetic-disk",
"flowchart-direct-access-storage",
"flowchart-display"
};
return std::find(vBlacklist.begin(), vBlacklist.end(), rShapeType) != vBlacklist.end();
}
static bool lcl_IsOnWhitelist(OUString const & rShapeType)
{
static const std::initializer_list<OUStringLiteral> vWhitelist = {
"forbidden",
"heart",
"puzzle"
};
return std::find(vWhitelist.begin(), vWhitelist.end(), rShapeType) != vWhitelist.end();
}
static bool lcl_GetHandlePosition( sal_Int32 &nValue, const EnhancedCustomShapeParameter &rParam, Sequence< EnhancedCustomShapeAdjustmentValue > &rSeq)
{
bool bAdj = false;
if ( rParam.Value.getValueTypeClass() == TypeClass_DOUBLE )
{
double fValue(0.0);
if ( rParam.Value >>= fValue )
nValue = static_cast<sal_Int32>(fValue);
}
else
rParam.Value >>= nValue;
if ( rParam.Type == EnhancedCustomShapeParameterType::ADJUSTMENT)
{
bAdj = true;
sal_Int32 nIdx = nValue;
if ( nIdx < rSeq.getLength() )
{
if ( rSeq[ nIdx ] .Value.getValueTypeClass() == TypeClass_DOUBLE )
{
double fValue(0.0);
rSeq[ nIdx ].Value >>= fValue;
nValue = fValue;
}
else
{
rSeq[ nIdx ].Value >>= nValue;
}
}
}
return bAdj;
}
static void lcl_AnalyzeHandles( const uno::Sequence<beans::PropertyValues> & rHandles,
std::vector< std::pair< sal_Int32, sal_Int32> > &rHandlePositionList,
Sequence< EnhancedCustomShapeAdjustmentValue > &rSeq)
{
sal_uInt16 k;
sal_uInt16 nHandles = rHandles.getLength();
for ( k = 0; k < nHandles ; k++ )
{
const OUString sPosition( "Position" );
bool bPosition = false;
EnhancedCustomShapeParameterPair aPosition;
EnhancedCustomShapeParameterPair aPolar;
const Sequence< PropertyValue >& rPropSeq = rHandles[ k ];
for ( const PropertyValue& rPropVal: rPropSeq )
{
if ( rPropVal.Name == sPosition )
{
if ( rPropVal.Value >>= aPosition )
bPosition = true;
}
}
if ( bPosition )
{
sal_Int32 nXPosition = 0;
sal_Int32 nYPosition = 0;
// For polar handles, nXPosition is radius and nYPosition is angle
lcl_GetHandlePosition( nXPosition, aPosition.First , rSeq );
lcl_GetHandlePosition( nYPosition, aPosition.Second, rSeq );
rHandlePositionList.emplace_back( nXPosition, nYPosition );
}
}
}
static void lcl_AppendAdjustmentValue( std::vector< std::pair< sal_Int32, sal_Int32> > &rAvList, sal_Int32 nAdjIdx, sal_Int32 nValue )
{
rAvList.emplace_back( nAdjIdx , nValue );
}
static sal_Int32 lcl_NormalizeAngle( sal_Int32 nAngle )
{
nAngle = nAngle % 360;
return nAngle < 0 ? ( nAngle + 360 ) : nAngle ;
}
ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
{
SAL_INFO("oox.shape", "write custom shape");
Reference< XPropertySet > rXPropSet( xShape, UNO_QUERY );
bool bPredefinedHandlesUsed = true;
bool bHasHandles = false;
OUString sShapeType;
ShapeFlag nMirrorFlags = ShapeFlag::NONE;
MSO_SPT eShapeType = EscherPropertyContainer::GetCustomShapeType( xShape, nMirrorFlags, sShapeType );
OSL_ENSURE(nullptr != dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(xShape)), "Not a SdrObjCustomShape (!)");
SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*GetSdrObjectFromXShape(xShape)));
const bool bIsDefaultObject(
EscherPropertyContainer::IsDefaultObject(
rSdrObjCustomShape,
eShapeType));
const char* sPresetShape = msfilter::util::GetOOXMLPresetGeometry(sShapeType.toUtf8().getStr());
SAL_INFO("oox.shape", "custom shape type: " << sShapeType << " ==> " << sPresetShape);
Sequence< PropertyValue > aGeometrySeq;
sal_Int32 nAdjustmentValuesIndex = -1;
awt::Rectangle aViewBox;
uno::Sequence<beans::PropertyValues> aHandles;
bool bFlipH = false;
bool bFlipV = false;
// Avoid interference of preset type to the next shape
m_presetWarp = "";
if( GETA( CustomShapeGeometry ) ) {
SAL_INFO("oox.shape", "got custom shape geometry");
if( mAny >>= aGeometrySeq ) {
SAL_INFO("oox.shape", "got custom shape geometry sequence");
for( int i = 0; i < aGeometrySeq.getLength(); i++ ) {
const PropertyValue& rProp = aGeometrySeq[ i ];
SAL_INFO("oox.shape", "geometry property: " << rProp.Name);
if ( rProp.Name == "MirroredX" )
rProp.Value >>= bFlipH;
if ( rProp.Name == "MirroredY" )
rProp.Value >>= bFlipV;
if ( rProp.Name == "AdjustmentValues" )
nAdjustmentValuesIndex = i;
else if ( rProp.Name == "Handles" )
{
rProp.Value >>= aHandles;
if ( aHandles.getLength() )
bHasHandles = true;
if( !bIsDefaultObject )
bPredefinedHandlesUsed = false;
// TODO: update nAdjustmentsWhichNeedsToBeConverted here
}
else if ( rProp.Name == "PresetTextWarp" )
{
rProp.Value >>= m_presetWarp;
}
else if ( rProp.Name == "ViewBox" )
rProp.Value >>= aViewBox;
}
}
}
FSHelperPtr pFS = GetFS();
pFS->startElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp), FSEND );
// non visual shape properties
if (GetDocumentType() != DOCUMENT_DOCX)
{
bool isVisible = true ;
if( GETA (Visible))
{
mAny >>= isVisible;
}
pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
pFS->startElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( GetNewShapeID( xShape ) ),
XML_name, IDS( CustomShape ),
XML_hidden, isVisible ? nullptr : "1",
FSEND );
if( GETA( URL ) )
{
OUString sURL;
mAny >>= sURL;
if( !sURL.isEmpty() )
{
OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
oox::getRelationship(Relationship::HYPERLINK),
mpURLTransformer->getTransformedString(sURL),
mpURLTransformer->isExternalURL(sURL));
mpFS->singleElementNS( XML_a, XML_hlinkClick,
FSNS(XML_r,XML_id), sRelId.toUtf8(),
FSEND );
}
}
pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
WriteNonVisualProperties( xShape );
pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
}
else
pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr, FSEND);
// visual shape properties
pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
// moon is flipped in MSO, and mso-spt89 (right up arrow) is mapped to leftUpArrow
if ( sShapeType == "moon" || sShapeType == "mso-spt89" )
bFlipH = !bFlipH;
// we export non-primitive shapes to custom geometry
// we also export non-ooxml shapes which have handles/equations to custom geometry, because
// we cannot convert ODF equations to DrawingML equations. TODO: see what binary DOC export filter does.
// but our WritePolyPolygon()/WriteCustomGeometry() functions are incomplete, therefore we use a blacklist
// we use a whitelist for shapes where mapping to MSO preset shape is not optimal
bool bCustGeom = true;
bool bOnBlacklist = false;
if( sShapeType == "ooxml-non-primitive" )
bCustGeom = true;
else if( sShapeType.startsWith("ooxml") )
bCustGeom = false;
else if( lcl_IsOnWhitelist(sShapeType) )
bCustGeom = true;
else if( lcl_IsOnBlacklist(sShapeType) )
{
bCustGeom = false;
bOnBlacklist = true;
}
else if( bHasHandles )
bCustGeom = true;
if (bHasHandles && bCustGeom)
{
WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV, false, true );// do not flip, polypolygon coordinates are flipped already
tools::PolyPolygon aPolyPolygon( rSdrObjCustomShape.GetLineGeometry(true) );
sal_Int32 nRotation = 0;
// The RotateAngle property's value is independent from any flipping, and that's exactly what we need here.
uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
if (xPropertySetInfo->hasPropertyByName("RotateAngle"))
xPropertySet->getPropertyValue("RotateAngle") >>= nRotation;
// Remove rotation
bool bInvertRotation = bFlipH != bFlipV;
if (nRotation != 0)
aPolyPolygon.Rotate(Point(0,0), static_cast<sal_uInt16>(bInvertRotation ? nRotation/10 : 3600-nRotation/10));
WritePolyPolygon( aPolyPolygon );
}
else if (bCustGeom)
{
WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV );
bool bSuccess = WriteCustomGeometry(xShape, rSdrObjCustomShape);
if (!bSuccess)
WritePresetShape( sPresetShape );
}
else if (bOnBlacklist && bHasHandles && nAdjustmentValuesIndex !=-1 && !sShapeType.startsWith("mso-spt"))
{
WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV );
Sequence< EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq;
std::vector< std::pair< sal_Int32, sal_Int32> > aHandlePositionList;
std::vector< std::pair< sal_Int32, sal_Int32> > aAvList;
aGeometrySeq[ nAdjustmentValuesIndex ].Value >>= aAdjustmentSeq ;
lcl_AnalyzeHandles( aHandles, aHandlePositionList, aAdjustmentSeq );
sal_Int32 nXPosition = 0;
sal_Int32 nYPosition = 0;
if ( !aHandlePositionList.empty() )
{
nXPosition = aHandlePositionList[0].first ;
nYPosition = aHandlePositionList[0].second ;
}
switch( eShapeType )
{
case mso_sptBorderCallout1:
{
sal_Int32 adj3 = double(nYPosition)/aViewBox.Height *100000;
sal_Int32 adj4 = double(nXPosition)/aViewBox.Width *100000;
lcl_AppendAdjustmentValue( aAvList, 1, 18750 );
lcl_AppendAdjustmentValue( aAvList, 2, -8333 );
lcl_AppendAdjustmentValue( aAvList, 3, adj3 );
lcl_AppendAdjustmentValue( aAvList, 4, adj4 );
break;
}
case mso_sptBorderCallout2:
{
sal_Int32 adj5 = double(nYPosition)/aViewBox.Height *100000;
sal_Int32 adj6 = double(nXPosition)/aViewBox.Width *100000;
sal_Int32 adj3 = 18750;
sal_Int32 adj4 = -16667;
lcl_AppendAdjustmentValue( aAvList, 1, 18750 );
lcl_AppendAdjustmentValue( aAvList, 2, -8333 );
if ( aHandlePositionList.size() > 1 )
{
nXPosition = aHandlePositionList[1].first ;
nYPosition = aHandlePositionList[1].second ;
adj3 = double(nYPosition)/aViewBox.Height *100000;
adj4 = double(nXPosition)/aViewBox.Width *100000;
}
lcl_AppendAdjustmentValue( aAvList, 3, adj3 );
lcl_AppendAdjustmentValue( aAvList, 4, adj4 );
lcl_AppendAdjustmentValue( aAvList, 5, adj5 );
lcl_AppendAdjustmentValue( aAvList, 6, adj6 );
break;
}
case mso_sptWedgeRectCallout:
case mso_sptWedgeRRectCallout:
case mso_sptWedgeEllipseCallout:
case mso_sptCloudCallout:
{
sal_Int32 adj1 = (double(nXPosition)/aViewBox.Width -0.5) *100000;
sal_Int32 adj2 = (double(nYPosition)/aViewBox.Height -0.5) *100000;
lcl_AppendAdjustmentValue( aAvList, 1, adj1 );
lcl_AppendAdjustmentValue( aAvList, 2, adj2 );
if ( eShapeType == mso_sptWedgeRRectCallout)
{
lcl_AppendAdjustmentValue( aAvList, 3, 16667);
}
break;
}
case mso_sptFoldedCorner:
{
sal_Int32 adj = double( aViewBox.Width - nXPosition) / std::min( aViewBox.Width,aViewBox.Height ) * 100000;
lcl_AppendAdjustmentValue( aAvList, 0, adj );
break;
}
case mso_sptDonut:
case mso_sptSun:
case mso_sptMoon:
case mso_sptHorizontalScroll:
case mso_sptBevel:
case mso_sptBracketPair:
{
sal_Int32 adj = double( nXPosition )/aViewBox.Width*100000 ;
lcl_AppendAdjustmentValue( aAvList, 0, adj );
break;
}
case mso_sptCan:
case mso_sptCube:
case mso_sptBracePair:
case mso_sptVerticalScroll:
{
sal_Int32 adj = double( nYPosition )/aViewBox.Height *100000 ;
lcl_AppendAdjustmentValue( aAvList, 0, adj );
break;
}
case mso_sptSmileyFace:
{
sal_Int32 adj = double( nYPosition )/aViewBox.Height *100000 - 76458.0;
lcl_AppendAdjustmentValue( aAvList, 0, adj );
break;
}
case mso_sptBlockArc:
{
sal_Int32 nRadius = 50000 * ( 1 - double(nXPosition) / 10800);
sal_Int32 nAngleStart = lcl_NormalizeAngle( nYPosition );
sal_Int32 nAngleEnd = lcl_NormalizeAngle( 180 - nAngleStart );
lcl_AppendAdjustmentValue( aAvList, 1, 21600000 / 360 * nAngleStart );
lcl_AppendAdjustmentValue( aAvList, 2, 21600000 / 360 * nAngleEnd );
lcl_AppendAdjustmentValue( aAvList, 3, nRadius );
break;
}
// case mso_sptNil:
// case mso_sptBentConnector3:
// case mso_sptBorderCallout3:
default:
{
if (!strcmp( sPresetShape, "frame" ))
{
sal_Int32 adj1 = double( nYPosition )/aViewBox.Height *100000 ;
lcl_AppendAdjustmentValue( aAvList, 1, adj1 );
}
break;
}
}
WritePresetShape( sPresetShape , aAvList );
}
else // preset geometry
{
WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV );
if( nAdjustmentValuesIndex != -1 )
{
WritePresetShape( sPresetShape, eShapeType, bPredefinedHandlesUsed,
aGeometrySeq[ nAdjustmentValuesIndex ] );
}
else
WritePresetShape( sPresetShape );
}
if( rXPropSet.is() )
{
// Preset shape with text has no fill
if( m_presetWarp.isEmpty() || !m_presetWarp.startsWith( "text" ) || m_presetWarp == "textNoShape" )
WriteFill( rXPropSet );
WriteOutline( rXPropSet );
WriteShapeEffects( rXPropSet );
WriteShape3DEffects( rXPropSet );
}
pFS->endElementNS( mnXmlNamespace, XML_spPr );
pFS->startElementNS( mnXmlNamespace, XML_style, FSEND );
WriteShapeStyle( rXPropSet );
pFS->endElementNS( mnXmlNamespace, XML_style );
// write text
WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp) );
return *this;
}
ShapeExport& ShapeExport::WriteEllipseShape( const Reference< XShape >& xShape )
{
SAL_INFO("oox.shape", "write ellipse shape");
FSHelperPtr pFS = GetFS();
pFS->startElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp), FSEND );
// TODO: arc, section, cut, connector
// non visual shape properties
if (GetDocumentType() != DOCUMENT_DOCX)
{
pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( GetNewShapeID( xShape ) ),
XML_name, IDS( Ellipse ),
FSEND );
pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
WriteNonVisualProperties( xShape );
pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
}
else
pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr, FSEND);
// visual shape properties
pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
WriteShapeTransformation( xShape, XML_a );
WritePresetShape( "ellipse" );
Reference< XPropertySet > xProps( xShape, UNO_QUERY );
if( xProps.is() )
{
WriteFill( xProps );
WriteOutline( xProps );
}
pFS->endElementNS( mnXmlNamespace, XML_spPr );
// write text
WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp) );
return *this;
}
ShapeExport& ShapeExport::WriteGraphicObjectShape( const Reference< XShape >& xShape )
{
WriteGraphicObjectShapePart( xShape );
return *this;
}
void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape, const Graphic* pGraphic )
{
SAL_INFO("oox.shape", "write graphic object shape");
if( NonEmptyText( xShape ) )
{
// avoid treating all 'IsPresentationObject' objects as having text.
Reference< XSimpleText > xText( xShape, UNO_QUERY );
if( xText.is() && !xText->getString().isEmpty() )
{
SAL_INFO("oox.shape", "graphicObject: wrote only text");
WriteTextShape( xShape );
return;
}
}
SAL_INFO("oox.shape", "graphicObject without text");
uno::Reference<graphic::XGraphic> xGraphic;
OUString sMediaURL;
Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
if (pGraphic)
{
xGraphic.set(pGraphic->GetXGraphic());
}
else if (xShapeProps.is() && xShapeProps->getPropertySetInfo()->hasPropertyByName("Graphic"))
{
xShapeProps->getPropertyValue("Graphic") >>= xGraphic;
}
bool bHasMediaURL = xShapeProps.is() && xShapeProps->getPropertySetInfo()->hasPropertyByName("MediaURL") && (xShapeProps->getPropertyValue("MediaURL") >>= sMediaURL);
if (!xGraphic.is() && !bHasMediaURL)
{
SAL_INFO("oox.shape", "no graphic or media URL found");
return;
}
FSHelperPtr pFS = GetFS();
XmlFilterBase* pFB = GetFB();
if (GetDocumentType() != DOCUMENT_DOCX)
pFS->startElementNS( mnXmlNamespace, XML_pic, FSEND );
else
pFS->startElementNS( mnXmlNamespace, XML_pic,
FSNS(XML_xmlns, XML_pic), OUStringToOString(pFB->getNamespaceURL(OOX_NS(dmlPicture)), RTL_TEXTENCODING_UTF8).getStr(),
FSEND );
pFS->startElementNS( mnXmlNamespace, XML_nvPicPr, FSEND );
OUString sName, sDescr, sURL;
bool bHaveName, bHaveDesc, bHaveURL;
if ( ( bHaveName= GetProperty( xShapeProps, "Name" ) ) )
mAny >>= sName;
if ( ( bHaveDesc = GetProperty( xShapeProps, "Description" ) ) )
mAny >>= sDescr;
if ( ( bHaveURL = GetProperty( xShapeProps, "URL" ) ) )
mAny >>= sURL;
pFS->startElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( GetNewShapeID( xShape ) ),
XML_name, bHaveName
? sName.toUtf8()
: OString("Picture " + OString::number(mnPictureIdMax++)),
XML_descr, bHaveDesc ? sDescr.toUtf8().getStr() : nullptr,
FSEND );
// OOXTODO: //cNvPr children: XML_extLst, XML_hlinkHover
if (bHasMediaURL)
pFS->singleElementNS(XML_a, XML_hlinkClick,
FSNS(XML_r, XML_id), "",
XML_action, "ppaction://media",
FSEND);
if( !sURL.isEmpty() )
{
OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
oox::getRelationship(Relationship::HYPERLINK),
mpURLTransformer->getTransformedString(sURL),
mpURLTransformer->isExternalURL(sURL));
mpFS->singleElementNS( XML_a, XML_hlinkClick,
FSNS( XML_r,XML_id ), OUStringToOString( sRelId, RTL_TEXTENCODING_UTF8 ).getStr(),
FSEND );
}
pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
pFS->singleElementNS( mnXmlNamespace, XML_cNvPicPr,
// OOXTODO: XML_preferRelativeSize
FSEND );
if (bHasMediaURL)
WriteMediaNonVisualProperties(xShape);
else
WriteNonVisualProperties(xShape);
pFS->endElementNS( mnXmlNamespace, XML_nvPicPr );
pFS->startElementNS( mnXmlNamespace, XML_blipFill, FSEND );
if (xGraphic.is())
{
WriteXGraphicBlip(xShapeProps, xGraphic, false);
}
else if (bHasMediaURL)
{
Reference<graphic::XGraphic> xFallbackGraphic;
if (xShapeProps->getPropertySetInfo()->hasPropertyByName("FallbackGraphic"))
xShapeProps->getPropertyValue("FallbackGraphic") >>= xFallbackGraphic;
WriteXGraphicBlip(xShapeProps, xFallbackGraphic, false);
}
if (xGraphic.is())
{
WriteSrcRectXGraphic(xShapeProps, xGraphic);
}
// now we stretch always when we get pGraphic (when changing that
// behavior, test n#780830 for regression, where the OLE sheet might get tiled
bool bStretch = false;
if( !pGraphic && GetProperty( xShapeProps, "FillBitmapStretch" ) )
mAny >>= bStretch;
if ( pGraphic || bStretch )
pFS->singleElementNS( XML_a, XML_stretch, FSEND );
pFS->endElementNS( mnXmlNamespace, XML_blipFill );
// visual shape properties
pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
bool bFlipH = false;
if( xShapeProps->getPropertySetInfo()->hasPropertyByName("IsMirrored") )
{
xShapeProps->getPropertyValue("IsMirrored") >>= bFlipH;
}
WriteShapeTransformation( xShape, XML_a, bFlipH, false, false, false, true );
WritePresetShape( "rect" );
// graphic object can come with the frame (bnc#654525)
WriteOutline( xShapeProps );
WriteShapeEffects( xShapeProps );
WriteShape3DEffects( xShapeProps );
pFS->endElementNS( mnXmlNamespace, XML_spPr );
pFS->endElementNS( mnXmlNamespace, XML_pic );
}
ShapeExport& ShapeExport::WriteConnectorShape( const Reference< XShape >& xShape )
{
bool bFlipH = false;
bool bFlipV = false;
SAL_INFO("oox.shape", "write connector shape");
FSHelperPtr pFS = GetFS();
const char* sGeometry = "line";
Reference< XPropertySet > rXPropSet( xShape, UNO_QUERY );
Reference< XPropertyState > rXPropState( xShape, UNO_QUERY );
awt::Point aStartPoint, aEndPoint;
Reference< XShape > rXShapeA;
Reference< XShape > rXShapeB;
PropertyState eState;
ConnectorType eConnectorType;
if( GETAD( EdgeKind ) ) {
mAny >>= eConnectorType;
switch( eConnectorType ) {
case ConnectorType_CURVE:
sGeometry = "curvedConnector3";
break;
case ConnectorType_STANDARD:
sGeometry = "bentConnector3";
break;
default:
case ConnectorType_LINE:
case ConnectorType_LINES:
sGeometry = "straightConnector1";
break;
}
if( GETAD( EdgeStartPoint ) ) {
mAny >>= aStartPoint;
if( GETAD( EdgeEndPoint ) ) {
mAny >>= aEndPoint;
}
}
GET( rXShapeA, EdgeStartConnection );
GET( rXShapeB, EdgeEndConnection );
}
EscherConnectorListEntry aConnectorEntry( xShape, aStartPoint, rXShapeA, aEndPoint, rXShapeB );
tools::Rectangle aRect( Point( aStartPoint.X, aStartPoint.Y ), Point( aEndPoint.X, aEndPoint.Y ) );
if( aRect.getWidth() < 0 ) {
bFlipH = true;
aRect.setX( aEndPoint.X );
aRect.setWidth( aStartPoint.X - aEndPoint.X );
}
if( aRect.getHeight() < 0 ) {
bFlipV = true;
aRect.setY( aEndPoint.Y );
aRect.setHeight( aStartPoint.Y - aEndPoint.Y );
}
pFS->startElementNS( mnXmlNamespace, XML_cxnSp, FSEND );
// non visual shape properties
pFS->startElementNS( mnXmlNamespace, XML_nvCxnSpPr, FSEND );
pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( GetNewShapeID( xShape ) ),
XML_name, IDS( Line ),
FSEND );
// non visual connector shape drawing properties
pFS->startElementNS( mnXmlNamespace, XML_cNvCxnSpPr, FSEND );
WriteConnectorConnections( aConnectorEntry, GetShapeID( rXShapeA ), GetShapeID( rXShapeB ) );
pFS->endElementNS( mnXmlNamespace, XML_cNvCxnSpPr );
pFS->singleElementNS( mnXmlNamespace, XML_nvPr, FSEND );
pFS->endElementNS( mnXmlNamespace, XML_nvCxnSpPr );
// visual shape properties
pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
WriteTransformation( aRect, XML_a, bFlipH, bFlipV );
// TODO: write adjustments (ppt export doesn't work well there either)
WritePresetShape( sGeometry );
Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
if( xShapeProps.is() )
WriteOutline( xShapeProps );
pFS->endElementNS( mnXmlNamespace, XML_spPr );
// write text
WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, XML_cxnSp );
return *this;
}
ShapeExport& ShapeExport::WriteLineShape( const Reference< XShape >& xShape )
{
bool bFlipH = false;
bool bFlipV = false;
SAL_INFO("oox.shape", "write line shape");
FSHelperPtr pFS = GetFS();
pFS->startElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp), FSEND );
tools::PolyPolygon aPolyPolygon = EscherPropertyContainer::GetPolyPolygon( xShape );
if( aPolyPolygon.Count() == 1 && aPolyPolygon[ 0 ].GetSize() == 2)
{
const tools::Polygon& rPoly = aPolyPolygon[ 0 ];
bFlipH = ( rPoly[ 0 ].X() > rPoly[ 1 ].X() );
bFlipV = ( rPoly[ 0 ].Y() > rPoly[ 1 ].Y() );
}
// non visual shape properties
if (GetDocumentType() != DOCUMENT_DOCX)
{
pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( GetNewShapeID( xShape ) ),
XML_name, IDS( Line ),
FSEND );
}
pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
if (GetDocumentType() != DOCUMENT_DOCX)
{
WriteNonVisualProperties( xShape );
pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
}
// visual shape properties
pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV, true);
WritePresetShape( "line" );
Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
if( xShapeProps.is() )
WriteOutline( xShapeProps );
pFS->endElementNS( mnXmlNamespace, XML_spPr );
//write style
pFS->startElementNS( mnXmlNamespace, XML_style, FSEND );
WriteShapeStyle( xShapeProps );
pFS->endElementNS( mnXmlNamespace, XML_style );
// write text
WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp) );
return *this;
}
ShapeExport& ShapeExport::WriteNonVisualDrawingProperties( const Reference< XShape >& xShape, const char* pName )
{
GetFS()->singleElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( GetNewShapeID( xShape ) ),
XML_name, pName,
FSEND );
return *this;
}
ShapeExport& ShapeExport::WriteNonVisualProperties( const Reference< XShape >& )
{
// Override to generate //nvPr elements.
return *this;
}
ShapeExport& ShapeExport::WriteRectangleShape( const Reference< XShape >& xShape )
{
SAL_INFO("oox.shape", "write rectangle shape");
FSHelperPtr pFS = GetFS();
pFS->startElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp), FSEND );
sal_Int32 nRadius = 0;
Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
if( xShapeProps.is() )
{
xShapeProps->getPropertyValue( "CornerRadius" ) >>= nRadius;
}
if( nRadius )
{
nRadius = MapSize( awt::Size( nRadius, 0 ) ).Width;
}
//TODO: use nRadius value more precisely than just deciding whether to use
// "rect" or "roundRect" preset shape below
// non visual shape properties
if (GetDocumentType() == DOCUMENT_DOCX)
pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( GetNewShapeID( xShape ) ),
XML_name, IDS( Rectangle ),
FSEND );
pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
WriteNonVisualProperties( xShape );
pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
// visual shape properties
pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
WriteShapeTransformation( xShape, XML_a );
WritePresetShape( nRadius == 0 ? "rect" : "roundRect" );
Reference< XPropertySet > xProps( xShape, UNO_QUERY );
if( xProps.is() )
{
WriteFill( xProps );
WriteOutline( xProps );
}
pFS->endElementNS( mnXmlNamespace, XML_spPr );
// write text
WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp) );
return *this;
}
typedef ShapeExport& (ShapeExport::*ShapeConverter)( const Reference< XShape >& );
typedef std::unordered_map< const char*, ShapeConverter, rtl::CStringHash, rtl::CStringEqual> NameToConvertMapType;
static const NameToConvertMapType& lcl_GetConverters()
{
static NameToConvertMapType const shape_converters
{
{ "com.sun.star.drawing.ClosedBezierShape" , &ShapeExport::WriteClosedPolyPolygonShape },
{ "com.sun.star.drawing.ConnectorShape" , &ShapeExport::WriteConnectorShape },
{ "com.sun.star.drawing.CustomShape" , &ShapeExport::WriteCustomShape },
{ "com.sun.star.drawing.EllipseShape" , &ShapeExport::WriteEllipseShape },
{ "com.sun.star.drawing.GraphicObjectShape" , &ShapeExport::WriteGraphicObjectShape },
{ "com.sun.star.drawing.LineShape" , &ShapeExport::WriteLineShape },
{ "com.sun.star.drawing.OpenBezierShape" , &ShapeExport::WriteOpenPolyPolygonShape },
{ "com.sun.star.drawing.PolyPolygonShape" , &ShapeExport::WriteClosedPolyPolygonShape },
{ "com.sun.star.drawing.PolyLineShape" , &ShapeExport::WriteClosedPolyPolygonShape },
{ "com.sun.star.drawing.RectangleShape" , &ShapeExport::WriteRectangleShape },
{ "com.sun.star.drawing.OLE2Shape" , &ShapeExport::WriteOLE2Shape },
{ "com.sun.star.drawing.TableShape" , &ShapeExport::WriteTableShape },
{ "com.sun.star.drawing.TextShape" , &ShapeExport::WriteTextShape },
{ "com.sun.star.drawing.GroupShape" , &ShapeExport::WriteGroupShape },
{ "com.sun.star.presentation.GraphicObjectShape" , &ShapeExport::WriteGraphicObjectShape },
{ "com.sun.star.presentation.MediaShape" , &ShapeExport::WriteGraphicObjectShape },
{ "com.sun.star.presentation.OLE2Shape" , &ShapeExport::WriteOLE2Shape },
{ "com.sun.star.presentation.TableShape" , &ShapeExport::WriteTableShape },
{ "com.sun.star.presentation.TextShape" , &ShapeExport::WriteTextShape },
{ "com.sun.star.presentation.DateTimeShape" , &ShapeExport::WriteTextShape },
{ "com.sun.star.presentation.FooterShape" , &ShapeExport::WriteTextShape },
{ "com.sun.star.presentation.HeaderShape" , &ShapeExport::WriteTextShape },
{ "com.sun.star.presentation.NotesShape" , &ShapeExport::WriteTextShape },
{ "com.sun.star.presentation.OutlinerShape" , &ShapeExport::WriteTextShape },
{ "com.sun.star.presentation.SlideNumberShape" , &ShapeExport::WriteTextShape },
{ "com.sun.star.presentation.TitleTextShape" , &ShapeExport::WriteTextShape },
};
return shape_converters;
}
ShapeExport& ShapeExport::WriteShape( const Reference< XShape >& xShape )
{
OUString sShapeType = xShape->getShapeType();
SAL_INFO("oox.shape", "write shape: " << sShapeType);
NameToConvertMapType::const_iterator aConverter
= lcl_GetConverters().find(sShapeType.toUtf8().getStr());
if (aConverter == lcl_GetConverters().end())
{
SAL_INFO("oox.shape", "unknown shape");
return WriteUnknownShape( xShape );
}
(this->*(aConverter->second))( xShape );
return *this;
}
ShapeExport& ShapeExport::WriteTextBox( const Reference< XInterface >& xIface, sal_Int32 nXmlNamespace )
{
// In case this shape has an associated textbox, then export that, and we're done.
if (GetDocumentType() == DOCUMENT_DOCX && GetTextExport())
{
uno::Reference<beans::XPropertySet> xPropertySet(xIface, uno::UNO_QUERY);
if (xPropertySet.is())
{
uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
if (xPropertySetInfo->hasPropertyByName("TextBox") && xPropertySet->getPropertyValue("TextBox").get<bool>())
{
GetTextExport()->WriteTextBox(uno::Reference<drawing::XShape>(xIface, uno::UNO_QUERY_THROW));
WriteText( xIface, m_presetWarp, /*bBodyPr=*/true, /*bText=*/false, /*nXmlNamespace=*/nXmlNamespace );
return *this;
}
}
}
Reference< XText > xXText( xIface, UNO_QUERY );
if( NonEmptyText( xIface ) && xXText.is() )
{
FSHelperPtr pFS = GetFS();
pFS->startElementNS( nXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_txBody : XML_txbx), FSEND );
WriteText( xIface, m_presetWarp, /*bBodyPr=*/(GetDocumentType() != DOCUMENT_DOCX) );
pFS->endElementNS( nXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_txBody : XML_txbx) );
if (GetDocumentType() == DOCUMENT_DOCX)
WriteText( xIface, m_presetWarp, /*bBodyPr=*/true, /*bText=*/false, /*nXmlNamespace=*/nXmlNamespace );
}
else if (GetDocumentType() == DOCUMENT_DOCX)
mpFS->singleElementNS(nXmlNamespace, XML_bodyPr, FSEND);
return *this;
}
void ShapeExport::WriteTable( const Reference< XShape >& rXShape )
{
Reference< XTable > xTable;
Reference< XPropertySet > xPropSet( rXShape, UNO_QUERY );
mpFS->startElementNS( XML_a, XML_graphic, FSEND );
mpFS->startElementNS( XML_a, XML_graphicData, XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/table", FSEND );
if ( xPropSet.is() && ( xPropSet->getPropertyValue( "Model" ) >>= xTable ) )
{
mpFS->startElementNS( XML_a, XML_tbl, FSEND );
mpFS->singleElementNS( XML_a, XML_tblPr, FSEND );
Reference< container::XIndexAccess > xColumns( xTable->getColumns(), UNO_QUERY_THROW );
Reference< container::XIndexAccess > xRows( xTable->getRows(), UNO_QUERY_THROW );
sal_uInt16 nRowCount = static_cast< sal_uInt16 >( xRows->getCount() );
sal_uInt16 nColumnCount = static_cast< sal_uInt16 >( xColumns->getCount() );
mpFS->startElementNS( XML_a, XML_tblGrid, FSEND );
for ( sal_Int32 x = 0; x < nColumnCount; x++ )
{
Reference< XPropertySet > xColPropSet( xColumns->getByIndex( x ), UNO_QUERY_THROW );
sal_Int32 nWidth(0);
xColPropSet->getPropertyValue( "Width" ) >>= nWidth;
mpFS->singleElementNS( XML_a, XML_gridCol, XML_w, I64S(oox::drawingml::convertHmmToEmu(nWidth)), FSEND );
}
mpFS->endElementNS( XML_a, XML_tblGrid );
// map for holding the transpose index of the merged cells and pair<parentTransposeIndex, parentCell>
typedef std::unordered_map<sal_Int32, std::pair<sal_Int32, Reference< XMergeableCell> > > transposeTableMap;
transposeTableMap mergedCellMap;
for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
{
Reference< XPropertySet > xRowPropSet( xRows->getByIndex( nRow ), UNO_QUERY_THROW );
sal_Int32 nRowHeight(0);
xRowPropSet->getPropertyValue( "Height" ) >>= nRowHeight;
mpFS->startElementNS( XML_a, XML_tr, XML_h, I64S( oox::drawingml::convertHmmToEmu( nRowHeight ) ), FSEND );
for( sal_Int32 nColumn = 0; nColumn < nColumnCount; nColumn++ )
{
Reference< XMergeableCell > xCell( xTable->getCellByPosition( nColumn, nRow ),
UNO_QUERY_THROW );
sal_Int32 transposedIndexofCell = (nRow * nColumnCount) + nColumn;
//assume we will open a cell, set to false below if we won't
bool bCellOpened = true;
if(xCell->getColumnSpan() > 1 && xCell->getRowSpan() > 1)
{
// having both : horizontal and vertical merge
mpFS->startElementNS(XML_a, XML_tc, XML_gridSpan,
I32S(xCell->getColumnSpan()),
XML_rowSpan, I32S(xCell->getRowSpan()),
FSEND);
// since, XMergeableCell doesn't have the information about
// cell having hMerge or vMerge.
// So, Populating the merged cell map in-order to use it to
// decide the attribute for the individual cell.
for(sal_Int32 columnIndex = nColumn; columnIndex < nColumn+xCell->getColumnSpan(); ++columnIndex)
{
for(sal_Int32 rowIndex = nRow; rowIndex < nRow+xCell->getRowSpan(); ++rowIndex)
{
sal_Int32 transposeIndexForMergeCell =
(rowIndex * nColumnCount) + columnIndex;
mergedCellMap[transposeIndexForMergeCell] =
std::make_pair(transposedIndexofCell, xCell);
}
}
}
else if(xCell->getColumnSpan() > 1)
{
// having : horizontal merge
mpFS->startElementNS(XML_a, XML_tc, XML_gridSpan,
I32S(xCell->getColumnSpan()), FSEND);
for(sal_Int32 columnIndex = nColumn; columnIndex < nColumn + xCell->getColumnSpan(); ++columnIndex) {
sal_Int32 transposeIndexForMergeCell = (nRow*nColumnCount) + columnIndex;
mergedCellMap[transposeIndexForMergeCell] =
std::make_pair(transposedIndexofCell, xCell);
}
}
else if(xCell->getRowSpan() > 1)
{
// having : vertical merge
mpFS->startElementNS(XML_a, XML_tc, XML_rowSpan,
I32S(xCell->getRowSpan()), FSEND);
for(sal_Int32 rowIndex = nRow; rowIndex < nRow + xCell->getRowSpan(); ++rowIndex) {
sal_Int32 transposeIndexForMergeCell = (rowIndex*nColumnCount) + nColumn;
mergedCellMap[transposeIndexForMergeCell] =
std::make_pair(transposedIndexofCell, xCell);
}
}
else
{
// now, the cell can be an independent cell or
// it can be a cell which is been merged to some parent cell
if(!xCell->isMerged())
{
// independent cell
mpFS->startElementNS( XML_a, XML_tc, FSEND );
}
else
{
// it a merged cell to some parent cell
// find the parent cell for the current cell at hand
transposeTableMap::iterator it = mergedCellMap.find(transposedIndexofCell);
if(it != mergedCellMap.end())
{
sal_Int32 transposeIndexOfParent = it->second.first;
Reference< XMergeableCell > parentCell = it->second.second;
// finding the row and column index for the parent cell from transposed index
sal_Int32 parentColumnIndex = transposeIndexOfParent % nColumnCount;
sal_Int32 parentRowIndex = transposeIndexOfParent / nColumnCount;
if(nColumn == parentColumnIndex)
{
// the cell is vertical merge and it might have gridspan
if(parentCell->getColumnSpan() > 1)
{
// vMerge and has gridSpan
mpFS->startElementNS( XML_a, XML_tc,
XML_vMerge, I32S(1),
XML_gridSpan, I32S(xCell->getColumnSpan()),
FSEND );
}
else
{
// only vMerge
mpFS->startElementNS( XML_a, XML_tc,
XML_vMerge, I32S(1), FSEND );
}
}
else if(nRow == parentRowIndex)
{
// the cell is horizontal merge and it might have rowspan
if(parentCell->getRowSpan() > 1)
{
// hMerge and has rowspan
mpFS->startElementNS( XML_a, XML_tc,
XML_hMerge, I32S(1),
XML_rowSpan, I32S(xCell->getRowSpan()),
FSEND );
}
else
{
// only hMerge
mpFS->startElementNS( XML_a, XML_tc,
XML_hMerge, I32S(1), FSEND );
}
}
else
{
// has hMerge and vMerge
mpFS->startElementNS( XML_a, XML_tc,
XML_vMerge, I32S(1),
XML_hMerge, I32S(1),
FSEND );
}
}
else
bCellOpened = false;
}
}
if (bCellOpened)
{
WriteTextBox( xCell, XML_a );
Reference< XPropertySet > xCellPropSet(xCell, UNO_QUERY_THROW);
WriteTableCellProperties(xCellPropSet);
mpFS->endElementNS( XML_a, XML_tc );
}
}
mpFS->endElementNS( XML_a, XML_tr );
}
mpFS->endElementNS( XML_a, XML_tbl );
}
mpFS->endElementNS( XML_a, XML_graphicData );
mpFS->endElementNS( XML_a, XML_graphic );
}
void ShapeExport::WriteTableCellProperties(const Reference< XPropertySet>& xCellPropSet)
{
sal_Int32 nLeftMargin(0), nRightMargin(0);
Any aLeftMargin = xCellPropSet->getPropertyValue("TextLeftDistance");
aLeftMargin >>= nLeftMargin;
Any aRightMargin = xCellPropSet->getPropertyValue("TextRightDistance");
aRightMargin >>= nRightMargin;
mpFS->startElementNS( XML_a, XML_tcPr,
XML_marL, nLeftMargin > 0 ? I32S( oox::drawingml::convertHmmToEmu( nLeftMargin ) ) : nullptr,
XML_marR, nRightMargin > 0 ? I32S( oox::drawingml::convertHmmToEmu( nRightMargin ) ): nullptr,
FSEND );
// Write background fill for table cell.
// TODO
// tcW : Table cell width
WriteTableCellBorders(xCellPropSet);
DrawingML::WriteFill(xCellPropSet);
mpFS->endElementNS( XML_a, XML_tcPr );
}
void ShapeExport::WriteBorderLine(const sal_Int32 XML_line, const BorderLine2& rBorderLine)
{
// While importing the table cell border line width, it converts EMU->Hmm then divided result by 2.
// To get original value of LineWidth need to multiple by 2.
sal_Int32 nBorderWidth = rBorderLine.LineWidth;
nBorderWidth *= 2;
nBorderWidth = oox::drawingml::convertHmmToEmu( nBorderWidth );
if ( nBorderWidth > 0 )
{
mpFS->startElementNS( XML_a, XML_line, XML_w, I32S(nBorderWidth), FSEND );
if ( rBorderLine.Color == sal_Int32( COL_AUTO ) )
mpFS->singleElementNS( XML_a, XML_noFill, FSEND );
else
DrawingML::WriteSolidFill( ::Color(rBorderLine.Color) );
mpFS->endElementNS( XML_a, XML_line );
}
}
void ShapeExport::WriteTableCellBorders(const Reference< XPropertySet>& xCellPropSet)
{
BorderLine2 aBorderLine;
// lnL - Left Border Line Properties of table cell
xCellPropSet->getPropertyValue("LeftBorder") >>= aBorderLine;
WriteBorderLine( XML_lnL, aBorderLine );
// lnR - Right Border Line Properties of table cell
xCellPropSet->getPropertyValue("RightBorder") >>= aBorderLine;
WriteBorderLine( XML_lnR, aBorderLine );
// lnT - Top Border Line Properties of table cell
xCellPropSet->getPropertyValue("TopBorder") >>= aBorderLine;
WriteBorderLine( XML_lnT, aBorderLine );
// lnB - Bottom Border Line Properties of table cell
xCellPropSet->getPropertyValue("BottomBorder") >>= aBorderLine;
WriteBorderLine( XML_lnB, aBorderLine );
}
ShapeExport& ShapeExport::WriteTableShape( const Reference< XShape >& xShape )
{
FSHelperPtr pFS = GetFS();
pFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND );
pFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND );
pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( GetNewShapeID( xShape ) ),
XML_name, IDS(Table),
FSEND );
pFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr,
FSEND );
if( GetDocumentType() == DOCUMENT_PPTX )
pFS->singleElementNS( mnXmlNamespace, XML_nvPr,
FSEND );
pFS->endElementNS( mnXmlNamespace, XML_nvGraphicFramePr );
WriteShapeTransformation( xShape, mnXmlNamespace );
WriteTable( xShape );
pFS->endElementNS( mnXmlNamespace, XML_graphicFrame );
return *this;
}
ShapeExport& ShapeExport::WriteTextShape( const Reference< XShape >& xShape )
{
FSHelperPtr pFS = GetFS();
pFS->startElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp), FSEND );
// non visual shape properties
if (GetDocumentType() != DOCUMENT_DOCX)
{
pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND );
WriteNonVisualDrawingProperties( xShape, IDS( TextShape ) );
}
pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, XML_txBox, "1", FSEND );
if (GetDocumentType() != DOCUMENT_DOCX)
{
WriteNonVisualProperties( xShape );
pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
}
// visual shape properties
pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND );
WriteShapeTransformation( xShape, XML_a );
WritePresetShape( "rect" );
uno::Reference<beans::XPropertySet> xPropertySet(xShape, UNO_QUERY);
WriteBlipOrNormalFill(xPropertySet, "Graphic");
WriteOutline(xPropertySet);
WriteShapeEffects(xPropertySet);
pFS->endElementNS( mnXmlNamespace, XML_spPr );
WriteTextBox( xShape, mnXmlNamespace );
pFS->endElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp) );
return *this;
}
void ShapeExport::WriteMathShape(Reference<XShape> const& xShape)
{
Reference<XPropertySet> const xPropSet(xShape, UNO_QUERY);
assert(xPropSet.is());
Reference<XModel> xMathModel;
xPropSet->getPropertyValue("Model") >>= xMathModel;
assert(xMathModel.is());
assert(GetDocumentType() != DOCUMENT_DOCX); // should be written in DocxAttributeOutput
SAL_WARN_IF(GetDocumentType() == DOCUMENT_XLSX, "oox.shape", "Math export to XLSX isn't tested, should it happen here?");
// ECMA standard does not actually allow oMath outside of
// WordProcessingML so write a MCE like PPT 2010 does
mpFS->startElementNS(XML_mc, XML_AlternateContent, FSEND);
mpFS->startElementNS(XML_mc, XML_Choice,
FSNS(XML_xmlns, XML_a14), OUStringToOString(mpFB->getNamespaceURL(OOX_NS(a14)), RTL_TEXTENCODING_UTF8).getStr(),
XML_Requires, "a14",
FSEND);
mpFS->startElementNS(mnXmlNamespace, XML_sp, FSEND);
mpFS->startElementNS(mnXmlNamespace, XML_nvSpPr, FSEND);
mpFS->singleElementNS(mnXmlNamespace, XML_cNvPr,
XML_id, OString::number(GetNewShapeID(xShape)).getStr(),
XML_name, OString("Formula " + OString::number(mnShapeIdMax++)).getStr(),
FSEND);
mpFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr, XML_txBox, "1", FSEND);
mpFS->singleElementNS(mnXmlNamespace, XML_nvPr, FSEND);
mpFS->endElementNS(mnXmlNamespace, XML_nvSpPr);
mpFS->startElementNS(mnXmlNamespace, XML_spPr, FSEND);
WriteShapeTransformation(xShape, XML_a);
WritePresetShape("rect");
mpFS->endElementNS(mnXmlNamespace, XML_spPr);
mpFS->startElementNS(mnXmlNamespace, XML_txBody, FSEND);
mpFS->startElementNS(XML_a, XML_bodyPr, FSEND);
mpFS->endElementNS(XML_a, XML_bodyPr);
mpFS->startElementNS(XML_a, XML_p, FSEND);
mpFS->startElementNS(XML_a14, XML_m, FSEND);
oox::FormulaExportBase *const pMagic(dynamic_cast<oox::FormulaExportBase*>(xMathModel.get()));
assert(pMagic);
pMagic->writeFormulaOoxml(GetFS(), GetFB()->getVersion(), GetDocumentType());
mpFS->endElementNS(XML_a14, XML_m);
mpFS->endElementNS(XML_a, XML_p);
mpFS->endElementNS(mnXmlNamespace, XML_txBody);
mpFS->endElementNS(mnXmlNamespace, XML_sp);
mpFS->endElementNS(XML_mc, XML_Choice);
mpFS->startElementNS(XML_mc, XML_Fallback, FSEND);
// TODO: export bitmap shape as fallback
mpFS->endElementNS(XML_mc, XML_Fallback);
mpFS->endElementNS(XML_mc, XML_AlternateContent);
}
ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape )
{
Reference< XPropertySet > xPropSet( xShape, UNO_QUERY );
if (!xPropSet.is())
return *this;
enum { CHART, MATH, OTHER } eType(OTHER);
OUString clsid;
xPropSet->getPropertyValue("CLSID") >>= clsid;
if (!clsid.isEmpty())
{
SvGlobalName aClassID;
bool const isValid = aClassID.MakeId(clsid);
assert(isValid); (void)isValid;
if (SotExchange::IsChart(aClassID))
eType = CHART;
else if (SotExchange::IsMath(aClassID))
eType = MATH;
}
if (CHART == eType)
{
Reference< XChartDocument > xChartDoc;
xPropSet->getPropertyValue("Model") >>= xChartDoc;
assert(xChartDoc.is());
//export the chart
Reference< XModel > xModel( xChartDoc, UNO_QUERY );
ChartExport aChartExport( mnXmlNamespace, GetFS(), xModel, GetFB(), GetDocumentType() );
static sal_Int32 nChartCount = 0;
aChartExport.WriteChartObj( xShape, GetNewShapeID( xShape ), ++nChartCount );
return *this;
}
if (MATH == eType)
{
WriteMathShape(xShape);
return *this;
}
uno::Reference<embed::XEmbeddedObject> const xObj(
xPropSet->getPropertyValue("EmbeddedObject"), uno::UNO_QUERY);
if (!xObj.is())
{
SAL_WARN("oox.shape", "ShapeExport::WriteOLE2Shape: no object");
return *this;
}
uno::Sequence<beans::PropertyValue> grabBag;
OUString entryName;
try
{
uno::Reference<beans::XPropertySet> const xParent(
uno::Reference<container::XChild>(xObj, uno::UNO_QUERY_THROW)->getParent(),
uno::UNO_QUERY_THROW);
xParent->getPropertyValue("InteropGrabBag") >>= grabBag;
entryName = uno::Reference<embed::XEmbedPersist>(xObj, uno::UNO_QUERY_THROW)->getEntryName();
}
catch (uno::Exception const& e)
{
SAL_WARN("oox.shape", "ShapeExport::WriteOLE2Shape: " << e);
return *this;
}
OUString progID;
for (auto const& it : grabBag)
{
if (it.Name == "EmbeddedObjects")
{
uno::Sequence<beans::PropertyValue> objects;
it.Value >>= objects;
for (auto const& object : objects)
{
if (object.Name == entryName)
{
uno::Sequence<beans::PropertyValue> props;
object.Value >>= props;
for (auto const& prop : props)
{
if (prop.Name == "ProgID")
{
prop.Value >>= progID;
break;
}
}
break;
}
}
break;
}
}
OUString sMediaType;
OUString sRelationType;
OUString sSuffix;
const char * pProgID(nullptr);
uno::Reference<io::XInputStream> const xInStream =
oox::GetOLEObjectStream(
mpFB->getComponentContext(), xObj, progID,
sMediaType, sRelationType, sSuffix, pProgID);
if (!xInStream.is())
{
return *this;
}
OString anotherProgID;
if (!pProgID && !progID.isEmpty())
{
anotherProgID = OUStringToOString(progID, RTL_TEXTENCODING_UTF8);
pProgID = anotherProgID.getStr();
}
assert(!sMediaType.isEmpty());
assert(!sRelationType.isEmpty());
assert(!sSuffix.isEmpty());
OUString sFileName = "embeddings/oleObject" + OUString::number(++m_nEmbeddedObjects) + "." + sSuffix;
uno::Reference<io::XOutputStream> const xOutStream(
mpFB->openFragmentStream(
OUString::createFromAscii(GetComponentDir()) + "/" + sFileName,
sMediaType));
assert(xOutStream.is()); // no reason why that could fail
try {
::comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream);
} catch (uno::Exception const& e) {
SAL_WARN("oox.shape", "ShapeExport::WriteOLEObject: " << e);
}
OUString const sRelId = mpFB->addRelation(
mpFS->getOutputStream(), sRelationType,
OUString::createFromAscii(GetRelationCompPrefix()) + sFileName);
mpFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND );
mpFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND );
mpFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( GetNewShapeID( xShape ) ),
XML_name, IDS(Object),
FSEND );
mpFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr,
FSEND );
if (GetDocumentType() == DOCUMENT_PPTX)
mpFS->singleElementNS( mnXmlNamespace, XML_nvPr,
FSEND );
mpFS->endElementNS( mnXmlNamespace, XML_nvGraphicFramePr );
WriteShapeTransformation( xShape, mnXmlNamespace );
mpFS->startElementNS( XML_a, XML_graphic, FSEND );
mpFS->startElementNS( XML_a, XML_graphicData,
XML_uri, "http://schemas.openxmlformats.org/presentationml/2006/ole",
FSEND );
if (pProgID)
{
mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
XML_progId, pProgID,
FSNS(XML_r, XML_id), sRelId.toUtf8(),
XML_spid, "",
FSEND );
}
else
{
mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
//? XML_name, "Document",
FSNS(XML_r, XML_id), sRelId.toUtf8(),
// The spec says that this is a required attribute, but PowerPoint can only handle an empty value.
XML_spid, "",
FSEND );
}
mpFS->singleElementNS( mnXmlNamespace, XML_embed, FSEND );
// pic element
SdrObject* pSdrOLE2( GetSdrObjectFromXShape( xShape ) );
// The spec doesn't allow <p:pic> here, but PowerPoint requires it.
bool bEcma = mpFB->getVersion() == oox::core::ECMA_DIALECT;
if (dynamic_cast<const SdrOle2Obj*>( pSdrOLE2) && bEcma)
{
const Graphic* pGraphic = static_cast<SdrOle2Obj*>(pSdrOLE2)->GetGraphic();
if (pGraphic)
WriteGraphicObjectShapePart( xShape, pGraphic );
}
mpFS->endElementNS( mnXmlNamespace, XML_oleObj );
mpFS->endElementNS( XML_a, XML_graphicData );
mpFS->endElementNS( XML_a, XML_graphic );
mpFS->endElementNS( mnXmlNamespace, XML_graphicFrame );
return *this;
}
ShapeExport& ShapeExport::WriteUnknownShape( const Reference< XShape >& )
{
// Override this method to do something useful.
return *this;
}
size_t ShapeExport::ShapeHash::operator()( const Reference < XShape >& rXShape ) const
{
return rXShape->getShapeType().hashCode();
}
sal_Int32 ShapeExport::GetNewShapeID( const Reference< XShape >& rXShape )
{
return GetNewShapeID( rXShape, GetFB() );
}
sal_Int32 ShapeExport::GetNewShapeID( const Reference< XShape >& rXShape, XmlFilterBase* pFB )
{
if( !rXShape.is() )
return -1;
sal_Int32 nID = pFB->GetUniqueId();
(*mpShapeMap)[ rXShape ] = nID;
return nID;
}
sal_Int32 ShapeExport::GetShapeID( const Reference< XShape >& rXShape )
{
return GetShapeID( rXShape, mpShapeMap );
}
sal_Int32 ShapeExport::GetShapeID( const Reference< XShape >& rXShape, ShapeHashMap* pShapeMap )
{
if( !rXShape.is() )
return -1;
ShapeHashMap::const_iterator aIter = pShapeMap->find( rXShape );
if( aIter == pShapeMap->end() )
return -1;
return aIter->second;
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|