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 {
143 }
144
145 ScCellInfo(const ScCellInfo&) = delete;
146 const ScCellInfo& operator=(const ScCellInfo&) = delete;
147
149
152 std::optional<Color> mxColorScale;
155
157
161
162 const SvxShadowItem* pShadowAttr; // original item (internal)
163
166
167 ScShadowPart eHShadowPart : 4; // shadow effective for drawing
171
172 bool bMerged : 1;
173 bool bHOverlapped : 1;
174 bool bVOverlapped : 1;
175 bool bAutoFilter : 1;
179 bool bPrinted : 1; // when required (pagebreak mode)
180 bool bHideGrid : 1; // output-internal
181};
182
184
186{
187 RowInfo() = default;
188 RowInfo(const RowInfo&) = delete;
189 const RowInfo& operator=(const RowInfo&) = delete;
190
192 {
193 assert( nCol >= nStartCol - 1 );
194#ifdef DBG_UTIL
195 assert( nCol <= nEndCol + 1 );
196#endif
197 return pCellInfo[ nCol - nStartCol + 1 ];
198 }
199 const ScCellInfo& cellInfo(SCCOL nCol) const
200 {
201 return const_cast<RowInfo*>(this)->cellInfo(nCol);
202 }
203
205 {
206 assert( nCol >= -1 );
207#ifdef DBG_UTIL
208 assert( nCol <= nEndCol + 1 );
209#endif
210 return pBasicCellInfo[ nCol + 1 ];
211 }
213 {
214 return const_cast<RowInfo*>(this)->basicCellInfo(nCol);
215 }
216
217 void allocCellInfo(SCCOL startCol, SCCOL endCol)
218 {
219 nStartCol = startCol;
220#ifdef DBG_UTIL
221 nEndCol = endCol;
222#endif
223 pCellInfo = new ScCellInfo[ endCol - nStartCol + 1 + 2 ];
224 pBasicCellInfo = new ScBasicCellInfo[ endCol + 1 + 2 ];
225 }
227 {
228 delete[] pCellInfo;
229 delete[] pBasicCellInfo;
230 }
231
232 sal_uInt16 nHeight;
234 SCCOL nRotMaxCol; // SC_ROTMAX_NONE, if nothing
235
239 bool bChanged:1; // TRUE, if not tested
240
241private:
242 // This class allocates ScCellInfo 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. ScCellInfo is allocated only for a given
245 // range of columns plus one on each side, ScBasicCellInfo is allocated for columns
246 // starting from column 0 until the last column given, again plus one on each side.
250#ifdef DBG_UTIL
252#endif
253};
254
256{
258 std::unique_ptr<RowInfo[]>
263
264 explicit ScTableInfo(const SCSIZE capacity = 1024);
265 ~ScTableInfo();
266 ScTableInfo(const ScTableInfo&) = delete;
267 const ScTableInfo& operator=(const ScTableInfo&) = delete;
268
269 void addDataBarInfo(std::unique_ptr<const ScDataBarInfo> info)
270 {
271 mDataBarInfos.push_back(std::move(info));
272 }
273 void addIconSetInfo(std::unique_ptr<const ScIconSetInfo> info)
274 {
275 mIconSetInfos.push_back(std::move(info));
276 }
277private:
278 // These are owned here and not in ScCellInfo to avoid freeing
279 // memory for every pointer in ScCellInfo, most of which are nullptr.
280 std::vector<std::unique_ptr<const ScDataBarInfo>> mDataBarInfos;
281 std::vector<std::unique_ptr<const ScIconSetInfo>> mIconSetInfos;
282};
283
284/* 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:183
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:236
RowInfo()=default
const ScBasicCellInfo & basicCellInfo(SCCOL nCol) const
Definition: fillinfo.hxx:212
bool bPivotButton
Definition: fillinfo.hxx:238
SCROW nRowNo
Definition: fillinfo.hxx:233
ScCellInfo * pCellInfo
Definition: fillinfo.hxx:247
SCCOL nRotMaxCol
Definition: fillinfo.hxx:234
bool bAutoFilter
Definition: fillinfo.hxx:237
void freeCellInfo()
Definition: fillinfo.hxx:226
const RowInfo & operator=(const RowInfo &)=delete
RowInfo(const RowInfo &)=delete
ScCellInfo & cellInfo(SCCOL nCol)
Definition: fillinfo.hxx:191
ScBasicCellInfo * pBasicCellInfo
Definition: fillinfo.hxx:248
ScBasicCellInfo & basicCellInfo(SCCOL nCol)
Definition: fillinfo.hxx:204
void allocCellInfo(SCCOL startCol, SCCOL endCol)
Definition: fillinfo.hxx:217
sal_uInt16 nHeight
Definition: fillinfo.hxx:232
bool bChanged
Definition: fillinfo.hxx:239
SCCOL nEndCol
Definition: fillinfo.hxx:251
const ScCellInfo & cellInfo(SCCOL nCol) const
Definition: fillinfo.hxx:199
SCCOL nStartCol
Definition: fillinfo.hxx:249
sal_uInt16 nWidth
Definition: fillinfo.hxx:110
ScRotateDir nRotateDir
Definition: fillinfo.hxx:170
const SvxShadowItem * pVShadowOrigin
Definition: fillinfo.hxx:165
const SfxItemSet * pConditionSet
Definition: fillinfo.hxx:151
const SvxShadowItem * pHShadowOrigin
Definition: fillinfo.hxx:164
ScClipMark nClipMark
Definition: fillinfo.hxx:169
bool bHideGrid
Definition: fillinfo.hxx:180
ScShadowPart eVShadowPart
Definition: fillinfo.hxx:168
ScRefCellValue maCell
Definition: fillinfo.hxx:148
bool bPivotPopupButton
Definition: fillinfo.hxx:177
std::optional< Color > mxColorScale
Definition: fillinfo.hxx:152
bool bVOverlapped
Definition: fillinfo.hxx:174
ScCellInfo(const ScCellInfo &)=delete
const SvxShadowItem * pShadowAttr
original item from document.
Definition: fillinfo.hxx:162
const SvxLineItem * mpBLTRLine
original item from document.
Definition: fillinfo.hxx:160
const ScCellInfo & operator=(const ScCellInfo &)=delete
const SvxBoxItem * pLinesAttr
Definition: fillinfo.hxx:158
bool bFilterActive
Definition: fillinfo.hxx:178
const SvxLineItem * mpTLBRLine
original item from document.
Definition: fillinfo.hxx:159
const ScPatternAttr * pPatternAttr
Definition: fillinfo.hxx:150
ScShadowPart eHShadowPart
Definition: fillinfo.hxx:167
bool bPivotButton
Definition: fillinfo.hxx:176
bool bHOverlapped
Definition: fillinfo.hxx:173
const ScDataBarInfo * pDataBar
Definition: fillinfo.hxx:153
bool bPrinted
Definition: fillinfo.hxx:179
bool bAutoFilter
Definition: fillinfo.hxx:175
const SvxBrushItem * pBackground
Definition: fillinfo.hxx:156
const ScIconSetInfo * pIconSet
Definition: fillinfo.hxx:154
bool bMerged
Definition: fillinfo.hxx:172
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:261
void addIconSetInfo(std::unique_ptr< const ScIconSetInfo > info)
Definition: fillinfo.hxx:273
std::vector< std::unique_ptr< const ScIconSetInfo > > mIconSetInfos
Definition: fillinfo.hxx:281
ScTableInfo(const SCSIZE capacity=1024)
Definition: fillinfo.cxx:1049
const ScTableInfo & operator=(const ScTableInfo &)=delete
SCSIZE mnArrCount
Definition: fillinfo.hxx:260
std::vector< std::unique_ptr< const ScDataBarInfo > > mDataBarInfos
Definition: fillinfo.hxx:280
std::unique_ptr< RowInfo[]> mpRowInfo
Definition: fillinfo.hxx:259
void addDataBarInfo(std::unique_ptr< const ScDataBarInfo > info)
Definition: fillinfo.hxx:269
ScTableInfo(const ScTableInfo &)=delete
svx::frame::Array maArray
Definition: fillinfo.hxx:257
bool mbPageMode
Definition: fillinfo.hxx:262
@ 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