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;
120 void Reset( const ScPatternAttr
* pPattern
, BOOL bAlloc
= TRUE
);
121 BOOL
Concat(SCSIZE nPos
);
123 const ScPatternAttr
* GetPattern( SCROW nRow
) const;
124 const ScPatternAttr
* GetPatternRange( SCROW
& rStartRow
, SCROW
& rEndRow
, SCROW nRow
) const;
125 void MergePatternArea( SCROW nStartRow
, SCROW nEndRow
, ScMergePatternState
& rState
, BOOL bDeep
) const;
127 void MergeBlockFrame( SvxBoxItem
* pLineOuter
, SvxBoxInfoItem
* pLineInner
, ScLineFlags
& rFlags
,
128 SCROW nStartRow
, SCROW nEndRow
, BOOL bLeft
, SCCOL nDistRight
) const;
129 void ApplyBlockFrame( const SvxBoxItem
* pLineOuter
, const SvxBoxInfoItem
* pLineInner
,
130 SCROW nStartRow
, SCROW nEndRow
, BOOL bLeft
, SCCOL nDistRight
);
132 void SetPattern( SCROW nRow
, const ScPatternAttr
* pPattern
, BOOL bPutToPool
= FALSE
);
133 void SetPatternArea( SCROW nStartRow
, SCROW nEndRow
, const ScPatternAttr
* pPattern
,
134 BOOL bPutToPool
= FALSE
, ScEditDataArray
* pDataArray
= NULL
);
135 void ApplyStyleArea( SCROW nStartRow
, SCROW nEndRow
, ScStyleSheet
* pStyle
);
136 void ApplyCacheArea( SCROW nStartRow
, SCROW nEndRow
, SfxItemPoolCache
* pCache
,
137 ScEditDataArray
* pDataArray
= NULL
);
138 void ApplyLineStyleArea( SCROW nStartRow
, SCROW nEndRow
,
139 const SvxBorderLine
* pLine
, BOOL bColorOnly
);
141 void ClearItems( SCROW nStartRow
, SCROW nEndRow
, const USHORT
* pWhich
);
142 void ChangeIndent( SCROW nStartRow
, SCROW nEndRow
, BOOL bIncrement
);
144 /// Including current, may return -1
145 SCsROW
GetNextUnprotected( SCsROW nRow
, BOOL bUp
) const;
147 /// May return -1 if not found
148 SCsROW
SearchStyle( SCsROW nRow
, const ScStyleSheet
* pSearchStyle
,
149 BOOL bUp
, ScMarkArray
* pMarkArray
= NULL
);
150 BOOL
SearchStyleRange( SCsROW
& rRow
, SCsROW
& rEndRow
, const ScStyleSheet
* pSearchStyle
,
151 BOOL bUp
, ScMarkArray
* pMarkArray
= NULL
);
153 BOOL
ApplyFlags( SCROW nStartRow
, SCROW nEndRow
, INT16 nFlags
);
154 BOOL
RemoveFlags( SCROW nStartRow
, SCROW nEndRow
, INT16 nFlags
);
156 BOOL
Search( SCROW nRow
, SCSIZE
& nIndex
) const;
158 BOOL
HasLines( SCROW nRow1
, SCROW nRow2
, Rectangle
& rSizes
,
159 BOOL bLeft
, BOOL bRight
) const;
160 BOOL
HasAttrib( SCROW nRow1
, SCROW nRow2
, USHORT nMask
) const;
161 BOOL
ExtendMerge( SCCOL nThisCol
, SCROW nStartRow
, SCROW nEndRow
,
162 SCCOL
& rPaintCol
, SCROW
& rPaintRow
,
163 BOOL bRefresh
, BOOL bAttrs
);
164 BOOL
RemoveAreaMerge( SCROW nStartRow
, SCROW nEndRow
);
166 void FindStyleSheet( const SfxStyleSheetBase
* pStyleSheet
, ScFlatBoolRowSegments
& rUsedRows
, bool bReset
);
167 BOOL
IsStyleSheetUsed( const ScStyleSheet
& rStyle
, BOOL bGatherAllStyles
) const;
169 void DeleteAreaSafe(SCROW nStartRow
, SCROW nEndRow
);
170 void SetPatternAreaSafe( SCROW nStartRow
, SCROW nEndRow
,
171 const ScPatternAttr
* pWantedPattern
, BOOL bDefault
);
172 void CopyAreaSafe( SCROW nStartRow
, SCROW nEndRow
, long nDy
, ScAttrArray
& rAttrArray
);
174 BOOL
IsEmpty() const;
176 //UNUSED2008-05 SCROW GetFirstEntryPos() const;
177 //UNUSED2008-05 SCROW GetLastEntryPos( BOOL bIncludeBottom ) const;
179 BOOL
GetFirstVisibleAttr( SCROW
& rFirstRow
) const;
180 BOOL
GetLastVisibleAttr( SCROW
& rLastRow
, SCROW nLastData
) const;
181 BOOL
HasVisibleAttrIn( SCROW nStartRow
, SCROW nEndRow
) const;
182 BOOL
IsVisibleEqual( const ScAttrArray
& rOther
,
183 SCROW nStartRow
, SCROW nEndRow
) const;
184 BOOL
IsAllEqual( const ScAttrArray
& rOther
, SCROW nStartRow
, SCROW nEndRow
) const;
186 BOOL
TestInsertCol( SCROW nStartRow
, SCROW nEndRow
) const;
187 BOOL
TestInsertRow( SCSIZE nSize
) const;
188 void InsertRow( SCROW nStartRow
, SCSIZE nSize
);
189 void DeleteRow( SCROW nStartRow
, SCSIZE nSize
);
190 void DeleteRange( SCSIZE nStartIndex
, SCSIZE nEndIndex
);
191 void DeleteArea( SCROW nStartRow
, SCROW nEndRow
);
192 void MoveTo( SCROW nStartRow
, SCROW nEndRow
, ScAttrArray
& rAttrArray
);
193 void CopyArea( SCROW nStartRow
, SCROW nEndRow
, long nDy
, ScAttrArray
& rAttrArray
,
194 INT16 nStripFlags
= 0 );
196 void DeleteHardAttr( SCROW nStartRow
, SCROW nEndRow
);
198 //UNUSED2008-05 void ConvertFontsAfterLoad(); // old binary file format
202 // ------------------------------------------------------------------------------
203 // Iterator fuer Attribute
204 // ------------------------------------------------------------------------------
208 const ScAttrArray
* pArray
;
213 inline ScAttrIterator( const ScAttrArray
* pNewArray
, SCROW nStart
, SCROW nEnd
);
214 inline const ScPatternAttr
* Next( SCROW
& rTop
, SCROW
& rBottom
);
215 SCROW
GetNextRow() const { return nRow
; }
219 inline ScAttrIterator::ScAttrIterator( const ScAttrArray
* pNewArray
, SCROW nStart
, SCROW nEnd
) :
225 pArray
->Search( nStart
, nPos
);
230 inline const ScPatternAttr
* ScAttrIterator::Next( SCROW
& rTop
, SCROW
& rBottom
)
232 const ScPatternAttr
* pRet
;
233 if ( nPos
< pArray
->nCount
&& nRow
<= nEndRow
)
236 rBottom
= Min( pArray
->pData
[nPos
].nRow
, nEndRow
);
237 pRet
= pArray
->pData
[nPos
].pPattern
;