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
|
/* -*- 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 <rtl/ustring.hxx>
#include <rtl/strbuf.hxx>
#include <unotools/fontcvt.hxx>
#include <unotools/fontdefs.hxx>
#include <vcl/svapp.hxx>
#include <filter/msfilter/util.hxx>
#include <boost/scoped_ptr.hpp>
#include <boost/unordered_map.hpp>
namespace msfilter {
namespace util {
rtl_TextEncoding getBestTextEncodingFromLocale(const ::com::sun::star::lang::Locale &rLocale)
{
// Obviously not comprehensive, feel free to expand these, they're for ultimate fallbacks
// in last-ditch broken-file-format cases to guess the right 8bit encodings
const OUString &rLanguage = rLocale.Language;
if (rLanguage == "cs" || rLanguage == "hu" || rLanguage == "pl")
return RTL_TEXTENCODING_MS_1250;
if (rLanguage == "ru" || rLanguage == "uk")
return RTL_TEXTENCODING_MS_1251;
if (rLanguage == "el")
return RTL_TEXTENCODING_MS_1253;
if (rLanguage == "tr")
return RTL_TEXTENCODING_MS_1254;
if (rLanguage == "lt")
return RTL_TEXTENCODING_MS_1257;
return RTL_TEXTENCODING_MS_1252;
}
sal_uInt32 BGRToRGB(sal_uInt32 nColor)
{
sal_uInt8
r(static_cast<sal_uInt8>(nColor&0xFF)),
g(static_cast<sal_uInt8>(((nColor)>>8)&0xFF)),
b(static_cast<sal_uInt8>((nColor>>16)&0xFF)),
t(static_cast<sal_uInt8>((nColor>>24)&0xFF));
nColor = (t<<24) + (r<<16) + (g<<8) + b;
return nColor;
}
DateTime DTTM2DateTime( long lDTTM )
{
/*
mint short :6 0000003F minutes (0-59)
hr short :5 000007C0 hours (0-23)
dom short :5 0000F800 days of month (1-31)
mon short :4 000F0000 months (1-12)
yr short :9 1FF00000 years (1900-2411)-1900
wdy short :3 E0000000 weekday(Sunday=0
Monday=1
( wdy can be ignored ) Tuesday=2
Wednesday=3
Thursday=4
Friday=5
Saturday=6)
*/
DateTime aDateTime(Date( 0 ), Time( 0 ));
if( lDTTM )
{
sal_uInt16 lMin = (sal_uInt16)(lDTTM & 0x0000003F);
lDTTM >>= 6;
sal_uInt16 lHour= (sal_uInt16)(lDTTM & 0x0000001F);
lDTTM >>= 5;
sal_uInt16 lDay = (sal_uInt16)(lDTTM & 0x0000001F);
lDTTM >>= 5;
sal_uInt16 lMon = (sal_uInt16)(lDTTM & 0x0000000F);
lDTTM >>= 4;
sal_uInt16 lYear= (sal_uInt16)(lDTTM & 0x000001FF) + 1900;
aDateTime = DateTime(Date(lDay, lMon, lYear), Time(lHour, lMin));
}
return aDateTime;
}
sal_Unicode bestFitOpenSymbolToMSFont(sal_Unicode cChar,
rtl_TextEncoding& rChrSet, OUString& rFontName, bool bDisableUnicodeSupport)
{
boost::scoped_ptr<StarSymbolToMSMultiFont> pConvert(CreateStarSymbolToMSMultiFont());
OUString sFont = pConvert->ConvertChar(cChar);
pConvert.reset();
if (!sFont.isEmpty())
{
cChar = static_cast< sal_Unicode >(cChar | 0xF000);
rFontName = sFont;
rChrSet = RTL_TEXTENCODING_SYMBOL;
}
else if (!bDisableUnicodeSupport && (cChar < 0xE000 || cChar > 0xF8FF))
{
/*
Ok we can't fit into a known windows unicode font, but
we are not in the private area, so we are a
standardized symbol, so turn off the symbol bit and
let words own font substitution kick in
*/
rChrSet = RTL_TEXTENCODING_UNICODE;
sal_Int32 nIndex = 0;
rFontName = ::GetNextFontToken(rFontName, nIndex);
}
else
{
/*
Well we don't have an available substition, and we're
in our private area, so give up and show a standard
bullet symbol
*/
rFontName = "Wingdings";
cChar = static_cast< sal_Unicode >(0x6C);
}
return cChar;
}
/*
http://social.msdn.microsoft.com/Forums/hu-HU/os_openXML-ecma/thread/1bf1f185-ee49-4314-94e7-f4e1563b5c00
The following information is being submitted to the standards working group as
a proposed resolution to a defect report and is not yet part of ISO 29500-1.
...
For each Unicode character in DrawingML text, the font face can be any of four
font "slots": latin ($21.1.2.3.7), cs ($21.1.2.3.1), ea ($21.1.2.3.3), or sym
($21.1.2.3.10), as specified in the following table. For all ranges not
explicitly called out below, the ea font shall be used.
U+0000-U+007F Use latin font
U+0080-U+00A6 Use latin font
U+00A9-U+00AF Use latin font
U+00B2-U+00B3 Use latin font
U+00B5-U+00D6 Use latin font
U+00D8-U+00F6 Use latin font
U+00F8-U+058F Use latin font
U+0590-U+074F Use cs font
U+0780-U+07BF Use cs font
U+0900-U+109F Use cs font
U+10A0-U+10FF Use latin font
U+1200-U+137F Use latin font
U+13A0-U+177F Use latin font
U+1D00-U+1D7F Use latin font
U+1E00-U+1FFF Use latin font
U+1780-U+18AF Use cs font
U+2000-U+200B Use latin font
U+200C-U+200F Use cs font
U+2010-U+2029 Use latin font Except, for the quote characters in the range
2018 - 201E, use ea font if the text has one of the following language
identifiers: ii-CN, ja-JP, ko-KR, zh-CN, zh-HK, zh-MO, zh-SG, zh-TW.
U+202A-U+202F Use cs font
U+2030-U+2046 Use latin font
U+204A-U+245F Use latin font
U+2670-U+2671 Use cs font
U+27C0-U+2BFF Use latin font
U+3099-U+309A Use ea font
U+D835 Use latin font
U+F000-U+F0FF Symbol, use sym font
U+FB00-U+FB17 Use latin font
U+FB1D-U+FB4F Use cs font
U+FE50-U+FE6F Use latin font
Otherwise Use ea font
*/
TextCategory categorizeCodePoint(sal_uInt32 codePoint, const OUString &rBcp47LanguageTag)
{
TextCategory eRet = ea;
if (codePoint <= 0x007F)
eRet = latin;
else if (0x0080 <= codePoint && codePoint <= 0x00A6)
eRet = latin;
else if (0x00A9 <= codePoint && codePoint <= 0x00AF)
eRet = latin;
else if (0x00B2 <= codePoint && codePoint <= 0x00B3)
eRet = latin;
else if (0x00B5 <= codePoint && codePoint <= 0x00D6)
eRet = latin;
else if (0x00D8 <= codePoint && codePoint <= 0x00F6)
eRet = latin;
else if (0x00F8 <= codePoint && codePoint <= 0x058F)
eRet = latin;
else if (0x0590 <= codePoint && codePoint <= 0x074F)
eRet = cs;
else if (0x0780 <= codePoint && codePoint <= 0x07BF)
eRet = cs;
else if (0x0900 <= codePoint && codePoint <= 0x109F)
eRet = cs;
else if (0x10A0 <= codePoint && codePoint <= 0x10FF)
eRet = latin;
else if (0x1200 <= codePoint && codePoint <= 0x137F)
eRet = latin;
else if (0x13A0 <= codePoint && codePoint <= 0x177F)
eRet = latin;
else if (0x1D00 <= codePoint && codePoint <= 0x1D7F)
eRet = latin;
else if (0x1E00 <= codePoint && codePoint <= 0x1FFF)
eRet = latin;
else if (0x1780 <= codePoint && codePoint <= 0x18AF)
eRet = cs;
else if (0x2000 <= codePoint && codePoint <= 0x200B)
eRet = latin;
else if (0x200C <= codePoint && codePoint <= 0x200F)
eRet = cs;
else if (0x2010 <= codePoint && codePoint <= 0x2029)
{
eRet = latin;
if (0x2018 <= codePoint && codePoint <= 0x201E)
{
if (rBcp47LanguageTag == "ii-CN" ||
rBcp47LanguageTag == "ja-JP" ||
rBcp47LanguageTag == "ko-KR" ||
rBcp47LanguageTag == "zh-CN" ||
rBcp47LanguageTag == "zh-HK" ||
rBcp47LanguageTag == "zh-MO" ||
rBcp47LanguageTag == "zh-SG" ||
rBcp47LanguageTag == "zh-TW")
{
eRet = ea;
}
}
}
else if (0x202A <= codePoint && codePoint <= 0x202F)
eRet = cs;
else if (0x2030 <= codePoint && codePoint <= 0x2046)
eRet = latin;
else if (0x204A <= codePoint && codePoint <= 0x245F)
eRet = latin;
else if (0x2670 <= codePoint && codePoint <= 0x2671)
eRet = latin;
else if (0x27C0 <= codePoint && codePoint <= 0x2BFF)
eRet = latin;
else if (0x3099 <= codePoint && codePoint <= 0x309A)
eRet = ea;
else if (0xD835 == codePoint)
eRet = latin;
else if (0xF000 <= codePoint && codePoint <= 0xF0FF)
eRet = sym;
else if (0xFB00 <= codePoint && codePoint <= 0xFB17)
eRet = latin;
else if (0xFB1D <= codePoint && codePoint <= 0xFB4F)
eRet = cs;
else if (0xFE50 <= codePoint && codePoint <= 0xFE6F)
eRet = latin;
return eRet;
}
OString ConvertColor( const Color &rColor, bool bAutoColor )
{
OString color( "auto" );
if (bAutoColor && rColor.GetColor() == OOXML_COLOR_AUTO)
return color;
if ( rColor.GetColor() != COL_AUTO )
{
const char pHexDigits[] = "0123456789ABCDEF";
char pBuffer[] = "000000";
pBuffer[0] = pHexDigits[ ( rColor.GetRed() >> 4 ) & 0x0F ];
pBuffer[1] = pHexDigits[ rColor.GetRed() & 0x0F ];
pBuffer[2] = pHexDigits[ ( rColor.GetGreen() >> 4 ) & 0x0F ];
pBuffer[3] = pHexDigits[ rColor.GetGreen() & 0x0F ];
pBuffer[4] = pHexDigits[ ( rColor.GetBlue() >> 4 ) & 0x0F ];
pBuffer[5] = pHexDigits[ rColor.GetBlue() & 0x0F ];
color = OString( pBuffer );
}
return color;
}
#define IN2MM100( v ) static_cast< sal_Int32 >( (v) * 2540.0 + 0.5 )
#define MM2MM100( v ) static_cast< sal_Int32 >( (v) * 100.0 + 0.5 )
static const ApiPaperSize spPaperSizeTable[] =
{
{ 0, 0 }, // 0 - (undefined)
{ IN2MM100( 8.5 ), IN2MM100( 11 ) }, // 1 - Letter paper
{ IN2MM100( 8.5 ), IN2MM100( 11 ) }, // 2 - Letter small paper
{ IN2MM100( 11 ), IN2MM100( 17 ) }, // 3 - Tabloid paper
{ IN2MM100( 17 ), IN2MM100( 11 ) }, // 4 - Ledger paper
{ IN2MM100( 8.5 ), IN2MM100( 14 ) }, // 5 - Legal paper
{ IN2MM100( 5.5 ), IN2MM100( 8.5 ) }, // 6 - Statement paper
{ IN2MM100( 7.25 ), IN2MM100( 10.5 ) }, // 7 - Executive paper
{ MM2MM100( 297 ), MM2MM100( 420 ) }, // 8 - A3 paper
{ MM2MM100( 210 ), MM2MM100( 297 ) }, // 9 - A4 paper
{ MM2MM100( 210 ), MM2MM100( 297 ) }, // 10 - A4 small paper
{ MM2MM100( 148 ), MM2MM100( 210 ) }, // 11 - A5 paper
{ MM2MM100( 250 ), MM2MM100( 353 ) }, // 12 - B4 paper
{ MM2MM100( 176 ), MM2MM100( 250 ) }, // 13 - B5 paper
{ IN2MM100( 8.5 ), IN2MM100( 13 ) }, // 14 - Folio paper
{ MM2MM100( 215 ), MM2MM100( 275 ) }, // 15 - Quarto paper
{ IN2MM100( 10 ), IN2MM100( 14 ) }, // 16 - Standard paper
{ IN2MM100( 11 ), IN2MM100( 17 ) }, // 17 - Standard paper
{ IN2MM100( 8.5 ), IN2MM100( 11 ) }, // 18 - Note paper
{ IN2MM100( 3.875 ), IN2MM100( 8.875 ) }, // 19 - #9 envelope
{ IN2MM100( 4.125 ), IN2MM100( 9.5 ) }, // 20 - #10 envelope
{ IN2MM100( 4.5 ), IN2MM100( 10.375 ) }, // 21 - #11 envelope
{ IN2MM100( 4.75 ), IN2MM100( 11 ) }, // 22 - #12 envelope
{ IN2MM100( 5 ), IN2MM100( 11.5 ) }, // 23 - #14 envelope
{ IN2MM100( 17 ), IN2MM100( 22 ) }, // 24 - C paper
{ IN2MM100( 22 ), IN2MM100( 34 ) }, // 25 - D paper
{ IN2MM100( 34 ), IN2MM100( 44 ) }, // 26 - E paper
{ MM2MM100( 110 ), MM2MM100( 220 ) }, // 27 - DL envelope
{ MM2MM100( 162 ), MM2MM100( 229 ) }, // 28 - C5 envelope
{ MM2MM100( 324 ), MM2MM100( 458 ) }, // 29 - C3 envelope
{ MM2MM100( 229 ), MM2MM100( 324 ) }, // 30 - C4 envelope
{ MM2MM100( 114 ), MM2MM100( 162 ) }, // 31 - C6 envelope
{ MM2MM100( 114 ), MM2MM100( 229 ) }, // 32 - C65 envelope
{ MM2MM100( 250 ), MM2MM100( 353 ) }, // 33 - B4 envelope
{ MM2MM100( 176 ), MM2MM100( 250 ) }, // 34 - B5 envelope
{ MM2MM100( 176 ), MM2MM100( 125 ) }, // 35 - B6 envelope
{ MM2MM100( 110 ), MM2MM100( 230 ) }, // 36 - Italy envelope
{ IN2MM100( 3.875 ), IN2MM100( 7.5 ) }, // 37 - Monarch envelope
{ IN2MM100( 3.625 ), IN2MM100( 6.5 ) }, // 38 - 6 3/4 envelope
{ IN2MM100( 14.875 ), IN2MM100( 11 ) }, // 39 - US standard fanfold
{ IN2MM100( 8.5 ), IN2MM100( 12 ) }, // 40 - German standard fanfold
{ IN2MM100( 8.5 ), IN2MM100( 13 ) }, // 41 - German legal fanfold
{ MM2MM100( 250 ), MM2MM100( 353 ) }, // 42 - ISO B4
{ MM2MM100( 200 ), MM2MM100( 148 ) }, // 43 - Japanese double postcard
{ IN2MM100( 9 ), IN2MM100( 11 ) }, // 44 - Standard paper
{ IN2MM100( 10 ), IN2MM100( 11 ) }, // 45 - Standard paper
{ IN2MM100( 15 ), IN2MM100( 11 ) }, // 46 - Standard paper
{ MM2MM100( 220 ), MM2MM100( 220 ) }, // 47 - Invite envelope
{ 0, 0 }, // 48 - (undefined)
{ 0, 0 }, // 49 - (undefined)
{ IN2MM100( 9.275 ), IN2MM100( 12 ) }, // 50 - Letter extra paper
{ IN2MM100( 9.275 ), IN2MM100( 15 ) }, // 51 - Legal extra paper
{ IN2MM100( 11.69 ), IN2MM100( 18 ) }, // 52 - Tabloid extra paper
{ MM2MM100( 236 ), MM2MM100( 322 ) }, // 53 - A4 extra paper
{ IN2MM100( 8.275 ), IN2MM100( 11 ) }, // 54 - Letter transverse paper
{ MM2MM100( 210 ), MM2MM100( 297 ) }, // 55 - A4 transverse paper
{ IN2MM100( 9.275 ), IN2MM100( 12 ) }, // 56 - Letter extra transverse paper
{ MM2MM100( 227 ), MM2MM100( 356 ) }, // 57 - SuperA/SuperA/A4 paper
{ MM2MM100( 305 ), MM2MM100( 487 ) }, // 58 - SuperB/SuperB/A3 paper
{ IN2MM100( 8.5 ), IN2MM100( 12.69 ) }, // 59 - Letter plus paper
{ MM2MM100( 210 ), MM2MM100( 330 ) }, // 60 - A4 plus paper
{ MM2MM100( 148 ), MM2MM100( 210 ) }, // 61 - A5 transverse paper
{ MM2MM100( 182 ), MM2MM100( 257 ) }, // 62 - JIS B5 transverse paper
{ MM2MM100( 322 ), MM2MM100( 445 ) }, // 63 - A3 extra paper
{ MM2MM100( 174 ), MM2MM100( 235 ) }, // 64 - A5 extra paper
{ MM2MM100( 201 ), MM2MM100( 276 ) }, // 65 - ISO B5 extra paper
{ MM2MM100( 420 ), MM2MM100( 594 ) }, // 66 - A2 paper
{ MM2MM100( 297 ), MM2MM100( 420 ) }, // 67 - A3 transverse paper
{ MM2MM100( 322 ), MM2MM100( 445 ) } // 68 - A3 extra transverse paper
};
sal_Int32 PaperSizeConv::getMSPaperSizeIndex( const com::sun::star::awt::Size& rSize )
{
sal_Int32 nElems = SAL_N_ELEMENTS( spPaperSizeTable );
// Need to find the best match for current size
sal_Int32 nDeltaWidth = 0;
sal_Int32 nDeltaHeight = 0;
sal_Int32 nPaperSizeIndex = 0; // Undefined
const ApiPaperSize* pItem = spPaperSizeTable;
const ApiPaperSize* pEnd = spPaperSizeTable + nElems;
for ( ; pItem != pEnd; ++pItem )
{
sal_Int32 nCurDeltaHeight = std::abs( pItem->mnHeight - rSize.Height );
sal_Int32 nCurDeltaWidth = std::abs( pItem->mnWidth - rSize.Width );
if ( pItem == spPaperSizeTable ) // initialize delta with first item
{
nDeltaWidth = nCurDeltaWidth;
nDeltaHeight = nCurDeltaHeight;
}
else
{
if ( nCurDeltaWidth < nDeltaWidth && nCurDeltaHeight < nDeltaHeight )
{
nDeltaWidth = nCurDeltaWidth;
nDeltaHeight = nCurDeltaHeight;
nPaperSizeIndex = (pItem - spPaperSizeTable);
}
}
}
sal_Int32 nTol = 10; // hmm not sure is this the best way
if ( nDeltaWidth <= nTol && nDeltaHeight <= nTol )
return nPaperSizeIndex;
return 0;
}
const ApiPaperSize& PaperSizeConv::getApiSizeForMSPaperSizeIndex( sal_Int32 nMSOPaperIndex )
{
sal_Int32 nElems = SAL_N_ELEMENTS( spPaperSizeTable );
if ( nMSOPaperIndex < 0 || nMSOPaperIndex > nElems - 1 )
return spPaperSizeTable[ 0 ];
return spPaperSizeTable[ nMSOPaperIndex ];
}
OUString findQuotedText( const OUString& rCommand,
const sal_Char* cStartQuote, const sal_Unicode uEndQuote )
{
OUString sRet;
OUString sStartQuote( OUString::createFromAscii(cStartQuote) );
sal_Int32 nStartIndex = rCommand.indexOf( sStartQuote );
if( nStartIndex >= 0 )
{
sal_Int32 nStartLength = sStartQuote.getLength();
sal_Int32 nEndIndex = rCommand.indexOf( uEndQuote, nStartIndex + nStartLength);
if( nEndIndex > nStartIndex )
{
sRet = rCommand.copy( nStartIndex + nStartLength, nEndIndex - nStartIndex - nStartLength);
}
}
return sRet;
}
WW8ReadFieldParams::WW8ReadFieldParams( const OUString& _rData )
: aData( _rData )
, nFnd( 0 )
, nNext( 0 )
, nSavPtr( 0 )
{
/*
First look for an opening bracket or a space or a quatation mark or a backslash, so that the field (i.e. INCLUDEPICTURE or EINFUEGENGRAFIK or...) gets oread over
*/
const sal_Int32 nLen = aData.getLength();
while ( nNext<nLen && aData[nNext]==' ' )
++nNext;
while ( nNext<nLen )
{
const sal_Unicode c = aData[nNext];
if ( c==' ' || c=='"' || c=='\\' || c==132 || c==0x201c )
break;
++nNext;
}
nFnd = nNext;
nSavPtr = nNext;
}
WW8ReadFieldParams::~WW8ReadFieldParams()
{
}
OUString WW8ReadFieldParams::GetResult() const
{
if (nFnd<0 && nSavPtr>nFnd)
return OUString();
else
{
return nSavPtr < nFnd ? aData.copy(nFnd) : aData.copy(nFnd, nSavPtr-nFnd);
}
}
bool WW8ReadFieldParams::GoToTokenParam()
{
const sal_Int32 nOld = nNext;
if( -2 == SkipToNextToken() )
return GetTokenSttPtr()>=0;
nNext = nOld;
return false;
}
// ret: -2: NOT a '\' parameter but normal text
sal_Int32 WW8ReadFieldParams::SkipToNextToken()
{
if ( nNext<0 || nNext>=aData.getLength() )
return -1;
nFnd = FindNextStringPiece(nNext);
if ( nFnd<0 )
return -1;
nSavPtr = nNext;
if (nFnd+1<aData.getLength() && aData[nFnd+1]!='\\' && aData[nFnd]=='\\')
{
const sal_Int32 nRet = aData[++nFnd];
nNext = ++nFnd; // and set after
return nRet;
}
if ( nSavPtr>0 && (aData[nSavPtr-1]=='"' || aData[nSavPtr-1]==0x201d ) )
{
--nSavPtr;
}
return -2;
}
// FindNextPara searches the next backslash parameter or the next string
// until the next blank or "\" or closing quatation mark
// or the end of the string of pStr.
//
// Output ppNext (if ppNext != 0) Suchbeginn fuer naechsten Parameter bzw. 0
//
// Return value: 0 if end of string reached,
// ansonsten Anfang des Paramters bzw. der Zeichenkette
//
sal_Int32 WW8ReadFieldParams::FindNextStringPiece(const sal_Int32 nStart)
{
const sal_Int32 nLen = aData.getLength();
sal_Int32 n = nStart<0 ? nFnd : nStart; // start
sal_Int32 n2; // end
nNext = -1; // if not found -> Default
while ( n<nLen && aData[n]==' ' )
++n;
if ( n==nLen )
return -1;
if ( aData[n]==0x13 )
{
// Skip the nested field code since it's not supported
while ( n<nLen && aData[n]!=0x14 )
++n;
if ( n==nLen )
return -1;
}
// quotation marks before paragraph?
if ( aData[n]=='"' || aData[n]==0x201c || aData[n]==132 || aData[n]==0x14 )
{
n++; // read over quatation marks
n2 = n; // search for the end from here on
while( (nLen > n2)
&& (aData[n2] != '"')
&& (aData[n2] != 0x201d)
&& (aData[n2] != 147)
&& (aData[n2] != 0x15) )
n2++; // search for the end of the paragraph
}
else // no quotation mark
{
n2 = n; // search for the end from here on
while ( n2<nLen && aData[n2]!=' ' ) // search for the end of the paragraph
{
if ( aData[n2]=='\\' )
{
if ( n2+1<nLen && aData[n2+1]=='\\' )
n2 += 2; // double backslash -> OK
else
{
if( n2 > n )
n2--;
break; // single backslash -> end
}
}
else
n2++; // no backslash -> OK
}
}
if( nLen > n2 )
{
if (aData[n2]!=' ') ++n2;
nNext = n2;
}
return n;
}
// read parameters "1-3" or 1-3 with both values between 1 and nMax
bool WW8ReadFieldParams::GetTokenSttFromTo(sal_Int32* pFrom, sal_Int32* pTo, sal_Int32 nMax)
{
sal_Int32 nStart = 0;
sal_Int32 nEnd = 0;
if ( GoToTokenParam() )
{
const OUString sParams( GetResult() );
sal_Int32 nIndex = 0;
const OUString sStart( sParams.getToken(0, '-', nIndex) );
if (nIndex>=0)
{
nStart = sStart.toInt32();
nEnd = sParams.copy(nIndex).toInt32();
}
}
if( pFrom ) *pFrom = nStart;
if( pTo ) *pTo = nEnd;
return nStart && nEnd && (nMax >= nStart) && (nMax >= nEnd);
}
EquationResult Read_SubF_Combined(WW8ReadFieldParams& rReadParam)
{
EquationResult aResult;
OUString sCombinedCharacters;
WW8ReadFieldParams aOriFldParam = rReadParam;
const sal_Int32 cGetChar = rReadParam.SkipToNextToken();
switch( cGetChar )
{
case 'a':
case 'A':
if ( !rReadParam.GetResult().startsWithIgnoreAsciiCase("d") )
{
break;
}
(void)rReadParam.SkipToNextToken();
// intentional fall-through
case -2:
{
if ( rReadParam.GetResult().startsWithIgnoreAsciiCase("(") )
{
for (int i=0;i<2;i++)
{
if ('s' == rReadParam.SkipToNextToken())
{
const sal_Int32 cChar = rReadParam.SkipToNextToken();
if (-2 != rReadParam.SkipToNextToken())
break;
const OUString sF = rReadParam.GetResult();
if ((('u' == cChar) && sF.startsWithIgnoreAsciiCase("p"))
|| (('d' == cChar) && sF.startsWithIgnoreAsciiCase("o")))
{
if (-2 == rReadParam.SkipToNextToken())
{
OUString sPart = rReadParam.GetResult();
sal_Int32 nBegin = sPart.indexOf('(');
// Word disallows brackets in this field, which
// aids figuring out the case of an end of )) vs )
sal_Int32 nEnd = sPart.indexOf(')');
if (nBegin != -1 && nEnd != -1)
{
sCombinedCharacters +=
sPart.copy(nBegin+1,nEnd-nBegin-1);
}
}
}
}
}
if (!sCombinedCharacters.isEmpty())
{
aResult.sType = "CombinedCharacters";
aResult.sResult = sCombinedCharacters;
}
else
{
const OUString sPart = aOriFldParam.GetResult();
sal_Int32 nBegin = sPart.indexOf('(');
sal_Int32 nEnd = sPart.indexOf(',');
if ( nEnd == -1 )
{
nEnd = sPart.indexOf(')');
}
if ( nBegin != -1 && nEnd != -1 )
{
// skip certain leading characters
for (int i = nBegin;i < nEnd-1;i++)
{
const sal_Unicode cC = sPart[nBegin+1];
if ( cC < 32 )
{
nBegin++;
}
else
break;
}
sCombinedCharacters = sPart.copy( nBegin+1, nEnd-nBegin-1 );
if ( !sCombinedCharacters.isEmpty() )
{
aResult.sType = "Input";
aResult.sResult = sCombinedCharacters;
}
}
}
}
}
default:
break;
}
return aResult;
}
EquationResult ParseCombinedChars(const OUString& rStr)
{
EquationResult aResult;
WW8ReadFieldParams aReadParam( rStr );
const sal_Int32 cChar = aReadParam.SkipToNextToken();
if ('o' == cChar || 'O' == cChar)
aResult = Read_SubF_Combined(aReadParam);
return aResult;
}
struct CustomShapeTypeTranslationTable
{
const char* sOOo;
const char* sMSO;
};
static const CustomShapeTypeTranslationTable pCustomShapeTypeTranslationTable[] =
{
// { "non-primitive", mso_sptMin },
{ "rectangle", "rect" },
{ "round-rectangle", "roundRect" },
{ "ellipse", "ellipse" },
{ "diamond", "diamond" },
{ "isosceles-triangle", "triangle" },
{ "right-triangle", "rtTriangle" },
{ "parallelogram", "parallelogram" },
{ "trapezoid", "trapezoid" },
{ "hexagon", "hexagon" },
{ "octagon", "octagon" },
{ "cross", "plus" },
{ "star5", "star5" },
{ "right-arrow", "rightArrow" },
// { "mso-spt14", mso_sptThickArrow },
{ "pentagon-right", "homePlate" },
{ "cube", "cube" },
// { "mso-spt17", mso_sptBalloon },
// { "mso-spt18", mso_sptSeal },
{ "mso-spt19", "arc" },
{ "mso-spt20", "line" },
{ "mso-spt21", "plaque" },
{ "can", "can" },
{ "ring", "donut" },
{ "mso-spt24", "textPlain" },
{ "mso-spt25", "textStop" },
{ "mso-spt26", "textTriangle" },
{ "mso-spt27", "textCanDown" },
{ "mso-spt28", "textWave1" },
{ "mso-spt29", "textArchUpPour" },
{ "mso-spt30", "textCanDown" },
{ "mso-spt31", "textArchUp" },
{ "mso-spt32", "straightConnector1" },
{ "mso-spt33", "bentConnector2" },
{ "mso-spt34", "bentConnector3" },
{ "mso-spt35", "bentConnector4" },
{ "mso-spt36", "bentConnector5" },
{ "mso-spt37", "curvedConnector2" },
{ "mso-spt38", "curvedConnector3" },
{ "mso-spt39", "curvedConnector4" },
{ "mso-spt40", "curvedConnector5" },
{ "mso-spt41", "callout1" },
{ "mso-spt42", "callout2" },
{ "mso-spt43", "callout3" },
{ "mso-spt44", "accentCallout1" },
{ "mso-spt45", "accentCallout2" },
{ "mso-spt46", "accentCallout3" },
{ "line-callout-1", "borderCallout1" },
{ "line-callout-2", "borderCallout2" },
{ "line-callout-3", "borderCallout3" },
{ "mso-spt49", "borderCallout3" },
{ "mso-spt50", "accentBorderCallout1" },
{ "mso-spt51", "accentBorderCallout2" },
{ "mso-spt52", "accentBorderCallout3" },
{ "mso-spt53", "ribbon" },
{ "mso-spt54", "ribbon2" },
{ "chevron", "chevron" },
{ "pentagon", "pentagon" },
{ "forbidden", "noSmoking" },
{ "star8", "star8" },
{ "mso-spt59", "star16" },
{ "mso-spt60", "star32" },
{ "rectangular-callout", "wedgeRectCallout" },
{ "round-rectangular-callout", "wedgeRoundRectCallout" },
{ "round-callout", "wedgeEllipseCallout" },
{ "mso-spt64", "wave" },
{ "paper", "foldedCorner" },
{ "left-arrow", "leftArrow" },
{ "down-arrow", "downArrow" },
{ "up-arrow", "upArrow" },
{ "left-right-arrow", "leftRightArrow" },
{ "up-down-arrow", "upDownArrow" },
{ "mso-spt71", "irregularSeal1" },
{ "bang", "irregularSeal2" },
{ "lightning", "lightningBolt" },
{ "heart", "heart" },
{ "quad-arrow", "quadArrow" },
{ "left-arrow-callout", "leftArrowCallout" },
{ "right-arrow-callout", "rightArrowCallout" },
{ "up-arrow-callout", "upArrowCallout" },
{ "down-arrow-callout", "downArrowCallout" },
{ "left-right-arrow-callout", "leftRightArrowCallout" },
{ "up-down-arrow-callout", "upDownArrowCallout" },
{ "quad-arrow-callout", "quadArrowCallout" },
{ "quad-bevel", "bevel" },
{ "left-bracket", "leftBracket" },
{ "right-bracket", "rightBracket" },
{ "left-brace", "leftBrace" },
{ "right-brace", "rightBrace" },
{ "mso-spt89", "leftUpArrow" },
{ "mso-spt90", "bentUpArrow" },
{ "mso-spt91", "bentArrow" },
{ "star24", "star24" },
{ "striped-right-arrow", "stripedRightArrow" },
{ "notched-right-arrow", "notchedRightArrow" },
{ "block-arc", "blockArc" },
{ "smiley", "smileyFace" },
{ "vertical-scroll", "verticalScroll" },
{ "horizontal-scroll", "horizontalScroll" },
{ "circular-arrow", "circularArrow" },
{ "mso-spt100", "pie" }, // looks like MSO_SPT is wrong here
{ "mso-spt101", "uturnArrow" },
{ "mso-spt102", "curvedRightArrow" },
{ "mso-spt103", "curvedLeftArrow" },
{ "mso-spt104", "curvedUpArrow" },
{ "mso-spt105", "curvedDownArrow" },
{ "cloud-callout", "cloudCallout" },
{ "mso-spt107", "ellipseRibbon" },
{ "mso-spt108", "ellipseRibbon2" },
{ "flowchart-process", "flowChartProcess" },
{ "flowchart-decision", "flowChartDecision" },
{ "flowchart-data", "flowChartInputOutput" },
{ "flowchart-predefined-process", "flowChartPredefinedProcess" },
{ "flowchart-internal-storage", "flowChartInternalStorage" },
{ "flowchart-document", "flowChartDocument" },
{ "flowchart-multidocument", "flowChartMultidocument" },
{ "flowchart-terminator", "flowChartTerminator" },
{ "flowchart-preparation", "flowChartPreparation" },
{ "flowchart-manual-input", "flowChartManualInput" },
{ "flowchart-manual-operation", "flowChartManualOperation" },
{ "flowchart-connector", "flowChartConnector" },
{ "flowchart-card", "flowChartPunchedCard" },
{ "flowchart-punched-tape", "flowChartPunchedTape" },
{ "flowchart-summing-junction", "flowChartSummingJunction" },
{ "flowchart-or", "flowChartOr" },
{ "flowchart-collate", "flowChartCollate" },
{ "flowchart-sort", "flowChartSort" },
{ "flowchart-extract", "flowChartExtract" },
{ "flowchart-merge", "flowChartMerge" },
{ "mso-spt129", "flowChartOfflineStorage" },
{ "flowchart-stored-data", "flowChartOnlineStorage" },
{ "flowchart-sequential-access", "flowChartMagneticTape" },
{ "flowchart-magnetic-disk", "flowChartMagneticDisk" },
{ "flowchart-direct-access-storage", "flowChartMagneticDrum" },
{ "flowchart-display", "flowChartDisplay" },
{ "flowchart-delay", "flowChartDelay" },
// { "fontwork-plain-text", "textPlainText" },
// { "fontwork-stop", "textStop" },
// { "fontwork-triangle-up", "textTriangle" },
// { "fontwork-triangle-down", "textTriangleInverted" },
// { "fontwork-chevron-up", "textChevron" },
// { "fontwork-chevron-down", "textChevronInverted" },
// { "mso-spt142", "textRingInside" },
// { "mso-spt143", "textRingOutside" },
// { "fontwork-arch-up-curve", "textArchUpCurve" },
// { "fontwork-arch-down-curve", "textArchDownCurve" },
// { "fontwork-circle-curve", "textCircleCurve" },
// { "fontwork-open-circle-curve", "textButtonCurve" },
// { "fontwork-arch-up-pour", "textArchUpPour" },
// { "fontwork-arch-down-pour", "textArchDownPour" },
// { "fontwork-circle-pour", "textCirclePour" },
// { "fontwork-open-circle-pour", "textButtonPour" },
// { "fontwork-curve-up", "textCurveUp" },
// { "fontwork-curve-down", "textCurveDown" },
// { "fontwork-fade-up-and-right", "textCascadeUp" },
// { "fontwork-fade-up-and-left", "textCascadeDown" },
// { "fontwork-wave", "textWave1" },
// { "mso-spt157", "textWave2" },
// { "mso-spt158", "textWave3" },
// { "mso-spt159", "textWave4" },
// { "fontwork-inflate", "textInflate" },
// { "mso-spt161", "textDeflate" },
// { "mso-spt162", "textInflateBottom" },
// { "mso-spt163", "textDeflateBottom" },
// { "mso-spt164", "textInflateTop" },
// { "mso-spt165", "textDeflateTop" },
// { "mso-spt166", "textDeflateInflate" },
// { "mso-spt167", "textDeflateInflateDeflate" },
// { "fontwork-fade-right", "textFadeRight" },
// { "fontwork-fade-left", "textFadeLeft" },
// { "fontwork-fade-up", "textFadeUp" },
// { "fontwork-fade-down", "textFadeDown" },
// { "fontwork-slant-up", "textSlantUp" },
// { "fontwork-slant-down", "textSlantDown" },
// { "mso-spt174", "textCanUp" },
// { "mso-spt175", "textCanDown" },
{ "flowchart-alternate-process", "flowChartAlternateProcess" },
{ "flowchart-off-page-connector", "flowChartOffpageConnector" },
{ "mso-spt178", "callout1" },
{ "mso-spt179", "accentCallout1" },
{ "mso-spt180", "borderCallout1" },
{ "mso-spt182", "leftRightUpArrow" },
{ "sun", "sun" },
{ "moon", "moon" },
{ "bracket-pair", "bracketPair" },
{ "brace-pair", "bracePair" },
{ "star4", "star4" },
{ "mso-spt188", "doubleWave" },
{ "mso-spt189", "actionButtonBlank" },
{ "mso-spt190", "actionButtonHome" },
{ "mso-spt191", "actionButtonHelp" },
{ "mso-spt192", "actionButtonInformation" },
{ "mso-spt193", "actionButtonForwardNext" },
{ "mso-spt194", "actionButtonBackPrevious" },
{ "mso-spt195", "actionButtonEnd" },
{ "mso-spt196", "actionButtonBeginning" },
{ "mso-spt197", "actionButtonReturn" },
{ "mso-spt198", "actionButtonDocument" },
{ "mso-spt199", "actionButtonSound" },
{ "mso-spt200", "actionButtonMovie" },
// { "mso-spt201", "hostControl" },
{ "mso-spt202", "rect" },
{ "ooxml-actionButtonSound", "actionButtonSound" },
{ "ooxml-borderCallout1", "borderCallout1" },
{ "ooxml-plaqueTabs", "plaqueTabs" },
{ "ooxml-curvedLeftArrow", "curvedLeftArrow" },
{ "ooxml-octagon", "octagon" },
{ "ooxml-leftRightRibbon", "leftRightRibbon" },
{ "ooxml-actionButtonInformation", "actionButtonInformation" },
{ "ooxml-bentConnector5", "bentConnector5" },
{ "ooxml-circularArrow", "circularArrow" },
{ "ooxml-downArrowCallout", "downArrowCallout" },
{ "ooxml-mathMinus", "mathMinus" },
{ "ooxml-gear9", "gear9" },
{ "ooxml-round1Rect", "round1Rect" },
{ "ooxml-sun", "sun" },
{ "ooxml-plaque", "plaque" },
{ "ooxml-chevron", "chevron" },
{ "ooxml-flowChartPreparation", "flowChartPreparation" },
{ "ooxml-diagStripe", "diagStripe" },
{ "ooxml-pentagon", "pentagon" },
{ "ooxml-funnel", "funnel" },
{ "ooxml-chartStar", "chartStar" },
{ "ooxml-accentBorderCallout1", "accentBorderCallout1" },
{ "ooxml-notchedRightArrow", "notchedRightArrow" },
{ "ooxml-rightBracket", "rightBracket" },
{ "ooxml-flowChartOffpageConnector", "flowChartOffpageConnector" },
{ "ooxml-leftRightArrow", "leftRightArrow" },
{ "ooxml-decagon", "decagon" },
{ "ooxml-actionButtonHelp", "actionButtonHelp" },
{ "ooxml-star24", "star24" },
{ "ooxml-mathDivide", "mathDivide" },
{ "ooxml-curvedConnector4", "curvedConnector4" },
{ "ooxml-flowChartOr", "flowChartOr" },
{ "ooxml-borderCallout3", "borderCallout3" },
{ "ooxml-upDownArrowCallout", "upDownArrowCallout" },
{ "ooxml-flowChartDecision", "flowChartDecision" },
{ "ooxml-leftRightArrowCallout", "leftRightArrowCallout" },
{ "ooxml-flowChartManualOperation", "flowChartManualOperation" },
{ "ooxml-snipRoundRect", "snipRoundRect" },
{ "ooxml-mathPlus", "mathPlus" },
{ "ooxml-actionButtonForwardNext", "actionButtonForwardNext" },
{ "ooxml-can", "can" },
{ "ooxml-foldedCorner", "foldedCorner" },
{ "ooxml-star32", "star32" },
{ "ooxml-flowChartInternalStorage", "flowChartInternalStorage" },
{ "ooxml-upDownArrow", "upDownArrow" },
{ "ooxml-irregularSeal2", "irregularSeal2" },
{ "ooxml-mathEqual", "mathEqual" },
{ "ooxml-star12", "star12" },
{ "ooxml-uturnArrow", "uturnArrow" },
{ "ooxml-squareTabs", "squareTabs" },
{ "ooxml-leftRightUpArrow", "leftRightUpArrow" },
{ "ooxml-homePlate", "homePlate" },
{ "ooxml-dodecagon", "dodecagon" },
{ "ooxml-leftArrowCallout", "leftArrowCallout" },
{ "ooxml-chord", "chord" },
{ "ooxml-quadArrowCallout", "quadArrowCallout" },
{ "ooxml-actionButtonBeginning", "actionButtonBeginning" },
{ "ooxml-ellipse", "ellipse" },
{ "ooxml-actionButtonEnd", "actionButtonEnd" },
{ "ooxml-arc", "arc" },
{ "ooxml-star16", "star16" },
{ "ooxml-parallelogram", "parallelogram" },
{ "ooxml-bevel", "bevel" },
{ "ooxml-roundRect", "roundRect" },
{ "ooxml-accentCallout1", "accentCallout1" },
{ "ooxml-flowChartSort", "flowChartSort" },
{ "ooxml-star8", "star8" },
{ "ooxml-flowChartAlternateProcess", "flowChartAlternateProcess" },
{ "ooxml-moon", "moon" },
{ "ooxml-star6", "star6" },
{ "ooxml-round2SameRect", "round2SameRect" },
{ "ooxml-nonIsoscelesTrapezoid", "nonIsoscelesTrapezoid" },
{ "ooxml-diamond", "diamond" },
{ "ooxml-ellipseRibbon", "ellipseRibbon" },
{ "ooxml-callout2", "callout2" },
{ "ooxml-pie", "pie" },
{ "ooxml-star4", "star4" },
{ "ooxml-flowChartPredefinedProcess", "flowChartPredefinedProcess" },
{ "ooxml-flowChartPunchedTape", "flowChartPunchedTape" },
{ "ooxml-curvedConnector2", "curvedConnector2" },
{ "ooxml-bentConnector3", "bentConnector3" },
{ "ooxml-cornerTabs", "cornerTabs" },
{ "ooxml-hexagon", "hexagon" },
{ "ooxml-flowChartConnector", "flowChartConnector" },
{ "ooxml-flowChartMagneticDisk", "flowChartMagneticDisk" },
{ "ooxml-heart", "heart" },
{ "ooxml-ribbon2", "ribbon2" },
{ "ooxml-bracePair", "bracePair" },
{ "ooxml-flowChartExtract", "flowChartExtract" },
{ "ooxml-actionButtonHome", "actionButtonHome" },
{ "ooxml-accentBorderCallout3", "accentBorderCallout3" },
{ "ooxml-flowChartOfflineStorage", "flowChartOfflineStorage" },
{ "ooxml-irregularSeal1", "irregularSeal1" },
{ "ooxml-quadArrow", "quadArrow" },
{ "ooxml-leftBrace", "leftBrace" },
{ "ooxml-leftBracket", "leftBracket" },
{ "ooxml-blockArc", "blockArc" },
{ "ooxml-curvedConnector3", "curvedConnector3" },
{ "ooxml-wedgeRoundRectCallout", "wedgeRoundRectCallout" },
{ "ooxml-actionButtonMovie", "actionButtonMovie" },
{ "ooxml-flowChartOnlineStorage", "flowChartOnlineStorage" },
{ "ooxml-gear6", "gear6" },
{ "ooxml-halfFrame", "halfFrame" },
{ "ooxml-snip2SameRect", "snip2SameRect" },
{ "ooxml-triangle", "triangle" },
{ "ooxml-teardrop", "teardrop" },
{ "ooxml-flowChartDocument", "flowChartDocument" },
{ "ooxml-rightArrowCallout", "rightArrowCallout" },
{ "ooxml-rightBrace", "rightBrace" },
{ "ooxml-chartPlus", "chartPlus" },
{ "ooxml-flowChartManualInput", "flowChartManualInput" },
{ "ooxml-flowChartMerge", "flowChartMerge" },
{ "ooxml-line", "line" },
{ "ooxml-downArrow", "downArrow" },
{ "ooxml-upArrow", "upArrow" },
{ "ooxml-curvedDownArrow", "curvedDownArrow" },
{ "ooxml-actionButtonReturn", "actionButtonReturn" },
{ "ooxml-flowChartInputOutput", "flowChartInputOutput" },
{ "ooxml-bracketPair", "bracketPair" },
{ "ooxml-smileyFace", "smileyFace" },
{ "ooxml-actionButtonBlank", "actionButtonBlank" },
{ "ooxml-wave", "wave" },
{ "ooxml-swooshArrow", "swooshArrow" },
{ "ooxml-flowChartSummingJunction", "flowChartSummingJunction" },
{ "ooxml-lightningBolt", "lightningBolt" },
{ "ooxml-flowChartDisplay", "flowChartDisplay" },
{ "ooxml-actionButtonBackPrevious", "actionButtonBackPrevious" },
{ "ooxml-frame", "frame" },
{ "ooxml-rtTriangle", "rtTriangle" },
{ "ooxml-flowChartMagneticTape", "flowChartMagneticTape" },
{ "ooxml-curvedRightArrow", "curvedRightArrow" },
{ "ooxml-leftUpArrow", "leftUpArrow" },
{ "ooxml-wedgeEllipseCallout", "wedgeEllipseCallout" },
{ "ooxml-doubleWave", "doubleWave" },
{ "ooxml-bentArrow", "bentArrow" },
{ "ooxml-star10", "star10" },
{ "ooxml-leftArrow", "leftArrow" },
{ "ooxml-curvedUpArrow", "curvedUpArrow" },
{ "ooxml-snip1Rect", "snip1Rect" },
{ "ooxml-ellipseRibbon2", "ellipseRibbon2" },
{ "ooxml-plus", "plus" },
{ "ooxml-accentCallout3", "accentCallout3" },
{ "ooxml-leftCircularArrow", "leftCircularArrow" },
{ "ooxml-rightArrow", "rightArrow" },
{ "ooxml-flowChartPunchedCard", "flowChartPunchedCard" },
{ "ooxml-snip2DiagRect", "snip2DiagRect" },
{ "ooxml-verticalScroll", "verticalScroll" },
{ "ooxml-star7", "star7" },
{ "ooxml-chartX", "chartX" },
{ "ooxml-cloud", "cloud" },
{ "ooxml-cube", "cube" },
{ "ooxml-round2DiagRect", "round2DiagRect" },
{ "ooxml-flowChartMultidocument", "flowChartMultidocument" },
{ "ooxml-actionButtonDocument", "actionButtonDocument" },
{ "ooxml-flowChartTerminator", "flowChartTerminator" },
{ "ooxml-flowChartDelay", "flowChartDelay" },
{ "ooxml-curvedConnector5", "curvedConnector5" },
{ "ooxml-horizontalScroll", "horizontalScroll" },
{ "ooxml-bentConnector4", "bentConnector4" },
{ "ooxml-leftRightCircularArrow", "leftRightCircularArrow" },
{ "ooxml-wedgeRectCallout", "wedgeRectCallout" },
{ "ooxml-accentCallout2", "accentCallout2" },
{ "ooxml-flowChartMagneticDrum", "flowChartMagneticDrum" },
{ "ooxml-corner", "corner" },
{ "ooxml-borderCallout2", "borderCallout2" },
{ "ooxml-donut", "donut" },
{ "ooxml-flowChartCollate", "flowChartCollate" },
{ "ooxml-mathNotEqual", "mathNotEqual" },
{ "ooxml-bentConnector2", "bentConnector2" },
{ "ooxml-mathMultiply", "mathMultiply" },
{ "ooxml-heptagon", "heptagon" },
{ "ooxml-rect", "rect" },
{ "ooxml-accentBorderCallout2", "accentBorderCallout2" },
{ "ooxml-pieWedge", "pieWedge" },
{ "ooxml-upArrowCallout", "upArrowCallout" },
{ "ooxml-flowChartProcess", "flowChartProcess" },
{ "ooxml-star5", "star5" },
{ "ooxml-lineInv", "lineInv" },
{ "ooxml-straightConnector1", "straightConnector1" },
{ "ooxml-stripedRightArrow", "stripedRightArrow" },
{ "ooxml-callout3", "callout3" },
{ "ooxml-bentUpArrow", "bentUpArrow" },
{ "ooxml-noSmoking", "noSmoking" },
{ "ooxml-trapezoid", "trapezoid" },
{ "ooxml-cloudCallout", "cloudCallout" },
{ "ooxml-callout1", "callout1" },
{ "ooxml-ribbon", "ribbon" },
{ "ooxml-rect", "rect" },
};
static struct {
const char* sDML;
MSO_SPT nVML;
} const pDMLToVMLTable[] = {
{"notPrimitive", mso_sptNotPrimitive},
{"rectangle", mso_sptRectangle},
{"roundRectangle", mso_sptRoundRectangle},
{"ellipse", mso_sptEllipse},
{"diamond", mso_sptDiamond},
{"triangle", mso_sptIsocelesTriangle},
{"rtTriangle", mso_sptRightTriangle},
{"parallelogram", mso_sptParallelogram},
{"trapezoid", mso_sptTrapezoid},
{"hexagon", mso_sptHexagon},
{"octagon", mso_sptOctagon},
{"plus", mso_sptPlus},
{"star5", mso_sptStar},
{"rightArrow", mso_sptArrow},
{"thickArrow", mso_sptThickArrow},
{"homePlate", mso_sptHomePlate},
{"cube", mso_sptCube},
{"wedgeRoundRectCallout", mso_sptBalloon},
{"star16", mso_sptSeal},
{"arc", mso_sptArc},
{"line", mso_sptLine},
{"plaque", mso_sptPlaque},
{"can", mso_sptCan},
{"donut", mso_sptDonut},
{"textPlain", mso_sptTextSimple},
{"textStop", mso_sptTextOctagon},
{"textTriangle", mso_sptTextHexagon},
{"textCanDown", mso_sptTextCurve},
{"textWave1", mso_sptTextWave},
{"textArchUpPour", mso_sptTextRing},
{"textCanDown", mso_sptTextOnCurve},
{"textArchUp", mso_sptTextOnRing},
{"straightConnector1", mso_sptStraightConnector1},
{"bentConnector2", mso_sptBentConnector2},
{"bentConnector3", mso_sptBentConnector3},
{"bentConnector4", mso_sptBentConnector4},
{"bentConnector5", mso_sptBentConnector5},
{"curvedConnector2", mso_sptCurvedConnector2},
{"curvedConnector3", mso_sptCurvedConnector3},
{"curvedConnector4", mso_sptCurvedConnector4},
{"curvedConnector5", mso_sptCurvedConnector5},
{"callout1", mso_sptCallout1},
{"callout2", mso_sptCallout2},
{"callout3", mso_sptCallout3},
{"accentCallout1", mso_sptAccentCallout1},
{"accentCallout2", mso_sptAccentCallout2},
{"accentCallout3", mso_sptAccentCallout3},
{"borderCallout1", mso_sptBorderCallout1},
{"borderCallout2", mso_sptBorderCallout2},
{"borderCallout3", mso_sptBorderCallout3},
{"accentBorderCallout1", mso_sptAccentBorderCallout1},
{"accentBorderCallout2", mso_sptAccentBorderCallout2},
{"accentBorderCallout3", mso_sptAccentBorderCallout3},
{"ribbon", mso_sptRibbon},
{"ribbon2", mso_sptRibbon2},
{"chevron", mso_sptChevron},
{"pentagon", mso_sptPentagon},
{"noSmoking", mso_sptNoSmoking},
{"star8", mso_sptSeal8},
{"star16", mso_sptSeal16},
{"star32", mso_sptSeal32},
{"wedgeRectCallout", mso_sptWedgeRectCallout},
{"wedgeRoundRectCallout", mso_sptWedgeRRectCallout},
{"wedgeEllipseCallout", mso_sptWedgeEllipseCallout},
{"wave", mso_sptWave},
{"foldedCorner", mso_sptFoldedCorner},
{"leftArrow", mso_sptLeftArrow},
{"downArrow", mso_sptDownArrow},
{"upArrow", mso_sptUpArrow},
{"leftRightArrow", mso_sptLeftRightArrow},
{"upDownArrow", mso_sptUpDownArrow},
{"irregularSeal1", mso_sptIrregularSeal1},
{"irregularSeal2", mso_sptIrregularSeal2},
{"lightningBolt", mso_sptLightningBolt},
{"heart", mso_sptHeart},
{"pictureFrame", mso_sptPictureFrame},
{"quadArrow", mso_sptQuadArrow},
{"leftArrowCallout", mso_sptLeftArrowCallout},
{"rightArrowCallout", mso_sptRightArrowCallout},
{"upArrowCallout", mso_sptUpArrowCallout},
{"downArrowCallout", mso_sptDownArrowCallout},
{"leftRightArrowCallout", mso_sptLeftRightArrowCallout},
{"upDownArrowCallout", mso_sptUpDownArrowCallout},
{"quadArrowCallout", mso_sptQuadArrowCallout},
{"bevel", mso_sptBevel},
{"leftBracket", mso_sptLeftBracket},
{"rightBracket", mso_sptRightBracket},
{"leftBrace", mso_sptLeftBrace},
{"rightBrace", mso_sptRightBrace},
{"leftUpArrow", mso_sptLeftUpArrow},
{"bentUpArrow", mso_sptBentUpArrow},
{"bentArrow", mso_sptBentArrow},
{"star24", mso_sptSeal24},
{"stripedRightArrow", mso_sptStripedRightArrow},
{"notchedRightArrow", mso_sptNotchedRightArrow},
{"blockArc", mso_sptBlockArc},
{"smileyFace", mso_sptSmileyFace},
{"verticalScroll", mso_sptVerticalScroll},
{"horizontalScroll", mso_sptHorizontalScroll},
{"circularArrow", mso_sptCircularArrow},
{"notchedCircularArrow", mso_sptNotchedCircularArrow},
{"uturnArrow", mso_sptUturnArrow},
{"curvedRightArrow", mso_sptCurvedRightArrow},
{"curvedLeftArrow", mso_sptCurvedLeftArrow},
{"curvedUpArrow", mso_sptCurvedUpArrow},
{"curvedDownArrow", mso_sptCurvedDownArrow},
{"cloudCallout", mso_sptCloudCallout},
{"ellipseRibbon", mso_sptEllipseRibbon},
{"ellipseRibbon2", mso_sptEllipseRibbon2},
{"flowChartProcess", mso_sptFlowChartProcess},
{"flowChartDecision", mso_sptFlowChartDecision},
{"flowChartInputOutput", mso_sptFlowChartInputOutput},
{"flowChartPredefinedProcess", mso_sptFlowChartPredefinedProcess},
{"flowChartInternalStorage", mso_sptFlowChartInternalStorage},
{"flowChartDocument", mso_sptFlowChartDocument},
{"flowChartMultidocument", mso_sptFlowChartMultidocument},
{"flowChartTerminator", mso_sptFlowChartTerminator},
{"flowChartPreparation", mso_sptFlowChartPreparation},
{"flowChartManualInput", mso_sptFlowChartManualInput},
{"flowChartManualOperation", mso_sptFlowChartManualOperation},
{"flowChartConnector", mso_sptFlowChartConnector},
{"flowChartPunchedCard", mso_sptFlowChartPunchedCard},
{"flowChartPunchedTape", mso_sptFlowChartPunchedTape},
{"flowChartSummingJunction", mso_sptFlowChartSummingJunction},
{"flowChartOr", mso_sptFlowChartOr},
{"flowChartCollate", mso_sptFlowChartCollate},
{"flowChartSort", mso_sptFlowChartSort},
{"flowChartExtract", mso_sptFlowChartExtract},
{"flowChartMerge", mso_sptFlowChartMerge},
{"flowChartOfflineStorage", mso_sptFlowChartOfflineStorage},
{"flowChartOnlineStorage", mso_sptFlowChartOnlineStorage},
{"flowChartMagneticTape", mso_sptFlowChartMagneticTape},
{"flowChartMagneticDisk", mso_sptFlowChartMagneticDisk},
{"flowChartMagneticDrum", mso_sptFlowChartMagneticDrum},
{"flowChartDisplay", mso_sptFlowChartDisplay},
{"flowChartDelay", mso_sptFlowChartDelay},
{"textPlain", mso_sptTextPlainText},
{"textStop", mso_sptTextStop},
{"textTriangle", mso_sptTextTriangle},
{"textTriangleInverted", mso_sptTextTriangleInverted},
{"textChevron", mso_sptTextChevron},
{"textChevronInverted", mso_sptTextChevronInverted},
{"textRingInside", mso_sptTextRingInside},
{"textRingOutside", mso_sptTextRingOutside},
{"textArchUp", mso_sptTextArchUpCurve},
{"textArchDown", mso_sptTextArchDownCurve},
{"textCircle", mso_sptTextCircleCurve},
{"textButton", mso_sptTextButtonCurve},
{"textArchUpPour", mso_sptTextArchUpPour},
{"textArchDownPour", mso_sptTextArchDownPour},
{"textCirclePour", mso_sptTextCirclePour},
{"textButtonPour", mso_sptTextButtonPour},
{"textCurveUp", mso_sptTextCurveUp},
{"textCurveDown", mso_sptTextCurveDown},
{"textCascadeUp", mso_sptTextCascadeUp},
{"textCascadeDown", mso_sptTextCascadeDown},
{"textWave1", mso_sptTextWave1},
{"textWave2", mso_sptTextWave2},
{"textWave3", mso_sptTextWave3},
{"textWave4", mso_sptTextWave4},
{"textInflate", mso_sptTextInflate},
{"textDeflate", mso_sptTextDeflate},
{"textInflateBottom", mso_sptTextInflateBottom},
{"textDeflateBottom", mso_sptTextDeflateBottom},
{"textInflateTop", mso_sptTextInflateTop},
{"textDeflateTop", mso_sptTextDeflateTop},
{"textDeflateInflate", mso_sptTextDeflateInflate},
{"textDeflateInflateDeflate", mso_sptTextDeflateInflateDeflate},
{"textFadeRight", mso_sptTextFadeRight},
{"textFadeLeft", mso_sptTextFadeLeft},
{"textFadeUp", mso_sptTextFadeUp},
{"textFadeDown", mso_sptTextFadeDown},
{"textSlantUp", mso_sptTextSlantUp},
{"textSlantDown", mso_sptTextSlantDown},
{"textCanUp", mso_sptTextCanUp},
{"textCanDown", mso_sptTextCanDown},
{"flowChartAlternateProcess", mso_sptFlowChartAlternateProcess},
{"flowChartOffpageConnector", mso_sptFlowChartOffpageConnector},
{"callout1", mso_sptCallout90},
{"accentCallout1", mso_sptAccentCallout90},
{"borderCallout1", mso_sptBorderCallout90},
{"accentBorderCallout1", mso_sptAccentBorderCallout90},
{"leftRightUpArrow", mso_sptLeftRightUpArrow},
{"sun", mso_sptSun},
{"moon", mso_sptMoon},
{"bracketPair", mso_sptBracketPair},
{"bracePair", mso_sptBracePair},
{"star4", mso_sptSeal4},
{"doubleWave", mso_sptDoubleWave},
{"actionButtonBlank", mso_sptActionButtonBlank},
{"actionButtonHome", mso_sptActionButtonHome},
{"actionButtonHelp", mso_sptActionButtonHelp},
{"actionButtonInformation", mso_sptActionButtonInformation},
{"actionButtonForwardNext", mso_sptActionButtonForwardNext},
{"actionButtonBackPrevious", mso_sptActionButtonBackPrevious},
{"actionButtonEnd", mso_sptActionButtonEnd},
{"actionButtonBeginning", mso_sptActionButtonBeginning},
{"actionButtonReturn", mso_sptActionButtonReturn},
{"actionButtonDocument", mso_sptActionButtonDocument},
{"actionButtonSound", mso_sptActionButtonSound},
{"actionButtonMovie", mso_sptActionButtonMovie},
{"hostControl", mso_sptHostControl},
{"textBox", mso_sptTextBox},
};
typedef boost::unordered_map< const char*, const char*, rtl::CStringHash, rtl::CStringEqual> CustomShapeTypeTranslationHashMap;
static CustomShapeTypeTranslationHashMap* pCustomShapeTypeTranslationHashMap = NULL;
const char* GetOOXMLPresetGeometry( const char* sShapeType )
{
const char* sPresetGeo;
if( pCustomShapeTypeTranslationHashMap == NULL )
{
pCustomShapeTypeTranslationHashMap = new CustomShapeTypeTranslationHashMap ();
for( unsigned int i = 0; i < SAL_N_ELEMENTS(pCustomShapeTypeTranslationTable); ++i )
{
(*pCustomShapeTypeTranslationHashMap)[ pCustomShapeTypeTranslationTable[ i ].sOOo ] = pCustomShapeTypeTranslationTable[ i ].sMSO;
}
}
sPresetGeo = (*pCustomShapeTypeTranslationHashMap)[ sShapeType ];
if( sPresetGeo == NULL )
sPresetGeo = "rect";
return sPresetGeo;
}
typedef boost::unordered_map< const char*, MSO_SPT, rtl::CStringHash, rtl::CStringEqual> DMLToVMLTranslationHashMap;
static DMLToVMLTranslationHashMap* pDMLToVMLMap;
MSO_SPT GETVMLShapeType(const OString& aType)
{
const char* pDML = GetOOXMLPresetGeometry(aType.getStr());
if (!pDMLToVMLMap)
{
pDMLToVMLMap = new DMLToVMLTranslationHashMap();
for (size_t i = 0; i < SAL_N_ELEMENTS(pDMLToVMLTable); ++i)
(*pDMLToVMLMap)[pDMLToVMLTable[i].sDML] = pDMLToVMLTable[i].nVML;
}
if (pDMLToVMLMap->find(pDML) == pDMLToVMLMap->end())
return mso_sptNil;
return (*pDMLToVMLMap)[pDML];
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|