Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sc / inc / attrib.hxx
blobd44a7cce4d77e03d7a5b572fd880e80e7373beb6
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 #ifndef INCLUDED_SC_INC_ATTRIB_HXX
21 #define INCLUDED_SC_INC_ATTRIB_HXX
23 #include <memory>
24 #include <svl/poolitem.hxx>
25 #include <svl/intitem.hxx>
26 #include <svl/eitem.hxx>
27 #include <o3tl/typed_flags_set.hxx>
28 #include "scdllapi.h"
29 #include "global.hxx"
31 // flags for cells hidden by merge
32 // and control for auto filter
33 enum class ScMF {
34 NONE = 0x0000,
35 Hor = 0x0001,
36 Ver = 0x0002,
37 Auto = 0x0004, /// autofilter arrow
38 Button = 0x0008, /// field button for datapilot
39 Scenario = 0x0010,
40 ButtonPopup = 0x0020, /// dp button with popup arrow
41 HiddenMember = 0x0040, /// dp field button with presence of hidden member
42 DpTable = 0x0080, /// dp table output
43 All = 0x00FF
45 namespace o3tl {
46 template<> struct typed_flags<ScMF> : is_typed_flags<ScMF, 0xff> {};
49 class EditTextObject;
50 namespace editeng { class SvxBorderLine; }
52 bool SC_DLLPUBLIC ScHasPriority( const ::editeng::SvxBorderLine* pThis, const ::editeng::SvxBorderLine* pOther );
54 class SC_DLLPUBLIC ScMergeAttr: public SfxPoolItem
56 SCCOL nColMerge;
57 SCROW nRowMerge;
58 public:
59 ScMergeAttr();
60 ScMergeAttr( SCCOL nCol, SCROW nRow );
61 ScMergeAttr( const ScMergeAttr& );
62 virtual ~ScMergeAttr() override;
64 virtual bool operator==( const SfxPoolItem& ) const override;
65 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
67 SCCOL GetColMerge() const {return nColMerge; }
68 SCROW GetRowMerge() const {return nRowMerge; }
70 bool IsMerged() const { return nColMerge>1 || nRowMerge>1; }
72 ScMergeAttr& operator=(const ScMergeAttr& rMerge)
74 nColMerge = rMerge.nColMerge;
75 nRowMerge = rMerge.nRowMerge;
76 return *this;
79 virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
82 class SC_DLLPUBLIC ScMergeFlagAttr: public SfxInt16Item
84 public:
85 ScMergeFlagAttr();
86 ScMergeFlagAttr(ScMF nFlags);
87 virtual ~ScMergeFlagAttr() override;
89 SfxPoolItem * Clone(SfxItemPool * pPool = nullptr) const override;
91 ScMF GetValue() const { return static_cast<ScMF>(SfxInt16Item::GetValue()); }
93 bool IsHorOverlapped() const { return bool( GetValue() & ScMF::Hor ); }
94 bool IsVerOverlapped() const { return bool( GetValue() & ScMF::Ver ); }
95 bool IsOverlapped() const { return bool( GetValue() & ( ScMF::Hor | ScMF::Ver ) ); }
97 bool HasAutoFilter() const { return bool( GetValue() & ScMF::Auto ); }
99 bool IsScenario() const { return bool( GetValue() & ScMF::Scenario ); }
101 bool HasPivotButton() const;
102 bool HasPivotPopupButton() const;
104 virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
107 class SC_DLLPUBLIC ScProtectionAttr: public SfxPoolItem
109 bool bProtection; ///< protect cell
110 bool bHideFormula; ///< hide formula
111 bool bHideCell; ///< hide cell
112 bool bHidePrint; ///< don't print cell
113 public:
114 static SfxPoolItem* CreateDefault();
115 ScProtectionAttr();
116 ScProtectionAttr( bool bProtect,
117 bool bHFormula = false,
118 bool bHCell = false,
119 bool bHPrint = false);
120 ScProtectionAttr( const ScProtectionAttr& );
121 virtual ~ScProtectionAttr() override;
123 OUString GetValueText() const;
124 virtual bool GetPresentation(
125 SfxItemPresentation ePres,
126 MapUnit eCoreMetric,
127 MapUnit ePresMetric,
128 OUString& rText,
129 const IntlWrapper& rIntl ) const override;
131 virtual bool operator==( const SfxPoolItem& ) const override;
132 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
134 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
135 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
137 bool GetProtection() const { return bProtection; }
138 void SetProtection( bool bProtect);
139 bool GetHideFormula() const { return bHideFormula; }
140 void SetHideFormula( bool bHFormula);
141 bool GetHideCell() const { return bHideCell; }
142 void SetHideCell( bool bHCell);
143 bool GetHidePrint() const { return bHidePrint; }
144 void SetHidePrint( bool bHPrint);
145 ScProtectionAttr& operator=(const ScProtectionAttr& rProtection)
147 bProtection = rProtection.bProtection;
148 bHideFormula = rProtection.bHideFormula;
149 bHideCell = rProtection.bHideCell;
150 bHidePrint = rProtection.bHidePrint;
151 return *this;
155 // page format item: contents of header and footer
157 #define SC_HF_LEFTAREA 1
158 #define SC_HF_CENTERAREA 2
159 #define SC_HF_RIGHTAREA 3
161 class SC_DLLPUBLIC ScPageHFItem : public SfxPoolItem
163 std::unique_ptr<EditTextObject> pLeftArea;
164 std::unique_ptr<EditTextObject> pCenterArea;
165 std::unique_ptr<EditTextObject> pRightArea;
167 public:
168 ScPageHFItem( sal_uInt16 nWhich );
169 ScPageHFItem( const ScPageHFItem& rItem );
170 virtual ~ScPageHFItem() override;
172 virtual bool operator==( const SfxPoolItem& ) const override;
173 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
175 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
176 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
178 const EditTextObject* GetLeftArea() const { return pLeftArea.get(); }
179 const EditTextObject* GetCenterArea() const { return pCenterArea.get(); }
180 const EditTextObject* GetRightArea() const { return pRightArea.get(); }
182 void SetLeftArea( const EditTextObject& rNew );
183 void SetCenterArea( const EditTextObject& rNew );
184 void SetRightArea( const EditTextObject& rNew );
187 // page format item: contents of header and footer
189 class SC_DLLPUBLIC ScViewObjectModeItem: public SfxEnumItem<ScVObjMode>
191 public:
192 ScViewObjectModeItem( sal_uInt16 nWhich );
193 ScViewObjectModeItem( sal_uInt16 nWhich, ScVObjMode eMode );
194 virtual ~ScViewObjectModeItem() override;
196 virtual sal_uInt16 GetValueCount() const override;
197 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
198 virtual sal_uInt16 GetVersion( sal_uInt16 nFileVersion ) const override;
199 virtual bool GetPresentation( SfxItemPresentation ePres,
200 MapUnit eCoreMetric,
201 MapUnit ePresMetric,
202 OUString& rText,
203 const IntlWrapper& rIntl ) const override;
206 class ScDoubleItem : public SfxPoolItem
208 public:
209 static SfxPoolItem* CreateDefault();
210 ScDoubleItem( sal_uInt16 nWhich, double nVal );
211 ScDoubleItem( const ScDoubleItem& rItem );
212 virtual ~ScDoubleItem() override;
214 virtual bool operator==( const SfxPoolItem& ) const override;
215 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
217 private:
218 double nValue;
221 /** Member ID for "page scale to width" value in QueryValue() and PutValue(). */
222 const sal_uInt8 SC_MID_PAGE_SCALETO_WIDTH = 1;
223 /** Member ID for "page scale to height" value in QueryValue() and PutValue(). */
224 const sal_uInt8 SC_MID_PAGE_SCALETO_HEIGHT = 2;
226 /** Contains the "scale to width/height" attribute in page styles. */
227 class SC_DLLPUBLIC ScPageScaleToItem : public SfxPoolItem
229 public:
230 /** Default c'tor sets the width and height to 0. */
231 explicit ScPageScaleToItem();
232 explicit ScPageScaleToItem( sal_uInt16 nWidth, sal_uInt16 nHeight );
234 virtual ~ScPageScaleToItem() override;
236 virtual ScPageScaleToItem* Clone( SfxItemPool* = nullptr ) const override;
238 virtual bool operator==( const SfxPoolItem& rCmp ) const override;
240 sal_uInt16 GetWidth() const { return mnWidth; }
241 sal_uInt16 GetHeight() const { return mnHeight; }
242 bool IsValid() const { return mnWidth || mnHeight; }
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; }
249 virtual bool GetPresentation( SfxItemPresentation ePresentation,
250 MapUnit, MapUnit,
251 OUString& rText,
252 const IntlWrapper& ) const override;
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;
257 private:
258 sal_uInt16 mnWidth;
259 sal_uInt16 mnHeight;
262 class ScCondFormatItem : public SfxPoolItem
264 public:
265 explicit ScCondFormatItem();
266 explicit ScCondFormatItem(const std::vector<sal_uInt32>& nIndex);
268 virtual ~ScCondFormatItem() override;
270 virtual bool operator==(const SfxPoolItem& rCmp ) const override;
271 virtual ScCondFormatItem* Clone( SfxItemPool* = nullptr ) const override;
273 const std::vector<sal_uInt32>& GetCondFormatData() const { return maIndex;}
274 void AddCondFormatData( sal_uInt32 nIndex );
275 void SetCondFormatData( const std::vector<sal_uInt32>& aIndex );
277 virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
279 private:
280 std::vector<sal_uInt32> maIndex;
283 #endif
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */