Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / inc / column.hxx
blob31ab3574815a898f83433677222a6d941ec5b107
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 "columnspanset.hxx"
26 #include "rangelst.hxx"
27 #include "types.hxx"
28 #include "mtvelements.hxx"
29 #include <formula/types.hxx>
30 #include <svl/zforlist.hxx>
31 #include <svx/svdobj.hxx>
32 #include "attarray.hxx"
34 #include <optional>
35 #include <set>
36 #include <vector>
38 #include <mdds/flat_segment_tree.hpp>
40 namespace editeng { class SvxBorderLine; }
41 namespace formula { struct VectorRefArray; }
43 namespace sc {
45 struct BroadcasterState;
46 struct FormulaGroupEntry;
47 class StartListeningContext;
48 class EndListeningContext;
49 class CopyFromClipContext;
50 class CopyToClipContext;
51 class CopyToDocContext;
52 class MixDocContext;
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;
68 class Sparkline;
72 class Fraction;
73 class OutputDevice;
74 class ScItemPoolCache;
75 class SvtListener;
76 class SfxPoolItem;
77 class SfxStyleSheetBase;
78 class SvxBoxInfoItem;
79 class SvxBoxItem;
81 class ScDocument;
82 class ScEditDataArray;
83 class ScFormulaCell;
84 class ScMarkData;
85 class ScPatternAttr;
86 class ScStyleSheet;
87 class SvtBroadcaster;
88 class ScTypedStrData;
89 class ScProgress;
90 class ScFunctionData;
91 class ScFlatBoolRowSegments;
92 struct ScSetStringParam;
93 struct ScColWidthParam;
94 struct ScRefCellValue;
95 struct ScCellValue;
96 class ScHint;
97 enum class ScMF;
98 struct ScFilterEntries;
99 struct ScInterpreterContext;
101 struct ScNeededSizeOptions
103 const ScPatternAttr* pPattern;
104 bool bFormula;
105 bool bSkipMerged;
106 bool bGetFont;
107 bool bTotalSize;
109 ScNeededSizeOptions();
112 // A shared implementation of some column code and data.
113 // This is used by ScColumn, but also by ScTable for the unallocated
114 // columns (one instance that is the default for all not-yet allocated columns).
115 class ScColumnData
117 protected:
118 std::unique_ptr<ScAttrArray> pAttrArray;
120 ScColumnData(const ScColumnData&) = delete;
121 ScColumnData& operator= (const ScColumnData&) = delete;
123 public:
124 ScColumnData() = default;
125 void InitAttrArray(ScAttrArray* attrArray) { pAttrArray.reset(attrArray); }
127 ScDocument& GetDoc() const { return pAttrArray->GetDoc(); }
129 ScAttrArray& AttrArray() { return *pAttrArray; }
130 const ScAttrArray& AttrArray() const { return *pAttrArray; }
132 const SfxPoolItem& GetAttr( SCROW nRow, sal_uInt16 nWhich ) const;
133 template<class T> const T& GetAttr( SCROW nRow, TypedWhichId<T> nWhich ) const
135 return static_cast<const T&>(GetAttr(nRow, sal_uInt16(nWhich)));
137 const SfxPoolItem& GetAttr( SCROW nRow, sal_uInt16 nWhich, SCROW& nStartRow, SCROW& nEndRow ) const;
138 template<class T> const T& GetAttr( SCROW nRow, TypedWhichId<T> nWhich, SCROW& nStartRow, SCROW& nEndRow ) const
140 return static_cast<const T&>(GetAttr(nRow, sal_uInt16(nWhich), nStartRow, nEndRow));
143 void SetAttrEntries(std::vector<ScAttrEntry> && vNewData);
145 const ScPatternAttr* GetPattern( SCROW nRow ) const;
146 const ScPatternAttr* GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow ) const;
147 void ApplySelectionStyle(const ScStyleSheet& rStyle, SCROW nTop, SCROW nBottom);
148 void ApplySelectionCache(ScItemPoolCache* pCache, SCROW nStartRow, SCROW nEndRow,
149 ScEditDataArray* pDataArray, bool* pIsChanged);
150 void ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr,
151 ScEditDataArray* pDataArray = nullptr,
152 bool* const pIsChanged = nullptr);
153 void MergePatternArea( ScMergePatternState& rState, SCROW nRow1, SCROW nRow2, bool bDeep ) const;
155 sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, SCROW nRow ) const;
156 sal_uInt32 GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const;
158 /// Including current, may return -1
159 SCROW GetNextUnprotected( SCROW nRow, bool bUp ) const;
161 const ScStyleSheet* GetStyle( SCROW nRow ) const;
162 void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle );
164 bool HasAttrib( SCROW nRow1, SCROW nRow2, HasAttrFlags nMask ) const;
165 bool HasAttrib( SCROW nRow, HasAttrFlags nMask, SCROW* nStartRow = nullptr, SCROW* nEndRow = nullptr ) const;
167 std::unique_ptr<ScAttrIterator> CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const;
169 bool IsAllAttrEqual( const ScColumnData& rCol, SCROW nStartRow, SCROW nEndRow ) const;
171 void ClearSelectionItems(const sal_uInt16* pWhich, SCROW nStartRow, SCROW nEndRow);
172 void ChangeSelectionIndent(bool bIncrement, SCROW nStartRow, SCROW nEndRow);
174 bool TestInsertRow( SCSIZE nSize ) const;
175 void InsertRow( SCROW nStartRow, SCSIZE nSize );
176 void DeleteRow( SCROW nStartRow, SCSIZE nSize );
178 // Applies a function to the selected ranges.
179 // The function looks like
180 // ApplyDataFunc(ScColumnData& applyTo, SCROW nTop, SCROW nBottom)
181 template <typename ApplyDataFunc> void Apply(const ScMarkData&, SCCOL, ApplyDataFunc);
184 // Use protected inheritance to prevent publishing some internal ScColumnData
185 // functions as part of ScColumn. If they should be public in ScColumn,
186 // use 'using' to make them public.
187 class ScColumn : protected ScColumnData
189 // Empty values correspond with empty cells. All non-empty cell positions
190 // must have non-empty elements. For text width, the value should be
191 // either the real text width, or TEXTWIDTH_DIRTY in case it hasn't been
192 // calculated yet. For script type, it should be either the real script
193 // type value or SvtScriptType::UNKNOWN.
194 sc::CellTextAttrStoreType maCellTextAttrs;
196 // Cell notes
197 sc::CellNoteStoreType maCellNotes;
199 // Broadcasters for formula cells.
200 sc::BroadcasterStoreType maBroadcasters;
202 // Cell values.
203 sc::CellStoreType maCells;
205 // Sparklines
206 sc::SparklineStoreType maSparklines;
208 sal_uInt32 mnBlkCountFormula;
209 sal_uInt32 mnBlkCountCellNotes;
211 SCCOL nCol;
212 SCTAB nTab;
214 bool mbEmptyBroadcastersPending : 1; // a broadcaster not removed during EnableDelayDeletingBroadcasters()
216 friend class ScDocument; // for FillInfo
217 friend class ScTable;
218 friend class ScValueIterator;
219 friend class ScHorizontalValueIterator;
220 friend class ScDBQueryDataIterator;
221 template< ScQueryCellIteratorAccess accessType, ScQueryCellIteratorType queryType >
222 friend class ScQueryCellIteratorBase;
223 template< ScQueryCellIteratorAccess accessType >
224 friend class ScQueryCellIteratorAccessSpecific;
225 friend class ScFormulaGroupIterator;
226 friend class ScCellIterator;
227 friend class ScHorizontalCellIterator;
228 friend class ScColumnTextWidthIterator;
229 friend class ScDocumentImport;
230 friend class sc::DocumentStreamAccess;
231 friend class sc::SingleColumnSpanSet;
232 friend class sc::ColumnSpanSet;
233 friend class sc::EditTextIterator;
234 friend class sc::CellValues;
235 friend class sc::TableValues;
236 friend class sc::CellStoreEvent;
238 bool ParseString(
239 ScCellValue& rCell,
240 SCROW nRow, SCTAB nTab, const OUString& rString, formula::FormulaGrammar::AddressConvention eConv,
241 const ScSetStringParam* pParam );
243 void duplicateSparkline(sc::CopyFromClipContext& rContext, sc::ColumnBlockPosition* pBlockPos,
244 size_t nColOffset, size_t nDestSize, ScAddress aDestPosition);
246 public:
248 /** Broadcast mode for SetDirty(SCROW,SCROW,BroadcastMode). */
249 enum BroadcastMode
251 BROADCAST_NONE, ///< no broadcasting
252 BROADCAST_DATA_POSITIONS, ///< broadcast existing cells with position => does AreaBroadcast
253 BROADCAST_BROADCASTERS ///< broadcast only existing cell broadcasters => no AreaBroadcast of range!
256 ScColumn(ScSheetLimits const &);
257 ~ScColumn() COVERITY_NOEXCEPT_FALSE;
259 void Init(SCCOL nNewCol, SCTAB nNewTab, ScDocument& rDoc, bool bEmptyAttrArray);
261 using ScColumnData::GetDoc;
262 SCTAB GetTab() const { return nTab; }
263 SCCOL GetCol() const { return nCol; }
264 sc::CellStoreType& GetCellStore() { return maCells; }
265 const sc::CellStoreType& GetCellStore() const { return maCells; }
266 sc::CellTextAttrStoreType& GetCellAttrStore() { return maCellTextAttrs; }
267 const sc::CellTextAttrStoreType& GetCellAttrStore() const { return maCellTextAttrs; }
268 sc::CellNoteStoreType& GetCellNoteStore() { return maCellNotes; }
269 const sc::CellNoteStoreType& GetCellNoteStore() const { return maCellNotes; }
270 sc::SparklineStoreType& GetSparklineStore() { return maSparklines; }
271 const sc::SparklineStoreType& GetSparklineStore() const { return maSparklines; }
273 ScRefCellValue GetCellValue( SCROW nRow ) const;
274 ScRefCellValue GetCellValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow );
275 ScRefCellValue GetCellValue( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
276 static ScRefCellValue GetCellValue( const sc::CellStoreType::const_iterator& itPos, size_t nOffset );
278 const sc::CellTextAttr* GetCellTextAttr( SCROW nRow ) const;
279 const sc::CellTextAttr* GetCellTextAttr( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
281 void Delete( SCROW nRow );
282 void DeleteContent( SCROW nRow, bool bBroadcast = true );
283 void FreeAll();
284 void FreeNotes();
285 void Swap( ScColumn& rOther, SCROW nRow1, SCROW nRow2, bool bPattern );
287 bool HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask ) const;
288 bool IsMerged( SCROW nRow ) const;
289 bool ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
290 SCCOL& rPaintCol, SCROW& rPaintRow,
291 bool bRefresh );
293 bool IsEmptyData() const;
294 bool IsEmptyAttr() const;
296 // data only:
297 bool IsEmptyData(SCROW nStartRow, SCROW nEndRow) const;
298 SCSIZE GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const;
299 bool HasDataAt( SCROW nRow, ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
300 bool HasDataAt( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow,
301 ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
302 bool HasDataAt( sc::ColumnBlockPosition& rBlockPos, SCROW nRow,
303 ScDataAreaExtras* pDataAreaExtras = nullptr );
304 void GetDataExtrasAt( SCROW nRow, ScDataAreaExtras& rDataAreaExtras ) const;
305 bool HasVisibleDataAt(SCROW nRow) const;
306 SCROW GetFirstDataPos() const;
307 SCROW GetLastDataPos() const;
308 SCROW GetLastDataPos( SCROW nLastRow, ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
309 bool GetPrevDataPos(SCROW& rRow) const;
310 bool GetNextDataPos(SCROW& rRow) const;
311 bool TrimEmptyBlocks(SCROW& rRowStart, SCROW& rRowEnd) const;
312 void FindDataAreaPos(SCROW& rRow, bool bDown) const; // (without Broadcaster)
313 void FindUsed( SCROW nStartRow, SCROW nEndRow, mdds::flat_segment_tree<SCROW, bool>& rUsed ) const;
315 SCSIZE VisibleCount( SCROW nStartRow, SCROW nEndRow ) const;
316 sc::MatrixEdge GetBlockMatrixEdges(SCROW nRow1, SCROW nRow2, sc::MatrixEdge nMask, bool bNoMatrixAtAll ) const;
317 // Repeated calls to HasSelectionMatrixFragment() repeatedly call rMark.GetMarkedRanges(),
318 // which may be quite slow. For that reason first save the result of rMark.GetMarkedRanges()
319 // pass that to HasSelectionMatrixFragment() calls.
320 bool HasSelectionMatrixFragment(const ScMarkData& rMark, const ScRangeList& rRangeList) const;
322 bool GetFirstVisibleAttr( SCROW& rFirstRow ) const;
323 bool GetLastVisibleAttr( SCROW& rLastRow, bool bSkipEmpty ) const;
324 bool HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
325 bool IsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW nEndRow ) const;
327 bool TestInsertCol( SCROW nStartRow, SCROW nEndRow) const;
328 bool TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const;
329 void InsertRow( SCROW nStartRow, SCSIZE nSize );
330 void GetUnprotectedCells(SCROW nStartRow, SCROW nEndRow, ScRangeList& rRangeList ) const;
333 * @param nStartRow top row position
334 * @param nSize size of the segment to delete.
335 * @param pGroupPos when non-NULL, stores the top position of formula
336 * group that's been merged as a result of row deletion.
338 void DeleteRow( SCROW nStartRow, SCSIZE nSize, std::vector<ScAddress>* pGroupPos );
340 void DeleteArea(
341 SCROW nStartRow, SCROW nEndRow, InsertDeleteFlags nDelFlag,
342 bool bBroadcast = true, sc::ColumnSpanSet* pBroadcastSpans = nullptr );
344 void DeleteRanges( const std::vector<sc::RowSpan>& rRanges, InsertDeleteFlags nDelFlag );
346 void CopyToClip(
347 sc::CopyToClipContext& rCxt, SCROW nRow1, SCROW nRow2, ScColumn& rColumn,
348 std::unordered_map<const ScPatternAttr*, const ScPatternAttr*>* pPatternPutCache = nullptr ) const;
350 void CopyStaticToDocument(
351 SCROW nRow1, SCROW nRow2, const SvNumberFormatterMergeMap& rMap, ScColumn& rDestCol );
353 void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDestCol );
354 void InitBlockPosition( sc::ColumnBlockPosition& rBlockPos );
355 void InitBlockPosition( sc::ColumnBlockConstPosition& rBlockPos ) const;
357 void DeleteBeforeCopyFromClip(
358 sc::CopyFromClipContext& rCxt, const ScColumn& rClipCol, sc::ColumnSpanSet& rBroadcastSpans );
360 void CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, size_t nColOffset );
362 void CopyFromClip(
363 sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, tools::Long nDy, ScColumn& rColumn );
365 void RemoveEditAttribs( sc::ColumnBlockPosition& rBlockPos, SCROW nStartRow, SCROW nEndRow );
367 // Selection (?) of this document
368 void MixMarked(
369 sc::MixDocContext& rCxt, const ScMarkData& rMark, ScPasteFunc nFunction,
370 bool bSkipEmpty, const ScColumn& rSrcCol );
371 void MixData(
372 sc::MixDocContext& rCxt, SCROW nRow1, SCROW nRow2, ScPasteFunc nFunction, bool bSkipEmpty,
373 const ScColumn& rSrcCol );
375 void UpdateSelectionFunction(
376 const ScRangeList& rRanges, ScFunctionData& rData, const ScFlatBoolRowSegments& rHiddenRows );
378 void CopyToColumn(
379 sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nFlags, bool bMarked,
380 ScColumn& rColumn, const ScMarkData* pMarkData = nullptr, bool bAsLink = false,
381 bool bGlobalNamesToLocal = false ) const;
383 void UndoToColumn(
384 sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nFlags, bool bMarked,
385 ScColumn& rColumn) const;
387 void CopyScenarioFrom( const ScColumn& rSrcCol );
388 void CopyScenarioTo( ScColumn& rDestCol ) const;
389 bool TestCopyScenarioTo( const ScColumn& rDestCol ) const;
390 void MarkScenarioIn( ScMarkData& rDestMark ) const;
392 void CopyUpdated( const ScColumn* pPosCol, ScColumn& rDestCol ) const;
394 void SwapCol(ScColumn& rCol);
395 void MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol);
397 bool HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst);
399 bool SetString(
400 SCROW nRow, SCTAB nTab, const OUString& rString, formula::FormulaGrammar::AddressConvention eConv,
401 const ScSetStringParam* pParam = nullptr );
403 void SetEditText( SCROW nRow, std::unique_ptr<EditTextObject> pEditText );
404 void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, std::unique_ptr<EditTextObject> pEditText );
405 void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const EditTextObject& rEditText );
406 void SetEditText( SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
407 void SetFormula( SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram );
408 void SetFormula( SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram );
411 * Takes ownership of pCell
413 * @return pCell if it was successfully inserted, NULL otherwise. pCell
414 * is deleted automatically on failure to insert.
416 ScFormulaCell* SetFormulaCell(
417 SCROW nRow, ScFormulaCell* pCell,
418 sc::StartListeningType eListenType = sc::SingleCellListening,
419 bool bInheritNumFormatIfNeeded = true);
420 void SetFormulaCell(
421 sc::ColumnBlockPosition& rBlockPos, SCROW nRow, ScFormulaCell* pCell,
422 sc::StartListeningType eListenType = sc::SingleCellListening,
423 bool bInheritNumFormatIfNeeded = true);
425 bool SetFormulaCells( SCROW nRow, std::vector<ScFormulaCell*>& rCells );
427 bool HasFormulaCell() const;
428 bool HasFormulaCell( SCROW nRow1, SCROW nRow2 ) const;
430 void CloneFormulaCell(
431 sc::ColumnBlockPosition& rBlockPos,
432 const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr,
433 const std::vector<sc::RowSpan>& rRanges );
435 void CloneFormulaCell(
436 const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr,
437 const std::vector<sc::RowSpan>& rRanges );
439 svl::SharedString GetSharedString( SCROW nRow ) const;
441 void SetRawString( SCROW nRow, const OUString& rStr );
442 void SetRawString( SCROW nRow, const svl::SharedString& rStr );
443 void SetRawString( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const svl::SharedString& rStr, bool bBroadcast = true );
444 void SetValue( SCROW nRow, double fVal );
445 void SetValues( const SCROW nRow, const std::vector<double>& rVals );
446 void SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double fVal, bool bBroadcast = true );
447 void SetError( SCROW nRow, const FormulaError nError);
449 OUString GetString( SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const
450 { return GetString( GetCellValue( nRow ), nRow, pContext ); }
451 OUString GetString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow,
452 const ScInterpreterContext* pContext = nullptr ) const
453 { return GetString( GetCellValue( rBlockPos, nRow ), nRow, pContext ); }
454 double* GetValueCell( SCROW nRow );
455 // Note that if pShared is set and a value is returned that way, the returned OUString is empty.
456 OUString GetInputString( SCROW nRow, bool bForceSystemLocale = false ) const
457 { return GetInputString( GetCellValue( nRow ), nRow, bForceSystemLocale ); }
458 OUString GetInputString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow,
459 bool bForceSystemLocale = false ) const
460 { return GetInputString( GetCellValue( rBlockPos, nRow ), nRow, bForceSystemLocale ); }
461 double GetValue( SCROW nRow ) const;
462 const EditTextObject* GetEditText( SCROW nRow ) const;
463 void RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr& rAttr );
464 OUString GetFormula( SCROW nRow ) const;
465 const ScFormulaCell* GetFormulaCell( SCROW nRow ) const;
466 ScFormulaCell* GetFormulaCell( SCROW nRow );
467 ScFormulaCell * const * GetFormulaCellBlockAddress( SCROW nRow, size_t& rBlockSize ) const;
468 CellType GetCellType( SCROW nRow ) const;
469 SCSIZE GetCellCount() const;
470 sal_uInt64 GetWeightedCount() const;
471 sal_uInt64 GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
472 sal_uInt64 GetCodeCount() const; // RPN-Code in formulas
473 FormulaError GetErrCode( SCROW nRow ) const;
475 bool HasStringData( SCROW nRow ) const;
476 bool HasValueData( SCROW nRow ) const;
477 bool HasStringCells( SCROW nStartRow, SCROW nEndRow ) const;
479 sc::MultiDataCellState::StateType HasDataCellsInRange(
480 SCROW nRow1, SCROW nRow2, SCROW* pRow1 ) const;
482 bool IsFormulaDirty( SCROW nRow ) const;
484 void CheckVectorizationState();
485 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
486 void SetDirtyFromClip( SCROW nRow1, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans );
487 void SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode );
488 void SetDirtyVar();
489 void SetDirtyAfterLoad();
490 void SetTableOpDirty( const ScRange& );
491 void CalcAll();
492 void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening );
493 void CompileAll( sc::CompileFormulaContext& rCxt );
494 void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress );
496 /** Broadcast single broadcasters in range, without explicitly setting
497 anything dirty, not doing area broadcasts.
498 @param rHint address is modified to adapt to the actual broadcasted
499 position on each iteration and upon return points to the last
500 position broadcasted. */
501 bool BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, SfxHintId nHint );
503 bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode );
505 void ResetChanged( SCROW nStartRow, SCROW nEndRow );
507 bool UpdateReferenceOnCopy( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr );
510 * Update reference addresses in formula cell in response to mass cell
511 * movement.
513 * @return true if reference of at least one formula cell has been
514 * updated, false otherwise.
516 bool UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc );
518 void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
519 void UpdateInsertTabOnlyCells( sc::RefUpdateInsertTabContext& rCxt );
520 void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
521 void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo );
522 void UpdateCompile( bool bForceIfNameInUse = false );
523 void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
524 ScDocument* pUndoDoc );
525 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
527 void SetTabNo(SCTAB nNewTab);
528 void FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, sc::UpdatedRangeNames& rIndexes) const;
530 void PreprocessRangeNameUpdate(
531 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
533 void CompileHybridFormula(
534 sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt );
536 void PreprocessDBDataUpdate(
537 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
539 using ScColumnData::GetAttr;
540 using ScColumnData::GetPattern;
541 using ScColumnData::GetNumberFormat;
543 void MergeSelectionPattern( ScMergePatternState& rState, const ScMarkData& rMark, bool bDeep ) const;
544 void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
545 ScLineFlags& rFlags,
546 SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const;
547 void ApplyBlockFrame(const SvxBoxItem& rLineOuter, const SvxBoxInfoItem* pLineInner,
548 SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight);
550 void ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr );
551 void ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr );
552 const ScPatternAttr* SetPattern( SCROW nRow, std::unique_ptr<ScPatternAttr> );
553 void SetPattern( SCROW nRow, const ScPatternAttr& );
554 void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& );
555 void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
556 const ScPatternAttr& rPattern, SvNumFormatType nNewType );
558 void ApplyStyle( SCROW nRow, const ScStyleSheet* rStyle );
559 void ApplySelectionLineStyle( const ScMarkData& rMark,
560 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
561 void AddCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
562 void RemoveCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
564 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
565 const ScStyleSheet* GetAreaStyle( bool& rFound, SCROW nRow1, SCROW nRow2 ) const;
567 void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset );
568 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
570 /// May return -1 if not found
571 SCROW SearchStyle(
572 SCROW nRow, const ScStyleSheet* pSearchStyle, bool bUp, bool bInSelection,
573 const ScMarkData& rMark) const;
575 bool SearchStyleRange(
576 SCROW& rRow, SCROW& rEndRow, const ScStyleSheet* pSearchStyle, bool bUp,
577 bool bInSelection, const ScMarkData& rMark) const;
579 bool ApplyFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags );
580 bool RemoveFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags );
581 void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
583 void RemoveProtected( SCROW nStartRow, SCROW nEndRow );
585 void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast );
587 tools::Long GetNeededSize(
588 SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY,
589 const Fraction& rZoomX, const Fraction& rZoomY,
590 bool bWidth, const ScNeededSizeOptions& rOptions, const ScPatternAttr** pPatternChange,
591 bool bInPrintTwips = false ) const;
593 sal_uInt16 GetOptimalColWidth(
594 OutputDevice* pDev, double nPPTX, double nPPTY,
595 const Fraction& rZoomX, const Fraction& rZoomY,
596 bool bFormula, sal_uInt16 nOldWidth, const ScMarkData* pMarkData, const ScColWidthParam* pParam) const;
598 void GetOptimalHeight(
599 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart );
601 void GetFilterEntries(
602 sc::ColumnBlockConstPosition& rBlockPos, SCROW nStartRow, SCROW nEndRow,
603 ScFilterEntries& rFilterEntries, bool bFiltering, bool bFilteredRow );
605 void GetBackColorFilterEntries(SCROW nRow1, SCROW nRow2, ScFilterEntries& rFilterEntries );
607 bool GetDataEntries( SCROW nRow, std::set<ScTypedStrData>& rStrings) const;
609 void UpdateInsertTabAbs(SCTAB nNewPos);
610 bool TestTabRefAbs(SCTAB nTable) const;
611 bool GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& rData) const;
613 void StartListeningFormulaCells(
614 sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt, SCROW nRow1, SCROW nRow2 );
616 void EndListeningFormulaCells(
617 sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2,
618 SCROW* pStartRow, SCROW* pEndRow );
620 void StartListening( SvtListener& rLst, SCROW nRow );
621 void EndListening( SvtListener& rLst, SCROW nRow );
622 void StartListening( sc::StartListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
623 void EndListening( sc::EndListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
624 void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
625 void SetDirtyIfPostponed();
626 void BroadcastRecalcOnRefMove();
627 void CollectListeners( std::vector<SvtListener*>& rListeners, SCROW nRow1, SCROW nRow2 );
628 void CollectFormulaCells( std::vector<ScFormulaCell*>& rCells, SCROW nRow1, SCROW nRow2 );
630 void CompileDBFormula( sc::CompileFormulaContext& rCxt );
631 void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt );
633 sal_Int32 GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
634 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
635 SCROW nRowStart, SCROW nRowEnd ) const;
637 sal_uInt16 GetTextWidth(SCROW nRow) const;
638 void SetTextWidth(SCROW nRow, sal_uInt16 nWidth);
640 SvtScriptType GetScriptType( SCROW nRow ) const;
643 * Get combined script types of the specified range. This method may
644 * update script types on demand if they have not been determined.
646 SvtScriptType GetRangeScriptType( sc::CellTextAttrStoreType::iterator& itPos, SCROW nRow1, SCROW nRow2,
647 const sc::CellStoreType::iterator& itr);
649 void SetScriptType( SCROW nRow, SvtScriptType nType );
650 void UpdateScriptTypes( SCROW nRow1, SCROW nRow2 );
652 formula::FormulaTokenRef ResolveStaticReference( SCROW nRow );
653 bool ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow1, SCROW nRow2 );
654 void FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2, svl::SharedStringPool* pPool ) const;
655 formula::VectorRefArray FetchVectorRefArray( SCROW nRow1, SCROW nRow2 );
656 bool HandleRefArrayForParallelism( SCROW nRow1, SCROW nRow2,
657 const ScFormulaCellGroupRef& mxGroup, ScAddress* pDirtiedAddress );
658 #ifdef DBG_UTIL
659 void AssertNoInterpretNeeded( SCROW nRow1, SCROW nRow2 );
660 #endif
661 void SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen );
663 void CalculateInThread( ScInterpreterContext& rContext, SCROW nRow, size_t nLen, size_t nOffset,
664 unsigned nThisThread, unsigned nThreadsTotal );
665 void HandleStuffAfterParallelCalculation( SCROW nRow, size_t nLen, ScInterpreter* pInterpreter );
667 void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
669 SvtBroadcaster* GetBroadcaster( SCROW nRow );
670 const SvtBroadcaster* GetBroadcaster( SCROW nRow ) const;
672 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 );
673 void PrepareBroadcastersForDestruction();
674 void DeleteEmptyBroadcasters();
676 void Broadcast( SCROW nRow );
677 void BroadcastCells( const std::vector<SCROW>& rRows, SfxHintId nHint );
678 void BroadcastRows( SCROW nStartRow, SCROW nEndRow, SfxHintId nHint );
680 // Spaklines
681 sc::SparklineCell* GetSparklineCell(SCROW nRow);
682 void CreateSparklineCell(SCROW nRow, std::shared_ptr<sc::Sparkline> const& pSparkline);
683 void DeleteSparklineCells(sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2);
684 bool DeleteSparkline(SCROW nRow);
685 bool IsSparklinesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
686 void CopyCellSparklinesToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol, SCROW nRowOffsetDest = 0) const;
687 void DuplicateSparklines(SCROW nStartRow, size_t nDataSize, ScColumn& rDestCol,
688 sc::ColumnBlockPosition& rDestBlockPos, SCROW nRowOffsetDest = 0) const;
689 bool HasSparklines() const;
690 SCROW GetSparklinesMaxRow() const;
691 SCROW GetSparklinesMinRow() const;
693 // cell notes
694 ScPostIt* GetCellNote( SCROW nRow );
695 const ScPostIt* GetCellNote( SCROW nRow ) const;
696 ScPostIt* GetCellNote( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow );
697 const ScPostIt* GetCellNote( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
698 void DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership );
699 bool HasCellNote(SCROW nStartRow, SCROW nEndRow) const;
700 bool HasCellNotes() const;
701 void SetCellNote( SCROW nRow, std::unique_ptr<ScPostIt> pNote);
702 bool IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
704 std::unique_ptr<ScPostIt> ReleaseNote( SCROW nRow );
705 size_t GetNoteCount() const;
706 void CreateAllNoteCaptions();
707 void ForgetNoteCaptions( SCROW nRow1, SCROW nRow2, bool bPreserveData );
708 SCROW GetNotePosition( size_t nIndex ) const;
709 void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
710 void GetNotesInRange( SCROW nStartRow, SCROW nEndRow, std::vector<sc::NoteEntry>& rNotes ) const;
712 SCROW GetCellNotesMaxRow() const;
713 SCROW GetCellNotesMinRow() const;
715 void CopyCellNotesToDocument(
716 SCROW nRow1, SCROW nRow2, ScColumn& rDestCol, bool bCloneCaption = true,
717 SCROW nRowOffsetDest = 0) const;
719 void DuplicateNotes(SCROW nStartRow, size_t nDataSize, ScColumn& rDestCol,
720 sc::ColumnBlockPosition& rDestBlockPos, bool bCloneCaption, SCROW nRowOffsetDest = 0) const;
722 void UpdateNoteCaptions( SCROW nRow1, SCROW nRow2, bool bAddressChanged = true );
723 void CommentNotifyAddressChange( SCROW nRow1, SCROW nRow2 );
725 void UpdateDrawObjects( std::vector<std::vector<SdrObject*>>& pObjects, SCROW nRowStart, SCROW nRowEnd );
726 void UpdateDrawObjectsForRow( std::vector<SdrObject*>& pObjects, SCCOL nTargetCol, SCROW nTargetRow );
727 bool IsDrawObjectsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
729 void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 );
730 bool InterpretCellsIfNeeded( SCROW nRow1, SCROW nRow2 );
732 static void JoinNewFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell );
735 * Detach a formula cell that's about to be deleted, or removed from
736 * document storage (if that ever happens).
738 * @param rNewSharedRows collects possible new shared row ranges (top and
739 * bottom of shared or remaining single twice) resulting from
740 * unsharing to reestablish listeners on.
742 void DetachFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell,
743 std::vector<SCROW>& rNewSharedRows );
745 /** Re-establish listeners on unshared formula groups */
746 void StartListeningUnshared( const std::vector<SCROW>& rNewSharedRows );
748 void DetachFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength,
749 std::vector<SCROW>* pNewSharedRows );
751 void AttachFormulaCells( sc::StartListeningContext& rCxt, SCROW nRow1, SCROW nRow2 );
752 void DetachFormulaCells( sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2 );
755 * Regroup formula cells for the entire column.
757 void RegroupFormulaCells( std::vector<ScAddress>* pGroupPos = nullptr );
760 * Reset column position of formula cells within specified row range.
761 * If bUpdateRefs==true then reference positions are also adjusted to
762 * reflect the new position so that the formula cells still reference the
763 * same cells or ranges after the position change.
764 * The position of a formula cell before the call is interpreted as the old
765 * position of that cell.
767 * Caller needs to ensure that no formula groups cross the top and bottom
768 * row boundaries.
770 * @param nRow1 top row boundary
771 * @param nRow2 bottom row boundary
772 * @param bUpdateRefs whether to adjust references
774 void ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2, bool bUpdateRefs );
776 void SplitFormulaGroupByRelativeRef( const ScRange& rBoundRange );
778 void TransferCellValuesTo( SCROW nRow, size_t nLen, sc::CellValues& rDest );
779 void CopyCellValuesFrom( SCROW nRow, const sc::CellValues& rSrc );
780 void ConvertFormulaToValue(
781 sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, sc::TableValues* pUndo );
783 void SwapNonEmpty(
784 sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
786 std::optional<sc::ColumnIterator> GetColumnIterator( SCROW nRow1, SCROW nRow2 ) const;
788 bool EnsureFormulaCellResults( SCROW nRow1, SCROW nRow2, bool bSkipRunning = false );
790 void StoreToCache(SvStream& rStrm) const;
791 void RestoreFromCache(SvStream& rStrm);
793 #if DUMP_COLUMN_STORAGE
794 void DumpColumnStorage() const;
795 #endif
797 SCSIZE GetPatternCount() const;
798 SCSIZE GetPatternCount( SCROW nRow1, SCROW nRow2 ) const;
799 bool ReservePatternCount( SCSIZE nReserve );
801 void CheckIntegrity() const;
803 private:
805 sc::CellStoreType::iterator GetPositionToInsert( SCROW nRow, std::vector<SCROW>& rNewSharedRows,
806 bool bInsertFormula );
807 sc::CellStoreType::iterator GetPositionToInsert( const sc::CellStoreType::iterator& it, SCROW nRow,
808 std::vector<SCROW>& rNewSharedRows, bool bInsertFormula );
810 void AttachNewFormulaCell(
811 const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell,
812 const std::vector<SCROW>& rNewSharedRows,
813 bool bJoin = true, sc::StartListeningType eListenType = sc::SingleCellListening );
815 void AttachNewFormulaCell(
816 const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell,
817 const std::vector<SCROW>& rNewSharedRows,
818 bool bJoin = true, sc::StartListeningType eListenType = sc::SingleCellListening );
820 public:
821 void AttachNewFormulaCells(const sc::CellStoreType::position_type& aPos, size_t nLength,
822 std::vector<SCROW>& rNewSharedRows);
824 private:
825 void BroadcastNewCell( SCROW nRow );
826 bool UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow, sc::CellStoreType::iterator& itr );
828 const ScFormulaCell* FetchFormulaCell( SCROW nRow ) const;
830 SCROW FindNextVisibleRowWithContent(
831 sc::CellStoreType::const_iterator& itPos, SCROW nRow, bool bForward) const;
832 SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const;
834 OUString GetString( const ScRefCellValue& cell, SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const;
835 OUString GetInputString( const ScRefCellValue& cell, SCROW nRow, bool bForceSystemLocale = false ) const;
838 * Called whenever the state of cell array gets modified i.e. new cell
839 * insertion, cell removal or relocation, cell value update and so on.
841 * Call this only from those methods where maCells is modified directly.
843 void CellStorageModified();
844 void CellNotesDeleting(SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership );
846 void CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol) const;
848 struct DeleteCellsResult
850 /** cell ranges that have been deleted. */
851 sc::SingleColumnSpanSet aDeletedRows;
852 /** formula cell range that has stopped listening. */
853 std::vector<std::pair<SCROW, SCROW>> aFormulaRanges;
855 DeleteCellsResult( const ScDocument& rDoc );
856 DeleteCellsResult( const DeleteCellsResult& ) = delete;
859 std::unique_ptr<DeleteCellsResult> DeleteCells(
860 sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nDelFlag );
863 * Get all non-grouped formula cells and formula cell groups in the whole
864 * column.
866 std::vector<sc::FormulaGroupEntry> GetFormulaGroupEntries();
868 void EndListeningIntersectedGroup(
869 sc::EndListeningContext& rCxt, SCROW nRow, std::vector<ScAddress>* pGroupPos );
871 void EndListeningIntersectedGroups(
872 sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, std::vector<ScAddress>* pGroupPos );
874 void EndListeningGroup( sc::EndListeningContext& rCxt, SCROW nRow );
875 void SetNeedsListeningGroup( SCROW nRow );
877 void CollectBroadcasterState(sc::BroadcasterState& rState) const;
880 inline bool ScColumn::IsEmptyAttr() const
882 return pAttrArray->IsEmpty();
885 inline bool ScColumnData::IsAllAttrEqual( const ScColumnData& rCol, SCROW nStartRow, SCROW nEndRow ) const
887 return pAttrArray->IsAllEqual( *rCol.pAttrArray, nStartRow, nEndRow );
890 inline bool ScColumn::IsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW nEndRow ) const
892 return pAttrArray->IsVisibleEqual( *rCol.pAttrArray, nStartRow, nEndRow );
895 inline bool ScColumn::GetFirstVisibleAttr( SCROW& rFirstRow ) const
897 return pAttrArray->GetFirstVisibleAttr( rFirstRow );
900 inline bool ScColumn::GetLastVisibleAttr( SCROW& rLastRow, bool bSkipEmpty ) const
902 // row of last cell is needed
903 SCROW nLastData = GetLastDataPos(); // always including notes, 0 if none
904 return pAttrArray->GetLastVisibleAttr( rLastRow, nLastData, bSkipEmpty );
907 inline bool ScColumn::HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const
909 return pAttrArray->HasVisibleAttrIn( nStartRow, nEndRow );
912 inline SCSIZE ScColumn::GetPatternCount() const
914 return pAttrArray->Count();
917 inline SCSIZE ScColumn::GetPatternCount( SCROW nRow1, SCROW nRow2 ) const
919 return pAttrArray->Count( nRow1, nRow2 );
922 inline bool ScColumn::ReservePatternCount( SCSIZE nReserve )
924 return pAttrArray && pAttrArray->Reserve( nReserve );
927 inline bool ScColumn::IsMerged( SCROW nRow ) const
929 return pAttrArray->IsMerged(nRow);
932 inline SCROW ScColumnData::GetNextUnprotected( SCROW nRow, bool bUp ) const
934 return pAttrArray->GetNextUnprotected(nRow, bUp);
937 inline bool ScColumnData::HasAttrib( SCROW nRow1, SCROW nRow2, HasAttrFlags nMask ) const
939 return pAttrArray->HasAttrib( nRow1, nRow2, nMask );
942 inline bool ScColumnData::HasAttrib( SCROW nRow, HasAttrFlags nMask, SCROW* nStartRow, SCROW* nEndRow ) const
944 return pAttrArray->HasAttrib( nRow, nMask, nStartRow, nEndRow );
947 inline bool ScColumn::ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
948 SCCOL& rPaintCol, SCROW& rPaintRow,
949 bool bRefresh )
951 return pAttrArray->ExtendMerge( nThisCol, nStartRow, nEndRow, rPaintCol, rPaintRow, bRefresh );
954 inline void ScColumnData::MergePatternArea( ScMergePatternState& rState, SCROW nRow1, SCROW nRow2, bool bDeep ) const
956 pAttrArray->MergePatternArea( nRow1, nRow2, rState, bDeep );
959 inline void ScColumn::MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
960 ScLineFlags& rFlags,
961 SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const
963 pAttrArray->MergeBlockFrame( pLineOuter, pLineInner, rFlags, nStartRow, nEndRow, bLeft, nDistRight );
966 inline void ScColumn::ApplyBlockFrame(const SvxBoxItem& rLineOuter, const SvxBoxInfoItem* pLineInner,
967 SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight)
969 pAttrArray->ApplyBlockFrame(rLineOuter, pLineInner, nStartRow, nEndRow, bLeft, nDistRight);
972 inline const ScPatternAttr* ScColumnData::GetPattern( SCROW nRow ) const
974 return pAttrArray->GetPattern( nRow );
977 inline const SfxPoolItem& ScColumnData::GetAttr( SCROW nRow, sal_uInt16 nWhich ) const
979 return pAttrArray->GetPattern( nRow )->GetItemSet().Get(nWhich);
982 inline const SfxPoolItem& ScColumnData::GetAttr( SCROW nRow, sal_uInt16 nWhich, SCROW& nStartRow, SCROW& nEndRow ) const
984 return pAttrArray->GetPatternRange( nStartRow, nEndRow, nRow )->GetItemSet().Get(nWhich);
987 inline sal_uInt32 ScColumnData::GetNumberFormat( const ScInterpreterContext& rContext, SCROW nRow ) const
989 return pAttrArray->GetPattern( nRow )->GetNumberFormat( rContext );
992 inline void ScColumn::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex )
994 pAttrArray->AddCondFormat( nStartRow, nEndRow, nIndex );
997 inline void ScColumn::RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex )
999 pAttrArray->RemoveCondFormat( nStartRow, nEndRow, nIndex );
1002 inline void ScColumnData::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle )
1004 pAttrArray->ApplyStyleArea(nStartRow, nEndRow, rStyle);
1007 inline const ScStyleSheet* ScColumnData::GetStyle( SCROW nRow ) const
1009 return pAttrArray->GetPattern( nRow )->GetStyleSheet();
1012 inline void ScColumn::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset )
1014 pAttrArray->FindStyleSheet( pStyleSheet, rUsedRows, bReset );
1017 inline bool ScColumn::IsStyleSheetUsed( const ScStyleSheet& rStyle ) const
1019 return pAttrArray->IsStyleSheetUsed( rStyle );
1022 inline bool ScColumn::ApplyFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags )
1024 return pAttrArray->ApplyFlags( nStartRow, nEndRow, nFlags );
1027 inline bool ScColumn::RemoveFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags )
1029 return pAttrArray->RemoveFlags( nStartRow, nEndRow, nFlags );
1032 inline void ScColumn::ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich )
1034 pAttrArray->ClearItems( nStartRow, nEndRow, pWhich );
1037 inline const ScPatternAttr* ScColumn::SetPattern( SCROW nRow, std::unique_ptr<ScPatternAttr> pPatAttr )
1039 return pAttrArray->SetPattern( nRow, std::move(pPatAttr), true/*bPutToPool*/ );
1042 inline void ScColumn::SetPattern( SCROW nRow, const ScPatternAttr& rPatAttr )
1044 pAttrArray->SetPattern( nRow, &rPatAttr, true/*bPutToPool*/ );
1047 inline void ScColumn::SetPatternArea( SCROW nStartRow, SCROW nEndRow,
1048 const ScPatternAttr& rPatAttr )
1050 pAttrArray->SetPatternArea( nStartRow, nEndRow, &rPatAttr, true/*bPutToPool*/ );
1053 inline void ScColumnData::SetAttrEntries(std::vector<ScAttrEntry> && vNewData)
1055 pAttrArray->SetAttrEntries( std::move( vNewData ));
1058 inline bool ScColumnData::TestInsertRow( SCSIZE nSize ) const
1060 return pAttrArray->TestInsertRow( nSize );
1063 inline void ScColumnData::InsertRow( SCROW nStartRow, SCSIZE nSize )
1065 pAttrArray->InsertRow( nStartRow, nSize );
1068 inline void ScColumnData::DeleteRow(SCROW nStartRow, SCSIZE nSize)
1070 pAttrArray->DeleteRow( nStartRow, nSize );
1073 template <typename ApplyDataFunc>
1074 void ScColumnData::Apply(const ScMarkData& rMark, SCCOL nCol, ApplyDataFunc apply)
1076 if (rMark.IsMultiMarked())
1078 ScMultiSelIter aMultiIter(rMark.GetMultiSelData(), nCol);
1079 SCROW nTop, nBottom;
1080 while (aMultiIter.Next(nTop, nBottom))
1081 apply(*this, nTop, nBottom);
1083 else if (rMark.IsMarked())
1085 const ScRange& aRange = rMark.GetMarkArea();
1086 if (aRange.aStart.Col() <= nCol && nCol <= aRange.aEnd.Col())
1087 apply(*this, aRange.aStart.Row(), aRange.aEnd.Row());
1091 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */