1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
27 class ScEditDataArray
;
31 class ScFlatBoolRowSegments
;
33 class SfxItemPoolCache
;
34 class SfxStyleSheetBase
;
38 namespace editeng
{ class SvxBorderLine
; }
40 #define SC_LINE_EMPTY 0
42 #define SC_LINE_DONTCARE 2
44 #define SC_ATTRARRAY_DELTA 4
55 ScLineFlags() : nLeft(SC_LINE_EMPTY
),nRight(SC_LINE_EMPTY
),nTop(SC_LINE_EMPTY
),
56 nBottom(SC_LINE_EMPTY
),nHori(SC_LINE_EMPTY
),nVert(SC_LINE_EMPTY
) {}
59 struct ScMergePatternState
61 SfxItemSet
* pItemSet
; ///< allocated in MergePatternArea, used for resulting ScPatternAttr
62 const ScPatternAttr
* pOld1
; ///< existing objects, temporary
63 const ScPatternAttr
* pOld2
;
65 ScMergePatternState() : pItemSet(NULL
), pOld1(NULL
), pOld2(NULL
) {}
71 const ScPatternAttr
* pPattern
;
80 ScDocument
* pDocument
;
86 friend class ScDocument
; // for FillInfo
87 friend class ScDocumentIterator
;
88 friend class ScAttrIterator
;
89 friend class ScHorizontalAttrIterator
;
91 bool ApplyFrame( const SvxBoxItem
* pLineOuter
, const SvxBoxInfoItem
* pLineInner
,
92 SCROW nStartRow
, SCROW nEndRow
,
93 bool bLeft
, SCCOL nDistRight
, bool bTop
, SCROW nDistBottom
);
95 void RemoveCellCharAttribs( SCROW nStartRow
, SCROW nEndRow
,
96 const ScPatternAttr
* pPattern
, ScEditDataArray
* pDataArray
);
98 // prevent the copy c'tor and operator=
99 // this is just to prevent accidental use
100 ScAttrArray(const ScAttrArray
&);
101 ScAttrArray
& operator=(const ScAttrArray
&);
104 ScAttrArray( SCCOL nNewCol
, SCTAB nNewTab
, ScDocument
* pDoc
);
107 void SetTab(SCTAB nNewTab
) { nTab
= nNewTab
; }
108 void SetCol(SCCOL nNewCol
) { nCol
= nNewCol
; }
109 #if OSL_DEBUG_LEVEL > 1
110 void TestData() const;
112 void Reset( const ScPatternAttr
* pPattern
);
113 bool Concat(SCSIZE nPos
);
115 const ScPatternAttr
* GetPattern( SCROW nRow
) const;
116 const ScPatternAttr
* GetPatternRange( SCROW
& rStartRow
, SCROW
& rEndRow
, SCROW nRow
) const;
117 void MergePatternArea( SCROW nStartRow
, SCROW nEndRow
, ScMergePatternState
& rState
, bool bDeep
) const;
119 void MergeBlockFrame( SvxBoxItem
* pLineOuter
, SvxBoxInfoItem
* pLineInner
, ScLineFlags
& rFlags
,
120 SCROW nStartRow
, SCROW nEndRow
, bool bLeft
, SCCOL nDistRight
) const;
121 void ApplyBlockFrame( const SvxBoxItem
* pLineOuter
, const SvxBoxInfoItem
* pLineInner
,
122 SCROW nStartRow
, SCROW nEndRow
, bool bLeft
, SCCOL nDistRight
);
124 void SetPattern( SCROW nRow
, const ScPatternAttr
* pPattern
, bool bPutToPool
= false );
125 void SetPatternArea( SCROW nStartRow
, SCROW nEndRow
, const ScPatternAttr
* pPattern
,
126 bool bPutToPool
= false, ScEditDataArray
* pDataArray
= NULL
);
127 void ApplyStyleArea( SCROW nStartRow
, SCROW nEndRow
, ScStyleSheet
* pStyle
);
128 void ApplyCacheArea( SCROW nStartRow
, SCROW nEndRow
, SfxItemPoolCache
* pCache
,
129 ScEditDataArray
* pDataArray
= NULL
);
130 bool SetAttrEntries(ScAttrEntry
* pNewData
, SCSIZE nSize
);
131 void ApplyLineStyleArea( SCROW nStartRow
, SCROW nEndRow
,
132 const ::editeng::SvxBorderLine
* pLine
, bool bColorOnly
);
134 void AddCondFormat( SCROW nStartRow
, SCROW nEndRow
, sal_uInt32 nIndex
);
135 void RemoveCondFormat( SCROW nStartRow
, SCROW nEndRow
, sal_uInt32 nIndex
);
137 void ClearItems( SCROW nStartRow
, SCROW nEndRow
, const sal_uInt16
* pWhich
);
138 void ChangeIndent( SCROW nStartRow
, SCROW nEndRow
, bool bIncrement
);
140 /// Including current, may return -1
141 SCsROW
GetNextUnprotected( SCsROW nRow
, bool bUp
) const;
143 /// May return -1 if not found
145 SCsROW nRow
, const ScStyleSheet
* pSearchStyle
, bool bUp
,
146 const ScMarkArray
* pMarkArray
= NULL
) const;
148 bool SearchStyleRange(
149 SCsROW
& rRow
, SCsROW
& rEndRow
, const ScStyleSheet
* pSearchStyle
, bool bUp
,
150 const ScMarkArray
* pMarkArray
= NULL
) const;
152 bool ApplyFlags( SCROW nStartRow
, SCROW nEndRow
, sal_Int16 nFlags
);
153 bool RemoveFlags( SCROW nStartRow
, SCROW nEndRow
, sal_Int16 nFlags
);
155 bool Search( SCROW nRow
, SCSIZE
& nIndex
) const;
157 bool HasAttrib( SCROW nRow1
, SCROW nRow2
, sal_uInt16 nMask
) const;
158 bool ExtendMerge( SCCOL nThisCol
, SCROW nStartRow
, SCROW nEndRow
,
159 SCCOL
& rPaintCol
, SCROW
& rPaintRow
,
161 bool RemoveAreaMerge( SCROW nStartRow
, SCROW nEndRow
);
163 void FindStyleSheet( const SfxStyleSheetBase
* pStyleSheet
, ScFlatBoolRowSegments
& rUsedRows
, bool bReset
);
164 bool IsStyleSheetUsed( const ScStyleSheet
& rStyle
, bool bGatherAllStyles
) const;
166 void DeleteAreaSafe(SCROW nStartRow
, SCROW nEndRow
);
167 void SetPatternAreaSafe( SCROW nStartRow
, SCROW nEndRow
,
168 const ScPatternAttr
* pWantedPattern
, bool bDefault
);
169 void CopyAreaSafe( SCROW nStartRow
, SCROW nEndRow
, long nDy
, ScAttrArray
& rAttrArray
);
171 bool IsEmpty() const;
173 bool GetFirstVisibleAttr( SCROW
& rFirstRow
) const;
174 bool GetLastVisibleAttr( SCROW
& rLastRow
, SCROW nLastData
, bool bFullFormattedArea
= false ) const;
175 bool HasVisibleAttrIn( SCROW nStartRow
, SCROW nEndRow
) const;
176 bool IsVisibleEqual( const ScAttrArray
& rOther
,
177 SCROW nStartRow
, SCROW nEndRow
) const;
178 bool IsAllEqual( const ScAttrArray
& rOther
, SCROW nStartRow
, SCROW nEndRow
) const;
180 bool TestInsertCol( SCROW nStartRow
, SCROW nEndRow
) const;
181 bool TestInsertRow( SCSIZE nSize
) const;
182 void InsertRow( SCROW nStartRow
, SCSIZE nSize
);
183 void DeleteRow( SCROW nStartRow
, SCSIZE nSize
);
184 void DeleteRange( SCSIZE nStartIndex
, SCSIZE nEndIndex
);
185 void DeleteArea( SCROW nStartRow
, SCROW nEndRow
);
186 void MoveTo( SCROW nStartRow
, SCROW nEndRow
, ScAttrArray
& rAttrArray
);
188 SCROW nStartRow
, SCROW nEndRow
, long nDy
, ScAttrArray
& rAttrArray
, sal_Int16 nStripFlags
= 0) const;
190 void DeleteHardAttr( SCROW nStartRow
, SCROW nEndRow
);
194 // ------------------------------------------------------------------------------
195 // Iterator for attributes
196 // ------------------------------------------------------------------------------
200 const ScAttrArray
* pArray
;
205 inline ScAttrIterator( const ScAttrArray
* pNewArray
, SCROW nStart
, SCROW nEnd
);
206 inline const ScPatternAttr
* Next( SCROW
& rTop
, SCROW
& rBottom
);
207 SCROW
GetNextRow() const { return nRow
; }
211 inline ScAttrIterator::ScAttrIterator( const ScAttrArray
* pNewArray
, SCROW nStart
, SCROW nEnd
) :
217 pArray
->Search( nStart
, nPos
);
222 inline const ScPatternAttr
* ScAttrIterator::Next( SCROW
& rTop
, SCROW
& rBottom
)
224 const ScPatternAttr
* pRet
;
225 if ( nPos
< pArray
->nCount
&& nRow
<= nEndRow
)
228 rBottom
= std::min( pArray
->pData
[nPos
].nRow
, nEndRow
);
229 pRet
= pArray
->pData
[nPos
].pPattern
;
243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */