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 .
22 #include <sal/config.h>
26 #include <svx/framelinkarray.hxx>
27 #include "colorscale.hxx"
28 #include "cellvalue.hxx"
29 #include <o3tl/typed_flags_set.hxx>
40 enum class ScRotateDir
: sal_uInt8
{
41 NONE
, Standard
, Left
, Right
, Center
44 enum class ScClipMark
: sal_uInt8
{
45 NONE
= 0x00, Left
= 0x01, Right
= 0x02, Bottom
= 0x03, Top
= 0x04
48 template<> struct typed_flags
<ScClipMark
> : is_typed_flags
<ScClipMark
, 0x07> {};
51 const sal_uInt8 SC_CLIPMARK_SIZE
= 64;
64 double mnZero
; // 0 to 100
66 double mnLength
; // -100 to 100
71 bool operator==(const ScDataBarInfo
& r
) const
73 if( mnZero
!= r
.mnZero
)
75 if( maColor
!= r
.maColor
)
77 if(mnLength
!= r
.mnLength
)
79 if (mbGradient
!= r
.mbGradient
)
85 bool operator!=(const ScDataBarInfo
& r
) const
94 ScIconSetType eIconSetType
;
95 tools::Long mnHeight
= 0;
99 // FillInfo() computes some info for all cells starting from column 0,
100 // but most of the info is needed only for cells in the given columns.
101 // Keeping all the info in CellInfo could lead to allocation and initialization
102 // of MiB's of memory, so split the info needed for all cells to a smaller structure.
107 , bEmptyCellText(true)
108 , bEditEngine(false) // view-internal
111 bool bEmptyCellText
: 1;
112 bool bEditEngine
: 1; // output-internal
118 : pPatternAttr(nullptr)
119 , pConditionSet(nullptr)
122 , pBackground(nullptr) // TODO: omit?
123 , pLinesAttr(nullptr)
124 , mpTLBRLine(nullptr)
125 , mpBLTRLine(nullptr)
126 , pShadowAttr(nullptr)
127 , pHShadowOrigin(nullptr)
128 , pVShadowOrigin(nullptr)
129 , eHShadowPart(SC_SHADOW_HSTART
)
130 , eVShadowPart(SC_SHADOW_HSTART
)
131 , nClipMark(ScClipMark::NONE
)
132 , nRotateDir(ScRotateDir::NONE
)
134 , bHOverlapped(false)
135 , bVOverlapped(false)
137 , bPivotButton(false)
138 , bPivotPopupButton(false)
139 , bFilterActive(false)
140 , bPrinted(false) // view-internal
141 , bHideGrid(false) // view-internal
145 CellInfo(const CellInfo
&) = delete;
146 const CellInfo
& operator=(const CellInfo
&) = delete;
148 ScRefCellValue maCell
;
150 const ScPatternAttr
* pPatternAttr
;
151 const SfxItemSet
* pConditionSet
;
152 std::optional
<Color
> mxColorScale
;
153 const ScDataBarInfo
* pDataBar
;
154 const ScIconSetInfo
* pIconSet
;
156 const SvxBrushItem
* pBackground
;
158 const SvxBoxItem
* pLinesAttr
; /// original item from document.
159 const SvxLineItem
* mpTLBRLine
; /// original item from document.
160 const SvxLineItem
* mpBLTRLine
; /// original item from document.
162 const SvxShadowItem
* pShadowAttr
; // original item (internal)
164 const SvxShadowItem
* pHShadowOrigin
;
165 const SvxShadowItem
* pVShadowOrigin
;
167 ScShadowPart eHShadowPart
: 4; // shadow effective for drawing
168 ScShadowPart eVShadowPart
: 4;
169 ScClipMark nClipMark
;
170 ScRotateDir nRotateDir
;
173 bool bHOverlapped
: 1;
174 bool bVOverlapped
: 1;
175 bool bAutoFilter
: 1;
177 bool bPivotPopupButton
:1;
178 bool bFilterActive
:1;
179 bool bPrinted
: 1; // when required (pagebreak mode)
180 bool bHideGrid
: 1; // output-internal
183 const SCCOL SC_ROTMAX_NONE
= SCCOL_MAX
;
188 RowInfo(const RowInfo
&) = delete;
189 const RowInfo
& operator=(const RowInfo
&) = delete;
191 CellInfo
& cellInfo(SCCOL nCol
)
193 assert( nCol
>= nStartCol
- 1 );
195 assert( nCol
<= nEndCol
+ 1 );
197 return pCellInfo
[ nCol
- nStartCol
+ 1 ];
199 const CellInfo
& cellInfo(SCCOL nCol
) const
201 return const_cast<RowInfo
*>(this)->cellInfo(nCol
);
204 BasicCellInfo
& basicCellInfo(SCCOL nCol
)
206 assert( nCol
>= -1 );
208 assert( nCol
<= nEndCol
+ 1 );
210 return pBasicCellInfo
[ nCol
+ 1 ];
212 const BasicCellInfo
& basicCellInfo(SCCOL nCol
) const
214 return const_cast<RowInfo
*>(this)->basicCellInfo(nCol
);
217 void allocCellInfo(SCCOL startCol
, SCCOL endCol
)
219 nStartCol
= startCol
;
223 pCellInfo
= new CellInfo
[ endCol
- nStartCol
+ 1 + 2 ];
224 pBasicCellInfo
= new BasicCellInfo
[ endCol
+ 1 + 2 ];
229 delete[] pBasicCellInfo
;
234 SCCOL nRotMaxCol
; // SC_ROTMAX_NONE, if nothing
239 bool bChanged
:1; // TRUE, if not tested
242 // This class allocates CellInfo with also one item extra before and after.
243 // To make handling easier, this is private and access functions take care of adjusting
244 // the array indexes and error-checking. CellInfo is allocated only for a given
245 // range of columns plus one on each side, BasicCellInfo is allocated for columns
246 // starting from column 0 until the last column given, again plus one on each side.
248 BasicCellInfo
* pBasicCellInfo
;
257 svx::frame::Array maArray
;
258 std::unique_ptr
<RowInfo
[]>
261 SCSIZE mnArrCapacity
;
264 explicit ScTableInfo(const SCSIZE capacity
= 1024);
266 ScTableInfo(const ScTableInfo
&) = delete;
267 const ScTableInfo
& operator=(const ScTableInfo
&) = delete;
269 void addDataBarInfo(std::unique_ptr
<const ScDataBarInfo
> info
)
271 mDataBarInfos
.push_back(std::move(info
));
273 void addIconSetInfo(std::unique_ptr
<const ScIconSetInfo
> info
)
275 mIconSetInfos
.push_back(std::move(info
));
278 // These are owned here and not in CellInfo to avoid freeing
279 // memory for every pointer in CellInfo, most of which are nullptr.
280 std::vector
<std::unique_ptr
<const ScDataBarInfo
>> mDataBarInfos
;
281 std::vector
<std::unique_ptr
<const ScIconSetInfo
>> mIconSetInfos
;
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */