summaryrefslogtreecommitdiff
path: root/sc/source/filter/inc/excrecds.hxx
blob: 63c169e11eec16019e327f400fbfd70e19d9bdfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
/*************************************************************************
 *
 *  $RCSfile: excrecds.hxx,v $
 *
 *  $Revision: 1.14 $
 *
 *  last change: $Author: dr $ $Date: 2001-05-10 17:26:23 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (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.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef _EXCRECDS_HXX
#define _EXCRECDS_HXX

#ifndef SC_OUTLINETAB_HXX
#include "olinetab.hxx"
#endif
#ifndef SC_FILTER_HXX
#include "filter.hxx"
#endif
#ifndef _XFBUFF_HXX
#include "xfbuff.hxx"
#endif
#ifndef _ROOT_HXX
#include "root.hxx"
#endif
#ifndef _FLTTOOLS_HXX
#include "flttools.hxx"
#endif
#ifndef _SC_XCLEXPHELPER_HXX
#include "XclExpHelper.hxx"
#endif
#ifndef _EXCDEFS_HXX
#include "excdefs.hxx"
#endif
#ifndef SC_CELL_HXX
#include "cell.hxx"
#endif

#ifndef _SOLAR_H
#include <tools/solar.h>
#endif
#ifndef _ZFORLIST_HXX
#include <svtools/zforlist.hxx>
#endif
#ifndef _STRING_HXX
#include <tools/string.hxx>
#endif
#ifndef _SV_FONTTYPE_HXX //autogen
#include <vcl/fonttype.hxx>
#endif
#ifndef _TOOLS_COLOR_HXX
#include <tools/color.hxx>
#endif

//------------------------------------------------------------------ Forwards -

class SvStream;
class XclExpStream;
class Font;
class List;
class ScPatternAttr;
class ScTokenArray;
class ScRangeData;
class ScDBData;
class ScEditCell;
class SfxItemSet;
class EditTextObject;
class ScPageHFItem;
class ScProgress;

class ExcTable;
class UsedAttrList;
class ExcArray;
class ExcArrays;
class ExcShrdFmla;
class ExcUPN;

//-------------------------------------------------- class XclExpTabNumBuffer -
// - stores the correct Excel table number for each Calc table

class XclExpTabNumBuffer : private UINT16List
{
private:
    UINT32*                     pBuffer;

    UINT16                      nScCnt;
    UINT16                      nExcCnt;
    UINT16                      nExtCnt;
    UINT16                      nCodeCnt;

    BOOL                        bEnableLog;

    void                        ApplyBuffer();

protected:
public:
                                XclExpTabNumBuffer( ScDocument& rDoc );
                                ~XclExpTabNumBuffer();

    BOOL                        IsExternal( UINT16 nScTab ) const;
    BOOL                        IsExportTable( UINT16 nScTab ) const;
    UINT16                      GetExcTable( UINT16 nScTab ) const;
    inline UINT16               GetScTabCount() const       { return nScCnt; }
    inline UINT16               GetExcTabCount() const      { return nExcCnt; }
    inline UINT16               GetExternTabCount() const   { return nExtCnt; }
    inline UINT16               GetCodenameCount() const    { return nCodeCnt; }
    inline UINT16               GetMaxScTabCount() const    { return Max( nScCnt, nCodeCnt ); }

// for change tracking:
                                // append table number pair, called by formula compiler
    void                        AppendTabRef( UINT16 nExcFirst, UINT16 nExcLast );
                                // enables logging of excel table nums in every 3D-ref
    inline void                 StartRefLog()       { UINT16List::Clear(); bEnableLog = TRUE; }
                                // disables logging
    inline void                 EndRefLog()         { bEnableLog = FALSE; }
                                // returns the index list
    inline const UINT16List&    GetRefLog() const   { return *this; }
};


//----------------------------------------------------------- class ExcRecord -

class ExcRecord
{
protected:
    virtual void            SaveCont( XclExpStream& rStrm );

public:
    virtual                 ~ExcRecord();

    virtual void            Save( XclExpStream& rStrm );

    virtual UINT16          GetNum() const = 0;
    virtual ULONG           GetLen() const = 0;
};


//--------------------------------------------------------- class ExcEmptyRec -

class ExcEmptyRec : public ExcRecord
{
private:
protected:
public:
    virtual void            Save( XclExpStream& rStrm );
    virtual UINT16          GetNum() const;
    virtual ULONG           GetLen() const;
};


//------------------------------------------------------- class ExcRecordList -

class ExcRecordList : protected List, public ExcEmptyRec
{
private:
protected:
public:
    virtual                 ~ExcRecordList();

                            List::Count;

    inline ExcRecord*       First( void )               { return ( ExcRecord* ) List::First(); }
    inline ExcRecord*       Next( void )                { return ( ExcRecord* ) List::Next(); }

    inline void             Append( ExcRecord* pNew )   { if( pNew ) List::Insert( pNew, LIST_APPEND ); }
    inline const ExcRecord* Get( UINT32 nNum ) const    { return ( ExcRecord* ) List::GetObject( nNum ); }

    virtual void            Save( XclExpStream& rStrm );
};


//--------------------------------------------------------- class ExcDummyRec -

class ExcDummyRec : public ExcRecord
{
protected:
public:
    virtual void            Save( XclExpStream& rStrm );
    virtual UINT16          GetNum() const;
    virtual const BYTE*     GetData() const = 0;    // byte data must contain header and body
};


//------------------------------------------------------- class ExcBoolRecord -
// stores BOOL as 16bit val ( 0x0000 | 0x0001 )

class ExcBoolRecord : public ExcRecord
{
private:
    virtual void            SaveCont( XclExpStream& rStrm );

protected:
    BOOL                    bVal;

    inline                  ExcBoolRecord() : bVal( FALSE ) {}

public:
    inline                  ExcBoolRecord( const BOOL bDefault ) : bVal( bDefault ) {}
                            ExcBoolRecord( SfxItemSet*, USHORT nWhich, BOOL bDefault );

    virtual ULONG           GetLen( void ) const;
};


//--------------------------------------------------------- class ExcBof_Base -

class ExcBof_Base : public ExcRecord
{
private:
protected:
    UINT16                  nDocType;
    UINT16                  nVers;
    UINT16                  nRupBuild;
    UINT16                  nRupYear;
public:
                            ExcBof_Base( void );
};


//-------------------------------------------------------------- class ExcBof -
// Header Record fuer WORKSHEETS

class ExcBof : public ExcBof_Base
{
private:
    virtual void            SaveCont( XclExpStream& rStrm );
public:
                            ExcBof( void );

    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//------------------------------------------------------------- class ExcBofW -
// Header Record fuer WORKBOOKS

class ExcBofW : public ExcBof_Base
{
private:
    virtual void            SaveCont( XclExpStream& rStrm );
public:
                            ExcBofW( void );

    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//-------------------------------------------------------------- class ExcEof -

class ExcEof : public ExcRecord
{
private:
public:
    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//----------------------------------------------------- class ExcFngroupcount -

class ExcFngroupcount : public ExcRecord
{
private:
    virtual void            SaveCont( XclExpStream& rStrm );
public:
    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//--------------------------------------------------------- class ExcDummy_00 -
// INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)

class ExcDummy_00 : public ExcDummyRec
{
private:
    static const BYTE       pMyData[];
    static const ULONG      nMyLen;
public:
    virtual ULONG           GetLen( void ) const;
    virtual const BYTE*     GetData( void ) const;
};


//-------------------------------------------------------- class ExcDummy_04x -
// WINDOWPROTECT to BOOKBOOL (see excrecds.cxx), no 1904

class ExcDummy_040 : public ExcDummyRec
{
private:
    static const BYTE       pMyData[];
    static const ULONG      nMyLen;
public:
    virtual ULONG           GetLen( void ) const;
    virtual const BYTE*     GetData( void ) const;
};



class ExcDummy_041 : public ExcDummyRec
{
private:
    static const BYTE       pMyData[];
    static const ULONG      nMyLen;
public:
    virtual ULONG           GetLen( void ) const;
    virtual const BYTE*     GetData( void ) const;
};


//------------------------------------------------------------- class Exc1904 -

class Exc1904 : public ExcBoolRecord
{
public:
                            Exc1904( ScDocument& rDoc );
    virtual UINT16          GetNum( void ) const;
};


//------------------------------------------------------------- class ExcFont -

class ExcPalette2;

class ExcFont : public ExcRecord
{
private:
    String                  sName;
    UINT16                  nNameLen;
    UINT16                  nHeight;
    UINT16                  nAttr;      // italic, strikeout, outline, shadow
    UINT32                  nColorSer;
    UINT16                  nWeight;
    UINT8                   nUnder;
    UINT8                   nFamily;
    UINT8                   nCharset;
    BOOL                    bIgnoreCol;
    UINT32                  nSign;      // quick ==
    BiffTyp                 eBiff;
    CharSet                 eCharSet;
    static ExcPalette2*     pPalette2;
#ifdef DBG_UTIL
    static UINT16           nObjCnt;
#endif

    virtual void            SaveCont( XclExpStream& rStrm );

public:
                            ExcFont( RootData& rRootData );
                            ExcFont( Font* pFont, RootData& rRootData );
    virtual                 ~ExcFont();

    BOOL                    operator==( const ExcFont& rRef ) const;
    inline BOOL             operator!=( const ExcFont& rRef ) const
                                { return !(*this == rRef); }

    static void             SetPalette( ExcPalette2& rPalette2 );
    void                    SetName( const String& rName );
    void                    SetColor( UINT32 nSerial );
    inline void             SetHeightPt( float fHt )                { nHeight = (UINT16)(fHt * EXC_FONTHGHT_COEFF); }
    inline void             SetHeight( UINT16 nHt )                 { nHeight = nHt; }
    inline void             SetItalic( BOOL bItalic )               { if( bItalic ) nAttr |= EXC_FONTATTR_ITALIC; }
    inline void             SetStrikeout( BOOL bStrikeout )         { if( bStrikeout ) nAttr |= EXC_FONTATTR_STRIKEOUT; }
    inline void             SetOutline( BOOL bOutline )             { if( bOutline ) nAttr |= EXC_FONTATTR_OUTLINE; }
    inline void             SetShadow( BOOL bShadow )               { if( bShadow ) nAttr |= EXC_FONTATTR_SHADOW; }
    inline void             SetWeight( FontWeight eWeight )         { nWeight = GetWeight( eWeight ); }
    inline void             SetUnderline( FontUnderline eUnder )    { nUnder = GetUnderline( eUnder ); }
    inline void             SetFamily( FontFamily eFamily )         { nFamily = GetFamily( eFamily ); }
    inline void             SetCharSet( rtl_TextEncoding eCharset ) { nCharset = GetCharSet( eCharset ); }

    inline BOOL             HasIgnoreCol() const    { return bIgnoreCol; }
    inline UINT32           GetColor() const        { return nColorSer; }

    static UINT16           GetWeight( const FontWeight eWeight );
    static UINT8            GetUnderline( const FontUnderline eUnder );
    static UINT8            GetFamily( const FontFamily eFamily );
    static UINT8            GetCharSet( const rtl_TextEncoding eCharset );

    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//--------------------------------------------------------- class ExcDummy_01 -
// Ersatz fuer Default Font Records

class ExcDummy_01: public ExcDummyRec
{
private:
    static const BYTE       pMyData[];
    static const ULONG      nMyLen;
public:
    virtual ULONG           GetLen( void ) const;
    virtual const BYTE*     GetData( void ) const;
};


//--------------------------------------------------------- class ExcDummy_Fm -
// Ersatz fuer Default Format Records

class ExcDummy_Fm : public ExcDummyRec
{
private:
    static const BYTE       pMyData[];
    static const ULONG      nMyLen;
public:
    virtual ULONG           GetLen( void ) const;
    virtual const BYTE*     GetData( void ) const;
};


//--------------------------------------------------------- class ExcDummy_XF -
// Ersatz fuer Default XF Records

class ExcDummy_XF : public ExcDummyRec
{
private:
    static const BYTE       pMyData[];
    static const ULONG      nMyLen;
public:
    virtual ULONG           GetLen( void ) const;
    virtual const BYTE*     GetData( void ) const;
};


//------------------------------------------------------ class ExcDummy_Style -
// Ersatz fuer Default Style Records

class ExcDummy_Style : public ExcDummyRec
{
private:
    static const BYTE       pMyData[];
    static const ULONG      nMyLen;
public:
    virtual ULONG           GetLen( void ) const;
    virtual const BYTE*     GetData( void ) const;
};


//------------------------------------------------------ class ExcBundlesheet -

class ExcBundlesheetBase : public ExcRecord
{
protected:
    ULONG                   nStrPos;
    ULONG                   nOwnPos;    // Position NACH # und Len
    UINT16                  nGrbit;

                            ExcBundlesheetBase();

public:
                            ExcBundlesheetBase( RootData& rRootData, UINT16 nTab );

    inline void             SetStreamPos( ULONG nNewStrPos ) { nStrPos = nNewStrPos; }
    void                    UpdateStreamPos( XclExpStream& rStrm );

    virtual UINT16          GetNum() const;
};



class ExcBundlesheet : public ExcBundlesheetBase
{
private:
    ByteString              aName;

    virtual void            SaveCont( XclExpStream& rStrm );

public:
                            ExcBundlesheet( RootData& rRootData, UINT16 nTab );
    virtual ULONG           GetLen() const;
};


//--------------------------------------------------------- class ExcDummy_02 -
// sheet dummies: CALCMODE to SETUP

class ExcDummy_02 : public ExcDummyRec
{
private:
    static const BYTE       pMyData[];
    static const ULONG      nMyLen;
public:
    virtual ULONG           GetLen( void ) const;
    virtual const BYTE*     GetData( void ) const;
};


//------------------------------------------------------------- class ExcNote -

class ExcNote : public ExcEmptyRec
{
private:
    ByteString*             pText;
    ScAddress               aPos;
    UINT16                  nTextLen;

public:
                            ExcNote( const ScAddress, const String& rText, RootData& );
    virtual                 ~ExcNote();

    virtual void            Save( XclExpStream& rStrm );
};


//------------------------------------------------------------- class ExcCell -

class ExcCell : public ExcRecord
{
protected:
    ScAddress               aPos;
    UINT16                  nXF;
    static UINT32           nCellCount;     // zaehlt DOPPELT: im Ctor und SaveCont
    static ScProgress*      pPrgrsBar;
#ifdef DBG_UTIL
    friend class ExcDocument;
    static INT32            _nRefCount;
#endif

                            ExcCell(
                                const ScAddress rPos,
                                const ScPatternAttr* pAttr,
                                RootData& rRootData,
                                const ULONG nAltNumForm = NUMBERFORMAT_ENTRY_NOT_FOUND,
                                BOOL bForceAltNumForm = FALSE );

    virtual void            SaveCont( XclExpStream& rStrm );
    virtual void            SaveDiff( XclExpStream& rStrm );
    virtual ULONG           GetDiffLen() const = 0;

public:
    virtual                 ~ExcCell();

    inline void             SetXF( UINT16 nNew )    { nXF = nNew; }
    virtual UINT16          GetXF() const;

    inline static void      ResetCellCount()        { nCellCount = 0; }
    inline static void      IncCellCount()          { nCellCount++; }
    inline static UINT32    GetCellCount()          { return nCellCount; }
    inline static void      SetPrgrsBar( ScProgress& rNewBar );
    inline static void      ClearPrgrsBar()         { pPrgrsBar = NULL; }

    virtual ULONG           GetLen() const;
};

inline void ExcCell::SetPrgrsBar( ScProgress& rNewBar )
{
    ResetCellCount();       // logisch... oder?
    pPrgrsBar = &rNewBar;
}


//----------------------------------------------------------- class ExcNumber -

class ExcNumber : public ExcCell
{
private:
    double                  fVal;

    virtual void            SaveDiff( XclExpStream& rStrm );    // instead of SaveCont()
    virtual ULONG           GetDiffLen( void ) const;

public:
                            ExcNumber(
                                const ScAddress,
                                const ScPatternAttr*,
                                RootData& rRootData,
                                const double& rVal );

    virtual UINT16          GetNum( void ) const;
};


//---------------------------------------------------------- class ExcBoolerr -

class ExcBoolerr : public ExcCell
{
private:
    UINT8                   nVal;
    UINT8                   bError;

    virtual void            SaveDiff( XclExpStream& rStrm );    // instead of SaveCont()
    virtual ULONG           GetDiffLen( void ) const;

public:
                            ExcBoolerr(
                                const ScAddress,
                                const ScPatternAttr*,
                                RootData& rRootData,
                                UINT8 nVal,
                                BOOL bIsError );

    virtual UINT16          GetNum( void ) const;
};


//---------------------------------------------------------- class ExcRKMulRK -

class ExcRKMulRK : private List, public ExcCell
{
private:
    struct ExcRKMulRKEntry
    {
        UINT32              nVal;
        UINT16              nXF;
    };

    inline ExcRKMulRKEntry* _First()    { return (ExcRKMulRKEntry*) List::First(); }
    inline ExcRKMulRKEntry* _Next()     { return (ExcRKMulRKEntry*) List::Next(); }
    inline ExcRKMulRKEntry* _Get( ULONG nIndex ) const
                                { return (ExcRKMulRKEntry*) List::GetObject( nIndex ); }

protected:
    virtual void            SaveCont( XclExpStream& rStrm );
    virtual ULONG           GetDiffLen( void ) const;

public:
                            ExcRKMulRK(
                                const ScAddress,
                                const ScPatternAttr*,
                                RootData& rRootData,
                                const INT32 nVal );
    virtual                 ~ExcRKMulRK();

                            // returns new RK or NULL if an old RK was extendable
    ExcRKMulRK*             Extend( const ScAddress rPos,
                                const ScPatternAttr *pAttr,
                                RootData& rRootData,
                                const INT32 nVal );
    virtual UINT16          GetXF() const;

    virtual UINT16          GetNum( void ) const;

    inline BOOL             IsRK( void ) const      { return List::Count() == 1; }
    inline BOOL             IsMulRK( void ) const   { return List::Count() > 1; }
};


//------------------------------------------------------------ class ExcLabel -

class ExcLabel : public ExcCell
{
private:
    ByteString              aText;
    UINT16                  nTextLen;

    virtual void            SaveDiff( XclExpStream& rStrm );    // instead of SaveCont()
    virtual ULONG           GetDiffLen( void ) const;

public:
                            ExcLabel(
                                const ScAddress,
                                const ScPatternAttr*,
                                RootData& rRootData,
                                const String& rText );
    virtual                 ~ExcLabel();

    virtual UINT16          GetNum( void ) const;
};


//---------------------------------------------------------- class ExcRichStr

// helper class for ExcRString and ExcLabel8/XclExpRichString
class ExcRichStr
{
private:
    UINT16List              aForms;     // Form und Pos nacheinander
    BiffTyp                 eBiff;
public:
                            ExcRichStr(
                                ExcCell&                rExcCell,
                                String&                 rText,
                                const ScPatternAttr*    pAttr,
                                const ScEditCell&       rEdCell,
                                RootData&               rRoot,
                                xub_StrLen              nMaxChars );
    inline                  ExcRichStr( const ExcRichStr& rCopy ) :
                                aForms( rCopy.aForms ), eBiff( rCopy.eBiff ) {}

                            ~ExcRichStr();

    inline  UINT16          GetFormCount() const;

                            // number of bytes to be saved
    inline  ULONG           GetByteCount() const;

                            // write list of forms
    void                    Write( SvStream& rStrm );
    void                    Write( XclExpStream& rStrm );
};


inline UINT16 ExcRichStr::GetFormCount() const
{
    return (UINT16) Min( aForms.Count() / 2, (eBiff < Biff8 ? ULONG(0xFF) : ULONG(0xFFFF)) );
}


inline ULONG ExcRichStr::GetByteCount() const
{
    return (eBiff < Biff8 ? 2 : 4) * GetFormCount();
}


//---------------------------------------------------------- class ExcRString -

class ExcRString : public ExcCell, ExcRoot
{
private:
    String                  aText;
    ExcRichStr*             pRichStr;
    UINT16                  nTextLen;

    virtual void            SaveDiff( XclExpStream& rStrm );    // instead of SaveCont()
    virtual ULONG           GetDiffLen( void ) const;

public:
                            ExcRString(
                                const ScAddress         aPos,
                                const ScPatternAttr*    pAttr,
                                RootData&               rRootData,
                                const ScEditCell&       rEdCell );
    virtual                 ~ExcRString();

    virtual UINT16          GetNum( void ) const;
};


//---------------------------------------------------------- class ExcFormula -

class ExcFormula : public ExcCell
{
private:
    sal_Char*               pData;
    UINT16                  nFormLen;
    BOOL                    bShrdFmla;

    virtual void            SaveDiff( XclExpStream& rStrm );    // instead of SaveCont()
    virtual ULONG           GetDiffLen( void ) const;

public:
                            ExcFormula(
                                const ScAddress rPos,
                                const ScPatternAttr *pAttr,
                                RootData& rRootData,
                                const ULONG nAltNumForm,
                                BOOL bForceAltNumForm,
                                const ScTokenArray& rCode,
                                ExcArray** ppArray = NULL,
                                ScMatrixMode eMM = MM_NONE,
                                ExcShrdFmla** ppShrdFmla = NULL,
                                ExcArrays* pShrdFmlas = NULL );
                            ~ExcFormula();

    inline const ScAddress& GetPosition() const { return aPos; }    // from ExcCell

    void                    SetTableOp( USHORT nCol, USHORT nRow ); // for TableOp export

    virtual UINT16          GetNum( void ) const;
};


//---------------------------------------------------- class ExcBlankMulblank -

class ExcBlankMulblank : public ExcCell, private UINT32List
{
protected:
    ULONG                   nRecLen;
    UINT16                  nLastCol;
    BOOL                    bMulBlank;
    BOOL                    bDummy;     // not saved, 'cause row contains formatting info

    inline UINT16           GetXF( UINT32 nEntry ) const    { return (UINT16) nEntry; }
    inline UINT16           GetCount( UINT32 nEntry ) const { return (UINT16)(nEntry >> 16); }

    inline void             Append( UINT16 nXF, UINT16 nCount );

    void                    AddEntries(
                                const ScAddress rPos,
                                const ScPatternAttr* pAttr,
                                RootData& rRootData,
                                UINT16 nCount,
                                ExcTable& rExcTab );

    virtual void            SaveDiff( XclExpStream& rStrm );    // instead of SaveCont()
    virtual ULONG           GetDiffLen( void ) const;

public:
                            ExcBlankMulblank(
                                const ScAddress rPos,
                                const ScPatternAttr* pFirstAttr,
                                RootData& rRootData,
                                UINT16 nFirstCount,
                                ExcTable& rExcTab );

    void                    Add(
                                const ScAddress rPos,
                                const ScPatternAttr* pAttr,
                                RootData& rRootData,
                                UINT16 nAddCount,
                                ExcTable& rExcTab );

    inline UINT16           GetLastCol() const  { return nLastCol; }
    virtual UINT16          GetXF() const;                      // returns last used XF

    virtual UINT16          GetNum() const;

    virtual void            Save( XclExpStream& );              // for dummy case
};


inline void ExcBlankMulblank::Append( UINT16 nXF, UINT16 nCount )
{
    UINT32List::Append( (UINT32) nXF + (((UINT32) nCount) << 16) );
}




//---------------------------------------------------- class ExcNameListEntry -

class ExcNameListEntry : public ExcRecord
{
private:
protected:
public:
    virtual                 ~ExcNameListEntry();
    virtual UINT16          GetNum( void ) const;
};


//------------------------------------------------------------- class ExcName -

class ExcName : public ExcNameListEntry, ExcRoot
{
private:
    String                  aName;
    UINT8*                  pData;
    UINT16                  nFormLen;
    UINT16                  nTabNum;
    BOOL                    bHidden;
    BOOL                    bBuiltIn;
    BOOL                    bDummy;
    BiffTyp                 eBiff;

    void                    Init( BOOL bHid = FALSE, BOOL bBIn = FALSE );
    void                    BuildFormula( const ScRange& rRange );

    void                    SaveCont( XclExpStream& rStrm );

protected:
    void                    SetName( const String& rRangeName );
    void                    SetUniqueName( const String& rRangeName );

public:
                            ExcName( RootData* pRD, ScRangeData* pRange );
                            ExcName( RootData* pRD, ScDBData* pArea );
                            ExcName( RootData* pRD, const ScRange& rRange,
                                    const String& rName );
                            ExcName( RootData* pRD, const ScRange& rRange,
                                    UINT8 nBuiltIn, BOOL bHid = FALSE );
    virtual                 ~ExcName();

    virtual void            Save( XclExpStream& rStrm );
    virtual ULONG           GetLen( void ) const;

    const String&           GetName( void ) const   { return aName; }
    inline BOOL             IsDummy( void ) const   { return bDummy; }
};


//--------------------------------------------------------- class ExcNameList -

class ExcNameList : public ExcEmptyRec, private List
{
private:
    inline ExcNameListEntry* _First()   { return (ExcNameListEntry*) List::First(); }
    inline ExcNameListEntry* _Next()    { return (ExcNameListEntry*) List::Next(); }

protected:
public:
    virtual                 ~ExcNameList();

    inline void             Append( ExcNameListEntry* pName )
                                { List::Insert( pName, LIST_APPEND ); }

    virtual void            Save( XclExpStream& rStrm );
};


//------------------------------------------------------- class ExcDimensions -

class ExcDimensions : public ExcRecord
{
private:
    UINT16                  nRwMic;
    UINT16                  nRwMac;
    UINT16                  nColMic;
    UINT16                  nColMac;
    BiffTyp                 eBiff;

    virtual void            SaveCont( XclExpStream& rStrm );

public:
                            ExcDimensions( BiffTyp );
                            ExcDimensions( UINT16 nFirstCol, UINT16 nFirstRow,
                                UINT16 nLastCol, UINT16 nLastRow, BiffTyp );

    void                    SetLimits( UINT16 nFirstCol, UINT16 nFirstRow,
                                UINT16 nLastCol, UINT16 nLastRow );

    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//--------------------------------------------------------- class ExcEOutline -

class ExcEOutline
{
private:
    ScOutlineArray*             pOLArray;
    UINT16                      nCurrExcLevel;
    BOOL                        bIsColl;
    UINT16                      nEnd[ SC_OL_MAXDEPTH ];
    BOOL                        bHidden[ SC_OL_MAXDEPTH ];

protected:
public:
                                ExcEOutline( ScOutlineArray* pArray );

    void                        Update( UINT16 nNum );

    inline BOOL                 IsCollapsed() const     { return bIsColl; }
    inline UINT16               GetLevel() const
                                    { return Min( nCurrExcLevel, (UINT16) EXC_OUTLINE_MAX ); }
};


//------------------------------------------------------------ class ExcEGuts -

class ExcEGuts : public ExcRecord
{
private:
    UINT16                      nRowLevel;
    UINT16                      nColLevel;

    virtual void                SaveCont( XclExpStream& rStrm );

protected:
public:
                                ExcEGuts( ScOutlineArray* pCol, ScOutlineArray* pRow );

    virtual UINT16              GetNum() const;
    virtual ULONG               GetLen() const;
};


//-------------------------------------------------------------- class ExcRow -

class ExcRow : public ExcRecord
{
private:
    friend class DefRowXFs;
    ExcTable&               rExcTab;
    UINT16                  nNum;
    UINT16                  nFirstCol;
    UINT16                  nLastCol;
    UINT16                  nHeight;
    UINT16                  nOptions;
    UINT16                  nXF;
    BOOL                    bDefHeight;

    void                    SetRange( UINT16 nFCol, UINT16 nLCol );
    void                    SetHeight( UINT16 nNewHeight, BOOL bUser );

    virtual void            SaveCont( XclExpStream& rStrm );

protected:
public:
                            ExcRow( UINT16 nNum, UINT16 nTab, UINT16 nFCol, UINT16 nLCol,
                                UINT16 nXF, ScDocument& rDoc, ExcEOutline& rOutline, ExcTable& rExcTab );

    inline BOOL             IsDefault();

    virtual UINT16          GetNum() const;
    virtual ULONG           GetLen() const;
};

inline BOOL ExcRow::IsDefault()
{
    return (TRUEBOOL( nHeight & EXC_ROW_FLAGDEFHEIGHT ) && !nOptions);
}


//--------------------------------------------------------- class ExcRowBlock -

class ExcRowBlock : public ExcEmptyRec
{
private:
    ExcRow**                ppRows; // 32 rows per block
    UINT16                  nNext;

protected:
public:
                            ExcRowBlock();
    virtual                 ~ExcRowBlock();

                            // returns new block or NULL if last block not full
    ExcRowBlock*            Append( ExcRow* pNewRow );

    void                    SetDefXFs( DefRowXFs& rDefRowXFs );

    virtual void            Save( XclExpStream& rStrm );
};


//------------------------------------------------------ class ExcDefcolwidth -

class ExcDefcolwidth : public ExcRecord
{
private:
    UINT16                  nWidth;

    virtual void            SaveCont( XclExpStream& rStrm );

public:
                            ExcDefcolwidth( UINT16 nDefColWidth );

    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//---------------------------------------------------------- class ExcColinfo -

class ExcColinfo : public ExcRecord
{
private:
    UINT16                  nFirstCol;
    UINT16                  nLastCol;
    UINT16                  nColWidth;
    UINT16                  nXF;
    UINT16                  nOptions;

    virtual void            SaveCont( XclExpStream& rStrm );

public:
                            ExcColinfo( UINT16 nCol, UINT16 nTab, UINT16 nXF, RootData&, ExcEOutline& rOutline );
    void                    SetWidth( UINT16 nWidth, double fColScale );

                            // if expandable, delete rpExp and set to NULL
    void                    Expand( ExcColinfo*& rpExp );

    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//--------------------------------------------------------------- class ExcXf -

class ExcXf : public ExcRecord
{
protected:
    static ExcPalette2*     pPalette2;

    UINT16                  nIfnt;
    UINT16                  nIfmt;

    UINT16                  nOffs8;

    UINT32                  nIcvForeSer;
    UINT32                  nIcvBackSer;
    UINT16                  nFls;

    UINT32                  nIcvTopSer;
    UINT32                  nIcvBotSer;
    UINT32                  nIcvLftSer;
    UINT32                  nIcvRigSer;

    UINT16                  nDgTop;
    UINT16                  nDgBottom;
    UINT16                  nDgLeft;
    UINT16                  nDgRight;

    ExcHorizAlign           eAlc;
    ExcVertAlign            eAlcV;
    ExcTextOrient           eOri;
    BOOL                    bFWrap;
    BOOL                    bFSxButton;

    BOOL                    bStyle;

    BOOL                    bAtrNum;
    BOOL                    bAtrFnt;
    BOOL                    bAtrAlc;
    BOOL                    bAtrBdr;
    BOOL                    bAtrPat;
    BOOL                    bAtrProt;

#ifdef DBG_UTIL
    static UINT16           nObjCnt;
#endif

    virtual void            SaveCont( XclExpStream& rStrm );

public:
                            ExcXf( UINT16 nFont, UINT16 nForm, const ScPatternAttr*, BOOL& rbLineBreak,
                                    BOOL bStyle = FALSE );
                                // rbLineBreak = TRUE erzwingt Wrap,
                                // return von rbLineBreak enthaelt immer tatsaechliches Wrap
#ifdef DBG_UTIL
    virtual                 ~ExcXf();
#endif

    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;

    static void             SetPalette( ExcPalette2& rPalette2 );

    static void             ScToExcBorderLine( const SvxBorderLine*, UINT32& rIcvSer, UINT16& rDg );
};


//----------------------------------------------------------- class ExcFormat -

class UsedFormList;
class SvNumberFormatter;

class ExcFormat : public ExcRecord, ExcRoot
{
private:
    friend                      UsedFormList;

    UINT16                      nIndex;     // Excel-Index
    UINT32                      nScIndex;   // ...
    String*                     pForm;
    BYTE                        nFormLen;
    BiffTyp                     eBiff;
    static SvNumberFormatter*   pFormatter;
    static UINT32               nObjCnt;

    virtual void                SaveCont( XclExpStream& rStrm );

public:
                                ExcFormat( RootData*, UINT32 nScIndex );
    virtual                     ~ExcFormat();

    virtual UINT16              GetNum( void ) const;
    virtual ULONG               GetLen( void ) const;
};



//--------------------------------------------------------- class ExcPalette2 -
// a new class for PALETTE record, supports color reduction

class ExcPal2Entry : private Color
{
private:
    UINT32                  nSerial;
    UINT32                  nWeight;

protected:
public:
    inline                  ExcPal2Entry( const Color& rCol, UINT32 nSer );

                            Color::GetRed;
                            Color::GetGreen;
                            Color::GetBlue;
                            Color::GetColor;
    inline UINT32           GetSerial() const       { return nSerial; }
    inline UINT32           GetWeighting() const    { return nWeight; }
    inline BOOL             IsGreater( const Color& rCol ) const;
    inline BOOL             IsEqual( const Color& rCol ) const;

    void                    UpdateEntry( UINT16 nColorType );
    inline void             AddWeighting( const ExcPal2Entry& rEntry );
    void                    AddColor( const ExcPal2Entry& rEntry );

    void                    Save( XclExpStream& rStrm );
};

inline ExcPal2Entry::ExcPal2Entry( const Color& rCol, UINT32 nSer ) :
        Color( rCol ),
        nSerial( nSer ),
        nWeight( 0 )
{   }

inline BOOL ExcPal2Entry::IsGreater( const Color& rCol ) const
{
    return mnColor > rCol.GetColor();
}

inline BOOL ExcPal2Entry::IsEqual( const Color& rCol ) const
{
    return mnColor == rCol.GetColor();
}

inline void ExcPal2Entry::AddWeighting( const ExcPal2Entry& rEntry )
{
    nWeight += rEntry.GetWeighting();
}



class ExcPalette2 : private List, public ExcRecord
{
private:
    ColorBuffer&            rColBuff;       // defaults
    UINT32                  nLastInd;
    UINT32                  nMaxSerial;
    UINT32*                 pColorIndex;
    Color*                  pColors;

    inline ExcPal2Entry*    _First()    { return (ExcPal2Entry*) List::First(); }
    inline ExcPal2Entry*    _Next()     { return (ExcPal2Entry*) List::Next(); }
    inline ExcPal2Entry*    _Get( UINT32 nIndex ) const;

    void                    SearchEntry( const Color& rCol, UINT32& nIndex, BOOL& bIsEqual ) const;
    ExcPal2Entry*           CreateEntry( const Color& rCol, UINT32 nIndex );
    void                    RecalcColorIndex( UINT32 nKeep, UINT32 nRemove );
    void                    MergeColors( UINT32 nKeep, UINT32 nRemove );
    UINT32                  GetRemoveColor() const;
    INT32                   GetNearColors( const Color& rCol, UINT32& rFirst, UINT32& rSecond ) const;
    UINT32                  GetNearestColor( const Color& rCol, UINT32 nIgnore ) const;
    UINT32                  GetNearestColor( UINT32 nIndex ) const;

    virtual void            SaveCont( XclExpStream& rStrm );

public:
                            ExcPalette2( ColorBuffer& rCB );
    virtual                 ~ExcPalette2();

    UINT32                  InsertColor( const Color& rCol, UINT16 nColorType );
    UINT32                  InsertIndex( UINT16 nIndex );
    void                    ReduceColors();
    UINT16                  GetColorIndex( const Color& rCol ) const;
    UINT16                  GetColorIndex( UINT32 nSerial ) const;
    void                    GetMixedColors( UINT32 nForeSer, UINT32 nBackSer,
                                UINT16& rForeInd, UINT16& rBackInd, UINT16& rPatt ) const;
    ColorData               GetRGBValue( UINT16 nIndex ) const;

    virtual UINT16          GetNum() const;
    virtual ULONG           GetLen() const;
};

inline ExcPal2Entry* ExcPalette2::_Get( UINT32 nIndex ) const
{
    return (ExcPal2Entry*) List::GetObject( nIndex );
}



//------------------------------------------------------ class ExcExterncount -

class ExcExterncount : public ExcRecord, ExcRoot
{
private:
    BOOL                    bTable;

    virtual void            SaveCont( XclExpStream& rStrm );
public:
                            ExcExterncount( RootData*, const BOOL bTable );
    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//------------------------------------------------------ class ExcExternsheet -

class ExcExternsheet : public ExcRecord, public ExcRoot
{
private:
    String                  aTabName;

    virtual void            SaveCont( XclExpStream& rStrm );
public:
                            ExcExternsheet( RootData* pRD, const UINT16 nTabNum );
    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//-------------------------------------------------- class ExcExternsheetList -

class ExcExternsheetList : public ExcEmptyRec, protected List
{
private:
    inline ExcExternsheet*  _First()    { return (ExcExternsheet*) List::First(); }
    inline ExcExternsheet*  _Next()     { return (ExcExternsheet*) List::Next(); }

protected:
public:
    virtual                 ~ExcExternsheetList();
    inline void             Add( ExcExternsheet* pNew ) { List::Insert( pNew, LIST_APPEND ); }

    virtual void            Save( XclExpStream& rStrm );
};


//-------------------------------------------------------- class ExcExternDup -

class ExcExternDup : public ExcEmptyRec
{
private:
    ExcExterncount&         rExtCnt;
    ExcExternsheetList&     rExtSheetList;

protected:
public:
                            ExcExternDup( ExcExterncount&, ExcExternsheetList& );
                            ExcExternDup( const ExcExternDup& );

    virtual void            Save( XclExpStream& rStrm );
};


//---------------------------------------------------------- class ExcWindow2 -

class ExcWindow2 : public ExcRecord
{
private:
    UINT16                  nTable;

    virtual void            SaveCont( XclExpStream& rStrm );

public:
                            ExcWindow2( UINT16 nTable );
    inline  UINT16          GetTable() const    { return nTable; }

    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//-------------------------------------------------------- class ExcSelection -

class ExcSelection : public ExcRecord
{
private:
    UINT16                  nCol;
    UINT16                  nRow;
    UINT8                   nPane;

    virtual void            SaveCont( XclExpStream& rStrm );

public:
    inline                  ExcSelection( UINT16 _nCol, UINT16 _nRow, UINT8 _nPane ) :
                                nCol( _nCol ), nRow( _nRow ), nPane( _nPane ) {}

    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//------------------------------------------------------------ class UsedList -

class UsedList : public List, public ExcEmptyRec
{
private:
protected:
    UINT16                  nBaseIndex;

public:
    inline                  UsedList() {}

    inline void             SetBaseIndex( UINT16 nNewVal ) { nBaseIndex = nNewVal; }

    virtual void            Save( XclExpStream& rStrm );
};


//-------------------------------------------------------- class UsedFontList -
// a list of FONT records

class UsedFontList : public UsedList, public ExcRoot
{
private:
    inline ExcFont*         _First()    { return (ExcFont*) List::First(); }
    inline ExcFont*         _Next()     { return (ExcFont*) List::Next(); }

public:
    inline                  UsedFontList( RootData& rRootData ) : ExcRoot( &rRootData ) {}
    virtual                 ~UsedFontList();

    BOOL                    Find( ExcFont* pExcFont, UINT16& rIndex );
    UINT16                  Add( ExcFont* pExcFont );   // add and forget
    UINT16                  Add( Font* pFont );
};


//-------------------------------------------------------- class UsedFormList -
// a list of FORMAT records

class UsedFormList : public UsedList
{
private:
    inline ExcFormat*       _First()    { return (ExcFormat*) List::First(); }
    inline ExcFormat*       _Next()     { return (ExcFormat*) List::Next(); }

public:
    virtual                 ~UsedFormList();
    UINT16                  Add( ExcFormat* pFormat );  // add and forget
};


//-------------------------------------------------------- class UsedAttrList -
// a list of ENTRY structs

class UsedAttrList : public UsedList, ExcRoot
{
private:
    struct ENTRY
    {
        const ScPatternAttr*    pPattAttr;
        ExcXf*              pXfRec;
        BOOL                bLineBreak;
        ULONG               nAltNumForm;

        inline              ENTRY() : nAltNumForm( NUMBERFORMAT_ENTRY_NOT_FOUND ), pXfRec( NULL ) {}
        inline              ~ENTRY() { if( pXfRec ) delete pXfRec; }

        inline BOOL         Equal( const ScPatternAttr* p, const ULONG n ) const
                            {
                                return pPattAttr == p && nAltNumForm == n;
                            }
    };

    inline ENTRY*           _First()    { return (ENTRY*) List::First(); }
    inline ENTRY*           _Next()     { return (ENTRY*) List::Next(); }

    ExcPalette2&            rPalette2;
    UsedFontList&           rFntLst;
    UsedFormList&           rFrmLst;

    void                    AddNewXF( const ScPatternAttr* pAttr,
                                const BOOL bStyle, const BOOL bExplLineBreak,
                                const ULONG nAltNumForm = NUMBERFORMAT_ENTRY_NOT_FOUND,
                                BOOL bForceAltNumForm = FALSE );

public:
                            UsedAttrList( RootData* pRD, ExcPalette2&,
                                UsedFontList&, UsedFormList& );
    virtual                 ~UsedAttrList();
    UINT16                  Find( const ScPatternAttr* pSearch, const BOOL bStyle = FALSE,
                                    const ULONG nAltNumForm = NUMBERFORMAT_ENTRY_NOT_FOUND,
                                    BOOL bForceAltNumForm = FALSE );
    UINT16                  FindWithLineBreak( const ScPatternAttr* pSearch );

    virtual void            Save( XclExpStream& rStrm );    // overloaded to get ExcRecord from ENTRY
};


//------------------------------------------------------------ class ExcSetup -

class ExcSetup : public ExcRecord
{
private:
    UINT16                  nPaperSize;
    UINT16                  nScale;
    UINT16                  nPageStart;
    UINT16                  nGrbit;

    virtual void            SaveCont( XclExpStream& rStrm );

public:
                            ExcSetup( RootData* );

    virtual UINT16          GetNum( void ) const;
    virtual ULONG           GetLen( void ) const;
};


//------------------- class ExcHeaderFooter, class ExcHeader, class ExcFooter -

class ExcHeaderFooter : public ExcRecord, ExcRoot
{
protected:
    String                  aFormatString;
    ULONG                   nLen;
    BOOL                    bUnicode;

    String                  GetFormatString( USHORT nWhich );
    String                  GetFormatString( const ScPageHFItem& );
    String                  GetFormatString( const EditTextObject& );

    void                    CalcLen();

    virtual void            SaveCont( XclExpStream& rStrm );

public:
                            ExcHeaderFooter( RootData*, const BOOL bUnicode );

    virtual void            Save( XclExpStream& rStrm );
    virtual ULONG           GetLen( void ) const;
};



class ExcHeader : public ExcHeaderFooter
{
protected:
public:
                            ExcHeader( RootData*, const BOOL bUnicode );

    virtual UINT16          GetNum( void ) const;
};



class ExcFooter : public ExcHeaderFooter
{
protected:
public:
                            ExcFooter( RootData*, const BOOL bUnicode );

    virtual UINT16          GetNum( void ) const;
};


//----------------------------------------------------- class ExcPrintheaders -

class ExcPrintheaders : public ExcBoolRecord
{
private:
public:
                            ExcPrintheaders( SfxItemSet* );

    virtual UINT16          GetNum( void ) const;
};


//--------------------------------------------------- class ExcPrintGridlines -

class ExcPrintGridlines : public ExcBoolRecord
{
private:
public:
                            ExcPrintGridlines( SfxItemSet* );

    virtual UINT16          GetNum( void ) const;
};


//---------------------------------------------------------- class ExcHcenter -

class ExcHcenter : public ExcBoolRecord
{
private:
public:
                            ExcHcenter( SfxItemSet* );

    virtual UINT16          GetNum( void ) const;
};


//---------------------------------------------------------- class ExcVcenter -

class ExcVcenter : public ExcBoolRecord
{
private:
public:
                            ExcVcenter( SfxItemSet* );

    virtual UINT16          GetNum( void ) const;
};


//---------------------------------------------------------------- AutoFilter -
// classes: ExcFilterMode, ExcAutoFilterInfo, ExcFilterCondition,
//          ExcAutoFilter, ExcAutoFilterRecs

class ExcFilterMode : public ExcRecord
{
public:
    virtual UINT16          GetNum() const;
    virtual ULONG           GetLen() const;
};



class ExcAutoFilterInfo : public ExcRecord
{
private:
    UINT16                  nCount;

    virtual void            SaveCont( XclExpStream& rStrm );

protected:
public:
    inline                  ExcAutoFilterInfo( UINT16 nC )  { nCount = nC; }
    virtual                 ~ExcAutoFilterInfo();

    virtual UINT16          GetNum() const;
    virtual ULONG           GetLen() const;
};



class ExcFilterCondition
{
private:
    UINT8                   nType;
    UINT8                   nOper;
    double                  fVal;
    XclExpUniString*        pText;

protected:
public:
                            ExcFilterCondition();
                            ~ExcFilterCondition();

    inline BOOL             IsEmpty() const     { return (nType == EXC_AFTYPE_NOTUSED); }
    inline BOOL             HasEqual() const    { return (nOper == EXC_AFOPER_EQUAL); }
    ULONG                   GetTextBytes() const;

    void                    SetCondition( UINT8 nTp, UINT8 nOp, double fV, String* pT );

    void                    Save( XclExpStream& rStrm );
    void                    SaveText( XclExpStream& rStrm );
};



class ExcAutoFilter : public ExcRecord
{
private:
    UINT16                  nCol;
    UINT16                  nFlags;
    ExcFilterCondition      aCond[ 2 ];

    BOOL                    AddCondition( ScQueryConnect eConn, UINT8 nType,
                                UINT8 nOp, double fVal, String* pText,
                                BOOL bSimple = FALSE );

    virtual void            SaveCont( XclExpStream& rStrm );

protected:
public:
                            ExcAutoFilter( UINT16 nC );

    inline UINT16           GetCol() const          { return nCol; }
    inline BOOL             HasCondition() const    { return !aCond[ 0 ].IsEmpty(); }
    inline BOOL             HasTop10() const        { return TRUEBOOL( nFlags & EXC_AFFLAG_TOP10 ); }

    BOOL                    AddEntry( RootData& rRoot, const ScQueryEntry& rEntry );

    virtual UINT16          GetNum() const;
    virtual ULONG           GetLen() const;
};



class ExcAutoFilterRecs : private List, public ExcEmptyRec
{
private:
    ExcFilterMode*          pFilterMode;
    ExcAutoFilterInfo*      pFilterInfo;

    inline ExcAutoFilter*   _First()    { return (ExcAutoFilter*) List::First(); }
    inline ExcAutoFilter*   _Next()     { return (ExcAutoFilter*) List::Next(); }
    ExcAutoFilter*          GetByCol( UINT16 nCol );    // always 0-based

    BOOL                    IsFiltered( UINT16 nCol );

    void                    DeleteList();
    inline void             Append( ExcAutoFilter* pFilter )
                                { List::Insert( pFilter, LIST_APPEND ); }
    void                    AddObjRecs( RootData& rRoot, const ScAddress& rPos, UINT16 nCols );
protected:
public:
                            ExcAutoFilterRecs( RootData& rRoot, UINT16 nTab );
    virtual                 ~ExcAutoFilterRecs();

    virtual void            Save( XclExpStream& rStrm );
};


//----------------------------------------------------------- class ExcMargin -

class ExcMargin : public ExcRecord
{
private:
    UINT16                  nVal;
    UINT16                  nId;

    virtual void            SaveCont( XclExpStream& rStrm );
protected:
public:
                            ExcMargin( long nMargin, IMPEXC_MARGINSIDE eSide );

    virtual UINT16          GetNum() const;
    virtual ULONG           GetLen() const;
};


//---------------------------------------------------- class XclExpPageBreaks -

class XclExpPageBreaks : public ExcRecord
{
private:
    UINT16                  nRecNum;

    virtual void            SaveCont( XclExpStream& rStrm );

protected:
    UINT16List              aPageBreaks;

public:
    enum ExcPBOrientation   { pbHorizontal, pbVertical };

                            XclExpPageBreaks( RootData& rRootData, UINT16 nScTab, ExcPBOrientation eOrient );
    virtual                 ~XclExpPageBreaks();

    virtual void            Save( XclExpStream& rStrm );
    virtual UINT16          GetNum() const;
    virtual ULONG           GetLen() const;
};


//------------------------ class ExcArray, class ExcArrays, class ExcShrdFmla -

class ExcArray : public ExcRecord
{
protected:
    UINT32                  nID;
    UINT16                  nFirstRow;
    UINT16                  nLastRow;
    UINT8                   nFirstCol;
    UINT8                   nLastCol;
    sal_Char*               pData;
    UINT16                  nFormLen;

    void                    SetColRow( UINT8 nCol, UINT16 nRow, UINT32 nID = 0xFFFFFFFF );

    virtual void            SaveCont( XclExpStream& rStrm );

                            ExcArray( const sal_Char* pData, UINT16 nLen, UINT8 nCol, UINT16 nRow );
public:
                            ExcArray( const ExcUPN&, UINT8 nCol, UINT16 nRow );
                            ExcArray( UINT8 nCol, UINT16 nRow, UINT32 nID );
    virtual                 ~ExcArray();

    virtual UINT16          GetNum() const;
    virtual ULONG           GetLen() const;

    BOOL                    AppendBy( const ExcArray& rExt );
                                // TRUE, if rEXt is touching given range and extend range
    BOOL                    AppendBy( UINT8 nStartCol, UINT16 nStartRow, UINT8 nEndCol, UINT16 nEndRow );
};




class ExcArrays : protected List
{
private:
protected:
public:
                            ExcArrays( void );
    virtual                 ~ExcArrays();

    BOOL                    Insert( ExcArray* pPossibleNewArrayFormula );
                                // insert only, if not already in array
                                // only ref in list, so if return is TRUE, do not delete _before_ using
                                //  Insert() the _last_ time!

    BOOL                    Extend( UINT8 nStartCol, UINT16 nStartRow, UINT8 nEndCol, UINT16 nEndRow );
                                // extend existing range, when start is base

    inline void             Append( ExcArray* );
};


inline void ExcArrays::Append( ExcArray* p )
{
    List::Insert( p, LIST_APPEND );
}




class ExcShrdFmla : public ExcArray
{
private:
//  ScRange                 aPos;
//  sal_Char*               pData;
//  UINT16                  nLen;

    virtual void            SaveCont( XclExpStream& rStrm );
public:
                            ExcShrdFmla( const sal_Char* pData, UINT16 nLen, const ScRange& rPos );
    virtual                 ~ExcShrdFmla();

    virtual UINT16          GetNum() const;
    virtual ULONG           GetLen() const;
};


//--------------------------- class XclExpTableOp, class XclExpTableOpManager -
// multiple operations aka table operations (record TABLE)

// a multiple operations record
// stores pointers to all affected formula records
class XclExpTableOp : private List, public ExcRecord
{
private:
    USHORT                  nFirstCol;
    USHORT                  nLastCol;
    USHORT                  nNextCol;           // next column of next row
    USHORT                  nFirstRow;
    USHORT                  nLastRow;
    USHORT                  nMode;
    USHORT                  nColInpCol;
    USHORT                  nColInpRow;
    USHORT                  nRowInpCol;
    USHORT                  nRowInpRow;
    BOOL                    bIsValid;

    inline ExcFormula*      _First()    { return (ExcFormula*) List::First(); }
    inline ExcFormula*      _Next()     { return (ExcFormula*) List::Next(); }

    inline void             Append( ExcFormula* pFmla ) { List::Insert( pFmla, LIST_APPEND ); }

    virtual void            SaveCont( XclExpStream& rStrm );

public:
                            XclExpTableOp(
                                ExcFormula& rFormula,
                                const ScAddress& rColFirstPos,
                                const ScAddress& rRowFirstPos,
                                USHORT nNewMode );
    virtual                 ~XclExpTableOp();

    BOOL                    IsAppendable( const ScAddress& rPos );

    BOOL                    CheckPosition(
                                const ScAddress& rPos,
                                const ScAddress& rFmlaPos,
                                const ScAddress& rColFirstPos, const ScAddress& rColRelPos,
                                const ScAddress& rRowFirstPos, const ScAddress& rRowRelPos,
                                BOOL bMode2 );

    static BOOL             CheckFirstPosition(
                                const ScAddress& rPos,
                                const ScAddress& rFmlaPos,
                                const ScAddress& rColFirstPos, const ScAddress& rColRelPos,
                                const ScAddress& rRowFirstPos, const ScAddress& rRowRelPos,
                                BOOL bMode2, USHORT& rnMode );

                            // insert pointer to Formula rec and update range data
    void                    InsertCell( ExcFormula& rFormula );
                            // change #NA error values of formula recs to TableOp values if in table op range
    void                    UpdateCells();

    virtual void            Save( XclExpStream& rStrm );

    virtual UINT16          GetNum() const;
    virtual ULONG           GetLen() const;
};

// stores pointers to ExcTableOp records - insert cells to existing or new ExcTableOp
class XclExpTableOpManager : private List
{
private:
    inline XclExpTableOp*   _First()    { return (XclExpTableOp*) List::First(); }
    inline XclExpTableOp*   _Next()     { return (XclExpTableOp*) List::Next(); }

public:
    inline                  XclExpTableOpManager() : List() {}
    virtual                 ~XclExpTableOpManager();

                            // create & return new TableOp record or insert to an existing
    XclExpTableOp*          InsertCell( const ScTokenArray* pTokenArray, ExcFormula& rFormula );
                            // change #NA error values of formula recs to TableOp values
    void                    UpdateCells();
};

#endif