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: attarray.hxx,v $
10 * $Revision: 1.9.32.3 $
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 ************************************************************************/
38 class ScEditDataArray
;
42 class ScFlatBoolRowSegments
;
45 class SfxItemPoolCache
;
46 class SfxStyleSheetBase
;
51 #define SC_LINE_EMPTY 0
53 #define SC_LINE_DONTCARE 2
55 #define SC_ATTRARRAY_DELTA 4
66 ScLineFlags() : nLeft(SC_LINE_EMPTY
),nRight(SC_LINE_EMPTY
),nTop(SC_LINE_EMPTY
),
67 nBottom(SC_LINE_EMPTY
),nHori(SC_LINE_EMPTY
),nVert(SC_LINE_EMPTY
) {}
70 struct ScMergePatternState
72 SfxItemSet
* pItemSet
; // allocated in MergePatternArea, used for resulting ScPatternAttr
73 const ScPatternAttr
* pOld1
; // existing objects, temporary
74 const ScPatternAttr
* pOld2
;
76 ScMergePatternState() : pItemSet(NULL
), pOld1(NULL
), pOld2(NULL
) {}
82 const ScPatternAttr
* pPattern
;
91 ScDocument
* pDocument
;
97 friend class ScDocument
; // fuer FillInfo
98 friend class ScDocumentIterator
;
99 friend class ScAttrIterator
;
100 friend class ScHorizontalAttrIterator
;
101 friend void lcl_IterGetNumberFormat( ULONG
& nFormat
,
102 const ScAttrArray
*& rpArr
, SCROW
& nAttrEndRow
,
103 const ScAttrArray
* pNewArr
, SCROW nRow
, ScDocument
* pDoc
);
105 BOOL
ApplyFrame( const SvxBoxItem
* pLineOuter
, const SvxBoxInfoItem
* pLineInner
,
106 SCROW nStartRow
, SCROW nEndRow
,
107 BOOL bLeft
, SCCOL nDistRight
, BOOL bTop
, SCROW nDistBottom
);
109 void RemoveCellCharAttribs( SCROW nStartRow
, SCROW nEndRow
,
110 const ScPatternAttr
* pPattern
, ScEditDataArray
* pDataArray
);
113 ScAttrArray( SCCOL nNewCol
, SCTAB nNewTab
, ScDocument
* pDoc
);
116 void SetTab(SCTAB nNewTab
) { nTab
= nNewTab
; }
117 void SetCol(SCCOL nNewCol
) { nCol
= nNewCol
; }
119 void TestData() const;
121 void Reset( const ScPatternAttr
* pPattern
, BOOL bAlloc
= TRUE
);
122 BOOL
Concat(SCSIZE nPos
);
124 const ScPatternAttr
* GetPattern( SCROW nRow
) const;
125 const ScPatternAttr
* GetPatternRange( SCROW
& rStartRow
, SCROW
& rEndRow
, SCROW nRow
) const;
126 void MergePatternArea( SCROW nStartRow
, SCROW nEndRow
, ScMergePatternState
& rState
, BOOL bDeep
) const;
128 void MergeBlockFrame( SvxBoxItem
* pLineOuter
, SvxBoxInfoItem
* pLineInner
, ScLineFlags
& rFlags
,
129 SCROW nStartRow
, SCROW nEndRow
, BOOL bLeft
, SCCOL nDistRight
) const;
130 void ApplyBlockFrame( const SvxBoxItem
* pLineOuter
, const SvxBoxInfoItem
* pLineInner
,
131 SCROW nStartRow
, SCROW nEndRow
, BOOL bLeft
, SCCOL nDistRight
);
133 void SetPattern( SCROW nRow
, const ScPatternAttr
* pPattern
, BOOL bPutToPool
= FALSE
);
134 void SetPatternArea( SCROW nStartRow
, SCROW nEndRow
, const ScPatternAttr
* pPattern
,
135 BOOL bPutToPool
= FALSE
, ScEditDataArray
* pDataArray
= NULL
);
136 void ApplyStyleArea( SCROW nStartRow
, SCROW nEndRow
, ScStyleSheet
* pStyle
);
137 void ApplyCacheArea( SCROW nStartRow
, SCROW nEndRow
, SfxItemPoolCache
* pCache
,
138 ScEditDataArray
* pDataArray
= NULL
);
139 void ApplyLineStyleArea( SCROW nStartRow
, SCROW nEndRow
,
140 const SvxBorderLine
* pLine
, BOOL bColorOnly
);
142 void ClearItems( SCROW nStartRow
, SCROW nEndRow
, const USHORT
* pWhich
);
143 void ChangeIndent( SCROW nStartRow
, SCROW nEndRow
, BOOL bIncrement
);
145 /// Including current, may return -1
146 SCsROW
GetNextUnprotected( SCsROW nRow
, BOOL bUp
) const;
148 /// May return -1 if not found
149 SCsROW
SearchStyle( SCsROW nRow
, const ScStyleSheet
* pSearchStyle
,
150 BOOL bUp
, ScMarkArray
* pMarkArray
= NULL
);
151 BOOL
SearchStyleRange( SCsROW
& rRow
, SCsROW
& rEndRow
, const ScStyleSheet
* pSearchStyle
,
152 BOOL bUp
, ScMarkArray
* pMarkArray
= NULL
);
154 BOOL
ApplyFlags( SCROW nStartRow
, SCROW nEndRow
, INT16 nFlags
);
155 BOOL
RemoveFlags( SCROW nStartRow
, SCROW nEndRow
, INT16 nFlags
);
157 BOOL
Search( SCROW nRow
, SCSIZE
& nIndex
) const;
159 BOOL
HasLines( SCROW nRow1
, SCROW nRow2
, Rectangle
& rSizes
,
160 BOOL bLeft
, BOOL bRight
) const;
161 BOOL
HasAttrib( SCROW nRow1
, SCROW nRow2
, USHORT nMask
) const;
162 BOOL
ExtendMerge( SCCOL nThisCol
, SCROW nStartRow
, SCROW nEndRow
,
163 SCCOL
& rPaintCol
, SCROW
& rPaintRow
,
164 BOOL bRefresh
, BOOL bAttrs
);
165 BOOL
RemoveAreaMerge( SCROW nStartRow
, SCROW nEndRow
);
167 void FindStyleSheet( const SfxStyleSheetBase
* pStyleSheet
, ScFlatBoolRowSegments
& rUsedRows
, bool bReset
);
168 BOOL
IsStyleSheetUsed( const ScStyleSheet
& rStyle
, BOOL bGatherAllStyles
) const;
170 void DeleteAreaSafe(SCROW nStartRow
, SCROW nEndRow
);
171 void SetPatternAreaSafe( SCROW nStartRow
, SCROW nEndRow
,
172 const ScPatternAttr
* pWantedPattern
, BOOL bDefault
);
173 void CopyAreaSafe( SCROW nStartRow
, SCROW nEndRow
, long nDy
, ScAttrArray
& rAttrArray
);
175 BOOL
IsEmpty() const;
177 //UNUSED2008-05 SCROW GetFirstEntryPos() const;
178 //UNUSED2008-05 SCROW GetLastEntryPos( BOOL bIncludeBottom ) const;
180 BOOL
GetFirstVisibleAttr( SCROW
& rFirstRow
) const;
181 BOOL
GetLastVisibleAttr( SCROW
& rLastRow
, SCROW nLastData
) const;
182 BOOL
HasVisibleAttrIn( SCROW nStartRow
, SCROW nEndRow
) const;
183 BOOL
IsVisibleEqual( const ScAttrArray
& rOther
,
184 SCROW nStartRow
, SCROW nEndRow
) const;
185 BOOL
IsAllEqual( const ScAttrArray
& rOther
, SCROW nStartRow
, SCROW nEndRow
) const;
187 BOOL
TestInsertCol( SCROW nStartRow
, SCROW nEndRow
) const;
188 BOOL
TestInsertRow( SCSIZE nSize
) const;
189 void InsertRow( SCROW nStartRow
, SCSIZE nSize
);
190 void DeleteRow( SCROW nStartRow
, SCSIZE nSize
);
191 void DeleteRange( SCSIZE nStartIndex
, SCSIZE nEndIndex
);
192 void DeleteArea( SCROW nStartRow
, SCROW nEndRow
);
193 void MoveTo( SCROW nStartRow
, SCROW nEndRow
, ScAttrArray
& rAttrArray
);
194 void CopyArea( SCROW nStartRow
, SCROW nEndRow
, long nDy
, ScAttrArray
& rAttrArray
,
195 INT16 nStripFlags
= 0 );
197 void DeleteHardAttr( SCROW nStartRow
, SCROW nEndRow
);
199 //UNUSED2008-05 void ConvertFontsAfterLoad(); // old binary file format
203 // ------------------------------------------------------------------------------
204 // Iterator fuer Attribute
205 // ------------------------------------------------------------------------------
209 const ScAttrArray
* pArray
;
214 inline ScAttrIterator( const ScAttrArray
* pNewArray
, SCROW nStart
, SCROW nEnd
);
215 inline const ScPatternAttr
* Next( SCROW
& rTop
, SCROW
& rBottom
);
216 SCROW
GetNextRow() const { return nRow
; }
220 inline ScAttrIterator::ScAttrIterator( const ScAttrArray
* pNewArray
, SCROW nStart
, SCROW nEnd
) :
226 pArray
->Search( nStart
, nPos
);
231 inline const ScPatternAttr
* ScAttrIterator::Next( SCROW
& rTop
, SCROW
& rBottom
)
233 const ScPatternAttr
* pRet
;
234 if ( nPos
< pArray
->nCount
&& nRow
<= nEndRow
)
237 rBottom
= Min( pArray
->pData
[nPos
].nRow
, nEndRow
);
238 pRet
= pArray
->pData
[nPos
].pPattern
;