update credits
[LibreOffice.git] / include / svl / cenumitm.hxx
blob35024c3a6d446c4baf3d4c380107c6a97d7adea4
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 _SVTOOLS_CENUMITM_HXX
21 #define _SVTOOLS_CENUMITM_HXX
23 #include "svl/svldllapi.h"
24 #include <tools/debug.hxx>
25 #include <svl/poolitem.hxx>
27 //============================================================================
28 DBG_NAMEEX(SfxEnumItemInterface)
30 class SVL_DLLPUBLIC SfxEnumItemInterface: public SfxPoolItem
32 protected:
33 explicit SfxEnumItemInterface(sal_uInt16 which): SfxPoolItem(which) {}
35 SfxEnumItemInterface(const SfxEnumItemInterface & rItem):
36 SfxPoolItem(rItem) {}
38 public:
39 TYPEINFO();
41 virtual int operator ==(const SfxPoolItem & rItem) const;
43 virtual SfxItemPresentation GetPresentation(SfxItemPresentation,
44 SfxMapUnit, SfxMapUnit,
45 OUString & rText,
46 const IntlWrapper * = 0)
47 const;
49 virtual bool QueryValue(com::sun::star::uno::Any & rVal, sal_uInt8 = 0) const;
51 virtual bool PutValue(const com::sun::star::uno::Any & rVal, sal_uInt8 = 0);
53 virtual sal_uInt16 GetValueCount() const = 0;
55 virtual OUString GetValueTextByPos(sal_uInt16 nPos) const;
57 virtual sal_uInt16 GetValueByPos(sal_uInt16 nPos) const;
59 /// Return the position of some value within this enumeration.
60 ///
61 /// @descr This method is implemented using GetValueCount() and
62 /// GetValueByPos(). Derived classes may replace this with a more
63 /// efficient implementation.
64 ///
65 /// @param nValue Some value.
66 ///
67 /// @return The position of nValue within this enumeration, or USHRT_MAX
68 /// if not included.
69 virtual sal_uInt16 GetPosByValue(sal_uInt16 nValue) const;
71 virtual sal_Bool IsEnabled(sal_uInt16 nValue) const;
73 virtual sal_uInt16 GetEnumValue() const = 0;
75 virtual void SetEnumValue(sal_uInt16 nValue) = 0;
77 virtual int HasBoolValue() const;
79 virtual sal_Bool GetBoolValue() const;
81 virtual void SetBoolValue(sal_Bool bValue);
84 //============================================================================
85 DBG_NAMEEX(CntEnumItem)
87 class SVL_DLLPUBLIC CntEnumItem: public SfxEnumItemInterface
89 sal_uInt16 m_nValue;
91 protected:
92 explicit CntEnumItem(sal_uInt16 which = 0, sal_uInt16 nTheValue = 0):
93 SfxEnumItemInterface(which), m_nValue(nTheValue) {}
95 CntEnumItem(sal_uInt16 which, SvStream & rStream);
97 CntEnumItem(const CntEnumItem & rItem):
98 SfxEnumItemInterface(rItem), m_nValue(rItem.m_nValue) {}
100 public:
101 TYPEINFO();
103 virtual SvStream & Store(SvStream & rStream, sal_uInt16) const;
105 virtual sal_uInt16 GetEnumValue() const;
107 virtual void SetEnumValue(sal_uInt16 nTheValue);
109 sal_uInt16 GetValue() const { return m_nValue; }
111 inline void SetValue(sal_uInt16 nTheValue);
114 inline void CntEnumItem::SetValue(sal_uInt16 nTheValue)
116 DBG_ASSERT(GetRefCount() == 0, "CntEnumItem::SetValue(): Pooled item");
117 m_nValue = nTheValue;
120 //============================================================================
121 DBG_NAMEEX(CntBoolItem)
123 class SVL_DLLPUBLIC CntBoolItem: public SfxPoolItem
125 sal_Bool m_bValue;
127 public:
128 TYPEINFO();
130 explicit CntBoolItem(sal_uInt16 which = 0, sal_Bool bTheValue = sal_False):
131 SfxPoolItem(which), m_bValue(bTheValue) {}
133 CntBoolItem(sal_uInt16 nWhich, SvStream & rStream);
135 CntBoolItem(const CntBoolItem & rItem):
136 SfxPoolItem(rItem), m_bValue(rItem.m_bValue) {}
138 virtual int operator ==(const SfxPoolItem & rItem) const;
140 using SfxPoolItem::Compare;
141 virtual int Compare(const SfxPoolItem & rWith) const;
143 virtual SfxItemPresentation GetPresentation(SfxItemPresentation,
144 SfxMapUnit, SfxMapUnit,
145 OUString & rText,
146 const IntlWrapper * = 0)
147 const;
149 virtual bool QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8 = 0) const;
151 virtual bool PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8 = 0);
153 virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const;
155 virtual SvStream & Store(SvStream & rStream, sal_uInt16) const;
157 virtual SfxPoolItem * Clone(SfxItemPool * = 0) const;
159 virtual sal_uInt16 GetValueCount() const;
161 virtual OUString GetValueTextByVal(sal_Bool bTheValue) const;
163 sal_Bool GetValue() const { return m_bValue; }
165 void SetValue(sal_Bool bTheValue) { m_bValue = bTheValue; }
168 #endif // _SVTOOLS_CENUMITM_HXX
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */