Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/inc/table.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <tools/gen.hxx>
23
#include <tools/color.hxx>
24
#include "attarray.hxx"
25
#include "column.hxx"
26
#include "colcontainer.hxx"
27
#include <sal/types.h>
28
#include "sortparam.hxx"
29
#include "types.hxx"
30
#include <formula/types.hxx>
31
#include "calcmacros.hxx"
32
#include <formula/errorcodes.hxx>
33
#include "document.hxx"
34
#include "drwlayer.hxx"
35
#include "SparklineList.hxx"
36
#include "SolverSettings.hxx"
37
#include "markdata.hxx"
38
#include "FilterData.hxx"
39
#include <algorithm>
40
#include <atomic>
41
#include <memory>
42
#include <optional>
43
#include <set>
44
#include <vector>
45
46
template <typename A, typename D> class ScBitMaskCompressedArray;
47
template <typename A, typename D> class ScCompressedArray;
48
49
namespace utl {
50
    class TextSearch;
51
}
52
53
namespace com::sun::star {
54
    namespace sheet {
55
        struct TablePageBreakData;
56
    }
57
}
58
59
namespace formula { struct VectorRefArray; }
60
namespace sc {
61
62
struct BroadcasterState;
63
class StartListeningContext;
64
class EndListeningContext;
65
class CopyFromClipContext;
66
class CopyToClipContext;
67
class CopyToDocContext;
68
class MixDocContext;
69
class ColumnSpanSet;
70
class RangeColumnSpanSet;
71
class ColumnSet;
72
struct ColumnBlockPosition;
73
struct RefUpdateContext;
74
struct RefUpdateInsertTabContext;
75
struct RefUpdateDeleteTabContext;
76
struct RefUpdateMoveTabContext;
77
struct NoteEntry;
78
class DocumentStreamAccess;
79
class CellValues;
80
class TableValues;
81
class RowHeightContext;
82
class CompileFormulaContext;
83
struct SetFormulaDirtyContext;
84
class ColumnIterator;
85
class SheetViewManager;
86
}
87
88
class SfxItemSet;
89
class SfxStyleSheetBase;
90
class SvxBoxInfoItem;
91
class SvxBoxItem;
92
class SvxSearchItem;
93
94
class ScAutoFormatData;
95
class ScEditDataArray;
96
class ScFormulaCell;
97
class ScOutlineTable;
98
class ScPrintSaverTab;
99
class ScProgress;
100
class ScRangeList;
101
class ScSheetEvents;
102
class ScConditionalFormat;
103
class ScConditionalFormatList;
104
class ScStyleSheet;
105
class ScTableProtection;
106
class ScUserListData;
107
struct RowInfo;
108
class ScFunctionData;
109
class CollatorWrapper;
110
class ScFlatUInt16RowSegments;
111
class ScFlatBoolRowSegments;
112
class ScFlatBoolColSegments;
113
struct ScSetStringParam;
114
struct ScColWidthParam;
115
class ScRangeName;
116
class ScDBData;
117
class ScPostIt;
118
struct ScInterpreterContext;
119
120
121
class ScColumnsRange final
122
{
123
 public:
124
    class Iterator final
125
    {
126
        SCCOL mCol;
127
    public:
128
        typedef std::bidirectional_iterator_tag iterator_category;
129
        typedef SCCOL value_type;
130
        typedef SCCOL difference_type;
131
        typedef const SCCOL* pointer;
132
        typedef SCCOL reference;
133
134
252k
        explicit Iterator(SCCOL nCol) : mCol(nCol) {}
135
136
376M
        Iterator& operator++() { ++mCol; return *this;}
137
0
        Iterator& operator--() { --mCol; return *this;}
138
139
        // Comparing iterators from different containers is undefined, so comparing mCol is enough.
140
376M
        bool operator==(const Iterator & rOther) const {return mCol == rOther.mCol;}
141
376M
        SCCOL operator*() const {return mCol;}
142
    };
143
144
126k
    ScColumnsRange(SCCOL nBegin, SCCOL nEnd) : maBegin(nBegin), maEnd(nEnd) {}
145
126k
    const Iterator & begin() { return maBegin; }
146
126k
    const Iterator & end() { return maEnd; }
147
0
    std::reverse_iterator<Iterator> rbegin() { return std::reverse_iterator<Iterator>(maEnd); }
148
0
    std::reverse_iterator<Iterator> rend() { return std::reverse_iterator<Iterator>(maBegin); }
149
private:
150
    const Iterator maBegin;
151
    const Iterator maEnd;
152
};
153
154
template <typename T>
155
concept ColumnDataApply = std::is_invocable_v<T, ScColumnData&, SCROW, SCROW>;
156
157
class ScTable
158
{
159
private:
160
    typedef ::std::vector< ScRange > ScRangeVec;
161
162
    SCTAB           nTab;
163
    ScDocument&     rDocument;
164
165
    ScColContainer aCol;
166
167
    OUString aName;
168
    OUString aCodeName;
169
    OUString aComment;
170
171
    OUString        aLinkDoc;
172
    OUString        aLinkFlt;
173
    OUString        aLinkOpt;
174
    OUString        aLinkTab;
175
    sal_Int32       nLinkRefreshDelay;
176
    ScLinkMode      nLinkMode;
177
178
    // page style template
179
    OUString        aPageStyle;
180
    Size            aPageSizeTwips;                 // size of the print-page
181
    SCCOL           nRepeatStartX;                  // repeating rows/columns
182
    SCCOL           nRepeatEndX;                    // REPEAT_NONE, if not used
183
    SCROW           nRepeatStartY;
184
    SCROW           nRepeatEndY;
185
186
    // Standard row height for this sheet - benefits XLSX because default height defined per sheet
187
    sal_uInt16 mnOptimalMinRowHeight; // in Twips
188
189
    std::unique_ptr<ScTableProtection> pTabProtection;
190
191
    std::unique_ptr<ScCompressedArray<SCCOL, sal_uInt16>> mpColWidth;
192
    std::unique_ptr<ScFlatUInt16RowSegments> mpRowHeights;
193
194
    std::unique_ptr<ScBitMaskCompressedArray<SCCOL, CRFlags>> mpColFlags;
195
    std::unique_ptr<ScBitMaskCompressedArray< SCROW, CRFlags>> pRowFlags;
196
197
    FilterData maFilterData;
198
199
    ::std::set<SCROW>                      maRowPageBreaks;
200
    ::std::set<SCROW>                      maRowManualBreaks;
201
    ::std::set<SCCOL>                      maColPageBreaks;
202
    ::std::set<SCCOL>                      maColManualBreaks;
203
204
    std::unique_ptr<ScOutlineTable> pOutlineTable;
205
206
    std::unique_ptr<ScSheetEvents>  pSheetEvents;
207
208
    mutable SCCOL nTableAreaX;
209
    mutable SCROW nTableAreaY;
210
    mutable SCCOL nTableAreaVisibleX;
211
    mutable SCROW nTableAreaVisibleY;
212
213
    std::unique_ptr<utl::TextSearch> pSearchText;
214
215
    mutable OUString aUpperName;             // #i62977# filled only on demand, reset in SetName
216
217
    // sort parameter to minimize stack size of quicksort
218
    ScSortParam     aSortParam;
219
    CollatorWrapper*    pSortCollator;
220
221
    ScRangeVec      aPrintRanges;
222
223
    std::optional<ScRange> moRepeatColRange;
224
    std::optional<ScRange> moRepeatRowRange;
225
226
    sal_uInt16          nLockCount;
227
228
    std::unique_ptr<ScRangeList> pScenarioRanges;
229
    Color           aScenarioColor;
230
    Color           aTabBgColor;
231
    ScScenarioFlags nScenarioFlags;
232
    std::unique_ptr<ScDBData> pDBDataNoName;
233
    mutable std::unique_ptr<ScRangeName> mpRangeName;
234
235
    std::unique_ptr<ScConditionalFormatList> mpCondFormatList;
236
    sc::SparklineList maSparklineList;
237
238
    ScAddress       maLOKFreezeCell;
239
240
    bool            bScenario:1;
241
    bool            bLayoutRTL:1;
242
    bool            bLoadingRTL:1;
243
    bool            bPageSizeValid:1;
244
    mutable bool    bTableAreaValid:1;
245
    mutable bool    bTableAreaVisibleValid:1;
246
    bool            bVisible:1;
247
    bool            bPendingRowHeights:1;
248
    bool            bCalcNotification:1;
249
    bool            bGlobalKeepQuery:1;
250
    bool            bPrintEntireSheet:1;
251
    bool            bActiveScenario:1;
252
    bool            mbPageBreaksValid:1;
253
    bool            mbForceBreaks:1;
254
    bool            mbTotalsRowBelow:1;
255
256
    sc::SheetViewID mnSheetViewID = sc::InvalidSheetViewID;
257
    ScTable* mpSheetViewFor = nullptr;
258
259
    /** this is touched from formula group threading context */
260
    std::atomic<bool> bStreamValid;
261
262
    // Solver settings in current tab
263
    std::shared_ptr<sc::SolverSettings> m_pSolverSettings;
264
265
    // Default attributes for the unallocated columns.
266
    ScColumnData    aDefaultColData;
267
268
    std::shared_ptr<sc::SheetViewManager> mpSheetViewManager;
269
270
friend class ScDocument;                    // for FillInfo
271
friend class ScColumn;
272
friend class ScValueIterator;
273
friend class ScHorizontalValueIterator;
274
friend class ScDBQueryDataIterator;
275
friend class ScFormulaGroupIterator;
276
friend class ScCellIterator;
277
template< ScQueryCellIteratorAccess accessType, ScQueryCellIteratorType queryType >
278
friend class ScQueryCellIteratorBase;
279
template< ScQueryCellIteratorAccess accessType >
280
friend class ScQueryCellIteratorAccessSpecific;
281
friend class ScHorizontalCellIterator;
282
friend class ScColumnTextWidthIterator;
283
friend class ScDocumentImport;
284
friend class sc::DocumentStreamAccess;
285
friend class sc::ColumnSpanSet;
286
friend class sc::RangeColumnSpanSet;
287
friend class sc::EditTextIterator;
288
friend class sc::FormulaGroupAreaListener;
289
friend class sc::TableContentCopier;
290
291
public:
292
                ScTable( ScDocument& rDoc, SCTAB nNewTab, const OUString& rNewName,
293
                         bool bColInfo = true, bool bRowInfo = true );
294
                ~ScTable();
295
                ScTable(const ScTable&) = delete;
296
    ScTable&    operator=(const ScTable&) = delete;
297
298
314M
    ScDocument& GetDoc() { return rDocument;}
299
754M
    const ScDocument& GetDoc() const { return rDocument;}
300
1.14M
    SCTAB GetTab() const { return nTab; }
301
302
43.1k
    ScOutlineTable* GetOutlineTable()               { return pOutlineTable.get(); }
303
304
    ScColumn& CreateColumnIfNotExists( const SCCOL nScCol )
305
73.1M
    {
306
73.1M
        if ( nScCol >= aCol.size() )
307
7.95M
            CreateColumnIfNotExistsImpl(nScCol);
308
73.1M
        return aCol[nScCol];
309
73.1M
    }
310
    // out-of-line the cold part of the function
311
    void CreateColumnIfNotExistsImpl( const SCCOL nScCol );
312
313
94.6M
    const ScColumnData& GetColumnData( SCCOL nCol ) const { return nCol < aCol.size() ? aCol[ nCol ] : aDefaultColData; }
314
36.3k
    ScColumnData& GetColumnData( SCCOL nCol ) { return nCol < aCol.size() ? aCol[ nCol ] : aDefaultColData; }
315
316
    sal_uInt64      GetCellCount() const;
317
    sal_uInt64      GetWeightedCount() const;
318
    sal_uInt64      GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
319
    sal_uInt64      GetCodeCount() const;       // RPN code in formula
320
321
    sal_uInt16 GetTextWidth(SCCOL nCol, SCROW nRow) const;
322
323
    bool        SetOutlineTable( const ScOutlineTable* pNewOutline );
324
    void        StartOutlineTable();
325
326
    void        DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
327
328
    bool        TestRemoveSubTotals( const ScSubTotalParam& rParam );
329
    void        RemoveSubTotals( ScSubTotalParam& rParam );
330
    void        RemoveSimpleSubTotals( ScSubTotalParam& rParam, const ScSubTotalParam& rOldParam );
331
    bool        DoSubTotals( ScSubTotalParam& rParam );
332
    bool        DoSimpleSubTotals( ScSubTotalParam& rParam );
333
334
710k
    const ScSheetEvents* GetSheetEvents() const              { return pSheetEvents.get(); }
335
    void        SetSheetEvents( std::unique_ptr<ScSheetEvents> pNew );
336
337
3.48k
    bool        IsVisible() const                            { return bVisible; }
338
    void        SetVisible( bool bVis );
339
340
136k
    bool        IsStreamValid() const                        { return bStreamValid; }
341
    void        SetStreamValid( bool bSet, bool bIgnoreLock = false );
342
343
    [[nodiscard]] bool IsColValid( const SCCOL nScCol ) const
344
12.9M
    {
345
12.9M
        return nScCol >= static_cast< SCCOL >( 0 ) && nScCol < aCol.size();
346
12.9M
    }
347
    [[nodiscard]] bool IsColRowValid( const SCCOL nScCol, const SCROW nScRow ) const
348
2.87M
    {
349
2.87M
        return IsColValid( nScCol ) && GetDoc().ValidRow( nScRow );
350
2.87M
    }
351
    [[nodiscard]] bool IsColRowTabValid( const SCCOL nScCol, const SCROW nScRow, const SCTAB nScTab ) const
352
0
    {
353
0
        return IsColValid( nScCol ) && GetDoc().ValidRow( nScRow ) && ValidTab( nScTab );
354
0
    }
355
555M
    [[nodiscard]] bool ValidCol(SCCOL nCol) const { return GetDoc().ValidCol(nCol); }
356
70.9M
    [[nodiscard]] bool ValidRow(SCROW nRow) const { return GetDoc().ValidRow(nRow); }
357
125M
    [[nodiscard]] bool ValidColRow(SCCOL nCol, SCROW nRow) const { return GetDoc().ValidColRow(nCol, nRow); }
358
359
1.10k
    bool        IsPendingRowHeights() const                  { return bPendingRowHeights; }
360
    void        SetPendingRowHeights( bool bSet );
361
362
0
    bool        GetCalcNotification() const                  { return bCalcNotification; }
363
    void        SetCalcNotification( bool bSet );
364
365
316k
    bool        IsLayoutRTL() const                          { return bLayoutRTL; }
366
737
    bool        IsLoadingRTL() const                         { return bLoadingRTL; }
367
    void        SetLayoutRTL( bool bSet );
368
    void        SetLoadingRTL( bool bSet );
369
370
622k
    bool        IsScenario() const                           { return bScenario; }
371
    void        SetScenario( bool bFlag );
372
160
    void        GetScenarioComment( OUString& rComment) const  { rComment = aComment; }
373
2.48k
    void        SetScenarioComment( const OUString& rComment ) { aComment = rComment; }
374
160
    const Color& GetScenarioColor() const                    { return aScenarioColor; }
375
2.48k
    void         SetScenarioColor(const Color& rNew)         { aScenarioColor = rNew; }
376
16
    const Color& GetTabBgColor() const                       { return aTabBgColor; }
377
    void         SetTabBgColor(const Color& rColor);
378
168
    ScScenarioFlags GetScenarioFlags() const                 { return nScenarioFlags; }
379
2.48k
    void        SetScenarioFlags(ScScenarioFlags nNew)       { nScenarioFlags = nNew; }
380
2.27k
    void        SetActiveScenario(bool bSet)                 { bActiveScenario = bSet; }
381
24
    bool        IsActiveScenario() const                     { return bActiveScenario; }
382
383
0
    ScLinkMode  GetLinkMode() const                          { return nLinkMode; }
384
0
    bool        IsLinked() const                             { return nLinkMode != ScLinkMode::NONE; }
385
0
    const OUString& GetLinkDoc() const                       { return aLinkDoc; }
386
0
    const OUString& GetLinkFlt() const                       { return aLinkFlt; }
387
0
    const OUString& GetLinkOpt() const                       { return aLinkOpt; }
388
0
    const OUString& GetLinkTab() const                       { return aLinkTab; }
389
0
    sal_Int32  GetLinkRefreshDelay() const                  { return nLinkRefreshDelay; }
390
391
    void        SetLink( ScLinkMode nMode, const OUString& rDoc, const OUString& rFlt,
392
                        const OUString& rOpt, const OUString& rTab, sal_Int32 nRefreshDelay );
393
394
    sal_Int64   GetHashCode () const;
395
396
1.93M
    const OUString& GetName() const { return aName; }
397
    void        SetName( const OUString& rNewName );
398
399
    void        SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData);
400
8.23k
    ScDBData*   GetAnonymousDBData() { return pDBDataNoName.get();}
401
0
    const ScDBData* GetAnonymousDBData() const { return pDBDataNoName.get(); }
402
403
30
    const OUString& GetCodeName() const { return aCodeName; }
404
21.4k
    void        SetCodeName( const OUString& rNewName ) { aCodeName = rNewName; }
405
406
0
    bool        GetTotalsRowBelow() const { return mbTotalsRowBelow; }
407
6
    void        SetTotalsRowBelow( bool bNewVal ) { mbTotalsRowBelow = bNewVal; }
408
409
    const OUString& GetUpperName() const;
410
411
531k
    const OUString&   GetPageStyle() const                    { return aPageStyle; }
412
    void            SetPageStyle( const OUString& rName );
413
    void            PageStyleModified( const OUString& rNewName );
414
415
    bool            IsProtected() const;
416
    void            SetProtection(const ScTableProtection* pProtect);
417
    const ScTableProtection* GetProtection() const;
418
    void            GetUnprotectedCells( ScRangeList& rRangeList ) const;
419
420
    bool            IsEditActionAllowed( sc::EditAction eAction, SCCOL nStartCol, SCROW nStartRow,
421
                                         SCCOL nEndCol, SCROW nEndRow ) const;
422
423
    Size            GetPageSize() const;
424
    void            SetPageSize( const Size& rSize );
425
    void            SetRepeatArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
426
427
    void        LockTable();
428
    void        UnlockTable();
429
430
    bool        IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2,
431
                        SCROW nRow2, bool* pOnlyNotBecauseOfMatrix = nullptr,
432
                        bool bNoMatrixAtAll = false ) const;
433
    bool        IsSelectionEditable( const ScMarkData& rMark,
434
                        bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
435
436
    bool        HasBlockMatrixFragment( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2,
437
                                        bool bNoMatrixAtAll = false ) const;
438
    bool        HasSelectionMatrixFragment( const ScMarkData& rMark ) const;
439
440
    // This also includes e.g. notes. Use IsEmptyData() for cell data only.
441
    bool        IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
442
    bool        IsNotesBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
443
444
    bool        SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
445
                           const ScSetStringParam * pParam = nullptr );
446
447
    bool SetEditText( SCCOL nCol, SCROW nRow, std::unique_ptr<EditTextObject> pEditText );
448
    void SetEditText( SCCOL nCol, SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
449
    SCROW GetFirstEditTextRow( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
450
451
    void SetEmptyCell( SCCOL nCol, SCROW nRow );
452
    void SetFormula(
453
        SCCOL nCol, SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram );
454
    void SetFormula(
455
        SCCOL nCol, SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram );
456
457
    SC_DLLPUBLIC const std::shared_ptr<sc::SolverSettings> & GetSolverSettings();
458
459
    // tdf#156815 Sets the solver settings object to nullptr to force reloading Solver settings the
460
    // next time the dialog is opened. This is required when sheets are renamed
461
1.84M
    void ResetSolverSettings() { m_pSolverSettings.reset(); }
462
463
    /**
464
     * Takes ownership of pCell
465
     *
466
     * @return pCell if it was successfully inserted, NULL otherwise. pCell
467
     *         is deleted automatically on failure to insert.
468
     */
469
    ScFormulaCell* SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell );
470
471
    bool SetFormulaCells( SCCOL nCol, SCROW nRow, std::vector<ScFormulaCell*>& rCells );
472
473
    bool HasFormulaCell( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 ) const;
474
475
    svl::SharedString GetSharedString( SCCOL nCol, SCROW nRow ) const;
476
477
    void        SetValue( SCCOL nCol, SCROW nRow, const double& rVal );
478
    void        SetValues( const SCCOL nCol, const SCROW nRow, const std::vector<double>& rVals );
479
    void        SetError( SCCOL nCol, SCROW nRow, FormulaError nError);
480
    SCSIZE      GetPatternCount( SCCOL nCol ) const;
481
    SCSIZE      GetPatternCount( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
482
    bool        ReservePatternCount( SCCOL nCol, SCSIZE nReserve );
483
484
    void        SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr );
485
    OUString    GetString( SCCOL nCol, SCROW nRow, ScInterpreterContext* pContext = nullptr ) const;
486
    double*     GetValueCell( SCCOL nCol, SCROW nRow );
487
    // Note that if pShared is set and a value is returned that way, the returned OUString is empty.
488
    OUString    GetInputString( SCCOL nCol, SCROW nRow, bool bForceSystemLocale = false ) const;
489
    double      GetValue( SCCOL nCol, SCROW nRow ) const;
490
    const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const;
491
    void RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
492
    OUString GetFormula( SCCOL nCol, SCROW nRow ) const;
493
    const ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ) const;
494
    ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow );
495
496
    CellType    GetCellType( SCCOL nCol, SCROW nRow ) const;
497
    ScRefCellValue GetCellValue( SCCOL nCol, sc::ColumnBlockPosition& rBlockPos, SCROW nRow );
498
    ScRefCellValue GetCellValue( SCCOL nCol, SCROW nRow ) const;
499
500
    void        GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const;
501
    void        GetLastDataPos(SCCOL& rCol, SCROW& rRow) const;
502
503
    // Sparklines
504
505
    std::shared_ptr<sc::Sparkline> GetSparkline(SCCOL nCol, SCROW nRow);
506
    sc::Sparkline* CreateSparkline(SCCOL nCol, SCROW nRow, std::shared_ptr<sc::SparklineGroup> const& pSparklineGroup);
507
    bool DeleteSparkline(SCCOL nCol, SCROW nRow);
508
509
    sc::SparklineList& GetSparklineList();
510
    void CopySparklinesToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab);
511
    void FillSparkline(bool bVertical, SCCOLROW nFixed, SCCOLROW nIteratingStart, SCCOLROW nIteratingEnd, SCCOLROW nFillStart, SCCOLROW nFillEnd);
512
513
    // Notes / Comments
514
    std::unique_ptr<ScPostIt> ReleaseNote( SCCOL nCol, SCROW nRow );
515
    ScPostIt*                 GetNote( SCCOL nCol, SCROW nRow );
516
    void                      SetNote( SCCOL nCol, SCROW nRow, std::unique_ptr<ScPostIt> pNote );
517
518
    size_t GetNoteCount( SCCOL nCol ) const;
519
    SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const;
520
    void CreateAllNoteCaptions();
521
    void ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bPreserveData );
522
    void CommentNotifyAddressChange(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
523
524
    void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
525
    void GetNotesInRange( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes ) const;
526
    CommentCaptionState GetAllNoteCaptionsState( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes );
527
    bool ContainsNotesInRange( const ScRange& rRange ) const;
528
529
    bool TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ) const;
530
    void        InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize );
531
    void DeleteRow(
532
        const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize,
533
        bool* pUndoOutline, std::vector<ScAddress>* pGroupPos );
534
535
    bool        TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const;
536
    void InsertCol(
537
        const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize );
538
    void DeleteCol(
539
        const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize, bool* pUndoOutline );
540
541
    void DeleteArea(
542
        SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, InsertDeleteFlags nDelFlag,
543
        bool bBroadcast = true, sc::ColumnSpanSet* pBroadcastSpans = nullptr );
544
545
    void CopyToClip( sc::CopyToClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTable );
546
    void CopyToClip( sc::CopyToClipContext& rCxt, const ScRangeList& rRanges, ScTable* pTable );
547
548
    void CopyStaticToDocument(
549
        SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const SvNumberFormatterMergeMap& rMap,
550
        ScTable* pDestTab );
551
552
    void CopyCellToDocument( SCCOL nSrcCol, SCROW nSrcRow, SCCOL nDestCol, SCROW nDestRow, ScTable& rDestTab );
553
554
    bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol );
555
556
    void DeleteBeforeCopyFromClip(
557
        sc::CopyFromClipContext& rCxt, const ScTable& rClipTab, sc::ColumnSpanSet& rBroadcastSpans );
558
559
    void CopyOneCellFromClip(
560
        sc::CopyFromClipContext& rCxt, const SCCOL nCol1, const SCROW nRow1,
561
        const SCCOL nCol2, const SCROW nRow2,
562
        const SCROW nSrcRow, const ScTable* pSrcTab );
563
564
    void CopyFromClip(
565
        sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
566
        SCCOL nDx, SCROW nDy, ScTable* pTable );
567
568
    void StartListeningFormulaCells(
569
        sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt,
570
        SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
571
572
    void SetDirtyFromClip(
573
        SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans );
574
575
    void CopyToTable(
576
        sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
577
        InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab,
578
        const ScMarkData* pMarkData, bool bAsLink, bool bColRowFlags,
579
        ScCloneFlags nCloneFlags, bool bCopyCaptions );
580
581
    void CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab, bool bCloneCaption );
582
583
    void UndoToTable(
584
        sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
585
        InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab );
586
587
    void        CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
588
                            SCCOL nDx, SCROW nDy, const ScTable* pTable);
589
    /**
590
     * @param nCombinedStartRow start row of the combined range;
591
     * used for transposed multi range selection with row direction;
592
     * for other cases than multi range row selection this it equal to nRow1
593
     * @param nRowDestOffset adjustment of destination row position;
594
     * used for transposed multi range selection with row direction, otherwise 0
595
     */
596
    void TransposeClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCROW nCombinedStartRow,
597
                       SCROW nRowDestOffset, ScTable* pTransClip, InsertDeleteFlags nFlags,
598
                       bool bAsLink, bool bIncludeFiltered);
599
600
    // mark of this document
601
    void MixMarked(
602
        sc::MixDocContext& rCxt, const ScMarkData& rMark, ScPasteFunc nFunction,
603
        bool bSkipEmpty, const ScTable* pSrcTab );
604
605
    void MixData(
606
        sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
607
        ScPasteFunc nFunction, bool bSkipEmpty, const ScTable* pSrcTab );
608
609
    void        CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
610
                            SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab );
611
612
    void        CopyScenarioFrom( const ScTable* pSrcTab );
613
    void        CopyScenarioTo( ScTable* pDestTab ) const;
614
    bool        TestCopyScenarioTo( const ScTable* pDestTab ) const;
615
    void        MarkScenarioIn(ScMarkData& rMark, ScScenarioFlags nNeededBits) const;
616
    bool        HasScenarioRange( const ScRange& rRange ) const;
617
    void        InvalidateScenarioRanges();
618
    const ScRangeList* GetScenarioRanges() const;
619
620
    void        CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const;
621
622
    void        InvalidateTableArea();
623
    void        InvalidatePageBreaks();
624
625
    bool        GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const;            // FALSE = empty
626
    bool        GetTableArea( SCCOL& rEndCol, SCROW& rEndRow, bool bCalcHiddens = false) const;
627
    bool        GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes, bool bCalcHiddens = false) const;
628
    bool        GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow,
629
                                SCCOL& rEndCol ) const;
630
    bool        GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
631
                                SCROW& rEndRow, bool bNotes ) const;
632
633
    bool        GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const;
634
635
    void        ExtendPrintArea( OutputDevice* pDev,
636
                        SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow );
637
638
    void        GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
639
                             bool bIncludeOld, bool bOnlyDown ) const;
640
641
    bool        GetDataAreaSubrange( ScRange& rRange ) const;
642
643
    bool        ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow,
644
                                      SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
645
                                      bool bStickyTopRow, bool bStickyLeftCol,
646
                                      ScDataAreaExtras* pDataAreaExtras ) const;
647
648
    SCROW       GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow,
649
                                ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
650
651
    bool        IsEmptyData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow) const;
652
    SCSIZE      GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
653
                                        SCCOL nEndCol, SCROW nEndRow, ScDirection eDir ) const;
654
655
    void        FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection ) const;
656
    void        GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY,
657
                            bool bMarked, bool bUnprotected, const ScMarkData& rMark, SCCOL nTabStartCol ) const;
658
659
    bool        SkipRow( const SCCOL rCol, SCROW& rRow, const SCROW nMovY, const ScMarkData& rMark,
660
                         const bool bUp, const SCROW nUsedY, const bool bMarked, const bool bSheetProtected ) const;
661
    void        LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
662
663
    bool        HasData( SCCOL nCol, SCROW nRow ) const;
664
    bool        HasStringData( SCCOL nCol, SCROW nRow ) const;
665
    bool        HasValueData( SCCOL nCol, SCROW nRow ) const;
666
    bool        HasStringCells( SCCOL nStartCol, SCROW nStartRow,
667
                                SCCOL nEndCol, SCROW nEndRow ) const;
668
669
    sc::MultiDataCellState HasMultipleDataCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
670
671
    FormulaError    GetErrCode( const ScAddress& rPos ) const
672
88
                    {
673
88
                        return IsColRowValid(rPos.Col(),rPos.Row()) ?
674
88
                            aCol[rPos.Col()].GetErrCode( rPos.Row() ) :
675
88
                            FormulaError::NONE;
676
88
                    }
677
678
    void        ResetChanged( const ScRange& rRange );
679
680
    void CheckVectorizationState();
681
    void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
682
    void        SetDirty( const ScRange&, ScColumn::BroadcastMode );
683
    void        SetDirtyAfterLoad();
684
    void        SetDirtyVar();
685
    void        SetTableOpDirty( const ScRange& );
686
    void        CalcAll();
687
    void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening );
688
    void CompileAll( sc::CompileFormulaContext& rCxt );
689
    void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress );
690
691
    /** Broadcast single broadcasters in range, without explicitly setting
692
        anything dirty, not doing area broadcasts.
693
        @param rHint address is modified to adapt to the actual broadcasted
694
                position on each iteration and upon return points to the last
695
                position broadcasted. */
696
    bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SfxHintId nHint );
697
698
    bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode );
699
700
    void UpdateReference(
701
        sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr,
702
        bool bIncludeDraw = true, bool bUpdateNoteCaptionPos = true );
703
704
    void        UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
705
                                    SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
706
                                    SCCOL nDx, SCROW nDy, SCTAB nDz, bool bUpdateNoteCaptionPos = true );
707
708
    void        UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
709
                                    ScDocument* pUndoDoc );
710
711
    void        UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
712
713
    void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
714
    void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
715
    void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo, ScProgress* pProgress );
716
    void        UpdateCompile( bool bForceIfNameInUse = false );
717
    void        SetTabNo(SCTAB nNewTab);
718
    void        FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
719
                                 sc::UpdatedRangeNames& rIndexes) const;
720
    void        Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
721
                        sal_uInt64 nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
722
                        double nStepValue, const tools::Duration& rDurationStep,
723
                        double nMaxValue, ScProgress* pProgress);
724
    OUString    GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
725
726
    void UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& rMark );
727
728
    void        AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
729
                                    sal_uInt16 nFormatNo, ScProgress* pProgress );
730
    bool        SearchAndReplace(
731
        const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark,
732
        ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc, bool& bMatchedRangesWereClamped);
733
734
    void        FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 );
735
736
    bool        HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, HasAttrFlags nMask ) const;
737
    bool        HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask ) const;
738
    bool        HasAttrib( SCCOL nCol, SCROW nRow, HasAttrFlags nMask,
739
                           SCROW* nStartRow = nullptr, SCROW* nEndRow = nullptr ) const;
740
    bool IsMerged( SCCOL nCol, SCROW nRow ) const;
741
    bool        ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
742
                                SCCOL& rEndCol, SCROW& rEndRow,
743
                                bool bRefresh );
744
    void SetMergedCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
745
746
    const SfxPoolItem*      GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) const;
747
    template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, TypedWhichId<T> nWhich ) const
748
0
    {
749
0
        return static_cast<const T*>(GetAttr(nCol, nRow, sal_uInt16(nWhich)));
750
0
    }
Unexecuted instantiation: ScMergeFlagAttr const* ScTable::GetAttr<ScMergeFlagAttr>(short, int, TypedWhichId<ScMergeFlagAttr>) const
Unexecuted instantiation: SfxUInt32Item const* ScTable::GetAttr<SfxUInt32Item>(short, int, TypedWhichId<SfxUInt32Item>) const
751
    const SfxPoolItem*      GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich, SCROW& nStartRow, SCROW& nEndRow ) const;
752
    template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, TypedWhichId<T> nWhich, SCROW& nStartRow, SCROW& nEndRow ) const
753
    {
754
        return static_cast<const T*>(GetAttr(nCol, nRow, sal_uInt16(nWhich), nStartRow, nEndRow));
755
    }
756
    const ScPatternAttr*    GetPattern( SCCOL nCol, SCROW nRow ) const;
757
    const ScPatternAttr*    GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
758
759
    sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& rPos ) const;
760
    sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow ) const;
761
    sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
762
763
    void SetNumberFormat( SCCOL nCol, SCROW nRow, sal_uInt32 nNumberFormat );
764
765
    void                    MergeSelectionPattern( ScMergePatternState& rState,
766
                                                const ScMarkData& rMark, bool bDeep ) const;
767
    void                    MergePatternArea( ScMergePatternState& rState, SCCOL nCol1, SCROW nRow1,
768
                                                SCCOL nCol2, SCROW nRow2, bool bDeep ) const;
769
    void                    MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
770
                                            ScLineFlags& rFlags,
771
                                            SCCOL nStartCol, SCROW nStartRow,
772
                                            SCCOL nEndCol, SCROW nEndRow ) const;
773
    void                    ApplyBlockFrame(const SvxBoxItem& rLineOuter,
774
                                            const SvxBoxInfoItem* pLineInner,
775
                                            SCCOL nStartCol, SCROW nStartRow,
776
                                            SCCOL nEndCol, SCROW nEndRow );
777
778
    void        ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr );
779
    void        ApplyPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
780
    void        ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
781
                                  const ScPatternAttr& rAttr, ScEditDataArray* pDataArray = nullptr,
782
                                  bool* const pIsChanged = nullptr );
783
    void        SetAttrEntries( SCCOL nStartCol, SCCOL nEndCol, std::vector<ScAttrEntry> && vNewData);
784
785
    void        SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr );
786
    void        SetPattern( SCCOL nCol, SCROW nRow, const CellAttributeHolder& rHolder );
787
    void        SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
788
    void        ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
789
                            const ScPatternAttr& rPattern, SvNumFormatType nNewType );
790
    void        AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
791
    void        RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
792
    void        SetPatternAreaCondFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow,
793
                    const ScPatternAttr& rAttr, const ScCondFormatIndexes& rCondFormatIndexes );
794
795
    void        ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet* rStyle );
796
    void        ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle );
797
    void        ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
798
    void        ApplySelectionLineStyle( const ScMarkData& rMark,
799
                                    const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
800
801
    const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow ) const;
802
    const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
803
    const ScStyleSheet* GetAreaStyle( bool& rFound, SCCOL nCol1, SCROW nRow1,
804
                                                    SCCOL nCol2, SCROW nRow2 ) const;
805
806
    void        StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
807
                                    OutputDevice* pDev,
808
                                    double nPPTX, double nPPTY,
809
                                    double fZoomX, double fZoomY );
810
811
    bool        IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
812
813
    bool        ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
814
    bool        RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
815
816
    void        ApplySelectionCache( ScItemPoolCache& rCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
817
    void        DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
818
819
    void        ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
820
    void        ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
821
822
1.15k
    const std::optional<ScRange>& GetRepeatColRange() const { return moRepeatColRange; }
823
1.50k
    const std::optional<ScRange>& GetRepeatRowRange() const { return moRepeatRowRange; }
824
    void            SetRepeatColRange( std::optional<ScRange> oNew );
825
    void            SetRepeatRowRange( std::optional<ScRange> oNew );
826
827
4.36k
    sal_uInt16          GetPrintRangeCount() const          { return static_cast< sal_uInt16 >( aPrintRanges.size() ); }
828
    const ScRange*  GetPrintRange(sal_uInt16 nPos) const;
829
    /** Returns true, if the sheet is always printed. */
830
3.15k
    bool            IsPrintEntireSheet() const          { return bPrintEntireSheet; }
831
832
    /** Removes all print ranges. */
833
    void            ClearPrintRanges();
834
    /** Adds a new print ranges. */
835
    void            AddPrintRange( const ScRange& rNew );
836
837
    // Removes all named ranges used for print ranges
838
    void            ClearPrintNamedRanges();
839
840
    /** Marks the specified sheet to be printed completely. Deletes old print ranges! */
841
    void            SetPrintEntireSheet();
842
843
    void            FillPrintSaver( ScPrintSaverTab& rSaveTab ) const;
844
    void            RestorePrintRanges( const ScPrintSaverTab& rSaveTab );
845
846
    sal_uInt16      GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev,
847
                                    double nPPTX, double nPPTY,
848
                                    double fZoomX, double fZoomY,
849
                                    bool bFormula, const ScMarkData* pMarkData,
850
                                    const ScColWidthParam* pParam );
851
    bool SetOptimalHeight(
852
        sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, bool bApi,
853
        ScProgress* pOuterProgress = nullptr, sal_uInt64 nProgressStart = 0 );
854
855
    void SetOptimalHeightOnly(
856
        sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
857
        ScProgress* pOuterProgress = nullptr, sal_uInt64 nProgressStart = 0 );
858
859
    tools::Long        GetNeededSize( SCCOL nCol, SCROW nRow,
860
                                    OutputDevice* pDev,
861
                                    double nPPTX, double nPPTY,
862
                                    double fZoomX, double fZoomY,
863
                                    bool bWidth, bool bTotalSize,
864
                                    bool bInPrintTwips = false);
865
    void        SetColWidth( SCCOL nCol, sal_uInt16 nNewWidth );
866
    void        SetColWidthOnly( SCCOL nCol, sal_uInt16 nNewWidth );
867
    void        SetRowHeight( SCROW nRow, sal_uInt16 nNewHeight );
868
    bool        SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight,
869
                                   double nPPTY, bool bApi );
870
871
    /**
872
     * Set specified row height to specified ranges.  Don't check for drawing
873
     * objects etc.  Just set the row height.  Nothing else.
874
     *
875
     * Note that setting a new row height via this function will not
876
     * invalidate page breaks.
877
     */
878
    void        SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight );
879
880
                        // nPPT to test for modification
881
    void        SetManualHeight( SCROW nStartRow, SCROW nEndRow, bool bManual );
882
883
    sal_uInt16 GetOptimalMinRowHeight() const
884
1.66M
    {
885
1.66M
        if (!mnOptimalMinRowHeight)
886
709k
            return ScGlobal::nStdRowHeight;
887
955k
        return mnOptimalMinRowHeight;
888
1.66M
    };
889
5.65k
    void SetOptimalMinRowHeight(sal_uInt16 nSet) { mnOptimalMinRowHeight = nSet; }
890
891
    sal_uInt16      GetColWidth( SCCOL nCol, bool bHiddenAsZero = true ) const;
892
    tools::Long     GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const;
893
    sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const;
894
    tools::Long     GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true ) const;
895
    tools::Long     GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const;
896
    tools::Long     GetColOffset( SCCOL nCol, bool bHiddenAsZero = true ) const;
897
    tools::Long     GetRowOffset( SCROW nRow, bool bHiddenAsZero = true ) const;
898
899
    /**
900
     * Get the last row such that the height of row 0 to the end row is as
901
     * high as possible without exceeding the specified height value.
902
     *
903
     * @param nHeight maximum desired height
904
     *
905
     * @return SCROW last row of the range within specified height.
906
     */
907
    SCROW       GetRowForHeight(tools::Long nHeight) const;
908
    /**
909
     * Given the height i.e. total vertical distance from the top of the sheet
910
     * grid, return the first visible row whose top position is below the
911
     * specified height.
912
     * Note that this variant uses pixels, not twips.
913
     * @param nStartRow the row to start searching at.
914
     * @param rStartRowHeightPx this is both the height at nStartRow, and returns the height of the first row
915
     *        which has height > nHeight
916
     */
917
    SCROW       GetRowForHeightPixels( SCROW nStartRow, tools::Long& rStartRowHeightPx, tools::Long nHeightPx, double fPPTY ) const;
918
919
    sal_uInt16      GetOriginalWidth( SCCOL nCol ) const;
920
    sal_uInt16      GetOriginalHeight( SCROW nRow ) const;
921
922
    sal_uInt16      GetCommonWidth( SCCOL nEndCol ) const;
923
924
    SCROW       GetHiddenRowCount( SCROW nRow ) const;
925
926
    void        ShowCol(SCCOL nCol, bool bShow);
927
    void        ShowRow(SCROW nRow, bool bShow);
928
    void        DBShowRow(SCROW nRow, bool bShow);
929
930
    void        ShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
931
    void        DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
932
933
    void        SetRowFlags( SCROW nRow, CRFlags nNewFlags );
934
    void        SetRowFlags( SCROW nStartRow, SCROW nEndRow, CRFlags nNewFlags );
935
936
                /// @return  the index of the last row with any set flags (auto-pagebreak is ignored).
937
    SCROW      GetLastFlaggedRow() const;
938
939
    /// @return  the index of the last changed column (flags and column width, auto pagebreak is ignored).
940
    SCCOL      GetLastChangedColFlagsWidth() const;
941
    /// @return  the index of the last changed row (flags and row height, auto pagebreak is ignored).
942
    SCROW      GetLastChangedRowFlagsWidth() const;
943
944
    bool       IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SCROW nRowEnd) const;
945
    bool       IsDataFiltered(const ScRange& rRange) const;
946
    CRFlags    GetColFlags( SCCOL nCol ) const;
947
    CRFlags    GetRowFlags( SCROW nRow ) const;
948
949
    const ScBitMaskCompressedArray< SCROW, CRFlags> * GetRowFlagsArray() const
950
0
                    { return pRowFlags.get(); }
951
952
    bool        UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, bool bShow );
953
    bool        UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, bool bShow );
954
955
    void        UpdatePageBreaks( const ScRange* pUserArea );
956
    void        RemoveManualBreaks();
957
    bool        HasManualBreaks() const;
958
    void        SetRowManualBreaks( ::std::set<SCROW>&& rBreaks );
959
    void        SetColManualBreaks( ::std::set<SCCOL>&& rBreaks );
960
961
    void        GetAllRowBreaks(::std::set<SCROW>& rBreaks, bool bPage, bool bManual) const;
962
    void        GetAllColBreaks(::std::set<SCCOL>& rBreaks, bool bPage, bool bManual) const;
963
    bool        HasRowPageBreak(SCROW nRow) const;
964
    bool        HasColPageBreak(SCCOL nCol) const;
965
    bool        HasRowManualBreak(SCROW nRow) const;
966
    bool        HasColManualBreak(SCCOL nCol) const;
967
968
    /**
969
     * Get the row position of the next manual break that occurs at or below
970
     * specified row.  When no more manual breaks are present at or below
971
     * the specified row, -1 is returned.
972
     *
973
     * @param nRow row at which the search begins.
974
     *
975
     * @return SCROW next row position with manual page break, or -1 if no
976
     *         more manual breaks are present.
977
     */
978
    SCROW       GetNextManualBreak(SCROW nRow) const;
979
980
    void        RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow);
981
    void        RemoveRowBreak(SCROW nRow, bool bPage, bool bManual);
982
    void        RemoveColBreak(SCCOL nCol, bool bPage, bool bManual);
983
    void        SetRowBreak(SCROW nRow, bool bPage, bool bManual);
984
    void        SetColBreak(SCCOL nCol, bool bPage, bool bManual);
985
    css::uno::Sequence<
986
        css::sheet::TablePageBreakData> GetRowBreakData() const;
987
988
    void updateObjectsForColsChanged(SCCOL nStartCol, SCCOL nEndCol, bool bHidden, bool bChanged);
989
    void updateObjectsForRowsChanged(SCROW nStartRow, SCROW nEndRow, bool bHidden, bool bChanged);
990
991
    bool        RowHidden(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
992
    bool        RowHiddenLeaf(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
993
    bool        HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const;
994
    bool        ColHidden(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
995
    bool        SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden);
996
    void        SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden);
997
    void        CopyColHidden(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
998
    void        CopyRowHidden(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
999
    void        CopyRowHeight(const ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset);
1000
    SCROW       FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
1001
    SCROW       LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
1002
    SCROW       CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const;
1003
    tools::Long GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true) const;
1004
1005
    SCCOL       CountVisibleCols(SCCOL nStartCol, SCCOL nEndCol) const;
1006
1007
    SCCOLROW    LastHiddenColRow(SCCOLROW nPos, bool bCol) const;
1008
1009
485
    FilterData& getFilterData() { return maFilterData; }
1010
18.0k
    FilterData const& getFilterData() const { return maFilterData; }
1011
1012
    Color GetCellBackgroundColor(ScAddress aPos) const;
1013
    Color GetCellTextColor(ScAddress aPos) const;
1014
1015
    bool IsManualRowHeight(SCROW nRow) const;
1016
1017
    bool HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const;
1018
1019
    void        SyncColRowFlags();
1020
1021
    void        StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
1022
    void        ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
1023
1024
    /** Sort a range of data. */
1025
    void Sort(
1026
        const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
1027
        ScProgress* pProgress, sc::ReorderParam* pUndo );
1028
1029
    void Reorder( const sc::ReorderParam& rParam );
1030
1031
    // For ValidQuery() see ScQueryEvalutor class.
1032
    void        TopTenQuery( ScQueryParam& );
1033
    void        PrepareQuery( ScQueryParam& rQueryParam );
1034
    SCSIZE      Query(const ScQueryParam& rQueryParam, bool bKeepSub, bool bKeepTotals = false);
1035
    bool        CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1036
1037
    void GetFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, ScFilterEntries& rFilterEntries, bool bFiltering = false);
1038
    void GetFilteredFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScQueryParam& rParam, ScFilterEntries& rFilterEntries, bool bFiltering );
1039
    [[nodiscard]]
1040
    bool GetDataEntries(SCCOL nCol, SCROW nRow, std::set<ScTypedStrData>& rStrings);
1041
1042
    bool        HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
1043
    bool        HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
1044
1045
    sal_Int32   GetMaxStringLen( SCCOL nCol,
1046
                                    SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
1047
    sal_Int32  GetMaxNumberStringLen( sal_uInt16& nPrecision,
1048
                                       SCCOL nCol,
1049
                                       SCROW nRowStart, SCROW nRowEnd ) const;
1050
1051
    bool        IsSortCollatorGlobal() const;
1052
    void        InitSortCollator( const ScSortParam& rPar );
1053
    void        DestroySortCollator();
1054
    void        SetDrawPageSize( bool bResetStreamValid = true, bool bUpdateNoteCaptionPos = true,
1055
                                 const ScObjectHandling eObjectHandling = ScObjectHandling::RecalcPosMode);
1056
1057
    void SetRangeName(std::unique_ptr<ScRangeName> pNew);
1058
    SC_DLLPUBLIC ScRangeName* GetRangeName() const;
1059
1060
    void PreprocessRangeNameUpdate(
1061
        sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
1062
1063
    void CompileHybridFormula(
1064
        sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt );
1065
1066
    void PreprocessDBDataUpdate(
1067
        sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
1068
1069
    ScConditionalFormatList* GetCondFormList();
1070
    const ScConditionalFormatList* GetCondFormList() const;
1071
    void SetCondFormList( ScConditionalFormatList* pList );
1072
1073
    void DeleteConditionalFormat(sal_uLong nOldIndex);
1074
1075
    sal_uInt32          AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew );
1076
1077
    SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow ) const;
1078
    void SetScriptType( SCCOL nCol, SCROW nRow, SvtScriptType nType );
1079
    void UpdateScriptTypes( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 );
1080
1081
    SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
1082
1083
    formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol, SCROW nRow );
1084
    formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1085
    formula::VectorRefArray FetchVectorRefArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
1086
    bool HandleRefArrayForParallelism( SCCOL nCol, SCROW nRow1, SCROW nRow2,
1087
                                       const ScFormulaCellGroupRef& mxGroup, ScAddress* pDirtiedAddress );
1088
#ifdef DBG_UTIL
1089
    void AssertNoInterpretNeeded( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
1090
#endif
1091
1092
    void SplitFormulaGroups( SCCOL nCol, std::vector<SCROW>& rRows );
1093
    void UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows );
1094
    void RegroupFormulaCells( SCCOL nCol );
1095
1096
    ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
1097
    ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow, sc::ColumnBlockPosition& rBlockPos );
1098
1099
    SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow );
1100
    const SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow ) const;
1101
    void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
1102
    void DeleteEmptyBroadcasters();
1103
1104
    void FillMatrix( ScMatrix& rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool* pPool ) const;
1105
1106
    void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1107
    bool InterpretCellsIfNeeded( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1108
1109
    void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, size_t nLen );
1110
1111
    void CalculateInColumnInThread( ScInterpreterContext& rContext, SCCOL nColStart, SCCOL nColEnd,
1112
                                    SCROW nRowStart, SCROW nRowEnd, unsigned nThisThread, unsigned nThreadsTotal);
1113
    void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, ScInterpreter* pInterpreter);
1114
1115
    /**
1116
     * Either start all formula cells as listeners unconditionally, or start
1117
     * those that are marked "needs listening".
1118
     *
1119
     * @param rCxt context object.
1120
     * @param bAll when true, start all formula cells as listeners. When
1121
     *             false, only start those that are marked "needs listening".
1122
     */
1123
    void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
1124
1125
    /**
1126
     * Mark formula cells dirty that have the mbPostponedDirty flag set or
1127
     * contain named ranges with relative references.
1128
     */
1129
    void SetDirtyIfPostponed();
1130
1131
    /**
1132
     * Broadcast dirty formula cells that contain functions such as CELL(),
1133
     * COLUMN() or ROW() which may change its value on move.
1134
     */
1135
    void BroadcastRecalcOnRefMove();
1136
1137
    void TransferCellValuesTo( const SCCOL nCol, SCROW nRow, size_t nLen, sc::CellValues& rDest );
1138
    void CopyCellValuesFrom( const SCCOL nCol, SCROW nRow, const sc::CellValues& rSrc );
1139
1140
    std::optional<sc::ColumnIterator> GetColumnIterator( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
1141
1142
    bool EnsureFormulaCellResults( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2, bool bSkipRunning = false );
1143
1144
    void ConvertFormulaToValue(
1145
        sc::EndListeningContext& rCxt,
1146
        const SCCOL nCol1, const SCROW nRow1, const SCCOL nCol2, const SCROW nRow2,
1147
        sc::TableValues* pUndo );
1148
1149
    void SwapNonEmpty(
1150
        sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
1151
1152
    void finalizeOutlineImport();
1153
1154
    void StoreToCache(SvStream& rStrm) const;
1155
1156
    void RestoreFromCache(SvStream& rStrm);
1157
1158
#if DUMP_COLUMN_STORAGE
1159
    void DumpColumnStorage( SCCOL nCol ) const;
1160
#endif
1161
1162
    /** Replace behaves differently to the Search; adjust the rCol and rRow accordingly.
1163
1164
        'Replace' replaces at the 'current' position, but in order to achieve
1165
        that, we have to 'shift' the rCol / rRow to the 'previous' position -
1166
        what it is depends on various settings in rSearchItem.
1167
    */
1168
    static void UpdateSearchItemAddressForReplace( const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow );
1169
1170
    ScColumnsRange GetWritableColumnsRange(SCCOL begin, SCCOL end);
1171
    ScColumnsRange GetAllocatedColumnsRange(SCCOL begin, SCCOL end) const;
1172
    ScColumnsRange GetColumnsRange(SCCOL begin, SCCOL end) const;
1173
23.8k
    SCCOL ClampToAllocatedColumns(SCCOL nCol) const { return std::min(nCol, static_cast<SCCOL>(aCol.size() - 1)); }
1174
27.3M
    SCCOL GetAllocatedColumnsCount() const { return aCol.size(); }
1175
1176
    /**
1177
     * Serializes the sheet's geometry data.
1178
     *
1179
     * @param bColumns - if true it dumps the data for columns, else it does for rows.
1180
     * @param eGeomType indicates the type of data to be dumped for rows/columns.
1181
     * @return the serialization of the sheet's geometry data as an OString.
1182
     */
1183
    OString dumpSheetGeomData(bool bColumns, SheetGeomType eGeomType);
1184
1185
    std::set<SCCOL> QueryColumnsWithFormulaCells() const;
1186
1187
    void CheckIntegrity() const;
1188
1189
    void CollectBroadcasterState(sc::BroadcasterState& rState) const;
1190
1191
    std::shared_ptr<sc::SheetViewManager> const& GetSheetViewManager() const;
1192
1193
0
    bool IsSheetViewHolder() const { return bool(mpSheetViewFor); }
1194
1195
0
    ScTable* GetDefaultViewTable() const { return mpSheetViewFor; }
1196
1197
    sc::SheetViewID GetSheetViewID() const
1198
0
    {
1199
0
        return mnSheetViewID;
1200
0
    }
1201
1202
1203
    void SetSheetViewHolder(sc::SheetViewID nID, ScTable* pDefaultViewTable)
1204
0
    {
1205
0
        mnSheetViewID = nID;
1206
0
        mpSheetViewFor = pDefaultViewTable;
1207
0
    }
1208
1209
    void RemoveSheetViewTablePointer()
1210
0
    {
1211
0
        mpSheetViewFor = nullptr;
1212
0
    }
1213
1214
private:
1215
1216
    void ImplDestroy();
1217
1218
    void FillFormulaVertical(
1219
        const ScFormulaCell& rSrcCell,
1220
        SCCOLROW& rInner, SCCOL nCol, SCROW nRow1, SCROW nRow2,
1221
        ScProgress* pProgress, sal_uInt64& rProgress );
1222
1223
    void FillSeriesSimple(
1224
        const ScCellValue& rSrcCell, SCCOLROW& rInner, SCCOLROW nIMin, SCCOLROW nIMax,
1225
        const SCCOLROW& rCol, const SCCOLROW& rRow, bool bVertical, ScProgress* pProgress, sal_uInt64& rProgress );
1226
1227
    void FillAutoSimple(
1228
        SCCOLROW nISrcStart, SCCOLROW nISrcEnd, SCCOLROW nIStart, SCCOLROW nIEnd,
1229
        SCCOLROW& rInner, const SCCOLROW& rCol, const SCCOLROW& rRow,
1230
        sal_uInt64 nActFormCnt, sal_uInt64 nMaxFormCnt,
1231
        bool bHasFiltered, bool bVertical, bool bPositive,
1232
        ScProgress* pProgress, sal_uInt64& rProgress );
1233
1234
    void        FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1235
                                sal_uInt64 nFillCount, FillDir eFillDir, FillCmd eFillCmd,
1236
                                FillDateCmd eFillDateCmd,
1237
                                double nStepValue, const tools::Duration& rDurationStep,
1238
                                double nMaxValue, sal_uInt16 nMinDigits,
1239
                                bool bAttribs, ScProgress* pProgress,
1240
                                bool bSkipOverlappedCells = false,
1241
                                std::vector<sal_Int32>* pNonOverlappedCellIdx = nullptr);
1242
    void        FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1243
                                FillCmd& rCmd, FillDateCmd& rDateCmd,
1244
                                double& rInc, tools::Duration& rDuration, sal_uInt16& rMinDigits,
1245
                                ScUserListData*& rListData, sal_uInt16& rListIndex,
1246
                                bool bHasFiltered, bool& rSkipOverlappedCells,
1247
                                std::vector<sal_Int32>& rNonOverlappedCellIdx );
1248
    void        FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1249
                        sal_uInt64 nFillCount, FillDir eFillDir, ScProgress* pProgress );
1250
1251
    bool        ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
1252
                                bool bMarked, bool bUnprotected ) const;
1253
1254
    void        AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1255
                                const ScPatternAttr& rAttr, sal_uInt16 nFormatNo);
1256
    bool        SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow,
1257
                           const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1258
    bool        Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1259
                       const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1260
    bool        Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1261
                       SCCOL nLastCol, SCROW nLastRow,
1262
                       const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc,
1263
                       std::vector< sc::ColumnBlockConstPosition >& blockPos);
1264
    bool        SearchAll(const SvxSearchItem& rSearchItem, const ScMarkData& rMark,
1265
                          ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1266
    bool        Replace(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1267
                        const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1268
    bool        ReplaceAll(
1269
        const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1270
        OUString& rUndoStr, ScDocument* pUndoDoc, bool& bMatchedRangesWereClamped);
1271
1272
    bool        SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1273
                            const ScMarkData& rMark);
1274
    bool        ReplaceStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1275
                             const ScMarkData& rMark, bool bIsUndo);
1276
    bool        SearchAllStyle(
1277
        const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges);
1278
    bool        ReplaceAllStyle(
1279
        const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1280
        ScDocument* pUndoDoc);
1281
    bool        SearchAndReplaceEmptyCells(
1282
                    const SvxSearchItem& rSearchItem,
1283
                    SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1284
                    OUString& rUndoStr, ScDocument* pUndoDoc);
1285
    bool        SearchRangeForEmptyCell(const ScRange& rRange,
1286
                    const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1287
                    OUString& rUndoStr);
1288
    bool        SearchRangeForAllEmptyCells(
1289
        const ScRange& rRange, const SvxSearchItem& rSearchItem,
1290
        ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1291
1292
                                // use the global sort parameter:
1293
    bool        IsSorted(SCCOLROW nStart, SCCOLROW nEnd) const;
1294
    static void DecoladeRow( ScSortInfoArray*, SCROW nRow1, SCROW nRow2 );
1295
    short CompareCell(
1296
        sal_uInt16 nSort,
1297
        ScRefCellValue& rCell1, SCCOL nCell1Col, SCROW nCell1Row,
1298
        ScRefCellValue& rCell2, SCCOL nCell2Col, SCROW nCell2Row ) const;
1299
    short       Compare(SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1300
    short       Compare( ScSortInfoArray*, SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1301
    std::unique_ptr<ScSortInfoArray> CreateSortInfoArray( const sc::ReorderParam& rParam );
1302
    std::unique_ptr<ScSortInfoArray> CreateSortInfoArray(
1303
        const ScSortParam& rSortParam, SCCOLROW nInd1, SCCOLROW nInd2,
1304
        bool bKeepQuery, bool bUpdateRefs );
1305
    void        QuickSort( ScSortInfoArray*, SCCOLROW nLo, SCCOLROW nHi);
1306
    void        SortReorderByColumn( const ScSortInfoArray* pArray, SCROW nRow1, SCROW nRow2,
1307
                                     bool bPattern, ScProgress* pProgress );
1308
    void        SortReorderAreaExtrasByColumn( const ScSortInfoArray* pArray, SCROW nDataRow1, SCROW nDataRow2,
1309
                                               const ScDataAreaExtras& rDataAreaExtras, ScProgress* pProgress );
1310
1311
    void        SortReorderByRow( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2,
1312
                                  ScProgress* pProgress, bool bOnlyDataAreaExtras );
1313
    void        SortReorderByRowRefUpdate( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2,
1314
                                           ScProgress* pProgress );
1315
    void        SortReorderAreaExtrasByRow( ScSortInfoArray* pArray, SCCOL nDataCol1, SCCOL nDataCol2,
1316
                                            const ScDataAreaExtras& rDataAreaExtras, ScProgress* pProgress );
1317
1318
    bool        CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1319
    bool        CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1320
    OUString    GetUpperCellString(SCCOL nCol, SCROW nRow);
1321
1322
    bool        RefVisible(const ScFormulaCell* pCell);
1323
1324
    bool        IsEmptyLine(SCROW nRow, SCCOL nStartCol, SCCOL nEndCol) const;
1325
1326
    void        IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillDateCmd eCmd);
1327
    void FillFormula(
1328
        const ScFormulaCell* pSrcCell, SCCOL nDestCol, SCROW nDestRow, bool bLast );
1329
    void        UpdateInsertTabAbs(SCTAB nNewPos);
1330
    bool        GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, bool bInSel,
1331
                                    const ScMarkData& rMark) const;
1332
    bool        GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark ) const;
1333
    void        TestTabRefAbs(SCTAB nTable) const;
1334
    void CompileDBFormula( sc::CompileFormulaContext& rCxt );
1335
    void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt );
1336
1337
    void        StartListening( const ScAddress& rAddress, SvtListener* pListener );
1338
    void        EndListening( const ScAddress& rAddress, SvtListener* pListener );
1339
    void StartListening( sc::StartListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
1340
    void EndListening( sc::EndListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
1341
1342
    void AttachFormulaCells( sc::StartListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1343
    void DetachFormulaCells( sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1344
1345
    void        SetLoadingMedium(bool bLoading);
1346
1347
    struct FillMaxRotCacheMapHash
1348
    {
1349
        size_t operator()(const std::pair<const ScPatternAttr*, const SfxItemSet*>& rPair) const noexcept
1350
0
        {
1351
0
            return std::hash<const ScPatternAttr*>{}(rPair.first) ^ (std::hash<const SfxItemSet*>{}(rPair.second) << 1);
1352
0
        }
1353
    };
1354
    typedef std::unordered_map<std::pair<const ScPatternAttr*, const SfxItemSet*>, ScRotateDir, FillMaxRotCacheMapHash> FillMaxRotCacheMap;
1355
1356
    SCSIZE      FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2,
1357
                            SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY,
1358
                            const ScPatternAttr* pPattern, const SfxItemSet* pCondSet,
1359
                            FillMaxRotCacheMap* pCache);
1360
1361
    // idle calculation of OutputDevice text width for cell
1362
    // also invalidates script type, broadcasts for "calc as shown"
1363
    void        InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
1364
                                     bool bNumFormatChanged, bool bBroadcast );
1365
1366
    void        SkipFilteredRows(SCROW& rRow, SCROW& rLastNonFilteredRow, bool bForward);
1367
1368
    /**
1369
     * In case the cell text goes beyond the column width, move the max column
1370
     * position to the right.  This is called from ExtendPrintArea.
1371
     */
1372
    void        MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY);
1373
1374
    void        CopyPrintRange(const ScTable& rTable);
1375
1376
    SCCOL       FindNextVisibleColWithContent(SCCOL nCol, bool bRight, SCROW nRow) const;
1377
1378
    SCCOL       FindNextVisibleCol(SCCOL nCol, bool bRight) const;
1379
1380
    /**
1381
     * Transpose clipboard patterns
1382
     * @param nCombinedStartRow start row of the combined range;
1383
     * used for transposed multi range selection with row direction;
1384
     * for other cases than multi range row selection this is equal to nRow1
1385
     * @param nRowDestOffset adjustment of destination row position;
1386
     * used for transposed multi range row selections, otherwise 0
1387
     */
1388
    void TransposeColPatterns(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1,
1389
                              SCROW nRow2, SCROW nCombinedStartRow, bool bIncludeFiltered,
1390
                              const std::vector<SCROW>& rFilteredRows, SCROW nRowDestOffset);
1391
1392
    /**
1393
     * Transpose clipboard notes
1394
     * @param nCombinedStartRow start row of the combined range;
1395
     * used for transposed multi range selection with row direction;
1396
     * for other cases than multi range row selection this is equal to nRow1
1397
     * @param nRowDestOffset adjustment of destination row position;
1398
     * used for transposed multi range row selections, otherwise 0
1399
     */
1400
    void TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1, SCROW nRow2,
1401
                           SCROW nCombinedStartRow, bool bIncludeFiltered, SCROW nRowDestOffset);
1402
1403
    ScColumn* FetchColumn( SCCOL nCol );
1404
    const ScColumn* FetchColumn( SCCOL nCol ) const;
1405
1406
    void EndListeningIntersectedGroup(
1407
        sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow, std::vector<ScAddress>* pGroupPos );
1408
1409
    void EndListeningIntersectedGroups(
1410
        sc::EndListeningContext& rCxt, const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2,
1411
        std::vector<ScAddress>* pGroupPos );
1412
1413
    void EndListeningGroup( sc::EndListeningContext& rCxt, const SCCOL nCol, SCROW nRow );
1414
    void SetNeedsListeningGroup( SCCOL nCol, SCROW nRow );
1415
1416
    /// Returns list-of-spans representation of the column-widths/row-heights in twips encoded as an OString.
1417
    OString dumpColumnRowSizes(bool bColumns);
1418
    /// Returns list-of-spans representation of hidden/filtered states of columns/rows encoded as an OString.
1419
    OString dumpHiddenFiltered(bool bColumns, bool bHidden);
1420
    /// Returns list-of-spans representation of the column/row groupings encoded as an OString.
1421
    OString dumpColumnRowGroups(bool bColumns) const;
1422
1423
    SCCOL GetLOKFreezeCol() const;
1424
    SCROW GetLOKFreezeRow() const;
1425
    bool  SetLOKFreezeCol(SCCOL nFreezeCol);
1426
    bool  SetLOKFreezeRow(SCROW nFreezeRow);
1427
1428
    /**
1429
     * Use this to iterate through non-empty visible cells in a single column.
1430
     */
1431
    class VisibleDataCellIterator
1432
    {
1433
        static constexpr SCROW ROW_NOT_FOUND = -1;
1434
1435
    public:
1436
        explicit VisibleDataCellIterator(const ScDocument& rDoc, ScFlatBoolRowSegments& rRowSegs, ScColumn& rColumn);
1437
1438
        /**
1439
         * Set the start row position.  In case there is no visible data cell
1440
         * at the specified row position, it will move to the position of the
1441
         * first visible data cell below that point.
1442
         *
1443
         * @return First visible data cell if found, or NULL otherwise.
1444
         */
1445
        ScRefCellValue reset(SCROW nRow);
1446
1447
        /**
1448
         * Find the next visible data cell position.
1449
         *
1450
         * @return Next visible data cell if found, or NULL otherwise.
1451
         */
1452
        ScRefCellValue next();
1453
1454
        /**
1455
         * Get the current row position.
1456
         *
1457
         * @return Current row position, or ROW_NOT_FOUND if the iterator
1458
         *         doesn't point to a valid data cell position.
1459
         */
1460
6.16k
        SCROW getRow() const { return mnCurRow;}
1461
1462
    private:
1463
        const ScDocument& mrDocument;
1464
        ScFlatBoolRowSegments& mrRowSegs;
1465
        ScColumn& mrColumn;
1466
        ScRefCellValue maCell;
1467
        SCROW mnCurRow;
1468
        SCROW mnUBound;
1469
    };
1470
1471
    // Applies a function to the selected ranges; makes sure to only allocate
1472
    // as few columns as needed, and applies the rest to default column data.
1473
    // The function looks like
1474
    //     ApplyDataFunc(ScColumnData& applyTo, SCROW nTop, SCROW nBottom)
1475
    template <ColumnDataApply ApplyDataFunc>
1476
    void ApplyWithAllocation(const ScMarkData&, ApplyDataFunc);
1477
1478
    // Applies a function to the selected ranges in a given column.
1479
    template <ColumnDataApply ApplyDataFunc> void Apply(const ScMarkData&, SCCOL, ApplyDataFunc);
1480
};
1481
1482
template <ColumnDataApply ApplyDataFunc>
1483
void ScTable::ApplyWithAllocation(const ScMarkData& rMark, ApplyDataFunc apply)
1484
77
{
1485
77
    if (!rMark.GetTableSelect(nTab) || !(rMark.IsMultiMarked() || rMark.IsMarked()))
1486
0
        return;
1487
77
    SCCOL lastChangeCol;
1488
77
    if (rMark.GetArea().aEnd.Col() == GetDoc().MaxCol())
1489
0
    {
1490
        // For the same unallocated columns until the end we can change just the default.
1491
0
        lastChangeCol = rMark.GetStartOfEqualColumns(GetDoc().MaxCol(), aCol.size()) - 1;
1492
        // Allocate needed different columns before changing the default.
1493
0
        if (lastChangeCol >= 0)
1494
0
            CreateColumnIfNotExists(lastChangeCol);
1495
1496
0
        Apply(rMark, GetDoc().MaxCol(), apply);
1497
0
    }
1498
77
    else // need to allocate all columns affected
1499
77
    {
1500
77
        lastChangeCol = rMark.GetArea().aEnd.Col();
1501
77
        CreateColumnIfNotExists(lastChangeCol);
1502
77
    }
1503
1504
    // The loop should go not to lastChangeCol, but over all columns, to apply to already allocated
1505
    // in the "StartOfEqualColumns" range
1506
36.3k
    for (SCCOL i = 0; i < aCol.size(); i++)
1507
36.3k
        Apply(rMark, i, apply);
1508
77
}
Unexecuted instantiation: table2.cxx:_ZN7ScTable19ApplyWithAllocationITk15ColumnDataApplyZNS_19ApplySelectionStyleERK12ScStyleSheetRK10ScMarkDataE3$_0EEvS6_T_
table2.cxx:_ZN7ScTable19ApplyWithAllocationITk15ColumnDataApplyZNS_19ApplySelectionCacheER15ScItemPoolCacheRK10ScMarkDataP15ScEditDataArrayPbE3$_0EEvS5_T_
Line
Count
Source
1484
77
{
1485
77
    if (!rMark.GetTableSelect(nTab) || !(rMark.IsMultiMarked() || rMark.IsMarked()))
1486
0
        return;
1487
77
    SCCOL lastChangeCol;
1488
77
    if (rMark.GetArea().aEnd.Col() == GetDoc().MaxCol())
1489
0
    {
1490
        // For the same unallocated columns until the end we can change just the default.
1491
0
        lastChangeCol = rMark.GetStartOfEqualColumns(GetDoc().MaxCol(), aCol.size()) - 1;
1492
        // Allocate needed different columns before changing the default.
1493
0
        if (lastChangeCol >= 0)
1494
0
            CreateColumnIfNotExists(lastChangeCol);
1495
1496
0
        Apply(rMark, GetDoc().MaxCol(), apply);
1497
0
    }
1498
77
    else // need to allocate all columns affected
1499
77
    {
1500
77
        lastChangeCol = rMark.GetArea().aEnd.Col();
1501
77
        CreateColumnIfNotExists(lastChangeCol);
1502
77
    }
1503
1504
    // The loop should go not to lastChangeCol, but over all columns, to apply to already allocated
1505
    // in the "StartOfEqualColumns" range
1506
36.3k
    for (SCCOL i = 0; i < aCol.size(); i++)
1507
36.3k
        Apply(rMark, i, apply);
1508
77
}
Unexecuted instantiation: table2.cxx:_ZN7ScTable19ApplyWithAllocationITk15ColumnDataApplyZNS_21ChangeSelectionIndentEbRK10ScMarkDataE3$_0EEvS3_T_
Unexecuted instantiation: table2.cxx:_ZN7ScTable19ApplyWithAllocationITk15ColumnDataApplyZNS_19ClearSelectionItemsEPKtRK10ScMarkDataE3$_0EEvS5_T_
1509
1510
template <ColumnDataApply ApplyDataFunc>
1511
void ScTable::Apply(const ScMarkData& rMark, SCCOL nCol, ApplyDataFunc apply)
1512
36.3k
{
1513
36.3k
    if (rMark.IsMultiMarked())
1514
36.3k
    {
1515
36.3k
        ScColumnData& rCol = GetColumnData(nCol);
1516
36.3k
        ScMultiSelIter aMultiIter(rMark.GetMultiSelData(), nCol);
1517
36.3k
        SCROW nTop, nBottom;
1518
36.5k
        while (aMultiIter.Next(nTop, nBottom))
1519
239
            apply(rCol, nTop, nBottom);
1520
36.3k
    }
1521
0
    else if (rMark.IsMarked())
1522
0
    {
1523
0
        const ScRange& aRange = rMark.GetMarkArea();
1524
0
        if (aRange.aStart.Col() <= nCol && nCol <= aRange.aEnd.Col())
1525
0
            apply(GetColumnData(nCol), aRange.aStart.Row(), aRange.aEnd.Row());
1526
0
    }
1527
36.3k
}
Unexecuted instantiation: table2.cxx:_ZN7ScTable5ApplyITk15ColumnDataApplyZNS_19ApplySelectionStyleERK12ScStyleSheetRK10ScMarkDataE3$_0EEvS6_sT_
table2.cxx:_ZN7ScTable5ApplyITk15ColumnDataApplyZNS_19ApplySelectionCacheER15ScItemPoolCacheRK10ScMarkDataP15ScEditDataArrayPbE3$_0EEvS5_sT_
Line
Count
Source
1512
36.3k
{
1513
36.3k
    if (rMark.IsMultiMarked())
1514
36.3k
    {
1515
36.3k
        ScColumnData& rCol = GetColumnData(nCol);
1516
36.3k
        ScMultiSelIter aMultiIter(rMark.GetMultiSelData(), nCol);
1517
36.3k
        SCROW nTop, nBottom;
1518
36.5k
        while (aMultiIter.Next(nTop, nBottom))
1519
239
            apply(rCol, nTop, nBottom);
1520
36.3k
    }
1521
0
    else if (rMark.IsMarked())
1522
0
    {
1523
0
        const ScRange& aRange = rMark.GetMarkArea();
1524
0
        if (aRange.aStart.Col() <= nCol && nCol <= aRange.aEnd.Col())
1525
0
            apply(GetColumnData(nCol), aRange.aStart.Row(), aRange.aEnd.Row());
1526
0
    }
1527
36.3k
}
Unexecuted instantiation: table2.cxx:_ZN7ScTable5ApplyITk15ColumnDataApplyZNS_21ChangeSelectionIndentEbRK10ScMarkDataE3$_0EEvS3_sT_
Unexecuted instantiation: table2.cxx:_ZN7ScTable5ApplyITk15ColumnDataApplyZNS_19ClearSelectionItemsEPKtRK10ScMarkDataE3$_0EEvS5_sT_
1528
1529
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */