xref: /trunk/main/sc/inc/document.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2011 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_DOCUMENT_HXX
29 #define SC_DOCUMENT_HXX
30 
31 
32 #include <vcl/prntypes.hxx>
33 #include <vcl/timer.hxx>
34 #include <com/sun/star/uno/Reference.hxx>
35 #include <vos/ref.hxx>
36 #include "scdllapi.h"
37 #include "table.hxx"        // FastGetRowHeight (inline)
38 #include "rangelst.hxx"
39 #include "brdcst.hxx"
40 #include "tabopparams.hxx"
41 #include "formula/grammar.hxx"
42 #include <com/sun/star/chart2/XChartDocument.hpp>
43 #include "scdllapi.h"
44 
45 #include <memory>
46 #include <map>
47 #include <set>
48 
49 // Wang Xu Ming -- 2009-8-17
50 // DataPilot Migration - Cache&&Performance
51 #include <list>
52 class ScDPTableDataCache;
53 // End Comments
54 
55 class KeyEvent;
56 class OutputDevice;
57 class SdrObject;
58 class SfxBroadcaster;
59 class SfxListener;
60 class SfxHint;
61 class SfxItemSet;
62 class SfxObjectShell;
63 class SfxBindings;
64 class SfxPoolItem;
65 class SfxItemPool;
66 class SfxPrinter;
67 class SfxStatusBarManager;
68 class SfxStyleSheetBase;
69 class SvMemoryStream;
70 class SvNumberFormatter;
71 class SvxBorderLine;
72 class SvxBoxInfoItem;
73 class SvxBoxItem;
74 class SvxBrushItem;
75 class SvxForbiddenCharactersTable;
76 namespace sfx2 {
77     class LinkManager;
78     }
79 class SvxSearchItem;
80 class SvxShadowItem;
81 class Window;
82 class XColorTable;
83 class List;
84 
85 class ScAutoFormatData;
86 class ScBaseCell;
87 class ScStringCell;
88 class ScBroadcastAreaSlotMachine;
89 class ScChangeViewSettings;
90 class ScChartCollection;
91 class ScChartListenerCollection;
92 class ScConditionalFormat;
93 class ScConditionalFormatList;
94 class ScDBCollection;
95 class ScDBData;
96 class ScDetOpData;
97 class ScDetOpList;
98 class ScDocOptions;
99 class ScDocProtection;
100 class ScDocumentPool;
101 class ScDrawLayer;
102 class ScExtDocOptions;
103 class ScExternalRefManager;
104 class ScFormulaCell;
105 class ScMarkData;
106 class ScOutlineTable;
107 class ScPatternAttr;
108 class ScPrintRangeSaver;
109 class ScRangeData;
110 class ScRangeName;
111 class ScStyleSheet;
112 class ScStyleSheetPool;
113 class ScTable;
114 class ScTableProtection;
115 class ScTokenArray;
116 class ScValidationData;
117 class ScValidationDataList;
118 class ScViewOptions;
119 class ScStrCollection;
120 class TypedScStrCollection;
121 class ScChangeTrack;
122 class ScEditEngineDefaulter;
123 class ScFieldEditEngine;
124 class ScNoteEditEngine;
125 struct ScConsolidateParam;
126 class ScDPObject;
127 class ScDPCollection;
128 class ScMatrix;
129 class ScScriptTypeData;
130 class ScPoolHelper;
131 struct ScSortParam;
132 class ScRefreshTimerControl;
133 class ScUnoListenerCalls;
134 class ScUnoRefList;
135 class ScRecursionHelper;
136 struct RowInfo;
137 struct ScTableInfo;
138 struct ScTabOpParam;
139 class VirtualDevice;
140 class ScAutoNameCache;
141 class ScTemporaryChartLock;
142 class ScLookupCache;
143 struct ScLookupCacheMapImpl;
144 class SfxUndoManager;
145 class ScFormulaParserPool;
146 struct ScClipParam;
147 struct ScClipRangeNameData;
148 class ScRowBreakIterator;
149 
150 namespace com { namespace sun { namespace star {
151     namespace lang {
152         class XMultiServiceFactory;
153         struct EventObject;
154     }
155     namespace i18n {
156         class XBreakIterator;
157     }
158     namespace util {
159         class XModifyListener;
160     }
161     namespace embed {
162         class XEmbeddedObject;
163     }
164     namespace script { namespace vba {
165         class XVBAEventProcessor;
166     } }
167     namespace sheet {
168         struct TablePageBreakData;
169     }
170 } } }
171 
172 #include <svl/zforlist.hxx>
173 /*
174 #ifdef _ZFORLIST_DECLARE_TABLE
175 class SvNumberFormatterIndexTable;
176 #else
177 class Table;
178 typedef Table SvNumberFormatterIndexTable;
179 #endif
180 */
181 
182 #define SC_DOC_NEW          0xFFFF
183 
184 #define SC_MACROCALL_ALLOWED        0
185 #define SC_MACROCALL_NOTALLOWED     1
186 #define SC_MACROCALL_ASK            2
187 
188 #define SC_ASIANCOMPRESSION_INVALID     0xff
189 #define SC_ASIANKERNING_INVALID         0xff
190 
191 
192 enum ScDocumentMode
193     {
194         SCDOCMODE_DOCUMENT,
195         SCDOCMODE_CLIP,
196         SCDOCMODE_UNDO
197     };
198 
199 
200 struct ScDocStat
201 {
202     String  aDocName;
203     SCTAB   nTableCount;
204     sal_uLong   nCellCount;
205     sal_uInt16  nPageCount;
206 };
207 
208 // The constant parameters to CopyBlockFromClip
209 struct ScCopyBlockFromClipParams
210 {
211     ScDocument* pRefUndoDoc;
212     ScDocument* pClipDoc;
213     sal_uInt16      nInsFlag;
214     SCTAB       nTabStart;
215     SCTAB       nTabEnd;
216     sal_Bool        bAsLink;
217     sal_Bool        bSkipAttrForEmpty;
218 };
219 
220 
221 // for loading of binary file format symbol string cells which need font conversion
222 struct ScSymbolStringCellEntry
223 {
224     ScStringCell*   pCell;
225     SCROW           nRow;
226 };
227 
228 
229 // -----------------------------------------------------------------------
230 
231 // DDE link modes
232 const sal_uInt8 SC_DDE_DEFAULT       = 0;
233 const sal_uInt8 SC_DDE_ENGLISH       = 1;
234 const sal_uInt8 SC_DDE_TEXT          = 2;
235 const sal_uInt8 SC_DDE_IGNOREMODE    = 255;       /// For usage in FindDdeLink() only!
236 
237 
238 // -----------------------------------------------------------------------
239 
240 class ScDocument
241 {
242 friend class ScDocumentIterator;
243 friend class ScValueIterator;
244 friend class ScHorizontalValueIterator;
245 friend class ScDBQueryDataIterator;
246 friend class ScCellIterator;
247 friend class ScQueryCellIterator;
248 friend class ScHorizontalCellIterator;
249 friend class ScHorizontalAttrIterator;
250 friend class ScDocAttrIterator;
251 friend class ScAttrRectIterator;
252 friend class ScDocShell;
253 
254 private:
255     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager;
256 
257     vos::ORef<ScPoolHelper> xPoolHelper;
258 
259     SfxUndoManager*     mpUndoManager;
260     ScFieldEditEngine*  pEditEngine;                    // uses pEditPool from xPoolHelper
261     ScNoteEditEngine*   pNoteEngine;                    // uses pEditPool from xPoolHelper
262     SfxItemPool*    pNoteItemPool; // SfxItemPool to be used if pDrawLayer not created.
263     SfxObjectShell*     pShell;
264     SfxPrinter*         pPrinter;
265     VirtualDevice*      pVirtualDevice_100th_mm;
266     ScDrawLayer*        pDrawLayer;                     // SdrModel
267     XColorTable*        pColorTable;
268     ScConditionalFormatList* pCondFormList;             // bedingte Formate
269     ScValidationDataList* pValidationList;              // Gueltigkeit
270     SvNumberFormatterIndexTable*    pFormatExchangeList;            // zum Umsetzen von Zahlenformaten
271     ScTable*            pTab[MAXTABCOUNT];
272     ScRangeName*        pRangeName;
273     ScDBCollection*     pDBCollection;
274     ScDPCollection*     pDPCollection;
275     // Wang Xu Ming -- 2009-8-17
276     // DataPilot Migration - Cache&&Performance
277     std::list<ScDPTableDataCache*>   m_listDPObjectsCaches;
278     // End Comments
279     ScChartCollection*  pChartCollection;
280     std::auto_ptr< ScTemporaryChartLock > apTemporaryChartLock;
281     ScPatternAttr*      pSelectionAttr;                 // Attribute eines Blocks
282     mutable sfx2::LinkManager*      pLinkManager;
283     ScFormulaCell*      pFormulaTree;                   // Berechnungsbaum Start
284     ScFormulaCell*      pEOFormulaTree;                 // Berechnungsbaum Ende, letzte Zelle
285     ScFormulaCell*      pFormulaTrack;                  // BroadcastTrack Start
286     ScFormulaCell*      pEOFormulaTrack;                // BrodcastTrack Ende, letzte Zelle
287     ScBroadcastAreaSlotMachine* pBASM;                  // BroadcastAreas
288     ScChartListenerCollection* pChartListenerCollection;
289     ScStrCollection*        pOtherObjects;                  // non-chart OLE objects
290     SvMemoryStream*     pClipData;
291     ScDetOpList*        pDetOpList;
292     ScChangeTrack*      pChangeTrack;
293     SfxBroadcaster*     pUnoBroadcaster;
294     ScUnoListenerCalls* pUnoListenerCalls;
295     ScUnoRefList*       pUnoRefUndoList;
296     ScChangeViewSettings* pChangeViewSettings;
297     ScScriptTypeData*   pScriptTypeData;
298     ScRefreshTimerControl* pRefreshTimerControl;
299     vos::ORef<SvxForbiddenCharactersTable> xForbiddenCharacters;
300 
301     ScFieldEditEngine*  pCacheFieldEditEngine;
302 
303     ::std::auto_ptr<ScDocProtection> pDocProtection;
304     ::std::auto_ptr<ScClipParam>     mpClipParam;
305 
306     ::std::auto_ptr<ScExternalRefManager> pExternalRefMgr;
307 
308     // mutable for lazy construction
309     mutable ::std::auto_ptr< ScFormulaParserPool >
310                         mxFormulaParserPool;            /// Pool for all external formula parsers used by this document.
311 
312     String              aDocName;                       // opt: Dokumentname
313     String              aDocCodeName;                       // opt: Dokumentname
314     ScRangePairListRef  xColNameRanges;
315     ScRangePairListRef  xRowNameRanges;
316 
317     ScViewOptions*      pViewOptions;                   // View-Optionen
318     ScDocOptions*       pDocOptions;                    // Dokument-Optionen
319     ScExtDocOptions*    pExtDocOptions;                 // fuer Import etc.
320     ScConsolidateParam* pConsolidateDlgData;
321 
322     ScRecursionHelper*  pRecursionHelper;               // information for recursive and iterative cell formulas
323 
324     ScAutoNameCache*    pAutoNameCache;                 // for automatic name lookup during CompileXML
325 
326     ScLookupCacheMapImpl* pLookupCacheMapImpl;          // cache for lookups like VLOOKUP and MATCH
327 
328     sal_Int64           nUnoObjectId;                   // counted up for UNO objects
329 
330     sal_uInt32          nRangeOverflowType;             // used in (xml) loading for overflow warnings
331 
332     ScRange             aEmbedRange;
333     ScAddress           aCurTextWidthCalcPos;
334     ScAddress           aOnlineSpellPos;                // within whole document
335     ScRange             aVisSpellRange;
336     ScAddress           aVisSpellPos;                   // within aVisSpellRange (see nVisSpellState)
337 
338     Timer               aTrackTimer;
339 
340     com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor >
341                         mxVbaEvents;
342 
343 public:
344     ScTabOpList         aTableOpList;                   // list of ScInterpreterTableOpParams currently in use
345     ScInterpreterTableOpParams  aLastTableOpParams;     // remember last params
346 private:
347 
348     LanguageType        eLanguage;                      // default language
349     LanguageType        eCjkLanguage;                   // default language for asian text
350     LanguageType        eCtlLanguage;                   // default language for complex text
351     CharSet             eSrcSet;                        // Einlesen: Quell-Zeichensatz
352 
353     /** The compiler grammar used in document storage. GRAM_PODF for ODF 1.1
354         documents, GRAM_ODFF for ODF 1.2 documents. */
355     formula::FormulaGrammar::Grammar  eStorageGrammar;
356 
357     /** The compiler grammar used in ODF import after brackets had been
358         stripped (which they shouldn't, but until that's fixed) by the XML
359         importer. */
360     formula::FormulaGrammar::Grammar  eXmlImportGrammar;
361 
362     sal_uLong               nFormulaCodeInTree;             // FormelRPN im Formelbaum
363     sal_uLong               nXMLImportedFormulaCount;        // progress count during XML import
364     sal_uInt16              nInterpretLevel;                // >0 wenn im Interpreter
365     sal_uInt16              nMacroInterpretLevel;           // >0 wenn Macro im Interpreter
366     sal_uInt16              nInterpreterTableOpLevel;       // >0 if in Interpreter TableOp
367     SCTAB               nMaxTableNumber;
368     sal_uInt16              nSrcVer;                        // Dateiversion (Laden/Speichern)
369     SCROW               nSrcMaxRow;                     // Zeilenzahl zum Laden/Speichern
370     sal_uInt16              nFormulaTrackCount;
371     sal_uInt16              nHardRecalcState;               // 0: soft, 1: hard-warn, 2: hard
372     SCTAB               nVisibleTab;                    // fuer OLE etc.
373 
374     ScLkUpdMode         eLinkMode;
375 
376     sal_Bool                bAutoCalc;                      // Automatisch Berechnen
377     sal_Bool                bAutoCalcShellDisabled;         // in/von/fuer ScDocShell disabled
378     // ob noch ForcedFormulas berechnet werden muessen,
379     // im Zusammenspiel mit ScDocShell SetDocumentModified,
380     // AutoCalcShellDisabled und TrackFormulas
381     sal_Bool                bForcedFormulaPending;
382     sal_Bool                bCalculatingFormulaTree;
383     sal_Bool                bIsClip;
384     sal_Bool                bIsUndo;
385     sal_Bool                bIsVisible;                     // set from view ctor
386 
387     sal_Bool                bIsEmbedded;                    // Embedded-Bereich anzeigen/anpassen ?
388 
389     // kein SetDirty bei ScFormulaCell::CompileTokenArray sondern am Ende
390     // von ScDocument::CompileAll[WithFormats], CopyScenario, CopyBlockFromClip
391     sal_Bool                bNoSetDirty;
392     // kein Broadcast, keine Listener aufbauen waehrend aus einem anderen
393     // Doc (per Filter o.ae.) inserted wird, erst bei CompileAll / CalcAfterLoad
394     sal_Bool                bInsertingFromOtherDoc;
395     bool                bLoadingMedium;
396     bool                bImportingXML;      // special handling of formula text
397     sal_Bool                bXMLFromWrapper;    // distinguish ScXMLImportWrapper from external component
398     sal_Bool                bCalcingAfterLoad;              // in CalcAfterLoad TRUE
399     // wenn temporaer keine Listener auf/abgebaut werden sollen
400     sal_Bool                bNoListening;
401     sal_Bool                bIdleDisabled;
402     sal_Bool                bInLinkUpdate;                  // TableLink or AreaLink
403     sal_Bool                bChartListenerCollectionNeedsUpdate;
404     // ob RC_FORCED Formelzellen im Dokument sind/waren (einmal an immer an)
405     sal_Bool                bHasForcedFormulas;
406     // ob das Doc gerade zerstoert wird (kein Notify-Tracking etc. mehr)
407     sal_Bool                bInDtorClear;
408     // ob bei Spalte/Zeile einfuegen am Rand einer Referenz die Referenz
409     // erweitert wird, wird in jedem UpdateReference aus InputOptions geholt,
410     // gesetzt und am Ende von UpdateReference zurueckgesetzt
411     sal_Bool                bExpandRefs;
412     // fuer Detektiv-Update, wird bei jeder Aenderung an Formeln gesetzt
413     sal_Bool                bDetectiveDirty;
414 
415     sal_uInt8               nMacroCallMode;     // Makros per Warnung-Dialog disabled?
416     sal_Bool                bHasMacroFunc;      // valid only after loading
417 
418     sal_uInt8               nVisSpellState;
419 
420     sal_uInt8               nAsianCompression;
421     sal_uInt8               nAsianKerning;
422     sal_Bool                bSetDrawDefaults;
423 
424     sal_Bool                bPastingDrawFromOtherDoc;
425 
426     sal_uInt8                nInDdeLinkUpdate;   // originating DDE links (stacked bool)
427 
428     sal_Bool                bInUnoBroadcast;
429     sal_Bool                bInUnoListenerCall;
430     formula::FormulaGrammar::Grammar  eGrammar;
431 
432     mutable sal_Bool        bStyleSheetUsageInvalid;
433 
434     bool                mbUndoEnabled;
435     bool                mbAdjustHeightEnabled;
436     bool                mbExecuteLinkEnabled;
437     bool                mbChangeReadOnlyEnabled;    // allow changes in read-only document (for API import filters)
438     bool                mbStreamValidLocked;
439 
440     sal_Int16           mnNamedRangesLockCount;
441 
442 public:
443     SC_DLLPUBLIC sal_uLong          GetCellCount() const;       // alle Zellen
444     SCSIZE          GetCellCount(SCTAB nTab, SCCOL nCol) const;
445     sal_uLong           GetWeightedCount() const;   // Formeln und Edit staerker gewichtet
446     sal_uLong           GetCodeCount() const;       // RPN-Code in Formeln
447     DECL_LINK( GetUserDefinedColor, sal_uInt16 * );
448                                                                 // Numberformatter
449 
450 public:
451     SC_DLLPUBLIC                ScDocument( ScDocumentMode eMode = SCDOCMODE_DOCUMENT,
452                                 SfxObjectShell* pDocShell = NULL );
453     SC_DLLPUBLIC                ~ScDocument();
454 
455     inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
456                     GetServiceManager() const { return xServiceManager; }
457 
458     SC_DLLPUBLIC const String&  GetName() const { return aDocName; }
459     void            SetName( const String& r ) { aDocName = r; }
460     const String&   GetCodeName() const { return aDocCodeName; }
461     void            SetCodeName( const String& r ) { aDocCodeName = r; }
462 
463     void            GetDocStat( ScDocStat& rDocStat );
464 
465     SC_DLLPUBLIC void           InitDrawLayer( SfxObjectShell* pDocShell = NULL );
466     XColorTable*    GetColorTable();
467 
468     SC_DLLPUBLIC sfx2::LinkManager*     GetLinkManager() const;
469 
470     SC_DLLPUBLIC const ScDocOptions&        GetDocOptions() const;
471     SC_DLLPUBLIC void                   SetDocOptions( const ScDocOptions& rOpt );
472     SC_DLLPUBLIC const ScViewOptions&   GetViewOptions() const;
473     SC_DLLPUBLIC void                   SetViewOptions( const ScViewOptions& rOpt );
474     void                    SetPrintOptions();
475 
476     ScExtDocOptions*        GetExtDocOptions()  { return pExtDocOptions; }
477     SC_DLLPUBLIC void                   SetExtDocOptions( ScExtDocOptions* pNewOptions );
478 
479     void                    GetLanguage( LanguageType& rLatin, LanguageType& rCjk, LanguageType& rCtl ) const;
480     void                    SetLanguage( LanguageType eLatin, LanguageType eCjk, LanguageType eCtl );
481 
482     void                    SetDrawDefaults();
483 
484     void                        SetConsolidateDlgData( const ScConsolidateParam* pData );
485     const ScConsolidateParam*   GetConsolidateDlgData() const { return pConsolidateDlgData; }
486 
487     void            Clear( sal_Bool bFromDestructor = sal_False );
488 
489     ScFieldEditEngine*  CreateFieldEditEngine();
490     void                DisposeFieldEditEngine(ScFieldEditEngine*& rpEditEngine);
491 
492     SC_DLLPUBLIC ScRangeName*   GetRangeName();
493     void            SetRangeName( ScRangeName* pNewRangeName );
494     SCTAB           GetMaxTableNumber() { return nMaxTableNumber; }
495     void            SetMaxTableNumber(SCTAB nNumber) { nMaxTableNumber = nNumber; }
496 
497     ScRangePairList*    GetColNameRanges() { return &xColNameRanges; }
498     ScRangePairList*    GetRowNameRanges() { return &xRowNameRanges; }
499     ScRangePairListRef& GetColNameRangesRef() { return xColNameRanges; }
500     ScRangePairListRef& GetRowNameRangesRef() { return xRowNameRanges; }
501 
502     SC_DLLPUBLIC ScDBCollection*    GetDBCollection() const;
503     void            SetDBCollection( ScDBCollection* pNewDBCollection,
504                                         sal_Bool bRemoveAutoFilter = sal_False );
505     ScDBData*       GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab,
506                                         sal_Bool bStartOnly = sal_False) const;
507     ScDBData*       GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
508     ScDBData*       GetFilterDBAtTable(SCTAB nTab) const;
509 //UNUSED2008-05  ScRangeData*   GetRangeAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab,
510 //UNUSED2008-05                                      sal_Bool bStartOnly = sal_False) const;
511     SC_DLLPUBLIC ScRangeData*   GetRangeAtBlock( const ScRange& rBlock, String* pName=NULL ) const;
512 
513     SC_DLLPUBLIC ScDPCollection*        GetDPCollection();
514     ScDPObject*         GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
515     ScDPObject*         GetDPAtBlock( const ScRange& rBlock ) const;
516     // Wang Xu Ming -- 2009-8-17
517     // DataPilot Migration - Cache&&Performance
518     SC_DLLPUBLIC ScDPTableDataCache*    GetDPObjectCache( long nID );
519     SC_DLLPUBLIC ScDPTableDataCache*    GetUsedDPObjectCache ( ScRange rRange );
520     SC_DLLPUBLIC long                                 AddDPObjectCache( ScDPTableDataCache* pData );
521     SC_DLLPUBLIC void                                 RemoveDPObjectCache( long nID );
522     SC_DLLPUBLIC void                                 RemoveUnusedDPObjectCaches();
523     SC_DLLPUBLIC void                                 GetUsedDPObjectCache( std::list<ScDPTableDataCache*>& usedlist );
524     SC_DLLPUBLIC long                                 GetNewDPObjectCacheId ();
525     // End Comments
526 
527     SC_DLLPUBLIC ScChartCollection* GetChartCollection() const;
528 
529     void                StopTemporaryChartLock();
530 
531     void            EnsureGraphicNames();
532 
533     SdrObject*      GetObjectAtPoint( SCTAB nTab, const Point& rPos );
534     sal_Bool            HasChartAtPoint( SCTAB nTab, const Point& rPos, String* pName = NULL );
535 
536     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > GetChartByName( const String& rChartName );
537     SC_DLLPUBLIC void            GetChartRanges( const String& rChartName, ::std::vector< ScRangeList >& rRanges, ScDocument* pSheetNameDoc );
538     void            SetChartRanges( const String& rChartName, const ::std::vector< ScRangeList >& rRanges );
539 
540     void            UpdateChartArea( const String& rChartName, const ScRange& rNewArea,
541                                         sal_Bool bColHeaders, sal_Bool bRowHeaders, sal_Bool bAdd );
542     void            UpdateChartArea( const String& rChartName,
543                                     const ScRangeListRef& rNewList,
544                                     sal_Bool bColHeaders, sal_Bool bRowHeaders, sal_Bool bAdd );
545     void            GetOldChartParameters( const String& rName,
546                                     ScRangeList& rRanges, sal_Bool& rColHeaders, sal_Bool& rRowHeaders );
547     ::com::sun::star::uno::Reference<
548             ::com::sun::star::embed::XEmbeddedObject >
549                     FindOleObjectByName( const String& rName );
550 
551     SC_DLLPUBLIC void           MakeTable( SCTAB nTab,bool _bNeedsNameCheck = true );
552 
553     SCTAB           GetVisibleTab() const       { return nVisibleTab; }
554     SC_DLLPUBLIC void           SetVisibleTab(SCTAB nTab)   { nVisibleTab = nTab; }
555 
556     SC_DLLPUBLIC sal_Bool           HasTable( SCTAB nTab ) const;
557     SC_DLLPUBLIC sal_Bool           GetName( SCTAB nTab, String& rName ) const;
558     SC_DLLPUBLIC sal_Bool           GetCodeName( SCTAB nTab, String& rName ) const;
559     SC_DLLPUBLIC sal_Bool           SetCodeName( SCTAB nTab, const String& rName );
560     SC_DLLPUBLIC sal_Bool           GetTable( const String& rName, SCTAB& rTab ) const;
561     SC_DLLPUBLIC inline SCTAB   GetTableCount() const { return nMaxTableNumber; }
562     SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; }
563 
564     SC_DLLPUBLIC ScDocProtection* GetDocProtection() const;
565     SC_DLLPUBLIC void            SetDocProtection(const ScDocProtection* pProtect);
566     SC_DLLPUBLIC sal_Bool           IsDocProtected() const;
567     sal_Bool            IsDocEditable() const;
568     SC_DLLPUBLIC sal_Bool           IsTabProtected( SCTAB nTab ) const;
569     SC_DLLPUBLIC    ScTableProtection* GetTabProtection( SCTAB nTab ) const;
570     SC_DLLPUBLIC void SetTabProtection(SCTAB nTab, const ScTableProtection* pProtect);
571     void            CopyTabProtection(SCTAB nTabSrc, SCTAB nTabDest);
572 
573     void            LockTable(SCTAB nTab);
574     void            UnlockTable(SCTAB nTab);
575 
576     sal_Bool            IsBlockEditable( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
577                                         SCCOL nEndCol, SCROW nEndRow,
578                                         sal_Bool* pOnlyNotBecauseOfMatrix = NULL ) const;
579     sal_Bool            IsSelectionEditable( const ScMarkData& rMark,
580                                         sal_Bool* pOnlyNotBecauseOfMatrix = NULL ) const;
581     sal_Bool            HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nStartRow,
582                                             SCCOL nEndCol, SCROW nEndRow,
583                                             const ScMarkData& rMark ) const;
584 
585     sal_Bool            GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix );
586 
587     sal_Bool            IsEmbedded() const;
588     void            GetEmbedded( ScRange& rRange ) const;
589     void            SetEmbedded( const ScRange& rRange );
590     void            ResetEmbedded();
591     Rectangle       GetEmbeddedRect() const;                        // 1/100 mm
592     void            SetEmbedded( const Rectangle& rRect );          // aus VisArea (1/100 mm)
593     void            SnapVisArea( Rectangle& rRect ) const;          // 1/100 mm
594 
595     SC_DLLPUBLIC sal_Bool           ValidTabName( const String& rName ) const;
596     SC_DLLPUBLIC sal_Bool           ValidNewTabName( const String& rName ) const;
597     SC_DLLPUBLIC void           CreateValidTabName(String& rName) const;
598     SC_DLLPUBLIC sal_Bool           InsertTab( SCTAB nPos, const String& rName,
599                                 sal_Bool bExternalDocument = sal_False );
600     SC_DLLPUBLIC sal_Bool            DeleteTab( SCTAB nTab, ScDocument* pRefUndoDoc = NULL );
601     SC_DLLPUBLIC sal_Bool           RenameTab( SCTAB nTab, const String& rName,
602                                 sal_Bool bUpdateRef = sal_True,
603                                 sal_Bool bExternalDocument = sal_False );
604     sal_Bool            MoveTab( SCTAB nOldPos, SCTAB nNewPos );
605     sal_Bool            CopyTab( SCTAB nOldPos, SCTAB nNewPos,
606                                 const ScMarkData* pOnlyMarked = NULL );
607     SC_DLLPUBLIC sal_uLong          TransferTab(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos,
608                                     sal_Bool bInsertNew = sal_True,
609                                     sal_Bool bResultsOnly = sal_False );
610     SC_DLLPUBLIC void           TransferDrawPage(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos);
611     SC_DLLPUBLIC void           SetVisible( SCTAB nTab, sal_Bool bVisible );
612     SC_DLLPUBLIC sal_Bool           IsVisible( SCTAB nTab ) const;
613     sal_Bool            IsStreamValid( SCTAB nTab ) const;
614     void            SetStreamValid( SCTAB nTab, sal_Bool bSet, sal_Bool bIgnoreLock = sal_False );
615     void            LockStreamValid( bool bLock );
616     bool            IsStreamValidLocked() const                         { return mbStreamValidLocked; }
617     sal_Bool            IsPendingRowHeights( SCTAB nTab ) const;
618     void            SetPendingRowHeights( SCTAB nTab, sal_Bool bSet );
619     SC_DLLPUBLIC void           SetLayoutRTL( SCTAB nTab, sal_Bool bRTL );
620     SC_DLLPUBLIC sal_Bool           IsLayoutRTL( SCTAB nTab ) const;
621     sal_Bool            IsNegativePage( SCTAB nTab ) const;
622     SC_DLLPUBLIC void           SetScenario( SCTAB nTab, sal_Bool bFlag );
623     SC_DLLPUBLIC sal_Bool           IsScenario( SCTAB nTab ) const;
624     SC_DLLPUBLIC void           GetScenarioData( SCTAB nTab, String& rComment,
625                                         Color& rColor, sal_uInt16& rFlags ) const;
626     SC_DLLPUBLIC void           SetScenarioData( SCTAB nTab, const String& rComment,
627                                         const Color& rColor, sal_uInt16 nFlags );
628     SC_DLLPUBLIC Color GetTabBgColor( SCTAB nTab ) const;
629     SC_DLLPUBLIC void SetTabBgColor( SCTAB nTab, const Color& rColor );
630     SC_DLLPUBLIC bool IsDefaultTabBgColor( SCTAB nTab ) const;
631     void            GetScenarioFlags( SCTAB nTab, sal_uInt16& rFlags ) const;
632     SC_DLLPUBLIC sal_Bool           IsActiveScenario( SCTAB nTab ) const;
633     SC_DLLPUBLIC void           SetActiveScenario( SCTAB nTab, sal_Bool bActive );      // nur fuer Undo etc.
634     SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const;
635     SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const;
636     void            SetGrammar( formula::FormulaGrammar::Grammar eGram );
637     SC_DLLPUBLIC sal_uInt8          GetLinkMode( SCTAB nTab ) const;
638     sal_Bool            IsLinked( SCTAB nTab ) const;
639     SC_DLLPUBLIC const String&  GetLinkDoc( SCTAB nTab ) const;
640     const String&   GetLinkFlt( SCTAB nTab ) const;
641     const String&   GetLinkOpt( SCTAB nTab ) const;
642     SC_DLLPUBLIC const String&  GetLinkTab( SCTAB nTab ) const;
643     sal_uLong           GetLinkRefreshDelay( SCTAB nTab ) const;
644     void            SetLink( SCTAB nTab, sal_uInt8 nMode, const String& rDoc,
645                             const String& rFilter, const String& rOptions,
646                             const String& rTabName, sal_uLong nRefreshDelay );
647     sal_Bool            HasLink( const String& rDoc,
648                             const String& rFilter, const String& rOptions ) const;
649     SC_DLLPUBLIC sal_Bool           LinkExternalTab( SCTAB& nTab, const String& aDocTab,
650                                     const String& aFileName,
651                                     const String& aTabName );
652 
653     bool            HasExternalRefManager() const { return pExternalRefMgr.get(); }
654     SC_DLLPUBLIC ScExternalRefManager* GetExternalRefManager() const;
655     bool            IsInExternalReferenceMarking() const;
656     void            MarkUsedExternalReferences();
657     bool            MarkUsedExternalReferences( ScTokenArray & rArr );
658 
659     /** Returns the pool containing external formula parsers. Creates the pool
660         on first call. */
661     ScFormulaParserPool& GetFormulaParserPool() const;
662 
663     sal_Bool            HasDdeLinks() const;
664     sal_Bool            HasAreaLinks() const;
665     void            UpdateExternalRefLinks();
666     void            UpdateDdeLinks();
667     void            UpdateAreaLinks();
668 
669                     // originating DDE links
670     void            IncInDdeLinkUpdate() { if ( nInDdeLinkUpdate < 255 ) ++nInDdeLinkUpdate; }
671     void            DecInDdeLinkUpdate() { if ( nInDdeLinkUpdate ) --nInDdeLinkUpdate; }
672     sal_Bool            IsInDdeLinkUpdate() const   { return nInDdeLinkUpdate != 0; }
673 
674     SC_DLLPUBLIC void           CopyDdeLinks( ScDocument* pDestDoc ) const;
675     void            DisconnectDdeLinks();
676 
677                     // Fuer StarOne Api:
678     sal_uInt16          GetDdeLinkCount() const;
679     sal_Bool            UpdateDdeLink( const String& rAppl, const String& rTopic, const String& rItem );
680 
681     /** Tries to find a DDE link with the specified connection data.
682         @param rnDdePos  (out-param) Returns the index of the DDE link (does not include other links from link manager).
683         @return  true = DDE link found, rnDdePos valid. */
684     SC_DLLPUBLIC bool            FindDdeLink( const String& rAppl, const String& rTopic, const String& rItem, sal_uInt8 nMode, sal_uInt16& rnDdePos );
685 
686     /** Returns the connection data of the specified DDE link.
687         @param nDdePos  Index of the DDE link (does not include other links from link manager).
688         @param rAppl  (out-param) The application name.
689         @param rTopic  (out-param) The DDE topic.
690         @param rItem  (out-param) The DDE item.
691         @return  true = DDE link found, out-parameters valid. */
692     bool            GetDdeLinkData( sal_uInt16 nDdePos, String& rAppl, String& rTopic, String& rItem ) const;
693     /** Returns the link mode of the specified DDE link.
694         @param nDdePos  Index of the DDE link (does not include other links from link manager).
695         @param rnMode  (out-param) The link mode of the specified DDE link.
696         @return  true = DDE link found, rnMode valid. */
697     bool            GetDdeLinkMode( sal_uInt16 nDdePos, sal_uInt8& rnMode ) const;
698     /** Returns the result matrix of the specified DDE link.
699         @param nDdePos  Index of the DDE link (does not include other links from link manager).
700         @return  The result matrix, if the DDE link has been found, 0 otherwise. */
701     SC_DLLPUBLIC const ScMatrix* GetDdeLinkResultMatrix( sal_uInt16 nDdePos ) const;
702 
703     /** Tries to find a DDE link or creates a new, if not extant.
704         @param pResults  If not 0, sets the matrix as as DDE link result matrix (also for existing links).
705         @return  true = DDE link found; false = Unpredictable error occured, no DDE link created. */
706     SC_DLLPUBLIC bool            CreateDdeLink( const String& rAppl, const String& rTopic, const String& rItem, sal_uInt8 nMode, ScMatrix* pResults = NULL );
707     /** Sets a result matrix for the specified DDE link.
708         @param nDdePos  Index of the DDE link (does not include other links from link manager).
709         @param pResults  The array containing all results of the DDE link (intrusive-ref-counted, do not delete).
710         @return  true = DDE link found and matrix set. */
711     bool            SetDdeLinkResultMatrix( sal_uInt16 nDdePos, ScMatrix* pResults );
712 
713 
714     SfxBindings*    GetViewBindings();
715     SfxObjectShell* GetDocumentShell() const    { return pShell; }
716     ScDrawLayer*    GetDrawLayer()              { return pDrawLayer; }
717     SfxBroadcaster* GetDrawBroadcaster();       // zwecks Header-Vermeidung
718     void            BeginDrawUndo();
719 
720     void            BeginUnoRefUndo();
721     bool            HasUnoRefUndo() const       { return ( pUnoRefUndoList != NULL ); }
722     ScUnoRefList*   EndUnoRefUndo();            // must be deleted by caller!
723     sal_Int64       GetNewUnoId();
724     void            AddUnoRefChange( sal_Int64 nId, const ScRangeList& rOldRanges );
725 
726     // #109985#
727     sal_Bool IsChart( const SdrObject* pObject );
728 
729     SC_DLLPUBLIC void           UpdateAllCharts();
730     void            UpdateChartRef( UpdateRefMode eUpdateRefMode,
731                                     SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
732                                     SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
733                                     SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
734                     //! setzt nur die neue RangeList, keine ChartListener o.ae.
735     void            SetChartRangeList( const String& rChartName,
736                         const ScRangeListRef& rNewRangeListRef );
737 
738     sal_Bool            HasControl( SCTAB nTab, const Rectangle& rMMRect );
739     void            InvalidateControls( Window* pWin, SCTAB nTab, const Rectangle& rMMRect );
740 
741     void            StartAnimations( SCTAB nTab, Window* pWin );
742 
743     sal_Bool            HasBackgroundDraw( SCTAB nTab, const Rectangle& rMMRect );
744     sal_Bool            HasAnyDraw( SCTAB nTab, const Rectangle& rMMRect );
745 
746     const ScSheetEvents* GetSheetEvents( SCTAB nTab ) const;
747     void            SetSheetEvents( SCTAB nTab, const ScSheetEvents* pNew );
748     bool            HasSheetEventScript( SCTAB nTab, sal_Int32 nEvent, bool bWithVbaEvents = false ) const;
749     bool            HasAnySheetEventScript( sal_Int32 nEvent, bool bWithVbaEvents = false ) const;  // on any sheet
750 
751     bool            HasAnyCalcNotification() const;
752     sal_Bool            HasCalcNotification( SCTAB nTab ) const;
753     void            SetCalcNotification( SCTAB nTab );
754     void            ResetCalcNotifications();
755 
756     SC_DLLPUBLIC ScOutlineTable*    GetOutlineTable( SCTAB nTab, sal_Bool bCreate = sal_False );
757     sal_Bool            SetOutlineTable( SCTAB nTab, const ScOutlineTable* pNewOutline );
758 
759     void            DoAutoOutline( SCCOL nStartCol, SCROW nStartRow,
760                                     SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
761 
762     sal_Bool            DoSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
763     void            RemoveSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
764     sal_Bool            TestRemoveSubTotals( SCTAB nTab, const ScSubTotalParam& rParam );
765     sal_Bool            HasSubTotalCells( const ScRange& rRange );
766 
767     SC_DLLPUBLIC void           PutCell( const ScAddress&, ScBaseCell* pCell, sal_Bool bForceTab = sal_False );
768 //UNUSED2009-05 SC_DLLPUBLIC void           PutCell( const ScAddress&, ScBaseCell* pCell,
769 //UNUSED2009-05                         sal_uLong nFormatIndex, sal_Bool bForceTab = sal_False);
770     SC_DLLPUBLIC void           PutCell( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell* pCell,
771                             sal_Bool bForceTab = sal_False );
772     SC_DLLPUBLIC void           PutCell(SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell* pCell,
773                             sal_uLong nFormatIndex, sal_Bool bForceTab = sal_False);
774                     //  return sal_True = Zahlformat gesetzt
775     SC_DLLPUBLIC sal_Bool           SetString(
776         SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString,
777         SvNumberFormatter* pFormatter = NULL, bool bDetectNumberFormat = true );
778     SC_DLLPUBLIC void           SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal );
779     void            SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const sal_uInt16 nError);
780 
781     SC_DLLPUBLIC void           InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
782                                         SCCOL nCol2, SCROW nRow2,
783                                         const ScMarkData& rMark,
784                                         const String& rFormula,
785                                         const ScTokenArray* p = NULL,
786                                         const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT );
787     SC_DLLPUBLIC void           InsertTableOp(const ScTabOpParam& rParam,   // Mehrfachoperation
788                                   SCCOL nCol1, SCROW nRow1,
789                                   SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark);
790 
791     SC_DLLPUBLIC void           GetString( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rString );
792     SC_DLLPUBLIC void           GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rString );
793     sal_uInt16                  GetStringForFormula( const ScAddress& rPos, rtl::OUString& rString );
794     SC_DLLPUBLIC double         GetValue( const ScAddress& );
795     SC_DLLPUBLIC void           GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, double& rValue );
796     SC_DLLPUBLIC double         RoundValueAsShown( double fVal, sal_uLong nFormat );
797     SC_DLLPUBLIC void           GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab,
798                                      sal_uInt32& rFormat );
799     SC_DLLPUBLIC sal_uInt32     GetNumberFormat( const ScAddress& ) const;
800                     /** If no number format attribute is set and the cell
801                         pointer passed is of type formula cell, the calculated
802                         number format of the formula cell is returned. pCell
803                         may be NULL. */
804     SC_DLLPUBLIC void           GetNumberFormatInfo( short& nType, sal_uLong& nIndex,
805                         const ScAddress& rPos, const ScBaseCell* pCell ) const;
806     void            GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rFormula,
807                                 sal_Bool bAsciiExport = sal_False ) const;
808     SC_DLLPUBLIC void           GetCellType( SCCOL nCol, SCROW nRow, SCTAB nTab, CellType& rCellType ) const;
809     SC_DLLPUBLIC CellType       GetCellType( const ScAddress& rPos ) const;
810     SC_DLLPUBLIC void           GetCell( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell*& rpCell ) const;
811     SC_DLLPUBLIC ScBaseCell*        GetCell( const ScAddress& rPos ) const;
812 
813 //UNUSED2008-05  void           RefreshNoteFlags();
814 
815     SC_DLLPUBLIC sal_Bool           HasData( SCCOL nCol, SCROW nRow, SCTAB nTab );
816     SC_DLLPUBLIC sal_Bool           HasStringData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
817     SC_DLLPUBLIC sal_Bool           HasValueData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
818     sal_Bool            HasStringCells( const ScRange& rRange ) const;
819 
820     /** Returns true, if there is any data to create a selection list for rPos. */
821     sal_Bool            HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
822 
823     /** Returns the pointer to a cell note object at the passed cell address. */
824     ScPostIt*       GetNote( const ScAddress& rPos );
825     /** Sets the passed note at the cell with the passed cell address. */
826     void            TakeNote( const ScAddress& rPos, ScPostIt*& rpNote );
827     /** Returns and forgets the cell note object at the passed cell address. */
828     ScPostIt*       ReleaseNote( const ScAddress& rPos );
829     /** Returns the pointer to an existing or created cell note object at the passed cell address. */
830     SC_DLLPUBLIC ScPostIt* GetOrCreateNote( const ScAddress& rPos );
831     /** Deletes the note at the passed cell address. */
832     void            DeleteNote( const ScAddress& rPos );
833     /** Creates the captions of all uninitialized cell notes in the specified sheet.
834         @param bForced  True = always create all captions, false = skip when Undo is disabled. */
835     void            InitializeNoteCaptions( SCTAB nTab, bool bForced = false );
836     /** Creates the captions of all uninitialized cell notes in all sheets.
837         @param bForced  True = always create all captions, false = skip when Undo is disabled. */
838     void            InitializeAllNoteCaptions( bool bForced = false );
839 
840     sal_Bool            ExtendMergeSel( SCCOL nStartCol, SCROW nStartRow,
841                                 SCCOL& rEndCol, SCROW& rEndRow, const ScMarkData& rMark,
842                                 sal_Bool bRefresh = sal_False, sal_Bool bAttrs = sal_False );
843     sal_Bool            ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
844                                 SCCOL& rEndCol, SCROW& rEndRow, SCTAB nTab,
845                                 sal_Bool bRefresh = sal_False, sal_Bool bAttrs = sal_False );
846     sal_Bool            ExtendMerge( ScRange& rRange, sal_Bool bRefresh = sal_False, sal_Bool bAttrs = sal_False );
847     sal_Bool            ExtendTotalMerge( ScRange& rRange );
848     SC_DLLPUBLIC sal_Bool           ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow,
849                                 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
850     SC_DLLPUBLIC sal_Bool           ExtendOverlapped( ScRange& rRange );
851 
852     sal_Bool            RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow,
853                                 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
854 
855     SC_DLLPUBLIC void           DoMergeContents( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
856                                     SCCOL nEndCol, SCROW nEndRow );
857                     //  ohne Ueberpruefung:
858     SC_DLLPUBLIC void           DoMerge( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
859                                     SCCOL nEndCol, SCROW nEndRow, bool bDeleteCaptions = true );
860     void            RemoveMerge( SCCOL nCol, SCROW nRow, SCTAB nTab );
861 
862     sal_Bool            IsBlockEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
863                                                 SCCOL nEndCol, SCROW nEndRow, bool bIgnoreNotes = false ) const;
864     sal_Bool            IsPrintEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
865                                                 SCCOL nEndCol, SCROW nEndRow,
866                                                 sal_Bool bLeftIsEmpty = sal_False,
867                                                 ScRange* pLastRange = NULL,
868                                                 Rectangle* pLastMM = NULL ) const;
869 
870     sal_Bool            IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
871     sal_Bool            IsVerOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
872 
873     SC_DLLPUBLIC bool           HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
874                                            SCCOL nCol2, SCROW nRow2, SCTAB nTab2, sal_uInt16 nMask );
875     SC_DLLPUBLIC bool           HasAttrib( const ScRange& rRange, sal_uInt16 nMask );
876 
877     void            GetBorderLines( SCCOL nCol, SCROW nRow, SCTAB nTab,
878                                     const SvxBorderLine** ppLeft,
879                                     const SvxBorderLine** ppTop,
880                                     const SvxBorderLine** ppRight,
881                                     const SvxBorderLine** ppBottom ) const;
882 
883     void            ResetChanged( const ScRange& rRange );
884 
885     void            SetDirty();
886     void            SetDirty( const ScRange& );
887     void            SetTableOpDirty( const ScRange& );  // for Interpreter TableOp
888     void            InterpretDirtyCells( const ScRangeList& rRanges );
889     void            CalcAll();
890     SC_DLLPUBLIC void           CalcAfterLoad();
891     void            CompileAll();
892     void            CompileXML();
893 
894     ScAutoNameCache* GetAutoNameCache()     { return pAutoNameCache; }
895 
896                     /** Creates a ScLookupCache cache for the range if it
897                         doesn't already exist. */
898     ScLookupCache & GetLookupCache( const ScRange & rRange );
899                     /** Only ScLookupCache ctor uses AddLookupCache(), do not
900                         use elsewhere! */
901     void            AddLookupCache( ScLookupCache & rCache );
902                     /** Only ScLookupCache dtor uses RemoveLookupCache(), do
903                         not use elsewhere! */
904     void            RemoveLookupCache( ScLookupCache & rCache );
905                     /** Zap all caches. */
906     void            ClearLookupCaches();
907 
908                     // Automatisch Berechnen
909     void            SetAutoCalc( sal_Bool bNewAutoCalc );
910     sal_Bool            GetAutoCalc() const { return bAutoCalc; }
911                     // Automatisch Berechnen in/von/fuer ScDocShell disabled
912     void            SetAutoCalcShellDisabled( sal_Bool bNew ) { bAutoCalcShellDisabled = bNew; }
913     sal_Bool            IsAutoCalcShellDisabled() const { return bAutoCalcShellDisabled; }
914                     // ForcedFormulas zu berechnen
915     void            SetForcedFormulaPending( sal_Bool bNew ) { bForcedFormulaPending = bNew; }
916     sal_Bool            IsForcedFormulaPending() const { return bForcedFormulaPending; }
917                     // if CalcFormulaTree() is currently running
918     sal_Bool            IsCalculatingFormulaTree() { return bCalculatingFormulaTree; }
919 
920     sal_uInt16          GetErrCode( const ScAddress& ) const;
921 
922                     /** Shrink a range to only include data area.
923 
924                         This is not the actually used area within the
925                         selection, but the bounds of the sheet's data area
926                         instead.
927 
928                         @returns True if the area passed intersected the data
929                                  area, false if not, in which case the values
930                                  obtained may be out of bounds, not in order or
931                                  unmodified. True does not mean that there
932                                  actually is any data within the selection.
933                      */
934     bool            ShrinkToDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
935 
936                     /** Shrink a range to only include used data area.
937 
938                         @param o_bShrunk
939                                Out parameter, True if area was shrunk, false if not.
940 
941                         @returns True if there is any data, fakse if not.
942                      */
943     bool            ShrinkToUsedDataArea( bool& o_bShrunk,
944                                           SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
945                                           SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const;
946 
947     SC_DLLPUBLIC void           GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
948                                     SCCOL& rEndCol, SCROW& rEndRow, sal_Bool bIncludeOld, bool bOnlyDown ) const;
949     SC_DLLPUBLIC sal_Bool           GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
950     SC_DLLPUBLIC sal_Bool           GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
951     SC_DLLPUBLIC sal_Bool           GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
952                                     sal_Bool bNotes = sal_True ) const;
953     SC_DLLPUBLIC sal_Bool           GetPrintAreaHor( SCTAB nTab, SCROW nStartRow, SCROW nEndRow,
954                                         SCCOL& rEndCol, sal_Bool bNotes = sal_True ) const;
955     SC_DLLPUBLIC sal_Bool           GetPrintAreaVer( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol,
956                                         SCROW& rEndRow, sal_Bool bNotes = sal_True ) const;
957     void            InvalidateTableArea();
958 
959 
960     SC_DLLPUBLIC sal_Bool           GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const;
961 
962     /**
963      * Find the maximum column position that contains printable data for the
964      * specified row range.  The final column position must be equal or less
965      * than the initial value of rEndCol.
966      */
967     void            ExtendPrintArea( OutputDevice* pDev, SCTAB nTab,
968                                     SCCOL nStartCol, SCROW nStartRow,
969                                     SCCOL& rEndCol, SCROW nEndRow );
970     SC_DLLPUBLIC SCSIZE         GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
971                                             SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab,
972                                             ScDirection eDir );
973 
974     void            FindAreaPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, SCsCOL nMovX, SCsROW nMovY );
975     SC_DLLPUBLIC void           GetNextPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, SCsCOL nMovX, SCsROW nMovY,
976                                 sal_Bool bMarked, sal_Bool bUnprotected, const ScMarkData& rMark );
977 
978     sal_Bool            GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, SCTAB nTab,
979                                         const ScMarkData& rMark );
980 
981     void            LimitChartArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
982                                                     SCCOL& rEndCol, SCROW& rEndRow );
983     void            LimitChartIfAll( ScRangeListRef& rRangeList );
984 
985     sal_Bool            InsertRow( SCCOL nStartCol, SCTAB nStartTab,
986                                SCCOL nEndCol,   SCTAB nEndTab,
987                                SCROW nStartRow, SCSIZE nSize, ScDocument* pRefUndoDoc = NULL,
988                                const ScMarkData* pTabMark = NULL );
989     SC_DLLPUBLIC sal_Bool           InsertRow( const ScRange& rRange, ScDocument* pRefUndoDoc = NULL );
990     void            DeleteRow( SCCOL nStartCol, SCTAB nStartTab,
991                                SCCOL nEndCol,   SCTAB nEndTab,
992                                SCROW nStartRow, SCSIZE nSize,
993                                ScDocument* pRefUndoDoc = NULL, sal_Bool* pUndoOutline = NULL,
994                                const ScMarkData* pTabMark = NULL );
995     void            DeleteRow( const ScRange& rRange,
996                                ScDocument* pRefUndoDoc = NULL, sal_Bool* pUndoOutline = NULL );
997     sal_Bool            InsertCol( SCROW nStartRow, SCTAB nStartTab,
998                                SCROW nEndRow,   SCTAB nEndTab,
999                                SCCOL nStartCol, SCSIZE nSize, ScDocument* pRefUndoDoc = NULL,
1000                                const ScMarkData* pTabMark = NULL );
1001     SC_DLLPUBLIC sal_Bool           InsertCol( const ScRange& rRange, ScDocument* pRefUndoDoc = NULL );
1002     void            DeleteCol( SCROW nStartRow, SCTAB nStartTab,
1003                                SCROW nEndRow, SCTAB nEndTab,
1004                                SCCOL nStartCol, SCSIZE nSize,
1005                                ScDocument* pRefUndoDoc = NULL, sal_Bool* pUndoOutline = NULL,
1006                                const ScMarkData* pTabMark = NULL );
1007     void            DeleteCol( const ScRange& rRange,
1008                                ScDocument* pRefUndoDoc = NULL, sal_Bool* pUndoOutline = NULL );
1009 
1010     sal_Bool            CanInsertRow( const ScRange& rRange ) const;
1011     sal_Bool            CanInsertCol( const ScRange& rRange ) const;
1012 
1013     void            FitBlock( const ScRange& rOld, const ScRange& rNew, sal_Bool bClear = sal_True );
1014     sal_Bool            CanFitBlock( const ScRange& rOld, const ScRange& rNew );
1015 
1016     sal_Bool            IsClipOrUndo() const                        { return bIsClip || bIsUndo; }
1017     sal_Bool            IsUndo() const                              { return bIsUndo; }
1018     sal_Bool            IsClipboard() const                         { return bIsClip; }
1019     bool            IsUndoEnabled() const                       { return mbUndoEnabled; }
1020     void            EnableUndo( bool bVal );
1021 
1022     bool            IsAdjustHeightEnabled() const               { return mbAdjustHeightEnabled; }
1023     void            EnableAdjustHeight( bool bVal )             { mbAdjustHeightEnabled = bVal; }
1024     bool            IsExecuteLinkEnabled() const                { return mbExecuteLinkEnabled; }
1025     void            EnableExecuteLink( bool bVal )              { mbExecuteLinkEnabled = bVal; }
1026     bool            IsChangeReadOnlyEnabled() const             { return mbChangeReadOnlyEnabled; }
1027     void            EnableChangeReadOnly( bool bVal )           { mbChangeReadOnlyEnabled = bVal; }
1028     SC_DLLPUBLIC sal_Int16       GetNamedRangesLockCount() const             { return mnNamedRangesLockCount; }
1029     void            SetNamedRangesLockCount( sal_Int16 nCount ) { mnNamedRangesLockCount = nCount; }
1030     SC_DLLPUBLIC void           ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks );
1031     SC_DLLPUBLIC void           ResetClip( ScDocument* pSourceDoc, SCTAB nTab );
1032     void            SetCutMode( sal_Bool bCut );
1033     sal_Bool            IsCutMode();
1034     void            SetClipArea( const ScRange& rArea, sal_Bool bCut = sal_False );
1035 
1036     SC_DLLPUBLIC sal_Bool           IsDocVisible() const                        { return bIsVisible; }
1037     void            SetDocVisible( sal_Bool bSet );
1038 
1039     sal_Bool            HasOLEObjectsInArea( const ScRange& rRange, const ScMarkData* pTabMark = NULL );
1040 
1041     void            DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1042                                         const ScMarkData& rMark );
1043     void            DeleteObjectsInSelection( const ScMarkData& rMark );
1044 
1045     void            DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1046                             const ScMarkData& rMark, sal_uInt16 nDelFlag);
1047     void            DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1048                                 SCTAB nTab, sal_uInt16 nDelFlag);
1049     void            DeleteAreaTab(const ScRange& rRange, sal_uInt16 nDelFlag);
1050 
1051     void            CopyToClip(const ScClipParam& rClipParam, ScDocument* pClipDoc,
1052                                const ScMarkData* pMarks = NULL, bool bAllTabs = false, bool bKeepScenarioFlags = false,
1053                                bool bIncludeObjects = false, bool bCloneNoteCaptions = true);
1054 
1055     void            CopyTabToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1056                                 SCTAB nTab, ScDocument* pClipDoc = NULL);
1057     void            CopyBlockFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1058                                     const ScMarkData& rMark, SCsCOL nDx, SCsROW nDy,
1059                                     const ScCopyBlockFromClipParams* pCBFCP );
1060     void            CopyNonFilteredFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1061                                     const ScMarkData& rMark, SCsCOL nDx, SCsROW nDy,
1062                                     const ScCopyBlockFromClipParams* pCBFCP,
1063                                     SCROW & rClipStartRow );
1064     void            StartListeningFromClip( SCCOL nCol1, SCROW nRow1,
1065                                         SCCOL nCol2, SCROW nRow2,
1066                                         const ScMarkData& rMark, sal_uInt16 nInsFlag );
1067     void            BroadcastFromClip( SCCOL nCol1, SCROW nRow1,
1068                                     SCCOL nCol2, SCROW nRow2,
1069                                     const ScMarkData& rMark, sal_uInt16 nInsFlag );
1070     /** If pDestRanges is given it overrides rDestRange, rDestRange in this
1071         case is the overall encompassing range. */
1072     void            CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMark,
1073                                     sal_uInt16 nInsFlag,
1074                                     ScDocument* pRefUndoDoc = NULL,
1075                                     ScDocument* pClipDoc = NULL,
1076                                     sal_Bool bResetCut = sal_True,
1077                                     sal_Bool bAsLink = sal_False,
1078                                     sal_Bool bIncludeFiltered = sal_True,
1079                                     sal_Bool bSkipAttrForEmpty = sal_False,
1080                                     const ScRangeList * pDestRanges = NULL );
1081 
1082     void            CopyMultiRangeFromClip(const ScAddress& rDestPos, const ScMarkData& rMark,
1083                                            sal_uInt16 nInsFlag, ScDocument* pClipDoc,
1084                                            bool bResetCut = true, bool bAsLink = false,
1085                                            bool bIncludeFiltered = true,
1086                                            bool bSkipAttrForEmpty = false);
1087 
1088     void            GetClipArea(SCCOL& nClipX, SCROW& nClipY, sal_Bool bIncludeFiltered);
1089     void            GetClipStart(SCCOL& nClipX, SCROW& nClipY);
1090 
1091     sal_Bool            HasClipFilteredRows();
1092 
1093     sal_Bool            IsClipboardSource() const;
1094 
1095     SC_DLLPUBLIC void           TransposeClip( ScDocument* pTransClip, sal_uInt16 nFlags, sal_Bool bAsLink );
1096 
1097     ScClipParam&    GetClipParam();
1098     void            SetClipParam(const ScClipParam& rParam);
1099 
1100     void            MixDocument( const ScRange& rRange, sal_uInt16 nFunction, sal_Bool bSkipEmpty,
1101                                     ScDocument* pSrcDoc );
1102 
1103     void            FillTab( const ScRange& rSrcArea, const ScMarkData& rMark,
1104                                 sal_uInt16 nFlags, sal_uInt16 nFunction,
1105                                 sal_Bool bSkipEmpty, sal_Bool bAsLink );
1106     void            FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark,
1107                                 sal_uInt16 nFlags, sal_uInt16 nFunction,
1108                                 sal_Bool bSkipEmpty, sal_Bool bAsLink );
1109 
1110     void            TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nType );
1111 
1112     SC_DLLPUBLIC void           InitUndo( ScDocument* pSrcDoc, SCTAB nTab1, SCTAB nTab2,
1113                                 sal_Bool bColInfo = sal_False, sal_Bool bRowInfo = sal_False );
1114     void            AddUndoTab( SCTAB nTab1, SCTAB nTab2,
1115                                 sal_Bool bColInfo = sal_False, sal_Bool bRowInfo = sal_False );
1116     SC_DLLPUBLIC void           InitUndoSelected( ScDocument* pSrcDoc, const ScMarkData& rTabSelection,
1117                                 sal_Bool bColInfo = sal_False, sal_Bool bRowInfo = sal_False );
1118 
1119                     //  nicht mehr benutzen:
1120     void            CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1121                                 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1122                                 sal_uInt16 nFlags, sal_Bool bMarked, ScDocument* pDestDoc,
1123                                 const ScMarkData* pMarks = NULL, sal_Bool bColRowFlags = sal_True);
1124     void            UndoToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1125                                 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1126                                 sal_uInt16 nFlags, sal_Bool bMarked, ScDocument* pDestDoc,
1127                                 const ScMarkData* pMarks = NULL);
1128 
1129     void            CopyToDocument(const ScRange& rRange,
1130                                 sal_uInt16 nFlags, sal_Bool bMarked, ScDocument* pDestDoc,
1131                                 const ScMarkData* pMarks = NULL, sal_Bool bColRowFlags = sal_True);
1132     void            UndoToDocument(const ScRange& rRange,
1133                                 sal_uInt16 nFlags, sal_Bool bMarked, ScDocument* pDestDoc,
1134                                 const ScMarkData* pMarks = NULL);
1135 
1136     void            CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, sal_Bool bNewScenario = sal_False );
1137     sal_Bool            TestCopyScenario( SCTAB nSrcTab, SCTAB nDestTab ) const;
1138     void            MarkScenario( SCTAB nSrcTab, SCTAB nDestTab,
1139                                     ScMarkData& rDestMark, sal_Bool bResetMark = sal_True,
1140                                     sal_uInt16 nNeededBits = 0 ) const;
1141     sal_Bool            HasScenarioRange( SCTAB nTab, const ScRange& rRange ) const;
1142     SC_DLLPUBLIC const ScRangeList* GetScenarioRanges( SCTAB nTab ) const;
1143 
1144     SC_DLLPUBLIC void           CopyUpdated( ScDocument* pPosDoc, ScDocument* pDestDoc );
1145 
1146     void            UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1147                                      SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1148                                      SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
1149                                      ScDocument* pUndoDoc = NULL, sal_Bool bIncludeDraw = sal_True,
1150                                      bool bUpdateNoteCaptionPos = true );
1151 
1152     SC_DLLPUBLIC void           UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDoc,
1153                                         const ScMarkData& rMark, ScDocument* pUndoDoc = NULL );
1154 
1155     void            UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
1156 
1157     void            Fill(   SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1158                             const ScMarkData& rMark,
1159                             sal_uLong nFillCount, FillDir eFillDir = FILL_TO_BOTTOM,
1160                             FillCmd eFillCmd = FILL_LINEAR, FillDateCmd eFillDateCmd = FILL_DAY,
1161                             double nStepValue = 1.0, double nMaxValue = 1E307);
1162     String          GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
1163 
1164     sal_Bool            GetSelectionFunction( ScSubTotalFunc eFunc,
1165                                             const ScAddress& rCursor, const ScMarkData& rMark,
1166                                             double& rResult );
1167 
1168     SC_DLLPUBLIC const SfxPoolItem*         GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
1169     SC_DLLPUBLIC const ScPatternAttr*   GetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1170     SC_DLLPUBLIC const ScPatternAttr*    GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const;
1171     const ScPatternAttr*    GetSelectionPattern( const ScMarkData& rMark, sal_Bool bDeep = sal_True );
1172     ScPatternAttr*          CreateSelectionPattern( const ScMarkData& rMark, sal_Bool bDeep = sal_True );
1173 
1174     const ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1175     SC_DLLPUBLIC const SfxItemSet*  GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1176     const SfxPoolItem*  GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
1177 
1178     SC_DLLPUBLIC const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >& GetBreakIterator();
1179     sal_Bool            HasStringWeakCharacters( const String& rString );
1180     SC_DLLPUBLIC sal_uInt8          GetStringScriptType( const String& rString );
1181     SC_DLLPUBLIC sal_uInt8          GetCellScriptType( ScBaseCell* pCell, sal_uLong nNumberFormat );
1182     SC_DLLPUBLIC sal_uInt8          GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell* pCell = NULL );
1183 
1184     sal_Bool            HasDetectiveOperations() const;
1185     void            AddDetectiveOperation( const ScDetOpData& rData );
1186     void            ClearDetectiveOperations();
1187     ScDetOpList*    GetDetOpList() const                { return pDetOpList; }
1188     void            SetDetOpList(ScDetOpList* pNew);
1189 
1190     sal_Bool            HasDetectiveObjects(SCTAB nTab) const;
1191 
1192     void            GetSelectionFrame( const ScMarkData& rMark,
1193                                        SvxBoxItem&      rLineOuter,
1194                                        SvxBoxInfoItem&  rLineInner );
1195     void            ApplySelectionFrame( const ScMarkData& rMark,
1196                                          const SvxBoxItem* pLineOuter,
1197                                          const SvxBoxInfoItem* pLineInner );
1198     void            ApplyFrameAreaTab( const ScRange& rRange,
1199                                          const SvxBoxItem* pLineOuter,
1200                                          const SvxBoxInfoItem* pLineInner );
1201 
1202     void            ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
1203     void            ChangeSelectionIndent( sal_Bool bIncrement, const ScMarkData& rMark );
1204 
1205     SC_DLLPUBLIC sal_uLong          AddCondFormat( const ScConditionalFormat& rNew );
1206     SC_DLLPUBLIC void           FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges );
1207     SC_DLLPUBLIC void           FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges, SCTAB nTab );
1208     void            ConditionalChanged( sal_uLong nKey );
1209 
1210     SC_DLLPUBLIC sal_uLong          AddValidationEntry( const ScValidationData& rNew );
1211 
1212     SC_DLLPUBLIC const ScValidationData*    GetValidationEntry( sal_uLong nIndex ) const;
1213 
1214     ScConditionalFormatList* GetCondFormList() const        // Ref-Undo
1215                     { return pCondFormList; }
1216     void            SetCondFormList(ScConditionalFormatList* pNew);
1217 
1218     ScValidationDataList* GetValidationList() const
1219                     { return pValidationList; }
1220 
1221     SC_DLLPUBLIC void           ApplyAttr( SCCOL nCol, SCROW nRow, SCTAB nTab,
1222                                 const SfxPoolItem& rAttr );
1223     SC_DLLPUBLIC void           ApplyPattern( SCCOL nCol, SCROW nRow, SCTAB nTab,
1224                                     const ScPatternAttr& rAttr );
1225     SC_DLLPUBLIC void           ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow,
1226                                         SCCOL nEndCol, SCROW nEndRow,
1227                                         const ScMarkData& rMark, const ScPatternAttr& rAttr );
1228     SC_DLLPUBLIC void           ApplyPatternAreaTab( SCCOL nStartCol, SCROW nStartRow,
1229                                             SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1230                                             const ScPatternAttr& rAttr );
1231     SC_DLLPUBLIC void           ApplyPatternIfNumberformatIncompatible(
1232                             const ScRange& rRange, const ScMarkData& rMark,
1233                             const ScPatternAttr& rPattern, short nNewType );
1234 
1235     void            ApplyStyle( SCCOL nCol, SCROW nRow, SCTAB nTab,
1236                                 const ScStyleSheet& rStyle);
1237     void            ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow,
1238                                     SCCOL nEndCol, SCROW nEndRow,
1239                                     const ScMarkData& rMark, const ScStyleSheet& rStyle);
1240     SC_DLLPUBLIC void           ApplyStyleAreaTab( SCCOL nStartCol, SCROW nStartRow,
1241                                         SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1242                                         const ScStyleSheet& rStyle);
1243 
1244     void            ApplySelectionStyle( const ScStyleSheet& rStyle, const ScMarkData& rMark );
1245     void            ApplySelectionLineStyle( const ScMarkData& rMark,
1246                                             const SvxBorderLine* pLine, sal_Bool bColorOnly );
1247 
1248     const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1249     const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark ) const;
1250 
1251     void            StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, sal_Bool bRemoved,
1252                                         OutputDevice* pDev,
1253                                         double nPPTX, double nPPTY,
1254                                         const Fraction& rZoomX, const Fraction& rZoomY );
1255 
1256     sal_Bool            IsStyleSheetUsed( const ScStyleSheet& rStyle, sal_Bool bGatherAllStyles ) const;
1257 
1258     SC_DLLPUBLIC sal_Bool           ApplyFlagsTab( SCCOL nStartCol, SCROW nStartRow,
1259                                             SCCOL nEndCol, SCROW nEndRow,
1260                                             SCTAB nTab, sal_Int16 nFlags );
1261     sal_Bool            RemoveFlagsTab( SCCOL nStartCol, SCROW nStartRow,
1262                                             SCCOL nEndCol, SCROW nEndRow,
1263                                             SCTAB nTab, sal_Int16 nFlags );
1264 
1265     SC_DLLPUBLIC void           SetPattern( const ScAddress&, const ScPatternAttr& rAttr,
1266                                     sal_Bool bPutToPool = sal_False );
1267     SC_DLLPUBLIC void           SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr& rAttr,
1268                                     sal_Bool bPutToPool = sal_False );
1269     void            DeleteNumberFormat( const sal_uInt32* pDelKeys, sal_uInt32 nCount );
1270 
1271     void            AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1272                                     sal_uInt16 nFormatNo, const ScMarkData& rMark );
1273     void            GetAutoFormatData( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1274                                         ScAutoFormatData& rData );
1275     sal_Bool            SearchAndReplace( const SvxSearchItem& rSearchItem,
1276                                         SCCOL& rCol, SCROW& rRow, SCTAB& rTab,
1277                                         ScMarkData& rMark,
1278                                         String& rUndoStr, ScDocument* pUndoDoc = NULL );
1279 
1280                     // Col/Row von Folgeaufrufen bestimmen
1281                     // (z.B. nicht gefunden von Anfang, oder folgende Tabellen)
1282     static void     GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem,
1283                         SCCOL& rCol, SCROW& rRow );
1284 
1285     sal_Bool            Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab,
1286                             SCCOL nVCol, SCROW nVRow, SCTAB nVTab,
1287                             const String& sValStr, double& nX);
1288 
1289     void            ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark );
1290     void            DeleteSelection( sal_uInt16 nDelFlag, const ScMarkData& rMark );
1291     void            DeleteSelectionTab( SCTAB nTab, sal_uInt16 nDelFlag, const ScMarkData& rMark );
1292 
1293     SC_DLLPUBLIC void           SetColWidth( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth );
1294     SC_DLLPUBLIC void           SetRowHeight( SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight );
1295     SC_DLLPUBLIC void           SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
1296                                             sal_uInt16 nNewHeight );
1297 
1298     SC_DLLPUBLIC void           SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
1299                                                   sal_uInt16 nNewHeight );
1300     void                        SetManualHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, sal_Bool bManual );
1301 
1302     SC_DLLPUBLIC sal_uInt16         GetColWidth( SCCOL nCol, SCTAB nTab ) const;
1303     SC_DLLPUBLIC sal_uInt16         GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1304     SC_DLLPUBLIC sal_uInt16         GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const;
1305     SC_DLLPUBLIC sal_uLong          GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const;
1306     SCROW                       GetRowForHeight( SCTAB nTab, sal_uLong nHeight ) const;
1307     sal_uLong                       GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const;
1308     SC_DLLPUBLIC sal_uLong          GetColOffset( SCCOL nCol, SCTAB nTab ) const;
1309     SC_DLLPUBLIC sal_uLong          GetRowOffset( SCROW nRow, SCTAB nTab ) const;
1310 
1311     SC_DLLPUBLIC sal_uInt16         GetOriginalWidth( SCCOL nCol, SCTAB nTab ) const;
1312     SC_DLLPUBLIC sal_uInt16         GetOriginalHeight( SCROW nRow, SCTAB nTab ) const;
1313 
1314     sal_uInt16          GetCommonWidth( SCCOL nEndCol, SCTAB nTab ) const;
1315 
1316     SCROW           GetHiddenRowCount( SCROW nRow, SCTAB nTab ) const;
1317 
1318     sal_uInt16          GetOptimalColWidth( SCCOL nCol, SCTAB nTab, OutputDevice* pDev,
1319                                         double nPPTX, double nPPTY,
1320                                         const Fraction& rZoomX, const Fraction& rZoomY,
1321                                         sal_Bool bFormula,
1322                                         const ScMarkData* pMarkData = NULL,
1323                                         sal_Bool bSimpleTextImport = sal_False );
1324     SC_DLLPUBLIC sal_Bool           SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, sal_uInt16 nExtra,
1325                                         OutputDevice* pDev,
1326                                         double nPPTX, double nPPTY,
1327                                         const Fraction& rZoomX, const Fraction& rZoomY,
1328                                         sal_Bool bShrink );
1329     void            UpdateAllRowHeights( OutputDevice* pDev,
1330                                         double nPPTX, double nPPTY,
1331                                         const Fraction& rZoomX, const Fraction& rZoomY,
1332                                         const ScMarkData* pTabMark = NULL );
1333     long            GetNeededSize( SCCOL nCol, SCROW nRow, SCTAB nTab,
1334                                     OutputDevice* pDev,
1335                                     double nPPTX, double nPPTY,
1336                                     const Fraction& rZoomX, const Fraction& rZoomY,
1337                                     sal_Bool bWidth, sal_Bool bTotalSize = sal_False );
1338 
1339     SC_DLLPUBLIC void           ShowCol(SCCOL nCol, SCTAB nTab, sal_Bool bShow);
1340     SC_DLLPUBLIC void           ShowRow(SCROW nRow, SCTAB nTab, sal_Bool bShow);
1341     SC_DLLPUBLIC void           ShowRows(SCROW nRow1, SCROW nRow2, SCTAB nTab, sal_Bool bShow);
1342     SC_DLLPUBLIC void           SetColFlags( SCCOL nCol, SCTAB nTab, sal_uInt8 nNewFlags );
1343     SC_DLLPUBLIC void           SetRowFlags( SCROW nRow, SCTAB nTab, sal_uInt8 nNewFlags );
1344     SC_DLLPUBLIC void           SetRowFlags( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, sal_uInt8 nNewFlags );
1345 
1346     SC_DLLPUBLIC sal_uInt8          GetColFlags( SCCOL nCol, SCTAB nTab ) const;
1347     SC_DLLPUBLIC sal_uInt8          GetRowFlags( SCROW nRow, SCTAB nTab ) const;
1348 
1349     SC_DLLPUBLIC const ScBitMaskCompressedArray< SCROW, sal_uInt8> & GetRowFlagsArray( SCTAB nTab ) const;
1350     SC_DLLPUBLIC       ScBitMaskCompressedArray< SCROW, sal_uInt8> & GetRowFlagsArrayModifiable( SCTAB nTab );
1351 
1352     SC_DLLPUBLIC void           GetAllRowBreaks(::std::set<SCROW>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
1353     SC_DLLPUBLIC void           GetAllColBreaks(::std::set<SCCOL>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
1354     SC_DLLPUBLIC ScBreakType    HasRowBreak(SCROW nRow, SCTAB nTab) const;
1355     SC_DLLPUBLIC ScBreakType    HasColBreak(SCCOL nCol, SCTAB nTab) const;
1356     SC_DLLPUBLIC void           SetRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
1357     SC_DLLPUBLIC void           SetColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
1358     void                        RemoveRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
1359     void                        RemoveColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
1360     ::com::sun::star::uno::Sequence<
1361         ::com::sun::star::sheet::TablePageBreakData> GetRowBreakData(SCTAB nTab) const;
1362 
1363     SC_DLLPUBLIC bool           RowHidden(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL);
1364     SC_DLLPUBLIC bool           RowHidden(SCROW nRow, SCTAB nTab, SCROW& rLastRow);
1365     SC_DLLPUBLIC bool           HasHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
1366     SC_DLLPUBLIC bool           ColHidden(SCCOL nCol, SCTAB nTab, SCCOL& rLastCol);
1367     SC_DLLPUBLIC bool           ColHidden(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL);
1368     SC_DLLPUBLIC void           SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden);
1369     SC_DLLPUBLIC void           SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden);
1370     SC_DLLPUBLIC SCROW          FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
1371     SC_DLLPUBLIC SCROW          LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
1372     SCROW                       CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
1373 
1374     bool                        RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL);
1375     bool                        HasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
1376     bool                        ColFiltered(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL);
1377     SC_DLLPUBLIC void           SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered);
1378     SC_DLLPUBLIC void           SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bFiltered);
1379     SCROW                       FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
1380     SCROW                       LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
1381     SCROW                       CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
1382 
1383     /**
1384      * Write all column row flags to table's flag data, because not all column
1385      * row attributes are stored in the flag data members.  This is necessary
1386      * for ods export.
1387      */
1388     void                        SyncColRowFlags();
1389 
1390                     /// @return  the index of the last row with any set flags (auto-pagebreak is ignored).
1391     SC_DLLPUBLIC SCROW          GetLastFlaggedRow( SCTAB nTab ) const;
1392 
1393                     /// @return  the index of the last changed column (flags and column width, auto pagebreak is ignored).
1394     SCCOL           GetLastChangedCol( SCTAB nTab ) const;
1395                     /// @return  the index of the last changed row (flags and row height, auto pagebreak is ignored).
1396     SCROW           GetLastChangedRow( SCTAB nTab ) const;
1397 
1398     SCCOL           GetNextDifferentChangedCol( SCTAB nTab, SCCOL nStart) const;
1399 
1400                     // #108550#; if bCareManualSize is set then the row
1401                     // heights are compared only if the manual size flag for
1402                     // the row is set. If the bCareManualSize is not set then
1403                     // the row heights are always compared.
1404     SCROW           GetNextDifferentChangedRow( SCTAB nTab, SCROW nStart, bool bCareManualSize = true) const;
1405 
1406     // returns whether to export a Default style for this col/row or not
1407     // nDefault is setted to one possition in the current row/col where the Default style is
1408     sal_Bool            GetColDefault( SCTAB nTab, SCCOL nCol, SCROW nLastRow, SCROW& nDefault);
1409     sal_Bool            GetRowDefault( SCTAB nTab, SCROW nRow, SCCOL nLastCol, SCCOL& nDefault);
1410 
1411     sal_Bool            UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, sal_Bool bShow );
1412     sal_Bool            UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, sal_Bool bShow );
1413 
1414     void            StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
1415     void            ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
1416 
1417     SC_DLLPUBLIC ScPatternAttr*     GetDefPattern() const;
1418     SC_DLLPUBLIC ScDocumentPool*        GetPool();
1419     SC_DLLPUBLIC ScStyleSheetPool*  GetStyleSheetPool() const;
1420 
1421     // PageStyle:
1422     SC_DLLPUBLIC const String&  GetPageStyle( SCTAB nTab ) const;
1423     SC_DLLPUBLIC void           SetPageStyle( SCTAB nTab, const String& rName );
1424     Size            GetPageSize( SCTAB nTab ) const;
1425     void            SetPageSize( SCTAB nTab, const Size& rSize );
1426     void            SetRepeatArea( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
1427     void            InvalidatePageBreaks(SCTAB nTab);
1428     void            UpdatePageBreaks( SCTAB nTab, const ScRange* pUserArea = NULL );
1429     void            RemoveManualBreaks( SCTAB nTab );
1430     sal_Bool            HasManualBreaks( SCTAB nTab ) const;
1431 
1432     sal_Bool            IsPageStyleInUse( const String& rStrPageStyle, SCTAB* pInTab = NULL );
1433     sal_Bool            RemovePageStyleInUse( const String& rStrPageStyle );
1434     sal_Bool            RenamePageStyleInUse( const String& rOld, const String& rNew );
1435     void            ModifyStyleSheet( SfxStyleSheetBase& rPageStyle,
1436                                       const SfxItemSet&  rChanges );
1437 
1438     void            PageStyleModified( SCTAB nTab, const String& rNewName );
1439 
1440     SC_DLLPUBLIC sal_Bool           NeedPageResetAfterTab( SCTAB nTab ) const;
1441 
1442     // war vorher im PageStyle untergracht. Jetzt an jeder Tabelle:
1443     SC_DLLPUBLIC sal_Bool           HasPrintRange();
1444     SC_DLLPUBLIC sal_uInt16         GetPrintRangeCount( SCTAB nTab );
1445     SC_DLLPUBLIC const ScRange* GetPrintRange( SCTAB nTab, sal_uInt16 nPos );
1446     SC_DLLPUBLIC const ScRange* GetRepeatColRange( SCTAB nTab );
1447     SC_DLLPUBLIC const ScRange* GetRepeatRowRange( SCTAB nTab );
1448     /** Returns true, if the specified sheet is always printed. */
1449     sal_Bool            IsPrintEntireSheet( SCTAB nTab ) const;
1450 
1451     /** Removes all print ranges. */
1452     SC_DLLPUBLIC void            ClearPrintRanges( SCTAB nTab );
1453     /** Adds a new print ranges. */
1454     SC_DLLPUBLIC void            AddPrintRange( SCTAB nTab, const ScRange& rNew );
1455 //UNUSED2009-05 /** Removes all old print ranges and sets the passed print ranges. */
1456 //UNUSED2009-05 void            SetPrintRange( SCTAB nTab, const ScRange& rNew );
1457     /** Marks the specified sheet to be printed completely. Deletes old print ranges on the sheet! */
1458     SC_DLLPUBLIC void            SetPrintEntireSheet( SCTAB nTab );
1459     SC_DLLPUBLIC void           SetRepeatColRange( SCTAB nTab, const ScRange* pNew );
1460     SC_DLLPUBLIC void           SetRepeatRowRange( SCTAB nTab, const ScRange* pNew );
1461     ScPrintRangeSaver* CreatePrintRangeSaver() const;
1462     void            RestorePrintRanges( const ScPrintRangeSaver& rSaver );
1463 
1464     SC_DLLPUBLIC Rectangle      GetMMRect( SCCOL nStartCol, SCROW nStartRow,
1465                                 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1466     SC_DLLPUBLIC ScRange            GetRange( SCTAB nTab, const Rectangle& rMMRect );
1467 
1468     void            UpdStlShtPtrsFrmNms();
1469     void            StylesToNames();
1470 
1471     SC_DLLPUBLIC void           CopyStdStylesFrom( ScDocument* pSrcDoc );
1472 
1473     CharSet         GetSrcCharSet() const   { return eSrcSet; }
1474     sal_uLong           GetSrcVersion() const   { return nSrcVer; }
1475     SCROW           GetSrcMaxRow() const    { return nSrcMaxRow; }
1476 
1477     void            SetSrcCharSet( CharSet eNew )   { eSrcSet = eNew; }
1478     void            UpdateFontCharSet();
1479 
1480     void            FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
1481                         SCTAB nTab, double nScaleX, double nScaleY,
1482                         sal_Bool bPageMode, sal_Bool bFormulaMode,
1483                         const ScMarkData* pMarkData = NULL );
1484 
1485     SC_DLLPUBLIC SvNumberFormatter* GetFormatTable() const;
1486 
1487     void            Sort( SCTAB nTab, const ScSortParam& rSortParam, sal_Bool bKeepQuery );
1488     SCSIZE          Query( SCTAB nTab, const ScQueryParam& rQueryParam, sal_Bool bKeepSub );
1489     sal_Bool            ValidQuery( SCROW nRow, SCTAB nTab, const ScQueryParam& rQueryParam, sal_Bool* pSpecial = NULL );
1490     SC_DLLPUBLIC sal_Bool           CreateQueryParam( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1491                                         SCTAB nTab, ScQueryParam& rQueryParam );
1492     void            GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab, String& rStr);
1493 
1494     sal_Bool            GetFilterEntries( SCCOL nCol, SCROW nRow, SCTAB nTab,
1495                                 bool bFilter, TypedScStrCollection& rStrings, bool& rHasDates);
1496     SC_DLLPUBLIC sal_Bool           GetFilterEntriesArea( SCCOL nCol, SCROW nStartRow, SCROW nEndRow,
1497                                 SCTAB nTab, TypedScStrCollection& rStrings, bool& rHasDates );
1498     sal_Bool            GetDataEntries( SCCOL nCol, SCROW nRow, SCTAB nTab,
1499                                 TypedScStrCollection& rStrings, sal_Bool bLimit = sal_False );
1500     sal_Bool            GetFormulaEntries( TypedScStrCollection& rStrings );
1501 
1502     sal_Bool            HasAutoFilter( SCCOL nCol, SCROW nRow, SCTAB nTab );
1503 
1504     SC_DLLPUBLIC sal_Bool           HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1505                                     SCTAB nTab );
1506     SC_DLLPUBLIC sal_Bool           HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1507                                     SCTAB nTab );
1508 
1509     SfxPrinter*     GetPrinter( sal_Bool bCreateIfNotExist = sal_True );
1510     void            SetPrinter( SfxPrinter* pNewPrinter );
1511     VirtualDevice*  GetVirtualDevice_100th_mm();
1512     SC_DLLPUBLIC OutputDevice*  GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice...
1513 
1514     void            EraseNonUsedSharedNames(sal_uInt16 nLevel);
1515     sal_Bool            GetNextSpellingCell(SCCOL& nCol, SCROW& nRow, SCTAB nTab,
1516                                         sal_Bool bInSel, const ScMarkData& rMark) const;
1517 
1518     sal_Bool            ReplaceStyle(const SvxSearchItem& rSearchItem,
1519                                  SCCOL nCol, SCROW nRow, SCTAB nTab,
1520                                  ScMarkData& rMark, sal_Bool bIsUndo);
1521 
1522     void            DoColResize( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCSIZE nAdd );
1523 
1524     void            InvalidateTextWidth( const String& rStyleName );
1525     void            InvalidateTextWidth( SCTAB nTab );
1526     void            InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo, sal_Bool bNumFormatChanged );
1527 
1528     sal_Bool            IdleCalcTextWidth();
1529     sal_Bool            IdleCheckLinks();
1530 
1531     sal_Bool            ContinueOnlineSpelling();   // sal_True = etwas gefunden
1532 
1533     void            RepaintRange( const ScRange& rRange );
1534 
1535     sal_Bool        IsIdleDisabled() const      { return bIdleDisabled; }
1536     void            DisableIdle(sal_Bool bDo)   { bIdleDisabled = bDo; }
1537 
1538     sal_Bool            IsDetectiveDirty() const     { return bDetectiveDirty; }
1539     void            SetDetectiveDirty(sal_Bool bSet) { bDetectiveDirty = bSet; }
1540 
1541     void            RemoveAutoSpellObj();
1542     void            SetOnlineSpellPos( const ScAddress& rPos );
1543     SC_DLLPUBLIC sal_Bool           SetVisibleSpellRange( const ScRange& rRange );  // sal_True = changed
1544 
1545     sal_uInt8           GetMacroCallMode() const     { return nMacroCallMode; }
1546     void            SetMacroCallMode(sal_uInt8 nNew)     { nMacroCallMode = nNew; }
1547 
1548     sal_Bool            GetHasMacroFunc() const      { return bHasMacroFunc; }
1549     void            SetHasMacroFunc(sal_Bool bSet)   { bHasMacroFunc = bSet; }
1550 
1551     sal_Bool            CheckMacroWarn();
1552 
1553     void            SetRangeOverflowType(sal_uInt32 nType)  { nRangeOverflowType = nType; }
1554     sal_Bool        HasRangeOverflow() const                { return nRangeOverflowType != 0; }
1555     SC_DLLPUBLIC sal_uInt32      GetRangeOverflowType() const            { return nRangeOverflowType; }
1556 
1557     // fuer Broadcasting/Listening
1558     void            SetNoSetDirty( sal_Bool bVal ) { bNoSetDirty = bVal; }
1559     sal_Bool            GetNoSetDirty() const { return bNoSetDirty; }
1560     void            SetInsertingFromOtherDoc( sal_Bool bVal ) { bInsertingFromOtherDoc = bVal; }
1561     sal_Bool            IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc; }
1562     void            SetLoadingMedium( bool bVal );
1563     void            SetImportingXML( bool bVal );
1564     bool            IsImportingXML() const { return bImportingXML; }
1565     void            SetXMLFromWrapper( sal_Bool bVal );
1566     sal_Bool            IsXMLFromWrapper() const { return bXMLFromWrapper; }
1567     void            SetCalcingAfterLoad( sal_Bool bVal ) { bCalcingAfterLoad = bVal; }
1568     sal_Bool            IsCalcingAfterLoad() const { return bCalcingAfterLoad; }
1569     void            SetNoListening( sal_Bool bVal ) { bNoListening = bVal; }
1570     sal_Bool            GetNoListening() const { return bNoListening; }
1571     ScBroadcastAreaSlotMachine* GetBASM() const { return pBASM; }
1572 
1573     ScChartListenerCollection* GetChartListenerCollection() const
1574                         { return pChartListenerCollection; }
1575     void            SetChartListenerCollection( ScChartListenerCollection*,
1576                         sal_Bool bSetChartRangeLists = sal_False );
1577     void            UpdateChart( const String& rName );
1578     void            RestoreChartListener( const String& rName );
1579     SC_DLLPUBLIC void           UpdateChartListenerCollection();
1580     sal_Bool            IsChartListenerCollectionNeedsUpdate() const
1581                         { return bChartListenerCollectionNeedsUpdate; }
1582     void            SetChartListenerCollectionNeedsUpdate( sal_Bool bFlg )
1583                         { bChartListenerCollectionNeedsUpdate = bFlg; }
1584     void            AddOLEObjectToCollection(const String& rName);
1585 
1586     ScChangeViewSettings* GetChangeViewSettings() const     { return pChangeViewSettings; }
1587     SC_DLLPUBLIC void               SetChangeViewSettings(const ScChangeViewSettings& rNew);
1588 
1589     vos::ORef<SvxForbiddenCharactersTable> GetForbiddenCharacters();
1590     void            SetForbiddenCharacters( const vos::ORef<SvxForbiddenCharactersTable> xNew );
1591 
1592     sal_uInt8           GetAsianCompression() const;        // CharacterCompressionType values
1593     sal_Bool            IsValidAsianCompression() const;
1594     void            SetAsianCompression(sal_uInt8 nNew);
1595 
1596     sal_Bool            GetAsianKerning() const;
1597     sal_Bool            IsValidAsianKerning() const;
1598     void            SetAsianKerning(sal_Bool bNew);
1599 
1600     void            ApplyAsianEditSettings(ScEditEngineDefaulter& rEngine);
1601 
1602     sal_uInt8           GetEditTextDirection(SCTAB nTab) const; // EEHorizontalTextDirection values
1603 
1604     SC_DLLPUBLIC ScLkUpdMode        GetLinkMode() const             { return eLinkMode ;}
1605     void            SetLinkMode( ScLkUpdMode nSet ) {   eLinkMode  = nSet;}
1606 
1607 
1608 private:
1609     ScDocument(const ScDocument& r); // disabled with no definition
1610 
1611     void                FindMaxRotCol( SCTAB nTab, RowInfo* pRowInfo, SCSIZE nArrCount,
1612                                         SCCOL nX1, SCCOL nX2 ) const;
1613 
1614     sal_uInt16              RowDifferences( SCROW nThisRow, SCTAB nThisTab,
1615                                         ScDocument& rOtherDoc,
1616                                         SCROW nOtherRow, SCTAB nOtherTab,
1617                                         SCCOL nMaxCol, SCCOLROW* pOtherCols );
1618     sal_uInt16              ColDifferences( SCCOL nThisCol, SCTAB nThisTab,
1619                                         ScDocument& rOtherDoc,
1620                                         SCCOL nOtherCol, SCTAB nOtherTab,
1621                                         SCROW nMaxRow, SCCOLROW* pOtherRows );
1622     void                FindOrder( SCCOLROW* pOtherRows, SCCOLROW nThisEndRow, SCCOLROW nOtherEndRow,
1623                                         sal_Bool bColumns,
1624                                         ScDocument& rOtherDoc, SCTAB nThisTab, SCTAB nOtherTab,
1625                                         SCCOLROW nEndCol, SCCOLROW* pTranslate,
1626                                         ScProgress* pProgress, sal_uLong nProAdd );
1627     sal_Bool                OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpellPos,
1628                                         sal_uInt16 nMaxTest );
1629 
1630     DECL_LINK( TrackTimeHdl, Timer* );
1631 
1632     static ScRecursionHelper*   CreateRecursionHelperInstance();
1633 
1634 public:
1635     void                StartListeningArea( const ScRange& rRange,
1636                                             SvtListener* pListener );
1637     void                EndListeningArea( const ScRange& rRange,
1638                                             SvtListener* pListener );
1639                         /** Broadcast wrapper, calls
1640     SC_DLLPUBLIC                         rHint.GetCell()->Broadcast() and AreaBroadcast()
1641                             and TrackFormulas() and conditional format list
1642                             SourceChanged().
1643                             Preferred.
1644                          */
1645     void                Broadcast( const ScHint& rHint );
1646                         /// deprecated
1647     void                Broadcast( sal_uLong nHint, const ScAddress& rAddr,
1648                                     ScBaseCell* pCell );
1649                         /// only area, no cell broadcast
1650     void                AreaBroadcast( const ScHint& rHint );
1651                         /// only areas in range, no cell broadcasts
1652     void                AreaBroadcastInRange( const ScRange& rRange,
1653                                               const ScHint& rHint );
1654     void                DelBroadcastAreasInRange( const ScRange& rRange );
1655     void                UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode,
1656                                             const ScRange& rRange,
1657                                             SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
1658 
1659 
1660     void                StartListeningCell( const ScAddress& rAddress,
1661                                             SvtListener* pListener );
1662     void                EndListeningCell( const ScAddress& rAddress,
1663                                             SvtListener* pListener );
1664     void                PutInFormulaTree( ScFormulaCell* pCell );
1665     void                RemoveFromFormulaTree( ScFormulaCell* pCell );
1666     void                CalcFormulaTree( sal_Bool bOnlyForced = sal_False,
1667                                         sal_Bool bNoProgressBar = sal_False );
1668     void                ClearFormulaTree();
1669     void                AppendToFormulaTrack( ScFormulaCell* pCell );
1670     void                RemoveFromFormulaTrack( ScFormulaCell* pCell );
1671     void                TrackFormulas( sal_uLong nHintId = SC_HINT_DATACHANGED );
1672     sal_uInt16              GetFormulaTrackCount() const { return nFormulaTrackCount; }
1673     sal_Bool                IsInFormulaTree( ScFormulaCell* pCell ) const;
1674     sal_Bool                IsInFormulaTrack( ScFormulaCell* pCell ) const;
1675     sal_uInt16              GetHardRecalcState() { return nHardRecalcState; }
1676     void                SetHardRecalcState( sal_uInt16 nVal ) { nHardRecalcState = nVal; }
1677     void                StartAllListeners();
1678     const ScFormulaCell*    GetFormulaTree() const { return pFormulaTree; }
1679     sal_Bool                HasForcedFormulas() const { return bHasForcedFormulas; }
1680     void                SetForcedFormulas( sal_Bool bVal ) { bHasForcedFormulas = bVal; }
1681     sal_uLong               GetFormulaCodeInTree() const { return nFormulaCodeInTree; }
1682     sal_Bool                IsInInterpreter() const { return nInterpretLevel != 0; }
1683     sal_uInt16              GetInterpretLevel() { return nInterpretLevel; }
1684     void                IncInterpretLevel()
1685                             {
1686                                 if ( nInterpretLevel < USHRT_MAX )
1687                                     nInterpretLevel++;
1688                             }
1689     void                DecInterpretLevel()
1690                             {
1691                                 if ( nInterpretLevel )
1692                                     nInterpretLevel--;
1693                             }
1694     sal_Bool                IsInMacroInterpreter() const { return nMacroInterpretLevel != 0; }
1695     sal_uInt16              GetMacroInterpretLevel() { return nMacroInterpretLevel; }
1696     void                IncMacroInterpretLevel()
1697                             {
1698                                 if ( nMacroInterpretLevel < USHRT_MAX )
1699                                     nMacroInterpretLevel++;
1700                             }
1701     void                DecMacroInterpretLevel()
1702                             {
1703                                 if ( nMacroInterpretLevel )
1704                                     nMacroInterpretLevel--;
1705                             }
1706     sal_Bool                IsInInterpreterTableOp() const { return nInterpreterTableOpLevel != 0; }
1707     sal_uInt16              GetInterpreterTableOpLevel() { return nInterpreterTableOpLevel; }
1708     void                IncInterpreterTableOpLevel()
1709                             {
1710                                 if ( nInterpreterTableOpLevel < USHRT_MAX )
1711                                     nInterpreterTableOpLevel++;
1712                             }
1713     void                DecInterpreterTableOpLevel()
1714                             {
1715                                 if ( nInterpreterTableOpLevel )
1716                                     nInterpreterTableOpLevel--;
1717                             }
1718                         // add a formula to be remembered for TableOp broadcasts
1719     void                AddTableOpFormulaCell( ScFormulaCell* );
1720     void                InvalidateLastTableOpParams() { aLastTableOpParams.bValid = sal_False; }
1721     ScRecursionHelper&  GetRecursionHelper()
1722                             {
1723                                 if (!pRecursionHelper)
1724                                     pRecursionHelper = CreateRecursionHelperInstance();
1725                                 return *pRecursionHelper;
1726                             }
1727     sal_Bool                IsInDtorClear() const { return bInDtorClear; }
1728     void                SetExpandRefs( sal_Bool bVal ) { bExpandRefs = bVal; }
1729     sal_Bool                IsExpandRefs() { return bExpandRefs; }
1730 
1731     SC_DLLPUBLIC void               IncSizeRecalcLevel( SCTAB nTab );
1732     SC_DLLPUBLIC void               DecSizeRecalcLevel( SCTAB nTab, bool bUpdateNoteCaptionPos = true );
1733 
1734     sal_uLong               GetXMLImportedFormulaCount() const { return nXMLImportedFormulaCount; }
1735     void                IncXMLImportedFormulaCount( sal_uLong nVal )
1736                             {
1737                                 if ( nXMLImportedFormulaCount + nVal > nXMLImportedFormulaCount )
1738                                     nXMLImportedFormulaCount += nVal;
1739                             }
1740     void                DecXMLImportedFormulaCount( sal_uLong nVal )
1741                             {
1742                                 if ( nVal <= nXMLImportedFormulaCount )
1743                                     nXMLImportedFormulaCount -= nVal;
1744                                 else
1745                                     nXMLImportedFormulaCount = 0;
1746                             }
1747 
1748     void                StartTrackTimer();
1749 
1750     void            CompileDBFormula();
1751     void            CompileDBFormula( sal_Bool bCreateFormulaString );
1752     void            CompileNameFormula( sal_Bool bCreateFormulaString );
1753     void            CompileColRowNameFormula();
1754 
1755     /** Maximum string length of a column, e.g. for dBase export.
1756         @return String length in octets (!) of the destination encoding. In
1757                 case of non-octet encodings (e.g. UCS2) the length in code
1758                 points times sizeof(sal_Unicode) is returned. */
1759     sal_Int32       GetMaxStringLen( SCTAB nTab, SCCOL nCol,
1760                                      SCROW nRowStart, SCROW nRowEnd,
1761                                      CharSet eCharSet ) const;
1762     /** Maximum string length of numerical cells of a column, e.g. for dBase export.
1763         @return String length in characters (!) including the decimal
1764                 separator, and the decimal precision needed. */
1765     xub_StrLen      GetMaxNumberStringLen( sal_uInt16& nPrecision,
1766                                            SCTAB nTab, SCCOL nCol,
1767                                            SCROW nRowStart, SCROW nRowEnd ) const;
1768 
1769     void    KeyInput( const KeyEvent& rKEvt );      // TimerDelays etc.
1770 
1771     ScChangeTrack*      GetChangeTrack() const { return pChangeTrack; }
1772 
1773     //! only for import filter, deletes any existing ChangeTrack via
1774     //! EndChangeTracking() and takes ownership of new ChangeTrack pTrack
1775     SC_DLLPUBLIC void           SetChangeTrack( ScChangeTrack* pTrack );
1776 
1777     void            StartChangeTracking();
1778     void            EndChangeTracking();
1779 
1780     SC_DLLPUBLIC void           CompareDocument( ScDocument& rOtherDoc );
1781 
1782     void            AddUnoObject( SfxListener& rObject );
1783     void            RemoveUnoObject( SfxListener& rObject );
1784     void            BroadcastUno( const SfxHint &rHint );
1785     void            AddUnoListenerCall( const ::com::sun::star::uno::Reference<
1786                                             ::com::sun::star::util::XModifyListener >& rListener,
1787                                         const ::com::sun::star::lang::EventObject& rEvent );
1788 
1789     void            SetInLinkUpdate(sal_Bool bSet);             // TableLink or AreaLink
1790     sal_Bool            IsInLinkUpdate() const;                 // including DdeLink
1791 
1792     SC_DLLPUBLIC SfxItemPool*       GetEditPool() const;
1793     SC_DLLPUBLIC SfxItemPool*       GetEnginePool() const;
1794     SC_DLLPUBLIC ScFieldEditEngine& GetEditEngine();
1795     SC_DLLPUBLIC ScNoteEditEngine&  GetNoteEngine();
1796 
1797     ScRefreshTimerControl*  GetRefreshTimerControl() const
1798         { return pRefreshTimerControl; }
1799     ScRefreshTimerControl * const * GetRefreshTimerControlAddress() const
1800         { return &pRefreshTimerControl; }
1801 
1802     void            SetPastingDrawFromOtherDoc( sal_Bool bVal )
1803                         { bPastingDrawFromOtherDoc = bVal; }
1804     sal_Bool            PastingDrawFromOtherDoc() const
1805                         { return bPastingDrawFromOtherDoc; }
1806 
1807                     /// an ID unique to each document instance
1808     sal_uInt32      GetDocumentID() const;
1809 
1810     void            InvalidateStyleSheetUsage()
1811                         { bStyleSheetUsageInvalid = sal_True; }
1812     void GetSortParam( ScSortParam& rParam, SCTAB nTab );
1813     void SetSortParam( ScSortParam& rParam, SCTAB nTab );
1814 
1815     inline void     SetVbaEventProcessor( const com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor >& rxVbaEvents )
1816                         { mxVbaEvents = rxVbaEvents; }
1817     inline com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor >
1818                     GetVbaEventProcessor() const { return mxVbaEvents; }
1819 
1820     /** Should only be GRAM_PODF or GRAM_ODFF. */
1821     void                SetStorageGrammar( formula::FormulaGrammar::Grammar eGrammar );
1822     formula::FormulaGrammar::Grammar  GetStorageGrammar() const
1823                             { return eStorageGrammar; }
1824 
1825     SfxUndoManager*     GetUndoManager();
1826     bool IsInVBAMode() const;
1827     ScRowBreakIterator* GetRowBreakIterator(SCTAB nTab) const;
1828 
1829 private: // CLOOK-Impl-Methoden
1830 
1831     /**
1832      * Use this class as a locale variable to merge number formatter from
1833      * another document, and set NULL pointer to pFormatExchangeList when
1834      * done.
1835      */
1836     class NumFmtMergeHandler
1837     {
1838     public:
1839         explicit NumFmtMergeHandler(ScDocument* pDoc, ScDocument* pSrcDoc);
1840         ~NumFmtMergeHandler();
1841 
1842     private:
1843         ScDocument* mpDoc;
1844     };
1845 
1846     void    MergeNumberFormatter(ScDocument* pSrcDoc);
1847 
1848     void    ImplCreateOptions(); // bei Gelegenheit auf on-demand umstellen?
1849     void    ImplDeleteOptions();
1850 
1851     void    DeleteDrawLayer();
1852     void    DeleteColorTable();
1853     SC_DLLPUBLIC sal_Bool   DrawGetPrintArea( ScRange& rRange, sal_Bool bSetHor, sal_Bool bSetVer ) const;
1854     void    DrawMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos );
1855     void    DrawCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos );
1856 
1857     void    UpdateDrawPrinter();
1858     void    UpdateDrawLanguages();
1859     void    UpdateDrawDefaults();
1860     SC_DLLPUBLIC void   InitClipPtrs( ScDocument* pSourceDoc );
1861 
1862     void    LoadDdeLinks(SvStream& rStream);
1863     void    SaveDdeLinks(SvStream& rStream) const;
1864 
1865     void    DeleteAreaLinksOnTab( SCTAB nTab );
1866     void    UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
1867                              const ScRange& r, SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
1868 
1869     void    CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks, bool bAllTabs);
1870     void    CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameData& rRangeNames);
1871     void    UpdateRangeNamesInFormulas(
1872         ScClipRangeNameData& rRangeNames, const ScRangeList& rDestRanges, const ScMarkData& rMark,
1873         SCCOL nXw, SCROW nYw);
1874 
1875     sal_Bool    HasPartOfMerged( const ScRange& rRange );
1876 
1877     std::map< SCTAB, ScSortParam > mSheetSortParams;
1878 
1879 };
1880 inline void ScDocument::GetSortParam( ScSortParam& rParam, SCTAB nTab )
1881 {
1882     rParam = mSheetSortParams[ nTab ];
1883 }
1884 
1885 inline void ScDocument::SetSortParam( ScSortParam& rParam, SCTAB nTab )
1886 {
1887     mSheetSortParams[ nTab ] = rParam;
1888 }
1889 
1890 #endif
1891 
1892 
1893