Show duplicate attribute
[LibreOffice.git] / sc / inc / column.hxx
blobd7dee135e84147d52ef3d749ade077bc4a09aa36
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 "markarr.hxx"
24 #include "global.hxx"
25 #include "address.hxx"
26 #include "rangenam.hxx"
27 #include "rangelst.hxx"
28 #include "types.hxx"
29 #include "mtvelements.hxx"
30 #include <formula/types.hxx>
31 #include <svl/zforlist.hxx>
33 #include <set>
34 #include <vector>
36 #include <boost/intrusive_ptr.hpp>
37 #include <mdds/flat_segment_tree.hpp>
39 namespace editeng { class SvxBorderLine; }
40 namespace formula { struct VectorRefArray; }
42 namespace sc {
44 struct FormulaGroupContext;
45 struct FormulaGroupEntry;
46 class StartListeningContext;
47 class EndListeningContext;
48 class CopyFromClipContext;
49 class CopyToClipContext;
50 class CopyToDocContext;
51 class MixDocContext;
52 class ColumnSpanSet;
53 struct ColumnBlockPosition;
54 class SingleColumnSpanSet;
55 struct RefUpdateContext;
56 struct RefUpdateInsertTabContext;
57 struct RefUpdateDeleteTabContext;
58 struct RefUpdateMoveTabContext;
59 class EditTextIterator;
60 struct NoteEntry;
61 class DocumentStreamAccess;
62 class CellValues;
63 class TableValues;
64 struct RowSpan;
65 class RowHeightContext;
66 class CompileFormulaContext;
67 struct SetFormulaDirtyContext;
68 class RefMovedHint;
72 class Fraction;
73 class OutputDevice;
74 class SfxItemPoolCache;
75 class SvtListener;
76 class SfxPoolItem;
77 class SfxStyleSheetBase;
78 class SvxBoxInfoItem;
79 class SvxBoxItem;
81 class ScAttrIterator;
82 class ScAttrArray;
83 struct ScAttrEntry;
84 class ScDocument;
85 class ScEditDataArray;
86 class ScFormulaCell;
87 class ScMarkData;
88 class ScPatternAttr;
89 class ScStyleSheet;
90 class SvtBroadcaster;
91 class ScTypedStrData;
92 class ScProgress;
93 struct ScFunctionData;
94 struct ScLineFlags;
95 struct ScMergePatternState;
96 class ScFlatBoolRowSegments;
97 struct ScSetStringParam;
98 struct ScColWidthParam;
99 class ScColumnTextWidthIterator;
100 struct ScFormulaCellGroup;
101 struct ScRefCellValue;
102 struct ScCellValue;
103 class ScDocumentImport;
104 class ScHint;
106 struct ScNeededSizeOptions
108 const ScPatternAttr* pPattern;
109 bool bFormula;
110 bool bSkipMerged;
111 bool bGetFont;
112 bool bTotalSize;
114 ScNeededSizeOptions();
117 class ScColumn
119 // Empty values correspond with empty cells. All non-empty cell positions
120 // must have non-empty elements. For text width, the value should be
121 // either the real text width, or TEXTWIDTH_DIRTY in case it hasn't been
122 // calculated yet. For script type, it should be either the real script
123 // type value or SC_SCRIPTTYPE_UNKNOWN.
124 sc::CellTextAttrStoreType maCellTextAttrs;
126 // Cell notes
127 sc::CellNoteStoreType maCellNotes;
129 // Broadcasters for formula cells.
130 sc::BroadcasterStoreType maBroadcasters;
132 // Cell values.
133 sc::CellStoreType maCells;
135 SCCOL nCol;
136 SCTAB nTab;
138 ScAttrArray* pAttrArray;
139 ScDocument* pDocument;
140 bool mbDirtyGroups; /// formula groups are dirty.
142 friend class ScDocument; // for FillInfo
143 friend class ScTable;
144 friend class ScValueIterator;
145 friend class ScHorizontalValueIterator;
146 friend class ScDBQueryDataIterator;
147 friend class ScQueryCellIterator;
148 friend class ScCellIterator;
149 friend class ScHorizontalCellIterator;
150 friend class ScHorizontalAttrIterator;
151 friend class ScColumnTextWidthIterator;
152 friend class ScDocumentImport;
153 friend class sc::DocumentStreamAccess;
154 friend class sc::SingleColumnSpanSet;
155 friend class sc::ColumnSpanSet;
156 friend class sc::EditTextIterator;
157 friend class sc::CellValues;
158 friend class sc::TableValues;
160 ScColumn(const ScColumn&) SAL_DELETED_FUNCTION;
161 ScColumn& operator= (const ScColumn&) SAL_DELETED_FUNCTION;
163 bool ParseString(
164 ScCellValue& rCell,
165 SCROW nRow, SCTAB nTab, const OUString& rString, formula::FormulaGrammar::AddressConvention eConv,
166 ScSetStringParam* pParam );
168 public:
170 /** Broadcast mode for SetDirty(SCROW,SCROW,BroadcastMode). */
171 enum BroadcastMode
173 BROADCAST_NONE, ///< no broadcasting
174 BROADCAST_DATA_POSITIONS, ///< broadcast existing cells with position => does AreaBroadcast
175 BROADCAST_BROADCASTERS ///< broadcast only existing cell broadcasters => no AreaBroadcast of range!
178 ScColumn();
179 ~ScColumn();
181 void Init(SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc);
183 ScDocument& GetDoc() { return *pDocument;}
184 const ScDocument& GetDoc() const { return *pDocument;}
185 SCTAB GetTab() const { return nTab; }
186 SCCOL GetCol() const { return nCol; }
187 sc::CellStoreType& GetCellStore() { return maCells; }
188 const sc::CellStoreType& GetCellStore() const { return maCells; }
189 sc::CellTextAttrStoreType& GetCellAttrStore() { return maCellTextAttrs; }
190 const sc::CellTextAttrStoreType& GetCellAttrStore() const { return maCellTextAttrs; }
191 sc::CellNoteStoreType& GetCellNoteStore() { return maCellNotes; }
192 const sc::CellNoteStoreType& GetCellNoteStore() const { return maCellNotes; }
194 ScRefCellValue GetCellValue( SCROW nRow ) const;
195 ScRefCellValue GetCellValue( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
196 ScRefCellValue GetCellValue( const sc::CellStoreType::const_iterator& itPos, size_t nOffset ) const;
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, sal_uInt16 nMask ) const;
208 bool HasAttribSelection( const ScMarkData& rMark, sal_uInt16 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;
216 bool IsEmpty() const;
218 // data only:
219 bool IsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
220 SCSIZE GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const;
221 bool HasDataAt(SCROW nRow) const;
222 bool HasVisibleDataAt(SCROW nRow) const;
223 SCROW GetFirstDataPos() const;
224 SCROW GetLastDataPos() const;
225 SCROW GetLastDataPos( SCROW nLastRow ) const;
226 bool GetPrevDataPos(SCROW& rRow) const;
227 bool GetNextDataPos(SCROW& rRow) const;
228 void FindDataAreaPos(SCROW& rRow, bool bDown) const; // (without Broadcaster)
229 void FindUsed( SCROW nStartRow, SCROW nEndRow, mdds::flat_segment_tree<SCROW, bool>& rUsed ) const;
231 SCSIZE VisibleCount( SCROW nStartRow, SCROW nEndRow ) const;
232 sal_uInt16 GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const;
233 bool HasSelectionMatrixFragment(const ScMarkData& rMark) const;
235 bool GetFirstVisibleAttr( SCROW& rFirstRow ) const;
236 bool GetLastVisibleAttr( SCROW& rLastRow, bool bFullFormattedArea = false ) const;
237 bool HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
238 bool IsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow = 0,
239 SCROW nEndRow = MAXROW ) const;
240 bool IsAllAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW nEndRow ) const;
242 bool TestInsertCol( SCROW nStartRow, SCROW nEndRow) const;
243 bool TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const;
244 void InsertRow( SCROW nStartRow, SCSIZE nSize );
247 * @param nStartRow top row position
248 * @param nSize size of the segment to delete.
249 * @param pGroupPos when non-NULL, stores the top position of formula
250 * group that's been merged as a result of row deletion.
252 void DeleteRow( SCROW nStartRow, SCSIZE nSize, std::vector<ScAddress>* pGroupPos = NULL );
254 void DeleteArea(
255 SCROW nStartRow, SCROW nEndRow, InsertDeleteFlags nDelFlag,
256 bool bBroadcast = true, sc::ColumnSpanSet* pBroadcastSpans = NULL );
258 void DeleteRanges( const std::vector<sc::RowSpan>& rRanges, InsertDeleteFlags nDelFlag, bool bBroadcast );
260 void CopyToClip(
261 sc::CopyToClipContext& rCxt, SCROW nRow1, SCROW nRow2, ScColumn& rColumn ) const;
263 void CopyStaticToDocument(
264 SCROW nRow1, SCROW nRow2, const SvNumberFormatterMergeMap& rMap, ScColumn& rDestCol );
266 void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDestCol );
267 bool InitBlockPosition( sc::ColumnBlockPosition& rBlockPos );
268 bool InitBlockPosition( sc::ColumnBlockConstPosition& rBlockPos ) const;
270 void DeleteBeforeCopyFromClip(
271 sc::CopyFromClipContext& rCxt, const ScColumn& rClipCol, sc::ColumnSpanSet& rBroadcastSpans );
273 void CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, size_t nColOffset );
275 void CopyFromClip(
276 sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, long nDy, ScColumn& rColumn );
278 void RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow );
280 // Selection (?) of this document
281 void MixMarked(
282 sc::MixDocContext& rCxt, const ScMarkData& rMark, sal_uInt16 nFunction,
283 bool bSkipEmpty, const ScColumn& rSrcCol );
284 void MixData(
285 sc::MixDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFunction, bool bSkipEmpty,
286 const ScColumn& rSrcCol );
288 ScAttrIterator* CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const;
290 void UpdateSelectionFunction(
291 const ScRangeList& rRanges, ScFunctionData& rData, ScFlatBoolRowSegments& rHiddenRows );
293 void CopyToColumn(
294 sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nFlags, bool bMarked,
295 ScColumn& rColumn, const ScMarkData* pMarkData = NULL, bool bAsLink = false) const;
297 void UndoToColumn(
298 sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nFlags, bool bMarked,
299 ScColumn& rColumn, const ScMarkData* pMarkData = NULL) const;
301 void CopyScenarioFrom( const ScColumn& rSrcCol );
302 void CopyScenarioTo( ScColumn& rDestCol ) const;
303 bool TestCopyScenarioTo( const ScColumn& rDestCol ) const;
304 void MarkScenarioIn( ScMarkData& rDestMark ) const;
306 void CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const;
308 void SwapCol(ScColumn& rCol);
309 void MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol);
311 bool HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst);
313 bool SetString(
314 SCROW nRow, SCTAB nTab, const OUString& rString, formula::FormulaGrammar::AddressConvention eConv,
315 ScSetStringParam* pParam = NULL );
317 void SetEditText( SCROW nRow, EditTextObject* pEditText );
318 void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, EditTextObject* pEditText );
319 void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const EditTextObject& rEditText );
320 void SetEditText( SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
321 void SetFormula( SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram );
322 void SetFormula( SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram );
325 * Takes ownership of pCell
327 * @return pCell if it was successfully inserted, NULL otherwise. pCell
328 * is deleted automatically on failure to insert.
330 ScFormulaCell* SetFormulaCell(
331 SCROW nRow, ScFormulaCell* pCell,
332 sc::StartListeningType eListenType = sc::SingleCellListening );
333 ScFormulaCell* SetFormulaCell(
334 sc::ColumnBlockPosition& rBlockPos, SCROW nRow, ScFormulaCell* pCell,
335 sc::StartListeningType eListenType = sc::SingleCellListening );
337 bool SetFormulaCells( SCROW nRow, std::vector<ScFormulaCell*>& rCells );
339 bool HasFormulaCell( SCROW nRow1, SCROW nRow2 ) const;
341 void CloneFormulaCell(
342 const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr,
343 const std::vector<sc::RowSpan>& rRanges, sc::StartListeningContext* pCxt );
345 svl::SharedString GetSharedString( SCROW nRow ) const;
347 void SetRawString( SCROW nRow, const OUString& rStr, bool bBroadcast = true );
348 void SetRawString( SCROW nRow, const svl::SharedString& rStr, bool bBroadcast = true );
349 void SetRawString( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const svl::SharedString& rStr, bool bBroadcast = true );
350 void SetValue( SCROW nRow, double fVal );
351 void SetValues( SCROW nRow, const std::vector<double>& rVals );
352 void SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double fVal, bool bBroadcast = true );
353 void SetError( SCROW nRow, const sal_uInt16 nError);
355 void GetString( SCROW nRow, OUString& rString ) const;
356 double* GetValueCell( SCROW nRow );
357 void GetInputString( SCROW nRow, OUString& rString ) const;
358 double GetValue( SCROW nRow ) const;
359 const EditTextObject* GetEditText( SCROW nRow ) const;
360 void RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr& rAttr );
361 void GetFormula( SCROW nRow, OUString& rFormula ) const;
362 const ScFormulaCell* GetFormulaCell( SCROW nRow ) const;
363 ScFormulaCell* GetFormulaCell( SCROW nRow );
364 ScFormulaCell * const * GetFormulaCellBlockAddress( SCROW nRow ) const;
365 CellType GetCellType( SCROW nRow ) const;
366 SCSIZE GetCellCount() const;
367 sal_uInt32 GetWeightedCount() const;
368 sal_uInt32 GetCodeCount() const; // RPN-Code in formulas
369 sal_uInt16 GetErrCode( SCROW nRow ) const;
371 bool HasStringData( SCROW nRow ) const;
372 bool HasValueData( SCROW nRow ) const;
373 bool HasStringCells( SCROW nStartRow, SCROW nEndRow ) const;
375 bool IsFormulaDirty( SCROW nRow ) const;
377 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
378 void SetDirtyFromClip( SCROW nRow1, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans );
379 void SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode );
380 void SetDirtyVar();
381 void SetDirtyAfterLoad();
382 void SetTableOpDirty( const ScRange& );
383 void CalcAll();
384 void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening );
385 void CompileAll( sc::CompileFormulaContext& rCxt );
386 void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress );
388 /** Broadcast single broadcasters in range, without explicitly setting
389 anything dirty, not doing area broadcasts.
390 @param rHint address is modified to adapt to the actual broadcasted
391 position on each iteration and upon return points to the last
392 position broadcasted. */
393 bool BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, ScHint& rHint );
395 bool CompileErrorCells( sc::CompileFormulaContext& rCxt, sal_uInt16 nErrCode );
397 void ResetChanged( SCROW nStartRow, SCROW nEndRow );
399 bool UpdateReferenceOnCopy( const sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = NULL );
402 * Update reference addresses in formula cell in response to mass cell
403 * movement.
405 * @return true if reference of at least one formula cell has been
406 * updated, false otherwise.
408 bool UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = NULL );
410 void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
411 void UpdateInsertTabOnlyCells( sc::RefUpdateInsertTabContext& rCxt );
412 void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
413 void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo );
414 void UpdateCompile( bool bForceIfNameInUse = false );
415 void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
416 ScDocument* pUndoDoc );
417 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
419 void SetTabNo(SCTAB nNewTab);
420 void FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, std::set<sal_uInt16>& rIndexes) const;
422 void PreprocessRangeNameUpdate(
423 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
425 void CompileHybridFormula(
426 sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt );
428 void PreprocessDBDataUpdate(
429 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
431 const SfxPoolItem* GetAttr( SCROW nRow, sal_uInt16 nWhich ) const;
432 const ScPatternAttr* GetPattern( SCROW nRow ) const;
433 const ScPatternAttr* GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow ) const;
435 sal_uInt32 GetNumberFormat( SCROW nRow ) const;
436 sal_uInt32 GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const;
438 void MergeSelectionPattern( ScMergePatternState& rState, const ScMarkData& rMark, bool bDeep ) const;
439 void MergePatternArea( ScMergePatternState& rState, SCROW nRow1, SCROW nRow2, bool bDeep ) const;
440 void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
441 ScLineFlags& rFlags,
442 SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const;
443 void ApplyBlockFrame( const SvxBoxItem* pLineOuter, const SvxBoxInfoItem* pLineInner,
444 SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight );
446 void ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr );
447 void ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr );
448 void ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr,
449 ScEditDataArray* pDataArray = NULL );
450 void SetPattern( SCROW nRow, const ScPatternAttr& rPatAttr, bool bPutToPool = false );
451 void SetPatternArea( SCROW nStartRow, SCROW nEndRow,
452 const ScPatternAttr& rPatAttr, bool bPutToPool = false );
453 void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
454 const ScPatternAttr& rPattern, short nNewType );
456 void ApplyStyle( SCROW nRow, const ScStyleSheet& rStyle );
457 void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle );
458 void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
459 void ApplySelectionLineStyle( const ScMarkData& rMark,
460 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
461 void AddCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
462 void RemoveCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
464 const ScStyleSheet* GetStyle( SCROW nRow ) const;
465 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
466 const ScStyleSheet* GetAreaStyle( bool& rFound, SCROW nRow1, SCROW nRow2 ) const;
468 void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset );
469 bool IsStyleSheetUsed( const ScStyleSheet& rStyle, bool bGatherAllStyles ) const;
471 /// May return -1 if not found
472 SCsROW SearchStyle(
473 SCsROW nRow, const ScStyleSheet* pSearchStyle, bool bUp, bool bInSelection,
474 const ScMarkData& rMark) const;
476 bool SearchStyleRange(
477 SCsROW& rRow, SCsROW& rEndRow, const ScStyleSheet* pSearchStyle, bool bUp,
478 bool bInSelection, const ScMarkData& rMark) const;
480 bool ApplyFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags );
481 bool RemoveFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags );
482 void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
484 void RemoveProtected( SCROW nStartRow, SCROW nEndRow );
486 SCsROW ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = NULL );
487 void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast );
489 void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
490 void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
492 long GetNeededSize(
493 SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY,
494 const Fraction& rZoomX, const Fraction& rZoomY,
495 bool bWidth, const ScNeededSizeOptions& rOptions, const ScPatternAttr** pPatternChange ) const;
497 sal_uInt16 GetOptimalColWidth(
498 OutputDevice* pDev, double nPPTX, double nPPTY,
499 const Fraction& rZoomX, const Fraction& rZoomY,
500 bool bFormula, sal_uInt16 nOldWidth, const ScMarkData* pMarkData, const ScColWidthParam* pParam) const;
502 void GetOptimalHeight(
503 sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart );
505 /// Including current, may return -1
506 SCsROW GetNextUnprotected( SCROW nRow, bool bUp ) const;
508 void GetFilterEntries(
509 sc::ColumnBlockConstPosition& rBlockPos, SCROW nStartRow, SCROW nEndRow,
510 std::vector<ScTypedStrData>& rStrings, bool& rHasDates );
512 bool GetDataEntries( SCROW nRow, std::set<ScTypedStrData>& rStrings, bool bLimit ) const;
514 void UpdateInsertTabAbs(SCTAB nNewPos);
515 bool TestTabRefAbs(SCTAB nTable) const;
516 bool GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& rData) const;
518 void StartListeningFormulaCells(
519 sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt, SCROW nRow1, SCROW nRow2,
520 SCROW* pStartRow = NULL, SCROW* pEndRow = NULL );
522 void EndListeningFormulaCells(
523 sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2,
524 SCROW* pStartRow = NULL, SCROW* pEndRow = NULL );
526 void StartListening( SvtListener& rLst, SCROW nRow );
527 void EndListening( SvtListener& rLst, SCROW nRow );
528 void StartListening( sc::StartListeningContext& rCxt, SCROW nRow, SvtListener& rListener );
529 void EndListening( sc::EndListeningContext& rCxt, SCROW nRow, SvtListener& rListener );
530 void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
531 void SetDirtyIfPostponed();
532 void BroadcastRecalcOnRefMove();
533 void TransferListeners( ScColumn& rDestCol, SCROW nRow1, SCROW nRow2, SCROW nRowDelta );
534 void CollectListeners( std::vector<SvtListener*>& rListeners, SCROW nRow1, SCROW nRow2 );
535 void CollectFormulaCells( std::vector<ScFormulaCell*>& rCells, SCROW nRow1, SCROW nRow2 );
537 void CompileDBFormula( sc::CompileFormulaContext& rCxt );
538 void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt );
540 sal_Int32 GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
541 sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
542 SCROW nRowStart, SCROW nRowEnd ) const;
544 sal_uInt16 GetTextWidth(SCROW nRow) const;
545 void SetTextWidth(SCROW nRow, sal_uInt16 nWidth);
547 sal_uInt8 GetScriptType( SCROW nRow ) const;
550 * Get combined script types of the specified range. This method may
551 * update script types on demand if they have not been determined.
553 sal_uInt8 GetRangeScriptType( sc::CellTextAttrStoreType::iterator& itPos, SCROW nRow1, SCROW nRow2,
554 const sc::CellStoreType::iterator& itr);
556 void SetScriptType( SCROW nRow, sal_uInt8 nType );
557 void UpdateScriptTypes( SCROW nRow1, SCROW nRow2 );
559 size_t GetFormulaHash( SCROW nRow ) const;
561 ScFormulaVectorState GetFormulaVectorState( SCROW nRow ) const;
562 formula::FormulaTokenRef ResolveStaticReference( SCROW nRow );
563 bool ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow1, SCROW nRow2 );
564 void FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2 ) const;
565 formula::VectorRefArray FetchVectorRefArray( SCROW nRow1, SCROW nRow2 );
566 void SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen );
567 void SetFormulaResults( SCROW nRow, const formula::FormulaTokenRef* pResults, size_t nLen );
569 void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
571 SvtBroadcaster* GetBroadcaster( SCROW nRow );
572 const SvtBroadcaster* GetBroadcaster( SCROW nRow ) const;
573 const SvtBroadcaster* GetBroadcaster( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
575 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 );
576 void PrepareBroadcastersForDestruction();
577 bool HasBroadcaster() const;
579 void Broadcast( SCROW nRow );
580 void BroadcastCells( const std::vector<SCROW>& rRows, sal_uLong nHint );
582 // cell notes
583 ScPostIt* GetCellNote( SCROW nRow );
584 const ScPostIt* GetCellNote( SCROW nRow ) const;
585 const ScPostIt* GetCellNote( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
586 void DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 );
587 bool HasCellNotes() const;
588 void SetCellNote( SCROW nRow, ScPostIt* pNote);
589 bool IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
591 ScPostIt* ReleaseNote( SCROW nRow );
592 size_t GetNoteCount() const;
593 void CreateAllNoteCaptions();
594 void ForgetNoteCaptions( SCROW nRow1, SCROW nRow2 );
595 SCROW GetNotePosition( size_t nIndex ) const;
596 void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
597 void GetNotesInRange( SCROW nStartRow, SCROW nEndRow, std::vector<sc::NoteEntry>& rNotes ) const;
599 SCROW GetCellNotesMaxRow() const;
600 SCROW GetCellNotesMinRow() const;
602 void CopyCellNotesToDocument(
603 SCROW nRow1, SCROW nRow2, ScColumn& rDestCol, bool bCloneCaption = true,
604 SCROW nRowOffsetDest = 0) const;
606 void DuplicateNotes(SCROW nStartRow, size_t nDataSize, ScColumn& rDestCol,
607 sc::ColumnBlockPosition& maDestBlockPos, bool bCloneCaption = true, SCROW nRowOffsetDest=0 ) const;
609 void UpdateNoteCaptions( SCROW nRow1, SCROW nRow2 );
611 void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 );
613 void JoinNewFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ) const;
616 * Detach a formula cell that's about to be deleted, or removed from
617 * document storage (if that ever happens).
619 void DetachFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell );
621 void DetachFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength );
623 void AttachFormulaCells( sc::StartListeningContext& rCxt, SCROW nRow1, SCROW nRow2 );
624 void DetachFormulaCells( sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2 );
627 * Regroup formula cells for the entire column.
629 void RegroupFormulaCells( std::vector<ScAddress>* pGroupPos = NULL );
632 * Reset column position of formula cells within specified row range.
633 * If bUpdateRefs==true then reference positions are also adjusted to
634 * reflect the new position so that the formula cells still reference the
635 * same cells or ranges after the the position change.
636 * The position of a formula cell before the call is interpreted as the old
637 * position of that cell.
639 * Caller needs to ensure that no formula groups cross the top and bottom
640 * row boundaries.
642 * @param nRow1 top row boundary
643 * @param nRow2 bottom row boundary
644 * @param bUpdateRefs whether to adjust references
646 void ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2, bool bUpdateRefs );
648 void SplitFormulaGroupByRelativeRef( const ScRange& rBoundRange );
650 void TransferCellValuesTo( SCROW nRow, size_t nLen, sc::CellValues& rDest );
651 void CopyCellValuesFrom( SCROW nRow, const sc::CellValues& rSrc );
652 void ConvertFormulaToValue(
653 sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, sc::TableValues* pUndo );
655 void SwapNonEmpty(
656 sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
658 #if DEBUG_COLUMN_STORAGE
659 void DumpFormulaGroups() const;
660 #endif
662 SCSIZE GetPatternCount() const;
663 SCSIZE GetPatternCount( SCROW nRow1, SCROW nRow2 ) const;
664 bool ReservePatternCount( SCSIZE nReserve );
665 private:
667 sc::CellStoreType::iterator GetPositionToInsert( SCROW nRow );
668 sc::CellStoreType::iterator GetPositionToInsert( const sc::CellStoreType::iterator& it, SCROW nRow );
670 void AttachNewFormulaCell(
671 const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell,
672 bool bJoin = true, sc::StartListeningType eListenType = sc::SingleCellListening );
674 void AttachNewFormulaCell(
675 const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell,
676 bool bJoin = true, sc::StartListeningType eListenType = sc::SingleCellListening );
678 void AttachNewFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength );
679 void BroadcastNewCell( SCROW nRow );
680 bool UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow, const sc::CellStoreType::iterator& itr );
682 const ScFormulaCell* FetchFormulaCell( SCROW nRow ) const;
684 SCROW FindNextVisibleRowWithContent(
685 sc::CellStoreType::const_iterator& itPos, SCROW nRow, bool bForward) const;
686 SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const;
689 * Called whenever the state of cell array gets modified i.e. new cell
690 * insertion, cell removal or relocation, cell value update and so on.
692 * Call this only from those methods where maCells is modified directly.
694 void CellStorageModified();
696 void CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol) const;
698 void DeleteCells(
699 sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nDelFlag,
700 sc::SingleColumnSpanSet& rDeleted );
703 * Get all non-grouped formula cells and formula cell groups in the whole
704 * column.
706 std::vector<sc::FormulaGroupEntry> GetFormulaGroupEntries();
708 void EndListeningIntersectedGroup(
709 sc::EndListeningContext& rCxt, SCROW nRow, std::vector<ScAddress>* pGroupPos = NULL );
711 void EndListeningIntersectedGroups(
712 sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, std::vector<ScAddress>* pGroupPos = NULL );
714 void EndListeningGroup( sc::EndListeningContext& rCxt, SCROW nRow );
715 void SetNeedsListeningGroup( SCROW nRow );
718 #endif
720 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */