Coverage Report

Created: 2026-06-30 11:14

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