LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / inc / attrib.hxx
blob92a0c3865c9c471b17d9155cca4f6d03df9a67e8
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 <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"
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 All = 0x00FF
46 namespace o3tl {
47 template<> struct typed_flags<ScMF> : is_typed_flags<ScMF, 0xff> {};
50 class EditTextObject;
51 namespace editeng { class SvxBorderLine; }
53 bool SC_DLLPUBLIC ScHasPriority( const ::editeng::SvxBorderLine* pThis, const ::editeng::SvxBorderLine* pOther );
55 class SC_DLLPUBLIC ScMergeAttr final : public SfxPoolItem
57 SCCOL nColMerge;
58 SCROW nRowMerge;
59 public:
60 ScMergeAttr();
61 ScMergeAttr( SCCOL nCol, SCROW nRow );
62 ScMergeAttr( const ScMergeAttr& );
63 virtual ~ScMergeAttr() override;
65 virtual bool operator==( const SfxPoolItem& ) const override;
66 virtual ScMergeAttr* Clone( SfxItemPool *pPool = nullptr ) const override;
68 SCCOL GetColMerge() const {return nColMerge; }
69 SCROW GetRowMerge() const {return nRowMerge; }
71 bool IsMerged() const { return nColMerge>1 || nRowMerge>1; }
73 ScMergeAttr& operator=(const ScMergeAttr& rMerge)
75 nColMerge = rMerge.nColMerge;
76 nRowMerge = rMerge.nRowMerge;
77 return *this;
80 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
83 class SC_DLLPUBLIC ScMergeFlagAttr final : public SfxInt16Item
85 public:
86 ScMergeFlagAttr();
87 ScMergeFlagAttr(ScMF nFlags);
88 virtual ~ScMergeFlagAttr() override;
90 ScMergeFlagAttr(ScMergeFlagAttr const &) = default;
91 ScMergeFlagAttr(ScMergeFlagAttr &&) = default;
92 ScMergeFlagAttr & operator =(ScMergeFlagAttr const &) = delete; // due to SfxInt16Item
93 ScMergeFlagAttr & operator =(ScMergeFlagAttr &&) = delete; // due to SfxInt16Item
95 ScMergeFlagAttr* Clone(SfxItemPool * pPool = nullptr) const override;
97 ScMF GetValue() const { return static_cast<ScMF>(SfxInt16Item::GetValue()); }
99 bool IsHorOverlapped() const { return bool( GetValue() & ScMF::Hor ); }
100 bool IsVerOverlapped() const { return bool( GetValue() & ScMF::Ver ); }
101 bool IsOverlapped() const { return bool( GetValue() & ( ScMF::Hor | ScMF::Ver ) ); }
103 bool HasAutoFilter() const { return bool( GetValue() & ScMF::Auto ); }
105 bool IsScenario() const { return bool( GetValue() & ScMF::Scenario ); }
107 bool HasPivotButton() const;
108 bool HasPivotPopupButton() const;
110 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
113 class SC_DLLPUBLIC ScProtectionAttr final : public SfxPoolItem
115 bool bProtection; ///< protect cell
116 bool bHideFormula; ///< hide formula
117 bool bHideCell; ///< hide cell
118 bool bHidePrint; ///< don't print cell
119 public:
120 static SfxPoolItem* CreateDefault();
121 ScProtectionAttr();
122 ScProtectionAttr( bool bProtect,
123 bool bHFormula = false,
124 bool bHCell = false,
125 bool bHPrint = false);
126 ScProtectionAttr( const ScProtectionAttr& );
127 virtual ~ScProtectionAttr() override;
129 OUString GetValueText() const;
130 virtual bool GetPresentation(
131 SfxItemPresentation ePres,
132 MapUnit eCoreMetric,
133 MapUnit ePresMetric,
134 OUString& rText,
135 const IntlWrapper& rIntl ) const override;
137 virtual bool operator==( const SfxPoolItem& ) const override;
138 virtual ScProtectionAttr* Clone( SfxItemPool *pPool = nullptr ) const override;
140 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
141 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
143 bool GetProtection() const { return bProtection; }
144 void SetProtection( bool bProtect);
145 bool GetHideFormula() const { return bHideFormula; }
146 void SetHideFormula( bool bHFormula);
147 bool GetHideCell() const { return bHideCell; }
148 void SetHideCell( bool bHCell);
149 bool GetHidePrint() const { return bHidePrint; }
150 void SetHidePrint( bool bHPrint);
151 ScProtectionAttr& operator=(const ScProtectionAttr& rProtection)
153 bProtection = rProtection.bProtection;
154 bHideFormula = rProtection.bHideFormula;
155 bHideCell = rProtection.bHideCell;
156 bHidePrint = rProtection.bHidePrint;
157 return *this;
159 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
162 // page format item: contents of header and footer
164 #define SC_HF_LEFTAREA 1
165 #define SC_HF_CENTERAREA 2
166 #define SC_HF_RIGHTAREA 3
168 class SC_DLLPUBLIC ScPageHFItem final : public SfxPoolItem
170 std::unique_ptr<EditTextObject> pLeftArea;
171 std::unique_ptr<EditTextObject> pCenterArea;
172 std::unique_ptr<EditTextObject> pRightArea;
174 public:
175 ScPageHFItem( sal_uInt16 nWhich );
176 ScPageHFItem( const ScPageHFItem& rItem );
177 virtual ~ScPageHFItem() override;
179 virtual bool operator==( const SfxPoolItem& ) const override;
180 virtual ScPageHFItem* Clone( SfxItemPool *pPool = nullptr ) const override;
182 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
183 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
185 const EditTextObject* GetLeftArea() const { return pLeftArea.get(); }
186 const EditTextObject* GetCenterArea() const { return pCenterArea.get(); }
187 const EditTextObject* GetRightArea() const { return pRightArea.get(); }
189 void SetLeftArea( const EditTextObject& rNew );
190 void SetCenterArea( const EditTextObject& rNew );
191 void SetRightArea( const EditTextObject& rNew );
192 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
195 // page format item: contents of header and footer
197 class SC_DLLPUBLIC ScViewObjectModeItem final : public SfxEnumItem<ScVObjMode>
199 public:
200 ScViewObjectModeItem( sal_uInt16 nWhich );
201 ScViewObjectModeItem( sal_uInt16 nWhich, ScVObjMode eMode );
202 virtual ~ScViewObjectModeItem() override;
204 ScViewObjectModeItem(ScViewObjectModeItem const &) = default;
205 ScViewObjectModeItem(ScViewObjectModeItem &&) = default;
206 ScViewObjectModeItem & operator =(ScViewObjectModeItem const &) = delete; // due to SfxEnumItem<ScVObjMode>
207 ScViewObjectModeItem & operator =(ScViewObjectModeItem &&) = delete; // due to SfxEnumItem<ScVObjMode>
209 virtual sal_uInt16 GetValueCount() const override;
210 virtual ScViewObjectModeItem* Clone( SfxItemPool *pPool = nullptr ) const override;
211 virtual bool GetPresentation( SfxItemPresentation ePres,
212 MapUnit eCoreMetric,
213 MapUnit ePresMetric,
214 OUString& rText,
215 const IntlWrapper& rIntl ) const override;
218 /** Member ID for "page scale to width" value in QueryValue() and PutValue(). */
219 const sal_uInt8 SC_MID_PAGE_SCALETO_WIDTH = 1;
220 /** Member ID for "page scale to height" value in QueryValue() and PutValue(). */
221 const sal_uInt8 SC_MID_PAGE_SCALETO_HEIGHT = 2;
223 /** Contains the "scale to width/height" attribute in page styles. */
224 class SC_DLLPUBLIC ScPageScaleToItem final : public SfxPoolItem
226 public:
227 /** Default c'tor sets the width and height to 0. */
228 explicit ScPageScaleToItem();
229 explicit ScPageScaleToItem( sal_uInt16 nWidth, sal_uInt16 nHeight );
231 virtual ~ScPageScaleToItem() override;
233 ScPageScaleToItem(ScPageScaleToItem const &) = default;
234 ScPageScaleToItem(ScPageScaleToItem &&) = default;
235 ScPageScaleToItem & operator =(ScPageScaleToItem const &) = delete; // due to SfxPoolItem
236 ScPageScaleToItem & operator =(ScPageScaleToItem &&) = delete; // due to SfxPoolItem
238 virtual ScPageScaleToItem* Clone( SfxItemPool* = nullptr ) const override;
240 virtual bool operator==( const SfxPoolItem& rCmp ) const override;
242 sal_uInt16 GetWidth() const { return mnWidth; }
243 sal_uInt16 GetHeight() const { return mnHeight; }
244 bool IsValid() const { return mnWidth || mnHeight; }
246 void SetWidth( sal_uInt16 nWidth ) { mnWidth = nWidth; }
247 void SetHeight( sal_uInt16 nHeight ) { mnHeight = nHeight; }
248 void Set( sal_uInt16 nWidth, sal_uInt16 nHeight )
249 { mnWidth = nWidth; mnHeight = nHeight; }
251 virtual bool GetPresentation( SfxItemPresentation ePresentation,
252 MapUnit, MapUnit,
253 OUString& rText,
254 const IntlWrapper& ) const override;
256 virtual bool QueryValue( css::uno::Any& rAny, sal_uInt8 nMemberId = 0 ) const override;
257 virtual bool PutValue( const css::uno::Any& rAny, sal_uInt8 nMemberId ) override;
258 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
260 private:
261 sal_uInt16 mnWidth;
262 sal_uInt16 mnHeight;
265 typedef o3tl::sorted_vector<sal_uInt32> ScCondFormatIndexes;
267 class ScCondFormatItem final : public SfxPoolItem
269 public:
270 explicit ScCondFormatItem();
271 explicit ScCondFormatItem(sal_uInt32 nIndex);
272 explicit ScCondFormatItem(const ScCondFormatIndexes& );
273 explicit ScCondFormatItem(ScCondFormatIndexes&&) noexcept;
275 virtual ~ScCondFormatItem() override;
277 virtual bool operator==(const SfxPoolItem& rCmp ) const override;
278 virtual bool operator<(const SfxPoolItem& rCmp) const override;
279 virtual bool IsSortable() const override { return true; }
280 virtual ScCondFormatItem* Clone( SfxItemPool* = nullptr ) const override;
282 const ScCondFormatIndexes& GetCondFormatData() const { return maIndex;}
284 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
286 private:
287 ScCondFormatIndexes maIndex;
290 class SC_DLLPUBLIC ScRotateValueItem final : public SdrAngleItem
292 public:
293 ScRotateValueItem(Degree100 nAngle);
294 virtual ScRotateValueItem* Clone(SfxItemPool* pPool=nullptr) const override;
296 virtual bool GetPresentation( SfxItemPresentation ePresentation,
297 MapUnit, MapUnit,
298 OUString& rText,
299 const IntlWrapper& rIntl) const override;
302 class SC_DLLPUBLIC ScShrinkToFitCell final : public SfxBoolItem
304 public:
305 ScShrinkToFitCell(bool bShrink = false);
306 virtual ScShrinkToFitCell* Clone(SfxItemPool *pPool = nullptr) const override;
307 virtual bool GetPresentation(SfxItemPresentation ePres,
308 MapUnit eCoreMetric,
309 MapUnit ePresMetric,
310 OUString &rText,
311 const IntlWrapper& rIntl) const override;
314 class SC_DLLPUBLIC ScVerticalStackCell final : public SfxBoolItem
316 public:
317 ScVerticalStackCell(bool bStack = false);
318 virtual ScVerticalStackCell* Clone(SfxItemPool *pPool = nullptr) const override;
319 virtual bool GetPresentation(SfxItemPresentation ePres,
320 MapUnit eCoreMetric,
321 MapUnit ePresMetric,
322 OUString &rText,
323 const IntlWrapper& rIntl) const override;
326 class SC_DLLPUBLIC ScLineBreakCell final : public SfxBoolItem
328 public:
329 ScLineBreakCell(bool bLineBreak = false);
330 virtual ScLineBreakCell* Clone(SfxItemPool *pPool = nullptr) const override;
331 virtual bool GetPresentation(SfxItemPresentation ePres,
332 MapUnit eCoreMetric,
333 MapUnit ePresMetric,
334 OUString &rText,
335 const IntlWrapper& rIntl) const override;
338 class ScHyphenateCell final : public SfxBoolItem
340 public:
341 ScHyphenateCell(bool bHyphenate= false);
342 virtual ScHyphenateCell* Clone(SfxItemPool *pPool = nullptr) const override;
343 virtual bool GetPresentation(SfxItemPresentation ePres,
344 MapUnit eCoreMetric,
345 MapUnit ePresMetric,
346 OUString &rText,
347 const IntlWrapper& rIntl) const override;
350 class SC_DLLPUBLIC ScIndentItem final : public SfxUInt16Item
352 public:
353 ScIndentItem(sal_uInt16 nIndent = 0);
354 virtual ScIndentItem* Clone(SfxItemPool* pPool=nullptr) const override;
356 virtual bool GetPresentation( SfxItemPresentation ePresentation,
357 MapUnit, MapUnit,
358 OUString& rText,
359 const IntlWrapper& rIntl) const override;
362 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */