LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / inc / fillinfo.hxx
blobecd836f89ec95153a381b8f8a88a81af00cbfc65
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 CellInfo 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 BasicCellInfo
105 BasicCellInfo()
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 CellInfo
117 CellInfo()
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
145 CellInfo(const CellInfo&) = delete;
146 const CellInfo& operator=(const CellInfo&) = delete;
148 ScRefCellValue maCell;
150 const ScPatternAttr* pPatternAttr;
151 const SfxItemSet* pConditionSet;
152 std::optional<Color> mxColorScale;
153 const ScDataBarInfo* pDataBar;
154 const ScIconSetInfo* pIconSet;
156 const SvxBrushItem* pBackground;
158 const SvxBoxItem* pLinesAttr; /// original item from document.
159 const SvxLineItem* mpTLBRLine; /// original item from document.
160 const SvxLineItem* mpBLTRLine; /// original item from document.
162 const SvxShadowItem* pShadowAttr; // original item (internal)
164 const SvxShadowItem* pHShadowOrigin;
165 const SvxShadowItem* pVShadowOrigin;
167 ScShadowPart eHShadowPart : 4; // shadow effective for drawing
168 ScShadowPart eVShadowPart : 4;
169 ScClipMark nClipMark;
170 ScRotateDir nRotateDir;
172 bool bMerged : 1;
173 bool bHOverlapped : 1;
174 bool bVOverlapped : 1;
175 bool bAutoFilter : 1;
176 bool bPivotButton:1;
177 bool bPivotPopupButton:1;
178 bool bFilterActive:1;
179 bool bPrinted : 1; // when required (pagebreak mode)
180 bool bHideGrid : 1; // output-internal
183 const SCCOL SC_ROTMAX_NONE = SCCOL_MAX;
185 struct RowInfo
187 RowInfo() = default;
188 RowInfo(const RowInfo&) = delete;
189 const RowInfo& operator=(const RowInfo&) = delete;
191 CellInfo& cellInfo(SCCOL nCol)
193 assert( nCol >= nStartCol - 1 );
194 #ifdef DBG_UTIL
195 assert( nCol <= nEndCol + 1 );
196 #endif
197 return pCellInfo[ nCol - nStartCol + 1 ];
199 const CellInfo& cellInfo(SCCOL nCol) const
201 return const_cast<RowInfo*>(this)->cellInfo(nCol);
204 BasicCellInfo& basicCellInfo(SCCOL nCol)
206 assert( nCol >= -1 );
207 #ifdef DBG_UTIL
208 assert( nCol <= nEndCol + 1 );
209 #endif
210 return pBasicCellInfo[ nCol + 1 ];
212 const BasicCellInfo& basicCellInfo(SCCOL nCol) const
214 return const_cast<RowInfo*>(this)->basicCellInfo(nCol);
217 void allocCellInfo(SCCOL startCol, SCCOL endCol)
219 nStartCol = startCol;
220 #ifdef DBG_UTIL
221 nEndCol = endCol;
222 #endif
223 pCellInfo = new CellInfo[ endCol - nStartCol + 1 + 2 ];
224 pBasicCellInfo = new BasicCellInfo[ endCol + 1 + 2 ];
226 void freeCellInfo()
228 delete[] pCellInfo;
229 delete[] pBasicCellInfo;
232 sal_uInt16 nHeight;
233 SCROW nRowNo;
234 SCCOL nRotMaxCol; // SC_ROTMAX_NONE, if nothing
236 bool bEmptyBack:1;
237 bool bAutoFilter:1;
238 bool bPivotButton:1;
239 bool bChanged:1; // TRUE, if not tested
241 private:
242 // This class allocates CellInfo 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. CellInfo is allocated only for a given
245 // range of columns plus one on each side, BasicCellInfo is allocated for columns
246 // starting from column 0 until the last column given, again plus one on each side.
247 CellInfo* pCellInfo;
248 BasicCellInfo* pBasicCellInfo;
249 SCCOL nStartCol;
250 #ifdef DBG_UTIL
251 SCCOL nEndCol;
252 #endif
255 struct ScTableInfo
257 svx::frame::Array maArray;
258 std::unique_ptr<RowInfo[]>
259 mpRowInfo;
260 SCSIZE mnArrCount;
261 SCSIZE mnArrCapacity;
262 bool mbPageMode;
264 explicit ScTableInfo(const SCSIZE capacity = 1024);
265 ~ScTableInfo();
266 ScTableInfo(const ScTableInfo&) = delete;
267 const ScTableInfo& operator=(const ScTableInfo&) = delete;
269 void addDataBarInfo(std::unique_ptr<const ScDataBarInfo> info)
271 mDataBarInfos.push_back(std::move(info));
273 void addIconSetInfo(std::unique_ptr<const ScIconSetInfo> info)
275 mIconSetInfos.push_back(std::move(info));
277 private:
278 // These are owned here and not in CellInfo to avoid freeing
279 // memory for every pointer in CellInfo, most of which are nullptr.
280 std::vector<std::unique_ptr<const ScDataBarInfo>> mDataBarInfos;
281 std::vector<std::unique_ptr<const ScIconSetInfo>> mIconSetInfos;
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */