tdf#48459 sw inline heading: don't apply inside frames or over 120 chars
[LibreOffice.git] / sc / inc / attrib.hxx
blobec004f37d8b6c82ee6ebe2131013f241825441e6
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 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
49 namespace o3tl {
50 template<> struct typed_flags<ScMF> : is_typed_flags<ScMF, 0x07ff> {};
53 class EditTextObject;
54 namespace editeng { class SvxBorderLine; }
56 bool SC_DLLPUBLIC ScHasPriority( const ::editeng::SvxBorderLine* pThis, const ::editeng::SvxBorderLine* pOther );
58 class SC_DLLPUBLIC ScMergeAttr final : public SfxPoolItem
60 SCCOL nColMerge;
61 SCROW nRowMerge;
62 public:
63 ScMergeAttr();
64 ScMergeAttr( SCCOL nCol, SCROW nRow );
65 ScMergeAttr( const ScMergeAttr& );
66 virtual ~ScMergeAttr() override;
68 virtual bool operator==( const SfxPoolItem& ) const override;
69 virtual ScMergeAttr* Clone( SfxItemPool *pPool = nullptr ) const override;
71 SCCOL GetColMerge() const {return nColMerge; }
72 SCROW GetRowMerge() const {return nRowMerge; }
74 bool IsMerged() const { return nColMerge>1 || nRowMerge>1; }
76 ScMergeAttr& operator=(const ScMergeAttr& rMerge)
78 nColMerge = rMerge.nColMerge;
79 nRowMerge = rMerge.nRowMerge;
80 return *this;
83 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
86 class SC_DLLPUBLIC ScMergeFlagAttr final : public SfxInt16Item
88 public:
89 ScMergeFlagAttr();
90 ScMergeFlagAttr(ScMF nFlags);
91 virtual ~ScMergeFlagAttr() override;
93 ScMergeFlagAttr(ScMergeFlagAttr const &) = default;
94 ScMergeFlagAttr(ScMergeFlagAttr &&) = default;
95 ScMergeFlagAttr & operator =(ScMergeFlagAttr const &) = delete; // due to SfxInt16Item
96 ScMergeFlagAttr & operator =(ScMergeFlagAttr &&) = delete; // due to SfxInt16Item
98 ScMergeFlagAttr* Clone(SfxItemPool * pPool = nullptr) const override;
100 ScMF GetValue() const { return static_cast<ScMF>(SfxInt16Item::GetValue()); }
102 bool IsHorOverlapped() const { return bool( GetValue() & ScMF::Hor ); }
103 bool IsVerOverlapped() const { return bool( GetValue() & ScMF::Ver ); }
104 bool IsOverlapped() const { return bool( GetValue() & ( ScMF::Hor | ScMF::Ver ) ); }
106 bool HasAutoFilter() const { return bool( GetValue() & ScMF::Auto ); }
108 bool IsScenario() const { return bool( GetValue() & ScMF::Scenario ); }
110 bool HasPivotButton() const;
111 bool HasPivotPopupButton() const;
112 bool HasPivotToggle() const;
113 bool HasPivotMultiFieldPopupButton() const;
115 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
118 class SC_DLLPUBLIC ScProtectionAttr final : public SfxPoolItem
120 bool bProtection; ///< protect cell
121 bool bHideFormula; ///< hide formula
122 bool bHideCell; ///< hide cell
123 bool bHidePrint; ///< don't print cell
124 public:
125 static SfxPoolItem* CreateDefault();
126 ScProtectionAttr();
127 ScProtectionAttr( bool bProtect,
128 bool bHFormula = false,
129 bool bHCell = false,
130 bool bHPrint = false);
131 ScProtectionAttr( const ScProtectionAttr& );
132 virtual ~ScProtectionAttr() override;
134 OUString GetValueText() const;
135 virtual bool GetPresentation(
136 SfxItemPresentation ePres,
137 MapUnit eCoreMetric,
138 MapUnit ePresMetric,
139 OUString& rText,
140 const IntlWrapper& rIntl ) const override;
142 virtual bool operator==( const SfxPoolItem& ) const override;
143 virtual ScProtectionAttr* Clone( SfxItemPool *pPool = nullptr ) const override;
145 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
146 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
148 bool GetProtection() const { return bProtection; }
149 void SetProtection( bool bProtect);
150 bool GetHideFormula() const { return bHideFormula; }
151 void SetHideFormula( bool bHFormula);
152 bool GetHideCell() const { return bHideCell; }
153 void SetHideCell( bool bHCell);
154 bool GetHidePrint() const { return bHidePrint; }
155 void SetHidePrint( bool bHPrint);
156 ScProtectionAttr& operator=(const ScProtectionAttr& rProtection)
158 bProtection = rProtection.bProtection;
159 bHideFormula = rProtection.bHideFormula;
160 bHideCell = rProtection.bHideCell;
161 bHidePrint = rProtection.bHidePrint;
162 return *this;
164 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
167 // page format item: contents of header and footer
169 #define SC_HF_LEFTAREA 1
170 #define SC_HF_CENTERAREA 2
171 #define SC_HF_RIGHTAREA 3
173 class SC_DLLPUBLIC ScPageHFItem final : public SfxPoolItem
175 std::unique_ptr<EditTextObject> pLeftArea;
176 std::unique_ptr<EditTextObject> pCenterArea;
177 std::unique_ptr<EditTextObject> pRightArea;
179 public:
180 ScPageHFItem( sal_uInt16 nWhich );
181 ScPageHFItem( const ScPageHFItem& rItem );
182 virtual ~ScPageHFItem() override;
184 virtual bool operator==( const SfxPoolItem& ) const override;
185 virtual ScPageHFItem* Clone( SfxItemPool *pPool = nullptr ) const override;
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;
190 const EditTextObject* GetLeftArea() const { return pLeftArea.get(); }
191 const EditTextObject* GetCenterArea() const { return pCenterArea.get(); }
192 const EditTextObject* GetRightArea() const { return pRightArea.get(); }
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;
200 // page format item: contents of header and footer
202 class SC_DLLPUBLIC ScViewObjectModeItem final : public SfxEnumItem<ScVObjMode>
204 public:
205 ScViewObjectModeItem( sal_uInt16 nWhich );
206 ScViewObjectModeItem( sal_uInt16 nWhich, ScVObjMode eMode );
207 virtual ~ScViewObjectModeItem() override;
209 ScViewObjectModeItem(ScViewObjectModeItem const &) = default;
210 ScViewObjectModeItem(ScViewObjectModeItem &&) = default;
211 ScViewObjectModeItem & operator =(ScViewObjectModeItem const &) = delete; // due to SfxEnumItem<ScVObjMode>
212 ScViewObjectModeItem & operator =(ScViewObjectModeItem &&) = delete; // due to SfxEnumItem<ScVObjMode>
214 virtual sal_uInt16 GetValueCount() const override;
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;
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;
228 /** Contains the "scale to width/height" attribute in page styles. */
229 class SC_DLLPUBLIC ScPageScaleToItem final : public SfxPoolItem
231 public:
232 /** Default c'tor sets the width and height to 0. */
233 explicit ScPageScaleToItem();
234 explicit ScPageScaleToItem( sal_uInt16 nWidth, sal_uInt16 nHeight );
236 virtual ~ScPageScaleToItem() override;
238 ScPageScaleToItem(ScPageScaleToItem const &) = default;
239 ScPageScaleToItem(ScPageScaleToItem &&) = default;
240 ScPageScaleToItem & operator =(ScPageScaleToItem const &) = delete; // due to SfxPoolItem
241 ScPageScaleToItem & operator =(ScPageScaleToItem &&) = delete; // due to SfxPoolItem
243 virtual ScPageScaleToItem* Clone( SfxItemPool* = nullptr ) const override;
245 virtual bool operator==( const SfxPoolItem& rCmp ) const override;
247 sal_uInt16 GetWidth() const { return mnWidth; }
248 sal_uInt16 GetHeight() const { return mnHeight; }
249 bool IsValid() const { return mnWidth || mnHeight; }
251 void SetWidth( sal_uInt16 nWidth ) { mnWidth = nWidth; }
252 void SetHeight( sal_uInt16 nHeight ) { mnHeight = nHeight; }
253 void Set( sal_uInt16 nWidth, sal_uInt16 nHeight )
254 { mnWidth = nWidth; mnHeight = nHeight; }
256 virtual bool GetPresentation( SfxItemPresentation ePresentation,
257 MapUnit, MapUnit,
258 OUString& rText,
259 const IntlWrapper& ) const override;
261 virtual bool QueryValue( css::uno::Any& rAny, sal_uInt8 nMemberId = 0 ) const override;
262 virtual bool PutValue( const css::uno::Any& rAny, sal_uInt8 nMemberId ) override;
263 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
265 private:
266 sal_uInt16 mnWidth;
267 sal_uInt16 mnHeight;
270 typedef o3tl::sorted_vector<sal_uInt32> ScCondFormatIndexes;
272 class SAL_DLLPUBLIC_RTTI ScCondFormatItem final : public SfxPoolItem
274 public:
275 explicit ScCondFormatItem();
276 explicit ScCondFormatItem(sal_uInt32 nIndex);
277 explicit ScCondFormatItem(const ScCondFormatIndexes& );
278 explicit ScCondFormatItem(ScCondFormatIndexes&&) noexcept;
280 virtual ~ScCondFormatItem() override;
282 virtual bool operator==(const SfxPoolItem& rCmp ) const override;
283 virtual ScCondFormatItem* Clone( SfxItemPool* = nullptr ) const override;
285 const ScCondFormatIndexes& GetCondFormatData() const { return maIndex;}
287 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
289 private:
290 ScCondFormatIndexes maIndex;
293 class SC_DLLPUBLIC ScRotateValueItem final : public SdrAngleItem
295 public:
296 ScRotateValueItem(Degree100 nAngle);
297 virtual ScRotateValueItem* Clone(SfxItemPool* pPool=nullptr) const override;
299 virtual bool GetPresentation( SfxItemPresentation ePresentation,
300 MapUnit, MapUnit,
301 OUString& rText,
302 const IntlWrapper& rIntl) const override;
305 class SC_DLLPUBLIC ScShrinkToFitCell final : public SfxBoolItem
307 public:
308 ScShrinkToFitCell(bool bShrink = false);
309 virtual ScShrinkToFitCell* Clone(SfxItemPool *pPool = nullptr) const override;
310 virtual bool GetPresentation(SfxItemPresentation ePres,
311 MapUnit eCoreMetric,
312 MapUnit ePresMetric,
313 OUString &rText,
314 const IntlWrapper& rIntl) const override;
317 class SC_DLLPUBLIC ScVerticalStackCell final : public SfxBoolItem
319 public:
320 ScVerticalStackCell(bool bStack = false);
321 virtual ScVerticalStackCell* Clone(SfxItemPool *pPool = nullptr) const override;
322 virtual bool GetPresentation(SfxItemPresentation ePres,
323 MapUnit eCoreMetric,
324 MapUnit ePresMetric,
325 OUString &rText,
326 const IntlWrapper& rIntl) const override;
329 class SC_DLLPUBLIC ScLineBreakCell final : public SfxBoolItem
331 public:
332 ScLineBreakCell(bool bLineBreak = false);
333 virtual ScLineBreakCell* Clone(SfxItemPool *pPool = nullptr) const override;
334 virtual bool GetPresentation(SfxItemPresentation ePres,
335 MapUnit eCoreMetric,
336 MapUnit ePresMetric,
337 OUString &rText,
338 const IntlWrapper& rIntl) const override;
341 class ScHyphenateCell final : public SfxBoolItem
343 public:
344 ScHyphenateCell(bool bHyphenate= false);
345 virtual ScHyphenateCell* Clone(SfxItemPool *pPool = nullptr) const override;
346 virtual bool GetPresentation(SfxItemPresentation ePres,
347 MapUnit eCoreMetric,
348 MapUnit ePresMetric,
349 OUString &rText,
350 const IntlWrapper& rIntl) const override;
353 class SC_DLLPUBLIC ScIndentItem final : public SfxUInt16Item
355 public:
356 ScIndentItem(sal_uInt16 nIndent = 0);
357 virtual ScIndentItem* Clone(SfxItemPool* pPool=nullptr) const override;
359 virtual bool GetPresentation( SfxItemPresentation ePresentation,
360 MapUnit, MapUnit,
361 OUString& rText,
362 const IntlWrapper& rIntl) const override;
365 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */