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_TABLE_HXX
21 : #define INCLUDED_SC_INC_TABLE_HXX
22 :
23 : #include <vector>
24 : #include <utility>
25 : #include <tools/gen.hxx>
26 : #include <tools/color.hxx>
27 : #include <com/sun/star/uno/Sequence.hxx>
28 : #include "column.hxx"
29 : #include "sortparam.hxx"
30 : #include "compressedarray.hxx"
31 : #include "postit.hxx"
32 : #include "types.hxx"
33 : #include "cellvalue.hxx"
34 : #include <formula/types.hxx>
35 : #include "calcmacros.hxx"
36 :
37 : #include <set>
38 : #include <map>
39 : #include <boost/scoped_ptr.hpp>
40 : #include <boost/noncopyable.hpp>
41 :
42 : namespace utl {
43 : class TextSearch;
44 : }
45 :
46 : namespace com { namespace sun { namespace star {
47 : namespace sheet {
48 : struct TablePageBreakData;
49 : }
50 : } } }
51 :
52 : namespace formula { struct VectorRefArray; }
53 : namespace sc {
54 :
55 : struct FormulaGroupContext;
56 : class StartListeningContext;
57 : class EndListeningContext;
58 : class CopyFromClipContext;
59 : class CopyToClipContext;
60 : class CopyToDocContext;
61 : class MixDocContext;
62 : class ColumnSpanSet;
63 : class ColumnSet;
64 : struct ColumnBlockPosition;
65 : struct RefUpdateContext;
66 : struct RefUpdateInsertTabContext;
67 : struct RefUpdateDeleteTabContext;
68 : struct RefUpdateMoveTabContext;
69 : struct NoteEntry;
70 : class DocumentStreamAccess;
71 : class CellValues;
72 : class TableValues;
73 : class RowHeightContext;
74 : class CompileFormulaContext;
75 : struct SetFormulaDirtyContext;
76 : class RefMovedHint;
77 : struct ReorderParam;
78 :
79 : }
80 :
81 : class SfxItemSet;
82 : class SfxStyleSheetBase;
83 : class SvxBoxInfoItem;
84 : class SvxBoxItem;
85 : class SvxSearchItem;
86 :
87 : class ScAutoFormatData;
88 : class ScDocument;
89 : class ScEditDataArray;
90 : class ScFormulaCell;
91 : class ScOutlineTable;
92 : class ScPrintSaverTab;
93 : class ScProgress;
94 : class ScRangeList;
95 : class ScSheetEvents;
96 : class ScSortInfoArray;
97 : class ScConditionalFormat;
98 : class ScConditionalFormatList;
99 : class ScStyleSheet;
100 : class ScTableProtection;
101 : class ScUserListData;
102 : struct RowInfo;
103 : struct ScFunctionData;
104 : struct ScLineFlags;
105 : class CollatorWrapper;
106 : class ScFlatUInt16RowSegments;
107 : class ScFlatBoolRowSegments;
108 : class ScFlatBoolColSegments;
109 : struct ScSetStringParam;
110 : struct ScColWidthParam;
111 : struct ScColWidthParam;
112 : class ScRangeName;
113 : class ScDBData;
114 : class ScDocumentImport;
115 : class ScHint;
116 :
117 : class ScTable : boost::noncopyable
118 : {
119 : private:
120 : typedef ::std::vector< ScRange > ScRangeVec;
121 :
122 : ScColumn aCol[MAXCOLCOUNT];
123 :
124 : OUString aName;
125 : OUString aCodeName;
126 : OUString aComment;
127 :
128 : OUString aLinkDoc;
129 : OUString aLinkFlt;
130 : OUString aLinkOpt;
131 : OUString aLinkTab;
132 : sal_uLong nLinkRefreshDelay;
133 : sal_uInt8 nLinkMode;
134 :
135 : // page style template
136 : OUString aPageStyle;
137 : Size aPageSizeTwips; // size of the print-page
138 : SCCOL nRepeatStartX; // repeating rows/columns
139 : SCCOL nRepeatEndX; // REPEAT_NONE, if not used
140 : SCROW nRepeatStartY;
141 : SCROW nRepeatEndY;
142 :
143 : boost::scoped_ptr<ScTableProtection> pTabProtection;
144 :
145 : sal_uInt16* pColWidth;
146 : boost::scoped_ptr<ScFlatUInt16RowSegments> mpRowHeights;
147 :
148 : sal_uInt8* pColFlags;
149 : ScBitMaskCompressedArray< SCROW, sal_uInt8>* pRowFlags;
150 : boost::scoped_ptr<ScFlatBoolColSegments> mpHiddenCols;
151 : boost::scoped_ptr<ScFlatBoolRowSegments> mpHiddenRows;
152 : boost::scoped_ptr<ScFlatBoolColSegments> mpFilteredCols;
153 : boost::scoped_ptr<ScFlatBoolRowSegments> mpFilteredRows;
154 :
155 : ::std::set<SCROW> maRowPageBreaks;
156 : ::std::set<SCROW> maRowManualBreaks;
157 : ::std::set<SCCOL> maColPageBreaks;
158 : ::std::set<SCCOL> maColManualBreaks;
159 :
160 : ScOutlineTable* pOutlineTable;
161 :
162 : ScSheetEvents* pSheetEvents;
163 :
164 : mutable SCCOL nTableAreaX;
165 : mutable SCROW nTableAreaY;
166 :
167 : SCTAB nTab;
168 : ScDocument* pDocument;
169 : utl::TextSearch* pSearchText;
170 :
171 : mutable OUString aUpperName; // #i62977# filled only on demand, reset in SetName
172 :
173 : // sort parameter to minimize stack size of quicksort
174 : ScSortParam aSortParam;
175 : CollatorWrapper* pSortCollator;
176 :
177 : ScRangeVec aPrintRanges;
178 :
179 : ScRange* pRepeatColRange;
180 : ScRange* pRepeatRowRange;
181 :
182 : sal_uInt16 nLockCount;
183 :
184 : ScRangeList* pScenarioRanges;
185 : Color aScenarioColor;
186 : Color aTabBgColor;
187 : sal_uInt16 nScenarioFlags;
188 : ScDBData* pDBDataNoName;
189 : mutable ScRangeName* mpRangeName;
190 :
191 : boost::scoped_ptr<ScConditionalFormatList> mpCondFormatList;
192 :
193 : bool bScenario:1;
194 : bool bLayoutRTL:1;
195 : bool bLoadingRTL:1;
196 : bool bPageSizeValid:1;
197 : mutable bool bTableAreaValid:1;
198 : bool bVisible:1;
199 : bool bStreamValid:1;
200 : bool bPendingRowHeights:1;
201 : bool bCalcNotification:1;
202 : bool bGlobalKeepQuery:1;
203 : bool bPrintEntireSheet:1;
204 : bool bActiveScenario:1;
205 : bool mbPageBreaksValid:1;
206 : bool mbForceBreaks:1;
207 :
208 : friend class ScDocument; // for FillInfo
209 : friend class ScValueIterator;
210 : friend class ScHorizontalValueIterator;
211 : friend class ScDBQueryDataIterator;
212 : friend class ScFormulaGroupIterator;
213 : friend class ScCellIterator;
214 : friend class ScQueryCellIterator;
215 : friend class ScHorizontalCellIterator;
216 : friend class ScHorizontalAttrIterator;
217 : friend class ScDocAttrIterator;
218 : friend class ScAttrRectIterator;
219 : friend class ScColumnTextWidthIterator;
220 : friend class ScDocumentImport;
221 : friend class sc::DocumentStreamAccess;
222 : friend class sc::ColumnSpanSet;
223 : friend class sc::EditTextIterator;
224 : friend class sc::FormulaGroupAreaListener;
225 :
226 : public:
227 : ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
228 : bool bColInfo = true, bool bRowInfo = true );
229 : ~ScTable();
230 :
231 1 : ScDocument& GetDoc() { return *pDocument;}
232 : const ScDocument& GetDoc() const { return *pDocument;}
233 1 : SCTAB GetTab() const { return nTab; }
234 :
235 15040 : ScOutlineTable* GetOutlineTable() { return pOutlineTable; }
236 :
237 : sal_uLong GetCellCount() const;
238 : sal_uLong GetWeightedCount() const;
239 : sal_uLong GetCodeCount() const; // RPN code in formula
240 :
241 : sal_uInt16 GetTextWidth(SCCOL nCol, SCROW nRow) const;
242 :
243 : bool SetOutlineTable( const ScOutlineTable* pNewOutline );
244 : void StartOutlineTable();
245 :
246 : void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
247 :
248 : bool TestRemoveSubTotals( const ScSubTotalParam& rParam );
249 : void RemoveSubTotals( ScSubTotalParam& rParam );
250 : bool DoSubTotals( ScSubTotalParam& rParam );
251 :
252 69294 : const ScSheetEvents* GetSheetEvents() const { return pSheetEvents; }
253 : void SetSheetEvents( const ScSheetEvents* pNew );
254 :
255 7846 : bool IsVisible() const { return bVisible; }
256 : void SetVisible( bool bVis );
257 :
258 749316 : bool IsStreamValid() const { return bStreamValid; }
259 : void SetStreamValid( bool bSet, bool bIgnoreLock = false );
260 :
261 10458 : bool IsPendingRowHeights() const { return bPendingRowHeights; }
262 : void SetPendingRowHeights( bool bSet );
263 :
264 13649 : bool GetCalcNotification() const { return bCalcNotification; }
265 : void SetCalcNotification( bool bSet );
266 :
267 157299 : bool IsLayoutRTL() const { return bLayoutRTL; }
268 351 : bool IsLoadingRTL() const { return bLoadingRTL; }
269 : void SetLayoutRTL( bool bSet );
270 : void SetLoadingRTL( bool bSet );
271 :
272 42578 : bool IsScenario() const { return bScenario; }
273 : void SetScenario( bool bFlag );
274 1 : void GetScenarioComment( OUString& rComment) const { rComment = aComment; }
275 1 : void SetScenarioComment( const OUString& rComment ) { aComment = rComment; }
276 1 : const Color& GetScenarioColor() const { return aScenarioColor; }
277 1 : void SetScenarioColor(const Color& rNew) { aScenarioColor = rNew; }
278 5134 : const Color& GetTabBgColor() const { return aTabBgColor; }
279 : void SetTabBgColor(const Color& rColor);
280 1 : sal_uInt16 GetScenarioFlags() const { return nScenarioFlags; }
281 1 : void SetScenarioFlags(sal_uInt16 nNew) { nScenarioFlags = nNew; }
282 1 : void SetActiveScenario(bool bSet) { bActiveScenario = bSet; }
283 2 : bool IsActiveScenario() const { return bActiveScenario; }
284 :
285 164 : sal_uInt8 GetLinkMode() const { return nLinkMode; }
286 1481 : bool IsLinked() const { return nLinkMode != SC_LINK_NONE; }
287 20 : const OUString& GetLinkDoc() const { return aLinkDoc; }
288 2 : const OUString& GetLinkFlt() const { return aLinkFlt; }
289 2 : const OUString& GetLinkOpt() const { return aLinkOpt; }
290 2 : const OUString& GetLinkTab() const { return aLinkTab; }
291 2 : sal_uLong GetLinkRefreshDelay() const { return nLinkRefreshDelay; }
292 :
293 : void SetLink( sal_uInt8 nMode, const OUString& rDoc, const OUString& rFlt,
294 : const OUString& rOpt, const OUString& rTab, sal_uLong nRefreshDelay );
295 :
296 : void GetName( OUString& rName ) const;
297 : void SetName( const OUString& rNewName );
298 :
299 : void SetAnonymousDBData(ScDBData* pDBData);
300 1225 : ScDBData* GetAnonymousDBData() { return pDBDataNoName;}
301 :
302 3893 : void GetCodeName( OUString& rName ) const { rName = aCodeName; }
303 710 : void SetCodeName( const OUString& rNewName ) { aCodeName = rNewName; }
304 :
305 : const OUString& GetUpperName() const;
306 :
307 48969 : const OUString& GetPageStyle() const { return aPageStyle; }
308 : void SetPageStyle( const OUString& rName );
309 : void PageStyleModified( const OUString& rNewName );
310 :
311 : bool IsProtected() const;
312 : void SetProtection(const ScTableProtection* pProtect);
313 : ScTableProtection* GetProtection();
314 :
315 : Size GetPageSize() const;
316 : void SetPageSize( const Size& rSize );
317 : void SetRepeatArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
318 :
319 : void LockTable();
320 : void UnlockTable();
321 :
322 : bool IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2,
323 : SCROW nRow2, bool* pOnlyNotBecauseOfMatrix = NULL ) const;
324 : bool IsSelectionEditable( const ScMarkData& rMark,
325 : bool* pOnlyNotBecauseOfMatrix = NULL ) const;
326 :
327 : bool HasBlockMatrixFragment( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
328 : bool HasSelectionMatrixFragment( const ScMarkData& rMark ) const;
329 :
330 : bool IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bIgnoreNotes = false ) const;
331 :
332 : bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
333 : ScSetStringParam* pParam = NULL );
334 :
335 : bool SetEditText( SCCOL nCol, SCROW nRow, EditTextObject* pEditText );
336 : void SetEditText( SCCOL nCol, SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool );
337 : SCROW GetFirstEditTextRow( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
338 :
339 : void SetEmptyCell( SCCOL nCol, SCROW nRow );
340 : void SetFormula(
341 : SCCOL nCol, SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram );
342 : void SetFormula(
343 : SCCOL nCol, SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram );
344 :
345 : /**
346 : * Takes ownership of pCell
347 : *
348 : * @return pCell if it was successfully inserted, NULL otherwise. pCell
349 : * is deleted automatically on failure to insert.
350 : */
351 : ScFormulaCell* SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell );
352 :
353 : bool SetFormulaCells( SCCOL nCol, SCROW nRow, std::vector<ScFormulaCell*>& rCells );
354 :
355 : bool HasFormulaCell( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
356 :
357 : svl::SharedString GetSharedString( SCCOL nCol, SCROW nRow ) const;
358 :
359 : void SetValue( SCCOL nCol, SCROW nRow, const double& rVal );
360 : void SetValues( SCCOL nCol, SCROW nRow, const std::vector<double>& rVals );
361 : void SetError( SCCOL nCol, SCROW nRow, sal_uInt16 nError);
362 : SCSIZE GetPatternCount( SCCOL nCol ) const;
363 : SCSIZE GetPatternCount( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
364 : bool ReservePatternCount( SCCOL nCol, SCSIZE nReserve );
365 :
366 : void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr );
367 : void GetString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
368 : double* GetValueCell( SCCOL nCol, SCROW nRow );
369 : void GetInputString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
370 : double GetValue( const ScAddress& rPos ) const
371 : {
372 : return ValidColRow(rPos.Col(),rPos.Row()) ?
373 : aCol[rPos.Col()].GetValue( rPos.Row() ) :
374 : 0.0;
375 : }
376 : double GetValue( SCCOL nCol, SCROW nRow ) const;
377 : const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const;
378 : void RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
379 : void GetFormula( SCCOL nCol, SCROW nRow, OUString& rFormula ) const;
380 : const ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ) const;
381 : ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow );
382 :
383 27606 : CellType GetCellType( const ScAddress& rPos ) const
384 : {
385 27606 : return ValidColRow(rPos.Col(),rPos.Row()) ?
386 27606 : aCol[rPos.Col()].GetCellType( rPos.Row() ) :
387 55212 : CELLTYPE_NONE;
388 : }
389 : CellType GetCellType( SCCOL nCol, SCROW nRow ) const;
390 : ScRefCellValue GetCellValue( SCCOL nCol, SCROW nRow ) const;
391 :
392 : void GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const;
393 : void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const;
394 :
395 : ScPostIt* ReleaseNote( SCCOL nCol, SCROW nRow );
396 :
397 : size_t GetNoteCount( SCCOL nCol ) const;
398 : SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const;
399 : void CreateAllNoteCaptions();
400 : void ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
401 :
402 : void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
403 : void GetNotesInRange( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes ) const;
404 : bool ContainsNotesInRange( const ScRange& rRange ) const;
405 :
406 : bool TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ) const;
407 : void InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize );
408 : void DeleteRow(
409 : const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize,
410 : bool* pUndoOutline = NULL, std::vector<ScAddress>* pGroupPos = NULL );
411 :
412 : bool TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const;
413 : void InsertCol(
414 : const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize );
415 : void DeleteCol(
416 : const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize, bool* pUndoOutline = NULL );
417 :
418 : void DeleteArea(
419 : SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, InsertDeleteFlags nDelFlag,
420 : bool bBroadcast = true, sc::ColumnSpanSet* pBroadcastSpans = NULL );
421 :
422 : void CopyToClip( sc::CopyToClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTable );
423 : void CopyToClip( sc::CopyToClipContext& rCxt, const ScRangeList& rRanges, ScTable* pTable );
424 :
425 : void CopyStaticToDocument(
426 : SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const SvNumberFormatterMergeMap& rMap,
427 : ScTable* pDestTab );
428 :
429 : void CopyCellToDocument( SCCOL nSrcCol, SCROW nSrcRow, SCCOL nDestCol, SCROW nDestRow, ScTable& rDestTab );
430 :
431 : bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol );
432 :
433 : void DeleteBeforeCopyFromClip(
434 : sc::CopyFromClipContext& rCxt, const ScTable& rClipTab, sc::ColumnSpanSet& rBroadcastSpans );
435 :
436 : void CopyOneCellFromClip(
437 : sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
438 :
439 : void CopyFromClip(
440 : sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
441 : SCsCOL nDx, SCsROW nDy, ScTable* pTable );
442 :
443 : void StartListeningFormulaCells(
444 : sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt,
445 : SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
446 :
447 : void EndListeningFormulaCells(
448 : sc::EndListeningContext& rEndCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
449 :
450 : void SetDirtyFromClip(
451 : SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans );
452 :
453 : void CopyToTable(
454 : sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
455 : InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab,
456 : const ScMarkData* pMarkData = NULL, bool bAsLink = false, bool bColRowFlags = true );
457 :
458 : void UndoToTable(
459 : sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
460 : InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab, const ScMarkData* pMarkData = NULL );
461 :
462 : void CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
463 : SCsCOL nDx, SCsROW nDy, ScTable* pTable);
464 : void TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
465 : ScTable* pTransClip, InsertDeleteFlags nFlags, bool bAsLink );
466 :
467 : // mark of this document
468 : void MixMarked(
469 : sc::MixDocContext& rCxt, const ScMarkData& rMark, sal_uInt16 nFunction,
470 : bool bSkipEmpty, const ScTable* pSrcTab );
471 :
472 : void MixData(
473 : sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
474 : sal_uInt16 nFunction, bool bSkipEmpty, const ScTable* pSrcTab );
475 :
476 : void CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
477 : SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab );
478 :
479 : void CopyScenarioFrom( const ScTable* pSrcTab );
480 : void CopyScenarioTo( ScTable* pDestTab ) const;
481 : bool TestCopyScenarioTo( const ScTable* pDestTab ) const;
482 : void MarkScenarioIn( ScMarkData& rMark, sal_uInt16 nNeededBits ) const;
483 : bool HasScenarioRange( const ScRange& rRange ) const;
484 : void InvalidateScenarioRanges();
485 : const ScRangeList* GetScenarioRanges() const;
486 :
487 : void CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const;
488 :
489 : void InvalidateTableArea();
490 : void InvalidatePageBreaks();
491 :
492 : bool GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const; // FALSE = empty
493 : bool GetTableArea( SCCOL& rEndCol, SCROW& rEndRow ) const;
494 : bool GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes, bool bFullFormattedArea = false ) const;
495 : bool GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow,
496 : SCCOL& rEndCol, bool bNotes ) const;
497 : bool GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
498 : SCROW& rEndRow, bool bNotes ) const;
499 :
500 : bool GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const;
501 :
502 : void ExtendPrintArea( OutputDevice* pDev,
503 : SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow );
504 :
505 : void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
506 : bool bIncludeOld, bool bOnlyDown ) const;
507 :
508 : bool ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow,
509 : SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly,
510 : bool bStickyTopRow, bool bStickyLeftCol ) const;
511 :
512 : SCROW GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const;
513 :
514 : SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
515 : SCCOL nEndCol, SCROW nEndRow, ScDirection eDir ) const;
516 :
517 : void FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection ) const;
518 : void GetNextPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY,
519 : bool bMarked, bool bUnprotected, const ScMarkData& rMark ) const;
520 :
521 : void LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
522 :
523 : bool HasData( SCCOL nCol, SCROW nRow ) const;
524 : bool HasStringData( SCCOL nCol, SCROW nRow ) const;
525 : bool HasValueData( SCCOL nCol, SCROW nRow ) const;
526 : bool HasStringCells( SCCOL nStartCol, SCROW nStartRow,
527 : SCCOL nEndCol, SCROW nEndRow ) const;
528 :
529 2478 : sal_uInt16 GetErrCode( const ScAddress& rPos ) const
530 : {
531 2478 : return ValidColRow(rPos.Col(),rPos.Row()) ?
532 2478 : aCol[rPos.Col()].GetErrCode( rPos.Row() ) :
533 4956 : 0;
534 : }
535 :
536 : void ResetChanged( const ScRange& rRange );
537 :
538 : void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
539 : void SetDirty( const ScRange&, ScColumn::BroadcastMode );
540 : void SetDirtyAfterLoad();
541 : void SetDirtyVar();
542 : void SetTableOpDirty( const ScRange& );
543 : void CalcAll();
544 : void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening );
545 : void CompileAll( sc::CompileFormulaContext& rCxt );
546 : void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress );
547 :
548 : /** Broadcast single broadcasters in range, without explicitly setting
549 : anything dirty, not doing area broadcasts.
550 : @param rHint address is modified to adapt to the actual broadcasted
551 : position on each iteration and upon return points to the last
552 : position broadcasted. */
553 : bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScHint& rHint );
554 :
555 : bool CompileErrorCells( sc::CompileFormulaContext& rCxt, sal_uInt16 nErrCode );
556 :
557 : void UpdateReference(
558 : sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = NULL,
559 : bool bIncludeDraw = true, bool bUpdateNoteCaptionPos = true );
560 :
561 : void UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
562 : SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
563 : SCsCOL nDx, SCsROW nDy, SCsTAB nDz, bool bUpdateNoteCaptionPos = true );
564 :
565 : void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
566 : ScDocument* pUndoDoc );
567 :
568 : void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
569 :
570 : void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt );
571 : void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt );
572 : void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo, ScProgress* pProgress );
573 : void UpdateCompile( bool bForceIfNameInUse = false );
574 : void SetTabNo(SCTAB nNewTab);
575 : void FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
576 : std::set<sal_uInt16>& rIndexes) const;
577 : void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
578 : sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
579 : double nStepValue, double nMaxValue, ScProgress* pProgress);
580 : OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
581 :
582 : void UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& rMark );
583 :
584 : void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
585 : sal_uInt16 nFormatNo );
586 : void GetAutoFormatData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData& rData);
587 : void ScReplaceTabsStr( OUString& rStr, const OUString& rSrch, const OUString& rRepl ); // from sw
588 : bool SearchAndReplace(
589 : const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark,
590 : ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
591 :
592 : void FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 );
593 :
594 : void GetBorderLines( SCCOL nCol, SCROW nRow,
595 : const ::editeng::SvxBorderLine** ppLeft, const ::editeng::SvxBorderLine** ppTop,
596 : const ::editeng::SvxBorderLine** ppRight, const ::editeng::SvxBorderLine** ppBottom ) const;
597 :
598 : bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sal_uInt16 nMask ) const;
599 : bool HasAttribSelection( const ScMarkData& rMark, sal_uInt16 nMask ) const;
600 : bool IsMerged( SCCOL nCol, SCROW nRow ) const;
601 : bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
602 : SCCOL& rEndCol, SCROW& rEndRow,
603 : bool bRefresh );
604 : const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) const;
605 : const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow ) const;
606 : const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
607 :
608 : sal_uInt32 GetNumberFormat( const ScAddress& rPos ) const;
609 : sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow ) const;
610 : sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
611 :
612 : void SetNumberFormat( SCCOL nCol, SCROW nRow, sal_uInt32 nNumberFormat );
613 :
614 : void MergeSelectionPattern( ScMergePatternState& rState,
615 : const ScMarkData& rMark, bool bDeep ) const;
616 : void MergePatternArea( ScMergePatternState& rState, SCCOL nCol1, SCROW nRow1,
617 : SCCOL nCol2, SCROW nRow2, bool bDeep ) const;
618 : void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
619 : ScLineFlags& rFlags,
620 : SCCOL nStartCol, SCROW nStartRow,
621 : SCCOL nEndCol, SCROW nEndRow ) const;
622 : void ApplyBlockFrame( const SvxBoxItem* pLineOuter,
623 : const SvxBoxInfoItem* pLineInner,
624 : SCCOL nStartCol, SCROW nStartRow,
625 : SCCOL nEndCol, SCROW nEndRow );
626 :
627 : void ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr );
628 : void ApplyPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
629 : void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
630 : const ScPatternAttr& rAttr, ScEditDataArray* pDataArray = NULL );
631 :
632 0 : void SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr, bool bPutToPool = false )
633 : {
634 0 : if (ValidColRow(rPos.Col(),rPos.Row()))
635 0 : aCol[rPos.Col()].SetPattern( rPos.Row(), rAttr, bPutToPool );
636 0 : }
637 : void SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr, bool bPutToPool = false );
638 : void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
639 : const ScPatternAttr& rPattern, short nNewType );
640 : void AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
641 : void RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
642 :
643 : void ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet& rStyle );
644 : void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle );
645 : void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
646 : void ApplySelectionLineStyle( const ScMarkData& rMark,
647 : const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
648 :
649 : const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow ) const;
650 : const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
651 : const ScStyleSheet* GetAreaStyle( bool& rFound, SCCOL nCol1, SCROW nRow1,
652 : SCCOL nCol2, SCROW nRow2 ) const;
653 :
654 : void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved,
655 : OutputDevice* pDev,
656 : double nPPTX, double nPPTY,
657 : const Fraction& rZoomX, const Fraction& rZoomY );
658 :
659 : bool IsStyleSheetUsed( const ScStyleSheet& rStyle, bool bGatherAllStyles ) const;
660 :
661 : bool ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, sal_Int16 nFlags );
662 : bool RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, sal_Int16 nFlags );
663 :
664 : void ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = NULL );
665 : void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
666 :
667 : void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
668 : void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
669 :
670 604 : const ScRange* GetRepeatColRange() const { return pRepeatColRange; }
671 610 : const ScRange* GetRepeatRowRange() const { return pRepeatRowRange; }
672 : void SetRepeatColRange( const ScRange* pNew );
673 : void SetRepeatRowRange( const ScRange* pNew );
674 :
675 1053 : sal_uInt16 GetPrintRangeCount() const { return static_cast< sal_uInt16 >( aPrintRanges.size() ); }
676 : const ScRange* GetPrintRange(sal_uInt16 nPos) const;
677 : /** Returns true, if the sheet is always printed. */
678 1654 : bool IsPrintEntireSheet() const { return bPrintEntireSheet; }
679 :
680 : /** Removes all print ranges. */
681 : void ClearPrintRanges();
682 : /** Adds a new print ranges. */
683 : void AddPrintRange( const ScRange& rNew );
684 : /** Marks the specified sheet to be printed completely. Deletes old print ranges! */
685 : void SetPrintEntireSheet();
686 :
687 : void FillPrintSaver( ScPrintSaverTab& rSaveTab ) const;
688 : void RestorePrintRanges( const ScPrintSaverTab& rSaveTab );
689 :
690 : sal_uInt16 GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev,
691 : double nPPTX, double nPPTY,
692 : const Fraction& rZoomX, const Fraction& rZoomY,
693 : bool bFormula, const ScMarkData* pMarkData,
694 : const ScColWidthParam* pParam );
695 : bool SetOptimalHeight(
696 : sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
697 : ScProgress* pOuterProgress = NULL, sal_uLong nProgressStart = 0 );
698 :
699 : void SetOptimalHeightOnly(
700 : sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
701 : ScProgress* pOuterProgress = NULL, sal_uLong nProgressStart = 0 );
702 :
703 : long GetNeededSize( SCCOL nCol, SCROW nRow,
704 : OutputDevice* pDev,
705 : double nPPTX, double nPPTY,
706 : const Fraction& rZoomX, const Fraction& rZoomY,
707 : bool bWidth, bool bTotalSize );
708 : void SetColWidth( SCCOL nCol, sal_uInt16 nNewWidth );
709 : void SetColWidthOnly( SCCOL nCol, sal_uInt16 nNewWidth );
710 : void SetRowHeight( SCROW nRow, sal_uInt16 nNewHeight );
711 : bool SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight,
712 : double nPPTX, double nPPTY );
713 :
714 : /**
715 : * Set specified row height to specified ranges. Don't check for drawing
716 : * objects etc. Just set the row height. Nothing else.
717 : *
718 : * Note that setting a new row height via this function will not
719 : * invalidate page breaks.
720 : */
721 : void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight );
722 :
723 : // nPPT to test for modification
724 : void SetManualHeight( SCROW nStartRow, SCROW nEndRow, bool bManual );
725 :
726 : sal_uInt16 GetColWidth( SCCOL nCol, bool bHiddenAsZero = true ) const;
727 : sal_uLong GetColWidth( SCCOL nStartCol, SCCOL nEndCol, bool bHiddenAsZero = true ) const;
728 : SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow = NULL, SCROW* pEndRow = NULL, bool bHiddenAsZero = true ) const;
729 : sal_uLong GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true ) const;
730 : sal_uLong GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const;
731 : sal_uLong GetColOffset( SCCOL nCol, bool bHiddenAsZero = true ) const;
732 : sal_uLong GetRowOffset( SCROW nRow, bool bHiddenAsZero = true ) const;
733 :
734 : /**
735 : * Get the last row such that the height of row 0 to the end row is as
736 : * high as possible without exceeding the specified height value.
737 : *
738 : * @param nHeight maximum desired height
739 : *
740 : * @return SCROW last row of the range within specified height.
741 : */
742 : SCROW GetRowForHeight(sal_uLong nHeight) const;
743 :
744 : sal_uInt16 GetOriginalWidth( SCCOL nCol ) const;
745 : sal_uInt16 GetOriginalHeight( SCROW nRow ) const;
746 :
747 : sal_uInt16 GetCommonWidth( SCCOL nEndCol ) const;
748 :
749 : SCROW GetHiddenRowCount( SCROW nRow ) const;
750 :
751 : void ShowCol(SCCOL nCol, bool bShow);
752 : void ShowRow(SCROW nRow, bool bShow);
753 : void DBShowRow(SCROW nRow, bool bShow);
754 :
755 : void ShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
756 : void DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow);
757 :
758 : void SetRowFlags( SCROW nRow, sal_uInt8 nNewFlags );
759 : void SetRowFlags( SCROW nStartRow, SCROW nEndRow, sal_uInt8 nNewFlags );
760 :
761 : /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
762 : SCROW GetLastFlaggedRow() const;
763 :
764 : /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
765 : SCCOL GetLastChangedCol() const;
766 : /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
767 : SCROW GetLastChangedRow() const;
768 :
769 : bool IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SCROW nRowEnd) const;
770 : bool IsDataFiltered(const ScRange& rRange) const;
771 : sal_uInt8 GetColFlags( SCCOL nCol ) const;
772 : sal_uInt8 GetRowFlags( SCROW nRow ) const;
773 :
774 62 : const ScBitMaskCompressedArray< SCROW, sal_uInt8> * GetRowFlagsArray() const
775 62 : { return pRowFlags; }
776 :
777 : bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, bool bShow );
778 : bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, bool bShow );
779 :
780 : void UpdatePageBreaks( const ScRange* pUserArea );
781 : void RemoveManualBreaks();
782 : bool HasManualBreaks() const;
783 : void SetRowManualBreaks( const ::std::set<SCROW>& rBreaks );
784 : void SetColManualBreaks( const ::std::set<SCCOL>& rBreaks );
785 :
786 : void GetAllRowBreaks(::std::set<SCROW>& rBreaks, bool bPage, bool bManual) const;
787 : void GetAllColBreaks(::std::set<SCCOL>& rBreaks, bool bPage, bool bManual) const;
788 : bool HasRowPageBreak(SCROW nRow) const;
789 : bool HasColPageBreak(SCCOL nCol) const;
790 : bool HasRowManualBreak(SCROW nRow) const;
791 : bool HasColManualBreak(SCCOL nCol) const;
792 :
793 : /**
794 : * Get the row position of the next manual break that occurs at or below
795 : * specified row. When no more manual breaks are present at or below
796 : * the specified row, -1 is returned.
797 : *
798 : * @param nRow row at which the search begins.
799 : *
800 : * @return SCROW next row position with manual page break, or -1 if no
801 : * more manual breaks are present.
802 : */
803 : SCROW GetNextManualBreak(SCROW nRow) const;
804 :
805 : void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow);
806 : void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual);
807 : void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual);
808 : void SetRowBreak(SCROW nRow, bool bPage, bool bManual);
809 : void SetColBreak(SCCOL nCol, bool bPage, bool bManual);
810 : ::com::sun::star::uno::Sequence<
811 : ::com::sun::star::sheet::TablePageBreakData> GetRowBreakData() const;
812 :
813 : bool RowHidden(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL) const;
814 : bool RowHiddenLeaf(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL) const;
815 : bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const;
816 : bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL) const;
817 : bool SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden);
818 : bool SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden);
819 : void CopyColHidden(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
820 : void CopyRowHidden(ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
821 : void CopyRowHeight(ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset);
822 : SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
823 : SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
824 : SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const;
825 : sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true) const;
826 :
827 : SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const;
828 :
829 : bool RowFiltered(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL) const;
830 : bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL) const;
831 : bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const;
832 : void CopyColFiltered(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
833 : void CopyRowFiltered(ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
834 : void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered);
835 : void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered);
836 : SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const;
837 : SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const;
838 : SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const;
839 :
840 : bool IsManualRowHeight(SCROW nRow) const;
841 :
842 : bool HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const;
843 :
844 : void SyncColRowFlags();
845 :
846 : void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
847 : void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
848 :
849 : /** Sort a range of data. */
850 : void Sort(
851 : const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs,
852 : ScProgress* pProgress, sc::ReorderParam* pUndo );
853 :
854 : void Reorder( const sc::ReorderParam& rParam, ScProgress* pProgress );
855 :
856 : bool ValidQuery(
857 : SCROW nRow, const ScQueryParam& rQueryParam, ScRefCellValue* pCell = NULL,
858 : bool* pbTestEqualCondition = NULL);
859 : void TopTenQuery( ScQueryParam& );
860 : SCSIZE Query(ScQueryParam& rQueryParam, bool bKeepSub);
861 : bool CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
862 :
863 : void GetFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, std::vector<ScTypedStrData>& rStrings, bool& rHasDates);
864 : void GetFilteredFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScQueryParam& rParam, std::vector<ScTypedStrData>& rStrings, bool& rHasDates );
865 : bool GetDataEntries(SCCOL nCol, SCROW nRow, std::set<ScTypedStrData>& rStrings, bool bLimit);
866 :
867 : bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
868 : bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const;
869 :
870 : sal_Int32 GetMaxStringLen( SCCOL nCol,
871 : SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
872 : sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision,
873 : SCCOL nCol,
874 : SCROW nRowStart, SCROW nRowEnd ) const;
875 :
876 : bool IsSortCollatorGlobal() const;
877 : void InitSortCollator( const ScSortParam& rPar );
878 : void DestroySortCollator();
879 : void SetDrawPageSize( bool bResetStreamValid = true, bool bUpdateNoteCaptionPos = true );
880 :
881 : void SetRangeName(ScRangeName* pNew);
882 : ScRangeName* GetRangeName() const;
883 :
884 : void PreprocessRangeNameUpdate(
885 : sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
886 :
887 : void CompileHybridFormula(
888 : sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt );
889 :
890 : void PreprocessDBDataUpdate(
891 : sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
892 :
893 : ScConditionalFormatList* GetCondFormList();
894 : const ScConditionalFormatList* GetCondFormList() const;
895 : void SetCondFormList( ScConditionalFormatList* pList );
896 :
897 : void DeleteConditionalFormat(sal_uLong nOldIndex);
898 :
899 : sal_uLong AddCondFormat( ScConditionalFormat* pNew );
900 :
901 : SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow ) const;
902 : void SetScriptType( SCCOL nCol, SCROW nRow, SvtScriptType nType );
903 : void UpdateScriptTypes( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
904 :
905 : SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
906 :
907 : size_t GetFormulaHash( SCCOL nCol, SCROW nRow ) const;
908 :
909 : ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const;
910 : formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol, SCROW nRow );
911 : formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
912 : formula::VectorRefArray FetchVectorRefArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
913 :
914 : void SplitFormulaGroups( SCCOL nCol, std::vector<SCROW>& rRows );
915 : void UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows );
916 : void RegroupFormulaCells( SCCOL nCol );
917 :
918 : ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
919 :
920 : SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow );
921 : const SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow ) const;
922 : void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 );
923 : bool HasBroadcaster( SCCOL nCol ) const;
924 :
925 : void FillMatrix( ScMatrix& rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
926 :
927 : void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
928 :
929 : void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, size_t nLen );
930 : void SetFormulaResults( SCCOL nCol, SCROW nRow, const formula::FormulaTokenRef* pResults, size_t nLen );
931 :
932 : /**
933 : * Either start all formula cells as listeners unconditionally, or start
934 : * those that are marked "needs listening".
935 : *
936 : * @param rCxt context object.
937 : * @param bAll when true, start all formula cells as listeners. When
938 : * false, only start those that are marked "needs listening".
939 : */
940 : void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
941 :
942 : /**
943 : * Mark formula cells dirty that have the mbPostponedDirty flag set or
944 : * contain named ranges with relative references.
945 : */
946 : void SetDirtyIfPostponed();
947 :
948 : /**
949 : * Broadcast dirty formula cells that contain functions such as CELL(),
950 : * COLUMN() or ROW() which may change its value on move.
951 : */
952 : void BroadcastRecalcOnRefMove();
953 :
954 : void CollectListeners( std::vector<SvtListener*>& rListeners, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
955 :
956 : void TransferListeners(
957 : ScTable& rDestTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
958 : SCCOL nColDelta, SCROW nRowDelta );
959 :
960 : void TransferCellValuesTo( SCCOL nCol, SCROW nRow, size_t nLen, sc::CellValues& rDest );
961 : void CopyCellValuesFrom( SCCOL nCol, SCROW nRow, const sc::CellValues& rSrc );
962 :
963 : void ConvertFormulaToValue(
964 : sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
965 : sc::TableValues* pUndo );
966 :
967 : void SwapNonEmpty(
968 : sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
969 :
970 : #if DEBUG_COLUMN_STORAGE
971 : void DumpFormulaGroups( SCCOL nCol ) const;
972 : #endif
973 :
974 : /** Replace behaves differently to the Search; adjust the rCol and rRow accordingly.
975 :
976 : 'Replace' replaces at the 'current' position, but in order to achieve
977 : that, we have to 'shift' the rCol / rRow to the 'previous' position -
978 : what it is depends on various settings in rSearchItem.
979 : */
980 : static void UpdateSearchItemAddressForReplace( const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow );
981 :
982 : private:
983 :
984 : void FillFormulaVertical(
985 : const ScFormulaCell& rSrcCell,
986 : SCCOLROW& rInner, SCCOL nCol, SCROW nRow1, SCROW nRow2,
987 : ScProgress* pProgress, sal_uLong& rProgress );
988 :
989 : void FillSeriesSimple(
990 : ScCellValue& rSrcCell, SCCOLROW& rInner, SCCOLROW nIMin, SCCOLROW nIMax,
991 : SCCOLROW& rCol, SCCOLROW& rRow, bool bVertical, ScProgress* pProgress, sal_uLong& rProgress );
992 :
993 : void FillAutoSimple(
994 : SCCOLROW nISrcStart, SCCOLROW nISrcEnd, SCCOLROW nIStart, SCCOLROW nIEnd,
995 : SCCOLROW& rInner, SCCOLROW& rCol, SCCOLROW& rRow,
996 : sal_uLong nActFormCnt, sal_uLong nMaxFormCnt,
997 : bool bHasFiltered, bool bVertical, bool bPositive,
998 : ScProgress* pProgress, sal_uLong& rProgress );
999 :
1000 : void FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1001 : sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd,
1002 : FillDateCmd eFillDateCmd,
1003 : double nStepValue, double nMaxValue, sal_uInt16 nMinDigits,
1004 : bool bAttribs, ScProgress* pProgress );
1005 : void FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1006 : FillCmd& rCmd, FillDateCmd& rDateCmd,
1007 : double& rInc, sal_uInt16& rMinDigits,
1008 : ScUserListData*& rListData, sal_uInt16& rListIndex);
1009 : void FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1010 : sal_uLong nFillCount, FillDir eFillDir, ScProgress* pProgress );
1011 :
1012 : bool ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
1013 : bool bMarked, bool bUnprotected ) const;
1014 :
1015 : void AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1016 : const ScPatternAttr& rAttr, sal_uInt16 nFormatNo);
1017 : void GetAutoFormatAttr(SCCOL nCol, SCROW nRow, sal_uInt16 nIndex, ScAutoFormatData& rData);
1018 : void GetAutoFormatFrame(SCCOL nCol, SCROW nRow, sal_uInt16 nFlags, sal_uInt16 nIndex, ScAutoFormatData& rData);
1019 : bool SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRow,
1020 : const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1021 : bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1022 : const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1023 : bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1024 : const SCCOL& nLastCol, const SCROW& nLastRow,
1025 : const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1026 : bool SearchAll(const SvxSearchItem& rSearchItem, const ScMarkData& rMark,
1027 : ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1028 : bool Replace(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1029 : const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc);
1030 : bool ReplaceAll(
1031 : const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1032 : OUString& rUndoStr, ScDocument* pUndoDoc);
1033 :
1034 : bool SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1035 : const ScMarkData& rMark);
1036 : bool ReplaceStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1037 : const ScMarkData& rMark, bool bIsUndo);
1038 : bool SearchAllStyle(
1039 : const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges);
1040 : bool ReplaceAllStyle(
1041 : const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1042 : ScDocument* pUndoDoc);
1043 : bool SearchAndReplaceEmptyCells(
1044 : const SvxSearchItem& rSearchItem,
1045 : SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark, ScRangeList& rMatchedRanges,
1046 : OUString& rUndoStr, ScDocument* pUndoDoc);
1047 : bool SearchRangeForEmptyCell(const ScRange& rRange,
1048 : const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
1049 : OUString& rUndoStr);
1050 : bool SearchRangeForAllEmptyCells(
1051 : const ScRange& rRange, const SvxSearchItem& rSearchItem,
1052 : ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc);
1053 :
1054 : // use the global sort parameter:
1055 : bool IsSorted(SCCOLROW nStart, SCCOLROW nEnd) const;
1056 : static void DecoladeRow( ScSortInfoArray*, SCROW nRow1, SCROW nRow2 );
1057 : short CompareCell(
1058 : sal_uInt16 nSort,
1059 : ScRefCellValue& rCell1, SCCOL nCell1Col, SCROW nCell1Row,
1060 : ScRefCellValue& rCell2, SCCOL nCell2Col, SCROW nCell2Row ) const;
1061 : short Compare(SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1062 : short Compare( ScSortInfoArray*, SCCOLROW nIndex1, SCCOLROW nIndex2) const;
1063 : ScSortInfoArray* CreateSortInfoArray( const sc::ReorderParam& rParam );
1064 : ScSortInfoArray* CreateSortInfoArray(
1065 : const ScSortParam& rSortParam, SCCOLROW nInd1, SCCOLROW nInd2,
1066 : bool bKeepQuery, bool bUpdateRefs );
1067 : void QuickSort( ScSortInfoArray*, SCsCOLROW nLo, SCsCOLROW nHi);
1068 : void SortReorderByColumn( ScSortInfoArray* pArray, SCROW nRow1, SCROW nRow2, bool bPattern, ScProgress* pProgress );
1069 :
1070 : void SortReorderByRow( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress );
1071 : void SortReorderByRowRefUpdate( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress );
1072 :
1073 : bool CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1074 : bool CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
1075 : void GetUpperCellString(SCCOL nCol, SCROW nRow, OUString& rStr);
1076 :
1077 : bool RefVisible(ScFormulaCell* pCell);
1078 :
1079 : bool IsEmptyLine(SCROW nRow, SCCOL nStartCol, SCCOL nEndCol) const;
1080 :
1081 : void IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillDateCmd eCmd);
1082 : void FillFormula(
1083 : ScFormulaCell* pSrcCell, SCCOL nDestCol, SCROW nDestRow, bool bLast );
1084 : void UpdateInsertTabAbs(SCTAB nNewPos);
1085 : bool GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, bool bInSel,
1086 : const ScMarkData& rMark) const;
1087 : bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark ) const;
1088 : bool TestTabRefAbs(SCTAB nTable) const;
1089 : void CompileDBFormula( sc::CompileFormulaContext& rCxt );
1090 : void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt );
1091 :
1092 : void StartListening( const ScAddress& rAddress, SvtListener* pListener );
1093 : void EndListening( const ScAddress& rAddress, SvtListener* pListener );
1094 : void StartListening( sc::StartListeningContext& rCxt, SCCOL nCol, SCROW nRow, SvtListener& rListener );
1095 : void EndListening( sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow, SvtListener& rListener );
1096 :
1097 : void AttachFormulaCells( sc::StartListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1098 : void DetachFormulaCells( sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
1099 :
1100 : void SetLoadingMedium(bool bLoading);
1101 :
1102 : SCSIZE FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2,
1103 : SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY,
1104 : const ScPatternAttr* pPattern, const SfxItemSet* pCondSet );
1105 :
1106 : // idle calculation of OutputDevice text width for cell
1107 : // also invalidates script type, broadcasts for "calc as shown"
1108 : void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
1109 : bool bNumFormatChanged, bool bBroadcast );
1110 :
1111 : void SkipFilteredRows(SCROW& rRow, SCROW& rLastNonFilteredRow, bool bForward);
1112 :
1113 : /**
1114 : * In case the cell text goes beyond the column width, move the max column
1115 : * position to the right. This is called from ExtendPrintArea.
1116 : */
1117 : void MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY);
1118 :
1119 : void CopyPrintRange(const ScTable& rTable);
1120 :
1121 : SCCOL FindNextVisibleColWithContent(SCCOL nCol, bool bRight, SCROW nRow) const;
1122 :
1123 : SCCOL FindNextVisibleCol(SCCOL nCol, bool bRight) const;
1124 :
1125 : // Clipboard transpose for notes
1126 : void TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1, SCROW nRow2);
1127 :
1128 : ScColumn* FetchColumn( SCCOL nCol );
1129 : const ScColumn* FetchColumn( SCCOL nCol ) const;
1130 :
1131 : void EndListeningIntersectedGroup(
1132 : sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow, std::vector<ScAddress>* pGroupPos = NULL );
1133 :
1134 : void EndListeningIntersectedGroups(
1135 : sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1136 : std::vector<ScAddress>* pGroupPos = NULL );
1137 :
1138 : void EndListeningGroup( sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow );
1139 : void SetNeedsListeningGroup( SCCOL nCol, SCROW nRow );
1140 :
1141 : /**
1142 : * Use this to iterate through non-empty visible cells in a single column.
1143 : */
1144 : class VisibleDataCellIterator
1145 : {
1146 : public:
1147 : static SCROW ROW_NOT_FOUND;
1148 :
1149 : explicit VisibleDataCellIterator(ScFlatBoolRowSegments& rRowSegs, ScColumn& rColumn);
1150 : ~VisibleDataCellIterator();
1151 :
1152 : /**
1153 : * Set the start row position. In case there is not visible data cell
1154 : * at the specified row position, it will move to the position of the
1155 : * first visible data cell below that point.
1156 : *
1157 : * @return First visible data cell if found, or NULL otherwise.
1158 : */
1159 : ScRefCellValue reset(SCROW nRow);
1160 :
1161 : /**
1162 : * Find the next visible data cell position.
1163 : *
1164 : * @return Next visible data cell if found, or NULL otherwise.
1165 : */
1166 : ScRefCellValue next();
1167 :
1168 : /**
1169 : * Get the current row position.
1170 : *
1171 : * @return Current row position, or ROW_NOT_FOUND if the iterator
1172 : * doesn't point to a valid data cell position.
1173 : */
1174 48 : SCROW getRow() const { return mnCurRow;}
1175 :
1176 : private:
1177 : ScFlatBoolRowSegments& mrRowSegs;
1178 : ScColumn& mrColumn;
1179 : ScRefCellValue maCell;
1180 : SCROW mnCurRow;
1181 : SCROW mnUBound;
1182 : };
1183 :
1184 : };
1185 :
1186 : #endif
1187 :
1188 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|