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
|
/* -*- 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 <xlstyle.hxx>
#include <com/sun/star/awt/FontFamily.hpp>
#include <com/sun/star/awt/FontSlant.hpp>
#include <com/sun/star/awt/FontStrikeout.hpp>
#include <com/sun/star/awt/FontUnderline.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <vcl/font.hxx>
#include <sal/macros.h>
#include <sal/log.hxx>
#include <rtl/tencinfo.h>
#include <svl/numformat.hxx>
#include <svtools/colorcfg.hxx>
#include <vcl/unohelp.hxx>
#include <editeng/svxfont.hxx>
#include <o3tl/unit_conversion.hxx>
#include <global.hxx>
#include <xlroot.hxx>
#include <xltools.hxx>
// Color data =================================================================
/** Standard EGA colors, bright. */
#define EXC_PALETTE_EGA_COLORS_LIGHT \
Color(0x000000), Color(0xFFFFFF), Color(0xFF0000), Color(0x00FF00), Color(0x0000FF), Color(0xFFFF00), Color(0xFF00FF), Color(0x00FFFF)
/** Standard EGA colors, dark. */
#define EXC_PALETTE_EGA_COLORS_DARK \
Color(0x800000), Color(0x008000), Color(0x000080), Color(0x808000), Color(0x800080), Color(0x008080), Color(0xC0C0C0), Color(0x808080)
/** Default color table for BIFF2. */
const Color spnDefColorTable2[] =
{
/* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT
};
/** Default color table for BIFF3/BIFF4. */
const Color spnDefColorTable3[] =
{
/* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT,
/* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT,
/* 16 */ EXC_PALETTE_EGA_COLORS_DARK
};
/** Default color table for BIFF5/BIFF7. */
const Color spnDefColorTable5[] =
{
/* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT,
/* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT,
/* 16 */ EXC_PALETTE_EGA_COLORS_DARK,
/* 24 */ Color(0x8080FF), Color(0x802060), Color(0xFFFFC0), Color(0xA0E0E0), Color(0x600080), Color(0xFF8080), Color(0x0080C0), Color(0xC0C0FF),
/* 32 */ Color(0x000080), Color(0xFF00FF), Color(0xFFFF00), Color(0x00FFFF), Color(0x800080), Color(0x800000), Color(0x008080), Color(0x0000FF),
/* 40 */ Color(0x00CFFF), Color(0x69FFFF), Color(0xE0FFE0), Color(0xFFFF80), Color(0xA6CAF0), Color(0xDD9CB3), Color(0xB38FEE), Color(0xE3E3E3),
/* 48 */ Color(0x2A6FF9), Color(0x3FB8CD), Color(0x488436), Color(0x958C41), Color(0x8E5E42), Color(0xA0627A), Color(0x624FAC), Color(0x969696),
/* 56 */ Color(0x1D2FBE), Color(0x286676), Color(0x004500), Color(0x453E01), Color(0x6A2813), Color(0x85396A), Color(0x4A3285), Color(0x424242)
};
/** Default color table for BIFF8. */
const Color spnDefColorTable8[] =
{
/* 0 */ EXC_PALETTE_EGA_COLORS_LIGHT,
/* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT,
/* 16 */ EXC_PALETTE_EGA_COLORS_DARK,
/* 24 */ Color(0x9999FF), Color(0x993366), Color(0xFFFFCC), Color(0xCCFFFF), Color(0x660066), Color(0xFF8080), Color(0x0066CC), Color(0xCCCCFF),
/* 32 */ Color(0x000080), Color(0xFF00FF), Color(0xFFFF00), Color(0x00FFFF), Color(0x800080), Color(0x800000), Color(0x008080), Color(0x0000FF),
/* 40 */ Color(0x00CCFF), Color(0xCCFFFF), Color(0xCCFFCC), Color(0xFFFF99), Color(0x99CCFF), Color(0xFF99CC), Color(0xCC99FF), Color(0xFFCC99),
/* 48 */ Color(0x3366FF), Color(0x33CCCC), Color(0x99CC00), Color(0xFFCC00), Color(0xFF9900), Color(0xFF6600), Color(0x666699), Color(0x969696),
/* 56 */ Color(0x003366), Color(0x339966), Color(0x003300), Color(0x333300), Color(0x993300), Color(0x993366), Color(0x333399), Color(0x333333)
};
#undef EXC_PALETTE_EGA_COLORS_LIGHT
#undef EXC_PALETTE_EGA_COLORS_DARK
XclDefaultPalette::XclDefaultPalette( const XclRoot& rRoot ) :
mpnColorTable( nullptr ),
mnTableSize( 0 )
{
const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
mnFaceColor = rSett.GetFaceColor();
// Don't use the system HelpBack and HelpText colours as it causes problems
// with modern gnome. This is because mnNoteText and mnNoteBack are used
// when colour indices ( instead of real colours ) are specified.
// Note: That this it is not an unusual scenario that we get the Note
// background specified as a real colour and the text specified as a
// colour index. That means the text colour would be picked from
// the system where the note background would be picked from a real colour.
// Previously the note text colour was picked from the system tooltip
// text colour, on modern gnome(e.g. 3) that tends to be 'white' with the
// default theme.
// Using the Libreoffice defaults ( instead of system specific colours
// ) lessens the chance of the one colour being an unsuitable combination
// because by default the note text is black and the note background is
// a light yellow colour ( very similar to Excel's normal defaults )
mnNoteText = svtools::ColorConfig::GetDefaultColor( svtools::FONTCOLOR );
mnNoteBack = svtools::ColorConfig::GetDefaultColor( svtools::CALCNOTESBACKGROUND );
// default colors
switch( rRoot.GetBiff() )
{
case EXC_BIFF2:
mpnColorTable = spnDefColorTable2;
mnTableSize = SAL_N_ELEMENTS( spnDefColorTable2 );
break;
case EXC_BIFF3:
case EXC_BIFF4:
mpnColorTable = spnDefColorTable3;
mnTableSize = SAL_N_ELEMENTS( spnDefColorTable3 );
break;
case EXC_BIFF5:
mpnColorTable = spnDefColorTable5;
mnTableSize = SAL_N_ELEMENTS( spnDefColorTable5 );
break;
case EXC_BIFF8:
mpnColorTable = spnDefColorTable8;
mnTableSize = SAL_N_ELEMENTS( spnDefColorTable8 );
break;
default:
DBG_ERROR_BIFF();
}
}
Color XclDefaultPalette::GetDefColor( sal_uInt16 nXclIndex ) const
{
Color nColor;
if( nXclIndex < mnTableSize )
nColor = mpnColorTable[ nXclIndex ];
else switch( nXclIndex )
{
case EXC_COLOR_WINDOWTEXT3:
case EXC_COLOR_WINDOWTEXT:
case EXC_COLOR_CHWINDOWTEXT: nColor = COL_BLACK; break;
case EXC_COLOR_WINDOWBACK3:
case EXC_COLOR_WINDOWBACK:
case EXC_COLOR_CHWINDOWBACK: nColor = COL_WHITE; break;
case EXC_COLOR_BUTTONBACK: nColor = mnFaceColor; break;
case EXC_COLOR_CHBORDERAUTO: nColor = COL_BLACK; break; // TODO: really always black?
case EXC_COLOR_NOTEBACK: nColor = mnNoteBack; break;
case EXC_COLOR_NOTETEXT: nColor = mnNoteText; break;
case EXC_COLOR_FONTAUTO: nColor = COL_AUTO; break;
default:
SAL_WARN("sc", "XclDefaultPalette::GetDefColor - unknown default color index: " << nXclIndex );
nColor = COL_AUTO;
}
return nColor;
}
// Font Data ==================================================================
namespace Awt = ::com::sun::star::awt;
namespace AwtFontFamily = Awt::FontFamily;
namespace AwtFontLineStyle = Awt::FontUnderline;
namespace AwtFontStrikeout = Awt::FontStrikeout;
XclFontData::XclFontData()
{
Clear();
}
XclFontData::XclFontData( const vcl::Font& rFont )
{
Clear();
FillFromVclFont( rFont );
}
XclFontData::XclFontData( const SvxFont& rFont )
{
FillFromSvxFont( rFont );
}
void XclFontData::Clear()
{
maName.clear();
maStyle.clear();
maColor = COL_AUTO;
mnHeight = 0;
mnWeight = EXC_FONTWGHT_DONTKNOW;
mnEscapem = EXC_FONTESC_NONE;
mnFamily = EXC_FONTFAM_SYSTEM;
mnCharSet = EXC_FONTCSET_ANSI_LATIN;
mnUnderline = EXC_FONTUNDERL_NONE;
mbItalic = mbStrikeout = mbOutline = mbShadow = false;
}
void XclFontData::FillFromVclFont( const vcl::Font& rFont )
{
maName = XclTools::GetXclFontName( rFont.GetFamilyName() ); // substitute with MS fonts
maStyle.clear();
maColor = rFont.GetColor();
SetScUnderline( rFont.GetUnderline() );
mnEscapem = EXC_FONTESC_NONE;
SetScHeight( rFont.GetFontSize().Height() );
SetScWeight( rFont.GetWeight() );
SetScFamily( rFont.GetFamilyType() );
SetFontEncoding( rFont.GetCharSet() );
SetScPosture( rFont.GetItalic() );
SetScStrikeout( rFont.GetStrikeout() );
mbOutline = rFont.IsOutline();
mbShadow = rFont.IsShadow();
}
void XclFontData::FillFromSvxFont( const SvxFont& rFont )
{
FillFromVclFont( rFont );
SetScEscapement( rFont.GetEscapement() );
}
// *** conversion of VCL/SVX constants *** ------------------------------------
FontFamily XclFontData::GetScFamily( rtl_TextEncoding eDefTextEnc ) const
{
FontFamily eScFamily;
// ! format differs from Windows documentation: family is in lower nibble, pitch unknown
switch( mnFamily & 0x0F )
{
case EXC_FONTFAM_ROMAN: eScFamily = FAMILY_ROMAN; break;
case EXC_FONTFAM_SWISS: eScFamily = FAMILY_SWISS; break;
case EXC_FONTFAM_MODERN: eScFamily = FAMILY_MODERN; break;
case EXC_FONTFAM_SCRIPT: eScFamily = FAMILY_SCRIPT; break;
case EXC_FONTFAM_DECORATIVE: eScFamily = FAMILY_DECORATIVE; break;
default:
eScFamily =
((eDefTextEnc == RTL_TEXTENCODING_APPLE_ROMAN) &&
(maName.equalsIgnoreAsciiCase( "Geneva" ) || maName.equalsIgnoreAsciiCase( "Chicago" ))) ?
FAMILY_SWISS : FAMILY_DONTKNOW;
}
return eScFamily;
}
rtl_TextEncoding XclFontData::GetFontEncoding() const
{
// convert Windows character set to text encoding identifier
return rtl_getTextEncodingFromWindowsCharset( mnCharSet );
}
FontItalic XclFontData::GetScPosture() const
{
return mbItalic ? ITALIC_NORMAL : ITALIC_NONE;
}
FontWeight XclFontData::GetScWeight() const
{
FontWeight eScWeight;
if( !mnWeight ) eScWeight = WEIGHT_DONTKNOW;
else if( mnWeight < 150 ) eScWeight = WEIGHT_THIN;
else if( mnWeight < 250 ) eScWeight = WEIGHT_ULTRALIGHT;
else if( mnWeight < 325 ) eScWeight = WEIGHT_LIGHT;
else if( mnWeight < 375 ) eScWeight = WEIGHT_SEMILIGHT;
else if( mnWeight < 450 ) eScWeight = WEIGHT_NORMAL;
else if( mnWeight < 550 ) eScWeight = WEIGHT_MEDIUM;
else if( mnWeight < 650 ) eScWeight = WEIGHT_SEMIBOLD;
else if( mnWeight < 750 ) eScWeight = WEIGHT_BOLD;
else if( mnWeight < 850 ) eScWeight = WEIGHT_ULTRABOLD;
else eScWeight = WEIGHT_BLACK;
return eScWeight;
}
FontLineStyle XclFontData::GetScUnderline() const
{
FontLineStyle eScUnderl = LINESTYLE_NONE;
switch( mnUnderline )
{
case EXC_FONTUNDERL_SINGLE:
case EXC_FONTUNDERL_SINGLE_ACC: eScUnderl = LINESTYLE_SINGLE; break;
case EXC_FONTUNDERL_DOUBLE:
case EXC_FONTUNDERL_DOUBLE_ACC: eScUnderl = LINESTYLE_DOUBLE; break;
}
return eScUnderl;
}
SvxEscapement XclFontData::GetScEscapement() const
{
SvxEscapement eScEscapem = SvxEscapement::Off;
switch( mnEscapem )
{
case EXC_FONTESC_SUPER: eScEscapem = SvxEscapement::Superscript; break;
case EXC_FONTESC_SUB: eScEscapem = SvxEscapement::Subscript; break;
}
return eScEscapem;
}
FontStrikeout XclFontData::GetScStrikeout() const
{
return mbStrikeout ? STRIKEOUT_SINGLE : STRIKEOUT_NONE;
}
void XclFontData::SetScHeight( sal_Int32 nTwips )
{
mnHeight = static_cast< sal_uInt16 >( ::std::min( nTwips, static_cast<sal_Int32>(0x7FFFL) ) );
}
void XclFontData::SetScFamily( FontFamily eScFamily )
{
switch( eScFamily )
{
case FAMILY_DONTKNOW: mnFamily = EXC_FONTFAM_DONTKNOW; break;
case FAMILY_DECORATIVE: mnFamily = EXC_FONTFAM_DECORATIVE; break;
case FAMILY_MODERN: mnFamily = EXC_FONTFAM_MODERN; break;
case FAMILY_ROMAN: mnFamily = EXC_FONTFAM_ROMAN; break;
case FAMILY_SCRIPT: mnFamily = EXC_FONTFAM_SCRIPT; break;
case FAMILY_SWISS: mnFamily = EXC_FONTFAM_SWISS; break;
case FAMILY_SYSTEM: mnFamily = EXC_FONTFAM_SYSTEM; break;
default:
OSL_FAIL( "XclFontData::SetScFamily - unknown font family" );
mnFamily = EXC_FONTFAM_DONTKNOW;
}
}
void XclFontData::SetFontEncoding( rtl_TextEncoding eFontEnc )
{
// convert text encoding identifier to Windows character set
mnCharSet = rtl_getBestWindowsCharsetFromTextEncoding( eFontEnc );
}
void XclFontData::SetScPosture( FontItalic eScPosture )
{
mbItalic = (eScPosture == ITALIC_OBLIQUE) || (eScPosture == ITALIC_NORMAL);
}
void XclFontData::SetScWeight( FontWeight eScWeight )
{
switch( eScWeight )
{
case WEIGHT_DONTKNOW: mnWeight = EXC_FONTWGHT_DONTKNOW; break;
case WEIGHT_THIN: mnWeight = EXC_FONTWGHT_THIN; break;
case WEIGHT_ULTRALIGHT: mnWeight = EXC_FONTWGHT_ULTRALIGHT; break;
case WEIGHT_LIGHT: mnWeight = EXC_FONTWGHT_LIGHT; break;
case WEIGHT_SEMILIGHT: mnWeight = EXC_FONTWGHT_SEMILIGHT; break;
case WEIGHT_NORMAL: mnWeight = EXC_FONTWGHT_NORMAL; break;
case WEIGHT_MEDIUM: mnWeight = EXC_FONTWGHT_MEDIUM; break;
case WEIGHT_SEMIBOLD: mnWeight = EXC_FONTWGHT_SEMIBOLD; break;
case WEIGHT_BOLD: mnWeight = EXC_FONTWGHT_BOLD; break;
case WEIGHT_ULTRABOLD: mnWeight = EXC_FONTWGHT_ULTRABOLD; break;
case WEIGHT_BLACK: mnWeight = EXC_FONTWGHT_BLACK; break;
default: mnWeight = EXC_FONTWGHT_NORMAL;
}
}
void XclFontData::SetScUnderline( FontLineStyle eScUnderl )
{
switch( eScUnderl )
{
case LINESTYLE_NONE:
case LINESTYLE_DONTKNOW: mnUnderline = EXC_FONTUNDERL_NONE; break;
case LINESTYLE_DOUBLE:
case LINESTYLE_DOUBLEWAVE: mnUnderline = EXC_FONTUNDERL_DOUBLE; break;
default: mnUnderline = EXC_FONTUNDERL_SINGLE;
}
}
void XclFontData::SetScEscapement( short nScEscapem )
{
if( nScEscapem > 0 )
mnEscapem = EXC_FONTESC_SUPER;
else if( nScEscapem < 0 )
mnEscapem = EXC_FONTESC_SUB;
else
mnEscapem = EXC_FONTESC_NONE;
}
void XclFontData::SetScStrikeout( FontStrikeout eScStrikeout )
{
mbStrikeout =
(eScStrikeout == STRIKEOUT_SINGLE) || (eScStrikeout == STRIKEOUT_DOUBLE) ||
(eScStrikeout == STRIKEOUT_BOLD) || (eScStrikeout == STRIKEOUT_SLASH) ||
(eScStrikeout == STRIKEOUT_X);
}
// *** conversion of API constants *** ----------------------------------------
float XclFontData::GetApiHeight() const
{
return o3tl::convert<double>(mnHeight, o3tl::Length::twip, o3tl::Length::pt);
}
sal_Int16 XclFontData::GetApiFamily() const
{
sal_Int16 nApiFamily = AwtFontFamily::DONTKNOW;
switch( mnFamily )
{
case FAMILY_DECORATIVE: nApiFamily = AwtFontFamily::DECORATIVE; break;
case FAMILY_MODERN: nApiFamily = AwtFontFamily::MODERN; break;
case FAMILY_ROMAN: nApiFamily = AwtFontFamily::ROMAN; break;
case FAMILY_SCRIPT: nApiFamily = AwtFontFamily::SCRIPT; break;
case FAMILY_SWISS: nApiFamily = AwtFontFamily::SWISS; break;
case FAMILY_SYSTEM: nApiFamily = AwtFontFamily::SYSTEM; break;
}
return nApiFamily;
}
sal_Int16 XclFontData::GetApiFontEncoding() const
{
// API constants are equal to rtl_TextEncoding constants
return static_cast< sal_Int16 >( GetFontEncoding() );
}
Awt::FontSlant XclFontData::GetApiPosture() const
{
return mbItalic ? Awt::FontSlant_ITALIC : Awt::FontSlant_NONE;
}
float XclFontData::GetApiWeight() const
{
return vcl::unohelper::ConvertFontWeight( GetScWeight() );
}
sal_Int16 XclFontData::GetApiUnderline() const
{
sal_Int16 nApiUnderl = AwtFontLineStyle::NONE;
switch( mnUnderline )
{
case EXC_FONTUNDERL_SINGLE:
case EXC_FONTUNDERL_SINGLE_ACC: nApiUnderl = AwtFontLineStyle::SINGLE; break;
case EXC_FONTUNDERL_DOUBLE:
case EXC_FONTUNDERL_DOUBLE_ACC: nApiUnderl = AwtFontLineStyle::DOUBLE; break;
}
return nApiUnderl;
}
sal_Int16 XclFontData::GetApiEscapement() const
{
sal_Int16 nApiEscapem = 0;
switch( mnEscapem )
{
case EXC_FONTESC_SUPER: nApiEscapem = 33; break;
case EXC_FONTESC_SUB: nApiEscapem = -33; break;
}
return nApiEscapem;
}
sal_Int16 XclFontData::GetApiStrikeout() const
{
return mbStrikeout ? AwtFontStrikeout::SINGLE : AwtFontStrikeout::NONE;
}
void XclFontData::SetApiHeight( float fPoint )
{
mnHeight = std::min(o3tl::convert(fPoint, o3tl::Length::pt, o3tl::Length::twip) + 0.5, 32767.0);
}
void XclFontData::SetApiFamily( sal_Int16 nApiFamily )
{
switch( nApiFamily )
{
case AwtFontFamily::DECORATIVE: mnFamily = FAMILY_DECORATIVE; break;
case AwtFontFamily::MODERN: mnFamily = FAMILY_MODERN; break;
case AwtFontFamily::ROMAN: mnFamily = FAMILY_ROMAN; break;
case AwtFontFamily::SCRIPT: mnFamily = FAMILY_SCRIPT; break;
case AwtFontFamily::SWISS: mnFamily = FAMILY_SWISS; break;
case AwtFontFamily::SYSTEM: mnFamily = FAMILY_SYSTEM; break;
default: mnFamily = FAMILY_DONTKNOW;
}
}
void XclFontData::SetApiPosture( Awt::FontSlant eApiPosture )
{
mbItalic =
(eApiPosture == Awt::FontSlant_OBLIQUE) ||
(eApiPosture == Awt::FontSlant_ITALIC) ||
(eApiPosture == Awt::FontSlant_REVERSE_OBLIQUE) ||
(eApiPosture == Awt::FontSlant_REVERSE_ITALIC);
}
void XclFontData::SetApiWeight( float fApiWeight )
{
SetScWeight( vcl::unohelper::ConvertFontWeight( fApiWeight ) );
}
void XclFontData::SetApiUnderline( sal_Int16 nApiUnderl )
{
switch( nApiUnderl )
{
case AwtFontLineStyle::NONE:
case AwtFontLineStyle::DONTKNOW: mnUnderline = EXC_FONTUNDERL_NONE; break;
case AwtFontLineStyle::DOUBLE:
case AwtFontLineStyle::DOUBLEWAVE: mnUnderline = EXC_FONTUNDERL_DOUBLE; break;
default: mnUnderline = EXC_FONTUNDERL_SINGLE;
}
}
void XclFontData::SetApiEscapement( sal_Int16 nApiEscapem )
{
if( nApiEscapem > 0 )
mnEscapem = EXC_FONTESC_SUPER;
else if( nApiEscapem < 0 )
mnEscapem = EXC_FONTESC_SUB;
else
mnEscapem = EXC_FONTESC_NONE;
}
void XclFontData::SetApiStrikeout( sal_Int16 nApiStrikeout )
{
mbStrikeout =
(nApiStrikeout != AwtFontStrikeout::NONE) &&
(nApiStrikeout != AwtFontStrikeout::DONTKNOW);
}
bool operator==( const XclFontData& rLeft, const XclFontData& rRight )
{
return
(rLeft.mnHeight == rRight.mnHeight) &&
(rLeft.mnWeight == rRight.mnWeight) &&
(rLeft.mnUnderline == rRight.mnUnderline) &&
(rLeft.maColor == rRight.maColor) &&
(rLeft.mnEscapem == rRight.mnEscapem) &&
(rLeft.mnFamily == rRight.mnFamily) &&
(rLeft.mnCharSet == rRight.mnCharSet) &&
(rLeft.mbItalic == rRight.mbItalic) &&
(rLeft.mbStrikeout == rRight.mbStrikeout) &&
(rLeft.mbOutline == rRight.mbOutline) &&
(rLeft.mbShadow == rRight.mbShadow) &&
(rLeft.maName == rRight.maName);
}
namespace {
/** Property names for common font settings. */
const char *const sppcPropNamesChCommon[] =
{
"CharUnderline", "CharStrikeout", "CharColor", "CharContoured", "CharShadowed", nullptr
};
/** Property names for Western font settings. */
const char *const sppcPropNamesChWstrn[] =
{
"CharFontName", "CharHeight", "CharPosture", "CharWeight", nullptr
};
/** Property names for Asian font settings. */
const char *const sppcPropNamesChAsian[] =
{
"CharFontNameAsian", "CharHeightAsian", "CharPostureAsian", "CharWeightAsian", nullptr
};
/** Property names for Complex font settings. */
const char *const sppcPropNamesChCmplx[] =
{
"CharFontNameComplex", "CharHeightComplex", "CharPostureComplex", "CharWeightComplex", nullptr
};
/** Property names for escapement. */
const char *const sppcPropNamesChEscapement[] =
{
"CharEscapement", "CharEscapementHeight", nullptr
};
const sal_Int8 EXC_API_ESC_HEIGHT = 58; /// Default escapement font height.
/** Property names for Western font settings without font name. */
const char *const *const sppcPropNamesChWstrnNoName = sppcPropNamesChWstrn + 1;
/** Property names for Asian font settings without font name. */
const char *const *const sppcPropNamesChAsianNoName = sppcPropNamesChAsian + 1;
/** Property names for Complex font settings without font name. */
const char *const *const sppcPropNamesChCmplxNoName = sppcPropNamesChCmplx + 1;
/** Property names for font settings in form controls. */
const char *const sppcPropNamesControl[] =
{
"FontName", "FontFamily", "FontCharset", "FontHeight", "FontSlant",
"FontWeight", "FontLineStyle", "FontStrikeout", "TextColor", nullptr
};
/** Inserts all passed API font settings into the font data object. */
void lclSetApiFontSettings( XclFontData& rFontData,
const OUString& rApiFontName, float fApiHeight, float fApiWeight,
Awt::FontSlant eApiPosture, sal_Int16 nApiUnderl, sal_Int16 nApiStrikeout )
{
rFontData.maName = XclTools::GetXclFontName( rApiFontName );
rFontData.SetApiHeight( fApiHeight );
rFontData.SetApiWeight( fApiWeight );
rFontData.SetApiPosture( eApiPosture );
rFontData.SetApiUnderline( nApiUnderl );
rFontData.SetApiStrikeout( nApiStrikeout );
}
/** Writes script dependent properties to a font property set helper. */
void lclWriteChartFont( ScfPropertySet& rPropSet,
ScfPropSetHelper& rHlpName, ScfPropSetHelper& rHlpNoName,
const XclFontData& rFontData, bool bHasFontName )
{
// select the font helper
ScfPropSetHelper& rPropSetHlp = bHasFontName ? rHlpName : rHlpNoName;
// initialize the font helper (must be called before writing any properties)
rPropSetHlp.InitializeWrite();
// write font name
if( bHasFontName )
rPropSetHlp << rFontData.maName;
// write remaining properties
rPropSetHlp << rFontData.GetApiHeight() << rFontData.GetApiPosture() << rFontData.GetApiWeight();
// write properties to property set
rPropSetHlp.WriteToPropertySet( rPropSet );
}
} // namespace
XclFontPropSetHelper::XclFontPropSetHelper() :
maHlpChCommon( sppcPropNamesChCommon ),
maHlpChWstrn( sppcPropNamesChWstrn ),
maHlpChAsian( sppcPropNamesChAsian ),
maHlpChCmplx( sppcPropNamesChCmplx ),
maHlpChWstrnNoName( sppcPropNamesChWstrnNoName ),
maHlpChAsianNoName( sppcPropNamesChAsianNoName ),
maHlpChCmplxNoName( sppcPropNamesChCmplxNoName ),
maHlpChEscapement( sppcPropNamesChEscapement ),
maHlpControl( sppcPropNamesControl )
{
}
void XclFontPropSetHelper::ReadFontProperties( XclFontData& rFontData,
const ScfPropertySet& rPropSet, XclFontPropSetType eType, sal_Int16 nScript )
{
switch( eType )
{
case EXC_FONTPROPSET_CHART:
{
OUString aApiFontName;
float fApiHeight, fApiWeight;
sal_Int16 nApiUnderl = 0, nApiStrikeout = 0;
Awt::FontSlant eApiPosture;
// read script type dependent properties
ScfPropSetHelper& rPropSetHlp = GetChartHelper( nScript );
rPropSetHlp.ReadFromPropertySet( rPropSet );
rPropSetHlp >> aApiFontName >> fApiHeight >> eApiPosture >> fApiWeight;
// read common properties
maHlpChCommon.ReadFromPropertySet( rPropSet );
maHlpChCommon >> nApiUnderl
>> nApiStrikeout
>> rFontData.maColor
>> rFontData.mbOutline
>> rFontData.mbShadow;
// convert API property values to Excel settings
lclSetApiFontSettings( rFontData, aApiFontName,
fApiHeight, fApiWeight, eApiPosture, nApiUnderl, nApiStrikeout );
// font escapement
sal_Int16 nApiEscapement = 0;
sal_Int8 nApiEscHeight = 0;
maHlpChEscapement.ReadFromPropertySet( rPropSet );
maHlpChEscapement.ReadFromPropertySet( rPropSet );
maHlpChEscapement.ReadFromPropertySet( rPropSet );
maHlpChEscapement >> nApiEscapement >> nApiEscHeight;
rFontData.SetApiEscapement( nApiEscapement );
}
break;
case EXC_FONTPROPSET_CONTROL:
{
OUString aApiFontName;
float fApiHeight(0.0), fApiWeight(0.0);
sal_Int16 nApiFamily(0), nApiCharSet(0), nApiPosture(0), nApiUnderl(0), nApiStrikeout(0);
// read font properties
maHlpControl.ReadFromPropertySet( rPropSet );
maHlpControl >> aApiFontName
>> nApiFamily
>> nApiCharSet
>> fApiHeight
>> nApiPosture
>> fApiWeight
>> nApiUnderl
>> nApiStrikeout
>> rFontData.maColor;
// convert API property values to Excel settings
Awt::FontSlant eApiPosture = static_cast< Awt::FontSlant >( nApiPosture );
lclSetApiFontSettings( rFontData, aApiFontName,
fApiHeight, fApiWeight, eApiPosture, nApiUnderl, nApiStrikeout );
rFontData.SetApiFamily( nApiFamily );
rFontData.SetFontEncoding( nApiCharSet );
}
break;
}
}
void XclFontPropSetHelper::WriteFontProperties(
ScfPropertySet& rPropSet, XclFontPropSetType eType,
const XclFontData& rFontData, bool bHasWstrn, bool bHasAsian, bool bHasCmplx,
const Color* pFontColor )
{
switch( eType )
{
case EXC_FONTPROPSET_CHART:
{
// write common properties
maHlpChCommon.InitializeWrite();
const Color& rColor = pFontColor ? *pFontColor : rFontData.maColor;
maHlpChCommon << rFontData.GetApiUnderline()
<< rFontData.GetApiStrikeout()
<< rColor
<< rFontData.mbOutline
<< rFontData.mbShadow;
maHlpChCommon.WriteToPropertySet( rPropSet );
// write script type dependent properties
lclWriteChartFont( rPropSet, maHlpChWstrn, maHlpChWstrnNoName, rFontData, bHasWstrn );
lclWriteChartFont( rPropSet, maHlpChAsian, maHlpChAsianNoName, rFontData, bHasAsian );
lclWriteChartFont( rPropSet, maHlpChCmplx, maHlpChCmplxNoName, rFontData, bHasCmplx );
// font escapement
if( rFontData.GetScEscapement() != SvxEscapement::Off )
{
maHlpChEscapement.InitializeWrite();
maHlpChEscapement << rFontData.GetApiEscapement() << EXC_API_ESC_HEIGHT;
maHlpChEscapement.WriteToPropertySet( rPropSet );
}
}
break;
case EXC_FONTPROPSET_CONTROL:
{
maHlpControl.InitializeWrite();
maHlpControl << rFontData.maName
<< rFontData.GetApiFamily()
<< rFontData.GetApiFontEncoding()
<< static_cast< sal_Int16 >( rFontData.GetApiHeight() + 0.5 )
<< rFontData.GetApiPosture()
<< rFontData.GetApiWeight()
<< rFontData.GetApiUnderline()
<< rFontData.GetApiStrikeout()
<< rFontData.maColor;
maHlpControl.WriteToPropertySet( rPropSet );
}
break;
}
}
ScfPropSetHelper& XclFontPropSetHelper::GetChartHelper( sal_Int16 nScript )
{
namespace ApiScriptType = ::com::sun::star::i18n::ScriptType;
switch( nScript )
{
case ApiScriptType::LATIN: return maHlpChWstrn;
case ApiScriptType::ASIAN: return maHlpChAsian;
case ApiScriptType::COMPLEX: return maHlpChCmplx;
default: OSL_FAIL( "XclFontPropSetHelper::GetChartHelper - unknown script type" );
}
return maHlpChWstrn;
}
// Number formats =============================================================
namespace {
/** Special number format index describing a reused format. */
const NfIndexTableOffset PRV_NF_INDEX_REUSE = NF_INDEX_TABLE_ENTRIES;
/** German primary language not defined, LANGUAGE_GERMAN belongs to Germany. */
constexpr LanguageType PRV_LANGUAGE_GERMAN_PRIM = primary(LANGUAGE_GERMAN);
/** French primary language not defined, LANGUAGE_FRENCH belongs to France. */
constexpr LanguageType PRV_LANGUAGE_FRENCH_PRIM = primary(LANGUAGE_FRENCH);
/** Parent language identifier for Asian languages. */
constexpr LanguageType PRV_LANGUAGE_ASIAN_PRIM = primary(LANGUAGE_CHINESE);
/** Stores the number format used in Calc for an Excel built-in number format. */
struct XclBuiltInFormat
{
sal_uInt16 mnXclNumFmt; /// Excel built-in index.
const char* mpFormat; /// Format string, may be 0 (meOffset used then).
NfIndexTableOffset meOffset; /// SvNumberFormatter format index, if mpFormat==0.
sal_uInt16 mnXclReuseFmt; /// Use this Excel format, if meOffset==PRV_NF_INDEX_REUSE.
};
/** Defines a literal Excel built-in number format. */
#define EXC_NUMFMT_STRING( nXclNumFmt, pcUtf8 ) \
{ nXclNumFmt, pcUtf8, NF_NUMBER_STANDARD, 0 }
/** Defines an Excel built-in number format that maps to an own built-in format. */
#define EXC_NUMFMT_OFFSET( nXclNumFmt, eOffset ) \
{ nXclNumFmt, nullptr, eOffset, 0 }
/** Defines an Excel built-in number format that is the same as the specified. */
#define EXC_NUMFMT_REUSE( nXclNumFmt, nXclReuse ) \
{ nXclNumFmt, nullptr, PRV_NF_INDEX_REUSE, nXclReuse }
/** Terminates an Excel built-in number format table. */
#define EXC_NUMFMT_ENDTABLE() \
{ EXC_FORMAT_NOTFOUND, nullptr, NF_NUMBER_STANDARD, 0 }
// Currency unit characters
#define UTF8_BAHT "\340\270\277"
#define UTF8_EURO "\342\202\254"
#define UTF8_POUND_UK "\302\243"
#define UTF8_SHEQEL "\342\202\252"
#define UTF8_WON "\357\277\246"
#define UTF8_YEN_CS "\357\277\245"
#define UTF8_YEN_JP "\302\245"
// Japanese/Chinese date/time characters
#define UTF8_CJ_YEAR "\345\271\264"
#define UTF8_CJ_MON "\346\234\210"
#define UTF8_CJ_DAY "\346\227\245"
#define UTF8_CJ_HOUR "\346\231\202"
#define UTF8_CJ_MIN "\345\210\206"
#define UTF8_CJ_SEC "\347\247\222"
// Chinese Simplified date/time characters
#define UTF8_CS_HOUR "\346\227\266"
// Korean date/time characters
#define UTF8_KO_YEAR "\353\205\204"
#define UTF8_KO_MON "\354\233\224"
#define UTF8_KO_DAY "\354\235\274"
#define UTF8_KO_HOUR "\354\213\234"
#define UTF8_KO_MIN "\353\266\204"
#define UTF8_KO_SEC "\354\264\210"
/** Default number format table. Last parent of all other tables, used for unknown languages. */
const XclBuiltInFormat spBuiltInFormats_DONTKNOW[] =
{
EXC_NUMFMT_OFFSET( 0, NF_NUMBER_STANDARD ), // General
EXC_NUMFMT_OFFSET( 1, NF_NUMBER_INT ), // 0
EXC_NUMFMT_OFFSET( 2, NF_NUMBER_DEC2 ), // 0.00
EXC_NUMFMT_OFFSET( 3, NF_NUMBER_1000INT ), // #,##0
EXC_NUMFMT_OFFSET( 4, NF_NUMBER_1000DEC2 ), // #,##0.00
// 5...8 contained in file
EXC_NUMFMT_OFFSET( 9, NF_PERCENT_INT ), // 0%
EXC_NUMFMT_OFFSET( 10, NF_PERCENT_DEC2 ), // 0.00%
EXC_NUMFMT_OFFSET( 11, NF_SCIENTIFIC_000E00 ), // 0.00E+00
EXC_NUMFMT_OFFSET( 12, NF_FRACTION_1D ), // # ?/?
EXC_NUMFMT_OFFSET( 13, NF_FRACTION_2D ), // # ??/??
// 14...22 date and time formats
EXC_NUMFMT_OFFSET( 14, NF_DATE_SYS_DDMMYYYY ),
EXC_NUMFMT_OFFSET( 15, NF_DATE_SYS_DMMMYY ),
EXC_NUMFMT_OFFSET( 16, NF_DATE_SYS_DDMMM ),
EXC_NUMFMT_OFFSET( 17, NF_DATE_SYS_MMYY ),
EXC_NUMFMT_OFFSET( 18, NF_TIME_HHMMAMPM ),
EXC_NUMFMT_OFFSET( 19, NF_TIME_HHMMSSAMPM ),
EXC_NUMFMT_OFFSET( 20, NF_TIME_HHMM ),
EXC_NUMFMT_OFFSET( 21, NF_TIME_HHMMSS ),
EXC_NUMFMT_OFFSET( 22, NF_DATETIME_SYSTEM_SHORT_HHMM ),
// 23...36 international formats
EXC_NUMFMT_REUSE( 23, 0 ),
EXC_NUMFMT_REUSE( 24, 0 ),
EXC_NUMFMT_REUSE( 25, 0 ),
EXC_NUMFMT_REUSE( 26, 0 ),
EXC_NUMFMT_REUSE( 27, 14 ),
EXC_NUMFMT_REUSE( 28, 14 ),
EXC_NUMFMT_REUSE( 29, 14 ),
EXC_NUMFMT_REUSE( 30, 14 ),
EXC_NUMFMT_REUSE( 31, 14 ),
EXC_NUMFMT_REUSE( 32, 21 ),
EXC_NUMFMT_REUSE( 33, 21 ),
EXC_NUMFMT_REUSE( 34, 21 ),
EXC_NUMFMT_REUSE( 35, 21 ),
EXC_NUMFMT_REUSE( 36, 14 ),
// 37...44 accounting formats
// 41...44 contained in file
EXC_NUMFMT_STRING( 37, "#,##0;-#,##0" ),
EXC_NUMFMT_STRING( 38, "#,##0;[RED]-#,##0" ),
EXC_NUMFMT_STRING( 39, "#,##0.00;-#,##0.00" ),
EXC_NUMFMT_STRING( 40, "#,##0.00;[RED]-#,##0.00" ),
// 45...49 more special formats
EXC_NUMFMT_STRING( 45, "mm:ss" ),
EXC_NUMFMT_STRING( 46, "[h]:mm:ss" ),
EXC_NUMFMT_STRING( 47, "mm:ss.0" ),
EXC_NUMFMT_STRING( 48, "##0.0E+0" ),
EXC_NUMFMT_OFFSET( 49, NF_TEXT ),
// 50...81 international formats
EXC_NUMFMT_REUSE( 50, 14 ),
EXC_NUMFMT_REUSE( 51, 14 ),
EXC_NUMFMT_REUSE( 52, 14 ),
EXC_NUMFMT_REUSE( 53, 14 ),
EXC_NUMFMT_REUSE( 54, 14 ),
EXC_NUMFMT_REUSE( 55, 14 ),
EXC_NUMFMT_REUSE( 56, 14 ),
EXC_NUMFMT_REUSE( 57, 14 ),
EXC_NUMFMT_REUSE( 58, 14 ),
EXC_NUMFMT_REUSE( 59, 1 ),
EXC_NUMFMT_REUSE( 60, 2 ),
EXC_NUMFMT_REUSE( 61, 3 ),
EXC_NUMFMT_REUSE( 62, 4 ),
EXC_NUMFMT_REUSE( 67, 9 ),
EXC_NUMFMT_REUSE( 68, 10 ),
EXC_NUMFMT_REUSE( 69, 12 ),
EXC_NUMFMT_REUSE( 70, 13 ),
EXC_NUMFMT_REUSE( 71, 14 ),
EXC_NUMFMT_REUSE( 72, 14 ),
EXC_NUMFMT_REUSE( 73, 15 ),
EXC_NUMFMT_REUSE( 74, 16 ),
EXC_NUMFMT_REUSE( 75, 17 ),
EXC_NUMFMT_REUSE( 76, 20 ),
EXC_NUMFMT_REUSE( 77, 21 ),
EXC_NUMFMT_REUSE( 78, 22 ),
EXC_NUMFMT_REUSE( 79, 45 ),
EXC_NUMFMT_REUSE( 80, 46 ),
EXC_NUMFMT_REUSE( 81, 47 ),
// 82...163 not used, must not occur in a file (Excel may crash)
EXC_NUMFMT_ENDTABLE()
};
// ENGLISH --------------------------------------------------------------------
/** Base table for English locales. */
const XclBuiltInFormat spBuiltInFormats_ENGLISH[] =
{
EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ),
EXC_NUMFMT_STRING( 16, "DD-MMM" ),
EXC_NUMFMT_STRING( 17, "MMM-YY" ),
EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
EXC_NUMFMT_STRING( 22, "DD/MM/YYYY hh:mm" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_ENGLISH_UK[] =
{
EXC_NUMFMT_STRING( 63, UTF8_POUND_UK "#,##0;-" UTF8_POUND_UK "#,##0" ),
EXC_NUMFMT_STRING( 64, UTF8_POUND_UK "#,##0;[RED]-" UTF8_POUND_UK "#,##0" ),
EXC_NUMFMT_STRING( 65, UTF8_POUND_UK "#,##0.00;-" UTF8_POUND_UK "#,##0.00" ),
EXC_NUMFMT_STRING( 66, UTF8_POUND_UK "#,##0.00;[RED]-" UTF8_POUND_UK "#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_ENGLISH_EIRE[] =
{
EXC_NUMFMT_STRING( 63, UTF8_EURO "#,##0;-" UTF8_EURO "#,##0" ),
EXC_NUMFMT_STRING( 64, UTF8_EURO "#,##0;[RED]-" UTF8_EURO "#,##0" ),
EXC_NUMFMT_STRING( 65, UTF8_EURO "#,##0.00;-" UTF8_EURO "#,##0.00" ),
EXC_NUMFMT_STRING( 66, UTF8_EURO "#,##0.00;[RED]-" UTF8_EURO "#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_ENGLISH_US[] =
{
EXC_NUMFMT_STRING( 14, "M/D/YYYY" ),
EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
EXC_NUMFMT_STRING( 16, "D-MMM" ),
EXC_NUMFMT_STRING( 20, "h:mm" ),
EXC_NUMFMT_STRING( 21, "h:mm:ss" ),
EXC_NUMFMT_STRING( 22, "M/D/YYYY h:mm" ),
EXC_NUMFMT_STRING( 37, "#,##0_);(#,##0)" ),
EXC_NUMFMT_STRING( 38, "#,##0_);[RED](#,##0)" ),
EXC_NUMFMT_STRING( 39, "#,##0.00_);(#,##0.00)" ),
EXC_NUMFMT_STRING( 40, "#,##0.00_);[RED](#,##0.00)" ),
EXC_NUMFMT_STRING( 63, "$#,##0_);($#,##0)" ),
EXC_NUMFMT_STRING( 64, "$#,##0_);[RED]($#,##0)" ),
EXC_NUMFMT_STRING( 65, "$#,##0.00_);($#,##0.00)" ),
EXC_NUMFMT_STRING( 66, "$#,##0.00_);[RED]($#,##0.00)" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_ENGLISH_CAN[] =
{
EXC_NUMFMT_STRING( 20, "h:mm" ),
EXC_NUMFMT_STRING( 21, "h:mm:ss" ),
EXC_NUMFMT_STRING( 22, "DD/MM/YYYY h:mm" ),
EXC_NUMFMT_STRING( 63, "$#,##0;-$#,##0" ),
EXC_NUMFMT_STRING( 64, "$#,##0;[RED]-$#,##0" ),
EXC_NUMFMT_STRING( 65, "$#,##0.00;-$#,##0.00" ),
EXC_NUMFMT_STRING( 66, "$#,##0.00;[RED]-$#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_ENGLISH_AUS[] =
{
EXC_NUMFMT_STRING( 14, "D/MM/YYYY" ),
EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
EXC_NUMFMT_STRING( 16, "D-MMM" ),
EXC_NUMFMT_STRING( 20, "h:mm" ),
EXC_NUMFMT_STRING( 21, "h:mm:ss" ),
EXC_NUMFMT_STRING( 22, "D/MM/YYYY h:mm" ),
EXC_NUMFMT_STRING( 63, "$#,##0;-$#,##0" ),
EXC_NUMFMT_STRING( 64, "$#,##0;[RED]-$#,##0" ),
EXC_NUMFMT_STRING( 65, "$#,##0.00;-$#,##0.00" ),
EXC_NUMFMT_STRING( 66, "$#,##0.00;[RED]-$#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_ENGLISH_SAFRICA[] =
{
EXC_NUMFMT_STRING( 14, "YYYY/MM/DD" ),
EXC_NUMFMT_OFFSET( 18, NF_TIME_HHMMAMPM ),
EXC_NUMFMT_OFFSET( 19, NF_TIME_HHMMSSAMPM ),
EXC_NUMFMT_STRING( 22, "YYYY/MM/DD hh:mm" ),
EXC_NUMFMT_STRING( 63, "\\R #,##0;\\R -#,##0" ),
EXC_NUMFMT_STRING( 64, "\\R #,##0;[RED]\\R -#,##0" ),
EXC_NUMFMT_STRING( 65, "\\R #,##0.00;\\R -#,##0.00" ),
EXC_NUMFMT_STRING( 66, "\\R #,##0.00;[RED]\\R -#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
// FRENCH ---------------------------------------------------------------------
/** Base table for French locales. */
const XclBuiltInFormat spBuiltInFormats_FRENCH[] =
{
EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ),
EXC_NUMFMT_STRING( 16, "DD-MMM" ),
EXC_NUMFMT_STRING( 17, "MMM-YY" ),
EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_FRENCH_FRANCE[] =
{
EXC_NUMFMT_STRING( 22, "DD/MM/YYYY hh:mm" ),
EXC_NUMFMT_STRING( 37, "#,##0\\ _" UTF8_EURO ";-#,##0\\ _" UTF8_EURO ),
EXC_NUMFMT_STRING( 38, "#,##0\\ _" UTF8_EURO ";[RED]-#,##0\\ _" UTF8_EURO ),
EXC_NUMFMT_STRING( 39, "#,##0.00\\ _" UTF8_EURO ";-#,##0.00\\ _" UTF8_EURO ),
EXC_NUMFMT_STRING( 40, "#,##0.00\\ _" UTF8_EURO ";[RED]-#,##0.00\\ _" UTF8_EURO ),
EXC_NUMFMT_STRING( 63, "#,##0\\ " UTF8_EURO ";-#,##0\\ " UTF8_EURO ),
EXC_NUMFMT_STRING( 64, "#,##0\\ " UTF8_EURO ";[RED]-#,##0\\ " UTF8_EURO ),
EXC_NUMFMT_STRING( 65, "#,##0.00\\ " UTF8_EURO ";-#,##0.00\\ " UTF8_EURO ),
EXC_NUMFMT_STRING( 66, "#,##0.00\\ " UTF8_EURO ";[RED]-#,##0.00\\ " UTF8_EURO ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_FRENCH_CANADIAN[] =
{
EXC_NUMFMT_STRING( 22, "YYYY-MM-DD hh:mm" ),
EXC_NUMFMT_STRING( 37, "#,##0\\ _$_-;#,##0\\ _$-" ),
EXC_NUMFMT_STRING( 38, "#,##0\\ _$_-;[RED]#,##0\\ _$-" ),
EXC_NUMFMT_STRING( 39, "#,##0.00\\ _$_-;#,##0.00\\ _$-" ),
EXC_NUMFMT_STRING( 40, "#,##0.00\\ _$_-;[RED]#,##0.00\\ _$-" ),
EXC_NUMFMT_STRING( 63, "#,##0\\ $_-;#,##0\\ $-" ),
EXC_NUMFMT_STRING( 64, "#,##0\\ $_-;[RED]#,##0\\ $-" ),
EXC_NUMFMT_STRING( 65, "#,##0.00\\ $_-;#,##0.00\\ $-" ),
EXC_NUMFMT_STRING( 66, "#,##0.00\\ $_-;[RED]#,##0.00\\ $-" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_FRENCH_SWISS[] =
{
EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ),
EXC_NUMFMT_STRING( 16, "DD.MMM" ),
EXC_NUMFMT_STRING( 17, "MMM.YY" ),
EXC_NUMFMT_STRING( 22, "DD.MM.YYYY hh:mm" ),
EXC_NUMFMT_STRING( 63, "\"SFr. \"#,##0;\"SFr. \"-#,##0" ),
EXC_NUMFMT_STRING( 64, "\"SFr. \"#,##0;[RED]\"SFr. \"-#,##0" ),
EXC_NUMFMT_STRING( 65, "\"SFr. \"#,##0.00;\"SFr. \"-#,##0.00" ),
EXC_NUMFMT_STRING( 66, "\"SFr. \"#,##0.00;[RED]\"SFr. \"-#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_FRENCH_BELGIAN[] =
{
EXC_NUMFMT_STRING( 14, "D/MM/YYYY" ),
EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
EXC_NUMFMT_STRING( 16, "D-MMM" ),
EXC_NUMFMT_STRING( 20, "h:mm" ),
EXC_NUMFMT_STRING( 21, "h:mm:ss" ),
EXC_NUMFMT_STRING( 22, "D/MM/YYYY h:mm" ),
EXC_NUMFMT_ENDTABLE()
};
// GERMAN ---------------------------------------------------------------------
/** Base table for German locales. */
const XclBuiltInFormat spBuiltInFormats_GERMAN[] =
{
EXC_NUMFMT_STRING( 15, "DD. MMM YY" ),
EXC_NUMFMT_STRING( 16, "DD. MMM" ),
EXC_NUMFMT_STRING( 17, "MMM YY" ),
EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
EXC_NUMFMT_STRING( 22, "DD.MM.YYYY hh:mm" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_GERMAN_GERMANY[] =
{
EXC_NUMFMT_STRING( 37, "#,##0 _" UTF8_EURO ";-#,##0 _" UTF8_EURO ),
EXC_NUMFMT_STRING( 38, "#,##0 _" UTF8_EURO ";[RED]-#,##0 _" UTF8_EURO ),
EXC_NUMFMT_STRING( 39, "#,##0.00 _" UTF8_EURO ";-#,##0.00 _" UTF8_EURO ),
EXC_NUMFMT_STRING( 40, "#,##0.00 _" UTF8_EURO ";[RED]-#,##0.00 _" UTF8_EURO ),
EXC_NUMFMT_STRING( 63, "#,##0 " UTF8_EURO ";-#,##0 " UTF8_EURO ),
EXC_NUMFMT_STRING( 64, "#,##0 " UTF8_EURO ";[RED]-#,##0 " UTF8_EURO ),
EXC_NUMFMT_STRING( 65, "#,##0.00 " UTF8_EURO ";-#,##0.00 " UTF8_EURO ),
EXC_NUMFMT_STRING( 66, "#,##0.00 " UTF8_EURO ";[RED]-#,##0.00 " UTF8_EURO ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_GERMAN_AUSTRIAN[] =
{
EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ),
EXC_NUMFMT_STRING( 16, "DD.MMM" ),
EXC_NUMFMT_STRING( 17, "MMM.YY" ),
EXC_NUMFMT_STRING( 63, UTF8_EURO " #,##0;-" UTF8_EURO " #,##0" ),
EXC_NUMFMT_STRING( 64, UTF8_EURO " #,##0;[RED]-" UTF8_EURO " #,##0" ),
EXC_NUMFMT_STRING( 65, UTF8_EURO " #,##0.00;-" UTF8_EURO " #,##0.00" ),
EXC_NUMFMT_STRING( 66, UTF8_EURO " #,##0.00;[RED]-" UTF8_EURO " #,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_GERMAN_SWISS[] =
{
EXC_NUMFMT_STRING( 63, "\"SFr. \"#,##0;\"SFr. \"-#,##0" ),
EXC_NUMFMT_STRING( 64, "\"SFr. \"#,##0;[RED]\"SFr. \"-#,##0" ),
EXC_NUMFMT_STRING( 65, "\"SFr. \"#,##0.00;\"SFr. \"-#,##0.00" ),
EXC_NUMFMT_STRING( 66, "\"SFr. \"#,##0.00;[RED]\"SFr. \"-#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_GERMAN_LUXEMBOURG[] =
{
EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ),
EXC_NUMFMT_STRING( 16, "DD.MMM" ),
EXC_NUMFMT_STRING( 17, "MMM.YY" ),
EXC_NUMFMT_STRING( 37, "#,##0 _" UTF8_EURO ";-#,##0 _" UTF8_EURO ),
EXC_NUMFMT_STRING( 38, "#,##0 _" UTF8_EURO ";[RED]-#,##0 _" UTF8_EURO ),
EXC_NUMFMT_STRING( 39, "#,##0.00 _" UTF8_EURO ";-#,##0.00 _" UTF8_EURO ),
EXC_NUMFMT_STRING( 40, "#,##0.00 _" UTF8_EURO ";[RED]-#,##0.00 _" UTF8_EURO ),
EXC_NUMFMT_STRING( 63, "#,##0 " UTF8_EURO ";-#,##0 " UTF8_EURO ),
EXC_NUMFMT_STRING( 64, "#,##0 " UTF8_EURO ";[RED]-#,##0 " UTF8_EURO ),
EXC_NUMFMT_STRING( 65, "#,##0.00 " UTF8_EURO ";-#,##0.00 " UTF8_EURO ),
EXC_NUMFMT_STRING( 66, "#,##0.00 " UTF8_EURO ";[RED]-#,##0.00 " UTF8_EURO ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_GERMAN_LIECHTENSTEIN[] =
{
EXC_NUMFMT_STRING( 63, "\"CHF \"#,##0;\"CHF \"-#,##0" ),
EXC_NUMFMT_STRING( 64, "\"CHF \"#,##0;[RED]\"CHF \"-#,##0" ),
EXC_NUMFMT_STRING( 65, "\"CHF \"#,##0.00;\"CHF \"-#,##0.00" ),
EXC_NUMFMT_STRING( 66, "\"CHF \"#,##0.00;[RED]\"CHF \"-#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
// ITALIAN --------------------------------------------------------------------
const XclBuiltInFormat spBuiltInFormats_ITALIAN_ITALY[] =
{
EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ),
EXC_NUMFMT_STRING( 16, "DD-MMM" ),
EXC_NUMFMT_STRING( 17, "MMM-YY" ),
EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
EXC_NUMFMT_STRING( 20, "h:mm" ),
EXC_NUMFMT_STRING( 21, "h:mm:ss" ),
EXC_NUMFMT_STRING( 22, "DD/MM/YYYY h:mm" ),
EXC_NUMFMT_STRING( 63, UTF8_EURO " #,##0;-" UTF8_EURO " #,##0" ),
EXC_NUMFMT_STRING( 64, UTF8_EURO " #,##0;[RED]-" UTF8_EURO " #,##0" ),
EXC_NUMFMT_STRING( 65, UTF8_EURO " #,##0.00;-" UTF8_EURO " #,##0.00" ),
EXC_NUMFMT_STRING( 66, UTF8_EURO " #,##0.00;[RED]-" UTF8_EURO " #,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_ITALIAN_SWISS[] =
{
EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ),
EXC_NUMFMT_STRING( 16, "DD.MMM" ),
EXC_NUMFMT_STRING( 17, "MMM.YY" ),
EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
EXC_NUMFMT_STRING( 22, "DD.MM.YYYY hh:mm" ),
EXC_NUMFMT_STRING( 63, "\"SFr. \"#,##0;\"SFr. \"-#,##0" ),
EXC_NUMFMT_STRING( 64, "\"SFr. \"#,##0;[RED]\"SFr. \"-#,##0" ),
EXC_NUMFMT_STRING( 65, "\"SFr. \"#,##0.00;\"SFr. \"-#,##0.00" ),
EXC_NUMFMT_STRING( 66, "\"SFr. \"#,##0.00;[RED]\"SFr. \"-#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
// SWEDISH --------------------------------------------------------------------
const XclBuiltInFormat spBuiltInFormats_SWEDISH_SWEDEN[] =
{
EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ),
EXC_NUMFMT_STRING( 16, "DD-MMM" ),
EXC_NUMFMT_STRING( 17, "MMM-YY" ),
EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
EXC_NUMFMT_STRING( 22, "YYYY-MM-DD hh:mm" ),
EXC_NUMFMT_STRING( 37, "#,##0 _k_r;-#,##0 _k_r" ),
EXC_NUMFMT_STRING( 38, "#,##0 _k_r;[RED]-#,##0 _k_r" ),
EXC_NUMFMT_STRING( 39, "#,##0.00 _k_r;-#,##0.00 _k_r" ),
EXC_NUMFMT_STRING( 40, "#,##0.00 _k_r;[RED]-#,##0.00 _k_r" ),
EXC_NUMFMT_STRING( 63, "#,##0 \"kr\";-#,##0 \"kr\"" ),
EXC_NUMFMT_STRING( 64, "#,##0 \"kr\";[RED]-#,##0 \"kr\"" ),
EXC_NUMFMT_STRING( 65, "#,##0.00 \"kr\";-#,##0.00 \"kr\"" ),
EXC_NUMFMT_STRING( 66, "#,##0.00 \"kr\";[RED]-#,##0.00 \"kr\"" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_SWEDISH_FINLAND[] =
{
EXC_NUMFMT_STRING( 9, "0 %" ),
EXC_NUMFMT_STRING( 10, "0.00 %" ),
EXC_NUMFMT_STRING( 15, "DD.MMM.YY" ),
EXC_NUMFMT_STRING( 16, "DD.MMM" ),
EXC_NUMFMT_STRING( 17, "MMM.YY" ),
EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
EXC_NUMFMT_STRING( 22, "D.M.YYYY hh:mm" ),
EXC_NUMFMT_STRING( 37, "#,##0 _" UTF8_EURO ";-#,##0 _" UTF8_EURO ),
EXC_NUMFMT_STRING( 38, "#,##0 _" UTF8_EURO ";[RED]-#,##0 _" UTF8_EURO ),
EXC_NUMFMT_STRING( 39, "#,##0.00 _" UTF8_EURO ";-#,##0.00 _" UTF8_EURO ),
EXC_NUMFMT_STRING( 40, "#,##0.00 _" UTF8_EURO ";[RED]-#,##0.00 _" UTF8_EURO ),
EXC_NUMFMT_STRING( 63, "#,##0 " UTF8_EURO ";-#,##0 " UTF8_EURO ),
EXC_NUMFMT_STRING( 64, "#,##0 " UTF8_EURO ";[RED]-#,##0 " UTF8_EURO ),
EXC_NUMFMT_STRING( 65, "#,##0.00 " UTF8_EURO ";-#,##0.00 " UTF8_EURO ),
EXC_NUMFMT_STRING( 66, "#,##0.00 " UTF8_EURO ";[RED]-#,##0.00 " UTF8_EURO ),
EXC_NUMFMT_ENDTABLE()
};
// ASIAN ----------------------------------------------------------------------
/** Base table for Asian locales. */
const XclBuiltInFormat spBuiltInFormats_ASIAN[] =
{
EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
EXC_NUMFMT_STRING( 20, "h:mm" ),
EXC_NUMFMT_STRING( 21, "h:mm:ss" ),
EXC_NUMFMT_STRING( 23, "$#,##0_);($#,##0)" ),
EXC_NUMFMT_STRING( 24, "$#,##0_);[RED]($#,##0)" ),
EXC_NUMFMT_STRING( 25, "$#,##0.00_);($#,##0.00)" ),
EXC_NUMFMT_STRING( 26, "$#,##0.00_);[RED]($#,##0.00)" ),
EXC_NUMFMT_REUSE( 29, 28 ),
EXC_NUMFMT_REUSE( 36, 27 ),
EXC_NUMFMT_REUSE( 50, 27 ),
EXC_NUMFMT_REUSE( 51, 28 ),
EXC_NUMFMT_REUSE( 52, 34 ),
EXC_NUMFMT_REUSE( 53, 35 ),
EXC_NUMFMT_REUSE( 54, 28 ),
EXC_NUMFMT_REUSE( 55, 34 ),
EXC_NUMFMT_REUSE( 56, 35 ),
EXC_NUMFMT_REUSE( 57, 27 ),
EXC_NUMFMT_REUSE( 58, 28 ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_JAPANESE[] =
{
EXC_NUMFMT_STRING( 14, "YYYY/M/D" ),
EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
EXC_NUMFMT_STRING( 16, "D-MMM" ),
EXC_NUMFMT_STRING( 17, "MMM-YY" ),
EXC_NUMFMT_STRING( 22, "YYYY/M/D h:mm" ),
EXC_NUMFMT_STRING( 27, "[$-0411]GE.M.D" ),
EXC_NUMFMT_STRING( 28, "[$-0411]GGGE" UTF8_CJ_YEAR "M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
EXC_NUMFMT_STRING( 30, "[$-0411]M/D/YY" ),
EXC_NUMFMT_STRING( 31, "[$-0411]YYYY" UTF8_CJ_YEAR "M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
EXC_NUMFMT_STRING( 32, "[$-0411]h" UTF8_CJ_HOUR "mm" UTF8_CJ_MIN ),
EXC_NUMFMT_STRING( 33, "[$-0411]h" UTF8_CJ_HOUR "mm" UTF8_CJ_MIN "ss" UTF8_CJ_SEC ),
EXC_NUMFMT_STRING( 34, "[$-0411]YYYY" UTF8_CJ_YEAR "M" UTF8_CJ_MON ),
EXC_NUMFMT_STRING( 35, "[$-0411]M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
EXC_NUMFMT_STRING( 63, UTF8_YEN_JP "#,##0;-" UTF8_YEN_JP "#,##0" ),
EXC_NUMFMT_STRING( 64, UTF8_YEN_JP "#,##0;[RED]-" UTF8_YEN_JP "#,##0" ),
EXC_NUMFMT_STRING( 65, UTF8_YEN_JP "#,##0.00;-" UTF8_YEN_JP "#,##0.00" ),
EXC_NUMFMT_STRING( 66, UTF8_YEN_JP "#,##0.00;[RED]-" UTF8_YEN_JP "#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_KOREAN[] =
{
EXC_NUMFMT_STRING( 14, "YYYY-MM-DD" ),
EXC_NUMFMT_STRING( 15, "DD-MMM-YY" ),
EXC_NUMFMT_STRING( 16, "DD-MMM" ),
EXC_NUMFMT_STRING( 17, "MMM-YY" ),
EXC_NUMFMT_STRING( 22, "YYYY-MM-DD h:mm" ),
EXC_NUMFMT_STRING( 27, "[$-0412]YYYY" UTF8_CJ_YEAR " MM" UTF8_CJ_MON " DD" UTF8_CJ_DAY ),
EXC_NUMFMT_STRING( 28, "[$-0412]MM-DD" ),
EXC_NUMFMT_STRING( 30, "[$-0412]MM-DD-YY" ),
EXC_NUMFMT_STRING( 31, "[$-0412]YYYY" UTF8_KO_YEAR " MM" UTF8_KO_MON " DD" UTF8_KO_DAY ),
EXC_NUMFMT_STRING( 32, "[$-0412]h" UTF8_KO_HOUR " mm" UTF8_KO_MIN ),
EXC_NUMFMT_STRING( 33, "[$-0412]h" UTF8_KO_HOUR " mm" UTF8_KO_MIN " ss" UTF8_KO_SEC ),
EXC_NUMFMT_STRING( 34, "[$-0412]YYYY\"/\"MM\"/\"DD" ),
EXC_NUMFMT_STRING( 35, "[$-0412]YYYY-MM-DD" ),
EXC_NUMFMT_STRING( 63, UTF8_WON "#,##0;-" UTF8_WON "#,##0" ),
EXC_NUMFMT_STRING( 64, UTF8_WON "#,##0;[RED]-" UTF8_WON "#,##0" ),
EXC_NUMFMT_STRING( 65, UTF8_WON "#,##0.00;-" UTF8_WON "#,##0.00" ),
EXC_NUMFMT_STRING( 66, UTF8_WON "#,##0.00;[RED]-" UTF8_WON "#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_CHINESE_SIMPLIFIED[] =
{
EXC_NUMFMT_STRING( 14, "YYYY-M-D" ),
EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
EXC_NUMFMT_STRING( 16, "D-MMM" ),
EXC_NUMFMT_STRING( 17, "MMM-YY" ),
EXC_NUMFMT_STRING( 22, "YYYY-M-D h:mm" ),
EXC_NUMFMT_STRING( 27, "[$-0804]YYYY" UTF8_CJ_YEAR "M" UTF8_CJ_MON ),
EXC_NUMFMT_STRING( 28, "[$-0804]M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
EXC_NUMFMT_STRING( 30, "[$-0804]M-D-YY" ),
EXC_NUMFMT_STRING( 31, "[$-0804]YYYY" UTF8_CJ_YEAR "M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
EXC_NUMFMT_STRING( 32, "[$-0804]h" UTF8_CS_HOUR "mm" UTF8_CJ_MIN ),
EXC_NUMFMT_STRING( 33, "[$-0804]h" UTF8_CS_HOUR "mm" UTF8_CJ_MIN "ss" UTF8_CJ_SEC ),
EXC_NUMFMT_STRING( 34, "[$-0804]AM/PMh" UTF8_CS_HOUR "mm" UTF8_CJ_MIN ),
EXC_NUMFMT_STRING( 35, "[$-0804]AM/PMh" UTF8_CS_HOUR "mm" UTF8_CJ_MIN "ss" UTF8_CJ_SEC ),
EXC_NUMFMT_REUSE( 52, 27 ),
EXC_NUMFMT_REUSE( 53, 28 ),
EXC_NUMFMT_STRING( 63, UTF8_YEN_CS "#,##0;-" UTF8_YEN_CS "#,##0" ),
EXC_NUMFMT_STRING( 64, UTF8_YEN_CS "#,##0;[RED]-" UTF8_YEN_CS "#,##0" ),
EXC_NUMFMT_STRING( 65, UTF8_YEN_CS "#,##0.00;-" UTF8_YEN_CS "#,##0.00" ),
EXC_NUMFMT_STRING( 66, UTF8_YEN_CS "#,##0.00;[RED]-" UTF8_YEN_CS "#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_CHINESE_TRADITIONAL[] =
{
EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
EXC_NUMFMT_STRING( 16, "D-MMM" ),
EXC_NUMFMT_STRING( 17, "MMM-YY" ),
EXC_NUMFMT_STRING( 18, "hh:mm AM/PM" ),
EXC_NUMFMT_STRING( 19, "hh:mm:ss AM/PM" ),
EXC_NUMFMT_OFFSET( 20, NF_TIME_HHMM ),
EXC_NUMFMT_OFFSET( 21, NF_TIME_HHMMSS ),
EXC_NUMFMT_STRING( 22, "YYYY/M/D hh:mm" ),
EXC_NUMFMT_STRING( 23, "US$#,##0_);(US$#,##0)" ),
EXC_NUMFMT_STRING( 24, "US$#,##0_);[RED](US$#,##0)" ),
EXC_NUMFMT_STRING( 25, "US$#,##0.00_);(US$#,##0.00)" ),
EXC_NUMFMT_STRING( 26, "US$#,##0.00_);[RED](US$#,##0.00)" ),
EXC_NUMFMT_STRING( 27, "[$-0404]E/M/D" ),
EXC_NUMFMT_STRING( 28, "[$-0404]E" UTF8_CJ_YEAR "M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
EXC_NUMFMT_STRING( 30, "[$-0404]M/D/YY" ),
EXC_NUMFMT_STRING( 31, "[$-0404]YYYY" UTF8_CJ_YEAR "M" UTF8_CJ_MON "D" UTF8_CJ_DAY ),
EXC_NUMFMT_STRING( 32, "[$-0404]hh" UTF8_CJ_HOUR "mm" UTF8_CJ_MIN ),
EXC_NUMFMT_STRING( 33, "[$-0404]hh" UTF8_CJ_HOUR "mm" UTF8_CJ_MIN "ss" UTF8_CJ_SEC ),
EXC_NUMFMT_STRING( 34, "[$-0404]AM/PMhh" UTF8_CJ_HOUR "mm" UTF8_CJ_MIN ),
EXC_NUMFMT_STRING( 35, "[$-0404]AM/PMhh" UTF8_CJ_HOUR "mm" UTF8_CJ_MIN "ss" UTF8_CJ_SEC ),
EXC_NUMFMT_STRING( 63, "$#,##0;-$#,##0" ),
EXC_NUMFMT_STRING( 64, "$#,##0;[RED]-$#,##0" ),
EXC_NUMFMT_STRING( 65, "$#,##0.00;-$#,##0.00" ),
EXC_NUMFMT_STRING( 66, "$#,##0.00;[RED]-$#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
// OTHER ----------------------------------------------------------------------
const XclBuiltInFormat spBuiltInFormats_HEBREW[] =
{
EXC_NUMFMT_STRING( 15, "DD-MMMM-YY" ),
EXC_NUMFMT_STRING( 16, "DD-MMMM" ),
EXC_NUMFMT_STRING( 17, "MMMM-YY" ),
EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
EXC_NUMFMT_STRING( 63, UTF8_SHEQEL " #,##0;" UTF8_SHEQEL " -#,##0" ),
EXC_NUMFMT_STRING( 64, UTF8_SHEQEL " #,##0;[RED]" UTF8_SHEQEL " -#,##0" ),
EXC_NUMFMT_STRING( 65, UTF8_SHEQEL " #,##0.00;" UTF8_SHEQEL " -#,##0.00" ),
EXC_NUMFMT_STRING( 66, UTF8_SHEQEL " #,##0.00;[RED]" UTF8_SHEQEL " -#,##0.00" ),
EXC_NUMFMT_ENDTABLE()
};
const XclBuiltInFormat spBuiltInFormats_THAI[] =
{
EXC_NUMFMT_STRING( 14, "D/M/YYYY" ),
EXC_NUMFMT_STRING( 15, "D-MMM-YY" ),
EXC_NUMFMT_STRING( 16, "D-MMM" ),
EXC_NUMFMT_STRING( 17, "MMM-YY" ),
EXC_NUMFMT_STRING( 18, "h:mm AM/PM" ),
EXC_NUMFMT_STRING( 19, "h:mm:ss AM/PM" ),
EXC_NUMFMT_STRING( 22, "D/M/YYYY h:mm" ),
EXC_NUMFMT_STRING( 59, "t0" ),
EXC_NUMFMT_STRING( 60, "t0.00" ),
EXC_NUMFMT_STRING( 61, "t#,##0" ),
EXC_NUMFMT_STRING( 62, "t#,##0.00" ),
EXC_NUMFMT_STRING( 63, "t" UTF8_BAHT "#,##0_);t(" UTF8_BAHT "#,##0)" ),
EXC_NUMFMT_STRING( 64, "t" UTF8_BAHT "#,##0_);[RED]t(" UTF8_BAHT "#,##0)" ),
EXC_NUMFMT_STRING( 65, "t" UTF8_BAHT "#,##0.00_);t(" UTF8_BAHT "#,##0.00)" ),
EXC_NUMFMT_STRING( 66, "t" UTF8_BAHT "#,##0.00_);[RED]t(" UTF8_BAHT "#,##0.00)" ),
EXC_NUMFMT_STRING( 67, "t0%" ),
EXC_NUMFMT_STRING( 68, "t0.00%" ),
EXC_NUMFMT_STRING( 69, "t# ?/?" ),
EXC_NUMFMT_STRING( 70, "t# ?\?/?\?" ),
EXC_NUMFMT_STRING( 71, "tD/M/EE" ),
EXC_NUMFMT_STRING( 72, "tD-MMM-E" ),
EXC_NUMFMT_STRING( 73, "tD-MMM" ),
EXC_NUMFMT_STRING( 74, "tMMM-E" ),
EXC_NUMFMT_STRING( 75, "th:mm" ),
EXC_NUMFMT_STRING( 76, "th:mm:ss" ),
EXC_NUMFMT_STRING( 77, "tD/M/EE h:mm" ),
EXC_NUMFMT_STRING( 78, "tmm:ss" ),
EXC_NUMFMT_STRING( 79, "t[h]:mm:ss" ),
EXC_NUMFMT_STRING( 80, "tmm:ss.0" ),
EXC_NUMFMT_STRING( 81, "D/M/E" ),
EXC_NUMFMT_ENDTABLE()
};
#undef EXC_NUMFMT_ENDTABLE
#undef EXC_NUMFMT_REUSE
#undef EXC_NUMFMT_OFFSET
#undef EXC_NUMFMT_STRING
/** Specifies a number format table for a specific language. */
struct XclBuiltInFormatTable
{
LanguageType meLanguage; /// The language of this table.
LanguageType meParentLang; /// The language of the parent table.
const XclBuiltInFormat* mpFormats; /// The number format table.
};
const XclBuiltInFormatTable spBuiltInFormatTables[] =
{ // language parent language format table
{ LANGUAGE_DONTKNOW, LANGUAGE_NONE, spBuiltInFormats_DONTKNOW },
{ LANGUAGE_ENGLISH, LANGUAGE_DONTKNOW, spBuiltInFormats_ENGLISH },
{ LANGUAGE_ENGLISH_UK, LANGUAGE_ENGLISH, spBuiltInFormats_ENGLISH_UK },
{ LANGUAGE_ENGLISH_EIRE, LANGUAGE_ENGLISH, spBuiltInFormats_ENGLISH_EIRE },
{ LANGUAGE_ENGLISH_US, LANGUAGE_ENGLISH, spBuiltInFormats_ENGLISH_US },
{ LANGUAGE_ENGLISH_CAN, LANGUAGE_ENGLISH, spBuiltInFormats_ENGLISH_CAN },
{ LANGUAGE_ENGLISH_AUS, LANGUAGE_ENGLISH, spBuiltInFormats_ENGLISH_AUS },
{ LANGUAGE_ENGLISH_SAFRICA, LANGUAGE_ENGLISH, spBuiltInFormats_ENGLISH_SAFRICA },
{ LANGUAGE_ENGLISH_NZ, LANGUAGE_ENGLISH_AUS, nullptr },
{ PRV_LANGUAGE_FRENCH_PRIM, LANGUAGE_DONTKNOW, spBuiltInFormats_FRENCH },
{ LANGUAGE_FRENCH, PRV_LANGUAGE_FRENCH_PRIM, spBuiltInFormats_FRENCH_FRANCE },
{ LANGUAGE_FRENCH_CANADIAN, PRV_LANGUAGE_FRENCH_PRIM, spBuiltInFormats_FRENCH_CANADIAN },
{ LANGUAGE_FRENCH_SWISS, PRV_LANGUAGE_FRENCH_PRIM, spBuiltInFormats_FRENCH_SWISS },
{ LANGUAGE_FRENCH_BELGIAN, LANGUAGE_FRENCH, spBuiltInFormats_FRENCH_BELGIAN },
{ LANGUAGE_FRENCH_LUXEMBOURG, LANGUAGE_FRENCH, nullptr },
{ LANGUAGE_FRENCH_MONACO, LANGUAGE_FRENCH, nullptr },
{ PRV_LANGUAGE_GERMAN_PRIM, LANGUAGE_DONTKNOW, spBuiltInFormats_GERMAN },
{ LANGUAGE_GERMAN, PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_GERMANY },
{ LANGUAGE_GERMAN_AUSTRIAN, PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_AUSTRIAN },
{ LANGUAGE_GERMAN_SWISS, PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_SWISS },
{ LANGUAGE_GERMAN_LUXEMBOURG, PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_LUXEMBOURG },
{ LANGUAGE_GERMAN_LIECHTENSTEIN, PRV_LANGUAGE_GERMAN_PRIM, spBuiltInFormats_GERMAN_LIECHTENSTEIN },
{ LANGUAGE_ITALIAN, LANGUAGE_DONTKNOW, spBuiltInFormats_ITALIAN_ITALY },
{ LANGUAGE_ITALIAN_SWISS, LANGUAGE_DONTKNOW, spBuiltInFormats_ITALIAN_SWISS },
{ LANGUAGE_SWEDISH, LANGUAGE_DONTKNOW, spBuiltInFormats_SWEDISH_SWEDEN },
{ LANGUAGE_SWEDISH_FINLAND, LANGUAGE_DONTKNOW, spBuiltInFormats_SWEDISH_FINLAND },
{ PRV_LANGUAGE_ASIAN_PRIM, LANGUAGE_DONTKNOW, spBuiltInFormats_ASIAN },
{ LANGUAGE_JAPANESE, PRV_LANGUAGE_ASIAN_PRIM, spBuiltInFormats_JAPANESE },
{ LANGUAGE_KOREAN, PRV_LANGUAGE_ASIAN_PRIM, spBuiltInFormats_KOREAN },
{ LANGUAGE_CHINESE_SIMPLIFIED, PRV_LANGUAGE_ASIAN_PRIM, spBuiltInFormats_CHINESE_SIMPLIFIED },
{ LANGUAGE_CHINESE_TRADITIONAL, PRV_LANGUAGE_ASIAN_PRIM, spBuiltInFormats_CHINESE_TRADITIONAL },
{ LANGUAGE_HEBREW, LANGUAGE_DONTKNOW, spBuiltInFormats_HEBREW },
{ LANGUAGE_THAI, LANGUAGE_DONTKNOW, spBuiltInFormats_THAI }
};
} // namespace
XclNumFmtBuffer::XclNumFmtBuffer( const XclRoot& rRoot ) :
meSysLang( rRoot.GetSysLanguage() ),
mnStdScNumFmt( rRoot.GetFormatter().GetStandardIndex( ScGlobal::eLnge ) )
{
// *** insert default formats (BIFF5+ only)***
if( rRoot.GetBiff() >= EXC_BIFF5 )
InsertBuiltinFormats();
}
void XclNumFmtBuffer::InitializeImport()
{
maFmtMap.clear();
}
void XclNumFmtBuffer::InsertFormat( sal_uInt16 nXclNumFmt, const OUString& rFormat )
{
XclNumFmt& rNumFmt = maFmtMap[ nXclNumFmt ];
rNumFmt.maFormat = rFormat;
// #i62053# rFormat may be an empty string, meOffset must be initialized
rNumFmt.meOffset = NF_NUMBER_STANDARD;
rNumFmt.meLanguage = LANGUAGE_SYSTEM;
}
void XclNumFmtBuffer::InsertBuiltinFormats()
{
// build a map containing tables for all languages
typedef ::std::map< LanguageType, const XclBuiltInFormatTable* > XclBuiltInMap;
XclBuiltInMap aBuiltInMap;
for(const auto &rTable : spBuiltInFormatTables)
aBuiltInMap[ rTable.meLanguage ] = &rTable;
// build a list of table pointers for the current language, with all parent tables
typedef ::std::vector< const XclBuiltInFormatTable* > XclBuiltInVec;
XclBuiltInVec aBuiltInVec;
for( XclBuiltInMap::const_iterator aMIt = aBuiltInMap.find( meSysLang ), aMEnd = aBuiltInMap.end();
aMIt != aMEnd; aMIt = aBuiltInMap.find( aMIt->second->meParentLang ) )
aBuiltInVec.push_back( aMIt->second );
// language not supported
if( aBuiltInVec.empty() )
{
SAL_WARN("sc", "XclNumFmtBuffer::InsertBuiltinFormats - language not supported (#i29949#) 0x" << std::hex << meSysLang );
XclBuiltInMap::const_iterator aMIt = aBuiltInMap.find( LANGUAGE_DONTKNOW );
OSL_ENSURE( aMIt != aBuiltInMap.end(), "XclNumFmtBuffer::InsertBuiltinFormats - default map not found" );
if( aMIt != aBuiltInMap.end() )
aBuiltInVec.push_back( aMIt->second );
}
// insert the default formats in the format map, from root parent to system language
std::map< sal_uInt16, sal_uInt16 > aReuseMap;
for( XclBuiltInVec::reverse_iterator aVIt = aBuiltInVec.rbegin(), aVEnd = aBuiltInVec.rend(); aVIt != aVEnd; ++aVIt )
{
// put LANGUAGE_SYSTEM for all entries in default table
LanguageType eLang = ((*aVIt)->meLanguage == LANGUAGE_DONTKNOW) ? LANGUAGE_SYSTEM : meSysLang;
for( const XclBuiltInFormat* pBuiltIn = (*aVIt)->mpFormats; pBuiltIn && (pBuiltIn->mnXclNumFmt != EXC_FORMAT_NOTFOUND); ++pBuiltIn )
{
XclNumFmt& rNumFmt = maFmtMap[ pBuiltIn->mnXclNumFmt ];
rNumFmt.meOffset = pBuiltIn->meOffset;
rNumFmt.meLanguage = eLang;
if( pBuiltIn->mpFormat )
rNumFmt.maFormat = OUString( pBuiltIn->mpFormat, strlen(pBuiltIn->mpFormat), RTL_TEXTENCODING_UTF8 );
else
rNumFmt.maFormat.clear();
if( pBuiltIn->meOffset == PRV_NF_INDEX_REUSE )
aReuseMap[ pBuiltIn->mnXclNumFmt ] = pBuiltIn->mnXclReuseFmt;
else
aReuseMap.erase( pBuiltIn->mnXclNumFmt );
}
}
// copy reused number formats
for( const auto& [rXclNumFmt, rXclReuseFmt] : aReuseMap )
maFmtMap[ rXclNumFmt ] = maFmtMap[ rXclReuseFmt ];
}
// Cell formatting data (XF) ==================================================
XclCellProt::XclCellProt() :
mbLocked( true ), // default in Excel and Calc
mbHidden( false )
{
}
bool operator==( const XclCellProt& rLeft, const XclCellProt& rRight )
{
return (rLeft.mbLocked == rRight.mbLocked) && (rLeft.mbHidden == rRight.mbHidden);
}
XclCellAlign::XclCellAlign() :
mnHorAlign( EXC_XF_HOR_GENERAL ),
mnVerAlign( EXC_XF_VER_BOTTOM ),
mnOrient( EXC_ORIENT_NONE ),
mnTextDir( EXC_XF_TEXTDIR_CONTEXT ),
mnRotation( EXC_ROT_NONE ),
mnIndent( 0 ),
mbLineBreak( false ),
mbShrink( false )
{
}
SvxCellHorJustify XclCellAlign::GetScHorAlign() const
{
SvxCellHorJustify eHorJust = SvxCellHorJustify::Standard;
switch( mnHorAlign )
{
case EXC_XF_HOR_GENERAL: eHorJust = SvxCellHorJustify::Standard; break;
case EXC_XF_HOR_LEFT: eHorJust = SvxCellHorJustify::Left; break;
case EXC_XF_HOR_CENTER_AS:
case EXC_XF_HOR_CENTER: eHorJust = SvxCellHorJustify::Center; break;
case EXC_XF_HOR_RIGHT: eHorJust = SvxCellHorJustify::Right; break;
case EXC_XF_HOR_FILL: eHorJust = SvxCellHorJustify::Repeat; break;
case EXC_XF_HOR_JUSTIFY:
case EXC_XF_HOR_DISTRIB: eHorJust = SvxCellHorJustify::Block; break;
default: OSL_FAIL( "XclCellAlign::GetScHorAlign - unknown horizontal alignment" );
}
return eHorJust;
}
SvxCellJustifyMethod XclCellAlign::GetScHorJustifyMethod() const
{
return (mnHorAlign == EXC_XF_HOR_DISTRIB) ? SvxCellJustifyMethod::Distribute : SvxCellJustifyMethod::Auto;
}
SvxCellVerJustify XclCellAlign::GetScVerAlign() const
{
SvxCellVerJustify eVerJust = SvxCellVerJustify::Standard;
switch( mnVerAlign )
{
case EXC_XF_VER_TOP: eVerJust = SvxCellVerJustify::Top; break;
case EXC_XF_VER_CENTER: eVerJust = SvxCellVerJustify::Center; break;
case EXC_XF_VER_BOTTOM: eVerJust = SvxCellVerJustify::Standard; break;
case EXC_XF_VER_JUSTIFY:
case EXC_XF_VER_DISTRIB: eVerJust = SvxCellVerJustify::Block; break;
default: OSL_FAIL( "XclCellAlign::GetScVerAlign - unknown vertical alignment" );
}
return eVerJust;
}
SvxCellJustifyMethod XclCellAlign::GetScVerJustifyMethod() const
{
return (mnVerAlign == EXC_XF_VER_DISTRIB) ? SvxCellJustifyMethod::Distribute : SvxCellJustifyMethod::Auto;
}
SvxFrameDirection XclCellAlign::GetScFrameDir() const
{
SvxFrameDirection eFrameDir = SvxFrameDirection::Environment;
switch( mnTextDir )
{
case EXC_XF_TEXTDIR_CONTEXT: eFrameDir = SvxFrameDirection::Environment; break;
case EXC_XF_TEXTDIR_LTR: eFrameDir = SvxFrameDirection::Horizontal_LR_TB; break;
case EXC_XF_TEXTDIR_RTL: eFrameDir = SvxFrameDirection::Horizontal_RL_TB; break;
default: OSL_FAIL( "XclCellAlign::GetScFrameDir - unknown CTL text direction" );
}
return eFrameDir;
}
void XclCellAlign::SetScHorAlign( SvxCellHorJustify eHorJust )
{
switch( eHorJust )
{
case SvxCellHorJustify::Standard: mnHorAlign = EXC_XF_HOR_GENERAL; break;
case SvxCellHorJustify::Left: mnHorAlign = EXC_XF_HOR_LEFT; break;
case SvxCellHorJustify::Center: mnHorAlign = EXC_XF_HOR_CENTER; break;
case SvxCellHorJustify::Right: mnHorAlign = EXC_XF_HOR_RIGHT; break;
case SvxCellHorJustify::Block: mnHorAlign = EXC_XF_HOR_JUSTIFY; break;
case SvxCellHorJustify::Repeat: mnHorAlign = EXC_XF_HOR_FILL; break;
default: mnHorAlign = EXC_XF_HOR_GENERAL;
OSL_FAIL( "XclCellAlign::SetScHorAlign - unknown horizontal alignment" );
}
}
void XclCellAlign::SetScVerAlign( SvxCellVerJustify eVerJust )
{
switch( eVerJust )
{
case SvxCellVerJustify::Standard: mnVerAlign = EXC_XF_VER_BOTTOM; break;
case SvxCellVerJustify::Top: mnVerAlign = EXC_XF_VER_TOP; break;
case SvxCellVerJustify::Center: mnVerAlign = EXC_XF_VER_CENTER; break;
case SvxCellVerJustify::Bottom: mnVerAlign = EXC_XF_VER_BOTTOM; break;
default: mnVerAlign = EXC_XF_VER_BOTTOM;
OSL_FAIL( "XclCellAlign::SetScVerAlign - unknown vertical alignment" );
}
}
void XclCellAlign::SetScFrameDir( SvxFrameDirection eFrameDir )
{
switch( eFrameDir )
{
case SvxFrameDirection::Environment: mnTextDir = EXC_XF_TEXTDIR_CONTEXT; break;
case SvxFrameDirection::Horizontal_LR_TB: mnTextDir = EXC_XF_TEXTDIR_LTR; break;
case SvxFrameDirection::Horizontal_RL_TB: mnTextDir = EXC_XF_TEXTDIR_RTL; break;
default: mnTextDir = EXC_XF_TEXTDIR_CONTEXT;
OSL_FAIL( "XclCellAlign::SetScFrameDir - unknown CTL text direction" );
}
}
bool operator==( const XclCellAlign& rLeft, const XclCellAlign& rRight )
{
return
(rLeft.mnHorAlign == rRight.mnHorAlign) && (rLeft.mnVerAlign == rRight.mnVerAlign) &&
(rLeft.mnTextDir == rRight.mnTextDir) && (rLeft.mnOrient == rRight.mnOrient) &&
(rLeft.mnRotation == rRight.mnRotation) && (rLeft.mnIndent == rRight.mnIndent) &&
(rLeft.mbLineBreak == rRight.mbLineBreak) && (rLeft.mbShrink == rRight.mbShrink);
}
XclCellBorder::XclCellBorder() :
mnLeftColor( 0 ),
mnRightColor( 0 ),
mnTopColor( 0 ),
mnBottomColor( 0 ),
mnDiagColor( 0 ),
mnLeftLine( EXC_LINE_NONE ),
mnRightLine( EXC_LINE_NONE ),
mnTopLine( EXC_LINE_NONE ),
mnBottomLine( EXC_LINE_NONE ),
mnDiagLine( EXC_LINE_NONE ),
mbDiagTLtoBR( false ),
mbDiagBLtoTR( false )
{
}
bool operator==( const XclCellBorder& rLeft, const XclCellBorder& rRight )
{
return
(rLeft.mnLeftColor == rRight.mnLeftColor) && (rLeft.mnRightColor == rRight.mnRightColor) &&
(rLeft.mnTopColor == rRight.mnTopColor) && (rLeft.mnBottomColor == rRight.mnBottomColor) &&
(rLeft.mnLeftLine == rRight.mnLeftLine) && (rLeft.mnRightLine == rRight.mnRightLine) &&
(rLeft.mnTopLine == rRight.mnTopLine) && (rLeft.mnBottomLine == rRight.mnBottomLine) &&
(rLeft.mnDiagColor == rRight.mnDiagColor) && (rLeft.mnDiagLine == rRight.mnDiagLine) &&
(rLeft.mbDiagTLtoBR == rRight.mbDiagTLtoBR) && (rLeft.mbDiagBLtoTR == rRight.mbDiagBLtoTR);
}
XclCellArea::XclCellArea() :
mnForeColor( EXC_COLOR_WINDOWTEXT ),
mnBackColor( EXC_COLOR_WINDOWBACK ),
mnPattern( EXC_PATT_NONE )
{
}
XclCellArea::XclCellArea(sal_uInt8 nPattern) :
mnForeColor( EXC_COLOR_WINDOWTEXT ),
mnBackColor( EXC_COLOR_WINDOWBACK ),
mnPattern( nPattern )
{
}
bool XclCellArea::IsTransparent() const
{
return (mnPattern == EXC_PATT_NONE) && (mnBackColor == EXC_COLOR_WINDOWBACK);
}
bool operator==( const XclCellArea& rLeft, const XclCellArea& rRight )
{
return
(rLeft.mnForeColor == rRight.mnForeColor) && (rLeft.mnBackColor == rRight.mnBackColor) &&
(rLeft.mnPattern == rRight.mnPattern);
}
XclXFBase::XclXFBase( bool bCellXF ) :
mnParent( bCellXF ? EXC_XF_DEFAULTSTYLE : EXC_XF_STYLEPARENT ),
mbCellXF( bCellXF )
{
SetAllUsedFlags( false );
}
XclXFBase::~XclXFBase()
{
}
void XclXFBase::SetAllUsedFlags( bool bUsed )
{
mbProtUsed = mbFontUsed = mbFmtUsed = mbAlignUsed = mbBorderUsed = mbAreaUsed = bUsed;
}
bool XclXFBase::HasUsedFlags() const
{
return mbProtUsed || mbFontUsed || mbFmtUsed || mbAlignUsed || mbBorderUsed || mbAreaUsed;
}
bool XclXFBase::Equals( const XclXFBase& rCmp ) const
{
return
(mbCellXF == rCmp.mbCellXF) && (mnParent == rCmp.mnParent) &&
(mbProtUsed == rCmp.mbProtUsed) && (mbFontUsed == rCmp.mbFontUsed) &&
(mbFmtUsed == rCmp.mbFmtUsed) && (mbAlignUsed == rCmp.mbAlignUsed) &&
(mbBorderUsed == rCmp.mbBorderUsed) && (mbAreaUsed == rCmp.mbAreaUsed);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|