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 
26 #include <svx/framelinkarray.hxx>
27 #include "colorscale.hxx"
28 #include "cellvalue.hxx"
29 #include <o3tl/typed_flags_set.hxx>
30 #include <optional>
31 
32 class SfxItemSet;
33 class SvxBrushItem;
34 class SvxBoxItem;
35 class SvxLineItem;
36 class SvxShadowItem;
37 
38 class ScPatternAttr;
39 
40 enum class ScRotateDir : sal_uInt8 {
42 };
43 
44 enum class ScClipMark : sal_uInt8 {
45  NONE = 0x00, Left = 0x01, Right = 0x02, Bottom = 0x03, Top = 0x04
46 };
47 namespace 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
67  bool mbGradient;
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;
111  bool bEmptyCellText : 1;
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)
136  , bAutoFilter(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;
176  bool bPivotButton:1;
179  bool bPrinted : 1; // when required (pagebreak mode)
180  bool bHideGrid : 1; // output-internal
181 };
182 
184 
185 struct RowInfo
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 
236  bool bEmptyBack:1;
237  bool bAutoFilter:1;
238  bool bPivotButton:1;
239  bool bChanged:1; // TRUE, if not tested
240 
241 private:
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  }
277 private:
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: */
ScRotateDir nRotateDir
Definition: fillinfo.hxx:170
std::optional< Color > mxColorScale
Definition: fillinfo.hxx:152
std::unique_ptr< RowInfo[]> mpRowInfo
Definition: fillinfo.hxx:259
bool mbGradient
Definition: fillinfo.hxx:67
const RowInfo & operator=(const RowInfo &)=delete
const SCCOL SC_ROTMAX_NONE
Definition: fillinfo.hxx:183
bool mbPageMode
Definition: fillinfo.hxx:262
ScRotateDir
Definition: fillinfo.hxx:40
const ScBasicCellInfo & basicCellInfo(SCCOL nCol) const
Definition: fillinfo.hxx:212
long Long
const SCCOL SCCOL_MAX
Definition: address.hxx:56
bool bVOverlapped
Definition: fillinfo.hxx:174
SCSIZE mnArrCount
Definition: fillinfo.hxx:260
ScCellInfo * pCellInfo
Definition: fillinfo.hxx:247
std::vector< std::unique_ptr< const ScDataBarInfo > > mDataBarInfos
Definition: fillinfo.hxx:280
sal_Int32 nIconIndex
Definition: fillinfo.hxx:93
const sal_uInt8 SC_CLIPMARK_SIZE
Definition: fillinfo.hxx:51
const SvxShadowItem * pVShadowOrigin
Definition: fillinfo.hxx:165
double mnZero
Definition: fillinfo.hxx:64
SCCOL nEndCol
Definition: fillinfo.hxx:251
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:103
bool bPivotPopupButton
Definition: fillinfo.hxx:177
std::vector< std::unique_ptr< const ScIconSetInfo > > mIconSetInfos
Definition: fillinfo.hxx:281
ScRefCellValue maCell
Definition: fillinfo.hxx:148
double mnLength
Definition: fillinfo.hxx:66
SCROW nRowNo
Definition: fillinfo.hxx:233
const SvxShadowItem * pHShadowOrigin
Definition: fillinfo.hxx:164
Color maColor
Definition: fillinfo.hxx:65
NONE
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
ScCellInfo & cellInfo(SCCOL nCol)
Definition: fillinfo.hxx:191
ScTableInfo(const SCSIZE capacity=1024)
Definition: fillinfo.cxx:1049
bool bPrinted
Definition: fillinfo.hxx:179
ScClipMark nClipMark
Definition: fillinfo.hxx:169
sal_uInt16 nHeight
Definition: fillinfo.hxx:232
const ScTableInfo & operator=(const ScTableInfo &)=delete
SCCOL nStartCol
Definition: fillinfo.hxx:249
ScShadowPart
Definition: fillinfo.hxx:53
const SvxLineItem * mpBLTRLine
original item from document.
Definition: fillinfo.hxx:160
SCCOL nRotMaxCol
Definition: fillinfo.hxx:234
const SvxBoxItem * pLinesAttr
Definition: fillinfo.hxx:158
bool bChanged
Definition: fillinfo.hxx:239
ScBasicCellInfo * pBasicCellInfo
Definition: fillinfo.hxx:248
void addIconSetInfo(std::unique_ptr< const ScIconSetInfo > info)
Definition: fillinfo.hxx:273
ScIconSetType eIconSetType
Definition: fillinfo.hxx:94
sal_Int16 SCCOL
Definition: types.hxx:21
svx::frame::Array maArray
Definition: fillinfo.hxx:257
ScShadowPart eVShadowPart
Definition: fillinfo.hxx:168
const ScCellInfo & cellInfo(SCCOL nCol) const
Definition: fillinfo.hxx:199
bool bPivotButton
Definition: fillinfo.hxx:176
const ScPatternAttr * pPatternAttr
Definition: fillinfo.hxx:150
const SfxItemSet * pConditionSet
Definition: fillinfo.hxx:151
bool bEmptyBack
Definition: fillinfo.hxx:236
bool bFilterActive
Definition: fillinfo.hxx:178
ScBasicCellInfo & basicCellInfo(SCCOL nCol)
Definition: fillinfo.hxx:204
const SvxShadowItem * pShadowAttr
original item from document.
Definition: fillinfo.hxx:162
ScShadowPart eHShadowPart
Definition: fillinfo.hxx:167
void allocCellInfo(SCCOL startCol, SCCOL endCol)
Definition: fillinfo.hxx:217
bool bPivotButton
Definition: fillinfo.hxx:238
RowInfo()=default
SCSIZE mnArrCapacity
Definition: fillinfo.hxx:261
sal_Int32 SCROW
Definition: types.hxx:17
const SvxLineItem * mpTLBRLine
original item from document.
Definition: fillinfo.hxx:159
bool mbShowValue
Definition: fillinfo.hxx:96
bool bHOverlapped
Definition: fillinfo.hxx:173
bool operator!=(const ScDataBarInfo &r) const
Definition: fillinfo.hxx:85
Color maAxisColor
Definition: fillinfo.hxx:69
unsigned char sal_uInt8
const ScIconSetInfo * pIconSet
Definition: fillinfo.hxx:154
bool bAutoFilter
Definition: fillinfo.hxx:175
bool operator==(const ScDataBarInfo &r) const
Definition: fillinfo.hxx:71
tools::Long mnHeight
Definition: fillinfo.hxx:95
bool bHideGrid
Definition: fillinfo.hxx:180
ScIconSetType
Definition: colorscale.hxx:188
bool mbShowValue
Definition: fillinfo.hxx:68
ScClipMark
Definition: fillinfo.hxx:44
const SvxBrushItem * pBackground
Definition: fillinfo.hxx:156
bool bAutoFilter
Definition: fillinfo.hxx:237
const ScCellInfo & operator=(const ScCellInfo &)=delete
void addDataBarInfo(std::unique_ptr< const ScDataBarInfo > info)
Definition: fillinfo.hxx:269
bool bMerged
Definition: fillinfo.hxx:172
void freeCellInfo()
Definition: fillinfo.hxx:226
const ScDataBarInfo * pDataBar
Definition: fillinfo.hxx:153
bool m_bDetectedRangeSegmentation false
sal_uInt16 nWidth
Definition: fillinfo.hxx:110