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