nss: upgrade to release 3.73
[LibreOffice.git] / sc / inc / column.hxx
blob3adca3745ec0286c89d1b3456571103c3e615d85
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_COLUMN_HXX
21 #define INCLUDED_SC_INC_COLUMN_HXX
23 #include "global.hxx"
24 #include "address.hxx"
25 #include "cellvalue.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 <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 sc::CellStoreEvent maCellsEvent;
128 // Cell values.
129 sc::CellStoreType maCells;
131 std::unique_ptr<ScAttrArray> pAttrArray;
133 size_t mnBlkCountFormula;
135 SCCOL nCol;
136 SCTAB nTab;
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 sc::CellStoreType& GetCellStore() { return maCells; }
186 const sc::CellStoreType& GetCellStore() const { return maCells; }
187 sc::CellTextAttrStoreType& GetCellAttrStore() { return maCellTextAttrs; }
188 const sc::CellTextAttrStoreType& GetCellAttrStore() const { return maCellTextAttrs; }
189 sc::CellNoteStoreType& GetCellNoteStore() { return maCellNotes; }
190 const sc::CellNoteStoreType& GetCellNoteStore() const { return maCellNotes; }
192 ScRefCellValue GetCellValue( SCROW nRow ) const;
193 ScRefCellValue GetCellValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow );
194 ScRefCellValue GetCellValue( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
195 static ScRefCellValue GetCellValue( const sc::CellStoreType::const_iterator& itPos, size_t nOffset );
197 const sc::CellTextAttr* GetCellTextAttr( SCROW nRow ) const;
198 const sc::CellTextAttr* GetCellTextAttr( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
200 void Delete( SCROW nRow );
201 void DeleteContent( SCROW nRow, bool bBroadcast = true );
202 void FreeAll();
203 void FreeNotes();
204 void Swap( ScColumn& rOther, SCROW nRow1, SCROW nRow2, bool bPattern );
206 bool HasAttrib( SCROW nRow1, SCROW nRow2, HasAttrFlags nMask ) const;
207 bool HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask ) const;
208 bool IsMerged( SCROW nRow ) const;
209 bool ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
210 SCCOL& rPaintCol, SCROW& rPaintRow,
211 bool bRefresh );
213 bool IsEmptyData() const;
214 bool IsEmptyAttr() const;
216 // data only:
217 bool IsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
218 SCSIZE GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const;
219 bool HasDataAt(SCROW nRow, bool bConsiderCellNotes=false,
220 bool bConsiderCellDrawObjects=false) const;
221 bool HasDataAt(sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow, bool bConsiderCellNotes=false,
222 bool bConsiderCellDrawObjects=false) const;
223 bool HasDataAt(sc::ColumnBlockPosition& rBlockPos, SCROW nRow, bool bConsiderCellNotes=false,
224 bool bConsiderCellDrawObjects=false);
225 bool HasVisibleDataAt(SCROW nRow) const;
226 SCROW GetFirstDataPos() const;
227 SCROW GetLastDataPos() const;
228 SCROW GetLastDataPos( SCROW nLastRow, bool bConsiderCellNotes=false,
229 bool bConsiderCellDrawObjects=false ) 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( 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 const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr,
353 const std::vector<sc::RowSpan>& rRanges );
355 svl::SharedString GetSharedString( SCROW nRow ) const;
357 void SetRawString( SCROW nRow, const OUString& rStr );
358 void SetRawString( SCROW nRow, const svl::SharedString& rStr );
359 void SetRawString( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const svl::SharedString& rStr, bool bBroadcast = true );
360 void SetValue( SCROW nRow, double fVal );
361 void SetValues( const SCROW nRow, const std::vector<double>& rVals );
362 void SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double fVal, bool bBroadcast = true );
363 void SetError( SCROW nRow, const FormulaError nError);
365 void GetString( SCROW nRow, OUString& rString, const ScInterpreterContext* pContext = nullptr ) const
366 { return GetString( GetCellValue( nRow ), nRow, rString, pContext ); }
367 void GetString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow,
368 OUString& rString, const ScInterpreterContext* pContext = nullptr ) const
369 { return GetString( GetCellValue( rBlockPos, nRow ), nRow, rString, pContext ); }
370 double* GetValueCell( SCROW nRow );
371 void GetInputString( SCROW nRow, OUString& rString ) const
372 { return GetInputString( GetCellValue( nRow ), nRow, rString ); }
373 void GetInputString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow, OUString& rString ) const
374 { return GetInputString( GetCellValue( rBlockPos, nRow ), nRow, rString ); }
375 double GetValue( SCROW nRow ) const;
376 const EditTextObject* GetEditText( SCROW nRow ) const;
377 void RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr& rAttr );
378 void GetFormula( SCROW nRow, OUString& rFormula ) const;
379 const ScFormulaCell* GetFormulaCell( SCROW nRow ) const;
380 ScFormulaCell* GetFormulaCell( SCROW nRow );
381 ScFormulaCell * const * GetFormulaCellBlockAddress( SCROW nRow, size_t& rBlockSize ) const;
382 CellType GetCellType( SCROW nRow ) const;
383 SCSIZE GetCellCount() const;
384 sal_uLong GetWeightedCount() const;
385 sal_uLong GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
386 sal_uInt32 GetCodeCount() const; // RPN-Code in formulas
387 FormulaError GetErrCode( SCROW nRow ) const;
389 bool HasStringData( SCROW nRow ) const;
390 bool HasValueData( SCROW nRow ) const;
391 bool HasStringCells( SCROW nStartRow, SCROW nEndRow ) const;
393 sc::MultiDataCellState::StateType HasDataCellsInRange(
394 SCROW nRow1, SCROW nRow2, SCROW* pRow1 ) const;
396 bool IsFormulaDirty( SCROW nRow ) const;
398 void CheckVectorizationState();
399 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
400 void SetDirtyFromClip( SCROW nRow1, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans );
401 void SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode );
402 void SetDirtyVar();
403 void SetDirtyAfterLoad();
404 void SetTableOpDirty( const ScRange& );
405 void CalcAll();
406 void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening );
407 void CompileAll( sc::CompileFormulaContext& rCxt );
408 void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress );
410 /** Broadcast single broadcasters in range, without explicitly setting
411 anything dirty, not doing area broadcasts.
412 @param rHint address is modified to adapt to the actual broadcasted
413 position on each iteration and upon return points to the last
414 position broadcasted. */
415 bool BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, ScHint& rHint );
417 bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode );
419 void ResetChanged( SCROW nStartRow, SCROW nEndRow );
421 bool UpdateReferenceOnCopy( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr );
424 * Update reference addresses in formula cell in response to mass cell
425 * movement.
427 * @return true if reference of at least one formula cell has been
428 * updated, false otherwise.
430 bool UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc );
432 void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
433 void UpdateInsertTabOnlyCells( sc::RefUpdateInsertTabContext& rCxt );
434 void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
435 void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo );
436 void UpdateCompile( bool bForceIfNameInUse = false );
437 void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
438 ScDocument* pUndoDoc );
439 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
441 void SetTabNo(SCTAB nNewTab);
442 void FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, sc::UpdatedRangeNames& rIndexes) const;
444 void PreprocessRangeNameUpdate(
445 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
447 void CompileHybridFormula(
448 sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt );
450 void PreprocessDBDataUpdate(
451 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
453 const SfxPoolItem& GetAttr( SCROW nRow, sal_uInt16 nWhich ) const;
454 template<class T> const T& GetAttr( SCROW nRow, TypedWhichId<T> nWhich ) const
456 return static_cast<const T&>(GetAttr(nRow, sal_uInt16(nWhich)));
458 const ScPatternAttr* GetPattern( SCROW nRow ) const;
459 const ScPatternAttr* GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow ) const;
461 sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, SCROW nRow ) const;
462 sal_uInt32 GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const;
464 void MergeSelectionPattern( ScMergePatternState& rState, const ScMarkData& rMark, bool bDeep ) const;
465 void MergePatternArea( ScMergePatternState& rState, SCROW nRow1, SCROW nRow2, bool bDeep ) const;
466 void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
467 ScLineFlags& rFlags,
468 SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const;
469 void ApplyBlockFrame(const SvxBoxItem& rLineOuter, const SvxBoxInfoItem* pLineInner,
470 SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight);
472 void ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr );
473 void ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr );
474 void ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr,
475 ScEditDataArray* pDataArray = nullptr,
476 bool* const pIsChanged = nullptr);
477 const ScPatternAttr* SetPattern( SCROW nRow, std::unique_ptr<ScPatternAttr> );
478 void SetPattern( SCROW nRow, const ScPatternAttr& );
479 void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& );
480 void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
481 const ScPatternAttr& rPattern, SvNumFormatType nNewType );
483 void ApplyStyle( SCROW nRow, const ScStyleSheet* rStyle );
484 void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle );
485 void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
486 void ApplySelectionLineStyle( const ScMarkData& rMark,
487 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
488 void AddCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
489 void RemoveCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
491 const ScStyleSheet* GetStyle( SCROW nRow ) const;
492 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
493 const ScStyleSheet* GetAreaStyle( bool& rFound, SCROW nRow1, SCROW nRow2 ) const;
495 void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset );
496 bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
498 /// May return -1 if not found
499 SCROW SearchStyle(
500 SCROW nRow, const ScStyleSheet* pSearchStyle, bool bUp, bool bInSelection,
501 const ScMarkData& rMark) const;
503 bool SearchStyleRange(
504 SCROW& rRow, SCROW& rEndRow, const ScStyleSheet* pSearchStyle, bool bUp,
505 bool bInSelection, const ScMarkData& rMark) const;
507 bool ApplyFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags );
508 bool RemoveFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags );
509 void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
511 void RemoveProtected( SCROW nStartRow, SCROW nEndRow );
513 SCROW ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged );
514 void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast );
516 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
517 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
519 tools::Long GetNeededSize(
520 SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY,
521 const Fraction& rZoomX, const Fraction& rZoomY,
522 bool bWidth, const ScNeededSizeOptions& rOptions, const ScPatternAttr** pPatternChange,
523 bool bInPrintTwips = false ) const;
525 sal_uInt16 GetOptimalColWidth(
526 OutputDevice* pDev, double nPPTX, double nPPTY,
527 const Fraction& rZoomX, const Fraction& rZoomY,
528 bool bFormula, sal_uInt16 nOldWidth, const ScMarkData* pMarkData, const ScColWidthParam* pParam) const;
530 void GetOptimalHeight(
531 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart );
533 /// Including current, may return -1
534 SCROW GetNextUnprotected( SCROW nRow, bool bUp ) const;
536 void GetFilterEntries(
537 sc::ColumnBlockConstPosition& rBlockPos, SCROW nStartRow, SCROW nEndRow,
538 ScFilterEntries& rFilterEntries );
540 bool GetDataEntries( SCROW nRow, std::set<ScTypedStrData>& rStrings, bool bLimit ) const;
542 void UpdateInsertTabAbs(SCTAB nNewPos);
543 bool TestTabRefAbs(SCTAB nTable) const;
544 bool GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& rData) const;
546 void StartListeningFormulaCells(
547 sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt, SCROW nRow1, SCROW nRow2 );
549 void EndListeningFormulaCells(
550 sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2,
551 SCROW* pStartRow, SCROW* pEndRow );
553 void StartListening( SvtListener& rLst, SCROW nRow );
554 void EndListening( SvtListener& rLst, SCROW nRow );
555 void StartListening( sc::StartListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
556 void EndListening( sc::EndListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener );
557 void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
558 void SetDirtyIfPostponed();
559 void BroadcastRecalcOnRefMove();
560 void CollectListeners( std::vector<SvtListener*>& rListeners, SCROW nRow1, SCROW nRow2 );
561 void CollectFormulaCells( std::vector<ScFormulaCell*>& rCells, SCROW nRow1, SCROW nRow2 );
563 void CompileDBFormula( sc::CompileFormulaContext& rCxt );
564 void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt );
566 sal_Int32 GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
567 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
568 SCROW nRowStart, SCROW nRowEnd ) const;
570 sal_uInt16 GetTextWidth(SCROW nRow) const;
571 void SetTextWidth(SCROW nRow, sal_uInt16 nWidth);
573 SvtScriptType GetScriptType( SCROW nRow ) const;
576 * Get combined script types of the specified range. This method may
577 * update script types on demand if they have not been determined.
579 SvtScriptType GetRangeScriptType( sc::CellTextAttrStoreType::iterator& itPos, SCROW nRow1, SCROW nRow2,
580 const sc::CellStoreType::iterator& itr);
582 void SetScriptType( SCROW nRow, SvtScriptType nType );
583 void UpdateScriptTypes( SCROW nRow1, SCROW nRow2 );
585 size_t GetFormulaHash( SCROW nRow ) const;
587 ScFormulaVectorState GetFormulaVectorState( SCROW nRow ) const;
588 formula::FormulaTokenRef ResolveStaticReference( SCROW nRow );
589 bool ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow1, SCROW nRow2 );
590 void FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2, svl::SharedStringPool* pPool ) const;
591 formula::VectorRefArray FetchVectorRefArray( SCROW nRow1, SCROW nRow2 );
592 bool HandleRefArrayForParallelism( SCROW nRow1, SCROW nRow2, const ScFormulaCellGroupRef& mxGroup );
593 #ifdef DBG_UTIL
594 void AssertNoInterpretNeeded( SCROW nRow1, SCROW nRow2 );
595 #endif
596 void SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen );
598 void CalculateInThread( ScInterpreterContext& rContext, SCROW nRow, size_t nLen, size_t nOffset,
599 unsigned nThisThread, unsigned nThreadsTotal );
600 void HandleStuffAfterParallelCalculation( SCROW nRow, size_t nLen, ScInterpreter* pInterpreter );
602 void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
604 SvtBroadcaster* GetBroadcaster( SCROW nRow );
605 const SvtBroadcaster* GetBroadcaster( SCROW nRow ) const;
607 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 );
608 void PrepareBroadcastersForDestruction();
610 void Broadcast( SCROW nRow );
611 void BroadcastCells( const std::vector<SCROW>& rRows, SfxHintId nHint );
612 void BroadcastRows( SCROW nStartRow, SCROW nEndRow, SfxHintId nHint );
614 // cell notes
615 ScPostIt* GetCellNote( SCROW nRow );
616 const ScPostIt* GetCellNote( SCROW nRow ) const;
617 ScPostIt* GetCellNote( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow );
618 const ScPostIt* GetCellNote( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
619 void DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership );
620 bool HasCellNotes() const;
621 void SetCellNote( SCROW nRow, std::unique_ptr<ScPostIt> pNote);
622 bool IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
624 std::unique_ptr<ScPostIt> ReleaseNote( SCROW nRow );
625 size_t GetNoteCount() const;
626 void CreateAllNoteCaptions();
627 void ForgetNoteCaptions( SCROW nRow1, SCROW nRow2, bool bPreserveData );
628 SCROW GetNotePosition( size_t nIndex ) const;
629 void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
630 void GetNotesInRange( SCROW nStartRow, SCROW nEndRow, std::vector<sc::NoteEntry>& rNotes ) const;
632 SCROW GetCellNotesMaxRow() const;
633 SCROW GetCellNotesMinRow() const;
635 void CopyCellNotesToDocument(
636 SCROW nRow1, SCROW nRow2, ScColumn& rDestCol, bool bCloneCaption = true,
637 SCROW nRowOffsetDest = 0) const;
639 void DuplicateNotes(SCROW nStartRow, size_t nDataSize, ScColumn& rDestCol,
640 sc::ColumnBlockPosition& maDestBlockPos, bool bCloneCaption, SCROW nRowOffsetDest=0 ) const;
642 void UpdateNoteCaptions( SCROW nRow1, SCROW nRow2 );
644 void UpdateDrawObjects( std::vector<std::vector<SdrObject*>>& pObjects, SCROW nRowStart, SCROW nRowEnd );
645 void UpdateDrawObjectsForRow( std::vector<SdrObject*>& pObjects, SCCOL nTargetCol, SCROW nTargetRow );
646 bool IsDrawObjectsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
648 void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 );
650 static void JoinNewFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell );
653 * Detach a formula cell that's about to be deleted, or removed from
654 * document storage (if that ever happens).
656 * @param rNewSharedRows collects possible new shared row ranges (top and
657 * bottom of shared or remaining single twice) resulting from
658 * unsharing to reestablish listeners on.
660 void DetachFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell,
661 std::vector<SCROW>& rNewSharedRows );
663 /** Re-establish listeners on unshared formula groups */
664 void StartListeningUnshared( const std::vector<SCROW>& rNewSharedRows );
666 void DetachFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength,
667 std::vector<SCROW>* pNewSharedRows );
669 void AttachFormulaCells( sc::StartListeningContext& rCxt, SCROW nRow1, SCROW nRow2 );
670 void DetachFormulaCells( sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2,
671 std::vector<SCROW>* pNewSharedRows );
674 * Regroup formula cells for the entire column.
676 void RegroupFormulaCells( std::vector<ScAddress>* pGroupPos = nullptr );
679 * Reset column position of formula cells within specified row range.
680 * If bUpdateRefs==true then reference positions are also adjusted to
681 * reflect the new position so that the formula cells still reference the
682 * same cells or ranges after the position change.
683 * The position of a formula cell before the call is interpreted as the old
684 * position of that cell.
686 * Caller needs to ensure that no formula groups cross the top and bottom
687 * row boundaries.
689 * @param nRow1 top row boundary
690 * @param nRow2 bottom row boundary
691 * @param bUpdateRefs whether to adjust references
693 void ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2, bool bUpdateRefs );
695 void SplitFormulaGroupByRelativeRef( const ScRange& rBoundRange );
697 void TransferCellValuesTo( SCROW nRow, size_t nLen, sc::CellValues& rDest );
698 void CopyCellValuesFrom( SCROW nRow, const sc::CellValues& rSrc );
699 void ConvertFormulaToValue(
700 sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, sc::TableValues* pUndo );
702 void SwapNonEmpty(
703 sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
705 std::unique_ptr<sc::ColumnIterator> GetColumnIterator( SCROW nRow1, SCROW nRow2 ) const;
707 bool EnsureFormulaCellResults( SCROW nRow1, SCROW nRow2, bool bSkipRunning = false );
709 void StoreToCache(SvStream& rStrm) const;
710 void RestoreFromCache(SvStream& rStrm);
712 #if DUMP_COLUMN_STORAGE
713 void DumpColumnStorage() const;
714 #endif
716 SCSIZE GetPatternCount() const;
717 SCSIZE GetPatternCount( SCROW nRow1, SCROW nRow2 ) const;
718 bool ReservePatternCount( SCSIZE nReserve );
719 private:
721 sc::CellStoreType::iterator GetPositionToInsert( SCROW nRow, std::vector<SCROW>& rNewSharedRows,
722 bool bInsertFormula );
723 sc::CellStoreType::iterator GetPositionToInsert( const sc::CellStoreType::iterator& it, SCROW nRow,
724 std::vector<SCROW>& rNewSharedRows, bool bInsertFormula );
726 void AttachNewFormulaCell(
727 const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell,
728 const std::vector<SCROW>& rNewSharedRows,
729 bool bJoin = true, sc::StartListeningType eListenType = sc::SingleCellListening );
731 void AttachNewFormulaCell(
732 const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell,
733 const std::vector<SCROW>& rNewSharedRows,
734 bool bJoin = true, sc::StartListeningType eListenType = sc::SingleCellListening );
736 void AttachNewFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength,
737 std::vector<SCROW>& rNewSharedRows );
739 void BroadcastNewCell( SCROW nRow );
740 bool UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow, sc::CellStoreType::iterator& itr );
742 const ScFormulaCell* FetchFormulaCell( SCROW nRow ) const;
744 SCROW FindNextVisibleRowWithContent(
745 sc::CellStoreType::const_iterator& itPos, SCROW nRow, bool bForward) const;
746 SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const;
748 void GetString( const ScRefCellValue& cell, SCROW nRow, OUString& rString, const ScInterpreterContext* pContext = nullptr ) const;
749 void GetInputString( const ScRefCellValue& cell, SCROW nRow, OUString& rString ) const;
752 * Called whenever the state of cell array gets modified i.e. new cell
753 * insertion, cell removal or relocation, cell value update and so on.
755 * Call this only from those methods where maCells is modified directly.
757 void CellStorageModified();
758 void CellNotesDeleting(SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership );
760 void CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol) const;
762 void DeleteCells(
763 sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nDelFlag,
764 sc::SingleColumnSpanSet& rDeleted );
767 * Get all non-grouped formula cells and formula cell groups in the whole
768 * column.
770 std::vector<sc::FormulaGroupEntry> GetFormulaGroupEntries();
772 void EndListeningIntersectedGroup(
773 sc::EndListeningContext& rCxt, SCROW nRow, std::vector<ScAddress>* pGroupPos );
775 void EndListeningIntersectedGroups(
776 sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, std::vector<ScAddress>* pGroupPos );
778 void EndListeningGroup( sc::EndListeningContext& rCxt, SCROW nRow );
779 void SetNeedsListeningGroup( SCROW nRow );
782 #endif
784 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */