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