/src/libreoffice/sc/inc/attrib.hxx
Line | Count | Source |
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 <memory> |
23 | | #include <svl/poolitem.hxx> |
24 | | #include <svl/intitem.hxx> |
25 | | #include <svl/eitem.hxx> |
26 | | #include <svx/sdangitm.hxx> |
27 | | #include <o3tl/sorted_vector.hxx> |
28 | | #include <o3tl/typed_flags_set.hxx> |
29 | | #include "scdllapi.h" |
30 | | #include "global.hxx" |
31 | | |
32 | | // flags for cells hidden by merge |
33 | | // and control for auto filter |
34 | | enum class ScMF { |
35 | | NONE = 0x0000, |
36 | | Hor = 0x0001, |
37 | | Ver = 0x0002, |
38 | | Auto = 0x0004, /// autofilter arrow |
39 | | Button = 0x0008, /// field button for datapilot |
40 | | Scenario = 0x0010, |
41 | | ButtonPopup = 0x0020, /// dp button with popup arrow |
42 | | HiddenMember = 0x0040, /// dp field button with presence of hidden member |
43 | | DpTable = 0x0080, /// dp table output |
44 | | DpCollapse = 0x0100, /// dp compact layout collapse button |
45 | | DpExpand = 0x0200, /// dp compact layout expand button |
46 | | ButtonPopup2 = 0x0400, /// dp button with popup arrow for multiple fields |
47 | | All = 0x07FF |
48 | | }; |
49 | | namespace o3tl { |
50 | | template<> struct typed_flags<ScMF> : is_typed_flags<ScMF, 0x07ff> {}; |
51 | | } |
52 | | |
53 | | class EditTextObject; |
54 | | namespace editeng { class SvxBorderLine; } |
55 | | |
56 | | bool SC_DLLPUBLIC ScHasPriority( const ::editeng::SvxBorderLine* pThis, const ::editeng::SvxBorderLine* pOther ); |
57 | | |
58 | | class SC_DLLPUBLIC ScMergeAttr final : public SfxPoolItem |
59 | | { |
60 | | SCCOL nColMerge; |
61 | | SCROW nRowMerge; |
62 | | public: |
63 | | DECLARE_ITEM_TYPE_FUNCTION(ScMergeAttr) |
64 | | ScMergeAttr(); |
65 | | ScMergeAttr( SCCOL nCol, SCROW nRow ); |
66 | | ScMergeAttr( const ScMergeAttr& ); |
67 | | virtual ~ScMergeAttr() override; |
68 | | |
69 | | virtual bool operator==( const SfxPoolItem& ) const override; |
70 | | virtual ScMergeAttr* Clone( SfxItemPool *pPool = nullptr ) const override; |
71 | | |
72 | 153k | SCCOL GetColMerge() const {return nColMerge; } |
73 | 4.02M | SCROW GetRowMerge() const {return nRowMerge; } |
74 | | |
75 | 0 | bool IsMerged() const { return nColMerge>1 || nRowMerge>1; } |
76 | | |
77 | | ScMergeAttr& operator=(const ScMergeAttr& rMerge) |
78 | 0 | { |
79 | 0 | nColMerge = rMerge.nColMerge; |
80 | 0 | nRowMerge = rMerge.nRowMerge; |
81 | 0 | return *this; |
82 | 0 | } |
83 | | |
84 | | virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; |
85 | | }; |
86 | | |
87 | | class SC_DLLPUBLIC ScMergeFlagAttr final : public SfxInt16Item |
88 | | { |
89 | | public: |
90 | | ScMergeFlagAttr(); |
91 | | ScMergeFlagAttr(ScMF nFlags); |
92 | | virtual ~ScMergeFlagAttr() override; |
93 | | |
94 | | DECLARE_ITEM_TYPE_FUNCTION(ScMergeFlagAttr) |
95 | 11.4M | ScMergeFlagAttr(ScMergeFlagAttr const &) = default; |
96 | | ScMergeFlagAttr(ScMergeFlagAttr &&) = default; |
97 | | ScMergeFlagAttr & operator =(ScMergeFlagAttr const &) = delete; // due to SfxInt16Item |
98 | | ScMergeFlagAttr & operator =(ScMergeFlagAttr &&) = delete; // due to SfxInt16Item |
99 | | |
100 | | ScMergeFlagAttr* Clone(SfxItemPool * pPool = nullptr) const override; |
101 | | |
102 | 124M | ScMF GetValue() const { return static_cast<ScMF>(SfxInt16Item::GetValue()); } |
103 | | |
104 | 1.88k | bool IsHorOverlapped() const { return bool( GetValue() & ScMF::Hor ); } |
105 | 73.0k | bool IsVerOverlapped() const { return bool( GetValue() & ScMF::Ver ); } |
106 | 4.15M | bool IsOverlapped() const { return bool( GetValue() & ( ScMF::Hor | ScMF::Ver ) ); } |
107 | | |
108 | 92.1M | bool HasAutoFilter() const { return bool( GetValue() & ScMF::Auto ); } |
109 | | |
110 | 15.4k | bool IsScenario() const { return bool( GetValue() & ScMF::Scenario ); } |
111 | | |
112 | | bool HasPivotButton() const; |
113 | | bool HasPivotPopupButton() const; |
114 | | bool HasPivotToggle() const; |
115 | | bool HasPivotMultiFieldPopupButton() const; |
116 | | |
117 | | virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; |
118 | | }; |
119 | | |
120 | | class SC_DLLPUBLIC ScProtectionAttr final : public SfxPoolItem |
121 | | { |
122 | | bool bProtection; ///< protect cell |
123 | | bool bHideFormula; ///< hide formula |
124 | | bool bHideCell; ///< hide cell |
125 | | bool bHidePrint; ///< don't print cell |
126 | | public: |
127 | | static SfxPoolItem* CreateDefault(); |
128 | | DECLARE_ITEM_TYPE_FUNCTION(ScProtectionAttr) |
129 | | ScProtectionAttr(); |
130 | | ScProtectionAttr( bool bProtect, |
131 | | bool bHFormula = false, |
132 | | bool bHCell = false, |
133 | | bool bHPrint = false); |
134 | | ScProtectionAttr( const ScProtectionAttr& ); |
135 | | virtual ~ScProtectionAttr() override; |
136 | | |
137 | | OUString GetValueText() const; |
138 | | virtual bool GetPresentation( |
139 | | SfxItemPresentation ePres, |
140 | | MapUnit eCoreMetric, |
141 | | MapUnit ePresMetric, |
142 | | OUString& rText, |
143 | | const IntlWrapper& rIntl ) const override; |
144 | | |
145 | | virtual bool operator==( const SfxPoolItem& ) const override; |
146 | | virtual ScProtectionAttr* Clone( SfxItemPool *pPool = nullptr ) const override; |
147 | | |
148 | | virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; |
149 | | virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; |
150 | | |
151 | 0 | bool GetProtection() const { return bProtection; } |
152 | | void SetProtection( bool bProtect); |
153 | 0 | bool GetHideFormula() const { return bHideFormula; } |
154 | | void SetHideFormula( bool bHFormula); |
155 | 0 | bool GetHideCell() const { return bHideCell; } |
156 | | void SetHideCell( bool bHCell); |
157 | 0 | bool GetHidePrint() const { return bHidePrint; } |
158 | | void SetHidePrint( bool bHPrint); |
159 | | ScProtectionAttr& operator=(const ScProtectionAttr& rProtection) |
160 | 0 | { |
161 | 0 | bProtection = rProtection.bProtection; |
162 | 0 | bHideFormula = rProtection.bHideFormula; |
163 | 0 | bHideCell = rProtection.bHideCell; |
164 | 0 | bHidePrint = rProtection.bHidePrint; |
165 | 0 | return *this; |
166 | 0 | } |
167 | | virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; |
168 | | }; |
169 | | |
170 | | // page format item: contents of header and footer |
171 | | |
172 | | class SC_DLLPUBLIC ScPageHFItem final : public SfxPoolItem |
173 | | { |
174 | | std::unique_ptr<EditTextObject> pLeftArea; |
175 | | std::unique_ptr<EditTextObject> pCenterArea; |
176 | | std::unique_ptr<EditTextObject> pRightArea; |
177 | | |
178 | | public: |
179 | | DECLARE_ITEM_TYPE_FUNCTION(ScPageHFItem) |
180 | | ScPageHFItem( sal_uInt16 nWhich ); |
181 | | ScPageHFItem( const ScPageHFItem& rItem ); |
182 | | virtual ~ScPageHFItem() override; |
183 | | |
184 | | virtual bool operator==( const SfxPoolItem& ) const override; |
185 | | virtual ScPageHFItem* Clone( SfxItemPool *pPool = nullptr ) const override; |
186 | | |
187 | | virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; |
188 | | virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; |
189 | | |
190 | 134k | const EditTextObject* GetLeftArea() const { return pLeftArea.get(); } |
191 | 134k | const EditTextObject* GetCenterArea() const { return pCenterArea.get(); } |
192 | 134k | const EditTextObject* GetRightArea() const { return pRightArea.get(); } |
193 | | |
194 | | void SetLeftArea( const EditTextObject& rNew ); |
195 | | void SetCenterArea( const EditTextObject& rNew ); |
196 | | void SetRightArea( const EditTextObject& rNew ); |
197 | | virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; |
198 | | }; |
199 | | |
200 | | // page format item: contents of header and footer |
201 | | |
202 | | class SC_DLLPUBLIC ScViewObjectModeItem final : public SfxEnumItem<ScVObjMode> |
203 | | { |
204 | | public: |
205 | | DECLARE_ITEM_TYPE_FUNCTION(ScViewObjectModeItem) |
206 | | ScViewObjectModeItem( sal_uInt16 nWhich ); |
207 | | ScViewObjectModeItem( sal_uInt16 nWhich, ScVObjMode eMode ); |
208 | | virtual ~ScViewObjectModeItem() override; |
209 | | |
210 | 762 | ScViewObjectModeItem(ScViewObjectModeItem const &) = default; |
211 | | ScViewObjectModeItem(ScViewObjectModeItem &&) = default; |
212 | | ScViewObjectModeItem & operator =(ScViewObjectModeItem const &) = delete; // due to SfxEnumItem<ScVObjMode> |
213 | | ScViewObjectModeItem & operator =(ScViewObjectModeItem &&) = delete; // due to SfxEnumItem<ScVObjMode> |
214 | | |
215 | | virtual ScViewObjectModeItem* Clone( SfxItemPool *pPool = nullptr ) const override; |
216 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
217 | | MapUnit eCoreMetric, |
218 | | MapUnit ePresMetric, |
219 | | OUString& rText, |
220 | | const IntlWrapper& rIntl ) const override; |
221 | | }; |
222 | | |
223 | | /** Member ID for "page scale to width" value in QueryValue() and PutValue(). */ |
224 | | const sal_uInt8 SC_MID_PAGE_SCALETO_WIDTH = 1; |
225 | | /** Member ID for "page scale to height" value in QueryValue() and PutValue(). */ |
226 | | const sal_uInt8 SC_MID_PAGE_SCALETO_HEIGHT = 2; |
227 | | |
228 | | /** Contains the "scale to width/height" attribute in page styles. */ |
229 | | class SC_DLLPUBLIC ScPageScaleToItem final : public SfxPoolItem |
230 | | { |
231 | | public: |
232 | | /** Default c'tor sets the width and height to 0. */ |
233 | | DECLARE_ITEM_TYPE_FUNCTION(ScPageScaleToItem) |
234 | | explicit ScPageScaleToItem(); |
235 | | explicit ScPageScaleToItem( sal_uInt16 nWidth, sal_uInt16 nHeight ); |
236 | | |
237 | | virtual ~ScPageScaleToItem() override; |
238 | | |
239 | 73.8k | ScPageScaleToItem(ScPageScaleToItem const &) = default; |
240 | | ScPageScaleToItem(ScPageScaleToItem &&) = default; |
241 | | ScPageScaleToItem & operator =(ScPageScaleToItem const &) = delete; // due to SfxPoolItem |
242 | | ScPageScaleToItem & operator =(ScPageScaleToItem &&) = delete; // due to SfxPoolItem |
243 | | |
244 | | virtual ScPageScaleToItem* Clone( SfxItemPool* = nullptr ) const override; |
245 | | |
246 | | virtual bool operator==( const SfxPoolItem& rCmp ) const override; |
247 | | |
248 | 42.1k | sal_uInt16 GetWidth() const { return mnWidth; } |
249 | 42.1k | sal_uInt16 GetHeight() const { return mnHeight; } |
250 | 42.1k | bool IsValid() const { return mnWidth || mnHeight; } |
251 | | |
252 | 436 | void SetWidth( sal_uInt16 nWidth ) { mnWidth = nWidth; } |
253 | 436 | void SetHeight( sal_uInt16 nHeight ) { mnHeight = nHeight; } |
254 | | void Set( sal_uInt16 nWidth, sal_uInt16 nHeight ) |
255 | 0 | { mnWidth = nWidth; mnHeight = nHeight; } |
256 | | |
257 | | virtual bool GetPresentation( SfxItemPresentation ePresentation, |
258 | | MapUnit, MapUnit, |
259 | | OUString& rText, |
260 | | const IntlWrapper& ) const override; |
261 | | |
262 | | virtual bool QueryValue( css::uno::Any& rAny, sal_uInt8 nMemberId = 0 ) const override; |
263 | | virtual bool PutValue( const css::uno::Any& rAny, sal_uInt8 nMemberId ) override; |
264 | | virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; |
265 | | |
266 | | private: |
267 | | sal_uInt16 mnWidth; |
268 | | sal_uInt16 mnHeight; |
269 | | }; |
270 | | |
271 | | typedef o3tl::sorted_vector<sal_uInt32> ScCondFormatIndexes; |
272 | | |
273 | | class SAL_DLLPUBLIC_RTTI ScCondFormatItem final : public SfxPoolItem |
274 | | { |
275 | | public: |
276 | | DECLARE_ITEM_TYPE_FUNCTION(ScCondFormatItem) |
277 | | explicit ScCondFormatItem(); |
278 | | explicit ScCondFormatItem(sal_uInt32 nIndex); |
279 | | explicit ScCondFormatItem(const ScCondFormatIndexes& ); |
280 | | explicit ScCondFormatItem(ScCondFormatIndexes&&) noexcept; |
281 | | |
282 | | virtual ~ScCondFormatItem() override; |
283 | | |
284 | | virtual bool operator==(const SfxPoolItem& rCmp ) const override; |
285 | | virtual bool supportsHashCode() const override; |
286 | | virtual size_t hashCode() const override; |
287 | | virtual ScCondFormatItem* Clone( SfxItemPool* = nullptr ) const override; |
288 | | |
289 | 4.90M | const ScCondFormatIndexes& GetCondFormatData() const { return maIndex;} |
290 | | |
291 | | virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; |
292 | | |
293 | | private: |
294 | | ScCondFormatIndexes maIndex; |
295 | | }; |
296 | | |
297 | | class SC_DLLPUBLIC ScRotateValueItem final : public SdrAngleItem |
298 | | { |
299 | | public: |
300 | | DECLARE_ITEM_TYPE_FUNCTION(ScRotateValueItem) |
301 | | ScRotateValueItem(Degree100 nAngle); |
302 | | virtual ScRotateValueItem* Clone(SfxItemPool* pPool=nullptr) const override; |
303 | | |
304 | | virtual bool GetPresentation( SfxItemPresentation ePresentation, |
305 | | MapUnit, MapUnit, |
306 | | OUString& rText, |
307 | | const IntlWrapper& rIntl) const override; |
308 | | }; |
309 | | |
310 | | class SC_DLLPUBLIC ScShrinkToFitCell final : public SfxBoolItem |
311 | | { |
312 | | public: |
313 | | DECLARE_ITEM_TYPE_FUNCTION(ScShrinkToFitCell) |
314 | | ScShrinkToFitCell(bool bShrink = false); |
315 | | virtual ScShrinkToFitCell* Clone(SfxItemPool *pPool = nullptr) const override; |
316 | | virtual bool GetPresentation(SfxItemPresentation ePres, |
317 | | MapUnit eCoreMetric, |
318 | | MapUnit ePresMetric, |
319 | | OUString &rText, |
320 | | const IntlWrapper& rIntl) const override; |
321 | | }; |
322 | | |
323 | | class SC_DLLPUBLIC ScVerticalStackCell final : public SfxBoolItem |
324 | | { |
325 | | public: |
326 | | DECLARE_ITEM_TYPE_FUNCTION(ScVerticalStackCell) |
327 | | ScVerticalStackCell(bool bStack = false); |
328 | | virtual ScVerticalStackCell* Clone(SfxItemPool *pPool = nullptr) const override; |
329 | | virtual bool GetPresentation(SfxItemPresentation ePres, |
330 | | MapUnit eCoreMetric, |
331 | | MapUnit ePresMetric, |
332 | | OUString &rText, |
333 | | const IntlWrapper& rIntl) const override; |
334 | | }; |
335 | | |
336 | | class SC_DLLPUBLIC ScLineBreakCell final : public SfxBoolItem |
337 | | { |
338 | | public: |
339 | | DECLARE_ITEM_TYPE_FUNCTION(ScLineBreakCell) |
340 | | ScLineBreakCell(bool bLineBreak = false); |
341 | | virtual ScLineBreakCell* Clone(SfxItemPool *pPool = nullptr) const override; |
342 | | virtual bool GetPresentation(SfxItemPresentation ePres, |
343 | | MapUnit eCoreMetric, |
344 | | MapUnit ePresMetric, |
345 | | OUString &rText, |
346 | | const IntlWrapper& rIntl) const override; |
347 | | }; |
348 | | |
349 | | class ScHyphenateCell final : public SfxBoolItem |
350 | | { |
351 | | public: |
352 | | DECLARE_ITEM_TYPE_FUNCTION(ScHyphenateCell) |
353 | | ScHyphenateCell(bool bHyphenate= false); |
354 | | virtual ScHyphenateCell* Clone(SfxItemPool *pPool = nullptr) const override; |
355 | | virtual bool GetPresentation(SfxItemPresentation ePres, |
356 | | MapUnit eCoreMetric, |
357 | | MapUnit ePresMetric, |
358 | | OUString &rText, |
359 | | const IntlWrapper& rIntl) const override; |
360 | | }; |
361 | | |
362 | | class SC_DLLPUBLIC ScIndentItem final : public SfxUInt16Item |
363 | | { |
364 | | public: |
365 | | DECLARE_ITEM_TYPE_FUNCTION(ScIndentItem) |
366 | | ScIndentItem(sal_uInt16 nIndent = 0); |
367 | | virtual ScIndentItem* Clone(SfxItemPool* pPool=nullptr) const override; |
368 | | |
369 | | virtual bool GetPresentation( SfxItemPresentation ePresentation, |
370 | | MapUnit, MapUnit, |
371 | | OUString& rText, |
372 | | const IntlWrapper& rIntl) const override; |
373 | | }; |
374 | | |
375 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |