Coverage Report

Created: 2025-07-07 10:01

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