check IFrame "FrameURL" target
[LibreOffice.git] / sc / inc / column.hxx
blobb8e348d00e70a87f79286d95ae08f8923b0914f2
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 "global.hxx"
23 #include "address.hxx"
24 #include "cellvalue.hxx"
25 #include "rangelst.hxx"
26 #include "types.hxx"
27 #include "mtvelements.hxx"
28 #include <formula/types.hxx>
29 #include <svl/zforlist.hxx>
30 #include <svx/svdobj.hxx>
31 #include "attarray.hxx"
33 #include <optional>
34 #include <set>
35 #include <vector>
37 #include <mdds/flat_segment_tree.hpp>
39 namespace editeng { class SvxBorderLine; }
40 namespace formula { struct VectorRefArray; }
42 namespace sc {
44 struct FormulaGroupEntry;
45 class StartListeningContext;
46 class EndListeningContext;
47 class CopyFromClipContext;
48 class CopyToClipContext;
49 class CopyToDocContext;
50 class MixDocContext;
51 class ColumnSpanSet;
52 class SingleColumnSpanSet;
53 struct RefUpdateContext;
54 struct RefUpdateInsertTabContext;
55 struct RefUpdateDeleteTabContext;
56 struct RefUpdateMoveTabContext;
57 class EditTextIterator;
58 struct NoteEntry;
59 class DocumentStreamAccess;
60 class CellValues;
61 class TableValues;
62 struct RowSpan;
63 class RowHeightContext;
64 class CompileFormulaContext;
65 struct SetFormulaDirtyContext;
66 enum class MatrixEdge;
67 class ColumnIterator;
71 class Fraction;
72 class OutputDevice;
73 class SfxItemPoolCache;
74 class SvtListener;
75 class SfxPoolItem;
76 class SfxStyleSheetBase;
77 class SvxBoxInfoItem;
78 class SvxBoxItem;
80 class ScDocument;
81 class ScEditDataArray;
82 class ScFormulaCell;
83 class ScMarkData;
84 class ScPatternAttr;
85 class ScStyleSheet;
86 class SvtBroadcaster;
87 class ScTypedStrData;
88 class ScProgress;
89 class ScFunctionData;
90 class ScFlatBoolRowSegments;
91 struct ScSetStringParam;
92 struct ScColWidthParam;
93 struct ScRefCellValue;
94 struct ScCellValue;
95 class ScHint;
96 enum class ScMF;
97 struct ScFilterEntries;
98 struct ScInterpreterContext;
100 struct ScNeededSizeOptions
102 const ScPatternAttr* pPattern;
103 bool bFormula;
104 bool bSkipMerged;
105 bool bGetFont;
106 bool bTotalSize;
108 ScNeededSizeOptions();
111 class ScColumn
113 // Empty values correspond with empty cells. All non-empty cell positions
114 // must have non-empty elements. For text width, the value should be
115 // either the real text width, or TEXTWIDTH_DIRTY in case it hasn't been
116 // calculated yet. For script type, it should be either the real script
117 // type value or SvtScriptType::UNKNOWN.
118 sc::CellTextAttrStoreType maCellTextAttrs;
120 // Cell notes
121 sc::CellNoteStoreType maCellNotes;
123 // Broadcasters for formula cells.
124 sc::BroadcasterStoreType maBroadcasters;
126 // Cell values.
127 sc::CellStoreType maCells;
129 std::unique_ptr<ScAttrArray> pAttrArray;
131 size_t mnBlkCountFormula;
133 SCCOL nCol;
134 SCTAB nTab;
136 bool mbFiltering; // it is true if there is a filtering in the column
138 friend class ScDocument; // for FillInfo
139 friend class ScTable;
140 friend class ScValueIterator;
141 friend class ScHorizontalValueIterator;
142 friend class ScDBQueryDataIterator;
143 friend class ScQueryCellIterator;
144 friend class ScCountIfCellIterator;
145 friend class ScFormulaGroupIterator;
146 friend class ScCellIterator;
147 friend class ScHorizontalCellIterator;
148 friend class ScHorizontalAttrIterator;
149 friend class ScColumnTextWidthIterator;
150 friend class ScDocumentImport;
151 friend class sc::DocumentStreamAccess;
152 friend class sc::SingleColumnSpanSet;
153 friend class sc::ColumnSpanSet;
154 friend class sc::EditTextIterator;
155 friend class sc::CellValues;
156 friend class sc::TableValues;
157 friend class sc::CellStoreEvent;
159 ScColumn(const ScColumn&) = delete;
160 ScColumn& operator= (const ScColumn&) = delete;
162 bool ParseString(
163 ScCellValue& rCell,
164 SCROW nRow, SCTAB nTab, const OUString& rString, formula::FormulaGrammar::AddressConvention eConv,
165 const ScSetStringParam* pParam );
167 public:
169 /** Broadcast mode for SetDirty(SCROW,SCROW,BroadcastMode). */
170 enum BroadcastMode
172 BROADCAST_NONE, ///< no broadcasting
173 BROADCAST_DATA_POSITIONS, ///< broadcast existing cells with position => does AreaBroadcast
174 BROADCAST_BROADCASTERS ///< broadcast only existing cell broadcasters => no AreaBroadcast of range!
177 ScColumn(ScSheetLimits const &);
178 ~ScColumn() COVERITY_NOEXCEPT_FALSE;
180 void Init(SCCOL nNewCol, SCTAB nNewTab, ScDocument& rDoc, bool bEmptyAttrArray);
182 ScDocument& GetDoc() const { return pAttrArray->GetDoc(); }
183 SCTAB GetTab() const { return nTab; }
184 SCCOL GetCol() const { return nCol; }
185 bool HasFiltering() const { return mbFiltering; }
186 sc::CellStoreType& GetCellStore() { return maCells; }
187 const sc::CellStoreType& GetCellStore() const { return maCells; }
188 sc::CellTextAttrStoreType& GetCellAttrStore() { return maCellTextAttrs; }
189 const sc::CellTextAttrStoreType& GetCellAttrStore() const { return maCellTextAttrs; }
190 sc::CellNoteStoreType& GetCellNoteStore() { return maCellNotes; }
191 const sc::CellNoteStoreType& GetCellNoteStore() const { return maCellNotes; }
193 ScRefCellValue GetCellValue( SCROW nRow ) const;
194 ScRefCellValue GetCellValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow );
195 ScRefCellValue GetCellValue( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
196 static ScRefCellValue GetCellValue( const sc::CellStoreType::const_iterator& itPos, size_t nOffset );
198 const sc::CellTextAttr* GetCellTextAttr( SCROW nRow ) const;
199 const sc::CellTextAttr* GetCellTextAttr( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
201 void Delete( SCROW nRow );
202 void DeleteContent( SCROW nRow, bool bBroadcast = true );
203 void FreeAll();
204 void FreeNotes();
205 void Swap( ScColumn& rOther, SCROW nRow1, SCROW nRow2, bool bPattern );
207 bool HasAttrib( SCROW nRow1, SCROW nRow2, HasAttrFlags nMask ) const;
208 bool HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask ) const;
209 bool IsMerged( SCROW nRow ) const;
210 bool ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
211 SCCOL& rPaintCol, SCROW& rPaintRow,
212 bool bRefresh );
214 bool IsEmptyData() const;
215 bool IsEmptyAttr() const;
217 // data only:
218 bool IsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
219 SCSIZE GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const;
220 bool HasDataAt( SCROW nRow, ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
221 bool HasDataAt( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow,
222 ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
223 bool HasDataAt( sc::ColumnBlockPosition& rBlockPos, SCROW nRow,
224 ScDataAreaExtras* pDataAreaExtras = nullptr );
225 void GetDataExtrasAt( SCROW nRow, ScDataAreaExtras& rDataAreaExtras ) const;
226 bool HasVisibleDataAt(SCROW nRow) const;
227 SCROW GetFirstDataPos() const;
228 SCROW GetLastDataPos() const;
229 SCROW GetLastDataPos( SCROW nLastRow, ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
230 bool GetPrevDataPos(SCROW& rRow) const;
231 bool GetNextDataPos(SCROW& rRow) const;
232 bool TrimEmptyBlocks(SCROW& rRowStart, SCROW& rRowEnd) const;
233 void FindDataAreaPos(SCROW& rRow, bool bDown) const; // (without Broadcaster)
234 void FindUsed( SCROW nStartRow, SCROW nEndRow, mdds::flat_segment_tree<SCROW, bool>& rUsed ) const;
236 SCSIZE VisibleCount( SCROW nStartRow, SCROW nEndRow ) const;
237 sc::MatrixEdge GetBlockMatrixEdges(SCROW nRow1, SCROW nRow2, sc::MatrixEdge nMask, bool bNoMatrixAtAll ) const;
238 bool HasSelectionMatrixFragment(const ScMarkData& rMark) const;
240 bool GetFirstVisibleAttr( SCROW& rFirstRow ) const;
241 bool GetLastVisibleAttr( SCROW& rLastRow ) const;
242 bool HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
243 bool IsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow = 0,
244 SCROW nEndRow = MAXROW ) const;
245 bool IsAllAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW nEndRow ) const;
247 bool TestInsertCol( SCROW nStartRow, SCROW nEndRow) const;
248 bool TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const;
249 void InsertRow( SCROW nStartRow, SCSIZE nSize );
250 void GetUnprotectedCells(SCROW nStartRow, SCROW nEndRow, ScRangeList& rRangeList ) const;
253 * @param nStartRow top row position
254 * @param nSize size of the segment to delete.
255 * @param pGroupPos when non-NULL, stores the top position of formula
256 * group that's been merged as a result of row deletion.
258 void DeleteRow( SCROW nStartRow, SCSIZE nSize, std::vector<ScAddress>* pGroupPos );
260 void DeleteArea(
261 SCROW nStartRow, SCROW nEndRow, InsertDeleteFlags nDelFlag,
262 bool bBroadcast = true, sc::ColumnSpanSet* pBroadcastSpans = nullptr );
264 void DeleteRanges( const std::vector<sc::RowSpan>& rRanges, InsertDeleteFlags nDelFlag );
266 void CopyToClip(
267 sc::CopyToClipContext& rCxt, SCROW nRow1, SCROW nRow2, ScColumn& rColumn ) const;
269 void CopyStaticToDocument(
270 SCROW nRow1, SCROW nRow2, const SvNumberFormatterMergeMap& rMap, ScColumn& rDestCol );
272 void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDestCol );
273 void InitBlockPosition( sc::ColumnBlockPosition& rBlockPos );
274 void InitBlockPosition( sc::ColumnBlockConstPosition& rBlockPos ) const;
276 void DeleteBeforeCopyFromClip(
277 sc::CopyFromClipContext& rCxt, const ScColumn& rClipCol, sc::ColumnSpanSet& rBroadcastSpans );
279 void CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, size_t nColOffset );
281 void CopyFromClip(
282 sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, tools::Long nDy, ScColumn& rColumn );
284 void RemoveEditAttribs( sc::ColumnBlockPosition& rBlockPos, SCROW nStartRow, SCROW nEndRow );
286 // Selection (?) of this document
287 void MixMarked(
288 sc::MixDocContext& rCxt, const ScMarkData& rMark, ScPasteFunc nFunction,
289 bool bSkipEmpty, const ScColumn& rSrcCol );
290 void MixData(
291 sc::MixDocContext& rCxt, SCROW nRow1, SCROW nRow2, ScPasteFunc nFunction, bool bSkipEmpty,
292 const ScColumn& rSrcCol );
294 std::unique_ptr<ScAttrIterator> CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const;
296 void UpdateSelectionFunction(
297 const ScRangeList& rRanges, ScFunctionData& rData, const ScFlatBoolRowSegments& rHiddenRows );
299 void CopyToColumn(
300 sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nFlags, bool bMarked,
301 ScColumn& rColumn, const ScMarkData* pMarkData = nullptr, bool bAsLink = false,
302 bool bGlobalNamesToLocal = false ) const;
304 void UndoToColumn(
305 sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nFlags, bool bMarked,
306 ScColumn& rColumn) const;
308 void CopyScenarioFrom( const ScColumn& rSrcCol );
309 void CopyScenarioTo( ScColumn& rDestCol ) const;
310 bool TestCopyScenarioTo( const ScColumn& rDestCol ) const;
311 void MarkScenarioIn( ScMarkData& rDestMark ) const;
313 void CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const;
315 void SwapCol(ScColumn& rCol);
316 void MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol);
318 bool HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst);
320 bool SetString(
321 SCROW nRow, SCTAB nTab, const OUString& rString, formula::FormulaGrammar::AddressConvention eConv,
322 const ScSetStringParam* pParam = nullptr );
324 void SetEditText( SCROW nRow, std::unique_ptr<EditTextObject> pEditText );
325 void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, std::unique_ptr<EditTextObject> pEditText );
326 void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const EditTextObject& rEditText );
327 void SetEditText( SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
328 void SetFormula( SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram );
329 void SetFormula( SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram );
332 * Takes ownership of pCell
334 * @return pCell if it was successfully inserted, NULL otherwise. pCell
335 * is deleted automatically on failure to insert.
337 ScFormulaCell* SetFormulaCell(
338 SCROW nRow, ScFormulaCell* pCell,
339 sc::StartListeningType eListenType = sc::SingleCellListening,
340 bool bInheritNumFormatIfNeeded = true);
341 void SetFormulaCell(
342 sc::ColumnBlockPosition& rBlockPos, SCROW nRow, ScFormulaCell* pCell,
343 sc::StartListeningType eListenType = sc::SingleCellListening,
344 bool bInheritNumFormatIfNeeded = true);
346 bool SetFormulaCells( SCROW nRow, std::vector<ScFormulaCell*>& rCells );
348 bool HasFormulaCell() const;
349 bool HasFormulaCell( SCROW nRow1, SCROW nRow2 ) const;
351 void CloneFormulaCell(
352 sc::ColumnBlockPosition& rBlockPos,
353 const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr,
354 const std::vector<sc::RowSpan>& rRanges );
356 void CloneFormulaCell(
357 const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr,
358 const std::vector<sc::RowSpan>& rRanges );
360 svl::SharedString GetSharedString( SCROW nRow ) const;
362 void SetRawString( SCROW nRow, const OUString& rStr );
363 void SetRawString( SCROW nRow, const svl::SharedString& rStr );
364 void SetRawString( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const svl::SharedString& rStr, bool bBroadcast = true );
365 void SetValue( SCROW nRow, double fVal );
366 void SetValues( const SCROW nRow, const std::vector<double>& rVals );
367 void SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double fVal, bool bBroadcast = true );
368 void SetError( SCROW nRow, const FormulaError nError);
370 OUString GetString( SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const
371 { return GetString( GetCellValue( nRow ), nRow, pContext ); }
372 OUString GetString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow,
373 const ScInterpreterContext* pContext = nullptr ) const
374 { return GetString( GetCellValue( rBlockPos, nRow ), nRow, pContext ); }
375 double* GetValueCell( SCROW nRow );
376 // Note that if pShared is set and a value is returned that way, the returned OUString is empty.
377 OUString GetInputString( SCROW nRow, const svl::SharedString** pShared = nullptr ) const
378 { return GetInputString( GetCellValue( nRow ), nRow, pShared ); }
379 OUString GetInputString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow,
380 const svl::SharedString** pShared = nullptr ) const
381 { return GetInputString( GetCellValue( rBlockPos, nRow ), nRow, pShared ); }
382 double GetValue( SCROW nRow ) const;
383 const EditTextObject* GetEditText( SCROW nRow ) const;
384 void RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr& rAttr );
385 OUString GetFormula( SCROW nRow ) const;
386 const ScFormulaCell* GetFormulaCell( SCROW nRow ) const;
387 ScFormulaCell* GetFormulaCell( SCROW nRow );
388 ScFormulaCell * const * GetFormulaCellBlockAddress( SCROW nRow, size_t& rBlockSize ) const;
389 CellType GetCellType( SCROW nRow ) const;
390 SCSIZE GetCellCount() const;
391 sal_uLong GetWeightedCount() const;
392 sal_uLong GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
393 sal_uInt32 GetCodeCount() const; // RPN-Code in formulas
394 FormulaError GetErrCode( SCROW nRow ) const;
396 bool HasStringData( SCROW nRow ) const;
397 bool HasValueData( SCROW nRow ) const;
398 bool HasStringCells( SCROW nStartRow, SCROW nEndRow ) const;
400 sc::MultiDataCellState::StateType HasDataCellsInRange(
401 SCROW nRow1, SCROW nRow2, SCROW* pRow1 ) const;
403 bool IsFormulaDirty( SCROW nRow ) const;
405 void CheckVectorizationState();
406 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
407 void SetDirtyFromClip( SCROW nRow1, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans );
408 void SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode );
409 void SetDirtyVar();
410 void SetDirtyAfterLoad();
411 void SetTableOpDirty( const ScRange& );
412 void CalcAll();
413 void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening );
414 void CompileAll( sc::CompileFormulaContext& rCxt );
415 void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress );
417 /** Broadcast single broadcasters in range, without explicitly setting
418 anything dirty, not doing area broadcasts.
419 @param rHint address is modified to adapt to the actual broadcasted
420 position on each iteration and upon return points to the last
421 position broadcasted. */
422 bool BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, SfxHintId nHint );
424 bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode );
426 void ResetChanged( SCROW nStartRow, SCROW nEndRow );
428 bool UpdateReferenceOnCopy( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr );
431 * Update reference addresses in formula cell in response to mass cell
432 * movement.
434 * @return true if reference of at least one formula cell has been
435 * updated, false otherwise.
437 bool UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc );
439 void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
440 void UpdateInsertTabOnlyCells( sc::RefUpdateInsertTabContext& rCxt );
441 void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
442 void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo );
443 void UpdateCompile( bool bForceIfNameInUse = false );
444 void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
445 ScDocument* pUndoDoc );
446 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
448 void SetTabNo(SCTAB nNewTab);
449 void FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, sc::UpdatedRangeNames& rIndexes) const;
451 void PreprocessRangeNameUpdate(
452 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
454 void CompileHybridFormula(
455 sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt );
457 void PreprocessDBDataUpdate(
458 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
460 const SfxPoolItem& GetAttr( SCROW nRow, sal_uInt16 nWhich ) const;
461 template<class T> const T& GetAttr( SCROW nRow, TypedWhichId<T> nWhich ) const
463 return static_cast<const T&>(GetAttr(nRow, sal_uInt16(nWhich)));
465 const ScPatternAttr* GetPattern( SCROW nRow ) const;
466 const ScPatternAttr* GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow ) const;
468 sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, SCROW nRow ) const;
469 sal_uInt32 GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const;
471 void MergeSelectionPattern( ScMergePatternState& rState, const ScMarkData& rMark, bool bDeep ) const;
472 void MergePatternArea( ScMergePatternState& rState, SCROW nRow1, SCROW nRow2, bool bDeep ) const;
473 void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
474 ScLineFlags& rFlags,
475 SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const;
476 void ApplyBlockFrame(const SvxBoxItem& rLineOuter, const SvxBoxInfoItem* pLineInner,
477 SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight);
479 void ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr );
480 void ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr );
481 void ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr,
482 ScEditDataArray* pDataArray = nullptr,
483 bool* const pIsChanged = nullptr);
484 const ScPatternAttr* SetPattern( SCROW nRow, std::unique_ptr<ScPatternAttr> );
485 void SetPattern( SCROW nRow, const ScPatternAttr& );
486 void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& );
487 void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
488 const ScPatternAttr& rPattern, SvNumFormatType nNewType );
490 void ApplyStyle( SCROW nRow, const ScStyleSheet* rStyle );
491 void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle );
492 void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
493 void ApplySelectionLineStyle( const ScMarkData& rMark,
494 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
495 void AddCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
496 void RemoveCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
498 const ScStyleSheet* GetStyle( SCROW nRow ) const;
499 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
500 const ScStyleSheet* GetAreaStyle( bool& rFound, SCROW nRow1, SCROW nRow2 ) const;
502 void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset );
503 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
505 /// May return -1 if not found
506 SCROW SearchStyle(
507 SCROW nRow, const ScStyleSheet* pSearchStyle, bool bUp, bool bInSelection,
508 const ScMarkData& rMark) const;
510 bool SearchStyleRange(
511 SCROW& rRow, SCROW& rEndRow, const ScStyleSheet* pSearchStyle, bool bUp,
512 bool bInSelection, const ScMarkData& rMark) const;
514 bool ApplyFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags );
515 bool RemoveFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags );
516 void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
518 void RemoveProtected( SCROW nStartRow, SCROW nEndRow );
520 SCROW ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged );
521 void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast );
523 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
524 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
526 tools::Long GetNeededSize(
527 SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY,
528 const Fraction& rZoomX, const Fraction& rZoomY,
529 bool bWidth, const ScNeededSizeOptions& rOptions, const ScPatternAttr** pPatternChange,
530 bool bInPrintTwips = false ) const;
532 sal_uInt16 GetOptimalColWidth(
533 OutputDevice* pDev, double nPPTX, double nPPTY,
534 const Fraction& rZoomX, const Fraction& rZoomY,
535 bool bFormula, sal_uInt16 nOldWidth, const ScMarkData* pMarkData, const ScColWidthParam* pParam) const;
537 void GetOptimalHeight(
538 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart );
540 /// Including current, may return -1
541 SCROW GetNextUnprotected( SCROW nRow, bool bUp ) const;
543 void GetFilterEntries(
544 sc::ColumnBlockConstPosition& rBlockPos, SCROW nStartRow, SCROW nEndRow,
545 ScFilterEntries& rFilterEntries, bool bFiltering );
547 bool GetDataEntries( SCROW nRow, std::set<ScTypedStrData>& rStrings) const;
549 void UpdateInsertTabAbs(SCTAB nNewPos);
550 bool TestTabRefAbs(SCTAB nTable) const;
551 bool GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& rData) const;
553 void StartListeningFormulaCells(
554 sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt, SCROW nRow1, SCROW nRow2 );
556 void EndListeningFormulaCells(
557 sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2,
558 SCROW* pStartRow, SCROW* pEndRow );
560 void StartListening( SvtListener& rLst, SCROW nRow );
561 void EndListening( SvtListener& rLst, SCROW nRow );
562 void StartListening( sc::StartListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
563 void EndListening( sc::EndListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
564 void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
565 void SetDirtyIfPostponed();
566 void BroadcastRecalcOnRefMove();
567 void CollectListeners( std::vector<SvtListener*>& rListeners, SCROW nRow1, SCROW nRow2 );
568 void CollectFormulaCells( std::vector<ScFormulaCell*>& rCells, SCROW nRow1, SCROW nRow2 );
570 void CompileDBFormula( sc::CompileFormulaContext& rCxt );
571 void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt );
573 sal_Int32 GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
574 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
575 SCROW nRowStart, SCROW nRowEnd ) const;
577 sal_uInt16 GetTextWidth(SCROW nRow) const;
578 void SetTextWidth(SCROW nRow, sal_uInt16 nWidth);
580 SvtScriptType GetScriptType( SCROW nRow ) const;
583 * Get combined script types of the specified range. This method may
584 * update script types on demand if they have not been determined.
586 SvtScriptType GetRangeScriptType( sc::CellTextAttrStoreType::iterator& itPos, SCROW nRow1, SCROW nRow2,
587 const sc::CellStoreType::iterator& itr);
589 void SetScriptType( SCROW nRow, SvtScriptType nType );
590 void UpdateScriptTypes( SCROW nRow1, SCROW nRow2 );
592 formula::FormulaTokenRef ResolveStaticReference( SCROW nRow );
593 bool ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow1, SCROW nRow2 );
594 void FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2, svl::SharedStringPool* pPool ) const;
595 formula::VectorRefArray FetchVectorRefArray( SCROW nRow1, SCROW nRow2 );
596 bool HandleRefArrayForParallelism( SCROW nRow1, SCROW nRow2, const ScFormulaCellGroupRef& mxGroup );
597 #ifdef DBG_UTIL
598 void AssertNoInterpretNeeded( SCROW nRow1, SCROW nRow2 );
599 #endif
600 void SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen );
602 void CalculateInThread( ScInterpreterContext& rContext, SCROW nRow, size_t nLen, size_t nOffset,
603 unsigned nThisThread, unsigned nThreadsTotal );
604 void HandleStuffAfterParallelCalculation( SCROW nRow, size_t nLen, ScInterpreter* pInterpreter );
606 void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
608 SvtBroadcaster* GetBroadcaster( SCROW nRow );
609 const SvtBroadcaster* GetBroadcaster( SCROW nRow ) const;
611 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 );
612 void PrepareBroadcastersForDestruction();
614 void Broadcast( SCROW nRow );
615 void BroadcastCells( const std::vector<SCROW>& rRows, SfxHintId nHint );
616 void BroadcastRows( SCROW nStartRow, SCROW nEndRow, SfxHintId nHint );
618 // cell notes
619 ScPostIt* GetCellNote( SCROW nRow );
620 const ScPostIt* GetCellNote( SCROW nRow ) const;
621 ScPostIt* GetCellNote( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow );
622 const ScPostIt* GetCellNote( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
623 void DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership );
624 bool HasCellNote(SCROW nStartRow, SCROW nEndRow) const;
625 bool HasCellNotes() const;
626 void SetCellNote( SCROW nRow, std::unique_ptr<ScPostIt> pNote);
627 bool IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
629 std::unique_ptr<ScPostIt> ReleaseNote( SCROW nRow );
630 size_t GetNoteCount() const;
631 void CreateAllNoteCaptions();
632 void ForgetNoteCaptions( SCROW nRow1, SCROW nRow2, bool bPreserveData );
633 SCROW GetNotePosition( size_t nIndex ) const;
634 void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
635 void GetNotesInRange( SCROW nStartRow, SCROW nEndRow, std::vector<sc::NoteEntry>& rNotes ) const;
637 SCROW GetCellNotesMaxRow() const;
638 SCROW GetCellNotesMinRow() const;
640 void CopyCellNotesToDocument(
641 SCROW nRow1, SCROW nRow2, ScColumn& rDestCol, bool bCloneCaption = true,
642 SCROW nRowOffsetDest = 0) const;
644 void DuplicateNotes(SCROW nStartRow, size_t nDataSize, ScColumn& rDestCol,
645 sc::ColumnBlockPosition& maDestBlockPos, bool bCloneCaption, SCROW nRowOffsetDest=0 ) const;
647 void UpdateNoteCaptions( SCROW nRow1, SCROW nRow2 );
649 void UpdateDrawObjects( std::vector<std::vector<SdrObject*>>& pObjects, SCROW nRowStart, SCROW nRowEnd );
650 void UpdateDrawObjectsForRow( std::vector<SdrObject*>& pObjects, SCCOL nTargetCol, SCROW nTargetRow );
651 bool IsDrawObjectsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
653 void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 );
654 void InterpretCellsIfNeeded( SCROW nRow1, SCROW nRow2 );
656 static void JoinNewFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell );
659 * Detach a formula cell that's about to be deleted, or removed from
660 * document storage (if that ever happens).
662 * @param rNewSharedRows collects possible new shared row ranges (top and
663 * bottom of shared or remaining single twice) resulting from
664 * unsharing to reestablish listeners on.
666 void DetachFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell,
667 std::vector<SCROW>& rNewSharedRows );
669 /** Re-establish listeners on unshared formula groups */
670 void StartListeningUnshared( const std::vector<SCROW>& rNewSharedRows );
672 void DetachFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength,
673 std::vector<SCROW>* pNewSharedRows );
675 void AttachFormulaCells( sc::StartListeningContext& rCxt, SCROW nRow1, SCROW nRow2 );
676 void DetachFormulaCells( sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2,
677 std::vector<SCROW>* pNewSharedRows );
680 * Regroup formula cells for the entire column.
682 void RegroupFormulaCells( std::vector<ScAddress>* pGroupPos = nullptr );
685 * Reset column position of formula cells within specified row range.
686 * If bUpdateRefs==true then reference positions are also adjusted to
687 * reflect the new position so that the formula cells still reference the
688 * same cells or ranges after the position change.
689 * The position of a formula cell before the call is interpreted as the old
690 * position of that cell.
692 * Caller needs to ensure that no formula groups cross the top and bottom
693 * row boundaries.
695 * @param nRow1 top row boundary
696 * @param nRow2 bottom row boundary
697 * @param bUpdateRefs whether to adjust references
699 void ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2, bool bUpdateRefs );
701 void SplitFormulaGroupByRelativeRef( const ScRange& rBoundRange );
703 void TransferCellValuesTo( SCROW nRow, size_t nLen, sc::CellValues& rDest );
704 void CopyCellValuesFrom( SCROW nRow, const sc::CellValues& rSrc );
705 void ConvertFormulaToValue(
706 sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, sc::TableValues* pUndo );
708 void SwapNonEmpty(
709 sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
711 std::optional<sc::ColumnIterator> GetColumnIterator( SCROW nRow1, SCROW nRow2 ) const;
713 bool EnsureFormulaCellResults( SCROW nRow1, SCROW nRow2, bool bSkipRunning = false );
715 void StoreToCache(SvStream& rStrm) const;
716 void RestoreFromCache(SvStream& rStrm);
718 #if DUMP_COLUMN_STORAGE
719 void DumpColumnStorage() const;
720 #endif
722 SCSIZE GetPatternCount() const;
723 SCSIZE GetPatternCount( SCROW nRow1, SCROW nRow2 ) const;
724 bool ReservePatternCount( SCSIZE nReserve );
726 void CheckIntegrity() const;
728 private:
730 sc::CellStoreType::iterator GetPositionToInsert( SCROW nRow, std::vector<SCROW>& rNewSharedRows,
731 bool bInsertFormula );
732 sc::CellStoreType::iterator GetPositionToInsert( const sc::CellStoreType::iterator& it, SCROW nRow,
733 std::vector<SCROW>& rNewSharedRows, bool bInsertFormula );
735 void AttachNewFormulaCell(
736 const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell,
737 const std::vector<SCROW>& rNewSharedRows,
738 bool bJoin = true, sc::StartListeningType eListenType = sc::SingleCellListening );
740 void AttachNewFormulaCell(
741 const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell,
742 const std::vector<SCROW>& rNewSharedRows,
743 bool bJoin = true, sc::StartListeningType eListenType = sc::SingleCellListening );
745 public:
746 void AttachNewFormulaCells(const sc::CellStoreType::position_type& aPos, size_t nLength,
747 std::vector<SCROW>& rNewSharedRows);
749 private:
750 void BroadcastNewCell( SCROW nRow );
751 bool UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow, sc::CellStoreType::iterator& itr );
753 const ScFormulaCell* FetchFormulaCell( SCROW nRow ) const;
755 SCROW FindNextVisibleRowWithContent(
756 sc::CellStoreType::const_iterator& itPos, SCROW nRow, bool bForward) const;
757 SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const;
759 OUString GetString( const ScRefCellValue& cell, SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const;
760 OUString GetInputString( const ScRefCellValue& cell, SCROW nRow, const svl::SharedString** pShared = nullptr ) const;
763 * Called whenever the state of cell array gets modified i.e. new cell
764 * insertion, cell removal or relocation, cell value update and so on.
766 * Call this only from those methods where maCells is modified directly.
768 void CellStorageModified();
769 void CellNotesDeleting(SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership );
771 void CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol) const;
773 void DeleteCells(
774 sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nDelFlag,
775 sc::SingleColumnSpanSet& rDeleted );
778 * Get all non-grouped formula cells and formula cell groups in the whole
779 * column.
781 std::vector<sc::FormulaGroupEntry> GetFormulaGroupEntries();
783 void EndListeningIntersectedGroup(
784 sc::EndListeningContext& rCxt, SCROW nRow, std::vector<ScAddress>* pGroupPos );
786 void EndListeningIntersectedGroups(
787 sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, std::vector<ScAddress>* pGroupPos );
789 void EndListeningGroup( sc::EndListeningContext& rCxt, SCROW nRow );
790 void SetNeedsListeningGroup( SCROW nRow );
793 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */