Revert "tdf#110987: type detection, binary Office formats > templates"
[LibreOffice.git] / sc / inc / table.hxx
blobe9aee6b689a5f87082c7ca5334e519fd732115fa
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 <vector>
24 #include <tools/gen.hxx>
25 #include <tools/color.hxx>
26 #include "attarray.hxx"
27 #include "column.hxx"
28 #include "colcontainer.hxx"
29 #include "sortparam.hxx"
30 #include "types.hxx"
31 #include "cellvalue.hxx"
32 #include <formula/types.hxx>
33 #include "calcmacros.hxx"
34 #include <formula/errorcodes.hxx>
35 #include "document.hxx"
37 #include <set>
38 #include <memory>
40 template <typename A, typename D> class ScBitMaskCompressedArray;
41 template <typename A, typename D> class ScCompressedArray;
43 namespace utl {
44 class TextSearch;
47 namespace com { namespace sun { namespace star {
48 namespace sheet {
49 struct TablePageBreakData;
51 } } }
53 namespace formula { struct VectorRefArray; }
54 namespace sc {
56 class StartListeningContext;
57 class EndListeningContext;
58 class CopyFromClipContext;
59 class CopyToClipContext;
60 class CopyToDocContext;
61 class MixDocContext;
62 class ColumnSpanSet;
63 class ColumnSet;
64 struct ColumnBlockPosition;
65 struct RefUpdateContext;
66 struct RefUpdateInsertTabContext;
67 struct RefUpdateDeleteTabContext;
68 struct RefUpdateMoveTabContext;
69 struct NoteEntry;
70 class DocumentStreamAccess;
71 class CellValues;
72 class TableValues;
73 class RowHeightContext;
74 class CompileFormulaContext;
75 struct SetFormulaDirtyContext;
76 class ColumnIterator;
80 class SfxItemSet;
81 class SfxStyleSheetBase;
82 class SvxBoxInfoItem;
83 class SvxBoxItem;
84 class SvxSearchItem;
86 class ScAutoFormatData;
87 class ScEditDataArray;
88 class ScFormulaCell;
89 class ScOutlineTable;
90 class ScPrintSaverTab;
91 class ScProgress;
92 class ScRangeList;
93 class ScSheetEvents;
94 class ScSortInfoArray;
95 class ScConditionalFormat;
96 class ScConditionalFormatList;
97 class ScStyleSheet;
98 class ScTableProtection;
99 class ScUserListData;
100 struct RowInfo;
101 struct ScFunctionData;
102 class CollatorWrapper;
103 class ScFlatUInt16RowSegments;
104 class ScFlatBoolRowSegments;
105 class ScFlatBoolColSegments;
106 struct ScSetStringParam;
107 struct ScColWidthParam;
108 class ScRangeName;
109 class ScDBData;
110 class ScHint;
111 class ScPostIt;
112 struct ScInterpreterContext;
115 class ScColumnsRange final
117 public:
118 class Iterator final
120 std::vector<std::unique_ptr<ScColumn>>::const_iterator maColIter;
121 public:
122 typedef std::input_iterator_tag iterator_category;
123 typedef SCCOL value_type;
124 typedef SCCOL difference_type;
125 typedef const SCCOL* pointer;
126 typedef SCCOL reference;
128 explicit Iterator(const std::vector<std::unique_ptr<ScColumn>>::const_iterator& colIter) : maColIter(colIter) {}
130 Iterator& operator++() { ++maColIter; return *this;}
131 Iterator& operator--() { --maColIter; return *this;}
133 bool operator==(const Iterator & rOther) const {return maColIter == rOther.maColIter;}
134 bool operator!=(const Iterator & rOther) const {return !(*this == rOther);}
135 SCCOL operator*() const {return (*maColIter)->GetCol();}
138 ScColumnsRange(const Iterator & rBegin, const Iterator & rEnd) : maBegin(rBegin), maEnd(rEnd) {}
139 const Iterator & begin() { return maBegin; }
140 const Iterator & end() { return maEnd; }
141 std::reverse_iterator<Iterator> rbegin() { return std::reverse_iterator<Iterator>(maEnd); }
142 std::reverse_iterator<Iterator> rend() { return std::reverse_iterator<Iterator>(maBegin); }
143 private:
144 const Iterator maBegin;
145 const Iterator maEnd;
148 class ScTable
150 private:
151 typedef ::std::vector< ScRange > ScRangeVec;
153 ScColContainer aCol;
155 OUString aName;
156 OUString aCodeName;
157 OUString aComment;
159 OUString aLinkDoc;
160 OUString aLinkFlt;
161 OUString aLinkOpt;
162 OUString aLinkTab;
163 sal_uLong nLinkRefreshDelay;
164 ScLinkMode nLinkMode;
166 // page style template
167 OUString aPageStyle;
168 Size aPageSizeTwips; // size of the print-page
169 SCCOL nRepeatStartX; // repeating rows/columns
170 SCCOL nRepeatEndX; // REPEAT_NONE, if not used
171 SCROW nRepeatStartY;
172 SCROW nRepeatEndY;
174 std::unique_ptr<ScTableProtection> pTabProtection;
176 std::unique_ptr<ScCompressedArray<SCCOL, sal_uInt16>> mpColWidth;
177 std::unique_ptr<ScFlatUInt16RowSegments> mpRowHeights;
179 std::unique_ptr<ScBitMaskCompressedArray<SCCOL, CRFlags>> mpColFlags;
180 std::unique_ptr<ScBitMaskCompressedArray< SCROW, CRFlags>> pRowFlags;
181 std::unique_ptr<ScFlatBoolColSegments> mpHiddenCols;
182 std::unique_ptr<ScFlatBoolRowSegments> mpHiddenRows;
183 std::unique_ptr<ScFlatBoolColSegments> mpFilteredCols;
184 std::unique_ptr<ScFlatBoolRowSegments> mpFilteredRows;
186 ::std::set<SCROW> maRowPageBreaks;
187 ::std::set<SCROW> maRowManualBreaks;
188 ::std::set<SCCOL> maColPageBreaks;
189 ::std::set<SCCOL> maColManualBreaks;
191 std::unique_ptr<ScOutlineTable> pOutlineTable;
193 std::unique_ptr<ScSheetEvents> pSheetEvents;
195 mutable SCCOL nTableAreaX;
196 mutable SCROW nTableAreaY;
198 SCTAB nTab;
199 ScDocument* pDocument;
200 std::unique_ptr<utl::TextSearch> pSearchText;
202 mutable OUString aUpperName; // #i62977# filled only on demand, reset in SetName
204 // sort parameter to minimize stack size of quicksort
205 ScSortParam aSortParam;
206 CollatorWrapper* pSortCollator;
208 ScRangeVec aPrintRanges;
210 std::unique_ptr<ScRange> pRepeatColRange;
211 std::unique_ptr<ScRange> pRepeatRowRange;
213 sal_uInt16 nLockCount;
215 std::unique_ptr<ScRangeList> pScenarioRanges;
216 Color aScenarioColor;
217 Color aTabBgColor;
218 ScScenarioFlags nScenarioFlags;
219 std::unique_ptr<ScDBData> pDBDataNoName;
220 mutable std::unique_ptr<ScRangeName> mpRangeName;
222 std::unique_ptr<ScConditionalFormatList> mpCondFormatList;
224 bool bScenario:1;
225 bool bLayoutRTL:1;
226 bool bLoadingRTL:1;
227 bool bPageSizeValid:1;
228 mutable bool bTableAreaValid:1;
229 bool bVisible:1;
230 bool bStreamValid:1;
231 bool bPendingRowHeights:1;
232 bool bCalcNotification:1;
233 bool bGlobalKeepQuery:1;
234 bool bPrintEntireSheet:1;
235 bool bActiveScenario:1;
236 bool mbPageBreaksValid:1;
237 bool mbForceBreaks:1;
239 // Default attributes for the unallocated columns.
240 ScAttrArray aDefaultColAttrArray;
242 friend class ScDocument; // for FillInfo
243 friend class ScColumn;
244 friend class ScValueIterator;
245 friend class ScHorizontalValueIterator;
246 friend class ScDBQueryDataIterator;
247 friend class ScFormulaGroupIterator;
248 friend class ScCellIterator;
249 friend class ScQueryCellIterator;
250 friend class ScHorizontalCellIterator;
251 friend class ScHorizontalAttrIterator;
252 friend class ScDocAttrIterator;
253 friend class ScAttrRectIterator;
254 friend class ScColumnTextWidthIterator;
255 friend class ScDocumentImport;
256 friend class sc::DocumentStreamAccess;
257 friend class sc::ColumnSpanSet;
258 friend class sc::EditTextIterator;
259 friend class sc::FormulaGroupAreaListener;
261 public:
262 ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
263 bool bColInfo = true, bool bRowInfo = true );
264 ~ScTable() COVERITY_NOEXCEPT_FALSE;
265 ScTable(const ScTable&) = delete;
266 ScTable& operator=(const ScTable&) = delete;
268 ScDocument& GetDoc() { return *pDocument;}
269 const ScDocument& GetDoc() const { return *pDocument;}
270 SCTAB GetTab() const { return nTab; }
272 ScOutlineTable* GetOutlineTable() { return pOutlineTable.get(); }
274 ScColumn& CreateColumnIfNotExists( const SCCOL nScCol )
276 if ( nScCol >= aCol.size() )
278 const SCCOL aOldColSize = aCol.size();
279 bool bUseEmptyAttrArray = false;
280 if ( aOldColSize == 0 )
281 bUseEmptyAttrArray = true;
282 aCol.resize( static_cast< size_t >( nScCol + 1 ) );
283 for (SCCOL i = aOldColSize; i <= nScCol; i++)
284 aCol[i].Init( i, nTab, pDocument, bUseEmptyAttrArray );
287 return aCol[nScCol];
289 sal_uLong GetCellCount() const;
290 sal_uLong GetWeightedCount() const;
291 sal_uLong GetCodeCount() const; // RPN code in formula
293 sal_uInt16 GetTextWidth(SCCOL nCol, SCROW nRow) const;
295 bool SetOutlineTable( const ScOutlineTable* pNewOutline );
296 void StartOutlineTable();
298 void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
300 bool TestRemoveSubTotals( const ScSubTotalParam& rParam );
301 void RemoveSubTotals( ScSubTotalParam& rParam );
302 bool DoSubTotals( ScSubTotalParam& rParam );
304 const ScSheetEvents* GetSheetEvents() const { return pSheetEvents.get(); }
305 void SetSheetEvents( std::unique_ptr<ScSheetEvents> pNew );
307 bool IsVisible() const { return bVisible; }
308 void SetVisible( bool bVis );
310 bool IsStreamValid() const { return bStreamValid; }
311 void SetStreamValid( bool bSet, bool bIgnoreLock = false );
313 SAL_WARN_UNUSED_RESULT bool IsColValid( const SCCOL nScCol ) const
315 return nScCol >= static_cast< SCCOL >( 0 ) && nScCol < aCol.size();
317 SAL_WARN_UNUSED_RESULT bool IsColRowValid( const SCCOL nScCol, const SCROW nScRow ) const
319 return IsColValid( nScCol ) && ValidRow( nScRow );
321 SAL_WARN_UNUSED_RESULT bool IsColRowTabValid( const SCCOL nScCol, const SCROW nScRow, const SCTAB nScTab ) const
323 return IsColValid( nScCol ) && ValidRow( nScRow ) && ValidTab( nScTab );
326 bool IsPendingRowHeights() const { return bPendingRowHeights; }
327 void SetPendingRowHeights( bool bSet );
329 bool GetCalcNotification() const { return bCalcNotification; }
330 void SetCalcNotification( bool bSet );
332 bool IsLayoutRTL() const { return bLayoutRTL; }
333 bool IsLoadingRTL() const { return bLoadingRTL; }
334 void SetLayoutRTL( bool bSet );
335 void SetLoadingRTL( bool bSet );
337 bool IsScenario() const { return bScenario; }
338 void SetScenario( bool bFlag );
339 void GetScenarioComment( OUString& rComment) const { rComment = aComment; }
340 void SetScenarioComment( const OUString& rComment ) { aComment = rComment; }
341 const Color& GetScenarioColor() const { return aScenarioColor; }
342 void SetScenarioColor(const Color& rNew) { aScenarioColor = rNew; }
343 const Color& GetTabBgColor() const { return aTabBgColor; }
344 void SetTabBgColor(const Color& rColor);
345 ScScenarioFlags GetScenarioFlags() const { return nScenarioFlags; }
346 void SetScenarioFlags(ScScenarioFlags nNew) { nScenarioFlags = nNew; }
347 void SetActiveScenario(bool bSet) { bActiveScenario = bSet; }
348 bool IsActiveScenario() const { return bActiveScenario; }
350 ScLinkMode GetLinkMode() const { return nLinkMode; }
351 bool IsLinked() const { return nLinkMode != ScLinkMode::NONE; }
352 const OUString& GetLinkDoc() const { return aLinkDoc; }
353 const OUString& GetLinkFlt() const { return aLinkFlt; }
354 const OUString& GetLinkOpt() const { return aLinkOpt; }
355 const OUString& GetLinkTab() const { return aLinkTab; }
356 sal_uLong GetLinkRefreshDelay() const { return nLinkRefreshDelay; }
358 void SetLink( ScLinkMode nMode, const OUString& rDoc, const OUString& rFlt,
359 const OUString& rOpt, const OUString& rTab, sal_uLong nRefreshDelay );
361 sal_Int64 GetHashCode () const;
363 const OUString& GetName() const { return aName; }
364 void SetName( const OUString& rNewName );
366 void SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData);
367 ScDBData* GetAnonymousDBData() { return pDBDataNoName.get();}
369 const OUString& GetCodeName() const { return aCodeName; }
370 void SetCodeName( const OUString& rNewName ) { aCodeName = rNewName; }
372 const OUString& GetUpperName() const;
374 const OUString& GetPageStyle() const { return aPageStyle; }
375 void SetPageStyle( const OUString& rName );
376 void PageStyleModified( const OUString& rNewName );
378 bool IsProtected() const;
379 void SetProtection(const ScTableProtection* pProtect);
380 ScTableProtection* GetProtection();
381 void GetUnprotectedCells( ScRangeList& rRangeList ) const;
383 bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCCOLROW nStart, SCCOLROW nEnd ) const;
385 Size GetPageSize() const;
386 void SetPageSize( const Size& rSize );
387 void SetRepeatArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
389 void LockTable();
390 void UnlockTable();
392 bool IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2,
393 SCROW nRow2, bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
394 bool IsSelectionEditable( const ScMarkData& rMark,
395 bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
397 bool HasBlockMatrixFragment( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 ) const;
398 bool HasSelectionMatrixFragment( const ScMarkData& rMark ) const;
400 bool IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bIgnoreNotes ) const;
402 bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
403 const ScSetStringParam * pParam = nullptr );
405 bool SetEditText( SCCOL nCol, SCROW nRow, std::unique_ptr<EditTextObject> pEditText );
406 void SetEditText( SCCOL nCol, SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
407 SCROW GetFirstEditTextRow( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
409 void SetEmptyCell( SCCOL nCol, SCROW nRow );
410 void SetFormula(
411 SCCOL nCol, SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram );
412 void SetFormula(
413 SCCOL nCol, SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram );
416 * Takes ownership of pCell
418 * @return pCell if it was successfully inserted, NULL otherwise. pCell
419 * is deleted automatically on failure to insert.
421 ScFormulaCell* SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell );
423 bool SetFormulaCells( SCCOL nCol, SCROW nRow, std::vector<ScFormulaCell*>& rCells );
425 bool HasFormulaCell( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 ) const;
427 svl::SharedString GetSharedString( SCCOL nCol, SCROW nRow ) const;
429 void SetValue( SCCOL nCol, SCROW nRow, const double& rVal );
430 void SetValues( const SCCOL nCol, const SCROW nRow, const std::vector<double>& rVals );
431 void SetError( SCCOL nCol, SCROW nRow, FormulaError nError);
432 SCSIZE GetPatternCount( SCCOL nCol ) const;
433 SCSIZE GetPatternCount( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
434 bool ReservePatternCount( SCCOL nCol, SCSIZE nReserve );
436 void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr );
437 void GetString( SCCOL nCol, SCROW nRow, OUString& rString,
438 const ScInterpreterContext* pContext = nullptr ) const;
439 double* GetValueCell( SCCOL nCol, SCROW nRow );
440 void GetInputString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
441 double GetValue( SCCOL nCol, SCROW nRow ) const;
442 const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const;
443 void RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
444 void GetFormula( SCCOL nCol, SCROW nRow, OUString& rFormula ) const;
445 const ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ) const;
446 ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow );
448 CellType GetCellType( const ScAddress& rPos ) const
450 return ValidColRow(rPos.Col(),rPos.Row()) ?
451 aCol[rPos.Col()].GetCellType( rPos.Row() ) :
452 CELLTYPE_NONE;
454 CellType GetCellType( SCCOL nCol, SCROW nRow ) const;
455 ScRefCellValue GetCellValue( SCCOL nCol, SCROW nRow ) const;
457 void GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const;
458 void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const;
460 ScPostIt* ReleaseNote( SCCOL nCol, SCROW nRow );
462 size_t GetNoteCount( SCCOL nCol ) const;
463 SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const;
464 void CreateAllNoteCaptions();
465 void ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bPreserveData );
467 void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
468 void GetNotesInRange( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes ) const;
469 CommentCaptionState GetAllNoteCaptionsState( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes );
470 bool ContainsNotesInRange( const ScRange& rRange ) const;
472 bool TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ) const;
473 void InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize );
474 void DeleteRow(
475 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize,
476 bool* pUndoOutline, std::vector<ScAddress>* pGroupPos );
478 bool TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const;
479 void InsertCol(
480 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize );
481 void DeleteCol(
482 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize, bool* pUndoOutline );
484 void DeleteArea(
485 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, InsertDeleteFlags nDelFlag,
486 bool bBroadcast = true, sc::ColumnSpanSet* pBroadcastSpans = nullptr );
488 void CopyToClip( sc::CopyToClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTable );
489 void CopyToClip( sc::CopyToClipContext& rCxt, const ScRangeList& rRanges, ScTable* pTable );
491 void CopyStaticToDocument(
492 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const SvNumberFormatterMergeMap& rMap,
493 ScTable* pDestTab );
495 void CopyCellToDocument( SCCOL nSrcCol, SCROW nSrcRow, SCCOL nDestCol, SCROW nDestRow, ScTable& rDestTab );
497 bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol );
499 void DeleteBeforeCopyFromClip(
500 sc::CopyFromClipContext& rCxt, const ScTable& rClipTab, sc::ColumnSpanSet& rBroadcastSpans );
502 void CopyOneCellFromClip(
503 sc::CopyFromClipContext& rCxt, const SCCOL nCol1, const SCROW nRow1,
504 const SCCOL nCol2, const SCROW nRow2,
505 const SCROW nSrcRow, const ScTable* pSrcTab );
507 void CopyFromClip(
508 sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
509 SCCOL nDx, SCROW nDy, ScTable* pTable );
511 void StartListeningFormulaCells(
512 sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt,
513 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
515 void SetDirtyFromClip(
516 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans );
518 void CopyToTable(
519 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
520 InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab,
521 const ScMarkData* pMarkData = nullptr, bool bAsLink = false, bool bColRowFlags = true,
522 bool bGlobalNamesToLocal = false, bool bCopyCaptions = true );
524 void CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab, bool bCloneCaption );
526 void UndoToTable(
527 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
528 InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab );
530 void CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
531 SCCOL nDx, SCROW nDy, const ScTable* pTable);
532 void TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
533 ScTable* pTransClip, InsertDeleteFlags nFlags, bool bAsLink );
535 // mark of this document
536 void MixMarked(
537 sc::MixDocContext& rCxt, const ScMarkData& rMark, ScPasteFunc nFunction,
538 bool bSkipEmpty, const ScTable* pSrcTab );
540 void MixData(
541 sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
542 ScPasteFunc nFunction, bool bSkipEmpty, const ScTable* pSrcTab );
544 void CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
545 SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab );
547 void CopyScenarioFrom( const ScTable* pSrcTab );
548 void CopyScenarioTo( ScTable* pDestTab ) const;
549 bool TestCopyScenarioTo( const ScTable* pDestTab ) const;
550 void MarkScenarioIn(ScMarkData& rMark, ScScenarioFlags nNeededBits) const;
551 bool HasScenarioRange( const ScRange& rRange ) const;
552 void InvalidateScenarioRanges();
553 const ScRangeList* GetScenarioRanges() const;
555 void CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const;
557 void InvalidateTableArea();
558 void InvalidatePageBreaks();
560 bool GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const; // FALSE = empty
561 bool GetTableArea( SCCOL& rEndCol, SCROW& rEndRow ) const;
562 bool GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes ) const;
563 bool GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow,
564 SCCOL& rEndCol ) const;
565 bool GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
566 SCROW& rEndRow, bool bNotes ) const;
568 bool GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const;
570 void ExtendPrintArea( OutputDevice* pDev,
571 SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow );
573 void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
574 bool bIncludeOld, bool bOnlyDown ) const;
576 bool ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow,
577 SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
578 bool bStickyTopRow, bool bStickyLeftCol, bool bConsiderCellNotes,
579 bool bConsiderCellDrawObjects ) const;
581 SCROW GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow,
582 bool bConsiderCellNotes = false, bool bConsiderCellDrawObjects = false ) const;
584 SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
585 SCCOL nEndCol, SCROW nEndRow, ScDirection eDir ) const;
587 void FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection ) const;
588 void GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY,
589 bool bMarked, bool bUnprotected, const ScMarkData& rMark ) const;
591 bool SkipRow( const SCCOL rCol, SCROW& rRow, const SCROW nMovY, const ScMarkData& rMark,
592 const bool bUp, const SCROW nUsedY, const bool bMarked, const bool bSheetProtected ) const;
593 void LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
595 bool HasData( SCCOL nCol, SCROW nRow ) const;
596 bool HasStringData( SCCOL nCol, SCROW nRow ) const;
597 bool HasValueData( SCCOL nCol, SCROW nRow ) const;
598 bool HasStringCells( SCCOL nStartCol, SCROW nStartRow,
599 SCCOL nEndCol, SCROW nEndRow ) const;
601 sc::MultiDataCellState HasMultipleDataCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
603 FormulaError GetErrCode( const ScAddress& rPos ) const
605 return IsColRowValid(rPos.Col(),rPos.Row()) ?
606 aCol[rPos.Col()].GetErrCode( rPos.Row() ) :
607 FormulaError::NONE;
610 void ResetChanged( const ScRange& rRange );
612 void CheckVectorizationState();
613 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
614 void SetDirty( const ScRange&, ScColumn::BroadcastMode );
615 void SetDirtyAfterLoad();
616 void SetDirtyVar();
617 void SetTableOpDirty( const ScRange& );
618 void CalcAll();
619 void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening );
620 void CompileAll( sc::CompileFormulaContext& rCxt );
621 void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress );
623 /** Broadcast single broadcasters in range, without explicitly setting
624 anything dirty, not doing area broadcasts.
625 @param rHint address is modified to adapt to the actual broadcasted
626 position on each iteration and upon return points to the last
627 position broadcasted. */
628 bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScHint& rHint );
630 bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode );
632 void UpdateReference(
633 sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr,
634 bool bIncludeDraw = true, bool bUpdateNoteCaptionPos = true );
636 void UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
637 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
638 SCCOL nDx, SCROW nDy, SCTAB nDz, bool bUpdateNoteCaptionPos = true );
640 void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
641 ScDocument* pUndoDoc );
643 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
645 void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
646 void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
647 void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo, ScProgress* pProgress );
648 void UpdateCompile( bool bForceIfNameInUse = false );
649 void SetTabNo(SCTAB nNewTab);
650 void FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
651 sc::UpdatedRangeNames& rIndexes) const;
652 void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
653 sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
654 double nStepValue, double nMaxValue, ScProgress* pProgress);
655 OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
657 void UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& rMark );
659 void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
660 sal_uInt16 nFormatNo );
661 void GetAutoFormatData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData& rData);
662 bool SearchAndReplace(
663 const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark,
664 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
666 void FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 );
668 bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, HasAttrFlags nMask ) const;
669 bool HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask ) const;
670 bool IsMerged( SCCOL nCol, SCROW nRow ) const;
671 bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
672 SCCOL& rEndCol, SCROW& rEndRow,
673 bool bRefresh );
674 void SetMergedCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
676 const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) const;
677 template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, TypedWhichId<T> nWhich ) const
679 return static_cast<const T*>(GetAttr(nCol, nRow, sal_uInt16(nWhich)));
681 const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow ) const;
682 const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
684 sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& rPos ) const;
685 sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow ) const;
686 sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
688 void SetNumberFormat( SCCOL nCol, SCROW nRow, sal_uInt32 nNumberFormat );
690 void MergeSelectionPattern( ScMergePatternState& rState,
691 const ScMarkData& rMark, bool bDeep ) const;
692 void MergePatternArea( ScMergePatternState& rState, SCCOL nCol1, SCROW nRow1,
693 SCCOL nCol2, SCROW nRow2, bool bDeep ) const;
694 void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
695 ScLineFlags& rFlags,
696 SCCOL nStartCol, SCROW nStartRow,
697 SCCOL nEndCol, SCROW nEndRow ) const;
698 void ApplyBlockFrame(const SvxBoxItem& rLineOuter,
699 const SvxBoxInfoItem* pLineInner,
700 SCCOL nStartCol, SCROW nStartRow,
701 SCCOL nEndCol, SCROW nEndRow );
703 void ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr );
704 void ApplyPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
705 void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
706 const ScPatternAttr& rAttr, ScEditDataArray* pDataArray = nullptr,
707 bool* const pIsChanged = nullptr );
709 void SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr )
711 if (ValidColRow(rPos.Col(),rPos.Row()))
712 aCol[rPos.Col()].SetPattern( rPos.Row(), rAttr );
714 void SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
715 void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
716 const ScPatternAttr& rPattern, SvNumFormatType nNewType );
717 void AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
718 void RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
720 void ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet* rStyle );
721 void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle );
722 void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
723 void ApplySelectionLineStyle( const ScMarkData& rMark,
724 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
726 const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow ) const;
727 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
728 const ScStyleSheet* GetAreaStyle( bool& rFound, SCCOL nCol1, SCROW nRow1,
729 SCCOL nCol2, SCROW nRow2 ) const;
731 void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
732 OutputDevice* pDev,
733 double nPPTX, double nPPTY,
734 const Fraction& rZoomX, const Fraction& rZoomY );
736 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
738 bool ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
739 bool RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
741 void ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
742 void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
744 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
745 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
747 const ScRange* GetRepeatColRange() const { return pRepeatColRange.get(); }
748 const ScRange* GetRepeatRowRange() const { return pRepeatRowRange.get(); }
749 void SetRepeatColRange( std::unique_ptr<ScRange> pNew );
750 void SetRepeatRowRange( std::unique_ptr<ScRange> pNew );
752 sal_uInt16 GetPrintRangeCount() const { return static_cast< sal_uInt16 >( aPrintRanges.size() ); }
753 const ScRange* GetPrintRange(sal_uInt16 nPos) const;
754 /** Returns true, if the sheet is always printed. */
755 bool IsPrintEntireSheet() const { return bPrintEntireSheet; }
757 /** Removes all print ranges. */
758 void ClearPrintRanges();
759 /** Adds a new print ranges. */
760 void AddPrintRange( const ScRange& rNew );
761 /** Marks the specified sheet to be printed completely. Deletes old print ranges! */
762 void SetPrintEntireSheet();
764 void FillPrintSaver( ScPrintSaverTab& rSaveTab ) const;
765 void RestorePrintRanges( const ScPrintSaverTab& rSaveTab );
767 sal_uInt16 GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev,
768 double nPPTX, double nPPTY,
769 const Fraction& rZoomX, const Fraction& rZoomY,
770 bool bFormula, const ScMarkData* pMarkData,
771 const ScColWidthParam* pParam );
772 bool SetOptimalHeight(
773 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
774 ScProgress* pOuterProgress = nullptr, sal_uLong nProgressStart = 0 );
776 void SetOptimalHeightOnly(
777 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
778 ScProgress* pOuterProgress = nullptr, sal_uLong nProgressStart = 0 );
780 long GetNeededSize( SCCOL nCol, SCROW nRow,
781 OutputDevice* pDev,
782 double nPPTX, double nPPTY,
783 const Fraction& rZoomX, const Fraction& rZoomY,
784 bool bWidth, bool bTotalSize );
785 void SetColWidth( SCCOL nCol, sal_uInt16 nNewWidth );
786 void SetColWidthOnly( SCCOL nCol, sal_uInt16 nNewWidth );
787 void SetRowHeight( SCROW nRow, sal_uInt16 nNewHeight );
788 bool SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight,
789 double nPPTY );
792 * Set specified row height to specified ranges. Don't check for drawing
793 * objects etc. Just set the row height. Nothing else.
795 * Note that setting a new row height via this function will not
796 * invalidate page breaks.
798 void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight );
800 // nPPT to test for modification
801 void SetManualHeight( SCROW nStartRow, SCROW nEndRow, bool bManual );
803 sal_uInt16 GetColWidth( SCCOL nCol, bool bHiddenAsZero = true ) const;
804 sal_uLong GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const;
805 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const;
806 sal_uLong GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true ) const;
807 sal_uLong GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const;
808 sal_uLong GetColOffset( SCCOL nCol, bool bHiddenAsZero = true ) const;
809 sal_uLong GetRowOffset( SCROW nRow, bool bHiddenAsZero = true ) const;
812 * Get the last row such that the height of row 0 to the end row is as
813 * high as possible without exceeding the specified height value.
815 * @param nHeight maximum desired height
817 * @return SCROW last row of the range within specified height.
819 SCROW GetRowForHeight(sal_uLong nHeight) const;
821 sal_uInt16 GetOriginalWidth( SCCOL nCol ) const;
822 sal_uInt16 GetOriginalHeight( SCROW nRow ) const;
824 sal_uInt16 GetCommonWidth( SCCOL nEndCol ) const;
826 SCROW GetHiddenRowCount( SCROW nRow ) const;
828 void ShowCol(SCCOL nCol, bool bShow);
829 void ShowRow(SCROW nRow, bool bShow);
830 void DBShowRow(SCROW nRow, bool bShow);
832 void ShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
833 void DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
835 void SetRowFlags( SCROW nRow, CRFlags nNewFlags );
836 void SetRowFlags( SCROW nStartRow, SCROW nEndRow, CRFlags nNewFlags );
838 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
839 SCROW GetLastFlaggedRow() const;
841 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
842 SCCOL GetLastChangedCol() const;
843 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
844 SCROW GetLastChangedRow() const;
846 bool IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SCROW nRowEnd) const;
847 bool IsDataFiltered(const ScRange& rRange) const;
848 CRFlags GetColFlags( SCCOL nCol ) const;
849 CRFlags GetRowFlags( SCROW nRow ) const;
851 const ScBitMaskCompressedArray< SCROW, CRFlags> * GetRowFlagsArray() const
852 { return pRowFlags.get(); }
854 bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, bool bShow );
855 bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, bool bShow );
857 void UpdatePageBreaks( const ScRange* pUserArea );
858 void RemoveManualBreaks();
859 bool HasManualBreaks() const;
860 void SetRowManualBreaks( const ::std::set<SCROW>& rBreaks );
861 void SetColManualBreaks( const ::std::set<SCCOL>& rBreaks );
863 void GetAllRowBreaks(::std::set<SCROW>& rBreaks, bool bPage, bool bManual) const;
864 void GetAllColBreaks(::std::set<SCCOL>& rBreaks, bool bPage, bool bManual) const;
865 bool HasRowPageBreak(SCROW nRow) const;
866 bool HasColPageBreak(SCCOL nCol) const;
867 bool HasRowManualBreak(SCROW nRow) const;
868 bool HasColManualBreak(SCCOL nCol) const;
871 * Get the row position of the next manual break that occurs at or below
872 * specified row. When no more manual breaks are present at or below
873 * the specified row, -1 is returned.
875 * @param nRow row at which the search begins.
877 * @return SCROW next row position with manual page break, or -1 if no
878 * more manual breaks are present.
880 SCROW GetNextManualBreak(SCROW nRow) const;
882 void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow);
883 void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual);
884 void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual);
885 void SetRowBreak(SCROW nRow, bool bPage, bool bManual);
886 void SetColBreak(SCCOL nCol, bool bPage, bool bManual);
887 css::uno::Sequence<
888 css::sheet::TablePageBreakData> GetRowBreakData() const;
890 bool RowHidden(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
891 bool RowHiddenLeaf(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
892 bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const;
893 bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
894 bool SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden);
895 void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden);
896 void CopyColHidden(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
897 void CopyRowHidden(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
898 void CopyRowHeight(const ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset);
899 SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
900 SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
901 SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const;
902 sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true) const;
904 SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const;
906 bool RowFiltered(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
907 bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
908 bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const;
909 void CopyColFiltered(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
910 void CopyRowFiltered(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
911 void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered);
912 void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered);
913 SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const;
914 SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const;
915 SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const;
917 bool IsManualRowHeight(SCROW nRow) const;
919 bool HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const;
921 void SyncColRowFlags();
923 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
924 void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
926 /** Sort a range of data. */
927 void Sort(
928 const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
929 ScProgress* pProgress, sc::ReorderParam* pUndo );
931 void Reorder( const sc::ReorderParam& rParam );
933 bool ValidQuery(
934 SCROW nRow, const ScQueryParam& rQueryParam, const ScRefCellValue* pCell = nullptr,
935 bool* pbTestEqualCondition = nullptr, const ScInterpreterContext* pContext = nullptr);
936 void TopTenQuery( ScQueryParam& );
937 SCSIZE Query(const ScQueryParam& rQueryParam, bool bKeepSub);
938 bool CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
940 void GetFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, ScFilterEntries& rFilterEntries );
941 void GetFilteredFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScQueryParam& rParam, ScFilterEntries& rFilterEntries );
942 SAL_WARN_UNUSED_RESULT
943 bool GetDataEntries(SCCOL nCol, SCROW nRow, std::set<ScTypedStrData>& rStrings, bool bLimit);
945 bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
946 bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
948 sal_Int32 GetMaxStringLen( SCCOL nCol,
949 SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
950 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
951 SCCOL nCol,
952 SCROW nRowStart, SCROW nRowEnd ) const;
954 bool IsSortCollatorGlobal() const;
955 void InitSortCollator( const ScSortParam& rPar );
956 void DestroySortCollator();
957 void SetDrawPageSize( bool bResetStreamValid = true, bool bUpdateNoteCaptionPos = true );
959 void SetRangeName(std::unique_ptr<ScRangeName> pNew);
960 ScRangeName* GetRangeName() const;
962 void PreprocessRangeNameUpdate(
963 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
965 void CompileHybridFormula(
966 sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt );
968 void PreprocessDBDataUpdate(
969 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
971 ScConditionalFormatList* GetCondFormList();
972 const ScConditionalFormatList* GetCondFormList() const;
973 void SetCondFormList( ScConditionalFormatList* pList );
975 void DeleteConditionalFormat(sal_uLong nOldIndex);
977 sal_uLong AddCondFormat( ScConditionalFormat* pNew );
979 SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow ) const;
980 void SetScriptType( SCCOL nCol, SCROW nRow, SvtScriptType nType );
981 void UpdateScriptTypes( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 );
983 SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
985 size_t GetFormulaHash( SCCOL nCol, SCROW nRow ) const;
987 ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const;
988 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol, SCROW nRow );
989 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
990 formula::VectorRefArray FetchVectorRefArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
991 bool HandleRefArrayForParallelism( SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScFormulaCellGroupRef& mxGroup );
993 void SplitFormulaGroups( SCCOL nCol, std::vector<SCROW>& rRows );
994 void UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows );
995 void RegroupFormulaCells( SCCOL nCol );
997 ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
999 SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow );
1000 const SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow ) const;
1001 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
1003 void FillMatrix( ScMatrix& rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool* pPool ) const;
1005 void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1007 void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, size_t nLen );
1009 void CalculateInColumnInThread( ScInterpreterContext& rContext, SCCOL nCol, SCROW nRow, size_t nLen, unsigned nThisThread, unsigned nThreadsTotal);
1010 void HandleStuffAfterParallelCalculation( SCCOL nCol, SCROW nRow, size_t nLen);
1013 * Either start all formula cells as listeners unconditionally, or start
1014 * those that are marked "needs listening".
1016 * @param rCxt context object.
1017 * @param bAll when true, start all formula cells as listeners. When
1018 * false, only start those that are marked "needs listening".
1020 void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
1023 * Mark formula cells dirty that have the mbPostponedDirty flag set or
1024 * contain named ranges with relative references.
1026 void SetDirtyIfPostponed();
1029 * Broadcast dirty formula cells that contain functions such as CELL(),
1030 * COLUMN() or ROW() which may change its value on move.
1032 void BroadcastRecalcOnRefMove();
1034 void CollectListeners( std::vector<SvtListener*>& rListeners, const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 );
1036 void TransferListeners(
1037 ScTable& rDestTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1038 SCCOL nColDelta, SCROW nRowDelta );
1040 void TransferCellValuesTo( const SCCOL nCol, SCROW nRow, size_t nLen, sc::CellValues& rDest );
1041 void CopyCellValuesFrom( const SCCOL nCol, SCROW nRow, const sc::CellValues& rSrc );
1043 std::unique_ptr<sc::ColumnIterator> GetColumnIterator( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
1045 void EnsureFormulaCellResults( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 );
1047 void ConvertFormulaToValue(
1048 sc::EndListeningContext& rCxt,
1049 const SCCOL nCol1, const SCROW nRow1, const SCCOL nCol2, const SCROW nRow2,
1050 sc::TableValues* pUndo );
1052 void SwapNonEmpty(
1053 sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
1055 void finalizeOutlineImport();
1057 void StoreToCache(SvStream& rStrm) const;
1059 void RestoreFromCache(SvStream& rStrm);
1061 #if DUMP_COLUMN_STORAGE
1062 void DumpColumnStorage( SCCOL nCol ) const;
1063 #endif
1065 /** Replace behaves differently to the Search; adjust the rCol and rRow accordingly.
1067 'Replace' replaces at the 'current' position, but in order to achieve
1068 that, we have to 'shift' the rCol / rRow to the 'previous' position -
1069 what it is depends on various settings in rSearchItem.
1071 static void UpdateSearchItemAddressForReplace( const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow );
1073 ScColumnsRange GetColumnsRange(SCCOL begin, SCCOL end) const;
1075 private:
1077 void FillFormulaVertical(
1078 const ScFormulaCell& rSrcCell,
1079 SCCOLROW& rInner, SCCOL nCol, SCROW nRow1, SCROW nRow2,
1080 ScProgress* pProgress, sal_uLong& rProgress );
1082 void FillSeriesSimple(
1083 const ScCellValue& rSrcCell, SCCOLROW& rInner, SCCOLROW nIMin, SCCOLROW nIMax,
1084 const SCCOLROW& rCol, const SCCOLROW& rRow, bool bVertical, ScProgress* pProgress, sal_uLong& rProgress );
1086 void FillAutoSimple(
1087 SCCOLROW nISrcStart, SCCOLROW nISrcEnd, SCCOLROW nIStart, SCCOLROW nIEnd,
1088 SCCOLROW& rInner, const SCCOLROW& rCol, const SCCOLROW& rRow,
1089 sal_uLong nActFormCnt, sal_uLong nMaxFormCnt,
1090 bool bHasFiltered, bool bVertical, bool bPositive,
1091 ScProgress* pProgress, sal_uLong& rProgress );
1093 void FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1094 sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd,
1095 FillDateCmd eFillDateCmd,
1096 double nStepValue, double nMaxValue, sal_uInt16 nMinDigits,
1097 bool bAttribs, ScProgress* pProgress );
1098 void FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1099 FillCmd& rCmd, FillDateCmd& rDateCmd,
1100 double& rInc, sal_uInt16& rMinDigits,
1101 ScUserListData*& rListData, sal_uInt16& rListIndex);
1102 void FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1103 sal_uLong nFillCount, FillDir eFillDir, ScProgress* pProgress );
1105 bool ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
1106 bool bMarked, bool bUnprotected ) const;
1108 void AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1109 const ScPatternAttr& rAttr, sal_uInt16 nFormatNo);
1110 void GetAutoFormatAttr(SCCOL nCol, SCROW nRow, sal_uInt16 nIndex, ScAutoFormatData& rData);
1111 void GetAutoFormatFrame(SCCOL nCol, SCROW nRow, sal_uInt16 nFlags, sal_uInt16 nIndex, ScAutoFormatData& rData);
1112 bool SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRow,
1113 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1114 bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1115 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1116 bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1117 SCCOL nLastCol, SCROW nLastRow,
1118 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1119 bool SearchAll(const SvxSearchItem& rSearchItem, const ScMarkData& rMark,
1120 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1121 bool Replace(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1122 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1123 bool ReplaceAll(
1124 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1125 OUString& rUndoStr, ScDocument* pUndoDoc);
1127 bool SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1128 const ScMarkData& rMark);
1129 bool ReplaceStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1130 const ScMarkData& rMark, bool bIsUndo);
1131 bool SearchAllStyle(
1132 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges);
1133 bool ReplaceAllStyle(
1134 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1135 ScDocument* pUndoDoc);
1136 bool SearchAndReplaceEmptyCells(
1137 const SvxSearchItem& rSearchItem,
1138 SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1139 OUString& rUndoStr, ScDocument* pUndoDoc);
1140 bool SearchRangeForEmptyCell(const ScRange& rRange,
1141 const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1142 OUString& rUndoStr);
1143 bool SearchRangeForAllEmptyCells(
1144 const ScRange& rRange, const SvxSearchItem& rSearchItem,
1145 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1147 // use the global sort parameter:
1148 bool IsSorted(SCCOLROW nStart, SCCOLROW nEnd) const;
1149 static void DecoladeRow( ScSortInfoArray*, SCROW nRow1, SCROW nRow2 );
1150 short CompareCell(
1151 sal_uInt16 nSort,
1152 ScRefCellValue& rCell1, SCCOL nCell1Col, SCROW nCell1Row,
1153 ScRefCellValue& rCell2, SCCOL nCell2Col, SCROW nCell2Row ) const;
1154 short Compare(SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1155 short Compare( ScSortInfoArray*, SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1156 std::unique_ptr<ScSortInfoArray> CreateSortInfoArray( const sc::ReorderParam& rParam );
1157 std::unique_ptr<ScSortInfoArray> CreateSortInfoArray(
1158 const ScSortParam& rSortParam, SCCOLROW nInd1, SCCOLROW nInd2,
1159 bool bKeepQuery, bool bUpdateRefs );
1160 void QuickSort( ScSortInfoArray*, SCCOLROW nLo, SCCOLROW nHi);
1161 void SortReorderByColumn( const ScSortInfoArray* pArray, SCROW nRow1, SCROW nRow2, bool bPattern, ScProgress* pProgress );
1163 void SortReorderByRow( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress );
1164 void SortReorderByRowRefUpdate( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress );
1166 bool CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1167 bool CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1168 void GetUpperCellString(SCCOL nCol, SCROW nRow, OUString& rStr);
1170 bool RefVisible(const ScFormulaCell* pCell);
1172 bool IsEmptyLine(SCROW nRow, SCCOL nStartCol, SCCOL nEndCol) const;
1174 void IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillDateCmd eCmd);
1175 void FillFormula(
1176 const ScFormulaCell* pSrcCell, SCCOL nDestCol, SCROW nDestRow, bool bLast );
1177 void UpdateInsertTabAbs(SCTAB nNewPos);
1178 bool GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, bool bInSel,
1179 const ScMarkData& rMark) const;
1180 bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark ) const;
1181 void TestTabRefAbs(SCTAB nTable) const;
1182 void CompileDBFormula( sc::CompileFormulaContext& rCxt );
1183 void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt );
1185 void StartListening( const ScAddress& rAddress, SvtListener* pListener );
1186 void EndListening( const ScAddress& rAddress, SvtListener* pListener );
1187 void StartListening( sc::StartListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
1188 void EndListening( sc::EndListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
1190 void AttachFormulaCells( sc::StartListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1191 void DetachFormulaCells( sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1193 void SetLoadingMedium(bool bLoading);
1195 SCSIZE FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2,
1196 SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY,
1197 const ScPatternAttr* pPattern, const SfxItemSet* pCondSet );
1199 // idle calculation of OutputDevice text width for cell
1200 // also invalidates script type, broadcasts for "calc as shown"
1201 void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
1202 bool bNumFormatChanged, bool bBroadcast );
1204 void SkipFilteredRows(SCROW& rRow, SCROW& rLastNonFilteredRow, bool bForward);
1207 * In case the cell text goes beyond the column width, move the max column
1208 * position to the right. This is called from ExtendPrintArea.
1210 void MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY);
1212 void CopyPrintRange(const ScTable& rTable);
1214 SCCOL FindNextVisibleColWithContent(SCCOL nCol, bool bRight, SCROW nRow) const;
1216 SCCOL FindNextVisibleCol(SCCOL nCol, bool bRight) const;
1218 // Clipboard transpose for notes
1219 void TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1, SCROW nRow2);
1221 ScColumn* FetchColumn( SCCOL nCol );
1222 const ScColumn* FetchColumn( SCCOL nCol ) const;
1224 void EndListeningIntersectedGroup(
1225 sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow, std::vector<ScAddress>* pGroupPos );
1227 void EndListeningIntersectedGroups(
1228 sc::EndListeningContext& rCxt, const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2,
1229 std::vector<ScAddress>* pGroupPos );
1231 void EndListeningGroup( sc::EndListeningContext& rCxt, const SCCOL nCol, SCROW nRow );
1232 void SetNeedsListeningGroup( SCCOL nCol, SCROW nRow );
1235 * Use this to iterate through non-empty visible cells in a single column.
1237 class VisibleDataCellIterator
1239 static constexpr SCROW ROW_NOT_FOUND = -1;
1241 public:
1242 explicit VisibleDataCellIterator(ScFlatBoolRowSegments& rRowSegs, ScColumn& rColumn);
1243 ~VisibleDataCellIterator();
1246 * Set the start row position. In case there is not visible data cell
1247 * at the specified row position, it will move to the position of the
1248 * first visible data cell below that point.
1250 * @return First visible data cell if found, or NULL otherwise.
1252 ScRefCellValue reset(SCROW nRow);
1255 * Find the next visible data cell position.
1257 * @return Next visible data cell if found, or NULL otherwise.
1259 ScRefCellValue next();
1262 * Get the current row position.
1264 * @return Current row position, or ROW_NOT_FOUND if the iterator
1265 * doesn't point to a valid data cell position.
1267 SCROW getRow() const { return mnCurRow;}
1269 private:
1270 ScFlatBoolRowSegments& mrRowSegs;
1271 ScColumn& mrColumn;
1272 ScRefCellValue maCell;
1273 SCROW mnCurRow;
1274 SCROW mnUBound;
1279 #endif
1281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */