Coverage Report

Created: 2025-11-16 09:57

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