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