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 #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,
39  Button = 0x0008,
40  Scenario = 0x0010,
41  ButtonPopup = 0x0020,
42  HiddenMember = 0x0040,
43  DpTable = 0x0080,
44  All = 0x00FF
45 };
46 namespace o3tl {
47  template<> struct typed_flags<ScMF> : is_typed_flags<ScMF, 0xff> {};
48 }
49 
50 class EditTextObject;
51 namespace editeng { class SvxBorderLine; }
52 
53 bool SC_DLLPUBLIC ScHasPriority( const ::editeng::SvxBorderLine* pThis, const ::editeng::SvxBorderLine* pOther );
54 
55 class SC_DLLPUBLIC ScMergeAttr final : public SfxPoolItem
56 {
59 public:
60  ScMergeAttr();
61  ScMergeAttr( SCCOL nCol, SCROW nRow );
62  ScMergeAttr( const ScMergeAttr& );
63  virtual ~ScMergeAttr() override;
64 
65  virtual bool operator==( const SfxPoolItem& ) const override;
66  virtual ScMergeAttr* Clone( SfxItemPool *pPool = nullptr ) const override;
67 
68  SCCOL GetColMerge() const {return nColMerge; }
69  SCROW GetRowMerge() const {return nRowMerge; }
70 
71  bool IsMerged() const { return nColMerge>1 || nRowMerge>1; }
72 
74  {
75  nColMerge = rMerge.nColMerge;
76  nRowMerge = rMerge.nRowMerge;
77  return *this;
78  }
79 
80  virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
81 };
82 
84 {
85 public:
87  ScMergeFlagAttr(ScMF nFlags);
88  virtual ~ScMergeFlagAttr() override;
89 
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
94 
95  ScMergeFlagAttr* Clone(SfxItemPool * pPool = nullptr) const override;
96 
97  ScMF GetValue() const { return static_cast<ScMF>(SfxInt16Item::GetValue()); }
98 
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 ) ); }
102 
103  bool HasAutoFilter() const { return bool( GetValue() & ScMF::Auto ); }
104 
105  bool IsScenario() const { return bool( GetValue() & ScMF::Scenario ); }
106 
107  bool HasPivotButton() const;
108  bool HasPivotPopupButton() const;
109 
110  virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
111 };
112 
114 {
115  bool bProtection;
117  bool bHideCell;
118  bool bHidePrint;
119 public:
120  static SfxPoolItem* CreateDefault();
122  ScProtectionAttr( bool bProtect,
123  bool bHFormula = false,
124  bool bHCell = false,
125  bool bHPrint = false);
127  virtual ~ScProtectionAttr() override;
128 
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;
136 
137  virtual bool operator==( const SfxPoolItem& ) const override;
138  virtual ScProtectionAttr* Clone( SfxItemPool *pPool = nullptr ) const override;
139 
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;
142 
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);
152  {
153  bProtection = rProtection.bProtection;
154  bHideFormula = rProtection.bHideFormula;
155  bHideCell = rProtection.bHideCell;
156  bHidePrint = rProtection.bHidePrint;
157  return *this;
158  }
159 };
160 
161 // page format item: contents of header and footer
162 
163 #define SC_HF_LEFTAREA 1
164 #define SC_HF_CENTERAREA 2
165 #define SC_HF_RIGHTAREA 3
166 
168 {
169  std::unique_ptr<EditTextObject> pLeftArea;
170  std::unique_ptr<EditTextObject> pCenterArea;
171  std::unique_ptr<EditTextObject> pRightArea;
172 
173 public:
174  ScPageHFItem( sal_uInt16 nWhich );
175  ScPageHFItem( const ScPageHFItem& rItem );
176  virtual ~ScPageHFItem() override;
177 
178  virtual bool operator==( const SfxPoolItem& ) const override;
179  virtual ScPageHFItem* Clone( SfxItemPool *pPool = nullptr ) const override;
180 
181  virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
182  virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
183 
184  const EditTextObject* GetLeftArea() const { return pLeftArea.get(); }
185  const EditTextObject* GetCenterArea() const { return pCenterArea.get(); }
186  const EditTextObject* GetRightArea() const { return pRightArea.get(); }
187 
188  void SetLeftArea( const EditTextObject& rNew );
189  void SetCenterArea( const EditTextObject& rNew );
190  void SetRightArea( const EditTextObject& rNew );
191 };
192 
193 // page format item: contents of header and footer
194 
195 class SC_DLLPUBLIC ScViewObjectModeItem final : public SfxEnumItem<ScVObjMode>
196 {
197 public:
198  ScViewObjectModeItem( sal_uInt16 nWhich );
199  ScViewObjectModeItem( sal_uInt16 nWhich, ScVObjMode eMode );
200  virtual ~ScViewObjectModeItem() override;
201 
202  ScViewObjectModeItem(ScViewObjectModeItem const &) = default;
204  ScViewObjectModeItem & operator =(ScViewObjectModeItem const &) = delete; // due to SfxEnumItem<ScVObjMode>
205  ScViewObjectModeItem & operator =(ScViewObjectModeItem &&) = delete; // due to SfxEnumItem<ScVObjMode>
206 
207  virtual sal_uInt16 GetValueCount() const override;
208  virtual ScViewObjectModeItem* Clone( SfxItemPool *pPool = nullptr ) const override;
209  virtual bool GetPresentation( SfxItemPresentation ePres,
210  MapUnit eCoreMetric,
211  MapUnit ePresMetric,
212  OUString& rText,
213  const IntlWrapper& rIntl ) const override;
214 };
215 
220 
223 {
224 public:
226  explicit ScPageScaleToItem();
227  explicit ScPageScaleToItem( sal_uInt16 nWidth, sal_uInt16 nHeight );
228 
229  virtual ~ScPageScaleToItem() override;
230 
231  ScPageScaleToItem(ScPageScaleToItem const &) = default;
232  ScPageScaleToItem(ScPageScaleToItem &&) = default;
233  ScPageScaleToItem & operator =(ScPageScaleToItem const &) = delete; // due to SfxPoolItem
234  ScPageScaleToItem & operator =(ScPageScaleToItem &&) = delete; // due to SfxPoolItem
235 
236  virtual ScPageScaleToItem* Clone( SfxItemPool* = nullptr ) const override;
237 
238  virtual bool operator==( const SfxPoolItem& rCmp ) const override;
239 
240  sal_uInt16 GetWidth() const { return mnWidth; }
241  sal_uInt16 GetHeight() const { return mnHeight; }
242  bool IsValid() const { return mnWidth || mnHeight; }
243 
244  void SetWidth( sal_uInt16 nWidth ) { mnWidth = nWidth; }
245  void SetHeight( sal_uInt16 nHeight ) { mnHeight = nHeight; }
246  void Set( sal_uInt16 nWidth, sal_uInt16 nHeight )
247  { mnWidth = nWidth; mnHeight = nHeight; }
248 
249  virtual bool GetPresentation( SfxItemPresentation ePresentation,
250  MapUnit, MapUnit,
251  OUString& rText,
252  const IntlWrapper& ) const override;
253 
254  virtual bool QueryValue( css::uno::Any& rAny, sal_uInt8 nMemberId = 0 ) const override;
255  virtual bool PutValue( const css::uno::Any& rAny, sal_uInt8 nMemberId ) override;
256 
257 private:
258  sal_uInt16 mnWidth;
259  sal_uInt16 mnHeight;
260 };
261 
263 
264 class ScCondFormatItem final : public SfxPoolItem
265 {
266 public:
267  explicit ScCondFormatItem();
268  explicit ScCondFormatItem(sal_uInt32 nIndex);
269  explicit ScCondFormatItem(const ScCondFormatIndexes& );
270  explicit ScCondFormatItem(ScCondFormatIndexes&&) noexcept;
271 
272  virtual ~ScCondFormatItem() override;
273 
274  virtual bool operator==(const SfxPoolItem& rCmp ) const override;
275  virtual bool operator<(const SfxPoolItem& rCmp) const override;
276  virtual bool IsSortable() const override { return true; }
277  virtual ScCondFormatItem* Clone( SfxItemPool* = nullptr ) const override;
278 
280 
281  virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
282 
283 private:
285 };
286 
288 {
289 public:
291  virtual ScRotateValueItem* Clone(SfxItemPool* pPool=nullptr) const override;
292 
293  virtual bool GetPresentation( SfxItemPresentation ePresentation,
294  MapUnit, MapUnit,
295  OUString& rText,
296  const IntlWrapper& rIntl) const override;
297 };
298 
300 {
301 public:
302  ScShrinkToFitCell(bool bShrink = false);
303  virtual ScShrinkToFitCell* Clone(SfxItemPool *pPool = nullptr) const override;
304  virtual bool GetPresentation(SfxItemPresentation ePres,
305  MapUnit eCoreMetric,
306  MapUnit ePresMetric,
307  OUString &rText,
308  const IntlWrapper& rIntl) const override;
309 };
310 
312 {
313 public:
314  ScVerticalStackCell(bool bStack = false);
315  virtual ScVerticalStackCell* 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 
324 {
325 public:
326  ScLineBreakCell(bool bLineBreak = false);
327  virtual ScLineBreakCell* Clone(SfxItemPool *pPool = nullptr) const override;
328  virtual bool GetPresentation(SfxItemPresentation ePres,
329  MapUnit eCoreMetric,
330  MapUnit ePresMetric,
331  OUString &rText,
332  const IntlWrapper& rIntl) const override;
333 };
334 
335 class ScHyphenateCell final : public SfxBoolItem
336 {
337 public:
338  ScHyphenateCell(bool bHyphenate= false);
339  virtual ScHyphenateCell* Clone(SfxItemPool *pPool = nullptr) const override;
340  virtual bool GetPresentation(SfxItemPresentation ePres,
341  MapUnit eCoreMetric,
342  MapUnit ePresMetric,
343  OUString &rText,
344  const IntlWrapper& rIntl) const override;
345 };
346 
348 {
349 public:
350  ScIndentItem(sal_uInt16 nIndent = 0);
351  virtual ScIndentItem* Clone(SfxItemPool* pPool=nullptr) const override;
352 
353  virtual bool GetPresentation( SfxItemPresentation ePresentation,
354  MapUnit, MapUnit,
355  OUString& rText,
356  const IntlWrapper& rIntl) const override;
357 };
358 
359 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~ScCondFormatItem() override
Definition: attrib.cxx:684
double mnHeight
sal_uInt16 GetHeight() const
Definition: attrib.hxx:241
SCCOL GetColMerge() const
Definition: attrib.hxx:68
std::unique_ptr< EditTextObject > pLeftArea
Definition: attrib.hxx:169
sal_Int32 nIndex
bool bHideFormula
hide formula
Definition: attrib.hxx:116
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:117
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:97
const sal_uInt8 SC_MID_PAGE_SCALETO_WIDTH
Member ID for "page scale to width" value in QueryValue() and PutValue().
Definition: attrib.hxx:217
const EditTextObject * GetCenterArea() const
Definition: attrib.hxx:185
bool IsOverlapped() const
Definition: attrib.hxx:101
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:219
void SetHeight(sal_uInt16 nHeight)
Definition: attrib.hxx:245
SCROW nRowMerge
Definition: attrib.hxx:58
sal_uInt16 mnWidth
Definition: attrib.hxx:258
bool IsValid() const
Definition: attrib.hxx:242
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
o3tl::sorted_vector< sal_uInt32 > ScCondFormatIndexes
Definition: attrib.hxx:262
ScCondFormatIndexes maIndex
Definition: attrib.hxx:284
virtual bool IsSortable() const override
Definition: attrib.hxx:276
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:151
void Set(sal_uInt16 nWidth, sal_uInt16 nHeight)
Definition: attrib.hxx:246
bool GetHideCell() const
Definition: attrib.hxx:147
sal_uInt16 GetWidth() const
Definition: attrib.hxx:240
dp button with popup arrow
bool IsVerOverlapped() const
Definition: attrib.hxx:100
virtual SdrAngleItem * Clone(SfxItemPool *pPool=nullptr) const override
SfxItemPresentation
virtual SfxInt16Item * Clone(SfxItemPool *=nullptr) const override
ScMergeAttr & operator=(const ScMergeAttr &rMerge)
Definition: attrib.hxx:73
sal_Int16 GetValue() const
bool bProtection
protect cell
Definition: attrib.hxx:115
virtual bool operator<(const SfxPoolItem &rCmp) const override
Definition: attrib.cxx:700
sal_Int16 SCCOL
Definition: types.hxx:21
bool GetHideFormula() const
Definition: attrib.hxx:145
ScHyphenateCell(bool bHyphenate=false)
Definition: attrib.cxx:811
virtual ScHyphenateCell * Clone(SfxItemPool *pPool=nullptr) const override
Definition: attrib.cxx:816
virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString &rText, const IntlWrapper &) const override
std::unique_ptr< EditTextObject > pRightArea
Definition: attrib.hxx:171
bool GetHidePrint() const
Definition: attrib.hxx:149
std::unique_ptr< EditTextObject > pCenterArea
Definition: attrib.hxx:170
sal_uInt16 mnHeight
Definition: attrib.hxx:259
bool SC_DLLPUBLIC ScHasPriority(const ::editeng::SvxBorderLine *pThis, const ::editeng::SvxBorderLine *pOther)
General Help Function.
Definition: attrib.cxx:49
bool IsMerged() const
Definition: attrib.hxx:71
bool IsHorOverlapped() const
Definition: attrib.hxx:99
sal_Int32 SCROW
Definition: types.hxx:17
ScMF
Definition: attrib.hxx:34
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:222
unsigned char sal_uInt8
virtual bool operator==(const SfxPoolItem &rCmp) const override
Definition: attrib.cxx:688
const EditTextObject * GetRightArea() const
Definition: attrib.hxx:186
const EditTextObject * GetLeftArea() const
Definition: attrib.hxx:184
bool GetProtection() const
Definition: attrib.hxx:143
field button for datapilot
double mnWidth
virtual sal_uInt16 GetValueCount() const =0
SCCOL nColMerge
Definition: attrib.hxx:57
const ScCondFormatIndexes & GetCondFormatData() const
Definition: attrib.hxx:279
virtual SfxUInt16Item * Clone(SfxItemPool *=nullptr) const override
virtual ScCondFormatItem * Clone(SfxItemPool *=nullptr) const override
Definition: attrib.cxx:713
ScVObjMode
Definition: global.hxx:377
bool bHidePrint
don't print cell
Definition: attrib.hxx:118
MapUnit
SCROW GetRowMerge() const
Definition: attrib.hxx:69
bool IsScenario() const
Definition: attrib.hxx:105
bool HasAutoFilter() const
Definition: attrib.hxx:103
void SetWidth(sal_uInt16 nWidth)
Definition: attrib.hxx:244
virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText, const IntlWrapper &rIntl) const override
Definition: attrib.cxx:821
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: attrib.cxx:718
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
dp table output
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const