Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef SC_COLUMN_HXX
21 : #define SC_COLUMN_HXX
22 :
23 : #include "markarr.hxx"
24 : #include "global.hxx"
25 : #include "address.hxx"
26 : #include "rangenam.hxx"
27 : #include "types.hxx"
28 : #include "mtvelements.hxx"
29 : #include "formula/types.hxx"
30 :
31 : #include <set>
32 : #include <vector>
33 :
34 : #include <boost/intrusive_ptr.hpp>
35 : #include <mdds/flat_segment_tree.hpp>
36 :
37 : namespace editeng { class SvxBorderLine; }
38 :
39 : namespace sc {
40 : struct FormulaGroupContext;
41 : class StartListeningContext;
42 : class EndListeningContext;
43 : class CopyFromClipContext;
44 : class CopyToClipContext;
45 : class CopyToDocContext;
46 : class MixDocContext;
47 : class ColumnSpanSet;
48 : struct ColumnBlockPosition;
49 : class SingleColumnSpanSet;
50 : }
51 :
52 : class Fraction;
53 : class OutputDevice;
54 : class SfxItemPoolCache;
55 : class SvtListener;
56 : class SfxPoolItem;
57 : class SfxStyleSheetBase;
58 : class SvxBoxInfoItem;
59 : class SvxBoxItem;
60 :
61 : class ScAttrIterator;
62 : class ScAttrArray;
63 : struct ScAttrEntry;
64 : class ScDocument;
65 : class ScEditDataArray;
66 : class ScFormulaCell;
67 : class ScMarkData;
68 : class ScPatternAttr;
69 : class ScStyleSheet;
70 : class SvtBroadcaster;
71 : class ScTypedStrData;
72 : class ScProgress;
73 : struct ScFunctionData;
74 : struct ScLineFlags;
75 : struct ScMergePatternState;
76 : class ScFlatBoolRowSegments;
77 : struct ScSetStringParam;
78 : struct ScColWidthParam;
79 : class ScColumnTextWidthIterator;
80 : struct ScFormulaCellGroup;
81 : struct ScRefCellValue;
82 : struct ScCellValue;
83 : class ScDocumentImport;
84 :
85 : struct ScNeededSizeOptions
86 : {
87 : const ScPatternAttr* pPattern;
88 : bool bFormula;
89 : bool bSkipMerged;
90 : bool bGetFont;
91 : bool bTotalSize;
92 :
93 : ScNeededSizeOptions();
94 : };
95 :
96 : class ScColumn
97 : {
98 : // Empty values correspond with empty cells. All non-empty cell positions
99 : // must have non-empty elements. For text width, the value should be
100 : // either the real text width, or TEXTWIDTH_DIRTY in case it hasn't been
101 : // calculated yet. For script type, it should be either the real script
102 : // type value or SC_SCRIPTTYPE_UNKNOWN.
103 : sc::CellTextAttrStoreType maCellTextAttrs;
104 :
105 : // Broadcasters for formula cells.
106 : sc::BroadcasterStoreType maBroadcasters;
107 :
108 : // Cell values.
109 : sc::CellStoreType maCells;
110 :
111 : SCCOL nCol;
112 : SCTAB nTab;
113 :
114 : ScAttrArray* pAttrArray;
115 : ScDocument* pDocument;
116 : bool mbDirtyGroups; /// formula groups are dirty.
117 :
118 : friend class ScDocument; // for FillInfo
119 : friend class ScTable;
120 : friend class ScValueIterator;
121 : friend class ScHorizontalValueIterator;
122 : friend class ScDBQueryDataIterator;
123 : friend class ScQueryCellIterator;
124 : friend class ScCellIterator;
125 : friend class ScHorizontalCellIterator;
126 : friend class ScHorizontalAttrIterator;
127 : friend class ScColumnTextWidthIterator;
128 : friend class ScDocumentImport;
129 : friend class sc::SingleColumnSpanSet;
130 : friend class sc::ColumnSpanSet;
131 :
132 : ScColumn(const ScColumn&); // disabled
133 : ScColumn& operator= (const ScColumn&); // disabled
134 :
135 : public:
136 : ScColumn();
137 : ~ScColumn();
138 :
139 : void Init(SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc);
140 :
141 : ScDocument& GetDoc();
142 : const ScDocument& GetDoc() const;
143 767 : SCTAB GetTab() const { return nTab; }
144 767 : SCCOL GetCol() const { return nCol; }
145 3232 : sc::CellStoreType& GetCellStore() { return maCells; }
146 : const sc::CellStoreType& GetCellStore() const { return maCells; }
147 2263 : sc::CellTextAttrStoreType& GetCellAttrStore() { return maCellTextAttrs; }
148 : const sc::CellTextAttrStoreType& GetCellAttrStore() const { return maCellTextAttrs; }
149 :
150 : ScRefCellValue GetCellValue( SCROW nRow ) const;
151 : ScRefCellValue GetCellValue( const sc::CellStoreType::const_iterator& itPos, size_t nOffset ) const;
152 :
153 : void Delete( SCROW nRow );
154 : void FreeAll();
155 : void SwapRow( SCROW nRow1, SCROW nRow2 );
156 : void SwapCell( SCROW nRow, ScColumn& rCol);
157 : void RebuildFormulaGroups();
158 :
159 : bool HasAttrib( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const;
160 : bool HasAttribSelection( const ScMarkData& rMark, sal_uInt16 nMask ) const;
161 : bool ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
162 : SCCOL& rPaintCol, SCROW& rPaintRow,
163 : bool bRefresh );
164 :
165 : bool IsEmptyData() const;
166 : bool IsEmptyAttr() const;
167 : bool IsEmpty() const;
168 :
169 : // data only:
170 : bool IsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
171 : SCSIZE GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const;
172 : bool HasDataAt(SCROW nRow) const;
173 : bool HasVisibleDataAt(SCROW nRow) const;
174 : SCROW GetFirstDataPos() const;
175 : SCROW GetLastDataPos() const;
176 : bool GetPrevDataPos(SCROW& rRow) const;
177 : bool GetNextDataPos(SCROW& rRow) const;
178 : void FindDataAreaPos(SCROW& rRow, bool bDown) const; // (without Broadcaster)
179 : void FindUsed( SCROW nStartRow, SCROW nEndRow, mdds::flat_segment_tree<SCROW, bool>& rUsed ) const;
180 :
181 : SCSIZE VisibleCount( SCROW nStartRow, SCROW nEndRow ) const;
182 : sal_uInt16 GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const;
183 : bool HasSelectionMatrixFragment(const ScMarkData& rMark) const;
184 :
185 : bool GetFirstVisibleAttr( SCROW& rFirstRow ) const;
186 : bool GetLastVisibleAttr( SCROW& rLastRow, bool bFullFormattedArea = false ) const;
187 : bool HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
188 : bool IsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow = 0,
189 : SCROW nEndRow = MAXROW ) const;
190 : bool IsAllAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW nEndRow ) const;
191 :
192 : bool TestInsertCol( SCROW nStartRow, SCROW nEndRow) const;
193 : bool TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const;
194 : void InsertRow( SCROW nStartRow, SCSIZE nSize );
195 : void DeleteRow( SCROW nStartRow, SCSIZE nSize );
196 : void DeleteArea(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nDelFlag );
197 : void CopyToClip(
198 : sc::CopyToClipContext& rCxt, SCROW nRow1, SCROW nRow2, ScColumn& rColumn ) const;
199 : void CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol);
200 : void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDestCol );
201 : bool InitBlockPosition( sc::ColumnBlockPosition& rBlockPos );
202 : bool InitBlockPosition( sc::ColumnBlockConstPosition& rBlockPos ) const;
203 : void CopyFromClip(
204 : sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, long nDy, ScColumn& rColumn );
205 :
206 : void StartListeningInArea( sc::StartListeningContext& rCxt, SCROW nRow1, SCROW nRow2 );
207 :
208 : void RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow );
209 :
210 : // Selection (?) of this document
211 : void MixMarked(
212 : sc::MixDocContext& rCxt, const ScMarkData& rMark, sal_uInt16 nFunction,
213 : bool bSkipEmpty, const ScColumn& rSrcCol );
214 : void MixData(
215 : sc::MixDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFunction, bool bSkipEmpty,
216 : const ScColumn& rSrcCol );
217 :
218 : ScAttrIterator* CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const;
219 :
220 : // UpdateSelectionFunction: multi-select
221 : void UpdateSelectionFunction(
222 : const ScMarkData& rMark, ScFunctionData& rData, ScFlatBoolRowSegments& rHiddenRows,
223 : bool bDoExclude, SCROW nExStartRow, SCROW nExEndRow );
224 :
225 : void UpdateAreaFunction(
226 : ScFunctionData& rData, ScFlatBoolRowSegments& rHiddenRows, SCROW nStartRow, SCROW nEndRow);
227 :
228 : void CopyToColumn(
229 : sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bMarked,
230 : ScColumn& rColumn, const ScMarkData* pMarkData = NULL, bool bAsLink = false) const;
231 :
232 : void UndoToColumn(
233 : sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bMarked,
234 : ScColumn& rColumn, const ScMarkData* pMarkData = NULL) const;
235 :
236 : void CopyScenarioFrom( const ScColumn& rSrcCol );
237 : void CopyScenarioTo( ScColumn& rDestCol ) const;
238 : bool TestCopyScenarioTo( const ScColumn& rDestCol ) const;
239 : void MarkScenarioIn( ScMarkData& rDestMark ) const;
240 :
241 : void CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const;
242 :
243 : void SwapCol(ScColumn& rCol);
244 : void MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol);
245 :
246 : void MarkSubTotalCells( sc::ColumnSpanSet& rSet, SCROW nRow1, SCROW nRow2, bool bVal ) const;
247 :
248 : bool HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst);
249 :
250 : bool SetString(
251 : SCROW nRow, SCTAB nTab, const String& rString, formula::FormulaGrammar::AddressConvention eConv,
252 : ScSetStringParam* pParam = NULL );
253 :
254 : void SetEditText( SCROW nRow, EditTextObject* pEditText );
255 : void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, EditTextObject* pEditText );
256 : void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const EditTextObject& rEditText );
257 : void SetEditText( SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
258 : void SetFormula( SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram );
259 : void SetFormula( SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram );
260 :
261 : /**
262 : * Takes ownership of pCell
263 : *
264 : * @return pCell if it was successfully inserted, NULL otherwise. pCell
265 : * is deleted automatically on failure to insert.
266 : */
267 : ScFormulaCell* SetFormulaCell( SCROW nRow, ScFormulaCell* pCell );
268 : ScFormulaCell* SetFormulaCell( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, ScFormulaCell* pCell );
269 :
270 : void SetRawString( SCROW nRow, const OUString& rStr, bool bBroadcast = true );
271 : void SetRawString( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const OUString& rStr, bool bBroadcast = true );
272 : void SetValue( SCROW nRow, double fVal );
273 : void SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double fVal, bool bBroadcast = true );
274 : void SetError( SCROW nRow, const sal_uInt16 nError);
275 :
276 : void GetString( SCROW nRow, OUString& rString ) const;
277 : const OUString* GetStringCell( SCROW nRow ) const;
278 : double* GetValueCell( SCROW nRow );
279 : void GetInputString( SCROW nRow, OUString& rString ) const;
280 : double GetValue( SCROW nRow ) const;
281 : const EditTextObject* GetEditText( SCROW nRow ) const;
282 : void RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr& rAttr );
283 : void GetFormula( SCROW nRow, OUString& rFormula ) const;
284 : const ScTokenArray* GetFormulaTokens( SCROW nRow ) const;
285 : const ScFormulaCell* GetFormulaCell( SCROW nRow ) const;
286 : ScFormulaCell* GetFormulaCell( SCROW nRow );
287 : CellType GetCellType( SCROW nRow ) const;
288 : SCSIZE GetCellCount() const;
289 : sal_uInt32 GetWeightedCount() const;
290 : sal_uInt32 GetCodeCount() const; // RPN-Code in formulas
291 : sal_uInt16 GetErrCode( SCROW nRow ) const;
292 :
293 : bool HasStringData( SCROW nRow ) const;
294 : bool HasValueData( SCROW nRow ) const;
295 : bool HasStringCells( SCROW nStartRow, SCROW nEndRow ) const;
296 :
297 : bool IsFormulaDirty( SCROW nRow ) const;
298 :
299 : void SetDirty();
300 : void SetDirty( SCROW nRow1, SCROW nRow2 );
301 : void SetDirtyVar();
302 : void SetDirtyAfterLoad();
303 : void SetTableOpDirty( const ScRange& );
304 : void CalcAll();
305 : void CalcAfterLoad();
306 : void CompileAll();
307 : void CompileXML( ScProgress& rProgress );
308 :
309 : bool CompileErrorCells(sal_uInt16 nErrCode);
310 :
311 : void ResetChanged( SCROW nStartRow, SCROW nEndRow );
312 :
313 : /**
314 : * Update reference addresses in formula cell in response to mass cell
315 : * movement.
316 : *
317 : * @param eUpdateRefMode update mode - insert/delete, copy, or move. The
318 : * reorder mode (which corresponds with the
319 : * reordering of sheets) is not used with this
320 : * method.
321 : *
322 : * @param rRange range of cells that are about to be moved for
323 : * insert/delete/move modes. For copy mode, it's the
324 : * destination range of cells that are about to be copied.
325 : *
326 : * @param nDx moved by how many cells in the column direction.
327 : * @param nDy moved by how many cells in the row direction.
328 : * @param nDz moved by how many sheets in the sheet direction.
329 : * @param pUndoDoc undo document instance.
330 : *
331 : * @return true if reference of at least one formula cell has been
332 : * updated, false otherwise.
333 : */
334 : bool UpdateReference(
335 : UpdateRefMode eUpdateRefMode, const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
336 : ScDocument* pUndoDoc = NULL );
337 :
338 : void UpdateInsertTab(SCTAB nInsPos, SCTAB nNewSheets = 1);
339 : void UpdateInsertTabOnlyCells(SCTAB nInsPos, SCTAB nNewSheets = 1);
340 : void UpdateDeleteTab(SCTAB nDelPos, bool bIsMove, ScColumn* pRefUndo = NULL, SCTAB nSheets = 1);
341 : void UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo);
342 : void UpdateCompile( bool bForceIfNameInUse = false );
343 : void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
344 : ScDocument* pUndoDoc );
345 : void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
346 :
347 : void SetTabNo(SCTAB nNewTab);
348 : void FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, std::set<sal_uInt16>& rIndexes) const;
349 :
350 : const SfxPoolItem* GetAttr( SCROW nRow, sal_uInt16 nWhich ) const;
351 : const ScPatternAttr* GetPattern( SCROW nRow ) const;
352 : const ScPatternAttr* GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow ) const;
353 :
354 : sal_uInt32 GetNumberFormat( SCROW nRow ) const;
355 : sal_uInt32 GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const;
356 :
357 : void MergeSelectionPattern( ScMergePatternState& rState, const ScMarkData& rMark, bool bDeep ) const;
358 : void MergePatternArea( ScMergePatternState& rState, SCROW nRow1, SCROW nRow2, bool bDeep ) const;
359 : void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
360 : ScLineFlags& rFlags,
361 : SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const;
362 : void ApplyBlockFrame( const SvxBoxItem* pLineOuter, const SvxBoxInfoItem* pLineInner,
363 : SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight );
364 :
365 : void ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr );
366 : void ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr );
367 : void ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr,
368 : ScEditDataArray* pDataArray = NULL );
369 : bool SetAttrEntries(ScAttrEntry* pData, SCSIZE nSize);
370 : void SetPattern( SCROW nRow, const ScPatternAttr& rPatAttr, bool bPutToPool = false );
371 : void SetPatternArea( SCROW nStartRow, SCROW nEndRow,
372 : const ScPatternAttr& rPatAttr, bool bPutToPool = false );
373 : void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
374 : const ScPatternAttr& rPattern, short nNewType );
375 :
376 : void ApplyStyle( SCROW nRow, const ScStyleSheet& rStyle );
377 : void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle );
378 : void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
379 : void ApplySelectionLineStyle( const ScMarkData& rMark,
380 : const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
381 : void AddCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
382 : void RemoveCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
383 :
384 : const ScStyleSheet* GetStyle( SCROW nRow ) const;
385 : const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
386 : const ScStyleSheet* GetAreaStyle( bool& rFound, SCROW nRow1, SCROW nRow2 ) const;
387 :
388 : void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset );
389 : bool IsStyleSheetUsed( const ScStyleSheet& rStyle, bool bGatherAllStyles ) const;
390 :
391 : /// May return -1 if not found
392 : SCsROW SearchStyle(
393 : SCsROW nRow, const ScStyleSheet* pSearchStyle, bool bUp, bool bInSelection,
394 : const ScMarkData& rMark) const;
395 :
396 : bool SearchStyleRange(
397 : SCsROW& rRow, SCsROW& rEndRow, const ScStyleSheet* pSearchStyle, bool bUp,
398 : bool bInSelection, const ScMarkData& rMark) const;
399 :
400 : bool ApplyFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags );
401 : bool RemoveFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags );
402 : void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
403 :
404 : void RemoveProtected( SCROW nStartRow, SCROW nEndRow );
405 :
406 : SCsROW ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = NULL );
407 : void DeleteSelection( sal_uInt16 nDelFlag, const ScMarkData& rMark );
408 :
409 : void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
410 : void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
411 :
412 : long GetNeededSize(
413 : SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY,
414 : const Fraction& rZoomX, const Fraction& rZoomY,
415 : bool bWidth, const ScNeededSizeOptions& rOptions) const;
416 :
417 : sal_uInt16 GetOptimalColWidth(
418 : OutputDevice* pDev, double nPPTX, double nPPTY,
419 : const Fraction& rZoomX, const Fraction& rZoomY,
420 : bool bFormula, sal_uInt16 nOldWidth, const ScMarkData* pMarkData, const ScColWidthParam* pParam) const;
421 :
422 : void GetOptimalHeight(
423 : SCROW nStartRow, SCROW nEndRow, sal_uInt16* pHeight, OutputDevice* pDev,
424 : double nPPTX, double nPPTY, const Fraction& rZoomX, const Fraction& rZoomY,
425 : bool bShrink, sal_uInt16 nMinHeight, SCROW nMinStart);
426 :
427 : /// Including current, may return -1
428 : SCsROW GetNextUnprotected( SCROW nRow, bool bUp ) const;
429 :
430 : void GetFilterEntries(SCROW nStartRow, SCROW nEndRow, std::vector<ScTypedStrData>& rStrings, bool& rHasDates);
431 : bool GetDataEntries( SCROW nRow, std::set<ScTypedStrData>& rStrings, bool bLimit ) const;
432 :
433 : void UpdateInsertTabAbs(SCTAB nNewPos);
434 : bool TestTabRefAbs(SCTAB nTable) const;
435 : bool GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& rData) const;
436 :
437 : void RemoveAutoSpellObj();
438 :
439 : void StartListening( SvtListener& rLst, SCROW nRow );
440 : void EndListening( SvtListener& rLst, SCROW nRow );
441 : void StartListening( sc::StartListeningContext& rCxt, SCROW nRow, SvtListener& rListener );
442 : void EndListening( sc::EndListeningContext& rCxt, SCROW nRow, SvtListener& rListener );
443 : void MoveListeners( SvtBroadcaster& rSource, SCROW nDestRow );
444 : void StartAllListeners();
445 : void StartNeededListeners(); // only for cells where NeedsListening()==true
446 : void SetRelNameDirty();
447 :
448 : void CompileDBFormula();
449 : void CompileDBFormula( bool bCreateFormulaString );
450 : void CompileNameFormula( bool bCreateFormulaString );
451 : void CompileColRowNameFormula();
452 :
453 : sal_Int32 GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCharSet ) const;
454 : xub_StrLen GetMaxNumberStringLen( sal_uInt16& nPrecision,
455 : SCROW nRowStart, SCROW nRowEnd ) const;
456 :
457 : sal_uInt16 GetTextWidth(SCROW nRow) const;
458 : void SetTextWidth(SCROW nRow, sal_uInt16 nWidth);
459 :
460 : sal_uInt8 GetScriptType( SCROW nRow ) const;
461 :
462 : /**
463 : * Get combined script types of the specified range. This method may
464 : * update script types on demand if they have not been determined.
465 : */
466 : sal_uInt8 GetRangeScriptType( sc::CellTextAttrStoreType::iterator& itPos, SCROW nRow1, SCROW nRow2 );
467 :
468 : void SetScriptType( SCROW nRow, sal_uInt8 nType );
469 :
470 : size_t GetFormulaHash( SCROW nRow ) const;
471 :
472 : ScFormulaVectorState GetFormulaVectorState( SCROW nRow ) const;
473 : formula::FormulaTokenRef ResolveStaticReference( SCROW nRow );
474 : bool ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow1, SCROW nRow2 );
475 : void FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2 ) const;
476 : const double* FetchDoubleArray( sc::FormulaGroupContext& rCxt, SCROW nRow1, SCROW nRow2 );
477 : void SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen );
478 :
479 : void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
480 :
481 : SvtBroadcaster* GetBroadcaster( SCROW nRow );
482 : const SvtBroadcaster* GetBroadcaster( SCROW nRow ) const;
483 : void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 );
484 : bool HasBroadcaster() const;
485 :
486 : void BroadcastCells( const std::vector<SCROW>& rRows );
487 : void EndFormulaListening( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 );
488 :
489 : void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 );
490 :
491 : void JoinNewFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ) const;
492 :
493 : /**
494 : * Detouch a formula cell that's about to be deleted, or removed from
495 : * document storage (if that ever happens).
496 : */
497 : void DetouchFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ) const;
498 :
499 : void UnshareFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ) const;
500 :
501 : /**
502 : * Split existing shared formula range at specified position. The cell at
503 : * specified position becomes the top cell of the lower shared formula
504 : * range after this call.
505 : */
506 : void SplitFormulaCellGroup( const sc::CellStoreType::position_type& aPos ) const;
507 :
508 : /**
509 : * Regroup formula cells for the entire column.
510 : */
511 : void RegroupFormulaCells();
512 :
513 : /**
514 : * Regroup existing formula cells when a new cell is inserted.
515 : *
516 : * @param nRow row at which a new cell is inserted.
517 : */
518 : void RegroupFormulaCells( SCROW nRow );
519 :
520 : /**
521 : * Regroup existing formula cells when a range of new cells are inserted.
522 : *
523 : * @param nRow1 first row of inserted new cell span.
524 : * @param nRow2 last row of inserted new cell span.
525 : */
526 : void RegroupFormulaCells( SCROW nRow1, SCROW nRow2 );
527 :
528 : void FormulaCellsUndecided( SCROW nRow1, SCROW nRow2 );
529 :
530 : #if DEBUG_COLUMN_STORAGE
531 : void DumpFormulaGroups() const;
532 : #endif
533 :
534 : private:
535 :
536 : sc::CellStoreType::iterator GetPositionToInsert( SCROW nRow );
537 : sc::CellStoreType::iterator GetPositionToInsert( const sc::CellStoreType::iterator& it, SCROW nRow );
538 : void ActivateNewFormulaCell( const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell );
539 : void ActivateNewFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell );
540 : void BroadcastNewCell( SCROW nRow );
541 : bool UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow );
542 :
543 : const ScFormulaCell* FetchFormulaCell( SCROW nRow ) const;
544 :
545 : SCROW FindNextVisibleRowWithContent(
546 : sc::CellStoreType::const_iterator& itPos, SCROW nRow, bool bForward) const;
547 : SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const;
548 :
549 : /**
550 : * Called whenever the state of cell array gets modified i.e. new cell
551 : * insertion, cell removal or relocation, cell value update and so on.
552 : *
553 : * Call this only from those methods where maCells is modified directly.
554 : */
555 : void CellStorageModified();
556 :
557 : void CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol) const;
558 :
559 : /**
560 : * Clear and re-populate the cell text attribute array from the non-empty
561 : * cells stored in the cell array.
562 : */
563 : void ResetCellTextAttrs();
564 :
565 : void SwapCellTextAttrs( SCROW nRow1, SCROW nRow2 );
566 : };
567 :
568 : #endif
569 :
570 :
571 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|