build fix
[LibreOffice.git] / sc / inc / table.hxx
blob81e8329b4b88102ad57ceda0541059eb95ef00bb
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"
40 #include <set>
41 #include <map>
42 #include <memory>
44 namespace utl {
45 class TextSearch;
48 namespace com { namespace sun { namespace star {
49 namespace sheet {
50 struct TablePageBreakData;
52 } } }
54 namespace formula { struct VectorRefArray; }
55 namespace sc {
57 struct FormulaGroupContext;
58 class StartListeningContext;
59 class EndListeningContext;
60 class CopyFromClipContext;
61 class CopyToClipContext;
62 class CopyToDocContext;
63 class MixDocContext;
64 class ColumnSpanSet;
65 class ColumnSet;
66 struct ColumnBlockPosition;
67 struct RefUpdateContext;
68 struct RefUpdateInsertTabContext;
69 struct RefUpdateDeleteTabContext;
70 struct RefUpdateMoveTabContext;
71 struct NoteEntry;
72 class DocumentStreamAccess;
73 class CellValues;
74 class TableValues;
75 class RowHeightContext;
76 class CompileFormulaContext;
77 struct SetFormulaDirtyContext;
78 class RefMovedHint;
79 struct ReorderParam;
80 class ColumnIterator;
84 class SfxItemSet;
85 class SfxStyleSheetBase;
86 class SvxBoxInfoItem;
87 class SvxBoxItem;
88 class SvxSearchItem;
90 class ScAutoFormatData;
91 class ScDocument;
92 class ScEditDataArray;
93 class ScFormulaCell;
94 class ScOutlineTable;
95 class ScPrintSaverTab;
96 class ScProgress;
97 class ScRangeList;
98 class ScSheetEvents;
99 class ScSortInfoArray;
100 class ScConditionalFormat;
101 class ScConditionalFormatList;
102 class ScStyleSheet;
103 class ScTableProtection;
104 class ScUserListData;
105 struct RowInfo;
106 struct ScFunctionData;
107 struct ScLineFlags;
108 class CollatorWrapper;
109 class ScFlatUInt16RowSegments;
110 class ScFlatBoolRowSegments;
111 class ScFlatBoolColSegments;
112 struct ScSetStringParam;
113 struct ScColWidthParam;
114 struct ScColWidthParam;
115 class ScRangeName;
116 class ScDBData;
117 class ScDocumentImport;
118 class ScHint;
120 class ScTable
122 private:
123 typedef ::std::vector< ScRange > ScRangeVec;
125 ScColContainer aCol;
127 OUString aName;
128 OUString aCodeName;
129 OUString aComment;
131 OUString aLinkDoc;
132 OUString aLinkFlt;
133 OUString aLinkOpt;
134 OUString aLinkTab;
135 sal_uLong nLinkRefreshDelay;
136 ScLinkMode nLinkMode;
138 // page style template
139 OUString aPageStyle;
140 Size aPageSizeTwips; // size of the print-page
141 SCCOL nRepeatStartX; // repeating rows/columns
142 SCCOL nRepeatEndX; // REPEAT_NONE, if not used
143 SCROW nRepeatStartY;
144 SCROW nRepeatEndY;
146 std::unique_ptr<ScTableProtection> pTabProtection;
148 sal_uInt16* pColWidth;
149 std::unique_ptr<ScFlatUInt16RowSegments> mpRowHeights;
151 CRFlags* pColFlags;
152 ScBitMaskCompressedArray< SCROW, CRFlags>* pRowFlags;
153 std::unique_ptr<ScFlatBoolColSegments> mpHiddenCols;
154 std::unique_ptr<ScFlatBoolRowSegments> mpHiddenRows;
155 std::unique_ptr<ScFlatBoolColSegments> mpFilteredCols;
156 std::unique_ptr<ScFlatBoolRowSegments> mpFilteredRows;
158 ::std::set<SCROW> maRowPageBreaks;
159 ::std::set<SCROW> maRowManualBreaks;
160 ::std::set<SCCOL> maColPageBreaks;
161 ::std::set<SCCOL> maColManualBreaks;
163 ScOutlineTable* pOutlineTable;
165 ScSheetEvents* pSheetEvents;
167 mutable SCCOL nTableAreaX;
168 mutable SCROW nTableAreaY;
170 SCTAB nTab;
171 ScDocument* pDocument;
172 utl::TextSearch* pSearchText;
174 mutable OUString aUpperName; // #i62977# filled only on demand, reset in SetName
176 // sort parameter to minimize stack size of quicksort
177 ScSortParam aSortParam;
178 CollatorWrapper* pSortCollator;
180 ScRangeVec aPrintRanges;
182 ScRange* pRepeatColRange;
183 ScRange* pRepeatRowRange;
185 sal_uInt16 nLockCount;
187 ScRangeList* pScenarioRanges;
188 Color aScenarioColor;
189 Color aTabBgColor;
190 ScScenarioFlags nScenarioFlags;
191 ScDBData* pDBDataNoName;
192 mutable ScRangeName* mpRangeName;
194 std::unique_ptr<ScConditionalFormatList> mpCondFormatList;
196 bool bScenario:1;
197 bool bLayoutRTL:1;
198 bool bLoadingRTL:1;
199 bool bPageSizeValid:1;
200 mutable bool bTableAreaValid:1;
201 bool bVisible:1;
202 bool bStreamValid:1;
203 bool bPendingRowHeights:1;
204 bool bCalcNotification:1;
205 bool bGlobalKeepQuery:1;
206 bool bPrintEntireSheet:1;
207 bool bActiveScenario:1;
208 bool mbPageBreaksValid:1;
209 bool mbForceBreaks:1;
211 ScAttrArray aNextColAttrArray;
213 friend class ScDocument; // for FillInfo
214 friend class ScColumn;
215 friend class ScValueIterator;
216 friend class ScHorizontalValueIterator;
217 friend class ScDBQueryDataIterator;
218 friend class ScFormulaGroupIterator;
219 friend class ScCellIterator;
220 friend class ScQueryCellIterator;
221 friend class ScHorizontalCellIterator;
222 friend class ScHorizontalAttrIterator;
223 friend class ScDocAttrIterator;
224 friend class ScAttrRectIterator;
225 friend class ScColumnTextWidthIterator;
226 friend class ScDocumentImport;
227 friend class sc::DocumentStreamAccess;
228 friend class sc::ColumnSpanSet;
229 friend class sc::EditTextIterator;
230 friend class sc::FormulaGroupAreaListener;
232 public:
233 ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
234 bool bColInfo = true, bool bRowInfo = true );
235 ~ScTable();
236 ScTable(const ScTable&) = delete;
237 ScTable& operator=(const ScTable&) = delete;
239 ScDocument& GetDoc() { return *pDocument;}
240 const ScDocument& GetDoc() const { return *pDocument;}
241 SCTAB GetTab() const { return nTab; }
243 ScOutlineTable* GetOutlineTable() { return pOutlineTable; }
245 sal_uLong GetCellCount() const;
246 sal_uLong GetWeightedCount() const;
247 sal_uLong GetCodeCount() const; // RPN code in formula
249 sal_uInt16 GetTextWidth(SCCOL nCol, SCROW nRow) const;
251 bool SetOutlineTable( const ScOutlineTable* pNewOutline );
252 void StartOutlineTable();
254 void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
256 bool TestRemoveSubTotals( const ScSubTotalParam& rParam );
257 void RemoveSubTotals( ScSubTotalParam& rParam );
258 bool DoSubTotals( ScSubTotalParam& rParam );
260 const ScSheetEvents* GetSheetEvents() const { return pSheetEvents; }
261 void SetSheetEvents( const ScSheetEvents* pNew );
263 bool IsVisible() const { return bVisible; }
264 void SetVisible( bool bVis );
266 bool IsStreamValid() const { return bStreamValid; }
267 void SetStreamValid( bool bSet, bool bIgnoreLock = false );
269 bool IsPendingRowHeights() const { return bPendingRowHeights; }
270 void SetPendingRowHeights( bool bSet );
272 bool GetCalcNotification() const { return bCalcNotification; }
273 void SetCalcNotification( bool bSet );
275 bool IsLayoutRTL() const { return bLayoutRTL; }
276 bool IsLoadingRTL() const { return bLoadingRTL; }
277 void SetLayoutRTL( bool bSet );
278 void SetLoadingRTL( bool bSet );
280 bool IsScenario() const { return bScenario; }
281 void SetScenario( bool bFlag );
282 void GetScenarioComment( OUString& rComment) const { rComment = aComment; }
283 void SetScenarioComment( const OUString& rComment ) { aComment = rComment; }
284 const Color& GetScenarioColor() const { return aScenarioColor; }
285 void SetScenarioColor(const Color& rNew) { aScenarioColor = rNew; }
286 const Color& GetTabBgColor() const { return aTabBgColor; }
287 void SetTabBgColor(const Color& rColor);
288 ScScenarioFlags GetScenarioFlags() const { return nScenarioFlags; }
289 void SetScenarioFlags(ScScenarioFlags nNew) { nScenarioFlags = nNew; }
290 void SetActiveScenario(bool bSet) { bActiveScenario = bSet; }
291 bool IsActiveScenario() const { return bActiveScenario; }
293 ScLinkMode GetLinkMode() const { return nLinkMode; }
294 bool IsLinked() const { return nLinkMode != ScLinkMode::NONE; }
295 const OUString& GetLinkDoc() const { return aLinkDoc; }
296 const OUString& GetLinkFlt() const { return aLinkFlt; }
297 const OUString& GetLinkOpt() const { return aLinkOpt; }
298 const OUString& GetLinkTab() const { return aLinkTab; }
299 sal_uLong GetLinkRefreshDelay() const { return nLinkRefreshDelay; }
301 void SetLink( ScLinkMode nMode, const OUString& rDoc, const OUString& rFlt,
302 const OUString& rOpt, const OUString& rTab, sal_uLong nRefreshDelay );
304 sal_Int64 GetHashCode () const;
306 void GetName( OUString& rName ) const;
307 void SetName( const OUString& rNewName );
309 void SetAnonymousDBData(ScDBData* pDBData);
310 ScDBData* GetAnonymousDBData() { return pDBDataNoName;}
312 void GetCodeName( OUString& rName ) const { rName = aCodeName; }
313 void SetCodeName( const OUString& rNewName ) { aCodeName = rNewName; }
315 const OUString& GetUpperName() const;
317 const OUString& GetPageStyle() const { return aPageStyle; }
318 void SetPageStyle( const OUString& rName );
319 void PageStyleModified( const OUString& rNewName );
321 bool IsProtected() const;
322 void SetProtection(const ScTableProtection* pProtect);
323 ScTableProtection* GetProtection();
325 bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCCOLROW nStart, SCCOLROW nEnd ) const;
327 Size GetPageSize() const;
328 void SetPageSize( const Size& rSize );
329 void SetRepeatArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
331 void LockTable();
332 void UnlockTable();
334 bool IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2,
335 SCROW nRow2, bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
336 bool IsSelectionEditable( const ScMarkData& rMark,
337 bool* pOnlyNotBecauseOfMatrix = nullptr ) const;
339 bool HasBlockMatrixFragment( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
340 bool HasSelectionMatrixFragment( const ScMarkData& rMark ) const;
342 bool IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bIgnoreNotes ) const;
344 bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
345 ScSetStringParam* pParam = nullptr );
347 bool SetEditText( SCCOL nCol, SCROW nRow, EditTextObject* pEditText );
348 void SetEditText( SCCOL nCol, SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
349 SCROW GetFirstEditTextRow( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
351 void SetEmptyCell( SCCOL nCol, SCROW nRow );
352 void SetFormula(
353 SCCOL nCol, SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram );
354 void SetFormula(
355 SCCOL nCol, SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram );
358 * Takes ownership of pCell
360 * @return pCell if it was successfully inserted, NULL otherwise. pCell
361 * is deleted automatically on failure to insert.
363 ScFormulaCell* SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell );
365 bool SetFormulaCells( SCCOL nCol, SCROW nRow, std::vector<ScFormulaCell*>& rCells );
367 bool HasFormulaCell( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
369 svl::SharedString GetSharedString( SCCOL nCol, SCROW nRow ) const;
371 void SetValue( SCCOL nCol, SCROW nRow, const double& rVal );
372 void SetValues( SCCOL nCol, SCROW nRow, const std::vector<double>& rVals );
373 void SetError( SCCOL nCol, SCROW nRow, FormulaError nError);
374 SCSIZE GetPatternCount( SCCOL nCol ) const;
375 SCSIZE GetPatternCount( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
376 bool ReservePatternCount( SCCOL nCol, SCSIZE nReserve );
378 void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr );
379 void GetString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
380 double* GetValueCell( SCCOL nCol, SCROW nRow );
381 void GetInputString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
382 double GetValue( SCCOL nCol, SCROW nRow ) const;
383 const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const;
384 void RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
385 void GetFormula( SCCOL nCol, SCROW nRow, OUString& rFormula ) const;
386 const ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ) const;
387 ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow );
389 CellType GetCellType( const ScAddress& rPos ) const
391 return ValidColRow(rPos.Col(),rPos.Row()) ?
392 aCol[rPos.Col()].GetCellType( rPos.Row() ) :
393 CELLTYPE_NONE;
395 CellType GetCellType( SCCOL nCol, SCROW nRow ) const;
396 ScRefCellValue GetCellValue( SCCOL nCol, SCROW nRow ) const;
398 void GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const;
399 void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const;
401 ScPostIt* ReleaseNote( SCCOL nCol, SCROW nRow );
403 size_t GetNoteCount( SCCOL nCol ) const;
404 SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const;
405 void CreateAllNoteCaptions();
406 void ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bPreserveData );
408 void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
409 void GetNotesInRange( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes ) const;
410 bool ContainsNotesInRange( const ScRange& rRange ) const;
412 bool TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ) const;
413 void InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize );
414 void DeleteRow(
415 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize,
416 bool* pUndoOutline, std::vector<ScAddress>* pGroupPos );
418 bool TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const;
419 void InsertCol(
420 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize );
421 void DeleteCol(
422 const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize, bool* pUndoOutline );
424 void DeleteArea(
425 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, InsertDeleteFlags nDelFlag,
426 bool bBroadcast = true, sc::ColumnSpanSet* pBroadcastSpans = nullptr );
428 void CopyToClip( sc::CopyToClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTable );
429 void CopyToClip( sc::CopyToClipContext& rCxt, const ScRangeList& rRanges, ScTable* pTable );
431 void CopyStaticToDocument(
432 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const SvNumberFormatterMergeMap& rMap,
433 ScTable* pDestTab );
435 void CopyCellToDocument( SCCOL nSrcCol, SCROW nSrcRow, SCCOL nDestCol, SCROW nDestRow, ScTable& rDestTab );
437 bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol );
439 void DeleteBeforeCopyFromClip(
440 sc::CopyFromClipContext& rCxt, const ScTable& rClipTab, sc::ColumnSpanSet& rBroadcastSpans );
442 void CopyOneCellFromClip(
443 sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCROW nSrcRow, ScTable* pSrcTab );
445 void CopyFromClip(
446 sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
447 SCsCOL nDx, SCsROW nDy, ScTable* pTable );
449 void StartListeningFormulaCells(
450 sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt,
451 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
453 void SetDirtyFromClip(
454 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans );
456 void CopyToTable(
457 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
458 InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab,
459 const ScMarkData* pMarkData = nullptr, bool bAsLink = false, bool bColRowFlags = true,
460 bool bGlobalNamesToLocal = false, bool bCopyCaptions = true );
462 void CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab, bool bCloneCaption );
464 void UndoToTable(
465 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
466 InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab );
468 void CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
469 SCsCOL nDx, SCsROW nDy, ScTable* pTable);
470 void TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
471 ScTable* pTransClip, InsertDeleteFlags nFlags, bool bAsLink );
473 // mark of this document
474 void MixMarked(
475 sc::MixDocContext& rCxt, const ScMarkData& rMark, ScPasteFunc nFunction,
476 bool bSkipEmpty, const ScTable* pSrcTab );
478 void MixData(
479 sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
480 ScPasteFunc nFunction, bool bSkipEmpty, const ScTable* pSrcTab );
482 void CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
483 SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab );
485 void CopyScenarioFrom( const ScTable* pSrcTab );
486 void CopyScenarioTo( ScTable* pDestTab ) const;
487 bool TestCopyScenarioTo( const ScTable* pDestTab ) const;
488 void MarkScenarioIn(ScMarkData& rMark, ScScenarioFlags nNeededBits) const;
489 bool HasScenarioRange( const ScRange& rRange ) const;
490 void InvalidateScenarioRanges();
491 const ScRangeList* GetScenarioRanges() const;
493 void CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const;
495 void InvalidateTableArea();
496 void InvalidatePageBreaks();
498 bool GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const; // FALSE = empty
499 bool GetTableArea( SCCOL& rEndCol, SCROW& rEndRow ) const;
500 bool GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes ) const;
501 bool GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow,
502 SCCOL& rEndCol, bool bNotes ) const;
503 bool GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
504 SCROW& rEndRow, bool bNotes ) const;
506 bool GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const;
508 void ExtendPrintArea( OutputDevice* pDev,
509 SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow );
511 void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
512 bool bIncludeOld, bool bOnlyDown ) const;
514 bool ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow,
515 SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
516 bool bStickyTopRow, bool bStickyLeftCol, bool bConsiderCellNotes=false ) const;
518 SCROW GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const;
520 SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
521 SCCOL nEndCol, SCROW nEndRow, ScDirection eDir ) const;
523 void FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection ) const;
524 void GetNextPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY,
525 bool bMarked, bool bUnprotected, const ScMarkData& rMark ) const;
527 void LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
529 bool HasData( SCCOL nCol, SCROW nRow ) const;
530 bool HasStringData( SCCOL nCol, SCROW nRow ) const;
531 bool HasValueData( SCCOL nCol, SCROW nRow ) const;
532 bool HasStringCells( SCCOL nStartCol, SCROW nStartRow,
533 SCCOL nEndCol, SCROW nEndRow ) const;
535 sc::MultiDataCellState HasMultipleDataCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
537 FormulaError GetErrCode( const ScAddress& rPos ) const
539 return ValidColRow(rPos.Col(),rPos.Row()) ?
540 aCol[rPos.Col()].GetErrCode( rPos.Row() ) :
541 FormulaError::NONE;
544 void ResetChanged( const ScRange& rRange );
546 void CheckVectorizationState();
547 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
548 void SetDirty( const ScRange&, ScColumn::BroadcastMode );
549 void SetDirtyAfterLoad();
550 void SetDirtyVar();
551 void SetTableOpDirty( const ScRange& );
552 void CalcAll();
553 void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening );
554 void CompileAll( sc::CompileFormulaContext& rCxt );
555 void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress );
557 /** Broadcast single broadcasters in range, without explicitly setting
558 anything dirty, not doing area broadcasts.
559 @param rHint address is modified to adapt to the actual broadcasted
560 position on each iteration and upon return points to the last
561 position broadcasted. */
562 bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScHint& rHint );
564 bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode );
566 void UpdateReference(
567 sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr,
568 bool bIncludeDraw = true, bool bUpdateNoteCaptionPos = true );
570 void UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
571 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
572 SCsCOL nDx, SCsROW nDy, SCsTAB nDz, bool bUpdateNoteCaptionPos = true );
574 void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
575 ScDocument* pUndoDoc );
577 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
579 void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
580 void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
581 void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo, ScProgress* pProgress );
582 void UpdateCompile( bool bForceIfNameInUse = false );
583 void SetTabNo(SCTAB nNewTab);
584 void FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
585 sc::UpdatedRangeNames& rIndexes) const;
586 void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
587 sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
588 double nStepValue, double nMaxValue, ScProgress* pProgress);
589 OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
591 void UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& rMark );
593 void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
594 sal_uInt16 nFormatNo );
595 void GetAutoFormatData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData& rData);
596 bool SearchAndReplace(
597 const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark,
598 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
600 void FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 );
602 bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, HasAttrFlags nMask ) const;
603 bool HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask ) const;
604 bool IsMerged( SCCOL nCol, SCROW nRow ) const;
605 bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
606 SCCOL& rEndCol, SCROW& rEndRow,
607 bool bRefresh );
608 const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) const;
609 const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow ) const;
610 const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
612 sal_uInt32 GetNumberFormat( const ScAddress& rPos ) const;
613 sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow ) const;
614 sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
616 void SetNumberFormat( SCCOL nCol, SCROW nRow, sal_uInt32 nNumberFormat );
618 void MergeSelectionPattern( ScMergePatternState& rState,
619 const ScMarkData& rMark, bool bDeep ) const;
620 void MergePatternArea( ScMergePatternState& rState, SCCOL nCol1, SCROW nRow1,
621 SCCOL nCol2, SCROW nRow2, bool bDeep ) const;
622 void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
623 ScLineFlags& rFlags,
624 SCCOL nStartCol, SCROW nStartRow,
625 SCCOL nEndCol, SCROW nEndRow ) const;
626 void ApplyBlockFrame( const SvxBoxItem* pLineOuter,
627 const SvxBoxInfoItem* pLineInner,
628 SCCOL nStartCol, SCROW nStartRow,
629 SCCOL nEndCol, SCROW nEndRow );
631 void ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr );
632 void ApplyPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
633 void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
634 const ScPatternAttr& rAttr, ScEditDataArray* pDataArray = nullptr );
636 void SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr )
638 if (ValidColRow(rPos.Col(),rPos.Row()))
639 aCol[rPos.Col()].SetPattern( rPos.Row(), rAttr );
641 void SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
642 void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
643 const ScPatternAttr& rPattern, short nNewType );
644 void AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
645 void RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
647 void ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet* rStyle );
648 void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle );
649 void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
650 void ApplySelectionLineStyle( const ScMarkData& rMark,
651 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
653 const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow ) const;
654 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
655 const ScStyleSheet* GetAreaStyle( bool& rFound, SCCOL nCol1, SCROW nRow1,
656 SCCOL nCol2, SCROW nRow2 ) const;
658 void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
659 OutputDevice* pDev,
660 double nPPTX, double nPPTY,
661 const Fraction& rZoomX, const Fraction& rZoomY );
663 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
665 bool ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
666 bool RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
668 void ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr );
669 void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
671 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
672 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
674 const ScRange* GetRepeatColRange() const { return pRepeatColRange; }
675 const ScRange* GetRepeatRowRange() const { return pRepeatRowRange; }
676 void SetRepeatColRange( const ScRange* pNew );
677 void SetRepeatRowRange( const ScRange* pNew );
679 sal_uInt16 GetPrintRangeCount() const { return static_cast< sal_uInt16 >( aPrintRanges.size() ); }
680 const ScRange* GetPrintRange(sal_uInt16 nPos) const;
681 /** Returns true, if the sheet is always printed. */
682 bool IsPrintEntireSheet() const { return bPrintEntireSheet; }
684 /** Removes all print ranges. */
685 void ClearPrintRanges();
686 /** Adds a new print ranges. */
687 void AddPrintRange( const ScRange& rNew );
688 /** Marks the specified sheet to be printed completely. Deletes old print ranges! */
689 void SetPrintEntireSheet();
691 void FillPrintSaver( ScPrintSaverTab& rSaveTab ) const;
692 void RestorePrintRanges( const ScPrintSaverTab& rSaveTab );
694 sal_uInt16 GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev,
695 double nPPTX, double nPPTY,
696 const Fraction& rZoomX, const Fraction& rZoomY,
697 bool bFormula, const ScMarkData* pMarkData,
698 const ScColWidthParam* pParam );
699 bool SetOptimalHeight(
700 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
701 ScProgress* pOuterProgress = nullptr, sal_uLong nProgressStart = 0 );
703 void SetOptimalHeightOnly(
704 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
705 ScProgress* pOuterProgress = nullptr, sal_uLong nProgressStart = 0 );
707 long GetNeededSize( SCCOL nCol, SCROW nRow,
708 OutputDevice* pDev,
709 double nPPTX, double nPPTY,
710 const Fraction& rZoomX, const Fraction& rZoomY,
711 bool bWidth, bool bTotalSize );
712 void SetColWidth( SCCOL nCol, sal_uInt16 nNewWidth );
713 void SetColWidthOnly( SCCOL nCol, sal_uInt16 nNewWidth );
714 void SetRowHeight( SCROW nRow, sal_uInt16 nNewHeight );
715 bool SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight,
716 double nPPTX, double nPPTY );
719 * Set specified row height to specified ranges. Don't check for drawing
720 * objects etc. Just set the row height. Nothing else.
722 * Note that setting a new row height via this function will not
723 * invalidate page breaks.
725 void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight );
727 // nPPT to test for modification
728 void SetManualHeight( SCROW nStartRow, SCROW nEndRow, bool bManual );
730 sal_uInt16 GetColWidth( SCCOL nCol, bool bHiddenAsZero = true ) const;
731 sal_uLong GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const;
732 SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow = nullptr, bool bHiddenAsZero = true ) const;
733 sal_uLong GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true ) const;
734 sal_uLong GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const;
735 sal_uLong GetColOffset( SCCOL nCol, bool bHiddenAsZero = true ) const;
736 sal_uLong GetRowOffset( SCROW nRow, bool bHiddenAsZero = true ) const;
739 * Get the last row such that the height of row 0 to the end row is as
740 * high as possible without exceeding the specified height value.
742 * @param nHeight maximum desired height
744 * @return SCROW last row of the range within specified height.
746 SCROW GetRowForHeight(sal_uLong nHeight) const;
748 sal_uInt16 GetOriginalWidth( SCCOL nCol ) const;
749 sal_uInt16 GetOriginalHeight( SCROW nRow ) const;
751 sal_uInt16 GetCommonWidth( SCCOL nEndCol ) const;
753 SCROW GetHiddenRowCount( SCROW nRow ) const;
755 void ShowCol(SCCOL nCol, bool bShow);
756 void ShowRow(SCROW nRow, bool bShow);
757 void DBShowRow(SCROW nRow, bool bShow);
759 void ShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
760 void DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
762 void SetRowFlags( SCROW nRow, CRFlags nNewFlags );
763 void SetRowFlags( SCROW nStartRow, SCROW nEndRow, CRFlags nNewFlags );
765 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
766 SCROW GetLastFlaggedRow() const;
768 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
769 SCCOL GetLastChangedCol() const;
770 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
771 SCROW GetLastChangedRow() const;
773 bool IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SCROW nRowEnd) const;
774 bool IsDataFiltered(const ScRange& rRange) const;
775 CRFlags GetColFlags( SCCOL nCol ) const;
776 CRFlags GetRowFlags( SCROW nRow ) const;
778 const ScBitMaskCompressedArray< SCROW, CRFlags> * GetRowFlagsArray() const
779 { return pRowFlags; }
781 bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, bool bShow );
782 bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, bool bShow );
784 void UpdatePageBreaks( const ScRange* pUserArea );
785 void RemoveManualBreaks();
786 bool HasManualBreaks() const;
787 void SetRowManualBreaks( const ::std::set<SCROW>& rBreaks );
788 void SetColManualBreaks( const ::std::set<SCCOL>& rBreaks );
790 void GetAllRowBreaks(::std::set<SCROW>& rBreaks, bool bPage, bool bManual) const;
791 void GetAllColBreaks(::std::set<SCCOL>& rBreaks, bool bPage, bool bManual) const;
792 bool HasRowPageBreak(SCROW nRow) const;
793 bool HasColPageBreak(SCCOL nCol) const;
794 bool HasRowManualBreak(SCROW nRow) const;
795 bool HasColManualBreak(SCCOL nCol) const;
798 * Get the row position of the next manual break that occurs at or below
799 * specified row. When no more manual breaks are present at or below
800 * the specified row, -1 is returned.
802 * @param nRow row at which the search begins.
804 * @return SCROW next row position with manual page break, or -1 if no
805 * more manual breaks are present.
807 SCROW GetNextManualBreak(SCROW nRow) const;
809 void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow);
810 void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual);
811 void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual);
812 void SetRowBreak(SCROW nRow, bool bPage, bool bManual);
813 void SetColBreak(SCCOL nCol, bool bPage, bool bManual);
814 css::uno::Sequence<
815 css::sheet::TablePageBreakData> GetRowBreakData() const;
817 bool RowHidden(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
818 bool RowHiddenLeaf(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
819 bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const;
820 bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
821 bool SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden);
822 void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden);
823 void CopyColHidden(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
824 void CopyRowHidden(ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
825 void CopyRowHeight(ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset);
826 SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
827 SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
828 SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const;
829 sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true) const;
831 SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const;
833 bool RowFiltered(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
834 bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const;
835 bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const;
836 void CopyColFiltered(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
837 void CopyRowFiltered(ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
838 void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered);
839 void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered);
840 SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const;
841 SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const;
842 SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const;
844 bool IsManualRowHeight(SCROW nRow) const;
846 bool HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const;
848 void SyncColRowFlags();
850 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
851 void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
853 /** Sort a range of data. */
854 void Sort(
855 const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
856 ScProgress* pProgress, sc::ReorderParam* pUndo );
858 void Reorder( const sc::ReorderParam& rParam );
860 bool ValidQuery(
861 SCROW nRow, const ScQueryParam& rQueryParam, ScRefCellValue* pCell = nullptr,
862 bool* pbTestEqualCondition = nullptr);
863 void TopTenQuery( ScQueryParam& );
864 SCSIZE Query(ScQueryParam& rQueryParam, bool bKeepSub);
865 bool CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
867 void GetFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, std::vector<ScTypedStrData>& rStrings, bool& rHasDates);
868 void GetFilteredFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScQueryParam& rParam, std::vector<ScTypedStrData>& rStrings, bool& rHasDates );
869 bool GetDataEntries(SCCOL nCol, SCROW nRow, std::set<ScTypedStrData>& rStrings, bool bLimit);
871 bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
872 bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
874 sal_Int32 GetMaxStringLen( SCCOL nCol,
875 SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
876 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
877 SCCOL nCol,
878 SCROW nRowStart, SCROW nRowEnd ) const;
880 bool IsSortCollatorGlobal() const;
881 void InitSortCollator( const ScSortParam& rPar );
882 void DestroySortCollator();
883 void SetDrawPageSize( bool bResetStreamValid = true, bool bUpdateNoteCaptionPos = true );
885 void SetRangeName(ScRangeName* pNew);
886 ScRangeName* GetRangeName() const;
888 void PreprocessRangeNameUpdate(
889 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
891 void CompileHybridFormula(
892 sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt );
894 void PreprocessDBDataUpdate(
895 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
897 ScConditionalFormatList* GetCondFormList();
898 const ScConditionalFormatList* GetCondFormList() const;
899 void SetCondFormList( ScConditionalFormatList* pList );
901 void DeleteConditionalFormat(sal_uLong nOldIndex);
903 sal_uLong AddCondFormat( ScConditionalFormat* pNew );
905 SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow ) const;
906 void SetScriptType( SCCOL nCol, SCROW nRow, SvtScriptType nType );
907 void UpdateScriptTypes( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
909 SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
911 size_t GetFormulaHash( SCCOL nCol, SCROW nRow ) const;
913 ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const;
914 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol, SCROW nRow );
915 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
916 formula::VectorRefArray FetchVectorRefArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
918 void SplitFormulaGroups( SCCOL nCol, std::vector<SCROW>& rRows );
919 void UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows );
920 void RegroupFormulaCells( SCCOL nCol );
922 ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
924 SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow );
925 const SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow ) const;
926 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
928 void FillMatrix( ScMatrix& rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool* pPool ) const;
930 void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
932 void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, size_t nLen );
933 void SetFormulaResults( SCCOL nCol, SCROW nRow, const formula::FormulaConstTokenRef* pResults, size_t nLen );
936 * Either start all formula cells as listeners unconditionally, or start
937 * those that are marked "needs listening".
939 * @param rCxt context object.
940 * @param bAll when true, start all formula cells as listeners. When
941 * false, only start those that are marked "needs listening".
943 void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
946 * Mark formula cells dirty that have the mbPostponedDirty flag set or
947 * contain named ranges with relative references.
949 void SetDirtyIfPostponed();
952 * Broadcast dirty formula cells that contain functions such as CELL(),
953 * COLUMN() or ROW() which may change its value on move.
955 void BroadcastRecalcOnRefMove();
957 void CollectListeners( std::vector<SvtListener*>& rListeners, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
959 void TransferListeners(
960 ScTable& rDestTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
961 SCCOL nColDelta, SCROW nRowDelta );
963 void TransferCellValuesTo( SCCOL nCol, SCROW nRow, size_t nLen, sc::CellValues& rDest );
964 void CopyCellValuesFrom( SCCOL nCol, SCROW nRow, const sc::CellValues& rSrc );
966 std::unique_ptr<sc::ColumnIterator> GetColumnIterator( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
968 void EnsureFormulaCellResults( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
970 void ConvertFormulaToValue(
971 sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
972 sc::TableValues* pUndo );
974 void SwapNonEmpty(
975 sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
977 void finalizeOutlineImport();
979 #if DUMP_COLUMN_STORAGE
980 void DumpColumnStorage( SCCOL nCol ) const;
981 #endif
983 /** Replace behaves differently to the Search; adjust the rCol and rRow accordingly.
985 'Replace' replaces at the 'current' position, but in order to achieve
986 that, we have to 'shift' the rCol / rRow to the 'previous' position -
987 what it is depends on various settings in rSearchItem.
989 static void UpdateSearchItemAddressForReplace( const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow );
991 private:
993 void FillFormulaVertical(
994 const ScFormulaCell& rSrcCell,
995 SCCOLROW& rInner, SCCOL nCol, SCROW nRow1, SCROW nRow2,
996 ScProgress* pProgress, sal_uLong& rProgress );
998 void FillSeriesSimple(
999 ScCellValue& rSrcCell, SCCOLROW& rInner, SCCOLROW nIMin, SCCOLROW nIMax,
1000 SCCOLROW& rCol, SCCOLROW& rRow, bool bVertical, ScProgress* pProgress, sal_uLong& rProgress );
1002 void FillAutoSimple(
1003 SCCOLROW nISrcStart, SCCOLROW nISrcEnd, SCCOLROW nIStart, SCCOLROW nIEnd,
1004 SCCOLROW& rInner, SCCOLROW& rCol, SCCOLROW& rRow,
1005 sal_uLong nActFormCnt, sal_uLong nMaxFormCnt,
1006 bool bHasFiltered, bool bVertical, bool bPositive,
1007 ScProgress* pProgress, sal_uLong& rProgress );
1009 void FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1010 sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd,
1011 FillDateCmd eFillDateCmd,
1012 double nStepValue, double nMaxValue, sal_uInt16 nMinDigits,
1013 bool bAttribs, ScProgress* pProgress );
1014 void FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1015 FillCmd& rCmd, FillDateCmd& rDateCmd,
1016 double& rInc, sal_uInt16& rMinDigits,
1017 ScUserListData*& rListData, sal_uInt16& rListIndex);
1018 void FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1019 sal_uLong nFillCount, FillDir eFillDir, ScProgress* pProgress );
1021 bool ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
1022 bool bMarked, bool bUnprotected ) const;
1024 void AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1025 const ScPatternAttr& rAttr, sal_uInt16 nFormatNo);
1026 void GetAutoFormatAttr(SCCOL nCol, SCROW nRow, sal_uInt16 nIndex, ScAutoFormatData& rData);
1027 void GetAutoFormatFrame(SCCOL nCol, SCROW nRow, sal_uInt16 nFlags, sal_uInt16 nIndex, ScAutoFormatData& rData);
1028 bool SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRow,
1029 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1030 bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1031 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1032 bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1033 SCCOL nLastCol, SCROW nLastRow,
1034 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1035 bool SearchAll(const SvxSearchItem& rSearchItem, const ScMarkData& rMark,
1036 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1037 bool Replace(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1038 const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1039 bool ReplaceAll(
1040 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1041 OUString& rUndoStr, ScDocument* pUndoDoc);
1043 bool SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1044 const ScMarkData& rMark);
1045 bool ReplaceStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1046 const ScMarkData& rMark, bool bIsUndo);
1047 bool SearchAllStyle(
1048 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges);
1049 bool ReplaceAllStyle(
1050 const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1051 ScDocument* pUndoDoc);
1052 bool SearchAndReplaceEmptyCells(
1053 const SvxSearchItem& rSearchItem,
1054 SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1055 OUString& rUndoStr, ScDocument* pUndoDoc);
1056 bool SearchRangeForEmptyCell(const ScRange& rRange,
1057 const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1058 OUString& rUndoStr);
1059 bool SearchRangeForAllEmptyCells(
1060 const ScRange& rRange, const SvxSearchItem& rSearchItem,
1061 ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1063 // use the global sort parameter:
1064 bool IsSorted(SCCOLROW nStart, SCCOLROW nEnd) const;
1065 static void DecoladeRow( ScSortInfoArray*, SCROW nRow1, SCROW nRow2 );
1066 short CompareCell(
1067 sal_uInt16 nSort,
1068 ScRefCellValue& rCell1, SCCOL nCell1Col, SCROW nCell1Row,
1069 ScRefCellValue& rCell2, SCCOL nCell2Col, SCROW nCell2Row ) const;
1070 short Compare(SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1071 short Compare( ScSortInfoArray*, SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1072 ScSortInfoArray* CreateSortInfoArray( const sc::ReorderParam& rParam );
1073 ScSortInfoArray* CreateSortInfoArray(
1074 const ScSortParam& rSortParam, SCCOLROW nInd1, SCCOLROW nInd2,
1075 bool bKeepQuery, bool bUpdateRefs );
1076 void QuickSort( ScSortInfoArray*, SCsCOLROW nLo, SCsCOLROW nHi);
1077 void SortReorderByColumn( ScSortInfoArray* pArray, SCROW nRow1, SCROW nRow2, bool bPattern, ScProgress* pProgress );
1079 void SortReorderByRow( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress );
1080 void SortReorderByRowRefUpdate( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress );
1082 bool CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1083 bool CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1084 void GetUpperCellString(SCCOL nCol, SCROW nRow, OUString& rStr);
1086 bool RefVisible(ScFormulaCell* pCell);
1088 bool IsEmptyLine(SCROW nRow, SCCOL nStartCol, SCCOL nEndCol) const;
1090 void IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillDateCmd eCmd);
1091 void FillFormula(
1092 ScFormulaCell* pSrcCell, SCCOL nDestCol, SCROW nDestRow, bool bLast );
1093 void UpdateInsertTabAbs(SCTAB nNewPos);
1094 bool GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, bool bInSel,
1095 const ScMarkData& rMark) const;
1096 bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark ) const;
1097 void TestTabRefAbs(SCTAB nTable) const;
1098 void CompileDBFormula( sc::CompileFormulaContext& rCxt );
1099 void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt );
1101 void StartListening( const ScAddress& rAddress, SvtListener* pListener );
1102 void EndListening( const ScAddress& rAddress, SvtListener* pListener );
1103 void StartListening( sc::StartListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
1104 void EndListening( sc::EndListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
1106 void AttachFormulaCells( sc::StartListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1107 void DetachFormulaCells( sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1109 void SetLoadingMedium(bool bLoading);
1111 SCSIZE FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2,
1112 SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY,
1113 const ScPatternAttr* pPattern, const SfxItemSet* pCondSet );
1115 // idle calculation of OutputDevice text width for cell
1116 // also invalidates script type, broadcasts for "calc as shown"
1117 void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
1118 bool bNumFormatChanged, bool bBroadcast );
1120 void SkipFilteredRows(SCROW& rRow, SCROW& rLastNonFilteredRow, bool bForward);
1123 * In case the cell text goes beyond the column width, move the max column
1124 * position to the right. This is called from ExtendPrintArea.
1126 void MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY);
1128 void CopyPrintRange(const ScTable& rTable);
1130 SCCOL FindNextVisibleColWithContent(SCCOL nCol, bool bRight, SCROW nRow) const;
1132 SCCOL FindNextVisibleCol(SCCOL nCol, bool bRight) const;
1134 // Clipboard transpose for notes
1135 void TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1, SCROW nRow2);
1137 ScColumn* FetchColumn( SCCOL nCol );
1138 const ScColumn* FetchColumn( SCCOL nCol ) const;
1140 void EndListeningIntersectedGroup(
1141 sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow, std::vector<ScAddress>* pGroupPos );
1143 void EndListeningIntersectedGroups(
1144 sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1145 std::vector<ScAddress>* pGroupPos );
1147 void EndListeningGroup( sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow );
1148 void SetNeedsListeningGroup( SCCOL nCol, SCROW nRow );
1151 * Use this to iterate through non-empty visible cells in a single column.
1153 class VisibleDataCellIterator
1155 public:
1156 static SCROW ROW_NOT_FOUND;
1158 explicit VisibleDataCellIterator(ScFlatBoolRowSegments& rRowSegs, ScColumn& rColumn);
1159 ~VisibleDataCellIterator();
1162 * Set the start row position. In case there is not visible data cell
1163 * at the specified row position, it will move to the position of the
1164 * first visible data cell below that point.
1166 * @return First visible data cell if found, or NULL otherwise.
1168 ScRefCellValue reset(SCROW nRow);
1171 * Find the next visible data cell position.
1173 * @return Next visible data cell if found, or NULL otherwise.
1175 ScRefCellValue next();
1178 * Get the current row position.
1180 * @return Current row position, or ROW_NOT_FOUND if the iterator
1181 * doesn't point to a valid data cell position.
1183 SCROW getRow() const { return mnCurRow;}
1185 private:
1186 ScFlatBoolRowSegments& mrRowSegs;
1187 ScColumn& mrColumn;
1188 ScRefCellValue maCell;
1189 SCROW mnCurRow;
1190 SCROW mnUBound;
1195 #endif
1197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */