LibreOffice Module sc (master) 1
fillinfo.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <memory>
25
27#include "colorscale.hxx"
28#include "cellvalue.hxx"
30#include <optional>
31
32class SfxItemSet;
33class SvxBrushItem;
34class SvxBoxItem;
35class SvxLineItem;
36class SvxShadowItem;
37
38class ScPatternAttr;
39
40enum class ScRotateDir : sal_uInt8 {
42};
43
44enum class ScClipMark : sal_uInt8 {
45 NONE = 0x00, Left = 0x01, Right = 0x02, Bottom = 0x03, Top = 0x04
46};
47namespace o3tl {
48 template<> struct typed_flags<ScClipMark> : is_typed_flags<ScClipMark, 0x07> {};
49}
50
52
54{
60};
61
63{
64 double mnZero; // 0 to 100
66 double mnLength; // -100 to 100
70
71 bool operator==(const ScDataBarInfo& r) const
72 {
73 if( mnZero != r.mnZero )
74 return false;
75 if( maColor != r.maColor )
76 return false;
77 if(mnLength != r.mnLength)
78 return false;
79 if (mbGradient != r.mbGradient)
80 return false;
81
82 return true;
83 }
84
85 bool operator!=(const ScDataBarInfo& r) const
86 {
87 return !(*this == r);
88 }
89};
90
92{
93 sal_Int32 nIconIndex;
97};
98
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.
104{
106 : nWidth(0)
107 , bEmptyCellText(true)
108 , bEditEngine(false) // view-internal
109 {}
110 sal_uInt16 nWidth;
112 bool bEditEngine : 1; // output-internal
113};
114
116{
118 : pPatternAttr(nullptr)
119 , pConditionSet(nullptr)
120 , pDataBar(nullptr)
121 , pIconSet(nullptr)
122 , pBackground(nullptr) // TODO: omit?
123 , pLinesAttr(nullptr)
124 , mpTLBRLine(nullptr)
125 , mpBLTRLine(nullptr)
126 , pShadowAttr(nullptr)
127 , pHShadowOrigin(nullptr)
128 , pVShadowOrigin(nullptr)
133 , bMerged(false)
134 , bHOverlapped(false)
135 , bVOverlapped(false)
136 , bAutoFilter(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)
145 {
146 }
147
148 ScCellInfo(const ScCellInfo&) = delete;
149 const ScCellInfo& operator=(const ScCellInfo&) = delete;
150
152
155 std::optional<Color> mxColorScale;
158
160
164
165 const SvxShadowItem* pShadowAttr; // original item (internal)
166
169
170 ScShadowPart eHShadowPart : 4; // shadow effective for drawing
174
175 bool bMerged : 1;
176 bool bHOverlapped : 1;
177 bool bVOverlapped : 1;
178 bool bAutoFilter : 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
187};
188
190
192{
193 RowInfo() = default;
194 RowInfo(const RowInfo&) = delete;
195 const RowInfo& operator=(const RowInfo&) = delete;
196
198 {
199 assert( nCol >= nStartCol - 1 );
200#ifdef DBG_UTIL
201 assert( nCol <= nEndCol + 1 );
202#endif
203 return pCellInfo[ nCol - nStartCol + 1 ];
204 }
205 const ScCellInfo& cellInfo(SCCOL nCol) const
206 {
207 return const_cast<RowInfo*>(this)->cellInfo(nCol);
208 }
209
211 {
212 assert( nCol >= -1 );
213#ifdef DBG_UTIL
214 assert( nCol <= nEndCol + 1 );
215#endif
216 return pBasicCellInfo[ nCol + 1 ];
217 }
219 {
220 return const_cast<RowInfo*>(this)->basicCellInfo(nCol);
221 }
222
223 void allocCellInfo(SCCOL startCol, SCCOL endCol)
224 {
225 nStartCol = startCol;
226#ifdef DBG_UTIL
227 nEndCol = endCol;
228#endif
229 pCellInfo = new ScCellInfo[ endCol - nStartCol + 1 + 2 ];
230 pBasicCellInfo = new ScBasicCellInfo[ endCol + 1 + 2 ];
231 }
233 {
234 delete[] pCellInfo;
235 delete[] pBasicCellInfo;
236 }
237
238 sal_uInt16 nHeight;
240 SCCOL nRotMaxCol; // SC_ROTMAX_NONE, if nothing
241
245 bool bChanged:1; // TRUE, if not tested
247
248private:
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.
257#ifdef DBG_UTIL
259#endif
260};
261
263{
265 std::unique_ptr<RowInfo[]>
270
271 explicit ScTableInfo(const SCSIZE capacity = 1024);
272 ~ScTableInfo();
273 ScTableInfo(const ScTableInfo&) = delete;
274 const ScTableInfo& operator=(const ScTableInfo&) = delete;
275
276 void addDataBarInfo(std::unique_ptr<const ScDataBarInfo> info)
277 {
278 mDataBarInfos.push_back(std::move(info));
279 }
280 void addIconSetInfo(std::unique_ptr<const ScIconSetInfo> info)
281 {
282 mIconSetInfos.push_back(std::move(info));
283 }
284private:
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;
289};
290
291/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SCCOL SCCOL_MAX
Definition: address.hxx:56
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
ScIconSetType
Definition: colorscale.hxx:189
ScRotateDir
Definition: fillinfo.hxx:40
const SCCOL SC_ROTMAX_NONE
Definition: fillinfo.hxx:189
ScShadowPart
Definition: fillinfo.hxx:54
@ SC_SHADOW_VSTART
Definition: fillinfo.hxx:56
@ SC_SHADOW_VERT
Definition: fillinfo.hxx:58
@ SC_SHADOW_CORNER
Definition: fillinfo.hxx:59
@ SC_SHADOW_HSTART
Definition: fillinfo.hxx:55
@ SC_SHADOW_HORIZ
Definition: fillinfo.hxx:57
const sal_uInt8 SC_CLIPMARK_SIZE
Definition: fillinfo.hxx:51
ScClipMark
Definition: fillinfo.hxx:44
NONE
long Long
bool bEmptyBack
Definition: fillinfo.hxx:242
RowInfo()=default
const ScBasicCellInfo & basicCellInfo(SCCOL nCol) const
Definition: fillinfo.hxx:218
bool bPivotButton
Definition: fillinfo.hxx:244
SCROW nRowNo
Definition: fillinfo.hxx:239
ScCellInfo * pCellInfo
Definition: fillinfo.hxx:254
SCCOL nRotMaxCol
Definition: fillinfo.hxx:240
bool bAutoFilter
Definition: fillinfo.hxx:243
void freeCellInfo()
Definition: fillinfo.hxx:232
bool bPivotToggle
Definition: fillinfo.hxx:246
const RowInfo & operator=(const RowInfo &)=delete
RowInfo(const RowInfo &)=delete
ScCellInfo & cellInfo(SCCOL nCol)
Definition: fillinfo.hxx:197
ScBasicCellInfo * pBasicCellInfo
Definition: fillinfo.hxx:255
ScBasicCellInfo & basicCellInfo(SCCOL nCol)
Definition: fillinfo.hxx:210
void allocCellInfo(SCCOL startCol, SCCOL endCol)
Definition: fillinfo.hxx:223
sal_uInt16 nHeight
Definition: fillinfo.hxx:238
bool bChanged
Definition: fillinfo.hxx:245
SCCOL nEndCol
Definition: fillinfo.hxx:258
const ScCellInfo & cellInfo(SCCOL nCol) const
Definition: fillinfo.hxx:205
SCCOL nStartCol
Definition: fillinfo.hxx:256
sal_uInt16 nWidth
Definition: fillinfo.hxx:110
ScRotateDir nRotateDir
Definition: fillinfo.hxx:173
const SvxShadowItem * pVShadowOrigin
Definition: fillinfo.hxx:168
const SfxItemSet * pConditionSet
Definition: fillinfo.hxx:154
const SvxShadowItem * pHShadowOrigin
Definition: fillinfo.hxx:167
ScClipMark nClipMark
Definition: fillinfo.hxx:172
bool bHideGrid
Definition: fillinfo.hxx:183
ScShadowPart eVShadowPart
Definition: fillinfo.hxx:171
ScRefCellValue maCell
Definition: fillinfo.hxx:151
bool bPivotPopupButton
Definition: fillinfo.hxx:180
std::optional< Color > mxColorScale
Definition: fillinfo.hxx:155
bool bVOverlapped
Definition: fillinfo.hxx:177
ScCellInfo(const ScCellInfo &)=delete
const SvxShadowItem * pShadowAttr
original item from document.
Definition: fillinfo.hxx:165
const SvxLineItem * mpBLTRLine
original item from document.
Definition: fillinfo.hxx:163
const ScCellInfo & operator=(const ScCellInfo &)=delete
const SvxBoxItem * pLinesAttr
Definition: fillinfo.hxx:161
bool bFilterActive
Definition: fillinfo.hxx:181
const SvxLineItem * mpTLBRLine
original item from document.
Definition: fillinfo.hxx:162
const ScPatternAttr * pPatternAttr
Definition: fillinfo.hxx:153
ScShadowPart eHShadowPart
Definition: fillinfo.hxx:170
bool bPivotButton
Definition: fillinfo.hxx:179
bool bPivotCollapseButton
Definition: fillinfo.hxx:184
bool bPivotPopupButtonMulti
Definition: fillinfo.hxx:186
bool bHOverlapped
Definition: fillinfo.hxx:176
const ScDataBarInfo * pDataBar
Definition: fillinfo.hxx:156
bool bPrinted
Definition: fillinfo.hxx:182
bool bAutoFilter
Definition: fillinfo.hxx:178
const SvxBrushItem * pBackground
Definition: fillinfo.hxx:159
const ScIconSetInfo * pIconSet
Definition: fillinfo.hxx:157
bool bMerged
Definition: fillinfo.hxx:175
bool bPivotExpandButton
Definition: fillinfo.hxx:185
bool operator!=(const ScDataBarInfo &r) const
Definition: fillinfo.hxx:85
double mnZero
Definition: fillinfo.hxx:64
Color maAxisColor
Definition: fillinfo.hxx:69
bool operator==(const ScDataBarInfo &r) const
Definition: fillinfo.hxx:71
Color maColor
Definition: fillinfo.hxx:65
bool mbShowValue
Definition: fillinfo.hxx:68
double mnLength
Definition: fillinfo.hxx:66
bool mbGradient
Definition: fillinfo.hxx:67
tools::Long mnHeight
Definition: fillinfo.hxx:95
ScIconSetType eIconSetType
Definition: fillinfo.hxx:94
sal_Int32 nIconIndex
Definition: fillinfo.hxx:93
bool mbShowValue
Definition: fillinfo.hxx:96
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:108
SCSIZE mnArrCapacity
Definition: fillinfo.hxx:268
void addIconSetInfo(std::unique_ptr< const ScIconSetInfo > info)
Definition: fillinfo.hxx:280
std::vector< std::unique_ptr< const ScIconSetInfo > > mIconSetInfos
Definition: fillinfo.hxx:288
ScTableInfo(const SCSIZE capacity=1024)
Definition: fillinfo.cxx:1078
const ScTableInfo & operator=(const ScTableInfo &)=delete
SCSIZE mnArrCount
Definition: fillinfo.hxx:267
std::vector< std::unique_ptr< const ScDataBarInfo > > mDataBarInfos
Definition: fillinfo.hxx:287
std::unique_ptr< RowInfo[]> mpRowInfo
Definition: fillinfo.hxx:266
void addDataBarInfo(std::unique_ptr< const ScDataBarInfo > info)
Definition: fillinfo.hxx:276
ScTableInfo(const ScTableInfo &)=delete
svx::frame::Array maArray
Definition: fillinfo.hxx:264
bool mbPageMode
Definition: fillinfo.hxx:269
@ Left
Definition: tphfedit.hxx:40
@ Center
Definition: tphfedit.hxx:41
@ Right
Definition: tphfedit.hxx:42
unsigned char sal_uInt8
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17