LOK: tilebench improvements
[LibreOffice.git] / sc / inc / table.hxx
blob12a961b59a5991adc54ecf3d44908ea734e9a16f
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 <utility>
25 #include <tools/gen.hxx>
26 #include <tools/color.hxx>
27 #include <com/sun/star/uno/Sequence.hxx>
28 #include "attarray.hxx"
29 #include "column.hxx"
30 #include "colcontainer.hxx"
31 #include "sortparam.hxx"
32 #include "compressedarray.hxx"
33 #include "postit.hxx"
34 #include "types.hxx"
35 #include "cellvalue.hxx"
36 #include <formula/types.hxx>
37 #include "calcmacros.hxx"
38 #include <formula/errorcodes.hxx>
39 #include "document.hxx"
41 #include <set>
42 #include <map>
43 #include <memory>
45 namespace utl {
46 class TextSearch;
49 namespace com { namespace sun { namespace star {
50 namespace sheet {
51 struct TablePageBreakData;
53 } } }
55 namespace formula { struct VectorRefArray; }
56 namespace sc {
58 struct FormulaGroupContext;
59 class StartListeningContext;
60 class EndListeningContext;
61 class CopyFromClipContext;
62 class CopyToClipContext;
63 class CopyToDocContext;
64 class MixDocContext;
65 class ColumnSpanSet;
66 class ColumnSet;
67 struct ColumnBlockPosition;
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 RefMovedHint;
80 struct ReorderParam;
81 class ColumnIterator;
85 class SfxItemSet;
86 class SfxStyleSheetBase;
87 class SvxBoxInfoItem;
88 class SvxBoxItem;
89 class SvxSearchItem;
91 class ScAutoFormatData;
92 class ScDocument;
93 class ScEditDataArray;
94 class ScFormulaCell;
95 class ScOutlineTable;
96 class ScPrintSaverTab;
97 class ScProgress;
98 class ScRangeList;
99 class ScSheetEvents;
100 class ScSortInfoArray;
101 class ScConditionalFormat;
102 class ScConditionalFormatList;
103 class ScStyleSheet;
104 class ScTableProtection;
105 class ScUserListData;
106 struct RowInfo;
107 struct ScFunctionData;
108 struct ScLineFlags;
109 class CollatorWrapper;
110 class ScFlatUInt16RowSegments;
111 class ScFlatBoolRowSegments;
112 class ScFlatBoolColSegments;
113 struct ScSetStringParam;
114 struct ScColWidthParam;
115 class ScRangeName;
116 class ScDBData;
117 class ScDocumentImport;
118 class ScHint;
119 struct ScInterpreterContext;
121 class ScColumnsRange final
123 public:
124 class Iterator final : public std::iterator<
125 std::input_iterator_tag, // iterator_category
126 SCCOL, // value_type
127 SCCOL, // difference_type
128 const SCCOL*, // pointer
129 SCCOL> // reference
131 std::vector<ScColumn*>::const_iterator maColIter;
132 public:
133 explicit Iterator(std::vector<ScColumn*>::const_iterator colIter) : maColIter(colIter) {}
135 Iterator& operator++() { maColIter++; return *this;}
136 Iterator& operator--() { maColIter--; return *this;}
138 bool operator==(Iterator other) const {return maColIter == other.maColIter;}
139 bool operator!=(Iterator other) const {return !(*this == other);}
140 reference operator*() const {return (*maColIter)->GetCol();}
143 ScColumnsRange(Iterator nBegin, Iterator nEnd) : maBegin(nBegin), maEnd(nEnd) {}
144 const Iterator & begin() { return maBegin; }
145 const Iterator & end() { return maEnd; }
146 std::reverse_iterator<Iterator> rbegin() { return std::reverse_iterator<Iterator>(maEnd); }
147 std::reverse_iterator<Iterator> rend() { return std::reverse_iterator<Iterator>(maBegin); }
148 private:
149 const Iterator maBegin;
150 const Iterator maEnd;
153 class ScTable
155 private:
156 typedef ::std::vector< ScRange > ScRangeVec;
158 ScColContainer aCol;
160 OUString aName;
161 OUString aCodeName;
162 OUString aComment;
164 OUString aLinkDoc;
165 OUString aLinkFlt;
166 OUString aLinkOpt;
167 OUString aLinkTab;
168 sal_uLong nLinkRefreshDelay;
169 ScLinkMode nLinkMode;
171 // page style template
172 OUString aPageStyle;
173 Size aPageSizeTwips; // size of the print-page
174 SCCOL nRepeatStartX; // repeating rows/columns
175 SCCOL nRepeatEndX; // REPEAT_NONE, if not used
176 SCROW nRepeatStartY;
177 SCROW nRepeatEndY;
179 std::unique_ptr<ScTableProtection> pTabProtection;
181 std::unique_ptr<ScCompressedArray<SCCOL, sal_uInt16>> mpColWidth;
182 std::unique_ptr<ScFlatUInt16RowSegments> mpRowHeights;
184 std::unique_ptr<ScBitMaskCompressedArray<SCCOL, CRFlags>> mpColFlags;
185 ScBitMaskCompressedArray< SCROW, CRFlags>* pRowFlags;
186 std::unique_ptr<ScFlatBoolColSegments> mpHiddenCols;
187 std::unique_ptr<ScFlatBoolRowSegments> mpHiddenRows;
188 std::unique_ptr<ScFlatBoolColSegments> mpFilteredCols;
189 std::unique_ptr<ScFlatBoolRowSegments> mpFilteredRows;
191 ::std::set<SCROW> maRowPageBreaks;
192 ::std::set<SCROW> maRowManualBreaks;
193 ::std::set<SCCOL> maColPageBreaks;
194 ::std::set<SCCOL> maColManualBreaks;
196 ScOutlineTable* pOutlineTable;
198 ScSheetEvents* pSheetEvents;
200 mutable SCCOL nTableAreaX;
201 mutable SCROW nTableAreaY;
203 SCTAB nTab;
204 ScDocument* pDocument;
205 utl::TextSearch* pSearchText;
207 mutable OUString aUpperName; // #i62977# filled only on demand, reset in SetName
209 // sort parameter to minimize stack size of quicksort
210 ScSortParam aSortParam;
211 CollatorWrapper* pSortCollator;
213 ScRangeVec aPrintRanges;
215 ScRange* pRepeatColRange;
216 ScRange* pRepeatRowRange;
218 sal_uInt16 nLockCount;
220 ScRangeList* pScenarioRanges;
221 Color aScenarioColor;
222 Color aTabBgColor;
223 ScScenarioFlags nScenarioFlags;
224 ScDBData* pDBDataNoName;
225 mutable ScRangeName* mpRangeName;
227 std::unique_ptr<ScConditionalFormatList> mpCondFormatList;
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 ScHorizontalCellIterator;
256 friend class ScHorizontalAttrIterator;
257 friend class ScDocAttrIterator;
258 friend class ScAttrRectIterator;
259 friend class ScColumnTextWidthIterator;
260 friend class ScDocumentImport;
261 friend class sc::DocumentStreamAccess;
262 friend class sc::ColumnSpanSet;
263 friend class sc::EditTextIterator;
264 friend class sc::FormulaGroupAreaListener;
266 public:
267 ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
268 bool bColInfo = true, bool bRowInfo = true );
269 ~ScTable() COVERITY_NOEXCEPT_FALSE;
270 ScTable(const ScTable&) = delete;
271 ScTable& operator=(const ScTable&) = delete;
273 ScDocument& GetDoc() { return *pDocument;}
274 const ScDocument& GetDoc() const { return *pDocument;}
275 SCTAB GetTab() const { return nTab; }
277 ScOutlineTable* GetOutlineTable() { return pOutlineTable; }
279 ScColumn& CreateColumnIfNotExists( SCCOL nScCol )
281 if ( nScCol >= aCol.size() )
283 SCCOL aOldColSize = aCol.size();
284 bool bUseEmptyAttrArray = false;
285 if ( aOldColSize == 0 )
286 bUseEmptyAttrArray = true;
287 aCol.resize( static_cast< size_t >( nScCol + 1 ) );
288 for (SCCOL i = aOldColSize; i <= nScCol; i++)
289 aCol[i].Init( i, nTab, pDocument, bUseEmptyAttrArray );
292 return aCol[nScCol];
294 sal_uLong GetCellCount() const;
295 sal_uLong GetWeightedCount() const;
296 sal_uLong GetCodeCount() const; // RPN code in formula
298 sal_uInt16 GetTextWidth(SCCOL nCol, SCROW nRow) const;
300 bool SetOutlineTable( const ScOutlineTable* pNewOutline );
301 void StartOutlineTable();
303 void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
305 bool TestRemoveSubTotals( const ScSubTotalParam& rParam );
306 void RemoveSubTotals( ScSubTotalParam& rParam );
307 bool DoSubTotals( ScSubTotalParam& rParam );
309 const ScSheetEvents* GetSheetEvents() const { return pSheetEvents; }
310 void SetSheetEvents( const ScSheetEvents* pNew );
312 bool IsVisible() const { return bVisible; }
313 void SetVisible( bool bVis );
315 bool IsStreamValid() const { return bStreamValid; }
316 void SetStreamValid( bool bSet, bool bIgnoreLock = false );
318 SAL_WARN_UNUSED_RESULT bool IsColValid( SCCOL nScCol ) const
320 return nScCol >= static_cast< SCCOL >( 0 ) && nScCol < aCol.size();
322 SAL_WARN_UNUSED_RESULT bool IsColRowValid( SCCOL nScCol, SCROW nScRow ) const
324 return IsColValid( nScCol ) && ValidRow( nScRow );
326 SAL_WARN_UNUSED_RESULT bool IsColRowTabValid( SCCOL nScCol, SCROW nScRow, SCTAB nScTab ) const
328 return IsColValid( nScCol ) && ValidRow( nScRow ) && ValidTab( nScTab );
331 bool IsPendingRowHeights() const { return bPendingRowHeights; }
332 void SetPendingRowHeights( bool bSet );
334 bool GetCalcNotification() const { return bCalcNotification; }
335 void SetCalcNotification( bool bSet );
337 bool IsLayoutRTL() const { return bLayoutRTL; }
338 bool IsLoadingRTL() const { return bLoadingRTL; }
339 void SetLayoutRTL( bool bSet );
340 void SetLoadingRTL( bool bSet );
342 bool IsScenario() const { return bScenario; }
343 void SetScenario( bool bFlag );
344 void GetScenarioComment( OUString& rComment) const { rComment = aComment; }
345 void SetScenarioComment( const OUString& rComment ) { aComment = rComment; }
346 const Color& GetScenarioColor() const { return aScenarioColor; }
347 void SetScenarioColor(const Color& rNew) { aScenarioColor = rNew; }
348 const Color& GetTabBgColor() const { return aTabBgColor; }
349 void SetTabBgColor(const Color& rColor);
350 ScScenarioFlags GetScenarioFlags() const { return nScenarioFlags; }
351 void SetScenarioFlags(ScScenarioFlags nNew) { nScenarioFlags = nNew; }
352 void SetActiveScenario(bool bSet) { bActiveScenario = bSet; }
353 bool IsActiveScenario() const { return bActiveScenario; }
355 ScLinkMode GetLinkMode() const { return nLinkMode; }
356 bool IsLinked() const { return nLinkMode != ScLinkMode::NONE; }
357 const OUString& GetLinkDoc() const { return aLinkDoc; }
358 const OUString& GetLinkFlt() const { return aLinkFlt; }
359 const OUString& GetLinkOpt() const { return aLinkOpt; }
360 const OUString& GetLinkTab() const { return aLinkTab; }
361 sal_uLong GetLinkRefreshDelay() const { return nLinkRefreshDelay; }
363 void SetLink( ScLinkMode nMode, const OUString& rDoc, const OUString& rFlt,
364 const OUString& rOpt, const OUString& rTab, sal_uLong nRefreshDelay );
366 sal_Int64 GetHashCode () const;
368 void GetName( OUString& rName ) const;
369 void SetName( const OUString& rNewName );
371 void SetAnonymousDBData(ScDBData* pDBData);
372 ScDBData* GetAnonymousDBData() { return pDBDataNoName;}
374 void GetCodeName( OUString& rName ) const { rName = aCodeName; }
375 void SetCodeName( const OUString& rNewName ) { aCodeName = rNewName; }
377 const OUString& GetUpperName() const;
379 const OUString& GetPageStyle() const { return aPageStyle; }
380 void SetPageStyle( const OUString& rName );
381 void PageStyleModified( const OUString& rNewName );
383 bool IsProtected() const;
384 void SetProtection(const ScTableProtection* pProtect);
385 ScTableProtection* GetProtection();
386 void GetUnprotectedCells( ScRangeList& rRangeList ) const;
388 bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCCOLROW nStart, SCCOLROW nEnd ) const;
390 Size GetPageSize() const;
391 void SetPageSize( const Size& rSize );
392 void SetRepeatArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
394 void LockTable();
395 void UnlockTable();
397 bool IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2,
398 SCROW nRow2, bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
399 bool IsSelectionEditable( const ScMarkData& rMark,
400 bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
402 bool HasBlockMatrixFragment( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
403 bool HasSelectionMatrixFragment( const ScMarkData& rMark ) const;
405 bool IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bIgnoreNotes ) const;
407 bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
408 ScSetStringParam* pParam = nullptr );
410 bool SetEditText( SCCOL nCol, SCROW nRow, EditTextObject* pEditText );
411 void SetEditText( SCCOL nCol, SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
412 SCROW GetFirstEditTextRow( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
414 void SetEmptyCell( SCCOL nCol, SCROW nRow );
415 void SetFormula(
416 SCCOL nCol, SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram );
417 void SetFormula(
418 SCCOL nCol, SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram );
421 * Takes ownership of pCell
423 * @return pCell if it was successfully inserted, NULL otherwise. pCell
424 * is deleted automatically on failure to insert.
426 ScFormulaCell* SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell );
428 bool SetFormulaCells( SCCOL nCol, SCROW nRow, std::vector<ScFormulaCell*>& rCells );
430 bool HasFormulaCell( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
432 svl::SharedString GetSharedString( SCCOL nCol, SCROW nRow ) const;
434 void SetValue( SCCOL nCol, SCROW nRow, const double& rVal );
435 void SetValues( SCCOL nCol, SCROW nRow, const std::vector<double>& rVals );
436 void SetError( SCCOL nCol, SCROW nRow, FormulaError nError);
437 SCSIZE GetPatternCount( SCCOL nCol ) const;
438 SCSIZE GetPatternCount( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
439 bool ReservePatternCount( SCCOL nCol, SCSIZE nReserve );
441 void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr );
442 void GetString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
443 double* GetValueCell( SCCOL nCol, SCROW nRow );
444 void GetInputString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
445 double GetValue( SCCOL nCol, SCROW nRow ) const;
446 const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const;
447 void RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
448 void GetFormula( SCCOL nCol, SCROW nRow, OUString& rFormula ) const;
449 const ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ) const;
450 ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow );
452 CellType GetCellType( const ScAddress& rPos ) const
454 return ValidColRow(rPos.Col(),rPos.Row()) ?
455 aCol[rPos.Col()].GetCellType( rPos.Row() ) :
456 CELLTYPE_NONE;
458 CellType GetCellType( SCCOL nCol, SCROW nRow ) const;
459 ScRefCellValue GetCellValue( SCCOL nCol, SCROW nRow ) const;
461 void GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const;
462 void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const;
464 ScPostIt* ReleaseNote( SCCOL nCol, SCROW nRow );
466 size_t GetNoteCount( SCCOL nCol ) const;
467 SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const;
468 void CreateAllNoteCaptions();
469 void ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bPreserveData );
471 void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
472 void GetNotesInRange( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes ) const;
473 CommentCaptionState GetAllNoteCaptionsState( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes );
474 bool ContainsNotesInRange( const ScRange& rRange ) const;
476 bool TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ) const;
477 void InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize );
478 void DeleteRow(
479 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize,
480 bool* pUndoOutline, std::vector<ScAddress>* pGroupPos );
482 bool TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const;
483 void InsertCol(
484 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize );
485 void DeleteCol(
486 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize, bool* pUndoOutline );
488 void DeleteArea(
489 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, InsertDeleteFlags nDelFlag,
490 bool bBroadcast = true, sc::ColumnSpanSet* pBroadcastSpans = nullptr );
492 void CopyToClip( sc::CopyToClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTable );
493 void CopyToClip( sc::CopyToClipContext& rCxt, const ScRangeList& rRanges, ScTable* pTable );
495 void CopyStaticToDocument(
496 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const SvNumberFormatterMergeMap& rMap,
497 ScTable* pDestTab );
499 void CopyCellToDocument( SCCOL nSrcCol, SCROW nSrcRow, SCCOL nDestCol, SCROW nDestRow, ScTable& rDestTab );
501 bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol );
503 void DeleteBeforeCopyFromClip(
504 sc::CopyFromClipContext& rCxt, const ScTable& rClipTab, sc::ColumnSpanSet& rBroadcastSpans );
506 void CopyOneCellFromClip(
507 sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCROW nSrcRow, ScTable* pSrcTab );
509 void CopyFromClip(
510 sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
511 SCCOL nDx, SCROW nDy, ScTable* pTable );
513 void StartListeningFormulaCells(
514 sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt,
515 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
517 void SetDirtyFromClip(
518 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans );
520 void CopyToTable(
521 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
522 InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab,
523 const ScMarkData* pMarkData = nullptr, bool bAsLink = false, bool bColRowFlags = true,
524 bool bGlobalNamesToLocal = false, bool bCopyCaptions = true );
526 void CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab, bool bCloneCaption );
528 void UndoToTable(
529 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
530 InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab );
532 void CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
533 SCCOL nDx, SCROW nDy, ScTable* pTable);
534 void TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
535 ScTable* pTransClip, InsertDeleteFlags nFlags, bool bAsLink );
537 // mark of this document
538 void MixMarked(
539 sc::MixDocContext& rCxt, const ScMarkData& rMark, ScPasteFunc nFunction,
540 bool bSkipEmpty, const ScTable* pSrcTab );
542 void MixData(
543 sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
544 ScPasteFunc nFunction, bool bSkipEmpty, const ScTable* pSrcTab );
546 void CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
547 SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab );
549 void CopyScenarioFrom( const ScTable* pSrcTab );
550 void CopyScenarioTo( ScTable* pDestTab ) const;
551 bool TestCopyScenarioTo( const ScTable* pDestTab ) const;
552 void MarkScenarioIn(ScMarkData& rMark, ScScenarioFlags nNeededBits) const;
553 bool HasScenarioRange( const ScRange& rRange ) const;
554 void InvalidateScenarioRanges();
555 const ScRangeList* GetScenarioRanges() const;
557 void CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const;
559 void InvalidateTableArea();
560 void InvalidatePageBreaks();
562 bool GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const; // FALSE = empty
563 bool GetTableArea( SCCOL& rEndCol, SCROW& rEndRow ) const;
564 bool GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes ) const;
565 bool GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow,
566 SCCOL& rEndCol ) const;
567 bool GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
568 SCROW& rEndRow, bool bNotes ) const;
570 bool GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const;
572 void ExtendPrintArea( OutputDevice* pDev,
573 SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow );
575 void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
576 bool bIncludeOld, bool bOnlyDown ) const;
578 bool ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow,
579 SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
580 bool bStickyTopRow, bool bStickyLeftCol, bool bConsiderCellNotes ) const;
582 SCROW GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) 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 void LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
593 bool HasData( SCCOL nCol, SCROW nRow ) const;
594 bool HasStringData( SCCOL nCol, SCROW nRow ) const;
595 bool HasValueData( SCCOL nCol, SCROW nRow ) const;
596 bool HasStringCells( SCCOL nStartCol, SCROW nStartRow,
597 SCCOL nEndCol, SCROW nEndRow ) const;
599 sc::MultiDataCellState HasMultipleDataCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
601 FormulaError GetErrCode( const ScAddress& rPos ) const
603 return IsColRowValid(rPos.Col(),rPos.Row()) ?
604 aCol[rPos.Col()].GetErrCode( rPos.Row() ) :
605 FormulaError::NONE;
608 void ResetChanged( const ScRange& rRange );
610 void CheckVectorizationState();
611 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
612 void SetDirty( const ScRange&, ScColumn::BroadcastMode );
613 void SetDirtyAfterLoad();
614 void SetDirtyVar();
615 void SetTableOpDirty( const ScRange& );
616 void CalcAll();
617 void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening );
618 void CompileAll( sc::CompileFormulaContext& rCxt );
619 void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress );
621 /** Broadcast single broadcasters in range, without explicitly setting
622 anything dirty, not doing area broadcasts.
623 @param rHint address is modified to adapt to the actual broadcasted
624 position on each iteration and upon return points to the last
625 position broadcasted. */
626 bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScHint& rHint );
628 bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode );
630 void UpdateReference(
631 sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr,
632 bool bIncludeDraw = true, bool bUpdateNoteCaptionPos = true );
634 void UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
635 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
636 SCCOL nDx, SCROW nDy, SCTAB nDz, bool bUpdateNoteCaptionPos = true );
638 void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
639 ScDocument* pUndoDoc );
641 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
643 void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
644 void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
645 void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo, ScProgress* pProgress );
646 void UpdateCompile( bool bForceIfNameInUse = false );
647 void SetTabNo(SCTAB nNewTab);
648 void FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
649 sc::UpdatedRangeNames& rIndexes) const;
650 void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
651 sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
652 double nStepValue, double nMaxValue, ScProgress* pProgress);
653 OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
655 void UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& rMark );
657 void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
658 sal_uInt16 nFormatNo );
659 void GetAutoFormatData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData& rData);
660 bool SearchAndReplace(
661 const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark,
662 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
664 void FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 );
666 bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, HasAttrFlags nMask ) const;
667 bool HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask ) const;
668 bool IsMerged( SCCOL nCol, SCROW nRow ) const;
669 bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
670 SCCOL& rEndCol, SCROW& rEndRow,
671 bool bRefresh );
672 void SetMergedCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
674 const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) const;
675 const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow ) const;
676 const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
678 sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& rPos ) const;
679 sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow ) const;
680 sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
682 void SetNumberFormat( SCCOL nCol, SCROW nRow, sal_uInt32 nNumberFormat );
684 void MergeSelectionPattern( ScMergePatternState& rState,
685 const ScMarkData& rMark, bool bDeep ) const;
686 void MergePatternArea( ScMergePatternState& rState, SCCOL nCol1, SCROW nRow1,
687 SCCOL nCol2, SCROW nRow2, bool bDeep ) const;
688 void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
689 ScLineFlags& rFlags,
690 SCCOL nStartCol, SCROW nStartRow,
691 SCCOL nEndCol, SCROW nEndRow ) const;
692 void ApplyBlockFrame(const SvxBoxItem& rLineOuter,
693 const SvxBoxInfoItem* pLineInner,
694 SCCOL nStartCol, SCROW nStartRow,
695 SCCOL nEndCol, SCROW nEndRow );
697 void ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr );
698 void ApplyPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
699 void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
700 const ScPatternAttr& rAttr, ScEditDataArray* pDataArray = nullptr,
701 bool* const pIsChanged = nullptr );
703 void SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr )
705 if (ValidColRow(rPos.Col(),rPos.Row()))
706 aCol[rPos.Col()].SetPattern( rPos.Row(), rAttr );
708 void SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
709 void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
710 const ScPatternAttr& rPattern, SvNumFormatType nNewType );
711 void AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
712 void RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
714 void ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet* rStyle );
715 void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle );
716 void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
717 void ApplySelectionLineStyle( const ScMarkData& rMark,
718 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
720 const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow ) const;
721 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
722 const ScStyleSheet* GetAreaStyle( bool& rFound, SCCOL nCol1, SCROW nRow1,
723 SCCOL nCol2, SCROW nRow2 ) const;
725 void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
726 OutputDevice* pDev,
727 double nPPTX, double nPPTY,
728 const Fraction& rZoomX, const Fraction& rZoomY );
730 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
732 bool ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
733 bool RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
735 void ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
736 void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
738 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
739 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
741 const ScRange* GetRepeatColRange() const { return pRepeatColRange; }
742 const ScRange* GetRepeatRowRange() const { return pRepeatRowRange; }
743 void SetRepeatColRange( const ScRange* pNew );
744 void SetRepeatRowRange( const ScRange* pNew );
746 sal_uInt16 GetPrintRangeCount() const { return static_cast< sal_uInt16 >( aPrintRanges.size() ); }
747 const ScRange* GetPrintRange(sal_uInt16 nPos) const;
748 /** Returns true, if the sheet is always printed. */
749 bool IsPrintEntireSheet() const { return bPrintEntireSheet; }
751 /** Removes all print ranges. */
752 void ClearPrintRanges();
753 /** Adds a new print ranges. */
754 void AddPrintRange( const ScRange& rNew );
755 /** Marks the specified sheet to be printed completely. Deletes old print ranges! */
756 void SetPrintEntireSheet();
758 void FillPrintSaver( ScPrintSaverTab& rSaveTab ) const;
759 void RestorePrintRanges( const ScPrintSaverTab& rSaveTab );
761 sal_uInt16 GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev,
762 double nPPTX, double nPPTY,
763 const Fraction& rZoomX, const Fraction& rZoomY,
764 bool bFormula, const ScMarkData* pMarkData,
765 const ScColWidthParam* pParam );
766 bool SetOptimalHeight(
767 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
768 ScProgress* pOuterProgress = nullptr, sal_uLong nProgressStart = 0 );
770 void SetOptimalHeightOnly(
771 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
772 ScProgress* pOuterProgress = nullptr, sal_uLong nProgressStart = 0 );
774 long GetNeededSize( SCCOL nCol, SCROW nRow,
775 OutputDevice* pDev,
776 double nPPTX, double nPPTY,
777 const Fraction& rZoomX, const Fraction& rZoomY,
778 bool bWidth, bool bTotalSize );
779 void SetColWidth( SCCOL nCol, sal_uInt16 nNewWidth );
780 void SetColWidthOnly( SCCOL nCol, sal_uInt16 nNewWidth );
781 void SetRowHeight( SCROW nRow, sal_uInt16 nNewHeight );
782 bool SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight,
783 double nPPTY );
786 * Set specified row height to specified ranges. Don't check for drawing
787 * objects etc. Just set the row height. Nothing else.
789 * Note that setting a new row height via this function will not
790 * invalidate page breaks.
792 void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight );
794 // nPPT to test for modification
795 void SetManualHeight( SCROW nStartRow, SCROW nEndRow, bool bManual );
797 sal_uInt16 GetColWidth( SCCOL nCol, bool bHiddenAsZero = true ) const;
798 sal_uLong GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const;
799 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const;
800 sal_uLong GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true ) const;
801 sal_uLong GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const;
802 sal_uLong GetColOffset( SCCOL nCol, bool bHiddenAsZero = true ) const;
803 sal_uLong GetRowOffset( SCROW nRow, bool bHiddenAsZero = true ) const;
806 * Get the last row such that the height of row 0 to the end row is as
807 * high as possible without exceeding the specified height value.
809 * @param nHeight maximum desired height
811 * @return SCROW last row of the range within specified height.
813 SCROW GetRowForHeight(sal_uLong nHeight) const;
815 sal_uInt16 GetOriginalWidth( SCCOL nCol ) const;
816 sal_uInt16 GetOriginalHeight( SCROW nRow ) const;
818 sal_uInt16 GetCommonWidth( SCCOL nEndCol ) const;
820 SCROW GetHiddenRowCount( SCROW nRow ) const;
822 void ShowCol(SCCOL nCol, bool bShow);
823 void ShowRow(SCROW nRow, bool bShow);
824 void DBShowRow(SCROW nRow, bool bShow);
826 void ShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
827 void DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
829 void SetRowFlags( SCROW nRow, CRFlags nNewFlags );
830 void SetRowFlags( SCROW nStartRow, SCROW nEndRow, CRFlags nNewFlags );
832 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
833 SCROW GetLastFlaggedRow() const;
835 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
836 SCCOL GetLastChangedCol() const;
837 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
838 SCROW GetLastChangedRow() const;
840 bool IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SCROW nRowEnd) const;
841 bool IsDataFiltered(const ScRange& rRange) const;
842 CRFlags GetColFlags( SCCOL nCol ) const;
843 CRFlags GetRowFlags( SCROW nRow ) const;
845 const ScBitMaskCompressedArray< SCROW, CRFlags> * GetRowFlagsArray() const
846 { return pRowFlags; }
848 bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, bool bShow );
849 bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, bool bShow );
851 void UpdatePageBreaks( const ScRange* pUserArea );
852 void RemoveManualBreaks();
853 bool HasManualBreaks() const;
854 void SetRowManualBreaks( const ::std::set<SCROW>& rBreaks );
855 void SetColManualBreaks( const ::std::set<SCCOL>& rBreaks );
857 void GetAllRowBreaks(::std::set<SCROW>& rBreaks, bool bPage, bool bManual) const;
858 void GetAllColBreaks(::std::set<SCCOL>& rBreaks, bool bPage, bool bManual) const;
859 bool HasRowPageBreak(SCROW nRow) const;
860 bool HasColPageBreak(SCCOL nCol) const;
861 bool HasRowManualBreak(SCROW nRow) const;
862 bool HasColManualBreak(SCCOL nCol) const;
865 * Get the row position of the next manual break that occurs at or below
866 * specified row. When no more manual breaks are present at or below
867 * the specified row, -1 is returned.
869 * @param nRow row at which the search begins.
871 * @return SCROW next row position with manual page break, or -1 if no
872 * more manual breaks are present.
874 SCROW GetNextManualBreak(SCROW nRow) const;
876 void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow);
877 void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual);
878 void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual);
879 void SetRowBreak(SCROW nRow, bool bPage, bool bManual);
880 void SetColBreak(SCCOL nCol, bool bPage, bool bManual);
881 css::uno::Sequence<
882 css::sheet::TablePageBreakData> GetRowBreakData() const;
884 bool RowHidden(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
885 bool RowHiddenLeaf(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
886 bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const;
887 bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
888 bool SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden);
889 void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden);
890 void CopyColHidden(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
891 void CopyRowHidden(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
892 void CopyRowHeight(const ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset);
893 SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
894 SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
895 SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const;
896 sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true) const;
898 SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const;
900 bool RowFiltered(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
901 bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
902 bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const;
903 void CopyColFiltered(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
904 void CopyRowFiltered(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
905 void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered);
906 void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered);
907 SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const;
908 SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const;
909 SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const;
911 bool IsManualRowHeight(SCROW nRow) const;
913 bool HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const;
915 void SyncColRowFlags();
917 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
918 void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
920 /** Sort a range of data. */
921 void Sort(
922 const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
923 ScProgress* pProgress, sc::ReorderParam* pUndo );
925 void Reorder( const sc::ReorderParam& rParam );
927 bool ValidQuery(
928 SCROW nRow, const ScQueryParam& rQueryParam, const ScRefCellValue* pCell = nullptr,
929 bool* pbTestEqualCondition = nullptr, const ScInterpreterContext* pContext = nullptr);
930 void TopTenQuery( ScQueryParam& );
931 SCSIZE Query(const ScQueryParam& rQueryParam, bool bKeepSub);
932 bool CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
934 void GetFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, ScFilterEntries& rFilterEntries );
935 void GetFilteredFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScQueryParam& rParam, ScFilterEntries& rFilterEntries );
936 bool GetDataEntries(SCCOL nCol, SCROW nRow, std::set<ScTypedStrData>& rStrings, bool bLimit);
938 bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
939 bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
941 sal_Int32 GetMaxStringLen( SCCOL nCol,
942 SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
943 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
944 SCCOL nCol,
945 SCROW nRowStart, SCROW nRowEnd ) const;
947 bool IsSortCollatorGlobal() const;
948 void InitSortCollator( const ScSortParam& rPar );
949 void DestroySortCollator();
950 void SetDrawPageSize( bool bResetStreamValid = true, bool bUpdateNoteCaptionPos = true );
952 void SetRangeName(ScRangeName* pNew);
953 ScRangeName* GetRangeName() const;
955 void PreprocessRangeNameUpdate(
956 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
958 void CompileHybridFormula(
959 sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt );
961 void PreprocessDBDataUpdate(
962 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
964 ScConditionalFormatList* GetCondFormList();
965 const ScConditionalFormatList* GetCondFormList() const;
966 void SetCondFormList( ScConditionalFormatList* pList );
968 void DeleteConditionalFormat(sal_uLong nOldIndex);
970 sal_uLong AddCondFormat( ScConditionalFormat* pNew );
972 SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow ) const;
973 void SetScriptType( SCCOL nCol, SCROW nRow, SvtScriptType nType );
974 void UpdateScriptTypes( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
976 SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
978 size_t GetFormulaHash( SCCOL nCol, SCROW nRow ) const;
980 ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const;
981 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol, SCROW nRow );
982 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
983 formula::VectorRefArray FetchVectorRefArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
984 bool HandleRefArrayForParallelism( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
986 void SplitFormulaGroups( SCCOL nCol, std::vector<SCROW>& rRows );
987 void UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows );
988 void RegroupFormulaCells( SCCOL nCol );
990 ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
992 SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow );
993 const SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow ) const;
994 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
996 void FillMatrix( ScMatrix& rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool* pPool ) const;
998 void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1000 void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, size_t nLen );
1001 void SetFormulaResults( SCCOL nCol, SCROW nRow, const formula::FormulaConstTokenRef* pResults, size_t nLen );
1003 void CalculateInColumnInThread( ScInterpreterContext& rContext, SCCOL nCol, SCROW nRow, size_t nLen, unsigned nThisThread, unsigned nThreadsTotal);
1004 void HandleStuffAfterParallelCalculation( SCCOL nCol, SCROW nRow, size_t nLen);
1007 * Either start all formula cells as listeners unconditionally, or start
1008 * those that are marked "needs listening".
1010 * @param rCxt context object.
1011 * @param bAll when true, start all formula cells as listeners. When
1012 * false, only start those that are marked "needs listening".
1014 void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
1017 * Mark formula cells dirty that have the mbPostponedDirty flag set or
1018 * contain named ranges with relative references.
1020 void SetDirtyIfPostponed();
1023 * Broadcast dirty formula cells that contain functions such as CELL(),
1024 * COLUMN() or ROW() which may change its value on move.
1026 void BroadcastRecalcOnRefMove();
1028 void CollectListeners( std::vector<SvtListener*>& rListeners, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1030 void TransferListeners(
1031 ScTable& rDestTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1032 SCCOL nColDelta, SCROW nRowDelta );
1034 void TransferCellValuesTo( SCCOL nCol, SCROW nRow, size_t nLen, sc::CellValues& rDest );
1035 void CopyCellValuesFrom( SCCOL nCol, SCROW nRow, const sc::CellValues& rSrc );
1037 std::unique_ptr<sc::ColumnIterator> GetColumnIterator( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
1039 void EnsureFormulaCellResults( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1041 void ConvertFormulaToValue(
1042 sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1043 sc::TableValues* pUndo );
1045 void SwapNonEmpty(
1046 sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
1048 void finalizeOutlineImport();
1050 void StoreToCache(SvStream& rStrm) const;
1052 void RestoreFromCache(SvStream& rStrm);
1054 #if DUMP_COLUMN_STORAGE
1055 void DumpColumnStorage( SCCOL nCol ) const;
1056 #endif
1058 /** Replace behaves differently to the Search; adjust the rCol and rRow accordingly.
1060 'Replace' replaces at the 'current' position, but in order to achieve
1061 that, we have to 'shift' the rCol / rRow to the 'previous' position -
1062 what it is depends on various settings in rSearchItem.
1064 static void UpdateSearchItemAddressForReplace( const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow );
1066 ScColumnsRange GetColumnsRange(SCCOL begin, SCCOL end) const;
1068 private:
1070 void FillFormulaVertical(
1071 const ScFormulaCell& rSrcCell,
1072 SCCOLROW& rInner, SCCOL nCol, SCROW nRow1, SCROW nRow2,
1073 ScProgress* pProgress, sal_uLong& rProgress );
1075 void FillSeriesSimple(
1076 const ScCellValue& rSrcCell, SCCOLROW& rInner, SCCOLROW nIMin, SCCOLROW nIMax,
1077 SCCOLROW& rCol, SCCOLROW& rRow, bool bVertical, ScProgress* pProgress, sal_uLong& rProgress );
1079 void FillAutoSimple(
1080 SCCOLROW nISrcStart, SCCOLROW nISrcEnd, SCCOLROW nIStart, SCCOLROW nIEnd,
1081 SCCOLROW& rInner, SCCOLROW& rCol, SCCOLROW& rRow,
1082 sal_uLong nActFormCnt, sal_uLong nMaxFormCnt,
1083 bool bHasFiltered, bool bVertical, bool bPositive,
1084 ScProgress* pProgress, sal_uLong& rProgress );
1086 void FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1087 sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd,
1088 FillDateCmd eFillDateCmd,
1089 double nStepValue, double nMaxValue, sal_uInt16 nMinDigits,
1090 bool bAttribs, ScProgress* pProgress );
1091 void FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1092 FillCmd& rCmd, FillDateCmd& rDateCmd,
1093 double& rInc, sal_uInt16& rMinDigits,
1094 ScUserListData*& rListData, sal_uInt16& rListIndex);
1095 void FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1096 sal_uLong nFillCount, FillDir eFillDir, ScProgress* pProgress );
1098 bool ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
1099 bool bMarked, bool bUnprotected ) const;
1101 void AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1102 const ScPatternAttr& rAttr, sal_uInt16 nFormatNo);
1103 void GetAutoFormatAttr(SCCOL nCol, SCROW nRow, sal_uInt16 nIndex, ScAutoFormatData& rData);
1104 void GetAutoFormatFrame(SCCOL nCol, SCROW nRow, sal_uInt16 nFlags, sal_uInt16 nIndex, ScAutoFormatData& rData);
1105 bool SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRow,
1106 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1107 bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1108 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1109 bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1110 SCCOL nLastCol, SCROW nLastRow,
1111 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1112 bool SearchAll(const SvxSearchItem& rSearchItem, const ScMarkData& rMark,
1113 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1114 bool Replace(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1115 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1116 bool ReplaceAll(
1117 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1118 OUString& rUndoStr, ScDocument* pUndoDoc);
1120 bool SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1121 const ScMarkData& rMark);
1122 bool ReplaceStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1123 const ScMarkData& rMark, bool bIsUndo);
1124 bool SearchAllStyle(
1125 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges);
1126 bool ReplaceAllStyle(
1127 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1128 ScDocument* pUndoDoc);
1129 bool SearchAndReplaceEmptyCells(
1130 const SvxSearchItem& rSearchItem,
1131 SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1132 OUString& rUndoStr, ScDocument* pUndoDoc);
1133 bool SearchRangeForEmptyCell(const ScRange& rRange,
1134 const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1135 OUString& rUndoStr);
1136 bool SearchRangeForAllEmptyCells(
1137 const ScRange& rRange, const SvxSearchItem& rSearchItem,
1138 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1140 // use the global sort parameter:
1141 bool IsSorted(SCCOLROW nStart, SCCOLROW nEnd) const;
1142 static void DecoladeRow( ScSortInfoArray*, SCROW nRow1, SCROW nRow2 );
1143 short CompareCell(
1144 sal_uInt16 nSort,
1145 ScRefCellValue& rCell1, SCCOL nCell1Col, SCROW nCell1Row,
1146 ScRefCellValue& rCell2, SCCOL nCell2Col, SCROW nCell2Row ) const;
1147 short Compare(SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1148 short Compare( ScSortInfoArray*, SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1149 ScSortInfoArray* CreateSortInfoArray( const sc::ReorderParam& rParam );
1150 ScSortInfoArray* CreateSortInfoArray(
1151 const ScSortParam& rSortParam, SCCOLROW nInd1, SCCOLROW nInd2,
1152 bool bKeepQuery, bool bUpdateRefs );
1153 void QuickSort( ScSortInfoArray*, SCCOLROW nLo, SCCOLROW nHi);
1154 void SortReorderByColumn( const ScSortInfoArray* pArray, SCROW nRow1, SCROW nRow2, bool bPattern, ScProgress* pProgress );
1156 void SortReorderByRow( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress );
1157 void SortReorderByRowRefUpdate( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress );
1159 bool CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1160 bool CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1161 void GetUpperCellString(SCCOL nCol, SCROW nRow, OUString& rStr);
1163 bool RefVisible(const ScFormulaCell* pCell);
1165 bool IsEmptyLine(SCROW nRow, SCCOL nStartCol, SCCOL nEndCol) const;
1167 void IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillDateCmd eCmd);
1168 void FillFormula(
1169 const ScFormulaCell* pSrcCell, SCCOL nDestCol, SCROW nDestRow, bool bLast );
1170 void UpdateInsertTabAbs(SCTAB nNewPos);
1171 bool GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, bool bInSel,
1172 const ScMarkData& rMark) const;
1173 bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark ) const;
1174 void TestTabRefAbs(SCTAB nTable) const;
1175 void CompileDBFormula( sc::CompileFormulaContext& rCxt );
1176 void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt );
1178 void StartListening( const ScAddress& rAddress, SvtListener* pListener );
1179 void EndListening( const ScAddress& rAddress, SvtListener* pListener );
1180 void StartListening( sc::StartListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
1181 void EndListening( sc::EndListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
1183 void AttachFormulaCells( sc::StartListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1184 void DetachFormulaCells( sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1186 void SetLoadingMedium(bool bLoading);
1188 SCSIZE FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2,
1189 SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY,
1190 const ScPatternAttr* pPattern, const SfxItemSet* pCondSet );
1192 // idle calculation of OutputDevice text width for cell
1193 // also invalidates script type, broadcasts for "calc as shown"
1194 void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
1195 bool bNumFormatChanged, bool bBroadcast );
1197 void SkipFilteredRows(SCROW& rRow, SCROW& rLastNonFilteredRow, bool bForward);
1200 * In case the cell text goes beyond the column width, move the max column
1201 * position to the right. This is called from ExtendPrintArea.
1203 void MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY);
1205 void CopyPrintRange(const ScTable& rTable);
1207 SCCOL FindNextVisibleColWithContent(SCCOL nCol, bool bRight, SCROW nRow) const;
1209 SCCOL FindNextVisibleCol(SCCOL nCol, bool bRight) const;
1211 // Clipboard transpose for notes
1212 void TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1, SCROW nRow2);
1214 ScColumn* FetchColumn( SCCOL nCol );
1215 const ScColumn* FetchColumn( SCCOL nCol ) const;
1217 void EndListeningIntersectedGroup(
1218 sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow, std::vector<ScAddress>* pGroupPos );
1220 void EndListeningIntersectedGroups(
1221 sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1222 std::vector<ScAddress>* pGroupPos );
1224 void EndListeningGroup( sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow );
1225 void SetNeedsListeningGroup( SCCOL nCol, SCROW nRow );
1228 * Use this to iterate through non-empty visible cells in a single column.
1230 class VisibleDataCellIterator
1232 static constexpr SCROW ROW_NOT_FOUND = -1;
1234 public:
1235 explicit VisibleDataCellIterator(ScFlatBoolRowSegments& rRowSegs, ScColumn& rColumn);
1236 ~VisibleDataCellIterator();
1239 * Set the start row position. In case there is not visible data cell
1240 * at the specified row position, it will move to the position of the
1241 * first visible data cell below that point.
1243 * @return First visible data cell if found, or NULL otherwise.
1245 ScRefCellValue reset(SCROW nRow);
1248 * Find the next visible data cell position.
1250 * @return Next visible data cell if found, or NULL otherwise.
1252 ScRefCellValue next();
1255 * Get the current row position.
1257 * @return Current row position, or ROW_NOT_FOUND if the iterator
1258 * doesn't point to a valid data cell position.
1260 SCROW getRow() const { return mnCurRow;}
1262 private:
1263 ScFlatBoolRowSegments& mrRowSegs;
1264 ScColumn& mrColumn;
1265 ScRefCellValue maCell;
1266 SCROW mnCurRow;
1267 SCROW mnUBound;
1272 #endif
1274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */