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 .
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>
32 // flags for cells hidden by merge
33 // and control for auto filter
38 Auto
= 0x0004, /// autofilter arrow
39 Button
= 0x0008, /// field button for datapilot
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
50 template<> struct typed_flags
<ScMF
> : is_typed_flags
<ScMF
, 0x07ff> {};
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
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
;
83 virtual void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
86 class SC_DLLPUBLIC ScMergeFlagAttr final
: public SfxInt16Item
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
125 static SfxPoolItem
* CreateDefault();
127 ScProtectionAttr( bool bProtect
,
128 bool bHFormula
= false,
130 bool bHPrint
= false);
131 ScProtectionAttr( const ScProtectionAttr
& );
132 virtual ~ScProtectionAttr() override
;
134 OUString
GetValueText() const;
135 virtual bool GetPresentation(
136 SfxItemPresentation ePres
,
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
;
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
;
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
>
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
,
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
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
,
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
;
270 typedef o3tl::sorted_vector
<sal_uInt32
> ScCondFormatIndexes
;
272 class SAL_DLLPUBLIC_RTTI ScCondFormatItem final
: public SfxPoolItem
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
;
290 ScCondFormatIndexes maIndex
;
293 class SC_DLLPUBLIC ScRotateValueItem final
: public SdrAngleItem
296 ScRotateValueItem(Degree100 nAngle
);
297 virtual ScRotateValueItem
* Clone(SfxItemPool
* pPool
=nullptr) const override
;
299 virtual bool GetPresentation( SfxItemPresentation ePresentation
,
302 const IntlWrapper
& rIntl
) const override
;
305 class SC_DLLPUBLIC ScShrinkToFitCell final
: public SfxBoolItem
308 ScShrinkToFitCell(bool bShrink
= false);
309 virtual ScShrinkToFitCell
* Clone(SfxItemPool
*pPool
= nullptr) const override
;
310 virtual bool GetPresentation(SfxItemPresentation ePres
,
314 const IntlWrapper
& rIntl
) const override
;
317 class SC_DLLPUBLIC ScVerticalStackCell final
: public SfxBoolItem
320 ScVerticalStackCell(bool bStack
= false);
321 virtual ScVerticalStackCell
* Clone(SfxItemPool
*pPool
= nullptr) const override
;
322 virtual bool GetPresentation(SfxItemPresentation ePres
,
326 const IntlWrapper
& rIntl
) const override
;
329 class SC_DLLPUBLIC ScLineBreakCell final
: public SfxBoolItem
332 ScLineBreakCell(bool bLineBreak
= false);
333 virtual ScLineBreakCell
* Clone(SfxItemPool
*pPool
= nullptr) const override
;
334 virtual bool GetPresentation(SfxItemPresentation ePres
,
338 const IntlWrapper
& rIntl
) const override
;
341 class ScHyphenateCell final
: public SfxBoolItem
344 ScHyphenateCell(bool bHyphenate
= false);
345 virtual ScHyphenateCell
* Clone(SfxItemPool
*pPool
= nullptr) const override
;
346 virtual bool GetPresentation(SfxItemPresentation ePres
,
350 const IntlWrapper
& rIntl
) const override
;
353 class SC_DLLPUBLIC ScIndentItem final
: public SfxUInt16Item
356 ScIndentItem(sal_uInt16 nIndent
= 0);
357 virtual ScIndentItem
* Clone(SfxItemPool
* pPool
=nullptr) const override
;
359 virtual bool GetPresentation( SfxItemPresentation ePresentation
,
362 const IntlWrapper
& rIntl
) const override
;
365 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */