ofz: Use-of-uninitialized-value
[LibreOffice.git] / sc / inc / document.hxx
blob2050eac9595f02f4e5684c5efbee9ec0bbbd8bde
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 #pragma once
22 #include <vcl/idle.hxx>
23 #include <vcl/errcode.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <vcl/vclptr.hxx>
26 #include "patattr.hxx"
27 #include "scdllapi.h"
28 #include "interpretercontext.hxx"
29 #include "rangelst.hxx"
30 #include "rangenam.hxx"
31 #include "tabopparams.hxx"
32 #include "types.hxx"
33 #include <formula/grammar.hxx>
34 #include <formula/types.hxx>
35 #include "typedstrdata.hxx"
36 #include "calcmacros.hxx"
37 #include "calcconfig.hxx"
38 #include "sheetlimits.hxx"
39 #include <o3tl/deleter.hxx>
40 #include <o3tl/sorted_vector.hxx>
41 #include <svl/hint.hxx>
42 #include <svl/typedwhich.hxx>
43 #include <svl/zforlist.hxx>
44 #include <tools/gen.hxx>
45 #include <tools/solar.h>
47 #include <cassert>
48 #include <memory>
49 #include <map>
50 #include <optional>
51 #include <set>
52 #include <unordered_map>
53 #include <vector>
55 #include "markdata.hxx"
56 #include "drwlayer.hxx"
58 namespace com::sun::star::chart2 { class XChartDocument; }
60 class Timer;
62 enum class SvtScriptType;
63 enum class ScMF;
64 enum class FormulaError : sal_uInt16;
65 enum class CharCompressType;
66 enum class EEHorizontalTextDirection;
67 namespace editeng { class SvxBorderLine; }
68 namespace formula { struct VectorRefArray; }
69 namespace svl {
71 class SharedString;
72 class SharedStringPool;
76 namespace sc {
78 struct FormulaGroupContext;
79 class StartListeningContext;
80 class EndListeningContext;
81 class CopyFromClipContext;
82 class ColumnSpanSet;
83 class RangeColumnSpanSet;
84 struct ColumnBlockPosition;
85 struct RefUpdateContext;
86 class EditTextIterator;
87 struct NoteEntry;
88 class DocumentStreamAccess;
89 class DocumentLinkManager;
90 class CellValues;
91 class TableValues;
92 class RowHeightContext;
93 struct SetFormulaDirtyContext;
94 class RefMovedHint;
95 struct ReorderParam;
96 class FormulaGroupAreaListener;
97 class ColumnSet;
98 class UpdatedRangeNames;
99 class TableColumnBlockPositionSet;
100 class ColumnIterator;
101 class ExternalDataMapper;
105 class Fraction;
107 class OutputDevice;
108 class SdrObject;
109 class SfxBroadcaster;
110 class SfxListener;
111 class SfxItemSet;
112 class SfxObjectShell;
113 class SfxBindings;
114 class SfxPoolItem;
115 class SfxItemPool;
116 class SfxPrinter;
117 class SfxStyleSheetBase;
118 class SvMemoryStream;
119 class SvxBoxInfoItem;
120 class SvxBoxItem;
121 class SvxForbiddenCharactersTable;
122 namespace sfx2 {
123 class LinkManager;
125 class SvxSearchItem;
126 class XColorList;
128 class ScAutoFormatData;
129 class ScBroadcastAreaSlotMachine;
130 class ScChangeViewSettings;
131 class ScChartListenerCollection;
132 class ScClipOptions;
133 class ScColumn;
134 class ScConditionalFormat;
135 class ScConditionalFormatList;
136 class ScDBCollection;
137 class ScDBData;
138 class ScDetOpData;
139 class ScDetOpList;
140 class ScDocOptions;
141 class ScDocProtection;
142 class ScDocumentPool;
143 class ScDrawLayer;
144 class ScExtDocOptions;
145 class ScExternalRefManager;
146 class ScFormulaCell;
147 class ScMacroManager;
148 class ScOutlineTable;
149 class ScPrintRangeSaver;
150 class ScStyleSheet;
151 class ScStyleSheetPool;
152 class ScTable;
153 class ScTableProtection;
154 class ScTokenArray;
155 class ScValidationData;
156 class ScValidationDataList;
157 class ScViewOptions;
158 class ScChangeTrack;
159 class ScEditEngineDefaulter;
160 class ScFieldEditEngine;
161 class ScNoteEditEngine;
162 class ScDPObject;
163 class ScDPCollection;
164 class ScMatrix;
165 class ScScriptTypeData;
166 class ScPoolHelper;
167 struct ScSortParam;
168 class ScRefreshTimerControl;
169 class ScUnoListenerCalls;
170 class ScUnoRefList;
171 class ScRecursionHelper;
172 struct RowInfo;
173 struct ScTableInfo;
174 struct ScTabOpParam;
175 class VirtualDevice;
176 class ScAutoNameCache;
177 class ScTemporaryChartLock;
178 class ScLookupCache;
179 struct ScLookupCacheMap;
180 class SfxUndoManager;
181 class ScFormulaParserPool;
182 struct ScClipParam;
183 class ScRowBreakIterator;
184 struct ScSetStringParam;
185 struct ScColWidthParam;
186 class ScSheetEvents;
187 class ScProgress;
188 class SvtListener;
189 class ScEditDataArray;
190 class EditTextObject;
191 struct ScRefCellValue;
192 class ScPostIt;
193 struct ScSubTotalParam;
194 struct ScQueryParam;
195 class ScHint;
196 class SvtBroadcaster;
197 enum class ScDBDataPortion;
198 enum class ScSheetEventId;
199 class BitmapEx;
200 class ScColumnsRange;
201 struct ScFilterEntries;
202 typedef o3tl::sorted_vector<sal_uInt32> ScCondFormatIndexes;
203 struct ScSheetLimits;
204 struct ScDataAreaExtras;
206 namespace sc {
208 typedef std::map<OUString, BitmapEx> IconSetBitmapMap;
212 namespace com::sun::star {
213 namespace lang {
214 struct EventObject;
216 namespace i18n {
217 class XBreakIterator;
219 namespace util {
220 class XModifyListener;
222 namespace embed {
223 class XEmbeddedObject;
225 namespace script::vba {
226 class XVBAEventProcessor;
228 namespace sheet {
229 struct TablePageBreakData;
233 namespace weld {
235 class Window;
239 #define SC_DOC_NEW 0xFFFF
241 #define SC_MACROCALL_ALLOWED 0
243 #define SC_ASIANKERNING_INVALID 0xff
245 enum ScDocumentMode
247 SCDOCMODE_DOCUMENT,
248 SCDOCMODE_CLIP,
249 SCDOCMODE_UNDO,
250 SCDOCMODE_FUNCTIONACCESS
253 enum CommentCaptionState
255 ALLSHOWN, // All comments captions are shown
256 ALLHIDDEN, // All comments captions are hidden
257 MIXED // There are comments in shown and hidden.
260 enum RangeNameScope
262 GLOBAL, // A range name can be defined
263 SHEET // with two scope on Manage Names dialog.
266 /// Represents the type of sheet geometry data.
267 enum class SheetGeomType
269 SIZES, // Column widths or row heights.
270 HIDDEN, // Hidden columns/rows.
271 FILTERED, // Filtered columns/rows.
272 GROUPS // Grouping of columns/rows.
275 struct ScDocStat
277 OUString aDocName;
278 SCTAB nTableCount;
279 sal_uLong nCellCount;
280 sal_uLong nFormulaCount;
281 sal_uInt16 nPageCount;
282 ScDocStat()
283 : nTableCount(0)
284 , nCellCount(0)
285 , nFormulaCount(0)
286 , nPageCount(0)
291 // DDE link modes
292 const sal_uInt8 SC_DDE_DEFAULT = 0;
293 const sal_uInt8 SC_DDE_ENGLISH = 1;
294 const sal_uInt8 SC_DDE_TEXT = 2;
295 const sal_uInt8 SC_DDE_IGNOREMODE = 255; /// For usage in FindDdeLink() only!
297 // During threaded calculation fields being mutated are kept in this struct
298 struct ScDocumentThreadSpecific
300 std::unique_ptr<ScRecursionHelper> xRecursionHelper; // information for recursive and iterative cell formulas
301 ScInterpreterContext* pContext = nullptr; // references the context passed around for easier access
304 /// Enumeration to determine which pieces of the code should not be mutated when set.
305 enum ScMutationGuardFlags
307 // Bit mask bits
308 CORE = 0x0001, /// Core calc data structures should not be mutated
311 typedef std::unique_ptr<ScTable, o3tl::default_delete<ScTable>> ScTableUniquePtr;
313 class ScDocument
315 friend class ScValueIterator;
316 friend class ScHorizontalValueIterator;
317 friend class ScDBQueryDataIterator;
318 friend class ScFormulaGroupIterator;
319 friend class ScCellIterator;
320 friend class ScQueryCellIterator;
321 friend class ScCountIfCellIterator;
322 friend class ScHorizontalCellIterator;
323 friend class ScHorizontalAttrIterator;
324 friend class ScDocAttrIterator;
325 friend class ScAccessibleTableBase;
326 friend class ScAttrRectIterator;
327 friend class ScDocShell;
328 friend class ScDocRowHeightUpdater;
329 friend class ScColumnTextWidthIterator;
330 friend class ScFormulaCell;
331 friend class ScTable;
332 friend class ScColumn;
333 friend struct ScRefCellValue;
334 friend class ScDocumentImport;
335 friend class sc::DocumentStreamAccess;
336 friend class sc::ColumnSpanSet;
337 friend class sc::RangeColumnSpanSet;
338 friend class sc::EditTextIterator;
339 friend class sc::FormulaGroupAreaListener;
340 friend class sc::TableColumnBlockPositionSet;
341 friend struct ScMutationGuard;
342 friend struct ScMutationDisable;
344 typedef std::vector<ScTableUniquePtr> TableContainer;
346 public:
347 enum class HardRecalcState
349 OFF, /// normal calculation of dependencies
350 TEMPORARY, /// CalcAll() without broadcast/notify but setting up new listeners
351 ETERNAL /// no new listeners are setup, no broadcast/notify
354 private:
355 rtl::Reference<ScPoolHelper> mxPoolHelper;
357 std::shared_ptr<svl::SharedStringPool> mpCellStringPool;
358 std::unique_ptr<sc::DocumentLinkManager> mpDocLinkMgr;
360 std::shared_ptr<sc::FormulaGroupContext> mpFormulaGroupCxt;
361 bool mbFormulaGroupCxtBlockDiscard;
363 ScCalcConfig maCalcConfig;
365 SfxUndoManager* mpUndoManager;
366 std::unique_ptr<ScFieldEditEngine> mpEditEngine; // uses pEditPool from xPoolHelper
367 std::unique_ptr<ScNoteEditEngine> mpNoteEngine; // uses pEditPool from xPoolHelper
368 SfxObjectShell* mpShell;
369 VclPtr<SfxPrinter> mpPrinter;
370 VclPtr<VirtualDevice> mpVirtualDevice_100th_mm;
371 std::unique_ptr<ScDrawLayer> mpDrawLayer; // SdrModel
372 rtl::Reference<XColorList> pColorList;
373 std::unique_ptr<ScValidationDataList> pValidationList; // validity
374 SvNumberFormatterIndexTable* pFormatExchangeList; // for application of number formats
375 TableContainer maTabs;
376 rtl::Reference<ScSheetLimits> mxSheetLimits;
377 std::vector<OUString> maTabNames; // for undo document, we need the information tab name <-> index
378 mutable std::unique_ptr<ScRangeName> pRangeName;
379 std::unique_ptr<ScDBCollection> pDBCollection;
380 std::unique_ptr<ScDPCollection> pDPCollection;
381 std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock;
382 std::unique_ptr<ScPatternAttr> pSelectionAttr; // Attributes of a block
383 ScFormulaCell* pFormulaTree; // formula tree (start)
384 ScFormulaCell* pEOFormulaTree; // formula tree (end), last cell
385 ScFormulaCell* pFormulaTrack; // BroadcastTrack (start)
386 ScFormulaCell* pEOFormulaTrack; // BroadcastTrack (end), last cell
387 std::unique_ptr<ScBroadcastAreaSlotMachine> pBASM; // BroadcastAreas
388 std::unique_ptr<ScChartListenerCollection> pChartListenerCollection;
389 std::unique_ptr<SvMemoryStream> pClipData;
390 std::unique_ptr<ScDetOpList> pDetOpList;
391 std::unique_ptr<ScChangeTrack> pChangeTrack;
392 std::unique_ptr<SfxBroadcaster> pUnoBroadcaster;
393 std::unique_ptr<ScUnoListenerCalls> pUnoListenerCalls;
394 std::unique_ptr<ScUnoRefList> pUnoRefUndoList;
395 std::unique_ptr<ScChangeViewSettings> pChangeViewSettings;
396 std::unique_ptr<ScScriptTypeData> pScriptTypeData;
397 std::unique_ptr<ScRefreshTimerControl> pRefreshTimerControl;
398 std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenCharacters;
399 std::unique_ptr<ScDBData> mpAnonymousDBData;
400 std::unique_ptr<sc::ExternalDataMapper> mpDataMapper;
402 std::unique_ptr<ScFieldEditEngine> pCacheFieldEditEngine;
404 std::unique_ptr<ScDocProtection> pDocProtection;
405 std::unique_ptr<ScClipParam> mpClipParam;
407 std::unique_ptr<ScExternalRefManager> pExternalRefMgr;
408 std::unique_ptr<ScMacroManager> mpMacroMgr;
410 // mutable for lazy construction
411 mutable std::unique_ptr< ScFormulaParserPool >
412 mxFormulaParserPool; /// Pool for all external formula parsers used by this document.
414 OUString aDocName; // optional: name of document
415 OUString aDocCodeName; // optional: name of document (twice?)
416 OUString maFileURL; // file URL for copy & paste
417 ScRangePairListRef xColNameRanges;
418 ScRangePairListRef xRowNameRanges;
420 std::unique_ptr<ScViewOptions> pViewOptions; // view options
421 std::unique_ptr<ScDocOptions> pDocOptions; // document options
422 std::unique_ptr<ScExtDocOptions> pExtDocOptions; // for import etc.
423 std::unique_ptr<ScClipOptions> mpClipOptions; // clipboard options
424 std::unique_ptr<ScConsolidateParam> pConsolidateDlgData;
426 std::unique_ptr<ScAutoNameCache> pAutoNameCache; // for automatic name lookup during CompileXML
428 std::unique_ptr<SfxItemSet> pPreviewFont; // convert to std::unique_ptr or whatever
429 ScStyleSheet* pPreviewCellStyle;
430 ScMarkData maPreviewSelection;
431 sal_Int64 nUnoObjectId; // counted up for UNO objects
433 ErrCode nRangeOverflowType; // used in (xml) loading for overflow warnings
435 ScRange aEmbedRange;
436 ScAddress aCurTextWidthCalcPos;
438 Idle aTrackIdle;
440 css::uno::Reference< css::script::vba::XVBAEventProcessor >
441 mxVbaEvents;
442 public:
443 /// list of ScInterpreterTableOpParams currently in use
444 std::vector<ScInterpreterTableOpParams*> m_TableOpList;
445 ScInterpreterTableOpParams aLastTableOpParams; // remember last params
447 private:
449 LanguageType eLanguage; // default language
450 LanguageType eCjkLanguage; // default language for asian text
451 LanguageType eCtlLanguage; // default language for complex text
452 rtl_TextEncoding eSrcSet; // during reading: source character set
454 /** The compiler grammar used in document storage. GRAM_PODF for ODF 1.1
455 documents, GRAM_ODFF for ODF 1.2 documents. */
456 formula::FormulaGrammar::Grammar eStorageGrammar;
458 sal_uLong nFormulaCodeInTree; // formula RPN in the formula tree
459 sal_uLong nXMLImportedFormulaCount; // progress count during XML import
460 sal_uInt16 nInterpretLevel; // >0 if in interpreter
461 sal_uInt16 nMacroInterpretLevel; // >0 if macro in interpreter
462 sal_uInt16 nInterpreterTableOpLevel; // >0 if in interpreter TableOp
464 ScDocumentThreadSpecific maNonThreaded;
466 // There can be only one ScDocument being calculated in a thread at a time, so we can use a
467 // plain thread_local static member.
468 thread_local static ScDocumentThreadSpecific maThreadSpecific;
470 mutable ScInterpreterContext maInterpreterContext;
472 osl::Mutex mScLookupMutex; // protection for thread-unsafe parts of handling ScLookup
474 static const sal_uInt16 nSrcVer; // file version (load/save)
475 sal_uInt16 nFormulaTrackCount;
476 HardRecalcState eHardRecalcState; // off, temporary, eternal
477 SCTAB nVisibleTab; // for OLE etc., don't use inside ScDocument
478 SCCOL nPosLeft; // for OLE etc., don't use inside ScDocument
479 SCROW nPosTop; // for OLE etc., don't use inside ScDocument
481 ScLkUpdMode eLinkMode;
483 bool bAutoCalc; // calculate automatically
484 bool bAutoCalcShellDisabled; // in/from/for ScDocShell disabled
485 // are there ForcedFormulas which have to be calculated
486 // in interaction with ScDocShell SetDocumentModified,
487 // AutoCalcShellDisabled and TrackFormulas
488 bool bForcedFormulaPending;
489 bool bCalculatingFormulaTree;
490 bool bIsClip;
491 bool bIsUndo;
492 bool bIsFunctionAccess;
493 bool bIsVisible; // set from view ctor
495 bool bIsEmbedded; // display/adjust Embedded area?
497 // no broadcast, construct no listener during insert from a different
498 // Doc (per filter or the like ), not until CompileAll / CalcAfterLoad
499 bool bInsertingFromOtherDoc;
500 bool bLoadingMedium;
501 bool bImportingXML; // special handling of formula text
502 bool bCalcingAfterLoad; // in CalcAfterLoad TRUE
503 // don't construct/destruct listeners temporarily
504 bool bNoListening;
505 bool mbIdleEnabled;
506 bool bInLinkUpdate; // TableLink or AreaLink
507 bool bChartListenerCollectionNeedsUpdate;
508 // are/were there RC_FORCED formula cells in the document (if set once to TRUE then set forever)
509 bool bHasForcedFormulas;
510 // is the Doc being destroyed? (no Notify-Tracking etc. needed anymore)
511 bool bInDtorClear;
512 // expand reference if insert column/row takes place at the border
513 // of a reference
514 // is fetched in each UpdateReference from InputOptions,
515 // assigned, and restored at the end of UpdateReference
516 bool bExpandRefs;
517 // for detective update, is set for each change of a formula
518 bool bDetectiveDirty;
519 // If the pointer is set, formula cells will not be automatically grouped into shared formula groups,
520 // instead the range will be extended to contain all such cells.
521 std::unique_ptr< ScRange > pDelayedFormulaGrouping;
522 // If non-empty, ScColumn::StartListeningFormulaCells() calls may be delayed using this,
523 // avoiding repeated calling for the same cells in the given range. The function will be called once
524 // later for all the cells in the range.
525 std::unordered_map< ScColumn*, std::pair<SCROW, SCROW>> pDelayedStartListeningFormulaCells;
527 bool bLinkFormulaNeedingCheck; // valid only after loading, for ocDde and ocWebservice
529 CharCompressType nAsianCompression;
530 sal_uInt8 nAsianKerning;
532 bool bPastingDrawFromOtherDoc;
534 sal_uInt8 nInDdeLinkUpdate; // originating DDE links (stacked bool)
536 bool bInUnoBroadcast;
537 bool bInUnoListenerCall;
538 sal_uInt32 nAdjustHeightLock;
539 formula::FormulaGrammar::Grammar eGrammar;
541 mutable bool bStyleSheetUsageInvalid;
543 bool mbUndoEnabled:1;
544 bool mbExecuteLinkEnabled:1;
545 bool mbChangeReadOnlyEnabled:1; // allow changes in read-only document (for API import filters)
546 bool mbStreamValidLocked:1;
547 bool mbUserInteractionEnabled:1; // whether or not to launch any kind of interactive dialogs.
549 sal_Int16 mnNamedRangesLockCount;
551 std::set<ScFormulaCell*> maSubTotalCells;
554 bool mbEmbedFonts : 1;
555 bool mbEmbedUsedFontsOnly : 1;
556 bool mbEmbedFontScriptLatin : 1;
557 bool mbEmbedFontScriptAsian : 1;
558 bool mbEmbedFontScriptComplex : 1;
560 std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap;
562 bool mbTrackFormulasPending : 1;
563 bool mbFinalTrackFormulas : 1;
564 // This indicates if a ScDocShell::DoRecalc() or ScDocShell::DoHardRecalc() is in progress.
565 bool mbDocShellRecalc : 1;
566 // This indicates if a ScOutputData::LayoutStrings() is in progress.
567 bool mbLayoutStrings : 1;
569 size_t mnMutationGuardFlags;
571 public:
572 bool IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBorder);
573 void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge);
575 bool IsEmbedFonts() const { return mbEmbedFonts; }
576 bool IsEmbedUsedFontsOnly() const { return mbEmbedUsedFontsOnly; }
577 bool IsEmbedFontScriptLatin() const { return mbEmbedFontScriptLatin; }
578 bool IsEmbedFontScriptAsian() const { return mbEmbedFontScriptAsian; }
579 bool IsEmbedFontScriptComplex() const { return mbEmbedFontScriptComplex; }
581 void SetEmbedFonts(bool bUse) { mbEmbedFonts = bUse; }
582 void SetEmbedUsedFontsOnly(bool bUse) { mbEmbedUsedFontsOnly = bUse; }
583 void SetEmbedFontScriptLatin(bool bUse) { mbEmbedFontScriptLatin = bUse; }
584 void SetEmbedFontScriptAsian(bool bUse) { mbEmbedFontScriptAsian = bUse; }
585 void SetEmbedFontScriptComplex(bool bUse) { mbEmbedFontScriptComplex = bUse; }
587 SC_DLLPUBLIC sal_uLong GetCellCount() const; // all cells
588 SC_DLLPUBLIC sal_uLong GetFormulaGroupCount() const; // all cells
589 sal_uLong GetCodeCount() const; // RPN-Code in formulas
590 DECL_LINK( GetUserDefinedColor, sal_uInt16, Color* );
591 // number formatter
592 public:
593 SC_DLLPUBLIC ScDocument( ScDocumentMode eMode = SCDOCMODE_DOCUMENT,
594 SfxObjectShell* pDocShell = nullptr );
595 SC_DLLPUBLIC ~ScDocument();
597 void SetName( const OUString& r ) { aDocName = r; }
598 const OUString& GetCodeName() const { return aDocCodeName; }
599 void SetCodeName( const OUString& r ) { aDocCodeName = r; }
600 const OUString& GetFileURL() const { return maFileURL; }
602 void GetDocStat( ScDocStat& rDocStat );
604 SC_DLLPUBLIC void InitDrawLayer( SfxObjectShell* pDocShell = nullptr );
606 ScInterpreterContext& GetNonThreadedContext() const
608 assert(!IsThreadedGroupCalcInProgress());
609 return maInterpreterContext;
611 // Uses thread_local.
612 ScInterpreterContext& GetThreadedContext() const
614 return IsThreadedGroupCalcInProgress() ? *maThreadSpecific.pContext : GetNonThreadedContext();
616 void SetupContextFromNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
617 void MergeContextBackIntoNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
618 void SetThreadedGroupCalcInProgress( bool set ) { (void)this; ScGlobal::bThreadedGroupCalcInProgress = set; }
619 bool IsThreadedGroupCalcInProgress() const { (void)this; return ScGlobal::bThreadedGroupCalcInProgress; }
621 SC_DLLPUBLIC sfx2::LinkManager* GetLinkManager();
622 SC_DLLPUBLIC const sfx2::LinkManager* GetLinkManager() const;
624 sc::DocumentLinkManager& GetDocLinkManager();
625 const sc::DocumentLinkManager& GetDocLinkManager() const;
627 SC_DLLPUBLIC const ScDocOptions& GetDocOptions() const;
628 SC_DLLPUBLIC void SetDocOptions( const ScDocOptions& rOpt );
629 SC_DLLPUBLIC const ScViewOptions& GetViewOptions() const;
630 SC_DLLPUBLIC void SetViewOptions( const ScViewOptions& rOpt );
631 void SetPrintOptions();
633 ScExtDocOptions* GetExtDocOptions() { return pExtDocOptions.get(); }
634 SC_DLLPUBLIC void SetExtDocOptions( std::unique_ptr<ScExtDocOptions> pNewOptions );
636 ScClipOptions* GetClipOptions() { return mpClipOptions.get(); }
637 void SetClipOptions(std::unique_ptr<ScClipOptions> pClipOptions);
639 SC_DLLPUBLIC void GetLanguage( LanguageType& rLatin, LanguageType& rCjk, LanguageType& rCtl ) const;
640 void SetLanguage( LanguageType eLatin, LanguageType eCjk, LanguageType eCtl );
642 void SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pData );
643 const ScConsolidateParam* GetConsolidateDlgData() const { return pConsolidateDlgData.get(); }
645 void Clear( bool bFromDestructor = false );
647 std::unique_ptr<ScFieldEditEngine> CreateFieldEditEngine();
648 void DisposeFieldEditEngine(std::unique_ptr<ScFieldEditEngine>& rpEditEngine);
651 * Get all range names that are local to each table. It only returns
652 * non-empty range name set.
654 SC_DLLPUBLIC void GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rRangeNames) const;
655 SC_DLLPUBLIC void SetAllRangeNames(const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap);
656 SC_DLLPUBLIC void GetRangeNameMap(std::map<OUString, ScRangeName*>& rRangeName);
657 SC_DLLPUBLIC ScRangeName* GetRangeName(SCTAB nTab) const;
658 SC_DLLPUBLIC ScRangeName* GetRangeName() const;
659 void SetRangeName(SCTAB nTab, std::unique_ptr<ScRangeName> pNew);
660 void SetRangeName( std::unique_ptr<ScRangeName> pNewRangeName );
661 bool IsAddressInRangeName( RangeNameScope eScope, const ScAddress& rAddress);
663 /** Find a named expression / range name in either global or a local scope.
664 @param nTab
665 If <0 search nIndex in global scope, if >=0 search nIndex in scope of nTab.
666 @param nIndex
667 Index of named expression / range name.
668 @return nullptr if indexed name not found.
670 ScRangeData* FindRangeNameBySheetAndIndex( SCTAB nTab, sal_uInt16 nIndex ) const;
672 /** Recursively find all named expressions that directly or indirectly
673 (nested) reference a given sheet, starting from a given named
674 expression nTokenTab/nTokenIndex.
676 Used to collect all named expressions/ranges that will need to be
677 copied along when copying sheets.
679 The different tab/sheets passed cater for the situation that a sheet is
680 copied and was already inserted and global names are already adjusted
681 but the sheet-local names of the shifted original sheet are not yet. If
682 no sheet was inserted and global and local names' references not
683 updated yet, then all 4 tab arguments would be identical.
685 @param nTokenTab
686 Tab/sheet on which to find the name, -1 if global scope.
687 For example obtained from ocName token.
689 @param nTokenIndex
690 Index of named expression. For example obtained from ocName token.
692 @param nGlobalRefTab
693 Tab to check if used in global names.
695 @param nLocalRefTab
696 Tab to check if used in sheet-local names.
698 @param nOldTokenTab
699 The original tab of the copied sheet, used as sheet-local
700 base position for relative references.
702 @param nOldTokenTabReplacement
703 The replacement to use for relative references if the name
704 encountered uses nOldTokenTab as base position.
706 @param bSameDoc
707 FALSE if collecting names for a sheet to be copied to another
708 document. Then all names encountered are considered to be
709 referencing the sheet. Else TRUE if collecting names to be
710 copied into the same document.
712 @param nRecursion
713 Recursion guard, initialize with 0.
715 bool FindRangeNamesReferencingSheet( sc::UpdatedRangeNames& rIndexes,
716 SCTAB nTokenTab, const sal_uInt16 nTokenIndex,
717 SCTAB nGlobalRefTab, SCTAB nLocalRefTab, SCTAB nOldTokenTab, SCTAB nOldTokenTabReplacement,
718 bool bSameDoc, int nRecursion ) const;
720 /** If necessary (name references sheet rOldPos.Tab()) copy and adjust
721 named expression/range from sheet-local to sheet-local, or global to
722 sheet-local if bGlobalNamesToLocal==true.
724 Also copies nested names and adjusts the ocName tokens of the calling name.
726 @param rSheet
727 On entry, the original sheet of the named expression/range, <0 global.
728 On return TRUE, the new sheet. Else unchanged.
730 @param rIndex
731 On entry, the original index of the named expression/range.
732 On return TRUE, the new index, or 0 if a new copied name couldn't be inserted. Else unchanged.
734 @param rpRangeData
735 On entry, the pointer to the original named expression/range.
736 On return TRUE, the pointer to the new copied name, or nullptr if hits happened.
738 @param rNewPos
739 New position of formula cell if called for that, else new base
740 position of a to be created new name adjusted for Tab.
741 rNewPos.nTab MUST point to the new sheet copied to.
743 @param rOldPos
744 Old position of formula cell if called for that, else base
745 position of the existing name adjusted for Tab.
746 rOldPos.nTab MUST point to the old sheet copied from.
748 @param bGlobalNamesToLocal
749 If TRUE, affected global names are copied to sheet-local names.
750 If FALSE, global names are copied to global names in another document.
752 @param bUsedByFormula
753 If TRUE, forces a global name to be affected/used.
754 If FALSE, a global name is only affected if it evaluates to be
755 referencing the sheet.
757 @return TRUE if copied and caller may need to evaluate rpRangeData and rSheet and rIndex.
758 FALSE if nothing to be done.
760 bool CopyAdjustRangeName( SCTAB& rSheet, sal_uInt16& rIndex, ScRangeData*& rpRangeData, ScDocument& rNewDoc,
761 const ScAddress& rNewPos, const ScAddress& rOldPos, const bool bGlobalNamesToLocal,
762 const bool bUsedByFormula ) const;
765 * Call this immediately before updating all named ranges.
767 SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate( const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap );
768 SC_DLLPUBLIC void PreprocessRangeNameUpdate();
769 SC_DLLPUBLIC void PreprocessDBDataUpdate();
771 * Call this immediately after updating named ranges.
773 SC_DLLPUBLIC void CompileHybridFormula();
776 * Insert a new named expression to the global scope.
778 * @param rName name for the expression.
779 * @param rPos base position.
780 * @param rExpr formula expression to be associated with the name. The
781 * current grammar is used to compile this expression.
783 * @return true if inserted successfully, false otherwise.
785 bool InsertNewRangeName( const OUString& rName, const ScAddress& rPos, const OUString& rExpr );
788 * Insert a new named expression to a sheet-local scope.
790 * @param nTab sheet for local scope.
791 * @param rName name for the expression.
792 * @param rPos base position.
793 * @param rExpr formula expression to be associated with the name. The
794 * current grammar is used to compile this expression.
796 * @return true if inserted successfully, false otherwise.
798 bool InsertNewRangeName( SCTAB nTab, const OUString& rName, const ScAddress& rPos, const OUString& rExpr );
800 /** Obtain the sheet separator corresponding to the document's grammar.
802 @return '.' for our own grammars, '!' for Excel grammars.
804 SC_DLLPUBLIC sal_Unicode GetSheetSeparator() const;
806 SCTAB GetMaxTableNumber() const { return static_cast<SCTAB>(maTabs.size()) - 1; }
808 ScRangePairList* GetColNameRanges() { return xColNameRanges.get(); }
809 ScRangePairList* GetRowNameRanges() { return xRowNameRanges.get(); }
810 ScRangePairListRef& GetColNameRangesRef() { return xColNameRanges; }
811 ScRangePairListRef& GetRowNameRangesRef() { return xRowNameRanges; }
813 SC_DLLPUBLIC SCCOL ClampToAllocatedColumns(SCTAB nTab, SCCOL nCol) const;
814 SC_DLLPUBLIC SCCOL GetAllocatedColumnsCount(SCTAB nTab) const;
816 SC_DLLPUBLIC ScDBCollection* GetDBCollection() const { return pDBCollection.get();}
817 void SetDBCollection( std::unique_ptr<ScDBCollection> pNewDBCollection,
818 bool bRemoveAutoFilter = false );
819 const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const;
820 ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion);
821 SC_DLLPUBLIC const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
822 SC_DLLPUBLIC ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
823 void RefreshDirtyTableColumnNames();
824 SC_DLLPUBLIC sc::ExternalDataMapper& GetExternalDataMapper();
826 SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock( const ScRange& rBlock, OUString& rName,
827 bool* pSheetLocal = nullptr ) const;
829 SC_DLLPUBLIC bool HasPivotTable() const;
830 SC_DLLPUBLIC ScDPCollection* GetDPCollection();
831 SC_DLLPUBLIC const ScDPCollection* GetDPCollection() const;
832 SC_DLLPUBLIC ScDPObject* GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
833 ScDPObject* GetDPAtBlock( const ScRange& rBlock ) const;
835 void StopTemporaryChartLock();
837 void EnsureGraphicNames();
839 SdrObject* GetObjectAtPoint( SCTAB nTab, const Point& rPos );
840 bool HasChartAtPoint( SCTAB nTab, const Point& rPos, OUString& rName );
842 css::uno::Reference< css::chart2::XChartDocument > GetChartByName( std::u16string_view rChartName );
844 SC_DLLPUBLIC void GetChartRanges( std::u16string_view rChartName, std::vector< ScRangeList >& rRanges, const ScDocument& rSheetNameDoc );
845 void SetChartRanges( std::u16string_view rChartName, const std::vector< ScRangeList >& rRanges );
847 void UpdateChartArea( const OUString& rChartName, const ScRange& rNewArea,
848 bool bColHeaders, bool bRowHeaders, bool bAdd );
849 void UpdateChartArea( const OUString& rChartName,
850 const ScRangeListRef& rNewList,
851 bool bColHeaders, bool bRowHeaders, bool bAdd );
852 void GetOldChartParameters( std::u16string_view rName,
853 ScRangeList& rRanges, bool& rColHeaders, bool& rRowHeaders );
854 css::uno::Reference<
855 css::embed::XEmbeddedObject >
856 FindOleObjectByName( std::u16string_view rName );
858 SC_DLLPUBLIC void MakeTable( SCTAB nTab,bool _bNeedsNameCheck = true );
860 SCTAB GetVisibleTab() const { return nVisibleTab; }
861 SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab) { nVisibleTab = nTab; }
862 SCCOL GetPosLeft() const { return nPosLeft; }
863 SC_DLLPUBLIC void SetPosLeft(SCCOL nCol) { nPosLeft = nCol; }
864 SCROW GetPosTop() const { return nPosTop; }
865 SC_DLLPUBLIC void SetPosTop(SCROW nRow) { nPosTop = nRow; }
867 SC_DLLPUBLIC bool HasTable( SCTAB nTab ) const;
868 SC_DLLPUBLIC bool GetHashCode( SCTAB nTab, sal_Int64& rHashCode) const;
869 SC_DLLPUBLIC bool GetName( SCTAB nTab, OUString& rName ) const;
870 SC_DLLPUBLIC bool GetCodeName( SCTAB nTab, OUString& rName ) const;
871 SC_DLLPUBLIC bool SetCodeName( SCTAB nTab, const OUString& rName );
872 SC_DLLPUBLIC bool GetTable( const OUString& rName, SCTAB& rTab ) const;
873 SC_DLLPUBLIC SCCOL MaxCol() const { return mxSheetLimits->mnMaxCol; }
874 SC_DLLPUBLIC SCROW MaxRow() const { return mxSheetLimits->mnMaxRow; }
875 ScSheetLimits& GetSheetLimits() const { return *mxSheetLimits; }
876 [[nodiscard]] bool ValidCol(SCCOL nCol) const { return ::ValidCol(nCol, mxSheetLimits->mnMaxCol); }
877 [[nodiscard]] bool ValidRow(SCROW nRow) const { return ::ValidRow(nRow, mxSheetLimits->mnMaxRow); }
878 [[nodiscard]] bool ValidColRow(SCCOL nCol, SCROW nRow) const { return ::ValidColRow(nCol, nRow, MaxCol(), MaxRow()); }
879 [[nodiscard]] bool ValidColRowTab(SCCOL nCol, SCROW nRow, SCTAB nTab) const { return ::ValidColRowTab(nCol, nRow, nTab, MaxCol(), MaxRow()); }
880 [[nodiscard]] bool ValidRange(const ScRange& rRange) const { return ::ValidRange(rRange, MaxCol(), MaxRow()); }
881 [[nodiscard]] bool ValidAddress(const ScAddress& rAddress) const { return ::ValidAddress(rAddress, MaxCol(), MaxRow()); }
882 [[nodiscard]] SCCOL SanitizeCol( SCCOL nCol ) const { return ::SanitizeCol(nCol, MaxCol()); }
883 [[nodiscard]] SCROW SanitizeRow( SCROW nRow ) const { return ::SanitizeRow(nRow, MaxRow()); }
885 SC_DLLPUBLIC std::vector<OUString> GetAllTableNames() const;
887 OUString GetCopyTabName(SCTAB nTab) const;
889 SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, std::unique_ptr<ScDBData> pDBData);
890 SC_DLLPUBLIC ScDBData* GetAnonymousDBData(SCTAB nTab);
892 /** One document global anonymous database range for temporary operations,
893 used if the corresponding sheet-local anonymous database range is
894 already used with AutoFilter and range differs. Not stored in document
895 files. */
896 SC_DLLPUBLIC void SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData);
897 SC_DLLPUBLIC ScDBData* GetAnonymousDBData();
899 SC_DLLPUBLIC SCTAB GetTableCount() const;
900 SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; }
902 SC_DLLPUBLIC ScDocProtection* GetDocProtection() const;
903 SC_DLLPUBLIC void SetDocProtection(const ScDocProtection* pProtect);
904 SC_DLLPUBLIC bool IsDocProtected() const;
905 bool IsDocEditable() const;
906 SC_DLLPUBLIC bool IsTabProtected( SCTAB nTab ) const;
907 SC_DLLPUBLIC const ScTableProtection* GetTabProtection(SCTAB nTab) const;
908 SC_DLLPUBLIC void SetTabProtection(SCTAB nTab, const ScTableProtection* pProtect);
909 void CopyTabProtection(SCTAB nTabSrc, SCTAB nTabDest);
911 void LockTable(SCTAB nTab);
912 void UnlockTable(SCTAB nTab);
914 bool IsBlockEditable( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
915 SCCOL nEndCol, SCROW nEndRow,
916 bool* pOnlyNotBecauseOfMatrix = nullptr,
917 bool bNoMatrixAtAll = false ) const;
918 bool IsSelectionEditable( const ScMarkData& rMark,
919 bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
920 bool HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nStartRow,
921 SCCOL nEndCol, SCROW nEndRow,
922 const ScMarkData& rMark ) const;
924 bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCTAB nTab, SCCOLROW nStart, SCCOLROW nEnd ) const;
925 bool IsEditActionAllowed( sc::ColRowEditAction eAction, const ScMarkData& rMark, SCCOLROW nStart, SCCOLROW nEnd ) const;
927 SC_DLLPUBLIC bool GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix );
929 bool IsEmbedded() const { return bIsEmbedded;}
930 void GetEmbedded( ScRange& rRange ) const;
931 void SetEmbedded( const ScRange& rRange );
932 void ResetEmbedded();
933 tools::Rectangle GetEmbeddedRect() const; // 1/100 mm
934 void SetEmbedded( SCTAB nTab, const tools::Rectangle& rRect ); // from VisArea (1/100 mm)
936 static SC_DLLPUBLIC bool ValidTabName( const OUString& rName );
938 SC_DLLPUBLIC bool ValidNewTabName( const OUString& rName ) const;
939 SC_DLLPUBLIC void CreateValidTabName(OUString& rName) const;
940 SC_DLLPUBLIC void CreateValidTabNames(std::vector<OUString>& aNames, SCTAB nCount) const;
942 void AppendTabOnLoad(const OUString& rName);
943 void SetTabNameOnLoad(SCTAB nTab, const OUString& rName);
944 void InvalidateStreamOnSave();
946 SC_DLLPUBLIC bool InsertTab( SCTAB nPos, const OUString& rName,
947 bool bExternalDocument = false, bool bUndoDeleteTab = false );
949 SC_DLLPUBLIC bool InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
950 bool bNamesValid = false );
951 SC_DLLPUBLIC bool DeleteTabs( SCTAB nTab, SCTAB nSheets );
952 SC_DLLPUBLIC bool DeleteTab( SCTAB nTab );
953 SC_DLLPUBLIC bool RenameTab( SCTAB nTab, const OUString& rName,
954 bool bExternalDocument = false );
955 bool MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress = nullptr );
956 bool CopyTab( SCTAB nOldPos, SCTAB nNewPos,
957 const ScMarkData* pOnlyMarked = nullptr );
958 SC_DLLPUBLIC sal_uLong TransferTab(ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos,
959 bool bInsertNew = true,
960 bool bResultsOnly = false );
961 SC_DLLPUBLIC void TransferDrawPage(const ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos);
962 SC_DLLPUBLIC void SetVisible( SCTAB nTab, bool bVisible );
963 SC_DLLPUBLIC bool IsVisible( SCTAB nTab ) const;
964 bool IsStreamValid( SCTAB nTab ) const;
965 void SetStreamValid( SCTAB nTab, bool bSet, bool bIgnoreLock = false );
966 void LockStreamValid( bool bLock );
967 bool IsStreamValidLocked() const { return mbStreamValidLocked; }
968 bool IsPendingRowHeights( SCTAB nTab ) const;
969 void SetPendingRowHeights( SCTAB nTab, bool bSet );
970 SC_DLLPUBLIC void SetLayoutRTL( SCTAB nTab, bool bRTL, ScObjectHandling eObjectHandling = ScObjectHandling::RecalcPosMode);
971 SC_DLLPUBLIC bool IsLayoutRTL( SCTAB nTab ) const;
972 SC_DLLPUBLIC bool IsNegativePage( SCTAB nTab ) const;
973 SC_DLLPUBLIC void SetScenario( SCTAB nTab, bool bFlag );
974 SC_DLLPUBLIC bool IsScenario( SCTAB nTab ) const;
975 SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString& rComment,
976 Color& rColor, ScScenarioFlags &rFlags) const;
977 SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString& rComment,
978 const Color& rColor, ScScenarioFlags nFlags);
979 SC_DLLPUBLIC Color GetTabBgColor( SCTAB nTab ) const;
980 SC_DLLPUBLIC void SetTabBgColor( SCTAB nTab, const Color& rColor );
981 SC_DLLPUBLIC bool IsDefaultTabBgColor( SCTAB nTab ) const;
982 void GetScenarioFlags(SCTAB nTab, ScScenarioFlags &rFlags) const;
983 SC_DLLPUBLIC bool IsActiveScenario( SCTAB nTab ) const;
984 SC_DLLPUBLIC void SetActiveScenario( SCTAB nTab, bool bActive ); // only for Undo etc.
985 SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const;
986 SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const { return eGrammar;}
987 SC_DLLPUBLIC void SetGrammar( formula::FormulaGrammar::Grammar eGram );
988 SC_DLLPUBLIC ScLinkMode GetLinkMode( SCTAB nTab ) const;
989 bool IsLinked( SCTAB nTab ) const;
990 SC_DLLPUBLIC OUString GetLinkDoc( SCTAB nTab ) const;
991 OUString GetLinkFlt( SCTAB nTab ) const;
992 OUString GetLinkOpt( SCTAB nTab ) const;
993 SC_DLLPUBLIC OUString GetLinkTab( SCTAB nTab ) const;
994 sal_uLong GetLinkRefreshDelay( SCTAB nTab ) const;
995 void SetLink( SCTAB nTab, ScLinkMode nMode, const OUString& rDoc,
996 const OUString& rFilter, const OUString& rOptions,
997 const OUString& rTabName, sal_uLong nRefreshDelay );
998 bool HasLink( std::u16string_view rDoc,
999 std::u16string_view rFilter, std::u16string_view rOptions ) const;
1000 SC_DLLPUBLIC bool LinkExternalTab( SCTAB& nTab, const OUString& aDocTab,
1001 const OUString& aFileName,
1002 const OUString& aTabName );
1004 bool HasExternalRefManager() const { return bool(pExternalRefMgr); }
1005 SC_DLLPUBLIC ScExternalRefManager* GetExternalRefManager() const;
1006 bool IsInExternalReferenceMarking() const;
1007 void MarkUsedExternalReferences();
1008 bool MarkUsedExternalReferences( const ScTokenArray& rArr, const ScAddress& rPos );
1010 /** Returns the pool containing external formula parsers. Creates the pool
1011 on first call. */
1012 ScFormulaParserPool& GetFormulaParserPool() const;
1014 bool HasAreaLinks() const;
1015 void UpdateExternalRefLinks(weld::Window* pWin);
1016 void UpdateAreaLinks();
1018 // originating DDE links
1019 void IncInDdeLinkUpdate() { if ( nInDdeLinkUpdate < 255 ) ++nInDdeLinkUpdate; }
1020 void DecInDdeLinkUpdate() { if ( nInDdeLinkUpdate ) --nInDdeLinkUpdate; }
1021 bool IsInDdeLinkUpdate() const { return nInDdeLinkUpdate != 0; }
1023 SC_DLLPUBLIC void CopyDdeLinks( ScDocument& rDestDoc ) const;
1025 /** Tries to find a DDE link with the specified connection data.
1026 @param rnDdePos (out-param) Returns the index of the DDE link (does not include other links from link manager).
1027 @return true = DDE link found, rnDdePos valid. */
1028 SC_DLLPUBLIC bool FindDdeLink( std::u16string_view rAppl, std::u16string_view rTopic,
1029 std::u16string_view rItem, sal_uInt8 nMode, size_t& rnDdePos );
1031 /** Returns the connection data of the specified DDE link.
1032 @param nDdePos Index of the DDE link (does not include other links from link manager).
1033 @param rAppl (out-param) The application name.
1034 @param rTopic (out-param) The DDE topic.
1035 @param rItem (out-param) The DDE item.
1036 @return true = DDE link found, out-parameters valid. */
1037 bool GetDdeLinkData( size_t nDdePos, OUString& rAppl, OUString& rTopic, OUString& rItem ) const;
1038 /** Returns the link mode of the specified DDE link.
1039 @param nDdePos Index of the DDE link (does not include other links from link manager).
1040 @param rnMode (out-param) The link mode of the specified DDE link.
1041 @return true = DDE link found, rnMode valid. */
1042 bool GetDdeLinkMode( size_t nDdePos, sal_uInt8& rnMode ) const;
1043 /** Returns the result matrix of the specified DDE link.
1044 @param nDdePos Index of the DDE link (does not include other links from link manager).
1045 @return The result matrix, if the DDE link has been found, 0 otherwise. */
1046 SC_DLLPUBLIC const ScMatrix* GetDdeLinkResultMatrix( size_t nDdePos ) const;
1048 /** Tries to find a DDE link or creates a new, if not extant.
1049 @param pResults If not 0, sets the matrix as DDE link result matrix (also for existing links).
1050 @return true = DDE link found; false = Unpredictable error occurred, no DDE link created. */
1051 SC_DLLPUBLIC bool CreateDdeLink( const OUString& rAppl, const OUString& rTopic, const OUString& rItem, sal_uInt8 nMode, const ScMatrixRef& pResults );
1052 /** Sets a result matrix for the specified DDE link.
1053 @param nDdePos Index of the DDE link (does not include other links from link manager).
1054 @param pResults The array containing all results of the DDE link (intrusive-ref-counted, do not delete).
1055 @return true = DDE link found and matrix set. */
1056 bool SetDdeLinkResultMatrix( size_t nDdePos, const ScMatrixRef& pResults );
1058 SfxBindings* GetViewBindings();
1059 SfxObjectShell* GetDocumentShell() const { return mpShell; }
1060 SC_DLLPUBLIC ScDrawLayer* GetDrawLayer() { return mpDrawLayer.get(); }
1061 SC_DLLPUBLIC const ScDrawLayer* GetDrawLayer() const { return mpDrawLayer.get(); }
1062 SfxBroadcaster* GetDrawBroadcaster(); // to avoid header
1063 void BeginDrawUndo();
1065 void BeginUnoRefUndo();
1066 bool HasUnoRefUndo() const { return ( pUnoRefUndoList != nullptr ); }
1067 [[nodiscard]]
1068 std::unique_ptr<ScUnoRefList> EndUnoRefUndo(); // must be deleted by caller!
1069 sal_Int64 GetNewUnoId() { return ++nUnoObjectId; }
1070 void AddUnoRefChange( sal_Int64 nId, const ScRangeList& rOldRanges );
1072 static bool IsChart( const SdrObject* pObject );
1074 void UpdateChartRef( UpdateRefMode eUpdateRefMode,
1075 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1076 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1077 SCCOL nDx, SCROW nDy, SCTAB nDz );
1078 //! only assigns the new RangeList, no ChartListener or the like
1079 void SetChartRangeList( std::u16string_view rChartName,
1080 const ScRangeListRef& rNewRangeListRef );
1082 void StartAnimations( SCTAB nTab );
1084 bool HasBackgroundDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const;
1085 bool HasAnyDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const;
1087 const ScSheetEvents* GetSheetEvents( SCTAB nTab ) const;
1088 void SetSheetEvents( SCTAB nTab, std::unique_ptr<ScSheetEvents> pNew );
1089 bool HasSheetEventScript( SCTAB nTab, ScSheetEventId nEvent, bool bWithVbaEvents = false ) const;
1090 bool HasAnySheetEventScript( ScSheetEventId nEvent, bool bWithVbaEvents = false ) const; // on any sheet
1092 bool HasAnyCalcNotification() const;
1093 bool HasCalcNotification( SCTAB nTab ) const;
1094 void SetCalcNotification( SCTAB nTab );
1095 void ResetCalcNotifications();
1097 SC_DLLPUBLIC ScOutlineTable* GetOutlineTable( SCTAB nTab, bool bCreate = false );
1098 bool SetOutlineTable( SCTAB nTab, const ScOutlineTable* pNewOutline );
1100 void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow,
1101 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1103 bool DoSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
1104 void RemoveSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
1105 bool TestRemoveSubTotals( SCTAB nTab, const ScSubTotalParam& rParam );
1106 bool HasSubTotalCells( const ScRange& rRange );
1108 SC_DLLPUBLIC void EnsureTable( SCTAB nTab );
1110 // return TRUE = number format is set
1111 SC_DLLPUBLIC bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
1112 const ScSetStringParam * pParam = nullptr );
1113 SC_DLLPUBLIC bool SetString( const ScAddress& rPos, const OUString& rString,
1114 const ScSetStringParam* pParam = nullptr );
1117 * This method manages the lifecycle of the passed edit text object. When
1118 * the text is successfully inserted, the cell takes over the ownership of
1119 * the text object. If not, the text object gets deleted.
1121 * <p>The caller must ensure that the passed edit text object <i>uses the
1122 * SfxItemPool instance returned from ScDocument::GetEditPool()</i>.
1123 * This is very important.</p>
1125 SC_DLLPUBLIC bool SetEditText( const ScAddress& rPos, std::unique_ptr<EditTextObject> pEditText );
1126 void SetEditText( const ScAddress& rPos, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
1127 SC_DLLPUBLIC void SetEditText( const ScAddress& rPos, const OUString& rStr );
1128 SC_DLLPUBLIC SCROW GetFirstEditTextRow( const ScRange& rRange ) const;
1131 * Call this if you are not sure whether to put this as an edit text or a
1132 * simple text.
1134 SC_DLLPUBLIC void SetTextCell( const ScAddress& rPos, const OUString& rStr );
1135 void SetEmptyCell( const ScAddress& rPos );
1136 SC_DLLPUBLIC void SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal );
1137 SC_DLLPUBLIC void SetValue( const ScAddress& rPos, double fVal );
1138 void SetValues( const ScAddress& rPos, const std::vector<double>& rVals );
1139 void SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError);
1140 SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const ScTokenArray& rArray );
1141 SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const OUString& rFormula,
1142 formula::FormulaGrammar::Grammar eGram );
1145 * Set formula cell, and transfer its ownership to the document. This call
1146 * attempts to group the passed formula cell with the adjacent cells or
1147 * cell groups if appropriate.
1149 * @return pCell if it was successfully inserted, NULL otherwise. pCell
1150 * is deleted automatically on failure to insert.
1152 SC_DLLPUBLIC ScFormulaCell* SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell );
1153 bool SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCell*>& rCells );
1156 * Check if there is at least one formula cell in specified range.
1158 bool HasFormulaCell( const ScRange& rRange ) const;
1159 SC_DLLPUBLIC void InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
1160 SCCOL nCol2, SCROW nRow2,
1161 const ScMarkData& rMark,
1162 const OUString& rFormula,
1163 const ScTokenArray* p = nullptr,
1164 const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT );
1165 SC_DLLPUBLIC void InsertTableOp(const ScTabOpParam& rParam, // multi-operation
1166 SCCOL nCol1, SCROW nRow1,
1167 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark);
1169 SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab,
1170 const ScInterpreterContext* pContext = nullptr ) const;
1171 SC_DLLPUBLIC OUString GetString( const ScAddress& rPos,
1172 const ScInterpreterContext* pContext = nullptr ) const;
1175 * Return a pointer to the double value stored in value cell.
1177 * @param rPos cell position
1179 * @return pointer to the double value stored in a numeric cell, or NULL
1180 * if the cell at specified position is not a numeric cell.
1182 SC_DLLPUBLIC double* GetValueCell( const ScAddress& rPos );
1184 SC_DLLPUBLIC svl::SharedStringPool& GetSharedStringPool();
1185 const svl::SharedStringPool& GetSharedStringPool() const;
1187 svl::SharedString GetSharedString( const ScAddress& rPos ) const;
1189 std::shared_ptr<sc::FormulaGroupContext>& GetFormulaGroupContext();
1190 void DiscardFormulaGroupContext();
1191 void BlockFormulaGroupContextDiscard( bool block )
1192 { mbFormulaGroupCxtBlockDiscard = block; }
1194 // Note that if pShared is set and a value is returned that way, the returned OUString is empty.
1195 SC_DLLPUBLIC OUString GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab,
1196 const svl::SharedString** pShared = nullptr ) const;
1197 FormulaError GetStringForFormula( const ScAddress& rPos, OUString& rString );
1198 SC_DLLPUBLIC double GetValue( const ScAddress& rPos ) const;
1199 SC_DLLPUBLIC double GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1200 SC_DLLPUBLIC const EditTextObject* GetEditText( const ScAddress& rPos ) const;
1201 void RemoveEditTextCharAttribs( const ScAddress& rPos, const ScPatternAttr& rAttr );
1202 SC_DLLPUBLIC double RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScInterpreterContext* pContext = nullptr ) const;
1203 SC_DLLPUBLIC sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1204 sal_uInt32 GetNumberFormat( const ScRange& rRange ) const;
1205 SC_DLLPUBLIC sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& ) const;
1206 void SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberFormat );
1208 void GetNumberFormatInfo( const ScInterpreterContext& rContext, SvNumFormatType& nType, sal_uInt32& nIndex, const ScAddress& rPos ) const;
1209 SC_DLLPUBLIC const ScFormulaCell* GetFormulaCell( const ScAddress& rPos ) const;
1210 SC_DLLPUBLIC ScFormulaCell* GetFormulaCell( const ScAddress& rPos );
1211 SC_DLLPUBLIC OUString GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1212 SC_DLLPUBLIC CellType GetCellType( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1213 SC_DLLPUBLIC CellType GetCellType( const ScAddress& rPos ) const;
1215 SC_DLLPUBLIC bool HasData( SCCOL nCol, SCROW nRow, SCTAB nTab );
1216 SC_DLLPUBLIC bool HasStringData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1217 SC_DLLPUBLIC bool HasValueData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1218 SC_DLLPUBLIC bool HasValueData( const ScAddress& rPos ) const;
1219 bool HasStringCells( const ScRange& rRange ) const;
1221 /** Returns true, if there is any data to create a selection list for rPos. */
1222 bool HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1223 bool HasValidationData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1226 * Check if the specified range contains either: 1) one non-empty cell, 2)
1227 * more than one non-empty cells, or 3) totally empty. In case the range
1228 * contains at least one non-empty cell, specify the position of the first
1229 * non-empty cell.
1231 sc::MultiDataCellState HasMultipleDataCells( const ScRange& rRange ) const;
1233 /** Notes **/
1234 SC_DLLPUBLIC ScPostIt* GetNote(const ScAddress& rPos);
1235 SC_DLLPUBLIC ScPostIt* GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
1236 void SetNote(const ScAddress& rPos, std::unique_ptr<ScPostIt> pNote);
1237 void SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, std::unique_ptr<ScPostIt> pNote);
1238 SC_DLLPUBLIC bool HasNote(const ScAddress& rPos) const;
1239 bool HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
1240 bool HasNote(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow) const;
1241 SC_DLLPUBLIC bool HasColNotes(SCCOL nCol, SCTAB nTab) const;
1242 SC_DLLPUBLIC bool HasTabNotes(SCTAB nTab) const;
1243 bool HasNotes() const;
1244 SC_DLLPUBLIC std::unique_ptr<ScPostIt> ReleaseNote(const ScAddress& rPos);
1245 SC_DLLPUBLIC ScPostIt* GetOrCreateNote(const ScAddress& rPos);
1246 SC_DLLPUBLIC ScPostIt* CreateNote(const ScAddress& rPos);
1247 size_t GetNoteCount( SCTAB nTab, SCCOL nCol ) const;
1250 * Ensure that all note objects have an associated sdr object. The export
1251 * code uses sdr objects to export note data.
1253 void CreateAllNoteCaptions();
1254 void ForgetNoteCaptions( const ScRangeList& rRanges, bool bPreserveData );
1255 CommentCaptionState GetAllNoteCaptionsState( const ScRangeList& rRanges);
1257 ScAddress GetNotePosition( size_t nIndex ) const;
1258 ScAddress GetNotePosition( size_t nIndex, SCTAB nTab ) const;
1259 SCROW GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const;
1261 SC_DLLPUBLIC void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
1262 SC_DLLPUBLIC void GetAllNoteEntries( SCTAB nTab, std::vector<sc::NoteEntry>& rNotes ) const;
1263 void GetNotesInRange( const ScRangeList& rRange, std::vector<sc::NoteEntry>& rNotes ) const;
1264 bool ContainsNotesInRange( const ScRangeList& rRange ) const;
1266 SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab);
1268 bool IsMerged( const ScAddress& rPos ) const;
1270 void ExtendMergeSel( SCCOL nStartCol, SCROW nStartRow,
1271 SCCOL& rEndCol, SCROW& rEndRow, const ScMarkData& rMark,
1272 bool bRefresh = false );
1273 SC_DLLPUBLIC bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
1274 SCCOL& rEndCol, SCROW& rEndRow, SCTAB nTab,
1275 bool bRefresh = false );
1276 bool ExtendMerge( ScRange& rRange, bool bRefresh = false );
1277 SC_DLLPUBLIC void ExtendTotalMerge( ScRange& rRange ) const;
1278 SC_DLLPUBLIC void ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow,
1279 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const;
1280 SC_DLLPUBLIC void ExtendOverlapped( ScRange& rRange ) const;
1282 bool RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow,
1283 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1285 SC_DLLPUBLIC void DoMergeContents( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1286 SCCOL nEndCol, SCROW nEndRow );
1287 SC_DLLPUBLIC void DoEmptyBlock( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1288 SCCOL nEndCol, SCROW nEndRow );
1289 // without checking:
1290 SC_DLLPUBLIC void DoMerge( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1291 SCCOL nEndCol, SCROW nEndRow, bool bDeleteCaptions = true );
1292 void RemoveMerge( SCCOL nCol, SCROW nRow, SCTAB nTab );
1294 bool IsBlockEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1295 SCCOL nEndCol, SCROW nEndRow, bool bIgnoreNotes = false ) const;
1296 bool IsPrintEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1297 SCCOL nEndCol, SCROW nEndRow,
1298 bool bLeftIsEmpty = false,
1299 ScRange* pLastRange = nullptr,
1300 tools::Rectangle* pLastMM = nullptr ) const;
1302 void SkipOverlapped( SCCOL& rCol, SCROW& rRow, SCTAB nTab ) const;
1303 bool IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1304 bool IsVerOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1306 SC_DLLPUBLIC bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1307 SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask ) const;
1308 SC_DLLPUBLIC bool HasAttrib( const ScRange& rRange, HasAttrFlags nMask ) const;
1310 SC_DLLPUBLIC void GetBorderLines( SCCOL nCol, SCROW nRow, SCTAB nTab,
1311 const ::editeng::SvxBorderLine** ppLeft,
1312 const ::editeng::SvxBorderLine** ppTop,
1313 const ::editeng::SvxBorderLine** ppRight,
1314 const ::editeng::SvxBorderLine** ppBottom ) const;
1316 void ResetChanged( const ScRange& rRange );
1318 void CheckVectorizationState();
1319 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
1320 void SetDirty( const ScRange&, bool bIncludeEmptyCells );
1321 void SetTableOpDirty( const ScRange& ); // for Interpreter TableOp
1322 void InterpretDirtyCells( const ScRangeList& rRanges );
1323 // Interprets cells that have NeedsInterpret(), i.e. the same like calling MaybeInterpret() on them.
1324 void InterpretCellsIfNeeded( const ScRangeList& rRanges );
1325 SC_DLLPUBLIC void CalcAll();
1326 SC_DLLPUBLIC void CalcAfterLoad( bool bStartListening = true );
1327 void CompileAll();
1328 void CompileXML();
1331 * Re-compile formula cells with error.
1333 * @param nErrCode specified error code to match. Only those cells with
1334 * this error code will be re-compiled. If this value is
1335 * 0, cells with any error values will be re-compiled.
1337 * @return true if at least one cell is re-compiled, false if no cells are
1338 * re-compiled.
1340 bool CompileErrorCells(FormulaError nErrCode);
1342 ScAutoNameCache* GetAutoNameCache() { return pAutoNameCache.get(); }
1343 void SetPreviewFont( std::unique_ptr<SfxItemSet> pFontSet );
1344 SfxItemSet* GetPreviewFont() { return pPreviewFont.get(); }
1345 SfxItemSet* GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab );
1346 const ScMarkData& GetPreviewSelection() const { return maPreviewSelection; }
1347 void SetPreviewSelection( const ScMarkData& rSel );
1348 ScStyleSheet* GetPreviewCellStyle() { return pPreviewCellStyle; }
1349 ScStyleSheet* GetPreviewCellStyle( SCCOL nCol, SCROW nRow, SCTAB nTab );
1350 void SetPreviewCellStyle( ScStyleSheet* pStyle ) { pPreviewCellStyle = pStyle; }
1351 SC_DLLPUBLIC void SetAutoNameCache( std::unique_ptr<ScAutoNameCache> pCache );
1353 /** Creates a ScLookupCache cache for the range if it
1354 doesn't already exist. */
1355 ScLookupCache & GetLookupCache( const ScRange & rRange, ScInterpreterContext* pContext );
1356 /** Only ScLookupCache dtor uses RemoveLookupCache(), do
1357 not use elsewhere! */
1358 void RemoveLookupCache( ScLookupCache & rCache );
1359 /** Zap all caches. */
1360 void ClearLookupCaches();
1362 // calculate automatically
1363 SC_DLLPUBLIC void SetAutoCalc( bool bNewAutoCalc );
1364 SC_DLLPUBLIC bool GetAutoCalc() const { return bAutoCalc; }
1365 // calculate automatically in/from/for ScDocShell disabled
1366 void SetAutoCalcShellDisabled( bool bNew ) { bAutoCalcShellDisabled = bNew; }
1367 bool IsAutoCalcShellDisabled() const { return bAutoCalcShellDisabled; }
1368 // ForcedFormulas are to be calculated
1369 void SetForcedFormulaPending( bool bNew ) { bForcedFormulaPending = bNew; }
1370 bool IsForcedFormulaPending() const { return bForcedFormulaPending; }
1371 // if CalcFormulaTree() is currently running
1372 bool IsCalculatingFormulaTree() const { return bCalculatingFormulaTree; }
1373 /// If set, joining cells into shared formula groups will be delayed until reset again
1374 /// (RegroupFormulaCells() will be called as needed).
1375 void DelayFormulaGrouping( bool delay );
1376 bool IsDelayedFormulaGrouping() const { return bool(pDelayedFormulaGrouping); }
1377 /// To be used only by SharedFormulaUtil::joinFormulaCells().
1378 void AddDelayedFormulaGroupingCell( const ScFormulaCell* cell );
1379 /// If set, ScColumn::StartListeningFormulaCells() calls may be delayed using
1380 /// CanDelayStartListeningFormulaCells() until reset again, at which point the function will
1381 /// be called as necessary.
1382 void EnableDelayStartListeningFormulaCells( ScColumn* column, bool delay );
1383 bool IsEnabledDelayStartListeningFormulaCells( ScColumn* column ) const;
1384 /// If true is returned, ScColumn::StartListeningFormulaCells() for the given cells will be performed
1385 /// later. If false is returned, it needs to be done explicitly.
1386 bool CanDelayStartListeningFormulaCells( ScColumn* column, SCROW row1, SCROW row2 );
1388 FormulaError GetErrCode( const ScAddress& ) const;
1390 /** Shrink a range to only include data area.
1392 This is not the actually used area within the
1393 selection, but the bounds of the sheet's data area
1394 instead.
1396 @returns TRUE if the area passed intersected the data
1397 area, FALSE if not, in which case the values
1398 obtained may be out of bounds, not in order or
1399 unmodified. TRUE does not mean that there
1400 actually is any data within the selection.
1402 bool ShrinkToDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
1404 /** Shrink a range to only include used data area.
1406 @param o_bShrunk
1407 Out parameter, true if area was shrunk, false if not.
1408 @param bColumnsOnly
1409 If TRUE, shrink only by columns, not rows.
1410 @param bStickyTopRow
1411 If TRUE, do not adjust the top row.
1412 @param bStickyLeftCol
1413 If TRUE, do not adjust the left column.
1414 @param pDataAreaExtras
1415 Consider additional area attributes like cell
1416 formatting, cell notes and draw objects. The
1417 possibly larger area than the actual cell
1418 content data area is returned within the
1419 struct.
1421 @returns true if there is any data, false if not.
1423 bool ShrinkToUsedDataArea( bool& o_bShrunk,
1424 SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1425 SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
1426 bool bStickyTopRow = false, bool bStickyLeftCol = false,
1427 ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
1430 * Return the last non-empty row position in given columns that's no
1431 * greater than the initial last row position, or 0 if the columns are
1432 * empty. A negative value is returned if the given sheet or column
1433 * positions are invalid.
1435 * <p>It starts from the specified last row position, and finds the first
1436 * non-empty row position in the upward direction if the start row
1437 * position is empty.</p>
1439 SCROW GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const;
1442 * Return the smallest area containing at least all contiguous cells
1443 * having data. This area is a square containing also empty cells. It may
1444 * shrink or extend the area given as input Flags as modifiers:
1446 * @param bIncludeOld when true, ensure that the returned area contains at
1447 * least the initial area even if the actual data area
1448 * is smaller than the initial area.
1450 * @param bOnlyDown when true, extend / shrink the data area only in a
1451 * downward direction i.e. only modify the end row
1452 * position.
1454 SC_DLLPUBLIC void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1455 SCCOL& rEndCol, SCROW& rEndRow,
1456 bool bIncludeOld, bool bOnlyDown ) const;
1459 * Returns true if there is a non-empty subrange in the range given as input.
1460 * In that case it also modifies rRange to largest subrange that does not
1461 * have empty col/row inrange-segments in the beginning/end.
1462 * It returns false if rRange is completely empty and in this case rRange is
1463 * left unmodified.
1465 bool GetDataAreaSubrange(ScRange& rRange) const;
1467 SC_DLLPUBLIC bool GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
1468 SC_DLLPUBLIC bool GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
1469 bool bCalcHiddens = false) const;
1470 SC_DLLPUBLIC bool GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
1471 bool bNotes = true) const;
1472 SC_DLLPUBLIC bool GetPrintAreaHor( SCTAB nTab, SCROW nStartRow, SCROW nEndRow,
1473 SCCOL& rEndCol ) const;
1474 SC_DLLPUBLIC bool GetPrintAreaVer( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol,
1475 SCROW& rEndRow, bool bNotes ) const;
1476 void InvalidateTableArea();
1478 /// Return the number of columns / rows that should be visible for the tiled rendering.
1479 SC_DLLPUBLIC void GetTiledRenderingArea(SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow) const;
1481 SC_DLLPUBLIC bool GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const;
1484 * Find the maximum column position that contains printable data for the
1485 * specified row range. The final column position must be equal or less
1486 * than the initial value of rEndCol.
1488 void ExtendPrintArea( OutputDevice* pDev, SCTAB nTab,
1489 SCCOL nStartCol, SCROW nStartRow,
1490 SCCOL& rEndCol, SCROW nEndRow ) const;
1491 SC_DLLPUBLIC SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
1492 SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab,
1493 ScDirection eDir );
1495 void FindAreaPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, ScMoveDirection eDirection ) const;
1496 SC_DLLPUBLIC void GetNextPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, SCCOL nMovX, SCROW nMovY,
1497 bool bMarked, bool bUnprotected, const ScMarkData& rMark,
1498 SCCOL nTabStartCol = SC_TABSTART_NONE ) const;
1500 bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, SCTAB nTab,
1501 const ScMarkData& rMark );
1503 void LimitChartArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1504 SCCOL& rEndCol, SCROW& rEndRow );
1505 void LimitChartIfAll( ScRangeListRef& rRangeList );
1507 bool InsertRow( SCCOL nStartCol, SCTAB nStartTab,
1508 SCCOL nEndCol, SCTAB nEndTab,
1509 SCROW nStartRow, SCSIZE nSize, ScDocument* pRefUndoDoc = nullptr,
1510 const ScMarkData* pTabMark = nullptr );
1511 SC_DLLPUBLIC bool InsertRow( const ScRange& rRange );
1512 void DeleteRow( SCCOL nStartCol, SCTAB nStartTab,
1513 SCCOL nEndCol, SCTAB nEndTab,
1514 SCROW nStartRow, SCSIZE nSize,
1515 ScDocument* pRefUndoDoc = nullptr, bool* pUndoOutline = nullptr,
1516 const ScMarkData* pTabMark = nullptr );
1517 SC_DLLPUBLIC void DeleteRow( const ScRange& rRange );
1518 bool InsertCol( SCROW nStartRow, SCTAB nStartTab,
1519 SCROW nEndRow, SCTAB nEndTab,
1520 SCCOL nStartCol, SCSIZE nSize, ScDocument* pRefUndoDoc = nullptr,
1521 const ScMarkData* pTabMark = nullptr );
1522 SC_DLLPUBLIC bool InsertCol( const ScRange& rRange );
1523 void DeleteCol( SCROW nStartRow, SCTAB nStartTab,
1524 SCROW nEndRow, SCTAB nEndTab,
1525 SCCOL nStartCol, SCSIZE nSize,
1526 ScDocument* pRefUndoDoc = nullptr, bool* pUndoOutline = nullptr,
1527 const ScMarkData* pTabMark = nullptr );
1528 void DeleteCol( const ScRange& rRange );
1530 bool CanInsertRow( const ScRange& rRange ) const;
1531 bool CanInsertCol( const ScRange& rRange ) const;
1533 void FitBlock( const ScRange& rOld, const ScRange& rNew, bool bClear = true );
1534 bool CanFitBlock( const ScRange& rOld, const ScRange& rNew );
1536 bool IsClipOrUndo() const { return bIsClip || bIsUndo; }
1537 bool IsUndo() const { return bIsUndo; }
1538 bool IsClipboard() const { return bIsClip; }
1539 bool IsUndoEnabled() const { return mbUndoEnabled; }
1540 SC_DLLPUBLIC void EnableUndo( bool bVal );
1541 bool IsFunctionAccess() const { return bIsFunctionAccess; }
1543 bool IsAdjustHeightLocked() const { return nAdjustHeightLock != 0; }
1544 void LockAdjustHeight() { ++nAdjustHeightLock; }
1545 SC_DLLPUBLIC void UnlockAdjustHeight();
1546 bool IsExecuteLinkEnabled() const { return mbExecuteLinkEnabled; }
1547 void EnableExecuteLink( bool bVal ) { mbExecuteLinkEnabled = bVal; }
1548 bool IsChangeReadOnlyEnabled() const { return mbChangeReadOnlyEnabled; }
1549 void EnableChangeReadOnly( bool bVal ) { mbChangeReadOnlyEnabled = bVal; }
1550 SC_DLLPUBLIC bool IsUserInteractionEnabled() const { return mbUserInteractionEnabled;}
1551 SC_DLLPUBLIC void EnableUserInteraction( bool bVal );
1552 SC_DLLPUBLIC sal_Int16 GetNamedRangesLockCount() const { return mnNamedRangesLockCount; }
1553 void SetNamedRangesLockCount( sal_Int16 nCount ) { mnNamedRangesLockCount = nCount; }
1554 SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks );
1555 SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, SCTAB nTab );
1556 void SetCutMode( bool bCut );
1557 bool IsCutMode();
1558 void SetClipArea( const ScRange& rArea, bool bCut = false );
1560 SC_DLLPUBLIC bool IsDocVisible() const { return bIsVisible; }
1561 SC_DLLPUBLIC void SetDocVisible( bool bSet );
1563 bool HasOLEObjectsInArea( const ScRange& rRange, const ScMarkData* pTabMark = nullptr );
1565 void DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1566 const ScMarkData& rMark, bool bAnchored = false );
1567 void DeleteObjectsInSelection( const ScMarkData& rMark );
1569 SC_DLLPUBLIC void DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark,
1570 InsertDeleteFlags nDelFlag, bool bBroadcast = true,
1571 sc::ColumnSpanSet* pBroadcastSpans = nullptr );
1573 SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1574 SCTAB nTab, InsertDeleteFlags nDelFlag);
1575 void DeleteAreaTab(const ScRange& rRange, InsertDeleteFlags nDelFlag);
1577 SC_DLLPUBLIC void CopyToClip( const ScClipParam& rClipParam, ScDocument* pClipDoc,
1578 const ScMarkData* pMarks, bool bKeepScenarioFlags,
1579 bool bIncludeObjects );
1582 * Copy only raw cell values to another document. Formula cells are
1583 * converted to raw cells. No formatting info are copied except for
1584 * number formats.
1586 * @param rSrcRange source range in the source document
1587 * @param nDestTab table in the clip document to copy to.
1588 * @param rDestDoc document to copy to
1590 SC_DLLPUBLIC void CopyStaticToDocument(const ScRange& rSrcRange, SCTAB nDestTab, ScDocument& rDestDoc);
1593 * Copy only cell, nothing but cell to another document.
1595 * @param rSrcPos source cell position
1596 * @param rDestPos destination cell position
1597 * @param rDestDoc destination document
1599 void CopyCellToDocument( const ScAddress& rSrcPos, const ScAddress& rDestPos, ScDocument& rDestDoc );
1601 void CopyTabToClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1602 SCTAB nTab, ScDocument* pClipDoc);
1604 SC_DLLPUBLIC bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCTAB nTab, SCCOL nCol );
1606 void DeleteBeforeCopyFromClip( sc::CopyFromClipContext& rCxt, const ScMarkData& rMark,
1607 sc::ColumnSpanSet& rBroadcastSpans );
1609 SC_DLLPUBLIC bool CopyOneCellFromClip(sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1610 SCCOL nCol2, SCROW nRow2 );
1611 void CopyBlockFromClip( sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1612 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark,
1613 SCCOL nDx, SCROW nDy );
1615 * @return the number of non-filtered rows.
1617 SCROW CopyNonFilteredFromClip(sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1618 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark, SCCOL nDx,
1619 SCROW& rClipStartRow, SCROW nClipEndRow);
1621 void StartListeningFromClip( SCCOL nCol1, SCROW nRow1,
1622 SCCOL nCol2, SCROW nRow2,
1623 const ScMarkData& rMark, InsertDeleteFlags nInsFlag );
1625 void SetDirtyFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1626 const ScMarkData& rMark, InsertDeleteFlags nInsFlag,
1627 sc::ColumnSpanSet& rBroadcastSpans );
1630 * Paste data from a clipboard document into this document.
1632 * @param rDestRange destination range.
1633 * @param pClipDoc pointer to the clipboard document to copy data from.
1634 * @param bSkipEmptyCells if this flag is set, empty cells in the source
1635 * range in the clipboard document will not overwrite
1636 * the target destination cells.
1637 * @param pDestRanges If pDestRanges is given it overrides rDestRange, where
1638 * rDestRange becomes the overall encompassing range.
1640 SC_DLLPUBLIC void CopyFromClip(
1641 const ScRange& rDestRange, const ScMarkData& rMark, InsertDeleteFlags nInsFlag,
1642 ScDocument* pRefUndoDoc, ScDocument* pClipDoc,
1643 bool bResetCut = true, bool bAsLink = false,
1644 bool bIncludeFiltered = true, bool bSkipEmptyCells = false,
1645 const ScRangeList* pDestRanges = nullptr );
1647 void CopyMultiRangeFromClip(const ScAddress& rDestPos, const ScMarkData& rMark,
1648 InsertDeleteFlags nInsFlag, ScDocument* pClipDoc,
1649 bool bResetCut = true, bool bAsLink = false,
1650 bool bIncludeFiltered = true,
1651 bool bSkipAttrForEmpty = false);
1653 void GetClipArea(SCCOL& nClipX, SCROW& nClipY, bool bIncludeFiltered);
1654 void GetClipStart(SCCOL& nClipX, SCROW& nClipY);
1656 bool HasClipFilteredRows();
1658 bool IsClipboardSource() const;
1660 SC_DLLPUBLIC void TransposeClip(ScDocument* pTransClip, InsertDeleteFlags nFlags, bool bAsLink,
1661 bool bIncludeFiltered);
1663 ScClipParam& GetClipParam();
1664 void SetClipParam(const ScClipParam& rParam);
1666 /** To be called at the clipboard document when closing a document that is
1667 the current clipboard source to decouple things from the originating
1668 document. Done in ScDocument dtor after determining
1669 IsClipboardSource().
1671 void ClosingClipboardSource();
1673 void MixDocument( const ScRange& rRange, ScPasteFunc nFunction, bool bSkipEmpty,
1674 ScDocument& rSrcDoc );
1676 void FillTab( const ScRange& rSrcArea, const ScMarkData& rMark,
1677 InsertDeleteFlags nFlags, ScPasteFunc nFunction,
1678 bool bSkipEmpty, bool bAsLink );
1679 void FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark,
1680 InsertDeleteFlags nFlags, ScPasteFunc nFunction,
1681 bool bSkipEmpty, bool bAsLink );
1683 void TransliterateText( const ScMarkData& rMultiMark, TransliterationFlags nType );
1685 SC_DLLPUBLIC void InitUndo( const ScDocument& rSrcDoc, SCTAB nTab1, SCTAB nTab2,
1686 bool bColInfo = false, bool bRowInfo = false );
1687 void AddUndoTab( SCTAB nTab1, SCTAB nTab2,
1688 bool bColInfo = false, bool bRowInfo = false );
1689 SC_DLLPUBLIC void InitUndoSelected( const ScDocument& rSrcDoc, const ScMarkData& rTabSelection,
1690 bool bColInfo = false, bool bRowInfo = false );
1692 // don't use anymore:
1693 void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1694 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1695 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc,
1696 const ScMarkData* pMarks = nullptr, bool bColRowFlags = true);
1697 void UndoToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1698 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1699 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc);
1701 SC_DLLPUBLIC void CopyToDocument(const ScRange& rRange,
1702 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc,
1703 const ScMarkData* pMarks = nullptr, bool bColRowFlags = true);
1704 void UndoToDocument(const ScRange& rRange,
1705 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc);
1707 void CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario = false );
1708 bool TestCopyScenario( SCTAB nSrcTab, SCTAB nDestTab ) const;
1709 void MarkScenario(SCTAB nSrcTab, SCTAB nDestTab,
1710 ScMarkData& rDestMark, bool bResetMark = true,
1711 ScScenarioFlags nNeededBits = ScScenarioFlags::NONE) const;
1712 bool HasScenarioRange( SCTAB nTab, const ScRange& rRange ) const;
1713 SC_DLLPUBLIC const ScRangeList* GetScenarioRanges( SCTAB nTab ) const;
1715 SC_DLLPUBLIC void CopyUpdated( ScDocument* pPosDoc, ScDocument* pDestDoc );
1717 void UpdateReference( sc::RefUpdateContext& rCxt, ScDocument*
1718 pUndoDoc = nullptr, bool bIncludeDraw = true,
1719 bool bUpdateNoteCaptionPos = true );
1721 * @param pClipDoc original clipboard doc, i.e. non-transposed
1722 * This clip doc is used to check references pointing to cut cells.
1724 SC_DLLPUBLIC void UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDoc,
1725 const ScMarkData& rMark, ScDocument* pUndoDoc );
1727 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
1729 SC_DLLPUBLIC void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1730 ScProgress* pProgress, const ScMarkData& rMark,
1731 sal_uLong nFillCount, FillDir eFillDir = FILL_TO_BOTTOM,
1732 FillCmd eFillCmd = FILL_LINEAR, FillDateCmd eFillDateCmd = FILL_DAY,
1733 double nStepValue = 1.0, double nMaxValue = 1E307 );
1734 OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
1736 bool GetSelectionFunction( ScSubTotalFunc eFunc,
1737 const ScAddress& rCursor, const ScMarkData& rMark,
1738 double& rResult );
1740 SC_DLLPUBLIC const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
1741 template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const
1743 return static_cast<const T*>(GetAttr(nCol, nRow, nTab, sal_uInt16(nWhich)));
1745 SC_DLLPUBLIC const SfxPoolItem* GetAttr( const ScAddress& rPos, sal_uInt16 nWhich ) const;
1746 template<class T> const T* GetAttr( const ScAddress& rPos, TypedWhichId<T> nWhich ) const
1748 return static_cast<const T*>(GetAttr(rPos, sal_uInt16(nWhich)));
1750 SC_DLLPUBLIC const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1751 SC_DLLPUBLIC const ScPatternAttr* GetPattern( const ScAddress& rPos ) const;
1752 SC_DLLPUBLIC const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const;
1753 const ScPatternAttr* GetSelectionPattern( const ScMarkData& rMark );
1754 std::unique_ptr<ScPatternAttr> CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
1755 SC_DLLPUBLIC void AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
1756 void RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
1758 SC_DLLPUBLIC ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1759 // pCell is an optimization, must point to rPos
1760 SC_DLLPUBLIC const SfxItemSet* GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab,
1761 ScRefCellValue* pCell = nullptr ) const;
1762 const SfxItemSet* GetCondResult( ScRefCellValue& rCell, const ScAddress& rPos,
1763 const ScConditionalFormatList& rList,
1764 const ScCondFormatIndexes& rIndex ) const;
1765 const SfxPoolItem* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
1766 template<class T> const T* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const
1768 return static_cast<const T*>(GetEffItem(nCol, nRow, nTab, sal_uInt16(nWhich)));
1771 SC_DLLPUBLIC const css::uno::Reference< css::i18n::XBreakIterator >& GetBreakIterator();
1772 bool HasStringWeakCharacters( const OUString& rString );
1773 SC_DLLPUBLIC SvtScriptType GetStringScriptType( const OUString& rString );
1774 // pCell is an optimization, must point to rPos
1775 SC_DLLPUBLIC SvtScriptType GetCellScriptType( const ScAddress& rPos, sal_uInt32 nNumberFormat,
1776 const ScRefCellValue* pCell = nullptr );
1777 // pCell is an optimization, must point to nCol,nRow,nTab
1778 SC_DLLPUBLIC SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab,
1779 const ScRefCellValue* pCell = nullptr );
1780 SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rPos, SCROW nLength );
1781 SvtScriptType GetRangeScriptType( const ScRangeList& rRanges );
1783 bool HasDetectiveOperations() const;
1784 void AddDetectiveOperation( const ScDetOpData& rData );
1785 void ClearDetectiveOperations();
1786 ScDetOpList* GetDetOpList() const { return pDetOpList.get(); }
1787 void SetDetOpList(std::unique_ptr<ScDetOpList> pNew);
1789 bool HasDetectiveObjects(SCTAB nTab) const;
1791 void GetSelectionFrame( const ScMarkData& rMark,
1792 SvxBoxItem& rLineOuter,
1793 SvxBoxInfoItem& rLineInner );
1794 void ApplySelectionFrame(const ScMarkData& rMark,
1795 const SvxBoxItem& rLineOuter,
1796 const SvxBoxInfoItem* pLineInner);
1797 void ApplyFrameAreaTab(const ScRange& rRange,
1798 const SvxBoxItem& rLineOuter,
1799 const SvxBoxInfoItem& rLineInner);
1801 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
1802 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
1804 SC_DLLPUBLIC sal_uLong AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew, SCTAB nTab );
1805 void DeleteConditionalFormat( sal_uLong nIndex, SCTAB nTab );
1807 void SetCondFormList( ScConditionalFormatList* pList, SCTAB nTab );
1808 SC_DLLPUBLIC sal_uLong AddValidationEntry( const ScValidationData& rNew );
1809 SC_DLLPUBLIC const ScValidationData* GetValidationEntry( sal_uLong nIndex ) const;
1811 SC_DLLPUBLIC ScConditionalFormatList* GetCondFormList( SCTAB nTab ) const;
1813 const ScValidationDataList* GetValidationList() const { return pValidationList.get();}
1814 ScValidationDataList* GetValidationList() { return pValidationList.get();}
1816 SC_DLLPUBLIC void ApplyAttr( SCCOL nCol, SCROW nRow, SCTAB nTab,
1817 const SfxPoolItem& rAttr );
1818 SC_DLLPUBLIC void ApplyPattern( SCCOL nCol, SCROW nRow, SCTAB nTab,
1819 const ScPatternAttr& rAttr );
1820 SC_DLLPUBLIC void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow,
1821 SCCOL nEndCol, SCROW nEndRow,
1822 const ScMarkData& rMark, const ScPatternAttr& rAttr,
1823 ScEditDataArray* pDataArray = nullptr,
1824 bool* const pIsChanged = nullptr );
1825 SC_DLLPUBLIC void ApplyPatternAreaTab( SCCOL nStartCol, SCROW nStartRow,
1826 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1827 const ScPatternAttr& rAttr );
1829 SC_DLLPUBLIC void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
1830 const ScMarkData& rMark,
1831 const ScPatternAttr& rPattern,
1832 SvNumFormatType nNewType );
1834 void ApplyStyle( SCCOL nCol, SCROW nRow, SCTAB nTab,
1835 const ScStyleSheet& rStyle);
1836 void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow,
1837 SCCOL nEndCol, SCROW nEndRow,
1838 const ScMarkData& rMark, const ScStyleSheet& rStyle);
1839 SC_DLLPUBLIC void ApplyStyleAreaTab( SCCOL nStartCol, SCROW nStartRow,
1840 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1841 const ScStyleSheet& rStyle);
1843 SC_DLLPUBLIC void ApplySelectionStyle( const ScStyleSheet& rStyle, const ScMarkData& rMark );
1844 void ApplySelectionLineStyle( const ScMarkData& rMark,
1845 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
1847 const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1848 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark ) const;
1850 void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
1851 OutputDevice* pDev,
1852 double nPPTX, double nPPTY,
1853 const Fraction& rZoomX, const Fraction& rZoomY );
1855 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
1857 SC_DLLPUBLIC bool ApplyFlagsTab( SCCOL nStartCol, SCROW nStartRow,
1858 SCCOL nEndCol, SCROW nEndRow,
1859 SCTAB nTab, ScMF nFlags );
1860 SC_DLLPUBLIC bool RemoveFlagsTab( SCCOL nStartCol, SCROW nStartRow,
1861 SCCOL nEndCol, SCROW nEndRow,
1862 SCTAB nTab, ScMF nFlags );
1864 SC_DLLPUBLIC void SetPattern( const ScAddress&, const ScPatternAttr& rAttr );
1865 SC_DLLPUBLIC const ScPatternAttr* SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, std::unique_ptr<ScPatternAttr> );
1866 SC_DLLPUBLIC void SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr& rAttr );
1868 void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1869 sal_uInt16 nFormatNo, const ScMarkData& rMark );
1870 void GetAutoFormatData( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1871 ScAutoFormatData& rData );
1872 bool SearchAndReplace( const SvxSearchItem& rSearchItem,
1873 SCCOL& rCol, SCROW& rRow, SCTAB& rTab,
1874 const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1875 OUString& rUndoStr, ScDocument* pUndoDoc = nullptr );
1876 static bool IsEmptyCellSearch( const SvxSearchItem& rSearchItem );
1878 // determine Col/Row of subsequent calls
1879 // (e.g. not found from the beginning, or subsequent tables)
1880 // meaning of explanation in "()" was already unclear in German
1881 void GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem,
1882 SCCOL& rCol, SCROW& rRow );
1884 bool Solver( SCCOL nFCol, SCROW nFRow, SCTAB nFTab,
1885 SCCOL nVCol, SCROW nVRow, SCTAB nVTab,
1886 const OUString& sValStr, double& nX);
1888 SC_DLLPUBLIC void ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark,
1889 ScEditDataArray* pDataArray = nullptr, bool* pIsChanged = nullptr );
1890 SC_DLLPUBLIC void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
1891 void DeleteSelectionTab( SCTAB nTab, InsertDeleteFlags nDelFlag, const ScMarkData& rMark );
1893 SC_DLLPUBLIC void SetColWidth( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth );
1894 SC_DLLPUBLIC void SetColWidthOnly( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth );
1895 SC_DLLPUBLIC void SetRowHeight( SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight );
1896 SC_DLLPUBLIC void SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
1897 sal_uInt16 nNewHeight );
1899 SC_DLLPUBLIC void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
1900 sal_uInt16 nNewHeight );
1901 SC_DLLPUBLIC void SetManualHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual );
1903 SC_DLLPUBLIC sal_uInt16 GetColWidth( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
1904 SC_DLLPUBLIC sal_uLong GetColWidth( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab ) const;
1905 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1906 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow ) const;
1907 SC_DLLPUBLIC sal_uLong GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1910 * Given the height i.e. total vertical distance from the top of the sheet
1911 * grid, return the first visible row whose top position is below the
1912 * specified height.
1914 SCROW GetRowForHeight( SCTAB nTab, sal_uLong nHeight ) const;
1915 sal_uLong GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const;
1916 SC_DLLPUBLIC sal_uLong GetColOffset( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
1917 SC_DLLPUBLIC sal_uLong GetRowOffset( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1919 SC_DLLPUBLIC sal_uInt16 GetOriginalWidth( SCCOL nCol, SCTAB nTab ) const;
1920 SC_DLLPUBLIC sal_uInt16 GetOriginalHeight( SCROW nRow, SCTAB nTab ) const;
1922 sal_uInt16 GetCommonWidth( SCCOL nEndCol, SCTAB nTab ) const;
1924 SCROW GetHiddenRowCount( SCROW nRow, SCTAB nTab ) const;
1926 sal_uInt16 GetOptimalColWidth( SCCOL nCol, SCTAB nTab, OutputDevice* pDev,
1927 double nPPTX, double nPPTY,
1928 const Fraction& rZoomX, const Fraction& rZoomY,
1929 bool bFormula,
1930 const ScMarkData* pMarkData = nullptr,
1931 const ScColWidthParam* pParam = nullptr );
1933 SC_DLLPUBLIC bool SetOptimalHeight( sc::RowHeightContext& rCxt, SCROW nStartRow,
1934 SCROW nEndRow, SCTAB nTab, bool bApi );
1936 void UpdateAllRowHeights( sc::RowHeightContext& rCxt, const ScMarkData* pTabMark );
1938 tools::Long GetNeededSize( SCCOL nCol, SCROW nRow, SCTAB nTab,
1939 OutputDevice* pDev,
1940 double nPPTX, double nPPTY,
1941 const Fraction& rZoomX, const Fraction& rZoomY,
1942 bool bWidth, bool bTotalSize = false,
1943 bool bInPrintTwips = false );
1945 SC_DLLPUBLIC void ShowCol(SCCOL nCol, SCTAB nTab, bool bShow);
1946 SC_DLLPUBLIC void ShowRow(SCROW nRow, SCTAB nTab, bool bShow);
1947 SC_DLLPUBLIC void ShowRows(SCROW nRow1, SCROW nRow2, SCTAB nTab, bool bShow);
1948 SC_DLLPUBLIC void SetRowFlags( SCROW nRow, SCTAB nTab, CRFlags nNewFlags );
1949 SC_DLLPUBLIC void SetRowFlags( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, CRFlags nNewFlags );
1951 SC_DLLPUBLIC CRFlags GetColFlags( SCCOL nCol, SCTAB nTab ) const;
1952 SC_DLLPUBLIC CRFlags GetRowFlags( SCROW nRow, SCTAB nTab ) const;
1954 SC_DLLPUBLIC void GetAllRowBreaks(std::set<SCROW>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
1955 SC_DLLPUBLIC void GetAllColBreaks(std::set<SCCOL>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
1956 SC_DLLPUBLIC ScBreakType HasRowBreak(SCROW nRow, SCTAB nTab) const;
1957 SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const;
1958 SC_DLLPUBLIC void SetRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
1959 SC_DLLPUBLIC void SetColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
1960 void RemoveRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
1961 void RemoveColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
1962 css::uno::Sequence<
1963 css::sheet::TablePageBreakData> GetRowBreakData(SCTAB nTab) const;
1965 SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
1966 SC_DLLPUBLIC bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1967 SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
1968 SC_DLLPUBLIC void SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden);
1969 SC_DLLPUBLIC void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden);
1970 SC_DLLPUBLIC SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1971 SC_DLLPUBLIC SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1972 SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1974 SC_DLLPUBLIC bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
1975 bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1976 bool ColFiltered(SCCOL nCol, SCTAB nTab) const;
1977 SC_DLLPUBLIC void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered);
1978 SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1979 SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1980 SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1982 SC_DLLPUBLIC bool IsManualRowHeight(SCROW nRow, SCTAB nTab) const;
1984 bool HasUniformRowHeight( SCTAB nTab, SCROW nRow1, SCROW nRow2 ) const;
1987 * Write all column row flags to table's flag data, because not all column
1988 * row attributes are stored in the flag data members. This is necessary
1989 * for ods export.
1991 void SyncColRowFlags();
1993 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
1994 SC_DLLPUBLIC SCROW GetLastFlaggedRow( SCTAB nTab ) const;
1996 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
1997 SCCOL GetLastChangedCol( SCTAB nTab ) const;
1998 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
1999 SCROW GetLastChangedRow( SCTAB nTab ) const;
2001 SCCOL GetNextDifferentChangedCol( SCTAB nTab, SCCOL nStart) const;
2003 SCROW GetNextDifferentChangedRow( SCTAB nTab, SCROW nStart) const;
2005 // returns whether to export a Default style for this col or not
2006 // nDefault is set to one position in the current row where the Default style is
2007 void GetColDefault( SCTAB nTab, SCCOL nCol, SCROW nLastRow, SCROW& nDefault);
2009 bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bShow );
2010 bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bShow );
2012 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
2013 void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
2015 SC_DLLPUBLIC ScPatternAttr* GetDefPattern() const;
2016 SC_DLLPUBLIC ScDocumentPool* GetPool();
2017 SC_DLLPUBLIC ScStyleSheetPool* GetStyleSheetPool() const;
2018 void GetUnprotectedCells( ScRangeList& rRange, SCTAB nTab ) const;
2020 // PageStyle:
2021 SC_DLLPUBLIC OUString GetPageStyle( SCTAB nTab ) const;
2022 SC_DLLPUBLIC void SetPageStyle( SCTAB nTab, const OUString& rName );
2023 Size GetPageSize( SCTAB nTab ) const;
2024 void SetPageSize( SCTAB nTab, const Size& rSize );
2025 void SetRepeatArea( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
2026 void InvalidatePageBreaks(SCTAB nTab);
2027 void UpdatePageBreaks( SCTAB nTab, const ScRange* pUserArea = nullptr );
2028 void RemoveManualBreaks( SCTAB nTab );
2029 bool HasManualBreaks( SCTAB nTab ) const;
2031 bool IsPageStyleInUse( std::u16string_view rStrPageStyle, SCTAB* pInTab );
2032 bool RemovePageStyleInUse( std::u16string_view rStrPageStyle );
2033 bool RenamePageStyleInUse( std::u16string_view rOld, const OUString& rNew );
2034 void ModifyStyleSheet( SfxStyleSheetBase& rPageStyle,
2035 const SfxItemSet& rChanges );
2037 void PageStyleModified( SCTAB nTab, const OUString& rNewName );
2039 SC_DLLPUBLIC bool NeedPageResetAfterTab( SCTAB nTab ) const;
2041 // Was stored in PageStyle previously. Now it exists for every table:
2042 SC_DLLPUBLIC bool HasPrintRange();
2043 SC_DLLPUBLIC sal_uInt16 GetPrintRangeCount( SCTAB nTab );
2044 SC_DLLPUBLIC const ScRange* GetPrintRange( SCTAB nTab, sal_uInt16 nPos );
2045 SC_DLLPUBLIC const ScRange* GetRepeatColRange( SCTAB nTab );
2046 SC_DLLPUBLIC const ScRange* GetRepeatRowRange( SCTAB nTab );
2047 /** Returns true, if the specified sheet is always printed. */
2048 bool IsPrintEntireSheet( SCTAB nTab ) const;
2050 /** Removes all print ranges. */
2051 SC_DLLPUBLIC void ClearPrintRanges( SCTAB nTab );
2052 /** Adds a new print ranges. */
2053 SC_DLLPUBLIC void AddPrintRange( SCTAB nTab, const ScRange& rNew );
2054 /** Marks the specified sheet to be printed completely. Deletes old print ranges on the sheet! */
2055 SC_DLLPUBLIC void SetPrintEntireSheet( SCTAB nTab );
2056 SC_DLLPUBLIC void SetRepeatColRange( SCTAB nTab, std::unique_ptr<ScRange> pNew );
2057 SC_DLLPUBLIC void SetRepeatRowRange( SCTAB nTab, std::unique_ptr<ScRange> pNew );
2058 std::unique_ptr<ScPrintRangeSaver> CreatePrintRangeSaver() const;
2059 void RestorePrintRanges( const ScPrintRangeSaver& rSaver );
2061 SC_DLLPUBLIC tools::Rectangle GetMMRect( SCCOL nStartCol, SCROW nStartRow,
2062 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
2063 SC_DLLPUBLIC ScRange GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool bHiddenAsZero = true ) const;
2065 void UpdStlShtPtrsFrmNms();
2066 void StylesToNames();
2068 SC_DLLPUBLIC void CopyStdStylesFrom( const ScDocument& rSrcDoc );
2070 static sal_uInt16 GetSrcVersion() { return nSrcVer; }
2072 void SetSrcCharSet( rtl_TextEncoding eNew ) { eSrcSet = eNew; }
2073 void UpdateFontCharSet();
2075 void FillInfo( ScTableInfo& rTabInfo, SCCOL nCol1, SCROW nRow1,
2076 SCCOL nCol2, SCROW nRow2, SCTAB nTab, double fColScale,
2077 double fRowScale, bool bPageMode, bool bFormulaMode,
2078 const ScMarkData* pMarkData = nullptr );
2080 SC_DLLPUBLIC SvNumberFormatter* GetFormatTable() const;
2082 /** Sort a range of data. */
2083 void Sort( SCTAB nTab, const ScSortParam& rSortParam,
2084 bool bKeepQuery, bool bUpdateRefs,
2085 ScProgress* pProgress, sc::ReorderParam* pUndo );
2087 void Reorder( const sc::ReorderParam& rParam );
2089 void PrepareQuery( SCTAB nTab, ScQueryParam& rQueryParam );
2090 SCSIZE Query( SCTAB nTab, const ScQueryParam& rQueryParam, bool bKeepSub );
2091 SC_DLLPUBLIC bool CreateQueryParam( const ScRange& rRange, ScQueryParam& rQueryParam );
2092 OUString GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab);
2095 * Get a list of unique strings to use in filtering criteria. The string
2096 * values are sorted, and there are no duplicate values in the list. The
2097 * data range to use to populate the filter entries is inferred from the
2098 * database range that contains the specified cell position.
2100 void GetFilterEntries( SCCOL nCol, SCROW nRow,
2101 SCTAB nTab, ScFilterEntries& rFilterEntries );
2103 SC_DLLPUBLIC void GetFilterEntriesArea( SCCOL nCol, SCROW nStartRow, SCROW nEndRow,
2104 SCTAB nTab, bool bCaseSens,
2105 ScFilterEntries& rFilterEntries );
2107 void GetDataEntries( SCCOL nCol, SCROW nRow, SCTAB nTab,
2108 std::vector<ScTypedStrData>& rStrings, bool bValidation = false );
2109 void GetFormulaEntries( ScTypedCaseStrSet& rStrings );
2111 bool HasAutoFilter( SCCOL nCol, SCROW nRow, SCTAB nTab );
2112 void GetFilterSelCount( SCCOL nCol, SCROW nRow, SCTAB nTab, SCSIZE& nSelected, SCSIZE& nTotal );
2114 SC_DLLPUBLIC bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
2115 SCTAB nTab );
2116 SC_DLLPUBLIC bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
2117 SCTAB nTab );
2119 SfxPrinter* GetPrinter( bool bCreateIfNotExist = true );
2120 void SetPrinter( VclPtr<SfxPrinter> const & pNewPrinter );
2121 VirtualDevice* GetVirtualDevice_100th_mm();
2122 SC_DLLPUBLIC OutputDevice* GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice...
2124 bool GetNextSpellingCell( SCCOL& nCol, SCROW& nRow, SCTAB nTab,
2125 bool bInSel, const ScMarkData& rMark) const;
2127 void ReplaceStyle( const SvxSearchItem& rSearchItem,
2128 SCCOL nCol, SCROW nRow, SCTAB nTab,
2129 const ScMarkData& rMark);
2131 void InvalidateTextWidth( std::u16string_view rStyleName );
2132 void InvalidateTextWidth( SCTAB nTab );
2133 void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo, bool bNumFormatChanged );
2135 bool IdleCalcTextWidth();
2137 void RepaintRange( const ScRange& rRange );
2138 void RepaintRange( const ScRangeList& rRange );
2140 bool IsIdleEnabled() const { return mbIdleEnabled; }
2141 void EnableIdle(bool bDo) { mbIdleEnabled = bDo; }
2143 bool IsDetectiveDirty() const { return bDetectiveDirty; }
2144 void SetDetectiveDirty(bool bSet) { bDetectiveDirty = bSet; }
2146 bool HasLinkFormulaNeedingCheck() const { return bLinkFormulaNeedingCheck; }
2147 void SetLinkFormulaNeedingCheck(bool bSet) { bLinkFormulaNeedingCheck = bSet; }
2148 /** Check token array and set link check if ocDde/ocWebservice is contained. */
2149 SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode );
2151 void SetRangeOverflowType(ErrCode nType) { nRangeOverflowType = nType; }
2152 bool HasRangeOverflow() const { return nRangeOverflowType != ERRCODE_NONE; }
2153 SC_DLLPUBLIC const ErrCode& GetRangeOverflowType() const { return nRangeOverflowType; }
2155 // for broadcasting/listening
2156 void SetInsertingFromOtherDoc( bool bVal ) { bInsertingFromOtherDoc = bVal; }
2157 bool IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc; }
2158 void SetLoadingMedium( bool bVal );
2159 SC_DLLPUBLIC void SetImportingXML( bool bVal );
2160 bool IsImportingXML() const { return bImportingXML; }
2161 bool IsCalcingAfterLoad() const { return bCalcingAfterLoad; }
2162 void SetNoListening( bool bVal ) { bNoListening = bVal; }
2163 bool GetNoListening() const { return bNoListening; }
2164 ScBroadcastAreaSlotMachine* GetBASM() const { return pBASM.get(); }
2166 SC_DLLPUBLIC ScChartListenerCollection* GetChartListenerCollection() const { return pChartListenerCollection.get(); }
2167 void SetChartListenerCollection( std::unique_ptr<ScChartListenerCollection>,
2168 bool bSetChartRangeLists );
2169 void UpdateChart( const OUString& rName );
2170 void RestoreChartListener( const OUString& rName );
2171 SC_DLLPUBLIC void UpdateChartListenerCollection();
2172 bool IsChartListenerCollectionNeedsUpdate() const { return bChartListenerCollectionNeedsUpdate; }
2173 void SetChartListenerCollectionNeedsUpdate( bool bFlg ) { bChartListenerCollectionNeedsUpdate = bFlg; }
2174 void AddOLEObjectToCollection(const OUString& rName);
2176 ScChangeViewSettings* GetChangeViewSettings() const { return pChangeViewSettings.get(); }
2177 SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings& rNew);
2179 const std::shared_ptr<SvxForbiddenCharactersTable>& GetForbiddenCharacters() const;
2180 void SetForbiddenCharacters(const std::shared_ptr<SvxForbiddenCharactersTable>& rNew);
2182 CharCompressType GetAsianCompression() const;
2183 bool IsValidAsianCompression() const;
2184 void SetAsianCompression(CharCompressType nNew);
2186 bool GetAsianKerning() const;
2187 bool IsValidAsianKerning() const;
2188 void SetAsianKerning(bool bNew);
2189 void ApplyAsianEditSettings(ScEditEngineDefaulter& rEngine);
2191 EEHorizontalTextDirection GetEditTextDirection(SCTAB nTab) const; // EEHorizontalTextDirection values
2193 SC_DLLPUBLIC ScLkUpdMode GetLinkMode() const { return eLinkMode ;}
2194 void SetLinkMode( ScLkUpdMode nSet ) { eLinkMode = nSet;}
2196 SC_DLLPUBLIC ScMacroManager* GetMacroManager();
2198 void FillMatrix( ScMatrix& rMat, SCTAB nTab, SCCOL nCol1,
2199 SCROW nRow1, SCCOL nCol2, SCROW nRow2,
2200 svl::SharedStringPool* pPool = nullptr) const;
2203 * Set an array of numerical formula results to a group of contiguous
2204 * formula cells.
2206 * @param rTopPos position of the top formula cell of a group.
2207 * @param pResults array of numeric results.
2208 * @param nLen length of numeric results.
2210 void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const double* pResults, size_t nLen );
2212 void CalculateInColumnInThread( ScInterpreterContext& rContext, const ScRange& rCalcRange, unsigned nThisThread, unsigned nThreadsTotal);
2213 void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab, ScInterpreter* pInterpreter );
2216 * Transfer a series of contiguous cell values from specified position to
2217 * the passed container. The specified segment will become empty after the
2218 * transfer.
2220 void TransferCellValuesTo( const ScAddress& rTopPos, size_t nLen, sc::CellValues& rDest );
2221 void CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellValues& rSrc );
2223 std::set<Color> GetDocColors();
2224 sc::IconSetBitmapMap& GetIconSetBitmapMap();
2226 std::set<SCCOL> QueryColumnsWithFormulaCells( SCTAB nTab ) const;
2229 * Check the integrity of the internal table state. Useful from testing
2230 * code. It throws an exception upon first failure.
2232 * Feel free to add more checks as needed.
2234 void CheckIntegrity( SCTAB nTab ) const;
2236 private:
2237 ScDocument(const ScDocument& r) = delete;
2239 void FindMaxRotCol( SCTAB nTab, RowInfo* pRowInfo, SCSIZE nArrCount,
2240 SCCOL nX1, SCCOL nX2 ) const;
2242 sal_uInt16 RowDifferences( SCROW nThisRow, SCTAB nThisTab,
2243 ScDocument& rOtherDoc,
2244 SCROW nOtherRow, SCTAB nOtherTab,
2245 SCCOL nMaxCol, const SCCOLROW* pOtherCols );
2246 sal_uInt16 ColDifferences( SCCOL nThisCol, SCTAB nThisTab,
2247 ScDocument& rOtherDoc,
2248 SCCOL nOtherCol, SCTAB nOtherTab,
2249 SCROW nMaxRow, const SCCOLROW* pOtherRows );
2250 void FindOrder( SCCOLROW* pOtherRows, SCCOLROW nThisEndRow, SCCOLROW nOtherEndRow,
2251 bool bColumns,
2252 ScDocument& rOtherDoc, SCTAB nThisTab, SCTAB nOtherTab,
2253 SCCOLROW nEndCol, const SCCOLROW* pTranslate,
2254 ScProgress* pProgress, sal_uLong nProAdd );
2256 DECL_LINK(TrackTimeHdl, Timer *, void);
2258 /** Adjust a range to available sheets.
2260 Used to start and stop listening on a sane range. Both o_rRange and
2261 o_bEntirelyOutOfBounds are set only if needed and don't have to be
2262 initialized by the caller.
2264 @param o_bEntirelyOutOfBounds
2265 <TRUE/> if both sheets in the range point outside the
2266 available sheet range, in which case no adjustment is done and
2267 o_rRange is not modified.
2269 @return <TRUE/> if any adjustment was done or o_bEntirelyOutOfBounds
2270 was set <TRUE/>.
2271 <FALSE/> if rRange was within the available sheets.
2273 bool LimitRangeToAvailableSheets( const ScRange& rRange, ScRange& o_rRange,
2274 bool& o_bEntirelyOutOfBounds ) const;
2276 public:
2277 void StartListeningArea( const ScRange& rRange, bool bGroupListening, SvtListener* pListener );
2279 void EndListeningArea( const ScRange& rRange, bool bGroupListening, SvtListener* pListener );
2280 /** Broadcast wrapper, calls
2281 rHint.GetCell()->Broadcast() and AreaBroadcast()
2282 and TrackFormulas()
2283 Preferred.
2285 void Broadcast( const ScHint& rHint );
2287 void BroadcastCells( const ScRange& rRange, SfxHintId nHint, bool bBroadcastSingleBroadcasters = true );
2289 /// only area, no cell broadcast
2290 void AreaBroadcast( const ScHint& rHint );
2291 void DelBroadcastAreasInRange( const ScRange& rRange );
2292 void UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode,
2293 const ScRange& rRange,
2294 SCCOL nDx, SCROW nDy, SCTAB nDz );
2296 void StartListeningCell( const ScAddress& rAddress,
2297 SvtListener* pListener );
2298 void EndListeningCell( const ScAddress& rAddress,
2299 SvtListener* pListener );
2301 void StartListeningCell( sc::StartListeningContext& rCxt, const ScAddress& rPos, SvtListener& rListener );
2302 void EndListeningCell( sc::EndListeningContext& rCxt, const ScAddress& rPos, SvtListener& rListener );
2304 void EndListeningFormulaCells( std::vector<ScFormulaCell*>& rCells );
2306 void PutInFormulaTree( ScFormulaCell* pCell );
2307 void RemoveFromFormulaTree( ScFormulaCell* pCell );
2310 * Calculate formula cells that are on the formula tree either partially,
2311 * or in full.
2313 * @param bOnlyForced when true, it only calculates those formula cells
2314 * that are marked "recalc forced".
2315 * @param bProgressBar whether or not to use progress bar.
2316 * @param bSetAllDirty when true, it marks all formula cells currently on
2317 * the formula tree dirty, which forces all of them to
2318 * be recalculated. When false, only those cells
2319 * that are marked dirty prior to this call get
2320 * recalculated.
2322 SC_DLLPUBLIC void CalcFormulaTree( bool bOnlyForced = false, bool bProgressBar = true, bool bSetAllDirty = true );
2323 void ClearFormulaTree();
2324 void AppendToFormulaTrack( ScFormulaCell* pCell );
2325 void RemoveFromFormulaTrack( ScFormulaCell* pCell );
2326 void TrackFormulas( SfxHintId nHintId = SfxHintId::ScDataChanged );
2327 void SetTrackFormulasPending() { mbTrackFormulasPending = true; }
2328 bool IsTrackFormulasPending() const { return mbTrackFormulasPending; }
2329 void FinalTrackFormulas( SfxHintId nHintId );
2330 bool IsFinalTrackFormulas() const { return mbFinalTrackFormulas; }
2331 inline bool IsInFormulaTree( const ScFormulaCell* pCell ) const;
2332 inline bool IsInFormulaTrack( const ScFormulaCell* pCell ) const;
2333 HardRecalcState GetHardRecalcState() const { return eHardRecalcState; }
2334 void SetHardRecalcState( HardRecalcState eVal ) { eHardRecalcState = eVal; }
2335 void StartAllListeners();
2336 void StartNeededListeners();
2337 void StartNeededListeners( const std::shared_ptr<const sc::ColumnSet>& rpColSet );
2338 SC_DLLPUBLIC void StartAllListeners( const ScRange& rRange );
2340 void SetForcedFormulas( bool bVal ) { bHasForcedFormulas = bVal; }
2341 sal_uLong GetFormulaCodeInTree() const { return nFormulaCodeInTree; }
2343 bool IsInInterpreter() const { return nInterpretLevel != 0; }
2345 void IncInterpretLevel()
2347 assert(!IsThreadedGroupCalcInProgress());
2348 if ( nInterpretLevel < USHRT_MAX )
2349 nInterpretLevel++;
2351 void DecInterpretLevel()
2353 assert(!IsThreadedGroupCalcInProgress());
2354 if ( nInterpretLevel )
2355 nInterpretLevel--;
2357 sal_uInt16 GetMacroInterpretLevel() const { return nMacroInterpretLevel; }
2358 void IncMacroInterpretLevel()
2360 assert(!IsThreadedGroupCalcInProgress());
2361 if ( nMacroInterpretLevel < USHRT_MAX )
2362 nMacroInterpretLevel++;
2364 void DecMacroInterpretLevel()
2366 assert(!IsThreadedGroupCalcInProgress());
2367 if ( nMacroInterpretLevel )
2368 nMacroInterpretLevel--;
2370 bool IsInInterpreterTableOp() const { return nInterpreterTableOpLevel != 0; }
2371 void IncInterpreterTableOpLevel()
2373 if ( nInterpreterTableOpLevel < USHRT_MAX )
2374 nInterpreterTableOpLevel++;
2376 void DecInterpreterTableOpLevel()
2378 if ( nInterpreterTableOpLevel )
2379 nInterpreterTableOpLevel--;
2382 // add a formula to be remembered for TableOp broadcasts
2383 void AddTableOpFormulaCell( ScFormulaCell* );
2384 void InvalidateLastTableOpParams() { aLastTableOpParams.bValid = false; }
2385 ScRecursionHelper& GetRecursionHelper();
2386 bool IsInDtorClear() const { return bInDtorClear; }
2387 void SetExpandRefs( bool bVal );
2388 bool IsExpandRefs() const { return bExpandRefs; }
2390 sal_uLong GetXMLImportedFormulaCount() const { return nXMLImportedFormulaCount; }
2391 void IncXMLImportedFormulaCount( sal_uLong nVal )
2393 if ( nXMLImportedFormulaCount + nVal > nXMLImportedFormulaCount )
2394 nXMLImportedFormulaCount += nVal;
2396 void DecXMLImportedFormulaCount( sal_uLong nVal )
2398 if ( nVal <= nXMLImportedFormulaCount )
2399 nXMLImportedFormulaCount -= nVal;
2400 else
2401 nXMLImportedFormulaCount = 0;
2404 void StartTrackTimer();
2406 void CompileDBFormula();
2407 void CompileColRowNameFormula();
2409 /** Maximum string length of a column, e.g. for dBase export.
2410 @return String length in octets (!) of the destination encoding. In
2411 case of non-octet encodings (e.g. UCS2) the length in code
2412 points times sizeof(sal_Unicode) is returned. */
2413 sal_Int32 GetMaxStringLen( SCTAB nTab, SCCOL nCol,
2414 SCROW nRowStart, SCROW nRowEnd,
2415 rtl_TextEncoding eCharSet ) const;
2416 /** Maximum string length of numerical cells of a column, e.g. for dBase export.
2417 @return String length in characters (!) including the decimal
2418 separator, and the decimal precision needed. */
2419 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
2420 SCTAB nTab, SCCOL nCol,
2421 SCROW nRowStart, SCROW nRowEnd ) const;
2423 void KeyInput(); // TimerDelays etc.
2425 ScChangeTrack* GetChangeTrack() const { return pChangeTrack.get(); }
2427 //! only for import filter, deletes any existing ChangeTrack via
2428 //! EndChangeTracking() and takes ownership of new ChangeTrack pTrack
2429 SC_DLLPUBLIC void SetChangeTrack( std::unique_ptr<ScChangeTrack> pTrack );
2431 void StartChangeTracking();
2432 void EndChangeTracking();
2434 SC_DLLPUBLIC void CompareDocument( ScDocument& rOtherDoc );
2436 void AddUnoObject( SfxListener& rObject );
2437 void RemoveUnoObject( SfxListener& rObject );
2438 void BroadcastUno( const SfxHint &rHint );
2439 void AddUnoListenerCall( const css::uno::Reference<
2440 css::util::XModifyListener >& rListener,
2441 const css::lang::EventObject& rEvent );
2443 void SetInLinkUpdate(bool bSet); // TableLink or AreaLink
2444 bool IsInLinkUpdate() const; // including DdeLink
2446 SC_DLLPUBLIC SfxItemPool* GetEditPool() const;
2447 SC_DLLPUBLIC SfxItemPool* GetEnginePool() const;
2448 SC_DLLPUBLIC ScFieldEditEngine& GetEditEngine();
2449 SC_DLLPUBLIC ScNoteEditEngine& GetNoteEngine();
2451 std::unique_ptr<ScRefreshTimerControl> const & GetRefreshTimerControlAddress() const
2452 { return pRefreshTimerControl; }
2454 void SetPastingDrawFromOtherDoc( bool bVal )
2455 { bPastingDrawFromOtherDoc = bVal; }
2456 bool PastingDrawFromOtherDoc() const
2457 { return bPastingDrawFromOtherDoc; }
2459 /// an ID unique to each document instance
2460 sal_uInt32 GetDocumentID() const;
2462 void InvalidateStyleSheetUsage() { bStyleSheetUsageInvalid = true; }
2463 void SC_DLLPUBLIC GetSortParam( ScSortParam& rParam, SCTAB nTab );
2464 void SC_DLLPUBLIC SetSortParam( const ScSortParam& rParam, SCTAB nTab );
2466 void SetVbaEventProcessor( const css::uno::Reference< css::script::vba::XVBAEventProcessor >& rxVbaEvents )
2467 { mxVbaEvents = rxVbaEvents; }
2468 const css::uno::Reference< css::script::vba::XVBAEventProcessor >& GetVbaEventProcessor() const { return mxVbaEvents; }
2470 /** Should only be GRAM_PODF or GRAM_ODFF. */
2471 void SetStorageGrammar( formula::FormulaGrammar::Grammar eGrammar );
2472 formula::FormulaGrammar::Grammar GetStorageGrammar() const { return eStorageGrammar; }
2474 SC_DLLPUBLIC SfxUndoManager* GetUndoManager();
2475 bool IsInVBAMode() const;
2476 ScRowBreakIterator* GetRowBreakIterator(SCTAB nTab) const;
2478 void AddSubTotalCell(ScFormulaCell* pCell);
2479 void RemoveSubTotalCell(ScFormulaCell* pCell);
2480 void SetSubTotalCellsDirty(const ScRange& rDirtyRange);
2482 sal_uInt16 GetTextWidth( const ScAddress& rPos ) const;
2484 SvtScriptType GetScriptType( const ScAddress& rPos ) const;
2485 void SetScriptType( const ScAddress& rPos, SvtScriptType nType );
2486 void UpdateScriptTypes( const ScAddress& rPos, SCCOL nColSize, SCROW nRowSize );
2489 * Make specified formula cells non-grouped.
2491 * @param nTab sheet index
2492 * @param nCol column index
2493 * @param rRows list of row indices at which formula cells are to be
2494 * unshared. This call sorts the passed row indices and
2495 * removes duplicates, which is why the caller must pass it
2496 * as reference.
2498 void UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector<SCROW>& rRows );
2499 void RegroupFormulaCells( SCTAB nTab, SCCOL nCol );
2500 void RegroupFormulaCells( const ScRange& range );
2502 formula::FormulaTokenRef ResolveStaticReference( const ScAddress& rPos );
2503 formula::FormulaTokenRef ResolveStaticReference( const ScRange& rRange );
2505 formula::VectorRefArray FetchVectorRefArray( const ScAddress& rPos, SCROW nLength );
2506 bool HandleRefArrayForParallelism( const ScAddress& rPos, SCROW nLength, const ScFormulaCellGroupRef& mxGroup );
2507 #ifdef DBG_UTIL
2508 void AssertNoInterpretNeeded( const ScAddress& rPos, SCROW nLength );
2509 #endif
2512 * Call this before any operations that might trigger one or more formula
2513 * cells to get calculated.
2515 void PrepareFormulaCalc();
2518 * Make sure all of the formula cells in the specified range have been
2519 * fully calculated. This method only re-calculates those formula cells
2520 * that have been flagged dirty. In case of formula-groups, this calculates
2521 * only the dirty subspans along with the dependents in the same way
2522 * recursively.
2524 * @param rRange range in which to potentially calculate the formula
2525 * cells.
2526 * @param bSkipRunning flag to skip evaluation of formula-cells that are
2527 * marked as already being evaluated.
2528 * @return true if at least one formula-cell in the specified range was dirty
2529 * else returns false.
2531 SC_DLLPUBLIC bool EnsureFormulaCellResults( const ScRange& rRange, bool bSkipRunning = false );
2533 SvtBroadcaster* GetBroadcaster( const ScAddress& rPos );
2534 const SvtBroadcaster* GetBroadcaster( const ScAddress& rPos ) const;
2535 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rTopPos, SCROW nLength );
2537 std::optional<sc::ColumnIterator> GetColumnIterator( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
2538 void CreateColumnIfNotExists( SCTAB nTab, SCCOL nCol );
2540 SC_DLLPUBLIC void StoreTabToCache(SCTAB nTab, SvStream& rStrm) const;
2541 SC_DLLPUBLIC void RestoreTabFromCache(SCTAB nTab, SvStream& rStream);
2543 #if DUMP_COLUMN_STORAGE
2544 SC_DLLPUBLIC void DumpColumnStorage( SCTAB nTab, SCCOL nCol ) const;
2545 #endif
2547 #if DEBUG_AREA_BROADCASTER
2548 SC_DLLPUBLIC void DumpAreaBroadcasters() const;
2549 #endif
2551 SC_DLLPUBLIC void SetCalcConfig( const ScCalcConfig& rConfig );
2552 const ScCalcConfig& GetCalcConfig() const { return maCalcConfig; }
2553 void ConvertFormulaToValue( const ScRange& rRange, sc::TableValues* pUndo );
2554 void SwapNonEmpty( sc::TableValues& rValues );
2555 void finalizeOutlineImport();
2556 bool TableExists( SCTAB nTab ) const;
2558 SC_DLLPUBLIC ScColumnsRange GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const;
2560 bool IsInDocShellRecalc() const { return mbDocShellRecalc; }
2561 void SetDocShellRecalc(bool bSet) { mbDocShellRecalc = bSet; }
2563 bool IsInLayoutStrings() const { return mbLayoutStrings; }
2564 void SetLayoutStrings(bool bSet) { mbLayoutStrings = bSet; }
2567 * Serializes the specified sheet's geometry data.
2569 * @param nTab is the index of the sheet to operate on.
2570 * @param bColumns - if true it dumps the data for columns, else it does for rows.
2571 * @param eGeomType indicates the type of data to be dumped for rows/columns.
2572 * @return the serialization of the specified sheet's geometry data as an OString.
2574 OString dumpSheetGeomData(SCTAB nTab, bool bColumns, SheetGeomType eGeomType);
2576 SCCOL GetLOKFreezeCol(SCTAB nTab) const;
2577 SCROW GetLOKFreezeRow(SCTAB nTab) const;
2578 bool SetLOKFreezeCol(SCCOL nFreezeCol, SCTAB nTab);
2579 bool SetLOKFreezeRow(SCROW nFreezeRow, SCTAB nTab);
2581 private:
2584 * Use this class as a locale variable to merge number formatter from
2585 * another document, and set NULL pointer to pFormatExchangeList when
2586 * done.
2588 class NumFmtMergeHandler
2590 public:
2591 explicit NumFmtMergeHandler(ScDocument& rDoc, const ScDocument& rSrcDoc);
2592 ~NumFmtMergeHandler();
2594 private:
2595 ScDocument& mrDoc;
2598 ScTable* FetchTable( SCTAB nTab );
2599 const ScTable* FetchTable( SCTAB nTab ) const;
2601 void MergeNumberFormatter(const ScDocument& rSrcDoc);
2603 void ImplCreateOptions(); // Suggestion: switch to on-demand?
2604 void ImplDeleteOptions();
2606 void DeleteDrawLayer();
2607 SC_DLLPUBLIC bool DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const;
2609 void UpdateDrawPrinter();
2610 void UpdateDrawLanguages();
2611 SC_DLLPUBLIC void InitClipPtrs( ScDocument* pSourceDoc );
2613 void LoadDdeLinks(SvStream& rStream);
2614 void SaveDdeLinks(SvStream& rStream) const;
2616 void DeleteAreaLinksOnTab( SCTAB nTab );
2617 void UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
2618 const ScRange& r, SCCOL nDx, SCROW nDy, SCTAB nDz );
2620 void CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks);
2622 bool HasPartOfMerged( const ScRange& rRange );
2624 public:
2625 ScRefCellValue GetRefCellValue( const ScAddress& rPos );
2626 private:
2627 ScRefCellValue GetRefCellValue( const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos );
2629 std::map< SCTAB, ScSortParam > mSheetSortParams;
2631 SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol ) const;
2632 SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
2633 void ReservePatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserve );
2635 void SharePooledResources( const ScDocument* pSrcDoc );
2637 void EndListeningIntersectedGroup(
2638 sc::EndListeningContext& rCxt, const ScAddress& rPos, std::vector<ScAddress>* pGroupPos );
2640 void EndListeningIntersectedGroups(
2641 sc::EndListeningContext& rCxt, const ScRange& rRange, std::vector<ScAddress>* pGroupPos );
2643 void EndListeningGroups( const std::vector<ScAddress>& rPosArray );
2644 void SetNeedsListeningGroups( const std::vector<ScAddress>& rPosArray );
2646 bool BroadcastHintInternal( const ScHint &rHint );
2649 typedef std::unique_ptr<ScDocument, o3tl::default_delete<ScDocument>> ScDocumentUniquePtr;
2652 * Instantiate this to ensure that subsequent modification of
2653 * the document will cause an assertion failure while this is
2654 * in-scope.
2656 struct ScMutationDisable
2658 #ifndef NDEBUG
2659 ScMutationDisable(ScDocument& rDocument, ScMutationGuardFlags nFlags)
2660 : mnFlagRestore(rDocument.mnMutationGuardFlags)
2661 , mrDocument(rDocument)
2663 assert((mnFlagRestore & nFlags) == 0);
2664 mrDocument.mnMutationGuardFlags |= static_cast<size_t>(nFlags);
2666 ~ScMutationDisable()
2668 mrDocument.mnMutationGuardFlags = mnFlagRestore;
2670 size_t mnFlagRestore;
2671 ScDocument& mrDocument;
2672 #else
2673 ScMutationDisable(ScDocument& rDocument, ScMutationGuardFlags nFlags)
2675 (void)rDocument; (void)nFlags;
2677 #endif
2681 * A pretty assertion that checks that the relevant bits in
2682 * the @nFlags are not set on the document at entry and exit.
2684 * Its primary use is for debugging threading. As such, an
2685 * @ScMutationDisable is created to forbid mutation, and this
2686 * condition is then asserted on at prominent sites that
2687 * mutate @nFlags.
2689 struct ScMutationGuard
2691 #ifndef NDEBUG
2692 ScMutationGuard(ScDocument& rDocument, ScMutationGuardFlags nFlags)
2693 : mnFlags(static_cast<size_t>(nFlags))
2694 , mrDocument(rDocument)
2696 assert((mrDocument.mnMutationGuardFlags & mnFlags) == 0);
2699 ~ScMutationGuard()
2701 assert((mrDocument.mnMutationGuardFlags & mnFlags) == 0);
2703 size_t mnFlags;
2704 ScDocument& mrDocument;
2705 #else
2706 ScMutationGuard(ScDocument& rDocument, ScMutationGuardFlags nFlags)
2708 (void)rDocument; (void)nFlags;
2710 #endif
2713 class ScDocShellRecalcGuard
2715 ScDocument& mrDoc;
2717 public:
2718 ScDocShellRecalcGuard(ScDocument& rDoc)
2719 : mrDoc(rDoc)
2721 assert(!mrDoc.IsInDocShellRecalc());
2722 mrDoc.SetDocShellRecalc(true);
2725 ~ScDocShellRecalcGuard()
2727 mrDoc.SetDocShellRecalc(false);
2731 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */