LibreOffice Module svl (master) 1
eitem.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_SVL_EITEM_HXX
21#define INCLUDED_SVL_EITEM_HXX
22
23#include <svl/svldllapi.h>
24#include <svl/cenumitm.hxx>
25
26
27template<typename EnumT>
28class SAL_DLLPUBLIC_RTTI SfxEnumItem : public SfxEnumItemInterface
29{
30 EnumT m_nValue;
31
32protected:
33 explicit SfxEnumItem(sal_uInt16 const nWhich, EnumT const nValue)
34 : SfxEnumItemInterface(nWhich)
35 , m_nValue(nValue)
36 { }
37
38 SfxEnumItem(const SfxEnumItem &) = default;
39
40public:
41
42 EnumT GetValue() const { return m_nValue; }
43
44 void SetValue(EnumT nTheValue)
45 {
46 assert(GetRefCount() == 0 && "SfxEnumItem::SetValue(): Pooled item");
47 m_nValue = nTheValue;
48 }
49
50 virtual sal_uInt16 GetEnumValue() const override
51 {
52 return static_cast<sal_uInt16>(GetValue());
53 }
54
55 virtual void SetEnumValue(sal_uInt16 nTheValue) override
56 {
57 SetValue(static_cast<EnumT>(nTheValue));
58 }
59
60 virtual bool operator==(SfxPoolItem const & other) const override
61 {
63 m_nValue == static_cast<const SfxEnumItem<EnumT> &>(other).m_nValue;
64 }
65};
66
68 : public SfxPoolItem
69{
71
72public:
73 static SfxPoolItem* CreateDefault();
74
75 explicit SfxBoolItem(sal_uInt16 const nWhich = 0, bool const bValue = false)
76 : SfxPoolItem(nWhich)
77 , m_bValue(bValue)
78 { }
79
80 bool GetValue() const { return m_bValue; }
81
82 void SetValue(bool const bTheValue) { m_bValue = bTheValue; }
83
84 // SfxPoolItem
85 virtual bool operator ==(const SfxPoolItem & rItem) const override;
86
89 OUString & rText,
90 const IntlWrapper&)
91 const override;
92
93 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
94
95 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 = 0) const override;
96
97 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8) override;
98
99
100 virtual SfxBoolItem* Clone(SfxItemPool * = nullptr) const override;
101
102 virtual OUString GetValueTextByVal(bool bTheValue) const;
103};
104
105#endif // INCLUDED_SVL_EITEM_HXX
106
107/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bValue
Definition: eitem.hxx:70
SfxBoolItem(sal_uInt16 const nWhich=0, bool const bValue=false)
Definition: eitem.hxx:75
void SetValue(bool const bTheValue)
Definition: eitem.hxx:82
bool GetValue() const
Definition: eitem.hxx:80
virtual bool operator==(const SfxPoolItem &rItem) const override
Definition: cenumitm.cxx:30
SfxEnumItem(const SfxEnumItem &)=default
SfxEnumItem(sal_uInt16 const nWhich, EnumT const nValue)
Definition: eitem.hxx:33
virtual sal_uInt16 GetEnumValue() const override
Definition: eitem.hxx:50
EnumT GetValue() const
Definition: eitem.hxx:42
void SetValue(EnumT nTheValue)
Definition: eitem.hxx:44
EnumT m_nValue
Definition: eitem.hxx:30
virtual void SetEnumValue(sal_uInt16 nTheValue) override
Definition: eitem.hxx:55
virtual bool operator==(SfxPoolItem const &other) const override
Definition: eitem.hxx:60
Base class for providers of defaults of SfxPoolItems.
Definition: itempool.hxx:51
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
Definition: poolitem.cxx:604
virtual bool GetPresentation(SfxItemPresentation ePresentation, MapUnit eCoreMetric, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntlWrapper) const
This virtual method allows to get a textual representation of the value for the SfxPoolItem subclasse...
Definition: poolitem.cxx:524
sal_uInt32 GetRefCount() const
Definition: poolitem.hxx:226
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: poolitem.cxx:534
virtual bool operator==(const SfxPoolItem &) const =0
Definition: poolitem.cxx:478
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId)
Definition: poolitem.cxx:610
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
virtual void SetValue(tools::Long nNew) override
struct _xmlTextWriter * xmlTextWriterPtr
sal_Int16 nValue
MapUnit
const char GetValue[]
SfxItemPresentation
Definition: poolitem.hxx:72
#define SVL_DLLPUBLIC
Definition: svldllapi.h:28
unsigned char sal_uInt8