Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sc / inc / document.hxx
blobdff46dffd69985d9e373c8f6ae525a1a856b52d7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_INC_DOCUMENT_HXX
21 #define INCLUDED_SC_INC_DOCUMENT_HXX
23 #include <vcl/prntypes.hxx>
24 #include <vcl/timer.hxx>
25 #include <vcl/idle.hxx>
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <vcl/vclptr.hxx>
28 #include "scdllapi.h"
29 #include "interpretercontext.hxx"
30 #include "rangelst.hxx"
31 #include "rangenam.hxx"
32 #include "tabopparams.hxx"
33 #include "types.hxx"
34 #include <formula/grammar.hxx>
35 #include <formula/types.hxx>
36 #include <com/sun/star/chart2/XChartDocument.hpp>
37 #include "typedstrdata.hxx"
38 #include "calcmacros.hxx"
39 #include "calcconfig.hxx"
40 #include <o3tl/deleter.hxx>
41 #include <svl/hint.hxx>
42 #include <tools/gen.hxx>
43 #include <svl/zforlist.hxx>
44 #include <svl/typedwhich.hxx>
46 #include <cassert>
47 #include <memory>
48 #include <map>
49 #include <mutex>
50 #include <set>
51 #include <vector>
53 #include "markdata.hxx"
55 enum class SvtScriptType;
56 enum class ScMF;
57 enum class FormulaError : sal_uInt16;
58 enum class CharCompressType;
59 enum class EEHorizontalTextDirection;
60 namespace editeng { class SvxBorderLine; }
61 namespace formula { struct VectorRefArray; }
62 namespace svl {
64 class SharedString;
65 class SharedStringPool;
69 namespace sc {
71 struct FormulaGroupContext;
72 class StartListeningContext;
73 class EndListeningContext;
74 class CopyFromClipContext;
75 class ColumnSpanSet;
76 struct ColumnBlockPosition;
77 struct RefUpdateContext;
78 class EditTextIterator;
79 struct NoteEntry;
80 class DocumentStreamAccess;
81 class DocumentLinkManager;
82 class CellValues;
83 class TableValues;
84 class RowHeightContext;
85 struct SetFormulaDirtyContext;
86 class RefMovedHint;
87 struct SortUndoParam;
88 struct ReorderParam;
89 class FormulaGroupAreaListener;
90 class ColumnSet;
91 class UpdatedRangeNames;
92 class TableColumnBlockPositionSet;
93 class ColumnIterator;
94 class ExternalDataMapper;
98 class Fraction;
99 class SvxFontItem;
101 class KeyEvent;
102 class OutputDevice;
103 class SdrObject;
104 class SfxBroadcaster;
105 class SfxListener;
106 class SfxHint;
107 class SfxItemSet;
108 class SfxObjectShell;
109 class SfxBindings;
110 class SfxPoolItem;
111 class SfxItemPool;
112 class SfxPrinter;
113 class SfxStyleSheetBase;
114 class SvMemoryStream;
115 class SvNumberFormatter;
116 class SvxBoxInfoItem;
117 class SvxBoxItem;
118 class SvxForbiddenCharactersTable;
119 namespace sfx2 {
120 class LinkManager;
122 class SvxSearchItem;
123 namespace vcl { class Window; }
124 class XColorList;
126 struct ScAttrEntry;
127 class ScAutoFormatData;
128 class ScBroadcastAreaSlotMachine;
129 class ScChangeViewSettings;
130 class ScChartListenerCollection;
131 class ScClipOptions;
132 class ScConditionalFormat;
133 class ScConditionalFormatList;
134 class ScDBCollection;
135 class ScDBData;
136 class ScDetOpData;
137 class ScDetOpList;
138 class ScDocOptions;
139 class ScDocProtection;
140 class ScDocumentPool;
141 class ScDrawLayer;
142 class ScExtDocOptions;
143 class ScExternalRefManager;
144 class ScFormulaCell;
145 class ScMacroManager;
146 class ScMarkData;
147 class ScOutlineTable;
148 class ScPatternAttr;
149 class ScPrintRangeSaver;
150 class ScRangeData;
151 class ScRangeName;
152 class ScStyleSheet;
153 class ScStyleSheetPool;
154 class ScTable;
155 class ScTableProtection;
156 class ScTokenArray;
157 class ScValidationData;
158 class ScValidationDataList;
159 class ScViewOptions;
160 class ScChangeTrack;
161 class ScEditEngineDefaulter;
162 class ScFieldEditEngine;
163 class ScNoteEditEngine;
164 struct ScConsolidateParam;
165 class ScDPObject;
166 class ScDPCollection;
167 class ScMatrix;
168 class ScScriptTypeData;
169 class ScPoolHelper;
170 struct ScSortParam;
171 class ScRefreshTimerControl;
172 class ScUnoListenerCalls;
173 class ScUnoRefList;
174 class ScRecursionHelper;
175 struct RowInfo;
176 struct ScTableInfo;
177 struct ScTabOpParam;
178 class VirtualDevice;
179 class ScAutoNameCache;
180 class ScTemporaryChartLock;
181 class ScLookupCache;
182 struct ScLookupCacheMapImpl;
183 class SfxUndoManager;
184 class ScFormulaParserPool;
185 struct ScClipParam;
186 class ScRowBreakIterator;
187 struct ScSetStringParam;
188 class ScDocRowHeightUpdater;
189 struct ScColWidthParam;
190 class ScSheetEvents;
191 class ScProgress;
192 class SvtListener;
193 class ScEditDataArray;
194 class EditTextObject;
195 struct ScRefCellValue;
196 class ScDocumentImport;
197 class ScPostIt;
198 struct ScSubTotalParam;
199 struct ScQueryParam;
200 class ScHint;
201 class SvtBroadcaster;
202 enum class ScDBDataPortion;
203 enum class ScSheetEventId;
204 class BitmapEx;
205 class ScColumnsRange;
206 struct ScFilterEntries;
208 namespace sc {
210 typedef std::map<OUString, BitmapEx> IconSetBitmapMap;
214 namespace com { namespace sun { namespace star {
215 namespace lang {
216 class XMultiServiceFactory;
217 struct EventObject;
219 namespace i18n {
220 class XBreakIterator;
222 namespace util {
223 class XModifyListener;
225 namespace embed {
226 class XEmbeddedObject;
228 namespace script { namespace vba {
229 class XVBAEventProcessor;
231 namespace sheet {
232 struct TablePageBreakData;
234 } } }
236 #define SC_DOC_NEW 0xFFFF
238 #define SC_MACROCALL_ALLOWED 0
240 #define SC_ASIANKERNING_INVALID 0xff
242 enum ScDocumentMode
244 SCDOCMODE_DOCUMENT,
245 SCDOCMODE_CLIP,
246 SCDOCMODE_UNDO,
247 SCDOCMODE_FUNCTIONACCESS
250 enum CommentCaptionState
252 ALLSHOWN, // All comments captions are shown
253 ALLHIDDEN, // All comments captions are hidden
254 MIXED // There are comments in shown and hidden.
257 enum RangeNameScope
259 GLOBAL, // A range name can be defined
260 SHEET // with two scope on Manage Names dialog.
263 struct ScDocStat
265 OUString aDocName;
266 SCTAB nTableCount;
267 sal_uLong nCellCount;
268 sal_uLong nFormulaCount;
269 sal_uInt16 nPageCount;
270 ScDocStat()
271 : nTableCount(0)
272 , nCellCount(0)
273 , nFormulaCount(0)
274 , nPageCount(0)
279 // DDE link modes
280 const sal_uInt8 SC_DDE_DEFAULT = 0;
281 const sal_uInt8 SC_DDE_ENGLISH = 1;
282 const sal_uInt8 SC_DDE_TEXT = 2;
283 const sal_uInt8 SC_DDE_IGNOREMODE = 255; /// For usage in FindDdeLink() only!
285 // During threaded calculation fields being mutated are kept in this struct
286 struct ScDocumentThreadSpecific
288 ScRecursionHelper* pRecursionHelper; // information for recursive and iterative cell formulas
290 ScLookupCacheMapImpl* pLookupCacheMapImpl; // cache for lookups like VLOOKUP and MATCH
292 ScDocumentThreadSpecific() :
293 pRecursionHelper(nullptr),
294 pLookupCacheMapImpl(nullptr)
298 // To be called in the thread at start
299 void SetupFromNonThreadedData(const ScDocumentThreadSpecific& rNonThreadedData);
301 // To be called in the main thread after the thread has finished
302 void MergeBackIntoNonThreadedData(ScDocumentThreadSpecific& rNonThreadedData);
305 /// Enumeration to determine which pieces of the code should not be mutated when set.
306 enum ScMutationGuardFlags
308 // Bit mask bits
309 CORE = 0x0001, /// Core calc data structures should not be mutated
312 class ScDocument
314 friend class ScValueIterator;
315 friend class ScHorizontalValueIterator;
316 friend class ScDBQueryDataIterator;
317 friend class ScFormulaGroupIterator;
318 friend class ScCellIterator;
319 friend class ScQueryCellIterator;
320 friend class ScHorizontalCellIterator;
321 friend class ScHorizontalAttrIterator;
322 friend class ScDocAttrIterator;
323 friend class ScAccessibleTableBase;
324 friend class ScAttrRectIterator;
325 friend class ScDocShell;
326 friend class ScDocRowHeightUpdater;
327 friend class ScColumnTextWidthIterator;
328 friend class ScFormulaCell;
329 friend class ScTable;
330 friend class ScColumn;
331 friend struct ScRefCellValue;
332 friend class ScDocumentImport;
333 friend class sc::DocumentStreamAccess;
334 friend class sc::ColumnSpanSet;
335 friend class sc::EditTextIterator;
336 friend class sc::FormulaGroupAreaListener;
337 friend class sc::TableColumnBlockPositionSet;
338 friend struct ScMutationGuard;
339 friend struct ScMutationDisable;
341 typedef std::vector<ScTable*> TableContainer;
343 public:
344 enum class HardRecalcState
346 OFF, /// normal calculation of dependencies
347 TEMPORARY, /// CalcAll() without broadcast/notify but setting up new listeners
348 ETERNAL /// no new listeners are setup, no broadcast/notify
351 private:
352 rtl::Reference<ScPoolHelper> mxPoolHelper;
354 std::shared_ptr<svl::SharedStringPool> mpCellStringPool;
355 std::unique_ptr<sc::DocumentLinkManager> mpDocLinkMgr;
357 std::shared_ptr<sc::FormulaGroupContext> mpFormulaGroupCxt;
358 bool mbFormulaGroupCxtBlockDiscard;
360 ScCalcConfig maCalcConfig;
362 SfxUndoManager* mpUndoManager;
363 std::unique_ptr<ScFieldEditEngine> mpEditEngine; // uses pEditPool from xPoolHelper
364 std::unique_ptr<ScNoteEditEngine> mpNoteEngine; // uses pEditPool from xPoolHelper
365 SfxObjectShell* mpShell;
366 VclPtr<SfxPrinter> mpPrinter;
367 VclPtr<VirtualDevice> mpVirtualDevice_100th_mm;
368 ScDrawLayer* mpDrawLayer; // SdrModel
369 rtl::Reference<XColorList> pColorList;
370 ScValidationDataList* pValidationList; // validity
371 SvNumberFormatterIndexTable* pFormatExchangeList; // for application of number formats
372 TableContainer maTabs;
373 std::vector<OUString> maTabNames; // for undo document, we need the information tab name <-> index
374 mutable std::unique_ptr<ScRangeName> pRangeName;
375 std::unique_ptr<ScDBCollection> pDBCollection;
376 std::unique_ptr<ScDPCollection> pDPCollection;
377 std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock;
378 std::unique_ptr<ScPatternAttr> pSelectionAttr; // Attributes of a block
379 ScFormulaCell* pFormulaTree; // formula tree (start)
380 ScFormulaCell* pEOFormulaTree; // formula tree (end), last cell
381 ScFormulaCell* pFormulaTrack; // BroadcastTrack (start)
382 ScFormulaCell* pEOFormulaTrack; // BroadcastTrack (end), last cell
383 std::unique_ptr<ScBroadcastAreaSlotMachine> pBASM; // BroadcastAreas
384 ScChartListenerCollection* pChartListenerCollection;
385 std::unique_ptr<SvMemoryStream> pClipData;
386 std::unique_ptr<ScDetOpList> pDetOpList;
387 std::unique_ptr<ScChangeTrack> pChangeTrack;
388 std::unique_ptr<SfxBroadcaster> pUnoBroadcaster;
389 std::unique_ptr<ScUnoListenerCalls> pUnoListenerCalls;
390 std::unique_ptr<ScUnoRefList> pUnoRefUndoList;
391 std::unique_ptr<ScChangeViewSettings> pChangeViewSettings;
392 std::unique_ptr<ScScriptTypeData> pScriptTypeData;
393 std::unique_ptr<ScRefreshTimerControl> pRefreshTimerControl;
394 std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenCharacters;
395 std::unique_ptr<ScDBData> mpAnonymousDBData;
396 std::unique_ptr<sc::ExternalDataMapper> mpDataMapper;
398 std::unique_ptr<ScFieldEditEngine> pCacheFieldEditEngine;
400 std::unique_ptr<ScDocProtection> pDocProtection;
401 std::unique_ptr<ScClipParam> mpClipParam;
403 std::unique_ptr<ScExternalRefManager> pExternalRefMgr;
404 std::unique_ptr<ScMacroManager> mpMacroMgr;
406 // mutable for lazy construction
407 mutable std::unique_ptr< ScFormulaParserPool >
408 mxFormulaParserPool; /// Pool for all external formula parsers used by this document.
410 OUString aDocName; // optional: name of document
411 OUString aDocCodeName; // optional: name of document (twice?)
412 OUString maFileURL; // file URL for copy & paste
413 ScRangePairListRef xColNameRanges;
414 ScRangePairListRef xRowNameRanges;
416 ScViewOptions* pViewOptions; // view options
417 ScDocOptions* pDocOptions; // document options
418 ScExtDocOptions* pExtDocOptions; // for import etc.
419 std::unique_ptr<ScClipOptions> mpClipOptions; // clipboard options
420 std::unique_ptr<ScConsolidateParam> pConsolidateDlgData;
422 ScAutoNameCache* pAutoNameCache; // for automatic name lookup during CompileXML
424 std::unique_ptr<SfxItemSet> pPreviewFont; // convert to std::unique_ptr or whatever
425 ScStyleSheet* pPreviewCellStyle;
426 ScMarkData maPreviewSelection;
427 sal_Int64 nUnoObjectId; // counted up for UNO objects
429 ErrCode nRangeOverflowType; // used in (xml) loading for overflow warnings
431 ScRange aEmbedRange;
432 ScAddress aCurTextWidthCalcPos;
434 Idle aTrackIdle;
436 css::uno::Reference< css::script::vba::XVBAEventProcessor >
437 mxVbaEvents;
438 public:
439 /// list of ScInterpreterTableOpParams currently in use
440 std::vector<std::unique_ptr<ScInterpreterTableOpParams>> m_TableOpList;
441 ScInterpreterTableOpParams aLastTableOpParams; // remember last params
443 private:
445 LanguageType eLanguage; // default language
446 LanguageType eCjkLanguage; // default language for asian text
447 LanguageType eCtlLanguage; // default language for complex text
448 rtl_TextEncoding eSrcSet; // during reading: source character set
450 /** The compiler grammar used in document storage. GRAM_PODF for ODF 1.1
451 documents, GRAM_ODFF for ODF 1.2 documents. */
452 formula::FormulaGrammar::Grammar eStorageGrammar;
454 sal_uLong nFormulaCodeInTree; // formula RPN in the formula tree
455 sal_uLong nXMLImportedFormulaCount; // progress count during XML import
456 sal_uInt16 nInterpretLevel; // >0 if in interpreter
457 sal_uInt16 nMacroInterpretLevel; // >0 if macro in interpreter
458 sal_uInt16 nInterpreterTableOpLevel; // >0 if in interpreter TableOp
460 ScDocumentThreadSpecific maNonThreaded;
462 // There can be only one ScDocument being calculated in a thread at a time, so we can use a
463 // plain thread_local static member.
464 thread_local static ScDocumentThreadSpecific maThreadSpecific;
466 mutable ScInterpreterContext maInterpreterContext;
468 sal_uInt16 nSrcVer; // file version (load/save)
469 sal_uInt16 nFormulaTrackCount;
470 HardRecalcState eHardRecalcState; // off, temporary, eternal
471 SCTAB nVisibleTab; // for OLE etc., don't use inside ScDocument
473 ScLkUpdMode eLinkMode;
475 bool bAutoCalc; // calculate automatically
476 bool bAutoCalcShellDisabled; // in/from/for ScDocShell disabled
477 // are there ForcedFormulas which have to be calculated
478 // in interaction with ScDocShell SetDocumentModified,
479 // AutoCalcShellDisabled and TrackFormulas
480 bool bForcedFormulaPending;
481 bool bCalculatingFormulaTree;
482 bool bIsClip;
483 bool bIsUndo;
484 bool bIsFunctionAccess;
485 bool bIsVisible; // set from view ctor
487 bool bIsEmbedded; // display/adjust Embedded area?
489 // no broadcast, construct no listener during insert from a different
490 // Doc (per filter or the like ), not until CompileAll / CalcAfterLoad
491 bool bInsertingFromOtherDoc;
492 bool bLoadingMedium;
493 bool bImportingXML; // special handling of formula text
494 bool bCalcingAfterLoad; // in CalcAfterLoad TRUE
495 // don't construct/destruct listeners temporarily
496 bool bNoListening;
497 bool mbIdleEnabled;
498 bool bInLinkUpdate; // TableLink or AreaLink
499 bool bChartListenerCollectionNeedsUpdate;
500 // are/were there RC_FORCED formula cells in the document (if set once to TRUE then set forever)
501 bool bHasForcedFormulas;
502 // is the Doc being destroyed? (no Notify-Tracking etc. needed anymore)
503 bool bInDtorClear;
504 // expand reference if insert column/row takes place at the border
505 // of a reference
506 // is fetched in each UpdateReference from InputOptions,
507 // assigned, and restored at the end of UpdateReference
508 bool bExpandRefs;
509 // for detective update, is set for each change of a formula
510 bool bDetectiveDirty;
512 bool bLinkFormulaNeedingCheck; // valid only after loading, for ocDde and ocWebservice
514 CharCompressType nAsianCompression;
515 sal_uInt8 nAsianKerning;
517 bool bPastingDrawFromOtherDoc;
519 sal_uInt8 nInDdeLinkUpdate; // originating DDE links (stacked bool)
521 bool bInUnoBroadcast;
522 bool bInUnoListenerCall;
523 sal_uInt32 nAdjustHeightLock;
524 formula::FormulaGrammar::Grammar eGrammar;
526 mutable bool bStyleSheetUsageInvalid;
528 bool mbUndoEnabled:1;
529 bool mbExecuteLinkEnabled:1;
530 bool mbChangeReadOnlyEnabled:1; // allow changes in read-only document (for API import filters)
531 bool mbStreamValidLocked:1;
532 bool mbUserInteractionEnabled:1; // whether or not to launch any kind of interactive dialogs.
534 sal_Int16 mnNamedRangesLockCount;
536 std::set<ScFormulaCell*> maSubTotalCells;
538 bool mbUseEmbedFonts;
540 std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap;
542 bool mbTrackFormulasPending : 1;
543 bool mbFinalTrackFormulas : 1;
545 size_t mnMutationGuardFlags;
547 public:
548 bool IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBorder);
549 void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge);
550 bool IsUsingEmbededFonts() { return mbUseEmbedFonts; }
551 void SetIsUsingEmbededFonts( bool bUse ) { mbUseEmbedFonts = bUse; }
552 SC_DLLPUBLIC sal_uLong GetCellCount() const; // all cells
553 SC_DLLPUBLIC sal_uLong GetFormulaGroupCount() const; // all cells
554 sal_uLong GetCodeCount() const; // RPN-Code in formulas
555 DECL_LINK( GetUserDefinedColor, sal_uInt16, Color* );
556 // number formatter
557 public:
558 SC_DLLPUBLIC ScDocument( ScDocumentMode eMode = SCDOCMODE_DOCUMENT,
559 SfxObjectShell* pDocShell = nullptr );
560 SC_DLLPUBLIC ~ScDocument();
562 void SetName( const OUString& r ) { aDocName = r; }
563 const OUString& GetCodeName() const { return aDocCodeName; }
564 void SetCodeName( const OUString& r ) { aDocCodeName = r; }
565 const OUString& GetFileURL() const { return maFileURL; }
567 void GetDocStat( ScDocStat& rDocStat );
569 SC_DLLPUBLIC void InitDrawLayer( SfxObjectShell* pDocShell = nullptr );
571 ScInterpreterContext& GetNonThreadedContext() const
573 // GetFormatTable() asserts that we are not in a threaded calculation
574 maInterpreterContext.mpFormatter = GetFormatTable();
575 return maInterpreterContext;
577 void MergeBackIntoNonThreadedContext( ScInterpreterContext& threadedContext );
578 void SetThreadedGroupCalcInProgress( bool set ) { (void)this; ScGlobal::bThreadedGroupCalcInProgress = set; }
579 bool IsThreadedGroupCalcInProgress() const { (void)this; return ScGlobal::bThreadedGroupCalcInProgress; }
581 SC_DLLPUBLIC sfx2::LinkManager* GetLinkManager();
582 SC_DLLPUBLIC const sfx2::LinkManager* GetLinkManager() const;
584 sc::DocumentLinkManager& GetDocLinkManager();
585 const sc::DocumentLinkManager& GetDocLinkManager() const;
587 SC_DLLPUBLIC const ScDocOptions& GetDocOptions() const;
588 SC_DLLPUBLIC void SetDocOptions( const ScDocOptions& rOpt );
589 SC_DLLPUBLIC const ScViewOptions& GetViewOptions() const;
590 SC_DLLPUBLIC void SetViewOptions( const ScViewOptions& rOpt );
591 void SetPrintOptions();
593 ScExtDocOptions* GetExtDocOptions() { return pExtDocOptions; }
594 SC_DLLPUBLIC void SetExtDocOptions( ScExtDocOptions* pNewOptions );
596 ScClipOptions* GetClipOptions() { return mpClipOptions.get(); }
597 void SetClipOptions(const ScClipOptions& rClipOptions);
599 SC_DLLPUBLIC void GetLanguage( LanguageType& rLatin, LanguageType& rCjk, LanguageType& rCtl ) const;
600 void SetLanguage( LanguageType eLatin, LanguageType eCjk, LanguageType eCtl );
602 void SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pData );
603 const ScConsolidateParam* GetConsolidateDlgData() const { return pConsolidateDlgData.get(); }
605 void Clear( bool bFromDestructor = false );
607 std::unique_ptr<ScFieldEditEngine> CreateFieldEditEngine();
608 void DisposeFieldEditEngine(std::unique_ptr<ScFieldEditEngine>& rpEditEngine);
611 * Get all range names that are local to each table. It only returns
612 * non-empty range name set.
614 SC_DLLPUBLIC void GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rRangeNames) const;
615 SC_DLLPUBLIC void SetAllRangeNames(const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap);
616 SC_DLLPUBLIC void GetRangeNameMap(std::map<OUString, ScRangeName*>& rRangeName);
617 SC_DLLPUBLIC ScRangeName* GetRangeName(SCTAB nTab) const;
618 SC_DLLPUBLIC ScRangeName* GetRangeName() const;
619 void SetRangeName(SCTAB nTab, std::unique_ptr<ScRangeName> pNew);
620 void SetRangeName( std::unique_ptr<ScRangeName> pNewRangeName );
621 bool IsAddressInRangeName( RangeNameScope eScope, const ScAddress& rAddress);
623 /** Find a named expression / range name in either global or a local scope.
624 @param nTab
625 If <0 search nIndex in global scope, if >=0 search nIndex in scope of nTab.
626 @param nIndex
627 Index of named expression / range name.
628 @return nullptr if indexed name not found.
630 ScRangeData* FindRangeNameBySheetAndIndex( SCTAB nTab, sal_uInt16 nIndex ) const;
632 /** Recursively find all named expressions that directly or indirectly
633 (nested) reference a given sheet, starting from a given named
634 expression nTokenTab/nTokenIndex.
636 Used to collect all named expressions/ranges that will need to be
637 copied along when copying sheets.
639 The different tab/sheets passed cater for the situation that a sheet is
640 copied and was already inserted and global names are already adjusted
641 but the sheet-local names of the shifted original sheet are not yet. If
642 no sheet was inserted and global and local names' references not
643 updated yet, then all 4 tab arguments would be identical.
645 @param nTokenTab
646 Tab/sheet on which to find the name, -1 if global scope.
647 For example obtained from ocName token.
649 @param nTokenIndex
650 Index of named expression. For example obtained from ocName token.
652 @param nGlobalRefTab
653 Tab to check if used in global names.
655 @param nLocalRefTab
656 Tab to check if used in sheet-local names.
658 @param nOldTokenTab
659 The original tab of the copied sheet, used as sheet-local
660 base position for relative references.
662 @param nOldTokenTabReplacement
663 The replacement to use for relative references if the name
664 encountered uses nOldTokenTab as base position.
666 @param bSameDoc
667 FALSE if collecting names for a sheet to be copied to another
668 document. Then all names encountered are considered to be
669 referencing the sheet. Else TRUE if collecting names to be
670 copied into the same document.
672 @param nRecursion
673 Recursion guard, initialize with 0.
675 bool FindRangeNamesReferencingSheet( sc::UpdatedRangeNames& rIndexes,
676 SCTAB nTokenTab, const sal_uInt16 nTokenIndex,
677 SCTAB nGlobalRefTab, SCTAB nLocalRefTab, SCTAB nOldTokenTab, SCTAB nOldTokenTabReplacement,
678 bool bSameDoc, int nRecursion ) const;
680 /** If necessary (name references sheet rOldPos.Tab()) copy and adjust
681 named expression/range from sheet-local to sheet-local, or global to
682 sheet-local if bGlobalNamesToLocal==true.
684 Also copies nested names and adjusts the ocName tokens of the calling name.
686 @param rSheet
687 On entry, the original sheet of the named expression/range, <0 global.
688 On return TRUE, the new sheet. Else unchanged.
690 @param rIndex
691 On entry, the original index of the named expression/range.
692 On return TRUE, the new index, or 0 if a new copied name couldn't be inserted. Else unchanged.
694 @param rpRangeData
695 On entry, the pointer to the original named expression/range.
696 On return TRUE, the pointer to the new copied name, or nullptr if hit shappened.
698 @param rNewPos
699 New position of formula cell if called for that, else new base
700 position of a to be created new name adjusted for Tab.
701 rNewPos.nTab MUST point to the new sheet copied to.
703 @param rOldPos
704 Old position of formula cell if called for that, else base
705 position of the existing name adjusted for Tab.
706 rOldPos.nTab MUST point to the old sheet copied from.
708 @param bGlobalNamesToLocal
709 If TRUE, affected global names are copied to sheet-local names.
710 If FALSE, global names are copied to global names in another document.
712 @param bUsedByFormula
713 If TRUE, forces a global name to be affected/used.
714 If FALSE, a global name is only affected if it evaluates to be
715 referencing the sheet.
717 @return TRUE if copied and caller may need to evaluate rpRangeData and rSheet and rIndex.
718 FALSE if nothing to be done.
720 bool CopyAdjustRangeName( SCTAB& rSheet, sal_uInt16& rIndex, ScRangeData*& rpRangeData, ScDocument& rNewDoc,
721 const ScAddress& rNewPos, const ScAddress& rOldPos, const bool bGlobalNamesToLocal,
722 const bool bUsedByFormula ) const;
725 * Call this immediately before updating all named ranges.
727 SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate( const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap );
728 SC_DLLPUBLIC void PreprocessRangeNameUpdate();
729 SC_DLLPUBLIC void PreprocessDBDataUpdate();
731 * Call this immediately after updating named ranges.
733 SC_DLLPUBLIC void CompileHybridFormula();
736 * Insert a new named expression to the global scope.
738 * @param rName name for the expression.
739 * @param rPos base position.
740 * @param rExpr formula expression to be associated with the name. The
741 * current grammar is used to compile this expression.
743 * @return true if inserted successfully, false otherwise.
745 bool InsertNewRangeName( const OUString& rName, const ScAddress& rPos, const OUString& rExpr );
748 * Insert a new named expression to a sheet-local scope.
750 * @param nTab sheet for local scope.
751 * @param rName name for the expression.
752 * @param rPos base position.
753 * @param rExpr formula expression to be associated with the name. The
754 * current grammar is used to compile this expression.
756 * @return true if inserted successfully, false otherwise.
758 bool InsertNewRangeName( SCTAB nTab, const OUString& rName, const ScAddress& rPos, const OUString& rExpr );
760 SCTAB GetMaxTableNumber() { return static_cast<SCTAB>(maTabs.size()) - 1; }
762 ScRangePairList* GetColNameRanges() { return xColNameRanges.get(); }
763 ScRangePairList* GetRowNameRanges() { return xRowNameRanges.get(); }
764 ScRangePairListRef& GetColNameRangesRef() { return xColNameRanges; }
765 ScRangePairListRef& GetRowNameRangesRef() { return xRowNameRanges; }
767 SC_DLLPUBLIC ScDBCollection* GetDBCollection() const { return pDBCollection.get();}
768 void SetDBCollection( std::unique_ptr<ScDBCollection> pNewDBCollection,
769 bool bRemoveAutoFilter = false );
770 const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const;
771 ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion);
772 const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
773 ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
774 void RefreshDirtyTableColumnNames();
775 SC_DLLPUBLIC sc::ExternalDataMapper& GetExternalDataMapper();
777 SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock( const ScRange& rBlock, OUString* pName ) const;
779 SC_DLLPUBLIC bool HasPivotTable() const;
780 SC_DLLPUBLIC ScDPCollection* GetDPCollection();
781 SC_DLLPUBLIC const ScDPCollection* GetDPCollection() const;
782 SC_DLLPUBLIC ScDPObject* GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
783 ScDPObject* GetDPAtBlock( const ScRange& rBlock ) const;
785 void StopTemporaryChartLock();
787 void EnsureGraphicNames();
789 SdrObject* GetObjectAtPoint( SCTAB nTab, const Point& rPos );
790 bool HasChartAtPoint( SCTAB nTab, const Point& rPos, OUString& rName );
792 css::uno::Reference< css::chart2::XChartDocument > GetChartByName( const OUString& rChartName );
794 SC_DLLPUBLIC void GetChartRanges( const OUString& rChartName, std::vector< ScRangeList >& rRanges, const ScDocument* pSheetNameDoc );
795 void SetChartRanges( const OUString& rChartName, const std::vector< ScRangeList >& rRanges );
797 void UpdateChartArea( const OUString& rChartName, const ScRange& rNewArea,
798 bool bColHeaders, bool bRowHeaders, bool bAdd );
799 void UpdateChartArea( const OUString& rChartName,
800 const ScRangeListRef& rNewList,
801 bool bColHeaders, bool bRowHeaders, bool bAdd );
802 void GetOldChartParameters( const OUString& rName,
803 ScRangeList& rRanges, bool& rColHeaders, bool& rRowHeaders );
804 css::uno::Reference<
805 css::embed::XEmbeddedObject >
806 FindOleObjectByName( const OUString& rName );
808 SC_DLLPUBLIC void MakeTable( SCTAB nTab,bool _bNeedsNameCheck = true );
810 SCTAB GetVisibleTab() const { return nVisibleTab; }
811 SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab) { nVisibleTab = nTab; }
813 SC_DLLPUBLIC bool HasTable( SCTAB nTab ) const;
814 SC_DLLPUBLIC bool GetHashCode( SCTAB nTab, sal_Int64& rHashCode) const;
815 SC_DLLPUBLIC bool GetName( SCTAB nTab, OUString& rName ) const;
816 SC_DLLPUBLIC bool GetCodeName( SCTAB nTab, OUString& rName ) const;
817 SC_DLLPUBLIC bool SetCodeName( SCTAB nTab, const OUString& rName );
818 SC_DLLPUBLIC bool GetTable( const OUString& rName, SCTAB& rTab ) const;
820 SC_DLLPUBLIC std::vector<OUString> GetAllTableNames() const;
822 OUString GetCopyTabName(SCTAB nTab) const;
824 SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, std::unique_ptr<ScDBData> pDBData);
825 SC_DLLPUBLIC ScDBData* GetAnonymousDBData(SCTAB nTab);
827 /** One document global anonymous database range for temporary operations,
828 used if the corresponding sheet-local anonymous database range is
829 already used with AutoFilter and range differs. Not stored in document
830 files. */
831 SC_DLLPUBLIC void SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData);
832 SC_DLLPUBLIC ScDBData* GetAnonymousDBData();
834 SC_DLLPUBLIC SCTAB GetTableCount() const;
835 SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; }
837 SC_DLLPUBLIC ScDocProtection* GetDocProtection() const;
838 SC_DLLPUBLIC void SetDocProtection(const ScDocProtection* pProtect);
839 SC_DLLPUBLIC bool IsDocProtected() const;
840 bool IsDocEditable() const;
841 SC_DLLPUBLIC bool IsTabProtected( SCTAB nTab ) const;
842 SC_DLLPUBLIC ScTableProtection* GetTabProtection( SCTAB nTab ) const;
843 SC_DLLPUBLIC void SetTabProtection(SCTAB nTab, const ScTableProtection* pProtect);
844 void CopyTabProtection(SCTAB nTabSrc, SCTAB nTabDest);
846 void LockTable(SCTAB nTab);
847 void UnlockTable(SCTAB nTab);
849 bool IsBlockEditable( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
850 SCCOL nEndCol, SCROW nEndRow,
851 bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
852 bool IsSelectionEditable( const ScMarkData& rMark,
853 bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
854 bool HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nStartRow,
855 SCCOL nEndCol, SCROW nEndRow,
856 const ScMarkData& rMark ) const;
858 bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCTAB nTab, SCCOLROW nStart, SCCOLROW nEnd ) const;
859 bool IsEditActionAllowed( sc::ColRowEditAction eAction, const ScMarkData& rMark, SCCOLROW nStart, SCCOLROW nEnd ) const;
861 SC_DLLPUBLIC bool GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix );
863 bool IsEmbedded() const { return bIsEmbedded;}
864 void GetEmbedded( ScRange& rRange ) const;
865 void SetEmbedded( const ScRange& rRange );
866 void ResetEmbedded();
867 tools::Rectangle GetEmbeddedRect() const; // 1/100 mm
868 void SetEmbedded( SCTAB nTab, const tools::Rectangle& rRect ); // from VisArea (1/100 mm)
870 static SC_DLLPUBLIC bool ValidTabName( const OUString& rName );
872 SC_DLLPUBLIC bool ValidNewTabName( const OUString& rName ) const;
873 SC_DLLPUBLIC void CreateValidTabName(OUString& rName) const;
874 SC_DLLPUBLIC void CreateValidTabNames(std::vector<OUString>& aNames, SCTAB nCount) const;
876 void AppendTabOnLoad(const OUString& rName);
877 void SetTabNameOnLoad(SCTAB nTab, const OUString& rName);
878 void InvalidateStreamOnSave();
880 SC_DLLPUBLIC bool InsertTab( SCTAB nPos, const OUString& rName,
881 bool bExternalDocument = false, bool bUndoDeleteTab = false );
883 SC_DLLPUBLIC bool InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
884 bool bNamesValid = false );
885 SC_DLLPUBLIC bool DeleteTabs( SCTAB nTab, SCTAB nSheets );
886 SC_DLLPUBLIC bool DeleteTab( SCTAB nTab );
887 SC_DLLPUBLIC bool RenameTab( SCTAB nTab, const OUString& rName,
888 bool bExternalDocument = false );
889 bool MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress = nullptr );
890 bool CopyTab( SCTAB nOldPos, SCTAB nNewPos,
891 const ScMarkData* pOnlyMarked = nullptr );
892 SC_DLLPUBLIC sal_uLong TransferTab(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos,
893 bool bInsertNew = true,
894 bool bResultsOnly = false );
895 SC_DLLPUBLIC void TransferDrawPage(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos);
896 SC_DLLPUBLIC void SetVisible( SCTAB nTab, bool bVisible );
897 SC_DLLPUBLIC bool IsVisible( SCTAB nTab ) const;
898 bool IsStreamValid( SCTAB nTab ) const;
899 void SetStreamValid( SCTAB nTab, bool bSet, bool bIgnoreLock = false );
900 void LockStreamValid( bool bLock );
901 bool IsStreamValidLocked() const { return mbStreamValidLocked; }
902 bool IsPendingRowHeights( SCTAB nTab ) const;
903 void SetPendingRowHeights( SCTAB nTab, bool bSet );
904 SC_DLLPUBLIC void SetLayoutRTL( SCTAB nTab, bool bRTL );
905 SC_DLLPUBLIC bool IsLayoutRTL( SCTAB nTab ) const;
906 SC_DLLPUBLIC bool IsNegativePage( SCTAB nTab ) const;
907 SC_DLLPUBLIC void SetScenario( SCTAB nTab, bool bFlag );
908 SC_DLLPUBLIC bool IsScenario( SCTAB nTab ) const;
909 SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString& rComment,
910 Color& rColor, ScScenarioFlags &rFlags) const;
911 SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString& rComment,
912 const Color& rColor, ScScenarioFlags nFlags);
913 SC_DLLPUBLIC Color GetTabBgColor( SCTAB nTab ) const;
914 SC_DLLPUBLIC void SetTabBgColor( SCTAB nTab, const Color& rColor );
915 SC_DLLPUBLIC bool IsDefaultTabBgColor( SCTAB nTab ) const;
916 void GetScenarioFlags(SCTAB nTab, ScScenarioFlags &rFlags) const;
917 SC_DLLPUBLIC bool IsActiveScenario( SCTAB nTab ) const;
918 SC_DLLPUBLIC void SetActiveScenario( SCTAB nTab, bool bActive ); // only for Undo etc.
919 SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const;
920 SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const { return eGrammar;}
921 SC_DLLPUBLIC void SetGrammar( formula::FormulaGrammar::Grammar eGram );
922 SC_DLLPUBLIC ScLinkMode GetLinkMode( SCTAB nTab ) const;
923 bool IsLinked( SCTAB nTab ) const;
924 SC_DLLPUBLIC const OUString GetLinkDoc( SCTAB nTab ) const;
925 const OUString GetLinkFlt( SCTAB nTab ) const;
926 const OUString GetLinkOpt( SCTAB nTab ) const;
927 SC_DLLPUBLIC const OUString GetLinkTab( SCTAB nTab ) const;
928 sal_uLong GetLinkRefreshDelay( SCTAB nTab ) const;
929 void SetLink( SCTAB nTab, ScLinkMode nMode, const OUString& rDoc,
930 const OUString& rFilter, const OUString& rOptions,
931 const OUString& rTabName, sal_uLong nRefreshDelay );
932 bool HasLink( const OUString& rDoc,
933 const OUString& rFilter, const OUString& rOptions ) const;
934 SC_DLLPUBLIC bool LinkExternalTab( SCTAB& nTab, const OUString& aDocTab,
935 const OUString& aFileName,
936 const OUString& aTabName );
938 bool HasExternalRefManager() const { return pExternalRefMgr.get(); }
939 SC_DLLPUBLIC ScExternalRefManager* GetExternalRefManager() const;
940 bool IsInExternalReferenceMarking() const;
941 void MarkUsedExternalReferences();
942 bool MarkUsedExternalReferences( const ScTokenArray& rArr, const ScAddress& rPos );
944 /** Returns the pool containing external formula parsers. Creates the pool
945 on first call. */
946 ScFormulaParserPool& GetFormulaParserPool() const;
948 bool HasAreaLinks() const;
949 void UpdateExternalRefLinks(vcl::Window* pWin);
950 void UpdateAreaLinks();
952 // originating DDE links
953 void IncInDdeLinkUpdate() { if ( nInDdeLinkUpdate < 255 ) ++nInDdeLinkUpdate; }
954 void DecInDdeLinkUpdate() { if ( nInDdeLinkUpdate ) --nInDdeLinkUpdate; }
955 bool IsInDdeLinkUpdate() const { return nInDdeLinkUpdate != 0; }
957 SC_DLLPUBLIC void CopyDdeLinks( ScDocument* pDestDoc ) const;
959 /** Tries to find a DDE link with the specified connection data.
960 @param rnDdePos (out-param) Returns the index of the DDE link (does not include other links from link manager).
961 @return true = DDE link found, rnDdePos valid. */
962 SC_DLLPUBLIC bool FindDdeLink( const OUString& rAppl, const OUString& rTopic,
963 const OUString& rItem, sal_uInt8 nMode, size_t& rnDdePos );
965 /** Returns the connection data of the specified DDE link.
966 @param nDdePos Index of the DDE link (does not include other links from link manager).
967 @param rAppl (out-param) The application name.
968 @param rTopic (out-param) The DDE topic.
969 @param rItem (out-param) The DDE item.
970 @return true = DDE link found, out-parameters valid. */
971 bool GetDdeLinkData( size_t nDdePos, OUString& rAppl, OUString& rTopic, OUString& rItem ) const;
972 /** Returns the link mode of the specified DDE link.
973 @param nDdePos Index of the DDE link (does not include other links from link manager).
974 @param rnMode (out-param) The link mode of the specified DDE link.
975 @return true = DDE link found, rnMode valid. */
976 bool GetDdeLinkMode( size_t nDdePos, sal_uInt8& rnMode ) const;
977 /** Returns the result matrix of the specified DDE link.
978 @param nDdePos Index of the DDE link (does not include other links from link manager).
979 @return The result matrix, if the DDE link has been found, 0 otherwise. */
980 SC_DLLPUBLIC const ScMatrix* GetDdeLinkResultMatrix( size_t nDdePos ) const;
982 /** Tries to find a DDE link or creates a new, if not extant.
983 @param pResults If not 0, sets the matrix as DDE link result matrix (also for existing links).
984 @return true = DDE link found; false = Unpredictable error occurred, no DDE link created. */
985 SC_DLLPUBLIC bool CreateDdeLink( const OUString& rAppl, const OUString& rTopic, const OUString& rItem, sal_uInt8 nMode, const ScMatrixRef& pResults );
986 /** Sets a result matrix for the specified DDE link.
987 @param nDdePos Index of the DDE link (does not include other links from link manager).
988 @param pResults The array containing all results of the DDE link (intrusive-ref-counted, do not delete).
989 @return true = DDE link found and matrix set. */
990 bool SetDdeLinkResultMatrix( size_t nDdePos, const ScMatrixRef& pResults );
992 SfxBindings* GetViewBindings();
993 SfxObjectShell* GetDocumentShell() const { return mpShell; }
994 SC_DLLPUBLIC ScDrawLayer* GetDrawLayer() { return mpDrawLayer; }
995 SC_DLLPUBLIC const ScDrawLayer* GetDrawLayer() const { return mpDrawLayer; }
996 SfxBroadcaster* GetDrawBroadcaster(); // to avoid header
997 void BeginDrawUndo();
999 void BeginUnoRefUndo();
1000 bool HasUnoRefUndo() const { return ( pUnoRefUndoList != nullptr ); }
1001 SAL_WARN_UNUSED_RESULT
1002 std::unique_ptr<ScUnoRefList> EndUnoRefUndo(); // must be deleted by caller!
1003 sal_Int64 GetNewUnoId() { return ++nUnoObjectId; }
1004 void AddUnoRefChange( sal_Int64 nId, const ScRangeList& rOldRanges );
1006 static bool IsChart( const SdrObject* pObject );
1008 void UpdateChartRef( UpdateRefMode eUpdateRefMode,
1009 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1010 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1011 SCCOL nDx, SCROW nDy, SCTAB nDz );
1012 //! only assigns the new RangeList, no ChartListener or the like
1013 void SetChartRangeList( const OUString& rChartName,
1014 const ScRangeListRef& rNewRangeListRef );
1016 void StartAnimations( SCTAB nTab );
1018 bool HasBackgroundDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const;
1019 bool HasAnyDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const;
1021 const ScSheetEvents* GetSheetEvents( SCTAB nTab ) const;
1022 void SetSheetEvents( SCTAB nTab, std::unique_ptr<ScSheetEvents> pNew );
1023 bool HasSheetEventScript( SCTAB nTab, ScSheetEventId nEvent, bool bWithVbaEvents = false ) const;
1024 bool HasAnySheetEventScript( ScSheetEventId nEvent, bool bWithVbaEvents = false ) const; // on any sheet
1026 bool HasAnyCalcNotification() const;
1027 bool HasCalcNotification( SCTAB nTab ) const;
1028 void SetCalcNotification( SCTAB nTab );
1029 void ResetCalcNotifications();
1031 SC_DLLPUBLIC ScOutlineTable* GetOutlineTable( SCTAB nTab, bool bCreate = false );
1032 bool SetOutlineTable( SCTAB nTab, const ScOutlineTable* pNewOutline );
1034 void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow,
1035 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1037 bool DoSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
1038 void RemoveSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
1039 bool TestRemoveSubTotals( SCTAB nTab, const ScSubTotalParam& rParam );
1040 bool HasSubTotalCells( const ScRange& rRange );
1042 SC_DLLPUBLIC void EnsureTable( SCTAB nTab );
1044 // return TRUE = number format is set
1045 SC_DLLPUBLIC bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
1046 const ScSetStringParam * pParam = nullptr );
1047 SC_DLLPUBLIC bool SetString( const ScAddress& rPos, const OUString& rString,
1048 const ScSetStringParam* pParam = nullptr );
1051 * This method manages the lifecycle of the passed edit text object. When
1052 * the text is successfully inserted, the cell takes over the ownership of
1053 * the text object. If not, the text object gets deleted.
1055 * <p>The caller must ensure that the passed edit text object <i>uses the
1056 * SfxItemPool instance returned from ScDocument::GetEditPool()</i>.
1057 * This is very important.</p>
1059 SC_DLLPUBLIC bool SetEditText( const ScAddress& rPos, std::unique_ptr<EditTextObject> pEditText );
1060 void SetEditText( const ScAddress& rPos, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
1061 SC_DLLPUBLIC void SetEditText( const ScAddress& rPos, const OUString& rStr );
1062 SC_DLLPUBLIC SCROW GetFirstEditTextRow( const ScRange& rRange ) const;
1065 * Call this if you are not sure whether to put this as an edit text or a
1066 * simple text.
1068 SC_DLLPUBLIC void SetTextCell( const ScAddress& rPos, const OUString& rStr );
1069 void SetEmptyCell( const ScAddress& rPos );
1070 SC_DLLPUBLIC void SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal );
1071 SC_DLLPUBLIC void SetValue( const ScAddress& rPos, double fVal );
1072 void SetValues( const ScAddress& rPos, const std::vector<double>& rVals );
1073 void SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError);
1074 SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const ScTokenArray& rArray );
1075 SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const OUString& rFormula,
1076 formula::FormulaGrammar::Grammar eGram );
1079 * Set formula cell, and transfer its ownership to the document. This call
1080 * attempts to group the passed formula cell with the adjacent cells or
1081 * cell groups if appropriate.
1083 * @return pCell if it was successfully inserted, NULL otherwise. pCell
1084 * is deleted automatically on failure to insert.
1086 SC_DLLPUBLIC ScFormulaCell* SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell );
1087 bool SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCell*>& rCells );
1090 * Check if there is at least one formula cell in specified range.
1092 bool HasFormulaCell( const ScRange& rRange ) const;
1093 SC_DLLPUBLIC void InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
1094 SCCOL nCol2, SCROW nRow2,
1095 const ScMarkData& rMark,
1096 const OUString& rFormula,
1097 const ScTokenArray* p = nullptr,
1098 const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT );
1099 SC_DLLPUBLIC void InsertTableOp(const ScTabOpParam& rParam, // multi-operation
1100 SCCOL nCol1, SCROW nRow1,
1101 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark);
1103 SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab,
1104 const ScInterpreterContext* pContext = nullptr ) const;
1105 SC_DLLPUBLIC OUString GetString( const ScAddress& rPos,
1106 const ScInterpreterContext* pContext = nullptr ) const;
1109 * Return a pointer to the double value stored in value cell.
1111 * @param rPos cell position
1113 * @return pointer to the double value stored in a numeric cell, or NULL
1114 * if the cell at specified position is not a numeric cell.
1116 double* GetValueCell( const ScAddress& rPos );
1118 SC_DLLPUBLIC svl::SharedStringPool& GetSharedStringPool();
1119 const svl::SharedStringPool& GetSharedStringPool() const;
1121 svl::SharedString GetSharedString( const ScAddress& rPos ) const;
1123 std::shared_ptr<sc::FormulaGroupContext>& GetFormulaGroupContext();
1124 void DiscardFormulaGroupContext();
1125 void BlockFormulaGroupContextDiscard( bool block )
1126 { mbFormulaGroupCxtBlockDiscard = block; }
1128 SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString );
1129 FormulaError GetStringForFormula( const ScAddress& rPos, OUString& rString );
1130 SC_DLLPUBLIC double GetValue( const ScAddress& rPos ) const;
1131 SC_DLLPUBLIC double GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1132 SC_DLLPUBLIC void GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, double& rValue ) const;
1133 SC_DLLPUBLIC const EditTextObject* GetEditText( const ScAddress& rPos ) const;
1134 void RemoveEditTextCharAttribs( const ScAddress& rPos, const ScPatternAttr& rAttr );
1135 SC_DLLPUBLIC double RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScInterpreterContext* pContext = nullptr ) const;
1136 SC_DLLPUBLIC void GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab,
1137 sal_uInt32& rFormat ) const;
1138 sal_uInt32 GetNumberFormat( const ScRange& rRange ) const;
1139 SC_DLLPUBLIC sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& ) const;
1140 void SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberFormat );
1142 void GetNumberFormatInfo( const ScInterpreterContext& rContext, SvNumFormatType& nType, sal_uInt32& nIndex, const ScAddress& rPos ) const;
1143 SC_DLLPUBLIC const ScFormulaCell* GetFormulaCell( const ScAddress& rPos ) const;
1144 SC_DLLPUBLIC ScFormulaCell* GetFormulaCell( const ScAddress& rPos );
1145 SC_DLLPUBLIC void GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rFormula ) const;
1146 SC_DLLPUBLIC void GetCellType( SCCOL nCol, SCROW nRow, SCTAB nTab, CellType& rCellType ) const;
1147 SC_DLLPUBLIC CellType GetCellType( const ScAddress& rPos ) const;
1149 SC_DLLPUBLIC bool HasData( SCCOL nCol, SCROW nRow, SCTAB nTab );
1150 SC_DLLPUBLIC bool HasStringData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1151 SC_DLLPUBLIC bool HasValueData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1152 SC_DLLPUBLIC bool HasValueData( const ScAddress& rPos ) const;
1153 bool HasStringCells( const ScRange& rRange ) const;
1155 /** Returns true, if there is any data to create a selection list for rPos. */
1156 bool HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1157 bool HasValidationData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1160 * Check if the specified range contains either: 1) one non-empty cell, 2)
1161 * more than one non-empty cells, or 3) totally empty. In case the range
1162 * contains at least one non-empty cell, specify the position of the first
1163 * non-empty cell.
1165 sc::MultiDataCellState HasMultipleDataCells( const ScRange& rRange ) const;
1167 /** Notes **/
1168 SC_DLLPUBLIC ScPostIt* GetNote(const ScAddress& rPos);
1169 SC_DLLPUBLIC ScPostIt* GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
1170 void SetNote(const ScAddress& rPos, ScPostIt* pNote);
1171 void SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, ScPostIt* pNote);
1172 SC_DLLPUBLIC bool HasNote(const ScAddress& rPos) const;
1173 bool HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
1174 SC_DLLPUBLIC bool HasColNotes(SCCOL nCol, SCTAB nTab) const;
1175 SC_DLLPUBLIC bool HasTabNotes(SCTAB nTab) const;
1176 bool HasNotes() const;
1177 SC_DLLPUBLIC ScPostIt* ReleaseNote(const ScAddress& rPos);
1178 SC_DLLPUBLIC ScPostIt* GetOrCreateNote(const ScAddress& rPos);
1179 SC_DLLPUBLIC ScPostIt* CreateNote(const ScAddress& rPos);
1180 size_t GetNoteCount( SCTAB nTab, SCCOL nCol ) const;
1183 * Ensure that all note objects have an associated sdr object. The export
1184 * code uses sdr objects to export note data.
1186 void CreateAllNoteCaptions();
1187 void ForgetNoteCaptions( const ScRangeList& rRanges, bool bPreserveData );
1188 CommentCaptionState GetAllNoteCaptionsState( const ScRangeList& rRanges);
1190 ScAddress GetNotePosition( size_t nIndex ) const;
1191 ScAddress GetNotePosition( size_t nIndex, SCTAB nTab ) const;
1192 SCROW GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const;
1194 SC_DLLPUBLIC void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
1195 SC_DLLPUBLIC void GetAllNoteEntries( SCTAB nTab, std::vector<sc::NoteEntry>& rNotes ) const;
1196 void GetNotesInRange( const ScRangeList& rRange, std::vector<sc::NoteEntry>& rNotes ) const;
1197 bool ContainsNotesInRange( const ScRangeList& rRange ) const;
1199 SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab);
1201 bool IsMerged( const ScAddress& rPos ) const;
1203 void ExtendMergeSel( SCCOL nStartCol, SCROW nStartRow,
1204 SCCOL& rEndCol, SCROW& rEndRow, const ScMarkData& rMark,
1205 bool bRefresh = false );
1206 SC_DLLPUBLIC bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
1207 SCCOL& rEndCol, SCROW& rEndRow, SCTAB nTab,
1208 bool bRefresh = false );
1209 bool ExtendMerge( ScRange& rRange, bool bRefresh = false );
1210 SC_DLLPUBLIC void ExtendTotalMerge( ScRange& rRange ) const;
1211 SC_DLLPUBLIC void ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow,
1212 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const;
1213 SC_DLLPUBLIC void ExtendOverlapped( ScRange& rRange ) const;
1215 bool RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow,
1216 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1218 SC_DLLPUBLIC void DoMergeContents( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1219 SCCOL nEndCol, SCROW nEndRow );
1220 SC_DLLPUBLIC void DoEmptyBlock( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1221 SCCOL nEndCol, SCROW nEndRow );
1222 // without checking:
1223 SC_DLLPUBLIC void DoMerge( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1224 SCCOL nEndCol, SCROW nEndRow, bool bDeleteCaptions = true );
1225 void RemoveMerge( SCCOL nCol, SCROW nRow, SCTAB nTab );
1227 bool IsBlockEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1228 SCCOL nEndCol, SCROW nEndRow, bool bIgnoreNotes = false ) const;
1229 bool IsPrintEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1230 SCCOL nEndCol, SCROW nEndRow,
1231 bool bLeftIsEmpty = false,
1232 ScRange* pLastRange = nullptr,
1233 tools::Rectangle* pLastMM = nullptr ) const;
1235 void SkipOverlapped( SCCOL& rCol, SCROW& rRow, SCTAB nTab ) const;
1236 bool IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1237 bool IsVerOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1239 SC_DLLPUBLIC bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1240 SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask ) const;
1241 SC_DLLPUBLIC bool HasAttrib( const ScRange& rRange, HasAttrFlags nMask ) const;
1243 SC_DLLPUBLIC void GetBorderLines( SCCOL nCol, SCROW nRow, SCTAB nTab,
1244 const ::editeng::SvxBorderLine** ppLeft,
1245 const ::editeng::SvxBorderLine** ppTop,
1246 const ::editeng::SvxBorderLine** ppRight,
1247 const ::editeng::SvxBorderLine** ppBottom ) const;
1249 void ResetChanged( const ScRange& rRange );
1251 void CheckVectorizationState();
1252 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
1253 void SetDirty( const ScRange&, bool bIncludeEmptyCells );
1254 void SetTableOpDirty( const ScRange& ); // for Interpreter TableOp
1255 void InterpretDirtyCells( const ScRangeList& rRanges );
1256 SC_DLLPUBLIC void CalcAll();
1257 SC_DLLPUBLIC void CalcAfterLoad( bool bStartListening = true );
1258 void CompileAll();
1259 void CompileXML();
1262 * Re-compile formula cells with error.
1264 * @param nErrCode specified error code to match. Only those cells with
1265 * this error code will be re-compiled. If this value is
1266 * 0, cells with any error values will be re-compiled.
1268 * @return true if at least one cell is re-compiled, false if no cells are
1269 * re-compiled.
1271 bool CompileErrorCells(FormulaError nErrCode);
1273 ScAutoNameCache* GetAutoNameCache() { return pAutoNameCache; }
1274 void SetPreviewFont( std::unique_ptr<SfxItemSet> pFontSet );
1275 SfxItemSet* GetPreviewFont() { return pPreviewFont.get(); }
1276 SfxItemSet* GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab );
1277 const ScMarkData& GetPreviewSelection() const { return maPreviewSelection; }
1278 void SetPreviewSelection( const ScMarkData& rSel );
1279 ScStyleSheet* GetPreviewCellStyle() { return pPreviewCellStyle; }
1280 ScStyleSheet* GetPreviewCellStyle( SCCOL nCol, SCROW nRow, SCTAB nTab );
1281 void SetPreviewCellStyle( ScStyleSheet* pStyle ) { pPreviewCellStyle = pStyle; }
1282 SC_DLLPUBLIC void SetAutoNameCache( ScAutoNameCache* pCache );
1284 /** Creates a ScLookupCache cache for the range if it
1285 doesn't already exist. */
1286 ScLookupCache & GetLookupCache( const ScRange & rRange );
1287 /** Only ScLookupCache ctor uses AddLookupCache(), do not
1288 use elsewhere! */
1289 void AddLookupCache( ScLookupCache & rCache );
1290 /** Only ScLookupCache dtor uses RemoveLookupCache(), do
1291 not use elsewhere! */
1292 void RemoveLookupCache( ScLookupCache & rCache );
1293 /** Zap all caches. */
1294 void ClearLookupCaches();
1296 // calculate automatically
1297 SC_DLLPUBLIC void SetAutoCalc( bool bNewAutoCalc );
1298 SC_DLLPUBLIC bool GetAutoCalc() const { return bAutoCalc; }
1299 // calculate automatically in/from/for ScDocShell disabled
1300 void SetAutoCalcShellDisabled( bool bNew ) { bAutoCalcShellDisabled = bNew; }
1301 bool IsAutoCalcShellDisabled() const { return bAutoCalcShellDisabled; }
1302 // ForcedFormulas are to be calculated
1303 void SetForcedFormulaPending( bool bNew ) { bForcedFormulaPending = bNew; }
1304 bool IsForcedFormulaPending() const { return bForcedFormulaPending; }
1305 // if CalcFormulaTree() is currently running
1306 bool IsCalculatingFormulaTree() { return bCalculatingFormulaTree; }
1308 FormulaError GetErrCode( const ScAddress& ) const;
1310 /** Shrink a range to only include data area.
1312 This is not the actually used area within the
1313 selection, but the bounds of the sheet's data area
1314 instead.
1316 @returns TRUE if the area passed intersected the data
1317 area, FALSE if not, in which case the values
1318 obtained may be out of bounds, not in order or
1319 unmodified. TRUE does not mean that there
1320 actually is any data within the selection.
1322 bool ShrinkToDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
1324 /** Shrink a range to only include used data area.
1326 @param o_bShrunk
1327 Out parameter, true if area was shrunk, false if not.
1328 @param bStickyTopRow
1329 If TRUE, do not adjust the top row.
1330 @param bStickyLeftCol
1331 If TRUE, do not adjust the left column.
1332 @param bConsiderCellNotes
1333 If TRUE, consider the presence of cell notes besides data.
1334 @param bConsiderCellDrawObjects
1335 If TRUE, consider the presence of draw objects anchored to the cell.
1337 @returns true if there is any data, false if not.
1339 bool ShrinkToUsedDataArea( bool& o_bShrunk,
1340 SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1341 SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
1342 bool bStickyTopRow = false, bool bStickyLeftCol = false,
1343 bool bConsiderCellNotes = false,
1344 bool bConsiderCellDrawObjects = false ) const;
1347 * Return the last non-empty row position in given columns that's no
1348 * greater than the initial last row position, or 0 if the columns are
1349 * empty. A negative value is returned if the given sheet or column
1350 * positions are invalid.
1352 * <p>It starts from the specified last row position, and finds the first
1353 * non-empty row position in the upward direction if the start row
1354 * position is empty.</p>
1356 SCROW GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const;
1359 * Return the smallest area containing at least all contiguous cells
1360 * having data. This area is a square containing also empty cells. It may
1361 * shrink or extend the area given as input Flags as modifiers:
1363 * @param bIncludeOld when true, ensure that the returned area contains at
1364 * least the initial area even if the actual data area
1365 * is smaller than the initial area.
1367 * @param bOnlyDown when true, extend / shrink the data area only in a
1368 * downward direction i.e. only modify the end row
1369 * position.
1371 SC_DLLPUBLIC void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1372 SCCOL& rEndCol, SCROW& rEndRow,
1373 bool bIncludeOld, bool bOnlyDown ) const;
1375 SC_DLLPUBLIC bool GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
1376 SC_DLLPUBLIC bool GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
1377 SC_DLLPUBLIC bool GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
1378 bool bNotes = true ) const;
1379 SC_DLLPUBLIC bool GetPrintAreaHor( SCTAB nTab, SCROW nStartRow, SCROW nEndRow,
1380 SCCOL& rEndCol ) const;
1381 SC_DLLPUBLIC bool GetPrintAreaVer( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol,
1382 SCROW& rEndRow, bool bNotes ) const;
1383 void InvalidateTableArea();
1385 /// Return the number of columns / rows that should be visible for the tiled rendering.
1386 SC_DLLPUBLIC void GetTiledRenderingArea(SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow) const;
1388 SC_DLLPUBLIC bool GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const;
1391 * Find the maximum column position that contains printable data for the
1392 * specified row range. The final column position must be equal or less
1393 * than the initial value of rEndCol.
1395 void ExtendPrintArea( OutputDevice* pDev, SCTAB nTab,
1396 SCCOL nStartCol, SCROW nStartRow,
1397 SCCOL& rEndCol, SCROW nEndRow ) const;
1398 SC_DLLPUBLIC SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
1399 SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab,
1400 ScDirection eDir );
1402 void FindAreaPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, ScMoveDirection eDirection ) const;
1403 SC_DLLPUBLIC void GetNextPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, SCCOL nMovX, SCROW nMovY,
1404 bool bMarked, bool bUnprotected, const ScMarkData& rMark ) const;
1406 bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, SCTAB nTab,
1407 const ScMarkData& rMark );
1409 void LimitChartArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1410 SCCOL& rEndCol, SCROW& rEndRow );
1411 void LimitChartIfAll( ScRangeListRef& rRangeList );
1413 bool InsertRow( SCCOL nStartCol, SCTAB nStartTab,
1414 SCCOL nEndCol, SCTAB nEndTab,
1415 SCROW nStartRow, SCSIZE nSize, ScDocument* pRefUndoDoc = nullptr,
1416 const ScMarkData* pTabMark = nullptr );
1417 SC_DLLPUBLIC bool InsertRow( const ScRange& rRange );
1418 void DeleteRow( SCCOL nStartCol, SCTAB nStartTab,
1419 SCCOL nEndCol, SCTAB nEndTab,
1420 SCROW nStartRow, SCSIZE nSize,
1421 ScDocument* pRefUndoDoc = nullptr, bool* pUndoOutline = nullptr,
1422 const ScMarkData* pTabMark = nullptr );
1423 SC_DLLPUBLIC void DeleteRow( const ScRange& rRange );
1424 bool InsertCol( SCROW nStartRow, SCTAB nStartTab,
1425 SCROW nEndRow, SCTAB nEndTab,
1426 SCCOL nStartCol, SCSIZE nSize, ScDocument* pRefUndoDoc = nullptr,
1427 const ScMarkData* pTabMark = nullptr );
1428 SC_DLLPUBLIC bool InsertCol( const ScRange& rRange );
1429 void DeleteCol( SCROW nStartRow, SCTAB nStartTab,
1430 SCROW nEndRow, SCTAB nEndTab,
1431 SCCOL nStartCol, SCSIZE nSize,
1432 ScDocument* pRefUndoDoc = nullptr, bool* pUndoOutline = nullptr,
1433 const ScMarkData* pTabMark = nullptr );
1434 void DeleteCol( const ScRange& rRange );
1436 bool CanInsertRow( const ScRange& rRange ) const;
1437 bool CanInsertCol( const ScRange& rRange ) const;
1439 void FitBlock( const ScRange& rOld, const ScRange& rNew, bool bClear = true );
1440 bool CanFitBlock( const ScRange& rOld, const ScRange& rNew );
1442 bool IsClipOrUndo() const { return bIsClip || bIsUndo; }
1443 bool IsUndo() const { return bIsUndo; }
1444 bool IsClipboard() const { return bIsClip; }
1445 bool IsUndoEnabled() const { return mbUndoEnabled; }
1446 SC_DLLPUBLIC void EnableUndo( bool bVal );
1447 bool IsFunctionAccess() const { return bIsFunctionAccess; }
1449 bool IsAdjustHeightLocked() const { return nAdjustHeightLock != 0; }
1450 void LockAdjustHeight() { ++nAdjustHeightLock; }
1451 SC_DLLPUBLIC void UnlockAdjustHeight();
1452 bool IsExecuteLinkEnabled() const { return mbExecuteLinkEnabled; }
1453 void EnableExecuteLink( bool bVal ) { mbExecuteLinkEnabled = bVal; }
1454 bool IsChangeReadOnlyEnabled() const { return mbChangeReadOnlyEnabled; }
1455 void EnableChangeReadOnly( bool bVal ) { mbChangeReadOnlyEnabled = bVal; }
1456 SC_DLLPUBLIC bool IsUserInteractionEnabled() const { return mbUserInteractionEnabled;}
1457 SC_DLLPUBLIC void EnableUserInteraction( bool bVal );
1458 SC_DLLPUBLIC sal_Int16 GetNamedRangesLockCount() const { return mnNamedRangesLockCount; }
1459 void SetNamedRangesLockCount( sal_Int16 nCount ) { mnNamedRangesLockCount = nCount; }
1460 SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks );
1461 SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, SCTAB nTab );
1462 void SetCutMode( bool bCut );
1463 bool IsCutMode();
1464 void SetClipArea( const ScRange& rArea, bool bCut = false );
1466 SC_DLLPUBLIC bool IsDocVisible() const { return bIsVisible; }
1467 SC_DLLPUBLIC void SetDocVisible( bool bSet );
1469 bool HasOLEObjectsInArea( const ScRange& rRange, const ScMarkData* pTabMark = nullptr );
1471 void DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1472 const ScMarkData& rMark );
1473 void DeleteObjectsInSelection( const ScMarkData& rMark );
1475 void DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark,
1476 InsertDeleteFlags nDelFlag, bool bBroadcast = true,
1477 sc::ColumnSpanSet* pBroadcastSpans = nullptr );
1479 SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1480 SCTAB nTab, InsertDeleteFlags nDelFlag);
1481 void DeleteAreaTab(const ScRange& rRange, InsertDeleteFlags nDelFlag);
1483 void CopyToClip( const ScClipParam& rClipParam, ScDocument* pClipDoc,
1484 const ScMarkData* pMarks, bool bKeepScenarioFlags,
1485 bool bIncludeObjects );
1488 * Copy only raw cell values to another document. Formula cells are
1489 * converted to raw cells. No formatting info are copied except for
1490 * number formats.
1492 * @param rSrcRange source range in the source document
1493 * @param nDestTab table in the clip document to copy to.
1494 * @param pDestDoc document to copy to
1496 SC_DLLPUBLIC void CopyStaticToDocument(const ScRange& rSrcRange, SCTAB nDestTab, ScDocument* pDestDoc);
1499 * Copy only cell, nothing but cell to another document.
1501 * @param rSrcPos source cell position
1502 * @param rDestPos destination cell position
1503 * @param rDestDoc destination document
1505 void CopyCellToDocument( const ScAddress& rSrcPos, const ScAddress& rDestPos, ScDocument& rDestDoc );
1507 void CopyTabToClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1508 SCTAB nTab, ScDocument* pClipDoc);
1510 bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCTAB nTab, SCCOL nCol );
1512 void DeleteBeforeCopyFromClip( sc::CopyFromClipContext& rCxt, const ScMarkData& rMark,
1513 sc::ColumnSpanSet& rBroadcastSpans );
1515 bool CopyOneCellFromClip(sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1516 SCCOL nCol2, SCROW nRow2 );
1517 void CopyBlockFromClip( sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1518 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark,
1519 SCCOL nDx, SCROW nDy );
1520 void CopyNonFilteredFromClip( sc::CopyFromClipContext& rCxt, SCCOL nCol1,
1521 SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1522 const ScMarkData& rMark, SCCOL nDx, SCROW & rClipStartRow );
1524 void StartListeningFromClip( SCCOL nCol1, SCROW nRow1,
1525 SCCOL nCol2, SCROW nRow2,
1526 const ScMarkData& rMark, InsertDeleteFlags nInsFlag );
1528 void SetDirtyFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1529 const ScMarkData& rMark, InsertDeleteFlags nInsFlag,
1530 sc::ColumnSpanSet& rBroadcastSpans );
1532 /** If pDestRanges is given it overrides rDestRange, rDestRange in this
1533 case is the overall encompassing range. */
1534 void CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMark,
1535 InsertDeleteFlags nInsFlag,
1536 ScDocument* pRefUndoDoc,
1537 ScDocument* pClipDoc,
1538 bool bResetCut = true,
1539 bool bAsLink = false,
1540 bool bIncludeFiltered = true,
1541 bool bSkipAttrForEmpty = false,
1542 const ScRangeList * pDestRanges = nullptr );
1544 void CopyMultiRangeFromClip(const ScAddress& rDestPos, const ScMarkData& rMark,
1545 InsertDeleteFlags nInsFlag, ScDocument* pClipDoc,
1546 bool bResetCut = true, bool bAsLink = false,
1547 bool bIncludeFiltered = true,
1548 bool bSkipAttrForEmpty = false);
1550 void GetClipArea(SCCOL& nClipX, SCROW& nClipY, bool bIncludeFiltered);
1551 void GetClipStart(SCCOL& nClipX, SCROW& nClipY);
1553 bool HasClipFilteredRows();
1555 bool IsClipboardSource() const;
1557 SC_DLLPUBLIC void TransposeClip( ScDocument* pTransClip, InsertDeleteFlags nFlags, bool bAsLink );
1559 ScClipParam& GetClipParam();
1560 void SetClipParam(const ScClipParam& rParam);
1562 /** To be called at the clipboard document when closing a document that is
1563 the current clipboard source to decouple things from the originating
1564 document. Done in ScDocument dtor after determining
1565 IsClipboardSource().
1567 void ClosingClipboardSource();
1569 void MixDocument( const ScRange& rRange, ScPasteFunc nFunction, bool bSkipEmpty,
1570 ScDocument* pSrcDoc );
1572 void FillTab( const ScRange& rSrcArea, const ScMarkData& rMark,
1573 InsertDeleteFlags nFlags, ScPasteFunc nFunction,
1574 bool bSkipEmpty, bool bAsLink );
1575 void FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark,
1576 InsertDeleteFlags nFlags, ScPasteFunc nFunction,
1577 bool bSkipEmpty, bool bAsLink );
1579 void TransliterateText( const ScMarkData& rMultiMark, TransliterationFlags nType );
1581 SC_DLLPUBLIC void InitUndo( const ScDocument* pSrcDoc, SCTAB nTab1, SCTAB nTab2,
1582 bool bColInfo = false, bool bRowInfo = false );
1583 void AddUndoTab( SCTAB nTab1, SCTAB nTab2,
1584 bool bColInfo = false, bool bRowInfo = false );
1585 SC_DLLPUBLIC void InitUndoSelected( const ScDocument* pSrcDoc, const ScMarkData& rTabSelection,
1586 bool bColInfo = false, bool bRowInfo = false );
1588 // don't use anymore:
1589 void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1590 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1591 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc,
1592 const ScMarkData* pMarks = nullptr, bool bColRowFlags = true);
1593 void UndoToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1594 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1595 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc);
1597 void CopyToDocument(const ScRange& rRange,
1598 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc,
1599 const ScMarkData* pMarks = nullptr, bool bColRowFlags = true);
1600 void UndoToDocument(const ScRange& rRange,
1601 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc);
1603 void CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario = false );
1604 bool TestCopyScenario( SCTAB nSrcTab, SCTAB nDestTab ) const;
1605 void MarkScenario(SCTAB nSrcTab, SCTAB nDestTab,
1606 ScMarkData& rDestMark, bool bResetMark = true,
1607 ScScenarioFlags nNeededBits = ScScenarioFlags::NONE) const;
1608 bool HasScenarioRange( SCTAB nTab, const ScRange& rRange ) const;
1609 SC_DLLPUBLIC const ScRangeList* GetScenarioRanges( SCTAB nTab ) const;
1611 SC_DLLPUBLIC void CopyUpdated( ScDocument* pPosDoc, ScDocument* pDestDoc );
1613 void UpdateReference( sc::RefUpdateContext& rCxt, ScDocument*
1614 pUndoDoc = nullptr, bool bIncludeDraw = true,
1615 bool bUpdateNoteCaptionPos = true );
1617 SC_DLLPUBLIC void UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDoc,
1618 const ScMarkData& rMark, ScDocument* pUndoDoc );
1620 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
1622 SC_DLLPUBLIC void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1623 ScProgress* pProgress, const ScMarkData& rMark,
1624 sal_uLong nFillCount, FillDir eFillDir = FILL_TO_BOTTOM,
1625 FillCmd eFillCmd = FILL_LINEAR, FillDateCmd eFillDateCmd = FILL_DAY,
1626 double nStepValue = 1.0, double nMaxValue = 1E307 );
1627 OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
1629 bool GetSelectionFunction( ScSubTotalFunc eFunc,
1630 const ScAddress& rCursor, const ScMarkData& rMark,
1631 double& rResult );
1633 SC_DLLPUBLIC const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
1634 template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const
1636 return static_cast<const T*>(GetAttr(nCol, nRow, nTab, sal_uInt16(nWhich)));
1638 SC_DLLPUBLIC const SfxPoolItem* GetAttr( const ScAddress& rPos, sal_uInt16 nWhich ) const;
1639 template<class T> const T* GetAttr( const ScAddress& rPos, TypedWhichId<T> nWhich ) const
1641 return static_cast<const T*>(GetAttr(rPos, sal_uInt16(nWhich)));
1643 SC_DLLPUBLIC const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1644 SC_DLLPUBLIC const ScPatternAttr* GetPattern( const ScAddress& rPos ) const;
1645 SC_DLLPUBLIC const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const;
1646 const ScPatternAttr* GetSelectionPattern( const ScMarkData& rMark );
1647 std::unique_ptr<ScPatternAttr> CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
1648 SC_DLLPUBLIC void AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
1649 void RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
1651 SC_DLLPUBLIC ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1652 SC_DLLPUBLIC const SfxItemSet* GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1653 const SfxItemSet* GetCondResult( ScRefCellValue& rCell, const ScAddress& rPos,
1654 const ScConditionalFormatList& rList,
1655 const std::vector<sal_uInt32>& rIndex ) const;
1656 const SfxPoolItem* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
1657 template<class T> const T* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const
1659 return static_cast<const T*>(GetEffItem(nCol, nRow, nTab, sal_uInt16(nWhich)));
1662 SC_DLLPUBLIC const css::uno::Reference< css::i18n::XBreakIterator >& GetBreakIterator();
1663 bool HasStringWeakCharacters( const OUString& rString );
1664 SC_DLLPUBLIC SvtScriptType GetStringScriptType( const OUString& rString );
1665 SC_DLLPUBLIC SvtScriptType GetCellScriptType( const ScAddress& rPos, sal_uInt32 nNumberFormat );
1666 SC_DLLPUBLIC SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab );
1667 SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rPos, SCROW nLength );
1668 SvtScriptType GetRangeScriptType( const ScRangeList& rRanges );
1670 bool HasDetectiveOperations() const;
1671 void AddDetectiveOperation( const ScDetOpData& rData );
1672 void ClearDetectiveOperations();
1673 ScDetOpList* GetDetOpList() const { return pDetOpList.get(); }
1674 void SetDetOpList(std::unique_ptr<ScDetOpList> pNew);
1676 bool HasDetectiveObjects(SCTAB nTab) const;
1678 void GetSelectionFrame( const ScMarkData& rMark,
1679 SvxBoxItem& rLineOuter,
1680 SvxBoxInfoItem& rLineInner );
1681 void ApplySelectionFrame(const ScMarkData& rMark,
1682 const SvxBoxItem& rLineOuter,
1683 const SvxBoxInfoItem* pLineInner);
1684 void ApplyFrameAreaTab(const ScRange& rRange,
1685 const SvxBoxItem& rLineOuter,
1686 const SvxBoxInfoItem& rLineInner);
1688 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
1689 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
1691 SC_DLLPUBLIC sal_uLong AddCondFormat( ScConditionalFormat* pNew, SCTAB nTab );
1692 void DeleteConditionalFormat( sal_uLong nIndex, SCTAB nTab );
1694 void SetCondFormList( ScConditionalFormatList* pList, SCTAB nTab );
1695 SC_DLLPUBLIC sal_uLong AddValidationEntry( const ScValidationData& rNew );
1696 SC_DLLPUBLIC const ScValidationData* GetValidationEntry( sal_uLong nIndex ) const;
1698 SC_DLLPUBLIC ScConditionalFormatList* GetCondFormList( SCTAB nTab ) const;
1700 const ScValidationDataList* GetValidationList() const { return pValidationList;}
1701 ScValidationDataList* GetValidationList() { return pValidationList;}
1703 SC_DLLPUBLIC void ApplyAttr( SCCOL nCol, SCROW nRow, SCTAB nTab,
1704 const SfxPoolItem& rAttr );
1705 SC_DLLPUBLIC void ApplyPattern( SCCOL nCol, SCROW nRow, SCTAB nTab,
1706 const ScPatternAttr& rAttr );
1707 SC_DLLPUBLIC void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow,
1708 SCCOL nEndCol, SCROW nEndRow,
1709 const ScMarkData& rMark, const ScPatternAttr& rAttr,
1710 ScEditDataArray* pDataArray = nullptr,
1711 bool* const pIsChanged = nullptr );
1712 SC_DLLPUBLIC void ApplyPatternAreaTab( SCCOL nStartCol, SCROW nStartRow,
1713 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1714 const ScPatternAttr& rAttr );
1716 SC_DLLPUBLIC void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
1717 const ScMarkData& rMark,
1718 const ScPatternAttr& rPattern,
1719 SvNumFormatType nNewType );
1721 void ApplyStyle( SCCOL nCol, SCROW nRow, SCTAB nTab,
1722 const ScStyleSheet& rStyle);
1723 void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow,
1724 SCCOL nEndCol, SCROW nEndRow,
1725 const ScMarkData& rMark, const ScStyleSheet& rStyle);
1726 SC_DLLPUBLIC void ApplyStyleAreaTab( SCCOL nStartCol, SCROW nStartRow,
1727 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1728 const ScStyleSheet& rStyle);
1730 SC_DLLPUBLIC void ApplySelectionStyle( const ScStyleSheet& rStyle, const ScMarkData& rMark );
1731 void ApplySelectionLineStyle( const ScMarkData& rMark,
1732 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
1734 const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1735 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark ) const;
1737 void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
1738 OutputDevice* pDev,
1739 double nPPTX, double nPPTY,
1740 const Fraction& rZoomX, const Fraction& rZoomY );
1742 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
1744 SC_DLLPUBLIC bool ApplyFlagsTab( SCCOL nStartCol, SCROW nStartRow,
1745 SCCOL nEndCol, SCROW nEndRow,
1746 SCTAB nTab, ScMF nFlags );
1747 SC_DLLPUBLIC bool RemoveFlagsTab( SCCOL nStartCol, SCROW nStartRow,
1748 SCCOL nEndCol, SCROW nEndRow,
1749 SCTAB nTab, ScMF nFlags );
1751 SC_DLLPUBLIC void SetPattern( const ScAddress&, const ScPatternAttr& rAttr );
1752 SC_DLLPUBLIC void SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr& rAttr );
1754 void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1755 sal_uInt16 nFormatNo, const ScMarkData& rMark );
1756 void GetAutoFormatData( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1757 ScAutoFormatData& rData );
1758 bool SearchAndReplace( const SvxSearchItem& rSearchItem,
1759 SCCOL& rCol, SCROW& rRow, SCTAB& rTab,
1760 const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1761 OUString& rUndoStr, ScDocument* pUndoDoc = nullptr );
1763 // determine Col/Row of subsequent calls
1764 // (e.g. not found from the beginning, or subsequent tables)
1765 // meaning of explanation in "()" was already unclear in German
1766 static void GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem,
1767 SCCOL& rCol, SCROW& rRow );
1769 bool Solver( SCCOL nFCol, SCROW nFRow, SCTAB nFTab,
1770 SCCOL nVCol, SCROW nVRow, SCTAB nVTab,
1771 const OUString& sValStr, double& nX);
1773 SC_DLLPUBLIC void ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark,
1774 ScEditDataArray* pDataArray = nullptr, bool* pIsChanged = nullptr );
1775 void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
1776 void DeleteSelectionTab( SCTAB nTab, InsertDeleteFlags nDelFlag, const ScMarkData& rMark );
1778 SC_DLLPUBLIC void SetColWidth( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth );
1779 SC_DLLPUBLIC void SetColWidthOnly( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth );
1780 SC_DLLPUBLIC void SetRowHeight( SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight );
1781 SC_DLLPUBLIC void SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
1782 sal_uInt16 nNewHeight );
1784 SC_DLLPUBLIC void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
1785 sal_uInt16 nNewHeight );
1786 SC_DLLPUBLIC void SetManualHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual );
1788 SC_DLLPUBLIC sal_uInt16 GetColWidth( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
1789 SC_DLLPUBLIC sal_uLong GetColWidth( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab ) const;
1790 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1791 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow ) const;
1792 SC_DLLPUBLIC sal_uLong GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1795 * Given the height i.e. total vertical distance from the top of the sheet
1796 * grid, return the first visible row whose top position is below the
1797 * specified height.
1799 SCROW GetRowForHeight( SCTAB nTab, sal_uLong nHeight ) const;
1800 sal_uLong GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const;
1801 SC_DLLPUBLIC sal_uLong GetColOffset( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
1802 SC_DLLPUBLIC sal_uLong GetRowOffset( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1804 SC_DLLPUBLIC sal_uInt16 GetOriginalWidth( SCCOL nCol, SCTAB nTab ) const;
1805 SC_DLLPUBLIC sal_uInt16 GetOriginalHeight( SCROW nRow, SCTAB nTab ) const;
1807 sal_uInt16 GetCommonWidth( SCCOL nEndCol, SCTAB nTab ) const;
1809 SCROW GetHiddenRowCount( SCROW nRow, SCTAB nTab ) const;
1811 sal_uInt16 GetOptimalColWidth( SCCOL nCol, SCTAB nTab, OutputDevice* pDev,
1812 double nPPTX, double nPPTY,
1813 const Fraction& rZoomX, const Fraction& rZoomY,
1814 bool bFormula,
1815 const ScMarkData* pMarkData = nullptr,
1816 const ScColWidthParam* pParam = nullptr );
1818 SC_DLLPUBLIC bool SetOptimalHeight( sc::RowHeightContext& rCxt, SCROW nStartRow,
1819 SCROW nEndRow, SCTAB nTab );
1821 void UpdateAllRowHeights( sc::RowHeightContext& rCxt, const ScMarkData* pTabMark );
1823 long GetNeededSize( SCCOL nCol, SCROW nRow, SCTAB nTab,
1824 OutputDevice* pDev,
1825 double nPPTX, double nPPTY,
1826 const Fraction& rZoomX, const Fraction& rZoomY,
1827 bool bWidth, bool bTotalSize = false );
1829 SC_DLLPUBLIC void ShowCol(SCCOL nCol, SCTAB nTab, bool bShow);
1830 SC_DLLPUBLIC void ShowRow(SCROW nRow, SCTAB nTab, bool bShow);
1831 SC_DLLPUBLIC void ShowRows(SCROW nRow1, SCROW nRow2, SCTAB nTab, bool bShow);
1832 SC_DLLPUBLIC void SetRowFlags( SCROW nRow, SCTAB nTab, CRFlags nNewFlags );
1833 SC_DLLPUBLIC void SetRowFlags( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, CRFlags nNewFlags );
1835 SC_DLLPUBLIC CRFlags GetColFlags( SCCOL nCol, SCTAB nTab ) const;
1836 SC_DLLPUBLIC CRFlags GetRowFlags( SCROW nRow, SCTAB nTab ) const;
1838 SC_DLLPUBLIC void GetAllRowBreaks(std::set<SCROW>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
1839 SC_DLLPUBLIC void GetAllColBreaks(std::set<SCCOL>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
1840 SC_DLLPUBLIC ScBreakType HasRowBreak(SCROW nRow, SCTAB nTab) const;
1841 SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const;
1842 SC_DLLPUBLIC void SetRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
1843 SC_DLLPUBLIC void SetColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
1844 void RemoveRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
1845 void RemoveColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
1846 css::uno::Sequence<
1847 css::sheet::TablePageBreakData> GetRowBreakData(SCTAB nTab) const;
1849 SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
1850 SC_DLLPUBLIC bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1851 SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
1852 SC_DLLPUBLIC void SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden);
1853 SC_DLLPUBLIC void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden);
1854 SC_DLLPUBLIC SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1855 SC_DLLPUBLIC SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1856 SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1858 bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
1859 bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1860 bool ColFiltered(SCCOL nCol, SCTAB nTab) const;
1861 SC_DLLPUBLIC void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered);
1862 SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1863 SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1864 SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1866 SC_DLLPUBLIC bool IsManualRowHeight(SCROW nRow, SCTAB nTab) const;
1868 bool HasUniformRowHeight( SCTAB nTab, SCROW nRow1, SCROW nRow2 ) const;
1871 * Write all column row flags to table's flag data, because not all column
1872 * row attributes are stored in the flag data members. This is necessary
1873 * for ods export.
1875 void SyncColRowFlags();
1877 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
1878 SC_DLLPUBLIC SCROW GetLastFlaggedRow( SCTAB nTab ) const;
1880 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
1881 SCCOL GetLastChangedCol( SCTAB nTab ) const;
1882 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
1883 SCROW GetLastChangedRow( SCTAB nTab ) const;
1885 SCCOL GetNextDifferentChangedCol( SCTAB nTab, SCCOL nStart) const;
1887 SCROW GetNextDifferentChangedRow( SCTAB nTab, SCROW nStart) const;
1889 // returns whether to export a Default style for this col or not
1890 // nDefault is set to one position in the current row where the Default style is
1891 void GetColDefault( SCTAB nTab, SCCOL nCol, SCROW nLastRow, SCROW& nDefault);
1893 bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bShow );
1894 bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bShow );
1896 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
1897 void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
1899 SC_DLLPUBLIC ScPatternAttr* GetDefPattern() const;
1900 SC_DLLPUBLIC ScDocumentPool* GetPool();
1901 SC_DLLPUBLIC ScStyleSheetPool* GetStyleSheetPool() const;
1902 void GetUnprotectedCells( ScRangeList& rRange, SCTAB nTab ) const;
1904 // PageStyle:
1905 SC_DLLPUBLIC const OUString GetPageStyle( SCTAB nTab ) const;
1906 SC_DLLPUBLIC void SetPageStyle( SCTAB nTab, const OUString& rName );
1907 Size GetPageSize( SCTAB nTab ) const;
1908 void SetPageSize( SCTAB nTab, const Size& rSize );
1909 void SetRepeatArea( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
1910 void InvalidatePageBreaks(SCTAB nTab);
1911 void UpdatePageBreaks( SCTAB nTab, const ScRange* pUserArea = nullptr );
1912 void RemoveManualBreaks( SCTAB nTab );
1913 bool HasManualBreaks( SCTAB nTab ) const;
1915 bool IsPageStyleInUse( const OUString& rStrPageStyle, SCTAB* pInTab );
1916 bool RemovePageStyleInUse( const OUString& rStrPageStyle );
1917 bool RenamePageStyleInUse( const OUString& rOld, const OUString& rNew );
1918 void ModifyStyleSheet( SfxStyleSheetBase& rPageStyle,
1919 const SfxItemSet& rChanges );
1921 void PageStyleModified( SCTAB nTab, const OUString& rNewName );
1923 SC_DLLPUBLIC bool NeedPageResetAfterTab( SCTAB nTab ) const;
1925 // Was stored in PageStyle previously. Now it exists for every table:
1926 SC_DLLPUBLIC bool HasPrintRange();
1927 SC_DLLPUBLIC sal_uInt16 GetPrintRangeCount( SCTAB nTab );
1928 SC_DLLPUBLIC const ScRange* GetPrintRange( SCTAB nTab, sal_uInt16 nPos );
1929 SC_DLLPUBLIC const ScRange* GetRepeatColRange( SCTAB nTab );
1930 SC_DLLPUBLIC const ScRange* GetRepeatRowRange( SCTAB nTab );
1931 /** Returns true, if the specified sheet is always printed. */
1932 bool IsPrintEntireSheet( SCTAB nTab ) const;
1934 /** Removes all print ranges. */
1935 SC_DLLPUBLIC void ClearPrintRanges( SCTAB nTab );
1936 /** Adds a new print ranges. */
1937 SC_DLLPUBLIC void AddPrintRange( SCTAB nTab, const ScRange& rNew );
1938 /** Marks the specified sheet to be printed completely. Deletes old print ranges on the sheet! */
1939 SC_DLLPUBLIC void SetPrintEntireSheet( SCTAB nTab );
1940 SC_DLLPUBLIC void SetRepeatColRange( SCTAB nTab, std::unique_ptr<ScRange> pNew );
1941 SC_DLLPUBLIC void SetRepeatRowRange( SCTAB nTab, std::unique_ptr<ScRange> pNew );
1942 ScPrintRangeSaver* CreatePrintRangeSaver() const;
1943 void RestorePrintRanges( const ScPrintRangeSaver& rSaver );
1945 SC_DLLPUBLIC tools::Rectangle GetMMRect( SCCOL nStartCol, SCROW nStartRow,
1946 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1947 SC_DLLPUBLIC ScRange GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool bHiddenAsZero = true ) const;
1949 void UpdStlShtPtrsFrmNms();
1950 void StylesToNames();
1952 SC_DLLPUBLIC void CopyStdStylesFrom( const ScDocument* pSrcDoc );
1954 sal_uLong GetSrcVersion() const { return nSrcVer; }
1956 void SetSrcCharSet( rtl_TextEncoding eNew ) { eSrcSet = eNew; }
1957 void UpdateFontCharSet();
1959 void FillInfo( ScTableInfo& rTabInfo, SCCOL nCol1, SCROW nRow1,
1960 SCCOL nCol2, SCROW nRow2, SCTAB nTab, double fColScale,
1961 double fRowScale, bool bPageMode, bool bFormulaMode,
1962 const ScMarkData* pMarkData = nullptr );
1964 SC_DLLPUBLIC SvNumberFormatter* GetFormatTable() const;
1966 /** Sort a range of data. */
1967 void Sort( SCTAB nTab, const ScSortParam& rSortParam,
1968 bool bKeepQuery, bool bUpdateRefs,
1969 ScProgress* pProgress, sc::ReorderParam* pUndo );
1971 void Reorder( const sc::ReorderParam& rParam );
1973 SCSIZE Query( SCTAB nTab, const ScQueryParam& rQueryParam, bool bKeepSub );
1974 SC_DLLPUBLIC bool CreateQueryParam( const ScRange& rRange, ScQueryParam& rQueryParam );
1975 void GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rStr);
1978 * Get a list of unique strings to use in filtering criteria. The string
1979 * values are sorted, and there are no duplicate values in the list. The
1980 * data range to use to populate the filter entries is inferred from the
1981 * database range that contains the specified cell position.
1983 void GetFilterEntries( SCCOL nCol, SCROW nRow,
1984 SCTAB nTab, ScFilterEntries& rFilterEntries );
1986 SC_DLLPUBLIC void GetFilterEntriesArea( SCCOL nCol, SCROW nStartRow, SCROW nEndRow,
1987 SCTAB nTab, bool bCaseSens,
1988 ScFilterEntries& rFilterEntries );
1990 void GetDataEntries( SCCOL nCol, SCROW nRow, SCTAB nTab,
1991 std::vector<ScTypedStrData>& rStrings, bool bLimit = false );
1992 void GetFormulaEntries( ScTypedCaseStrSet& rStrings );
1994 bool HasAutoFilter( SCCOL nCol, SCROW nRow, SCTAB nTab );
1995 void GetFilterSelCount( SCCOL nCol, SCROW nRow, SCTAB nTab, SCSIZE& nSelected, SCSIZE& nTotal );
1997 SC_DLLPUBLIC bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1998 SCTAB nTab );
1999 SC_DLLPUBLIC bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
2000 SCTAB nTab );
2002 SfxPrinter* GetPrinter( bool bCreateIfNotExist = true );
2003 void SetPrinter( VclPtr<SfxPrinter> const & pNewPrinter );
2004 VirtualDevice* GetVirtualDevice_100th_mm();
2005 SC_DLLPUBLIC OutputDevice* GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice...
2007 bool GetNextSpellingCell( SCCOL& nCol, SCROW& nRow, SCTAB nTab,
2008 bool bInSel, const ScMarkData& rMark) const;
2010 void ReplaceStyle( const SvxSearchItem& rSearchItem,
2011 SCCOL nCol, SCROW nRow, SCTAB nTab,
2012 const ScMarkData& rMark);
2014 void InvalidateTextWidth( const OUString& rStyleName );
2015 void InvalidateTextWidth( SCTAB nTab );
2016 void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo, bool bNumFormatChanged );
2018 bool IdleCalcTextWidth();
2020 void RepaintRange( const ScRange& rRange );
2021 void RepaintRange( const ScRangeList& rRange );
2023 bool IsIdleEnabled() const { return mbIdleEnabled; }
2024 void EnableIdle(bool bDo) { mbIdleEnabled = bDo; }
2026 bool IsDetectiveDirty() const { return bDetectiveDirty; }
2027 void SetDetectiveDirty(bool bSet) { bDetectiveDirty = bSet; }
2029 bool HasLinkFormulaNeedingCheck() const { return bLinkFormulaNeedingCheck; }
2030 void SetLinkFormulaNeedingCheck(bool bSet) { bLinkFormulaNeedingCheck = bSet; }
2031 /** Check token array and set link check if ocDde/ocWebservice is contained. */
2032 SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode );
2034 void SetRangeOverflowType(ErrCode nType) { nRangeOverflowType = nType; }
2035 bool HasRangeOverflow() const { return nRangeOverflowType != ERRCODE_NONE; }
2036 SC_DLLPUBLIC const ErrCode& GetRangeOverflowType() const { return nRangeOverflowType; }
2038 // for broadcasting/listening
2039 void SetInsertingFromOtherDoc( bool bVal ) { bInsertingFromOtherDoc = bVal; }
2040 bool IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc; }
2041 void SetLoadingMedium( bool bVal );
2042 SC_DLLPUBLIC void SetImportingXML( bool bVal );
2043 bool IsImportingXML() const { return bImportingXML; }
2044 bool IsCalcingAfterLoad() const { return bCalcingAfterLoad; }
2045 void SetNoListening( bool bVal ) { bNoListening = bVal; }
2046 bool GetNoListening() const { return bNoListening; }
2047 ScBroadcastAreaSlotMachine* GetBASM() const { return pBASM.get(); }
2049 SC_DLLPUBLIC ScChartListenerCollection* GetChartListenerCollection() const { return pChartListenerCollection;}
2050 void SetChartListenerCollection( ScChartListenerCollection*,
2051 bool bSetChartRangeLists );
2052 void UpdateChart( const OUString& rName );
2053 void RestoreChartListener( const OUString& rName );
2054 SC_DLLPUBLIC void UpdateChartListenerCollection();
2055 bool IsChartListenerCollectionNeedsUpdate() const { return bChartListenerCollectionNeedsUpdate; }
2056 void SetChartListenerCollectionNeedsUpdate( bool bFlg ) { bChartListenerCollectionNeedsUpdate = bFlg; }
2057 void AddOLEObjectToCollection(const OUString& rName);
2059 ScChangeViewSettings* GetChangeViewSettings() const { return pChangeViewSettings.get(); }
2060 SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings& rNew);
2062 const std::shared_ptr<SvxForbiddenCharactersTable>& GetForbiddenCharacters();
2063 void SetForbiddenCharacters(const std::shared_ptr<SvxForbiddenCharactersTable>& rNew);
2065 CharCompressType GetAsianCompression() const;
2066 bool IsValidAsianCompression() const;
2067 void SetAsianCompression(CharCompressType nNew);
2069 bool GetAsianKerning() const;
2070 bool IsValidAsianKerning() const;
2071 void SetAsianKerning(bool bNew);
2072 void ApplyAsianEditSettings(ScEditEngineDefaulter& rEngine);
2074 EEHorizontalTextDirection GetEditTextDirection(SCTAB nTab) const; // EEHorizontalTextDirection values
2076 SC_DLLPUBLIC ScLkUpdMode GetLinkMode() const { return eLinkMode ;}
2077 void SetLinkMode( ScLkUpdMode nSet ) { eLinkMode = nSet;}
2079 SC_DLLPUBLIC ScMacroManager* GetMacroManager();
2081 void FillMatrix( ScMatrix& rMat, SCTAB nTab, SCCOL nCol1,
2082 SCROW nRow1, SCCOL nCol2, SCROW nRow2,
2083 svl::SharedStringPool* pPool = nullptr) const;
2086 * Set an array of numerical formula results to a group of contiguous
2087 * formula cells.
2089 * @param rTopPos position of the top formula cell of a group.
2090 * @param pResults array of numeric results.
2091 * @param nLen length of numeric results.
2093 void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const double* pResults, size_t nLen );
2094 void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const formula::FormulaConstTokenRef* pResults, size_t nLen );
2096 const ScDocumentThreadSpecific& CalculateInColumnInThread( ScInterpreterContext& rContext, const ScAddress& rTopPos, size_t nLen, unsigned nThisThread, unsigned nThreadsTotal);
2097 void HandleStuffAfterParallelCalculation( const ScAddress& rTopPos, size_t nLen );
2100 * Transfer a series of contiguous cell values from specified position to
2101 * the passed container. The specified segment will become empty after the
2102 * transfer.
2104 void TransferCellValuesTo( const ScAddress& rTopPos, size_t nLen, sc::CellValues& rDest );
2105 void CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellValues& rSrc );
2107 std::set<Color> GetDocColors();
2108 sc::IconSetBitmapMap& GetIconSetBitmapMap();
2110 private:
2111 ScDocument(const ScDocument& r) = delete;
2113 void FindMaxRotCol( SCTAB nTab, RowInfo* pRowInfo, SCSIZE nArrCount,
2114 SCCOL nX1, SCCOL nX2 ) const;
2116 sal_uInt16 RowDifferences( SCROW nThisRow, SCTAB nThisTab,
2117 ScDocument& rOtherDoc,
2118 SCROW nOtherRow, SCTAB nOtherTab,
2119 SCCOL nMaxCol, const SCCOLROW* pOtherCols );
2120 sal_uInt16 ColDifferences( SCCOL nThisCol, SCTAB nThisTab,
2121 ScDocument& rOtherDoc,
2122 SCCOL nOtherCol, SCTAB nOtherTab,
2123 SCROW nMaxRow, const SCCOLROW* pOtherRows );
2124 void FindOrder( SCCOLROW* pOtherRows, SCCOLROW nThisEndRow, SCCOLROW nOtherEndRow,
2125 bool bColumns,
2126 ScDocument& rOtherDoc, SCTAB nThisTab, SCTAB nOtherTab,
2127 SCCOLROW nEndCol, const SCCOLROW* pTranslate,
2128 ScProgress* pProgress, sal_uLong nProAdd );
2130 DECL_LINK(TrackTimeHdl, Timer *, void);
2132 static ScRecursionHelper* CreateRecursionHelperInstance();
2134 /** Adjust a range to available sheets.
2136 Used to start and stop listening on a sane range. Both o_rRange and
2137 o_bEntirelyOutOfBounds are set only if needed and don't have to be
2138 initialized by the caller.
2140 @param o_bEntirelyOutOfBounds
2141 <TRUE/> if both sheets in the range point outside the
2142 available sheet range, in which case no adjustment is done and
2143 o_rRange is not modified.
2145 @return <TRUE/> if any adjustment was done or o_bEntirelyOutOfBounds
2146 was set <TRUE/>.
2147 <FALSE/> if rRange was within the available sheets.
2149 bool LimitRangeToAvailableSheets( const ScRange& rRange, ScRange& o_rRange,
2150 bool& o_bEntirelyOutOfBounds ) const;
2152 public:
2153 void StartListeningArea( const ScRange& rRange, bool bGroupListening, SvtListener* pListener );
2155 void EndListeningArea( const ScRange& rRange, bool bGroupListening, SvtListener* pListener );
2156 /** Broadcast wrapper, calls
2157 rHint.GetCell()->Broadcast() and AreaBroadcast()
2158 and TrackFormulas()
2159 Preferred.
2161 void Broadcast( const ScHint& rHint );
2163 void BroadcastCells( const ScRange& rRange, SfxHintId nHint, bool bBroadcastSingleBroadcasters = true );
2164 void BroadcastRefMoved( const sc::RefMovedHint& rHint );
2166 /// only area, no cell broadcast
2167 void AreaBroadcast( const ScHint& rHint );
2168 void DelBroadcastAreasInRange( const ScRange& rRange );
2169 void UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode,
2170 const ScRange& rRange,
2171 SCCOL nDx, SCROW nDy, SCTAB nDz );
2173 void StartListeningCell( const ScAddress& rAddress,
2174 SvtListener* pListener );
2175 void EndListeningCell( const ScAddress& rAddress,
2176 SvtListener* pListener );
2178 void StartListeningCell( sc::StartListeningContext& rCxt, const ScAddress& rPos, SvtListener& rListener );
2179 void EndListeningCell( sc::EndListeningContext& rCxt, const ScAddress& rPos, SvtListener& rListener );
2181 void EndListeningFormulaCells( std::vector<ScFormulaCell*>& rCells );
2182 void CollectAllAreaListeners(
2183 std::vector<SvtListener*>& rListeners, const ScRange& rRange, sc::AreaOverlapType eType );
2185 void PutInFormulaTree( ScFormulaCell* pCell );
2186 void RemoveFromFormulaTree( ScFormulaCell* pCell );
2189 * Calculate formula cells that are on the formula tree either partially,
2190 * or in full.
2192 * @param bOnlyForced when true, it only calculates those formula cells
2193 * that are marked "recalc forced".
2194 * @param bProgressBar whether or not to use progress bar.
2195 * @param bSetAllDirty when true, it marks all formula cells currently on
2196 * the formula tree dirty, which forces all of them to
2197 * be recalculated. When false, only those cells
2198 * that are marked dirty prior to this call get
2199 * recalculated.
2201 SC_DLLPUBLIC void CalcFormulaTree( bool bOnlyForced = false, bool bProgressBar = true, bool bSetAllDirty = true );
2202 void ClearFormulaTree();
2203 void AppendToFormulaTrack( ScFormulaCell* pCell );
2204 void RemoveFromFormulaTrack( ScFormulaCell* pCell );
2205 void TrackFormulas( SfxHintId nHintId = SfxHintId::ScDataChanged );
2206 void SetTrackFormulasPending() { mbTrackFormulasPending = true; }
2207 bool IsTrackFormulasPending() const { return mbTrackFormulasPending; }
2208 void FinalTrackFormulas( SfxHintId nHintId );
2209 bool IsFinalTrackFormulas() const { return mbFinalTrackFormulas; }
2210 bool IsInFormulaTree( const ScFormulaCell* pCell ) const;
2211 bool IsInFormulaTrack( const ScFormulaCell* pCell ) const;
2212 HardRecalcState GetHardRecalcState() { return eHardRecalcState; }
2213 void SetHardRecalcState( HardRecalcState eVal ) { eHardRecalcState = eVal; }
2214 void StartAllListeners();
2215 void StartNeededListeners();
2216 void StartNeededListeners( const std::shared_ptr<const sc::ColumnSet>& rpColSet );
2217 void StartAllListeners( const ScRange& rRange );
2219 void SetForcedFormulas( bool bVal ) { bHasForcedFormulas = bVal; }
2220 sal_uLong GetFormulaCodeInTree() const { return nFormulaCodeInTree; }
2222 bool IsInInterpreter() const { return nInterpretLevel != 0; }
2224 void IncInterpretLevel()
2226 assert(!IsThreadedGroupCalcInProgress());
2227 if ( nInterpretLevel < USHRT_MAX )
2228 nInterpretLevel++;
2230 void DecInterpretLevel()
2232 assert(!IsThreadedGroupCalcInProgress());
2233 if ( nInterpretLevel )
2234 nInterpretLevel--;
2236 sal_uInt16 GetMacroInterpretLevel() { return nMacroInterpretLevel; }
2237 void IncMacroInterpretLevel()
2239 assert(!IsThreadedGroupCalcInProgress());
2240 if ( nMacroInterpretLevel < USHRT_MAX )
2241 nMacroInterpretLevel++;
2243 void DecMacroInterpretLevel()
2245 assert(!IsThreadedGroupCalcInProgress());
2246 if ( nMacroInterpretLevel )
2247 nMacroInterpretLevel--;
2249 bool IsInInterpreterTableOp() const { return nInterpreterTableOpLevel != 0; }
2250 void IncInterpreterTableOpLevel()
2252 if ( nInterpreterTableOpLevel < USHRT_MAX )
2253 nInterpreterTableOpLevel++;
2255 void DecInterpreterTableOpLevel()
2257 if ( nInterpreterTableOpLevel )
2258 nInterpreterTableOpLevel--;
2261 // add a formula to be remembered for TableOp broadcasts
2262 void AddTableOpFormulaCell( ScFormulaCell* );
2263 void InvalidateLastTableOpParams() { aLastTableOpParams.bValid = false; }
2264 ScRecursionHelper& GetRecursionHelper();
2265 bool IsInDtorClear() const { return bInDtorClear; }
2266 void SetExpandRefs( bool bVal );
2267 bool IsExpandRefs() const { return bExpandRefs; }
2269 sal_uLong GetXMLImportedFormulaCount() const { return nXMLImportedFormulaCount; }
2270 void IncXMLImportedFormulaCount( sal_uLong nVal )
2272 if ( nXMLImportedFormulaCount + nVal > nXMLImportedFormulaCount )
2273 nXMLImportedFormulaCount += nVal;
2275 void DecXMLImportedFormulaCount( sal_uLong nVal )
2277 if ( nVal <= nXMLImportedFormulaCount )
2278 nXMLImportedFormulaCount -= nVal;
2279 else
2280 nXMLImportedFormulaCount = 0;
2283 void StartTrackTimer();
2285 void CompileDBFormula();
2286 void CompileColRowNameFormula();
2288 /** Maximum string length of a column, e.g. for dBase export.
2289 @return String length in octets (!) of the destination encoding. In
2290 case of non-octet encodings (e.g. UCS2) the length in code
2291 points times sizeof(sal_Unicode) is returned. */
2292 sal_Int32 GetMaxStringLen( SCTAB nTab, SCCOL nCol,
2293 SCROW nRowStart, SCROW nRowEnd,
2294 rtl_TextEncoding eCharSet ) const;
2295 /** Maximum string length of numerical cells of a column, e.g. for dBase export.
2296 @return String length in characters (!) including the decimal
2297 separator, and the decimal precision needed. */
2298 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
2299 SCTAB nTab, SCCOL nCol,
2300 SCROW nRowStart, SCROW nRowEnd ) const;
2302 void KeyInput(); // TimerDelays etc.
2304 ScChangeTrack* GetChangeTrack() const { return pChangeTrack.get(); }
2306 //! only for import filter, deletes any existing ChangeTrack via
2307 //! EndChangeTracking() and takes ownership of new ChangeTrack pTrack
2308 SC_DLLPUBLIC void SetChangeTrack( std::unique_ptr<ScChangeTrack> pTrack );
2310 void StartChangeTracking();
2311 void EndChangeTracking();
2313 SC_DLLPUBLIC void CompareDocument( ScDocument& rOtherDoc );
2315 void AddUnoObject( SfxListener& rObject );
2316 void RemoveUnoObject( SfxListener& rObject );
2317 void BroadcastUno( const SfxHint &rHint );
2318 void AddUnoListenerCall( const css::uno::Reference<
2319 css::util::XModifyListener >& rListener,
2320 const css::lang::EventObject& rEvent );
2322 void SetInLinkUpdate(bool bSet); // TableLink or AreaLink
2323 bool IsInLinkUpdate() const; // including DdeLink
2325 SC_DLLPUBLIC SfxItemPool* GetEditPool() const;
2326 SC_DLLPUBLIC SfxItemPool* GetEnginePool() const;
2327 SC_DLLPUBLIC ScFieldEditEngine& GetEditEngine();
2328 SC_DLLPUBLIC ScNoteEditEngine& GetNoteEngine();
2330 std::unique_ptr<ScRefreshTimerControl> const & GetRefreshTimerControlAddress() const
2331 { return pRefreshTimerControl; }
2333 void SetPastingDrawFromOtherDoc( bool bVal )
2334 { bPastingDrawFromOtherDoc = bVal; }
2335 bool PastingDrawFromOtherDoc() const
2336 { return bPastingDrawFromOtherDoc; }
2338 /// an ID unique to each document instance
2339 sal_uInt32 GetDocumentID() const;
2341 void InvalidateStyleSheetUsage() { bStyleSheetUsageInvalid = true; }
2342 void SC_DLLPUBLIC GetSortParam( ScSortParam& rParam, SCTAB nTab );
2343 void SC_DLLPUBLIC SetSortParam( const ScSortParam& rParam, SCTAB nTab );
2345 void SetVbaEventProcessor( const css::uno::Reference< css::script::vba::XVBAEventProcessor >& rxVbaEvents )
2346 { mxVbaEvents = rxVbaEvents; }
2347 const css::uno::Reference< css::script::vba::XVBAEventProcessor >& GetVbaEventProcessor() const { return mxVbaEvents; }
2349 /** Should only be GRAM_PODF or GRAM_ODFF. */
2350 void SetStorageGrammar( formula::FormulaGrammar::Grammar eGrammar );
2351 formula::FormulaGrammar::Grammar GetStorageGrammar() const { return eStorageGrammar; }
2353 SC_DLLPUBLIC SfxUndoManager* GetUndoManager();
2354 bool IsInVBAMode() const;
2355 ScRowBreakIterator* GetRowBreakIterator(SCTAB nTab) const;
2357 void AddSubTotalCell(ScFormulaCell* pCell);
2358 void RemoveSubTotalCell(ScFormulaCell* pCell);
2359 void SetSubTotalCellsDirty(const ScRange& rDirtyRange);
2361 sal_uInt16 GetTextWidth( const ScAddress& rPos ) const;
2363 SvtScriptType GetScriptType( const ScAddress& rPos ) const;
2364 void SetScriptType( const ScAddress& rPos, SvtScriptType nType );
2365 void UpdateScriptTypes( const ScAddress& rPos, SCCOL nColSize, SCROW nRowSize );
2367 size_t GetFormulaHash( const ScAddress& rPos ) const;
2370 * Make specified formula cells non-grouped.
2372 * @param nTab sheet index
2373 * @param nCol column index
2374 * @param rRows list of row indices at which formula cells are to be
2375 * unshared. This call sorts the passed row indices and
2376 * removes duplicates, which is why the caller must pass it
2377 * as reference.
2379 void UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector<SCROW>& rRows );
2380 void RegroupFormulaCells( SCTAB nTab, SCCOL nCol );
2382 ScFormulaVectorState GetFormulaVectorState( const ScAddress& rPos ) const;
2384 formula::FormulaTokenRef ResolveStaticReference( const ScAddress& rPos );
2385 formula::FormulaTokenRef ResolveStaticReference( const ScRange& rRange );
2387 formula::VectorRefArray FetchVectorRefArray( const ScAddress& rPos, SCROW nLength );
2388 bool HandleRefArrayForParallelism( const ScAddress& rPos, SCROW nLength );
2391 * Call this before any operations that might trigger one or more formula
2392 * cells to get calculated.
2394 void PrepareFormulaCalc();
2397 * Make sure all of the formula cells in the specified range have been
2398 * fully calculated. This method only re-calculates those formula cells
2399 * that have been flagged dirty.
2401 * @param rRange range in which to potentially calculate the formula
2402 * cells.
2404 void EnsureFormulaCellResults( const ScRange& rRange );
2406 SvtBroadcaster* GetBroadcaster( const ScAddress& rPos );
2407 const SvtBroadcaster* GetBroadcaster( const ScAddress& rPos ) const;
2408 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rTopPos, SCROW nLength );
2410 std::unique_ptr<sc::ColumnIterator> GetColumnIterator( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
2412 SC_DLLPUBLIC void StoreTabToCache(SCTAB nTab, SvStream& rStrm) const;
2413 SC_DLLPUBLIC void RestoreTabFromCache(SCTAB nTab, SvStream& rStream);
2415 #if DUMP_COLUMN_STORAGE
2416 SC_DLLPUBLIC void DumpColumnStorage( SCTAB nTab, SCCOL nCol ) const;
2417 #endif
2419 #if DEBUG_AREA_BROADCASTER
2420 SC_DLLPUBLIC void DumpAreaBroadcasters() const;
2421 #endif
2423 SC_DLLPUBLIC void SetCalcConfig( const ScCalcConfig& rConfig );
2424 const ScCalcConfig& GetCalcConfig() const { return maCalcConfig; }
2425 void ConvertFormulaToValue( const ScRange& rRange, sc::TableValues* pUndo );
2426 void SwapNonEmpty( sc::TableValues& rValues );
2427 void finalizeOutlineImport();
2428 bool TableExists( SCTAB nTab ) const;
2430 SC_DLLPUBLIC ScColumnsRange GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const;
2432 private:
2435 * Use this class as a locale variable to merge number formatter from
2436 * another document, and set NULL pointer to pFormatExchangeList when
2437 * done.
2439 class NumFmtMergeHandler
2441 public:
2442 explicit NumFmtMergeHandler(ScDocument* pDoc, const ScDocument* pSrcDoc);
2443 ~NumFmtMergeHandler();
2445 private:
2446 ScDocument* mpDoc;
2449 ScTable* FetchTable( SCTAB nTab );
2450 const ScTable* FetchTable( SCTAB nTab ) const;
2452 void MergeNumberFormatter(const ScDocument* pSrcDoc);
2454 void ImplCreateOptions(); // Suggestion: switch to on-demand?
2455 void ImplDeleteOptions();
2457 void DeleteDrawLayer();
2458 SC_DLLPUBLIC bool DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const;
2460 void UpdateDrawPrinter();
2461 void UpdateDrawLanguages();
2462 SC_DLLPUBLIC void InitClipPtrs( ScDocument* pSourceDoc );
2464 void LoadDdeLinks(SvStream& rStream);
2465 void SaveDdeLinks(SvStream& rStream) const;
2467 void DeleteAreaLinksOnTab( SCTAB nTab );
2468 void UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
2469 const ScRange& r, SCCOL nDx, SCROW nDy, SCTAB nDz );
2471 void CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks);
2473 bool HasPartOfMerged( const ScRange& rRange );
2475 ScRefCellValue GetRefCellValue( const ScAddress& rPos );
2477 std::map< SCTAB, ScSortParam > mSheetSortParams;
2479 SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol ) const;
2480 SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
2481 void ReservePatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserve );
2483 void SharePooledResources( const ScDocument* pSrcDoc );
2485 void EndListeningIntersectedGroup(
2486 sc::EndListeningContext& rCxt, const ScAddress& rPos, std::vector<ScAddress>* pGroupPos );
2488 void EndListeningIntersectedGroups(
2489 sc::EndListeningContext& rCxt, const ScRange& rRange, std::vector<ScAddress>* pGroupPos );
2491 void EndListeningGroups( const std::vector<ScAddress>& rPosArray );
2492 void SetNeedsListeningGroups( const std::vector<ScAddress>& rPosArray );
2495 typedef std::unique_ptr<ScDocument, o3tl::default_delete<ScDocument>> ScDocumentUniquePtr;
2498 * Instantiate this to ensure that subsequent modification of
2499 * the document will cause an assertion failure while this is
2500 * in-scope.
2502 struct ScMutationDisable
2504 ScMutationDisable(ScDocument* pDocument, ScMutationGuardFlags nFlags)
2506 #ifndef NDEBUG
2507 mpDocument = pDocument;
2508 mnFlagRestore = pDocument->mnMutationGuardFlags;
2509 assert((mnFlagRestore & nFlags) == 0);
2510 mpDocument->mnMutationGuardFlags |= static_cast<size_t>(nFlags);
2511 #else
2512 (void)pDocument; (void)nFlags;
2513 #endif
2515 #ifndef NDEBUG
2516 ~ScMutationDisable()
2518 mpDocument->mnMutationGuardFlags = mnFlagRestore;
2520 size_t mnFlagRestore;
2521 ScDocument* mpDocument;
2522 #endif
2526 * A pretty assertion that checks that the relevant bits in
2527 * the @nFlags are not set on the document at entry and exit.
2529 * Its primary use is for debugging threading. As such, an
2530 * @ScMutationDisable is created to forbid mutation, and this
2531 * condition is then asserted on at prominent sites that
2532 * mutate @nFlags.
2534 struct ScMutationGuard
2536 ScMutationGuard(ScDocument* pDocument, ScMutationGuardFlags nFlags)
2538 #ifndef NDEBUG
2539 mpDocument = pDocument;
2540 mnFlags = static_cast<size_t>(nFlags);
2541 assert((mpDocument->mnMutationGuardFlags & mnFlags) == 0);
2542 #else
2543 (void)pDocument; (void)nFlags;
2544 #endif
2546 #ifndef NDEBUG
2547 ~ScMutationGuard()
2549 assert((mpDocument->mnMutationGuardFlags & mnFlags) == 0);
2551 size_t mnFlags;
2552 ScDocument* mpDocument;
2553 #endif
2556 #endif
2558 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */