merge the formfield patch from ooo-build
[ooovba.git] / sc / inc / table.hxx
blobb8fd37b0600e60ce011545b8fe3c650cd2ccfeba
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: table.hxx,v $
10 * $Revision: 1.35.126.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_TABLE_HXX
32 #define SC_TABLE_HXX
34 #include <vector>
35 #include <memory>
36 #include <utility>
37 #include <tools/gen.hxx>
38 #include <tools/color.hxx>
39 #include <com/sun/star/uno/Sequence.hxx>
40 #include "column.hxx"
41 #include "sortparam.hxx"
42 #include "compressedarray.hxx"
44 #include <memory>
45 #include <set>
46 #include <boost/shared_ptr.hpp>
48 namespace utl {
49 class SearchParam;
50 class TextSearch;
53 namespace com { namespace sun { namespace star {
54 namespace sheet {
55 struct TablePageBreakData;
57 } } }
59 class SfxItemSet;
60 class SfxStyleSheetBase;
61 class SvxBoxInfoItem;
62 class SvxBoxItem;
63 class SvxSearchItem;
65 class ScAutoFormat;
66 class ScAutoFormatData;
67 class ScBaseCell;
68 class ScDocument;
69 class ScDrawLayer;
70 class ScEditDataArray;
71 class ScFormulaCell;
72 class ScOutlineTable;
73 class ScPostIt;
74 class ScPrintSaverTab;
75 class ScProgress;
76 class ScProgress;
77 class ScRangeList;
78 class ScSortInfoArray;
79 class ScStyleSheet;
80 class ScTableLink;
81 class ScTableProtection;
82 class ScUserListData;
83 struct RowInfo;
84 struct ScFunctionData;
85 struct ScLineFlags;
86 class CollatorWrapper;
87 struct ScSetStringParam;
88 class ScFlatBoolRowSegments;
89 class ScFlatBoolColSegments;
91 class ScTable
93 private:
94 typedef ::std::vector< ScRange > ScRangeVec;
95 typedef ::std::pair< SCCOL, SCROW > ScAddress2D;
96 typedef ::std::vector< ScAddress2D > ScAddress2DVec;
97 typedef ::std::auto_ptr< ScAddress2DVec > ScAddress2DVecPtr;
99 // Daten pro Tabelle ------------------
100 ScColumn aCol[MAXCOLCOUNT];
102 String aName;
103 String aCodeName;
104 String aComment;
105 BOOL bScenario;
106 BOOL bLayoutRTL;
107 BOOL bLoadingRTL;
109 String aLinkDoc;
110 String aLinkFlt;
111 String aLinkOpt;
112 String aLinkTab;
113 ULONG nLinkRefreshDelay;
114 BYTE nLinkMode;
116 // Seitenformatvorlage
117 String aPageStyle;
118 BOOL bPageSizeValid;
119 Size aPageSizeTwips; // Groesse der Druck-Seite
120 SCCOL nRepeatStartX; // Wiederholungszeilen/Spalten
121 SCCOL nRepeatEndX; // REPEAT_NONE, wenn nicht benutzt
122 SCROW nRepeatStartY;
123 SCROW nRepeatEndY;
125 ::std::auto_ptr<ScTableProtection> pTabProtection;
127 USHORT* pColWidth;
128 ScSummableCompressedArray< SCROW, USHORT>* pRowHeight;
130 BYTE* pColFlags;
131 ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags;
132 ::boost::shared_ptr<ScFlatBoolColSegments> mpHiddenCols;
133 ::boost::shared_ptr<ScFlatBoolRowSegments> mpHiddenRows;
134 ::boost::shared_ptr<ScFlatBoolColSegments> mpFilteredCols;
135 ::boost::shared_ptr<ScFlatBoolRowSegments> mpFilteredRows;
137 ::std::set<SCROW> maRowPageBreaks;
138 ::std::set<SCROW> maRowManualBreaks;
139 ::std::set<SCCOL> maColPageBreaks;
140 ::std::set<SCCOL> maColManualBreaks;
142 ScOutlineTable* pOutlineTable;
144 SCCOL nTableAreaX;
145 SCROW nTableAreaY;
146 BOOL bTableAreaValid;
148 // interne Verwaltung ------------------
149 BOOL bVisible;
150 BOOL bStreamValid;
151 BOOL bPendingRowHeights;
153 SCTAB nTab;
154 USHORT nRecalcLvl; // Rekursionslevel Size-Recalc
155 ScDocument* pDocument;
156 utl::SearchParam* pSearchParam;
157 utl::TextSearch* pSearchText;
159 mutable String aUpperName; // #i62977# filled only on demand, reset in SetName
161 ScAddress2DVecPtr mxUninitNotes;
163 // SortierParameter um den Stackbedarf von Quicksort zu Minimieren
164 ScSortParam aSortParam;
165 CollatorWrapper* pSortCollator;
166 BOOL bGlobalKeepQuery;
167 BOOL bSharedNameInserted;
169 ScRangeVec aPrintRanges;
170 BOOL bPrintEntireSheet;
172 ScRange* pRepeatColRange;
173 ScRange* pRepeatRowRange;
175 USHORT nLockCount;
177 ScRangeList* pScenarioRanges;
178 Color aScenarioColor;
179 USHORT nScenarioFlags;
180 BOOL bActiveScenario;
181 bool mbPageBreaksValid;
183 friend class ScDocument; // fuer FillInfo
184 friend class ScDocumentIterator;
185 friend class ScValueIterator;
186 friend class ScDBQueryDataIterator;
187 friend class ScCellIterator;
188 friend class ScQueryCellIterator;
189 friend class ScHorizontalCellIterator;
190 friend class ScHorizontalAttrIterator;
191 friend class ScDocAttrIterator;
192 friend class ScAttrRectIterator;
195 public:
196 ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName,
197 BOOL bColInfo = TRUE, BOOL bRowInfo = TRUE );
198 ~ScTable();
200 ScOutlineTable* GetOutlineTable() { return pOutlineTable; }
202 ULONG GetCellCount() const;
203 ULONG GetWeightedCount() const;
204 ULONG GetCodeCount() const; // RPN-Code in Formeln
206 BOOL SetOutlineTable( const ScOutlineTable* pNewOutline );
207 void StartOutlineTable();
209 void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
211 BOOL TestRemoveSubTotals( const ScSubTotalParam& rParam );
212 void RemoveSubTotals( ScSubTotalParam& rParam );
213 BOOL DoSubTotals( ScSubTotalParam& rParam );
215 BOOL IsVisible() const { return bVisible; }
216 void SetVisible( BOOL bVis );
218 BOOL IsStreamValid() const { return bStreamValid; }
219 void SetStreamValid( BOOL bSet, BOOL bIgnoreLock = FALSE );
221 BOOL IsPendingRowHeights() const { return bPendingRowHeights; }
222 void SetPendingRowHeights( BOOL bSet );
224 BOOL IsLayoutRTL() const { return bLayoutRTL; }
225 BOOL IsLoadingRTL() const { return bLoadingRTL; }
226 void SetLayoutRTL( BOOL bSet );
227 void SetLoadingRTL( BOOL bSet );
229 BOOL IsScenario() const { return bScenario; }
230 void SetScenario( BOOL bFlag );
231 void GetScenarioComment( String& rComment) const { rComment = aComment; }
232 void SetScenarioComment( const String& rComment ) { aComment = rComment; }
233 const Color& GetScenarioColor() const { return aScenarioColor; }
234 void SetScenarioColor(const Color& rNew) { aScenarioColor = rNew; }
235 USHORT GetScenarioFlags() const { return nScenarioFlags; }
236 void SetScenarioFlags(USHORT nNew) { nScenarioFlags = nNew; }
237 void SetActiveScenario(BOOL bSet) { bActiveScenario = bSet; }
238 BOOL IsActiveScenario() const { return bActiveScenario; }
240 BYTE GetLinkMode() const { return nLinkMode; }
241 BOOL IsLinked() const { return nLinkMode != SC_LINK_NONE; }
242 const String& GetLinkDoc() const { return aLinkDoc; }
243 const String& GetLinkFlt() const { return aLinkFlt; }
244 const String& GetLinkOpt() const { return aLinkOpt; }
245 const String& GetLinkTab() const { return aLinkTab; }
246 ULONG GetLinkRefreshDelay() const { return nLinkRefreshDelay; }
248 void SetLink( BYTE nMode, const String& rDoc, const String& rFlt,
249 const String& rOpt, const String& rTab, ULONG nRefreshDelay );
251 void GetName( String& rName ) const;
252 void SetName( const String& rNewName );
254 void GetCodeName( String& rName ) const { rName = aCodeName; }
255 void SetCodeName( const String& rNewName ) { aCodeName = rNewName; }
257 const String& GetUpperName() const;
259 const String& GetPageStyle() const { return aPageStyle; }
260 void SetPageStyle( const String& rName );
261 void PageStyleModified( const String& rNewName );
263 BOOL IsProtected() const;
264 void SetProtection(const ScTableProtection* pProtect);
265 ScTableProtection* GetProtection();
267 Size GetPageSize() const;
268 void SetPageSize( const Size& rSize );
269 void SetRepeatArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
271 void RemoveAutoSpellObj();
273 void LockTable();
274 void UnlockTable();
276 BOOL IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2,
277 SCROW nRow2, BOOL* pOnlyNotBecauseOfMatrix = NULL ) const;
278 BOOL IsSelectionEditable( const ScMarkData& rMark,
279 BOOL* pOnlyNotBecauseOfMatrix = NULL ) const;
281 BOOL HasBlockMatrixFragment( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
282 BOOL HasSelectionMatrixFragment( const ScMarkData& rMark ) const;
284 BOOL IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bIgnoreNotes = false ) const;
286 void PutCell( const ScAddress&, ScBaseCell* pCell );
287 //UNUSED2009-05 void PutCell( const ScAddress&, ULONG nFormatIndex, ScBaseCell* pCell);
288 void PutCell( SCCOL nCol, SCROW nRow, ScBaseCell* pCell );
289 void PutCell(SCCOL nCol, SCROW nRow, ULONG nFormatIndex, ScBaseCell* pCell);
290 // TRUE = Zahlformat gesetzt
291 BOOL SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString,
292 ScSetStringParam* pParam = NULL );
293 void SetValue( SCCOL nCol, SCROW nRow, const double& rVal );
294 void SetError( SCCOL nCol, SCROW nRow, USHORT nError);
296 void GetString( SCCOL nCol, SCROW nRow, String& rString );
297 void GetInputString( SCCOL nCol, SCROW nRow, String& rString );
298 double GetValue( const ScAddress& rPos ) const
300 return ValidColRow(rPos.Col(),rPos.Row()) ?
301 aCol[rPos.Col()].GetValue( rPos.Row() ) :
302 0.0;
304 double GetValue( SCCOL nCol, SCROW nRow );
305 void GetFormula( SCCOL nCol, SCROW nRow, String& rFormula,
306 BOOL bAsciiExport = FALSE );
308 CellType GetCellType( const ScAddress& rPos ) const
310 return ValidColRow(rPos.Col(),rPos.Row()) ?
311 aCol[rPos.Col()].GetCellType( rPos.Row() ) :
312 CELLTYPE_NONE;
314 CellType GetCellType( SCCOL nCol, SCROW nRow ) const;
315 ScBaseCell* GetCell( const ScAddress& rPos ) const
317 return ValidColRow(rPos.Col(),rPos.Row()) ?
318 aCol[rPos.Col()].GetCell( rPos.Row() ) :
319 NULL;
321 ScBaseCell* GetCell( SCCOL nCol, SCROW nRow ) const;
323 void GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const;
324 void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const;
326 /** Returns the pointer to a cell note object at the passed cell address. */
327 ScPostIt* GetNote( SCCOL nCol, SCROW nRow );
328 /** Sets the passed cell note object at the passed cell address. Takes ownership! */
329 void TakeNote( SCCOL nCol, SCROW nRow, ScPostIt*& rpNote );
330 /** Returns and forgets the cell note object at the passed cell address. */
331 ScPostIt* ReleaseNote( SCCOL nCol, SCROW nRow );
332 /** Deletes the note at the passed cell address. */
333 void DeleteNote( SCCOL nCol, SCROW nRow );
334 /** Creates the captions of all uninitialized cell notes.
335 @param bForced True = always create all captions, false = skip when Undo is disabled. */
336 void InitializeNoteCaptions( bool bForced = false );
338 BOOL TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCSIZE nSize );
339 void InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize );
340 void DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize,
341 BOOL* pUndoOutline = NULL );
343 BOOL TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize );
344 void InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize );
345 void DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize,
346 BOOL* pUndoOutline = NULL );
348 void DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, USHORT nDelFlag);
349 void CopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTable,
350 BOOL bKeepScenarioFlags, BOOL bCloneNoteCaptions);
351 void CopyToClip(const ScRangeList& rRanges, ScTable* pTable,
352 bool bKeepScenarioFlags, bool bCloneNoteCaptions);
353 void CopyFromClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCsCOL nDx, SCsROW nDy,
354 USHORT nInsFlag, BOOL bAsLink, BOOL bSkipAttrForEmpty, ScTable* pTable);
355 void StartListeningInArea( SCCOL nCol1, SCROW nRow1,
356 SCCOL nCol2, SCROW nRow2 );
357 void BroadcastInArea( SCCOL nCol1, SCROW nRow1,
358 SCCOL nCol2, SCROW nRow2 );
360 void CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
361 USHORT nFlags, BOOL bMarked, ScTable* pDestTab,
362 const ScMarkData* pMarkData = NULL,
363 BOOL bAsLink = FALSE, BOOL bColRowFlags = TRUE);
364 void UndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
365 USHORT nFlags, BOOL bMarked, ScTable* pDestTab,
366 const ScMarkData* pMarkData = NULL);
368 void TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
369 ScTable* pTransClip, USHORT nFlags, BOOL bAsLink );
371 // Markierung von diesem Dokument
372 void MixMarked( const ScMarkData& rMark, USHORT nFunction,
373 BOOL bSkipEmpty, ScTable* pSrcTab );
374 void MixData( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
375 USHORT nFunction, BOOL bSkipEmpty, ScTable* pSrcTab );
377 void CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
378 SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab );
380 void CopyScenarioFrom( const ScTable* pSrcTab );
381 void CopyScenarioTo( ScTable* pDestTab ) const;
382 BOOL TestCopyScenarioTo( const ScTable* pDestTab ) const;
383 void MarkScenarioIn( ScMarkData& rMark, USHORT nNeededBits ) const;
384 BOOL HasScenarioRange( const ScRange& rRange ) const;
385 void InvalidateScenarioRanges();
386 const ScRangeList* GetScenarioRanges() const;
388 void CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const;
390 void InvalidateTableArea();
391 void InvalidatePageBreaks();
393 BOOL GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const; // FALSE = leer
394 BOOL GetTableArea( SCCOL& rEndCol, SCROW& rEndRow ) const;
395 BOOL GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, BOOL bNotes ) const;
396 BOOL GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow,
397 SCCOL& rEndCol, BOOL bNotes ) const;
398 BOOL GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
399 SCROW& rEndRow, BOOL bNotes ) const;
401 BOOL GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const;
403 void ExtendPrintArea( OutputDevice* pDev,
404 SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow );
406 void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
407 BOOL bIncludeOld ) const;
409 SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
410 SCCOL nEndCol, SCROW nEndRow, ScDirection eDir );
412 void FindAreaPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY );
413 void GetNextPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY,
414 BOOL bMarked, BOOL bUnprotected, const ScMarkData& rMark );
416 void LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow );
418 BOOL HasData( SCCOL nCol, SCROW nRow );
419 BOOL HasStringData( SCCOL nCol, SCROW nRow );
420 BOOL HasValueData( SCCOL nCol, SCROW nRow );
421 //UNUSED2008-05 USHORT GetErrorData(SCCOL nCol, SCROW nRow) const;
422 BOOL HasStringCells( SCCOL nStartCol, SCROW nStartRow,
423 SCCOL nEndCol, SCROW nEndRow ) const;
425 USHORT GetErrCode( const ScAddress& rPos ) const
427 return ValidColRow(rPos.Col(),rPos.Row()) ?
428 aCol[rPos.Col()].GetErrCode( rPos.Row() ) :
431 //UNUSED2008-05 USHORT GetErrCode( SCCOL nCol, SCROW nRow ) const;
433 void ResetChanged( const ScRange& rRange );
435 void SetDirty();
436 void SetDirty( const ScRange& );
437 void SetDirtyAfterLoad();
438 void SetDirtyVar();
439 void SetTableOpDirty( const ScRange& );
440 void CalcAll();
441 void CalcAfterLoad();
442 void CompileAll();
443 void CompileXML( ScProgress& rProgress );
444 bool MarkUsedExternalReferences();
446 void UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
447 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
448 SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
449 ScDocument* pUndoDoc = NULL, BOOL bIncludeDraw = TRUE );
451 void UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
452 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
453 SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
455 void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
456 ScDocument* pUndoDoc );
458 void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
460 void UpdateInsertTab(SCTAB nTable);
461 //UNUSED2008-05 void UpdateInsertTabOnlyCells(SCTAB nTable);
462 void UpdateDeleteTab( SCTAB nTable, BOOL bIsMove, ScTable* pRefUndo = NULL );
463 void UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo, ScProgress& );
464 void UpdateCompile( BOOL bForceIfNameInUse = FALSE );
465 void SetTabNo(SCTAB nNewTab);
466 BOOL IsRangeNameInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
467 USHORT nIndex) const;
468 void FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
469 std::set<USHORT>& rIndexes) const;
470 void ReplaceRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
471 const ScRangeData::IndexMap& rMap );
472 void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
473 ULONG nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
474 double nStepValue, double nMaxValue);
475 String GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY );
477 void UpdateSelectionFunction( ScFunctionData& rData,
478 SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
479 const ScMarkData& rMark );
481 void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
482 USHORT nFormatNo );
483 void GetAutoFormatData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData& rData);
484 void ScReplaceTabsStr( String& rStr, const String& rSrch, const String& rRepl ); // aus sw
485 BOOL SearchAndReplace(const SvxSearchItem& rSearchItem,
486 SCCOL& rCol, SCROW& rRow, ScMarkData& rMark,
487 String& rUndoStr, ScDocument* pUndoDoc);
489 void FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 );
491 void GetBorderLines( SCCOL nCol, SCROW nRow,
492 const SvxBorderLine** ppLeft, const SvxBorderLine** ppTop,
493 const SvxBorderLine** ppRight, const SvxBorderLine** ppBottom ) const;
495 //UNUSED2009-05 BOOL HasLines( const ScRange& rRange, Rectangle& rSizes ) const;
496 BOOL HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, USHORT nMask ) const;
497 BOOL HasAttribSelection( const ScMarkData& rMark, USHORT nMask ) const;
498 BOOL ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
499 SCCOL& rEndCol, SCROW& rEndRow,
500 BOOL bRefresh, BOOL bAttrs );
501 const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, USHORT nWhich ) const;
502 const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow ) const;
503 const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
505 ULONG GetNumberFormat( const ScAddress& rPos ) const
507 return ValidColRow(rPos.Col(),rPos.Row()) ?
508 aCol[rPos.Col()].GetNumberFormat( rPos.Row() ) :
511 ULONG GetNumberFormat( SCCOL nCol, SCROW nRow ) const;
512 sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
513 void MergeSelectionPattern( ScMergePatternState& rState,
514 const ScMarkData& rMark, BOOL bDeep ) const;
515 void MergePatternArea( ScMergePatternState& rState, SCCOL nCol1, SCROW nRow1,
516 SCCOL nCol2, SCROW nRow2, BOOL bDeep ) const;
517 void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
518 ScLineFlags& rFlags,
519 SCCOL nStartCol, SCROW nStartRow,
520 SCCOL nEndCol, SCROW nEndRow ) const;
521 void ApplyBlockFrame( const SvxBoxItem* pLineOuter,
522 const SvxBoxInfoItem* pLineInner,
523 SCCOL nStartCol, SCROW nStartRow,
524 SCCOL nEndCol, SCROW nEndRow );
526 void ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr );
527 void ApplyPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
528 void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
529 const ScPatternAttr& rAttr, ScEditDataArray* pDataArray = NULL );
530 void SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr, BOOL bPutToPool = FALSE )
532 if (ValidColRow(rPos.Col(),rPos.Row()))
533 aCol[rPos.Col()].SetPattern( rPos.Row(), rAttr, bPutToPool );
535 void SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr, BOOL bPutToPool = FALSE );
536 void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
537 const ScPatternAttr& rPattern, short nNewType );
539 void ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet& rStyle );
540 void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle );
541 void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
542 void ApplySelectionLineStyle( const ScMarkData& rMark,
543 const SvxBorderLine* pLine, BOOL bColorOnly );
545 const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow ) const;
546 const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, BOOL& rFound ) const;
547 const ScStyleSheet* GetAreaStyle( BOOL& rFound, SCCOL nCol1, SCROW nRow1,
548 SCCOL nCol2, SCROW nRow2 ) const;
550 void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, BOOL bRemoved,
551 OutputDevice* pDev,
552 double nPPTX, double nPPTY,
553 const Fraction& rZoomX, const Fraction& rZoomY );
555 BOOL IsStyleSheetUsed( const ScStyleSheet& rStyle, BOOL bGatherAllStyles ) const;
557 BOOL ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, INT16 nFlags );
558 BOOL RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, INT16 nFlags );
560 void ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = NULL );
561 void DeleteSelection( USHORT nDelFlag, const ScMarkData& rMark );
563 void ClearSelectionItems( const USHORT* pWhich, const ScMarkData& rMark );
564 void ChangeSelectionIndent( BOOL bIncrement, const ScMarkData& rMark );
566 const ScRange* GetRepeatColRange() const { return pRepeatColRange; }
567 const ScRange* GetRepeatRowRange() const { return pRepeatRowRange; }
568 void SetRepeatColRange( const ScRange* pNew );
569 void SetRepeatRowRange( const ScRange* pNew );
571 USHORT GetPrintRangeCount() const { return static_cast< USHORT >( aPrintRanges.size() ); }
572 const ScRange* GetPrintRange(USHORT nPos) const;
573 /** Returns true, if the sheet is always printed. */
574 BOOL IsPrintEntireSheet() const { return bPrintEntireSheet; }
576 /** Removes all print ranges. */
577 void ClearPrintRanges();
578 /** Adds a new print ranges. */
579 void AddPrintRange( const ScRange& rNew );
580 //UNUSED2009-05 /** Removes all old print ranges and sets the passed print ranges. */
581 //UNUSED2009-05 void SetPrintRange( const ScRange& rNew );
582 /** Marks the specified sheet to be printed completely. Deletes old print ranges! */
583 void SetPrintEntireSheet();
585 void FillPrintSaver( ScPrintSaverTab& rSaveTab ) const;
586 void RestorePrintRanges( const ScPrintSaverTab& rSaveTab );
588 USHORT GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev,
589 double nPPTX, double nPPTY,
590 const Fraction& rZoomX, const Fraction& rZoomY,
591 BOOL bFormula, const ScMarkData* pMarkData,
592 BOOL bSimpleTextImport );
593 BOOL SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, USHORT nExtra,
594 OutputDevice* pDev,
595 double nPPTX, double nPPTY,
596 const Fraction& rZoomX, const Fraction& rZoomY,
597 BOOL bForce,
598 ScProgress* pOuterProgress = NULL, ULONG nProgressStart = 0 );
599 long GetNeededSize( SCCOL nCol, SCROW nRow,
600 OutputDevice* pDev,
601 double nPPTX, double nPPTY,
602 const Fraction& rZoomX, const Fraction& rZoomY,
603 BOOL bWidth, BOOL bTotalSize );
604 void SetColWidth( SCCOL nCol, USHORT nNewWidth );
605 void SetRowHeight( SCROW nRow, USHORT nNewHeight );
606 BOOL SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeight,
607 double nPPTX, double nPPTY );
608 // nPPT fuer Test auf Veraenderung
609 void SetManualHeight( SCROW nStartRow, SCROW nEndRow, BOOL bManual );
611 USHORT GetColWidth( SCCOL nCol );
612 SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow );
613 ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow );
614 ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale );
615 ULONG GetColOffset( SCCOL nCol );
616 ULONG GetRowOffset( SCROW nRow );
618 /**
619 * Get the last row such that the height of row 0 to the end row is as
620 * high as possible without exceeding the specified height value.
622 * @param nHeight maximum desired height
624 * @return SCROW last row of the range within specified height.
626 SCROW GetRowForHeight(ULONG nHeight);
628 USHORT GetOriginalWidth( SCCOL nCol ) const;
629 USHORT GetOriginalHeight( SCROW nRow ) const;
631 USHORT GetCommonWidth( SCCOL nEndCol );
633 SCROW GetHiddenRowCount( SCROW nRow );
635 void ShowCol(SCCOL nCol, BOOL bShow);
636 void ShowRow(SCROW nRow, BOOL bShow);
637 void DBShowRow(SCROW nRow, BOOL bShow);
639 void ShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow);
640 void DBShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow);
642 void SetColFlags( SCCOL nCol, BYTE nNewFlags );
643 void SetRowFlags( SCROW nRow, BYTE nNewFlags );
644 void SetRowFlags( SCROW nStartRow, SCROW nEndRow, BYTE nNewFlags );
646 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
647 SCROW GetLastFlaggedRow() const;
649 /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored).
650 SCCOL GetLastChangedCol() const;
651 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
652 SCROW GetLastChangedRow() const;
654 BYTE GetColFlags( SCCOL nCol ) const;
655 BYTE GetRowFlags( SCROW nRow ) const;
657 const ScBitMaskCompressedArray< SCROW, BYTE> * GetRowFlagsArray() const
658 { return pRowFlags; }
659 const ScSummableCompressedArray< SCROW, USHORT> * GetRowHeightArray() const
660 { return pRowHeight; }
662 BOOL UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, BOOL bShow );
663 BOOL UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, BOOL bShow );
665 void UpdatePageBreaks( const ScRange* pUserArea );
666 void RemoveManualBreaks();
667 BOOL HasManualBreaks() const;
669 void GetAllRowBreaks(::std::set<SCROW>& rBreaks, bool bPage, bool bManual) const;
670 void GetAllColBreaks(::std::set<SCCOL>& rBreaks, bool bPage, bool bManual) const;
671 bool HasRowPageBreak(SCROW nRow) const;
672 bool HasColPageBreak(SCCOL nCol) const;
673 bool HasRowManualBreak(SCROW nRow) const;
674 bool HasColManualBreak(SCCOL nCol) const;
675 void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow);
676 void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual);
677 void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual);
678 void SetRowBreak(SCROW nRow, bool bPage, bool bManual);
679 void SetColBreak(SCCOL nCol, bool bPage, bool bManual);
680 ::com::sun::star::uno::Sequence<
681 ::com::sun::star::sheet::TablePageBreakData> GetRowBreakData() const;
683 bool RowHidden(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL);
684 bool RowHidden(SCROW nRow, SCROW& rLastRow);
685 bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow);
686 bool ColHidden(SCCOL nCol, SCCOL& rLastCol);
687 bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL);
688 void SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden);
689 void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden);
690 void CopyColHidden(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
691 void CopyRowHidden(ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
692 SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow);
693 SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow);
694 SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow);
695 sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow);
697 SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol);
699 bool RowFiltered(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL);
700 bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL);
701 bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow);
702 void CopyColFiltered(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
703 void CopyRowFiltered(ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
704 void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered);
705 void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered);
706 SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow);
707 SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow);
708 SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow);
710 void SyncColRowFlags();
712 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
713 void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
715 void Sort(const ScSortParam& rSortParam, BOOL bKeepQuery);
716 BOOL ValidQuery(SCROW nRow, const ScQueryParam& rQueryParam,
717 BOOL* pSpecial = NULL, ScBaseCell* pCell = NULL,
718 BOOL* pbTestEqualCondition = NULL );
719 void TopTenQuery( ScQueryParam& );
720 SCSIZE Query(ScQueryParam& rQueryParam, BOOL bKeepSub);
721 BOOL CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
723 void GetFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, TypedScStrCollection& rStrings, bool& rHasDates);
724 void GetFilteredFilterEntries( SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScQueryParam& rParam, TypedScStrCollection& rStrings, bool& rHasDates );
725 BOOL GetDataEntries(SCCOL nCol, SCROW nRow, TypedScStrCollection& rStrings, BOOL bLimit);
727 BOOL HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
728 BOOL HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
730 void DoColResize( SCCOL nCol1, SCCOL nCol2, SCSIZE nAdd );
732 sal_Int32 GetMaxStringLen( SCCOL nCol,
733 SCROW nRowStart, SCROW nRowEnd, CharSet eCharSet ) const;
734 xub_StrLen GetMaxNumberStringLen( USHORT& nPrecision,
735 SCCOL nCol,
736 SCROW nRowStart, SCROW nRowEnd ) const;
738 void FindConditionalFormat( ULONG nKey, ScRangeList& rRanges );
740 void IncRecalcLevel() { ++nRecalcLvl; }
741 void DecRecalcLevel() { if (!--nRecalcLvl) SetDrawPageSize(); }
743 BOOL IsSortCollatorGlobal() const;
744 void InitSortCollator( const ScSortParam& rPar );
745 void DestroySortCollator();
747 private:
748 void FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
749 ULONG nFillCount, FillDir eFillDir, FillCmd eFillCmd,
750 FillDateCmd eFillDateCmd,
751 double nStepValue, double nMaxValue, USHORT nMinDigits,
752 BOOL bAttribs, ScProgress& rProgress );
753 void FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
754 FillCmd& rCmd, FillDateCmd& rDateCmd,
755 double& rInc, USHORT& rMinDigits,
756 ScUserListData*& rListData, USHORT& rListIndex);
757 void FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
758 ULONG nFillCount, FillDir eFillDir, ScProgress& rProgress );
760 BOOL ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
761 BOOL bMarked, BOOL bUnprotected );
763 void AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
764 const ScPatternAttr& rAttr, USHORT nFormatNo);
765 void GetAutoFormatAttr(SCCOL nCol, SCROW nRow, USHORT nIndex, ScAutoFormatData& rData);
766 void GetAutoFormatFrame(SCCOL nCol, SCROW nRow, USHORT nFlags, USHORT nIndex, ScAutoFormatData& rData);
767 BOOL SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRow,
768 const ScMarkData& rMark, String& rUndoStr, ScDocument* pUndoDoc);
769 BOOL Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
770 const ScMarkData& rMark, String& rUndoStr, ScDocument* pUndoDoc);
771 BOOL SearchAll(const SvxSearchItem& rSearchItem, ScMarkData& rMark,
772 String& rUndoStr, ScDocument* pUndoDoc);
773 BOOL Replace(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
774 const ScMarkData& rMark, String& rUndoStr, ScDocument* pUndoDoc);
775 BOOL ReplaceAll(const SvxSearchItem& rSearchItem, ScMarkData& rMark,
776 String& rUndoStr, ScDocument* pUndoDoc);
778 BOOL SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
779 ScMarkData& rMark);
780 BOOL ReplaceStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
781 ScMarkData& rMark, BOOL bIsUndo);
782 BOOL SearchAllStyle(const SvxSearchItem& rSearchItem, ScMarkData& rMark);
783 BOOL ReplaceAllStyle(const SvxSearchItem& rSearchItem, ScMarkData& rMark,
784 ScDocument* pUndoDoc);
785 bool SearchAndReplaceEmptyCells(
786 const SvxSearchItem& rSearchItem,
787 SCCOL& rCol, SCROW& rRow, ScMarkData& rMark,
788 String& rUndoStr, ScDocument* pUndoDoc);
789 bool SearchRangeForEmptyCell(const ScRange& rRange,
790 const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow,
791 String& rUndoStr, ScDocument* pUndoDoc);
792 bool SearchRangeForAllEmptyCells(const ScRange& rRange,
793 const SvxSearchItem& rSearchItem, ScMarkData& rMark,
794 String& rUndoStr, ScDocument* pUndoDoc);
796 // benutzen globalen SortParam:
797 BOOL IsSorted(SCCOLROW nStart, SCCOLROW nEnd);
798 void DecoladeRow( ScSortInfoArray*, SCROW nRow1, SCROW nRow2 );
799 void SwapCol(SCCOL nCol1, SCCOL nCol2);
800 void SwapRow(SCROW nRow1, SCROW nRow2);
801 short CompareCell( USHORT nSort,
802 ScBaseCell* pCell1, SCCOL nCell1Col, SCROW nCell1Row,
803 ScBaseCell* pCell2, SCCOL nCell2Col, SCROW nCell2Row );
804 short Compare(SCCOLROW nIndex1, SCCOLROW nIndex2);
805 short Compare( ScSortInfoArray*, SCCOLROW nIndex1, SCCOLROW nIndex2);
806 ScSortInfoArray* CreateSortInfoArray( SCCOLROW nInd1, SCCOLROW nInd2 );
807 void QuickSort( ScSortInfoArray*, SCsCOLROW nLo, SCsCOLROW nHi);
808 void SortReorder( ScSortInfoArray*, ScProgress& );
810 BOOL CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
811 BOOL CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam);
812 void GetUpperCellString(SCCOL nCol, SCROW nRow, String& rStr);
814 BOOL RefVisible(ScFormulaCell* pCell);
816 BOOL IsEmptyLine(SCROW nRow, SCCOL nStartCol, SCCOL nEndCol);
818 void IncDate(double& rVal, USHORT& nDayOfMonth, double nStep, FillDateCmd eCmd);
819 void FillFormula(ULONG& nFormulaCounter, BOOL bFirst, ScFormulaCell* pSrcCell,
820 SCCOL nDestCol, SCROW nDestRow, BOOL bLast );
821 void UpdateInsertTabAbs(SCTAB nNewPos);
822 BOOL GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, BOOL bInSel,
823 const ScMarkData& rMark) const;
824 BOOL GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark );
825 void SetDrawPageSize(bool bResetStreamValid = true);
826 BOOL TestTabRefAbs(SCTAB nTable);
827 void CompileDBFormula();
828 void CompileDBFormula( BOOL bCreateFormulaString );
829 void CompileNameFormula( BOOL bCreateFormulaString );
830 void CompileColRowNameFormula();
832 void StartListening( const ScAddress& rAddress, SvtListener* pListener );
833 void EndListening( const ScAddress& rAddress, SvtListener* pListener );
834 void StartAllListeners();
835 void StartNeededListeners(); // only for cells where NeedsListening()==TRUE
836 void SetRelNameDirty();
838 SCSIZE FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2,
839 SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY,
840 const ScPatternAttr* pPattern, const SfxItemSet* pCondSet );
842 // idle calculation of OutputDevice text width for cell
843 // also invalidates script type, broadcasts for "calc as shown"
844 void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
845 BOOL bNumFormatChanged, BOOL bBroadcast );
847 void SkipFilteredRows(SCROW& rRow, SCROW& rLastNonFilteredRow, bool bForward);
851 #endif