Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / inc / document.hxx
blob52fd5a4a509f7b31f6df26727b3b065bfd854fc6
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 <comphelper/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 "recursionhelper.hxx"
32 #include "tabopparams.hxx"
33 #include "types.hxx"
34 #include <formula/grammar.hxx>
35 #include <formula/types.hxx>
36 #include "typedstrdata.hxx"
37 #include "calcmacros.hxx"
38 #include "calcconfig.hxx"
39 #include "sheetlimits.hxx"
40 #include <o3tl/deleter.hxx>
41 #include <o3tl/sorted_vector.hxx>
42 #include <svl/hint.hxx>
43 #include <svl/typedwhich.hxx>
44 #include <svl/zforlist.hxx>
45 #include <tools/gen.hxx>
46 #include <tools/solar.h>
48 #include <cassert>
49 #include <memory>
50 #include <map>
51 #include <shared_mutex>
52 #include <optional>
53 #include <set>
54 #include <unordered_map>
55 #include <vector>
57 #include "markdata.hxx"
58 #include "drwlayer.hxx"
60 namespace com::sun::star::chart2 { class XChartDocument; }
62 class Timer;
64 enum class SvtScriptType : sal_uInt8;
65 enum class ScMF;
66 enum class FormulaError : sal_uInt16;
67 enum class CharCompressType;
68 enum class EEHorizontalTextDirection;
69 namespace editeng { class SvxBorderLine; }
70 namespace formula { struct VectorRefArray; }
71 namespace svl {
72 class SharedString;
73 class SharedStringPool;
76 namespace tools { class Guid; }
78 namespace sc {
80 struct BroadcasterState;
81 struct FormulaGroupContext;
82 class StartListeningContext;
83 class EndListeningContext;
84 class CopyFromClipContext;
85 class ColumnSpanSet;
86 class RangeColumnSpanSet;
87 struct ColumnBlockPosition;
88 struct RefUpdateContext;
89 class EditTextIterator;
90 struct NoteEntry;
91 class DocumentStreamAccess;
92 class DocumentLinkManager;
93 class CellValues;
94 class TableValues;
95 class RowHeightContext;
96 struct SetFormulaDirtyContext;
97 class RefMovedHint;
98 struct ReorderParam;
99 class FormulaGroupAreaListener;
100 class ColumnSet;
101 class UpdatedRangeNames;
102 class TableColumnBlockPositionSet;
103 class ColumnIterator;
104 class ExternalDataMapper;
105 class Sparkline;
106 class SparklineGroup;
107 class SparklineList;
111 class Fraction;
113 class OutputDevice;
114 class SdrObject;
115 class SfxBroadcaster;
116 class SfxListener;
117 class SfxItemSet;
118 class SfxObjectShell;
119 class SfxBindings;
120 class SfxPoolItem;
121 class SfxItemPool;
122 class SfxPrinter;
123 class SfxStyleSheetBase;
124 class SvMemoryStream;
125 class SvxBoxInfoItem;
126 class SvxBoxItem;
127 class SvxForbiddenCharactersTable;
128 namespace sfx2 {
129 class LinkManager;
131 class SvxSearchItem;
132 class XColorList;
134 class ScAutoFormatData;
135 class ScBroadcastAreaSlotMachine;
136 class ScChangeViewSettings;
137 class ScChartListenerCollection;
138 class ScClipOptions;
139 class ScColumn;
140 class ScConditionalFormat;
141 class ScConditionalFormatList;
142 class ScDBCollection;
143 class ScDBData;
144 class ScDetOpData;
145 class ScDetOpList;
146 class ScDocOptions;
147 class ScDocProtection;
148 class ScDocumentPool;
149 class ScDrawLayer;
150 class ScExtDocOptions;
151 class ScExternalRefManager;
152 class ScFormulaCell;
153 class ScMacroManager;
154 class ScOutlineTable;
155 class ScPrintRangeSaver;
156 class ScStyleSheet;
157 class ScStyleSheetPool;
158 class ScTable;
159 class ScTableProtection;
160 class ScTokenArray;
161 class ScValidationData;
162 class ScValidationDataList;
163 class ScViewOptions;
164 class ScChangeTrack;
165 class ScEditEngineDefaulter;
166 class ScFieldEditEngine;
167 class ScNoteEditEngine;
168 class ScDPObject;
169 class ScDPCollection;
170 class ScMatrix;
171 class ScScriptTypeData;
172 class ScPoolHelper;
173 struct ScSortParam;
174 class ScRefreshTimerControl;
175 class ScUnoListenerCalls;
176 class ScUnoRefList;
177 class ScRecursionHelper;
178 struct RowInfo;
179 struct ScTableInfo;
180 struct ScTabOpParam;
181 class VirtualDevice;
182 class ScAutoNameCache;
183 class ScTemporaryChartLock;
184 class ScLookupCache;
185 struct ScLookupCacheMap;
186 class ScSortedRangeCache;
187 struct ScSortedRangeCacheMap;
188 class ScUndoManager;
189 class ScFormulaParserPool;
190 struct ScClipParam;
191 class ScRowBreakIterator;
192 struct ScSetStringParam;
193 struct ScColWidthParam;
194 class ScSheetEvents;
195 class ScProgress;
196 class SvtListener;
197 class ScEditDataArray;
198 class EditTextObject;
199 struct ScRefCellValue;
200 class ScPostIt;
201 struct ScSubTotalParam;
202 struct ScQueryParam;
203 class ScHint;
204 class SvtBroadcaster;
205 enum class ScDBDataPortion;
206 enum class ScSheetEventId;
207 class BitmapEx;
208 class ScColumnsRange;
209 struct ScFilterEntries;
210 typedef o3tl::sorted_vector<sal_uInt32> ScCondFormatIndexes;
211 struct ScSheetLimits;
212 struct ScDataAreaExtras;
213 enum class ScConditionMode;
216 namespace sc {
218 typedef std::map<OUString, BitmapEx> IconSetBitmapMap;
222 namespace com::sun::star {
223 namespace lang {
224 struct EventObject;
226 namespace i18n {
227 class XBreakIterator;
229 namespace util {
230 class XModifyListener;
232 namespace embed {
233 class XEmbeddedObject;
235 namespace script::vba {
236 class XVBAEventProcessor;
238 namespace sheet {
239 struct TablePageBreakData;
243 namespace weld {
245 class Window;
249 #define SC_DOC_NEW 0xFFFF
251 #define SC_MACROCALL_ALLOWED 0
253 #define SC_ASIANKERNING_INVALID 0xff
255 enum ScDocumentMode
257 SCDOCMODE_DOCUMENT,
258 SCDOCMODE_CLIP,
259 SCDOCMODE_UNDO,
260 SCDOCMODE_FUNCTIONACCESS
263 enum CommentCaptionState
265 ALLSHOWN, // All comments captions are shown
266 ALLHIDDEN, // All comments captions are hidden
267 MIXED // There are comments in shown and hidden.
270 enum RangeNameScope
272 GLOBAL, // A range name can be defined
273 SHEET // with two scope on Manage Names dialog.
276 /// Represents the type of sheet geometry data.
277 enum class SheetGeomType
279 SIZES, // Column widths or row heights.
280 HIDDEN, // Hidden columns/rows.
281 FILTERED, // Filtered columns/rows.
282 GROUPS // Grouping of columns/rows.
285 struct ScDocStat
287 OUString aDocName;
288 SCTAB nTableCount;
289 sal_uInt64 nCellCount;
290 sal_uInt64 nFormulaCount;
291 sal_uInt16 nPageCount;
292 ScDocStat()
293 : nTableCount(0)
294 , nCellCount(0)
295 , nFormulaCount(0)
296 , nPageCount(0)
301 // DDE link modes
302 const sal_uInt8 SC_DDE_DEFAULT = 0;
303 const sal_uInt8 SC_DDE_ENGLISH = 1;
304 const sal_uInt8 SC_DDE_TEXT = 2;
305 const sal_uInt8 SC_DDE_IGNOREMODE = 255; /// For usage in FindDdeLink() only!
307 // During threaded calculation fields being mutated are kept in this struct
308 struct ScDocumentThreadSpecific
310 std::unique_ptr<ScRecursionHelper> xRecursionHelper; // information for recursive and iterative cell formulas
311 ScInterpreterContext* pContext = nullptr; // references the context passed around for easier access
314 /// Enumeration to determine which pieces of the code should not be mutated when set.
315 enum ScMutationGuardFlags
317 // Bit mask bits
318 CORE = 0x0001, /// Core calc data structures should not be mutated
321 typedef std::unique_ptr<ScTable, o3tl::default_delete<ScTable>> ScTableUniquePtr;
323 class ScDocument
325 friend class ScValueIterator;
326 friend class ScHorizontalValueIterator;
327 friend class ScDBQueryDataIterator;
328 friend class ScCellIterator;
329 template< ScQueryCellIteratorAccess accessType, ScQueryCellIteratorType queryType >
330 friend class ScQueryCellIteratorBase;
331 template< ScQueryCellIteratorAccess accessType >
332 friend class ScQueryCellIteratorAccessSpecific;
333 friend class ScHorizontalCellIterator;
334 friend class ScHorizontalAttrIterator;
335 friend class ScDocAttrIterator;
336 friend class ScAttrRectIterator;
337 friend class ScDocShell;
338 friend class ScDocRowHeightUpdater;
339 friend class ScColumnTextWidthIterator;
340 friend class ScTable;
341 friend class ScColumn;
342 friend struct ScRefCellValue;
343 friend class ScDocumentImport;
344 friend class sc::EditTextIterator;
345 friend struct ScMutationGuard;
346 friend struct ScMutationDisable;
348 typedef std::vector<ScTableUniquePtr> TableContainer;
350 public:
351 enum class HardRecalcState
353 OFF, /// normal calculation of dependencies
354 TEMPORARY, /// CalcAll() without broadcast/notify but setting up new listeners
355 ETERNAL /// no new listeners are setup, no broadcast/notify
358 private:
359 rtl::Reference<ScPoolHelper> mxPoolHelper;
361 std::shared_ptr<svl::SharedStringPool> mpCellStringPool;
362 std::unique_ptr<sc::DocumentLinkManager> mpDocLinkMgr;
364 std::shared_ptr<sc::FormulaGroupContext> mpFormulaGroupCxt;
365 bool mbFormulaGroupCxtBlockDiscard;
367 ScCalcConfig maCalcConfig;
369 ScUndoManager* mpUndoManager;
370 std::unique_ptr<ScFieldEditEngine> mpEditEngine; // uses pEditPool from xPoolHelper
371 std::unique_ptr<ScNoteEditEngine> mpNoteEngine; // uses pEditPool from xPoolHelper
372 ScDocShell* mpShell;
373 VclPtr<SfxPrinter> mpPrinter;
374 VclPtr<VirtualDevice> mpVirtualDevice_100th_mm;
375 std::unique_ptr<ScDrawLayer> mpDrawLayer; // SdrModel
376 rtl::Reference<XColorList> pColorList;
377 std::unique_ptr<ScValidationDataList> pValidationList; // validity
378 SvNumberFormatterIndexTable* pFormatExchangeList; // for application of number formats
379 TableContainer maTabs;
380 rtl::Reference<ScSheetLimits> mxSheetLimits;
381 std::vector<OUString> maTabNames; // for undo document, we need the information tab name <-> index
382 mutable std::unique_ptr<ScRangeName> pRangeName;
383 std::unique_ptr<ScDBCollection> pDBCollection;
384 std::unique_ptr<ScDPCollection> pDPCollection;
385 std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock;
386 std::unique_ptr<ScPatternAttr> pSelectionAttr; // Attributes of a block
387 ScFormulaCell* pFormulaTree; // formula tree (start)
388 ScFormulaCell* pEOFormulaTree; // formula tree (end), last cell
389 ScFormulaCell* pFormulaTrack; // BroadcastTrack (start)
390 ScFormulaCell* pEOFormulaTrack; // BroadcastTrack (end), last cell
391 std::unique_ptr<ScBroadcastAreaSlotMachine> pBASM; // BroadcastAreas
392 std::unique_ptr<ScChartListenerCollection> pChartListenerCollection;
393 std::unique_ptr<SvMemoryStream> pClipData;
394 std::unique_ptr<ScDetOpList> pDetOpList;
395 std::unique_ptr<ScChangeTrack> pChangeTrack;
396 std::unique_ptr<SfxBroadcaster> pUnoBroadcaster;
397 std::unique_ptr<ScUnoListenerCalls> pUnoListenerCalls;
398 std::unique_ptr<ScUnoRefList> pUnoRefUndoList;
399 std::unique_ptr<ScChangeViewSettings> pChangeViewSettings;
400 std::unique_ptr<ScScriptTypeData> pScriptTypeData;
401 std::unique_ptr<ScRefreshTimerControl> pRefreshTimerControl;
402 std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenCharacters;
403 std::unique_ptr<ScDBData> mpAnonymousDBData;
404 std::unique_ptr<sc::ExternalDataMapper> mpDataMapper;
406 std::unique_ptr<ScFieldEditEngine> pCacheFieldEditEngine;
408 std::unique_ptr<ScDocProtection> pDocProtection;
409 std::unique_ptr<ScClipParam> mpClipParam;
411 std::unique_ptr<ScExternalRefManager> pExternalRefMgr;
412 std::unique_ptr<ScMacroManager> mpMacroMgr;
414 // mutable for lazy construction
415 mutable std::unique_ptr< ScFormulaParserPool >
416 mxFormulaParserPool; /// Pool for all external formula parsers used by this document.
418 OUString aDocName; // optional: name of document
419 OUString aDocCodeName; // optional: name of document (twice?)
420 OUString maFileURL; // file URL for copy & paste
421 ScRangePairListRef xColNameRanges;
422 ScRangePairListRef xRowNameRanges;
424 std::unique_ptr<ScViewOptions> pViewOptions; // view options
425 std::unique_ptr<ScDocOptions> pDocOptions; // document options
426 std::unique_ptr<ScExtDocOptions> pExtDocOptions; // for import etc.
427 std::unique_ptr<ScClipOptions> mpClipOptions; // clipboard options
428 std::unique_ptr<ScConsolidateParam> pConsolidateDlgData;
429 std::unique_ptr<ScConditionMode> pConditionalFormatDialogMode;
431 std::unique_ptr<ScAutoNameCache> pAutoNameCache; // for automatic name lookup during CompileXML
433 std::unique_ptr<SfxItemSet> pPreviewFont; // convert to std::unique_ptr or whatever
434 ScStyleSheet* pPreviewCellStyle;
435 ScMarkData maPreviewSelection;
436 sal_Int64 nUnoObjectId; // counted up for UNO objects
438 ErrCode nRangeOverflowType; // used in (xml) loading for overflow warnings
440 ScRange aEmbedRange;
441 ScAddress aCurTextWidthCalcPos;
443 Idle aTrackIdle;
445 css::uno::Reference< css::script::vba::XVBAEventProcessor >
446 mxVbaEvents;
447 public:
448 /// list of ScInterpreterTableOpParams currently in use
449 std::vector<ScInterpreterTableOpParams*> m_TableOpList;
450 ScInterpreterTableOpParams aLastTableOpParams; // remember last params
452 private:
454 LanguageType eLanguage; // default language
455 LanguageType eCjkLanguage; // default language for asian text
456 LanguageType eCtlLanguage; // default language for complex text
457 rtl_TextEncoding eSrcSet; // during reading: source character set
459 /** The compiler grammar used in document storage. GRAM_PODF for ODF 1.1
460 documents, GRAM_ODFF for ODF 1.2 documents. */
461 formula::FormulaGrammar::Grammar eStorageGrammar;
463 sal_uInt64 nFormulaCodeInTree; // formula RPN in the formula tree
464 sal_uInt64 nXMLImportedFormulaCount; // progress count during XML import
465 sal_uInt16 nInterpretLevel; // >0 if in interpreter
466 sal_uInt16 nMacroInterpretLevel; // >0 if macro in interpreter
467 sal_uInt16 nInterpreterTableOpLevel; // >0 if in interpreter TableOp
469 ScDocumentThreadSpecific maNonThreaded;
471 // There can be only one ScDocument being calculated in a thread at a time, so we can use a
472 // plain thread_local static member.
473 thread_local static ScDocumentThreadSpecific maThreadSpecific;
475 mutable ScInterpreterContext maInterpreterContext;
477 std::shared_mutex mScLookupMutex; // protection for thread-unsafe parts of handling ScLookup
478 std::unique_ptr<ScSortedRangeCacheMap> mxScSortedRangeCache; // cache for unsorted lookups
480 static const sal_uInt16 nSrcVer; // file version (load/save)
481 sal_uInt16 nFormulaTrackCount;
482 HardRecalcState eHardRecalcState; // off, temporary, eternal
483 SCTAB nVisibleTab; // for OLE etc., don't use inside ScDocument
484 SCCOL nPosLeft; // for OLE etc., don't use inside ScDocument
485 SCROW nPosTop; // for OLE etc., don't use inside ScDocument
487 ScLkUpdMode eLinkMode;
489 bool bAutoCalc; // calculate automatically
490 bool bAutoCalcShellDisabled; // in/from/for ScDocShell disabled
491 // are there ForcedFormulas which have to be calculated
492 // in interaction with ScDocShell SetDocumentModified,
493 // AutoCalcShellDisabled and TrackFormulas
494 bool bForcedFormulaPending;
495 bool bCalculatingFormulaTree;
496 bool bIsClip;
497 bool bIsUndo;
498 bool bIsFunctionAccess;
499 bool bIsVisible; // set from view ctor
501 bool bIsEmbedded; // display/adjust Embedded area?
503 // no broadcast, construct no listener during insert from a different
504 // Doc (per filter or the like ), not until CompileAll / CalcAfterLoad
505 bool bInsertingFromOtherDoc;
506 bool bLoadingMedium;
507 bool bImportingXML; // special handling of formula text
508 bool bCalcingAfterLoad; // in CalcAfterLoad TRUE
509 // don't construct/destruct listeners temporarily
510 bool bNoListening;
511 bool mbIdleEnabled;
512 bool bInLinkUpdate; // TableLink or AreaLink
513 bool bChartListenerCollectionNeedsUpdate;
514 // are/were there RC_FORCED formula cells in the document (if set once to TRUE then set forever)
515 bool bHasForcedFormulas;
516 // is the Doc being destroyed? (no Notify-Tracking etc. needed anymore)
517 bool bInDtorClear;
518 // expand reference if insert column/row takes place at the border
519 // of a reference
520 // is fetched in each UpdateReference from InputOptions,
521 // assigned, and restored at the end of UpdateReference
522 bool bExpandRefs;
523 // for detective update, is set for each change of a formula
524 bool bDetectiveDirty;
525 // If the pointer is set, formula cells will not be automatically grouped into shared formula groups,
526 // instead the range will be extended to contain all such cells.
527 std::unique_ptr< ScRange > pDelayedFormulaGrouping;
528 // If non-empty, ScColumn::StartListeningFormulaCells() calls may be delayed using this,
529 // avoiding repeated calling for the same cells in the given range. The function will be called once
530 // later for all the cells in the range.
531 std::unordered_map< ScColumn*, std::pair<SCROW, SCROW>> pDelayedStartListeningFormulaCells;
532 // Cells will not delete their broadcasters if delayed, avoiding possible extensive mdds vector changes.
533 bool bDelayedDeletingBroadcasters;
535 bool bLinkFormulaNeedingCheck; // valid only after loading, for ocDde and ocWebservice
537 CharCompressType nAsianCompression;
538 sal_uInt8 nAsianKerning;
540 bool bPastingDrawFromOtherDoc;
542 sal_uInt8 nInDdeLinkUpdate; // originating DDE links (stacked bool)
544 bool bInUnoBroadcast;
545 bool bInUnoListenerCall;
546 sal_uInt32 nAdjustHeightLock;
547 formula::FormulaGrammar::Grammar eGrammar;
549 mutable bool bStyleSheetUsageInvalid;
551 bool mbUndoEnabled:1;
552 bool mbExecuteLinkEnabled:1;
553 bool mbChangeReadOnlyEnabled:1; // allow changes in read-only document (for API import filters)
554 bool mbStreamValidLocked:1;
555 bool mbUserInteractionEnabled:1; // whether or not to launch any kind of interactive dialogs.
557 sal_Int16 mnNamedRangesLockCount;
559 std::set<ScFormulaCell*> maSubTotalCells;
562 bool mbEmbedFonts : 1;
563 bool mbEmbedUsedFontsOnly : 1;
564 bool mbEmbedFontScriptLatin : 1;
565 bool mbEmbedFontScriptAsian : 1;
566 bool mbEmbedFontScriptComplex : 1;
568 sal_Int32 mnImagePreferredDPI;
570 std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap;
572 bool mbTrackFormulasPending : 1;
573 bool mbFinalTrackFormulas : 1;
574 // This indicates if a ScDocShell::DoRecalc() or ScDocShell::DoHardRecalc() is in progress.
575 bool mbDocShellRecalc : 1;
576 // This indicates if a ScOutputData::LayoutStrings() is in progress.
577 bool mbLayoutStrings : 1;
579 size_t mnMutationGuardFlags;
581 public:
582 bool IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBorder);
583 void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge);
585 bool IsEmbedFonts() const { return mbEmbedFonts; }
586 bool IsEmbedUsedFontsOnly() const { return mbEmbedUsedFontsOnly; }
587 bool IsEmbedFontScriptLatin() const { return mbEmbedFontScriptLatin; }
588 bool IsEmbedFontScriptAsian() const { return mbEmbedFontScriptAsian; }
589 bool IsEmbedFontScriptComplex() const { return mbEmbedFontScriptComplex; }
591 void SetEmbedFonts(bool bUse) { mbEmbedFonts = bUse; }
592 void SetEmbedUsedFontsOnly(bool bUse) { mbEmbedUsedFontsOnly = bUse; }
593 void SetEmbedFontScriptLatin(bool bUse) { mbEmbedFontScriptLatin = bUse; }
594 void SetEmbedFontScriptAsian(bool bUse) { mbEmbedFontScriptAsian = bUse; }
595 void SetEmbedFontScriptComplex(bool bUse) { mbEmbedFontScriptComplex = bUse; }
597 void SetImagePreferredDPI(sal_Int32 nValue) { mnImagePreferredDPI = nValue; }
598 sal_Int32 GetImagePreferredDPI() { return mnImagePreferredDPI; }
600 SC_DLLPUBLIC sal_uInt64 GetCellCount() const; // all cells
601 SC_DLLPUBLIC sal_uInt64 GetFormulaGroupCount() const; // all cells
602 sal_uInt64 GetCodeCount() const; // RPN-Code in formulas
603 DECL_LINK( GetUserDefinedColor, sal_uInt16, Color* );
604 // number formatter
605 public:
606 SC_DLLPUBLIC ScDocument( ScDocumentMode eMode = SCDOCMODE_DOCUMENT,
607 ScDocShell* pDocShell = nullptr );
608 SC_DLLPUBLIC ~ScDocument();
610 void SetName( const OUString& r ) { aDocName = r; }
611 const OUString& GetCodeName() const { return aDocCodeName; }
612 void SetCodeName( const OUString& r ) { aDocCodeName = r; }
613 const OUString& GetFileURL() const { return maFileURL; }
615 void GetDocStat( ScDocStat& rDocStat );
617 SC_DLLPUBLIC void InitDrawLayer( ScDocShell* pDocShell = nullptr );
619 ScInterpreterContext& GetNonThreadedContext() const
621 assert(!IsThreadedGroupCalcInProgress());
622 return maInterpreterContext;
624 // Uses thread_local.
625 ScInterpreterContext& GetThreadedContext() const
627 return IsThreadedGroupCalcInProgress() ? *maThreadSpecific.pContext : GetNonThreadedContext();
629 void SetupContextFromNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
630 void MergeContextBackIntoNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
631 void SetThreadedGroupCalcInProgress( bool set ) { (void)this; ScGlobal::bThreadedGroupCalcInProgress = set; }
632 bool IsThreadedGroupCalcInProgress() const { (void)this; return ScGlobal::bThreadedGroupCalcInProgress; }
634 SC_DLLPUBLIC sfx2::LinkManager* GetLinkManager();
635 SC_DLLPUBLIC const sfx2::LinkManager* GetLinkManager() const;
637 sc::DocumentLinkManager& GetDocLinkManager();
638 const sc::DocumentLinkManager& GetDocLinkManager() const;
640 SC_DLLPUBLIC const ScDocOptions& GetDocOptions() const;
641 SC_DLLPUBLIC void SetDocOptions( const ScDocOptions& rOpt );
642 SC_DLLPUBLIC const ScViewOptions& GetViewOptions() const;
643 SC_DLLPUBLIC void SetViewOptions( const ScViewOptions& rOpt );
644 void SetPrintOptions();
646 ScExtDocOptions* GetExtDocOptions() { return pExtDocOptions.get(); }
647 SC_DLLPUBLIC void SetExtDocOptions( std::unique_ptr<ScExtDocOptions> pNewOptions );
649 ScClipOptions* GetClipOptions() { return mpClipOptions.get(); }
650 void SetClipOptions(std::unique_ptr<ScClipOptions> pClipOptions);
652 SC_DLLPUBLIC void GetLanguage( LanguageType& rLatin, LanguageType& rCjk, LanguageType& rCtl ) const;
653 void SetLanguage( LanguageType eLatin, LanguageType eCjk, LanguageType eCtl );
655 void SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pData );
656 const ScConsolidateParam* GetConsolidateDlgData() const { return pConsolidateDlgData.get(); }
657 void SetEasyConditionalFormatDialogData(std::unique_ptr<ScConditionMode> pMode);
658 const ScConditionMode* GetEasyConditionalFormatDialogData() const { return pConditionalFormatDialogMode.get(); }
660 void Clear( bool bFromDestructor = false );
662 std::unique_ptr<ScFieldEditEngine> CreateFieldEditEngine();
663 void DisposeFieldEditEngine(std::unique_ptr<ScFieldEditEngine>& rpEditEngine);
666 * Get all range names that are local to each table. It only returns
667 * non-empty range name set.
669 SC_DLLPUBLIC void GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rRangeNames) const;
670 SC_DLLPUBLIC void SetAllRangeNames(const std::map<OUString, ScRangeName>& rRangeMap);
671 SC_DLLPUBLIC void GetRangeNameMap(std::map<OUString, ScRangeName*>& rRangeName);
672 SC_DLLPUBLIC ScRangeName* GetRangeName(SCTAB nTab) const;
673 SC_DLLPUBLIC ScRangeName* GetRangeName() const;
674 void SetRangeName(SCTAB nTab, std::unique_ptr<ScRangeName> pNew);
675 void SetRangeName( std::unique_ptr<ScRangeName> pNewRangeName );
676 bool IsAddressInRangeName( RangeNameScope eScope, const ScAddress& rAddress);
678 /** Find a named expression / range name in either global or a local scope.
679 @param nTab
680 If <0 search nIndex in global scope, if >=0 search nIndex in scope of nTab.
681 @param nIndex
682 Index of named expression / range name.
683 @return nullptr if indexed name not found.
685 ScRangeData* FindRangeNameBySheetAndIndex( SCTAB nTab, sal_uInt16 nIndex ) const;
687 /** Recursively find all named expressions that directly or indirectly
688 (nested) reference a given sheet, starting from a given named
689 expression nTokenTab/nTokenIndex.
691 Used to collect all named expressions/ranges that will need to be
692 copied along when copying sheets.
694 The different tab/sheets passed cater for the situation that a sheet is
695 copied and was already inserted and global names are already adjusted
696 but the sheet-local names of the shifted original sheet are not yet. If
697 no sheet was inserted and global and local names' references not
698 updated yet, then all 4 tab arguments would be identical.
700 @param nTokenTab
701 Tab/sheet on which to find the name, -1 if global scope.
702 For example obtained from ocName token.
704 @param nTokenIndex
705 Index of named expression. For example obtained from ocName token.
707 @param nGlobalRefTab
708 Tab to check if used in global names.
710 @param nLocalRefTab
711 Tab to check if used in sheet-local names.
713 @param nOldTokenTab
714 The original tab of the copied sheet, used as sheet-local
715 base position for relative references.
717 @param nOldTokenTabReplacement
718 The replacement to use for relative references if the name
719 encountered uses nOldTokenTab as base position.
721 @param bSameDoc
722 FALSE if collecting names for a sheet to be copied to another
723 document. Then all names encountered are considered to be
724 referencing the sheet. Else TRUE if collecting names to be
725 copied into the same document.
727 @param nRecursion
728 Recursion guard, initialize with 0.
730 bool FindRangeNamesReferencingSheet( sc::UpdatedRangeNames& rIndexes,
731 SCTAB nTokenTab, const sal_uInt16 nTokenIndex,
732 SCTAB nGlobalRefTab, SCTAB nLocalRefTab, SCTAB nOldTokenTab, SCTAB nOldTokenTabReplacement,
733 bool bSameDoc, int nRecursion ) const;
735 /** If necessary (name references sheet rOldPos.Tab()) copy and adjust
736 named expression/range from sheet-local to sheet-local, or global to
737 sheet-local if bGlobalNamesToLocal==true.
739 Also copies nested names and adjusts the ocName tokens of the calling name.
741 @param rSheet
742 On entry, the original sheet of the named expression/range, <0 global.
743 On return TRUE, the new sheet. Else unchanged.
745 @param rIndex
746 On entry, the original index of the named expression/range.
747 On return TRUE, the new index, or 0 if a new copied name couldn't be inserted. Else unchanged.
749 @param rpRangeData
750 On entry, the pointer to the original named expression/range.
751 On return TRUE, the pointer to the new copied name, or nullptr if hits happened.
753 @param rNewPos
754 New position of formula cell if called for that, else new base
755 position of a to be created new name adjusted for Tab.
756 rNewPos.nTab MUST point to the new sheet copied to.
758 @param rOldPos
759 Old position of formula cell if called for that, else base
760 position of the existing name adjusted for Tab.
761 rOldPos.nTab MUST point to the old sheet copied from.
763 @param bGlobalNamesToLocal
764 If TRUE, affected global names are copied to sheet-local names.
765 If FALSE, global names are copied to global names in another document.
767 @param bUsedByFormula
768 If TRUE, forces a global name to be affected/used.
769 If FALSE, a global name is only affected if it evaluates to be
770 referencing the sheet.
772 @return TRUE if copied and caller may need to evaluate rpRangeData and rSheet and rIndex.
773 FALSE if nothing to be done.
775 bool CopyAdjustRangeName( SCTAB& rSheet, sal_uInt16& rIndex, ScRangeData*& rpRangeData, ScDocument& rNewDoc,
776 const ScAddress& rNewPos, const ScAddress& rOldPos, const bool bGlobalNamesToLocal,
777 const bool bUsedByFormula ) const;
780 * Call this immediately before updating all named ranges.
782 SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate( const std::map<OUString, ScRangeName>& rRangeMap );
783 SC_DLLPUBLIC void PreprocessRangeNameUpdate();
784 SC_DLLPUBLIC void PreprocessDBDataUpdate();
786 * Call this immediately after updating named ranges.
788 SC_DLLPUBLIC void CompileHybridFormula();
791 * Insert a new named expression to the global scope.
793 * @param rName name for the expression.
794 * @param rPos base position.
795 * @param rExpr formula expression to be associated with the name. The
796 * current grammar is used to compile this expression.
798 * @return true if inserted successfully, false otherwise.
800 bool InsertNewRangeName( const OUString& rName, const ScAddress& rPos, const OUString& rExpr );
803 * Insert a new named expression to a sheet-local scope.
805 * @param nTab sheet for local scope.
806 * @param rName name for the expression.
807 * @param rPos base position.
808 * @param rExpr formula expression to be associated with the name. The
809 * current grammar is used to compile this expression.
811 * @return true if inserted successfully, false otherwise.
813 bool InsertNewRangeName( SCTAB nTab, const OUString& rName, const ScAddress& rPos, const OUString& rExpr );
815 /** Obtain the sheet separator corresponding to the document's grammar.
817 @return '.' for our own grammars, '!' for Excel grammars.
819 SC_DLLPUBLIC sal_Unicode GetSheetSeparator() const;
821 SCTAB GetMaxTableNumber() const { return static_cast<SCTAB>(maTabs.size()) - 1; }
823 ScRangePairList* GetColNameRanges() { return xColNameRanges.get(); }
824 ScRangePairList* GetRowNameRanges() { return xRowNameRanges.get(); }
825 ScRangePairListRef& GetColNameRangesRef() { return xColNameRanges; }
826 ScRangePairListRef& GetRowNameRangesRef() { return xRowNameRanges; }
828 SC_DLLPUBLIC SCCOL ClampToAllocatedColumns(SCTAB nTab, SCCOL nCol) const;
829 SC_DLLPUBLIC SCCOL GetAllocatedColumnsCount(SCTAB nTab) const;
831 SC_DLLPUBLIC ScDBCollection* GetDBCollection() const { return pDBCollection.get();}
832 void SetDBCollection( std::unique_ptr<ScDBCollection> pNewDBCollection,
833 bool bRemoveAutoFilter = false );
834 const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const;
835 ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion);
836 SC_DLLPUBLIC const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
837 SC_DLLPUBLIC ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
838 void RefreshDirtyTableColumnNames();
839 SC_DLLPUBLIC sc::ExternalDataMapper& GetExternalDataMapper();
841 SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock( const ScRange& rBlock, OUString& rName,
842 bool* pSheetLocal = nullptr ) const;
844 SC_DLLPUBLIC bool HasPivotTable() const;
845 SC_DLLPUBLIC ScDPCollection* GetDPCollection();
846 SC_DLLPUBLIC const ScDPCollection* GetDPCollection() const;
847 SC_DLLPUBLIC ScDPObject* GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
848 SC_DLLPUBLIC ScDPObject* GetDPAtCursor(ScAddress const& rAddress) const
850 return GetDPAtCursor(rAddress.Col(), rAddress.Row(), rAddress.Tab());
852 SC_DLLPUBLIC bool HasDataPilotAtPosition(ScAddress const& rAddress) const
854 return GetDPAtCursor(rAddress) != nullptr;
856 ScDPObject* GetDPAtBlock( const ScRange& rBlock ) const;
858 void StopTemporaryChartLock();
860 void EnsureGraphicNames();
862 SdrObject* GetObjectAtPoint( SCTAB nTab, const Point& rPos );
863 bool HasChartAtPoint( SCTAB nTab, const Point& rPos, OUString& rName );
865 css::uno::Reference< css::chart2::XChartDocument > GetChartByName( std::u16string_view rChartName );
867 SC_DLLPUBLIC void GetChartRanges( std::u16string_view rChartName, std::vector< ScRangeList >& rRanges, const ScDocument& rSheetNameDoc );
868 void SetChartRanges( std::u16string_view rChartName, const std::vector< ScRangeList >& rRanges );
870 void UpdateChartArea( const OUString& rChartName, const ScRange& rNewArea,
871 bool bColHeaders, bool bRowHeaders, bool bAdd );
872 void UpdateChartArea( const OUString& rChartName,
873 const ScRangeListRef& rNewList,
874 bool bColHeaders, bool bRowHeaders, bool bAdd );
875 void GetOldChartParameters( std::u16string_view rName,
876 ScRangeList& rRanges, bool& rColHeaders, bool& rRowHeaders );
877 css::uno::Reference<
878 css::embed::XEmbeddedObject >
879 FindOleObjectByName( std::u16string_view rName );
881 SC_DLLPUBLIC void MakeTable( SCTAB nTab,bool _bNeedsNameCheck = true );
883 SCTAB GetVisibleTab() const { return nVisibleTab; }
884 SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab) { nVisibleTab = nTab; }
885 SCCOL GetPosLeft() const { return nPosLeft; }
886 SC_DLLPUBLIC void SetPosLeft(SCCOL nCol) { nPosLeft = nCol; }
887 SCROW GetPosTop() const { return nPosTop; }
888 SC_DLLPUBLIC void SetPosTop(SCROW nRow) { nPosTop = nRow; }
890 SC_DLLPUBLIC bool HasTable( SCTAB nTab ) const;
891 SC_DLLPUBLIC bool GetHashCode( SCTAB nTab, sal_Int64& rHashCode) const;
892 SC_DLLPUBLIC bool GetName( SCTAB nTab, OUString& rName ) const;
893 SC_DLLPUBLIC bool GetCodeName( SCTAB nTab, OUString& rName ) const;
894 SC_DLLPUBLIC bool SetCodeName( SCTAB nTab, const OUString& rName );
895 SC_DLLPUBLIC bool GetTable( const OUString& rName, SCTAB& rTab ) const;
896 SC_DLLPUBLIC SCCOL MaxCol() const { return mxSheetLimits->mnMaxCol; }
897 SC_DLLPUBLIC SCROW MaxRow() const { return mxSheetLimits->mnMaxRow; }
898 SC_DLLPUBLIC SCCOL GetMaxColCount() const { return mxSheetLimits->GetMaxColCount(); }
899 SC_DLLPUBLIC SCROW GetMaxRowCount() const { return mxSheetLimits->GetMaxRowCount(); }
900 SC_DLLPUBLIC OUString MaxRowAsString() const { return mxSheetLimits->MaxRowAsString(); }
901 SC_DLLPUBLIC OUString MaxColAsString() const { return mxSheetLimits->MaxColAsString(); }
902 ScSheetLimits& GetSheetLimits() const { return *mxSheetLimits; }
903 [[nodiscard]] bool ValidCol(SCCOL nCol) const { return ::ValidCol(nCol, mxSheetLimits->mnMaxCol); }
904 [[nodiscard]] bool ValidRow(SCROW nRow) const { return ::ValidRow(nRow, mxSheetLimits->mnMaxRow); }
905 [[nodiscard]] bool ValidColRow(SCCOL nCol, SCROW nRow) const { return ::ValidColRow(nCol, nRow, MaxCol(), MaxRow()); }
906 [[nodiscard]] bool ValidColRowTab(SCCOL nCol, SCROW nRow, SCTAB nTab) const { return ::ValidColRowTab(nCol, nRow, nTab, MaxCol(), MaxRow()); }
907 [[nodiscard]] bool ValidRange(const ScRange& rRange) const { return ::ValidRange(rRange, MaxCol(), MaxRow()); }
908 [[nodiscard]] bool ValidAddress(const ScAddress& rAddress) const { return ::ValidAddress(rAddress, MaxCol(), MaxRow()); }
909 [[nodiscard]] SCCOL SanitizeCol( SCCOL nCol ) const { return ::SanitizeCol(nCol, MaxCol()); }
910 [[nodiscard]] SCROW SanitizeRow( SCROW nRow ) const { return ::SanitizeRow(nRow, MaxRow()); }
912 SC_DLLPUBLIC std::vector<OUString> GetAllTableNames() const;
914 OUString GetCopyTabName(SCTAB nTab) const;
916 SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, std::unique_ptr<ScDBData> pDBData);
917 SC_DLLPUBLIC ScDBData* GetAnonymousDBData(SCTAB nTab);
919 /** One document global anonymous database range for temporary operations,
920 used if the corresponding sheet-local anonymous database range is
921 already used with AutoFilter and range differs. Not stored in document
922 files. */
923 SC_DLLPUBLIC void SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData);
924 SC_DLLPUBLIC ScDBData* GetAnonymousDBData();
926 SC_DLLPUBLIC SCTAB GetTableCount() const;
927 SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; }
929 SC_DLLPUBLIC ScDocProtection* GetDocProtection() const;
930 SC_DLLPUBLIC void SetDocProtection(const ScDocProtection* pProtect);
931 SC_DLLPUBLIC bool IsDocProtected() const;
932 bool IsDocEditable() const;
933 SC_DLLPUBLIC bool IsTabProtected( SCTAB nTab ) const;
934 SC_DLLPUBLIC const ScTableProtection* GetTabProtection(SCTAB nTab) const;
935 SC_DLLPUBLIC void SetTabProtection(SCTAB nTab, const ScTableProtection* pProtect);
936 void CopyTabProtection(SCTAB nTabSrc, SCTAB nTabDest);
938 void LockTable(SCTAB nTab);
939 void UnlockTable(SCTAB nTab);
941 bool IsBlockEditable( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
942 SCCOL nEndCol, SCROW nEndRow,
943 bool* pOnlyNotBecauseOfMatrix = nullptr,
944 bool bNoMatrixAtAll = false ) const;
945 bool IsSelectionEditable( const ScMarkData& rMark,
946 bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
947 bool HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nStartRow,
948 SCCOL nEndCol, SCROW nEndRow,
949 const ScMarkData& rMark ) const;
951 bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCTAB nTab, SCCOLROW nStart, SCCOLROW nEnd ) const;
952 bool IsEditActionAllowed( sc::ColRowEditAction eAction, const ScMarkData& rMark, SCCOLROW nStart, SCCOLROW nEnd ) const;
954 SC_DLLPUBLIC bool GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix );
956 bool IsEmbedded() const { return bIsEmbedded;}
957 void GetEmbedded( ScRange& rRange ) const;
958 void SetEmbedded( const ScRange& rRange );
959 void ResetEmbedded();
960 tools::Rectangle GetEmbeddedRect() const; // 1/100 mm
961 void SetEmbedded( SCTAB nTab, const tools::Rectangle& rRect ); // from VisArea (1/100 mm)
963 static SC_DLLPUBLIC bool ValidTabName( const OUString& rName );
965 SC_DLLPUBLIC bool ValidNewTabName( const OUString& rName ) const;
966 SC_DLLPUBLIC void CreateValidTabName(OUString& rName) const;
967 SC_DLLPUBLIC void CreateValidTabNames(std::vector<OUString>& aNames, SCTAB nCount) const;
969 void AppendTabOnLoad(const OUString& rName);
970 void SetTabNameOnLoad(SCTAB nTab, const OUString& rName);
971 void InvalidateStreamOnSave();
973 SC_DLLPUBLIC bool InsertTab( SCTAB nPos, const OUString& rName,
974 bool bExternalDocument = false, bool bUndoDeleteTab = false );
976 SC_DLLPUBLIC bool InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
977 bool bNamesValid = false );
978 SC_DLLPUBLIC bool DeleteTabs( SCTAB nTab, SCTAB nSheets );
979 SC_DLLPUBLIC bool DeleteTab( SCTAB nTab );
980 SC_DLLPUBLIC bool RenameTab( SCTAB nTab, const OUString& rName,
981 bool bExternalDocument = false );
982 bool MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress = nullptr );
983 SC_DLLPUBLIC bool CopyTab( SCTAB nOldPos, SCTAB nNewPos,
984 const ScMarkData* pOnlyMarked = nullptr );
985 SC_DLLPUBLIC bool TransferTab(ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos,
986 bool bInsertNew = true,
987 bool bResultsOnly = false );
988 SC_DLLPUBLIC void TransferDrawPage(const ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos);
989 SC_DLLPUBLIC void SetVisible( SCTAB nTab, bool bVisible );
990 SC_DLLPUBLIC bool IsVisible( SCTAB nTab ) const;
991 bool IsStreamValid( SCTAB nTab ) const;
992 void SetStreamValid( SCTAB nTab, bool bSet, bool bIgnoreLock = false );
993 void LockStreamValid( bool bLock );
994 bool IsStreamValidLocked() const { return mbStreamValidLocked; }
995 bool IsPendingRowHeights( SCTAB nTab ) const;
996 void SetPendingRowHeights( SCTAB nTab, bool bSet );
997 sal_uInt16 GetSheetOptimalMinRowHeight(SCTAB nTab) const;
998 SC_DLLPUBLIC void SetLayoutRTL( SCTAB nTab, bool bRTL, ScObjectHandling eObjectHandling = ScObjectHandling::RecalcPosMode);
999 SC_DLLPUBLIC bool IsLayoutRTL( SCTAB nTab ) const;
1000 SC_DLLPUBLIC bool IsNegativePage( SCTAB nTab ) const;
1001 SC_DLLPUBLIC void SetScenario( SCTAB nTab, bool bFlag );
1002 SC_DLLPUBLIC bool IsScenario( SCTAB nTab ) const;
1003 SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString& rComment,
1004 Color& rColor, ScScenarioFlags &rFlags) const;
1005 SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString& rComment,
1006 const Color& rColor, ScScenarioFlags nFlags);
1007 SC_DLLPUBLIC Color GetTabBgColor( SCTAB nTab ) const;
1008 SC_DLLPUBLIC void SetTabBgColor( SCTAB nTab, const Color& rColor );
1009 SC_DLLPUBLIC bool IsDefaultTabBgColor( SCTAB nTab ) const;
1010 void GetScenarioFlags(SCTAB nTab, ScScenarioFlags &rFlags) const;
1011 SC_DLLPUBLIC bool IsActiveScenario( SCTAB nTab ) const;
1012 SC_DLLPUBLIC void SetActiveScenario( SCTAB nTab, bool bActive ); // only for Undo etc.
1013 SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const;
1014 SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const { return eGrammar;}
1015 SC_DLLPUBLIC void SetGrammar( formula::FormulaGrammar::Grammar eGram );
1016 SC_DLLPUBLIC ScLinkMode GetLinkMode( SCTAB nTab ) const;
1017 bool IsLinked( SCTAB nTab ) const;
1018 SC_DLLPUBLIC OUString GetLinkDoc( SCTAB nTab ) const;
1019 OUString GetLinkFlt( SCTAB nTab ) const;
1020 OUString GetLinkOpt( SCTAB nTab ) const;
1021 SC_DLLPUBLIC OUString GetLinkTab( SCTAB nTab ) const;
1022 sal_uLong GetLinkRefreshDelay( SCTAB nTab ) const;
1023 void SetLink( SCTAB nTab, ScLinkMode nMode, const OUString& rDoc,
1024 const OUString& rFilter, const OUString& rOptions,
1025 const OUString& rTabName, sal_uLong nRefreshDelay );
1026 bool HasLink( std::u16string_view rDoc,
1027 std::u16string_view rFilter, std::u16string_view rOptions ) const;
1028 SC_DLLPUBLIC bool LinkExternalTab( SCTAB& nTab, const OUString& aDocTab,
1029 const OUString& aFileName,
1030 const OUString& aTabName );
1032 bool HasExternalRefManager() const { return bool(pExternalRefMgr); }
1033 SC_DLLPUBLIC ScExternalRefManager* GetExternalRefManager() const;
1034 bool IsInExternalReferenceMarking() const;
1035 void MarkUsedExternalReferences();
1036 bool MarkUsedExternalReferences( const ScTokenArray& rArr, const ScAddress& rPos );
1038 /** Returns the pool containing external formula parsers. Creates the pool
1039 on first call. */
1040 ScFormulaParserPool& GetFormulaParserPool() const;
1042 bool HasAreaLinks() const;
1043 void UpdateExternalRefLinks(weld::Window* pWin);
1044 void UpdateAreaLinks();
1046 // originating DDE links
1047 void IncInDdeLinkUpdate() { if ( nInDdeLinkUpdate < 255 ) ++nInDdeLinkUpdate; }
1048 void DecInDdeLinkUpdate() { if ( nInDdeLinkUpdate ) --nInDdeLinkUpdate; }
1049 bool IsInDdeLinkUpdate() const { return nInDdeLinkUpdate != 0; }
1051 SC_DLLPUBLIC void CopyDdeLinks( ScDocument& rDestDoc ) const;
1053 /** Tries to find a DDE link with the specified connection data.
1054 @param rnDdePos (out-param) Returns the index of the DDE link (does not include other links from link manager).
1055 @return true = DDE link found, rnDdePos valid. */
1056 SC_DLLPUBLIC bool FindDdeLink( std::u16string_view rAppl, std::u16string_view rTopic,
1057 std::u16string_view rItem, sal_uInt8 nMode, size_t& rnDdePos );
1059 /** Returns the connection data of the specified DDE link.
1060 @param nDdePos Index of the DDE link (does not include other links from link manager).
1061 @param rAppl (out-param) The application name.
1062 @param rTopic (out-param) The DDE topic.
1063 @param rItem (out-param) The DDE item.
1064 @return true = DDE link found, out-parameters valid. */
1065 bool GetDdeLinkData( size_t nDdePos, OUString& rAppl, OUString& rTopic, OUString& rItem ) const;
1066 /** Returns the link mode of the specified DDE link.
1067 @param nDdePos Index of the DDE link (does not include other links from link manager).
1068 @param rnMode (out-param) The link mode of the specified DDE link.
1069 @return true = DDE link found, rnMode valid. */
1070 bool GetDdeLinkMode( size_t nDdePos, sal_uInt8& rnMode ) const;
1071 /** Returns the result matrix of the specified DDE link.
1072 @param nDdePos Index of the DDE link (does not include other links from link manager).
1073 @return The result matrix, if the DDE link has been found, 0 otherwise. */
1074 SC_DLLPUBLIC const ScMatrix* GetDdeLinkResultMatrix( size_t nDdePos ) const;
1076 /** Tries to find a DDE link or creates a new, if not extant.
1077 @param pResults If not 0, sets the matrix as DDE link result matrix (also for existing links).
1078 @return true = DDE link found; false = Unpredictable error occurred, no DDE link created. */
1079 SC_DLLPUBLIC bool CreateDdeLink( const OUString& rAppl, const OUString& rTopic, const OUString& rItem, sal_uInt8 nMode, const ScMatrixRef& pResults );
1080 /** Sets a result matrix for the specified DDE link.
1081 @param nDdePos Index of the DDE link (does not include other links from link manager).
1082 @param pResults The array containing all results of the DDE link (intrusive-ref-counted, do not delete).
1083 @return true = DDE link found and matrix set. */
1084 bool SetDdeLinkResultMatrix( size_t nDdePos, const ScMatrixRef& pResults );
1086 SfxBindings* GetViewBindings();
1087 ScDocShell* GetDocumentShell() const { return mpShell; }
1088 SC_DLLPUBLIC ScDrawLayer* GetDrawLayer() { return mpDrawLayer.get(); }
1089 SC_DLLPUBLIC const ScDrawLayer* GetDrawLayer() const { return mpDrawLayer.get(); }
1090 SfxBroadcaster* GetDrawBroadcaster(); // to avoid header
1091 void BeginDrawUndo();
1093 void BeginUnoRefUndo();
1094 bool HasUnoRefUndo() const { return ( pUnoRefUndoList != nullptr ); }
1095 [[nodiscard]]
1096 std::unique_ptr<ScUnoRefList> EndUnoRefUndo(); // must be deleted by caller!
1097 sal_Int64 GetNewUnoId() { return ++nUnoObjectId; }
1098 void AddUnoRefChange( sal_Int64 nId, const ScRangeList& rOldRanges );
1100 static bool IsChart( const SdrObject* pObject );
1102 void UpdateChartRef( UpdateRefMode eUpdateRefMode,
1103 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1104 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1105 SCCOL nDx, SCROW nDy, SCTAB nDz );
1106 //! only assigns the new RangeList, no ChartListener or the like
1107 void SetChartRangeList( std::u16string_view rChartName,
1108 const ScRangeListRef& rNewRangeListRef );
1110 void StartAnimations( SCTAB nTab );
1112 bool HasBackgroundDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const;
1113 bool HasAnyDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const;
1115 const ScSheetEvents* GetSheetEvents( SCTAB nTab ) const;
1116 void SetSheetEvents( SCTAB nTab, std::unique_ptr<ScSheetEvents> pNew );
1117 bool HasSheetEventScript( SCTAB nTab, ScSheetEventId nEvent, bool bWithVbaEvents = false ) const;
1118 bool HasAnySheetEventScript( ScSheetEventId nEvent, bool bWithVbaEvents = false ) const; // on any sheet
1120 bool HasAnyCalcNotification() const;
1121 bool HasCalcNotification( SCTAB nTab ) const;
1122 void SetCalcNotification( SCTAB nTab );
1123 void ResetCalcNotifications();
1125 SC_DLLPUBLIC ScOutlineTable* GetOutlineTable( SCTAB nTab, bool bCreate = false );
1126 bool SetOutlineTable( SCTAB nTab, const ScOutlineTable* pNewOutline );
1128 void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow,
1129 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1131 bool DoSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
1132 void RemoveSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
1133 bool TestRemoveSubTotals( SCTAB nTab, const ScSubTotalParam& rParam );
1134 bool HasSubTotalCells( const ScRange& rRange );
1136 SC_DLLPUBLIC void EnsureTable( SCTAB nTab );
1138 // return TRUE = number format is set
1139 SC_DLLPUBLIC bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
1140 const ScSetStringParam * pParam = nullptr );
1141 SC_DLLPUBLIC bool SetString( const ScAddress& rPos, const OUString& rString,
1142 const ScSetStringParam* pParam = nullptr );
1145 * This method manages the lifecycle of the passed edit text object. When
1146 * the text is successfully inserted, the cell takes over the ownership of
1147 * the text object. If not, the text object gets deleted.
1149 * <p>The caller must ensure that the passed edit text object <i>uses the
1150 * SfxItemPool instance returned from ScDocument::GetEditPool()</i>.
1151 * This is very important.</p>
1153 SC_DLLPUBLIC bool SetEditText( const ScAddress& rPos, std::unique_ptr<EditTextObject> pEditText );
1154 void SetEditText( const ScAddress& rPos, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
1155 SC_DLLPUBLIC void SetEditText( const ScAddress& rPos, const OUString& rStr );
1156 SC_DLLPUBLIC SCROW GetFirstEditTextRow( const ScRange& rRange ) const;
1159 * Call this if you are not sure whether to put this as an edit text or a
1160 * simple text.
1162 SC_DLLPUBLIC void SetTextCell( const ScAddress& rPos, const OUString& rStr );
1163 void SetEmptyCell( const ScAddress& rPos );
1164 SC_DLLPUBLIC void SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal );
1165 SC_DLLPUBLIC void SetValue( const ScAddress& rPos, double fVal );
1166 void SetValues( const ScAddress& rPos, const std::vector<double>& rVals );
1167 void SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError);
1168 SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const ScTokenArray& rArray );
1169 SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const OUString& rFormula,
1170 formula::FormulaGrammar::Grammar eGram );
1173 * Set formula cell, and transfer its ownership to the document. This call
1174 * attempts to group the passed formula cell with the adjacent cells or
1175 * cell groups if appropriate.
1177 * @return pCell if it was successfully inserted, NULL otherwise. pCell
1178 * is deleted automatically on failure to insert.
1180 SC_DLLPUBLIC ScFormulaCell* SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell );
1181 bool SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCell*>& rCells );
1184 * Check if there is at least one formula cell in specified range.
1186 bool HasFormulaCell( const ScRange& rRange ) const;
1187 SC_DLLPUBLIC void InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
1188 SCCOL nCol2, SCROW nRow2,
1189 const ScMarkData& rMark,
1190 const OUString& rFormula,
1191 const ScTokenArray* p = nullptr,
1192 const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT );
1193 SC_DLLPUBLIC void InsertTableOp(const ScTabOpParam& rParam, // multi-operation
1194 SCCOL nCol1, SCROW nRow1,
1195 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark);
1197 SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab,
1198 const ScInterpreterContext* pContext = nullptr ) const;
1199 SC_DLLPUBLIC OUString GetString( const ScAddress& rPos,
1200 const ScInterpreterContext* pContext = nullptr ) const;
1203 * Return a pointer to the double value stored in value cell.
1205 * @param rPos cell position
1207 * @return pointer to the double value stored in a numeric cell, or NULL
1208 * if the cell at specified position is not a numeric cell.
1210 SC_DLLPUBLIC double* GetValueCell( const ScAddress& rPos );
1212 SC_DLLPUBLIC svl::SharedStringPool& GetSharedStringPool();
1213 const svl::SharedStringPool& GetSharedStringPool() const;
1215 svl::SharedString GetSharedString( const ScAddress& rPos ) const;
1217 std::shared_ptr<sc::FormulaGroupContext>& GetFormulaGroupContext();
1218 void DiscardFormulaGroupContext();
1219 void BlockFormulaGroupContextDiscard( bool block )
1220 { mbFormulaGroupCxtBlockDiscard = block; }
1222 // Note that if pShared is set and a value is returned that way, the returned OUString is empty.
1223 SC_DLLPUBLIC OUString GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, bool bForceSystemLocale = false ) const;
1224 FormulaError GetStringForFormula( const ScAddress& rPos, OUString& rString );
1225 SC_DLLPUBLIC double GetValue( const ScAddress& rPos ) const;
1226 SC_DLLPUBLIC double GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1227 SC_DLLPUBLIC const EditTextObject* GetEditText( const ScAddress& rPos ) const;
1228 void RemoveEditTextCharAttribs( const ScAddress& rPos, const ScPatternAttr& rAttr );
1229 SC_DLLPUBLIC double RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScInterpreterContext* pContext = nullptr ) const;
1230 SC_DLLPUBLIC sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1231 sal_uInt32 GetNumberFormat( const ScRange& rRange ) const;
1232 SC_DLLPUBLIC sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& ) const;
1233 SC_DLLPUBLIC void SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberFormat );
1235 void GetNumberFormatInfo( const ScInterpreterContext& rContext, SvNumFormatType& nType, sal_uInt32& nIndex, const ScAddress& rPos ) const;
1236 SC_DLLPUBLIC const ScFormulaCell* GetFormulaCell( const ScAddress& rPos ) const;
1237 SC_DLLPUBLIC ScFormulaCell* GetFormulaCell( const ScAddress& rPos );
1238 SC_DLLPUBLIC OUString GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1239 SC_DLLPUBLIC CellType GetCellType( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1240 SC_DLLPUBLIC CellType GetCellType( const ScAddress& rPos ) const;
1242 SC_DLLPUBLIC bool HasData( SCCOL nCol, SCROW nRow, SCTAB nTab );
1243 SC_DLLPUBLIC bool HasStringData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1244 SC_DLLPUBLIC bool HasValueData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1245 SC_DLLPUBLIC bool HasValueData( const ScAddress& rPos ) const;
1246 bool HasStringCells( const ScRange& rRange ) const;
1248 /** Returns true, if there is any data to create a selection list for rPos. */
1249 bool HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1250 bool HasValidationData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1253 * Check if the specified range contains either: 1) one non-empty cell, 2)
1254 * more than one non-empty cells, or 3) totally empty. In case the range
1255 * contains at least one non-empty cell, specify the position of the first
1256 * non-empty cell.
1258 sc::MultiDataCellState HasMultipleDataCells( const ScRange& rRange ) const;
1260 // Spaklines
1261 /** Returns sparkline at the address if it exists */
1262 SC_DLLPUBLIC std::shared_ptr<sc::Sparkline> GetSparkline(ScAddress const & rPosition);
1263 SC_DLLPUBLIC bool HasSparkline(ScAddress const & rPosition);
1264 SC_DLLPUBLIC sc::Sparkline* CreateSparkline(ScAddress const & rPosition, std::shared_ptr<sc::SparklineGroup> const& pSparklineGroup);
1265 SC_DLLPUBLIC sc::SparklineList* GetSparklineList(SCTAB nTab);
1266 SC_DLLPUBLIC bool DeleteSparkline(ScAddress const& rPosition);
1269 * Returns true if the whole range covers one and the same sparkline
1270 * group and returns the group via out parameter
1272 SC_DLLPUBLIC bool GetSparklineGroupInRange(ScRange const& rRange, std::shared_ptr<sc::SparklineGroup>& rGroup);
1273 SC_DLLPUBLIC bool HasOneSparklineGroup(ScRange const& rRange);
1274 SC_DLLPUBLIC std::shared_ptr<sc::SparklineGroup> SearchSparklineGroup(tools::Guid const& rGuid);
1276 // Notes
1277 SC_DLLPUBLIC ScPostIt* GetNote(const ScAddress& rPos);
1278 SC_DLLPUBLIC ScPostIt* GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
1279 void SetNote(const ScAddress& rPos, std::unique_ptr<ScPostIt> pNote);
1280 void SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, std::unique_ptr<ScPostIt> pNote);
1281 SC_DLLPUBLIC bool HasNote(const ScAddress& rPos) const;
1282 bool HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
1283 bool HasNote(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow) const;
1284 SC_DLLPUBLIC bool HasColNotes(SCCOL nCol, SCTAB nTab) const;
1285 SC_DLLPUBLIC bool HasTabNotes(SCTAB nTab) const;
1286 bool HasNotes() const;
1287 SC_DLLPUBLIC std::unique_ptr<ScPostIt> ReleaseNote(const ScAddress& rPos);
1288 SC_DLLPUBLIC ScPostIt* GetOrCreateNote(const ScAddress& rPos);
1289 SC_DLLPUBLIC ScPostIt* CreateNote(const ScAddress& rPos);
1290 size_t GetNoteCount( SCTAB nTab, SCCOL nCol ) const;
1293 * Ensure that all note objects have an associated sdr object. The export
1294 * code uses sdr objects to export note data.
1296 void CreateAllNoteCaptions();
1297 void ForgetNoteCaptions( const ScRangeList& rRanges, bool bPreserveData );
1298 CommentCaptionState GetAllNoteCaptionsState( const ScRangeList& rRanges);
1300 ScAddress GetNotePosition( size_t nIndex ) const;
1301 ScAddress GetNotePosition( size_t nIndex, SCTAB nTab ) const;
1302 SCROW GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const;
1304 SC_DLLPUBLIC void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
1305 SC_DLLPUBLIC void GetAllNoteEntries( SCTAB nTab, std::vector<sc::NoteEntry>& rNotes ) const;
1306 void GetNotesInRange( const ScRangeList& rRange, std::vector<sc::NoteEntry>& rNotes ) const;
1308 bool ContainsNotesInRange( const ScRangeList& rRange ) const;
1310 SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab);
1312 bool IsMerged( const ScAddress& rPos ) const;
1314 void ExtendMergeSel( SCCOL nStartCol, SCROW nStartRow,
1315 SCCOL& rEndCol, SCROW& rEndRow, const ScMarkData& rMark,
1316 bool bRefresh = false );
1317 SC_DLLPUBLIC bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
1318 SCCOL& rEndCol, SCROW& rEndRow, SCTAB nTab,
1319 bool bRefresh = false );
1320 bool ExtendMerge( ScRange& rRange, bool bRefresh = false );
1321 SC_DLLPUBLIC void ExtendTotalMerge( ScRange& rRange ) const;
1322 SC_DLLPUBLIC void ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow,
1323 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const;
1324 SC_DLLPUBLIC void ExtendOverlapped( ScRange& rRange ) const;
1326 bool RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow,
1327 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1329 SC_DLLPUBLIC void DoMergeContents( SCCOL nStartCol, SCROW nStartRow,
1330 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1331 SC_DLLPUBLIC void DoEmptyBlock( SCCOL nStartCol, SCROW nStartRow,
1332 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1333 // without checking:
1334 SC_DLLPUBLIC void DoMerge( SCCOL nStartCol, SCROW nStartRow,
1335 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bDeleteCaptions = true );
1336 void RemoveMerge( SCCOL nCol, SCROW nRow, SCTAB nTab );
1338 // This also includes e.g. notes. Use IsEmptyData() for cell data only.
1339 bool IsBlockEmpty( SCCOL nStartCol, SCROW nStartRow,
1340 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const;
1341 bool IsPrintEmpty( SCCOL nStartCol, SCROW nStartRow,
1342 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1343 bool bLeftIsEmpty = false,
1344 ScRange* pLastRange = nullptr,
1345 tools::Rectangle* pLastMM = nullptr ) const;
1347 void SkipOverlapped( SCCOL& rCol, SCROW& rRow, SCTAB nTab ) const;
1348 bool IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1349 bool IsVerOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab,
1350 SCROW* nStartRow = nullptr, SCROW* nEndRow = nullptr ) const;
1352 SC_DLLPUBLIC bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1353 SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask ) const;
1354 SC_DLLPUBLIC bool HasAttrib( const ScRange& rRange, HasAttrFlags nMask ) const;
1355 bool HasAttrib( SCCOL nCol, SCROW nRow, SCTAB nTab, HasAttrFlags nMask,
1356 SCROW* nStartRow = nullptr, SCROW* nEndRow = nullptr ) const;
1358 SC_DLLPUBLIC void GetBorderLines( SCCOL nCol, SCROW nRow, SCTAB nTab,
1359 const ::editeng::SvxBorderLine** ppLeft,
1360 const ::editeng::SvxBorderLine** ppTop,
1361 const ::editeng::SvxBorderLine** ppRight,
1362 const ::editeng::SvxBorderLine** ppBottom ) const;
1364 void ResetChanged( const ScRange& rRange );
1366 void CheckVectorizationState();
1367 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
1368 void SetDirty( const ScRange&, bool bIncludeEmptyCells );
1369 void SetTableOpDirty( const ScRange& ); // for Interpreter TableOp
1370 void InterpretDirtyCells( const ScRangeList& rRanges );
1371 // Interprets cells that have NeedsInterpret(), i.e. the same like calling MaybeInterpret() on them.
1372 // Returns false if some couldn't be interpreted (i.e. they still have NeedsInterpret()).
1373 // Useful to ensure that the given cells will not need interpreting.
1374 bool InterpretCellsIfNeeded( const ScRangeList& rRanges );
1375 SC_DLLPUBLIC void CalcAll();
1376 SC_DLLPUBLIC void CalcAfterLoad( bool bStartListening = true );
1377 void CompileAll();
1378 void CompileXML();
1381 * Re-compile formula cells with error.
1383 * @param nErrCode specified error code to match. Only those cells with
1384 * this error code will be re-compiled. If this value is
1385 * 0, cells with any error values will be re-compiled.
1387 * @return true if at least one cell is re-compiled, false if no cells are
1388 * re-compiled.
1390 bool CompileErrorCells(FormulaError nErrCode);
1392 ScAutoNameCache* GetAutoNameCache() { return pAutoNameCache.get(); }
1393 void SetPreviewFont( std::unique_ptr<SfxItemSet> pFontSet );
1394 SfxItemSet* GetPreviewFont() { return pPreviewFont.get(); }
1395 SfxItemSet* GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab );
1396 const ScMarkData& GetPreviewSelection() const { return maPreviewSelection; }
1397 void SetPreviewSelection( const ScMarkData& rSel );
1398 ScStyleSheet* GetPreviewCellStyle() { return pPreviewCellStyle; }
1399 ScStyleSheet* GetPreviewCellStyle( SCCOL nCol, SCROW nRow, SCTAB nTab );
1400 void SetPreviewCellStyle( ScStyleSheet* pStyle ) { pPreviewCellStyle = pStyle; }
1401 SC_DLLPUBLIC void SetAutoNameCache( std::unique_ptr<ScAutoNameCache> pCache );
1403 /** Creates a ScLookupCache cache for the range if it
1404 doesn't already exist. */
1405 ScLookupCache & GetLookupCache( const ScRange & rRange, ScInterpreterContext* pContext );
1406 ScSortedRangeCache & GetSortedRangeCache( const ScRange & rRange, const ScQueryParam& param,
1407 ScInterpreterContext* pContext, sal_uInt8 nSortedBinarySearch = 0x00 );
1408 /** Only ScLookupCache dtor uses RemoveLookupCache(), do
1409 not use elsewhere! */
1410 void RemoveLookupCache( ScLookupCache & rCache );
1411 void RemoveSortedRangeCache( ScSortedRangeCache & rCache );
1412 /** Zap all caches. */
1413 void ClearLookupCaches();
1415 // calculate automatically
1416 SC_DLLPUBLIC void SetAutoCalc( bool bNewAutoCalc );
1417 SC_DLLPUBLIC bool GetAutoCalc() const { return bAutoCalc; }
1418 // calculate automatically in/from/for ScDocShell disabled
1419 void SetAutoCalcShellDisabled( bool bNew ) { bAutoCalcShellDisabled = bNew; }
1420 bool IsAutoCalcShellDisabled() const { return bAutoCalcShellDisabled; }
1421 // ForcedFormulas are to be calculated
1422 void SetForcedFormulaPending( bool bNew ) { bForcedFormulaPending = bNew; }
1423 bool IsForcedFormulaPending() const { return bForcedFormulaPending; }
1424 // if CalcFormulaTree() is currently running
1425 bool IsCalculatingFormulaTree() const { return bCalculatingFormulaTree; }
1426 /// If set, joining cells into shared formula groups will be delayed until reset again
1427 /// (RegroupFormulaCells() will be called as needed).
1428 void DelayFormulaGrouping( bool delay );
1429 bool IsDelayedFormulaGrouping() const { return bool(pDelayedFormulaGrouping); }
1430 /// To be used only by SharedFormulaUtil::joinFormulaCells().
1431 void AddDelayedFormulaGroupingCell( const ScFormulaCell* cell );
1432 /// If set, ScColumn::StartListeningFormulaCells() calls may be delayed using
1433 /// CanDelayStartListeningFormulaCells() until reset again, at which point the function will
1434 /// be called as necessary.
1435 void EnableDelayStartListeningFormulaCells( ScColumn* column, bool delay );
1436 bool IsEnabledDelayStartListeningFormulaCells( ScColumn* column ) const;
1437 /// If true is returned, ScColumn::StartListeningFormulaCells() for the given cells will be performed
1438 /// later. If false is returned, it needs to be done explicitly.
1439 bool CanDelayStartListeningFormulaCells( ScColumn* column, SCROW row1, SCROW row2 );
1440 /// If set, cells will not delete their empty broadcasters, avoiding possible extensive mdds
1441 /// vector changes. Disabling delay will collect and delete all empty broadcasters.
1442 void EnableDelayDeletingBroadcasters(bool set);
1443 bool IsDelayedDeletingBroadcasters() const { return bDelayedDeletingBroadcasters; }
1445 FormulaError GetErrCode( const ScAddress& ) const;
1447 /** Shrink a range to only include data area.
1449 This is not the actually used area within the
1450 selection, but the bounds of the sheet's data area
1451 instead.
1453 @returns TRUE if the area passed intersected the data
1454 area, FALSE if not, in which case the values
1455 obtained may be out of bounds, not in order or
1456 unmodified. TRUE does not mean that there
1457 actually is any data within the selection.
1459 bool ShrinkToDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
1461 /** Shrink a range to only include used data area.
1463 @param o_bShrunk
1464 Out parameter, true if area was shrunk, false if not.
1465 @param bColumnsOnly
1466 If TRUE, shrink only by columns, not rows.
1467 @param bStickyTopRow
1468 If TRUE, do not adjust the top row.
1469 @param bStickyLeftCol
1470 If TRUE, do not adjust the left column.
1471 @param pDataAreaExtras
1472 Consider additional area attributes like cell
1473 formatting, cell notes and draw objects. The
1474 possibly larger area than the actual cell
1475 content data area is returned within the
1476 struct.
1478 @returns true if there is any data, false if not.
1480 bool ShrinkToUsedDataArea( bool& o_bShrunk,
1481 SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1482 SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
1483 bool bStickyTopRow = false, bool bStickyLeftCol = false,
1484 ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
1487 * Return the last non-empty row position in given columns that's no
1488 * greater than the initial last row position, or 0 if the columns are
1489 * empty. A negative value is returned if the given sheet or column
1490 * positions are invalid.
1492 * <p>It starts from the specified last row position, and finds the first
1493 * non-empty row position in the upward direction if the start row
1494 * position is empty.</p>
1496 SC_DLLPUBLIC SCROW GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const;
1499 * Return the smallest area containing at least all contiguous cells
1500 * having data. This area is a square containing also empty cells. It may
1501 * shrink or extend the area given as input Flags as modifiers:
1503 * @param bIncludeOld when true, ensure that the returned area contains at
1504 * least the initial area even if the actual data area
1505 * is smaller than the initial area.
1507 * @param bOnlyDown when true, extend / shrink the data area only in a
1508 * downward direction i.e. only modify the end row
1509 * position.
1511 SC_DLLPUBLIC void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1512 SCCOL& rEndCol, SCROW& rEndRow,
1513 bool bIncludeOld, bool bOnlyDown ) const;
1516 * Return the extended area containing at least all contiguous cells
1517 * having background color.
1519 SC_DLLPUBLIC void GetBackColorArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1520 SCCOL& rEndCol, SCROW& rEndRow ) const;
1523 * Returns true if there is a non-empty subrange in the range given as input.
1524 * In that case it also modifies rRange to largest subrange that does not
1525 * have empty col/row inrange-segments in the beginning/end.
1526 * It returns false if rRange is completely empty and in this case rRange is
1527 * left unmodified.
1529 bool GetDataAreaSubrange(ScRange& rRange) const;
1531 SC_DLLPUBLIC bool GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
1532 SC_DLLPUBLIC bool GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
1533 bool bCalcHiddens = false) const;
1534 SC_DLLPUBLIC bool GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
1535 bool bNotes = true) const;
1536 SC_DLLPUBLIC bool GetPrintAreaHor( SCTAB nTab, SCROW nStartRow, SCROW nEndRow,
1537 SCCOL& rEndCol ) const;
1538 SC_DLLPUBLIC bool GetPrintAreaVer( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol,
1539 SCROW& rEndRow, bool bNotes ) const;
1540 void InvalidateTableArea();
1542 /// Return the number of columns / rows that should be visible for the tiled rendering.
1543 SC_DLLPUBLIC void GetTiledRenderingArea(SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow) const;
1545 SC_DLLPUBLIC bool GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const;
1548 * Find the maximum column position that contains printable data for the
1549 * specified row range. The final column position must be equal or less
1550 * than the initial value of rEndCol.
1552 void ExtendPrintArea( OutputDevice* pDev, SCTAB nTab,
1553 SCCOL nStartCol, SCROW nStartRow,
1554 SCCOL& rEndCol, SCROW nEndRow ) const;
1555 SC_DLLPUBLIC bool IsEmptyData(SCCOL nStartCol, SCROW nStartRow,
1556 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const;
1557 // I think this returns the number of empty cells starting from the given direction.
1558 SC_DLLPUBLIC SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
1559 SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab,
1560 ScDirection eDir );
1562 void FindAreaPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, ScMoveDirection eDirection ) const;
1563 SC_DLLPUBLIC void GetNextPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, SCCOL nMovX, SCROW nMovY,
1564 bool bMarked, bool bUnprotected, const ScMarkData& rMark,
1565 SCCOL nTabStartCol = SC_TABSTART_NONE ) const;
1567 bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, SCTAB nTab,
1568 const ScMarkData& rMark );
1570 void LimitChartArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1571 SCCOL& rEndCol, SCROW& rEndRow );
1572 void LimitChartIfAll( ScRangeListRef& rRangeList );
1574 bool InsertRow( SCCOL nStartCol, SCTAB nStartTab,
1575 SCCOL nEndCol, SCTAB nEndTab,
1576 SCROW nStartRow, SCSIZE nSize, ScDocument* pRefUndoDoc = nullptr,
1577 const ScMarkData* pTabMark = nullptr );
1578 SC_DLLPUBLIC bool InsertRow( const ScRange& rRange );
1579 void DeleteRow( SCCOL nStartCol, SCTAB nStartTab,
1580 SCCOL nEndCol, SCTAB nEndTab,
1581 SCROW nStartRow, SCSIZE nSize,
1582 ScDocument* pRefUndoDoc = nullptr, bool* pUndoOutline = nullptr,
1583 const ScMarkData* pTabMark = nullptr );
1584 SC_DLLPUBLIC void DeleteRow( const ScRange& rRange );
1585 bool InsertCol( SCROW nStartRow, SCTAB nStartTab,
1586 SCROW nEndRow, SCTAB nEndTab,
1587 SCCOL nStartCol, SCSIZE nSize, ScDocument* pRefUndoDoc = nullptr,
1588 const ScMarkData* pTabMark = nullptr );
1589 SC_DLLPUBLIC bool InsertCol( const ScRange& rRange );
1590 void DeleteCol( SCROW nStartRow, SCTAB nStartTab,
1591 SCROW nEndRow, SCTAB nEndTab,
1592 SCCOL nStartCol, SCSIZE nSize,
1593 ScDocument* pRefUndoDoc = nullptr, bool* pUndoOutline = nullptr,
1594 const ScMarkData* pTabMark = nullptr );
1595 void DeleteCol( const ScRange& rRange );
1597 bool CanInsertRow( const ScRange& rRange ) const;
1598 bool CanInsertCol( const ScRange& rRange ) const;
1600 void FitBlock( const ScRange& rOld, const ScRange& rNew, bool bClear = true );
1601 bool CanFitBlock( const ScRange& rOld, const ScRange& rNew );
1603 bool IsClipOrUndo() const { return bIsClip || bIsUndo; }
1604 bool IsUndo() const { return bIsUndo; }
1605 bool IsClipboard() const { return bIsClip; }
1606 bool IsUndoEnabled() const { return mbUndoEnabled; }
1607 SC_DLLPUBLIC void EnableUndo( bool bVal );
1608 bool IsFunctionAccess() const { return bIsFunctionAccess; }
1610 bool IsAdjustHeightLocked() const { return nAdjustHeightLock != 0; }
1611 void LockAdjustHeight() { ++nAdjustHeightLock; }
1612 SC_DLLPUBLIC void UnlockAdjustHeight();
1613 bool IsExecuteLinkEnabled() const { return mbExecuteLinkEnabled; }
1614 void EnableExecuteLink( bool bVal ) { mbExecuteLinkEnabled = bVal; }
1615 bool IsChangeReadOnlyEnabled() const { return mbChangeReadOnlyEnabled; }
1616 void EnableChangeReadOnly( bool bVal ) { mbChangeReadOnlyEnabled = bVal; }
1617 SC_DLLPUBLIC bool IsUserInteractionEnabled() const { return mbUserInteractionEnabled;}
1618 SC_DLLPUBLIC void EnableUserInteraction( bool bVal );
1619 SC_DLLPUBLIC sal_Int16 GetNamedRangesLockCount() const { return mnNamedRangesLockCount; }
1620 void SetNamedRangesLockCount( sal_Int16 nCount ) { mnNamedRangesLockCount = nCount; }
1621 SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks );
1622 SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, SCTAB nTab );
1623 void SetCutMode( bool bCut );
1624 bool IsCutMode();
1625 void SetClipArea( const ScRange& rArea, bool bCut = false );
1627 SC_DLLPUBLIC bool IsDocVisible() const { return bIsVisible; }
1628 SC_DLLPUBLIC void SetDocVisible( bool bSet );
1630 bool HasOLEObjectsInArea( const ScRange& rRange, const ScMarkData* pTabMark = nullptr );
1632 void DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1633 const ScMarkData& rMark, bool bAnchored = false );
1634 void DeleteObjectsInSelection( const ScMarkData& rMark );
1636 SC_DLLPUBLIC void DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark,
1637 InsertDeleteFlags nDelFlag, bool bBroadcast = true,
1638 sc::ColumnSpanSet* pBroadcastSpans = nullptr );
1640 SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1641 SCTAB nTab, InsertDeleteFlags nDelFlag);
1642 void DeleteAreaTab(const ScRange& rRange, InsertDeleteFlags nDelFlag);
1644 SC_DLLPUBLIC void CopyToClip( const ScClipParam& rClipParam, ScDocument* pClipDoc,
1645 const ScMarkData* pMarks, bool bKeepScenarioFlags,
1646 bool bIncludeObjects );
1649 * Copy only raw cell values to another document. Formula cells are
1650 * converted to raw cells. No formatting info are copied except for
1651 * number formats.
1653 * @param rSrcRange source range in the source document
1654 * @param nDestTab table in the clip document to copy to.
1655 * @param rDestDoc document to copy to
1657 SC_DLLPUBLIC void CopyStaticToDocument(const ScRange& rSrcRange, SCTAB nDestTab, ScDocument& rDestDoc);
1660 * Copy only cell, nothing but cell to another document.
1662 * @param rSrcPos source cell position
1663 * @param rDestPos destination cell position
1664 * @param rDestDoc destination document
1666 void CopyCellToDocument( const ScAddress& rSrcPos, const ScAddress& rDestPos, ScDocument& rDestDoc );
1668 void CopyTabToClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1669 SCTAB nTab, ScDocument* pClipDoc);
1671 SC_DLLPUBLIC bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCTAB nTab, SCCOL nCol );
1673 void DeleteBeforeCopyFromClip( sc::CopyFromClipContext& rCxt, const ScMarkData& rMark,
1674 sc::ColumnSpanSet& rBroadcastSpans );
1676 SC_DLLPUBLIC bool CopyOneCellFromClip(sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1677 SCCOL nCol2, SCROW nRow2 );
1678 void CopyBlockFromClip( sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1679 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark,
1680 SCCOL nDx, SCROW nDy );
1682 * @return the number of non-filtered rows.
1684 SCROW CopyNonFilteredFromClip(sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1685 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark, SCCOL nDx,
1686 SCROW& rClipStartRow, SCROW nClipEndRow);
1688 void StartListeningFromClip(
1689 sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt,
1690 SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1691 void StartListeningFromClip( SCCOL nCol1, SCROW nRow1,
1692 SCCOL nCol2, SCROW nRow2,
1693 const ScMarkData& rMark, InsertDeleteFlags nInsFlag );
1695 void SetDirtyFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1696 const ScMarkData& rMark, InsertDeleteFlags nInsFlag,
1697 sc::ColumnSpanSet& rBroadcastSpans );
1700 * Paste data from a clipboard document into this document.
1702 * @param rDestRange destination range.
1703 * @param pClipDoc pointer to the clipboard document to copy data from.
1704 * @param bSkipEmptyCells if this flag is set, empty cells in the source
1705 * range in the clipboard document will not overwrite
1706 * the target destination cells.
1707 * @param pDestRanges If pDestRanges is given it overrides rDestRange, where
1708 * rDestRange becomes the overall encompassing range.
1710 SC_DLLPUBLIC void CopyFromClip(
1711 const ScRange& rDestRange, const ScMarkData& rMark, InsertDeleteFlags nInsFlag,
1712 ScDocument* pRefUndoDoc, ScDocument* pClipDoc,
1713 bool bResetCut = true, bool bAsLink = false,
1714 bool bIncludeFiltered = true, bool bSkipEmptyCells = false,
1715 const ScRangeList* pDestRanges = nullptr );
1717 void CopyMultiRangeFromClip(const ScAddress& rDestPos, const ScMarkData& rMark,
1718 InsertDeleteFlags nInsFlag, ScDocument* pClipDoc,
1719 bool bResetCut = true, bool bAsLink = false,
1720 bool bIncludeFiltered = true,
1721 bool bSkipAttrForEmpty = false);
1723 void GetClipArea(SCCOL& nClipX, SCROW& nClipY, bool bIncludeFiltered);
1724 void GetClipStart(SCCOL& nClipX, SCROW& nClipY);
1726 bool HasClipFilteredRows();
1728 bool IsClipboardSource() const;
1730 SC_DLLPUBLIC void TransposeClip(ScDocument* pTransClip, InsertDeleteFlags nFlags, bool bAsLink,
1731 bool bIncludeFiltered);
1733 ScClipParam& GetClipParam();
1734 void SetClipParam(const ScClipParam& rParam);
1736 /** To be called at the clipboard document when closing a document that is
1737 the current clipboard source to decouple things from the originating
1738 document. Done in ScDocument dtor after determining
1739 IsClipboardSource().
1741 void ClosingClipboardSource();
1743 void MixDocument( const ScRange& rRange, ScPasteFunc nFunction, bool bSkipEmpty,
1744 ScDocument& rSrcDoc );
1746 void FillTab( const ScRange& rSrcArea, const ScMarkData& rMark,
1747 InsertDeleteFlags nFlags, ScPasteFunc nFunction,
1748 bool bSkipEmpty, bool bAsLink );
1749 void FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark,
1750 InsertDeleteFlags nFlags, ScPasteFunc nFunction,
1751 bool bSkipEmpty, bool bAsLink );
1753 void TransliterateText( const ScMarkData& rMultiMark, TransliterationFlags nType );
1755 SC_DLLPUBLIC void InitUndo( const ScDocument& rSrcDoc, SCTAB nTab1, SCTAB nTab2,
1756 bool bColInfo = false, bool bRowInfo = false );
1757 void AddUndoTab( SCTAB nTab1, SCTAB nTab2,
1758 bool bColInfo = false, bool bRowInfo = false );
1759 SC_DLLPUBLIC void InitUndoSelected( const ScDocument& rSrcDoc, const ScMarkData& rTabSelection,
1760 bool bColInfo = false, bool bRowInfo = false );
1762 // don't use anymore:
1763 void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1764 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1765 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc,
1766 const ScMarkData* pMarks = nullptr, bool bColRowFlags = true);
1767 void UndoToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1768 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1769 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc);
1771 SC_DLLPUBLIC void CopyToDocument(const ScRange& rRange,
1772 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc,
1773 const ScMarkData* pMarks = nullptr, bool bColRowFlags = true);
1774 void UndoToDocument(const ScRange& rRange,
1775 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc);
1777 void CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario = false );
1778 bool TestCopyScenario( SCTAB nSrcTab, SCTAB nDestTab ) const;
1779 void MarkScenario(SCTAB nSrcTab, SCTAB nDestTab,
1780 ScMarkData& rDestMark, bool bResetMark = true,
1781 ScScenarioFlags nNeededBits = ScScenarioFlags::NONE) const;
1782 bool HasScenarioRange( SCTAB nTab, const ScRange& rRange ) const;
1783 SC_DLLPUBLIC const ScRangeList* GetScenarioRanges( SCTAB nTab ) const;
1785 SC_DLLPUBLIC void CopyUpdated( ScDocument* pPosDoc, ScDocument* pDestDoc );
1787 void UpdateReference( sc::RefUpdateContext& rCxt, ScDocument*
1788 pUndoDoc = nullptr, bool bIncludeDraw = true,
1789 bool bUpdateNoteCaptionPos = true );
1791 * @param pClipDoc original clipboard doc, i.e. non-transposed
1792 * This clip doc is used to check references pointing to cut cells.
1794 SC_DLLPUBLIC void UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDoc,
1795 const ScMarkData& rMark, ScDocument* pUndoDoc );
1797 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
1799 SC_DLLPUBLIC void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1800 ScProgress* pProgress, const ScMarkData& rMark,
1801 sal_uInt64 nFillCount, FillDir eFillDir = FILL_TO_BOTTOM,
1802 FillCmd eFillCmd = FILL_LINEAR, FillDateCmd eFillDateCmd = FILL_DAY,
1803 double nStepValue = 1.0, double nMaxValue = 1E307 );
1804 OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
1806 bool GetSelectionFunction( ScSubTotalFunc eFunc,
1807 const ScAddress& rCursor, const ScMarkData& rMark,
1808 double& rResult );
1810 SC_DLLPUBLIC const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
1811 template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const
1813 return static_cast<const T*>(GetAttr(nCol, nRow, nTab, sal_uInt16(nWhich)));
1815 SC_DLLPUBLIC const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich,
1816 SCROW& nStartRow, SCROW& nEndRow ) const;
1817 template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich,
1818 SCROW& nStartRow, SCROW& nEndRow ) const
1820 return static_cast<const T*>(GetAttr(nCol, nRow, nTab, sal_uInt16(nWhich), nStartRow, nEndRow));
1822 SC_DLLPUBLIC const SfxPoolItem* GetAttr( const ScAddress& rPos, sal_uInt16 nWhich ) const;
1823 template<class T> const T* GetAttr( const ScAddress& rPos, TypedWhichId<T> nWhich ) const
1825 return static_cast<const T*>(GetAttr(rPos, sal_uInt16(nWhich)));
1827 SC_DLLPUBLIC const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1828 SC_DLLPUBLIC const ScPatternAttr* GetPattern( const ScAddress& rPos ) const;
1829 SC_DLLPUBLIC const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const;
1830 const ScPatternAttr* GetSelectionPattern( const ScMarkData& rMark );
1831 std::unique_ptr<ScPatternAttr> CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
1832 SC_DLLPUBLIC void AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
1833 void RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
1835 SC_DLLPUBLIC ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1836 // pCell is an optimization, must point to rPos
1837 SC_DLLPUBLIC const SfxItemSet* GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab,
1838 ScRefCellValue* pCell = nullptr ) const;
1839 const SfxItemSet* GetCondResult( ScRefCellValue& rCell, const ScAddress& rPos,
1840 const ScConditionalFormatList& rList,
1841 const ScCondFormatIndexes& rIndex ) const;
1842 const SfxPoolItem* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
1843 template<class T> const T* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const
1845 return static_cast<const T*>(GetEffItem(nCol, nRow, nTab, sal_uInt16(nWhich)));
1848 SC_DLLPUBLIC const css::uno::Reference< css::i18n::XBreakIterator >& GetBreakIterator();
1849 bool HasStringWeakCharacters( const OUString& rString );
1850 SC_DLLPUBLIC SvtScriptType GetStringScriptType( const OUString& rString );
1851 // pCell is an optimization, must point to rPos
1852 SC_DLLPUBLIC SvtScriptType GetCellScriptType( const ScAddress& rPos, sal_uInt32 nNumberFormat,
1853 const ScRefCellValue* pCell = nullptr );
1854 // pCell is an optimization, must point to nCol,nRow,nTab
1855 SC_DLLPUBLIC SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab,
1856 const ScRefCellValue* pCell = nullptr );
1857 SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rPos, SCROW nLength );
1858 SvtScriptType GetRangeScriptType( const ScRangeList& rRanges );
1860 bool HasDetectiveOperations() const;
1861 void AddDetectiveOperation( const ScDetOpData& rData );
1862 void ClearDetectiveOperations();
1863 ScDetOpList* GetDetOpList() const { return pDetOpList.get(); }
1864 void SetDetOpList(std::unique_ptr<ScDetOpList> pNew);
1866 bool HasDetectiveObjects(SCTAB nTab) const;
1868 void GetSelectionFrame( const ScMarkData& rMark,
1869 SvxBoxItem& rLineOuter,
1870 SvxBoxInfoItem& rLineInner );
1871 void ApplySelectionFrame(const ScMarkData& rMark,
1872 const SvxBoxItem& rLineOuter,
1873 const SvxBoxInfoItem* pLineInner);
1874 void ApplyFrameAreaTab(const ScRange& rRange,
1875 const SvxBoxItem& rLineOuter,
1876 const SvxBoxInfoItem& rLineInner);
1878 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
1879 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
1881 SC_DLLPUBLIC sal_uLong AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew, SCTAB nTab );
1882 void DeleteConditionalFormat( sal_uLong nIndex, SCTAB nTab );
1884 void SetCondFormList( ScConditionalFormatList* pList, SCTAB nTab );
1885 SC_DLLPUBLIC sal_uLong AddValidationEntry( const ScValidationData& rNew );
1886 SC_DLLPUBLIC const ScValidationData* GetValidationEntry( sal_uInt32 nIndex ) const;
1888 SC_DLLPUBLIC ScConditionalFormatList* GetCondFormList( SCTAB nTab ) const;
1890 const ScValidationDataList* GetValidationList() const { return pValidationList.get();}
1891 ScValidationDataList* GetValidationList() { return pValidationList.get();}
1893 SC_DLLPUBLIC void ApplyAttr( SCCOL nCol, SCROW nRow, SCTAB nTab,
1894 const SfxPoolItem& rAttr );
1895 SC_DLLPUBLIC void ApplyPattern( SCCOL nCol, SCROW nRow, SCTAB nTab,
1896 const ScPatternAttr& rAttr );
1897 SC_DLLPUBLIC void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow,
1898 SCCOL nEndCol, SCROW nEndRow,
1899 const ScMarkData& rMark, const ScPatternAttr& rAttr,
1900 ScEditDataArray* pDataArray = nullptr,
1901 bool* const pIsChanged = nullptr );
1902 SC_DLLPUBLIC void ApplyPatternAreaTab( SCCOL nStartCol, SCROW nStartRow,
1903 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1904 const ScPatternAttr& rAttr );
1906 SC_DLLPUBLIC void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
1907 const ScMarkData& rMark,
1908 const ScPatternAttr& rPattern,
1909 SvNumFormatType nNewType );
1911 void ApplyStyle( SCCOL nCol, SCROW nRow, SCTAB nTab,
1912 const ScStyleSheet& rStyle);
1913 void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow,
1914 SCCOL nEndCol, SCROW nEndRow,
1915 const ScMarkData& rMark, const ScStyleSheet& rStyle);
1916 SC_DLLPUBLIC void ApplyStyleAreaTab( SCCOL nStartCol, SCROW nStartRow,
1917 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1918 const ScStyleSheet& rStyle);
1920 SC_DLLPUBLIC void ApplySelectionStyle( const ScStyleSheet& rStyle, const ScMarkData& rMark );
1921 void ApplySelectionLineStyle( const ScMarkData& rMark,
1922 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
1924 const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1925 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark ) const;
1927 void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
1928 OutputDevice* pDev,
1929 double nPPTX, double nPPTY,
1930 const Fraction& rZoomX, const Fraction& rZoomY );
1932 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
1934 SC_DLLPUBLIC bool ApplyFlagsTab( SCCOL nStartCol, SCROW nStartRow,
1935 SCCOL nEndCol, SCROW nEndRow,
1936 SCTAB nTab, ScMF nFlags );
1937 SC_DLLPUBLIC bool RemoveFlagsTab( SCCOL nStartCol, SCROW nStartRow,
1938 SCCOL nEndCol, SCROW nEndRow,
1939 SCTAB nTab, ScMF nFlags );
1941 SC_DLLPUBLIC void SetPattern( const ScAddress&, const ScPatternAttr& rAttr );
1942 SC_DLLPUBLIC const ScPatternAttr* SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, std::unique_ptr<ScPatternAttr> pAttr );
1943 SC_DLLPUBLIC const ScPatternAttr* SetPattern( const ScAddress& rPos, std::unique_ptr<ScPatternAttr> pAttr );
1944 SC_DLLPUBLIC void SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr& rAttr );
1946 void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1947 sal_uInt16 nFormatNo, const ScMarkData& rMark );
1948 void GetAutoFormatData( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1949 ScAutoFormatData& rData );
1950 bool SearchAndReplace( const SvxSearchItem& rSearchItem,
1951 SCCOL& rCol, SCROW& rRow, SCTAB& rTab,
1952 const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1953 OUString& rUndoStr, ScDocument* pUndoDoc, bool& bMatchedRangesWereClamped );
1954 static bool IsEmptyCellSearch( const SvxSearchItem& rSearchItem );
1956 // determine Col/Row of subsequent calls
1957 // (e.g. not found from the beginning, or subsequent tables)
1958 // meaning of explanation in "()" was already unclear in German
1959 void GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem,
1960 SCCOL& rCol, SCROW& rRow );
1962 bool Solver( SCCOL nFCol, SCROW nFRow, SCTAB nFTab,
1963 SCCOL nVCol, SCROW nVRow, SCTAB nVTab,
1964 const OUString& sValStr, double& nX);
1966 SC_DLLPUBLIC void ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark,
1967 ScEditDataArray* pDataArray = nullptr, bool* pIsChanged = nullptr );
1968 SC_DLLPUBLIC void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
1969 void DeleteSelectionTab( SCTAB nTab, InsertDeleteFlags nDelFlag, const ScMarkData& rMark );
1971 SC_DLLPUBLIC void SetColWidth( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth );
1972 SC_DLLPUBLIC void SetColWidthOnly( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth );
1973 SC_DLLPUBLIC void SetRowHeight( SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight );
1974 SC_DLLPUBLIC void SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
1975 sal_uInt16 nNewHeight );
1977 SC_DLLPUBLIC void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
1978 sal_uInt16 nNewHeight );
1979 SC_DLLPUBLIC void SetManualHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual );
1981 SC_DLLPUBLIC sal_uInt16 GetColWidth( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
1982 SC_DLLPUBLIC tools::Long GetColWidth( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab ) const;
1983 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1984 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const;
1985 SC_DLLPUBLIC tools::Long GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1988 * Given the height i.e. total vertical distance from the top of the sheet
1989 * grid, return the first visible row whose top position is below the
1990 * specified height.
1992 SCROW GetRowForHeight( SCTAB nTab, tools::Long nHeight ) const;
1993 tools::Long GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const;
1994 SC_DLLPUBLIC tools::Long GetColOffset( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
1995 SC_DLLPUBLIC tools::Long GetRowOffset( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1997 SC_DLLPUBLIC sal_uInt16 GetOriginalWidth( SCCOL nCol, SCTAB nTab ) const;
1998 SC_DLLPUBLIC sal_uInt16 GetOriginalHeight( SCROW nRow, SCTAB nTab ) const;
2000 sal_uInt16 GetCommonWidth( SCCOL nEndCol, SCTAB nTab ) const;
2002 SCROW GetHiddenRowCount( SCROW nRow, SCTAB nTab ) const;
2004 sal_uInt16 GetOptimalColWidth( SCCOL nCol, SCTAB nTab, OutputDevice* pDev,
2005 double nPPTX, double nPPTY,
2006 const Fraction& rZoomX, const Fraction& rZoomY,
2007 bool bFormula,
2008 const ScMarkData* pMarkData = nullptr,
2009 const ScColWidthParam* pParam = nullptr );
2011 SC_DLLPUBLIC bool SetOptimalHeight( sc::RowHeightContext& rCxt, SCROW nStartRow,
2012 SCROW nEndRow, SCTAB nTab, bool bApi );
2014 void UpdateAllRowHeights( sc::RowHeightContext& rCxt, const ScMarkData* pTabMark );
2016 tools::Long GetNeededSize( SCCOL nCol, SCROW nRow, SCTAB nTab,
2017 OutputDevice* pDev,
2018 double nPPTX, double nPPTY,
2019 const Fraction& rZoomX, const Fraction& rZoomY,
2020 bool bWidth, bool bTotalSize = false,
2021 bool bInPrintTwips = false );
2023 SC_DLLPUBLIC void ShowCol(SCCOL nCol, SCTAB nTab, bool bShow);
2024 SC_DLLPUBLIC void ShowRow(SCROW nRow, SCTAB nTab, bool bShow);
2025 SC_DLLPUBLIC void ShowRows(SCROW nRow1, SCROW nRow2, SCTAB nTab, bool bShow);
2026 SC_DLLPUBLIC void SetRowFlags( SCROW nRow, SCTAB nTab, CRFlags nNewFlags );
2027 SC_DLLPUBLIC void SetRowFlags( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, CRFlags nNewFlags );
2029 SC_DLLPUBLIC CRFlags GetColFlags( SCCOL nCol, SCTAB nTab ) const;
2030 SC_DLLPUBLIC CRFlags GetRowFlags( SCROW nRow, SCTAB nTab ) const;
2032 SC_DLLPUBLIC void GetAllRowBreaks(std::set<SCROW>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
2033 SC_DLLPUBLIC void GetAllColBreaks(std::set<SCCOL>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
2034 SC_DLLPUBLIC ScBreakType HasRowBreak(SCROW nRow, SCTAB nTab) const;
2035 SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const;
2036 SC_DLLPUBLIC void SetRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
2037 SC_DLLPUBLIC void SetColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
2038 void RemoveRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
2039 void RemoveColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
2040 css::uno::Sequence<
2041 css::sheet::TablePageBreakData> GetRowBreakData(SCTAB nTab) const;
2043 SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
2044 SC_DLLPUBLIC bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2045 SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
2046 SC_DLLPUBLIC void SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden);
2047 SC_DLLPUBLIC void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden);
2048 SC_DLLPUBLIC SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2049 SC_DLLPUBLIC SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2050 SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2052 SC_DLLPUBLIC bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
2053 bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2054 bool ColFiltered(SCCOL nCol, SCTAB nTab) const;
2055 SC_DLLPUBLIC void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered);
2056 SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2057 SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2058 SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2060 SC_DLLPUBLIC bool IsManualRowHeight(SCROW nRow, SCTAB nTab) const;
2062 bool HasUniformRowHeight( SCTAB nTab, SCROW nRow1, SCROW nRow2 ) const;
2065 * Write all column row flags to table's flag data, because not all column
2066 * row attributes are stored in the flag data members. This is necessary
2067 * for ods export.
2069 void SyncColRowFlags();
2071 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
2072 SC_DLLPUBLIC SCROW GetLastFlaggedRow( SCTAB nTab ) const;
2074 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
2075 SCCOL GetLastChangedColFlagsWidth( SCTAB nTab ) const;
2076 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
2077 SCROW GetLastChangedRowFlagsWidth( SCTAB nTab ) const;
2079 SCCOL GetNextDifferentChangedColFlagsWidth( SCTAB nTab, SCCOL nStart) const;
2081 SCROW GetNextDifferentChangedRowFlagsWidth( SCTAB nTab, SCROW nStart) const;
2083 // returns whether to export a Default style for this col or not
2084 // nDefault is set to one position in the current row where the Default style is
2085 void GetColDefault( SCTAB nTab, SCCOL nCol, SCROW nLastRow, SCROW& nDefault);
2087 bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bShow );
2088 bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bShow );
2090 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
2091 void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
2093 SC_DLLPUBLIC ScPatternAttr* GetDefPattern() const;
2094 SC_DLLPUBLIC ScDocumentPool* GetPool();
2095 SC_DLLPUBLIC ScStyleSheetPool* GetStyleSheetPool() const;
2096 void GetUnprotectedCells( ScRangeList& rRange, SCTAB nTab ) const;
2098 // PageStyle:
2099 SC_DLLPUBLIC OUString GetPageStyle( SCTAB nTab ) const;
2100 SC_DLLPUBLIC void SetPageStyle( SCTAB nTab, const OUString& rName );
2101 Size GetPageSize( SCTAB nTab ) const;
2102 void SetPageSize( SCTAB nTab, const Size& rSize );
2103 void SetRepeatArea( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
2104 void InvalidatePageBreaks(SCTAB nTab);
2105 void UpdatePageBreaks( SCTAB nTab, const ScRange* pUserArea = nullptr );
2106 void RemoveManualBreaks( SCTAB nTab );
2107 bool HasManualBreaks( SCTAB nTab ) const;
2109 bool IsPageStyleInUse( std::u16string_view rStrPageStyle, SCTAB* pInTab );
2110 bool RemovePageStyleInUse( std::u16string_view rStrPageStyle );
2111 bool RenamePageStyleInUse( std::u16string_view rOld, const OUString& rNew );
2112 void ModifyStyleSheet( SfxStyleSheetBase& rPageStyle,
2113 const SfxItemSet& rChanges );
2115 void PageStyleModified( SCTAB nTab, const OUString& rNewName );
2117 SC_DLLPUBLIC bool NeedPageResetAfterTab( SCTAB nTab ) const;
2119 // Was stored in PageStyle previously. Now it exists for every table:
2120 SC_DLLPUBLIC bool HasPrintRange();
2121 SC_DLLPUBLIC sal_uInt16 GetPrintRangeCount( SCTAB nTab );
2122 SC_DLLPUBLIC const ScRange* GetPrintRange( SCTAB nTab, sal_uInt16 nPos );
2123 SC_DLLPUBLIC std::optional<ScRange> GetRepeatColRange( SCTAB nTab );
2124 SC_DLLPUBLIC std::optional<ScRange> GetRepeatRowRange( SCTAB nTab );
2125 /** Returns true, if the specified sheet is always printed. */
2126 bool IsPrintEntireSheet( SCTAB nTab ) const;
2128 /** Removes all print ranges. */
2129 SC_DLLPUBLIC void ClearPrintRanges( SCTAB nTab );
2130 /** Adds a new print ranges. */
2131 SC_DLLPUBLIC void AddPrintRange( SCTAB nTab, const ScRange& rNew );
2132 // Removes all named ranges used for print ranges in a given tab
2133 SC_DLLPUBLIC void ClearPrintNamedRanges( SCTAB nTab );
2134 /** Marks the specified sheet to be printed completely. Deletes old print ranges on the sheet! */
2135 SC_DLLPUBLIC void SetPrintEntireSheet( SCTAB nTab );
2136 SC_DLLPUBLIC void SetRepeatColRange( SCTAB nTab, std::optional<ScRange> oNew );
2137 SC_DLLPUBLIC void SetRepeatRowRange( SCTAB nTab, std::optional<ScRange> oNew );
2138 std::unique_ptr<ScPrintRangeSaver> CreatePrintRangeSaver() const;
2139 void RestorePrintRanges( const ScPrintRangeSaver& rSaver );
2141 SC_DLLPUBLIC tools::Rectangle GetMMRect( SCCOL nStartCol, SCROW nStartRow,
2142 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
2143 SC_DLLPUBLIC ScRange GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool bHiddenAsZero = true ) const;
2145 void UpdStlShtPtrsFrmNms();
2146 void StylesToNames();
2148 SC_DLLPUBLIC void CopyStdStylesFrom( const ScDocument& rSrcDoc );
2150 static sal_uInt16 GetSrcVersion() { return nSrcVer; }
2152 void SetSrcCharSet( rtl_TextEncoding eNew ) { eSrcSet = eNew; }
2153 void UpdateFontCharSet();
2155 void FillInfo( ScTableInfo& rTabInfo, SCCOL nCol1, SCROW nRow1,
2156 SCCOL nCol2, SCROW nRow2, SCTAB nTab, double fColScale,
2157 double fRowScale, bool bPageMode, bool bFormulaMode,
2158 const ScMarkData* pMarkData = nullptr );
2160 SC_DLLPUBLIC SvNumberFormatter* GetFormatTable() const;
2162 /** Sort a range of data. */
2163 void Sort( SCTAB nTab, const ScSortParam& rSortParam,
2164 bool bKeepQuery, bool bUpdateRefs,
2165 ScProgress* pProgress, sc::ReorderParam* pUndo );
2167 void Reorder( const sc::ReorderParam& rParam );
2169 void PrepareQuery( SCTAB nTab, ScQueryParam& rQueryParam );
2170 SCSIZE Query( SCTAB nTab, const ScQueryParam& rQueryParam, bool bKeepSub );
2171 SC_DLLPUBLIC bool CreateQueryParam( const ScRange& rRange, ScQueryParam& rQueryParam );
2172 OUString GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab);
2175 * Get a list of unique strings to use in filtering criteria. The string
2176 * values are sorted, and there are no duplicate values in the list. The
2177 * data range to use to populate the filter entries is inferred from the
2178 * database range that contains the specified cell position.
2180 void GetFilterEntries( SCCOL nCol, SCROW nRow,
2181 SCTAB nTab, ScFilterEntries& rFilterEntries );
2183 SC_DLLPUBLIC void GetFilterEntriesArea( SCCOL nCol, SCROW nStartRow, SCROW nEndRow,
2184 SCTAB nTab, bool bCaseSens,
2185 ScFilterEntries& rFilterEntries );
2187 void GetDataEntries( SCCOL nCol, SCROW nRow, SCTAB nTab,
2188 std::vector<ScTypedStrData>& rStrings, bool bValidation = false );
2189 void GetFormulaEntries( ScTypedCaseStrSet& rStrings );
2191 bool HasAutoFilter( SCCOL nCol, SCROW nRow, SCTAB nTab );
2192 void GetFilterSelCount( SCCOL nCol, SCROW nRow, SCTAB nTab, SCSIZE& nSelected, SCSIZE& nTotal );
2194 SC_DLLPUBLIC bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
2195 SCTAB nTab );
2196 SC_DLLPUBLIC bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
2197 SCTAB nTab );
2199 SfxPrinter* GetPrinter( bool bCreateIfNotExist = true );
2200 void SetPrinter( VclPtr<SfxPrinter> const & pNewPrinter );
2201 VirtualDevice* GetVirtualDevice_100th_mm();
2202 SC_DLLPUBLIC OutputDevice* GetRefDevice(bool bForceVirtDev = false); // WYSIWYG: Printer, otherwise VirtualDevice...
2204 bool GetNextSpellingCell( SCCOL& nCol, SCROW& nRow, SCTAB nTab,
2205 bool bInSel, const ScMarkData& rMark) const;
2207 void ReplaceStyle( const SvxSearchItem& rSearchItem,
2208 SCCOL nCol, SCROW nRow, SCTAB nTab,
2209 const ScMarkData& rMark);
2211 void InvalidateTextWidth( std::u16string_view rStyleName );
2212 void InvalidateTextWidth( SCTAB nTab );
2213 void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo, bool bNumFormatChanged );
2215 bool IdleCalcTextWidth();
2217 void RepaintRange( const ScRange& rRange );
2218 void RepaintRange( const ScRangeList& rRange );
2220 bool IsIdleEnabled() const { return mbIdleEnabled; }
2221 void EnableIdle(bool bDo) { mbIdleEnabled = bDo; }
2223 bool IsDetectiveDirty() const { return bDetectiveDirty; }
2224 void SetDetectiveDirty(bool bSet) { bDetectiveDirty = bSet; }
2226 bool HasLinkFormulaNeedingCheck() const { return bLinkFormulaNeedingCheck; }
2227 void SetLinkFormulaNeedingCheck(bool bSet) { bLinkFormulaNeedingCheck = bSet; }
2228 /** Check token array and set link check if ocDde/ocWebservice is contained. */
2229 SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode );
2231 void SetRangeOverflowType(ErrCode nType) { nRangeOverflowType = nType; }
2232 bool HasRangeOverflow() const { return nRangeOverflowType != ERRCODE_NONE; }
2233 SC_DLLPUBLIC const ErrCode& GetRangeOverflowType() const { return nRangeOverflowType; }
2235 // for broadcasting/listening
2236 void SetInsertingFromOtherDoc( bool bVal ) { bInsertingFromOtherDoc = bVal; }
2237 bool IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc; }
2238 void SetLoadingMedium( bool bVal );
2239 SC_DLLPUBLIC void SetImportingXML( bool bVal );
2240 bool IsImportingXML() const { return bImportingXML; }
2241 bool IsCalcingAfterLoad() const { return bCalcingAfterLoad; }
2242 void SetNoListening( bool bVal ) { bNoListening = bVal; }
2243 bool GetNoListening() const { return bNoListening; }
2244 ScBroadcastAreaSlotMachine* GetBASM() const { return pBASM.get(); }
2246 SC_DLLPUBLIC ScChartListenerCollection* GetChartListenerCollection() const { return pChartListenerCollection.get(); }
2247 void SetChartListenerCollection( std::unique_ptr<ScChartListenerCollection>,
2248 bool bSetChartRangeLists );
2249 void UpdateChart( const OUString& rName );
2250 void RestoreChartListener( const OUString& rName );
2251 SC_DLLPUBLIC void UpdateChartListenerCollection();
2252 bool IsChartListenerCollectionNeedsUpdate() const { return bChartListenerCollectionNeedsUpdate; }
2253 void SetChartListenerCollectionNeedsUpdate( bool bFlg ) { bChartListenerCollectionNeedsUpdate = bFlg; }
2254 void AddOLEObjectToCollection(const OUString& rName);
2256 ScChangeViewSettings* GetChangeViewSettings() const { return pChangeViewSettings.get(); }
2257 SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings& rNew);
2259 const std::shared_ptr<SvxForbiddenCharactersTable>& GetForbiddenCharacters() const;
2260 void SetForbiddenCharacters(const std::shared_ptr<SvxForbiddenCharactersTable>& rNew);
2262 CharCompressType GetAsianCompression() const;
2263 bool IsValidAsianCompression() const;
2264 void SetAsianCompression(CharCompressType nNew);
2266 bool GetAsianKerning() const;
2267 bool IsValidAsianKerning() const;
2268 void SetAsianKerning(bool bNew);
2269 void ApplyAsianEditSettings(ScEditEngineDefaulter& rEngine);
2271 EEHorizontalTextDirection GetEditTextDirection(SCTAB nTab) const; // EEHorizontalTextDirection values
2273 SC_DLLPUBLIC ScLkUpdMode GetLinkMode() const { return eLinkMode ;}
2274 void SetLinkMode( ScLkUpdMode nSet ) { eLinkMode = nSet;}
2276 SC_DLLPUBLIC ScMacroManager* GetMacroManager();
2278 void FillMatrix( ScMatrix& rMat, SCTAB nTab, SCCOL nCol1,
2279 SCROW nRow1, SCCOL nCol2, SCROW nRow2,
2280 svl::SharedStringPool* pPool = nullptr) const;
2283 * Set an array of numerical formula results to a group of contiguous
2284 * formula cells.
2286 * @param rTopPos position of the top formula cell of a group.
2287 * @param pResults array of numeric results.
2288 * @param nLen length of numeric results.
2290 void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const double* pResults, size_t nLen );
2292 void CalculateInColumnInThread( ScInterpreterContext& rContext, const ScRange& rCalcRange, unsigned nThisThread, unsigned nThreadsTotal);
2293 void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab, ScInterpreter* pInterpreter );
2296 * Transfer a series of contiguous cell values from specified position to
2297 * the passed container. The specified segment will become empty after the
2298 * transfer.
2300 void TransferCellValuesTo( const ScAddress& rTopPos, size_t nLen, sc::CellValues& rDest );
2301 void CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellValues& rSrc );
2303 std::set<Color> GetDocColors();
2304 sc::IconSetBitmapMap& GetIconSetBitmapMap();
2306 std::set<SCCOL> QueryColumnsWithFormulaCells( SCTAB nTab ) const;
2309 * Check the integrity of the internal table state. Useful from testing
2310 * code. It throws an exception upon first failure.
2312 * Feel free to add more checks as needed.
2314 void CheckIntegrity( SCTAB nTab ) const;
2316 private:
2317 ScDocument(const ScDocument& r) = delete;
2319 void FindMaxRotCol( SCTAB nTab, RowInfo* pRowInfo, SCSIZE nArrCount,
2320 SCCOL nX1, SCCOL nX2 ) const;
2322 sal_uInt16 RowDifferences( SCROW nThisRow, SCTAB nThisTab,
2323 ScDocument& rOtherDoc,
2324 SCROW nOtherRow, SCTAB nOtherTab,
2325 SCCOL nMaxCol, const SCCOLROW* pOtherCols );
2326 sal_uInt16 ColDifferences( SCCOL nThisCol, SCTAB nThisTab,
2327 ScDocument& rOtherDoc,
2328 SCCOL nOtherCol, SCTAB nOtherTab,
2329 SCROW nMaxRow, const SCCOLROW* pOtherRows );
2330 void FindOrder( SCCOLROW* pOtherRows, SCCOLROW nThisEndRow, SCCOLROW nOtherEndRow,
2331 bool bColumns,
2332 ScDocument& rOtherDoc, SCTAB nThisTab, SCTAB nOtherTab,
2333 SCCOLROW nEndCol, const SCCOLROW* pTranslate,
2334 ScProgress* pProgress, sal_uInt64 nProAdd );
2336 DECL_LINK(TrackTimeHdl, Timer *, void);
2338 /** Adjust a range to available sheets.
2340 Used to start and stop listening on a sane range. Both o_rRange and
2341 o_bEntirelyOutOfBounds are set only if needed and don't have to be
2342 initialized by the caller.
2344 @param o_bEntirelyOutOfBounds
2345 <TRUE/> if both sheets in the range point outside the
2346 available sheet range, in which case no adjustment is done and
2347 o_rRange is not modified.
2349 @return <TRUE/> if any adjustment was done or o_bEntirelyOutOfBounds
2350 was set <TRUE/>.
2351 <FALSE/> if rRange was within the available sheets.
2353 bool LimitRangeToAvailableSheets( const ScRange& rRange, ScRange& o_rRange,
2354 bool& o_bEntirelyOutOfBounds ) const;
2356 public:
2357 void StartListeningArea( const ScRange& rRange, bool bGroupListening, SvtListener* pListener );
2359 void EndListeningArea( const ScRange& rRange, bool bGroupListening, SvtListener* pListener );
2360 /** Broadcast wrapper, calls
2361 rHint.GetCell()->Broadcast() and AreaBroadcast()
2362 and TrackFormulas()
2363 Preferred.
2365 void Broadcast( const ScHint& rHint );
2367 void BroadcastCells( const ScRange& rRange, SfxHintId nHint, bool bBroadcastSingleBroadcasters = true );
2369 /// only area, no cell broadcast
2370 void AreaBroadcast( const ScHint& rHint );
2371 void DelBroadcastAreasInRange( const ScRange& rRange );
2372 void UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode,
2373 const ScRange& rRange,
2374 SCCOL nDx, SCROW nDy, SCTAB nDz );
2376 void StartListeningCell( const ScAddress& rAddress,
2377 SvtListener* pListener );
2378 void EndListeningCell( const ScAddress& rAddress,
2379 SvtListener* pListener );
2381 void StartListeningCell( sc::StartListeningContext& rCxt, const ScAddress& rPos, SvtListener& rListener );
2382 void EndListeningCell( sc::EndListeningContext& rCxt, const ScAddress& rPos, SvtListener& rListener );
2384 void EndListeningFormulaCells( std::vector<ScFormulaCell*>& rCells );
2386 sc::BroadcasterState GetBroadcasterState() const;
2388 void PutInFormulaTree( ScFormulaCell* pCell );
2389 void RemoveFromFormulaTree( ScFormulaCell* pCell );
2392 * Calculate formula cells that are on the formula tree either partially,
2393 * or in full.
2395 * @param bOnlyForced when true, it only calculates those formula cells
2396 * that are marked "recalc forced".
2397 * @param bProgressBar whether or not to use progress bar.
2398 * @param bSetAllDirty when true, it marks all formula cells currently on
2399 * the formula tree dirty, which forces all of them to
2400 * be recalculated. When false, only those cells
2401 * that are marked dirty prior to this call get
2402 * recalculated.
2404 SC_DLLPUBLIC void CalcFormulaTree( bool bOnlyForced = false, bool bProgressBar = true, bool bSetAllDirty = true );
2405 void ClearFormulaTree();
2406 void AppendToFormulaTrack( ScFormulaCell* pCell );
2407 void RemoveFromFormulaTrack( ScFormulaCell* pCell );
2408 void TrackFormulas( SfxHintId nHintId = SfxHintId::ScDataChanged );
2409 void SetTrackFormulasPending() { mbTrackFormulasPending = true; }
2410 bool IsTrackFormulasPending() const { return mbTrackFormulasPending; }
2411 void FinalTrackFormulas( SfxHintId nHintId );
2412 bool IsFinalTrackFormulas() const { return mbFinalTrackFormulas; }
2413 inline bool IsInFormulaTree( const ScFormulaCell* pCell ) const;
2414 inline bool IsInFormulaTrack( const ScFormulaCell* pCell ) const;
2415 HardRecalcState GetHardRecalcState() const { return eHardRecalcState; }
2416 void SetHardRecalcState( HardRecalcState eVal ) { eHardRecalcState = eVal; }
2417 void StartAllListeners();
2418 void StartNeededListeners();
2419 void StartNeededListeners( const std::shared_ptr<const sc::ColumnSet>& rpColSet );
2420 SC_DLLPUBLIC void StartAllListeners( const ScRange& rRange );
2422 void SetForcedFormulas( bool bVal ) { bHasForcedFormulas = bVal; }
2423 sal_uInt64 GetFormulaCodeInTree() const { return nFormulaCodeInTree; }
2425 bool IsInInterpreter() const { return nInterpretLevel != 0; }
2427 void IncInterpretLevel()
2429 assert(!IsThreadedGroupCalcInProgress());
2430 if ( nInterpretLevel < USHRT_MAX )
2431 nInterpretLevel++;
2433 void DecInterpretLevel()
2435 assert(!IsThreadedGroupCalcInProgress());
2436 if ( nInterpretLevel )
2437 nInterpretLevel--;
2439 sal_uInt16 GetMacroInterpretLevel() const { return nMacroInterpretLevel; }
2440 void IncMacroInterpretLevel()
2442 assert(!IsThreadedGroupCalcInProgress());
2443 if ( nMacroInterpretLevel < USHRT_MAX )
2444 nMacroInterpretLevel++;
2446 void DecMacroInterpretLevel()
2448 assert(!IsThreadedGroupCalcInProgress());
2449 if ( nMacroInterpretLevel )
2450 nMacroInterpretLevel--;
2452 bool IsInInterpreterTableOp() const { return nInterpreterTableOpLevel != 0; }
2453 void IncInterpreterTableOpLevel()
2455 if ( nInterpreterTableOpLevel < USHRT_MAX )
2456 nInterpreterTableOpLevel++;
2458 void DecInterpreterTableOpLevel()
2460 if ( nInterpreterTableOpLevel )
2461 nInterpreterTableOpLevel--;
2464 // add a formula to be remembered for TableOp broadcasts
2465 void AddTableOpFormulaCell( ScFormulaCell* );
2466 void InvalidateLastTableOpParams() { aLastTableOpParams.bValid = false; }
2467 ScRecursionHelper& GetRecursionHelper();
2468 bool IsInDtorClear() const { return bInDtorClear; }
2469 void SetExpandRefs( bool bVal );
2470 bool IsExpandRefs() const { return bExpandRefs; }
2472 sal_uInt64 GetXMLImportedFormulaCount() const { return nXMLImportedFormulaCount; }
2473 void IncXMLImportedFormulaCount( sal_uInt64 nVal )
2475 if ( nXMLImportedFormulaCount + nVal > nXMLImportedFormulaCount )
2476 nXMLImportedFormulaCount += nVal;
2478 void DecXMLImportedFormulaCount( sal_uInt64 nVal )
2480 if ( nVal <= nXMLImportedFormulaCount )
2481 nXMLImportedFormulaCount -= nVal;
2482 else
2483 nXMLImportedFormulaCount = 0;
2486 void StartTrackTimer();
2488 void CompileDBFormula();
2489 void CompileColRowNameFormula();
2491 /** Maximum string length of a column, e.g. for dBase export.
2492 @return String length in octets (!) of the destination encoding. In
2493 case of non-octet encodings (e.g. UCS2) the length in code
2494 points times sizeof(sal_Unicode) is returned. */
2495 sal_Int32 GetMaxStringLen( SCTAB nTab, SCCOL nCol,
2496 SCROW nRowStart, SCROW nRowEnd,
2497 rtl_TextEncoding eCharSet ) const;
2498 /** Maximum string length of numerical cells of a column, e.g. for dBase export.
2499 @return String length in characters (!) including the decimal
2500 separator, and the decimal precision needed. */
2501 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
2502 SCTAB nTab, SCCOL nCol,
2503 SCROW nRowStart, SCROW nRowEnd ) const;
2505 void KeyInput(); // TimerDelays etc.
2507 ScChangeTrack* GetChangeTrack() const { return pChangeTrack.get(); }
2509 //! only for import filter, deletes any existing ChangeTrack via
2510 //! EndChangeTracking() and takes ownership of new ChangeTrack pTrack
2511 SC_DLLPUBLIC void SetChangeTrack( std::unique_ptr<ScChangeTrack> pTrack );
2513 void StartChangeTracking();
2514 void EndChangeTracking();
2516 SC_DLLPUBLIC void CompareDocument( ScDocument& rOtherDoc );
2518 void AddUnoObject( SfxListener& rObject );
2519 void RemoveUnoObject( SfxListener& rObject );
2520 void BroadcastUno( const SfxHint &rHint );
2521 void AddUnoListenerCall( const css::uno::Reference<
2522 css::util::XModifyListener >& rListener,
2523 const css::lang::EventObject& rEvent );
2525 void SetInLinkUpdate(bool bSet); // TableLink or AreaLink
2526 bool IsInLinkUpdate() const; // including DdeLink
2528 SC_DLLPUBLIC SfxItemPool* GetEditPool() const;
2529 SC_DLLPUBLIC SfxItemPool* GetEnginePool() const;
2530 SC_DLLPUBLIC ScFieldEditEngine& GetEditEngine();
2531 SC_DLLPUBLIC ScNoteEditEngine& GetNoteEngine();
2533 std::unique_ptr<EditTextObject> CreateSharedStringTextObject( const svl::SharedString& rSS );
2535 std::unique_ptr<ScRefreshTimerControl> const & GetRefreshTimerControlAddress() const
2536 { return pRefreshTimerControl; }
2538 void SetPastingDrawFromOtherDoc( bool bVal )
2539 { bPastingDrawFromOtherDoc = bVal; }
2540 bool PastingDrawFromOtherDoc() const
2541 { return bPastingDrawFromOtherDoc; }
2543 /// an ID unique to each document instance
2544 sal_uInt32 GetDocumentID() const;
2546 void InvalidateStyleSheetUsage() { bStyleSheetUsageInvalid = true; }
2547 void SC_DLLPUBLIC GetSortParam( ScSortParam& rParam, SCTAB nTab );
2548 void SC_DLLPUBLIC SetSortParam( const ScSortParam& rParam, SCTAB nTab );
2550 void SetVbaEventProcessor( const css::uno::Reference< css::script::vba::XVBAEventProcessor >& rxVbaEvents )
2551 { mxVbaEvents = rxVbaEvents; }
2552 const css::uno::Reference< css::script::vba::XVBAEventProcessor >& GetVbaEventProcessor() const { return mxVbaEvents; }
2554 /** Should only be GRAM_PODF or GRAM_ODFF. */
2555 void SetStorageGrammar( formula::FormulaGrammar::Grammar eGrammar );
2556 formula::FormulaGrammar::Grammar GetStorageGrammar() const { return eStorageGrammar; }
2558 SC_DLLPUBLIC ScUndoManager* GetUndoManager();
2559 bool IsInVBAMode() const;
2560 ScRowBreakIterator* GetRowBreakIterator(SCTAB nTab) const;
2562 void AddSubTotalCell(ScFormulaCell* pCell);
2563 void RemoveSubTotalCell(ScFormulaCell* pCell);
2564 void SetSubTotalCellsDirty(const ScRange& rDirtyRange);
2566 sal_uInt16 GetTextWidth( const ScAddress& rPos ) const;
2568 SvtScriptType GetScriptType( const ScAddress& rPos ) const;
2569 void SetScriptType( const ScAddress& rPos, SvtScriptType nType );
2570 void UpdateScriptTypes( const ScAddress& rPos, SCCOL nColSize, SCROW nRowSize );
2573 * Make specified formula cells non-grouped.
2575 * @param nTab sheet index
2576 * @param nCol column index
2577 * @param rRows list of row indices at which formula cells are to be
2578 * unshared. This call sorts the passed row indices and
2579 * removes duplicates, which is why the caller must pass it
2580 * as reference.
2582 void UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector<SCROW>& rRows );
2583 void RegroupFormulaCells( SCTAB nTab, SCCOL nCol );
2584 SC_DLLPUBLIC void RegroupFormulaCells( const ScRange& range );
2586 formula::FormulaTokenRef ResolveStaticReference( const ScAddress& rPos );
2587 formula::FormulaTokenRef ResolveStaticReference( const ScRange& rRange );
2589 formula::VectorRefArray FetchVectorRefArray( const ScAddress& rPos, SCROW nLength );
2590 bool HandleRefArrayForParallelism( const ScAddress& rPos, SCROW nLength,
2591 const ScFormulaCellGroupRef& mxGroup, ScAddress* pDirtiedAddress );
2592 #ifdef DBG_UTIL
2593 void AssertNoInterpretNeeded( const ScAddress& rPos, SCROW nLength );
2594 #endif
2597 * Call this before any operations that might trigger one or more formula
2598 * cells to get calculated.
2600 void PrepareFormulaCalc();
2603 * Make sure all of the formula cells in the specified range have been
2604 * fully calculated. This method only re-calculates those formula cells
2605 * that have been flagged dirty. In case of formula-groups, this calculates
2606 * only the dirty subspans along with the dependents in the same way
2607 * recursively.
2609 * @param rRange range in which to potentially calculate the formula
2610 * cells.
2611 * @param bSkipRunning flag to skip evaluation of formula-cells that are
2612 * marked as already being evaluated.
2613 * @return true if at least one formula-cell in the specified range was dirty
2614 * else returns false.
2616 SC_DLLPUBLIC bool EnsureFormulaCellResults( const ScRange& rRange, bool bSkipRunning = false );
2618 SvtBroadcaster* GetBroadcaster( const ScAddress& rPos );
2619 const SvtBroadcaster* GetBroadcaster( const ScAddress& rPos ) const;
2620 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rTopPos, SCROW nLength );
2622 std::optional<sc::ColumnIterator> GetColumnIterator( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
2623 void CreateColumnIfNotExists( SCTAB nTab, SCCOL nCol );
2625 SC_DLLPUBLIC void StoreTabToCache(SCTAB nTab, SvStream& rStrm) const;
2626 SC_DLLPUBLIC void RestoreTabFromCache(SCTAB nTab, SvStream& rStream);
2628 #if DUMP_COLUMN_STORAGE
2629 SC_DLLPUBLIC void DumpColumnStorage( SCTAB nTab, SCCOL nCol ) const;
2630 #endif
2632 SC_DLLPUBLIC void SetCalcConfig( const ScCalcConfig& rConfig );
2633 const ScCalcConfig& GetCalcConfig() const { return maCalcConfig; }
2634 void ConvertFormulaToValue( const ScRange& rRange, sc::TableValues* pUndo );
2635 void SwapNonEmpty( sc::TableValues& rValues );
2636 void finalizeOutlineImport();
2638 // Returns the given column range, first allocating all the columns if necessary.
2639 SC_DLLPUBLIC ScColumnsRange GetWritableColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd);
2640 // Returns a column range, clamped to the allocated columns.
2641 SC_DLLPUBLIC ScColumnsRange GetAllocatedColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const;
2642 // Returns the given range, without any adjustments. One of the variants above may return
2643 // a smaller range (better performance) if the use case is known.
2644 SC_DLLPUBLIC ScColumnsRange GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const;
2646 bool IsInDocShellRecalc() const { return mbDocShellRecalc; }
2647 void SetDocShellRecalc(bool bSet) { mbDocShellRecalc = bSet; }
2649 bool IsInLayoutStrings() const { return mbLayoutStrings; }
2650 void SetLayoutStrings(bool bSet) { mbLayoutStrings = bSet; }
2653 * Serializes the specified sheet's geometry data.
2655 * @param nTab is the index of the sheet to operate on.
2656 * @param bColumns - if true it dumps the data for columns, else it does for rows.
2657 * @param eGeomType indicates the type of data to be dumped for rows/columns.
2658 * @return the serialization of the specified sheet's geometry data as an OString.
2660 OString dumpSheetGeomData(SCTAB nTab, bool bColumns, SheetGeomType eGeomType);
2662 SCCOL GetLOKFreezeCol(SCTAB nTab) const;
2663 SCROW GetLOKFreezeRow(SCTAB nTab) const;
2664 bool SetLOKFreezeCol(SCCOL nFreezeCol, SCTAB nTab);
2665 bool SetLOKFreezeRow(SCROW nFreezeRow, SCTAB nTab);
2667 private:
2670 * Use this class as a locale variable to merge number formatter from
2671 * another document, and set NULL pointer to pFormatExchangeList when
2672 * done.
2674 class NumFmtMergeHandler
2676 public:
2677 explicit NumFmtMergeHandler(ScDocument& rDoc, const ScDocument& rSrcDoc);
2678 ~NumFmtMergeHandler();
2680 private:
2681 ScDocument& mrDoc;
2684 void MergeNumberFormatter(const ScDocument& rSrcDoc);
2686 void ImplCreateOptions(); // Suggestion: switch to on-demand?
2687 void ImplDeleteOptions();
2689 SC_DLLPUBLIC bool DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const;
2691 void UpdateDrawPrinter();
2692 void UpdateDrawLanguages();
2693 SC_DLLPUBLIC void InitClipPtrs( ScDocument* pSourceDoc );
2695 void LoadDdeLinks(SvStream& rStream);
2696 void SaveDdeLinks(SvStream& rStream) const;
2698 void DeleteAreaLinksOnTab( SCTAB nTab );
2699 void UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
2700 const ScRange& r, SCCOL nDx, SCROW nDy, SCTAB nDz );
2702 void CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks);
2704 bool HasPartOfMerged( const ScRange& rRange );
2706 public:
2707 SC_DLLPUBLIC ScTable* FetchTable( SCTAB nTab );
2708 const ScTable* FetchTable( SCTAB nTab ) const;
2710 ScRefCellValue GetRefCellValue( const ScAddress& rPos );
2711 private:
2712 ScRefCellValue GetRefCellValue( const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos );
2714 std::map< SCTAB, ScSortParam > mSheetSortParams;
2716 SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol ) const;
2717 SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
2718 void ReservePatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserve );
2720 void SharePooledResources( const ScDocument* pSrcDoc );
2722 void EndListeningIntersectedGroup(
2723 sc::EndListeningContext& rCxt, const ScAddress& rPos, std::vector<ScAddress>* pGroupPos );
2725 void EndListeningIntersectedGroups(
2726 sc::EndListeningContext& rCxt, const ScRange& rRange, std::vector<ScAddress>* pGroupPos );
2728 void EndListeningGroups( const std::vector<ScAddress>& rPosArray );
2729 void SetNeedsListeningGroups( const std::vector<ScAddress>& rPosArray );
2731 bool BroadcastHintInternal( const ScHint &rHint );
2734 typedef std::unique_ptr<ScDocument, o3tl::default_delete<ScDocument>> ScDocumentUniquePtr;
2737 * Instantiate this to ensure that subsequent modification of
2738 * the document will cause an assertion failure while this is
2739 * in-scope.
2741 struct ScMutationDisable
2743 #ifndef NDEBUG
2744 ScMutationDisable(ScDocument& rDocument, ScMutationGuardFlags nFlags)
2745 : mnFlagRestore(rDocument.mnMutationGuardFlags)
2746 , mrDocument(rDocument)
2748 assert((mnFlagRestore & nFlags) == 0);
2749 mrDocument.mnMutationGuardFlags |= static_cast<size_t>(nFlags);
2751 ~ScMutationDisable()
2753 mrDocument.mnMutationGuardFlags = mnFlagRestore;
2755 size_t mnFlagRestore;
2756 ScDocument& mrDocument;
2757 #else
2758 ScMutationDisable(ScDocument& rDocument, ScMutationGuardFlags nFlags)
2760 (void)rDocument; (void)nFlags;
2762 #endif
2766 * A pretty assertion that checks that the relevant bits in
2767 * the @nFlags are not set on the document at entry and exit.
2769 * Its primary use is for debugging threading. As such, an
2770 * @ScMutationDisable is created to forbid mutation, and this
2771 * condition is then asserted on at prominent sites that
2772 * mutate @nFlags.
2774 struct ScMutationGuard
2776 #ifndef NDEBUG
2777 ScMutationGuard(ScDocument& rDocument, ScMutationGuardFlags nFlags)
2778 : mnFlags(static_cast<size_t>(nFlags))
2779 , mrDocument(rDocument)
2781 assert((mrDocument.mnMutationGuardFlags & mnFlags) == 0);
2784 ~ScMutationGuard()
2786 assert((mrDocument.mnMutationGuardFlags & mnFlags) == 0);
2788 size_t mnFlags;
2789 ScDocument& mrDocument;
2790 #else
2791 ScMutationGuard(ScDocument& rDocument, ScMutationGuardFlags nFlags)
2793 (void)rDocument; (void)nFlags;
2795 #endif
2798 class ScDocShellRecalcGuard
2800 ScDocument& mrDoc;
2802 public:
2803 ScDocShellRecalcGuard(ScDocument& rDoc)
2804 : mrDoc(rDoc)
2806 assert(!mrDoc.IsInDocShellRecalc());
2807 mrDoc.SetDocShellRecalc(true);
2810 ~ScDocShellRecalcGuard()
2812 mrDoc.SetDocShellRecalc(false);
2816 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */