summaryrefslogtreecommitdiff
path: root/sc/inc/document.hxx
blob: 0ee37414279a7c2823ace47c91509f431a35b9fb (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
/*************************************************************************
 *
 *  $RCSfile: document.hxx,v $
 *
 *  $Revision: 1.65 $
 *
 *  last change: $Author: hr $ $Date: 2003-03-26 18:03:34 $
 *
 *  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 SC_DOCUMENT_HXX
#define SC_DOCUMENT_HXX


#ifndef _SV_PRNTYPES_HXX //autogen
#include <vcl/prntypes.hxx>
#endif

#ifndef _SV_TIMER_HXX //autogen
#include <vcl/timer.hxx>
#endif

#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
#include <com/sun/star/uno/Reference.hxx>
#endif

#ifndef _VOS_REF_HXX_
#include <vos/ref.hxx>
#endif

#ifndef SC_TABLE_HXX
#include "table.hxx"        // FastGetRowHeight (inline)
#endif

#ifndef SC_RANGELST_HXX
#include "rangelst.hxx"
#endif

#ifndef _SC_BRDCST_HXX
#include "brdcst.hxx"
#endif

#ifndef SC_TABOPPARAMS_HXX
#include "tabopparams.hxx"
#endif

class KeyEvent;
class OutputDevice;
class SdrObject;
class SfxBroadcaster;
class SfxHint;
class SfxItemSet;
class SfxObjectShell;
class SfxBindings;
class SfxPoolItem;
class SfxItemPool;
class SfxPrinter;
class SfxStatusBarManager;
class SfxStyleSheetBase;
class SvMemoryStream;
class SvNumberFormatter;
class SvxBorderLine;
class SvxBoxInfoItem;
class SvxBoxItem;
class SvxBrushItem;
class SvxForbiddenCharactersTable;
class SvxLinkManager;
class SvxSearchItem;
class SvxShadowItem;
class Window;
class XColorTable;
class List;

class ScAutoFormatData;
class ScBaseCell;
class ScStringCell;
class ScBroadcastAreaSlotMachine;
class ScChangeViewSettings;
class ScChartCollection;
class ScChartListenerCollection;
class ScConditionalFormat;
class ScConditionalFormatList;
class ScDBCollection;
class ScDBData;
class ScDetOpData;
class ScDetOpList;
class ScDocOptions;
class ScDocumentPool;
class ScDrawLayer;
class ScExtDocOptions;
class ScFormulaCell;
class SchMemChart;
class ScMarkData;
class ScOutlineTable;
class ScPatternAttr;
class ScPivot;
class ScPivotCollection;
class ScPrintRangeSaver;
class ScRangeData;
class ScRangeName;
class ScStyleSheet;
class ScStyleSheetPool;
class ScTable;
class ScTokenArray;
class ScValidationData;
class ScValidationDataList;
class ScViewOptions;
class StrCollection;
class TypedStrCollection;
class ScChangeTrack;
class ScFieldEditEngine;
struct ScConsolidateParam;
class ScDPObject;
class ScDPCollection;
class ScMatrix;
class ScScriptTypeData;
class ScPoolHelper;
class ScImpExpLogMsg;
struct ScSortParam;
class ScRefreshTimerControl;

namespace com { namespace sun { namespace star {
    namespace lang {
        class XMultiServiceFactory;
    }
    namespace i18n {
        class XBreakIterator;
    }
} } }


#ifdef _ZFORLIST_DECLARE_TABLE
class SvULONGTable;
#else
class Table;
typedef Table SvULONGTable;
#endif


#define SC_TAB_APPEND       0xFFFF
#define SC_DOC_NEW          0xFFFF
#define REPEAT_NONE         0xFFFF

#define SC_MACROCALL_ALLOWED        0
#define SC_MACROCALL_NOTALLOWED     1
#define SC_MACROCALL_ASK            2

#define SC_ASIANCOMPRESSION_INVALID     0xff
#define SC_ASIANKERNING_INVALID         0xff


enum ScDocumentMode
    {
        SCDOCMODE_DOCUMENT,
        SCDOCMODE_CLIP,
        SCDOCMODE_UNDO
    };



// -----------------------------------------------------------------------
//
//          structs fuer FillInfo
//

enum ScShadowPart
{
    SC_SHADOW_HSTART,
    SC_SHADOW_VSTART,
    SC_SHADOW_HORIZ,
    SC_SHADOW_VERT,
    SC_SHADOW_CORNER
};

#define SC_ROTDIR_NONE          0
#define SC_ROTDIR_STANDARD      1
#define SC_ROTDIR_LEFT          2
#define SC_ROTDIR_RIGHT         3
#define SC_ROTDIR_CENTER        4

struct CellInfo
    {
        ScBaseCell*                 pCell;

        const ScPatternAttr*        pPatternAttr;
        const SfxItemSet*           pConditionSet;

        const SvxBrushItem*         pBackground;

        const SvxBoxItem*           pLinesAttr;             // Original-Item (intern)

        const SvxBorderLine*        pThisBottom;            // einzelne inkl. zusammengefasst
        const SvxBorderLine*        pNextTop;               // (intern)
        const SvxBorderLine*        pThisRight;
        const SvxBorderLine*        pNextLeft;

        const SvxBorderLine*        pRightLine;             // dickere zum Zeichnen
        const SvxBorderLine*        pBottomLine;

        const SvxShadowItem*        pShadowAttr;            // Original-Item (intern)

        ScShadowPart                eHShadowPart;           // Schatten effektiv zum Zeichnen
        ScShadowPart                eVShadowPart;
        const SvxShadowItem*        pHShadowOrigin;
        const SvxShadowItem*        pVShadowOrigin;

        USHORT                      nWidth;

        BOOL                        bMarked;
        BOOL                        bStandard;
        BOOL                        bEmptyCellText;

        BOOL                        bMerged;
        BOOL                        bHOverlapped;
        BOOL                        bVOverlapped;
        BOOL                        bAutoFilter;
        BOOL                        bPushButton;
        BYTE                        nRotateDir;

        BOOL                        bPrinted;               // bei Bedarf (Pagebreak-Modus)

        BOOL                        bHideGrid;              // output-intern
        BOOL                        bEditEngine;            // output-intern
    };

#define SC_ROTMAX_NONE  USHRT_MAX

struct RowInfo
    {
        CellInfo*       pCellInfo;

        USHORT          nHeight;
        USHORT          nRowNo;
        USHORT          nRotMaxCol;         // SC_ROTMAX_NONE, wenn nichts

        BOOL            bEmptyBack;
        BOOL            bEmptyText;
        BOOL            bAutoFilter;
        BOOL            bPushButton;
        BOOL            bChanged;           // TRUE, wenn nicht getestet
    };

struct ScDocStat
{
    String  aDocName;
    USHORT  nTableCount;
    ULONG   nCellCount;
    USHORT  nPageCount;
};

// nicht 11 Parameter bei CopyBlockFromClip, konstante Werte der Schleife hier
struct ScCopyBlockFromClipParams
{
    ScDocument* pRefUndoDoc;
    ScDocument* pClipDoc;
    USHORT      nInsFlag;
    USHORT      nTabStart;
    USHORT      nTabEnd;
    BOOL        bAsLink;
    BOOL        bSkipAttrForEmpty;
};

#define ROWINFO_MAX 1024


// for loading of binary file format symbol string cells which need font conversion
struct ScSymbolStringCellEntry
{
    ScStringCell*   pCell;
    USHORT          nRow;
};


// Spezialwert fuer Recalc-Alwyas-Zellen

#define BCA_BRDCST_ALWAYS ScAddress( 0, 32767, 0 )
#define BCA_LISTEN_ALWAYS ScRange( BCA_BRDCST_ALWAYS, BCA_BRDCST_ALWAYS )

// -----------------------------------------------------------------------

// DDE Link Modes

#define SC_DDE_DEFAULT      0
#define SC_DDE_ENGLISH      1
#define SC_DDE_TEXT         2
#define SC_DDE_IGNOREMODE   255     // for usage in FindDdeLink() only!

// -----------------------------------------------------------------------

class ScDocument
{
friend class ScDocumentIterator;
friend class ScValueIterator;
friend class ScQueryValueIterator;
friend class ScCellIterator;
friend class ScQueryCellIterator;
friend class ScHorizontalCellIterator;
friend class ScHorizontalAttrIterator;
friend class ScDocAttrIterator;
friend class ScAttrRectIterator;
friend class ScPivot;

private:
    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager;

    vos::ORef<ScPoolHelper> xPoolHelper;

    ScFieldEditEngine*  pEditEngine;                    // uses pEditPool from xPoolHelper
    SfxObjectShell*     pShell;
    SfxPrinter*         pPrinter;
    ScDrawLayer*        pDrawLayer;                     // SdrModel
    XColorTable*        pColorTable;
    ScConditionalFormatList* pCondFormList;             // bedingte Formate
    ScValidationDataList* pValidationList;              // Gueltigkeit
    SvULONGTable*       pFormatExchangeList;            // zum Umsetzen von Zahlenformaten
    ScTable*            pTab[MAXTAB+1];
    ScRangeName*        pRangeName;
    ScDBCollection*     pDBCollection;
    ScPivotCollection*  pPivotCollection;
    ScDPCollection*     pDPCollection;
    ScChartCollection*  pChartCollection;
    ScPatternAttr*      pSelectionAttr;                 // Attribute eines Blocks
    SvxLinkManager*     pLinkManager;
    ScFormulaCell*      pFormulaTree;                   // Berechnungsbaum Start
    ScFormulaCell*      pEOFormulaTree;                 // Berechnungsbaum Ende, letzte Zelle
    ScFormulaCell*      pFormulaTrack;                  // BroadcastTrack Start
    ScFormulaCell*      pEOFormulaTrack;                // BrodcastTrack Ende, letzte Zelle
    ScBroadcastAreaSlotMachine* pBASM;                  // BroadcastAreas
    ScChartListenerCollection* pChartListenerCollection;
    StrCollection*      pOtherObjects;                  // non-chart OLE objects
    SvMemoryStream*     pClipData;
    ScDetOpList*        pDetOpList;
    ScChangeTrack*      pChangeTrack;
    SfxBroadcaster*     pUnoBroadcaster;
    ScChangeViewSettings* pChangeViewSettings;
    ScScriptTypeData*   pScriptTypeData;
    ScRefreshTimerControl* pRefreshTimerControl;
    vos::ORef<SvxForbiddenCharactersTable> xForbiddenCharacters;

    ScFieldEditEngine*  pCacheFieldEditEngine;

    com::sun::star::uno::Sequence<sal_Int8> aProtectPass;
    String              aDocName;                       // opt: Dokumentname
    ScRangePairListRef  xColNameRanges;
    ScRangePairListRef  xRowNameRanges;

    ScViewOptions*      pViewOptions;                   // View-Optionen
    ScDocOptions*       pDocOptions;                    // Dokument-Optionen
    ScExtDocOptions*    pExtDocOptions;                 // fuer Import etc.
    ScConsolidateParam* pConsolidateDlgData;

    List*               pLoadedSymbolStringCellList;    // binary file format import of symbol font string cells

    ScRange             aClipRange;
    ScRange             aEmbedRange;
    ScAddress           aCurTextWidthCalcPos;
    ScAddress           aOnlineSpellPos;                // within whole document
    ScRange             aVisSpellRange;
    ScAddress           aVisSpellPos;                   // within aVisSpellRange (see nVisSpellState)

    Timer               aTrackTimer;

public:
    ScTabOpList         aTableOpList;                   // list of ScInterpreterTableOpParams currently in use
    ScInterpreterTableOpParams  aLastTableOpParams;     // remember last params
private:

    LanguageType        eLanguage;                      // default language
    LanguageType        eCjkLanguage;                   // default language for asian text
    LanguageType        eCtlLanguage;                   // default language for complex text
    CharSet             eSrcSet;                        // Einlesen: Quell-Zeichensatz

    ULONG               nFormulaCodeInTree;             // FormelRPN im Formelbaum
    ULONG               nXMLImportedFormulaCount;        // progress count during XML import
    USHORT              nInterpretLevel;                // >0 wenn im Interpreter
    USHORT              nMacroInterpretLevel;           // >0 wenn Macro im Interpreter
    USHORT              nInterpreterTableOpLevel;       // >0 if in Interpreter TableOp
    USHORT              nMaxTableNumber;
    USHORT              nSrcVer;                        // Dateiversion (Laden/Speichern)
    USHORT              nSrcMaxRow;                     // Zeilenzahl zum Laden/Speichern
    USHORT              nFormulaTrackCount;
    USHORT              nHardRecalcState;               // 0: soft, 1: hard-warn, 2: hard
    USHORT              nVisibleTab;                    // fuer OLE etc.

    ScLkUpdMode         eLinkMode;

    BOOL                bProtected;
    BOOL                bAutoCalc;                      // Automatisch Berechnen
    BOOL                bAutoCalcShellDisabled;         // in/von/fuer ScDocShell disabled
    // ob noch ForcedFormulas berechnet werden muessen,
    // im Zusammenspiel mit ScDocShell SetDocumentModified,
    // AutoCalcShellDisabled und TrackFormulas
    BOOL                bForcedFormulaPending;
    BOOL                bCalculatingFormulaTree;
    BOOL                bIsClip;
    BOOL                bCutMode;
    BOOL                bIsUndo;

    BOOL                bIsEmbedded;                    // Embedded-Bereich anzeigen/anpassen ?

    // kein SetDirty bei ScFormulaCell::CompileTokenArray sondern am Ende
    // von ScDocument::CompileAll[WithFormats], CopyScenario, CopyBlockFromClip
    BOOL                bNoSetDirty;
    // kein Broadcast, keine Listener aufbauen waehrend aus einem anderen
    // Doc (per Filter o.ae.) inserted wird, erst bei CompileAll / CalcAfterLoad
    BOOL                bInsertingFromOtherDoc;
    BOOL                bImportingXML;      // special handling of formula text
    BOOL                bCalcingAfterLoad;              // in CalcAfterLoad TRUE
    // wenn temporaer keine Listener auf/abgebaut werden sollen
    BOOL                bNoListening;
    BOOL                bLoadingDone;
    BOOL                bIdleDisabled;
    BOOL                bInLinkUpdate;                  // TableLink or AreaLink
    BOOL                bChartListenerCollectionNeedsUpdate;
    // ob RC_FORCED Formelzellen im Dokument sind/waren (einmal an immer an)
    BOOL                bHasForcedFormulas;
    // ist beim Laden/Speichern etwas weggelassen worden?
    BOOL                bLostData;
    // ob das Doc gerade zerstoert wird (kein Notify-Tracking etc. mehr)
    BOOL                bInDtorClear;
    // ob bei Spalte/Zeile einfuegen am Rand einer Referenz die Referenz
    // erweitert wird, wird in jedem UpdateReference aus InputOptions geholt,
    // gesetzt und am Ende von UpdateReference zurueckgesetzt
    BOOL                bExpandRefs;
    // fuer Detektiv-Update, wird bei jeder Aenderung an Formeln gesetzt
    BOOL                bDetectiveDirty;

    BYTE                nMacroCallMode;     // Makros per Warnung-Dialog disabled?
    BOOL                bHasMacroFunc;      // valid only after loading

    BYTE                nVisSpellState;

    BYTE                nAsianCompression;
    BYTE                nAsianKerning;

    BOOL                bPastingDrawFromOtherDoc;

    BYTE                nInDdeLinkUpdate;   // originating DDE links (stacked bool)

    BOOL                bInUnoBroadcast;

    mutable BOOL        bStyleSheetUsageInvalid;


    inline BOOL         RowHidden( USHORT nRow, USHORT nTab );      // FillInfo

public:
    long            GetCellCount() const;       // alle Zellen
    long            GetWeightedCount() const;   // Formeln und Edit staerker gewichtet
    ULONG           GetCodeCount() const;       // RPN-Code in Formeln
    DECL_LINK( GetUserDefinedColor, USHORT * );
                                                                // Numberformatter

public:
                    ScDocument( ScDocumentMode eMode = SCDOCMODE_DOCUMENT,
                                SfxObjectShell* pDocShell = NULL );
                    ~ScDocument();

    inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
                    GetServiceManager() const { return xServiceManager; }

    const String&   GetName() const { return aDocName; }
    void            SetName( const String& r ) { aDocName = r; }

    void            GetDocStat( ScDocStat& rDocStat );

    void            InitDrawLayer( SfxObjectShell* pDocShell = NULL );
    XColorTable*    GetColorTable();

    SvxLinkManager*     GetLinkManager() { return pLinkManager; }
    void                SetLinkManager( SvxLinkManager* pNew );

    const ScDocOptions&     GetDocOptions() const;
    void                    SetDocOptions( const ScDocOptions& rOpt );
    const ScViewOptions&    GetViewOptions() const;
    void                    SetViewOptions( const ScViewOptions& rOpt );
    void                    SetPrintOptions();

    ScExtDocOptions*        GetExtDocOptions()  { return pExtDocOptions; }
    void                    SetExtDocOptions( ScExtDocOptions* pNewOptions );

    void                    GetLanguage( LanguageType& rLatin, LanguageType& rCjk, LanguageType& rCtl ) const;
    void                    SetLanguage( LanguageType eLatin, LanguageType eCjk, LanguageType eCtl );

    void                        SetConsolidateDlgData( const ScConsolidateParam* pData );
    const ScConsolidateParam*   GetConsolidateDlgData() const { return pConsolidateDlgData; }

    void            Clear();

    ScFieldEditEngine*  CreateFieldEditEngine();
    void                DisposeFieldEditEngine(ScFieldEditEngine*& rpEditEngine);

    ScRangeName*    GetRangeName();
    void            SetRangeName( ScRangeName* pNewRangeName );
    USHORT          GetMaxTableNumber() { return nMaxTableNumber; }
    void            SetMaxTableNumber(USHORT nNumber) { nMaxTableNumber = nNumber; }

    ScRangePairList*    GetColNameRanges() { return &xColNameRanges; }
    ScRangePairList*    GetRowNameRanges() { return &xRowNameRanges; }
    ScRangePairListRef& GetColNameRangesRef() { return xColNameRanges; }
    ScRangePairListRef& GetRowNameRangesRef() { return xRowNameRanges; }

    ScDBCollection* GetDBCollection() const;
    void            SetDBCollection( ScDBCollection* pNewDBCollection,
                                        BOOL bRemoveAutoFilter = FALSE );
    ScDBData*       GetDBAtCursor(USHORT nCol, USHORT nRow, USHORT nTab,
                                        BOOL bStartOnly = FALSE) const;
    ScDBData*       GetDBAtArea(USHORT nTab, USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2) const;

    ScRangeData*    GetRangeAtCursor(USHORT nCol, USHORT nRow, USHORT nTab,
                                        BOOL bStartOnly = FALSE) const;
    ScRangeData*    GetRangeAtBlock( const ScRange& rBlock, String* pName=NULL ) const;

    ScDPCollection*     GetDPCollection();
    ScDPObject*         GetDPAtCursor(USHORT nCol, USHORT nRow, USHORT nTab) const;

    ScPivotCollection*  GetPivotCollection() const;
    void                SetPivotCollection(ScPivotCollection* pNewPivotCollection);
    ScPivot*            GetPivotAtCursor(USHORT nCol, USHORT nRow, USHORT nTab) const;

    ScChartCollection*  GetChartCollection() const;
    void                SetChartCollection(ScChartCollection* pNewChartCollection);

    void            EnsureGraphicNames();

    SdrObject*      GetObjectAtPoint( USHORT nTab, const Point& rPos );
    BOOL            HasChartAtPoint( USHORT nTab, const Point& rPos, String* pName = NULL );
    void            UpdateChartArea( const String& rChartName, const ScRange& rNewArea,
                                        BOOL bColHeaders, BOOL bRowHeaders, BOOL bAdd,
                                        Window* pWindow );
    void            UpdateChartArea( const String& rChartName,
                                    const ScRangeListRef& rNewList,
                                    BOOL bColHeaders, BOOL bRowHeaders, BOOL bAdd,
                                    Window* pWindow );
    SchMemChart*    FindChartData(const String& rName, BOOL bForModify = FALSE);

    void            MakeTable( USHORT nTab );

    USHORT          GetVisibleTab() const       { return nVisibleTab; }
    void            SetVisibleTab(USHORT nTab)  { nVisibleTab = nTab; }

    BOOL            HasTable( USHORT nTab ) const;
    BOOL            GetName( USHORT nTab, String& rName ) const;
    BOOL            GetTable( const String& rName, USHORT& rTab ) const;
    inline USHORT   GetTableCount() const { return nMaxTableNumber; }
    SvULONGTable*   GetFormatExchangeList() const { return pFormatExchangeList; }

    void            SetDocProtection( BOOL bProtect, const com::sun::star::uno::Sequence <sal_Int8>& aPass );
    void            SetTabProtection( USHORT nTab, BOOL bProtect, const com::sun::star::uno::Sequence <sal_Int8>& aPass );
    BOOL            IsDocProtected() const;
    BOOL            IsDocEditable() const;
    BOOL            IsTabProtected( USHORT nTab ) const;
    const com::sun::star::uno::Sequence <sal_Int8>& GetDocPassword() const;
    const com::sun::star::uno::Sequence <sal_Int8>& GetTabPassword( USHORT nTab ) const;

    void            LockTable(USHORT nTab);
    void            UnlockTable(USHORT nTab);

    BOOL            IsBlockEditable( USHORT nTab, USHORT nStartCol, USHORT nStartRow,
                                        USHORT nEndCol, USHORT nEndRow,
                                        BOOL* pOnlyNotBecauseOfMatrix = NULL ) const;
    BOOL            IsSelectedBlockEditable( USHORT nStartCol, USHORT nStartRow,
                                            USHORT nEndCol, USHORT nEndRow,
                                            const ScMarkData& rMark ) const;
    BOOL            IsSelectionEditable( const ScMarkData& rMark,
                                        BOOL* pOnlyNotBecauseOfMatrix = NULL ) const;
    BOOL            IsSelectionOrBlockEditable( USHORT nTab, USHORT nStartCol, USHORT nStartRow,
                                        USHORT nEndCol, USHORT nEndRow,
                                        const ScMarkData& rMark ) const;
    BOOL            IsSelectedOrBlockEditable( USHORT nStartCol, USHORT nStartRow,
                                            USHORT nEndCol, USHORT nEndRow,
                                            const ScMarkData& rMark ) const;

    BOOL            HasSelectedBlockMatrixFragment( USHORT nStartCol, USHORT nStartRow,
                                            USHORT nEndCol, USHORT nEndRow,
                                            const ScMarkData& rMark ) const;

    BOOL            GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix );

    BOOL            IsEmbedded() const;
    void            GetEmbedded( ScTripel& rStart, ScTripel& rEnd ) const;
    void            SetEmbedded( const ScTripel& rStart, const ScTripel& rEnd );
    void            ResetEmbedded();
    Rectangle       GetEmbeddedRect() const;                        // 1/100 mm
    void            SetEmbedded( const Rectangle& rRect );          // aus VisArea (1/100 mm)
    void            SnapVisArea( Rectangle& rRect ) const;          // 1/100 mm

    BOOL            ValidTabName( const String& rName ) const;
    BOOL            ValidNewTabName( const String& rName ) const;
    void            CreateValidTabName(String& rName) const;
    BOOL            InsertTab( USHORT nPos, const String& rName,
                                BOOL bExternalDocument = FALSE );
    BOOL            DeleteTab( USHORT nTab, ScDocument* pRefUndoDoc = NULL );
    BOOL            RenameTab( USHORT nTab, const String& rName,
                                BOOL bUpdateRef = TRUE,
                                BOOL bExternalDocument = FALSE );
    BOOL            MoveTab( USHORT nOldPos, USHORT nNewPos );
    BOOL            CopyTab( USHORT nOldPos, USHORT nNewPos,
                                const ScMarkData* pOnlyMarked = NULL );
    ULONG           TransferTab(ScDocument* pSrcDoc, USHORT nSrcPos, USHORT nDestPos,
                                    BOOL bInsertNew = TRUE,
                                    BOOL bResultsOnly = FALSE );
    void            TransferDrawPage(ScDocument* pSrcDoc, USHORT nSrcPos, USHORT nDestPos);
    void            ClearDrawPage(USHORT nTab);
    void            SetVisible( USHORT nTab, BOOL bVisible );
    BOOL            IsVisible( USHORT nTab ) const;
    void            SetScenario( USHORT nTab, BOOL bFlag );
    BOOL            IsScenario( USHORT nTab ) const;
    void            GetScenarioData( USHORT nTab, String& rComment,
                                        Color& rColor, USHORT& rFlags ) const;
    void            SetScenarioData( USHORT nTab, const String& rComment,
                                        const Color& rColor, USHORT nFlags );
    BOOL            IsActiveScenario( USHORT nTab ) const;
    void            SetActiveScenario( USHORT nTab, BOOL bActive );     // nur fuer Undo etc.
    BYTE            GetLinkMode( USHORT nTab ) const;
    BOOL            IsLinked( USHORT nTab ) const;
    const String&   GetLinkDoc( USHORT nTab ) const;
    const String&   GetLinkFlt( USHORT nTab ) const;
    const String&   GetLinkOpt( USHORT nTab ) const;
    const String&   GetLinkTab( USHORT nTab ) const;
    ULONG           GetLinkRefreshDelay( USHORT nTab ) const;
    void            SetLink( USHORT nTab, BYTE nMode, const String& rDoc,
                            const String& rFilter, const String& rOptions,
                            const String& rTabName, ULONG nRefreshDelay );
    BOOL            HasLink( const String& rDoc,
                            const String& rFilter, const String& rOptions ) const;
    BOOL            LinkEmptyTab( USHORT& nTab, const String& aDocTab,
                                    const String& aFileName,
                                    const String& aTabName );   // insert empty tab & link
    BOOL            LinkExternalTab( USHORT& nTab, const String& aDocTab,
                                    const String& aFileName,
                                    const String& aTabName );

    BOOL            HasDdeLinks() const;
    BOOL            HasAreaLinks() const;
    void            UpdateDdeLinks();
    void            UpdateAreaLinks();

                    // originating DDE links
    void            IncInDdeLinkUpdate() { if ( nInDdeLinkUpdate < 255 ) ++nInDdeLinkUpdate; }
    void            DecInDdeLinkUpdate() { if ( nInDdeLinkUpdate ) --nInDdeLinkUpdate; }
    BOOL            IsInDdeLinkUpdate() const   { return nInDdeLinkUpdate != 0; }

    void            CopyDdeLinks( ScDocument* pDestDoc ) const;
    void            DisconnectDdeLinks();

                    // Fuer StarOne Api:
    USHORT          GetDdeLinkCount() const;
    BOOL            GetDdeLinkData( USHORT nPos, String& rAppl, String& rTopic, String& rItem ) const;
    BOOL            UpdateDdeLink( const String& rAppl, const String& rTopic, const String& rItem );

                    // For XCL/XML Export (nPos is index of DDE links only):
    BOOL            GetDdeLinkMode(USHORT nPos, USHORT& nMode);
    BOOL            GetDdeLinkResultDimension( USHORT nPos , USHORT& nCol, USHORT& nRow, ScMatrix*& pMatrix);
    BOOL            GetDdeLinkResult(const ScMatrix* pMatrix, USHORT nCol, USHORT nRow, String& rStrValue, double& rDoubValue, BOOL& bIsString);

                    // For XCL/XML Import (nPos is index of DDE links only):
    void            CreateDdeLink(const String& rAppl, const String& rTopic, const String& rItem, const BYTE nMode = SC_DDE_DEFAULT );
    BOOL            FindDdeLink(const String& rAppl, const String& rTopic, const String& rItem, const BYTE nMode, USHORT& nPos );
    BOOL            CreateDdeLinkResultDimension(USHORT nPos, USHORT nCols, USHORT nRows, ScMatrix*& pMatrix);
    void            SetDdeLinkResult(ScMatrix* pMatrix, const USHORT nCol, const USHORT nRow, const String& rStrValue, const double& rDoubValue, BOOL bString, BOOL bEmpty);


    SfxBindings*    GetViewBindings();
    SfxObjectShell* GetDocumentShell() const    { return pShell; }
    ScDrawLayer*    GetDrawLayer()              { return pDrawLayer; }
    SfxBroadcaster* GetDrawBroadcaster();       // zwecks Header-Vermeidung
    void            BeginDrawUndo();

    BOOL            IsChart( SdrObject* pObject );
    void            UpdateAllCharts( BOOL bDoUpdate = TRUE );
    void            UpdateChartRef( UpdateRefMode eUpdateRefMode,
                                    USHORT nCol1, USHORT nRow1, USHORT nTab1,
                                    USHORT nCol2, USHORT nRow2, USHORT nTab2,
                                    short nDx, short nDy, short nDz );
                    //! setzt nur die neue RangeList, keine ChartListener o.ae.
    void            SetChartRangeList( const String& rChartName,
                        const ScRangeListRef& rNewRangeListRef );

    BOOL            HasControl( USHORT nTab, const Rectangle& rMMRect );
    void            InvalidateControls( Window* pWin, USHORT nTab, const Rectangle& rMMRect );

    void            StopAnimations( USHORT nTab, Window* pWin );
    void            StartAnimations( USHORT nTab, Window* pWin );

    BOOL            HasBackgroundDraw( USHORT nTab, const Rectangle& rMMRect );
    BOOL            HasAnyDraw( USHORT nTab, const Rectangle& rMMRect );

    ScOutlineTable* GetOutlineTable( USHORT nTab, BOOL bCreate = FALSE );
    BOOL            SetOutlineTable( USHORT nTab, const ScOutlineTable* pNewOutline );

    void            DoAutoOutline( USHORT nStartCol, USHORT nStartRow,
                                    USHORT nEndCol, USHORT nEndRow, USHORT nTab );

    BOOL            DoSubTotals( USHORT nTab, ScSubTotalParam& rParam );
    void            RemoveSubTotals( USHORT nTab, ScSubTotalParam& rParam );
    BOOL            TestRemoveSubTotals( USHORT nTab, const ScSubTotalParam& rParam );
    BOOL            HasSubTotalCells( const ScRange& rRange );

    void            PutCell( const ScAddress&, ScBaseCell* pCell, BOOL bForceTab = FALSE );
    void            PutCell( const ScAddress&, ScBaseCell* pCell,
                            ULONG nFormatIndex, BOOL bForceTab = FALSE);
    void            PutCell( USHORT nCol, USHORT nRow, USHORT nTab, ScBaseCell* pCell,
                            BOOL bForceTab = FALSE );
    void            PutCell(USHORT nCol, USHORT nRow, USHORT nTab, ScBaseCell* pCell,
                            ULONG nFormatIndex, BOOL bForceTab = FALSE);
                    //  return TRUE = Zahlformat gesetzt
    BOOL            SetString( USHORT nCol, USHORT nRow, USHORT nTab, const String& rString );
    void            SetValue( USHORT nCol, USHORT nRow, USHORT nTab, const double& rVal );
    void            SetNote( USHORT nCol, USHORT nRow, USHORT nTab, const ScPostIt& rNote );
    void            SetError( USHORT nCol, USHORT nRow, USHORT nTab, const USHORT nError);

    void            InsertMatrixFormula(USHORT nCol1, USHORT nRow1,
                                        USHORT nCol2, USHORT nRow2,
                                        const ScMarkData& rMark,
                                        const String& rFormula,
                                        const ScTokenArray* p = NULL );
    void            InsertTableOp(const ScTabOpParam& rParam,   // Mehrfachoperation
                                  USHORT nCol1, USHORT nRow1,
                                  USHORT nCol2, USHORT nRow2, const ScMarkData& rMark);

    void            GetString( USHORT nCol, USHORT nRow, USHORT nTab, String& rString );
    void            GetInputString( USHORT nCol, USHORT nRow, USHORT nTab, String& rString );
    double          GetValue( const ScAddress& );
    void            GetValue( USHORT nCol, USHORT nRow, USHORT nTab, double& rValue );
    double          RoundValueAsShown( double fVal, ULONG nFormat );
    void            GetNumberFormat( USHORT nCol, USHORT nRow, USHORT nTab,
                                     ULONG& rFormat );
    ULONG           GetNumberFormat( const ScAddress& ) const;
                    /// if no number format attribute is set the calculated
                    /// number format of the formula cell is returned
    void            GetNumberFormatInfo( short& nType, ULONG& nIndex,
                        const ScAddress& rPos, const ScFormulaCell& rFCell ) const;
    void            GetFormula( USHORT nCol, USHORT nRow, USHORT nTab, String& rFormula,
                                BOOL bAsciiExport = FALSE ) const;
    BOOL            GetNote( USHORT nCol, USHORT nRow, USHORT nTab, ScPostIt& rNote);
    void            GetCellType( USHORT nCol, USHORT nRow, USHORT nTab, CellType& rCellType ) const;
    CellType        GetCellType( const ScAddress& rPos ) const;
    void            GetCell( USHORT nCol, USHORT nRow, USHORT nTab, ScBaseCell*& rpCell ) const;
    ScBaseCell*     GetCell( const ScAddress& rPos ) const;

    void            RefreshNoteFlags();
    BOOL            HasNoteObject( USHORT nCol, USHORT nRow, USHORT nTab ) const;

    BOOL            HasData( USHORT nCol, USHORT nRow, USHORT nTab );
    BOOL            HasStringData( USHORT nCol, USHORT nRow, USHORT nTab ) const;
    BOOL            HasValueData( USHORT nCol, USHORT nRow, USHORT nTab ) const;
    USHORT          GetErrorData(USHORT nCol, USHORT nRow, USHORT nTab) const;
    BOOL            HasStringCells( const ScRange& rRange ) const;

    BOOL            ExtendMerge( USHORT nStartCol, USHORT nStartRow,
                                USHORT& rEndCol, USHORT& rEndRow, USHORT nTab,
                                BOOL bRefresh = FALSE, BOOL bAttrs = FALSE );
    BOOL            ExtendMerge( ScRange& rRange, BOOL bRefresh = FALSE, BOOL bAttrs = FALSE );
    BOOL            ExtendTotalMerge( ScRange& rRange );
    BOOL            ExtendOverlapped( USHORT& rStartCol, USHORT& rStartRow,
                                USHORT nEndCol, USHORT nEndRow, USHORT nTab );
    BOOL            ExtendOverlapped( ScRange& rRange );

    BOOL            RefreshAutoFilter( USHORT nStartCol, USHORT nStartRow,
                                USHORT nEndCol, USHORT nEndRow, USHORT nTab );

    void            DoMergeContents( USHORT nTab, USHORT nStartCol, USHORT nStartRow,
                                    USHORT nEndCol, USHORT nEndRow );
                    //  ohne Ueberpruefung:
    void            DoMerge( USHORT nTab, USHORT nStartCol, USHORT nStartRow,
                                    USHORT nEndCol, USHORT nEndRow );
    void            RemoveMerge( USHORT nCol, USHORT nRow, USHORT nTab );

    BOOL            IsBlockEmpty( USHORT nTab, USHORT nStartCol, USHORT nStartRow,
                                                USHORT nEndCol, USHORT nEndRow ) const;
    BOOL            IsPrintEmpty( USHORT nTab, USHORT nStartCol, USHORT nStartRow,
                                                USHORT nEndCol, USHORT nEndRow,
                                                BOOL bLeftIsEmpty = FALSE,
                                                ScRange* pLastRange = NULL,
                                                Rectangle* pLastMM = NULL ) const;

    BOOL            IsOverlapped( USHORT nCol, USHORT nRow, USHORT nTab ) const;
    BOOL            IsHorOverlapped( USHORT nCol, USHORT nRow, USHORT nTab ) const;
    BOOL            IsVerOverlapped( USHORT nCol, USHORT nRow, USHORT nTab ) const;

    BOOL            HasAttrib( USHORT nCol1, USHORT nRow1, USHORT nTab1,
                            USHORT nCol2, USHORT nRow2, USHORT nTab2, USHORT nMask );
    BOOL            HasAttrib( const ScRange& rRange, USHORT nMask );

    BOOL            HasLines( const ScRange& rRange, Rectangle& rSizes ) const;

    void            GetBorderLines( USHORT nCol, USHORT nRow, USHORT nTab,
                                    const SvxBorderLine** ppLeft,
                                    const SvxBorderLine** ppTop,
                                    const SvxBorderLine** ppRight,
                                    const SvxBorderLine** ppBottom ) const;

    void            ResetChanged( const ScRange& rRange );

    void            SetDirty();
    void            SetDirty( const ScRange& );
    void            SetDirtyVar();
    void            SetTableOpDirty( const ScRange& );  // for Interpreter TableOp
    void            CalcAll();
    void            CalcAfterLoad();
    void            CompileAll();
    void            CompileXML();

                    // Automatisch Berechnen
    void            SetAutoCalc( BOOL bNewAutoCalc );
    BOOL            GetAutoCalc() const { return bAutoCalc; }
                    // Automatisch Berechnen in/von/fuer ScDocShell disabled
    void            SetAutoCalcShellDisabled( BOOL bNew ) { bAutoCalcShellDisabled = bNew; }
    BOOL            IsAutoCalcShellDisabled() const { return bAutoCalcShellDisabled; }
                    // ForcedFormulas zu berechnen
    void            SetForcedFormulaPending( BOOL bNew ) { bForcedFormulaPending = bNew; }
    BOOL            IsForcedFormulaPending() const { return bForcedFormulaPending; }
                    // if CalcFormulaTree() is currently running
    BOOL            IsCalculatingFormulaTree() { return bCalculatingFormulaTree; }

    void            GetErrCode( USHORT nCol, USHORT nRow, USHORT nTab, USHORT& rErrCode );
    USHORT          GetErrCode( const ScAddress& ) const;

    void            GetDataArea( USHORT nTab, USHORT& rStartCol, USHORT& rStartRow,
                                    USHORT& rEndCol, USHORT& rEndRow, BOOL bIncludeOld );
    BOOL            GetCellArea( USHORT nTab, USHORT& rEndCol, USHORT& rEndRow ) const;
    BOOL            GetTableArea( USHORT nTab, USHORT& rEndCol, USHORT& rEndRow ) const;
    BOOL            GetPrintArea( USHORT nTab, USHORT& rEndCol, USHORT& rEndRow,
                                    BOOL bNotes = TRUE ) const;
    BOOL            GetPrintAreaHor( USHORT nTab, USHORT nStartRow, USHORT nEndRow,
                                        USHORT& rEndCol, BOOL bNotes = TRUE ) const;
    BOOL            GetPrintAreaVer( USHORT nTab, USHORT nStartCol, USHORT nEndCol,
                                        USHORT& rEndRow, BOOL bNotes = TRUE ) const;
    void            InvalidateTableArea();

    BOOL            GetDataStart( USHORT nTab, USHORT& rStartCol, USHORT& rStartRow ) const;

    void            ExtendPrintArea( OutputDevice* pDev, USHORT nTab,
                                    USHORT nStartCol, USHORT nStartRow,
                                    USHORT& rEndCol, USHORT nEndRow );

    USHORT          GetEmptyLinesInBlock( USHORT nStartCol, USHORT nStartRow, USHORT nStartTab,
                                            USHORT nEndCol, USHORT nEndRow, USHORT nEndTab,
                                            ScDirection eDir );

    void            FindAreaPos( USHORT& rCol, USHORT& rRow, USHORT nTab, short nMovX, short nMovY );
    void            GetNextPos( USHORT& rCol, USHORT& rRow, USHORT nTab, short nMovX, short nMovY,
                                BOOL bMarked, BOOL bUnprotected, const ScMarkData& rMark );

    BOOL            GetNextMarkedCell( USHORT& rCol, USHORT& rRow, USHORT nTab,
                                        const ScMarkData& rMark );

    void            LimitChartArea( USHORT nTab, USHORT& rStartCol, USHORT& rStartRow,
                                                    USHORT& rEndCol, USHORT& rEndRow );
    void            LimitChartIfAll( ScRangeListRef& rRangeList );

    BOOL            InsertRow( USHORT nStartCol, USHORT nStartTab,
                               USHORT nEndCol,   USHORT nEndTab,
                               USHORT nStartRow, USHORT nSize, ScDocument* pRefUndoDoc = NULL );
    BOOL            InsertRow( const ScRange& rRange, ScDocument* pRefUndoDoc = NULL );
    void            DeleteRow( USHORT nStartCol, USHORT nStartTab,
                               USHORT nEndCol,   USHORT nEndTab,
                               USHORT nStartRow, USHORT nSize,
                               ScDocument* pRefUndoDoc = NULL, BOOL* pUndoOutline = NULL );
    void            DeleteRow( const ScRange& rRange,
                               ScDocument* pRefUndoDoc = NULL, BOOL* pUndoOutline = NULL );
    BOOL            InsertCol( USHORT nStartRow, USHORT nStartTab,
                               USHORT nEndRow,   USHORT nEndTab,
                               USHORT nStartCol, USHORT nSize, ScDocument* pRefUndoDoc = NULL );
    BOOL            InsertCol( const ScRange& rRange, ScDocument* pRefUndoDoc = NULL );
    void            DeleteCol( USHORT nStartRow, USHORT nStartTab,
                               USHORT nEndRow, USHORT nEndTab,
                               USHORT nStartCol, USHORT nSize,
                               ScDocument* pRefUndoDoc = NULL, BOOL* pUndoOutline = NULL );
    void            DeleteCol( const ScRange& rRange,
                               ScDocument* pRefUndoDoc = NULL, BOOL* pUndoOutline = NULL );

    BOOL            CanInsertRow( const ScRange& rRange ) const;
    BOOL            CanInsertCol( const ScRange& rRange ) const;

    void            FitBlock( const ScRange& rOld, const ScRange& rNew, BOOL bClear = TRUE );
    BOOL            CanFitBlock( const ScRange& rOld, const ScRange& rNew );

    BOOL            IsClipOrUndo() const                        { return bIsClip || bIsUndo; }
    BOOL            IsUndo() const                              { return bIsUndo; }
    BOOL            IsClipboard() const                         { return bIsClip; }
    BOOL            IsUndoEnabled() const                       { return !bImportingXML; }
    void            ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks );
    void            ResetClip( ScDocument* pSourceDoc, USHORT nTab );
    void            SetCutMode( BOOL bCut );
    BOOL            IsCutMode();
    void            SetClipArea( const ScRange& rArea, BOOL bCut = FALSE );

    BOOL            HasOLEObjectsInArea( const ScRange& rRange, const ScMarkData* pTabMark = NULL );

    void            DeleteObjectsInArea( USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2,
                                        const ScMarkData& rMark );
    void            DeleteObjectsInSelection( const ScMarkData& rMark );
    void            DeleteObjects( USHORT nTab );

    void            DeleteArea(USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2,
                            const ScMarkData& rMark, USHORT nDelFlag);
    void            DeleteAreaTab(USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2,
                                USHORT nTab, USHORT nDelFlag);
    void            DeleteAreaTab(const ScRange& rRange, USHORT nDelFlag);
    void            CopyToClip(USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2,
                                BOOL bCut, ScDocument* pClipDoc, BOOL bAllTabs,
                                const ScMarkData* pMarks = NULL,
                                BOOL bKeepScenarioFlags = FALSE, BOOL bIncludeObjects = FALSE);
    void            CopyTabToClip(USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2,
                                USHORT nTab, ScDocument* pClipDoc = NULL);
    void            CopyBlockFromClip( USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2,
                                    const ScMarkData& rMark, short nDx, short nDy,
                                    const ScCopyBlockFromClipParams* pCBFCP );
    void            CopyNonFilteredFromClip( USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2,
                                    const ScMarkData& rMark, short nDx, short nDy,
                                    const ScCopyBlockFromClipParams* pCBFCP );
    void            StartListeningFromClip( USHORT nCol1, USHORT nRow1,
                                        USHORT nCol2, USHORT nRow2,
                                        const ScMarkData& rMark, USHORT nInsFlag );
    void            BroadcastFromClip( USHORT nCol1, USHORT nRow1,
                                    USHORT nCol2, USHORT nRow2,
                                    const ScMarkData& rMark, USHORT nInsFlag );
    void            CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMark,
                                    USHORT nInsFlag,
                                    ScDocument* pRefUndoDoc = NULL,
                                    ScDocument* pClipDoc = NULL,
                                    BOOL bResetCut = TRUE,
                                    BOOL bAsLink = FALSE,
                                    BOOL bIncludeFiltered = TRUE,
                                    BOOL bSkipAttrForEmpty = FALSE );

    void            GetClipArea(USHORT& nClipX, USHORT& nClipY, BOOL bIncludeFiltered);
    void            GetClipStart(USHORT& nClipX, USHORT& nClipY);

    BOOL            HasClipFilteredRows();

    BOOL            IsClipboardSource() const;

    void            TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsLink );

    void            MixDocument( const ScRange& rRange, USHORT nFunction, BOOL bSkipEmpty,
                                    ScDocument* pSrcDoc );

    void            FillTab( const ScRange& rSrcArea, const ScMarkData& rMark,
                                USHORT nFlags, USHORT nFunction,
                                BOOL bSkipEmpty, BOOL bAsLink );
    void            FillTabMarked( USHORT nSrcTab, const ScMarkData& rMark,
                                USHORT nFlags, USHORT nFunction,
                                BOOL bSkipEmpty, BOOL bAsLink );

    void            TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nType );

    void            InitUndo( ScDocument* pSrcDoc, USHORT nTab1, USHORT nTab2,
                                BOOL bColInfo = FALSE, BOOL bRowInfo = FALSE );
    void            AddUndoTab( USHORT nTab1, USHORT nTab2,
                                BOOL bColInfo = FALSE, BOOL bRowInfo = FALSE );

                    //  nicht mehr benutzen:
    void            CopyToDocument(USHORT nCol1, USHORT nRow1, USHORT nTab1,
                                USHORT nCol2, USHORT nRow2, USHORT nTab2,
                                USHORT nFlags, BOOL bMarked, ScDocument* pDestDoc,
                                const ScMarkData* pMarks = NULL, BOOL bColRowFlags = TRUE);
    void            UndoToDocument(USHORT nCol1, USHORT nRow1, USHORT nTab1,
                                USHORT nCol2, USHORT nRow2, USHORT nTab2,
                                USHORT nFlags, BOOL bMarked, ScDocument* pDestDoc,
                                const ScMarkData* pMarks = NULL);

    void            CopyToDocument(const ScRange& rRange,
                                USHORT nFlags, BOOL bMarked, ScDocument* pDestDoc,
                                const ScMarkData* pMarks = NULL, BOOL bColRowFlags = TRUE);
    void            UndoToDocument(const ScRange& rRange,
                                USHORT nFlags, BOOL bMarked, ScDocument* pDestDoc,
                                const ScMarkData* pMarks = NULL);

    void            CopyScenario( USHORT nSrcTab, USHORT nDestTab, BOOL bNewScenario = FALSE );
    BOOL            TestCopyScenario( USHORT nSrcTab, USHORT nDestTab ) const;
    void            MarkScenario( USHORT nSrcTab, USHORT nDestTab,
                                    ScMarkData& rDestMark, BOOL bResetMark = TRUE,
                                    USHORT nNeededBits = 0 ) const;
    BOOL            HasScenarioRange( USHORT nTab, const ScRange& rRange ) const;
    const ScRangeList* GetScenarioRanges( USHORT nTab ) const;

    void            CopyUpdated( ScDocument* pPosDoc, ScDocument* pDestDoc );

    void            UpdateReference( UpdateRefMode eUpdateRefMode, USHORT nCol1, USHORT nRow1, USHORT nTab1,
                                     USHORT nCol2, USHORT nRow2, USHORT nTab2,
                                     short nDx, short nDy, short nDz,
                                     ScDocument* pUndoDoc = NULL, BOOL bIncludeDraw = TRUE );

    void            UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDoc,
                                        const ScMarkData& rMark, ScDocument* pUndoDoc = NULL );

    void            UpdateGrow( const ScRange& rArea, USHORT nGrowX, USHORT nGrowY );

    void            Fill(   USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2,
                            const ScMarkData& rMark,
                            USHORT nFillCount, FillDir eFillDir = FILL_TO_BOTTOM,
                            FillCmd eFillCmd = FILL_LINEAR, FillDateCmd eFillDateCmd = FILL_DAY,
                            double nStepValue = 1.0, double nMaxValue = 1E307);
    String          GetAutoFillPreview( const ScRange& rSource, USHORT nEndX, USHORT nEndY );

    BOOL            GetSelectionFunction( ScSubTotalFunc eFunc,
                                            const ScAddress& rCursor, const ScMarkData& rMark,
                                            double& rResult );

    const SfxPoolItem*      GetAttr( USHORT nCol, USHORT nRow, USHORT nTab, USHORT nWhich ) const;
    const ScPatternAttr*    GetPattern( USHORT nCol, USHORT nRow, USHORT nTab ) const;
    const ScPatternAttr*    GetSelectionPattern( const ScMarkData& rMark, BOOL bDeep = TRUE );
    ScPatternAttr*          CreateSelectionPattern( const ScMarkData& rMark, BOOL bDeep = TRUE );

    const ScConditionalFormat* GetCondFormat( USHORT nCol, USHORT nRow, USHORT nTab ) const;
    const SfxItemSet*   GetCondResult( USHORT nCol, USHORT nRow, USHORT nTab ) const;
    const SfxPoolItem*  GetEffItem( USHORT nCol, USHORT nRow, USHORT nTab, USHORT nWhich ) const;

    const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >& GetBreakIterator();
    BOOL            HasStringWeakCharacters( const String& rString );
    BYTE            GetStringScriptType( const String& rString );
    BYTE            GetCellScriptType( ScBaseCell* pCell, ULONG nNumberFormat );
    BYTE            GetScriptType( USHORT nCol, USHORT nRow, USHORT nTab, ScBaseCell* pCell = NULL );

    BOOL            HasDetectiveOperations() const;
    void            AddDetectiveOperation( const ScDetOpData& rData );
    void            ClearDetectiveOperations();
    ScDetOpList*    GetDetOpList() const                { return pDetOpList; }
    void            SetDetOpList(ScDetOpList* pNew);

    BOOL            HasDetectiveObjects(USHORT nTab) const;

    void            GetSelectionFrame( const ScMarkData& rMark,
                                       SvxBoxItem&      rLineOuter,
                                       SvxBoxInfoItem&  rLineInner );
    void            ApplySelectionFrame( const ScMarkData& rMark,
                                         const SvxBoxItem* pLineOuter,
                                         const SvxBoxInfoItem* pLineInner );
    void            ApplyFrameAreaTab( const ScRange& rRange,
                                         const SvxBoxItem* pLineOuter,
                                         const SvxBoxInfoItem* pLineInner );

    void            ClearSelectionItems( const USHORT* pWhich, const ScMarkData& rMark );
    void            ChangeSelectionIndent( BOOL bIncrement, const ScMarkData& rMark );

    ULONG           AddCondFormat( const ScConditionalFormat& rNew );
    void            FindConditionalFormat( ULONG nKey, ScRangeList& rRanges );
    void            ConditionalChanged( ULONG nKey );
    void            SetConditionalUsed( ULONG nKey );       // beim Speichern

    ULONG           AddValidationEntry( const ScValidationData& rNew );
    void            SetValidationUsed( ULONG nKey );        // beim Speichern

    const ScValidationData* GetValidationEntry( ULONG nIndex ) const;

    ScConditionalFormatList* GetCondFormList() const        // Ref-Undo
                    { return pCondFormList; }
    void            SetCondFormList(ScConditionalFormatList* pNew);

    ScValidationDataList* GetValidationList() const
                    { return pValidationList; }

    void            ApplyAttr( USHORT nCol, USHORT nRow, USHORT nTab,
                                const SfxPoolItem& rAttr );
    void            ApplyPattern( USHORT nCol, USHORT nRow, USHORT nTab,
                                    const ScPatternAttr& rAttr );
    void            ApplyPatternArea( USHORT nStartCol, USHORT nStartRow,
                                        USHORT nEndCol, USHORT nEndRow,
                                        const ScMarkData& rMark, const ScPatternAttr& rAttr );
    void            ApplyPatternAreaTab( USHORT nStartCol, USHORT nStartRow,
                                            USHORT nEndCol, USHORT nEndRow, USHORT nTab,
                                            const ScPatternAttr& rAttr );
    void            ApplyPatternIfNumberformatIncompatible(
                            const ScRange& rRange, const ScMarkData& rMark,
                            const ScPatternAttr& rPattern, short nNewType );

    void            ApplyStyle( USHORT nCol, USHORT nRow, USHORT nTab,
                                const ScStyleSheet& rStyle);
    void            ApplyStyleArea( USHORT nStartCol, USHORT nStartRow,
                                    USHORT nEndCol, USHORT nEndRow,
                                    const ScMarkData& rMark, const ScStyleSheet& rStyle);
    void            ApplyStyleAreaTab( USHORT nStartCol, USHORT nStartRow,
                                        USHORT nEndCol, USHORT nEndRow, USHORT nTab,
                                        const ScStyleSheet& rStyle);

    void            ApplySelectionStyle( const ScStyleSheet& rStyle, const ScMarkData& rMark );
    void            ApplySelectionLineStyle( const ScMarkData& rMark,
                                            const SvxBorderLine* pLine, BOOL bColorOnly );

    const ScStyleSheet* GetStyle( USHORT nCol, USHORT nRow, USHORT nTab ) const;
    const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark ) const;

    void            StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, BOOL bRemoved,
                                        OutputDevice* pDev,
                                        double nPPTX, double nPPTY,
                                        const Fraction& rZoomX, const Fraction& rZoomY );

    BOOL            IsStyleSheetUsed( const ScStyleSheet& rStyle, BOOL bGatherAllStyles ) const;

                    // Rueckgabe TRUE bei ApplyFlags: Wert geaendert
    BOOL            ApplyFlags( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow,
                                    const ScMarkData& rMark, INT16 nFlags );
    BOOL            ApplyFlagsTab( USHORT nStartCol, USHORT nStartRow,
                                            USHORT nEndCol, USHORT nEndRow,
                                            USHORT nTab, INT16 nFlags );
    BOOL            RemoveFlags( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow,
                                    const ScMarkData& rMark, INT16 nFlags );
    BOOL            RemoveFlagsTab( USHORT nStartCol, USHORT nStartRow,
                                            USHORT nEndCol, USHORT nEndRow,
                                            USHORT nTab, INT16 nFlags );

    void            SetPattern( const ScAddress&, const ScPatternAttr& rAttr,
                                    BOOL bPutToPool = FALSE );
    void            SetPattern( USHORT nCol, USHORT nRow, USHORT nTab, const ScPatternAttr& rAttr,
                                    BOOL bPutToPool = FALSE );
    void            DeleteNumberFormat( const ULONG* pDelKeys, ULONG nCount );

    void            AutoFormat( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow,
                                    USHORT nFormatNo, const ScMarkData& rMark );
    void            GetAutoFormatData( USHORT nTab, USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow,
                                        ScAutoFormatData& rData );
    BOOL            SearchAndReplace( const SvxSearchItem& rSearchItem,
                                        USHORT& rCol, USHORT& rRow, USHORT& rTab,
                                        ScMarkData& rMark,
                                        String& rUndoStr, ScDocument* pUndoDoc = NULL );

                    // Col/Row von Folgeaufrufen bestimmen
                    // (z.B. nicht gefunden von Anfang, oder folgende Tabellen)
    static void     GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem,
                        USHORT& rCol, USHORT& rRow );

    BOOL            Solver(USHORT nFCol, USHORT nFRow, USHORT nFTab,
                            USHORT nVCol, USHORT nVRow, USHORT nVTab,
                            const String& sValStr, double& nX);

    void            ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark );
    void            DeleteSelection( USHORT nDelFlag, const ScMarkData& rMark );
    void            DeleteSelectionTab( USHORT nTab, USHORT nDelFlag, const ScMarkData& rMark );

                    //

    void            SetColWidth( USHORT nCol, USHORT nTab, USHORT nNewWidth );
    void            SetRowHeight( USHORT nRow, USHORT nTab, USHORT nNewHeight );
    void            SetRowHeightRange( USHORT nStartRow, USHORT nEndRow, USHORT nTab,
                                            USHORT nNewHeight );
    void            SetManualHeight( USHORT nStartRow, USHORT nEndRow, USHORT nTab, BOOL bManual );

    USHORT          GetColWidth( USHORT nCol, USHORT nTab ) const;
    USHORT          GetRowHeight( USHORT nRow, USHORT nTab ) const;
    ULONG           GetColOffset( USHORT nCol, USHORT nTab ) const;
    ULONG           GetRowOffset( USHORT nRow, USHORT nTab ) const;

    USHORT          GetOriginalWidth( USHORT nCol, USHORT nTab ) const;
    USHORT          GetOriginalHeight( USHORT nRow, USHORT nTab ) const;

    USHORT          GetCommonWidth( USHORT nEndCol, USHORT nTab ) const;

    inline USHORT   FastGetRowHeight( USHORT nRow, USHORT nTab ) const;     // ohne Ueberpruefungen!

    USHORT          GetHiddenRowCount( USHORT nRow, USHORT nTab ) const;

    USHORT          GetOptimalColWidth( USHORT nCol, USHORT nTab, OutputDevice* pDev,
                                        double nPPTX, double nPPTY,
                                        const Fraction& rZoomX, const Fraction& rZoomY,
                                        BOOL bFormula,
                                        const ScMarkData* pMarkData = NULL,
                                        BOOL bSimpleTextImport = FALSE );
    BOOL            SetOptimalHeight( USHORT nStartRow, USHORT nEndRow, USHORT nTab, USHORT nExtra,
                                        OutputDevice* pDev,
                                        double nPPTX, double nPPTY,
                                        const Fraction& rZoomX, const Fraction& rZoomY,
                                        BOOL bShrink );
    long            GetNeededSize( USHORT nCol, USHORT nRow, USHORT nTab,
                                    OutputDevice* pDev,
                                    double nPPTX, double nPPTY,
                                    const Fraction& rZoomX, const Fraction& rZoomY,
                                    BOOL bWidth, BOOL bTotalSize = FALSE );

    void            ShowCol(USHORT nCol, USHORT nTab, BOOL bShow);
    void            ShowRow(USHORT nRow, USHORT nTab, BOOL bShow);
    void            ShowRows(USHORT nRow1, USHORT nRow2, USHORT nTab, BOOL bShow);
    void            SetColFlags( USHORT nCol, USHORT nTab, BYTE nNewFlags );
    void            SetRowFlags( USHORT nRow, USHORT nTab, BYTE nNewFlags );

    BYTE            GetColFlags( USHORT nCol, USHORT nTab ) const;
    BYTE            GetRowFlags( USHORT nRow, USHORT nTab ) const;

                    /// @return  the index of the last column with any set flags (auto-pagebreak is ignored).
    USHORT          GetLastFlaggedCol( USHORT nTab ) const;
                    /// @return  the index of the last row with any set flags (auto-pagebreak is ignored).
    USHORT          GetLastFlaggedRow( USHORT nTab ) const;

                    /// @return  the index of the last changed column (flags and column width, auto pagebreak is ignored).
    USHORT          GetLastChangedCol( USHORT nTab ) const;
                    /// @return  the index of the last changed row (flags and row height, auto pagebreak is ignored).
    USHORT          GetLastChangedRow( USHORT nTab ) const;

    USHORT          GetNextDifferentChangedCol( USHORT nTab, USHORT nStart) const;
    USHORT          GetNextDifferentChangedRow( USHORT nTab, USHORT nStart) const;

    // returns whether to export a Default style for this col/row or not
    // nDefault is setted to one possition in the current row/col where the Default style is
    BOOL            GetColDefault( USHORT nTab, USHORT nCol, USHORT nLastRow, USHORT& nDefault);
    BOOL            GetRowDefault( USHORT nTab, USHORT nRow, USHORT nLastCol, USHORT& nDefault);

    BOOL            IsFiltered( USHORT nRow, USHORT nTab ) const;

    BOOL            UpdateOutlineCol( USHORT nStartCol, USHORT nEndCol, USHORT nTab, BOOL bShow );
    BOOL            UpdateOutlineRow( USHORT nStartRow, USHORT nEndRow, USHORT nTab, BOOL bShow );

    void            StripHidden( USHORT& rX1, USHORT& rY1, USHORT& rX2, USHORT& rY2, USHORT nTab );
    void            ExtendHidden( USHORT& rX1, USHORT& rY1, USHORT& rX2, USHORT& rY2, USHORT nTab );

    ScPatternAttr*      GetDefPattern() const;
    ScDocumentPool*     GetPool();
    ScStyleSheetPool*   GetStyleSheetPool() const;

    // PageStyle:
    const String&   GetPageStyle( USHORT nTab ) const;
    void            SetPageStyle( USHORT nTab, const String& rName );
    Size            GetPageSize( USHORT nTab ) const;
    void            SetPageSize( USHORT nTab, const Size& rSize );
    void            SetRepeatArea( USHORT nTab, USHORT nStartCol, USHORT nEndCol, USHORT nStartRow, USHORT nEndRow );
    void            UpdatePageBreaks();
    void            UpdatePageBreaks( USHORT nTab, const ScRange* pUserArea = NULL );
    void            RemoveManualBreaks( USHORT nTab );
    BOOL            HasManualBreaks( USHORT nTab ) const;

    BOOL            IsPageStyleInUse( const String& rStrPageStyle, USHORT* pInTab = NULL );
    BOOL            RemovePageStyleInUse( const String& rStrPageStyle );
    BOOL            RenamePageStyleInUse( const String& rOld, const String& rNew );
    void            ModifyStyleSheet( SfxStyleSheetBase& rPageStyle,
                                      const SfxItemSet&  rChanges );

    void            PageStyleModified( USHORT nTab, const String& rNewName );

    BOOL            NeedPageResetAfterTab( USHORT nTab ) const;

    // war vorher im PageStyle untergracht. Jetzt an jeder Tabelle:
    BOOL            HasPrintRange();
    USHORT          GetPrintRangeCount( USHORT nTab );
    const ScRange*  GetPrintRange( USHORT nTab, USHORT nPos );
    const ScRange*  GetRepeatColRange( USHORT nTab );
    const ScRange*  GetRepeatRowRange( USHORT nTab );
    void            SetPrintRangeCount( USHORT nTab, USHORT nNew );
    void            SetPrintRange( USHORT nTab, USHORT nPos, const ScRange& rNew );
    void            SetRepeatColRange( USHORT nTab, const ScRange* pNew );
    void            SetRepeatRowRange( USHORT nTab, const ScRange* pNew );
    ScPrintRangeSaver* CreatePrintRangeSaver() const;
    void            RestorePrintRanges( const ScPrintRangeSaver& rSaver );

    Rectangle       GetMMRect( USHORT nStartCol, USHORT nStartRow,
                                USHORT nEndCol, USHORT nEndRow, USHORT nTab );
    ScRange         GetRange( USHORT nTab, const Rectangle& rMMRect );

    BOOL            LoadPool( SvStream& rStream, BOOL bLoadRefCounts );
    BOOL            SavePool( SvStream& rStream ) const;

    BOOL            Load( SvStream& rStream, ScProgress* pProgress );
    BOOL            Save( SvStream& rStream, ScProgress* pProgress ) const;

    void            UpdStlShtPtrsFrmNms();
    void            StylesToNames();

    void            CopyStdStylesFrom( ScDocument* pSrcDoc );

    CharSet         GetSrcCharSet() const   { return eSrcSet; }
    ULONG           GetSrcVersion() const   { return nSrcVer; }
    USHORT          GetSrcMaxRow() const    { return nSrcMaxRow; }

    void            SetLostData();
    BOOL            HasLostData() const     { return bLostData; }

    void            SetSrcCharSet( CharSet eNew )   { eSrcSet = eNew; }
    void            UpdateFontCharSet();

    friend SvStream& operator>>( SvStream& rStream, ScDocument& rDocument );
    friend SvStream& operator<<( SvStream& rStream, const ScDocument& rDocument );

    USHORT          FillInfo( RowInfo* pRowInfo, USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2,
                        USHORT nTab, double nScaleX, double nScaleY,
                        BOOL bPageMode, BOOL bFormulaMode,
                        const ScMarkData* pMarkData = NULL );

    SvNumberFormatter*  GetFormatTable() const;

    void            Sort( USHORT nTab, const ScSortParam& rSortParam, BOOL bKeepQuery );
    USHORT          Query( USHORT nTab, const ScQueryParam& rQueryParam, BOOL bKeepSub );
    BOOL            ValidQuery( USHORT nRow, USHORT nTab, const ScQueryParam& rQueryParam, BOOL* pSpecial = NULL );
    BOOL            CreateQueryParam( USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2,
                                        USHORT nTab, ScQueryParam& rQueryParam );
    void            GetUpperCellString(USHORT nCol, USHORT nRow, USHORT nTab, String& rStr);

    BOOL            GetFilterEntries( USHORT nCol, USHORT nRow, USHORT nTab,
                                TypedStrCollection& rStrings );
    BOOL            GetFilterEntriesArea( USHORT nCol, USHORT nStartRow, USHORT nEndRow,
                                USHORT nTab, TypedStrCollection& rStrings );
    BOOL            GetDataEntries( USHORT nCol, USHORT nRow, USHORT nTab,
                                TypedStrCollection& rStrings, BOOL bLimit = FALSE );
    BOOL            GetFormulaEntries( TypedStrCollection& rStrings );

    BOOL            HasAutoFilter( USHORT nCol, USHORT nRow, USHORT nTab );

    BOOL            HasColHeader( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow,
                                    USHORT nTab );
    BOOL            HasRowHeader( USHORT nStartCol, USHORT nStartRow, USHORT nEndCol, USHORT nEndRow,
                                    USHORT nTab );

    SfxPrinter*     GetPrinter();
    void            SetPrinter( SfxPrinter* pNewPrinter );
    void            EraseNonUsedSharedNames(USHORT nLevel);
    BOOL            GetNextSpellingCell(USHORT& nCol, USHORT& nRow, USHORT nTab,
                                        BOOL bInSel, const ScMarkData& rMark) const;

    BOOL            ReplaceStyle(const SvxSearchItem& rSearchItem,
                                 USHORT nCol, USHORT nRow, USHORT nTab,
                                 ScMarkData& rMark, BOOL bIsUndo);

    void            DoColResize( USHORT nTab, USHORT nCol1, USHORT nCol2, USHORT nAdd );

    // Idleberechnung der OutputDevice-Zelltextbreite
    BOOL            IsLoadingDone() const { return bLoadingDone; }
    void            InvalidateTextWidth( const String& rStyleName );
    void            InvalidateTextWidth( USHORT nTab );
    void            InvalidateTextWidth( const ScAddress* pAdrFrom = NULL,
                                         const ScAddress* pAdrTo   = NULL,
                                         BOOL bBroadcast = FALSE );

    BOOL            IdleCalcTextWidth();
    BOOL            IdleCheckLinks();

    BOOL            ContinueOnlineSpelling();   // TRUE = etwas gefunden

    BOOL            IsIdleDisabled() const      { return bIdleDisabled; }
    void            DisableIdle(BOOL bDo)       { bIdleDisabled = bDo; }

    BOOL            IsDetectiveDirty() const     { return bDetectiveDirty; }
    void            SetDetectiveDirty(BOOL bSet) { bDetectiveDirty = bSet; }

    void            RemoveAutoSpellObj();
    void            SetOnlineSpellPos( const ScAddress& rPos );
    BOOL            SetVisibleSpellRange( const ScRange& rRange );  // TRUE = changed

    BYTE            GetMacroCallMode() const     { return nMacroCallMode; }
    void            SetMacroCallMode(BYTE nNew)  { nMacroCallMode = nNew; }

    BOOL            GetHasMacroFunc() const      { return bHasMacroFunc; }
    void            SetHasMacroFunc(BOOL bSet)   { bHasMacroFunc = bSet; }

    BOOL            HasMacroCallsAfterLoad();
    BOOL            CheckMacroWarn();

    // fuer Broadcasting/Listening
    void            SetNoSetDirty( BOOL bVal ) { bNoSetDirty = bVal; }
    BOOL            GetNoSetDirty() const { return bNoSetDirty; }
    void            SetInsertingFromOtherDoc( BOOL bVal ) { bInsertingFromOtherDoc = bVal; }
    BOOL            IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc; }
    void            SetImportingXML( BOOL bVal );
    BOOL            IsImportingXML() const { return bImportingXML; }
    void            SetCalcingAfterLoad( BOOL bVal ) { bCalcingAfterLoad = bVal; }
    BOOL            IsCalcingAfterLoad() const { return bCalcingAfterLoad; }
    void            SetNoListening( BOOL bVal ) { bNoListening = bVal; }
    BOOL            GetNoListening() const { return bNoListening; }

    ScChartListenerCollection* GetChartListenerCollection() const
                        { return pChartListenerCollection; }
    void            SetChartListenerCollection( ScChartListenerCollection*,
                        BOOL bSetChartRangeLists = FALSE );
    void            UpdateChart( const String& rName, Window* pWin );
    void            UpdateChartListenerCollection();
    BOOL            IsChartListenerCollectionNeedsUpdate() const
                        { return bChartListenerCollectionNeedsUpdate; }
    void            SetChartListenerCollectionNeedsUpdate( BOOL bFlg )
                        { bChartListenerCollectionNeedsUpdate = bFlg; }
    void            AddOLEObjectToCollection(const String& rName);

    ScChangeViewSettings* GetChangeViewSettings() const     { return pChangeViewSettings; }
    void                SetChangeViewSettings(const ScChangeViewSettings& rNew);

    vos::ORef<SvxForbiddenCharactersTable> GetForbiddenCharacters();
    void            SetForbiddenCharacters( const vos::ORef<SvxForbiddenCharactersTable> xNew );

    BYTE            GetAsianCompression() const;        // CharacterCompressionType values
    BOOL            IsValidAsianCompression() const;
    void            SetAsianCompression(BYTE nNew);

    BOOL            GetAsianKerning() const;
    BOOL            IsValidAsianKerning() const;
    void            SetAsianKerning(BOOL bNew);

    BYTE            GetEditTextDirection(USHORT nTab) const;    // EEHorizontalTextDirection values

    ScLkUpdMode     GetLinkMode() const             { return eLinkMode ;}
    void            SetLinkMode( ScLkUpdMode nSet ) {   eLinkMode  = nSet;}


private:
    void                SetAutoFilterFlags();
    void                FindMaxRotCol( USHORT nTab, RowInfo* pRowInfo, USHORT nArrCount,
                                        USHORT nX1, USHORT nX2 ) const;

    USHORT              RowDifferences( USHORT nThisRow, USHORT nThisTab,
                                        ScDocument& rOtherDoc,
                                        USHORT nOtherRow, USHORT nOtherTab,
                                        USHORT nMaxCol, USHORT* pOtherCols );
    USHORT              ColDifferences( USHORT nThisCol, USHORT nThisTab,
                                        ScDocument& rOtherDoc,
                                        USHORT nOtherCol, USHORT nOtherTab,
                                        USHORT nMaxRow, USHORT* pOtherRows );
    void                FindOrder( USHORT* pOtherRows, USHORT nThisEndRow, USHORT nOtherEndRow,
                                        BOOL bColumns,
                                        ScDocument& rOtherDoc, USHORT nThisTab, USHORT nOtherTab,
                                        USHORT nEndCol, USHORT* pTranslate,
                                        ScProgress* pProgress, ULONG nProAdd );
    BOOL                OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpellPos,
                                        USHORT nMaxTest );

    DECL_LINK( TrackTimeHdl, Timer* );

public:
    void                StartListeningArea( const ScRange& rRange,
                                            SfxListener* pListener );
    void                EndListeningArea( const ScRange& rRange,
                                            SfxListener* pListener );
                        /** Broadcast wrapper, calls
                            rHint.GetCell()->Broadcast() and AreaBroadcast()
                            and TrackFormulas() and conditional format list
                            SourceChanged().
                            Preferred.
                         */
    void                Broadcast( const ScHint& rHint );
                        /// deprecated
    void                Broadcast( ULONG nHint, const ScAddress& rAddr,
                                    ScBaseCell* pCell );
                        /// only area, no cell broadcast
    void                AreaBroadcast( const ScHint& rHint );
                        /// only areas in range, no cell broadcasts
    void                AreaBroadcastInRange( const ScRange& rRange,
                                              const ScHint& rHint );
    void                DelBroadcastAreasInRange( const ScRange& rRange );
    void                UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode,
                                            const ScRange& rRange,
                                            short nDx, short nDy, short nDz );


    void                StartListeningCell( const ScAddress& rAddress,
                                            SfxListener* pListener );
    void                EndListeningCell( const ScAddress& rAddress,
                                            SfxListener* pListener );
    void                PutInFormulaTree( ScFormulaCell* pCell );
    void                RemoveFromFormulaTree( ScFormulaCell* pCell );
    void                CalcFormulaTree( BOOL bOnlyForced = FALSE,
                                        BOOL bNoProgressBar = FALSE );
    void                ClearFormulaTree();
    void                AppendToFormulaTrack( ScFormulaCell* pCell );
    void                RemoveFromFormulaTrack( ScFormulaCell* pCell );
    void                TrackFormulas( ULONG nHintId = SC_HINT_DATACHANGED );
    USHORT              GetFormulaTrackCount() const { return nFormulaTrackCount; }
    BOOL                IsInFormulaTree( ScFormulaCell* pCell ) const;
    BOOL                IsInFormulaTrack( ScFormulaCell* pCell ) const;
    USHORT              GetHardRecalcState() { return nHardRecalcState; }
    void                SetHardRecalcState( USHORT nVal ) { nHardRecalcState = nVal; }
    void                StartAllListeners();
    const ScFormulaCell*    GetFormulaTree() const { return pFormulaTree; }
    BOOL                HasForcedFormulas() const { return bHasForcedFormulas; }
    void                SetForcedFormulas( BOOL bVal ) { bHasForcedFormulas = bVal; }
    ULONG               GetFormulaCodeInTree() const { return nFormulaCodeInTree; }
    BOOL                IsInInterpreter() const { return nInterpretLevel != 0; }
    USHORT              GetInterpretLevel() { return nInterpretLevel; }
    void                IncInterpretLevel()
                            {
                                if ( nInterpretLevel < USHRT_MAX )
                                    nInterpretLevel++;
                            }
    void                DecInterpretLevel()
                            {
                                if ( nInterpretLevel )
                                    nInterpretLevel--;
                            }
    BOOL                IsInMacroInterpreter() const { return nMacroInterpretLevel != 0; }
    USHORT              GetMacroInterpretLevel() { return nMacroInterpretLevel; }
    void                IncMacroInterpretLevel()
                            {
                                if ( nMacroInterpretLevel < USHRT_MAX )
                                    nMacroInterpretLevel++;
                            }
    void                DecMacroInterpretLevel()
                            {
                                if ( nMacroInterpretLevel )
                                    nMacroInterpretLevel--;
                            }
    BOOL                IsInInterpreterTableOp() const { return nInterpreterTableOpLevel != 0; }
    USHORT              GetInterpreterTableOpLevel() { return nInterpreterTableOpLevel; }
    void                IncInterpreterTableOpLevel()
                            {
                                if ( nInterpreterTableOpLevel < USHRT_MAX )
                                    nInterpreterTableOpLevel++;
                            }
    void                DecInterpreterTableOpLevel()
                            {
                                if ( nInterpreterTableOpLevel )
                                    nInterpreterTableOpLevel--;
                            }
                        // add a formula to be remembered for TableOp broadcasts
    void                AddTableOpFormulaCell( ScFormulaCell* );
    void                InvalidateLastTableOpParams() { aLastTableOpParams.bValid = FALSE; }
    BOOL                IsInDtorClear() const { return bInDtorClear; }
    void                SetExpandRefs( BOOL bVal ) { bExpandRefs = bVal; }
    BOOL                IsExpandRefs() { return bExpandRefs; }

    void                IncSizeRecalcLevel( USHORT nTab );
    void                DecSizeRecalcLevel( USHORT nTab );

    ULONG               GetXMLImportedFormulaCount() const { return nXMLImportedFormulaCount; }
    void                IncXMLImportedFormulaCount( ULONG nVal )
                            {
                                if ( nXMLImportedFormulaCount + nVal > nXMLImportedFormulaCount )
                                    nXMLImportedFormulaCount += nVal;
                            }
    void                DecXMLImportedFormulaCount( ULONG nVal )
                            {
                                if ( nVal <= nXMLImportedFormulaCount )
                                    nXMLImportedFormulaCount -= nVal;
                                else
                                    nXMLImportedFormulaCount = 0;
                            }

    void                StartTrackTimer();

    void            CompileDBFormula();
    void            CompileDBFormula( BOOL bCreateFormulaString );
    void            CompileNameFormula( BOOL bCreateFormulaString );
    void            CompileColRowNameFormula();

    // maximale Stringlaengen einer Column, fuer z.B. dBase Export
    xub_StrLen      GetMaxStringLen( USHORT nTab, USHORT nCol,
                                    USHORT nRowStart, USHORT nRowEnd ) const;
    xub_StrLen      GetMaxNumberStringLen( USHORT& nPrecision,
                                    USHORT nTab, USHORT nCol,
                                    USHORT nRowStart, USHORT nRowEnd ) const;

    void    KeyInput( const KeyEvent& rKEvt );      // TimerDelays etc.

    ScChangeTrack*      GetChangeTrack() const { return pChangeTrack; }

    //! only for import filter, deletes any existing ChangeTrack via
    //! EndChangeTracking() and takes ownership of new ChangeTrack pTrack
    void            SetChangeTrack( ScChangeTrack* pTrack );

    void            StartChangeTracking();
    void            EndChangeTracking();

    void            CompareDocument( ScDocument& rOtherDoc );

    void            AddUnoObject( SfxListener& rObject );
    void            RemoveUnoObject( SfxListener& rObject );
    void            BroadcastUno( const SfxHint &rHint );

    void            SetInLinkUpdate(BOOL bSet);             // TableLink or AreaLink
    BOOL            IsInLinkUpdate() const;                 // including DdeLink

    SfxItemPool*        GetEditPool() const;
    SfxItemPool*        GetEnginePool() const;
    ScFieldEditEngine&  GetEditEngine();

    void            AddToImpExpLog( const ScImpExpLogMsg& rMsg );
    void            AddToImpExpLog( ScImpExpLogMsg* pMsg );

    ScRefreshTimerControl*  GetRefreshTimerControl() const
        { return pRefreshTimerControl; }
    ScRefreshTimerControl * const * GetRefreshTimerControlAddress() const
        { return &pRefreshTimerControl; }

                    /// if symbol string cells of old binary file format are in list
    BOOL            SymbolStringCellsPending() const;
                    /// get list of ScSymbolStringCellEntry, create if necessary
    List&           GetLoadedSymbolStringCellsList();

    void            SetPastingDrawFromOtherDoc( BOOL bVal )
                        { bPastingDrawFromOtherDoc = bVal; }
    BOOL            PastingDrawFromOtherDoc() const
                        { return bPastingDrawFromOtherDoc; }

                    /// an ID unique to each document instance
    sal_uInt32      GetDocumentID() const;

    void            InvalidateStyleSheetUsage()
                        { bStyleSheetUsageInvalid = TRUE; }

private: // CLOOK-Impl-Methoden
    void    ImplLoadDocOptions( SvStream& rStream );
    void    ImplLoadViewOptions( SvStream& rStream );
    void    ImplSaveDocOptions( SvStream& rStream ) const;
    void    ImplSaveViewOptions( SvStream& rStream ) const;
    void    ImplCreateOptions(); // bei Gelegenheit auf on-demand umstellen?
    void    ImplDeleteOptions();

    void    DeleteDrawLayer();
    void    DeleteColorTable();
    void    LoadDrawLayer(SvStream& rStream);
    void    StoreDrawLayer(SvStream& rStream) const;
    BOOL    DrawGetPrintArea( ScRange& rRange, BOOL bSetHor, BOOL bSetVer ) const;
    void    DrawMovePage( USHORT nOldPos, USHORT nNewPos );
    void    DrawCopyPage( USHORT nOldPos, USHORT nNewPos );

    void    UpdateDrawPrinter();
    void    UpdateDrawLanguages();
    void    InitClipPtrs( ScDocument* pSourceDoc );

    void    LoadDdeLinks(SvStream& rStream);
    void    SaveDdeLinks(SvStream& rStream) const;
    void    LoadAreaLinks(SvStream& rStream);
    void    SaveAreaLinks(SvStream& rStream) const;

    void    UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
                             const ScRange& r, short nDx, short nDy, short nDz );

    BOOL    HasPartOfMerged( const ScRange& rRange );

};


inline USHORT ScDocument::FastGetRowHeight( USHORT nRow, USHORT nTab ) const
{
    return ( pTab[nTab]->pRowFlags[nRow] & CR_HIDDEN ) ? 0 : pTab[nTab]->pRowHeight[nRow];
}



#endif