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 ScCellInfo could lead to allocation and initialization
102 // of MiB's of memory, so split the info needed for all cells to a smaller structure.
103 struct ScBasicCellInfo
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
142 , bPivotCollapseButton(false)
143 , bPivotExpandButton(false)
144 , bPivotPopupButtonMulti(false)
148 ScCellInfo(const ScCellInfo
&) = delete;
149 const ScCellInfo
& operator=(const ScCellInfo
&) = delete;
151 ScRefCellValue maCell
;
153 const ScPatternAttr
* pPatternAttr
;
154 const SfxItemSet
* pConditionSet
;
155 std::optional
<Color
> mxColorScale
;
156 const ScDataBarInfo
* pDataBar
;
157 const ScIconSetInfo
* pIconSet
;
159 const SvxBrushItem
* pBackground
;
161 const SvxBoxItem
* pLinesAttr
; /// original item from document.
162 const SvxLineItem
* mpTLBRLine
; /// original item from document.
163 const SvxLineItem
* mpBLTRLine
; /// original item from document.
165 const SvxShadowItem
* pShadowAttr
; // original item (internal)
167 const SvxShadowItem
* pHShadowOrigin
;
168 const SvxShadowItem
* pVShadowOrigin
;
170 ScShadowPart eHShadowPart
: 4; // shadow effective for drawing
171 ScShadowPart eVShadowPart
: 4;
172 ScClipMark nClipMark
;
173 ScRotateDir nRotateDir
;
176 bool bHOverlapped
: 1;
177 bool bVOverlapped
: 1;
178 bool bAutoFilter
: 1;
180 bool bPivotPopupButton
:1;
181 bool bFilterActive
:1;
182 bool bPrinted
: 1; // when required (pagebreak mode)
183 bool bHideGrid
: 1; // output-internal
184 bool bPivotCollapseButton
: 1; // dp compact layout collapse button
185 bool bPivotExpandButton
: 1; // dp compact layout expand button
186 bool bPivotPopupButtonMulti
: 1; // dp button with popup arrow for multiple fields
189 const SCCOL SC_ROTMAX_NONE
= SCCOL_MAX
;
194 RowInfo(const RowInfo
&) = delete;
195 const RowInfo
& operator=(const RowInfo
&) = delete;
197 ScCellInfo
& cellInfo(SCCOL nCol
)
199 assert( nCol
>= nStartCol
- 1 );
201 assert( nCol
<= nEndCol
+ 1 );
203 return pCellInfo
[ nCol
- nStartCol
+ 1 ];
205 const ScCellInfo
& cellInfo(SCCOL nCol
) const
207 return const_cast<RowInfo
*>(this)->cellInfo(nCol
);
210 ScBasicCellInfo
& basicCellInfo(SCCOL nCol
)
212 assert( nCol
>= -1 );
214 assert( nCol
<= nEndCol
+ 1 );
216 return pBasicCellInfo
[ nCol
+ 1 ];
218 const ScBasicCellInfo
& basicCellInfo(SCCOL nCol
) const
220 return const_cast<RowInfo
*>(this)->basicCellInfo(nCol
);
223 void allocCellInfo(SCCOL startCol
, SCCOL endCol
)
225 nStartCol
= startCol
;
229 pCellInfo
= new ScCellInfo
[ endCol
- nStartCol
+ 1 + 2 ];
230 pBasicCellInfo
= new ScBasicCellInfo
[ endCol
+ 1 + 2 ];
235 delete[] pBasicCellInfo
;
240 SCCOL nRotMaxCol
; // SC_ROTMAX_NONE, if nothing
245 bool bChanged
:1; // TRUE, if not tested
249 // This class allocates ScCellInfo with also one item extra before and after.
250 // To make handling easier, this is private and access functions take care of adjusting
251 // the array indexes and error-checking. ScCellInfo is allocated only for a given
252 // range of columns plus one on each side, ScBasicCellInfo is allocated for columns
253 // starting from column 0 until the last column given, again plus one on each side.
254 ScCellInfo
* pCellInfo
;
255 ScBasicCellInfo
* pBasicCellInfo
;
264 svx::frame::Array maArray
;
265 std::unique_ptr
<RowInfo
[]>
268 SCSIZE mnArrCapacity
;
271 explicit ScTableInfo(const SCSIZE capacity
= 1024);
273 ScTableInfo(const ScTableInfo
&) = delete;
274 const ScTableInfo
& operator=(const ScTableInfo
&) = delete;
276 void addDataBarInfo(std::unique_ptr
<const ScDataBarInfo
> info
)
278 mDataBarInfos
.push_back(std::move(info
));
280 void addIconSetInfo(std::unique_ptr
<const ScIconSetInfo
> info
)
282 mIconSetInfos
.push_back(std::move(info
));
285 // These are owned here and not in ScCellInfo to avoid freeing
286 // memory for every pointer in ScCellInfo, most of which are nullptr.
287 std::vector
<std::unique_ptr
<const ScDataBarInfo
>> mDataBarInfos
;
288 std::vector
<std::unique_ptr
<const ScIconSetInfo
>> mIconSetInfos
;
291 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */