android: Update app-specific/MIME type icons
[LibreOffice.git] / sc / inc / fillinfo.hxx
blob81086ed358ba4cc7563f36e7f7742dedc522e79c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
22 #include <sal/config.h>
24 #include <memory>
26 #include <svx/framelinkarray.hxx>
27 #include "colorscale.hxx"
28 #include "cellvalue.hxx"
29 #include <o3tl/typed_flags_set.hxx>
30 #include <optional>
32 class SfxItemSet;
33 class SvxBrushItem;
34 class SvxBoxItem;
35 class SvxLineItem;
36 class SvxShadowItem;
38 class ScPatternAttr;
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
47 namespace o3tl {
48 template<> struct typed_flags<ScClipMark> : is_typed_flags<ScClipMark, 0x07> {};
51 const sal_uInt8 SC_CLIPMARK_SIZE = 64;
53 enum ScShadowPart
55 SC_SHADOW_HSTART,
56 SC_SHADOW_VSTART,
57 SC_SHADOW_HORIZ,
58 SC_SHADOW_VERT,
59 SC_SHADOW_CORNER
62 struct ScDataBarInfo
64 double mnZero; // 0 to 100
65 Color maColor;
66 double mnLength; // -100 to 100
67 bool mbGradient;
68 bool mbShowValue;
69 Color maAxisColor;
71 bool operator==(const ScDataBarInfo& r) const
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;
82 return true;
85 bool operator!=(const ScDataBarInfo& r) const
87 return !(*this == r);
91 struct ScIconSetInfo
93 sal_Int32 nIconIndex;
94 ScIconSetType eIconSetType;
95 tools::Long mnHeight = 0;
96 bool mbShowValue;
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
105 ScBasicCellInfo()
106 : nWidth(0)
107 , bEmptyCellText(true)
108 , bEditEngine(false) // view-internal
110 sal_uInt16 nWidth;
111 bool bEmptyCellText : 1;
112 bool bEditEngine : 1; // output-internal
115 struct ScCellInfo
117 ScCellInfo()
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)
129 , eHShadowPart(SC_SHADOW_HSTART)
130 , eVShadowPart(SC_SHADOW_HSTART)
131 , nClipMark(ScClipMark::NONE)
132 , nRotateDir(ScRotateDir::NONE)
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)
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;
175 bool bMerged : 1;
176 bool bHOverlapped : 1;
177 bool bVOverlapped : 1;
178 bool bAutoFilter : 1;
179 bool bPivotButton: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;
191 struct RowInfo
193 RowInfo() = default;
194 RowInfo(const RowInfo&) = delete;
195 const RowInfo& operator=(const RowInfo&) = delete;
197 ScCellInfo& cellInfo(SCCOL nCol)
199 assert( nCol >= nStartCol - 1 );
200 #ifdef DBG_UTIL
201 assert( nCol <= nEndCol + 1 );
202 #endif
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 );
213 #ifdef DBG_UTIL
214 assert( nCol <= nEndCol + 1 );
215 #endif
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;
226 #ifdef DBG_UTIL
227 nEndCol = endCol;
228 #endif
229 pCellInfo = new ScCellInfo[ endCol - nStartCol + 1 + 2 ];
230 pBasicCellInfo = new ScBasicCellInfo[ endCol + 1 + 2 ];
232 void freeCellInfo()
234 delete[] pCellInfo;
235 delete[] pBasicCellInfo;
238 sal_uInt16 nHeight;
239 SCROW nRowNo;
240 SCCOL nRotMaxCol; // SC_ROTMAX_NONE, if nothing
242 bool bEmptyBack:1;
243 bool bAutoFilter:1;
244 bool bPivotButton:1;
245 bool bChanged:1; // TRUE, if not tested
246 bool bPivotToggle:1;
248 private:
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;
256 SCCOL nStartCol;
257 #ifdef DBG_UTIL
258 SCCOL nEndCol;
259 #endif
262 struct ScTableInfo
264 svx::frame::Array maArray;
265 std::unique_ptr<RowInfo[]>
266 mpRowInfo;
267 SCSIZE mnArrCount;
268 SCSIZE mnArrCapacity;
269 bool mbPageMode;
271 explicit ScTableInfo(const SCSIZE capacity = 1024);
272 ~ScTableInfo();
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));
284 private:
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: */