Teach symstore more duplicated DLLs
[LibreOffice.git] / sc / inc / document.hxx
blob4cc98b01096eb0a838a27567b8162bf6b98602cd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_INC_DOCUMENT_HXX
21 #define INCLUDED_SC_INC_DOCUMENT_HXX
23 #include <vcl/idle.hxx>
24 #include <vcl/errcode.hxx>
25 #include <com/sun/star/uno/Reference.hxx>
26 #include <vcl/vclptr.hxx>
27 #include "patattr.hxx"
28 #include "scdllapi.h"
29 #include "interpretercontext.hxx"
30 #include "rangelst.hxx"
31 #include "rangenam.hxx"
32 #include "tabopparams.hxx"
33 #include "types.hxx"
34 #include <formula/grammar.hxx>
35 #include <formula/types.hxx>
36 #include "typedstrdata.hxx"
37 #include "calcmacros.hxx"
38 #include "calcconfig.hxx"
39 #include <o3tl/deleter.hxx>
40 #include <o3tl/sorted_vector.hxx>
41 #include <svl/hint.hxx>
42 #include <svl/typedwhich.hxx>
43 #include <svl/zforlist.hxx>
44 #include <tools/gen.hxx>
45 #include <tools/solar.h>
47 #include <cassert>
48 #include <memory>
49 #include <map>
50 #include <set>
51 #include <vector>
53 #include "markdata.hxx"
55 namespace com { namespace sun { namespace star { namespace chart2 { class XChartDocument; } } } }
57 class Timer;
59 enum class SvtScriptType;
60 enum class ScMF;
61 enum class FormulaError : sal_uInt16;
62 enum class CharCompressType;
63 enum class EEHorizontalTextDirection;
64 namespace editeng { class SvxBorderLine; }
65 namespace formula { struct VectorRefArray; }
66 namespace svl {
68 class SharedString;
69 class SharedStringPool;
73 namespace sc {
75 struct FormulaGroupContext;
76 class StartListeningContext;
77 class EndListeningContext;
78 class CopyFromClipContext;
79 class ColumnSpanSet;
80 class RangeColumnSpanSet;
81 struct ColumnBlockPosition;
82 struct RefUpdateContext;
83 class EditTextIterator;
84 struct NoteEntry;
85 class DocumentStreamAccess;
86 class DocumentLinkManager;
87 class CellValues;
88 class TableValues;
89 class RowHeightContext;
90 struct SetFormulaDirtyContext;
91 class RefMovedHint;
92 struct ReorderParam;
93 class FormulaGroupAreaListener;
94 class ColumnSet;
95 class UpdatedRangeNames;
96 class TableColumnBlockPositionSet;
97 class ColumnIterator;
98 class ExternalDataMapper;
102 class Fraction;
104 class OutputDevice;
105 class SdrObject;
106 class SfxBroadcaster;
107 class SfxListener;
108 class SfxItemSet;
109 class SfxObjectShell;
110 class SfxBindings;
111 class SfxPoolItem;
112 class SfxItemPool;
113 class SfxPrinter;
114 class SfxStyleSheetBase;
115 class SvMemoryStream;
116 class SvxBoxInfoItem;
117 class SvxBoxItem;
118 class SvxForbiddenCharactersTable;
119 namespace sfx2 {
120 class LinkManager;
122 class SvxSearchItem;
123 namespace vcl { class Window; }
124 class XColorList;
126 class ScAutoFormatData;
127 class ScBroadcastAreaSlotMachine;
128 class ScChangeViewSettings;
129 class ScChartListenerCollection;
130 class ScClipOptions;
131 class ScConditionalFormat;
132 class ScConditionalFormatList;
133 class ScDBCollection;
134 class ScDBData;
135 class ScDetOpData;
136 class ScDetOpList;
137 class ScDocOptions;
138 class ScDocProtection;
139 class ScDocumentPool;
140 class ScDrawLayer;
141 class ScExtDocOptions;
142 class ScExternalRefManager;
143 class ScFormulaCell;
144 class ScMacroManager;
145 class ScOutlineTable;
146 class ScPrintRangeSaver;
147 class ScStyleSheet;
148 class ScStyleSheetPool;
149 class ScTable;
150 class ScTableProtection;
151 class ScTokenArray;
152 class ScValidationData;
153 class ScValidationDataList;
154 class ScViewOptions;
155 class ScChangeTrack;
156 class ScEditEngineDefaulter;
157 class ScFieldEditEngine;
158 class ScNoteEditEngine;
159 class ScDPObject;
160 class ScDPCollection;
161 class ScMatrix;
162 class ScScriptTypeData;
163 class ScPoolHelper;
164 struct ScSortParam;
165 class ScRefreshTimerControl;
166 class ScUnoListenerCalls;
167 class ScUnoRefList;
168 class ScRecursionHelper;
169 struct RowInfo;
170 struct ScTableInfo;
171 struct ScTabOpParam;
172 class VirtualDevice;
173 class ScAutoNameCache;
174 class ScTemporaryChartLock;
175 class ScLookupCache;
176 struct ScLookupCacheMap;
177 class SfxUndoManager;
178 class ScFormulaParserPool;
179 struct ScClipParam;
180 class ScRowBreakIterator;
181 struct ScSetStringParam;
182 struct ScColWidthParam;
183 class ScSheetEvents;
184 class ScProgress;
185 class SvtListener;
186 class ScEditDataArray;
187 class EditTextObject;
188 struct ScRefCellValue;
189 class ScPostIt;
190 struct ScSubTotalParam;
191 struct ScQueryParam;
192 class ScHint;
193 class SvtBroadcaster;
194 enum class ScDBDataPortion;
195 enum class ScSheetEventId;
196 class BitmapEx;
197 class ScColumnsRange;
198 struct ScFilterEntries;
199 typedef o3tl::sorted_vector<sal_uInt32> ScCondFormatIndexes;
201 namespace sc {
203 typedef std::map<OUString, BitmapEx> IconSetBitmapMap;
207 namespace com { namespace sun { namespace star {
208 namespace lang {
209 struct EventObject;
211 namespace i18n {
212 class XBreakIterator;
214 namespace util {
215 class XModifyListener;
217 namespace embed {
218 class XEmbeddedObject;
220 namespace script { namespace vba {
221 class XVBAEventProcessor;
223 namespace sheet {
224 struct TablePageBreakData;
226 } } }
228 namespace weld {
230 class Window;
234 #define SC_DOC_NEW 0xFFFF
236 #define SC_MACROCALL_ALLOWED 0
238 #define SC_ASIANKERNING_INVALID 0xff
240 enum ScDocumentMode
242 SCDOCMODE_DOCUMENT,
243 SCDOCMODE_CLIP,
244 SCDOCMODE_UNDO,
245 SCDOCMODE_FUNCTIONACCESS
248 enum CommentCaptionState
250 ALLSHOWN, // All comments captions are shown
251 ALLHIDDEN, // All comments captions are hidden
252 MIXED // There are comments in shown and hidden.
255 enum RangeNameScope
257 GLOBAL, // A range name can be defined
258 SHEET // with two scope on Manage Names dialog.
261 struct ScDocStat
263 OUString aDocName;
264 SCTAB nTableCount;
265 sal_uLong nCellCount;
266 sal_uLong nFormulaCount;
267 sal_uInt16 nPageCount;
268 ScDocStat()
269 : nTableCount(0)
270 , nCellCount(0)
271 , nFormulaCount(0)
272 , nPageCount(0)
277 // DDE link modes
278 const sal_uInt8 SC_DDE_DEFAULT = 0;
279 const sal_uInt8 SC_DDE_ENGLISH = 1;
280 const sal_uInt8 SC_DDE_TEXT = 2;
281 const sal_uInt8 SC_DDE_IGNOREMODE = 255; /// For usage in FindDdeLink() only!
283 // During threaded calculation fields being mutated are kept in this struct
284 struct ScDocumentThreadSpecific
286 ScRecursionHelper* pRecursionHelper; // information for recursive and iterative cell formulas
287 ScInterpreterContext* pContext; // references the context passed around for easier access
289 ScDocumentThreadSpecific()
290 : pRecursionHelper(nullptr)
291 , pContext(nullptr)
295 // To be called in the thread at start
296 static void SetupFromNonThreadedData(const ScDocumentThreadSpecific& rNonThreadedData);
298 // To be called in the main thread after the thread has finished
299 static void MergeBackIntoNonThreadedData(ScDocumentThreadSpecific& rNonThreadedData);
302 /// Enumeration to determine which pieces of the code should not be mutated when set.
303 enum ScMutationGuardFlags
305 // Bit mask bits
306 CORE = 0x0001, /// Core calc data structures should not be mutated
309 typedef std::unique_ptr<ScTable, o3tl::default_delete<ScTable>> ScTableUniquePtr;
311 class ScDocument
313 friend class ScValueIterator;
314 friend class ScHorizontalValueIterator;
315 friend class ScDBQueryDataIterator;
316 friend class ScFormulaGroupIterator;
317 friend class ScCellIterator;
318 friend class ScQueryCellIterator;
319 friend class ScCountIfCellIterator;
320 friend class ScHorizontalCellIterator;
321 friend class ScHorizontalAttrIterator;
322 friend class ScDocAttrIterator;
323 friend class ScAccessibleTableBase;
324 friend class ScAttrRectIterator;
325 friend class ScDocShell;
326 friend class ScDocRowHeightUpdater;
327 friend class ScColumnTextWidthIterator;
328 friend class ScFormulaCell;
329 friend class ScTable;
330 friend class ScColumn;
331 friend struct ScRefCellValue;
332 friend class ScDocumentImport;
333 friend class sc::DocumentStreamAccess;
334 friend class sc::ColumnSpanSet;
335 friend class sc::RangeColumnSpanSet;
336 friend class sc::EditTextIterator;
337 friend class sc::FormulaGroupAreaListener;
338 friend class sc::TableColumnBlockPositionSet;
339 friend struct ScMutationGuard;
340 friend struct ScMutationDisable;
342 typedef std::vector<ScTableUniquePtr> TableContainer;
344 public:
345 enum class HardRecalcState
347 OFF, /// normal calculation of dependencies
348 TEMPORARY, /// CalcAll() without broadcast/notify but setting up new listeners
349 ETERNAL /// no new listeners are setup, no broadcast/notify
352 private:
353 rtl::Reference<ScPoolHelper> mxPoolHelper;
355 std::shared_ptr<svl::SharedStringPool> mpCellStringPool;
356 std::unique_ptr<sc::DocumentLinkManager> mpDocLinkMgr;
358 std::shared_ptr<sc::FormulaGroupContext> mpFormulaGroupCxt;
359 bool mbFormulaGroupCxtBlockDiscard;
361 ScCalcConfig maCalcConfig;
363 SfxUndoManager* mpUndoManager;
364 std::unique_ptr<ScFieldEditEngine> mpEditEngine; // uses pEditPool from xPoolHelper
365 std::unique_ptr<ScNoteEditEngine> mpNoteEngine; // uses pEditPool from xPoolHelper
366 SfxObjectShell* mpShell;
367 VclPtr<SfxPrinter> mpPrinter;
368 VclPtr<VirtualDevice> mpVirtualDevice_100th_mm;
369 std::unique_ptr<ScDrawLayer> mpDrawLayer; // SdrModel
370 rtl::Reference<XColorList> pColorList;
371 std::unique_ptr<ScValidationDataList> pValidationList; // validity
372 SvNumberFormatterIndexTable* pFormatExchangeList; // for application of number formats
373 TableContainer maTabs;
374 SCCOL mnMaxCol; /// Maximum addressable column
375 SCROW mnMaxRow; /// Maximum addressable row
376 std::vector<OUString> maTabNames; // for undo document, we need the information tab name <-> index
377 mutable std::unique_ptr<ScRangeName> pRangeName;
378 std::unique_ptr<ScDBCollection> pDBCollection;
379 std::unique_ptr<ScDPCollection> pDPCollection;
380 std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock;
381 std::unique_ptr<ScPatternAttr> pSelectionAttr; // Attributes of a block
382 ScFormulaCell* pFormulaTree; // formula tree (start)
383 ScFormulaCell* pEOFormulaTree; // formula tree (end), last cell
384 ScFormulaCell* pFormulaTrack; // BroadcastTrack (start)
385 ScFormulaCell* pEOFormulaTrack; // BroadcastTrack (end), last cell
386 std::unique_ptr<ScBroadcastAreaSlotMachine> pBASM; // BroadcastAreas
387 std::unique_ptr<ScChartListenerCollection> pChartListenerCollection;
388 std::unique_ptr<SvMemoryStream> pClipData;
389 std::unique_ptr<ScDetOpList> pDetOpList;
390 std::unique_ptr<ScChangeTrack> pChangeTrack;
391 std::unique_ptr<SfxBroadcaster> pUnoBroadcaster;
392 std::unique_ptr<ScUnoListenerCalls> pUnoListenerCalls;
393 std::unique_ptr<ScUnoRefList> pUnoRefUndoList;
394 std::unique_ptr<ScChangeViewSettings> pChangeViewSettings;
395 std::unique_ptr<ScScriptTypeData> pScriptTypeData;
396 std::unique_ptr<ScRefreshTimerControl> pRefreshTimerControl;
397 std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenCharacters;
398 std::unique_ptr<ScDBData> mpAnonymousDBData;
399 std::unique_ptr<sc::ExternalDataMapper> mpDataMapper;
401 std::unique_ptr<ScFieldEditEngine> pCacheFieldEditEngine;
403 std::unique_ptr<ScDocProtection> pDocProtection;
404 std::unique_ptr<ScClipParam> mpClipParam;
406 std::unique_ptr<ScExternalRefManager> pExternalRefMgr;
407 std::unique_ptr<ScMacroManager> mpMacroMgr;
409 // mutable for lazy construction
410 mutable std::unique_ptr< ScFormulaParserPool >
411 mxFormulaParserPool; /// Pool for all external formula parsers used by this document.
413 OUString aDocName; // optional: name of document
414 OUString aDocCodeName; // optional: name of document (twice?)
415 OUString maFileURL; // file URL for copy & paste
416 ScRangePairListRef xColNameRanges;
417 ScRangePairListRef xRowNameRanges;
419 std::unique_ptr<ScViewOptions> pViewOptions; // view options
420 std::unique_ptr<ScDocOptions> pDocOptions; // document options
421 std::unique_ptr<ScExtDocOptions> pExtDocOptions; // for import etc.
422 std::unique_ptr<ScClipOptions> mpClipOptions; // clipboard options
423 std::unique_ptr<ScConsolidateParam> pConsolidateDlgData;
425 std::unique_ptr<ScAutoNameCache> pAutoNameCache; // for automatic name lookup during CompileXML
427 std::unique_ptr<SfxItemSet> pPreviewFont; // convert to std::unique_ptr or whatever
428 ScStyleSheet* pPreviewCellStyle;
429 ScMarkData maPreviewSelection;
430 sal_Int64 nUnoObjectId; // counted up for UNO objects
432 ErrCode nRangeOverflowType; // used in (xml) loading for overflow warnings
434 ScRange aEmbedRange;
435 ScAddress aCurTextWidthCalcPos;
437 Idle aTrackIdle;
439 css::uno::Reference< css::script::vba::XVBAEventProcessor >
440 mxVbaEvents;
441 public:
442 /// list of ScInterpreterTableOpParams currently in use
443 std::vector<ScInterpreterTableOpParams*> m_TableOpList;
444 ScInterpreterTableOpParams aLastTableOpParams; // remember last params
446 private:
448 LanguageType eLanguage; // default language
449 LanguageType eCjkLanguage; // default language for asian text
450 LanguageType eCtlLanguage; // default language for complex text
451 rtl_TextEncoding eSrcSet; // during reading: source character set
453 /** The compiler grammar used in document storage. GRAM_PODF for ODF 1.1
454 documents, GRAM_ODFF for ODF 1.2 documents. */
455 formula::FormulaGrammar::Grammar eStorageGrammar;
457 sal_uLong nFormulaCodeInTree; // formula RPN in the formula tree
458 sal_uLong nXMLImportedFormulaCount; // progress count during XML import
459 sal_uInt16 nInterpretLevel; // >0 if in interpreter
460 sal_uInt16 nMacroInterpretLevel; // >0 if macro in interpreter
461 sal_uInt16 nInterpreterTableOpLevel; // >0 if in interpreter TableOp
463 ScDocumentThreadSpecific maNonThreaded;
465 // There can be only one ScDocument being calculated in a thread at a time, so we can use a
466 // plain thread_local static member.
467 thread_local static ScDocumentThreadSpecific maThreadSpecific;
469 mutable ScInterpreterContext maInterpreterContext;
471 osl::Mutex mScLookupMutex; // protection for thread-unsafe parts of handling ScLookup
473 static const sal_uInt16 nSrcVer; // file version (load/save)
474 sal_uInt16 nFormulaTrackCount;
475 HardRecalcState eHardRecalcState; // off, temporary, eternal
476 SCTAB nVisibleTab; // for OLE etc., don't use inside ScDocument
477 SCCOL nPosLeft; // for OLE etc., don't use inside ScDocument
478 SCROW nPosTop; // for OLE etc., don't use inside ScDocument
480 ScLkUpdMode eLinkMode;
482 bool bAutoCalc; // calculate automatically
483 bool bAutoCalcShellDisabled; // in/from/for ScDocShell disabled
484 // are there ForcedFormulas which have to be calculated
485 // in interaction with ScDocShell SetDocumentModified,
486 // AutoCalcShellDisabled and TrackFormulas
487 bool bForcedFormulaPending;
488 bool bCalculatingFormulaTree;
489 bool const bIsClip;
490 bool const bIsUndo;
491 bool const bIsFunctionAccess;
492 bool bIsVisible; // set from view ctor
494 bool bIsEmbedded; // display/adjust Embedded area?
496 // no broadcast, construct no listener during insert from a different
497 // Doc (per filter or the like ), not until CompileAll / CalcAfterLoad
498 bool bInsertingFromOtherDoc;
499 bool bLoadingMedium;
500 bool bImportingXML; // special handling of formula text
501 bool bCalcingAfterLoad; // in CalcAfterLoad TRUE
502 // don't construct/destruct listeners temporarily
503 bool bNoListening;
504 bool mbIdleEnabled;
505 bool bInLinkUpdate; // TableLink or AreaLink
506 bool bChartListenerCollectionNeedsUpdate;
507 // are/were there RC_FORCED formula cells in the document (if set once to TRUE then set forever)
508 bool bHasForcedFormulas;
509 // is the Doc being destroyed? (no Notify-Tracking etc. needed anymore)
510 bool bInDtorClear;
511 // expand reference if insert column/row takes place at the border
512 // of a reference
513 // is fetched in each UpdateReference from InputOptions,
514 // assigned, and restored at the end of UpdateReference
515 bool bExpandRefs;
516 // for detective update, is set for each change of a formula
517 bool bDetectiveDirty;
518 // If the pointer is set, formula cells will not be automatically grouped into shared formula groups,
519 // instead the range will be extended to contain all such cells.
520 std::unique_ptr< ScRange > pDelayedFormulaGrouping;
522 bool bLinkFormulaNeedingCheck; // valid only after loading, for ocDde and ocWebservice
524 CharCompressType nAsianCompression;
525 sal_uInt8 nAsianKerning;
527 bool bPastingDrawFromOtherDoc;
529 sal_uInt8 nInDdeLinkUpdate; // originating DDE links (stacked bool)
531 bool bInUnoBroadcast;
532 bool bInUnoListenerCall;
533 sal_uInt32 nAdjustHeightLock;
534 formula::FormulaGrammar::Grammar eGrammar;
536 mutable bool bStyleSheetUsageInvalid;
538 bool mbUndoEnabled:1;
539 bool mbExecuteLinkEnabled:1;
540 bool mbChangeReadOnlyEnabled:1; // allow changes in read-only document (for API import filters)
541 bool mbStreamValidLocked:1;
542 bool mbUserInteractionEnabled:1; // whether or not to launch any kind of interactive dialogs.
544 sal_Int16 mnNamedRangesLockCount;
546 std::set<ScFormulaCell*> maSubTotalCells;
549 bool mbEmbedFonts : 1;
550 bool mbEmbedUsedFontsOnly : 1;
551 bool mbEmbedFontScriptLatin : 1;
552 bool mbEmbedFontScriptAsian : 1;
553 bool mbEmbedFontScriptComplex : 1;
555 std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap;
557 bool mbTrackFormulasPending : 1;
558 bool mbFinalTrackFormulas : 1;
559 // This indicates if a ScDocShell::DoRecalc() or ScDocShell::DoHardRecalc() is in progress.
560 bool mbDocShellRecalc : 1;
561 // This indicates if a ScOutputData::LayoutStrings() is in progress.
562 bool mbLayoutStrings : 1;
564 size_t mnMutationGuardFlags;
566 public:
567 bool IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBorder);
568 void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge);
570 bool IsEmbedFonts() const { return mbEmbedFonts; }
571 bool IsEmbedUsedFontsOnly() const { return mbEmbedUsedFontsOnly; }
572 bool IsEmbedFontScriptLatin() const { return mbEmbedFontScriptLatin; }
573 bool IsEmbedFontScriptAsian() const { return mbEmbedFontScriptAsian; }
574 bool IsEmbedFontScriptComplex() const { return mbEmbedFontScriptComplex; }
576 void SetEmbedFonts(bool bUse) { mbEmbedFonts = bUse; }
577 void SetEmbedUsedFontsOnly(bool bUse) { mbEmbedUsedFontsOnly = bUse; }
578 void SetEmbedFontScriptLatin(bool bUse) { mbEmbedFontScriptLatin = bUse; }
579 void SetEmbedFontScriptAsian(bool bUse) { mbEmbedFontScriptAsian = bUse; }
580 void SetEmbedFontScriptComplex(bool bUse) { mbEmbedFontScriptComplex = bUse; }
582 SC_DLLPUBLIC sal_uLong GetCellCount() const; // all cells
583 SC_DLLPUBLIC sal_uLong GetFormulaGroupCount() const; // all cells
584 sal_uLong GetCodeCount() const; // RPN-Code in formulas
585 DECL_LINK( GetUserDefinedColor, sal_uInt16, Color* );
586 // number formatter
587 public:
588 SC_DLLPUBLIC ScDocument( ScDocumentMode eMode = SCDOCMODE_DOCUMENT,
589 SfxObjectShell* pDocShell = nullptr );
590 SC_DLLPUBLIC ~ScDocument();
592 void SetName( const OUString& r ) { aDocName = r; }
593 const OUString& GetCodeName() const { return aDocCodeName; }
594 void SetCodeName( const OUString& r ) { aDocCodeName = r; }
595 const OUString& GetFileURL() const { return maFileURL; }
597 void GetDocStat( ScDocStat& rDocStat );
599 SC_DLLPUBLIC void InitDrawLayer( SfxObjectShell* pDocShell = nullptr );
601 ScInterpreterContext& GetNonThreadedContext() const
603 assert(!IsThreadedGroupCalcInProgress());
604 return maInterpreterContext;
606 // Uses thread_local.
607 ScInterpreterContext& GetThreadedContext() const
609 return IsThreadedGroupCalcInProgress() ? *maThreadSpecific.pContext : GetNonThreadedContext();
611 static void SetupFromNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
612 void MergeBackIntoNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber );
613 void SetThreadedGroupCalcInProgress( bool set ) { (void)this; ScGlobal::bThreadedGroupCalcInProgress = set; }
614 bool IsThreadedGroupCalcInProgress() const { (void)this; return ScGlobal::bThreadedGroupCalcInProgress; }
616 SC_DLLPUBLIC sfx2::LinkManager* GetLinkManager();
617 SC_DLLPUBLIC const sfx2::LinkManager* GetLinkManager() const;
619 sc::DocumentLinkManager& GetDocLinkManager();
620 const sc::DocumentLinkManager& GetDocLinkManager() const;
622 SC_DLLPUBLIC const ScDocOptions& GetDocOptions() const;
623 SC_DLLPUBLIC void SetDocOptions( const ScDocOptions& rOpt );
624 SC_DLLPUBLIC const ScViewOptions& GetViewOptions() const;
625 SC_DLLPUBLIC void SetViewOptions( const ScViewOptions& rOpt );
626 void SetPrintOptions();
628 ScExtDocOptions* GetExtDocOptions() { return pExtDocOptions.get(); }
629 SC_DLLPUBLIC void SetExtDocOptions( std::unique_ptr<ScExtDocOptions> pNewOptions );
631 ScClipOptions* GetClipOptions() { return mpClipOptions.get(); }
632 void SetClipOptions(std::unique_ptr<ScClipOptions> pClipOptions);
634 SC_DLLPUBLIC void GetLanguage( LanguageType& rLatin, LanguageType& rCjk, LanguageType& rCtl ) const;
635 void SetLanguage( LanguageType eLatin, LanguageType eCjk, LanguageType eCtl );
637 void SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pData );
638 const ScConsolidateParam* GetConsolidateDlgData() const { return pConsolidateDlgData.get(); }
640 void Clear( bool bFromDestructor = false );
642 std::unique_ptr<ScFieldEditEngine> CreateFieldEditEngine();
643 void DisposeFieldEditEngine(std::unique_ptr<ScFieldEditEngine>& rpEditEngine);
646 * Get all range names that are local to each table. It only returns
647 * non-empty range name set.
649 SC_DLLPUBLIC void GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rRangeNames) const;
650 SC_DLLPUBLIC void SetAllRangeNames(const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap);
651 SC_DLLPUBLIC void GetRangeNameMap(std::map<OUString, ScRangeName*>& rRangeName);
652 SC_DLLPUBLIC ScRangeName* GetRangeName(SCTAB nTab) const;
653 SC_DLLPUBLIC ScRangeName* GetRangeName() const;
654 void SetRangeName(SCTAB nTab, std::unique_ptr<ScRangeName> pNew);
655 void SetRangeName( std::unique_ptr<ScRangeName> pNewRangeName );
656 bool IsAddressInRangeName( RangeNameScope eScope, const ScAddress& rAddress);
658 /** Find a named expression / range name in either global or a local scope.
659 @param nTab
660 If <0 search nIndex in global scope, if >=0 search nIndex in scope of nTab.
661 @param nIndex
662 Index of named expression / range name.
663 @return nullptr if indexed name not found.
665 ScRangeData* FindRangeNameBySheetAndIndex( SCTAB nTab, sal_uInt16 nIndex ) const;
667 /** Recursively find all named expressions that directly or indirectly
668 (nested) reference a given sheet, starting from a given named
669 expression nTokenTab/nTokenIndex.
671 Used to collect all named expressions/ranges that will need to be
672 copied along when copying sheets.
674 The different tab/sheets passed cater for the situation that a sheet is
675 copied and was already inserted and global names are already adjusted
676 but the sheet-local names of the shifted original sheet are not yet. If
677 no sheet was inserted and global and local names' references not
678 updated yet, then all 4 tab arguments would be identical.
680 @param nTokenTab
681 Tab/sheet on which to find the name, -1 if global scope.
682 For example obtained from ocName token.
684 @param nTokenIndex
685 Index of named expression. For example obtained from ocName token.
687 @param nGlobalRefTab
688 Tab to check if used in global names.
690 @param nLocalRefTab
691 Tab to check if used in sheet-local names.
693 @param nOldTokenTab
694 The original tab of the copied sheet, used as sheet-local
695 base position for relative references.
697 @param nOldTokenTabReplacement
698 The replacement to use for relative references if the name
699 encountered uses nOldTokenTab as base position.
701 @param bSameDoc
702 FALSE if collecting names for a sheet to be copied to another
703 document. Then all names encountered are considered to be
704 referencing the sheet. Else TRUE if collecting names to be
705 copied into the same document.
707 @param nRecursion
708 Recursion guard, initialize with 0.
710 bool FindRangeNamesReferencingSheet( sc::UpdatedRangeNames& rIndexes,
711 SCTAB nTokenTab, const sal_uInt16 nTokenIndex,
712 SCTAB nGlobalRefTab, SCTAB nLocalRefTab, SCTAB nOldTokenTab, SCTAB nOldTokenTabReplacement,
713 bool bSameDoc, int nRecursion ) const;
715 /** If necessary (name references sheet rOldPos.Tab()) copy and adjust
716 named expression/range from sheet-local to sheet-local, or global to
717 sheet-local if bGlobalNamesToLocal==true.
719 Also copies nested names and adjusts the ocName tokens of the calling name.
721 @param rSheet
722 On entry, the original sheet of the named expression/range, <0 global.
723 On return TRUE, the new sheet. Else unchanged.
725 @param rIndex
726 On entry, the original index of the named expression/range.
727 On return TRUE, the new index, or 0 if a new copied name couldn't be inserted. Else unchanged.
729 @param rpRangeData
730 On entry, the pointer to the original named expression/range.
731 On return TRUE, the pointer to the new copied name, or nullptr if hits happened.
733 @param rNewPos
734 New position of formula cell if called for that, else new base
735 position of a to be created new name adjusted for Tab.
736 rNewPos.nTab MUST point to the new sheet copied to.
738 @param rOldPos
739 Old position of formula cell if called for that, else base
740 position of the existing name adjusted for Tab.
741 rOldPos.nTab MUST point to the old sheet copied from.
743 @param bGlobalNamesToLocal
744 If TRUE, affected global names are copied to sheet-local names.
745 If FALSE, global names are copied to global names in another document.
747 @param bUsedByFormula
748 If TRUE, forces a global name to be affected/used.
749 If FALSE, a global name is only affected if it evaluates to be
750 referencing the sheet.
752 @return TRUE if copied and caller may need to evaluate rpRangeData and rSheet and rIndex.
753 FALSE if nothing to be done.
755 bool CopyAdjustRangeName( SCTAB& rSheet, sal_uInt16& rIndex, ScRangeData*& rpRangeData, ScDocument& rNewDoc,
756 const ScAddress& rNewPos, const ScAddress& rOldPos, const bool bGlobalNamesToLocal,
757 const bool bUsedByFormula ) const;
760 * Call this immediately before updating all named ranges.
762 SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate( const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap );
763 SC_DLLPUBLIC void PreprocessRangeNameUpdate();
764 SC_DLLPUBLIC void PreprocessDBDataUpdate();
766 * Call this immediately after updating named ranges.
768 SC_DLLPUBLIC void CompileHybridFormula();
771 * Insert a new named expression to the global scope.
773 * @param rName name for the expression.
774 * @param rPos base position.
775 * @param rExpr formula expression to be associated with the name. The
776 * current grammar is used to compile this expression.
778 * @return true if inserted successfully, false otherwise.
780 bool InsertNewRangeName( const OUString& rName, const ScAddress& rPos, const OUString& rExpr );
783 * Insert a new named expression to a sheet-local scope.
785 * @param nTab sheet for local scope.
786 * @param rName name for the expression.
787 * @param rPos base position.
788 * @param rExpr formula expression to be associated with the name. The
789 * current grammar is used to compile this expression.
791 * @return true if inserted successfully, false otherwise.
793 bool InsertNewRangeName( SCTAB nTab, const OUString& rName, const ScAddress& rPos, const OUString& rExpr );
795 SCTAB GetMaxTableNumber() const { return static_cast<SCTAB>(maTabs.size()) - 1; }
797 ScRangePairList* GetColNameRanges() { return xColNameRanges.get(); }
798 ScRangePairList* GetRowNameRanges() { return xRowNameRanges.get(); }
799 ScRangePairListRef& GetColNameRangesRef() { return xColNameRanges; }
800 ScRangePairListRef& GetRowNameRangesRef() { return xRowNameRanges; }
802 SC_DLLPUBLIC SCCOL ClampToAllocatedColumns(SCTAB nTab, SCCOL nCol) const;
803 SC_DLLPUBLIC SCCOL GetAllocatedColumnsCount(SCTAB nTab) const;
805 SC_DLLPUBLIC ScDBCollection* GetDBCollection() const { return pDBCollection.get();}
806 void SetDBCollection( std::unique_ptr<ScDBCollection> pNewDBCollection,
807 bool bRemoveAutoFilter = false );
808 const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const;
809 ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion);
810 SC_DLLPUBLIC const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
811 SC_DLLPUBLIC ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
812 void RefreshDirtyTableColumnNames();
813 SC_DLLPUBLIC sc::ExternalDataMapper& GetExternalDataMapper();
815 SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock( const ScRange& rBlock, OUString* pName ) const;
817 SC_DLLPUBLIC bool HasPivotTable() const;
818 SC_DLLPUBLIC ScDPCollection* GetDPCollection();
819 SC_DLLPUBLIC const ScDPCollection* GetDPCollection() const;
820 SC_DLLPUBLIC ScDPObject* GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
821 ScDPObject* GetDPAtBlock( const ScRange& rBlock ) const;
823 void StopTemporaryChartLock();
825 void EnsureGraphicNames();
827 SdrObject* GetObjectAtPoint( SCTAB nTab, const Point& rPos );
828 bool HasChartAtPoint( SCTAB nTab, const Point& rPos, OUString& rName );
830 css::uno::Reference< css::chart2::XChartDocument > GetChartByName( const OUString& rChartName );
832 SC_DLLPUBLIC void GetChartRanges( const OUString& rChartName, std::vector< ScRangeList >& rRanges, const ScDocument* pSheetNameDoc );
833 void SetChartRanges( const OUString& rChartName, const std::vector< ScRangeList >& rRanges );
835 void UpdateChartArea( const OUString& rChartName, const ScRange& rNewArea,
836 bool bColHeaders, bool bRowHeaders, bool bAdd );
837 void UpdateChartArea( const OUString& rChartName,
838 const ScRangeListRef& rNewList,
839 bool bColHeaders, bool bRowHeaders, bool bAdd );
840 void GetOldChartParameters( const OUString& rName,
841 ScRangeList& rRanges, bool& rColHeaders, bool& rRowHeaders );
842 css::uno::Reference<
843 css::embed::XEmbeddedObject >
844 FindOleObjectByName( const OUString& rName );
846 SC_DLLPUBLIC void MakeTable( SCTAB nTab,bool _bNeedsNameCheck = true );
848 SCTAB GetVisibleTab() const { return nVisibleTab; }
849 SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab) { nVisibleTab = nTab; }
850 SCCOL GetPosLeft() const { return nPosLeft; }
851 SC_DLLPUBLIC void SetPosLeft(SCCOL nCol) { nPosLeft = nCol; }
852 SCROW GetPosTop() const { return nPosTop; }
853 SC_DLLPUBLIC void SetPosTop(SCROW nRow) { nPosTop = nRow; }
855 SC_DLLPUBLIC bool HasTable( SCTAB nTab ) const;
856 SC_DLLPUBLIC bool GetHashCode( SCTAB nTab, sal_Int64& rHashCode) const;
857 SC_DLLPUBLIC bool GetName( SCTAB nTab, OUString& rName ) const;
858 SC_DLLPUBLIC bool GetCodeName( SCTAB nTab, OUString& rName ) const;
859 SC_DLLPUBLIC bool SetCodeName( SCTAB nTab, const OUString& rName );
860 SC_DLLPUBLIC bool GetTable( const OUString& rName, SCTAB& rTab ) const;
861 SC_DLLPUBLIC SCCOL MaxCol() const { return mnMaxCol; }
862 SC_DLLPUBLIC SCROW MaxRow() const { return mnMaxRow; }
864 SC_DLLPUBLIC std::vector<OUString> GetAllTableNames() const;
866 OUString GetCopyTabName(SCTAB nTab) const;
868 SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, std::unique_ptr<ScDBData> pDBData);
869 SC_DLLPUBLIC ScDBData* GetAnonymousDBData(SCTAB nTab);
871 /** One document global anonymous database range for temporary operations,
872 used if the corresponding sheet-local anonymous database range is
873 already used with AutoFilter and range differs. Not stored in document
874 files. */
875 SC_DLLPUBLIC void SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData);
876 SC_DLLPUBLIC ScDBData* GetAnonymousDBData();
878 SC_DLLPUBLIC SCTAB GetTableCount() const;
879 SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; }
881 SC_DLLPUBLIC ScDocProtection* GetDocProtection() const;
882 SC_DLLPUBLIC void SetDocProtection(const ScDocProtection* pProtect);
883 SC_DLLPUBLIC bool IsDocProtected() const;
884 bool IsDocEditable() const;
885 SC_DLLPUBLIC bool IsTabProtected( SCTAB nTab ) const;
886 SC_DLLPUBLIC ScTableProtection* GetTabProtection( SCTAB nTab ) const;
887 SC_DLLPUBLIC void SetTabProtection(SCTAB nTab, const ScTableProtection* pProtect);
888 void CopyTabProtection(SCTAB nTabSrc, SCTAB nTabDest);
890 void LockTable(SCTAB nTab);
891 void UnlockTable(SCTAB nTab);
893 bool IsBlockEditable( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
894 SCCOL nEndCol, SCROW nEndRow,
895 bool* pOnlyNotBecauseOfMatrix = nullptr,
896 bool bNoMatrixAtAll = false ) const;
897 bool IsSelectionEditable( const ScMarkData& rMark,
898 bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
899 bool HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nStartRow,
900 SCCOL nEndCol, SCROW nEndRow,
901 const ScMarkData& rMark ) const;
903 bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCTAB nTab, SCCOLROW nStart, SCCOLROW nEnd ) const;
904 bool IsEditActionAllowed( sc::ColRowEditAction eAction, const ScMarkData& rMark, SCCOLROW nStart, SCCOLROW nEnd ) const;
906 SC_DLLPUBLIC bool GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix );
908 bool IsEmbedded() const { return bIsEmbedded;}
909 void GetEmbedded( ScRange& rRange ) const;
910 void SetEmbedded( const ScRange& rRange );
911 void ResetEmbedded();
912 tools::Rectangle GetEmbeddedRect() const; // 1/100 mm
913 void SetEmbedded( SCTAB nTab, const tools::Rectangle& rRect ); // from VisArea (1/100 mm)
915 static SC_DLLPUBLIC bool ValidTabName( const OUString& rName );
917 SC_DLLPUBLIC bool ValidNewTabName( const OUString& rName ) const;
918 SC_DLLPUBLIC void CreateValidTabName(OUString& rName) const;
919 SC_DLLPUBLIC void CreateValidTabNames(std::vector<OUString>& aNames, SCTAB nCount) const;
921 void AppendTabOnLoad(const OUString& rName);
922 void SetTabNameOnLoad(SCTAB nTab, const OUString& rName);
923 void InvalidateStreamOnSave();
925 SC_DLLPUBLIC bool InsertTab( SCTAB nPos, const OUString& rName,
926 bool bExternalDocument = false, bool bUndoDeleteTab = false );
928 SC_DLLPUBLIC bool InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
929 bool bNamesValid = false );
930 SC_DLLPUBLIC bool DeleteTabs( SCTAB nTab, SCTAB nSheets );
931 SC_DLLPUBLIC bool DeleteTab( SCTAB nTab );
932 SC_DLLPUBLIC bool RenameTab( SCTAB nTab, const OUString& rName,
933 bool bExternalDocument = false );
934 bool MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress = nullptr );
935 bool CopyTab( SCTAB nOldPos, SCTAB nNewPos,
936 const ScMarkData* pOnlyMarked = nullptr );
937 SC_DLLPUBLIC sal_uLong TransferTab(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos,
938 bool bInsertNew = true,
939 bool bResultsOnly = false );
940 SC_DLLPUBLIC void TransferDrawPage(const ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos);
941 SC_DLLPUBLIC void SetVisible( SCTAB nTab, bool bVisible );
942 SC_DLLPUBLIC bool IsVisible( SCTAB nTab ) const;
943 bool IsStreamValid( SCTAB nTab ) const;
944 void SetStreamValid( SCTAB nTab, bool bSet, bool bIgnoreLock = false );
945 void LockStreamValid( bool bLock );
946 bool IsStreamValidLocked() const { return mbStreamValidLocked; }
947 bool IsPendingRowHeights( SCTAB nTab ) const;
948 void SetPendingRowHeights( SCTAB nTab, bool bSet );
949 SC_DLLPUBLIC void SetLayoutRTL( SCTAB nTab, bool bRTL );
950 SC_DLLPUBLIC bool IsLayoutRTL( SCTAB nTab ) const;
951 SC_DLLPUBLIC bool IsNegativePage( SCTAB nTab ) const;
952 SC_DLLPUBLIC void SetScenario( SCTAB nTab, bool bFlag );
953 SC_DLLPUBLIC bool IsScenario( SCTAB nTab ) const;
954 SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString& rComment,
955 Color& rColor, ScScenarioFlags &rFlags) const;
956 SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString& rComment,
957 const Color& rColor, ScScenarioFlags nFlags);
958 SC_DLLPUBLIC Color GetTabBgColor( SCTAB nTab ) const;
959 SC_DLLPUBLIC void SetTabBgColor( SCTAB nTab, const Color& rColor );
960 SC_DLLPUBLIC bool IsDefaultTabBgColor( SCTAB nTab ) const;
961 void GetScenarioFlags(SCTAB nTab, ScScenarioFlags &rFlags) const;
962 SC_DLLPUBLIC bool IsActiveScenario( SCTAB nTab ) const;
963 SC_DLLPUBLIC void SetActiveScenario( SCTAB nTab, bool bActive ); // only for Undo etc.
964 SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const;
965 SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const { return eGrammar;}
966 SC_DLLPUBLIC void SetGrammar( formula::FormulaGrammar::Grammar eGram );
967 SC_DLLPUBLIC ScLinkMode GetLinkMode( SCTAB nTab ) const;
968 bool IsLinked( SCTAB nTab ) const;
969 SC_DLLPUBLIC OUString GetLinkDoc( SCTAB nTab ) const;
970 OUString GetLinkFlt( SCTAB nTab ) const;
971 OUString GetLinkOpt( SCTAB nTab ) const;
972 SC_DLLPUBLIC OUString GetLinkTab( SCTAB nTab ) const;
973 sal_uLong GetLinkRefreshDelay( SCTAB nTab ) const;
974 void SetLink( SCTAB nTab, ScLinkMode nMode, const OUString& rDoc,
975 const OUString& rFilter, const OUString& rOptions,
976 const OUString& rTabName, sal_uLong nRefreshDelay );
977 bool HasLink( const OUString& rDoc,
978 const OUString& rFilter, const OUString& rOptions ) const;
979 SC_DLLPUBLIC bool LinkExternalTab( SCTAB& nTab, const OUString& aDocTab,
980 const OUString& aFileName,
981 const OUString& aTabName );
983 bool HasExternalRefManager() const { return pExternalRefMgr.get(); }
984 SC_DLLPUBLIC ScExternalRefManager* GetExternalRefManager() const;
985 bool IsInExternalReferenceMarking() const;
986 void MarkUsedExternalReferences();
987 bool MarkUsedExternalReferences( const ScTokenArray& rArr, const ScAddress& rPos );
989 /** Returns the pool containing external formula parsers. Creates the pool
990 on first call. */
991 ScFormulaParserPool& GetFormulaParserPool() const;
993 bool HasAreaLinks() const;
994 void UpdateExternalRefLinks(weld::Window* pWin);
995 void UpdateAreaLinks();
997 // originating DDE links
998 void IncInDdeLinkUpdate() { if ( nInDdeLinkUpdate < 255 ) ++nInDdeLinkUpdate; }
999 void DecInDdeLinkUpdate() { if ( nInDdeLinkUpdate ) --nInDdeLinkUpdate; }
1000 bool IsInDdeLinkUpdate() const { return nInDdeLinkUpdate != 0; }
1002 SC_DLLPUBLIC void CopyDdeLinks( ScDocument* pDestDoc ) const;
1004 /** Tries to find a DDE link with the specified connection data.
1005 @param rnDdePos (out-param) Returns the index of the DDE link (does not include other links from link manager).
1006 @return true = DDE link found, rnDdePos valid. */
1007 SC_DLLPUBLIC bool FindDdeLink( const OUString& rAppl, const OUString& rTopic,
1008 const OUString& rItem, sal_uInt8 nMode, size_t& rnDdePos );
1010 /** Returns the connection data of the specified DDE link.
1011 @param nDdePos Index of the DDE link (does not include other links from link manager).
1012 @param rAppl (out-param) The application name.
1013 @param rTopic (out-param) The DDE topic.
1014 @param rItem (out-param) The DDE item.
1015 @return true = DDE link found, out-parameters valid. */
1016 bool GetDdeLinkData( size_t nDdePos, OUString& rAppl, OUString& rTopic, OUString& rItem ) const;
1017 /** Returns the link mode of the specified DDE link.
1018 @param nDdePos Index of the DDE link (does not include other links from link manager).
1019 @param rnMode (out-param) The link mode of the specified DDE link.
1020 @return true = DDE link found, rnMode valid. */
1021 bool GetDdeLinkMode( size_t nDdePos, sal_uInt8& rnMode ) const;
1022 /** Returns the result matrix of the specified DDE link.
1023 @param nDdePos Index of the DDE link (does not include other links from link manager).
1024 @return The result matrix, if the DDE link has been found, 0 otherwise. */
1025 SC_DLLPUBLIC const ScMatrix* GetDdeLinkResultMatrix( size_t nDdePos ) const;
1027 /** Tries to find a DDE link or creates a new, if not extant.
1028 @param pResults If not 0, sets the matrix as DDE link result matrix (also for existing links).
1029 @return true = DDE link found; false = Unpredictable error occurred, no DDE link created. */
1030 SC_DLLPUBLIC bool CreateDdeLink( const OUString& rAppl, const OUString& rTopic, const OUString& rItem, sal_uInt8 nMode, const ScMatrixRef& pResults );
1031 /** Sets a result matrix for the specified DDE link.
1032 @param nDdePos Index of the DDE link (does not include other links from link manager).
1033 @param pResults The array containing all results of the DDE link (intrusive-ref-counted, do not delete).
1034 @return true = DDE link found and matrix set. */
1035 bool SetDdeLinkResultMatrix( size_t nDdePos, const ScMatrixRef& pResults );
1037 SfxBindings* GetViewBindings();
1038 SfxObjectShell* GetDocumentShell() const { return mpShell; }
1039 SC_DLLPUBLIC ScDrawLayer* GetDrawLayer() { return mpDrawLayer.get(); }
1040 SC_DLLPUBLIC const ScDrawLayer* GetDrawLayer() const { return mpDrawLayer.get(); }
1041 SfxBroadcaster* GetDrawBroadcaster(); // to avoid header
1042 void BeginDrawUndo();
1044 void BeginUnoRefUndo();
1045 bool HasUnoRefUndo() const { return ( pUnoRefUndoList != nullptr ); }
1046 [[nodiscard]]
1047 std::unique_ptr<ScUnoRefList> EndUnoRefUndo(); // must be deleted by caller!
1048 sal_Int64 GetNewUnoId() { return ++nUnoObjectId; }
1049 void AddUnoRefChange( sal_Int64 nId, const ScRangeList& rOldRanges );
1051 static bool IsChart( const SdrObject* pObject );
1053 void UpdateChartRef( UpdateRefMode eUpdateRefMode,
1054 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1055 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1056 SCCOL nDx, SCROW nDy, SCTAB nDz );
1057 //! only assigns the new RangeList, no ChartListener or the like
1058 void SetChartRangeList( const OUString& rChartName,
1059 const ScRangeListRef& rNewRangeListRef );
1061 void StartAnimations( SCTAB nTab );
1063 bool HasBackgroundDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const;
1064 bool HasAnyDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const;
1066 const ScSheetEvents* GetSheetEvents( SCTAB nTab ) const;
1067 void SetSheetEvents( SCTAB nTab, std::unique_ptr<ScSheetEvents> pNew );
1068 bool HasSheetEventScript( SCTAB nTab, ScSheetEventId nEvent, bool bWithVbaEvents = false ) const;
1069 bool HasAnySheetEventScript( ScSheetEventId nEvent, bool bWithVbaEvents = false ) const; // on any sheet
1071 bool HasAnyCalcNotification() const;
1072 bool HasCalcNotification( SCTAB nTab ) const;
1073 void SetCalcNotification( SCTAB nTab );
1074 void ResetCalcNotifications();
1076 SC_DLLPUBLIC ScOutlineTable* GetOutlineTable( SCTAB nTab, bool bCreate = false );
1077 bool SetOutlineTable( SCTAB nTab, const ScOutlineTable* pNewOutline );
1079 void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow,
1080 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1082 bool DoSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
1083 void RemoveSubTotals( SCTAB nTab, ScSubTotalParam& rParam );
1084 bool TestRemoveSubTotals( SCTAB nTab, const ScSubTotalParam& rParam );
1085 bool HasSubTotalCells( const ScRange& rRange );
1087 SC_DLLPUBLIC void EnsureTable( SCTAB nTab );
1089 // return TRUE = number format is set
1090 SC_DLLPUBLIC bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
1091 const ScSetStringParam * pParam = nullptr );
1092 SC_DLLPUBLIC bool SetString( const ScAddress& rPos, const OUString& rString,
1093 const ScSetStringParam* pParam = nullptr );
1096 * This method manages the lifecycle of the passed edit text object. When
1097 * the text is successfully inserted, the cell takes over the ownership of
1098 * the text object. If not, the text object gets deleted.
1100 * <p>The caller must ensure that the passed edit text object <i>uses the
1101 * SfxItemPool instance returned from ScDocument::GetEditPool()</i>.
1102 * This is very important.</p>
1104 SC_DLLPUBLIC bool SetEditText( const ScAddress& rPos, std::unique_ptr<EditTextObject> pEditText );
1105 void SetEditText( const ScAddress& rPos, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
1106 SC_DLLPUBLIC void SetEditText( const ScAddress& rPos, const OUString& rStr );
1107 SC_DLLPUBLIC SCROW GetFirstEditTextRow( const ScRange& rRange ) const;
1110 * Call this if you are not sure whether to put this as an edit text or a
1111 * simple text.
1113 SC_DLLPUBLIC void SetTextCell( const ScAddress& rPos, const OUString& rStr );
1114 void SetEmptyCell( const ScAddress& rPos );
1115 SC_DLLPUBLIC void SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal );
1116 SC_DLLPUBLIC void SetValue( const ScAddress& rPos, double fVal );
1117 void SetValues( const ScAddress& rPos, const std::vector<double>& rVals );
1118 void SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError);
1119 SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const ScTokenArray& rArray );
1120 SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const OUString& rFormula,
1121 formula::FormulaGrammar::Grammar eGram );
1124 * Set formula cell, and transfer its ownership to the document. This call
1125 * attempts to group the passed formula cell with the adjacent cells or
1126 * cell groups if appropriate.
1128 * @return pCell if it was successfully inserted, NULL otherwise. pCell
1129 * is deleted automatically on failure to insert.
1131 SC_DLLPUBLIC ScFormulaCell* SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell );
1132 bool SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCell*>& rCells );
1135 * Check if there is at least one formula cell in specified range.
1137 bool HasFormulaCell( const ScRange& rRange ) const;
1138 SC_DLLPUBLIC void InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
1139 SCCOL nCol2, SCROW nRow2,
1140 const ScMarkData& rMark,
1141 const OUString& rFormula,
1142 const ScTokenArray* p = nullptr,
1143 const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT );
1144 SC_DLLPUBLIC void InsertTableOp(const ScTabOpParam& rParam, // multi-operation
1145 SCCOL nCol1, SCROW nRow1,
1146 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark);
1148 SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab,
1149 const ScInterpreterContext* pContext = nullptr ) const;
1150 SC_DLLPUBLIC OUString GetString( const ScAddress& rPos,
1151 const ScInterpreterContext* pContext = nullptr ) const;
1154 * Return a pointer to the double value stored in value cell.
1156 * @param rPos cell position
1158 * @return pointer to the double value stored in a numeric cell, or NULL
1159 * if the cell at specified position is not a numeric cell.
1161 double* GetValueCell( const ScAddress& rPos );
1163 SC_DLLPUBLIC svl::SharedStringPool& GetSharedStringPool();
1164 const svl::SharedStringPool& GetSharedStringPool() const;
1166 svl::SharedString GetSharedString( const ScAddress& rPos ) const;
1168 std::shared_ptr<sc::FormulaGroupContext>& GetFormulaGroupContext();
1169 void DiscardFormulaGroupContext();
1170 void BlockFormulaGroupContextDiscard( bool block )
1171 { mbFormulaGroupCxtBlockDiscard = block; }
1173 SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString );
1174 FormulaError GetStringForFormula( const ScAddress& rPos, OUString& rString );
1175 SC_DLLPUBLIC double GetValue( const ScAddress& rPos ) const;
1176 SC_DLLPUBLIC double GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1177 SC_DLLPUBLIC void GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, double& rValue ) const;
1178 SC_DLLPUBLIC const EditTextObject* GetEditText( const ScAddress& rPos ) const;
1179 void RemoveEditTextCharAttribs( const ScAddress& rPos, const ScPatternAttr& rAttr );
1180 SC_DLLPUBLIC double RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScInterpreterContext* pContext = nullptr ) const;
1181 SC_DLLPUBLIC void GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab,
1182 sal_uInt32& rFormat ) const;
1183 sal_uInt32 GetNumberFormat( const ScRange& rRange ) const;
1184 SC_DLLPUBLIC sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& ) const;
1185 void SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberFormat );
1187 void GetNumberFormatInfo( const ScInterpreterContext& rContext, SvNumFormatType& nType, sal_uInt32& nIndex, const ScAddress& rPos ) const;
1188 SC_DLLPUBLIC const ScFormulaCell* GetFormulaCell( const ScAddress& rPos ) const;
1189 SC_DLLPUBLIC ScFormulaCell* GetFormulaCell( const ScAddress& rPos );
1190 SC_DLLPUBLIC void GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rFormula ) const;
1191 SC_DLLPUBLIC void GetCellType( SCCOL nCol, SCROW nRow, SCTAB nTab, CellType& rCellType ) const;
1192 SC_DLLPUBLIC CellType GetCellType( const ScAddress& rPos ) const;
1194 SC_DLLPUBLIC bool HasData( SCCOL nCol, SCROW nRow, SCTAB nTab );
1195 SC_DLLPUBLIC bool HasStringData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1196 SC_DLLPUBLIC bool HasValueData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1197 SC_DLLPUBLIC bool HasValueData( const ScAddress& rPos ) const;
1198 bool HasStringCells( const ScRange& rRange ) const;
1200 /** Returns true, if there is any data to create a selection list for rPos. */
1201 bool HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1202 bool HasValidationData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1205 * Check if the specified range contains either: 1) one non-empty cell, 2)
1206 * more than one non-empty cells, or 3) totally empty. In case the range
1207 * contains at least one non-empty cell, specify the position of the first
1208 * non-empty cell.
1210 sc::MultiDataCellState HasMultipleDataCells( const ScRange& rRange ) const;
1212 /** Notes **/
1213 SC_DLLPUBLIC ScPostIt* GetNote(const ScAddress& rPos);
1214 SC_DLLPUBLIC ScPostIt* GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab);
1215 void SetNote(const ScAddress& rPos, std::unique_ptr<ScPostIt> pNote);
1216 void SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, std::unique_ptr<ScPostIt> pNote);
1217 SC_DLLPUBLIC bool HasNote(const ScAddress& rPos) const;
1218 bool HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
1219 SC_DLLPUBLIC bool HasColNotes(SCCOL nCol, SCTAB nTab) const;
1220 SC_DLLPUBLIC bool HasTabNotes(SCTAB nTab) const;
1221 bool HasNotes() const;
1222 SC_DLLPUBLIC std::unique_ptr<ScPostIt> ReleaseNote(const ScAddress& rPos);
1223 SC_DLLPUBLIC ScPostIt* GetOrCreateNote(const ScAddress& rPos);
1224 SC_DLLPUBLIC ScPostIt* CreateNote(const ScAddress& rPos);
1225 size_t GetNoteCount( SCTAB nTab, SCCOL nCol ) const;
1228 * Ensure that all note objects have an associated sdr object. The export
1229 * code uses sdr objects to export note data.
1231 void CreateAllNoteCaptions();
1232 void ForgetNoteCaptions( const ScRangeList& rRanges, bool bPreserveData );
1233 CommentCaptionState GetAllNoteCaptionsState( const ScRangeList& rRanges);
1235 ScAddress GetNotePosition( size_t nIndex ) const;
1236 ScAddress GetNotePosition( size_t nIndex, SCTAB nTab ) const;
1237 SCROW GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const;
1239 SC_DLLPUBLIC void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
1240 SC_DLLPUBLIC void GetAllNoteEntries( SCTAB nTab, std::vector<sc::NoteEntry>& rNotes ) const;
1241 void GetNotesInRange( const ScRangeList& rRange, std::vector<sc::NoteEntry>& rNotes ) const;
1242 bool ContainsNotesInRange( const ScRangeList& rRange ) const;
1244 SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab);
1246 bool IsMerged( const ScAddress& rPos ) const;
1248 void ExtendMergeSel( SCCOL nStartCol, SCROW nStartRow,
1249 SCCOL& rEndCol, SCROW& rEndRow, const ScMarkData& rMark,
1250 bool bRefresh = false );
1251 SC_DLLPUBLIC bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
1252 SCCOL& rEndCol, SCROW& rEndRow, SCTAB nTab,
1253 bool bRefresh = false );
1254 bool ExtendMerge( ScRange& rRange, bool bRefresh = false );
1255 SC_DLLPUBLIC void ExtendTotalMerge( ScRange& rRange ) const;
1256 SC_DLLPUBLIC void ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow,
1257 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const;
1258 SC_DLLPUBLIC void ExtendOverlapped( ScRange& rRange ) const;
1260 bool RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow,
1261 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab );
1263 SC_DLLPUBLIC void DoMergeContents( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1264 SCCOL nEndCol, SCROW nEndRow );
1265 SC_DLLPUBLIC void DoEmptyBlock( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1266 SCCOL nEndCol, SCROW nEndRow );
1267 // without checking:
1268 SC_DLLPUBLIC void DoMerge( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1269 SCCOL nEndCol, SCROW nEndRow, bool bDeleteCaptions = true );
1270 void RemoveMerge( SCCOL nCol, SCROW nRow, SCTAB nTab );
1272 bool IsBlockEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1273 SCCOL nEndCol, SCROW nEndRow, bool bIgnoreNotes = false ) const;
1274 bool IsPrintEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
1275 SCCOL nEndCol, SCROW nEndRow,
1276 bool bLeftIsEmpty = false,
1277 ScRange* pLastRange = nullptr,
1278 tools::Rectangle* pLastMM = nullptr ) const;
1280 void SkipOverlapped( SCCOL& rCol, SCROW& rRow, SCTAB nTab ) const;
1281 bool IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1282 bool IsVerOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1284 SC_DLLPUBLIC bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1285 SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask ) const;
1286 SC_DLLPUBLIC bool HasAttrib( const ScRange& rRange, HasAttrFlags nMask ) const;
1288 SC_DLLPUBLIC void GetBorderLines( SCCOL nCol, SCROW nRow, SCTAB nTab,
1289 const ::editeng::SvxBorderLine** ppLeft,
1290 const ::editeng::SvxBorderLine** ppTop,
1291 const ::editeng::SvxBorderLine** ppRight,
1292 const ::editeng::SvxBorderLine** ppBottom ) const;
1294 void ResetChanged( const ScRange& rRange );
1296 void CheckVectorizationState();
1297 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
1298 void SetDirty( const ScRange&, bool bIncludeEmptyCells );
1299 void SetTableOpDirty( const ScRange& ); // for Interpreter TableOp
1300 void InterpretDirtyCells( const ScRangeList& rRanges );
1301 SC_DLLPUBLIC void CalcAll();
1302 SC_DLLPUBLIC void CalcAfterLoad( bool bStartListening = true );
1303 void CompileAll();
1304 void CompileXML();
1307 * Re-compile formula cells with error.
1309 * @param nErrCode specified error code to match. Only those cells with
1310 * this error code will be re-compiled. If this value is
1311 * 0, cells with any error values will be re-compiled.
1313 * @return true if at least one cell is re-compiled, false if no cells are
1314 * re-compiled.
1316 bool CompileErrorCells(FormulaError nErrCode);
1318 ScAutoNameCache* GetAutoNameCache() { return pAutoNameCache.get(); }
1319 void SetPreviewFont( std::unique_ptr<SfxItemSet> pFontSet );
1320 SfxItemSet* GetPreviewFont() { return pPreviewFont.get(); }
1321 SfxItemSet* GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab );
1322 const ScMarkData& GetPreviewSelection() const { return maPreviewSelection; }
1323 void SetPreviewSelection( const ScMarkData& rSel );
1324 ScStyleSheet* GetPreviewCellStyle() { return pPreviewCellStyle; }
1325 ScStyleSheet* GetPreviewCellStyle( SCCOL nCol, SCROW nRow, SCTAB nTab );
1326 void SetPreviewCellStyle( ScStyleSheet* pStyle ) { pPreviewCellStyle = pStyle; }
1327 SC_DLLPUBLIC void SetAutoNameCache( std::unique_ptr<ScAutoNameCache> pCache );
1329 /** Creates a ScLookupCache cache for the range if it
1330 doesn't already exist. */
1331 ScLookupCache & GetLookupCache( const ScRange & rRange, ScInterpreterContext* pContext );
1332 /** Only ScLookupCache dtor uses RemoveLookupCache(), do
1333 not use elsewhere! */
1334 void RemoveLookupCache( ScLookupCache & rCache );
1335 /** Zap all caches. */
1336 void ClearLookupCaches();
1338 // calculate automatically
1339 SC_DLLPUBLIC void SetAutoCalc( bool bNewAutoCalc );
1340 SC_DLLPUBLIC bool GetAutoCalc() const { return bAutoCalc; }
1341 // calculate automatically in/from/for ScDocShell disabled
1342 void SetAutoCalcShellDisabled( bool bNew ) { bAutoCalcShellDisabled = bNew; }
1343 bool IsAutoCalcShellDisabled() const { return bAutoCalcShellDisabled; }
1344 // ForcedFormulas are to be calculated
1345 void SetForcedFormulaPending( bool bNew ) { bForcedFormulaPending = bNew; }
1346 bool IsForcedFormulaPending() const { return bForcedFormulaPending; }
1347 // if CalcFormulaTree() is currently running
1348 bool IsCalculatingFormulaTree() const { return bCalculatingFormulaTree; }
1349 /// If set, joining cells into shared formula groups will be delayed until reset again
1350 /// (RegroupFormulaCells() will be called as needed).
1351 void DelayFormulaGrouping( bool delay );
1352 bool IsDelayedFormulaGrouping() const { return pDelayedFormulaGrouping.get() != nullptr; }
1353 /// To be used only by SharedFormulaUtil::joinFormulaCells().
1354 void AddDelayedFormulaGroupingCell( const ScFormulaCell* cell );
1356 FormulaError GetErrCode( const ScAddress& ) const;
1358 /** Shrink a range to only include data area.
1360 This is not the actually used area within the
1361 selection, but the bounds of the sheet's data area
1362 instead.
1364 @returns TRUE if the area passed intersected the data
1365 area, FALSE if not, in which case the values
1366 obtained may be out of bounds, not in order or
1367 unmodified. TRUE does not mean that there
1368 actually is any data within the selection.
1370 bool ShrinkToDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
1372 /** Shrink a range to only include used data area.
1374 @param o_bShrunk
1375 Out parameter, true if area was shrunk, false if not.
1376 @param bStickyTopRow
1377 If TRUE, do not adjust the top row.
1378 @param bStickyLeftCol
1379 If TRUE, do not adjust the left column.
1380 @param bConsiderCellNotes
1381 If TRUE, consider the presence of cell notes besides data.
1382 @param bConsiderCellDrawObjects
1383 If TRUE, consider the presence of draw objects anchored to the cell.
1385 @returns true if there is any data, false if not.
1387 bool ShrinkToUsedDataArea( bool& o_bShrunk,
1388 SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1389 SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
1390 bool bStickyTopRow = false, bool bStickyLeftCol = false,
1391 bool bConsiderCellNotes = false,
1392 bool bConsiderCellDrawObjects = false ) const;
1395 * Return the last non-empty row position in given columns that's no
1396 * greater than the initial last row position, or 0 if the columns are
1397 * empty. A negative value is returned if the given sheet or column
1398 * positions are invalid.
1400 * <p>It starts from the specified last row position, and finds the first
1401 * non-empty row position in the upward direction if the start row
1402 * position is empty.</p>
1404 SCROW GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const;
1407 * Return the smallest area containing at least all contiguous cells
1408 * having data. This area is a square containing also empty cells. It may
1409 * shrink or extend the area given as input Flags as modifiers:
1411 * @param bIncludeOld when true, ensure that the returned area contains at
1412 * least the initial area even if the actual data area
1413 * is smaller than the initial area.
1415 * @param bOnlyDown when true, extend / shrink the data area only in a
1416 * downward direction i.e. only modify the end row
1417 * position.
1419 SC_DLLPUBLIC void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1420 SCCOL& rEndCol, SCROW& rEndRow,
1421 bool bIncludeOld, bool bOnlyDown ) const;
1424 * Returns true if there is a non-empty subrange in the range given as input.
1425 * In that case it also modifies rRange to largest subrange that does not
1426 * have empty col/row inrange-segments in the beginning/end.
1427 * It returns false if rRange is completely empty and in this case rRange is
1428 * left unmodified.
1430 bool GetDataAreaSubrange(ScRange& rRange) const;
1432 SC_DLLPUBLIC bool GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
1433 SC_DLLPUBLIC bool GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
1434 SC_DLLPUBLIC bool GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
1435 bool bNotes = true ) const;
1436 SC_DLLPUBLIC bool GetPrintAreaHor( SCTAB nTab, SCROW nStartRow, SCROW nEndRow,
1437 SCCOL& rEndCol ) const;
1438 SC_DLLPUBLIC bool GetPrintAreaVer( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol,
1439 SCROW& rEndRow, bool bNotes ) const;
1440 void InvalidateTableArea();
1442 /// Return the number of columns / rows that should be visible for the tiled rendering.
1443 SC_DLLPUBLIC void GetTiledRenderingArea(SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow) const;
1445 SC_DLLPUBLIC bool GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const;
1448 * Find the maximum column position that contains printable data for the
1449 * specified row range. The final column position must be equal or less
1450 * than the initial value of rEndCol.
1452 void ExtendPrintArea( OutputDevice* pDev, SCTAB nTab,
1453 SCCOL nStartCol, SCROW nStartRow,
1454 SCCOL& rEndCol, SCROW nEndRow ) const;
1455 SC_DLLPUBLIC SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
1456 SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab,
1457 ScDirection eDir );
1459 void FindAreaPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, ScMoveDirection eDirection ) const;
1460 SC_DLLPUBLIC void GetNextPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, SCCOL nMovX, SCROW nMovY,
1461 bool bMarked, bool bUnprotected, const ScMarkData& rMark,
1462 SCCOL nTabStartCol = SC_TABSTART_NONE ) const;
1464 bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, SCTAB nTab,
1465 const ScMarkData& rMark );
1467 void LimitChartArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
1468 SCCOL& rEndCol, SCROW& rEndRow );
1469 void LimitChartIfAll( ScRangeListRef& rRangeList );
1471 bool InsertRow( SCCOL nStartCol, SCTAB nStartTab,
1472 SCCOL nEndCol, SCTAB nEndTab,
1473 SCROW nStartRow, SCSIZE nSize, ScDocument* pRefUndoDoc = nullptr,
1474 const ScMarkData* pTabMark = nullptr );
1475 SC_DLLPUBLIC bool InsertRow( const ScRange& rRange );
1476 void DeleteRow( SCCOL nStartCol, SCTAB nStartTab,
1477 SCCOL nEndCol, SCTAB nEndTab,
1478 SCROW nStartRow, SCSIZE nSize,
1479 ScDocument* pRefUndoDoc = nullptr, bool* pUndoOutline = nullptr,
1480 const ScMarkData* pTabMark = nullptr );
1481 SC_DLLPUBLIC void DeleteRow( const ScRange& rRange );
1482 bool InsertCol( SCROW nStartRow, SCTAB nStartTab,
1483 SCROW nEndRow, SCTAB nEndTab,
1484 SCCOL nStartCol, SCSIZE nSize, ScDocument* pRefUndoDoc = nullptr,
1485 const ScMarkData* pTabMark = nullptr );
1486 SC_DLLPUBLIC bool InsertCol( const ScRange& rRange );
1487 void DeleteCol( SCROW nStartRow, SCTAB nStartTab,
1488 SCROW nEndRow, SCTAB nEndTab,
1489 SCCOL nStartCol, SCSIZE nSize,
1490 ScDocument* pRefUndoDoc = nullptr, bool* pUndoOutline = nullptr,
1491 const ScMarkData* pTabMark = nullptr );
1492 void DeleteCol( const ScRange& rRange );
1494 bool CanInsertRow( const ScRange& rRange ) const;
1495 bool CanInsertCol( const ScRange& rRange ) const;
1497 void FitBlock( const ScRange& rOld, const ScRange& rNew, bool bClear = true );
1498 bool CanFitBlock( const ScRange& rOld, const ScRange& rNew );
1500 bool IsClipOrUndo() const { return bIsClip || bIsUndo; }
1501 bool IsUndo() const { return bIsUndo; }
1502 bool IsClipboard() const { return bIsClip; }
1503 bool IsUndoEnabled() const { return mbUndoEnabled; }
1504 SC_DLLPUBLIC void EnableUndo( bool bVal );
1505 bool IsFunctionAccess() const { return bIsFunctionAccess; }
1507 bool IsAdjustHeightLocked() const { return nAdjustHeightLock != 0; }
1508 void LockAdjustHeight() { ++nAdjustHeightLock; }
1509 SC_DLLPUBLIC void UnlockAdjustHeight();
1510 bool IsExecuteLinkEnabled() const { return mbExecuteLinkEnabled; }
1511 void EnableExecuteLink( bool bVal ) { mbExecuteLinkEnabled = bVal; }
1512 bool IsChangeReadOnlyEnabled() const { return mbChangeReadOnlyEnabled; }
1513 void EnableChangeReadOnly( bool bVal ) { mbChangeReadOnlyEnabled = bVal; }
1514 SC_DLLPUBLIC bool IsUserInteractionEnabled() const { return mbUserInteractionEnabled;}
1515 SC_DLLPUBLIC void EnableUserInteraction( bool bVal );
1516 SC_DLLPUBLIC sal_Int16 GetNamedRangesLockCount() const { return mnNamedRangesLockCount; }
1517 void SetNamedRangesLockCount( sal_Int16 nCount ) { mnNamedRangesLockCount = nCount; }
1518 SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks );
1519 SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, SCTAB nTab );
1520 void SetCutMode( bool bCut );
1521 bool IsCutMode();
1522 void SetClipArea( const ScRange& rArea, bool bCut = false );
1524 SC_DLLPUBLIC bool IsDocVisible() const { return bIsVisible; }
1525 SC_DLLPUBLIC void SetDocVisible( bool bSet );
1527 bool HasOLEObjectsInArea( const ScRange& rRange, const ScMarkData* pTabMark = nullptr );
1529 void DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1530 const ScMarkData& rMark, bool bAnchored = false );
1531 void DeleteObjectsInSelection( const ScMarkData& rMark );
1533 void DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark,
1534 InsertDeleteFlags nDelFlag, bool bBroadcast = true,
1535 sc::ColumnSpanSet* pBroadcastSpans = nullptr );
1537 SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1538 SCTAB nTab, InsertDeleteFlags nDelFlag);
1539 void DeleteAreaTab(const ScRange& rRange, InsertDeleteFlags nDelFlag);
1541 SC_DLLPUBLIC void CopyToClip( const ScClipParam& rClipParam, ScDocument* pClipDoc,
1542 const ScMarkData* pMarks, bool bKeepScenarioFlags,
1543 bool bIncludeObjects );
1546 * Copy only raw cell values to another document. Formula cells are
1547 * converted to raw cells. No formatting info are copied except for
1548 * number formats.
1550 * @param rSrcRange source range in the source document
1551 * @param nDestTab table in the clip document to copy to.
1552 * @param pDestDoc document to copy to
1554 SC_DLLPUBLIC void CopyStaticToDocument(const ScRange& rSrcRange, SCTAB nDestTab, ScDocument* pDestDoc);
1557 * Copy only cell, nothing but cell to another document.
1559 * @param rSrcPos source cell position
1560 * @param rDestPos destination cell position
1561 * @param rDestDoc destination document
1563 void CopyCellToDocument( const ScAddress& rSrcPos, const ScAddress& rDestPos, ScDocument& rDestDoc );
1565 void CopyTabToClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1566 SCTAB nTab, ScDocument* pClipDoc);
1568 SC_DLLPUBLIC bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCTAB nTab, SCCOL nCol );
1570 void DeleteBeforeCopyFromClip( sc::CopyFromClipContext& rCxt, const ScMarkData& rMark,
1571 sc::ColumnSpanSet& rBroadcastSpans );
1573 bool CopyOneCellFromClip(sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1574 SCCOL nCol2, SCROW nRow2 );
1575 void CopyBlockFromClip( sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1,
1576 SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark,
1577 SCCOL nDx, SCROW nDy );
1578 void CopyNonFilteredFromClip( sc::CopyFromClipContext& rCxt, SCCOL nCol1,
1579 SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1580 const ScMarkData& rMark, SCCOL nDx, SCROW & rClipStartRow );
1582 void StartListeningFromClip( SCCOL nCol1, SCROW nRow1,
1583 SCCOL nCol2, SCROW nRow2,
1584 const ScMarkData& rMark, InsertDeleteFlags nInsFlag );
1586 void SetDirtyFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1587 const ScMarkData& rMark, InsertDeleteFlags nInsFlag,
1588 sc::ColumnSpanSet& rBroadcastSpans );
1590 /** If pDestRanges is given it overrides rDestRange, rDestRange in this
1591 case is the overall encompassing range. */
1592 SC_DLLPUBLIC void CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMark,
1593 InsertDeleteFlags nInsFlag,
1594 ScDocument* pRefUndoDoc,
1595 ScDocument* pClipDoc,
1596 bool bResetCut = true,
1597 bool bAsLink = false,
1598 bool bIncludeFiltered = true,
1599 bool bSkipAttrForEmpty = false,
1600 const ScRangeList * pDestRanges = nullptr );
1602 void CopyMultiRangeFromClip(const ScAddress& rDestPos, const ScMarkData& rMark,
1603 InsertDeleteFlags nInsFlag, ScDocument* pClipDoc,
1604 bool bResetCut = true, bool bAsLink = false,
1605 bool bIncludeFiltered = true,
1606 bool bSkipAttrForEmpty = false);
1608 void GetClipArea(SCCOL& nClipX, SCROW& nClipY, bool bIncludeFiltered);
1609 void GetClipStart(SCCOL& nClipX, SCROW& nClipY);
1611 bool HasClipFilteredRows();
1613 bool IsClipboardSource() const;
1615 SC_DLLPUBLIC void TransposeClip( ScDocument* pTransClip, InsertDeleteFlags nFlags, bool bAsLink );
1617 ScClipParam& GetClipParam();
1618 void SetClipParam(const ScClipParam& rParam);
1620 /** To be called at the clipboard document when closing a document that is
1621 the current clipboard source to decouple things from the originating
1622 document. Done in ScDocument dtor after determining
1623 IsClipboardSource().
1625 void ClosingClipboardSource();
1627 void MixDocument( const ScRange& rRange, ScPasteFunc nFunction, bool bSkipEmpty,
1628 ScDocument* pSrcDoc );
1630 void FillTab( const ScRange& rSrcArea, const ScMarkData& rMark,
1631 InsertDeleteFlags nFlags, ScPasteFunc nFunction,
1632 bool bSkipEmpty, bool bAsLink );
1633 void FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark,
1634 InsertDeleteFlags nFlags, ScPasteFunc nFunction,
1635 bool bSkipEmpty, bool bAsLink );
1637 void TransliterateText( const ScMarkData& rMultiMark, TransliterationFlags nType );
1639 SC_DLLPUBLIC void InitUndo( const ScDocument* pSrcDoc, SCTAB nTab1, SCTAB nTab2,
1640 bool bColInfo = false, bool bRowInfo = false );
1641 void AddUndoTab( SCTAB nTab1, SCTAB nTab2,
1642 bool bColInfo = false, bool bRowInfo = false );
1643 SC_DLLPUBLIC void InitUndoSelected( const ScDocument* pSrcDoc, const ScMarkData& rTabSelection,
1644 bool bColInfo = false, bool bRowInfo = false );
1646 // don't use anymore:
1647 void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1648 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1649 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc,
1650 const ScMarkData* pMarks = nullptr, bool bColRowFlags = true);
1651 void UndoToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
1652 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
1653 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc);
1655 void CopyToDocument(const ScRange& rRange,
1656 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc,
1657 const ScMarkData* pMarks = nullptr, bool bColRowFlags = true);
1658 void UndoToDocument(const ScRange& rRange,
1659 InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc);
1661 void CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario = false );
1662 bool TestCopyScenario( SCTAB nSrcTab, SCTAB nDestTab ) const;
1663 void MarkScenario(SCTAB nSrcTab, SCTAB nDestTab,
1664 ScMarkData& rDestMark, bool bResetMark = true,
1665 ScScenarioFlags nNeededBits = ScScenarioFlags::NONE) const;
1666 bool HasScenarioRange( SCTAB nTab, const ScRange& rRange ) const;
1667 SC_DLLPUBLIC const ScRangeList* GetScenarioRanges( SCTAB nTab ) const;
1669 SC_DLLPUBLIC void CopyUpdated( ScDocument* pPosDoc, ScDocument* pDestDoc );
1671 void UpdateReference( sc::RefUpdateContext& rCxt, ScDocument*
1672 pUndoDoc = nullptr, bool bIncludeDraw = true,
1673 bool bUpdateNoteCaptionPos = true );
1675 SC_DLLPUBLIC void UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDoc,
1676 const ScMarkData& rMark, ScDocument* pUndoDoc );
1678 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
1680 SC_DLLPUBLIC void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1681 ScProgress* pProgress, const ScMarkData& rMark,
1682 sal_uLong nFillCount, FillDir eFillDir = FILL_TO_BOTTOM,
1683 FillCmd eFillCmd = FILL_LINEAR, FillDateCmd eFillDateCmd = FILL_DAY,
1684 double nStepValue = 1.0, double nMaxValue = 1E307 );
1685 OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
1687 bool GetSelectionFunction( ScSubTotalFunc eFunc,
1688 const ScAddress& rCursor, const ScMarkData& rMark,
1689 double& rResult );
1691 SC_DLLPUBLIC const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
1692 template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const
1694 return static_cast<const T*>(GetAttr(nCol, nRow, nTab, sal_uInt16(nWhich)));
1696 SC_DLLPUBLIC const SfxPoolItem* GetAttr( const ScAddress& rPos, sal_uInt16 nWhich ) const;
1697 template<class T> const T* GetAttr( const ScAddress& rPos, TypedWhichId<T> nWhich ) const
1699 return static_cast<const T*>(GetAttr(rPos, sal_uInt16(nWhich)));
1701 SC_DLLPUBLIC const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1702 SC_DLLPUBLIC const ScPatternAttr* GetPattern( const ScAddress& rPos ) const;
1703 SC_DLLPUBLIC const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const;
1704 const ScPatternAttr* GetSelectionPattern( const ScMarkData& rMark );
1705 std::unique_ptr<ScPatternAttr> CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
1706 SC_DLLPUBLIC void AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
1707 void RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
1709 SC_DLLPUBLIC ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1710 // pCell is an optimization, must point to rPos
1711 SC_DLLPUBLIC const SfxItemSet* GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab,
1712 ScRefCellValue* pCell = nullptr ) const;
1713 const SfxItemSet* GetCondResult( ScRefCellValue& rCell, const ScAddress& rPos,
1714 const ScConditionalFormatList& rList,
1715 const ScCondFormatIndexes& rIndex ) const;
1716 const SfxPoolItem* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
1717 template<class T> const T* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const
1719 return static_cast<const T*>(GetEffItem(nCol, nRow, nTab, sal_uInt16(nWhich)));
1722 SC_DLLPUBLIC const css::uno::Reference< css::i18n::XBreakIterator >& GetBreakIterator();
1723 bool HasStringWeakCharacters( const OUString& rString );
1724 SC_DLLPUBLIC SvtScriptType GetStringScriptType( const OUString& rString );
1725 // pCell is an optimization, must point to rPos
1726 SC_DLLPUBLIC SvtScriptType GetCellScriptType( const ScAddress& rPos, sal_uInt32 nNumberFormat,
1727 const ScRefCellValue* pCell = nullptr );
1728 // pCell is an optimization, must point to nCol,nRow,nTab
1729 SC_DLLPUBLIC SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab,
1730 const ScRefCellValue* pCell = nullptr );
1731 SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rPos, SCROW nLength );
1732 SvtScriptType GetRangeScriptType( const ScRangeList& rRanges );
1734 bool HasDetectiveOperations() const;
1735 void AddDetectiveOperation( const ScDetOpData& rData );
1736 void ClearDetectiveOperations();
1737 ScDetOpList* GetDetOpList() const { return pDetOpList.get(); }
1738 void SetDetOpList(std::unique_ptr<ScDetOpList> pNew);
1740 bool HasDetectiveObjects(SCTAB nTab) const;
1742 void GetSelectionFrame( const ScMarkData& rMark,
1743 SvxBoxItem& rLineOuter,
1744 SvxBoxInfoItem& rLineInner );
1745 void ApplySelectionFrame(const ScMarkData& rMark,
1746 const SvxBoxItem& rLineOuter,
1747 const SvxBoxInfoItem* pLineInner);
1748 void ApplyFrameAreaTab(const ScRange& rRange,
1749 const SvxBoxItem& rLineOuter,
1750 const SvxBoxInfoItem& rLineInner);
1752 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
1753 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
1755 SC_DLLPUBLIC sal_uLong AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew, SCTAB nTab );
1756 void DeleteConditionalFormat( sal_uLong nIndex, SCTAB nTab );
1758 void SetCondFormList( ScConditionalFormatList* pList, SCTAB nTab );
1759 SC_DLLPUBLIC sal_uLong AddValidationEntry( const ScValidationData& rNew );
1760 SC_DLLPUBLIC const ScValidationData* GetValidationEntry( sal_uLong nIndex ) const;
1762 SC_DLLPUBLIC ScConditionalFormatList* GetCondFormList( SCTAB nTab ) const;
1764 const ScValidationDataList* GetValidationList() const { return pValidationList.get();}
1765 ScValidationDataList* GetValidationList() { return pValidationList.get();}
1767 SC_DLLPUBLIC void ApplyAttr( SCCOL nCol, SCROW nRow, SCTAB nTab,
1768 const SfxPoolItem& rAttr );
1769 SC_DLLPUBLIC void ApplyPattern( SCCOL nCol, SCROW nRow, SCTAB nTab,
1770 const ScPatternAttr& rAttr );
1771 SC_DLLPUBLIC void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow,
1772 SCCOL nEndCol, SCROW nEndRow,
1773 const ScMarkData& rMark, const ScPatternAttr& rAttr,
1774 ScEditDataArray* pDataArray = nullptr,
1775 bool* const pIsChanged = nullptr );
1776 SC_DLLPUBLIC void ApplyPatternAreaTab( SCCOL nStartCol, SCROW nStartRow,
1777 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1778 const ScPatternAttr& rAttr );
1780 SC_DLLPUBLIC void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
1781 const ScMarkData& rMark,
1782 const ScPatternAttr& rPattern,
1783 SvNumFormatType nNewType );
1785 void ApplyStyle( SCCOL nCol, SCROW nRow, SCTAB nTab,
1786 const ScStyleSheet& rStyle);
1787 void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow,
1788 SCCOL nEndCol, SCROW nEndRow,
1789 const ScMarkData& rMark, const ScStyleSheet& rStyle);
1790 SC_DLLPUBLIC void ApplyStyleAreaTab( SCCOL nStartCol, SCROW nStartRow,
1791 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
1792 const ScStyleSheet& rStyle);
1794 SC_DLLPUBLIC void ApplySelectionStyle( const ScStyleSheet& rStyle, const ScMarkData& rMark );
1795 void ApplySelectionLineStyle( const ScMarkData& rMark,
1796 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
1798 const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
1799 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark ) const;
1801 void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
1802 OutputDevice* pDev,
1803 double nPPTX, double nPPTY,
1804 const Fraction& rZoomX, const Fraction& rZoomY );
1806 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
1808 SC_DLLPUBLIC bool ApplyFlagsTab( SCCOL nStartCol, SCROW nStartRow,
1809 SCCOL nEndCol, SCROW nEndRow,
1810 SCTAB nTab, ScMF nFlags );
1811 SC_DLLPUBLIC bool RemoveFlagsTab( SCCOL nStartCol, SCROW nStartRow,
1812 SCCOL nEndCol, SCROW nEndRow,
1813 SCTAB nTab, ScMF nFlags );
1815 SC_DLLPUBLIC void SetPattern( const ScAddress&, const ScPatternAttr& rAttr );
1816 SC_DLLPUBLIC const ScPatternAttr* SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, std::unique_ptr<ScPatternAttr> );
1817 SC_DLLPUBLIC void SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr& rAttr );
1819 void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1820 sal_uInt16 nFormatNo, const ScMarkData& rMark );
1821 void GetAutoFormatData( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1822 ScAutoFormatData& rData );
1823 bool SearchAndReplace( const SvxSearchItem& rSearchItem,
1824 SCCOL& rCol, SCROW& rRow, SCTAB& rTab,
1825 const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1826 OUString& rUndoStr, ScDocument* pUndoDoc = nullptr );
1828 // determine Col/Row of subsequent calls
1829 // (e.g. not found from the beginning, or subsequent tables)
1830 // meaning of explanation in "()" was already unclear in German
1831 void GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem,
1832 SCCOL& rCol, SCROW& rRow );
1834 bool Solver( SCCOL nFCol, SCROW nFRow, SCTAB nFTab,
1835 SCCOL nVCol, SCROW nVRow, SCTAB nVTab,
1836 const OUString& sValStr, double& nX);
1838 SC_DLLPUBLIC void ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark,
1839 ScEditDataArray* pDataArray = nullptr, bool* pIsChanged = nullptr );
1840 void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
1841 void DeleteSelectionTab( SCTAB nTab, InsertDeleteFlags nDelFlag, const ScMarkData& rMark );
1843 SC_DLLPUBLIC void SetColWidth( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth );
1844 SC_DLLPUBLIC void SetColWidthOnly( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth );
1845 SC_DLLPUBLIC void SetRowHeight( SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight );
1846 SC_DLLPUBLIC void SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
1847 sal_uInt16 nNewHeight );
1849 SC_DLLPUBLIC void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, SCTAB nTab,
1850 sal_uInt16 nNewHeight );
1851 SC_DLLPUBLIC void SetManualHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual );
1853 SC_DLLPUBLIC sal_uInt16 GetColWidth( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
1854 SC_DLLPUBLIC sal_uLong GetColWidth( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab ) const;
1855 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1856 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow ) const;
1857 SC_DLLPUBLIC sal_uLong GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1860 * Given the height i.e. total vertical distance from the top of the sheet
1861 * grid, return the first visible row whose top position is below the
1862 * specified height.
1864 SCROW GetRowForHeight( SCTAB nTab, sal_uLong nHeight ) const;
1865 sal_uLong GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const;
1866 SC_DLLPUBLIC sal_uLong GetColOffset( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
1867 SC_DLLPUBLIC sal_uLong GetRowOffset( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
1869 SC_DLLPUBLIC sal_uInt16 GetOriginalWidth( SCCOL nCol, SCTAB nTab ) const;
1870 SC_DLLPUBLIC sal_uInt16 GetOriginalHeight( SCROW nRow, SCTAB nTab ) const;
1872 sal_uInt16 GetCommonWidth( SCCOL nEndCol, SCTAB nTab ) const;
1874 SCROW GetHiddenRowCount( SCROW nRow, SCTAB nTab ) const;
1876 sal_uInt16 GetOptimalColWidth( SCCOL nCol, SCTAB nTab, OutputDevice* pDev,
1877 double nPPTX, double nPPTY,
1878 const Fraction& rZoomX, const Fraction& rZoomY,
1879 bool bFormula,
1880 const ScMarkData* pMarkData = nullptr,
1881 const ScColWidthParam* pParam = nullptr );
1883 SC_DLLPUBLIC bool SetOptimalHeight( sc::RowHeightContext& rCxt, SCROW nStartRow,
1884 SCROW nEndRow, SCTAB nTab );
1886 void UpdateAllRowHeights( sc::RowHeightContext& rCxt, const ScMarkData* pTabMark );
1888 long GetNeededSize( SCCOL nCol, SCROW nRow, SCTAB nTab,
1889 OutputDevice* pDev,
1890 double nPPTX, double nPPTY,
1891 const Fraction& rZoomX, const Fraction& rZoomY,
1892 bool bWidth, bool bTotalSize = false );
1894 SC_DLLPUBLIC void ShowCol(SCCOL nCol, SCTAB nTab, bool bShow);
1895 SC_DLLPUBLIC void ShowRow(SCROW nRow, SCTAB nTab, bool bShow);
1896 SC_DLLPUBLIC void ShowRows(SCROW nRow1, SCROW nRow2, SCTAB nTab, bool bShow);
1897 SC_DLLPUBLIC void SetRowFlags( SCROW nRow, SCTAB nTab, CRFlags nNewFlags );
1898 SC_DLLPUBLIC void SetRowFlags( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, CRFlags nNewFlags );
1900 SC_DLLPUBLIC CRFlags GetColFlags( SCCOL nCol, SCTAB nTab ) const;
1901 SC_DLLPUBLIC CRFlags GetRowFlags( SCROW nRow, SCTAB nTab ) const;
1903 SC_DLLPUBLIC void GetAllRowBreaks(std::set<SCROW>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
1904 SC_DLLPUBLIC void GetAllColBreaks(std::set<SCCOL>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
1905 SC_DLLPUBLIC ScBreakType HasRowBreak(SCROW nRow, SCTAB nTab) const;
1906 SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const;
1907 SC_DLLPUBLIC void SetRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
1908 SC_DLLPUBLIC void SetColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
1909 void RemoveRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
1910 void RemoveColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
1911 css::uno::Sequence<
1912 css::sheet::TablePageBreakData> GetRowBreakData(SCTAB nTab) const;
1914 SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
1915 SC_DLLPUBLIC bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1916 SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
1917 SC_DLLPUBLIC void SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden);
1918 SC_DLLPUBLIC void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden);
1919 SC_DLLPUBLIC SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1920 SC_DLLPUBLIC SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1921 SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1923 bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
1924 bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1925 bool ColFiltered(SCCOL nCol, SCTAB nTab) const;
1926 SC_DLLPUBLIC void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered);
1927 SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1928 SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1929 SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
1931 SC_DLLPUBLIC bool IsManualRowHeight(SCROW nRow, SCTAB nTab) const;
1933 bool HasUniformRowHeight( SCTAB nTab, SCROW nRow1, SCROW nRow2 ) const;
1936 * Write all column row flags to table's flag data, because not all column
1937 * row attributes are stored in the flag data members. This is necessary
1938 * for ods export.
1940 void SyncColRowFlags();
1942 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
1943 SC_DLLPUBLIC SCROW GetLastFlaggedRow( SCTAB nTab ) const;
1945 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
1946 SCCOL GetLastChangedCol( SCTAB nTab ) const;
1947 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
1948 SCROW GetLastChangedRow( SCTAB nTab ) const;
1950 SCCOL GetNextDifferentChangedCol( SCTAB nTab, SCCOL nStart) const;
1952 SCROW GetNextDifferentChangedRow( SCTAB nTab, SCROW nStart) const;
1954 // returns whether to export a Default style for this col or not
1955 // nDefault is set to one position in the current row where the Default style is
1956 void GetColDefault( SCTAB nTab, SCCOL nCol, SCROW nLastRow, SCROW& nDefault);
1958 bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bShow );
1959 bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bShow );
1961 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
1962 void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
1964 SC_DLLPUBLIC ScPatternAttr* GetDefPattern() const;
1965 SC_DLLPUBLIC ScDocumentPool* GetPool();
1966 SC_DLLPUBLIC ScStyleSheetPool* GetStyleSheetPool() const;
1967 void GetUnprotectedCells( ScRangeList& rRange, SCTAB nTab ) const;
1969 // PageStyle:
1970 SC_DLLPUBLIC OUString GetPageStyle( SCTAB nTab ) const;
1971 SC_DLLPUBLIC void SetPageStyle( SCTAB nTab, const OUString& rName );
1972 Size GetPageSize( SCTAB nTab ) const;
1973 void SetPageSize( SCTAB nTab, const Size& rSize );
1974 void SetRepeatArea( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
1975 void InvalidatePageBreaks(SCTAB nTab);
1976 void UpdatePageBreaks( SCTAB nTab, const ScRange* pUserArea = nullptr );
1977 void RemoveManualBreaks( SCTAB nTab );
1978 bool HasManualBreaks( SCTAB nTab ) const;
1980 bool IsPageStyleInUse( const OUString& rStrPageStyle, SCTAB* pInTab );
1981 bool RemovePageStyleInUse( const OUString& rStrPageStyle );
1982 bool RenamePageStyleInUse( const OUString& rOld, const OUString& rNew );
1983 void ModifyStyleSheet( SfxStyleSheetBase& rPageStyle,
1984 const SfxItemSet& rChanges );
1986 void PageStyleModified( SCTAB nTab, const OUString& rNewName );
1988 SC_DLLPUBLIC bool NeedPageResetAfterTab( SCTAB nTab ) const;
1990 // Was stored in PageStyle previously. Now it exists for every table:
1991 SC_DLLPUBLIC bool HasPrintRange();
1992 SC_DLLPUBLIC sal_uInt16 GetPrintRangeCount( SCTAB nTab );
1993 SC_DLLPUBLIC const ScRange* GetPrintRange( SCTAB nTab, sal_uInt16 nPos );
1994 SC_DLLPUBLIC const ScRange* GetRepeatColRange( SCTAB nTab );
1995 SC_DLLPUBLIC const ScRange* GetRepeatRowRange( SCTAB nTab );
1996 /** Returns true, if the specified sheet is always printed. */
1997 bool IsPrintEntireSheet( SCTAB nTab ) const;
1999 /** Removes all print ranges. */
2000 SC_DLLPUBLIC void ClearPrintRanges( SCTAB nTab );
2001 /** Adds a new print ranges. */
2002 SC_DLLPUBLIC void AddPrintRange( SCTAB nTab, const ScRange& rNew );
2003 /** Marks the specified sheet to be printed completely. Deletes old print ranges on the sheet! */
2004 SC_DLLPUBLIC void SetPrintEntireSheet( SCTAB nTab );
2005 SC_DLLPUBLIC void SetRepeatColRange( SCTAB nTab, std::unique_ptr<ScRange> pNew );
2006 SC_DLLPUBLIC void SetRepeatRowRange( SCTAB nTab, std::unique_ptr<ScRange> pNew );
2007 std::unique_ptr<ScPrintRangeSaver> CreatePrintRangeSaver() const;
2008 void RestorePrintRanges( const ScPrintRangeSaver& rSaver );
2010 SC_DLLPUBLIC tools::Rectangle GetMMRect( SCCOL nStartCol, SCROW nStartRow,
2011 SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
2012 SC_DLLPUBLIC ScRange GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool bHiddenAsZero = true ) const;
2014 void UpdStlShtPtrsFrmNms();
2015 void StylesToNames();
2017 SC_DLLPUBLIC void CopyStdStylesFrom( const ScDocument* pSrcDoc );
2019 static sal_uInt16 GetSrcVersion() { return nSrcVer; }
2021 void SetSrcCharSet( rtl_TextEncoding eNew ) { eSrcSet = eNew; }
2022 void UpdateFontCharSet();
2024 void FillInfo( ScTableInfo& rTabInfo, SCCOL nCol1, SCROW nRow1,
2025 SCCOL nCol2, SCROW nRow2, SCTAB nTab, double fColScale,
2026 double fRowScale, bool bPageMode, bool bFormulaMode,
2027 const ScMarkData* pMarkData = nullptr );
2029 SC_DLLPUBLIC SvNumberFormatter* GetFormatTable() const;
2031 /** Sort a range of data. */
2032 void Sort( SCTAB nTab, const ScSortParam& rSortParam,
2033 bool bKeepQuery, bool bUpdateRefs,
2034 ScProgress* pProgress, sc::ReorderParam* pUndo );
2036 void Reorder( const sc::ReorderParam& rParam );
2038 SCSIZE Query( SCTAB nTab, const ScQueryParam& rQueryParam, bool bKeepSub );
2039 SC_DLLPUBLIC bool CreateQueryParam( const ScRange& rRange, ScQueryParam& rQueryParam );
2040 void GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rStr);
2043 * Get a list of unique strings to use in filtering criteria. The string
2044 * values are sorted, and there are no duplicate values in the list. The
2045 * data range to use to populate the filter entries is inferred from the
2046 * database range that contains the specified cell position.
2048 void GetFilterEntries( SCCOL nCol, SCROW nRow,
2049 SCTAB nTab, ScFilterEntries& rFilterEntries );
2051 SC_DLLPUBLIC void GetFilterEntriesArea( SCCOL nCol, SCROW nStartRow, SCROW nEndRow,
2052 SCTAB nTab, bool bCaseSens,
2053 ScFilterEntries& rFilterEntries );
2055 void GetDataEntries( SCCOL nCol, SCROW nRow, SCTAB nTab,
2056 std::vector<ScTypedStrData>& rStrings, bool bLimit = false );
2057 void GetFormulaEntries( ScTypedCaseStrSet& rStrings );
2059 bool HasAutoFilter( SCCOL nCol, SCROW nRow, SCTAB nTab );
2060 void GetFilterSelCount( SCCOL nCol, SCROW nRow, SCTAB nTab, SCSIZE& nSelected, SCSIZE& nTotal );
2062 SC_DLLPUBLIC bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
2063 SCTAB nTab );
2064 SC_DLLPUBLIC bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
2065 SCTAB nTab );
2067 SfxPrinter* GetPrinter( bool bCreateIfNotExist = true );
2068 void SetPrinter( VclPtr<SfxPrinter> const & pNewPrinter );
2069 VirtualDevice* GetVirtualDevice_100th_mm();
2070 SC_DLLPUBLIC OutputDevice* GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice...
2072 bool GetNextSpellingCell( SCCOL& nCol, SCROW& nRow, SCTAB nTab,
2073 bool bInSel, const ScMarkData& rMark) const;
2075 void ReplaceStyle( const SvxSearchItem& rSearchItem,
2076 SCCOL nCol, SCROW nRow, SCTAB nTab,
2077 const ScMarkData& rMark);
2079 void InvalidateTextWidth( const OUString& rStyleName );
2080 void InvalidateTextWidth( SCTAB nTab );
2081 void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo, bool bNumFormatChanged );
2083 bool IdleCalcTextWidth();
2085 void RepaintRange( const ScRange& rRange );
2086 void RepaintRange( const ScRangeList& rRange );
2088 bool IsIdleEnabled() const { return mbIdleEnabled; }
2089 void EnableIdle(bool bDo) { mbIdleEnabled = bDo; }
2091 bool IsDetectiveDirty() const { return bDetectiveDirty; }
2092 void SetDetectiveDirty(bool bSet) { bDetectiveDirty = bSet; }
2094 bool HasLinkFormulaNeedingCheck() const { return bLinkFormulaNeedingCheck; }
2095 void SetLinkFormulaNeedingCheck(bool bSet) { bLinkFormulaNeedingCheck = bSet; }
2096 /** Check token array and set link check if ocDde/ocWebservice is contained. */
2097 SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode );
2099 void SetRangeOverflowType(ErrCode nType) { nRangeOverflowType = nType; }
2100 bool HasRangeOverflow() const { return nRangeOverflowType != ERRCODE_NONE; }
2101 SC_DLLPUBLIC const ErrCode& GetRangeOverflowType() const { return nRangeOverflowType; }
2103 // for broadcasting/listening
2104 void SetInsertingFromOtherDoc( bool bVal ) { bInsertingFromOtherDoc = bVal; }
2105 bool IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc; }
2106 void SetLoadingMedium( bool bVal );
2107 SC_DLLPUBLIC void SetImportingXML( bool bVal );
2108 bool IsImportingXML() const { return bImportingXML; }
2109 bool IsCalcingAfterLoad() const { return bCalcingAfterLoad; }
2110 void SetNoListening( bool bVal ) { bNoListening = bVal; }
2111 bool GetNoListening() const { return bNoListening; }
2112 ScBroadcastAreaSlotMachine* GetBASM() const { return pBASM.get(); }
2114 SC_DLLPUBLIC ScChartListenerCollection* GetChartListenerCollection() const { return pChartListenerCollection.get(); }
2115 void SetChartListenerCollection( std::unique_ptr<ScChartListenerCollection>,
2116 bool bSetChartRangeLists );
2117 void UpdateChart( const OUString& rName );
2118 void RestoreChartListener( const OUString& rName );
2119 SC_DLLPUBLIC void UpdateChartListenerCollection();
2120 bool IsChartListenerCollectionNeedsUpdate() const { return bChartListenerCollectionNeedsUpdate; }
2121 void SetChartListenerCollectionNeedsUpdate( bool bFlg ) { bChartListenerCollectionNeedsUpdate = bFlg; }
2122 void AddOLEObjectToCollection(const OUString& rName);
2124 ScChangeViewSettings* GetChangeViewSettings() const { return pChangeViewSettings.get(); }
2125 SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings& rNew);
2127 const std::shared_ptr<SvxForbiddenCharactersTable>& GetForbiddenCharacters() const;
2128 void SetForbiddenCharacters(const std::shared_ptr<SvxForbiddenCharactersTable>& rNew);
2130 CharCompressType GetAsianCompression() const;
2131 bool IsValidAsianCompression() const;
2132 void SetAsianCompression(CharCompressType nNew);
2134 bool GetAsianKerning() const;
2135 bool IsValidAsianKerning() const;
2136 void SetAsianKerning(bool bNew);
2137 void ApplyAsianEditSettings(ScEditEngineDefaulter& rEngine);
2139 EEHorizontalTextDirection GetEditTextDirection(SCTAB nTab) const; // EEHorizontalTextDirection values
2141 SC_DLLPUBLIC ScLkUpdMode GetLinkMode() const { return eLinkMode ;}
2142 void SetLinkMode( ScLkUpdMode nSet ) { eLinkMode = nSet;}
2144 SC_DLLPUBLIC ScMacroManager* GetMacroManager();
2146 void FillMatrix( ScMatrix& rMat, SCTAB nTab, SCCOL nCol1,
2147 SCROW nRow1, SCCOL nCol2, SCROW nRow2,
2148 svl::SharedStringPool* pPool = nullptr) const;
2151 * Set an array of numerical formula results to a group of contiguous
2152 * formula cells.
2154 * @param rTopPos position of the top formula cell of a group.
2155 * @param pResults array of numeric results.
2156 * @param nLen length of numeric results.
2158 void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const double* pResults, size_t nLen );
2160 const ScDocumentThreadSpecific& CalculateInColumnInThread( ScInterpreterContext& rContext, const ScRange& rCalcRange, unsigned nThisThread, unsigned nThreadsTotal);
2161 void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab, ScInterpreter* pInterpreter );
2164 * Transfer a series of contiguous cell values from specified position to
2165 * the passed container. The specified segment will become empty after the
2166 * transfer.
2168 void TransferCellValuesTo( const ScAddress& rTopPos, size_t nLen, sc::CellValues& rDest );
2169 void CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellValues& rSrc );
2171 std::set<Color> GetDocColors();
2172 sc::IconSetBitmapMap& GetIconSetBitmapMap();
2174 private:
2175 ScDocument(const ScDocument& r) = delete;
2177 void FindMaxRotCol( SCTAB nTab, RowInfo* pRowInfo, SCSIZE nArrCount,
2178 SCCOL nX1, SCCOL nX2 ) const;
2180 sal_uInt16 RowDifferences( SCROW nThisRow, SCTAB nThisTab,
2181 ScDocument& rOtherDoc,
2182 SCROW nOtherRow, SCTAB nOtherTab,
2183 SCCOL nMaxCol, const SCCOLROW* pOtherCols );
2184 sal_uInt16 ColDifferences( SCCOL nThisCol, SCTAB nThisTab,
2185 ScDocument& rOtherDoc,
2186 SCCOL nOtherCol, SCTAB nOtherTab,
2187 SCROW nMaxRow, const SCCOLROW* pOtherRows );
2188 void FindOrder( SCCOLROW* pOtherRows, SCCOLROW nThisEndRow, SCCOLROW nOtherEndRow,
2189 bool bColumns,
2190 ScDocument& rOtherDoc, SCTAB nThisTab, SCTAB nOtherTab,
2191 SCCOLROW nEndCol, const SCCOLROW* pTranslate,
2192 ScProgress* pProgress, sal_uLong nProAdd );
2194 DECL_LINK(TrackTimeHdl, Timer *, void);
2196 static ScRecursionHelper* CreateRecursionHelperInstance();
2198 /** Adjust a range to available sheets.
2200 Used to start and stop listening on a sane range. Both o_rRange and
2201 o_bEntirelyOutOfBounds are set only if needed and don't have to be
2202 initialized by the caller.
2204 @param o_bEntirelyOutOfBounds
2205 <TRUE/> if both sheets in the range point outside the
2206 available sheet range, in which case no adjustment is done and
2207 o_rRange is not modified.
2209 @return <TRUE/> if any adjustment was done or o_bEntirelyOutOfBounds
2210 was set <TRUE/>.
2211 <FALSE/> if rRange was within the available sheets.
2213 bool LimitRangeToAvailableSheets( const ScRange& rRange, ScRange& o_rRange,
2214 bool& o_bEntirelyOutOfBounds ) const;
2216 public:
2217 void StartListeningArea( const ScRange& rRange, bool bGroupListening, SvtListener* pListener );
2219 void EndListeningArea( const ScRange& rRange, bool bGroupListening, SvtListener* pListener );
2220 /** Broadcast wrapper, calls
2221 rHint.GetCell()->Broadcast() and AreaBroadcast()
2222 and TrackFormulas()
2223 Preferred.
2225 void Broadcast( const ScHint& rHint );
2227 void BroadcastCells( const ScRange& rRange, SfxHintId nHint, bool bBroadcastSingleBroadcasters = true );
2229 /// only area, no cell broadcast
2230 void AreaBroadcast( const ScHint& rHint );
2231 void DelBroadcastAreasInRange( const ScRange& rRange );
2232 void UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode,
2233 const ScRange& rRange,
2234 SCCOL nDx, SCROW nDy, SCTAB nDz );
2236 void StartListeningCell( const ScAddress& rAddress,
2237 SvtListener* pListener );
2238 void EndListeningCell( const ScAddress& rAddress,
2239 SvtListener* pListener );
2241 void StartListeningCell( sc::StartListeningContext& rCxt, const ScAddress& rPos, SvtListener& rListener );
2242 void EndListeningCell( sc::EndListeningContext& rCxt, const ScAddress& rPos, SvtListener& rListener );
2244 void EndListeningFormulaCells( std::vector<ScFormulaCell*>& rCells );
2246 void PutInFormulaTree( ScFormulaCell* pCell );
2247 void RemoveFromFormulaTree( ScFormulaCell* pCell );
2250 * Calculate formula cells that are on the formula tree either partially,
2251 * or in full.
2253 * @param bOnlyForced when true, it only calculates those formula cells
2254 * that are marked "recalc forced".
2255 * @param bProgressBar whether or not to use progress bar.
2256 * @param bSetAllDirty when true, it marks all formula cells currently on
2257 * the formula tree dirty, which forces all of them to
2258 * be recalculated. When false, only those cells
2259 * that are marked dirty prior to this call get
2260 * recalculated.
2262 SC_DLLPUBLIC void CalcFormulaTree( bool bOnlyForced = false, bool bProgressBar = true, bool bSetAllDirty = true );
2263 void ClearFormulaTree();
2264 void AppendToFormulaTrack( ScFormulaCell* pCell );
2265 void RemoveFromFormulaTrack( ScFormulaCell* pCell );
2266 void TrackFormulas( SfxHintId nHintId = SfxHintId::ScDataChanged );
2267 void SetTrackFormulasPending() { mbTrackFormulasPending = true; }
2268 bool IsTrackFormulasPending() const { return mbTrackFormulasPending; }
2269 void FinalTrackFormulas( SfxHintId nHintId );
2270 bool IsFinalTrackFormulas() const { return mbFinalTrackFormulas; }
2271 bool IsInFormulaTree( const ScFormulaCell* pCell ) const;
2272 bool IsInFormulaTrack( const ScFormulaCell* pCell ) const;
2273 HardRecalcState GetHardRecalcState() const { return eHardRecalcState; }
2274 void SetHardRecalcState( HardRecalcState eVal ) { eHardRecalcState = eVal; }
2275 void StartAllListeners();
2276 void StartNeededListeners();
2277 void StartNeededListeners( const std::shared_ptr<const sc::ColumnSet>& rpColSet );
2278 void StartAllListeners( const ScRange& rRange );
2280 void SetForcedFormulas( bool bVal ) { bHasForcedFormulas = bVal; }
2281 sal_uLong GetFormulaCodeInTree() const { return nFormulaCodeInTree; }
2283 bool IsInInterpreter() const { return nInterpretLevel != 0; }
2285 void IncInterpretLevel()
2287 assert(!IsThreadedGroupCalcInProgress());
2288 if ( nInterpretLevel < USHRT_MAX )
2289 nInterpretLevel++;
2291 void DecInterpretLevel()
2293 assert(!IsThreadedGroupCalcInProgress());
2294 if ( nInterpretLevel )
2295 nInterpretLevel--;
2297 sal_uInt16 GetMacroInterpretLevel() const { return nMacroInterpretLevel; }
2298 void IncMacroInterpretLevel()
2300 assert(!IsThreadedGroupCalcInProgress());
2301 if ( nMacroInterpretLevel < USHRT_MAX )
2302 nMacroInterpretLevel++;
2304 void DecMacroInterpretLevel()
2306 assert(!IsThreadedGroupCalcInProgress());
2307 if ( nMacroInterpretLevel )
2308 nMacroInterpretLevel--;
2310 bool IsInInterpreterTableOp() const { return nInterpreterTableOpLevel != 0; }
2311 void IncInterpreterTableOpLevel()
2313 if ( nInterpreterTableOpLevel < USHRT_MAX )
2314 nInterpreterTableOpLevel++;
2316 void DecInterpreterTableOpLevel()
2318 if ( nInterpreterTableOpLevel )
2319 nInterpreterTableOpLevel--;
2322 // add a formula to be remembered for TableOp broadcasts
2323 void AddTableOpFormulaCell( ScFormulaCell* );
2324 void InvalidateLastTableOpParams() { aLastTableOpParams.bValid = false; }
2325 ScRecursionHelper& GetRecursionHelper();
2326 bool IsInDtorClear() const { return bInDtorClear; }
2327 void SetExpandRefs( bool bVal );
2328 bool IsExpandRefs() const { return bExpandRefs; }
2330 sal_uLong GetXMLImportedFormulaCount() const { return nXMLImportedFormulaCount; }
2331 void IncXMLImportedFormulaCount( sal_uLong nVal )
2333 if ( nXMLImportedFormulaCount + nVal > nXMLImportedFormulaCount )
2334 nXMLImportedFormulaCount += nVal;
2336 void DecXMLImportedFormulaCount( sal_uLong nVal )
2338 if ( nVal <= nXMLImportedFormulaCount )
2339 nXMLImportedFormulaCount -= nVal;
2340 else
2341 nXMLImportedFormulaCount = 0;
2344 void StartTrackTimer();
2346 void CompileDBFormula();
2347 void CompileColRowNameFormula();
2349 /** Maximum string length of a column, e.g. for dBase export.
2350 @return String length in octets (!) of the destination encoding. In
2351 case of non-octet encodings (e.g. UCS2) the length in code
2352 points times sizeof(sal_Unicode) is returned. */
2353 sal_Int32 GetMaxStringLen( SCTAB nTab, SCCOL nCol,
2354 SCROW nRowStart, SCROW nRowEnd,
2355 rtl_TextEncoding eCharSet ) const;
2356 /** Maximum string length of numerical cells of a column, e.g. for dBase export.
2357 @return String length in characters (!) including the decimal
2358 separator, and the decimal precision needed. */
2359 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
2360 SCTAB nTab, SCCOL nCol,
2361 SCROW nRowStart, SCROW nRowEnd ) const;
2363 void KeyInput(); // TimerDelays etc.
2365 ScChangeTrack* GetChangeTrack() const { return pChangeTrack.get(); }
2367 //! only for import filter, deletes any existing ChangeTrack via
2368 //! EndChangeTracking() and takes ownership of new ChangeTrack pTrack
2369 SC_DLLPUBLIC void SetChangeTrack( std::unique_ptr<ScChangeTrack> pTrack );
2371 void StartChangeTracking();
2372 void EndChangeTracking();
2374 SC_DLLPUBLIC void CompareDocument( ScDocument& rOtherDoc );
2376 void AddUnoObject( SfxListener& rObject );
2377 void RemoveUnoObject( SfxListener& rObject );
2378 void BroadcastUno( const SfxHint &rHint );
2379 void AddUnoListenerCall( const css::uno::Reference<
2380 css::util::XModifyListener >& rListener,
2381 const css::lang::EventObject& rEvent );
2383 void SetInLinkUpdate(bool bSet); // TableLink or AreaLink
2384 bool IsInLinkUpdate() const; // including DdeLink
2386 SC_DLLPUBLIC SfxItemPool* GetEditPool() const;
2387 SC_DLLPUBLIC SfxItemPool* GetEnginePool() const;
2388 SC_DLLPUBLIC ScFieldEditEngine& GetEditEngine();
2389 SC_DLLPUBLIC ScNoteEditEngine& GetNoteEngine();
2391 std::unique_ptr<ScRefreshTimerControl> const & GetRefreshTimerControlAddress() const
2392 { return pRefreshTimerControl; }
2394 void SetPastingDrawFromOtherDoc( bool bVal )
2395 { bPastingDrawFromOtherDoc = bVal; }
2396 bool PastingDrawFromOtherDoc() const
2397 { return bPastingDrawFromOtherDoc; }
2399 /// an ID unique to each document instance
2400 sal_uInt32 GetDocumentID() const;
2402 void InvalidateStyleSheetUsage() { bStyleSheetUsageInvalid = true; }
2403 void SC_DLLPUBLIC GetSortParam( ScSortParam& rParam, SCTAB nTab );
2404 void SC_DLLPUBLIC SetSortParam( const ScSortParam& rParam, SCTAB nTab );
2406 void SetVbaEventProcessor( const css::uno::Reference< css::script::vba::XVBAEventProcessor >& rxVbaEvents )
2407 { mxVbaEvents = rxVbaEvents; }
2408 const css::uno::Reference< css::script::vba::XVBAEventProcessor >& GetVbaEventProcessor() const { return mxVbaEvents; }
2410 /** Should only be GRAM_PODF or GRAM_ODFF. */
2411 void SetStorageGrammar( formula::FormulaGrammar::Grammar eGrammar );
2412 formula::FormulaGrammar::Grammar GetStorageGrammar() const { return eStorageGrammar; }
2414 SC_DLLPUBLIC SfxUndoManager* GetUndoManager();
2415 bool IsInVBAMode() const;
2416 ScRowBreakIterator* GetRowBreakIterator(SCTAB nTab) const;
2418 void AddSubTotalCell(ScFormulaCell* pCell);
2419 void RemoveSubTotalCell(ScFormulaCell* pCell);
2420 void SetSubTotalCellsDirty(const ScRange& rDirtyRange);
2422 sal_uInt16 GetTextWidth( const ScAddress& rPos ) const;
2424 SvtScriptType GetScriptType( const ScAddress& rPos ) const;
2425 void SetScriptType( const ScAddress& rPos, SvtScriptType nType );
2426 void UpdateScriptTypes( const ScAddress& rPos, SCCOL nColSize, SCROW nRowSize );
2428 size_t GetFormulaHash( const ScAddress& rPos ) const;
2431 * Make specified formula cells non-grouped.
2433 * @param nTab sheet index
2434 * @param nCol column index
2435 * @param rRows list of row indices at which formula cells are to be
2436 * unshared. This call sorts the passed row indices and
2437 * removes duplicates, which is why the caller must pass it
2438 * as reference.
2440 void UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector<SCROW>& rRows );
2441 void RegroupFormulaCells( SCTAB nTab, SCCOL nCol );
2442 void RegroupFormulaCells( const ScRange& range );
2444 ScFormulaVectorState GetFormulaVectorState( const ScAddress& rPos ) const;
2446 formula::FormulaTokenRef ResolveStaticReference( const ScAddress& rPos );
2447 formula::FormulaTokenRef ResolveStaticReference( const ScRange& rRange );
2449 formula::VectorRefArray FetchVectorRefArray( const ScAddress& rPos, SCROW nLength );
2450 bool HandleRefArrayForParallelism( const ScAddress& rPos, SCROW nLength, const ScFormulaCellGroupRef& mxGroup );
2451 #ifdef DBG_UTIL
2452 void AssertNoInterpretNeeded( const ScAddress& rPos, SCROW nLength );
2453 #endif
2456 * Call this before any operations that might trigger one or more formula
2457 * cells to get calculated.
2459 void PrepareFormulaCalc();
2462 * Make sure all of the formula cells in the specified range have been
2463 * fully calculated. This method only re-calculates those formula cells
2464 * that have been flagged dirty. In case of formula-groups, this calculates
2465 * only the dirty subspans along with the dependents in the same way
2466 * recursively.
2468 * @param rRange range in which to potentially calculate the formula
2469 * cells.
2470 * @param bSkipRunning flag to skip evaluation of formula-cells that are
2471 * marked as already being evaluated.
2472 * @return true if at least one formula-cell in the specified range was dirty
2473 * else returns false.
2475 SC_DLLPUBLIC bool EnsureFormulaCellResults( const ScRange& rRange, bool bSkipRunning = false );
2477 SvtBroadcaster* GetBroadcaster( const ScAddress& rPos );
2478 const SvtBroadcaster* GetBroadcaster( const ScAddress& rPos ) const;
2479 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rTopPos, SCROW nLength );
2481 std::unique_ptr<sc::ColumnIterator> GetColumnIterator( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
2482 void CreateColumnIfNotExists( SCTAB nTab, SCCOL nCol );
2484 SC_DLLPUBLIC void StoreTabToCache(SCTAB nTab, SvStream& rStrm) const;
2485 SC_DLLPUBLIC void RestoreTabFromCache(SCTAB nTab, SvStream& rStream);
2487 #if DUMP_COLUMN_STORAGE
2488 SC_DLLPUBLIC void DumpColumnStorage( SCTAB nTab, SCCOL nCol ) const;
2489 #endif
2491 #if DEBUG_AREA_BROADCASTER
2492 SC_DLLPUBLIC void DumpAreaBroadcasters() const;
2493 #endif
2495 SC_DLLPUBLIC void SetCalcConfig( const ScCalcConfig& rConfig );
2496 const ScCalcConfig& GetCalcConfig() const { return maCalcConfig; }
2497 void ConvertFormulaToValue( const ScRange& rRange, sc::TableValues* pUndo );
2498 void SwapNonEmpty( sc::TableValues& rValues );
2499 void finalizeOutlineImport();
2500 bool TableExists( SCTAB nTab ) const;
2502 SC_DLLPUBLIC ScColumnsRange GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const;
2504 bool IsInDocShellRecalc() const { return mbDocShellRecalc; }
2505 void SetDocShellRecalc(bool bSet) { mbDocShellRecalc = bSet; }
2507 bool IsInLayoutStrings() const { return mbLayoutStrings; }
2508 void SetLayoutStrings(bool bSet) { mbLayoutStrings = bSet; }
2510 private:
2513 * Use this class as a locale variable to merge number formatter from
2514 * another document, and set NULL pointer to pFormatExchangeList when
2515 * done.
2517 class NumFmtMergeHandler
2519 public:
2520 explicit NumFmtMergeHandler(ScDocument* pDoc, const ScDocument* pSrcDoc);
2521 ~NumFmtMergeHandler();
2523 private:
2524 ScDocument* mpDoc;
2527 ScTable* FetchTable( SCTAB nTab );
2528 const ScTable* FetchTable( SCTAB nTab ) const;
2530 void MergeNumberFormatter(const ScDocument* pSrcDoc);
2532 void ImplCreateOptions(); // Suggestion: switch to on-demand?
2533 void ImplDeleteOptions();
2535 void DeleteDrawLayer();
2536 SC_DLLPUBLIC bool DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const;
2538 void UpdateDrawPrinter();
2539 void UpdateDrawLanguages();
2540 SC_DLLPUBLIC void InitClipPtrs( ScDocument* pSourceDoc );
2542 void LoadDdeLinks(SvStream& rStream);
2543 void SaveDdeLinks(SvStream& rStream) const;
2545 void DeleteAreaLinksOnTab( SCTAB nTab );
2546 void UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
2547 const ScRange& r, SCCOL nDx, SCROW nDy, SCTAB nDz );
2549 void CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks);
2551 bool HasPartOfMerged( const ScRange& rRange );
2553 ScRefCellValue GetRefCellValue( const ScAddress& rPos );
2554 ScRefCellValue GetRefCellValue( const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos );
2556 std::map< SCTAB, ScSortParam > mSheetSortParams;
2558 SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol ) const;
2559 SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
2560 void ReservePatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserve );
2562 void SharePooledResources( const ScDocument* pSrcDoc );
2564 void EndListeningIntersectedGroup(
2565 sc::EndListeningContext& rCxt, const ScAddress& rPos, std::vector<ScAddress>* pGroupPos );
2567 void EndListeningIntersectedGroups(
2568 sc::EndListeningContext& rCxt, const ScRange& rRange, std::vector<ScAddress>* pGroupPos );
2570 void EndListeningGroups( const std::vector<ScAddress>& rPosArray );
2571 void SetNeedsListeningGroups( const std::vector<ScAddress>& rPosArray );
2574 typedef std::unique_ptr<ScDocument, o3tl::default_delete<ScDocument>> ScDocumentUniquePtr;
2577 * Instantiate this to ensure that subsequent modification of
2578 * the document will cause an assertion failure while this is
2579 * in-scope.
2581 struct ScMutationDisable
2583 ScMutationDisable(ScDocument* pDocument, ScMutationGuardFlags nFlags)
2585 #ifndef NDEBUG
2586 mpDocument = pDocument;
2587 mnFlagRestore = pDocument->mnMutationGuardFlags;
2588 assert((mnFlagRestore & nFlags) == 0);
2589 mpDocument->mnMutationGuardFlags |= static_cast<size_t>(nFlags);
2590 #else
2591 (void)pDocument; (void)nFlags;
2592 #endif
2594 #ifndef NDEBUG
2595 ~ScMutationDisable()
2597 mpDocument->mnMutationGuardFlags = mnFlagRestore;
2599 size_t mnFlagRestore;
2600 ScDocument* mpDocument;
2601 #endif
2605 * A pretty assertion that checks that the relevant bits in
2606 * the @nFlags are not set on the document at entry and exit.
2608 * Its primary use is for debugging threading. As such, an
2609 * @ScMutationDisable is created to forbid mutation, and this
2610 * condition is then asserted on at prominent sites that
2611 * mutate @nFlags.
2613 struct ScMutationGuard
2615 ScMutationGuard(ScDocument* pDocument, ScMutationGuardFlags nFlags)
2617 #ifndef NDEBUG
2618 mpDocument = pDocument;
2619 mnFlags = static_cast<size_t>(nFlags);
2620 assert((mpDocument->mnMutationGuardFlags & mnFlags) == 0);
2621 #else
2622 (void)pDocument; (void)nFlags;
2623 #endif
2625 #ifndef NDEBUG
2626 ~ScMutationGuard()
2628 assert((mpDocument->mnMutationGuardFlags & mnFlags) == 0);
2630 size_t mnFlags;
2631 ScDocument* mpDocument;
2632 #endif
2636 class ScDocShellRecalcGuard
2638 ScDocument& mrDoc;
2640 public:
2641 ScDocShellRecalcGuard(ScDocument& rDoc)
2642 : mrDoc(rDoc)
2644 assert(!mrDoc.IsInDocShellRecalc());
2645 mrDoc.SetDocShellRecalc(true);
2648 ~ScDocShellRecalcGuard()
2650 mrDoc.SetDocShellRecalc(false);
2654 #endif
2656 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */