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 INCLUDED_SC_INC_COLUMN_HXX
21 : #define INCLUDED_SC_INC_COLUMN_HXX
22 :
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>
32 :
33 : #include <set>
34 : #include <vector>
35 :
36 : #include <boost/intrusive_ptr.hpp>
37 : #include <mdds/flat_segment_tree.hpp>
38 :
39 : namespace editeng { class SvxBorderLine; }
40 : namespace formula { struct VectorRefArray; }
41 :
42 : namespace sc {
43 :
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;
69 :
70 : }
71 :
72 : class Fraction;
73 : class OutputDevice;
74 : class SfxItemPoolCache;
75 : class SvtListener;
76 : class SfxPoolItem;
77 : class SfxStyleSheetBase;
78 : class SvxBoxInfoItem;
79 : class SvxBoxItem;
80 :
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 :
105 : struct ScNeededSizeOptions
106 : {
107 : const ScPatternAttr* pPattern;
108 : bool bFormula;
109 : bool bSkipMerged;
110 : bool bGetFont;
111 : bool bTotalSize;
112 :
113 : ScNeededSizeOptions();
114 : };
115 :
116 : class ScColumn
117 : {
118 : // Empty values correspond with empty cells. All non-empty cell positions
119 : // must have non-empty elements. For text width, the value should be
120 : // either the real text width, or TEXTWIDTH_DIRTY in case it hasn't been
121 : // calculated yet. For script type, it should be either the real script
122 : // type value or SC_SCRIPTTYPE_UNKNOWN.
123 : sc::CellTextAttrStoreType maCellTextAttrs;
124 :
125 : // Cell notes
126 : sc::CellNoteStoreType maCellNotes;
127 :
128 : // Broadcasters for formula cells.
129 : sc::BroadcasterStoreType maBroadcasters;
130 :
131 : // Cell values.
132 : sc::CellStoreType maCells;
133 :
134 : SCCOL nCol;
135 : SCTAB nTab;
136 :
137 : ScAttrArray* pAttrArray;
138 : ScDocument* pDocument;
139 : bool mbDirtyGroups; /// formula groups are dirty.
140 :
141 : friend class ScDocument; // for FillInfo
142 : friend class ScTable;
143 : friend class ScValueIterator;
144 : friend class ScHorizontalValueIterator;
145 : friend class ScDBQueryDataIterator;
146 : friend class ScQueryCellIterator;
147 : friend class ScCellIterator;
148 : friend class ScHorizontalCellIterator;
149 : friend class ScHorizontalAttrIterator;
150 : friend class ScColumnTextWidthIterator;
151 : friend class ScDocumentImport;
152 : friend class sc::DocumentStreamAccess;
153 : friend class sc::SingleColumnSpanSet;
154 : friend class sc::ColumnSpanSet;
155 : friend class sc::EditTextIterator;
156 : friend class sc::CellValues;
157 : friend class sc::TableValues;
158 :
159 : ScColumn(const ScColumn&); // disabled
160 : ScColumn& operator= (const ScColumn&); // disabled
161 :
162 : bool ParseString(
163 : ScCellValue& rCell,
164 : SCROW nRow, SCTAB nTab, const OUString& rString, formula::FormulaGrammar::AddressConvention eConv,
165 : ScSetStringParam* pParam );
166 :
167 : public:
168 : ScColumn();
169 : ~ScColumn();
170 :
171 : void Init(SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc);
172 :
173 2277104 : ScDocument& GetDoc() { return *pDocument;}
174 3150 : const ScDocument& GetDoc() const { return *pDocument;}
175 2275970 : SCTAB GetTab() const { return nTab; }
176 1139192 : SCCOL GetCol() const { return nCol; }
177 2519472 : sc::CellStoreType& GetCellStore() { return maCells; }
178 : const sc::CellStoreType& GetCellStore() const { return maCells; }
179 3654302 : sc::CellTextAttrStoreType& GetCellAttrStore() { return maCellTextAttrs; }
180 : const sc::CellTextAttrStoreType& GetCellAttrStore() const { return maCellTextAttrs; }
181 84 : sc::CellNoteStoreType& GetCellNoteStore() { return maCellNotes; }
182 : const sc::CellNoteStoreType& GetCellNoteStore() const { return maCellNotes; }
183 :
184 : ScRefCellValue GetCellValue( SCROW nRow ) const;
185 : ScRefCellValue GetCellValue( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
186 : ScRefCellValue GetCellValue( const sc::CellStoreType::const_iterator& itPos, size_t nOffset ) const;
187 :
188 : const sc::CellTextAttr* GetCellTextAttr( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
189 :
190 : void Delete( SCROW nRow );
191 : void FreeAll();
192 : void Swap( ScColumn& rOther, SCROW nRow1, SCROW nRow2, bool bPattern );
193 :
194 : bool HasAttrib( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const;
195 : bool HasAttribSelection( const ScMarkData& rMark, sal_uInt16 nMask ) const;
196 : bool IsMerged( SCROW nRow ) const;
197 : bool ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
198 : SCCOL& rPaintCol, SCROW& rPaintRow,
199 : bool bRefresh );
200 :
201 : bool IsEmptyData() const;
202 : bool IsEmptyAttr() const;
203 : bool IsEmpty() const;
204 :
205 : // data only:
206 : bool IsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
207 : SCSIZE GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const;
208 : bool HasDataAt(SCROW nRow) const;
209 : bool HasVisibleDataAt(SCROW nRow) const;
210 : SCROW GetFirstDataPos() const;
211 : SCROW GetLastDataPos() const;
212 : SCROW GetLastDataPos( SCROW nLastRow ) const;
213 : bool GetPrevDataPos(SCROW& rRow) const;
214 : bool GetNextDataPos(SCROW& rRow) const;
215 : void FindDataAreaPos(SCROW& rRow, bool bDown) const; // (without Broadcaster)
216 : void FindUsed( SCROW nStartRow, SCROW nEndRow, mdds::flat_segment_tree<SCROW, bool>& rUsed ) const;
217 :
218 : SCSIZE VisibleCount( SCROW nStartRow, SCROW nEndRow ) const;
219 : sal_uInt16 GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const;
220 : bool HasSelectionMatrixFragment(const ScMarkData& rMark) const;
221 :
222 : bool GetFirstVisibleAttr( SCROW& rFirstRow ) const;
223 : bool GetLastVisibleAttr( SCROW& rLastRow, bool bFullFormattedArea = false ) const;
224 : bool HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
225 : bool IsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow = 0,
226 : SCROW nEndRow = MAXROW ) const;
227 : bool IsAllAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW nEndRow ) const;
228 :
229 : bool TestInsertCol( SCROW nStartRow, SCROW nEndRow) const;
230 : bool TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const;
231 : void InsertRow( SCROW nStartRow, SCSIZE nSize );
232 : void DeleteRow( SCROW nStartRow, SCSIZE nSize );
233 : void DeleteArea(
234 : SCROW nStartRow, SCROW nEndRow, InsertDeleteFlags nDelFlag, bool bBroadcast = true );
235 : void DeleteRanges( const std::vector<sc::RowSpan>& rRanges, InsertDeleteFlags nDelFlag, bool bBroadcast );
236 :
237 : void CopyToClip(
238 : sc::CopyToClipContext& rCxt, SCROW nRow1, SCROW nRow2, ScColumn& rColumn ) const;
239 :
240 : void CopyStaticToDocument(
241 : SCROW nRow1, SCROW nRow2, const SvNumberFormatterMergeMap& rMap, ScColumn& rDestCol );
242 :
243 : void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDestCol );
244 : bool InitBlockPosition( sc::ColumnBlockPosition& rBlockPos );
245 : bool InitBlockPosition( sc::ColumnBlockConstPosition& rBlockPos ) const;
246 :
247 : void DeleteBeforeCopyFromClip( sc::CopyFromClipContext& rCxt, const ScColumn& rClipCol );
248 : void CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2 );
249 :
250 : void CopyFromClip(
251 : sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, long nDy, ScColumn& rColumn );
252 :
253 : void StartListeningInArea( sc::StartListeningContext& rCxt, SCROW nRow1, SCROW nRow2 );
254 :
255 : void RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow );
256 :
257 : // Selection (?) of this document
258 : void MixMarked(
259 : sc::MixDocContext& rCxt, const ScMarkData& rMark, sal_uInt16 nFunction,
260 : bool bSkipEmpty, const ScColumn& rSrcCol );
261 : void MixData(
262 : sc::MixDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFunction, bool bSkipEmpty,
263 : const ScColumn& rSrcCol );
264 :
265 : ScAttrIterator* CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const;
266 :
267 : void UpdateSelectionFunction(
268 : const ScRangeList& rRanges, ScFunctionData& rData, ScFlatBoolRowSegments& rHiddenRows );
269 :
270 : void CopyToColumn(
271 : sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nFlags, bool bMarked,
272 : ScColumn& rColumn, const ScMarkData* pMarkData = NULL, bool bAsLink = false) const;
273 :
274 : void UndoToColumn(
275 : sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nFlags, bool bMarked,
276 : ScColumn& rColumn, const ScMarkData* pMarkData = NULL) const;
277 :
278 : void CopyScenarioFrom( const ScColumn& rSrcCol );
279 : void CopyScenarioTo( ScColumn& rDestCol ) const;
280 : bool TestCopyScenarioTo( const ScColumn& rDestCol ) const;
281 : void MarkScenarioIn( ScMarkData& rDestMark ) const;
282 :
283 : void CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const;
284 :
285 : void SwapCol(ScColumn& rCol);
286 : void MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol);
287 :
288 : void MarkSubTotalCells( sc::ColumnSpanSet& rSet, SCROW nRow1, SCROW nRow2, bool bVal ) const;
289 :
290 : bool HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst);
291 :
292 : bool SetString(
293 : SCROW nRow, SCTAB nTab, const OUString& rString, formula::FormulaGrammar::AddressConvention eConv,
294 : ScSetStringParam* pParam = NULL );
295 :
296 : void SetEditText( SCROW nRow, EditTextObject* pEditText );
297 : void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, EditTextObject* pEditText );
298 : void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const EditTextObject& rEditText );
299 : void SetEditText( SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
300 : void SetFormula( SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram );
301 : void SetFormula( SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram );
302 :
303 : /**
304 : * Takes ownership of pCell
305 : *
306 : * @return pCell if it was successfully inserted, NULL otherwise. pCell
307 : * is deleted automatically on failure to insert.
308 : */
309 : ScFormulaCell* SetFormulaCell( SCROW nRow, ScFormulaCell* pCell );
310 : ScFormulaCell* SetFormulaCell( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, ScFormulaCell* pCell );
311 :
312 : bool SetFormulaCells( SCROW nRow, std::vector<ScFormulaCell*>& rCells );
313 :
314 : bool HasFormulaCell( SCROW nRow1, SCROW nRow2 ) const;
315 :
316 : void CloneFormulaCell( const ScFormulaCell& rSrc, const std::vector<sc::RowSpan>& rRanges );
317 :
318 : svl::SharedString GetSharedString( SCROW nRow ) const;
319 :
320 : void SetRawString( SCROW nRow, const OUString& rStr, bool bBroadcast = true );
321 : void SetRawString( SCROW nRow, const svl::SharedString& rStr, bool bBroadcast = true );
322 : void SetRawString( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const svl::SharedString& rStr, bool bBroadcast = true );
323 : void SetValue( SCROW nRow, double fVal );
324 : void SetValues( SCROW nRow, const std::vector<double>& rVals );
325 : void SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double fVal, bool bBroadcast = true );
326 : void SetError( SCROW nRow, const sal_uInt16 nError);
327 :
328 : void GetString( SCROW nRow, OUString& rString ) const;
329 : double* GetValueCell( SCROW nRow );
330 : void GetInputString( SCROW nRow, OUString& rString ) const;
331 : double GetValue( SCROW nRow ) const;
332 : const EditTextObject* GetEditText( SCROW nRow ) const;
333 : void RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr& rAttr );
334 : void GetFormula( SCROW nRow, OUString& rFormula ) const;
335 : const ScFormulaCell* GetFormulaCell( SCROW nRow ) const;
336 : ScFormulaCell* GetFormulaCell( SCROW nRow );
337 : CellType GetCellType( SCROW nRow ) const;
338 : SCSIZE GetCellCount() const;
339 : sal_uInt32 GetWeightedCount() const;
340 : sal_uInt32 GetCodeCount() const; // RPN-Code in formulas
341 : sal_uInt16 GetErrCode( SCROW nRow ) const;
342 :
343 : bool HasStringData( SCROW nRow ) const;
344 : bool HasValueData( SCROW nRow ) const;
345 : bool HasStringCells( SCROW nStartRow, SCROW nEndRow ) const;
346 :
347 : bool IsFormulaDirty( SCROW nRow ) const;
348 :
349 : void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
350 : void SetDirty( SCROW nRow1, SCROW nRow2 );
351 : void SetDirtyVar();
352 : void SetDirtyAfterLoad();
353 : void SetTableOpDirty( const ScRange& );
354 : void CalcAll();
355 : void CalcAfterLoad( sc::CompileFormulaContext& rCxt );
356 : void CompileAll( sc::CompileFormulaContext& rCxt );
357 : void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress );
358 :
359 : bool CompileErrorCells( sc::CompileFormulaContext& rCxt, sal_uInt16 nErrCode );
360 :
361 : void ResetChanged( SCROW nStartRow, SCROW nEndRow );
362 :
363 : bool UpdateReferenceOnCopy( const sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = NULL );
364 :
365 : /**
366 : * Update reference addresses in formula cell in response to mass cell
367 : * movement.
368 : *
369 : * @return true if reference of at least one formula cell has been
370 : * updated, false otherwise.
371 : */
372 : bool UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = NULL );
373 :
374 : void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
375 : void UpdateInsertTabOnlyCells( sc::RefUpdateInsertTabContext& rCxt );
376 : void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
377 : void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo );
378 : void UpdateCompile( bool bForceIfNameInUse = false );
379 : void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
380 : ScDocument* pUndoDoc );
381 : void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
382 :
383 : void SetTabNo(SCTAB nNewTab);
384 : void FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, std::set<sal_uInt16>& rIndexes) const;
385 :
386 : void PreprocessRangeNameUpdate(
387 : sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
388 :
389 : void CompileHybridFormula(
390 : sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt );
391 :
392 : void PreprocessDBDataUpdate(
393 : sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
394 :
395 : const SfxPoolItem* GetAttr( SCROW nRow, sal_uInt16 nWhich ) const;
396 : const ScPatternAttr* GetPattern( SCROW nRow ) const;
397 : const ScPatternAttr* GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow ) const;
398 :
399 : sal_uInt32 GetNumberFormat( SCROW nRow ) const;
400 : sal_uInt32 GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const;
401 :
402 : void MergeSelectionPattern( ScMergePatternState& rState, const ScMarkData& rMark, bool bDeep ) const;
403 : void MergePatternArea( ScMergePatternState& rState, SCROW nRow1, SCROW nRow2, bool bDeep ) const;
404 : void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
405 : ScLineFlags& rFlags,
406 : SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const;
407 : void ApplyBlockFrame( const SvxBoxItem* pLineOuter, const SvxBoxInfoItem* pLineInner,
408 : SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight );
409 :
410 : void ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr );
411 : void ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr );
412 : void ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr,
413 : ScEditDataArray* pDataArray = NULL );
414 : void SetPattern( SCROW nRow, const ScPatternAttr& rPatAttr, bool bPutToPool = false );
415 : void SetPatternArea( SCROW nStartRow, SCROW nEndRow,
416 : const ScPatternAttr& rPatAttr, bool bPutToPool = false );
417 : void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
418 : const ScPatternAttr& rPattern, short nNewType );
419 :
420 : void ApplyStyle( SCROW nRow, const ScStyleSheet& rStyle );
421 : void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle );
422 : void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
423 : void ApplySelectionLineStyle( const ScMarkData& rMark,
424 : const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
425 : void AddCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
426 : void RemoveCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
427 :
428 : const ScStyleSheet* GetStyle( SCROW nRow ) const;
429 : const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
430 : const ScStyleSheet* GetAreaStyle( bool& rFound, SCROW nRow1, SCROW nRow2 ) const;
431 :
432 : void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset );
433 : bool IsStyleSheetUsed( const ScStyleSheet& rStyle, bool bGatherAllStyles ) const;
434 :
435 : /// May return -1 if not found
436 : SCsROW SearchStyle(
437 : SCsROW nRow, const ScStyleSheet* pSearchStyle, bool bUp, bool bInSelection,
438 : const ScMarkData& rMark) const;
439 :
440 : bool SearchStyleRange(
441 : SCsROW& rRow, SCsROW& rEndRow, const ScStyleSheet* pSearchStyle, bool bUp,
442 : bool bInSelection, const ScMarkData& rMark) const;
443 :
444 : bool ApplyFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags );
445 : bool RemoveFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags );
446 : void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
447 :
448 : void RemoveProtected( SCROW nStartRow, SCROW nEndRow );
449 :
450 : SCsROW ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = NULL );
451 : void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast );
452 :
453 : void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
454 : void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
455 :
456 : long GetNeededSize(
457 : SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY,
458 : const Fraction& rZoomX, const Fraction& rZoomY,
459 : bool bWidth, const ScNeededSizeOptions& rOptions, const ScPatternAttr** pPatternChange ) const;
460 :
461 : sal_uInt16 GetOptimalColWidth(
462 : OutputDevice* pDev, double nPPTX, double nPPTY,
463 : const Fraction& rZoomX, const Fraction& rZoomY,
464 : bool bFormula, sal_uInt16 nOldWidth, const ScMarkData* pMarkData, const ScColWidthParam* pParam) const;
465 :
466 : void GetOptimalHeight(
467 : sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart );
468 :
469 : /// Including current, may return -1
470 : SCsROW GetNextUnprotected( SCROW nRow, bool bUp ) const;
471 :
472 : void GetFilterEntries(
473 : sc::ColumnBlockConstPosition& rBlockPos, SCROW nStartRow, SCROW nEndRow,
474 : std::vector<ScTypedStrData>& rStrings, bool& rHasDates );
475 :
476 : bool GetDataEntries( SCROW nRow, std::set<ScTypedStrData>& rStrings, bool bLimit ) const;
477 :
478 : void UpdateInsertTabAbs(SCTAB nNewPos);
479 : bool TestTabRefAbs(SCTAB nTable) const;
480 : bool GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& rData) const;
481 :
482 : void StartListening( SvtListener& rLst, SCROW nRow );
483 : void EndListening( SvtListener& rLst, SCROW nRow );
484 : void StartListening( sc::StartListeningContext& rCxt, SCROW nRow, SvtListener& rListener );
485 : void EndListening( sc::EndListeningContext& rCxt, SCROW nRow, SvtListener& rListener );
486 : void StartAllListeners();
487 : void StartNeededListeners(); // only for cells where NeedsListening()==true
488 : void SetDirtyIfPostponed();
489 : void BroadcastRecalcOnRefMove();
490 : void TransferListeners( ScColumn& rDestCol, SCROW nRow1, SCROW nRow2, SCROW nRowDelta );
491 : void CollectListeners( std::vector<SvtListener*>& rListeners, SCROW nRow1, SCROW nRow2 );
492 :
493 : void CompileDBFormula( sc::CompileFormulaContext& rCxt );
494 : void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt );
495 :
496 : sal_Int32 GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
497 : sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
498 : SCROW nRowStart, SCROW nRowEnd ) const;
499 :
500 : sal_uInt16 GetTextWidth(SCROW nRow) const;
501 : void SetTextWidth(SCROW nRow, sal_uInt16 nWidth);
502 :
503 : sal_uInt8 GetScriptType( SCROW nRow ) const;
504 :
505 : /**
506 : * Get combined script types of the specified range. This method may
507 : * update script types on demand if they have not been determined.
508 : */
509 : sal_uInt8 GetRangeScriptType( sc::CellTextAttrStoreType::iterator& itPos, SCROW nRow1, SCROW nRow2,
510 : const sc::CellStoreType::iterator& itr);
511 :
512 : void SetScriptType( SCROW nRow, sal_uInt8 nType );
513 : void UpdateScriptTypes( SCROW nRow1, SCROW nRow2 );
514 :
515 : size_t GetFormulaHash( SCROW nRow ) const;
516 :
517 : ScFormulaVectorState GetFormulaVectorState( SCROW nRow ) const;
518 : formula::FormulaTokenRef ResolveStaticReference( SCROW nRow );
519 : bool ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow1, SCROW nRow2 );
520 : void FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2 ) const;
521 : formula::VectorRefArray FetchVectorRefArray( SCROW nRow1, SCROW nRow2 );
522 : void SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen );
523 : void SetFormulaResults( SCROW nRow, const formula::FormulaTokenRef* pResults, size_t nLen );
524 :
525 : void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
526 :
527 : SvtBroadcaster* GetBroadcaster( SCROW nRow );
528 : const SvtBroadcaster* GetBroadcaster( SCROW nRow ) const;
529 : const SvtBroadcaster* GetBroadcaster( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
530 :
531 : void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 );
532 : void PrepareBroadcastersForDestruction();
533 : bool HasBroadcaster() const;
534 :
535 : void Broadcast( SCROW nRow );
536 : void BroadcastCells( const std::vector<SCROW>& rRows, sal_uLong nHint );
537 :
538 : // cell notes
539 : ScPostIt* GetCellNote( SCROW nRow );
540 : const ScPostIt* GetCellNote( SCROW nRow ) const;
541 : const ScPostIt* GetCellNote( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
542 : void DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 );
543 : bool HasCellNotes() const;
544 : void SetCellNote( SCROW nRow, ScPostIt* pNote);
545 : bool IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
546 :
547 : ScPostIt* ReleaseNote( SCROW nRow );
548 : size_t GetNoteCount() const;
549 : void CreateAllNoteCaptions();
550 : void ForgetNoteCaptions( SCROW nRow1, SCROW nRow2 );
551 : SCROW GetNotePosition( size_t nIndex ) const;
552 : void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
553 : void GetNotesInRange( SCROW nStartRow, SCROW nEndRow, std::vector<sc::NoteEntry>& rNotes ) const;
554 :
555 : SCROW GetCellNotesMaxRow() const;
556 : SCROW GetCellNotesMinRow() const;
557 :
558 : void CopyCellNotesToDocument(
559 : SCROW nRow1, SCROW nRow2, ScColumn& rDestCol, bool bCloneCaption = true,
560 : SCROW nRowOffsetDest = 0) const;
561 :
562 : void DuplicateNotes(SCROW nStartRow, size_t nDataSize, ScColumn& rDestCol,
563 : sc::ColumnBlockPosition& maDestBlockPos, bool bCloneCaption = true, SCROW nRowOffsetDest=0 ) const;
564 :
565 : void UpdateNoteCaptions( SCROW nRow1, SCROW nRow2 );
566 :
567 : void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 );
568 :
569 : void JoinNewFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ) const;
570 :
571 : /**
572 : * Detach a formula cell that's about to be deleted, or removed from
573 : * document storage (if that ever happens).
574 : */
575 : void DetachFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell );
576 :
577 : void DetachFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength );
578 :
579 : void AttachFormulaCells( sc::StartListeningContext& rCxt, SCROW nRow1, SCROW nRow2 );
580 : void DetachFormulaCells( sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2 );
581 :
582 : /**
583 : * Regroup formula cells for the entire column.
584 : */
585 : void RegroupFormulaCells();
586 :
587 : /**
588 : * Reset column position of formula cells within specified row range.
589 : * Reference positions are also adjusted to reflect the new position so
590 : * that the formula cells still reference the same cells or ranges after
591 : * the the position change. The position of a formula cell before the
592 : * call is interpreted as the old position of that cell.
593 : *
594 : * Caller needs to ensure that no formula groups cross the top and bottom
595 : * row boundaries.
596 : *
597 : * @param nRow1 top row boundary
598 : * @param nRow2 bottom row boundary
599 : */
600 : void ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2 );
601 :
602 : void SplitFormulaGroupByRelativeRef( const ScRange& rBoundRange );
603 :
604 : void TransferCellValuesTo( SCROW nRow, size_t nLen, sc::CellValues& rDest );
605 : void CopyCellValuesFrom( SCROW nRow, const sc::CellValues& rSrc );
606 : void ConvertFormulaToValue(
607 : sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, sc::TableValues* pUndo );
608 :
609 : void SwapNonEmpty(
610 : sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
611 :
612 : #if DEBUG_COLUMN_STORAGE
613 : void DumpFormulaGroups() const;
614 : #endif
615 :
616 : SCSIZE GetPatternCount() const;
617 : SCSIZE GetPatternCount( SCROW nRow1, SCROW nRow2 ) const;
618 : bool ReservePatternCount( SCSIZE nReserve );
619 : private:
620 :
621 : sc::CellStoreType::iterator GetPositionToInsert( SCROW nRow );
622 : sc::CellStoreType::iterator GetPositionToInsert( const sc::CellStoreType::iterator& it, SCROW nRow );
623 : void ActivateNewFormulaCell( const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell, bool bJoin = true );
624 : void ActivateNewFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell, bool bJoin = true );
625 : void AttachNewFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength );
626 : void BroadcastNewCell( SCROW nRow );
627 : bool UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow, const sc::CellStoreType::iterator& itr );
628 :
629 : const ScFormulaCell* FetchFormulaCell( SCROW nRow ) const;
630 :
631 : SCROW FindNextVisibleRowWithContent(
632 : sc::CellStoreType::const_iterator& itPos, SCROW nRow, bool bForward) const;
633 : SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const;
634 :
635 : /**
636 : * Called whenever the state of cell array gets modified i.e. new cell
637 : * insertion, cell removal or relocation, cell value update and so on.
638 : *
639 : * Call this only from those methods where maCells is modified directly.
640 : */
641 : void CellStorageModified();
642 :
643 : void CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol) const;
644 :
645 : void DeleteCells(
646 : sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nDelFlag,
647 : std::vector<SCROW>& rDeleted );
648 :
649 : /**
650 : * Get all non-grouped formula cells and formula cell groups in the whole
651 : * column.
652 : */
653 : std::vector<sc::FormulaGroupEntry> GetFormulaGroupEntries();
654 : };
655 :
656 : #endif
657 :
658 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|