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: column.hxx,v $
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 ************************************************************************/
34 #ifndef SC_MARKARR_HXX
35 #include "markarr.hxx"
47 class SfxItemPoolCache
;
51 class SfxStyleSheetBase
;
63 class ScMultipleReadHeader
;
64 class ScMultipleWriteHeader
;
67 class ScBroadcasterList
;
68 class TypedStrCollection
;
70 struct ScFunctionData
;
74 #define COLUMN_DELTA 4
77 struct ScNeededSizeOptions
79 const ScPatternAttr
* pPattern
;
114 ScAttrArray
* pAttrArray
;
115 ScDocument
* pDocument
;
117 friend class ScDocument
; // fuer FillInfo
118 friend class ScValueIterator
;
119 friend class ScQueryValueIterator
;
120 friend class ScColumnIterator
;
121 friend class ScQueryCellIterator
;
122 friend class ScMarkedDataIter
;
123 friend class ScCellIterator
;
124 friend class ScHorizontalCellIterator
;
127 static BOOL bDoubleAlloc
; // fuer Import: Groesse beim Allozieren verdoppeln
133 void Init(USHORT nNewCol
, USHORT nNewTab
, ScDocument
* pDoc
);
135 BOOL
Search( USHORT nRow
, USHORT
& nIndex
) const;
136 ScBaseCell
* GetCell( USHORT nRow
) const;
137 void Insert( USHORT nRow
, ScBaseCell
* pCell
);
138 void Insert( USHORT nRow
, ULONG nFormatIndex
, ScBaseCell
* pCell
);
139 void Append( USHORT nRow
, ScBaseCell
* pCell
);
140 void DeleteAtIndex( USHORT nIndex
);
142 void Resize( USHORT nSize
);
144 BOOL
HasAttrib( USHORT nRow1
, USHORT nRow2
, USHORT nMask
) const;
145 BOOL
ExtendMerge( USHORT nThisCol
, USHORT nStartRow
, USHORT nEndRow
,
146 USHORT
& rPaintCol
, USHORT
& rPaintRow
,
147 BOOL bRefresh
, BOOL bAttrs
);
149 BOOL
IsEmptyVisData(BOOL bNotes
) const; // ohne Broadcaster
150 BOOL
IsEmptyData() const;
151 BOOL
IsEmptyAttr() const;
152 /*N*/ BOOL
IsEmpty() const;
155 BOOL
HasDataAt(USHORT nRow
) const;
156 USHORT
GetLastVisDataPos(BOOL bNotes
) const; // ohne Broadcaster
157 USHORT
GetFirstVisDataPos(BOOL bNotes
) const;
160 USHORT
GetBlockMatrixEdges( USHORT nRow1
, USHORT nRow2
, USHORT nMask
) const;
161 BOOL
HasSelectionMatrixFragment(const ScMarkData
& rMark
) const;
163 // Daten oder Attribute:
166 BOOL
HasVisibleAttr( USHORT
& rFirstRow
, USHORT
& rLastRow
, BOOL bSkipFirst
) const;
167 BOOL
IsVisibleAttrEqual( const ScColumn
& rCol
, USHORT nStartRow
= 0,
168 USHORT nEndRow
= MAXROW
) const;
169 BOOL
IsAllAttrEqual( const ScColumn
& rCol
, USHORT nStartRow
, USHORT nEndRow
) const;
171 /*N*/ BOOL
TestInsertCol( USHORT nStartRow
, USHORT nEndRow
) const;
172 /*N*/ BOOL
TestInsertRow( USHORT nSize
) const;
173 /*N*/ void InsertRow( USHORT nStartRow
, USHORT nSize
);
174 /*N*/ void DeleteRow( USHORT nStartRow
, USHORT nSize
);
175 void DeleteRange( USHORT nStartIndex
, USHORT nEndIndex
, USHORT nDelFlag
);
176 void DeleteArea(USHORT nStartRow
, USHORT nEndRow
, USHORT nDelFlag
);
179 // Markierung von diesem Dokument
182 ScAttrIterator
* CreateAttrIterator( USHORT nStartRow
, USHORT nEndRow
) const;
184 USHORT
GetCol() const { return nCol
; }
186 // UpdateSelectionFunction: Mehrfachselektion
187 void UpdateSelectionFunction( const ScMarkData
& rMark
,
188 ScFunctionData
& rData
, const BYTE
* pRowFlags
,
189 BOOL bDoExclude
, USHORT nExStartRow
, USHORT nExEndRow
);
190 void UpdateAreaFunction( ScFunctionData
& rData
, BYTE
* pRowFlags
,
191 USHORT nStartRow
, USHORT nEndRow
);
193 void CopyToColumn(USHORT nRow1
, USHORT nRow2
, USHORT nFlags
, BOOL bMarked
,
194 ScColumn
& rColumn
, const ScMarkData
* pMarkData
= NULL
,
195 BOOL bAsLink
= FALSE
);
197 void MarkScenarioIn( ScMarkData
& rDestMark
) const;
200 /*N*/ void SwapCol(ScColumn
& rCol
);
201 /*N*/ void MoveTo(USHORT nStartRow
, USHORT nEndRow
, ScColumn
& rCol
);
203 BOOL
HasEditCells(USHORT nStartRow
, USHORT nEndRow
, USHORT
& rFirst
) const;
205 // TRUE = Zahlformat gesetzt
206 BOOL
SetString( USHORT nRow
, USHORT nTab
, const String
& rString
);
207 void SetValue( USHORT nRow
, const double& rVal
);
208 void SetNote( USHORT nRow
, const ScPostIt
& rNote
);
209 void SetError( USHORT nRow
, const USHORT nError
);
211 void GetString( USHORT nRow
, String
& rString
) const;
212 void GetInputString( USHORT nRow
, String
& rString
) const;
213 double GetValue( USHORT nRow
) const;
214 BOOL
GetNote( USHORT nRow
, ScPostIt
& rNote
) const;
215 CellType
GetCellType( USHORT nRow
) const;
216 USHORT
GetCellCount() const { return nCount
; }
217 long GetWeightedCount() const;
218 USHORT
GetErrCode( USHORT nRow
) const;
220 BOOL
HasStringData( USHORT nRow
) const;
221 BOOL
HasValueData( USHORT nRow
) const;
225 void SetDirtyAfterLoad();
226 void SetTableOpDirty( const ScRange
& );
228 void CalcAfterLoad();
230 void CompileXML( ScProgress
& rProgress
);
232 void ResetChanged( USHORT nStartRow
, USHORT nEndRow
);
234 void UpdateReference( UpdateRefMode eUpdateRefMode
, USHORT nCol1
, USHORT nRow1
, USHORT nTab1
,
235 USHORT nCol2
, USHORT nRow2
, USHORT nTab2
,
236 short nDx
, short nDy
, short nDz
,
237 ScDocument
* pUndoDoc
= NULL
);
238 void UpdateInsertTab( USHORT nTable
);
239 void UpdateInsertTabOnlyCells( USHORT nTable
);
240 void UpdateDeleteTab( USHORT nTable
, BOOL bIsMove
, ScColumn
* pRefUndo
= NULL
);
241 void UpdateCompile( BOOL bForceIfNameInUse
= FALSE
);
243 void SetTabNo(USHORT nNewTab
);
244 BOOL
IsRangeNameInUse(USHORT nRow1
, USHORT nRow2
, USHORT nIndex
) const;
246 const SfxPoolItem
* GetAttr( USHORT nRow
, USHORT nWhich
) const;
247 const ScPatternAttr
* GetPattern( USHORT nRow
) const;
248 ULONG
GetNumberFormat( USHORT nRow
) const;
250 void MergeSelectionPattern( SfxItemSet
** ppSet
, const ScMarkData
& rMark
, BOOL bDeep
) const;
251 void MergePatternArea( SfxItemSet
** ppSet
, USHORT nRow1
, USHORT nRow2
, BOOL bDeep
) const;
253 void ApplyAttr( USHORT nRow
, const SfxPoolItem
& rAttr
);
254 void ApplyPatternArea( USHORT nStartRow
, USHORT nEndRow
, const ScPatternAttr
& rPatAttr
);
256 void ApplyStyleArea( USHORT nStartRow
, USHORT nEndRow
, const ScStyleSheet
& rStyle
);
257 void ApplySelectionStyle(const ScStyleSheet
& rStyle
, const ScMarkData
& rMark
);
259 const ScStyleSheet
* GetSelectionStyle( const ScMarkData
& rMark
, BOOL
& rFound
) const;
260 const ScStyleSheet
* GetAreaStyle( BOOL
& rFound
, USHORT nRow1
, USHORT nRow2
) const;
262 void FindStyleSheet( const SfxStyleSheetBase
* pStyleSheet
, BOOL
* pUsed
, BOOL bReset
);
265 BOOL
ApplyFlags( USHORT nStartRow
, USHORT nEndRow
, INT16 nFlags
);
266 /*N*/ BOOL
RemoveFlags( USHORT nStartRow
, USHORT nEndRow
, INT16 nFlags
);
267 /*N*/ void ClearItems( USHORT nStartRow
, USHORT nEndRow
, const USHORT
* pWhich
);
270 short ApplySelectionCache( SfxItemPoolCache
* pCache
, const ScMarkData
& rMark
);
273 long GetNeededSize( USHORT nRow
, OutputDevice
* pDev
,
274 double nPPTX
, double nPPTY
,
275 const Fraction
& rZoomX
, const Fraction
& rZoomY
,
276 BOOL bWidth
, const ScNeededSizeOptions
& rOptions
);
277 USHORT
GetOptimalColWidth( OutputDevice
* pDev
, double nPPTX
, double nPPTY
,
278 const Fraction
& rZoomX
, const Fraction
& rZoomY
,
279 BOOL bFormula
, USHORT nOldWidth
,
280 const ScMarkData
* pMarkData
,
281 BOOL bSimpleTextImport
);
282 void GetOptimalHeight( USHORT nStartRow
, USHORT nEndRow
, USHORT
* pHeight
,
284 double nPPTX
, double nPPTY
,
285 const Fraction
& rZoomX
, const Fraction
& rZoomY
,
286 BOOL bShrink
, USHORT nMinHeight
, USHORT nMinStart
);
288 long GetSimpleTextNeededSize( USHORT nIndex
, OutputDevice
* pDev
,
294 USHORT
NoteCount( USHORT nMaxRow
= MAXROW
) const;
296 void LoadData( SvStream
& rStream
);
297 void SaveData( SvStream
& rStream
) const;
299 void LoadNotes( SvStream
& rStream
);
300 void SaveNotes( SvStream
& rStream
) const;
302 BOOL
Load( SvStream
& rStream
, ScMultipleReadHeader
& rHdr
);
303 BOOL
Save( SvStream
& rStream
, ScMultipleWriteHeader
& rHdr
) const;
304 BOOL
TestTabRefAbs(USHORT nTable
);
307 void StartListening( SfxListener
& rLst
, USHORT nRow
);
308 void EndListening( SfxListener
& rLst
, USHORT nRow
);
309 /*N*/ void MoveListeners( ScBroadcasterList
& rSource
, USHORT nDestRow
);
310 void StartAllListeners();
311 /*N*/ void StartNameListeners( BOOL bOnlyRelNames
);
312 /*N*/ void SetRelNameDirty();
314 void CompileDBFormula( BOOL bCreateFormulaString
);
315 void CompileNameFormula( BOOL bCreateFormulaString
);
316 void CompileColRowNameFormula();
318 // maximale Stringlaengen einer Column, fuer z.B. dBase Export
321 ScBaseCell
* CloneCell(USHORT nIndex
, USHORT nFlags
,
322 ScDocument
* pDestDoc
, const ScAddress
& rDestPos
);
323 void CorrectSymbolCells( CharSet eStreamCharSet
);
327 class ScColumnIterator
// alle Daten eines Bereichs durchgehen
329 const ScColumn
* pColumn
;
334 ScColumnIterator( const ScColumn
* pCol
, USHORT nStart
=0, USHORT nEnd
=MAXROW
);
337 BOOL
Next( USHORT
& rRow
, ScBaseCell
*& rpCell
);
341 class ScMarkedDataIter
// Daten in selektierten Bereichen durchgehen
343 const ScColumn
* pColumn
;
345 ScMarkArrayIter
* pMarkIter
;
352 ScMarkedDataIter( const ScColumn
* pCol
, const ScMarkData
* pMarkData
,
353 BOOL bAllIfNone
= FALSE
);
356 BOOL
Next( USHORT
& rIndex
);
360 } //namespace binfilter