tdf#154546 skip dispatch when presenter controller is not set
[LibreOffice.git] / sc / inc / document.hxx
blob285fcf1a7d31b68a463b8784b4c11119fb61707c
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;
215 namespace sc {
217 typedef std::map<OUString, BitmapEx> IconSetBitmapMap;
221 namespace com::sun::star {
222 namespace lang {
223 struct EventObject;
225 namespace i18n {
226 class XBreakIterator;
228 namespace util {
229 class XModifyListener;
231 namespace embed {
232 class XEmbeddedObject;
234 namespace script::vba {
235 class XVBAEventProcessor;
237 namespace sheet {
238 struct TablePageBreakData;
242 namespace weld {
244 class Window;
248 #define SC_DOC_NEW 0xFFFF
250 #define SC_MACROCALL_ALLOWED 0
252 #define SC_ASIANKERNING_INVALID 0xff
254 enum ScDocumentMode
256 SCDOCMODE_DOCUMENT,
257 SCDOCMODE_CLIP,
258 SCDOCMODE_UNDO,
259 SCDOCMODE_FUNCTIONACCESS
262 enum CommentCaptionState
264 ALLSHOWN, // All comments captions are shown
265 ALLHIDDEN, // All comments captions are hidden
266 MIXED // There are comments in shown and hidden.
269 enum RangeNameScope
271 GLOBAL, // A range name can be defined
272 SHEET // with two scope on Manage Names dialog.
275 /// Represents the type of sheet geometry data.
276 enum class SheetGeomType
278 SIZES, // Column widths or row heights.
279 HIDDEN, // Hidden columns/rows.
280 FILTERED, // Filtered columns/rows.
281 GROUPS // Grouping of columns/rows.
284 struct ScDocStat
286 OUString aDocName;
287 SCTAB nTableCount;
288 sal_uInt64 nCellCount;
289 sal_uInt64 nFormulaCount;
290 sal_uInt16 nPageCount;
291 ScDocStat()
292 : nTableCount(0)
293 , nCellCount(0)
294 , nFormulaCount(0)
295 , nPageCount(0)
300 // DDE link modes
301 const sal_uInt8 SC_DDE_DEFAULT = 0;
302 const sal_uInt8 SC_DDE_ENGLISH = 1;
303 const sal_uInt8 SC_DDE_TEXT = 2;
304 const sal_uInt8 SC_DDE_IGNOREMODE = 255; /// For usage in FindDdeLink() only!
306 // During threaded calculation fields being mutated are kept in this struct
307 struct ScDocumentThreadSpecific
309 std::unique_ptr<ScRecursionHelper> xRecursionHelper; // information for recursive and iterative cell formulas
310 ScInterpreterContext* pContext = nullptr; // references the context passed around for easier access
313 /// Enumeration to determine which pieces of the code should not be mutated when set.
314 enum ScMutationGuardFlags
316 // Bit mask bits
317 CORE = 0x0001, /// Core calc data structures should not be mutated
320 typedef std::unique_ptr<ScTable, o3tl::default_delete<ScTable>> ScTableUniquePtr;
322 class ScDocument
324 friend class ScValueIterator;
325 friend class ScHorizontalValueIterator;
326 friend class ScDBQueryDataIterator;
327 friend class ScCellIterator;
328 template< ScQueryCellIteratorAccess accessType, ScQueryCellIteratorType queryType >
329 friend class ScQueryCellIteratorBase;
330 template< ScQueryCellIteratorAccess accessType >
331 friend class ScQueryCellIteratorAccessSpecific;
332 friend class ScHorizontalCellIterator;
333 friend class ScHorizontalAttrIterator;
334 friend class ScDocAttrIterator;
335 friend class ScAttrRectIterator;
336 friend class ScDocShell;
337 friend class ScDocRowHeightUpdater;
338 friend class ScColumnTextWidthIterator;
339 friend class ScTable;
340 friend class ScColumn;
341 friend struct ScRefCellValue;
342 friend class ScDocumentImport;
343 friend class sc::EditTextIterator;
344 friend struct ScMutationGuard;
345 friend struct ScMutationDisable;
347 typedef std::vector<ScTableUniquePtr> TableContainer;
349 public:
350 enum class HardRecalcState
352 OFF, /// normal calculation of dependencies
353 TEMPORARY, /// CalcAll() without broadcast/notify but setting up new listeners
354 ETERNAL /// no new listeners are setup, no broadcast/notify
357 private:
358 rtl::Reference<ScPoolHelper> mxPoolHelper;
360 std::shared_ptr<svl::SharedStringPool> mpCellStringPool;
361 std::unique_ptr<sc::DocumentLinkManager> mpDocLinkMgr;
363 std::shared_ptr<sc::FormulaGroupContext> mpFormulaGroupCxt;
364 bool mbFormulaGroupCxtBlockDiscard;
366 ScCalcConfig maCalcConfig;
368 ScUndoManager* mpUndoManager;
369 std::unique_ptr<ScFieldEditEngine> mpEditEngine; // uses pEditPool from xPoolHelper
370 std::unique_ptr<ScNoteEditEngine> mpNoteEngine; // uses pEditPool from xPoolHelper
371 SfxObjectShell* mpShell;
372 VclPtr<SfxPrinter> mpPrinter;
373 VclPtr<VirtualDevice> mpVirtualDevice_100th_mm;
374 std::unique_ptr<ScDrawLayer> mpDrawLayer; // SdrModel
375 rtl::Reference<XColorList> pColorList;
376 std::unique_ptr<ScValidationDataList> pValidationList; // validity
377 SvNumberFormatterIndexTable* pFormatExchangeList; // for application of number formats
378 TableContainer maTabs;
379 rtl::Reference<ScSheetLimits> mxSheetLimits;
380 std::vector<OUString> maTabNames; // for undo document, we need the information tab name <-> index
381 mutable std::unique_ptr<ScRangeName> pRangeName;
382 std::unique_ptr<ScDBCollection> pDBCollection;
383 std::unique_ptr<ScDPCollection> pDPCollection;
384 std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock;
385 std::unique_ptr<ScPatternAttr> pSelectionAttr; // Attributes of a block
386 ScFormulaCell* pFormulaTree; // formula tree (start)
387 ScFormulaCell* pEOFormulaTree; // formula tree (end), last cell
388 ScFormulaCell* pFormulaTrack; // BroadcastTrack (start)
389 ScFormulaCell* pEOFormulaTrack; // BroadcastTrack (end), last cell
390 std::unique_ptr<ScBroadcastAreaSlotMachine> pBASM; // BroadcastAreas
391 std::unique_ptr<ScChartListenerCollection> pChartListenerCollection;
392 std::unique_ptr<SvMemoryStream> pClipData;
393 std::unique_ptr<ScDetOpList> pDetOpList;
394 std::unique_ptr<ScChangeTrack> pChangeTrack;
395 std::unique_ptr<SfxBroadcaster> pUnoBroadcaster;
396 std::unique_ptr<ScUnoListenerCalls> pUnoListenerCalls;
397 std::unique_ptr<ScUnoRefList> pUnoRefUndoList;
398 std::unique_ptr<ScChangeViewSettings> pChangeViewSettings;
399 std::unique_ptr<ScScriptTypeData> pScriptTypeData;
400 std::unique_ptr<ScRefreshTimerControl> pRefreshTimerControl;
401 std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenCharacters;
402 std::unique_ptr<ScDBData> mpAnonymousDBData;
403 std::unique_ptr<sc::ExternalDataMapper> mpDataMapper;
405 std::unique_ptr<ScFieldEditEngine> pCacheFieldEditEngine;
407 std::unique_ptr<ScDocProtection> pDocProtection;
408 std::unique_ptr<ScClipParam> mpClipParam;
410 std::unique_ptr<ScExternalRefManager> pExternalRefMgr;
411 std::unique_ptr<ScMacroManager> mpMacroMgr;
413 // mutable for lazy construction
414 mutable std::unique_ptr< ScFormulaParserPool >
415 mxFormulaParserPool; /// Pool for all external formula parsers used by this document.
417 OUString aDocName; // optional: name of document
418 OUString aDocCodeName; // optional: name of document (twice?)
419 OUString maFileURL; // file URL for copy & paste
420 ScRangePairListRef xColNameRanges;
421 ScRangePairListRef xRowNameRanges;
423 std::unique_ptr<ScViewOptions> pViewOptions; // view options
424 std::unique_ptr<ScDocOptions> pDocOptions; // document options
425 std::unique_ptr<ScExtDocOptions> pExtDocOptions; // for import etc.
426 std::unique_ptr<ScClipOptions> mpClipOptions; // clipboard options
427 std::unique_ptr<ScConsolidateParam> pConsolidateDlgData;
429 std::unique_ptr<ScAutoNameCache> pAutoNameCache; // for automatic name lookup during CompileXML
431 std::unique_ptr<SfxItemSet> pPreviewFont; // convert to std::unique_ptr or whatever
432 ScStyleSheet* pPreviewCellStyle;
433 ScMarkData maPreviewSelection;
434 sal_Int64 nUnoObjectId; // counted up for UNO objects
436 ErrCode nRangeOverflowType; // used in (xml) loading for overflow warnings
438 ScRange aEmbedRange;
439 ScAddress aCurTextWidthCalcPos;
441 Idle aTrackIdle;
443 css::uno::Reference< css::script::vba::XVBAEventProcessor >
444 mxVbaEvents;
445 public:
446 /// list of ScInterpreterTableOpParams currently in use
447 std::vector<ScInterpreterTableOpParams*> m_TableOpList;
448 ScInterpreterTableOpParams aLastTableOpParams; // remember last params
450 private:
452 LanguageType eLanguage; // default language
453 LanguageType eCjkLanguage; // default language for asian text
454 LanguageType eCtlLanguage; // default language for complex text
455 rtl_TextEncoding eSrcSet; // during reading: source character set
457 /** The compiler grammar used in document storage. GRAM_PODF for ODF 1.1
458 documents, GRAM_ODFF for ODF 1.2 documents. */
459 formula::FormulaGrammar::Grammar eStorageGrammar;
461 sal_uInt64 nFormulaCodeInTree; // formula RPN in the formula tree
462 sal_uInt64 nXMLImportedFormulaCount; // progress count during XML import
463 sal_uInt16 nInterpretLevel; // >0 if in interpreter
464 sal_uInt16 nMacroInterpretLevel; // >0 if macro in interpreter
465 sal_uInt16 nInterpreterTableOpLevel; // >0 if in interpreter TableOp
467 ScDocumentThreadSpecific maNonThreaded;
469 // There can be only one ScDocument being calculated in a thread at a time, so we can use a
470 // plain thread_local static member.
471 thread_local static ScDocumentThreadSpecific maThreadSpecific;
473 mutable ScInterpreterContext maInterpreterContext;
475 std::shared_mutex mScLookupMutex; // protection for thread-unsafe parts of handling ScLookup
476 std::unique_ptr<ScSortedRangeCacheMap> mxScSortedRangeCache; // cache for unsorted lookups
478 static const sal_uInt16 nSrcVer; // file version (load/save)
479 sal_uInt16 nFormulaTrackCount;
480 HardRecalcState eHardRecalcState; // off, temporary, eternal
481 SCTAB nVisibleTab; // for OLE etc., don't use inside ScDocument
482 SCCOL nPosLeft; // for OLE etc., don't use inside ScDocument
483 SCROW nPosTop; // for OLE etc., don't use inside ScDocument
485 ScLkUpdMode eLinkMode;
487 bool bAutoCalc; // calculate automatically
488 bool bAutoCalcShellDisabled; // in/from/for ScDocShell disabled
489 // are there ForcedFormulas which have to be calculated
490 // in interaction with ScDocShell SetDocumentModified,
491 // AutoCalcShellDisabled and TrackFormulas
492 bool bForcedFormulaPending;
493 bool bCalculatingFormulaTree;
494 bool bIsClip;
495 bool bIsUndo;
496 bool bIsFunctionAccess;
497 bool bIsVisible; // set from view ctor
499 bool bIsEmbedded; // display/adjust Embedded area?
501 // no broadcast, construct no listener during insert from a different
502 // Doc (per filter or the like ), not until CompileAll / CalcAfterLoad
503 bool bInsertingFromOtherDoc;
504 bool bLoadingMedium;
505 bool bImportingXML; // special handling of formula text
506 bool bCalcingAfterLoad; // in CalcAfterLoad TRUE
507 // don't construct/destruct listeners temporarily
508 bool bNoListening;
509 bool mbIdleEnabled;
510 bool bInLinkUpdate; // TableLink or AreaLink
511 bool bChartListenerCollectionNeedsUpdate;
512 // are/were there RC_FORCED formula cells in the document (if set once to TRUE then set forever)
513 bool bHasForcedFormulas;
514 // is the Doc being destroyed? (no Notify-Tracking etc. needed anymore)
515 bool bInDtorClear;
516 // expand reference if insert column/row takes place at the border
517 // of a reference
518 // is fetched in each UpdateReference from InputOptions,
519 // assigned, and restored at the end of UpdateReference
520 bool bExpandRefs;
521 // for detective update, is set for each change of a formula
522 bool bDetectiveDirty;
523 // If the pointer is set, formula cells will not be automatically grouped into shared formula groups,
524 // instead the range will be extended to contain all such cells.
525 std::unique_ptr< ScRange > pDelayedFormulaGrouping;
526 // If non-empty, ScColumn::StartListeningFormulaCells() calls may be delayed using this,
527 // avoiding repeated calling for the same cells in the given range. The function will be called once
528 // later for all the cells in the range.
529 std::unordered_map< ScColumn*, std::pair<SCROW, SCROW>> pDelayedStartListeningFormulaCells;
530 // Cells will not delete their broadcasters if delayed, avoiding possible extensive mdds vector changes.
531 bool bDelayedDeletingBroadcasters;
533 bool bLinkFormulaNeedingCheck; // valid only after loading, for ocDde and ocWebservice
535 CharCompressType nAsianCompression;
536 sal_uInt8 nAsianKerning;
538 bool bPastingDrawFromOtherDoc;
540 sal_uInt8 nInDdeLinkUpdate; // originating DDE links (stacked bool)
542 bool bInUnoBroadcast;
543 bool bInUnoListenerCall;
544 sal_uInt32 nAdjustHeightLock;
545 formula::FormulaGrammar::Grammar eGrammar;
547 mutable bool bStyleSheetUsageInvalid;
549 bool mbUndoEnabled:1;
550 bool mbExecuteLinkEnabled:1;
551 bool mbChangeReadOnlyEnabled:1; // allow changes in read-only document (for API import filters)
552 bool mbStreamValidLocked:1;
553 bool mbUserInteractionEnabled:1; // whether or not to launch any kind of interactive dialogs.
555 sal_Int16 mnNamedRangesLockCount;
557 std::set<ScFormulaCell*> maSubTotalCells;
560 bool mbEmbedFonts : 1;
561 bool mbEmbedUsedFontsOnly : 1;
562 bool mbEmbedFontScriptLatin : 1;
563 bool mbEmbedFontScriptAsian : 1;
564 bool mbEmbedFontScriptComplex : 1;
566 sal_Int32 mnImagePreferredDPI;
568 std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap;
570 bool mbTrackFormulasPending : 1;
571 bool mbFinalTrackFormulas : 1;
572 // This indicates if a ScDocShell::DoRecalc() or ScDocShell::DoHardRecalc() is in progress.
573 bool mbDocShellRecalc : 1;
574 // This indicates if a ScOutputData::LayoutStrings() is in progress.
575 bool mbLayoutStrings : 1;
577 size_t mnMutationGuardFlags;
579 public:
580 bool IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBorder);
581 void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge);
583 bool IsEmbedFonts() const { return mbEmbedFonts; }
584 bool IsEmbedUsedFontsOnly() const { return mbEmbedUsedFontsOnly; }
585 bool IsEmbedFontScriptLatin() const { return mbEmbedFontScriptLatin; }
586 bool IsEmbedFontScriptAsian() const { return mbEmbedFontScriptAsian; }
587 bool IsEmbedFontScriptComplex() const { return mbEmbedFontScriptComplex; }
589 void SetEmbedFonts(bool bUse) { mbEmbedFonts = bUse; }
590 void SetEmbedUsedFontsOnly(bool bUse) { mbEmbedUsedFontsOnly = bUse; }
591 void SetEmbedFontScriptLatin(bool bUse) { mbEmbedFontScriptLatin = bUse; }
592 void SetEmbedFontScriptAsian(bool bUse) { mbEmbedFontScriptAsian = bUse; }
593 void SetEmbedFontScriptComplex(bool bUse) { mbEmbedFontScriptComplex = bUse; }
595 void SetImagePreferredDPI(sal_Int32 nValue) { mnImagePreferredDPI = nValue; }
596 sal_Int32 GetImagePreferredDPI() { return mnImagePreferredDPI; }
598 SC_DLLPUBLIC sal_uInt64 GetCellCount() const; // all cells
599 SC_DLLPUBLIC sal_uInt64 GetFormulaGroupCount() const; // all cells
600 sal_uInt64 GetCodeCount() const; // RPN-Code in formulas
601 DECL_LINK( GetUserDefinedColor, sal_uInt16, Color* );
602 // number formatter
603 public:
604 SC_DLLPUBLIC ScDocument( ScDocumentMode eMode = SCDOCMODE_DOCUMENT,
605 SfxObjectShell* pDocShell = nullptr );
606 SC_DLLPUBLIC ~ScDocument();
608 void SetName( const OUString& r ) { aDocName = r; }
609 const OUString& GetCodeName() const { return aDocCodeName; }
610 void SetCodeName( const OUString& r ) { aDocCodeName = r; }
611 const OUString& GetFileURL() const { return maFileURL; }
613 void GetDocStat( ScDocStat& rDocStat );
615 SC_DLLPUBLIC void InitDrawLayer( SfxObjectShell* pDocShell = nullptr );
617 ScInterpreterContext& GetNonThreadedContext() const
619 assert(!IsThreadedGroupCalcInProgress());
620 return maInterpreterContext;
622 // Uses thread_local.
623 ScInterpreterContext& GetThreadedContext() const
625 return IsThreadedGroupCalcInProgress() ? *maThreadSpecific.pContext : GetNonThreadedContext();
627 void SetupContextFromNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
628 void MergeContextBackIntoNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
629 void SetThreadedGroupCalcInProgress( bool set ) { (void)this; ScGlobal::bThreadedGroupCalcInProgress = set; }
630 bool IsThreadedGroupCalcInProgress() const { (void)this; return ScGlobal::bThreadedGroupCalcInProgress; }
632 SC_DLLPUBLIC sfx2::LinkManager* GetLinkManager();
633 SC_DLLPUBLIC const sfx2::LinkManager* GetLinkManager() const;
635 sc::DocumentLinkManager& GetDocLinkManager();
636 const sc::DocumentLinkManager& GetDocLinkManager() const;
638 SC_DLLPUBLIC const ScDocOptions& GetDocOptions() const;
639 SC_DLLPUBLIC void SetDocOptions( const ScDocOptions& rOpt );
640 SC_DLLPUBLIC const ScViewOptions& GetViewOptions() const;
641 SC_DLLPUBLIC void SetViewOptions( const ScViewOptions& rOpt );
642 void SetPrintOptions();
644 ScExtDocOptions* GetExtDocOptions() { return pExtDocOptions.get(); }
645 SC_DLLPUBLIC void SetExtDocOptions( std::unique_ptr<ScExtDocOptions> pNewOptions );
647 ScClipOptions* GetClipOptions() { return mpClipOptions.get(); }
648 void SetClipOptions(std::unique_ptr<ScClipOptions> pClipOptions);
650 SC_DLLPUBLIC void GetLanguage( LanguageType& rLatin, LanguageType& rCjk, LanguageType& rCtl ) const;
651 void SetLanguage( LanguageType eLatin, LanguageType eCjk, LanguageType eCtl );
653 void SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pData );
654 const ScConsolidateParam* GetConsolidateDlgData() const { return pConsolidateDlgData.get(); }
656 void Clear( bool bFromDestructor = false );
658 std::unique_ptr<ScFieldEditEngine> CreateFieldEditEngine();
659 void DisposeFieldEditEngine(std::unique_ptr<ScFieldEditEngine>& rpEditEngine);
662 * Get all range names that are local to each table. It only returns
663 * non-empty range name set.
665 SC_DLLPUBLIC void GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rRangeNames) const;
666 SC_DLLPUBLIC void SetAllRangeNames(const std::map<OUString, ScRangeName>& rRangeMap);
667 SC_DLLPUBLIC void GetRangeNameMap(std::map<OUString, ScRangeName*>& rRangeName);
668 SC_DLLPUBLIC ScRangeName* GetRangeName(SCTAB nTab) const;
669 SC_DLLPUBLIC ScRangeName* GetRangeName() const;
670 void SetRangeName(SCTAB nTab, std::unique_ptr<ScRangeName> pNew);
671 void SetRangeName( std::unique_ptr<ScRangeName> pNewRangeName );
672 bool IsAddressInRangeName( RangeNameScope eScope, const ScAddress& rAddress);
674 /** Find a named expression / range name in either global or a local scope.
675 @param nTab
676 If <0 search nIndex in global scope, if >=0 search nIndex in scope of nTab.
677 @param nIndex
678 Index of named expression / range name.
679 @return nullptr if indexed name not found.
681 ScRangeData* FindRangeNameBySheetAndIndex( SCTAB nTab, sal_uInt16 nIndex ) const;
683 /** Recursively find all named expressions that directly or indirectly
684 (nested) reference a given sheet, starting from a given named
685 expression nTokenTab/nTokenIndex.
687 Used to collect all named expressions/ranges that will need to be
688 copied along when copying sheets.
690 The different tab/sheets passed cater for the situation that a sheet is
691 copied and was already inserted and global names are already adjusted
692 but the sheet-local names of the shifted original sheet are not yet. If
693 no sheet was inserted and global and local names' references not
694 updated yet, then all 4 tab arguments would be identical.
696 @param nTokenTab
697 Tab/sheet on which to find the name, -1 if global scope.
698 For example obtained from ocName token.
700 @param nTokenIndex
701 Index of named expression. For example obtained from ocName token.
703 @param nGlobalRefTab
704 Tab to check if used in global names.
706 @param nLocalRefTab
707 Tab to check if used in sheet-local names.
709 @param nOldTokenTab
710 The original tab of the copied sheet, used as sheet-local
711 base position for relative references.
713 @param nOldTokenTabReplacement
714 The replacement to use for relative references if the name
715 encountered uses nOldTokenTab as base position.
717 @param bSameDoc
718 FALSE if collecting names for a sheet to be copied to another
719 document. Then all names encountered are considered to be
720 referencing the sheet. Else TRUE if collecting names to be
721 copied into the same document.
723 @param nRecursion
724 Recursion guard, initialize with 0.
726 bool FindRangeNamesReferencingSheet( sc::UpdatedRangeNames& rIndexes,
727 SCTAB nTokenTab, const sal_uInt16 nTokenIndex,
728 SCTAB nGlobalRefTab, SCTAB nLocalRefTab, SCTAB nOldTokenTab, SCTAB nOldTokenTabReplacement,
729 bool bSameDoc, int nRecursion ) const;
731 /** If necessary (name references sheet rOldPos.Tab()) copy and adjust
732 named expression/range from sheet-local to sheet-local, or global to
733 sheet-local if bGlobalNamesToLocal==true.
735 Also copies nested names and adjusts the ocName tokens of the calling name.
737 @param rSheet
738 On entry, the original sheet of the named expression/range, <0 global.
739 On return TRUE, the new sheet. Else unchanged.
741 @param rIndex
742 On entry, the original index of the named expression/range.
743 On return TRUE, the new index, or 0 if a new copied name couldn't be inserted. Else unchanged.
745 @param rpRangeData
746 On entry, the pointer to the original named expression/range.
747 On return TRUE, the pointer to the new copied name, or nullptr if hits happened.
749 @param rNewPos
750 New position of formula cell if called for that, else new base
751 position of a to be created new name adjusted for Tab.
752 rNewPos.nTab MUST point to the new sheet copied to.
754 @param rOldPos
755 Old position of formula cell if called for that, else base
756 position of the existing name adjusted for Tab.
757 rOldPos.nTab MUST point to the old sheet copied from.
759 @param bGlobalNamesToLocal
760 If TRUE, affected global names are copied to sheet-local names.
761 If FALSE, global names are copied to global names in another document.
763 @param bUsedByFormula
764 If TRUE, forces a global name to be affected/used.
765 If FALSE, a global name is only affected if it evaluates to be
766 referencing the sheet.
768 @return TRUE if copied and caller may need to evaluate rpRangeData and rSheet and rIndex.
769 FALSE if nothing to be done.
771 bool CopyAdjustRangeName( SCTAB& rSheet, sal_uInt16& rIndex, ScRangeData*& rpRangeData, ScDocument& rNewDoc,
772 const ScAddress& rNewPos, const ScAddress& rOldPos, const bool bGlobalNamesToLocal,
773 const bool bUsedByFormula ) const;
776 * Call this immediately before updating all named ranges.
778 SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate( const std::map<OUString, ScRangeName>& rRangeMap );
779 SC_DLLPUBLIC void PreprocessRangeNameUpdate();
780 SC_DLLPUBLIC void PreprocessDBDataUpdate();
782 * Call this immediately after updating named ranges.
784 SC_DLLPUBLIC void CompileHybridFormula();
787 * Insert a new named expression to the global scope.
789 * @param rName name for the expression.
790 * @param rPos base position.
791 * @param rExpr formula expression to be associated with the name. The
792 * current grammar is used to compile this expression.
794 * @return true if inserted successfully, false otherwise.
796 bool InsertNewRangeName( const OUString& rName, const ScAddress& rPos, const OUString& rExpr );
799 * Insert a new named expression to a sheet-local scope.
801 * @param nTab sheet for local scope.
802 * @param rName name for the expression.
803 * @param rPos base position.
804 * @param rExpr formula expression to be associated with the name. The
805 * current grammar is used to compile this expression.
807 * @return true if inserted successfully, false otherwise.
809 bool InsertNewRangeName( SCTAB nTab, const OUString& rName, const ScAddress& rPos, const OUString& rExpr );
811 /** Obtain the sheet separator corresponding to the document's grammar.
813 @return '.' for our own grammars, '!' for Excel grammars.
815 SC_DLLPUBLIC sal_Unicode GetSheetSeparator() const;
817 SCTAB GetMaxTableNumber() const { return static_cast<SCTAB>(maTabs.size()) - 1; }
819 ScRangePairList* GetColNameRanges() { return xColNameRanges.get(); }
820 ScRangePairList* GetRowNameRanges() { return xRowNameRanges.get(); }
821 ScRangePairListRef& GetColNameRangesRef() { return xColNameRanges; }
822 ScRangePairListRef& GetRowNameRangesRef() { return xRowNameRanges; }
824 SC_DLLPUBLIC SCCOL ClampToAllocatedColumns(SCTAB nTab, SCCOL nCol) const;
825 SC_DLLPUBLIC SCCOL GetAllocatedColumnsCount(SCTAB nTab) const;
827 SC_DLLPUBLIC ScDBCollection* GetDBCollection() const { return pDBCollection.get();}
828 void SetDBCollection( std::unique_ptr<ScDBCollection> pNewDBCollection,
829 bool bRemoveAutoFilter = false );
830 const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const;
831 ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion);
832 SC_DLLPUBLIC const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
833 SC_DLLPUBLIC ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
834 void RefreshDirtyTableColumnNames();
835 SC_DLLPUBLIC sc::ExternalDataMapper& GetExternalDataMapper();
837 SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock( const ScRange& rBlock, OUString& rName,
838 bool* pSheetLocal = nullptr ) const;
840 SC_DLLPUBLIC bool HasPivotTable() const;
841 SC_DLLPUBLIC ScDPCollection* GetDPCollection();
842 SC_DLLPUBLIC const ScDPCollection* GetDPCollection() const;
843 SC_DLLPUBLIC ScDPObject* GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
844 SC_DLLPUBLIC ScDPObject* GetDPAtCursor(ScAddress const& rAddress) const
846 return GetDPAtCursor(rAddress.Col(), rAddress.Row(), rAddress.Tab());
848 SC_DLLPUBLIC bool HasDataPilotAtPosition(ScAddress const& rAddress) const
850 return GetDPAtCursor(rAddress) != nullptr;
852 ScDPObject* GetDPAtBlock( const ScRange& rBlock ) const;
854 void StopTemporaryChartLock();
856 void EnsureGraphicNames();
858 SdrObject* GetObjectAtPoint( SCTAB nTab, const Point& rPos );
859 bool HasChartAtPoint( SCTAB nTab, const Point& rPos, OUString& rName );
861 css::uno::Reference< css::chart2::XChartDocument > GetChartByName( std::u16string_view rChartName );
863 SC_DLLPUBLIC void GetChartRanges( std::u16string_view rChartName, std::vector< ScRangeList >& rRanges, const ScDocument& rSheetNameDoc );
864 void SetChartRanges( std::u16string_view rChartName, const std::vector< ScRangeList >& rRanges );
866 void UpdateChartArea( const OUString& rChartName, const ScRange& rNewArea,
867 bool bColHeaders, bool bRowHeaders, bool bAdd );
868 void UpdateChartArea( const OUString& rChartName,
869 const ScRangeListRef& rNewList,
870 bool bColHeaders, bool bRowHeaders, bool bAdd );
871 void GetOldChartParameters( std::u16string_view rName,
872 ScRangeList& rRanges, bool& rColHeaders, bool& rRowHeaders );
873 css::uno::Reference<
874 css::embed::XEmbeddedObject >
875 FindOleObjectByName( std::u16string_view rName );
877 SC_DLLPUBLIC void MakeTable( SCTAB nTab,bool _bNeedsNameCheck = true );
879 SCTAB GetVisibleTab() const { return nVisibleTab; }
880 SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab) { nVisibleTab = nTab; }
881 SCCOL GetPosLeft() const { return nPosLeft; }
882 SC_DLLPUBLIC void SetPosLeft(SCCOL nCol) { nPosLeft = nCol; }
883 SCROW GetPosTop() const { return nPosTop; }
884 SC_DLLPUBLIC void SetPosTop(SCROW nRow) { nPosTop = nRow; }
886 SC_DLLPUBLIC bool HasTable( SCTAB nTab ) const;
887 SC_DLLPUBLIC bool GetHashCode( SCTAB nTab, sal_Int64& rHashCode) const;
888 SC_DLLPUBLIC bool GetName( SCTAB nTab, OUString& rName ) const;
889 SC_DLLPUBLIC bool GetCodeName( SCTAB nTab, OUString& rName ) const;
890 SC_DLLPUBLIC bool SetCodeName( SCTAB nTab, const OUString& rName );
891 SC_DLLPUBLIC bool GetTable( const OUString& rName, SCTAB& rTab ) const;
892 SC_DLLPUBLIC SCCOL MaxCol() const { return mxSheetLimits->mnMaxCol; }
893 SC_DLLPUBLIC SCROW MaxRow() const { return mxSheetLimits->mnMaxRow; }
894 SC_DLLPUBLIC SCCOL GetMaxColCount() const { return mxSheetLimits->GetMaxColCount(); }
895 SC_DLLPUBLIC SCROW GetMaxRowCount() const { return mxSheetLimits->GetMaxRowCount(); }
896 SC_DLLPUBLIC OUString MaxRowAsString() const { return mxSheetLimits->MaxRowAsString(); }
897 SC_DLLPUBLIC OUString MaxColAsString() const { return mxSheetLimits->MaxColAsString(); }
898 ScSheetLimits& GetSheetLimits() const { return *mxSheetLimits; }
899 [[nodiscard]] bool ValidCol(SCCOL nCol) const { return ::ValidCol(nCol, mxSheetLimits->mnMaxCol); }
900 [[nodiscard]] bool ValidRow(SCROW nRow) const { return ::ValidRow(nRow, mxSheetLimits->mnMaxRow); }
901 [[nodiscard]] bool ValidColRow(SCCOL nCol, SCROW nRow) const { return ::ValidColRow(nCol, nRow, MaxCol(), MaxRow()); }
902 [[nodiscard]] bool ValidColRowTab(SCCOL nCol, SCROW nRow, SCTAB nTab) const { return ::ValidColRowTab(nCol, nRow, nTab, MaxCol(), MaxRow()); }
903 [[nodiscard]] bool ValidRange(const ScRange& rRange) const { return ::ValidRange(rRange, MaxCol(), MaxRow()); }
904 [[nodiscard]] bool ValidAddress(const ScAddress& rAddress) const { return ::ValidAddress(rAddress, MaxCol(), MaxRow()); }
905 [[nodiscard]] SCCOL SanitizeCol( SCCOL nCol ) const { return ::SanitizeCol(nCol, MaxCol()); }
906 [[nodiscard]] SCROW SanitizeRow( SCROW nRow ) const { return ::SanitizeRow(nRow, MaxRow()); }
908 SC_DLLPUBLIC std::vector<OUString> GetAllTableNames() const;
910 OUString GetCopyTabName(SCTAB nTab) const;
912 SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, std::unique_ptr<ScDBData> pDBData);
913 SC_DLLPUBLIC ScDBData* GetAnonymousDBData(SCTAB nTab);
915 /** One document global anonymous database range for temporary operations,
916 used if the corresponding sheet-local anonymous database range is
917 already used with AutoFilter and range differs. Not stored in document
918 files. */
919 SC_DLLPUBLIC void SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData);
920 SC_DLLPUBLIC ScDBData* GetAnonymousDBData();
922 SC_DLLPUBLIC SCTAB GetTableCount() const;
923 SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; }
925 SC_DLLPUBLIC ScDocProtection* GetDocProtection() const;
926 SC_DLLPUBLIC void SetDocProtection(const ScDocProtection* pProtect);
927 SC_DLLPUBLIC bool IsDocProtected() const;
928 bool IsDocEditable() const;
929 SC_DLLPUBLIC bool IsTabProtected( SCTAB nTab ) const;
930 SC_DLLPUBLIC const ScTableProtection* GetTabProtection(SCTAB nTab) const;
931 SC_DLLPUBLIC void SetTabProtection(SCTAB nTab, const ScTableProtection* pProtect);
932 void CopyTabProtection(SCTAB nTabSrc, SCTAB nTabDest);
934 void LockTable(SCTAB nTab);
935 void UnlockTable(SCTAB nTab);
937 bool IsBlockEditable( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
938 SCCOL nEndCol, SCROW nEndRow,
939 bool* pOnlyNotBecauseOfMatrix = nullptr,
940 bool bNoMatrixAtAll = false ) const;
941 bool IsSelectionEditable( const ScMarkData& rMark,
942 bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
943 bool HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nStartRow,
944 SCCOL nEndCol, SCROW nEndRow,
945 const ScMarkData& rMark ) const;
947 bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCTAB nTab, SCCOLROW nStart, SCCOLROW nEnd ) const;
948 bool IsEditActionAllowed( sc::ColRowEditAction eAction, const ScMarkData& rMark, SCCOLROW nStart, SCCOLROW nEnd ) const;
950 SC_DLLPUBLIC bool GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix );
952 bool IsEmbedded() const { return bIsEmbedded;}
953 void GetEmbedded( ScRange& rRange ) const;
954 void SetEmbedded( const ScRange& rRange );
955 void ResetEmbedded();
956 tools::Rectangle GetEmbeddedRect() const; // 1/100 mm
957 void SetEmbedded( SCTAB nTab, const tools::Rectangle& rRect ); // from VisArea (1/100 mm)
959 static SC_DLLPUBLIC bool ValidTabName( const OUString& rName );
961 SC_DLLPUBLIC bool ValidNewTabName( const OUString& rName ) const;
962 SC_DLLPUBLIC void CreateValidTabName(OUString& rName) const;
963 SC_DLLPUBLIC void CreateValidTabNames(std::vector<OUString>& aNames, SCTAB nCount) const;
965 void AppendTabOnLoad(const OUString& rName);
966 void SetTabNameOnLoad(SCTAB nTab, const OUString& rName);
967 void InvalidateStreamOnSave();
969 SC_DLLPUBLIC bool InsertTab( SCTAB nPos, const OUString& rName,
970 bool bExternalDocument = false, bool bUndoDeleteTab = false );
972 SC_DLLPUBLIC bool InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
973 bool bNamesValid = false );
974 SC_DLLPUBLIC bool DeleteTabs( SCTAB nTab, SCTAB nSheets );
975 SC_DLLPUBLIC bool DeleteTab( SCTAB nTab );
976 SC_DLLPUBLIC bool RenameTab( SCTAB nTab, const OUString& rName,
977 bool bExternalDocument = false );
978 bool MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress = nullptr );
979 SC_DLLPUBLIC bool CopyTab( SCTAB nOldPos, SCTAB nNewPos,
980 const ScMarkData* pOnlyMarked = nullptr );
981 SC_DLLPUBLIC sal_uLong TransferTab(ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos,
982 bool bInsertNew = true,
983 bool bResultsOnly = false );
984 SC_DLLPUBLIC void TransferDrawPage(const ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos);
985 SC_DLLPUBLIC void SetVisible( SCTAB nTab, bool bVisible );
986 SC_DLLPUBLIC bool IsVisible( SCTAB nTab ) const;
987 bool IsStreamValid( SCTAB nTab ) const;
988 void SetStreamValid( SCTAB nTab, bool bSet, bool bIgnoreLock = false );
989 void LockStreamValid( bool bLock );
990 bool IsStreamValidLocked() const { return mbStreamValidLocked; }
991 bool IsPendingRowHeights( SCTAB nTab ) const;
992 void SetPendingRowHeights( SCTAB nTab, bool bSet );
993 SC_DLLPUBLIC void SetLayoutRTL( SCTAB nTab, bool bRTL, ScObjectHandling eObjectHandling = ScObjectHandling::RecalcPosMode);
994 SC_DLLPUBLIC bool IsLayoutRTL( SCTAB nTab ) const;
995 SC_DLLPUBLIC bool IsNegativePage( SCTAB nTab ) const;
996 SC_DLLPUBLIC void SetScenario( SCTAB nTab, bool bFlag );
997 SC_DLLPUBLIC bool IsScenario( SCTAB nTab ) const;
998 SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString& rComment,
999 Color& rColor, ScScenarioFlags &rFlags) const;
1000 SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString& rComment,
1001 const Color& rColor, ScScenarioFlags nFlags);
1002 SC_DLLPUBLIC Color GetTabBgColor( SCTAB nTab ) const;
1003 SC_DLLPUBLIC void SetTabBgColor( SCTAB nTab, const Color& rColor );
1004 SC_DLLPUBLIC bool IsDefaultTabBgColor( SCTAB nTab ) const;
1005 void GetScenarioFlags(SCTAB nTab, ScScenarioFlags &rFlags) const;
1006 SC_DLLPUBLIC bool IsActiveScenario( SCTAB nTab ) const;
1007 SC_DLLPUBLIC void SetActiveScenario( SCTAB nTab, bool bActive ); // only for Undo etc.
1008 SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const;
1009 SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const { return eGrammar;}
1010 SC_DLLPUBLIC void SetGrammar( formula::FormulaGrammar::Grammar eGram );
1011 SC_DLLPUBLIC ScLinkMode GetLinkMode( SCTAB nTab ) const;
1012 bool IsLinked( SCTAB nTab ) const;
1013 SC_DLLPUBLIC OUString GetLinkDoc( SCTAB nTab ) const;
1014 OUString GetLinkFlt( SCTAB nTab ) const;
1015 OUString GetLinkOpt( SCTAB nTab ) const;
1016 SC_DLLPUBLIC OUString GetLinkTab( SCTAB nTab ) const;
1017 sal_uLong GetLinkRefreshDelay( SCTAB nTab ) const;
1018 void SetLink( SCTAB nTab, ScLinkMode nMode, const OUString& rDoc,
1019 const OUString& rFilter, const OUString& rOptions,
1020 const OUString& rTabName, sal_uLong nRefreshDelay );
1021 bool HasLink( std::u16string_view rDoc,
1022 std::u16string_view rFilter, std::u16string_view rOptions ) const;
1023 SC_DLLPUBLIC bool LinkExternalTab( SCTAB& nTab, const OUString& aDocTab,
1024 const OUString& aFileName,
1025 const OUString& aTabName );
1027 bool HasExternalRefManager() const { return bool(pExternalRefMgr); }
1028 SC_DLLPUBLIC ScExternalRefManager* GetExternalRefManager() const;
1029 bool IsInExternalReferenceMarking() const;
1030 void MarkUsedExternalReferences();
1031 bool MarkUsedExternalReferences( const ScTokenArray& rArr, const ScAddress& rPos );
1033 /** Returns the pool containing external formula parsers. Creates the pool
1034 on first call. */
1035 ScFormulaParserPool& GetFormulaParserPool() const;
1037 bool HasAreaLinks() const;
1038 void UpdateExternalRefLinks(weld::Window* pWin);
1039 void UpdateAreaLinks();
1041 // originating DDE links
1042 void IncInDdeLinkUpdate() { if ( nInDdeLinkUpdate < 255 ) ++nInDdeLinkUpdate; }
1043 void DecInDdeLinkUpdate() { if ( nInDdeLinkUpdate ) --nInDdeLinkUpdate; }
1044 bool IsInDdeLinkUpdate() const { return nInDdeLinkUpdate != 0; }
1046 SC_DLLPUBLIC void CopyDdeLinks( ScDocument& rDestDoc ) const;
1048 /** Tries to find a DDE link with the specified connection data.
1049 @param rnDdePos (out-param) Returns the index of the DDE link (does not include other links from link manager).
1050 @return true = DDE link found, rnDdePos valid. */
1051 SC_DLLPUBLIC bool FindDdeLink( std::u16string_view rAppl, std::u16string_view rTopic,
1052 std::u16string_view rItem, sal_uInt8 nMode, size_t& rnDdePos );
1054 /** Returns the connection data of the specified DDE link.
1055 @param nDdePos Index of the DDE link (does not include other links from link manager).
1056 @param rAppl (out-param) The application name.
1057 @param rTopic (out-param) The DDE topic.
1058 @param rItem (out-param) The DDE item.
1059 @return true = DDE link found, out-parameters valid. */
1060 bool GetDdeLinkData( size_t nDdePos, OUString& rAppl, OUString& rTopic, OUString& rItem ) const;
1061 /** Returns the link mode of the specified DDE link.
1062 @param nDdePos Index of the DDE link (does not include other links from link manager).
1063 @param rnMode (out-param) The link mode of the specified DDE link.
1064 @return true = DDE link found, rnMode valid. */
1065 bool GetDdeLinkMode( size_t nDdePos, sal_uInt8& rnMode ) const;
1066 /** Returns the result matrix of the specified DDE link.
1067 @param nDdePos Index of the DDE link (does not include other links from link manager).
1068 @return The result matrix, if the DDE link has been found, 0 otherwise. */
1069 SC_DLLPUBLIC const ScMatrix* GetDdeLinkResultMatrix( size_t nDdePos ) const;
1071 /** Tries to find a DDE link or creates a new, if not extant.
1072 @param pResults If not 0, sets the matrix as DDE link result matrix (also for existing links).
1073 @return true = DDE link found; false = Unpredictable error occurred, no DDE link created. */
1074 SC_DLLPUBLIC bool CreateDdeLink( const OUString& rAppl, const OUString& rTopic, const OUString& rItem, sal_uInt8 nMode, const ScMatrixRef& pResults );
1075 /** Sets a result matrix for the specified DDE link.
1076 @param nDdePos Index of the DDE link (does not include other links from link manager).
1077 @param pResults The array containing all results of the DDE link (intrusive-ref-counted, do not delete).
1078 @return true = DDE link found and matrix set. */
1079 bool SetDdeLinkResultMatrix( size_t nDdePos, const ScMatrixRef& pResults );
1081 SfxBindings* GetViewBindings();
1082 SfxObjectShell* GetDocumentShell() const { return mpShell; }
1083 SC_DLLPUBLIC ScDrawLayer* GetDrawLayer() { return mpDrawLayer.get(); }
1084 SC_DLLPUBLIC const ScDrawLayer* GetDrawLayer() const { return mpDrawLayer.get(); }
1085 SfxBroadcaster* GetDrawBroadcaster(); // to avoid header
1086 void BeginDrawUndo();
1088 void BeginUnoRefUndo();
1089 bool HasUnoRefUndo() const { return ( pUnoRefUndoList != nullptr ); }
1090 [[nodiscard]]
1091 std::unique_ptr<ScUnoRefList> EndUnoRefUndo(); // must be deleted by caller!
1092 sal_Int64 GetNewUnoId() { return ++nUnoObjectId; }
1093 void AddUnoRefChange( sal_Int64 nId, const ScRangeList& rOldRanges );
1095 static bool IsChart( const SdrObject* pObject );
1097 void UpdateChartRef( UpdateRefMode eUpdateRefMode,
1098 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1099 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1100 SCCOL nDx, SCROW nDy, SCTAB nDz );
1101 //! only assigns the new RangeList, no ChartListener or the like
1102 void SetChartRangeList( std::u16string_view rChartName,
1103 const ScRangeListRef& rNewRangeListRef );
1105 void StartAnimations( SCTAB nTab );
1107 bool HasBackgroundDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const;
1108 bool HasAnyDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const;
1110 const ScSheetEvents* GetSheetEvents( SCTAB nTab ) const;
1111 void SetSheetEvents( SCTAB nTab, std::unique_ptr<ScSheetEvents> pNew );
1112 bool HasSheetEventScript( SCTAB nTab, ScSheetEventId nEvent, bool bWithVbaEvents = false ) const;
1113 bool HasAnySheetEventScript( ScSheetEventId nEvent, bool bWithVbaEvents = false ) const; // on any sheet
1115 bool HasAnyCalcNotification() const;
1116 bool HasCalcNotification( SCTAB nTab ) const;
1117 void SetCalcNotification( SCTAB nTab );
1118 void ResetCalcNotifications();
1120 SC_DLLPUBLIC ScOutlineTable* GetOutlineTable( SCTAB nTab, bool bCreate = false );
1121 bool SetOutlineTable( SCTAB nTab, const ScOutlineTable* pNewOutline );
1123 void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow,
1124 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1126 bool DoSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
1127 void RemoveSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
1128 bool TestRemoveSubTotals( SCTAB nTab, const ScSubTotalParam& rParam );
1129 bool HasSubTotalCells( const ScRange& rRange );
1131 SC_DLLPUBLIC void EnsureTable( SCTAB nTab );
1133 // return TRUE = number format is set
1134 SC_DLLPUBLIC bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
1135 const ScSetStringParam * pParam = nullptr );
1136 SC_DLLPUBLIC bool SetString( const ScAddress& rPos, const OUString& rString,
1137 const ScSetStringParam* pParam = nullptr );
1140 * This method manages the lifecycle of the passed edit text object. When
1141 * the text is successfully inserted, the cell takes over the ownership of
1142 * the text object. If not, the text object gets deleted.
1144 * <p>The caller must ensure that the passed edit text object <i>uses the
1145 * SfxItemPool instance returned from ScDocument::GetEditPool()</i>.
1146 * This is very important.</p>
1148 SC_DLLPUBLIC bool SetEditText( const ScAddress& rPos, std::unique_ptr<EditTextObject> pEditText );
1149 void SetEditText( const ScAddress& rPos, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
1150 SC_DLLPUBLIC void SetEditText( const ScAddress& rPos, const OUString& rStr );
1151 SC_DLLPUBLIC SCROW GetFirstEditTextRow( const ScRange& rRange ) const;
1154 * Call this if you are not sure whether to put this as an edit text or a
1155 * simple text.
1157 SC_DLLPUBLIC void SetTextCell( const ScAddress& rPos, const OUString& rStr );
1158 void SetEmptyCell( const ScAddress& rPos );
1159 SC_DLLPUBLIC void SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal );
1160 SC_DLLPUBLIC void SetValue( const ScAddress& rPos, double fVal );
1161 void SetValues( const ScAddress& rPos, const std::vector<double>& rVals );
1162 void SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError);
1163 SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const ScTokenArray& rArray );
1164 SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const OUString& rFormula,
1165 formula::FormulaGrammar::Grammar eGram );
1168 * Set formula cell, and transfer its ownership to the document. This call
1169 * attempts to group the passed formula cell with the adjacent cells or
1170 * cell groups if appropriate.
1172 * @return pCell if it was successfully inserted, NULL otherwise. pCell
1173 * is deleted automatically on failure to insert.
1175 SC_DLLPUBLIC ScFormulaCell* SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell );
1176 bool SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCell*>& rCells );
1179 * Check if there is at least one formula cell in specified range.
1181 bool HasFormulaCell( const ScRange& rRange ) const;
1182 SC_DLLPUBLIC void InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
1183 SCCOL nCol2, SCROW nRow2,
1184 const ScMarkData& rMark,
1185 const OUString& rFormula,
1186 const ScTokenArray* p = nullptr,
1187 const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT );
1188 SC_DLLPUBLIC void InsertTableOp(const ScTabOpParam& rParam, // multi-operation
1189 SCCOL nCol1, SCROW nRow1,
1190 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark);
1192 SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab,
1193 const ScInterpreterContext* pContext = nullptr ) const;
1194 SC_DLLPUBLIC OUString GetString( const ScAddress& rPos,
1195 const ScInterpreterContext* pContext = nullptr ) const;
1198 * Return a pointer to the double value stored in value cell.
1200 * @param rPos cell position
1202 * @return pointer to the double value stored in a numeric cell, or NULL
1203 * if the cell at specified position is not a numeric cell.
1205 SC_DLLPUBLIC double* GetValueCell( const ScAddress& rPos );
1207 SC_DLLPUBLIC svl::SharedStringPool& GetSharedStringPool();
1208 const svl::SharedStringPool& GetSharedStringPool() const;
1210 svl::SharedString GetSharedString( const ScAddress& rPos ) const;
1212 std::shared_ptr<sc::FormulaGroupContext>& GetFormulaGroupContext();
1213 void DiscardFormulaGroupContext();
1214 void BlockFormulaGroupContextDiscard( bool block )
1215 { mbFormulaGroupCxtBlockDiscard = block; }
1217 // Note that if pShared is set and a value is returned that way, the returned OUString is empty.
1218 SC_DLLPUBLIC OUString GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, bool bForceSystemLocale = false ) const;
1219 FormulaError GetStringForFormula( const ScAddress& rPos, OUString& rString );
1220 SC_DLLPUBLIC double GetValue( const ScAddress& rPos ) const;
1221 SC_DLLPUBLIC double GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1222 SC_DLLPUBLIC const EditTextObject* GetEditText( const ScAddress& rPos ) const;
1223 void RemoveEditTextCharAttribs( const ScAddress& rPos, const ScPatternAttr& rAttr );
1224 SC_DLLPUBLIC double RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScInterpreterContext* pContext = nullptr ) const;
1225 SC_DLLPUBLIC sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1226 sal_uInt32 GetNumberFormat( const ScRange& rRange ) const;
1227 SC_DLLPUBLIC sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& ) const;
1228 SC_DLLPUBLIC void SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberFormat );
1230 void GetNumberFormatInfo( const ScInterpreterContext& rContext, SvNumFormatType& nType, sal_uInt32& nIndex, const ScAddress& rPos ) const;
1231 SC_DLLPUBLIC const ScFormulaCell* GetFormulaCell( const ScAddress& rPos ) const;
1232 SC_DLLPUBLIC ScFormulaCell* GetFormulaCell( const ScAddress& rPos );
1233 SC_DLLPUBLIC OUString GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1234 SC_DLLPUBLIC CellType GetCellType( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1235 SC_DLLPUBLIC CellType GetCellType( const ScAddress& rPos ) const;
1237 SC_DLLPUBLIC bool HasData( SCCOL nCol, SCROW nRow, SCTAB nTab );
1238 SC_DLLPUBLIC bool HasStringData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1239 SC_DLLPUBLIC bool HasValueData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1240 SC_DLLPUBLIC bool HasValueData( const ScAddress& rPos ) const;
1241 bool HasStringCells( const ScRange& rRange ) const;
1243 /** Returns true, if there is any data to create a selection list for rPos. */
1244 bool HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1245 bool HasValidationData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1248 * Check if the specified range contains either: 1) one non-empty cell, 2)
1249 * more than one non-empty cells, or 3) totally empty. In case the range
1250 * contains at least one non-empty cell, specify the position of the first
1251 * non-empty cell.
1253 sc::MultiDataCellState HasMultipleDataCells( const ScRange& rRange ) const;
1255 // Spaklines
1256 /** Returns sparkline at the address if it exists */
1257 SC_DLLPUBLIC std::shared_ptr<sc::Sparkline> GetSparkline(ScAddress const & rPosition);
1258 SC_DLLPUBLIC bool HasSparkline(ScAddress const & rPosition);
1259 SC_DLLPUBLIC sc::Sparkline* CreateSparkline(ScAddress const & rPosition, std::shared_ptr<sc::SparklineGroup> const& pSparklineGroup);
1260 SC_DLLPUBLIC sc::SparklineList* GetSparklineList(SCTAB nTab);
1261 SC_DLLPUBLIC bool DeleteSparkline(ScAddress const& rPosition);
1264 * Returns true if the whole range covers one and the same sparkline
1265 * group and returns the group via out parameter
1267 SC_DLLPUBLIC bool GetSparklineGroupInRange(ScRange const& rRange, std::shared_ptr<sc::SparklineGroup>& rGroup);
1268 SC_DLLPUBLIC bool HasOneSparklineGroup(ScRange const& rRange);
1269 SC_DLLPUBLIC std::shared_ptr<sc::SparklineGroup> SearchSparklineGroup(tools::Guid const& rGuid);
1271 // Notes
1272 SC_DLLPUBLIC ScPostIt* GetNote(const ScAddress& rPos);
1273 SC_DLLPUBLIC ScPostIt* GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
1274 void SetNote(const ScAddress& rPos, std::unique_ptr<ScPostIt> pNote);
1275 void SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, std::unique_ptr<ScPostIt> pNote);
1276 SC_DLLPUBLIC bool HasNote(const ScAddress& rPos) const;
1277 bool HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
1278 bool HasNote(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow) const;
1279 SC_DLLPUBLIC bool HasColNotes(SCCOL nCol, SCTAB nTab) const;
1280 SC_DLLPUBLIC bool HasTabNotes(SCTAB nTab) const;
1281 bool HasNotes() const;
1282 SC_DLLPUBLIC std::unique_ptr<ScPostIt> ReleaseNote(const ScAddress& rPos);
1283 SC_DLLPUBLIC ScPostIt* GetOrCreateNote(const ScAddress& rPos);
1284 SC_DLLPUBLIC ScPostIt* CreateNote(const ScAddress& rPos);
1285 size_t GetNoteCount( SCTAB nTab, SCCOL nCol ) const;
1288 * Ensure that all note objects have an associated sdr object. The export
1289 * code uses sdr objects to export note data.
1291 void CreateAllNoteCaptions();
1292 void ForgetNoteCaptions( const ScRangeList& rRanges, bool bPreserveData );
1293 CommentCaptionState GetAllNoteCaptionsState( const ScRangeList& rRanges);
1295 ScAddress GetNotePosition( size_t nIndex ) const;
1296 ScAddress GetNotePosition( size_t nIndex, SCTAB nTab ) const;
1297 SCROW GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const;
1299 SC_DLLPUBLIC void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
1300 SC_DLLPUBLIC void GetAllNoteEntries( SCTAB nTab, std::vector<sc::NoteEntry>& rNotes ) const;
1301 void GetNotesInRange( const ScRangeList& rRange, std::vector<sc::NoteEntry>& rNotes ) const;
1303 bool ContainsNotesInRange( const ScRangeList& rRange ) const;
1305 SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab);
1307 bool IsMerged( const ScAddress& rPos ) const;
1309 void ExtendMergeSel( SCCOL nStartCol, SCROW nStartRow,
1310 SCCOL& rEndCol, SCROW& rEndRow, const ScMarkData& rMark,
1311 bool bRefresh = false );
1312 SC_DLLPUBLIC bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
1313 SCCOL& rEndCol, SCROW& rEndRow, SCTAB nTab,
1314 bool bRefresh = false );
1315 bool ExtendMerge( ScRange& rRange, bool bRefresh = false );
1316 SC_DLLPUBLIC void ExtendTotalMerge( ScRange& rRange ) const;
1317 SC_DLLPUBLIC void ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow,
1318 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const;
1319 SC_DLLPUBLIC void ExtendOverlapped( ScRange& rRange ) const;
1321 bool RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow,
1322 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1324 SC_DLLPUBLIC void DoMergeContents( SCCOL nStartCol, SCROW nStartRow,
1325 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1326 SC_DLLPUBLIC void DoEmptyBlock( SCCOL nStartCol, SCROW nStartRow,
1327 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1328 // without checking:
1329 SC_DLLPUBLIC void DoMerge( SCCOL nStartCol, SCROW nStartRow,
1330 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bDeleteCaptions = true );
1331 void RemoveMerge( SCCOL nCol, SCROW nRow, SCTAB nTab );
1333 // This also includes e.g. notes. Use IsEmptyData() for cell data only.
1334 bool IsBlockEmpty( SCCOL nStartCol, SCROW nStartRow,
1335 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const;
1336 bool IsPrintEmpty( SCCOL nStartCol, SCROW nStartRow,
1337 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1338 bool bLeftIsEmpty = false,
1339 ScRange* pLastRange = nullptr,
1340 tools::Rectangle* pLastMM = nullptr ) const;
1342 void SkipOverlapped( SCCOL& rCol, SCROW& rRow, SCTAB nTab ) const;
1343 bool IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1344 bool IsVerOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab,
1345 SCROW* nStartRow = nullptr, SCROW* nEndRow = nullptr ) const;
1347 SC_DLLPUBLIC bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1348 SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask ) const;
1349 SC_DLLPUBLIC bool HasAttrib( const ScRange& rRange, HasAttrFlags nMask ) const;
1350 bool HasAttrib( SCCOL nCol, SCROW nRow, SCTAB nTab, HasAttrFlags nMask,
1351 SCROW* nStartRow = nullptr, SCROW* nEndRow = nullptr ) const;
1353 SC_DLLPUBLIC void GetBorderLines( SCCOL nCol, SCROW nRow, SCTAB nTab,
1354 const ::editeng::SvxBorderLine** ppLeft,
1355 const ::editeng::SvxBorderLine** ppTop,
1356 const ::editeng::SvxBorderLine** ppRight,
1357 const ::editeng::SvxBorderLine** ppBottom ) const;
1359 void ResetChanged( const ScRange& rRange );
1361 void CheckVectorizationState();
1362 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
1363 void SetDirty( const ScRange&, bool bIncludeEmptyCells );
1364 void SetTableOpDirty( const ScRange& ); // for Interpreter TableOp
1365 void InterpretDirtyCells( const ScRangeList& rRanges );
1366 // Interprets cells that have NeedsInterpret(), i.e. the same like calling MaybeInterpret() on them.
1367 // Returns false if some couldn't be interpreted (i.e. they still have NeedsInterpret()).
1368 // Useful to ensure that the given cells will not need interpreting.
1369 bool InterpretCellsIfNeeded( const ScRangeList& rRanges );
1370 SC_DLLPUBLIC void CalcAll();
1371 SC_DLLPUBLIC void CalcAfterLoad( bool bStartListening = true );
1372 void CompileAll();
1373 void CompileXML();
1376 * Re-compile formula cells with error.
1378 * @param nErrCode specified error code to match. Only those cells with
1379 * this error code will be re-compiled. If this value is
1380 * 0, cells with any error values will be re-compiled.
1382 * @return true if at least one cell is re-compiled, false if no cells are
1383 * re-compiled.
1385 bool CompileErrorCells(FormulaError nErrCode);
1387 ScAutoNameCache* GetAutoNameCache() { return pAutoNameCache.get(); }
1388 void SetPreviewFont( std::unique_ptr<SfxItemSet> pFontSet );
1389 SfxItemSet* GetPreviewFont() { return pPreviewFont.get(); }
1390 SfxItemSet* GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab );
1391 const ScMarkData& GetPreviewSelection() const { return maPreviewSelection; }
1392 void SetPreviewSelection( const ScMarkData& rSel );
1393 ScStyleSheet* GetPreviewCellStyle() { return pPreviewCellStyle; }
1394 ScStyleSheet* GetPreviewCellStyle( SCCOL nCol, SCROW nRow, SCTAB nTab );
1395 void SetPreviewCellStyle( ScStyleSheet* pStyle ) { pPreviewCellStyle = pStyle; }
1396 SC_DLLPUBLIC void SetAutoNameCache( std::unique_ptr<ScAutoNameCache> pCache );
1398 /** Creates a ScLookupCache cache for the range if it
1399 doesn't already exist. */
1400 ScLookupCache & GetLookupCache( const ScRange & rRange, ScInterpreterContext* pContext );
1401 ScSortedRangeCache & GetSortedRangeCache( const ScRange & rRange, const ScQueryParam& param,
1402 ScInterpreterContext* pContext );
1403 /** Only ScLookupCache dtor uses RemoveLookupCache(), do
1404 not use elsewhere! */
1405 void RemoveLookupCache( ScLookupCache & rCache );
1406 void RemoveSortedRangeCache( ScSortedRangeCache & rCache );
1407 /** Zap all caches. */
1408 void ClearLookupCaches();
1410 // calculate automatically
1411 SC_DLLPUBLIC void SetAutoCalc( bool bNewAutoCalc );
1412 SC_DLLPUBLIC bool GetAutoCalc() const { return bAutoCalc; }
1413 // calculate automatically in/from/for ScDocShell disabled
1414 void SetAutoCalcShellDisabled( bool bNew ) { bAutoCalcShellDisabled = bNew; }
1415 bool IsAutoCalcShellDisabled() const { return bAutoCalcShellDisabled; }
1416 // ForcedFormulas are to be calculated
1417 void SetForcedFormulaPending( bool bNew ) { bForcedFormulaPending = bNew; }
1418 bool IsForcedFormulaPending() const { return bForcedFormulaPending; }
1419 // if CalcFormulaTree() is currently running
1420 bool IsCalculatingFormulaTree() const { return bCalculatingFormulaTree; }
1421 /// If set, joining cells into shared formula groups will be delayed until reset again
1422 /// (RegroupFormulaCells() will be called as needed).
1423 void DelayFormulaGrouping( bool delay );
1424 bool IsDelayedFormulaGrouping() const { return bool(pDelayedFormulaGrouping); }
1425 /// To be used only by SharedFormulaUtil::joinFormulaCells().
1426 void AddDelayedFormulaGroupingCell( const ScFormulaCell* cell );
1427 /// If set, ScColumn::StartListeningFormulaCells() calls may be delayed using
1428 /// CanDelayStartListeningFormulaCells() until reset again, at which point the function will
1429 /// be called as necessary.
1430 void EnableDelayStartListeningFormulaCells( ScColumn* column, bool delay );
1431 bool IsEnabledDelayStartListeningFormulaCells( ScColumn* column ) const;
1432 /// If true is returned, ScColumn::StartListeningFormulaCells() for the given cells will be performed
1433 /// later. If false is returned, it needs to be done explicitly.
1434 bool CanDelayStartListeningFormulaCells( ScColumn* column, SCROW row1, SCROW row2 );
1435 /// If set, cells will not delete their empty broadcasters, avoiding possible extensive mdds
1436 /// vector changes. Disabling delay will collect and delete all empty broadcasters.
1437 void EnableDelayDeletingBroadcasters(bool set);
1438 bool IsDelayedDeletingBroadcasters() const { return bDelayedDeletingBroadcasters; }
1440 FormulaError GetErrCode( const ScAddress& ) const;
1442 /** Shrink a range to only include data area.
1444 This is not the actually used area within the
1445 selection, but the bounds of the sheet's data area
1446 instead.
1448 @returns TRUE if the area passed intersected the data
1449 area, FALSE if not, in which case the values
1450 obtained may be out of bounds, not in order or
1451 unmodified. TRUE does not mean that there
1452 actually is any data within the selection.
1454 bool ShrinkToDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
1456 /** Shrink a range to only include used data area.
1458 @param o_bShrunk
1459 Out parameter, true if area was shrunk, false if not.
1460 @param bColumnsOnly
1461 If TRUE, shrink only by columns, not rows.
1462 @param bStickyTopRow
1463 If TRUE, do not adjust the top row.
1464 @param bStickyLeftCol
1465 If TRUE, do not adjust the left column.
1466 @param pDataAreaExtras
1467 Consider additional area attributes like cell
1468 formatting, cell notes and draw objects. The
1469 possibly larger area than the actual cell
1470 content data area is returned within the
1471 struct.
1473 @returns true if there is any data, false if not.
1475 bool ShrinkToUsedDataArea( bool& o_bShrunk,
1476 SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1477 SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
1478 bool bStickyTopRow = false, bool bStickyLeftCol = false,
1479 ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
1482 * Return the last non-empty row position in given columns that's no
1483 * greater than the initial last row position, or 0 if the columns are
1484 * empty. A negative value is returned if the given sheet or column
1485 * positions are invalid.
1487 * <p>It starts from the specified last row position, and finds the first
1488 * non-empty row position in the upward direction if the start row
1489 * position is empty.</p>
1491 SC_DLLPUBLIC SCROW GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const;
1494 * Return the smallest area containing at least all contiguous cells
1495 * having data. This area is a square containing also empty cells. It may
1496 * shrink or extend the area given as input Flags as modifiers:
1498 * @param bIncludeOld when true, ensure that the returned area contains at
1499 * least the initial area even if the actual data area
1500 * is smaller than the initial area.
1502 * @param bOnlyDown when true, extend / shrink the data area only in a
1503 * downward direction i.e. only modify the end row
1504 * position.
1506 SC_DLLPUBLIC void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1507 SCCOL& rEndCol, SCROW& rEndRow,
1508 bool bIncludeOld, bool bOnlyDown ) const;
1511 * Returns true if there is a non-empty subrange in the range given as input.
1512 * In that case it also modifies rRange to largest subrange that does not
1513 * have empty col/row inrange-segments in the beginning/end.
1514 * It returns false if rRange is completely empty and in this case rRange is
1515 * left unmodified.
1517 bool GetDataAreaSubrange(ScRange& rRange) const;
1519 SC_DLLPUBLIC bool GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
1520 SC_DLLPUBLIC bool GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
1521 bool bCalcHiddens = false) const;
1522 SC_DLLPUBLIC bool GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
1523 bool bNotes = true) const;
1524 SC_DLLPUBLIC bool GetPrintAreaHor( SCTAB nTab, SCROW nStartRow, SCROW nEndRow,
1525 SCCOL& rEndCol ) const;
1526 SC_DLLPUBLIC bool GetPrintAreaVer( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol,
1527 SCROW& rEndRow, bool bNotes ) const;
1528 void InvalidateTableArea();
1530 /// Return the number of columns / rows that should be visible for the tiled rendering.
1531 SC_DLLPUBLIC void GetTiledRenderingArea(SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow) const;
1533 SC_DLLPUBLIC bool GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const;
1536 * Find the maximum column position that contains printable data for the
1537 * specified row range. The final column position must be equal or less
1538 * than the initial value of rEndCol.
1540 void ExtendPrintArea( OutputDevice* pDev, SCTAB nTab,
1541 SCCOL nStartCol, SCROW nStartRow,
1542 SCCOL& rEndCol, SCROW nEndRow ) const;
1543 SC_DLLPUBLIC bool IsEmptyData(SCCOL nStartCol, SCROW nStartRow,
1544 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const;
1545 // I think this returns the number of empty cells starting from the given direction.
1546 SC_DLLPUBLIC SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
1547 SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab,
1548 ScDirection eDir );
1550 void FindAreaPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, ScMoveDirection eDirection ) const;
1551 SC_DLLPUBLIC void GetNextPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, SCCOL nMovX, SCROW nMovY,
1552 bool bMarked, bool bUnprotected, const ScMarkData& rMark,
1553 SCCOL nTabStartCol = SC_TABSTART_NONE ) const;
1555 bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, SCTAB nTab,
1556 const ScMarkData& rMark );
1558 void LimitChartArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1559 SCCOL& rEndCol, SCROW& rEndRow );
1560 void LimitChartIfAll( ScRangeListRef& rRangeList );
1562 bool InsertRow( SCCOL nStartCol, SCTAB nStartTab,
1563 SCCOL nEndCol, SCTAB nEndTab,
1564 SCROW nStartRow, SCSIZE nSize, ScDocument* pRefUndoDoc = nullptr,
1565 const ScMarkData* pTabMark = nullptr );
1566 SC_DLLPUBLIC bool InsertRow( const ScRange& rRange );
1567 void DeleteRow( SCCOL nStartCol, SCTAB nStartTab,
1568 SCCOL nEndCol, SCTAB nEndTab,
1569 SCROW nStartRow, SCSIZE nSize,
1570 ScDocument* pRefUndoDoc = nullptr, bool* pUndoOutline = nullptr,
1571 const ScMarkData* pTabMark = nullptr );
1572 SC_DLLPUBLIC void DeleteRow( const ScRange& rRange );
1573 bool InsertCol( SCROW nStartRow, SCTAB nStartTab,
1574 SCROW nEndRow, SCTAB nEndTab,
1575 SCCOL nStartCol, SCSIZE nSize, ScDocument* pRefUndoDoc = nullptr,
1576 const ScMarkData* pTabMark = nullptr );
1577 SC_DLLPUBLIC bool InsertCol( const ScRange& rRange );
1578 void DeleteCol( SCROW nStartRow, SCTAB nStartTab,
1579 SCROW nEndRow, SCTAB nEndTab,
1580 SCCOL nStartCol, SCSIZE nSize,
1581 ScDocument* pRefUndoDoc = nullptr, bool* pUndoOutline = nullptr,
1582 const ScMarkData* pTabMark = nullptr );
1583 void DeleteCol( const ScRange& rRange );
1585 bool CanInsertRow( const ScRange& rRange ) const;
1586 bool CanInsertCol( const ScRange& rRange ) const;
1588 void FitBlock( const ScRange& rOld, const ScRange& rNew, bool bClear = true );
1589 bool CanFitBlock( const ScRange& rOld, const ScRange& rNew );
1591 bool IsClipOrUndo() const { return bIsClip || bIsUndo; }
1592 bool IsUndo() const { return bIsUndo; }
1593 bool IsClipboard() const { return bIsClip; }
1594 bool IsUndoEnabled() const { return mbUndoEnabled; }
1595 SC_DLLPUBLIC void EnableUndo( bool bVal );
1596 bool IsFunctionAccess() const { return bIsFunctionAccess; }
1598 bool IsAdjustHeightLocked() const { return nAdjustHeightLock != 0; }
1599 void LockAdjustHeight() { ++nAdjustHeightLock; }
1600 SC_DLLPUBLIC void UnlockAdjustHeight();
1601 bool IsExecuteLinkEnabled() const { return mbExecuteLinkEnabled; }
1602 void EnableExecuteLink( bool bVal ) { mbExecuteLinkEnabled = bVal; }
1603 bool IsChangeReadOnlyEnabled() const { return mbChangeReadOnlyEnabled; }
1604 void EnableChangeReadOnly( bool bVal ) { mbChangeReadOnlyEnabled = bVal; }
1605 SC_DLLPUBLIC bool IsUserInteractionEnabled() const { return mbUserInteractionEnabled;}
1606 SC_DLLPUBLIC void EnableUserInteraction( bool bVal );
1607 SC_DLLPUBLIC sal_Int16 GetNamedRangesLockCount() const { return mnNamedRangesLockCount; }
1608 void SetNamedRangesLockCount( sal_Int16 nCount ) { mnNamedRangesLockCount = nCount; }
1609 SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks );
1610 SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, SCTAB nTab );
1611 void SetCutMode( bool bCut );
1612 bool IsCutMode();
1613 void SetClipArea( const ScRange& rArea, bool bCut = false );
1615 SC_DLLPUBLIC bool IsDocVisible() const { return bIsVisible; }
1616 SC_DLLPUBLIC void SetDocVisible( bool bSet );
1618 bool HasOLEObjectsInArea( const ScRange& rRange, const ScMarkData* pTabMark = nullptr );
1620 void DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1621 const ScMarkData& rMark, bool bAnchored = false );
1622 void DeleteObjectsInSelection( const ScMarkData& rMark );
1624 SC_DLLPUBLIC void DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark,
1625 InsertDeleteFlags nDelFlag, bool bBroadcast = true,
1626 sc::ColumnSpanSet* pBroadcastSpans = nullptr );
1628 SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1629 SCTAB nTab, InsertDeleteFlags nDelFlag);
1630 void DeleteAreaTab(const ScRange& rRange, InsertDeleteFlags nDelFlag);
1632 SC_DLLPUBLIC void CopyToClip( const ScClipParam& rClipParam, ScDocument* pClipDoc,
1633 const ScMarkData* pMarks, bool bKeepScenarioFlags,
1634 bool bIncludeObjects );
1637 * Copy only raw cell values to another document. Formula cells are
1638 * converted to raw cells. No formatting info are copied except for
1639 * number formats.
1641 * @param rSrcRange source range in the source document
1642 * @param nDestTab table in the clip document to copy to.
1643 * @param rDestDoc document to copy to
1645 SC_DLLPUBLIC void CopyStaticToDocument(const ScRange& rSrcRange, SCTAB nDestTab, ScDocument& rDestDoc);
1648 * Copy only cell, nothing but cell to another document.
1650 * @param rSrcPos source cell position
1651 * @param rDestPos destination cell position
1652 * @param rDestDoc destination document
1654 void CopyCellToDocument( const ScAddress& rSrcPos, const ScAddress& rDestPos, ScDocument& rDestDoc );
1656 void CopyTabToClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1657 SCTAB nTab, ScDocument* pClipDoc);
1659 SC_DLLPUBLIC bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCTAB nTab, SCCOL nCol );
1661 void DeleteBeforeCopyFromClip( sc::CopyFromClipContext& rCxt, const ScMarkData& rMark,
1662 sc::ColumnSpanSet& rBroadcastSpans );
1664 SC_DLLPUBLIC bool CopyOneCellFromClip(sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1665 SCCOL nCol2, SCROW nRow2 );
1666 void CopyBlockFromClip( sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1667 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark,
1668 SCCOL nDx, SCROW nDy );
1670 * @return the number of non-filtered rows.
1672 SCROW CopyNonFilteredFromClip(sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1673 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark, SCCOL nDx,
1674 SCROW& rClipStartRow, SCROW nClipEndRow);
1676 void StartListeningFromClip(
1677 sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt,
1678 SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1679 void StartListeningFromClip( SCCOL nCol1, SCROW nRow1,
1680 SCCOL nCol2, SCROW nRow2,
1681 const ScMarkData& rMark, InsertDeleteFlags nInsFlag );
1683 void SetDirtyFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1684 const ScMarkData& rMark, InsertDeleteFlags nInsFlag,
1685 sc::ColumnSpanSet& rBroadcastSpans );
1688 * Paste data from a clipboard document into this document.
1690 * @param rDestRange destination range.
1691 * @param pClipDoc pointer to the clipboard document to copy data from.
1692 * @param bSkipEmptyCells if this flag is set, empty cells in the source
1693 * range in the clipboard document will not overwrite
1694 * the target destination cells.
1695 * @param pDestRanges If pDestRanges is given it overrides rDestRange, where
1696 * rDestRange becomes the overall encompassing range.
1698 SC_DLLPUBLIC void CopyFromClip(
1699 const ScRange& rDestRange, const ScMarkData& rMark, InsertDeleteFlags nInsFlag,
1700 ScDocument* pRefUndoDoc, ScDocument* pClipDoc,
1701 bool bResetCut = true, bool bAsLink = false,
1702 bool bIncludeFiltered = true, bool bSkipEmptyCells = false,
1703 const ScRangeList* pDestRanges = nullptr );
1705 void CopyMultiRangeFromClip(const ScAddress& rDestPos, const ScMarkData& rMark,
1706 InsertDeleteFlags nInsFlag, ScDocument* pClipDoc,
1707 bool bResetCut = true, bool bAsLink = false,
1708 bool bIncludeFiltered = true,
1709 bool bSkipAttrForEmpty = false);
1711 void GetClipArea(SCCOL& nClipX, SCROW& nClipY, bool bIncludeFiltered);
1712 void GetClipStart(SCCOL& nClipX, SCROW& nClipY);
1714 bool HasClipFilteredRows();
1716 bool IsClipboardSource() const;
1718 SC_DLLPUBLIC void TransposeClip(ScDocument* pTransClip, InsertDeleteFlags nFlags, bool bAsLink,
1719 bool bIncludeFiltered);
1721 ScClipParam& GetClipParam();
1722 void SetClipParam(const ScClipParam& rParam);
1724 /** To be called at the clipboard document when closing a document that is
1725 the current clipboard source to decouple things from the originating
1726 document. Done in ScDocument dtor after determining
1727 IsClipboardSource().
1729 void ClosingClipboardSource();
1731 void MixDocument( const ScRange& rRange, ScPasteFunc nFunction, bool bSkipEmpty,
1732 ScDocument& rSrcDoc );
1734 void FillTab( const ScRange& rSrcArea, const ScMarkData& rMark,
1735 InsertDeleteFlags nFlags, ScPasteFunc nFunction,
1736 bool bSkipEmpty, bool bAsLink );
1737 void FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark,
1738 InsertDeleteFlags nFlags, ScPasteFunc nFunction,
1739 bool bSkipEmpty, bool bAsLink );
1741 void TransliterateText( const ScMarkData& rMultiMark, TransliterationFlags nType );
1743 SC_DLLPUBLIC void InitUndo( const ScDocument& rSrcDoc, SCTAB nTab1, SCTAB nTab2,
1744 bool bColInfo = false, bool bRowInfo = false );
1745 void AddUndoTab( SCTAB nTab1, SCTAB nTab2,
1746 bool bColInfo = false, bool bRowInfo = false );
1747 SC_DLLPUBLIC void InitUndoSelected( const ScDocument& rSrcDoc, const ScMarkData& rTabSelection,
1748 bool bColInfo = false, bool bRowInfo = false );
1750 // don't use anymore:
1751 void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1752 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1753 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc,
1754 const ScMarkData* pMarks = nullptr, bool bColRowFlags = true);
1755 void UndoToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1756 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1757 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc);
1759 SC_DLLPUBLIC void CopyToDocument(const ScRange& rRange,
1760 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc,
1761 const ScMarkData* pMarks = nullptr, bool bColRowFlags = true);
1762 void UndoToDocument(const ScRange& rRange,
1763 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc);
1765 void CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario = false );
1766 bool TestCopyScenario( SCTAB nSrcTab, SCTAB nDestTab ) const;
1767 void MarkScenario(SCTAB nSrcTab, SCTAB nDestTab,
1768 ScMarkData& rDestMark, bool bResetMark = true,
1769 ScScenarioFlags nNeededBits = ScScenarioFlags::NONE) const;
1770 bool HasScenarioRange( SCTAB nTab, const ScRange& rRange ) const;
1771 SC_DLLPUBLIC const ScRangeList* GetScenarioRanges( SCTAB nTab ) const;
1773 SC_DLLPUBLIC void CopyUpdated( ScDocument* pPosDoc, ScDocument* pDestDoc );
1775 void UpdateReference( sc::RefUpdateContext& rCxt, ScDocument*
1776 pUndoDoc = nullptr, bool bIncludeDraw = true,
1777 bool bUpdateNoteCaptionPos = true );
1779 * @param pClipDoc original clipboard doc, i.e. non-transposed
1780 * This clip doc is used to check references pointing to cut cells.
1782 SC_DLLPUBLIC void UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDoc,
1783 const ScMarkData& rMark, ScDocument* pUndoDoc );
1785 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
1787 SC_DLLPUBLIC void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1788 ScProgress* pProgress, const ScMarkData& rMark,
1789 sal_uInt64 nFillCount, FillDir eFillDir = FILL_TO_BOTTOM,
1790 FillCmd eFillCmd = FILL_LINEAR, FillDateCmd eFillDateCmd = FILL_DAY,
1791 double nStepValue = 1.0, double nMaxValue = 1E307 );
1792 OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
1794 bool GetSelectionFunction( ScSubTotalFunc eFunc,
1795 const ScAddress& rCursor, const ScMarkData& rMark,
1796 double& rResult );
1798 SC_DLLPUBLIC const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
1799 template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const
1801 return static_cast<const T*>(GetAttr(nCol, nRow, nTab, sal_uInt16(nWhich)));
1803 SC_DLLPUBLIC const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich,
1804 SCROW& nStartRow, SCROW& nEndRow ) const;
1805 template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich,
1806 SCROW& nStartRow, SCROW& nEndRow ) const
1808 return static_cast<const T*>(GetAttr(nCol, nRow, nTab, sal_uInt16(nWhich), nStartRow, nEndRow));
1810 SC_DLLPUBLIC const SfxPoolItem* GetAttr( const ScAddress& rPos, sal_uInt16 nWhich ) const;
1811 template<class T> const T* GetAttr( const ScAddress& rPos, TypedWhichId<T> nWhich ) const
1813 return static_cast<const T*>(GetAttr(rPos, sal_uInt16(nWhich)));
1815 SC_DLLPUBLIC const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1816 SC_DLLPUBLIC const ScPatternAttr* GetPattern( const ScAddress& rPos ) const;
1817 SC_DLLPUBLIC const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const;
1818 const ScPatternAttr* GetSelectionPattern( const ScMarkData& rMark );
1819 std::unique_ptr<ScPatternAttr> CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
1820 SC_DLLPUBLIC void AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
1821 void RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
1823 SC_DLLPUBLIC ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1824 // pCell is an optimization, must point to rPos
1825 SC_DLLPUBLIC const SfxItemSet* GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab,
1826 ScRefCellValue* pCell = nullptr ) const;
1827 const SfxItemSet* GetCondResult( ScRefCellValue& rCell, const ScAddress& rPos,
1828 const ScConditionalFormatList& rList,
1829 const ScCondFormatIndexes& rIndex ) const;
1830 const SfxPoolItem* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
1831 template<class T> const T* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const
1833 return static_cast<const T*>(GetEffItem(nCol, nRow, nTab, sal_uInt16(nWhich)));
1836 SC_DLLPUBLIC const css::uno::Reference< css::i18n::XBreakIterator >& GetBreakIterator();
1837 bool HasStringWeakCharacters( const OUString& rString );
1838 SC_DLLPUBLIC SvtScriptType GetStringScriptType( const OUString& rString );
1839 // pCell is an optimization, must point to rPos
1840 SC_DLLPUBLIC SvtScriptType GetCellScriptType( const ScAddress& rPos, sal_uInt32 nNumberFormat,
1841 const ScRefCellValue* pCell = nullptr );
1842 // pCell is an optimization, must point to nCol,nRow,nTab
1843 SC_DLLPUBLIC SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab,
1844 const ScRefCellValue* pCell = nullptr );
1845 SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rPos, SCROW nLength );
1846 SvtScriptType GetRangeScriptType( const ScRangeList& rRanges );
1848 bool HasDetectiveOperations() const;
1849 void AddDetectiveOperation( const ScDetOpData& rData );
1850 void ClearDetectiveOperations();
1851 ScDetOpList* GetDetOpList() const { return pDetOpList.get(); }
1852 void SetDetOpList(std::unique_ptr<ScDetOpList> pNew);
1854 bool HasDetectiveObjects(SCTAB nTab) const;
1856 void GetSelectionFrame( const ScMarkData& rMark,
1857 SvxBoxItem& rLineOuter,
1858 SvxBoxInfoItem& rLineInner );
1859 void ApplySelectionFrame(const ScMarkData& rMark,
1860 const SvxBoxItem& rLineOuter,
1861 const SvxBoxInfoItem* pLineInner);
1862 void ApplyFrameAreaTab(const ScRange& rRange,
1863 const SvxBoxItem& rLineOuter,
1864 const SvxBoxInfoItem& rLineInner);
1866 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
1867 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
1869 SC_DLLPUBLIC sal_uLong AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew, SCTAB nTab );
1870 void DeleteConditionalFormat( sal_uLong nIndex, SCTAB nTab );
1872 void SetCondFormList( ScConditionalFormatList* pList, SCTAB nTab );
1873 SC_DLLPUBLIC sal_uLong AddValidationEntry( const ScValidationData& rNew );
1874 SC_DLLPUBLIC const ScValidationData* GetValidationEntry( sal_uInt32 nIndex ) const;
1876 SC_DLLPUBLIC ScConditionalFormatList* GetCondFormList( SCTAB nTab ) const;
1878 const ScValidationDataList* GetValidationList() const { return pValidationList.get();}
1879 ScValidationDataList* GetValidationList() { return pValidationList.get();}
1881 SC_DLLPUBLIC void ApplyAttr( SCCOL nCol, SCROW nRow, SCTAB nTab,
1882 const SfxPoolItem& rAttr );
1883 SC_DLLPUBLIC void ApplyPattern( SCCOL nCol, SCROW nRow, SCTAB nTab,
1884 const ScPatternAttr& rAttr );
1885 SC_DLLPUBLIC void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow,
1886 SCCOL nEndCol, SCROW nEndRow,
1887 const ScMarkData& rMark, const ScPatternAttr& rAttr,
1888 ScEditDataArray* pDataArray = nullptr,
1889 bool* const pIsChanged = nullptr );
1890 SC_DLLPUBLIC void ApplyPatternAreaTab( SCCOL nStartCol, SCROW nStartRow,
1891 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1892 const ScPatternAttr& rAttr );
1894 SC_DLLPUBLIC void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
1895 const ScMarkData& rMark,
1896 const ScPatternAttr& rPattern,
1897 SvNumFormatType nNewType );
1899 void ApplyStyle( SCCOL nCol, SCROW nRow, SCTAB nTab,
1900 const ScStyleSheet& rStyle);
1901 void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow,
1902 SCCOL nEndCol, SCROW nEndRow,
1903 const ScMarkData& rMark, const ScStyleSheet& rStyle);
1904 SC_DLLPUBLIC void ApplyStyleAreaTab( SCCOL nStartCol, SCROW nStartRow,
1905 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1906 const ScStyleSheet& rStyle);
1908 SC_DLLPUBLIC void ApplySelectionStyle( const ScStyleSheet& rStyle, const ScMarkData& rMark );
1909 void ApplySelectionLineStyle( const ScMarkData& rMark,
1910 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
1912 const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1913 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark ) const;
1915 void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
1916 OutputDevice* pDev,
1917 double nPPTX, double nPPTY,
1918 const Fraction& rZoomX, const Fraction& rZoomY );
1920 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
1922 SC_DLLPUBLIC bool ApplyFlagsTab( SCCOL nStartCol, SCROW nStartRow,
1923 SCCOL nEndCol, SCROW nEndRow,
1924 SCTAB nTab, ScMF nFlags );
1925 SC_DLLPUBLIC bool RemoveFlagsTab( SCCOL nStartCol, SCROW nStartRow,
1926 SCCOL nEndCol, SCROW nEndRow,
1927 SCTAB nTab, ScMF nFlags );
1929 SC_DLLPUBLIC void SetPattern( const ScAddress&, const ScPatternAttr& rAttr );
1930 SC_DLLPUBLIC const ScPatternAttr* SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, std::unique_ptr<ScPatternAttr> pAttr );
1931 SC_DLLPUBLIC const ScPatternAttr* SetPattern( const ScAddress& rPos, std::unique_ptr<ScPatternAttr> pAttr );
1932 SC_DLLPUBLIC void SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr& rAttr );
1934 void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1935 sal_uInt16 nFormatNo, const ScMarkData& rMark );
1936 void GetAutoFormatData( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1937 ScAutoFormatData& rData );
1938 bool SearchAndReplace( const SvxSearchItem& rSearchItem,
1939 SCCOL& rCol, SCROW& rRow, SCTAB& rTab,
1940 const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1941 OUString& rUndoStr, ScDocument* pUndoDoc, bool& bMatchedRangesWereClamped );
1942 static bool IsEmptyCellSearch( const SvxSearchItem& rSearchItem );
1944 // determine Col/Row of subsequent calls
1945 // (e.g. not found from the beginning, or subsequent tables)
1946 // meaning of explanation in "()" was already unclear in German
1947 void GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem,
1948 SCCOL& rCol, SCROW& rRow );
1950 bool Solver( SCCOL nFCol, SCROW nFRow, SCTAB nFTab,
1951 SCCOL nVCol, SCROW nVRow, SCTAB nVTab,
1952 const OUString& sValStr, double& nX);
1954 SC_DLLPUBLIC void ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark,
1955 ScEditDataArray* pDataArray = nullptr, bool* pIsChanged = nullptr );
1956 SC_DLLPUBLIC void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
1957 void DeleteSelectionTab( SCTAB nTab, InsertDeleteFlags nDelFlag, const ScMarkData& rMark );
1959 SC_DLLPUBLIC void SetColWidth( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth );
1960 SC_DLLPUBLIC void SetColWidthOnly( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth );
1961 SC_DLLPUBLIC void SetRowHeight( SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight );
1962 SC_DLLPUBLIC void SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
1963 sal_uInt16 nNewHeight );
1965 SC_DLLPUBLIC void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
1966 sal_uInt16 nNewHeight );
1967 SC_DLLPUBLIC void SetManualHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual );
1969 SC_DLLPUBLIC sal_uInt16 GetColWidth( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
1970 SC_DLLPUBLIC tools::Long GetColWidth( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab ) const;
1971 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1972 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const;
1973 SC_DLLPUBLIC tools::Long GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1976 * Given the height i.e. total vertical distance from the top of the sheet
1977 * grid, return the first visible row whose top position is below the
1978 * specified height.
1980 SCROW GetRowForHeight( SCTAB nTab, tools::Long nHeight ) const;
1981 tools::Long GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const;
1982 SC_DLLPUBLIC tools::Long GetColOffset( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
1983 SC_DLLPUBLIC tools::Long GetRowOffset( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1985 SC_DLLPUBLIC sal_uInt16 GetOriginalWidth( SCCOL nCol, SCTAB nTab ) const;
1986 SC_DLLPUBLIC sal_uInt16 GetOriginalHeight( SCROW nRow, SCTAB nTab ) const;
1988 sal_uInt16 GetCommonWidth( SCCOL nEndCol, SCTAB nTab ) const;
1990 SCROW GetHiddenRowCount( SCROW nRow, SCTAB nTab ) const;
1992 sal_uInt16 GetOptimalColWidth( SCCOL nCol, SCTAB nTab, OutputDevice* pDev,
1993 double nPPTX, double nPPTY,
1994 const Fraction& rZoomX, const Fraction& rZoomY,
1995 bool bFormula,
1996 const ScMarkData* pMarkData = nullptr,
1997 const ScColWidthParam* pParam = nullptr );
1999 SC_DLLPUBLIC bool SetOptimalHeight( sc::RowHeightContext& rCxt, SCROW nStartRow,
2000 SCROW nEndRow, SCTAB nTab, bool bApi );
2002 void UpdateAllRowHeights( sc::RowHeightContext& rCxt, const ScMarkData* pTabMark );
2004 tools::Long GetNeededSize( SCCOL nCol, SCROW nRow, SCTAB nTab,
2005 OutputDevice* pDev,
2006 double nPPTX, double nPPTY,
2007 const Fraction& rZoomX, const Fraction& rZoomY,
2008 bool bWidth, bool bTotalSize = false,
2009 bool bInPrintTwips = false );
2011 SC_DLLPUBLIC void ShowCol(SCCOL nCol, SCTAB nTab, bool bShow);
2012 SC_DLLPUBLIC void ShowRow(SCROW nRow, SCTAB nTab, bool bShow);
2013 SC_DLLPUBLIC void ShowRows(SCROW nRow1, SCROW nRow2, SCTAB nTab, bool bShow);
2014 SC_DLLPUBLIC void SetRowFlags( SCROW nRow, SCTAB nTab, CRFlags nNewFlags );
2015 SC_DLLPUBLIC void SetRowFlags( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, CRFlags nNewFlags );
2017 SC_DLLPUBLIC CRFlags GetColFlags( SCCOL nCol, SCTAB nTab ) const;
2018 SC_DLLPUBLIC CRFlags GetRowFlags( SCROW nRow, SCTAB nTab ) const;
2020 SC_DLLPUBLIC void GetAllRowBreaks(std::set<SCROW>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
2021 SC_DLLPUBLIC void GetAllColBreaks(std::set<SCCOL>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
2022 SC_DLLPUBLIC ScBreakType HasRowBreak(SCROW nRow, SCTAB nTab) const;
2023 SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const;
2024 SC_DLLPUBLIC void SetRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
2025 SC_DLLPUBLIC void SetColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
2026 void RemoveRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
2027 void RemoveColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
2028 css::uno::Sequence<
2029 css::sheet::TablePageBreakData> GetRowBreakData(SCTAB nTab) const;
2031 SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
2032 SC_DLLPUBLIC bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2033 SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
2034 SC_DLLPUBLIC void SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden);
2035 SC_DLLPUBLIC void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden);
2036 SC_DLLPUBLIC SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2037 SC_DLLPUBLIC SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2038 SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2039 SCROW CountHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2040 SCCOL CountHiddenCols(SCROW nStartCol, SCROW nEndCol, SCTAB nTab) const;
2042 SC_DLLPUBLIC bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
2043 bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2044 bool ColFiltered(SCCOL nCol, SCTAB nTab) const;
2045 SC_DLLPUBLIC void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered);
2046 SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2047 SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2048 SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
2050 SC_DLLPUBLIC bool IsManualRowHeight(SCROW nRow, SCTAB nTab) const;
2052 bool HasUniformRowHeight( SCTAB nTab, SCROW nRow1, SCROW nRow2 ) const;
2055 * Write all column row flags to table's flag data, because not all column
2056 * row attributes are stored in the flag data members. This is necessary
2057 * for ods export.
2059 void SyncColRowFlags();
2061 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
2062 SC_DLLPUBLIC SCROW GetLastFlaggedRow( SCTAB nTab ) const;
2064 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
2065 SCCOL GetLastChangedColFlagsWidth( SCTAB nTab ) const;
2066 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
2067 SCROW GetLastChangedRowFlagsWidth( SCTAB nTab ) const;
2069 SCCOL GetNextDifferentChangedColFlagsWidth( SCTAB nTab, SCCOL nStart) const;
2071 SCROW GetNextDifferentChangedRowFlagsWidth( SCTAB nTab, SCROW nStart) const;
2073 // returns whether to export a Default style for this col or not
2074 // nDefault is set to one position in the current row where the Default style is
2075 void GetColDefault( SCTAB nTab, SCCOL nCol, SCROW nLastRow, SCROW& nDefault);
2077 bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bShow );
2078 bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bShow );
2080 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
2081 void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
2083 SC_DLLPUBLIC ScPatternAttr* GetDefPattern() const;
2084 SC_DLLPUBLIC ScDocumentPool* GetPool();
2085 SC_DLLPUBLIC ScStyleSheetPool* GetStyleSheetPool() const;
2086 void GetUnprotectedCells( ScRangeList& rRange, SCTAB nTab ) const;
2088 // PageStyle:
2089 SC_DLLPUBLIC OUString GetPageStyle( SCTAB nTab ) const;
2090 SC_DLLPUBLIC void SetPageStyle( SCTAB nTab, const OUString& rName );
2091 Size GetPageSize( SCTAB nTab ) const;
2092 void SetPageSize( SCTAB nTab, const Size& rSize );
2093 void SetRepeatArea( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
2094 void InvalidatePageBreaks(SCTAB nTab);
2095 void UpdatePageBreaks( SCTAB nTab, const ScRange* pUserArea = nullptr );
2096 void RemoveManualBreaks( SCTAB nTab );
2097 bool HasManualBreaks( SCTAB nTab ) const;
2099 bool IsPageStyleInUse( std::u16string_view rStrPageStyle, SCTAB* pInTab );
2100 bool RemovePageStyleInUse( std::u16string_view rStrPageStyle );
2101 bool RenamePageStyleInUse( std::u16string_view rOld, const OUString& rNew );
2102 void ModifyStyleSheet( SfxStyleSheetBase& rPageStyle,
2103 const SfxItemSet& rChanges );
2105 void PageStyleModified( SCTAB nTab, const OUString& rNewName );
2107 SC_DLLPUBLIC bool NeedPageResetAfterTab( SCTAB nTab ) const;
2109 // Was stored in PageStyle previously. Now it exists for every table:
2110 SC_DLLPUBLIC bool HasPrintRange();
2111 SC_DLLPUBLIC sal_uInt16 GetPrintRangeCount( SCTAB nTab );
2112 SC_DLLPUBLIC const ScRange* GetPrintRange( SCTAB nTab, sal_uInt16 nPos );
2113 SC_DLLPUBLIC std::optional<ScRange> GetRepeatColRange( SCTAB nTab );
2114 SC_DLLPUBLIC std::optional<ScRange> GetRepeatRowRange( SCTAB nTab );
2115 /** Returns true, if the specified sheet is always printed. */
2116 bool IsPrintEntireSheet( SCTAB nTab ) const;
2118 /** Removes all print ranges. */
2119 SC_DLLPUBLIC void ClearPrintRanges( SCTAB nTab );
2120 /** Adds a new print ranges. */
2121 SC_DLLPUBLIC void AddPrintRange( SCTAB nTab, const ScRange& rNew );
2122 /** Marks the specified sheet to be printed completely. Deletes old print ranges on the sheet! */
2123 SC_DLLPUBLIC void SetPrintEntireSheet( SCTAB nTab );
2124 SC_DLLPUBLIC void SetRepeatColRange( SCTAB nTab, std::optional<ScRange> oNew );
2125 SC_DLLPUBLIC void SetRepeatRowRange( SCTAB nTab, std::optional<ScRange> oNew );
2126 std::unique_ptr<ScPrintRangeSaver> CreatePrintRangeSaver() const;
2127 void RestorePrintRanges( const ScPrintRangeSaver& rSaver );
2129 SC_DLLPUBLIC tools::Rectangle GetMMRect( SCCOL nStartCol, SCROW nStartRow,
2130 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
2131 SC_DLLPUBLIC ScRange GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool bHiddenAsZero = true ) const;
2133 void UpdStlShtPtrsFrmNms();
2134 void StylesToNames();
2136 SC_DLLPUBLIC void CopyStdStylesFrom( const ScDocument& rSrcDoc );
2138 static sal_uInt16 GetSrcVersion() { return nSrcVer; }
2140 void SetSrcCharSet( rtl_TextEncoding eNew ) { eSrcSet = eNew; }
2141 void UpdateFontCharSet();
2143 void FillInfo( ScTableInfo& rTabInfo, SCCOL nCol1, SCROW nRow1,
2144 SCCOL nCol2, SCROW nRow2, SCTAB nTab, double fColScale,
2145 double fRowScale, bool bPageMode, bool bFormulaMode,
2146 const ScMarkData* pMarkData = nullptr );
2148 SC_DLLPUBLIC SvNumberFormatter* GetFormatTable() const;
2150 /** Sort a range of data. */
2151 void Sort( SCTAB nTab, const ScSortParam& rSortParam,
2152 bool bKeepQuery, bool bUpdateRefs,
2153 ScProgress* pProgress, sc::ReorderParam* pUndo );
2155 void Reorder( const sc::ReorderParam& rParam );
2157 void PrepareQuery( SCTAB nTab, ScQueryParam& rQueryParam );
2158 SCSIZE Query( SCTAB nTab, const ScQueryParam& rQueryParam, bool bKeepSub );
2159 SC_DLLPUBLIC bool CreateQueryParam( const ScRange& rRange, ScQueryParam& rQueryParam );
2160 OUString GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab);
2163 * Get a list of unique strings to use in filtering criteria. The string
2164 * values are sorted, and there are no duplicate values in the list. The
2165 * data range to use to populate the filter entries is inferred from the
2166 * database range that contains the specified cell position.
2168 void GetFilterEntries( SCCOL nCol, SCROW nRow,
2169 SCTAB nTab, ScFilterEntries& rFilterEntries );
2171 SC_DLLPUBLIC void GetFilterEntriesArea( SCCOL nCol, SCROW nStartRow, SCROW nEndRow,
2172 SCTAB nTab, bool bCaseSens,
2173 ScFilterEntries& rFilterEntries );
2175 void GetDataEntries( SCCOL nCol, SCROW nRow, SCTAB nTab,
2176 std::vector<ScTypedStrData>& rStrings, bool bValidation = false );
2177 void GetFormulaEntries( ScTypedCaseStrSet& rStrings );
2179 bool HasAutoFilter( SCCOL nCol, SCROW nRow, SCTAB nTab );
2180 void GetFilterSelCount( SCCOL nCol, SCROW nRow, SCTAB nTab, SCSIZE& nSelected, SCSIZE& nTotal );
2182 SC_DLLPUBLIC bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
2183 SCTAB nTab );
2184 SC_DLLPUBLIC bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
2185 SCTAB nTab );
2187 SfxPrinter* GetPrinter( bool bCreateIfNotExist = true );
2188 void SetPrinter( VclPtr<SfxPrinter> const & pNewPrinter );
2189 VirtualDevice* GetVirtualDevice_100th_mm();
2190 SC_DLLPUBLIC OutputDevice* GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice...
2192 bool GetNextSpellingCell( SCCOL& nCol, SCROW& nRow, SCTAB nTab,
2193 bool bInSel, const ScMarkData& rMark) const;
2195 void ReplaceStyle( const SvxSearchItem& rSearchItem,
2196 SCCOL nCol, SCROW nRow, SCTAB nTab,
2197 const ScMarkData& rMark);
2199 void InvalidateTextWidth( std::u16string_view rStyleName );
2200 void InvalidateTextWidth( SCTAB nTab );
2201 void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo, bool bNumFormatChanged );
2203 bool IdleCalcTextWidth();
2205 void RepaintRange( const ScRange& rRange );
2206 void RepaintRange( const ScRangeList& rRange );
2208 bool IsIdleEnabled() const { return mbIdleEnabled; }
2209 void EnableIdle(bool bDo) { mbIdleEnabled = bDo; }
2211 bool IsDetectiveDirty() const { return bDetectiveDirty; }
2212 void SetDetectiveDirty(bool bSet) { bDetectiveDirty = bSet; }
2214 bool HasLinkFormulaNeedingCheck() const { return bLinkFormulaNeedingCheck; }
2215 void SetLinkFormulaNeedingCheck(bool bSet) { bLinkFormulaNeedingCheck = bSet; }
2216 /** Check token array and set link check if ocDde/ocWebservice is contained. */
2217 SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode );
2219 void SetRangeOverflowType(ErrCode nType) { nRangeOverflowType = nType; }
2220 bool HasRangeOverflow() const { return nRangeOverflowType != ERRCODE_NONE; }
2221 SC_DLLPUBLIC const ErrCode& GetRangeOverflowType() const { return nRangeOverflowType; }
2223 // for broadcasting/listening
2224 void SetInsertingFromOtherDoc( bool bVal ) { bInsertingFromOtherDoc = bVal; }
2225 bool IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc; }
2226 void SetLoadingMedium( bool bVal );
2227 SC_DLLPUBLIC void SetImportingXML( bool bVal );
2228 bool IsImportingXML() const { return bImportingXML; }
2229 bool IsCalcingAfterLoad() const { return bCalcingAfterLoad; }
2230 void SetNoListening( bool bVal ) { bNoListening = bVal; }
2231 bool GetNoListening() const { return bNoListening; }
2232 ScBroadcastAreaSlotMachine* GetBASM() const { return pBASM.get(); }
2234 SC_DLLPUBLIC ScChartListenerCollection* GetChartListenerCollection() const { return pChartListenerCollection.get(); }
2235 void SetChartListenerCollection( std::unique_ptr<ScChartListenerCollection>,
2236 bool bSetChartRangeLists );
2237 void UpdateChart( const OUString& rName );
2238 void RestoreChartListener( const OUString& rName );
2239 SC_DLLPUBLIC void UpdateChartListenerCollection();
2240 bool IsChartListenerCollectionNeedsUpdate() const { return bChartListenerCollectionNeedsUpdate; }
2241 void SetChartListenerCollectionNeedsUpdate( bool bFlg ) { bChartListenerCollectionNeedsUpdate = bFlg; }
2242 void AddOLEObjectToCollection(const OUString& rName);
2244 ScChangeViewSettings* GetChangeViewSettings() const { return pChangeViewSettings.get(); }
2245 SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings& rNew);
2247 const std::shared_ptr<SvxForbiddenCharactersTable>& GetForbiddenCharacters() const;
2248 void SetForbiddenCharacters(const std::shared_ptr<SvxForbiddenCharactersTable>& rNew);
2250 CharCompressType GetAsianCompression() const;
2251 bool IsValidAsianCompression() const;
2252 void SetAsianCompression(CharCompressType nNew);
2254 bool GetAsianKerning() const;
2255 bool IsValidAsianKerning() const;
2256 void SetAsianKerning(bool bNew);
2257 void ApplyAsianEditSettings(ScEditEngineDefaulter& rEngine);
2259 EEHorizontalTextDirection GetEditTextDirection(SCTAB nTab) const; // EEHorizontalTextDirection values
2261 SC_DLLPUBLIC ScLkUpdMode GetLinkMode() const { return eLinkMode ;}
2262 void SetLinkMode( ScLkUpdMode nSet ) { eLinkMode = nSet;}
2264 SC_DLLPUBLIC ScMacroManager* GetMacroManager();
2266 void FillMatrix( ScMatrix& rMat, SCTAB nTab, SCCOL nCol1,
2267 SCROW nRow1, SCCOL nCol2, SCROW nRow2,
2268 svl::SharedStringPool* pPool = nullptr) const;
2271 * Set an array of numerical formula results to a group of contiguous
2272 * formula cells.
2274 * @param rTopPos position of the top formula cell of a group.
2275 * @param pResults array of numeric results.
2276 * @param nLen length of numeric results.
2278 void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const double* pResults, size_t nLen );
2280 void CalculateInColumnInThread( ScInterpreterContext& rContext, const ScRange& rCalcRange, unsigned nThisThread, unsigned nThreadsTotal);
2281 void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab, ScInterpreter* pInterpreter );
2284 * Transfer a series of contiguous cell values from specified position to
2285 * the passed container. The specified segment will become empty after the
2286 * transfer.
2288 void TransferCellValuesTo( const ScAddress& rTopPos, size_t nLen, sc::CellValues& rDest );
2289 void CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellValues& rSrc );
2291 std::set<Color> GetDocColors();
2292 sc::IconSetBitmapMap& GetIconSetBitmapMap();
2294 std::set<SCCOL> QueryColumnsWithFormulaCells( SCTAB nTab ) const;
2297 * Check the integrity of the internal table state. Useful from testing
2298 * code. It throws an exception upon first failure.
2300 * Feel free to add more checks as needed.
2302 void CheckIntegrity( SCTAB nTab ) const;
2304 private:
2305 ScDocument(const ScDocument& r) = delete;
2307 void FindMaxRotCol( SCTAB nTab, RowInfo* pRowInfo, SCSIZE nArrCount,
2308 SCCOL nX1, SCCOL nX2 ) const;
2310 sal_uInt16 RowDifferences( SCROW nThisRow, SCTAB nThisTab,
2311 ScDocument& rOtherDoc,
2312 SCROW nOtherRow, SCTAB nOtherTab,
2313 SCCOL nMaxCol, const SCCOLROW* pOtherCols );
2314 sal_uInt16 ColDifferences( SCCOL nThisCol, SCTAB nThisTab,
2315 ScDocument& rOtherDoc,
2316 SCCOL nOtherCol, SCTAB nOtherTab,
2317 SCROW nMaxRow, const SCCOLROW* pOtherRows );
2318 void FindOrder( SCCOLROW* pOtherRows, SCCOLROW nThisEndRow, SCCOLROW nOtherEndRow,
2319 bool bColumns,
2320 ScDocument& rOtherDoc, SCTAB nThisTab, SCTAB nOtherTab,
2321 SCCOLROW nEndCol, const SCCOLROW* pTranslate,
2322 ScProgress* pProgress, sal_uInt64 nProAdd );
2324 DECL_LINK(TrackTimeHdl, Timer *, void);
2326 /** Adjust a range to available sheets.
2328 Used to start and stop listening on a sane range. Both o_rRange and
2329 o_bEntirelyOutOfBounds are set only if needed and don't have to be
2330 initialized by the caller.
2332 @param o_bEntirelyOutOfBounds
2333 <TRUE/> if both sheets in the range point outside the
2334 available sheet range, in which case no adjustment is done and
2335 o_rRange is not modified.
2337 @return <TRUE/> if any adjustment was done or o_bEntirelyOutOfBounds
2338 was set <TRUE/>.
2339 <FALSE/> if rRange was within the available sheets.
2341 bool LimitRangeToAvailableSheets( const ScRange& rRange, ScRange& o_rRange,
2342 bool& o_bEntirelyOutOfBounds ) const;
2344 public:
2345 void StartListeningArea( const ScRange& rRange, bool bGroupListening, SvtListener* pListener );
2347 void EndListeningArea( const ScRange& rRange, bool bGroupListening, SvtListener* pListener );
2348 /** Broadcast wrapper, calls
2349 rHint.GetCell()->Broadcast() and AreaBroadcast()
2350 and TrackFormulas()
2351 Preferred.
2353 void Broadcast( const ScHint& rHint );
2355 void BroadcastCells( const ScRange& rRange, SfxHintId nHint, bool bBroadcastSingleBroadcasters = true );
2357 /// only area, no cell broadcast
2358 void AreaBroadcast( const ScHint& rHint );
2359 void DelBroadcastAreasInRange( const ScRange& rRange );
2360 void UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode,
2361 const ScRange& rRange,
2362 SCCOL nDx, SCROW nDy, SCTAB nDz );
2364 void StartListeningCell( const ScAddress& rAddress,
2365 SvtListener* pListener );
2366 void EndListeningCell( const ScAddress& rAddress,
2367 SvtListener* pListener );
2369 void StartListeningCell( sc::StartListeningContext& rCxt, const ScAddress& rPos, SvtListener& rListener );
2370 void EndListeningCell( sc::EndListeningContext& rCxt, const ScAddress& rPos, SvtListener& rListener );
2372 void EndListeningFormulaCells( std::vector<ScFormulaCell*>& rCells );
2374 sc::BroadcasterState GetBroadcasterState() const;
2376 void PutInFormulaTree( ScFormulaCell* pCell );
2377 void RemoveFromFormulaTree( ScFormulaCell* pCell );
2380 * Calculate formula cells that are on the formula tree either partially,
2381 * or in full.
2383 * @param bOnlyForced when true, it only calculates those formula cells
2384 * that are marked "recalc forced".
2385 * @param bProgressBar whether or not to use progress bar.
2386 * @param bSetAllDirty when true, it marks all formula cells currently on
2387 * the formula tree dirty, which forces all of them to
2388 * be recalculated. When false, only those cells
2389 * that are marked dirty prior to this call get
2390 * recalculated.
2392 SC_DLLPUBLIC void CalcFormulaTree( bool bOnlyForced = false, bool bProgressBar = true, bool bSetAllDirty = true );
2393 void ClearFormulaTree();
2394 void AppendToFormulaTrack( ScFormulaCell* pCell );
2395 void RemoveFromFormulaTrack( ScFormulaCell* pCell );
2396 void TrackFormulas( SfxHintId nHintId = SfxHintId::ScDataChanged );
2397 void SetTrackFormulasPending() { mbTrackFormulasPending = true; }
2398 bool IsTrackFormulasPending() const { return mbTrackFormulasPending; }
2399 void FinalTrackFormulas( SfxHintId nHintId );
2400 bool IsFinalTrackFormulas() const { return mbFinalTrackFormulas; }
2401 inline bool IsInFormulaTree( const ScFormulaCell* pCell ) const;
2402 inline bool IsInFormulaTrack( const ScFormulaCell* pCell ) const;
2403 HardRecalcState GetHardRecalcState() const { return eHardRecalcState; }
2404 void SetHardRecalcState( HardRecalcState eVal ) { eHardRecalcState = eVal; }
2405 void StartAllListeners();
2406 void StartNeededListeners();
2407 void StartNeededListeners( const std::shared_ptr<const sc::ColumnSet>& rpColSet );
2408 SC_DLLPUBLIC void StartAllListeners( const ScRange& rRange );
2410 void SetForcedFormulas( bool bVal ) { bHasForcedFormulas = bVal; }
2411 sal_uInt64 GetFormulaCodeInTree() const { return nFormulaCodeInTree; }
2413 bool IsInInterpreter() const { return nInterpretLevel != 0; }
2415 void IncInterpretLevel()
2417 assert(!IsThreadedGroupCalcInProgress());
2418 if ( nInterpretLevel < USHRT_MAX )
2419 nInterpretLevel++;
2421 void DecInterpretLevel()
2423 assert(!IsThreadedGroupCalcInProgress());
2424 if ( nInterpretLevel )
2425 nInterpretLevel--;
2427 sal_uInt16 GetMacroInterpretLevel() const { return nMacroInterpretLevel; }
2428 void IncMacroInterpretLevel()
2430 assert(!IsThreadedGroupCalcInProgress());
2431 if ( nMacroInterpretLevel < USHRT_MAX )
2432 nMacroInterpretLevel++;
2434 void DecMacroInterpretLevel()
2436 assert(!IsThreadedGroupCalcInProgress());
2437 if ( nMacroInterpretLevel )
2438 nMacroInterpretLevel--;
2440 bool IsInInterpreterTableOp() const { return nInterpreterTableOpLevel != 0; }
2441 void IncInterpreterTableOpLevel()
2443 if ( nInterpreterTableOpLevel < USHRT_MAX )
2444 nInterpreterTableOpLevel++;
2446 void DecInterpreterTableOpLevel()
2448 if ( nInterpreterTableOpLevel )
2449 nInterpreterTableOpLevel--;
2452 // add a formula to be remembered for TableOp broadcasts
2453 void AddTableOpFormulaCell( ScFormulaCell* );
2454 void InvalidateLastTableOpParams() { aLastTableOpParams.bValid = false; }
2455 ScRecursionHelper& GetRecursionHelper();
2456 bool IsInDtorClear() const { return bInDtorClear; }
2457 void SetExpandRefs( bool bVal );
2458 bool IsExpandRefs() const { return bExpandRefs; }
2460 sal_uInt64 GetXMLImportedFormulaCount() const { return nXMLImportedFormulaCount; }
2461 void IncXMLImportedFormulaCount( sal_uInt64 nVal )
2463 if ( nXMLImportedFormulaCount + nVal > nXMLImportedFormulaCount )
2464 nXMLImportedFormulaCount += nVal;
2466 void DecXMLImportedFormulaCount( sal_uInt64 nVal )
2468 if ( nVal <= nXMLImportedFormulaCount )
2469 nXMLImportedFormulaCount -= nVal;
2470 else
2471 nXMLImportedFormulaCount = 0;
2474 void StartTrackTimer();
2476 void CompileDBFormula();
2477 void CompileColRowNameFormula();
2479 /** Maximum string length of a column, e.g. for dBase export.
2480 @return String length in octets (!) of the destination encoding. In
2481 case of non-octet encodings (e.g. UCS2) the length in code
2482 points times sizeof(sal_Unicode) is returned. */
2483 sal_Int32 GetMaxStringLen( SCTAB nTab, SCCOL nCol,
2484 SCROW nRowStart, SCROW nRowEnd,
2485 rtl_TextEncoding eCharSet ) const;
2486 /** Maximum string length of numerical cells of a column, e.g. for dBase export.
2487 @return String length in characters (!) including the decimal
2488 separator, and the decimal precision needed. */
2489 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
2490 SCTAB nTab, SCCOL nCol,
2491 SCROW nRowStart, SCROW nRowEnd ) const;
2493 void KeyInput(); // TimerDelays etc.
2495 ScChangeTrack* GetChangeTrack() const { return pChangeTrack.get(); }
2497 //! only for import filter, deletes any existing ChangeTrack via
2498 //! EndChangeTracking() and takes ownership of new ChangeTrack pTrack
2499 SC_DLLPUBLIC void SetChangeTrack( std::unique_ptr<ScChangeTrack> pTrack );
2501 void StartChangeTracking();
2502 void EndChangeTracking();
2504 SC_DLLPUBLIC void CompareDocument( ScDocument& rOtherDoc );
2506 void AddUnoObject( SfxListener& rObject );
2507 void RemoveUnoObject( SfxListener& rObject );
2508 void BroadcastUno( const SfxHint &rHint );
2509 void AddUnoListenerCall( const css::uno::Reference<
2510 css::util::XModifyListener >& rListener,
2511 const css::lang::EventObject& rEvent );
2513 void SetInLinkUpdate(bool bSet); // TableLink or AreaLink
2514 bool IsInLinkUpdate() const; // including DdeLink
2516 SC_DLLPUBLIC SfxItemPool* GetEditPool() const;
2517 SC_DLLPUBLIC SfxItemPool* GetEnginePool() const;
2518 SC_DLLPUBLIC ScFieldEditEngine& GetEditEngine();
2519 SC_DLLPUBLIC ScNoteEditEngine& GetNoteEngine();
2521 std::unique_ptr<EditTextObject> CreateSharedStringTextObject( const svl::SharedString& rSS );
2523 std::unique_ptr<ScRefreshTimerControl> const & GetRefreshTimerControlAddress() const
2524 { return pRefreshTimerControl; }
2526 void SetPastingDrawFromOtherDoc( bool bVal )
2527 { bPastingDrawFromOtherDoc = bVal; }
2528 bool PastingDrawFromOtherDoc() const
2529 { return bPastingDrawFromOtherDoc; }
2531 /// an ID unique to each document instance
2532 sal_uInt32 GetDocumentID() const;
2534 void InvalidateStyleSheetUsage() { bStyleSheetUsageInvalid = true; }
2535 void SC_DLLPUBLIC GetSortParam( ScSortParam& rParam, SCTAB nTab );
2536 void SC_DLLPUBLIC SetSortParam( const ScSortParam& rParam, SCTAB nTab );
2538 void SetVbaEventProcessor( const css::uno::Reference< css::script::vba::XVBAEventProcessor >& rxVbaEvents )
2539 { mxVbaEvents = rxVbaEvents; }
2540 const css::uno::Reference< css::script::vba::XVBAEventProcessor >& GetVbaEventProcessor() const { return mxVbaEvents; }
2542 /** Should only be GRAM_PODF or GRAM_ODFF. */
2543 void SetStorageGrammar( formula::FormulaGrammar::Grammar eGrammar );
2544 formula::FormulaGrammar::Grammar GetStorageGrammar() const { return eStorageGrammar; }
2546 SC_DLLPUBLIC ScUndoManager* GetUndoManager();
2547 bool IsInVBAMode() const;
2548 ScRowBreakIterator* GetRowBreakIterator(SCTAB nTab) const;
2550 void AddSubTotalCell(ScFormulaCell* pCell);
2551 void RemoveSubTotalCell(ScFormulaCell* pCell);
2552 void SetSubTotalCellsDirty(const ScRange& rDirtyRange);
2554 sal_uInt16 GetTextWidth( const ScAddress& rPos ) const;
2556 SvtScriptType GetScriptType( const ScAddress& rPos ) const;
2557 void SetScriptType( const ScAddress& rPos, SvtScriptType nType );
2558 void UpdateScriptTypes( const ScAddress& rPos, SCCOL nColSize, SCROW nRowSize );
2561 * Make specified formula cells non-grouped.
2563 * @param nTab sheet index
2564 * @param nCol column index
2565 * @param rRows list of row indices at which formula cells are to be
2566 * unshared. This call sorts the passed row indices and
2567 * removes duplicates, which is why the caller must pass it
2568 * as reference.
2570 void UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector<SCROW>& rRows );
2571 void RegroupFormulaCells( SCTAB nTab, SCCOL nCol );
2572 SC_DLLPUBLIC void RegroupFormulaCells( const ScRange& range );
2574 formula::FormulaTokenRef ResolveStaticReference( const ScAddress& rPos );
2575 formula::FormulaTokenRef ResolveStaticReference( const ScRange& rRange );
2577 formula::VectorRefArray FetchVectorRefArray( const ScAddress& rPos, SCROW nLength );
2578 bool HandleRefArrayForParallelism( const ScAddress& rPos, SCROW nLength, const ScFormulaCellGroupRef& mxGroup );
2579 #ifdef DBG_UTIL
2580 void AssertNoInterpretNeeded( const ScAddress& rPos, SCROW nLength );
2581 #endif
2584 * Call this before any operations that might trigger one or more formula
2585 * cells to get calculated.
2587 void PrepareFormulaCalc();
2590 * Make sure all of the formula cells in the specified range have been
2591 * fully calculated. This method only re-calculates those formula cells
2592 * that have been flagged dirty. In case of formula-groups, this calculates
2593 * only the dirty subspans along with the dependents in the same way
2594 * recursively.
2596 * @param rRange range in which to potentially calculate the formula
2597 * cells.
2598 * @param bSkipRunning flag to skip evaluation of formula-cells that are
2599 * marked as already being evaluated.
2600 * @return true if at least one formula-cell in the specified range was dirty
2601 * else returns false.
2603 SC_DLLPUBLIC bool EnsureFormulaCellResults( const ScRange& rRange, bool bSkipRunning = false );
2605 SvtBroadcaster* GetBroadcaster( const ScAddress& rPos );
2606 const SvtBroadcaster* GetBroadcaster( const ScAddress& rPos ) const;
2607 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rTopPos, SCROW nLength );
2609 std::optional<sc::ColumnIterator> GetColumnIterator( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
2610 void CreateColumnIfNotExists( SCTAB nTab, SCCOL nCol );
2612 SC_DLLPUBLIC void StoreTabToCache(SCTAB nTab, SvStream& rStrm) const;
2613 SC_DLLPUBLIC void RestoreTabFromCache(SCTAB nTab, SvStream& rStream);
2615 #if DUMP_COLUMN_STORAGE
2616 SC_DLLPUBLIC void DumpColumnStorage( SCTAB nTab, SCCOL nCol ) const;
2617 #endif
2619 SC_DLLPUBLIC void SetCalcConfig( const ScCalcConfig& rConfig );
2620 const ScCalcConfig& GetCalcConfig() const { return maCalcConfig; }
2621 void ConvertFormulaToValue( const ScRange& rRange, sc::TableValues* pUndo );
2622 void SwapNonEmpty( sc::TableValues& rValues );
2623 void finalizeOutlineImport();
2624 bool TableExists( SCTAB nTab ) const;
2626 // Returns the given column range, first allocating all the columns if necessary.
2627 SC_DLLPUBLIC ScColumnsRange GetWritableColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd);
2628 // Returns a column range, clamped to the allocated columns.
2629 SC_DLLPUBLIC ScColumnsRange GetAllocatedColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const;
2630 // Returns the given range, without any adjustments. One of the variants above may return
2631 // a smaller range (better performance) if the use case is known.
2632 SC_DLLPUBLIC ScColumnsRange GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const;
2634 bool IsInDocShellRecalc() const { return mbDocShellRecalc; }
2635 void SetDocShellRecalc(bool bSet) { mbDocShellRecalc = bSet; }
2637 bool IsInLayoutStrings() const { return mbLayoutStrings; }
2638 void SetLayoutStrings(bool bSet) { mbLayoutStrings = bSet; }
2641 * Serializes the specified sheet's geometry data.
2643 * @param nTab is the index of the sheet to operate on.
2644 * @param bColumns - if true it dumps the data for columns, else it does for rows.
2645 * @param eGeomType indicates the type of data to be dumped for rows/columns.
2646 * @return the serialization of the specified sheet's geometry data as an OString.
2648 OString dumpSheetGeomData(SCTAB nTab, bool bColumns, SheetGeomType eGeomType);
2650 SCCOL GetLOKFreezeCol(SCTAB nTab) const;
2651 SCROW GetLOKFreezeRow(SCTAB nTab) const;
2652 bool SetLOKFreezeCol(SCCOL nFreezeCol, SCTAB nTab);
2653 bool SetLOKFreezeRow(SCROW nFreezeRow, SCTAB nTab);
2655 private:
2658 * Use this class as a locale variable to merge number formatter from
2659 * another document, and set NULL pointer to pFormatExchangeList when
2660 * done.
2662 class NumFmtMergeHandler
2664 public:
2665 explicit NumFmtMergeHandler(ScDocument& rDoc, const ScDocument& rSrcDoc);
2666 ~NumFmtMergeHandler();
2668 private:
2669 ScDocument& mrDoc;
2672 void MergeNumberFormatter(const ScDocument& rSrcDoc);
2674 void ImplCreateOptions(); // Suggestion: switch to on-demand?
2675 void ImplDeleteOptions();
2677 SC_DLLPUBLIC bool DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const;
2679 void UpdateDrawPrinter();
2680 void UpdateDrawLanguages();
2681 SC_DLLPUBLIC void InitClipPtrs( ScDocument* pSourceDoc );
2683 void LoadDdeLinks(SvStream& rStream);
2684 void SaveDdeLinks(SvStream& rStream) const;
2686 void DeleteAreaLinksOnTab( SCTAB nTab );
2687 void UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
2688 const ScRange& r, SCCOL nDx, SCROW nDy, SCTAB nDz );
2690 void CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks);
2692 bool HasPartOfMerged( const ScRange& rRange );
2694 public:
2695 SC_DLLPUBLIC ScTable* FetchTable( SCTAB nTab );
2696 const ScTable* FetchTable( SCTAB nTab ) const;
2698 ScRefCellValue GetRefCellValue( const ScAddress& rPos );
2699 private:
2700 ScRefCellValue GetRefCellValue( const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos );
2702 std::map< SCTAB, ScSortParam > mSheetSortParams;
2704 SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol ) const;
2705 SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
2706 void ReservePatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserve );
2708 void SharePooledResources( const ScDocument* pSrcDoc );
2710 void EndListeningIntersectedGroup(
2711 sc::EndListeningContext& rCxt, const ScAddress& rPos, std::vector<ScAddress>* pGroupPos );
2713 void EndListeningIntersectedGroups(
2714 sc::EndListeningContext& rCxt, const ScRange& rRange, std::vector<ScAddress>* pGroupPos );
2716 void EndListeningGroups( const std::vector<ScAddress>& rPosArray );
2717 void SetNeedsListeningGroups( const std::vector<ScAddress>& rPosArray );
2719 bool BroadcastHintInternal( const ScHint &rHint );
2722 typedef std::unique_ptr<ScDocument, o3tl::default_delete<ScDocument>> ScDocumentUniquePtr;
2725 * Instantiate this to ensure that subsequent modification of
2726 * the document will cause an assertion failure while this is
2727 * in-scope.
2729 struct ScMutationDisable
2731 #ifndef NDEBUG
2732 ScMutationDisable(ScDocument& rDocument, ScMutationGuardFlags nFlags)
2733 : mnFlagRestore(rDocument.mnMutationGuardFlags)
2734 , mrDocument(rDocument)
2736 assert((mnFlagRestore & nFlags) == 0);
2737 mrDocument.mnMutationGuardFlags |= static_cast<size_t>(nFlags);
2739 ~ScMutationDisable()
2741 mrDocument.mnMutationGuardFlags = mnFlagRestore;
2743 size_t mnFlagRestore;
2744 ScDocument& mrDocument;
2745 #else
2746 ScMutationDisable(ScDocument& rDocument, ScMutationGuardFlags nFlags)
2748 (void)rDocument; (void)nFlags;
2750 #endif
2754 * A pretty assertion that checks that the relevant bits in
2755 * the @nFlags are not set on the document at entry and exit.
2757 * Its primary use is for debugging threading. As such, an
2758 * @ScMutationDisable is created to forbid mutation, and this
2759 * condition is then asserted on at prominent sites that
2760 * mutate @nFlags.
2762 struct ScMutationGuard
2764 #ifndef NDEBUG
2765 ScMutationGuard(ScDocument& rDocument, ScMutationGuardFlags nFlags)
2766 : mnFlags(static_cast<size_t>(nFlags))
2767 , mrDocument(rDocument)
2769 assert((mrDocument.mnMutationGuardFlags & mnFlags) == 0);
2772 ~ScMutationGuard()
2774 assert((mrDocument.mnMutationGuardFlags & mnFlags) == 0);
2776 size_t mnFlags;
2777 ScDocument& mrDocument;
2778 #else
2779 ScMutationGuard(ScDocument& rDocument, ScMutationGuardFlags nFlags)
2781 (void)rDocument; (void)nFlags;
2783 #endif
2786 class ScDocShellRecalcGuard
2788 ScDocument& mrDoc;
2790 public:
2791 ScDocShellRecalcGuard(ScDocument& rDoc)
2792 : mrDoc(rDoc)
2794 assert(!mrDoc.IsInDocShellRecalc());
2795 mrDoc.SetDocShellRecalc(true);
2798 ~ScDocShellRecalcGuard()
2800 mrDoc.SetDocShellRecalc(false);
2804 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */