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