1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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>
33 // flags for cells hidden by merge
34 // and control for auto filter
39 Auto
= 0x0004, /// autofilter arrow
40 Button
= 0x0008, /// field button for datapilot
42 ButtonPopup
= 0x0020, /// dp button with popup arrow
43 HiddenMember
= 0x0040, /// dp field button with presence of hidden member
44 DpTable
= 0x0080, /// dp table output
48 template<> struct typed_flags
<ScMF
> : is_typed_flags
<ScMF
, 0xff> {};
52 namespace editeng
{ class SvxBorderLine
; }
54 bool SC_DLLPUBLIC
ScHasPriority( const ::editeng::SvxBorderLine
* pThis
, const ::editeng::SvxBorderLine
* pOther
);
56 class SC_DLLPUBLIC ScMergeAttr final
: public SfxPoolItem
62 ScMergeAttr( SCCOL nCol
, SCROW nRow
);
63 ScMergeAttr( const ScMergeAttr
& );
64 virtual ~ScMergeAttr() override
;
66 virtual bool operator==( const SfxPoolItem
& ) const override
;
67 virtual ScMergeAttr
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
69 SCCOL
GetColMerge() const {return nColMerge
; }
70 SCROW
GetRowMerge() const {return nRowMerge
; }
72 bool IsMerged() const { return nColMerge
>1 || nRowMerge
>1; }
74 ScMergeAttr
& operator=(const ScMergeAttr
& rMerge
)
76 nColMerge
= rMerge
.nColMerge
;
77 nRowMerge
= rMerge
.nRowMerge
;
81 virtual void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
84 class SC_DLLPUBLIC ScMergeFlagAttr final
: public SfxInt16Item
88 ScMergeFlagAttr(ScMF nFlags
);
89 virtual ~ScMergeFlagAttr() override
;
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
96 ScMergeFlagAttr
* Clone(SfxItemPool
* pPool
= nullptr) const override
;
98 ScMF
GetValue() const { return static_cast<ScMF
>(SfxInt16Item::GetValue()); }
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
) ); }
104 bool HasAutoFilter() const { return bool( GetValue() & ScMF::Auto
); }
106 bool IsScenario() const { return bool( GetValue() & ScMF::Scenario
); }
108 bool HasPivotButton() const;
109 bool HasPivotPopupButton() const;
111 virtual void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
114 class SC_DLLPUBLIC ScProtectionAttr final
: public SfxPoolItem
116 bool bProtection
; ///< protect cell
117 bool bHideFormula
; ///< hide formula
118 bool bHideCell
; ///< hide cell
119 bool bHidePrint
; ///< don't print cell
121 static SfxPoolItem
* CreateDefault();
123 ScProtectionAttr( bool bProtect
,
124 bool bHFormula
= false,
126 bool bHPrint
= false);
127 ScProtectionAttr( const ScProtectionAttr
& );
128 virtual ~ScProtectionAttr() override
;
130 OUString
GetValueText() const;
131 virtual bool GetPresentation(
132 SfxItemPresentation ePres
,
136 const IntlWrapper
& rIntl
) const override
;
138 virtual bool operator==( const SfxPoolItem
& ) const override
;
139 virtual ScProtectionAttr
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
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
;
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
);
152 ScProtectionAttr
& operator=(const ScProtectionAttr
& rProtection
)
154 bProtection
= rProtection
.bProtection
;
155 bHideFormula
= rProtection
.bHideFormula
;
156 bHideCell
= rProtection
.bHideCell
;
157 bHidePrint
= rProtection
.bHidePrint
;
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
;
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
);
194 // page format item: contents of header and footer
196 class SC_DLLPUBLIC ScViewObjectModeItem final
: public SfxEnumItem
<ScVObjMode
>
199 ScViewObjectModeItem( sal_uInt16 nWhich
);
200 ScViewObjectModeItem( sal_uInt16 nWhich
, ScVObjMode eMode
);
201 virtual ~ScViewObjectModeItem() override
;
203 ScViewObjectModeItem(ScViewObjectModeItem
const &) = default;
204 ScViewObjectModeItem(ScViewObjectModeItem
&&) = default;
205 ScViewObjectModeItem
& operator =(ScViewObjectModeItem
const &) = delete; // due to SfxEnumItem<ScVObjMode>
206 ScViewObjectModeItem
& operator =(ScViewObjectModeItem
&&) = delete; // due to SfxEnumItem<ScVObjMode>
208 virtual sal_uInt16
GetValueCount() const override
;
209 virtual ScViewObjectModeItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
210 virtual bool GetPresentation( SfxItemPresentation ePres
,
214 const IntlWrapper
& rIntl
) const override
;
217 /** Member ID for "page scale to width" value in QueryValue() and PutValue(). */
218 const sal_uInt8 SC_MID_PAGE_SCALETO_WIDTH
= 1;
219 /** Member ID for "page scale to height" value in QueryValue() and PutValue(). */
220 const sal_uInt8 SC_MID_PAGE_SCALETO_HEIGHT
= 2;
222 /** Contains the "scale to width/height" attribute in page styles. */
223 class SC_DLLPUBLIC ScPageScaleToItem final
: public SfxPoolItem
226 /** Default c'tor sets the width and height to 0. */
227 explicit ScPageScaleToItem();
228 explicit ScPageScaleToItem( sal_uInt16 nWidth
, sal_uInt16 nHeight
);
230 virtual ~ScPageScaleToItem() override
;
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
237 virtual ScPageScaleToItem
* Clone( SfxItemPool
* = nullptr ) const override
;
239 virtual bool operator==( const SfxPoolItem
& rCmp
) const override
;
241 sal_uInt16
GetWidth() const { return mnWidth
; }
242 sal_uInt16
GetHeight() const { return mnHeight
; }
243 bool IsValid() const { return mnWidth
|| mnHeight
; }
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
; }
250 virtual bool GetPresentation( SfxItemPresentation ePresentation
,
253 const IntlWrapper
& ) const override
;
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
;
263 typedef o3tl::sorted_vector
<sal_uInt32
> ScCondFormatIndexes
;
265 class ScCondFormatItem final
: public SfxPoolItem
268 explicit ScCondFormatItem();
269 explicit ScCondFormatItem(sal_uInt32 nIndex
);
270 explicit ScCondFormatItem(const ScCondFormatIndexes
& );
271 explicit ScCondFormatItem(ScCondFormatIndexes
&&) noexcept
;
273 virtual ~ScCondFormatItem() override
;
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
;
280 const ScCondFormatIndexes
& GetCondFormatData() const { return maIndex
;}
282 virtual void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
285 ScCondFormatIndexes maIndex
;
288 class SC_DLLPUBLIC ScRotateValueItem final
: public SdrAngleItem
291 ScRotateValueItem(sal_Int32 nAngle
);
292 virtual ScRotateValueItem
* Clone(SfxItemPool
* pPool
=nullptr) const override
;
294 virtual bool GetPresentation( SfxItemPresentation ePresentation
,
297 const IntlWrapper
& rIntl
) const override
;
300 class SC_DLLPUBLIC ScShrinkToFitCell final
: public SfxBoolItem
303 ScShrinkToFitCell(bool bShrink
= false);
304 virtual ScShrinkToFitCell
* Clone(SfxItemPool
*pPool
= nullptr) const override
;
305 virtual bool GetPresentation(SfxItemPresentation ePres
,
309 const IntlWrapper
& rIntl
) const override
;
312 class SC_DLLPUBLIC ScVerticalStackCell final
: public SfxBoolItem
315 ScVerticalStackCell(bool bStack
= false);
316 virtual ScVerticalStackCell
* Clone(SfxItemPool
*pPool
= nullptr) const override
;
317 virtual bool GetPresentation(SfxItemPresentation ePres
,
321 const IntlWrapper
& rIntl
) const override
;
324 class SC_DLLPUBLIC ScLineBreakCell final
: public SfxBoolItem
327 ScLineBreakCell(bool bLineBreak
= false);
328 virtual ScLineBreakCell
* Clone(SfxItemPool
*pPool
= nullptr) const override
;
329 virtual bool GetPresentation(SfxItemPresentation ePres
,
333 const IntlWrapper
& rIntl
) const override
;
336 class ScHyphenateCell final
: public SfxBoolItem
339 ScHyphenateCell(bool bHyphenate
= false);
340 virtual ScHyphenateCell
* Clone(SfxItemPool
*pPool
= nullptr) const override
;
341 virtual bool GetPresentation(SfxItemPresentation ePres
,
345 const IntlWrapper
& rIntl
) const override
;
348 class SC_DLLPUBLIC ScIndentItem final
: public SfxUInt16Item
351 ScIndentItem(sal_uInt16 nIndent
= 0);
352 virtual ScIndentItem
* Clone(SfxItemPool
* pPool
=nullptr) const override
;
354 virtual bool GetPresentation( SfxItemPresentation ePresentation
,
357 const IntlWrapper
& rIntl
) const override
;
362 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */