Bump version to 6.4-15
[LibreOffice.git] / sc / inc / table.hxx
blob93003911f8aee49c73b51862b715770cea22dcf0
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 #ifndef INCLUDED_SC_INC_TABLE_HXX
21 #define INCLUDED_SC_INC_TABLE_HXX
23 #include <algorithm>
24 #include <vector>
25 #include <tools/gen.hxx>
26 #include <tools/color.hxx>
27 #include "attarray.hxx"
28 #include "column.hxx"
29 #include "colcontainer.hxx"
30 #include "sortparam.hxx"
31 #include "types.hxx"
32 #include "cellvalue.hxx"
33 #include <formula/types.hxx>
34 #include "calcmacros.hxx"
35 #include <formula/errorcodes.hxx>
36 #include "document.hxx"
38 #include <set>
39 #include <memory>
41 template <typename A, typename D> class ScBitMaskCompressedArray;
42 template <typename A, typename D> class ScCompressedArray;
44 namespace utl {
45 class TextSearch;
48 namespace com { namespace sun { namespace star {
49 namespace sheet {
50 struct TablePageBreakData;
52 } } }
54 namespace formula { struct VectorRefArray; }
55 namespace sc {
57 class StartListeningContext;
58 class EndListeningContext;
59 class CopyFromClipContext;
60 class CopyToClipContext;
61 class CopyToDocContext;
62 class MixDocContext;
63 class ColumnSpanSet;
64 class RangeColumnSpanSet;
65 class ColumnSet;
66 struct ColumnBlockPosition;
67 class TableColumnBlockPositionSet;
68 struct RefUpdateContext;
69 struct RefUpdateInsertTabContext;
70 struct RefUpdateDeleteTabContext;
71 struct RefUpdateMoveTabContext;
72 struct NoteEntry;
73 class DocumentStreamAccess;
74 class CellValues;
75 class TableValues;
76 class RowHeightContext;
77 class CompileFormulaContext;
78 struct SetFormulaDirtyContext;
79 class ColumnIterator;
83 class SfxItemSet;
84 class SfxStyleSheetBase;
85 class SvxBoxInfoItem;
86 class SvxBoxItem;
87 class SvxSearchItem;
89 class ScAutoFormatData;
90 class ScEditDataArray;
91 class ScFormulaCell;
92 class ScOutlineTable;
93 class ScPrintSaverTab;
94 class ScProgress;
95 class ScRangeList;
96 class ScSheetEvents;
97 class ScSortInfoArray;
98 class ScConditionalFormat;
99 class ScConditionalFormatList;
100 class ScStyleSheet;
101 class ScTableProtection;
102 class ScUserListData;
103 struct RowInfo;
104 class ScFunctionData;
105 class CollatorWrapper;
106 class ScFlatUInt16RowSegments;
107 class ScFlatBoolRowSegments;
108 class ScFlatBoolColSegments;
109 struct ScSetStringParam;
110 struct ScColWidthParam;
111 class ScRangeName;
112 class ScDBData;
113 class ScHint;
114 class ScPostIt;
115 struct ScInterpreterContext;
118 class ScColumnsRange final
120 public:
121 class Iterator final
123 std::vector<std::unique_ptr<ScColumn>>::const_iterator maColIter;
124 public:
125 typedef std::input_iterator_tag iterator_category;
126 typedef SCCOL value_type;
127 typedef SCCOL difference_type;
128 typedef const SCCOL* pointer;
129 typedef SCCOL reference;
131 explicit Iterator(const std::vector<std::unique_ptr<ScColumn>>::const_iterator& colIter) : maColIter(colIter) {}
133 Iterator& operator++() { ++maColIter; return *this;}
134 Iterator& operator--() { --maColIter; return *this;}
136 bool operator==(const Iterator & rOther) const {return maColIter == rOther.maColIter;}
137 bool operator!=(const Iterator & rOther) const {return !(*this == rOther);}
138 SCCOL operator*() const {return (*maColIter)->GetCol();}
141 ScColumnsRange(const Iterator & rBegin, const Iterator & rEnd) : maBegin(rBegin), maEnd(rEnd) {}
142 const Iterator & begin() { return maBegin; }
143 const Iterator & end() { return maEnd; }
144 std::reverse_iterator<Iterator> rbegin() { return std::reverse_iterator<Iterator>(maEnd); }
145 std::reverse_iterator<Iterator> rend() { return std::reverse_iterator<Iterator>(maBegin); }
146 private:
147 const Iterator maBegin;
148 const Iterator maEnd;
151 class ScTable
153 private:
154 typedef ::std::vector< ScRange > ScRangeVec;
156 mutable ScColContainer aCol;
158 OUString aName;
159 OUString aCodeName;
160 OUString aComment;
162 OUString aLinkDoc;
163 OUString aLinkFlt;
164 OUString aLinkOpt;
165 OUString aLinkTab;
166 sal_uLong nLinkRefreshDelay;
167 ScLinkMode nLinkMode;
169 // page style template
170 OUString aPageStyle;
171 Size aPageSizeTwips; // size of the print-page
172 SCCOL nRepeatStartX; // repeating rows/columns
173 SCCOL nRepeatEndX; // REPEAT_NONE, if not used
174 SCROW nRepeatStartY;
175 SCROW nRepeatEndY;
177 std::unique_ptr<ScTableProtection> pTabProtection;
179 std::unique_ptr<ScCompressedArray<SCCOL, sal_uInt16>> mpColWidth;
180 std::unique_ptr<ScFlatUInt16RowSegments> mpRowHeights;
182 std::unique_ptr<ScBitMaskCompressedArray<SCCOL, CRFlags>> mpColFlags;
183 std::unique_ptr<ScBitMaskCompressedArray< SCROW, CRFlags>> pRowFlags;
184 std::unique_ptr<ScFlatBoolColSegments> mpHiddenCols;
185 std::unique_ptr<ScFlatBoolRowSegments> mpHiddenRows;
186 std::unique_ptr<ScFlatBoolColSegments> mpFilteredCols;
187 std::unique_ptr<ScFlatBoolRowSegments> mpFilteredRows;
189 ::std::set<SCROW> maRowPageBreaks;
190 ::std::set<SCROW> maRowManualBreaks;
191 ::std::set<SCCOL> maColPageBreaks;
192 ::std::set<SCCOL> maColManualBreaks;
194 std::unique_ptr<ScOutlineTable> pOutlineTable;
196 std::unique_ptr<ScSheetEvents> pSheetEvents;
198 mutable SCCOL nTableAreaX;
199 mutable SCROW nTableAreaY;
201 SCTAB nTab;
202 ScDocument* pDocument;
203 std::unique_ptr<utl::TextSearch> pSearchText;
205 mutable OUString aUpperName; // #i62977# filled only on demand, reset in SetName
207 // sort parameter to minimize stack size of quicksort
208 ScSortParam aSortParam;
209 CollatorWrapper* pSortCollator;
211 ScRangeVec aPrintRanges;
213 std::unique_ptr<ScRange> pRepeatColRange;
214 std::unique_ptr<ScRange> pRepeatRowRange;
216 sal_uInt16 nLockCount;
218 std::unique_ptr<ScRangeList> pScenarioRanges;
219 Color aScenarioColor;
220 Color aTabBgColor;
221 ScScenarioFlags nScenarioFlags;
222 std::unique_ptr<ScDBData> pDBDataNoName;
223 mutable std::unique_ptr<ScRangeName> mpRangeName;
225 std::unique_ptr<ScConditionalFormatList> mpCondFormatList;
227 ScAddress maLOKFreezeCell;
229 bool bScenario:1;
230 bool bLayoutRTL:1;
231 bool bLoadingRTL:1;
232 bool bPageSizeValid:1;
233 mutable bool bTableAreaValid:1;
234 bool bVisible:1;
235 bool bStreamValid:1;
236 bool bPendingRowHeights:1;
237 bool bCalcNotification:1;
238 bool bGlobalKeepQuery:1;
239 bool bPrintEntireSheet:1;
240 bool bActiveScenario:1;
241 bool mbPageBreaksValid:1;
242 bool mbForceBreaks:1;
244 // Default attributes for the unallocated columns.
245 ScAttrArray aDefaultColAttrArray;
247 friend class ScDocument; // for FillInfo
248 friend class ScColumn;
249 friend class ScValueIterator;
250 friend class ScHorizontalValueIterator;
251 friend class ScDBQueryDataIterator;
252 friend class ScFormulaGroupIterator;
253 friend class ScCellIterator;
254 friend class ScQueryCellIterator;
255 friend class ScCountIfCellIterator;
256 friend class ScHorizontalCellIterator;
257 friend class ScHorizontalAttrIterator;
258 friend class ScDocAttrIterator;
259 friend class ScAttrRectIterator;
260 friend class ScColumnTextWidthIterator;
261 friend class ScDocumentImport;
262 friend class sc::DocumentStreamAccess;
263 friend class sc::ColumnSpanSet;
264 friend class sc::RangeColumnSpanSet;
265 friend class sc::EditTextIterator;
266 friend class sc::FormulaGroupAreaListener;
268 public:
269 ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
270 bool bColInfo = true, bool bRowInfo = true );
271 ~ScTable() COVERITY_NOEXCEPT_FALSE;
272 ScTable(const ScTable&) = delete;
273 ScTable& operator=(const ScTable&) = delete;
275 ScDocument& GetDoc() { return *pDocument;}
276 const ScDocument& GetDoc() const { return *pDocument;}
277 SCTAB GetTab() const { return nTab; }
279 ScOutlineTable* GetOutlineTable() { return pOutlineTable.get(); }
281 ScColumn& CreateColumnIfNotExists( const SCCOL nScCol ) const
283 if ( nScCol >= aCol.size() )
284 CreateColumnIfNotExistsImpl(nScCol);
285 return aCol[nScCol];
287 // out-of-line the cold part of the function
288 void CreateColumnIfNotExistsImpl( const SCCOL nScCol ) const;
289 sal_uLong GetCellCount() const;
290 sal_uLong GetWeightedCount() const;
291 sal_uLong GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
292 sal_uLong GetCodeCount() const; // RPN code in formula
294 sal_uInt16 GetTextWidth(SCCOL nCol, SCROW nRow) const;
296 bool SetOutlineTable( const ScOutlineTable* pNewOutline );
297 void StartOutlineTable();
299 void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
301 bool TestRemoveSubTotals( const ScSubTotalParam& rParam );
302 void RemoveSubTotals( ScSubTotalParam& rParam );
303 bool DoSubTotals( ScSubTotalParam& rParam );
305 const ScSheetEvents* GetSheetEvents() const { return pSheetEvents.get(); }
306 void SetSheetEvents( std::unique_ptr<ScSheetEvents> pNew );
308 bool IsVisible() const { return bVisible; }
309 void SetVisible( bool bVis );
311 bool IsStreamValid() const { return bStreamValid; }
312 void SetStreamValid( bool bSet, bool bIgnoreLock = false );
314 [[nodiscard]] bool IsColValid( const SCCOL nScCol ) const
316 return nScCol >= static_cast< SCCOL >( 0 ) && nScCol < aCol.size();
318 [[nodiscard]] bool IsColRowValid( const SCCOL nScCol, const SCROW nScRow ) const
320 return IsColValid( nScCol ) && ValidRow( nScRow );
322 [[nodiscard]] bool IsColRowTabValid( const SCCOL nScCol, const SCROW nScRow, const SCTAB nScTab ) const
324 return IsColValid( nScCol ) && ValidRow( nScRow ) && ValidTab( nScTab );
327 bool IsPendingRowHeights() const { return bPendingRowHeights; }
328 void SetPendingRowHeights( bool bSet );
330 bool GetCalcNotification() const { return bCalcNotification; }
331 void SetCalcNotification( bool bSet );
333 bool IsLayoutRTL() const { return bLayoutRTL; }
334 bool IsLoadingRTL() const { return bLoadingRTL; }
335 void SetLayoutRTL( bool bSet );
336 void SetLoadingRTL( bool bSet );
338 bool IsScenario() const { return bScenario; }
339 void SetScenario( bool bFlag );
340 void GetScenarioComment( OUString& rComment) const { rComment = aComment; }
341 void SetScenarioComment( const OUString& rComment ) { aComment = rComment; }
342 const Color& GetScenarioColor() const { return aScenarioColor; }
343 void SetScenarioColor(const Color& rNew) { aScenarioColor = rNew; }
344 const Color& GetTabBgColor() const { return aTabBgColor; }
345 void SetTabBgColor(const Color& rColor);
346 ScScenarioFlags GetScenarioFlags() const { return nScenarioFlags; }
347 void SetScenarioFlags(ScScenarioFlags nNew) { nScenarioFlags = nNew; }
348 void SetActiveScenario(bool bSet) { bActiveScenario = bSet; }
349 bool IsActiveScenario() const { return bActiveScenario; }
351 ScLinkMode GetLinkMode() const { return nLinkMode; }
352 bool IsLinked() const { return nLinkMode != ScLinkMode::NONE; }
353 const OUString& GetLinkDoc() const { return aLinkDoc; }
354 const OUString& GetLinkFlt() const { return aLinkFlt; }
355 const OUString& GetLinkOpt() const { return aLinkOpt; }
356 const OUString& GetLinkTab() const { return aLinkTab; }
357 sal_uLong GetLinkRefreshDelay() const { return nLinkRefreshDelay; }
359 void SetLink( ScLinkMode nMode, const OUString& rDoc, const OUString& rFlt,
360 const OUString& rOpt, const OUString& rTab, sal_uLong nRefreshDelay );
362 sal_Int64 GetHashCode () const;
364 const OUString& GetName() const { return aName; }
365 void SetName( const OUString& rNewName );
367 void SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData);
368 ScDBData* GetAnonymousDBData() { return pDBDataNoName.get();}
370 const OUString& GetCodeName() const { return aCodeName; }
371 void SetCodeName( const OUString& rNewName ) { aCodeName = rNewName; }
373 const OUString& GetUpperName() const;
375 const OUString& GetPageStyle() const { return aPageStyle; }
376 void SetPageStyle( const OUString& rName );
377 void PageStyleModified( const OUString& rNewName );
379 bool IsProtected() const;
380 void SetProtection(const ScTableProtection* pProtect);
381 ScTableProtection* GetProtection();
382 void GetUnprotectedCells( ScRangeList& rRangeList ) const;
384 bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCCOLROW nStart, SCCOLROW nEnd ) const;
386 Size GetPageSize() const;
387 void SetPageSize( const Size& rSize );
388 void SetRepeatArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
390 void LockTable();
391 void UnlockTable();
393 bool IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2,
394 SCROW nRow2, bool* pOnlyNotBecauseOfMatrix = nullptr,
395 bool bNoMatrixAtAll = false ) const;
396 bool IsSelectionEditable( const ScMarkData& rMark,
397 bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
399 bool HasBlockMatrixFragment( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2,
400 bool bNoMatrixAtAll = false ) const;
401 bool HasSelectionMatrixFragment( const ScMarkData& rMark ) const;
403 bool IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bIgnoreNotes ) const;
405 bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
406 const ScSetStringParam * pParam = nullptr );
408 bool SetEditText( SCCOL nCol, SCROW nRow, std::unique_ptr<EditTextObject> pEditText );
409 void SetEditText( SCCOL nCol, SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
410 SCROW GetFirstEditTextRow( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
412 void SetEmptyCell( SCCOL nCol, SCROW nRow );
413 void SetFormula(
414 SCCOL nCol, SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram );
415 void SetFormula(
416 SCCOL nCol, SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram );
419 * Takes ownership of pCell
421 * @return pCell if it was successfully inserted, NULL otherwise. pCell
422 * is deleted automatically on failure to insert.
424 ScFormulaCell* SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell );
426 bool SetFormulaCells( SCCOL nCol, SCROW nRow, std::vector<ScFormulaCell*>& rCells );
428 bool HasFormulaCell( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 ) const;
430 svl::SharedString GetSharedString( SCCOL nCol, SCROW nRow ) const;
432 void SetValue( SCCOL nCol, SCROW nRow, const double& rVal );
433 void SetValues( const SCCOL nCol, const SCROW nRow, const std::vector<double>& rVals );
434 void SetError( SCCOL nCol, SCROW nRow, FormulaError nError);
435 SCSIZE GetPatternCount( SCCOL nCol ) const;
436 SCSIZE GetPatternCount( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
437 bool ReservePatternCount( SCCOL nCol, SCSIZE nReserve );
439 void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr );
440 void GetString( SCCOL nCol, SCROW nRow, OUString& rString,
441 const ScInterpreterContext* pContext = nullptr ) const;
442 double* GetValueCell( SCCOL nCol, SCROW nRow );
443 void GetInputString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
444 double GetValue( SCCOL nCol, SCROW nRow ) const;
445 const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const;
446 void RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
447 void GetFormula( SCCOL nCol, SCROW nRow, OUString& rFormula ) const;
448 const ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ) const;
449 ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow );
451 CellType GetCellType( const ScAddress& rPos ) const
453 if (!ValidColRow(rPos.Col(),rPos.Row()))
454 return CELLTYPE_NONE;
455 if (rPos.Col() >= aCol.size())
456 return CELLTYPE_NONE;
457 return aCol[rPos.Col()].GetCellType( rPos.Row() );
459 CellType GetCellType( SCCOL nCol, SCROW nRow ) const;
460 ScRefCellValue GetCellValue( SCCOL nCol, SCROW nRow ) const;
462 void GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const;
463 void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const;
465 std::unique_ptr<ScPostIt> ReleaseNote( SCCOL nCol, SCROW nRow );
467 size_t GetNoteCount( SCCOL nCol ) const;
468 SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const;
469 void CreateAllNoteCaptions();
470 void ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bPreserveData );
472 void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
473 void GetNotesInRange( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes ) const;
474 CommentCaptionState GetAllNoteCaptionsState( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes );
475 bool ContainsNotesInRange( const ScRange& rRange ) const;
477 bool TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ) const;
478 void InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize );
479 void DeleteRow(
480 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize,
481 bool* pUndoOutline, std::vector<ScAddress>* pGroupPos );
483 bool TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const;
484 void InsertCol(
485 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize );
486 void DeleteCol(
487 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize, bool* pUndoOutline );
489 void DeleteArea(
490 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, InsertDeleteFlags nDelFlag,
491 bool bBroadcast = true, sc::ColumnSpanSet* pBroadcastSpans = nullptr );
493 void CopyToClip( sc::CopyToClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTable );
494 void CopyToClip( sc::CopyToClipContext& rCxt, const ScRangeList& rRanges, ScTable* pTable );
496 void CopyStaticToDocument(
497 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const SvNumberFormatterMergeMap& rMap,
498 ScTable* pDestTab );
500 void CopyCellToDocument( SCCOL nSrcCol, SCROW nSrcRow, SCCOL nDestCol, SCROW nDestRow, ScTable& rDestTab );
502 bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol );
504 void DeleteBeforeCopyFromClip(
505 sc::CopyFromClipContext& rCxt, const ScTable& rClipTab, sc::ColumnSpanSet& rBroadcastSpans );
507 void CopyOneCellFromClip(
508 sc::CopyFromClipContext& rCxt, const SCCOL nCol1, const SCROW nRow1,
509 const SCCOL nCol2, const SCROW nRow2,
510 const SCROW nSrcRow, const ScTable* pSrcTab );
512 void CopyFromClip(
513 sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
514 SCCOL nDx, SCROW nDy, ScTable* pTable );
516 void StartListeningFormulaCells(
517 sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt,
518 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
520 void SetDirtyFromClip(
521 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans );
523 void CopyToTable(
524 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
525 InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab,
526 const ScMarkData* pMarkData, bool bAsLink, bool bColRowFlags,
527 bool bGlobalNamesToLocal, bool bCopyCaptions );
529 void CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab, bool bCloneCaption );
531 void UndoToTable(
532 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
533 InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab );
535 void CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
536 SCCOL nDx, SCROW nDy, const ScTable* pTable);
537 void TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
538 ScTable* pTransClip, InsertDeleteFlags nFlags, bool bAsLink );
540 // mark of this document
541 void MixMarked(
542 sc::MixDocContext& rCxt, const ScMarkData& rMark, ScPasteFunc nFunction,
543 bool bSkipEmpty, const ScTable* pSrcTab );
545 void MixData(
546 sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
547 ScPasteFunc nFunction, bool bSkipEmpty, const ScTable* pSrcTab );
549 void CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
550 SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab );
552 void CopyScenarioFrom( const ScTable* pSrcTab );
553 void CopyScenarioTo( const ScTable* pDestTab ) const;
554 bool TestCopyScenarioTo( const ScTable* pDestTab ) const;
555 void MarkScenarioIn(ScMarkData& rMark, ScScenarioFlags nNeededBits) const;
556 bool HasScenarioRange( const ScRange& rRange ) const;
557 void InvalidateScenarioRanges();
558 const ScRangeList* GetScenarioRanges() const;
560 void CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const;
562 void InvalidateTableArea();
563 void InvalidatePageBreaks();
565 bool GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const; // FALSE = empty
566 bool GetTableArea( SCCOL& rEndCol, SCROW& rEndRow ) const;
567 bool GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes ) const;
568 bool GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow,
569 SCCOL& rEndCol ) const;
570 bool GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
571 SCROW& rEndRow, bool bNotes ) const;
573 bool GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const;
575 void ExtendPrintArea( OutputDevice* pDev,
576 SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow );
578 void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
579 bool bIncludeOld, bool bOnlyDown ) const;
581 bool GetDataAreaSubrange( ScRange& rRange ) const;
583 bool ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow,
584 SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
585 bool bStickyTopRow, bool bStickyLeftCol, bool bConsiderCellNotes,
586 bool bConsiderCellDrawObjects ) const;
588 SCROW GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow,
589 bool bConsiderCellNotes = false, bool bConsiderCellDrawObjects = false ) const;
591 SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
592 SCCOL nEndCol, SCROW nEndRow, ScDirection eDir ) const;
594 void FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection ) const;
595 void GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY,
596 bool bMarked, bool bUnprotected, const ScMarkData& rMark, SCCOL nTabStartCol ) const;
598 bool SkipRow( const SCCOL rCol, SCROW& rRow, const SCROW nMovY, const ScMarkData& rMark,
599 const bool bUp, const SCROW nUsedY, const bool bMarked, const bool bSheetProtected ) const;
600 void LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
602 bool HasData( SCCOL nCol, SCROW nRow ) const;
603 bool HasStringData( SCCOL nCol, SCROW nRow ) const;
604 bool HasValueData( SCCOL nCol, SCROW nRow ) const;
605 bool HasStringCells( SCCOL nStartCol, SCROW nStartRow,
606 SCCOL nEndCol, SCROW nEndRow ) const;
608 sc::MultiDataCellState HasMultipleDataCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
610 FormulaError GetErrCode( const ScAddress& rPos ) const
612 return IsColRowValid(rPos.Col(),rPos.Row()) ?
613 aCol[rPos.Col()].GetErrCode( rPos.Row() ) :
614 FormulaError::NONE;
617 void ResetChanged( const ScRange& rRange );
619 void CheckVectorizationState();
620 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
621 void SetDirty( const ScRange&, ScColumn::BroadcastMode );
622 void SetDirtyAfterLoad();
623 void SetDirtyVar();
624 void SetTableOpDirty( const ScRange& );
625 void CalcAll();
626 void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening );
627 void CompileAll( sc::CompileFormulaContext& rCxt );
628 void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress );
630 /** Broadcast single broadcasters in range, without explicitly setting
631 anything dirty, not doing area broadcasts.
632 @param rHint address is modified to adapt to the actual broadcasted
633 position on each iteration and upon return points to the last
634 position broadcasted. */
635 bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScHint& rHint );
637 bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode );
639 void UpdateReference(
640 sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr,
641 bool bIncludeDraw = true, bool bUpdateNoteCaptionPos = true );
643 void UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
644 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
645 SCCOL nDx, SCROW nDy, SCTAB nDz, bool bUpdateNoteCaptionPos = true );
647 void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
648 ScDocument* pUndoDoc );
650 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
652 void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
653 void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
654 void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo, ScProgress* pProgress );
655 void UpdateCompile( bool bForceIfNameInUse = false );
656 void SetTabNo(SCTAB nNewTab);
657 void FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
658 sc::UpdatedRangeNames& rIndexes) const;
659 void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
660 sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
661 double nStepValue, double nMaxValue, ScProgress* pProgress);
662 OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
664 void UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& rMark );
666 void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
667 sal_uInt16 nFormatNo );
668 void GetAutoFormatData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData& rData);
669 bool SearchAndReplace(
670 const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark,
671 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
673 void FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 );
675 bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, HasAttrFlags nMask ) const;
676 bool HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask ) const;
677 bool IsMerged( SCCOL nCol, SCROW nRow ) const;
678 bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
679 SCCOL& rEndCol, SCROW& rEndRow,
680 bool bRefresh );
681 void SetMergedCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
683 const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) const;
684 template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, TypedWhichId<T> nWhich ) const
686 return static_cast<const T*>(GetAttr(nCol, nRow, sal_uInt16(nWhich)));
688 const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow ) const;
689 const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
691 sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& rPos ) const;
692 sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow ) const;
693 sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
695 void SetNumberFormat( SCCOL nCol, SCROW nRow, sal_uInt32 nNumberFormat );
697 void MergeSelectionPattern( ScMergePatternState& rState,
698 const ScMarkData& rMark, bool bDeep ) const;
699 void MergePatternArea( ScMergePatternState& rState, SCCOL nCol1, SCROW nRow1,
700 SCCOL nCol2, SCROW nRow2, bool bDeep ) const;
701 void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
702 ScLineFlags& rFlags,
703 SCCOL nStartCol, SCROW nStartRow,
704 SCCOL nEndCol, SCROW nEndRow ) const;
705 void ApplyBlockFrame(const SvxBoxItem& rLineOuter,
706 const SvxBoxInfoItem* pLineInner,
707 SCCOL nStartCol, SCROW nStartRow,
708 SCCOL nEndCol, SCROW nEndRow );
710 void ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr );
711 void ApplyPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
712 void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
713 const ScPatternAttr& rAttr, ScEditDataArray* pDataArray = nullptr,
714 bool* const pIsChanged = nullptr );
716 void SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr );
717 const ScPatternAttr* SetPattern( SCCOL nCol, SCROW nRow, std::unique_ptr<ScPatternAttr> );
718 void SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
719 void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
720 const ScPatternAttr& rPattern, SvNumFormatType nNewType );
721 void AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
722 void RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
723 void SetPatternAreaCondFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow,
724 const ScPatternAttr& rAttr, const ScCondFormatIndexes& rCondFormatIndexes );
726 void ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet* rStyle );
727 void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle );
728 void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
729 void ApplySelectionLineStyle( const ScMarkData& rMark,
730 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
732 const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow ) const;
733 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
734 const ScStyleSheet* GetAreaStyle( bool& rFound, SCCOL nCol1, SCROW nRow1,
735 SCCOL nCol2, SCROW nRow2 ) const;
737 void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
738 OutputDevice* pDev,
739 double nPPTX, double nPPTY,
740 const Fraction& rZoomX, const Fraction& rZoomY );
742 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
744 bool ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
745 bool RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
747 void ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
748 void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
750 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
751 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
753 const ScRange* GetRepeatColRange() const { return pRepeatColRange.get(); }
754 const ScRange* GetRepeatRowRange() const { return pRepeatRowRange.get(); }
755 void SetRepeatColRange( std::unique_ptr<ScRange> pNew );
756 void SetRepeatRowRange( std::unique_ptr<ScRange> pNew );
758 sal_uInt16 GetPrintRangeCount() const { return static_cast< sal_uInt16 >( aPrintRanges.size() ); }
759 const ScRange* GetPrintRange(sal_uInt16 nPos) const;
760 /** Returns true, if the sheet is always printed. */
761 bool IsPrintEntireSheet() const { return bPrintEntireSheet; }
763 /** Removes all print ranges. */
764 void ClearPrintRanges();
765 /** Adds a new print ranges. */
766 void AddPrintRange( const ScRange& rNew );
767 /** Marks the specified sheet to be printed completely. Deletes old print ranges! */
768 void SetPrintEntireSheet();
770 void FillPrintSaver( ScPrintSaverTab& rSaveTab ) const;
771 void RestorePrintRanges( const ScPrintSaverTab& rSaveTab );
773 sal_uInt16 GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev,
774 double nPPTX, double nPPTY,
775 const Fraction& rZoomX, const Fraction& rZoomY,
776 bool bFormula, const ScMarkData* pMarkData,
777 const ScColWidthParam* pParam );
778 bool SetOptimalHeight(
779 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
780 ScProgress* pOuterProgress = nullptr, sal_uLong nProgressStart = 0 );
782 void SetOptimalHeightOnly(
783 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
784 ScProgress* pOuterProgress = nullptr, sal_uLong nProgressStart = 0 );
786 long GetNeededSize( SCCOL nCol, SCROW nRow,
787 OutputDevice* pDev,
788 double nPPTX, double nPPTY,
789 const Fraction& rZoomX, const Fraction& rZoomY,
790 bool bWidth, bool bTotalSize,
791 bool bInPrintTwips = false);
792 void SetColWidth( SCCOL nCol, sal_uInt16 nNewWidth );
793 void SetColWidthOnly( SCCOL nCol, sal_uInt16 nNewWidth );
794 void SetRowHeight( SCROW nRow, sal_uInt16 nNewHeight );
795 bool SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight,
796 double nPPTY );
799 * Set specified row height to specified ranges. Don't check for drawing
800 * objects etc. Just set the row height. Nothing else.
802 * Note that setting a new row height via this function will not
803 * invalidate page breaks.
805 void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight );
807 // nPPT to test for modification
808 void SetManualHeight( SCROW nStartRow, SCROW nEndRow, bool bManual );
810 sal_uInt16 GetColWidth( SCCOL nCol, bool bHiddenAsZero = true ) const;
811 sal_uLong GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const;
812 sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const;
813 sal_uLong GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true ) const;
814 sal_uLong GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale, const sal_uLong* pnMaxHeight = nullptr ) const;
815 sal_uLong GetColOffset( SCCOL nCol, bool bHiddenAsZero = true ) const;
816 sal_uLong GetRowOffset( SCROW nRow, bool bHiddenAsZero = true ) const;
819 * Get the last row such that the height of row 0 to the end row is as
820 * high as possible without exceeding the specified height value.
822 * @param nHeight maximum desired height
824 * @return SCROW last row of the range within specified height.
826 SCROW GetRowForHeight(sal_uLong nHeight) const;
828 sal_uInt16 GetOriginalWidth( SCCOL nCol ) const;
829 sal_uInt16 GetOriginalHeight( SCROW nRow ) const;
831 sal_uInt16 GetCommonWidth( SCCOL nEndCol ) const;
833 SCROW GetHiddenRowCount( SCROW nRow ) const;
835 void ShowCol(SCCOL nCol, bool bShow);
836 void ShowRow(SCROW nRow, bool bShow);
837 void DBShowRow(SCROW nRow, bool bShow);
839 void ShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
840 void DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
842 void SetRowFlags( SCROW nRow, CRFlags nNewFlags );
843 void SetRowFlags( SCROW nStartRow, SCROW nEndRow, CRFlags nNewFlags );
845 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
846 SCROW GetLastFlaggedRow() const;
848 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
849 SCCOL GetLastChangedCol() const;
850 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
851 SCROW GetLastChangedRow() const;
853 bool IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SCROW nRowEnd) const;
854 bool IsDataFiltered(const ScRange& rRange) const;
855 CRFlags GetColFlags( SCCOL nCol ) const;
856 CRFlags GetRowFlags( SCROW nRow ) const;
858 const ScBitMaskCompressedArray< SCROW, CRFlags> * GetRowFlagsArray() const
859 { return pRowFlags.get(); }
861 bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, bool bShow );
862 bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, bool bShow );
864 void UpdatePageBreaks( const ScRange* pUserArea );
865 void RemoveManualBreaks();
866 bool HasManualBreaks() const;
867 void SetRowManualBreaks( const ::std::set<SCROW>& rBreaks );
868 void SetColManualBreaks( const ::std::set<SCCOL>& rBreaks );
870 void GetAllRowBreaks(::std::set<SCROW>& rBreaks, bool bPage, bool bManual) const;
871 void GetAllColBreaks(::std::set<SCCOL>& rBreaks, bool bPage, bool bManual) const;
872 bool HasRowPageBreak(SCROW nRow) const;
873 bool HasColPageBreak(SCCOL nCol) const;
874 bool HasRowManualBreak(SCROW nRow) const;
875 bool HasColManualBreak(SCCOL nCol) const;
878 * Get the row position of the next manual break that occurs at or below
879 * specified row. When no more manual breaks are present at or below
880 * the specified row, -1 is returned.
882 * @param nRow row at which the search begins.
884 * @return SCROW next row position with manual page break, or -1 if no
885 * more manual breaks are present.
887 SCROW GetNextManualBreak(SCROW nRow) const;
889 void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow);
890 void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual);
891 void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual);
892 void SetRowBreak(SCROW nRow, bool bPage, bool bManual);
893 void SetColBreak(SCCOL nCol, bool bPage, bool bManual);
894 css::uno::Sequence<
895 css::sheet::TablePageBreakData> GetRowBreakData() const;
897 bool RowHidden(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
898 bool RowHiddenLeaf(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
899 bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const;
900 bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
901 bool SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden);
902 void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden);
903 void CopyColHidden(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
904 void CopyRowHidden(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
905 void CopyRowHeight(const ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset);
906 SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
907 SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
908 SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const;
909 sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true) const;
911 SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const;
913 bool RowFiltered(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
914 bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
915 bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const;
916 void CopyColFiltered(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
917 void CopyRowFiltered(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
918 void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered);
919 void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered);
920 SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const;
921 SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const;
922 SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const;
924 bool IsManualRowHeight(SCROW nRow) const;
926 bool HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const;
928 void SyncColRowFlags();
930 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
931 void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
933 /** Sort a range of data. */
934 void Sort(
935 const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
936 ScProgress* pProgress, sc::ReorderParam* pUndo );
938 void Reorder( const sc::ReorderParam& rParam );
940 bool ValidQuery(
941 SCROW nRow, const ScQueryParam& rQueryParam, const ScRefCellValue* pCell = nullptr,
942 bool* pbTestEqualCondition = nullptr, const ScInterpreterContext* pContext = nullptr,
943 sc::TableColumnBlockPositionSet* pBlockPos = nullptr );
944 void TopTenQuery( ScQueryParam& );
945 SCSIZE Query(const ScQueryParam& rQueryParam, bool bKeepSub);
946 bool CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
948 void GetFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, ScFilterEntries& rFilterEntries );
949 void GetFilteredFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScQueryParam& rParam, ScFilterEntries& rFilterEntries );
950 [[nodiscard]]
951 bool GetDataEntries(SCCOL nCol, SCROW nRow, std::set<ScTypedStrData>& rStrings, bool bLimit);
953 bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
954 bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
956 sal_Int32 GetMaxStringLen( SCCOL nCol,
957 SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
958 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
959 SCCOL nCol,
960 SCROW nRowStart, SCROW nRowEnd ) const;
962 bool IsSortCollatorGlobal() const;
963 void InitSortCollator( const ScSortParam& rPar );
964 void DestroySortCollator();
965 void SetDrawPageSize( bool bResetStreamValid = true, bool bUpdateNoteCaptionPos = true );
967 void SetRangeName(std::unique_ptr<ScRangeName> pNew);
968 ScRangeName* GetRangeName() const;
970 void PreprocessRangeNameUpdate(
971 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
973 void CompileHybridFormula(
974 sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt );
976 void PreprocessDBDataUpdate(
977 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
979 ScConditionalFormatList* GetCondFormList();
980 const ScConditionalFormatList* GetCondFormList() const;
981 void SetCondFormList( ScConditionalFormatList* pList );
983 void DeleteConditionalFormat(sal_uLong nOldIndex);
985 sal_uLong AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew );
987 SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow ) const;
988 void SetScriptType( SCCOL nCol, SCROW nRow, SvtScriptType nType );
989 void UpdateScriptTypes( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 );
991 SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
993 size_t GetFormulaHash( SCCOL nCol, SCROW nRow ) const;
995 ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const;
996 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol, SCROW nRow );
997 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
998 formula::VectorRefArray FetchVectorRefArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
999 bool HandleRefArrayForParallelism( SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScFormulaCellGroupRef& mxGroup );
1000 #ifdef DBG_UTIL
1001 void AssertNoInterpretNeeded( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
1002 #endif
1004 void SplitFormulaGroups( SCCOL nCol, std::vector<SCROW>& rRows );
1005 void UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows );
1006 void RegroupFormulaCells( SCCOL nCol );
1008 ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
1009 ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow, sc::ColumnBlockPosition& rBlockPos );
1011 SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow );
1012 const SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow ) const;
1013 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
1015 void FillMatrix( ScMatrix& rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool* pPool ) const;
1017 void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1019 void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, size_t nLen );
1021 void CalculateInColumnInThread( ScInterpreterContext& rContext, SCCOL nColStart, SCCOL nColEnd,
1022 SCROW nRowStart, SCROW nRowEnd, unsigned nThisThread, unsigned nThreadsTotal);
1023 void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, ScInterpreter* pInterpreter);
1026 * Either start all formula cells as listeners unconditionally, or start
1027 * those that are marked "needs listening".
1029 * @param rCxt context object.
1030 * @param bAll when true, start all formula cells as listeners. When
1031 * false, only start those that are marked "needs listening".
1033 void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
1036 * Mark formula cells dirty that have the mbPostponedDirty flag set or
1037 * contain named ranges with relative references.
1039 void SetDirtyIfPostponed();
1042 * Broadcast dirty formula cells that contain functions such as CELL(),
1043 * COLUMN() or ROW() which may change its value on move.
1045 void BroadcastRecalcOnRefMove();
1047 void TransferCellValuesTo( const SCCOL nCol, SCROW nRow, size_t nLen, sc::CellValues& rDest );
1048 void CopyCellValuesFrom( const SCCOL nCol, SCROW nRow, const sc::CellValues& rSrc );
1050 std::unique_ptr<sc::ColumnIterator> GetColumnIterator( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
1052 bool EnsureFormulaCellResults( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2, bool bSkipRunning = false );
1054 void ConvertFormulaToValue(
1055 sc::EndListeningContext& rCxt,
1056 const SCCOL nCol1, const SCROW nRow1, const SCCOL nCol2, const SCROW nRow2,
1057 sc::TableValues* pUndo );
1059 void SwapNonEmpty(
1060 sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
1062 void finalizeOutlineImport();
1064 void StoreToCache(SvStream& rStrm) const;
1066 void RestoreFromCache(SvStream& rStrm);
1068 #if DUMP_COLUMN_STORAGE
1069 void DumpColumnStorage( SCCOL nCol ) const;
1070 #endif
1072 /** Replace behaves differently to the Search; adjust the rCol and rRow accordingly.
1074 'Replace' replaces at the 'current' position, but in order to achieve
1075 that, we have to 'shift' the rCol / rRow to the 'previous' position -
1076 what it is depends on various settings in rSearchItem.
1078 static void UpdateSearchItemAddressForReplace( const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow );
1080 ScColumnsRange GetColumnsRange(SCCOL begin, SCCOL end) const;
1081 SCCOL ClampToAllocatedColumns(SCCOL nCol) const { return std::min(nCol, static_cast<SCCOL>(aCol.size() - 1)); }
1082 SCCOL GetAllocatedColumnsCount() const { return aCol.size(); }
1085 * Serializes the sheet's geometry data.
1087 * @param bColumns - if true it dumps the data for columns, else it does for rows.
1088 * @param eGeomType indicates the type of data to be dumped for rows/columns.
1089 * @return the serialization of the sheet's geometry data as an OString.
1091 OString dumpSheetGeomData(bool bColumns, SheetGeomType eGeomType);
1093 private:
1095 void FillFormulaVertical(
1096 const ScFormulaCell& rSrcCell,
1097 SCCOLROW& rInner, SCCOL nCol, SCROW nRow1, SCROW nRow2,
1098 ScProgress* pProgress, sal_uLong& rProgress );
1100 void FillSeriesSimple(
1101 const ScCellValue& rSrcCell, SCCOLROW& rInner, SCCOLROW nIMin, SCCOLROW nIMax,
1102 const SCCOLROW& rCol, const SCCOLROW& rRow, bool bVertical, ScProgress* pProgress, sal_uLong& rProgress );
1104 void FillAutoSimple(
1105 SCCOLROW nISrcStart, SCCOLROW nISrcEnd, SCCOLROW nIStart, SCCOLROW nIEnd,
1106 SCCOLROW& rInner, const SCCOLROW& rCol, const SCCOLROW& rRow,
1107 sal_uLong nActFormCnt, sal_uLong nMaxFormCnt,
1108 bool bHasFiltered, bool bVertical, bool bPositive,
1109 ScProgress* pProgress, sal_uLong& rProgress );
1111 void FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1112 sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd,
1113 FillDateCmd eFillDateCmd,
1114 double nStepValue, double nMaxValue, sal_uInt16 nMinDigits,
1115 bool bAttribs, ScProgress* pProgress );
1116 void FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1117 FillCmd& rCmd, FillDateCmd& rDateCmd,
1118 double& rInc, sal_uInt16& rMinDigits,
1119 ScUserListData*& rListData, sal_uInt16& rListIndex);
1120 void FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1121 sal_uLong nFillCount, FillDir eFillDir, ScProgress* pProgress );
1123 bool ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
1124 bool bMarked, bool bUnprotected ) const;
1126 void AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1127 const ScPatternAttr& rAttr, sal_uInt16 nFormatNo);
1128 void GetAutoFormatAttr(SCCOL nCol, SCROW nRow, sal_uInt16 nIndex, ScAutoFormatData& rData);
1129 void GetAutoFormatFrame(SCCOL nCol, SCROW nRow, sal_uInt16 nFlags, sal_uInt16 nIndex, ScAutoFormatData& rData);
1130 bool SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow,
1131 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1132 bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1133 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1134 bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1135 SCCOL nLastCol, SCROW nLastRow,
1136 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1137 bool SearchAll(const SvxSearchItem& rSearchItem, const ScMarkData& rMark,
1138 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1139 bool Replace(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1140 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1141 bool ReplaceAll(
1142 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1143 OUString& rUndoStr, ScDocument* pUndoDoc);
1145 bool SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1146 const ScMarkData& rMark);
1147 bool ReplaceStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1148 const ScMarkData& rMark, bool bIsUndo);
1149 bool SearchAllStyle(
1150 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges);
1151 bool ReplaceAllStyle(
1152 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1153 ScDocument* pUndoDoc);
1154 bool SearchAndReplaceEmptyCells(
1155 const SvxSearchItem& rSearchItem,
1156 SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1157 OUString& rUndoStr, ScDocument* pUndoDoc);
1158 bool SearchRangeForEmptyCell(const ScRange& rRange,
1159 const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1160 OUString& rUndoStr);
1161 bool SearchRangeForAllEmptyCells(
1162 const ScRange& rRange, const SvxSearchItem& rSearchItem,
1163 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1165 // use the global sort parameter:
1166 bool IsSorted(SCCOLROW nStart, SCCOLROW nEnd) const;
1167 static void DecoladeRow( ScSortInfoArray*, SCROW nRow1, SCROW nRow2 );
1168 short CompareCell(
1169 sal_uInt16 nSort,
1170 ScRefCellValue& rCell1, SCCOL nCell1Col, SCROW nCell1Row,
1171 ScRefCellValue& rCell2, SCCOL nCell2Col, SCROW nCell2Row ) const;
1172 short Compare(SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1173 short Compare( ScSortInfoArray*, SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1174 std::unique_ptr<ScSortInfoArray> CreateSortInfoArray( const sc::ReorderParam& rParam );
1175 std::unique_ptr<ScSortInfoArray> CreateSortInfoArray(
1176 const ScSortParam& rSortParam, SCCOLROW nInd1, SCCOLROW nInd2,
1177 bool bKeepQuery, bool bUpdateRefs );
1178 void QuickSort( ScSortInfoArray*, SCCOLROW nLo, SCCOLROW nHi);
1179 void SortReorderByColumn( const ScSortInfoArray* pArray, SCROW nRow1, SCROW nRow2, bool bPattern, ScProgress* pProgress );
1181 void SortReorderByRow( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress );
1182 void SortReorderByRowRefUpdate( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress );
1184 bool CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1185 bool CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1186 void GetUpperCellString(SCCOL nCol, SCROW nRow, OUString& rStr);
1188 bool RefVisible(const ScFormulaCell* pCell);
1190 bool IsEmptyLine(SCROW nRow, SCCOL nStartCol, SCCOL nEndCol) const;
1192 void IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillDateCmd eCmd);
1193 void FillFormula(
1194 const ScFormulaCell* pSrcCell, SCCOL nDestCol, SCROW nDestRow, bool bLast );
1195 void UpdateInsertTabAbs(SCTAB nNewPos);
1196 bool GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, bool bInSel,
1197 const ScMarkData& rMark) const;
1198 bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark ) const;
1199 void TestTabRefAbs(SCTAB nTable) const;
1200 void CompileDBFormula( sc::CompileFormulaContext& rCxt );
1201 void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt );
1203 void StartListening( const ScAddress& rAddress, SvtListener* pListener );
1204 void EndListening( const ScAddress& rAddress, SvtListener* pListener );
1205 void StartListening( sc::StartListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
1206 void EndListening( sc::EndListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
1208 void AttachFormulaCells( sc::StartListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1209 void DetachFormulaCells( sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1211 void SetLoadingMedium(bool bLoading);
1213 SCSIZE FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2,
1214 SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY,
1215 const ScPatternAttr* pPattern, const SfxItemSet* pCondSet );
1217 // idle calculation of OutputDevice text width for cell
1218 // also invalidates script type, broadcasts for "calc as shown"
1219 void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
1220 bool bNumFormatChanged, bool bBroadcast );
1222 void SkipFilteredRows(SCROW& rRow, SCROW& rLastNonFilteredRow, bool bForward);
1225 * In case the cell text goes beyond the column width, move the max column
1226 * position to the right. This is called from ExtendPrintArea.
1228 void MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY);
1230 void CopyPrintRange(const ScTable& rTable);
1232 SCCOL FindNextVisibleColWithContent(SCCOL nCol, bool bRight, SCROW nRow) const;
1234 SCCOL FindNextVisibleCol(SCCOL nCol, bool bRight) const;
1236 // Clipboard transpose for notes
1237 void TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1, SCROW nRow2);
1239 ScColumn* FetchColumn( SCCOL nCol );
1240 const ScColumn* FetchColumn( SCCOL nCol ) const;
1242 void EndListeningIntersectedGroup(
1243 sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow, std::vector<ScAddress>* pGroupPos );
1245 void EndListeningIntersectedGroups(
1246 sc::EndListeningContext& rCxt, const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2,
1247 std::vector<ScAddress>* pGroupPos );
1249 void EndListeningGroup( sc::EndListeningContext& rCxt, const SCCOL nCol, SCROW nRow );
1250 void SetNeedsListeningGroup( SCCOL nCol, SCROW nRow );
1252 /// Returns list-of-spans representation of the column-widths/row-heights in twips encoded as an OString.
1253 OString dumpColumnRowSizes(bool bColumns);
1254 /// Returns list-of-spans representation of hidden/filtered states of columns/rows encoded as an OString.
1255 OString dumpHiddenFiltered(bool bColumns, bool bHidden);
1256 /// Returns list-of-spans representation of the column/row groupings encoded as an OString.
1257 OString dumpColumnRowGroups(bool bColumns) const;
1259 SCCOL GetLOKFreezeCol() const;
1260 SCROW GetLOKFreezeRow() const;
1261 bool SetLOKFreezeCol(SCCOL nFreezeCol);
1262 bool SetLOKFreezeRow(SCROW nFreezeRow);
1265 * Use this to iterate through non-empty visible cells in a single column.
1267 class VisibleDataCellIterator
1269 static constexpr SCROW ROW_NOT_FOUND = -1;
1271 public:
1272 explicit VisibleDataCellIterator(const ScDocument* pDoc, ScFlatBoolRowSegments& rRowSegs, ScColumn& rColumn);
1273 ~VisibleDataCellIterator();
1276 * Set the start row position. In case there is not visible data cell
1277 * at the specified row position, it will move to the position of the
1278 * first visible data cell below that point.
1280 * @return First visible data cell if found, or NULL otherwise.
1282 ScRefCellValue reset(SCROW nRow);
1285 * Find the next visible data cell position.
1287 * @return Next visible data cell if found, or NULL otherwise.
1289 ScRefCellValue next();
1292 * Get the current row position.
1294 * @return Current row position, or ROW_NOT_FOUND if the iterator
1295 * doesn't point to a valid data cell position.
1297 SCROW getRow() const { return mnCurRow;}
1299 private:
1300 const ScDocument* mpDocument;
1301 ScFlatBoolRowSegments& mrRowSegs;
1302 ScColumn& mrColumn;
1303 ScRefCellValue maCell;
1304 SCROW mnCurRow;
1305 SCROW mnUBound;
1310 #endif
1312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */