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