Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / inc / table.hxx
bloba50e3c75491b7df12f8e43dc964b34da357543ac
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <tools/gen.hxx>
23 #include <tools/color.hxx>
24 #include "attarray.hxx"
25 #include "column.hxx"
26 #include "colcontainer.hxx"
27 #include "sortparam.hxx"
28 #include "types.hxx"
29 #include <formula/types.hxx>
30 #include "calcmacros.hxx"
31 #include <formula/errorcodes.hxx>
32 #include "document.hxx"
33 #include "drwlayer.hxx"
34 #include "SparklineList.hxx"
35 #include "SolverSettings.hxx"
36 #include "markdata.hxx"
38 #include <algorithm>
39 #include <atomic>
40 #include <memory>
41 #include <optional>
42 #include <set>
43 #include <vector>
45 template <typename A, typename D> class ScBitMaskCompressedArray;
46 template <typename A, typename D> class ScCompressedArray;
48 namespace utl {
49 class TextSearch;
52 namespace com::sun::star {
53 namespace sheet {
54 struct TablePageBreakData;
58 namespace formula { struct VectorRefArray; }
59 namespace sc {
61 struct BroadcasterState;
62 class StartListeningContext;
63 class EndListeningContext;
64 class CopyFromClipContext;
65 class CopyToClipContext;
66 class CopyToDocContext;
67 class MixDocContext;
68 class ColumnSpanSet;
69 class RangeColumnSpanSet;
70 class ColumnSet;
71 struct ColumnBlockPosition;
72 class TableColumnBlockPositionSet;
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 ScDrawObjData;
88 class SfxItemSet;
89 class SfxStyleSheetBase;
90 class SvxBoxInfoItem;
91 class SvxBoxItem;
92 class SvxSearchItem;
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 ScSortInfoArray;
103 class ScConditionalFormat;
104 class ScConditionalFormatList;
105 class ScStyleSheet;
106 class ScTableProtection;
107 class ScUserListData;
108 struct RowInfo;
109 class ScFunctionData;
110 class CollatorWrapper;
111 class ScFlatUInt16RowSegments;
112 class ScFlatBoolRowSegments;
113 class ScFlatBoolColSegments;
114 struct ScSetStringParam;
115 struct ScColWidthParam;
116 class ScRangeName;
117 class ScDBData;
118 class ScHint;
119 class ScPostIt;
120 struct ScInterpreterContext;
123 class ScColumnsRange final
125 public:
126 class Iterator final
128 SCCOL mCol;
129 public:
130 typedef std::bidirectional_iterator_tag iterator_category;
131 typedef SCCOL value_type;
132 typedef SCCOL difference_type;
133 typedef const SCCOL* pointer;
134 typedef SCCOL reference;
136 explicit Iterator(SCCOL nCol) : mCol(nCol) {}
138 Iterator& operator++() { ++mCol; return *this;}
139 Iterator& operator--() { --mCol; return *this;}
141 // Comparing iterators from different containers is undefined, so comparing mCol is enough.
142 bool operator==(const Iterator & rOther) const {return mCol == rOther.mCol;}
143 bool operator!=(const Iterator & rOther) const {return !(*this == rOther);}
144 SCCOL operator*() const {return mCol;}
147 ScColumnsRange(SCCOL nBegin, SCCOL nEnd) : maBegin(nBegin), maEnd(nEnd) {}
148 const Iterator & begin() { return maBegin; }
149 const Iterator & end() { return maEnd; }
150 std::reverse_iterator<Iterator> rbegin() { return std::reverse_iterator<Iterator>(maEnd); }
151 std::reverse_iterator<Iterator> rend() { return std::reverse_iterator<Iterator>(maBegin); }
152 private:
153 const Iterator maBegin;
154 const Iterator maEnd;
157 class ScTable
159 private:
160 typedef ::std::vector< ScRange > ScRangeVec;
162 ScColContainer aCol;
164 OUString aName;
165 OUString aCodeName;
166 OUString aComment;
168 OUString aLinkDoc;
169 OUString aLinkFlt;
170 OUString aLinkOpt;
171 OUString aLinkTab;
172 sal_uLong nLinkRefreshDelay;
173 ScLinkMode nLinkMode;
175 // page style template
176 OUString aPageStyle;
177 Size aPageSizeTwips; // size of the print-page
178 SCCOL nRepeatStartX; // repeating rows/columns
179 SCCOL nRepeatEndX; // REPEAT_NONE, if not used
180 SCROW nRepeatStartY;
181 SCROW nRepeatEndY;
183 // Standard row height for this sheet - benefits XLSX because default height defined per sheet
184 sal_uInt16 mnOptimalMinRowHeight; // in Twips
186 std::unique_ptr<ScTableProtection> pTabProtection;
188 std::unique_ptr<ScCompressedArray<SCCOL, sal_uInt16>> mpColWidth;
189 std::unique_ptr<ScFlatUInt16RowSegments> mpRowHeights;
191 std::unique_ptr<ScBitMaskCompressedArray<SCCOL, CRFlags>> mpColFlags;
192 std::unique_ptr<ScBitMaskCompressedArray< SCROW, CRFlags>> pRowFlags;
193 std::unique_ptr<ScFlatBoolColSegments> mpHiddenCols;
194 std::unique_ptr<ScFlatBoolRowSegments> mpHiddenRows;
195 std::unique_ptr<ScFlatBoolColSegments> mpFilteredCols;
196 std::unique_ptr<ScFlatBoolRowSegments> mpFilteredRows;
198 ::std::set<SCROW> maRowPageBreaks;
199 ::std::set<SCROW> maRowManualBreaks;
200 ::std::set<SCCOL> maColPageBreaks;
201 ::std::set<SCCOL> maColManualBreaks;
203 std::unique_ptr<ScOutlineTable> pOutlineTable;
205 std::unique_ptr<ScSheetEvents> pSheetEvents;
207 mutable SCCOL nTableAreaX;
208 mutable SCROW nTableAreaY;
209 mutable SCCOL nTableAreaVisibleX;
210 mutable SCROW nTableAreaVisibleY;
212 SCTAB nTab;
213 ScDocument& rDocument;
214 std::unique_ptr<utl::TextSearch> pSearchText;
216 mutable OUString aUpperName; // #i62977# filled only on demand, reset in SetName
218 // sort parameter to minimize stack size of quicksort
219 ScSortParam aSortParam;
220 CollatorWrapper* pSortCollator;
222 ScRangeVec aPrintRanges;
224 std::optional<ScRange> moRepeatColRange;
225 std::optional<ScRange> moRepeatRowRange;
227 sal_uInt16 nLockCount;
229 std::unique_ptr<ScRangeList> pScenarioRanges;
230 Color aScenarioColor;
231 Color aTabBgColor;
232 ScScenarioFlags nScenarioFlags;
233 std::unique_ptr<ScDBData> pDBDataNoName;
234 mutable std::unique_ptr<ScRangeName> mpRangeName;
236 std::unique_ptr<ScConditionalFormatList> mpCondFormatList;
237 sc::SparklineList maSparklineList;
239 ScAddress maLOKFreezeCell;
241 bool bScenario:1;
242 bool bLayoutRTL:1;
243 bool bLoadingRTL:1;
244 bool bPageSizeValid:1;
245 mutable bool bTableAreaValid:1;
246 mutable bool bTableAreaVisibleValid:1;
247 bool bVisible:1;
248 bool bPendingRowHeights:1;
249 bool bCalcNotification:1;
250 bool bGlobalKeepQuery:1;
251 bool bPrintEntireSheet:1;
252 bool bActiveScenario:1;
253 bool mbPageBreaksValid:1;
254 bool mbForceBreaks:1;
255 /** this is touched from formula group threading context */
256 std::atomic<bool> bStreamValid;
258 // Solver settings in current tab
259 std::shared_ptr<sc::SolverSettings> m_pSolverSettings;
261 // Default attributes for the unallocated columns.
262 ScColumnData aDefaultColData;
264 friend class ScDocument; // for FillInfo
265 friend class ScColumn;
266 friend class ScValueIterator;
267 friend class ScHorizontalValueIterator;
268 friend class ScDBQueryDataIterator;
269 friend class ScFormulaGroupIterator;
270 friend class ScCellIterator;
271 template< ScQueryCellIteratorAccess accessType, ScQueryCellIteratorType queryType >
272 friend class ScQueryCellIteratorBase;
273 template< ScQueryCellIteratorAccess accessType >
274 friend class ScQueryCellIteratorAccessSpecific;
275 friend class ScHorizontalCellIterator;
276 friend class ScColumnTextWidthIterator;
277 friend class ScDocumentImport;
278 friend class sc::DocumentStreamAccess;
279 friend class sc::ColumnSpanSet;
280 friend class sc::RangeColumnSpanSet;
281 friend class sc::EditTextIterator;
282 friend class sc::FormulaGroupAreaListener;
284 public:
285 ScTable( ScDocument& rDoc, SCTAB nNewTab, const OUString& rNewName,
286 bool bColInfo = true, bool bRowInfo = true );
287 ~ScTable() COVERITY_NOEXCEPT_FALSE;
288 ScTable(const ScTable&) = delete;
289 ScTable& operator=(const ScTable&) = delete;
291 ScDocument& GetDoc() { return rDocument;}
292 const ScDocument& GetDoc() const { return rDocument;}
293 SCTAB GetTab() const { return nTab; }
295 ScOutlineTable* GetOutlineTable() { return pOutlineTable.get(); }
297 ScColumn& CreateColumnIfNotExists( const SCCOL nScCol )
299 if ( nScCol >= aCol.size() )
300 CreateColumnIfNotExistsImpl(nScCol);
301 return aCol[nScCol];
303 // out-of-line the cold part of the function
304 void CreateColumnIfNotExistsImpl( const SCCOL nScCol );
306 ScColumnData& GetColumnData( SCCOL nCol )
308 if( nCol >= aCol.size())
309 return aDefaultColData;
310 return aCol[nCol];
313 sal_uInt64 GetCellCount() const;
314 sal_uInt64 GetWeightedCount() const;
315 sal_uInt64 GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
316 sal_uInt64 GetCodeCount() const; // RPN code in formula
318 sal_uInt16 GetTextWidth(SCCOL nCol, SCROW nRow) const;
320 bool SetOutlineTable( const ScOutlineTable* pNewOutline );
321 void StartOutlineTable();
323 void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
325 bool TestRemoveSubTotals( const ScSubTotalParam& rParam );
326 void RemoveSubTotals( ScSubTotalParam& rParam );
327 bool DoSubTotals( ScSubTotalParam& rParam );
329 const ScSheetEvents* GetSheetEvents() const { return pSheetEvents.get(); }
330 void SetSheetEvents( std::unique_ptr<ScSheetEvents> pNew );
332 bool IsVisible() const { return bVisible; }
333 void SetVisible( bool bVis );
335 bool IsStreamValid() const { return bStreamValid; }
336 void SetStreamValid( bool bSet, bool bIgnoreLock = false );
338 [[nodiscard]] bool IsColValid( const SCCOL nScCol ) const
340 return nScCol >= static_cast< SCCOL >( 0 ) && nScCol < aCol.size();
342 [[nodiscard]] bool IsColRowValid( const SCCOL nScCol, const SCROW nScRow ) const
344 return IsColValid( nScCol ) && GetDoc().ValidRow( nScRow );
346 [[nodiscard]] bool IsColRowTabValid( const SCCOL nScCol, const SCROW nScRow, const SCTAB nScTab ) const
348 return IsColValid( nScCol ) && GetDoc().ValidRow( nScRow ) && ValidTab( nScTab );
350 [[nodiscard]] bool ValidCol(SCCOL nCol) const { return GetDoc().ValidCol(nCol); }
351 [[nodiscard]] bool ValidRow(SCROW nRow) const { return GetDoc().ValidRow(nRow); }
352 [[nodiscard]] bool ValidColRow(SCCOL nCol, SCROW nRow) const { return GetDoc().ValidColRow(nCol, nRow); }
354 bool IsPendingRowHeights() const { return bPendingRowHeights; }
355 void SetPendingRowHeights( bool bSet );
357 bool GetCalcNotification() const { return bCalcNotification; }
358 void SetCalcNotification( bool bSet );
360 bool IsLayoutRTL() const { return bLayoutRTL; }
361 bool IsLoadingRTL() const { return bLoadingRTL; }
362 void SetLayoutRTL( bool bSet );
363 void SetLoadingRTL( bool bSet );
365 bool IsScenario() const { return bScenario; }
366 void SetScenario( bool bFlag );
367 void GetScenarioComment( OUString& rComment) const { rComment = aComment; }
368 void SetScenarioComment( const OUString& rComment ) { aComment = rComment; }
369 const Color& GetScenarioColor() const { return aScenarioColor; }
370 void SetScenarioColor(const Color& rNew) { aScenarioColor = rNew; }
371 const Color& GetTabBgColor() const { return aTabBgColor; }
372 void SetTabBgColor(const Color& rColor);
373 ScScenarioFlags GetScenarioFlags() const { return nScenarioFlags; }
374 void SetScenarioFlags(ScScenarioFlags nNew) { nScenarioFlags = nNew; }
375 void SetActiveScenario(bool bSet) { bActiveScenario = bSet; }
376 bool IsActiveScenario() const { return bActiveScenario; }
378 ScLinkMode GetLinkMode() const { return nLinkMode; }
379 bool IsLinked() const { return nLinkMode != ScLinkMode::NONE; }
380 const OUString& GetLinkDoc() const { return aLinkDoc; }
381 const OUString& GetLinkFlt() const { return aLinkFlt; }
382 const OUString& GetLinkOpt() const { return aLinkOpt; }
383 const OUString& GetLinkTab() const { return aLinkTab; }
384 sal_uLong GetLinkRefreshDelay() const { return nLinkRefreshDelay; }
386 void SetLink( ScLinkMode nMode, const OUString& rDoc, const OUString& rFlt,
387 const OUString& rOpt, const OUString& rTab, sal_uLong nRefreshDelay );
389 sal_Int64 GetHashCode () const;
391 const OUString& GetName() const { return aName; }
392 void SetName( const OUString& rNewName );
394 void SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData);
395 ScDBData* GetAnonymousDBData() { return pDBDataNoName.get();}
397 const OUString& GetCodeName() const { return aCodeName; }
398 void SetCodeName( const OUString& rNewName ) { aCodeName = rNewName; }
400 const OUString& GetUpperName() const;
402 const OUString& GetPageStyle() const { return aPageStyle; }
403 void SetPageStyle( const OUString& rName );
404 void PageStyleModified( const OUString& rNewName );
406 bool IsProtected() const;
407 void SetProtection(const ScTableProtection* pProtect);
408 const ScTableProtection* GetProtection() const;
409 void GetUnprotectedCells( ScRangeList& rRangeList ) const;
411 bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCCOLROW nStart, SCCOLROW nEnd ) const;
413 Size GetPageSize() const;
414 void SetPageSize( const Size& rSize );
415 void SetRepeatArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
417 void LockTable();
418 void UnlockTable();
420 bool IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2,
421 SCROW nRow2, bool* pOnlyNotBecauseOfMatrix = nullptr,
422 bool bNoMatrixAtAll = false ) const;
423 bool IsSelectionEditable( const ScMarkData& rMark,
424 bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
426 bool HasBlockMatrixFragment( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2,
427 bool bNoMatrixAtAll = false ) const;
428 bool HasSelectionMatrixFragment( const ScMarkData& rMark ) const;
430 // This also includes e.g. notes. Use IsEmptyData() for cell data only.
431 bool IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
433 bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
434 const ScSetStringParam * pParam = nullptr );
436 bool SetEditText( SCCOL nCol, SCROW nRow, std::unique_ptr<EditTextObject> pEditText );
437 void SetEditText( SCCOL nCol, SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
438 SCROW GetFirstEditTextRow( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
440 void SetEmptyCell( SCCOL nCol, SCROW nRow );
441 void SetFormula(
442 SCCOL nCol, SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram );
443 void SetFormula(
444 SCCOL nCol, SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram );
446 SC_DLLPUBLIC std::shared_ptr<sc::SolverSettings> GetSolverSettings();
448 // tdf#156815 Sets the solver settings object to nullptr to force reloading Solver settings the
449 // next time the dialog is opened. This is required when sheets are renamed
450 void ResetSolverSettings() { m_pSolverSettings.reset(); }
453 * Takes ownership of pCell
455 * @return pCell if it was successfully inserted, NULL otherwise. pCell
456 * is deleted automatically on failure to insert.
458 ScFormulaCell* SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell );
460 bool SetFormulaCells( SCCOL nCol, SCROW nRow, std::vector<ScFormulaCell*>& rCells );
462 bool HasFormulaCell( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 ) const;
464 svl::SharedString GetSharedString( SCCOL nCol, SCROW nRow ) const;
466 void SetValue( SCCOL nCol, SCROW nRow, const double& rVal );
467 void SetValues( const SCCOL nCol, const SCROW nRow, const std::vector<double>& rVals );
468 void SetError( SCCOL nCol, SCROW nRow, FormulaError nError);
469 SCSIZE GetPatternCount( SCCOL nCol ) const;
470 SCSIZE GetPatternCount( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
471 bool ReservePatternCount( SCCOL nCol, SCSIZE nReserve );
473 void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr );
474 OUString GetString( SCCOL nCol, SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const;
475 double* GetValueCell( SCCOL nCol, SCROW nRow );
476 // Note that if pShared is set and a value is returned that way, the returned OUString is empty.
477 OUString GetInputString( SCCOL nCol, SCROW nRow, bool bForceSystemLocale = false ) const;
478 double GetValue( SCCOL nCol, SCROW nRow ) const;
479 const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const;
480 void RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
481 OUString GetFormula( SCCOL nCol, SCROW nRow ) const;
482 const ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ) const;
483 ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow );
485 CellType GetCellType( const ScAddress& rPos ) const
487 if (!GetDoc().ValidColRow(rPos.Col(),rPos.Row()))
488 return CELLTYPE_NONE;
489 if (rPos.Col() >= aCol.size())
490 return CELLTYPE_NONE;
491 return aCol[rPos.Col()].GetCellType( rPos.Row() );
493 CellType GetCellType( SCCOL nCol, SCROW nRow ) const;
494 ScRefCellValue GetCellValue( SCCOL nCol, sc::ColumnBlockPosition& rBlockPos, SCROW nRow );
495 ScRefCellValue GetCellValue( SCCOL nCol, SCROW nRow ) const;
497 void GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const;
498 void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const;
500 // Sparklines
502 std::shared_ptr<sc::Sparkline> GetSparkline(SCCOL nCol, SCROW nRow);
503 sc::Sparkline* CreateSparkline(SCCOL nCol, SCROW nRow, std::shared_ptr<sc::SparklineGroup> const& pSparklineGroup);
504 bool DeleteSparkline(SCCOL nCol, SCROW nRow);
506 sc::SparklineList& GetSparklineList();
507 void CopySparklinesToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab);
508 void FillSparkline(bool bVertical, SCCOLROW nFixed, SCCOLROW nIteratingStart, SCCOLROW nIteratingEnd, SCCOLROW nFillStart, SCCOLROW nFillEnd);
510 // Notes / Comments
511 std::unique_ptr<ScPostIt> ReleaseNote( SCCOL nCol, SCROW nRow );
512 ScPostIt* GetNote( SCCOL nCol, SCROW nRow );
513 void SetNote( SCCOL nCol, SCROW nRow, std::unique_ptr<ScPostIt> pNote );
515 size_t GetNoteCount( SCCOL nCol ) const;
516 SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const;
517 void CreateAllNoteCaptions();
518 void ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bPreserveData );
519 void CommentNotifyAddressChange(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
521 void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
522 void GetNotesInRange( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes ) const;
523 CommentCaptionState GetAllNoteCaptionsState( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes );
524 bool ContainsNotesInRange( const ScRange& rRange ) const;
526 bool TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ) const;
527 void InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize );
528 void DeleteRow(
529 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize,
530 bool* pUndoOutline, std::vector<ScAddress>* pGroupPos );
532 bool TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const;
533 void InsertCol(
534 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize );
535 void DeleteCol(
536 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize, bool* pUndoOutline );
538 void DeleteArea(
539 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, InsertDeleteFlags nDelFlag,
540 bool bBroadcast = true, sc::ColumnSpanSet* pBroadcastSpans = nullptr );
542 void CopyToClip( sc::CopyToClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTable,
543 std::unordered_map<const ScPatternAttr*, const ScPatternAttr*>* pPatternPutCache = nullptr );
544 void CopyToClip( sc::CopyToClipContext& rCxt, const ScRangeList& rRanges, ScTable* pTable,
545 std::unordered_map<const ScPatternAttr*, const ScPatternAttr*>* pPatternPutCache = nullptr );
547 void CopyStaticToDocument(
548 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const SvNumberFormatterMergeMap& rMap,
549 ScTable* pDestTab );
551 void CopyCellToDocument( SCCOL nSrcCol, SCROW nSrcRow, SCCOL nDestCol, SCROW nDestRow, ScTable& rDestTab );
553 bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol );
555 void DeleteBeforeCopyFromClip(
556 sc::CopyFromClipContext& rCxt, const ScTable& rClipTab, sc::ColumnSpanSet& rBroadcastSpans );
558 void CopyOneCellFromClip(
559 sc::CopyFromClipContext& rCxt, const SCCOL nCol1, const SCROW nRow1,
560 const SCCOL nCol2, const SCROW nRow2,
561 const SCROW nSrcRow, const ScTable* pSrcTab );
563 void CopyFromClip(
564 sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
565 SCCOL nDx, SCROW nDy, ScTable* pTable );
567 void StartListeningFormulaCells(
568 sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt,
569 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
571 void SetDirtyFromClip(
572 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans );
574 void CopyToTable(
575 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
576 InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab,
577 const ScMarkData* pMarkData, bool bAsLink, bool bColRowFlags,
578 bool bGlobalNamesToLocal, bool bCopyCaptions );
580 void CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab, bool bCloneCaption );
582 void UndoToTable(
583 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
584 InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab );
586 void CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
587 SCCOL nDx, SCROW nDy, const ScTable* pTable);
589 * @param nCombinedStartRow start row of the combined range;
590 * used for transposed multi range selection with row direction;
591 * for other cases than multi range row selection this it equal to nRow1
592 * @param nRowDestOffset adjustment of destination row position;
593 * used for transposed multi range selection with row direction, otherwise 0
595 void TransposeClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCROW nCombinedStartRow,
596 SCROW nRowDestOffset, ScTable* pTransClip, InsertDeleteFlags nFlags,
597 bool bAsLink, bool bIncludeFiltered);
599 // mark of this document
600 void MixMarked(
601 sc::MixDocContext& rCxt, const ScMarkData& rMark, ScPasteFunc nFunction,
602 bool bSkipEmpty, const ScTable* pSrcTab );
604 void MixData(
605 sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
606 ScPasteFunc nFunction, bool bSkipEmpty, const ScTable* pSrcTab );
608 void CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
609 SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab );
611 void CopyScenarioFrom( const ScTable* pSrcTab );
612 void CopyScenarioTo( ScTable* pDestTab ) const;
613 bool TestCopyScenarioTo( const ScTable* pDestTab ) const;
614 void MarkScenarioIn(ScMarkData& rMark, ScScenarioFlags nNeededBits) const;
615 bool HasScenarioRange( const ScRange& rRange ) const;
616 void InvalidateScenarioRanges();
617 const ScRangeList* GetScenarioRanges() const;
619 void CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const;
621 void InvalidateTableArea();
622 void InvalidatePageBreaks();
624 bool GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const; // FALSE = empty
625 bool GetTableArea( SCCOL& rEndCol, SCROW& rEndRow, bool bCalcHiddens = false) const;
626 bool GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes, bool bCalcHiddens = false) const;
627 bool GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow,
628 SCCOL& rEndCol ) const;
629 bool GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
630 SCROW& rEndRow, bool bNotes ) const;
632 bool GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const;
634 void ExtendPrintArea( OutputDevice* pDev,
635 SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow );
637 void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
638 bool bIncludeOld, bool bOnlyDown ) const;
640 void GetBackColorArea( SCCOL& rStartCol, SCROW& rStartRow,
641 SCCOL& rEndCol, SCROW& rEndRow ) const;
643 bool GetDataAreaSubrange( ScRange& rRange ) const;
645 bool ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow,
646 SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
647 bool bStickyTopRow, bool bStickyLeftCol,
648 ScDataAreaExtras* pDataAreaExtras ) const;
650 SCROW GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow,
651 ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
653 bool IsEmptyData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow) const;
654 SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
655 SCCOL nEndCol, SCROW nEndRow, ScDirection eDir ) const;
657 void FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection ) const;
658 void GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY,
659 bool bMarked, bool bUnprotected, const ScMarkData& rMark, SCCOL nTabStartCol ) const;
661 bool SkipRow( const SCCOL rCol, SCROW& rRow, const SCROW nMovY, const ScMarkData& rMark,
662 const bool bUp, const SCROW nUsedY, const bool bMarked, const bool bSheetProtected ) const;
663 void LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
665 bool HasData( SCCOL nCol, SCROW nRow ) const;
666 bool HasStringData( SCCOL nCol, SCROW nRow ) const;
667 bool HasValueData( SCCOL nCol, SCROW nRow ) const;
668 bool HasStringCells( SCCOL nStartCol, SCROW nStartRow,
669 SCCOL nEndCol, SCROW nEndRow ) const;
671 sc::MultiDataCellState HasMultipleDataCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
673 FormulaError GetErrCode( const ScAddress& rPos ) const
675 return IsColRowValid(rPos.Col(),rPos.Row()) ?
676 aCol[rPos.Col()].GetErrCode( rPos.Row() ) :
677 FormulaError::NONE;
680 void ResetChanged( const ScRange& rRange );
682 void CheckVectorizationState();
683 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
684 void SetDirty( const ScRange&, ScColumn::BroadcastMode );
685 void SetDirtyAfterLoad();
686 void SetDirtyVar();
687 void SetTableOpDirty( const ScRange& );
688 void CalcAll();
689 void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening );
690 void CompileAll( sc::CompileFormulaContext& rCxt );
691 void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress );
693 /** Broadcast single broadcasters in range, without explicitly setting
694 anything dirty, not doing area broadcasts.
695 @param rHint address is modified to adapt to the actual broadcasted
696 position on each iteration and upon return points to the last
697 position broadcasted. */
698 bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SfxHintId nHint );
700 bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode );
702 void UpdateReference(
703 sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr,
704 bool bIncludeDraw = true, bool bUpdateNoteCaptionPos = true );
706 void UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
707 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
708 SCCOL nDx, SCROW nDy, SCTAB nDz, bool bUpdateNoteCaptionPos = true );
710 void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
711 ScDocument* pUndoDoc );
713 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
715 void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
716 void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
717 void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo, ScProgress* pProgress );
718 void UpdateCompile( bool bForceIfNameInUse = false );
719 void SetTabNo(SCTAB nNewTab);
720 void FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
721 sc::UpdatedRangeNames& rIndexes) const;
722 void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
723 sal_uInt64 nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
724 double nStepValue, const tools::Duration& rDurationStep,
725 double nMaxValue, ScProgress* pProgress);
726 OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
728 void UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& rMark );
730 void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
731 sal_uInt16 nFormatNo );
732 void GetAutoFormatData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData& rData);
733 bool SearchAndReplace(
734 const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark,
735 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc, bool& bMatchedRangesWereClamped);
737 void FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 );
739 bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, HasAttrFlags nMask ) const;
740 bool HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask ) const;
741 bool HasAttrib( SCCOL nCol, SCROW nRow, HasAttrFlags nMask,
742 SCROW* nStartRow = nullptr, SCROW* nEndRow = nullptr ) const;
743 bool IsMerged( SCCOL nCol, SCROW nRow ) const;
744 bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
745 SCCOL& rEndCol, SCROW& rEndRow,
746 bool bRefresh );
747 void SetMergedCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
749 const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) const;
750 template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, TypedWhichId<T> nWhich ) const
752 return static_cast<const T*>(GetAttr(nCol, nRow, sal_uInt16(nWhich)));
754 const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich, SCROW& nStartRow, SCROW& nEndRow ) const;
755 template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, TypedWhichId<T> nWhich, SCROW& nStartRow, SCROW& nEndRow ) const
757 return static_cast<const T*>(GetAttr(nCol, nRow, sal_uInt16(nWhich), nStartRow, nEndRow));
759 const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow ) const;
760 const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
762 sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& rPos ) const;
763 sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow ) const;
764 sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
766 void SetNumberFormat( SCCOL nCol, SCROW nRow, sal_uInt32 nNumberFormat );
768 void MergeSelectionPattern( ScMergePatternState& rState,
769 const ScMarkData& rMark, bool bDeep ) const;
770 void MergePatternArea( ScMergePatternState& rState, SCCOL nCol1, SCROW nRow1,
771 SCCOL nCol2, SCROW nRow2, bool bDeep ) const;
772 void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
773 ScLineFlags& rFlags,
774 SCCOL nStartCol, SCROW nStartRow,
775 SCCOL nEndCol, SCROW nEndRow ) const;
776 void ApplyBlockFrame(const SvxBoxItem& rLineOuter,
777 const SvxBoxInfoItem* pLineInner,
778 SCCOL nStartCol, SCROW nStartRow,
779 SCCOL nEndCol, SCROW nEndRow );
781 void ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr );
782 void ApplyPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
783 void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
784 const ScPatternAttr& rAttr, ScEditDataArray* pDataArray = nullptr,
785 bool* const pIsChanged = nullptr );
786 void SetAttrEntries( SCCOL nStartCol, SCCOL nEndCol, std::vector<ScAttrEntry> && vNewData);
788 void SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr );
789 const ScPatternAttr* SetPattern( SCCOL nCol, SCROW nRow, std::unique_ptr<ScPatternAttr> );
790 void SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
791 void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
792 const ScPatternAttr& rPattern, SvNumFormatType nNewType );
793 void AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
794 void RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
795 void SetPatternAreaCondFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow,
796 const ScPatternAttr& rAttr, const ScCondFormatIndexes& rCondFormatIndexes );
798 void ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet* rStyle );
799 void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle );
800 void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
801 void ApplySelectionLineStyle( const ScMarkData& rMark,
802 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
804 const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow ) const;
805 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
806 const ScStyleSheet* GetAreaStyle( bool& rFound, SCCOL nCol1, SCROW nRow1,
807 SCCOL nCol2, SCROW nRow2 ) const;
809 void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
810 OutputDevice* pDev,
811 double nPPTX, double nPPTY,
812 const Fraction& rZoomX, const Fraction& rZoomY );
814 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
816 bool ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
817 bool RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
819 void ApplySelectionCache( ScItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
820 void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
822 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
823 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
825 const std::optional<ScRange>& GetRepeatColRange() const { return moRepeatColRange; }
826 const std::optional<ScRange>& GetRepeatRowRange() const { return moRepeatRowRange; }
827 void SetRepeatColRange( std::optional<ScRange> oNew );
828 void SetRepeatRowRange( std::optional<ScRange> oNew );
830 sal_uInt16 GetPrintRangeCount() const { return static_cast< sal_uInt16 >( aPrintRanges.size() ); }
831 const ScRange* GetPrintRange(sal_uInt16 nPos) const;
832 /** Returns true, if the sheet is always printed. */
833 bool IsPrintEntireSheet() const { return bPrintEntireSheet; }
835 /** Removes all print ranges. */
836 void ClearPrintRanges();
837 /** Adds a new print ranges. */
838 void AddPrintRange( const ScRange& rNew );
840 // Removes all named ranges used for print ranges
841 void ClearPrintNamedRanges();
843 /** Marks the specified sheet to be printed completely. Deletes old print ranges! */
844 void SetPrintEntireSheet();
846 void FillPrintSaver( ScPrintSaverTab& rSaveTab ) const;
847 void RestorePrintRanges( const ScPrintSaverTab& rSaveTab );
849 sal_uInt16 GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev,
850 double nPPTX, double nPPTY,
851 const Fraction& rZoomX, const Fraction& rZoomY,
852 bool bFormula, const ScMarkData* pMarkData,
853 const ScColWidthParam* pParam );
854 bool SetOptimalHeight(
855 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, bool bApi,
856 ScProgress* pOuterProgress = nullptr, sal_uInt64 nProgressStart = 0 );
858 void SetOptimalHeightOnly(
859 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
860 ScProgress* pOuterProgress = nullptr, sal_uInt64 nProgressStart = 0 );
862 tools::Long GetNeededSize( SCCOL nCol, SCROW nRow,
863 OutputDevice* pDev,
864 double nPPTX, double nPPTY,
865 const Fraction& rZoomX, const Fraction& rZoomY,
866 bool bWidth, bool bTotalSize,
867 bool bInPrintTwips = false);
868 void SetColWidth( SCCOL nCol, sal_uInt16 nNewWidth );
869 void SetColWidthOnly( SCCOL nCol, sal_uInt16 nNewWidth );
870 void SetRowHeight( SCROW nRow, sal_uInt16 nNewHeight );
871 bool SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight,
872 double nPPTY, bool bApi );
875 * Set specified row height to specified ranges. Don't check for drawing
876 * objects etc. Just set the row height. Nothing else.
878 * Note that setting a new row height via this function will not
879 * invalidate page breaks.
881 void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight );
883 // nPPT to test for modification
884 void SetManualHeight( SCROW nStartRow, SCROW nEndRow, bool bManual );
886 sal_uInt16 GetOptimalMinRowHeight() const
888 if (!mnOptimalMinRowHeight)
889 return ScGlobal::nStdRowHeight;
890 return mnOptimalMinRowHeight;
892 void SetOptimalMinRowHeight(sal_uInt16 nSet) { mnOptimalMinRowHeight = nSet; }
894 sal_uInt16 GetColWidth( SCCOL nCol, bool bHiddenAsZero = true ) const;
895 tools::Long GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const;
896 sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const;
897 tools::Long GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true ) const;
898 tools::Long GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const;
899 tools::Long GetColOffset( SCCOL nCol, bool bHiddenAsZero = true ) const;
900 tools::Long GetRowOffset( SCROW nRow, bool bHiddenAsZero = true ) const;
903 * Get the last row such that the height of row 0 to the end row is as
904 * high as possible without exceeding the specified height value.
906 * @param nHeight maximum desired height
908 * @return SCROW last row of the range within specified height.
910 SCROW GetRowForHeight(tools::Long nHeight) const;
912 sal_uInt16 GetOriginalWidth( SCCOL nCol ) const;
913 sal_uInt16 GetOriginalHeight( SCROW nRow ) const;
915 sal_uInt16 GetCommonWidth( SCCOL nEndCol ) const;
917 SCROW GetHiddenRowCount( SCROW nRow ) const;
919 void ShowCol(SCCOL nCol, bool bShow);
920 void ShowRow(SCROW nRow, bool bShow);
921 void DBShowRow(SCROW nRow, bool bShow);
923 void ShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
924 void DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
926 void SetRowFlags( SCROW nRow, CRFlags nNewFlags );
927 void SetRowFlags( SCROW nStartRow, SCROW nEndRow, CRFlags nNewFlags );
929 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
930 SCROW GetLastFlaggedRow() const;
932 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
933 SCCOL GetLastChangedColFlagsWidth() const;
934 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
935 SCROW GetLastChangedRowFlagsWidth() const;
937 bool IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SCROW nRowEnd) const;
938 bool IsDataFiltered(const ScRange& rRange) const;
939 CRFlags GetColFlags( SCCOL nCol ) const;
940 CRFlags GetRowFlags( SCROW nRow ) const;
942 const ScBitMaskCompressedArray< SCROW, CRFlags> * GetRowFlagsArray() const
943 { return pRowFlags.get(); }
945 bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, bool bShow );
946 bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, bool bShow );
948 void UpdatePageBreaks( const ScRange* pUserArea );
949 void RemoveManualBreaks();
950 bool HasManualBreaks() const;
951 void SetRowManualBreaks( ::std::set<SCROW>&& rBreaks );
952 void SetColManualBreaks( ::std::set<SCCOL>&& rBreaks );
954 void GetAllRowBreaks(::std::set<SCROW>& rBreaks, bool bPage, bool bManual) const;
955 void GetAllColBreaks(::std::set<SCCOL>& rBreaks, bool bPage, bool bManual) const;
956 bool HasRowPageBreak(SCROW nRow) const;
957 bool HasColPageBreak(SCCOL nCol) const;
958 bool HasRowManualBreak(SCROW nRow) const;
959 bool HasColManualBreak(SCCOL nCol) const;
962 * Get the row position of the next manual break that occurs at or below
963 * specified row. When no more manual breaks are present at or below
964 * the specified row, -1 is returned.
966 * @param nRow row at which the search begins.
968 * @return SCROW next row position with manual page break, or -1 if no
969 * more manual breaks are present.
971 SCROW GetNextManualBreak(SCROW nRow) const;
973 void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow);
974 void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual);
975 void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual);
976 void SetRowBreak(SCROW nRow, bool bPage, bool bManual);
977 void SetColBreak(SCCOL nCol, bool bPage, bool bManual);
978 css::uno::Sequence<
979 css::sheet::TablePageBreakData> GetRowBreakData() const;
981 bool RowHidden(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
982 bool RowHiddenLeaf(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
983 bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const;
984 bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
985 bool SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden);
986 void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden);
987 void CopyColHidden(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
988 void CopyRowHidden(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
989 void CopyRowHeight(const ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset);
990 SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
991 SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
992 SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const;
993 tools::Long GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true) const;
995 SCCOL CountVisibleCols(SCCOL nStartCol, SCCOL nEndCol) const;
997 SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const;
999 bool RowFiltered(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
1000 bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
1001 bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const;
1002 void CopyColFiltered(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
1003 void CopyRowFiltered(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
1004 void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered);
1005 void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered);
1006 SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const;
1007 SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const;
1008 SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const;
1010 Color GetCellBackgroundColor(ScAddress aPos) const;
1011 Color GetCellTextColor(ScAddress aPos) const;
1013 bool IsManualRowHeight(SCROW nRow) const;
1015 bool HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const;
1017 void SyncColRowFlags();
1019 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
1020 void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
1022 /** Sort a range of data. */
1023 void Sort(
1024 const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
1025 ScProgress* pProgress, sc::ReorderParam* pUndo );
1027 void Reorder( const sc::ReorderParam& rParam );
1029 // For ValidQuery() see ScQueryEvalutor class.
1030 void TopTenQuery( ScQueryParam& );
1031 void PrepareQuery( ScQueryParam& rQueryParam );
1032 SCSIZE Query(const ScQueryParam& rQueryParam, bool bKeepSub);
1033 bool CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1035 void GetFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, ScFilterEntries& rFilterEntries, bool bFiltering = false);
1036 void GetFilteredFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScQueryParam& rParam, ScFilterEntries& rFilterEntries, bool bFiltering );
1037 [[nodiscard]]
1038 bool GetDataEntries(SCCOL nCol, SCROW nRow, std::set<ScTypedStrData>& rStrings);
1040 bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
1041 bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
1043 sal_Int32 GetMaxStringLen( SCCOL nCol,
1044 SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
1045 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
1046 SCCOL nCol,
1047 SCROW nRowStart, SCROW nRowEnd ) const;
1049 bool IsSortCollatorGlobal() const;
1050 void InitSortCollator( const ScSortParam& rPar );
1051 void DestroySortCollator();
1052 void SetDrawPageSize( bool bResetStreamValid = true, bool bUpdateNoteCaptionPos = true,
1053 const ScObjectHandling eObjectHandling = ScObjectHandling::RecalcPosMode);
1055 void SetRangeName(std::unique_ptr<ScRangeName> pNew);
1056 ScRangeName* GetRangeName() const;
1058 void PreprocessRangeNameUpdate(
1059 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
1061 void CompileHybridFormula(
1062 sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt );
1064 void PreprocessDBDataUpdate(
1065 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
1067 ScConditionalFormatList* GetCondFormList();
1068 const ScConditionalFormatList* GetCondFormList() const;
1069 void SetCondFormList( ScConditionalFormatList* pList );
1071 void DeleteConditionalFormat(sal_uLong nOldIndex);
1073 sal_uLong AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew );
1075 SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow ) const;
1076 void SetScriptType( SCCOL nCol, SCROW nRow, SvtScriptType nType );
1077 void UpdateScriptTypes( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 );
1079 SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
1081 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol, SCROW nRow );
1082 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1083 formula::VectorRefArray FetchVectorRefArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
1084 bool HandleRefArrayForParallelism( SCCOL nCol, SCROW nRow1, SCROW nRow2,
1085 const ScFormulaCellGroupRef& mxGroup, ScAddress* pDirtiedAddress );
1086 #ifdef DBG_UTIL
1087 void AssertNoInterpretNeeded( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
1088 #endif
1090 void SplitFormulaGroups( SCCOL nCol, std::vector<SCROW>& rRows );
1091 void UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows );
1092 void RegroupFormulaCells( SCCOL nCol );
1094 ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
1095 ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow, sc::ColumnBlockPosition& rBlockPos );
1097 SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow );
1098 const SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow ) const;
1099 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
1100 void DeleteEmptyBroadcasters();
1102 void FillMatrix( ScMatrix& rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool* pPool ) const;
1104 void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1105 bool InterpretCellsIfNeeded( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1107 void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, size_t nLen );
1109 void CalculateInColumnInThread( ScInterpreterContext& rContext, SCCOL nColStart, SCCOL nColEnd,
1110 SCROW nRowStart, SCROW nRowEnd, unsigned nThisThread, unsigned nThreadsTotal);
1111 void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, ScInterpreter* pInterpreter);
1114 * Either start all formula cells as listeners unconditionally, or start
1115 * those that are marked "needs listening".
1117 * @param rCxt context object.
1118 * @param bAll when true, start all formula cells as listeners. When
1119 * false, only start those that are marked "needs listening".
1121 void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
1124 * Mark formula cells dirty that have the mbPostponedDirty flag set or
1125 * contain named ranges with relative references.
1127 void SetDirtyIfPostponed();
1130 * Broadcast dirty formula cells that contain functions such as CELL(),
1131 * COLUMN() or ROW() which may change its value on move.
1133 void BroadcastRecalcOnRefMove();
1135 void TransferCellValuesTo( const SCCOL nCol, SCROW nRow, size_t nLen, sc::CellValues& rDest );
1136 void CopyCellValuesFrom( const SCCOL nCol, SCROW nRow, const sc::CellValues& rSrc );
1138 std::optional<sc::ColumnIterator> GetColumnIterator( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
1140 bool EnsureFormulaCellResults( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2, bool bSkipRunning = false );
1142 void ConvertFormulaToValue(
1143 sc::EndListeningContext& rCxt,
1144 const SCCOL nCol1, const SCROW nRow1, const SCCOL nCol2, const SCROW nRow2,
1145 sc::TableValues* pUndo );
1147 void SwapNonEmpty(
1148 sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
1150 void finalizeOutlineImport();
1152 void StoreToCache(SvStream& rStrm) const;
1154 void RestoreFromCache(SvStream& rStrm);
1156 #if DUMP_COLUMN_STORAGE
1157 void DumpColumnStorage( SCCOL nCol ) const;
1158 #endif
1160 /** Replace behaves differently to the Search; adjust the rCol and rRow accordingly.
1162 'Replace' replaces at the 'current' position, but in order to achieve
1163 that, we have to 'shift' the rCol / rRow to the 'previous' position -
1164 what it is depends on various settings in rSearchItem.
1166 static void UpdateSearchItemAddressForReplace( const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow );
1168 ScColumnsRange GetWritableColumnsRange(SCCOL begin, SCCOL end);
1169 ScColumnsRange GetAllocatedColumnsRange(SCCOL begin, SCCOL end) const;
1170 ScColumnsRange GetColumnsRange(SCCOL begin, SCCOL end) const;
1171 SCCOL ClampToAllocatedColumns(SCCOL nCol) const { return std::min(nCol, static_cast<SCCOL>(aCol.size() - 1)); }
1172 SCCOL GetAllocatedColumnsCount() const { return aCol.size(); }
1175 * Serializes the sheet's geometry data.
1177 * @param bColumns - if true it dumps the data for columns, else it does for rows.
1178 * @param eGeomType indicates the type of data to be dumped for rows/columns.
1179 * @return the serialization of the sheet's geometry data as an OString.
1181 OString dumpSheetGeomData(bool bColumns, SheetGeomType eGeomType);
1183 std::set<SCCOL> QueryColumnsWithFormulaCells() const;
1185 const ScColumnData& ColumnData( SCCOL nCol ) const { return nCol < aCol.size() ? aCol[ nCol ] : aDefaultColData; }
1187 void CheckIntegrity() const;
1189 void CollectBroadcasterState(sc::BroadcasterState& rState) const;
1191 private:
1193 void FillFormulaVertical(
1194 const ScFormulaCell& rSrcCell,
1195 SCCOLROW& rInner, SCCOL nCol, SCROW nRow1, SCROW nRow2,
1196 ScProgress* pProgress, sal_uInt64& rProgress );
1198 void FillSeriesSimple(
1199 const ScCellValue& rSrcCell, SCCOLROW& rInner, SCCOLROW nIMin, SCCOLROW nIMax,
1200 const SCCOLROW& rCol, const SCCOLROW& rRow, bool bVertical, ScProgress* pProgress, sal_uInt64& rProgress );
1202 void FillAutoSimple(
1203 SCCOLROW nISrcStart, SCCOLROW nISrcEnd, SCCOLROW nIStart, SCCOLROW nIEnd,
1204 SCCOLROW& rInner, const SCCOLROW& rCol, const SCCOLROW& rRow,
1205 sal_uInt64 nActFormCnt, sal_uInt64 nMaxFormCnt,
1206 bool bHasFiltered, bool bVertical, bool bPositive,
1207 ScProgress* pProgress, sal_uInt64& rProgress );
1209 void FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1210 sal_uInt64 nFillCount, FillDir eFillDir, FillCmd eFillCmd,
1211 FillDateCmd eFillDateCmd,
1212 double nStepValue, const tools::Duration& rDurationStep,
1213 double nMaxValue, sal_uInt16 nMinDigits,
1214 bool bAttribs, ScProgress* pProgress,
1215 bool bSkipOverlappedCells = false,
1216 std::vector<sal_Int32>* pNonOverlappedCellIdx = nullptr);
1217 void FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1218 FillCmd& rCmd, FillDateCmd& rDateCmd,
1219 double& rInc, tools::Duration& rDuration, sal_uInt16& rMinDigits,
1220 ScUserListData*& rListData, sal_uInt16& rListIndex,
1221 bool bHasFiltered, bool& rSkipOverlappedCells,
1222 std::vector<sal_Int32>& rNonOverlappedCellIdx );
1223 void FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1224 sal_uInt64 nFillCount, FillDir eFillDir, ScProgress* pProgress );
1226 bool ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
1227 bool bMarked, bool bUnprotected ) const;
1229 void AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1230 const ScPatternAttr& rAttr, sal_uInt16 nFormatNo);
1231 void GetAutoFormatAttr(SCCOL nCol, SCROW nRow, sal_uInt16 nIndex, ScAutoFormatData& rData);
1232 void GetAutoFormatFrame(SCCOL nCol, SCROW nRow, sal_uInt16 nFlags, sal_uInt16 nIndex, ScAutoFormatData& rData);
1233 bool SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow,
1234 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1235 bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1236 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1237 bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1238 SCCOL nLastCol, SCROW nLastRow,
1239 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc,
1240 std::vector< sc::ColumnBlockConstPosition >& blockPos);
1241 bool SearchAll(const SvxSearchItem& rSearchItem, const ScMarkData& rMark,
1242 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1243 bool Replace(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1244 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1245 bool ReplaceAll(
1246 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1247 OUString& rUndoStr, ScDocument* pUndoDoc, bool& bMatchedRangesWereClamped);
1249 bool SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1250 const ScMarkData& rMark);
1251 bool ReplaceStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1252 const ScMarkData& rMark, bool bIsUndo);
1253 bool SearchAllStyle(
1254 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges);
1255 bool ReplaceAllStyle(
1256 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1257 ScDocument* pUndoDoc);
1258 bool SearchAndReplaceEmptyCells(
1259 const SvxSearchItem& rSearchItem,
1260 SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1261 OUString& rUndoStr, ScDocument* pUndoDoc);
1262 bool SearchRangeForEmptyCell(const ScRange& rRange,
1263 const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1264 OUString& rUndoStr);
1265 bool SearchRangeForAllEmptyCells(
1266 const ScRange& rRange, const SvxSearchItem& rSearchItem,
1267 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1269 // use the global sort parameter:
1270 bool IsSorted(SCCOLROW nStart, SCCOLROW nEnd) const;
1271 static void DecoladeRow( ScSortInfoArray*, SCROW nRow1, SCROW nRow2 );
1272 short CompareCell(
1273 sal_uInt16 nSort,
1274 ScRefCellValue& rCell1, SCCOL nCell1Col, SCROW nCell1Row,
1275 ScRefCellValue& rCell2, SCCOL nCell2Col, SCROW nCell2Row ) const;
1276 short Compare(SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1277 short Compare( ScSortInfoArray*, SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1278 std::unique_ptr<ScSortInfoArray> CreateSortInfoArray( const sc::ReorderParam& rParam );
1279 std::unique_ptr<ScSortInfoArray> CreateSortInfoArray(
1280 const ScSortParam& rSortParam, SCCOLROW nInd1, SCCOLROW nInd2,
1281 bool bKeepQuery, bool bUpdateRefs );
1282 void QuickSort( ScSortInfoArray*, SCCOLROW nLo, SCCOLROW nHi);
1283 void SortReorderByColumn( const ScSortInfoArray* pArray, SCROW nRow1, SCROW nRow2,
1284 bool bPattern, ScProgress* pProgress );
1285 void SortReorderAreaExtrasByColumn( const ScSortInfoArray* pArray, SCROW nDataRow1, SCROW nDataRow2,
1286 const ScDataAreaExtras& rDataAreaExtras, ScProgress* pProgress );
1288 void SortReorderByRow( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2,
1289 ScProgress* pProgress, bool bOnlyDataAreaExtras );
1290 void SortReorderByRowRefUpdate( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2,
1291 ScProgress* pProgress );
1292 void SortReorderAreaExtrasByRow( ScSortInfoArray* pArray, SCCOL nDataCol1, SCCOL nDataCol2,
1293 const ScDataAreaExtras& rDataAreaExtras, ScProgress* pProgress );
1295 bool CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1296 bool CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1297 OUString GetUpperCellString(SCCOL nCol, SCROW nRow);
1299 bool RefVisible(const ScFormulaCell* pCell);
1301 bool IsEmptyLine(SCROW nRow, SCCOL nStartCol, SCCOL nEndCol) const;
1303 void IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillDateCmd eCmd);
1304 void FillFormula(
1305 const ScFormulaCell* pSrcCell, SCCOL nDestCol, SCROW nDestRow, bool bLast );
1306 void UpdateInsertTabAbs(SCTAB nNewPos);
1307 bool GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, bool bInSel,
1308 const ScMarkData& rMark) const;
1309 bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark ) const;
1310 void TestTabRefAbs(SCTAB nTable) const;
1311 void CompileDBFormula( sc::CompileFormulaContext& rCxt );
1312 void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt );
1314 void StartListening( const ScAddress& rAddress, SvtListener* pListener );
1315 void EndListening( const ScAddress& rAddress, SvtListener* pListener );
1316 void StartListening( sc::StartListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
1317 void EndListening( sc::EndListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
1319 void AttachFormulaCells( sc::StartListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1320 void DetachFormulaCells( sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1322 void SetLoadingMedium(bool bLoading);
1324 SCSIZE FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2,
1325 SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY,
1326 const ScPatternAttr* pPattern, const SfxItemSet* pCondSet );
1328 // idle calculation of OutputDevice text width for cell
1329 // also invalidates script type, broadcasts for "calc as shown"
1330 void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
1331 bool bNumFormatChanged, bool bBroadcast );
1333 void SkipFilteredRows(SCROW& rRow, SCROW& rLastNonFilteredRow, bool bForward);
1336 * In case the cell text goes beyond the column width, move the max column
1337 * position to the right. This is called from ExtendPrintArea.
1339 void MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY);
1341 void CopyPrintRange(const ScTable& rTable);
1343 SCCOL FindNextVisibleColWithContent(SCCOL nCol, bool bRight, SCROW nRow) const;
1345 SCCOL FindNextVisibleCol(SCCOL nCol, bool bRight) const;
1348 * Transpose clipboard patterns
1349 * @param nCombinedStartRow start row of the combined range;
1350 * used for transposed multi range selection with row direction;
1351 * for other cases than multi range row selection this it equal to nRow1
1352 * @param nRowDestOffset adjustment of destination row position;
1353 * used for transposed multi range row selections, otherwise 0
1355 void TransposeColPatterns(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1,
1356 SCROW nRow2, SCROW nCombinedStartRow, bool bIncludeFiltered,
1357 const std::vector<SCROW>& rFilteredRows, SCROW nRowDestOffset);
1360 * Transpose clipboard notes
1361 * @param nCombinedStartRow start row of the combined range;
1362 * used for transposed multi range selection with row direction;
1363 * for other cases than multi range row selection this it equal to nRow1
1364 * @param nRowDestOffset adjustment of destination row position;
1365 * used for transposed multi range row selections, otherwise 0
1367 void TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1, SCROW nRow2,
1368 SCROW nCombinedStartRow, bool bIncludeFiltered, SCROW nRowDestOffset);
1370 ScColumn* FetchColumn( SCCOL nCol );
1371 const ScColumn* FetchColumn( SCCOL nCol ) const;
1373 void EndListeningIntersectedGroup(
1374 sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow, std::vector<ScAddress>* pGroupPos );
1376 void EndListeningIntersectedGroups(
1377 sc::EndListeningContext& rCxt, const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2,
1378 std::vector<ScAddress>* pGroupPos );
1380 void EndListeningGroup( sc::EndListeningContext& rCxt, const SCCOL nCol, SCROW nRow );
1381 void SetNeedsListeningGroup( SCCOL nCol, SCROW nRow );
1383 /// Returns list-of-spans representation of the column-widths/row-heights in twips encoded as an OString.
1384 OString dumpColumnRowSizes(bool bColumns);
1385 /// Returns list-of-spans representation of hidden/filtered states of columns/rows encoded as an OString.
1386 OString dumpHiddenFiltered(bool bColumns, bool bHidden);
1387 /// Returns list-of-spans representation of the column/row groupings encoded as an OString.
1388 OString dumpColumnRowGroups(bool bColumns) const;
1390 SCCOL GetLOKFreezeCol() const;
1391 SCROW GetLOKFreezeRow() const;
1392 bool SetLOKFreezeCol(SCCOL nFreezeCol);
1393 bool SetLOKFreezeRow(SCROW nFreezeRow);
1396 * Use this to iterate through non-empty visible cells in a single column.
1398 class VisibleDataCellIterator
1400 static constexpr SCROW ROW_NOT_FOUND = -1;
1402 public:
1403 explicit VisibleDataCellIterator(const ScDocument& rDoc, ScFlatBoolRowSegments& rRowSegs, ScColumn& rColumn);
1406 * Set the start row position. In case there is not visible data cell
1407 * at the specified row position, it will move to the position of the
1408 * first visible data cell below that point.
1410 * @return First visible data cell if found, or NULL otherwise.
1412 ScRefCellValue reset(SCROW nRow);
1415 * Find the next visible data cell position.
1417 * @return Next visible data cell if found, or NULL otherwise.
1419 ScRefCellValue next();
1422 * Get the current row position.
1424 * @return Current row position, or ROW_NOT_FOUND if the iterator
1425 * doesn't point to a valid data cell position.
1427 SCROW getRow() const { return mnCurRow;}
1429 private:
1430 const ScDocument& mrDocument;
1431 ScFlatBoolRowSegments& mrRowSegs;
1432 ScColumn& mrColumn;
1433 ScRefCellValue maCell;
1434 SCROW mnCurRow;
1435 SCROW mnUBound;
1438 // Applies a function to the selected ranges; makes sure to only allocate
1439 // as few columns as needed, and applies the rest to default column data.
1440 // The function looks like
1441 // ApplyDataFunc(ScColumnData& applyTo, SCROW nTop, SCROW nBottom)
1442 template <typename ApplyDataFunc>
1443 void ApplyWithAllocation(const ScMarkData&, ApplyDataFunc);
1446 template <typename ApplyDataFunc>
1447 void ScTable::ApplyWithAllocation(const ScMarkData& rMark, ApplyDataFunc apply)
1449 if (!rMark.GetTableSelect(nTab) || !(rMark.IsMultiMarked() || rMark.IsMarked()))
1450 return;
1451 SCCOL lastChangeCol;
1452 if (rMark.GetArea().aEnd.Col() == GetDoc().MaxCol())
1454 // For the same unallocated columns until the end we can change just the default.
1455 lastChangeCol = rMark.GetStartOfEqualColumns(GetDoc().MaxCol(), aCol.size()) - 1;
1456 // Allocate needed different columns before changing the default.
1457 if (lastChangeCol >= 0)
1458 CreateColumnIfNotExists(lastChangeCol);
1460 aDefaultColData.Apply(rMark, GetDoc().MaxCol(), apply);
1462 else // need to allocate all columns affected
1464 lastChangeCol = rMark.GetArea().aEnd.Col();
1465 CreateColumnIfNotExists(lastChangeCol);
1468 // The loop should go not to lastChangeCol, but over all columns, to apply to already allocated
1469 // in the "StartOfEqualColumns" range
1470 for (SCCOL i = 0; i < aCol.size(); i++)
1471 aCol[i].Apply(rMark, i, apply);
1474 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */