xref: /AOO41X/main/svl/inc/svl/cenumitm.hxx (revision 39a19a47feaddbaa21988da8c7bf801707fd3d48)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVTOOLS_CENUMITM_HXX
25 #define _SVTOOLS_CENUMITM_HXX
26 
27 #include "svl/svldllapi.h"
28 #include <tools/debug.hxx>
29 #include <svl/poolitem.hxx>
30 
31 //============================================================================
32 DBG_NAMEEX(SfxEnumItemInterface)
33 
34 class SVL_DLLPUBLIC SfxEnumItemInterface: public SfxPoolItem
35 {
36 protected:
SfxEnumItemInterface(sal_uInt16 which)37     SfxEnumItemInterface(sal_uInt16 which): SfxPoolItem(which) {}
38 
SfxEnumItemInterface(const SfxEnumItemInterface & rItem)39     SfxEnumItemInterface(const SfxEnumItemInterface & rItem):
40         SfxPoolItem(rItem) {}
41 
42 public:
43     TYPEINFO();
44 
45     virtual int operator ==(const SfxPoolItem & rItem) const;
46 
47     virtual SfxItemPresentation GetPresentation(SfxItemPresentation,
48                                                 SfxMapUnit, SfxMapUnit,
49                                                 XubString & rText,
50                                                 const IntlWrapper * = 0)
51         const;
52 
53     virtual sal_Bool QueryValue(com::sun::star::uno::Any & rVal, sal_uInt8 = 0) const;
54 
55     virtual sal_Bool PutValue(const com::sun::star::uno::Any & rVal, sal_uInt8 = 0);
56 
57     virtual sal_uInt16 GetValueCount() const = 0;
58 
59     virtual XubString GetValueTextByPos(sal_uInt16 nPos) const;
60 
61     virtual sal_uInt16 GetValueByPos(sal_uInt16 nPos) const;
62 
63     /// Return the position of some value within this enumeration.
64     ///
65     /// @descr  This method is implemented using GetValueCount() and
66     /// GetValueByPos().  Derived classes may replace this with a more
67     /// efficient implementation.
68     ///
69     /// @param nValue  Some value.
70     ///
71     /// @return  The position of nValue within this enumeration, or USHRT_MAX
72     /// if not included.
73     virtual sal_uInt16 GetPosByValue(sal_uInt16 nValue) const;
74 
75     virtual sal_Bool IsEnabled(sal_uInt16 nValue) const;
76 
77     virtual sal_uInt16 GetEnumValue() const = 0;
78 
79     virtual void SetEnumValue(sal_uInt16 nValue) = 0;
80 
81     virtual int HasBoolValue() const;
82 
83     virtual sal_Bool GetBoolValue() const;
84 
85     virtual void SetBoolValue(sal_Bool bValue);
86 };
87 
88 //============================================================================
89 DBG_NAMEEX(CntEnumItem)
90 
91 class SVL_DLLPUBLIC CntEnumItem: public SfxEnumItemInterface
92 {
93     sal_uInt16 m_nValue;
94 
95 protected:
CntEnumItem(sal_uInt16 which=0,sal_uInt16 nTheValue=0)96     CntEnumItem(sal_uInt16 which = 0, sal_uInt16 nTheValue = 0):
97         SfxEnumItemInterface(which), m_nValue(nTheValue) {}
98 
99     CntEnumItem(sal_uInt16 which, SvStream & rStream);
100 
CntEnumItem(const CntEnumItem & rItem)101     CntEnumItem(const CntEnumItem & rItem):
102         SfxEnumItemInterface(rItem), m_nValue(rItem.m_nValue) {}
103 
104 public:
105     TYPEINFO();
106 
107     virtual SvStream & Store(SvStream & rStream, sal_uInt16) const;
108 
109     virtual sal_uInt16 GetEnumValue() const;
110 
111     virtual void SetEnumValue(sal_uInt16 nTheValue);
112 
GetValue() const113     sal_uInt16 GetValue() const { return m_nValue; }
114 
115     inline void SetValue(sal_uInt16 nTheValue);
116 };
117 
SetValue(sal_uInt16 nTheValue)118 inline void CntEnumItem::SetValue(sal_uInt16 nTheValue)
119 {
120     DBG_ASSERT(GetRefCount() == 0, "CntEnumItem::SetValue(): Pooled item");
121     m_nValue = nTheValue;
122 }
123 
124 //============================================================================
125 DBG_NAMEEX(CntBoolItem)
126 
127 class SVL_DLLPUBLIC CntBoolItem: public SfxPoolItem
128 {
129     sal_Bool m_bValue;
130 
131 public:
132     TYPEINFO();
133 
CntBoolItem(sal_uInt16 which=0,sal_Bool bTheValue=sal_False)134     CntBoolItem(sal_uInt16 which = 0, sal_Bool bTheValue = sal_False):
135         SfxPoolItem(which), m_bValue(bTheValue) {}
136 
137     CntBoolItem(sal_uInt16 nWhich, SvStream & rStream);
138 
CntBoolItem(const CntBoolItem & rItem)139     CntBoolItem(const CntBoolItem & rItem):
140         SfxPoolItem(rItem), m_bValue(rItem.m_bValue) {}
141 
142     virtual int operator ==(const SfxPoolItem & rItem) const;
143 
144     using SfxPoolItem::Compare;
145     virtual int Compare(const SfxPoolItem & rWith) const;
146 
147     virtual SfxItemPresentation GetPresentation(SfxItemPresentation,
148                                                 SfxMapUnit, SfxMapUnit,
149                                                 UniString & rText,
150                                                 const IntlWrapper * = 0)
151         const;
152 
153     virtual sal_Bool QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8 = 0) const;
154 
155     virtual sal_Bool PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8 = 0);
156 
157     virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const;
158 
159     virtual SvStream & Store(SvStream & rStream, sal_uInt16) const;
160 
161     virtual SfxPoolItem * Clone(SfxItemPool * = 0) const;
162 
163     virtual sal_uInt16 GetValueCount() const;
164 
165     virtual UniString GetValueTextByVal(sal_Bool bTheValue) const;
166 
GetValue() const167     sal_Bool GetValue() const { return m_bValue; }
168 
SetValue(sal_Bool bTheValue)169     void SetValue(sal_Bool bTheValue) { m_bValue = bTheValue; }
170 };
171 
172 #endif // _SVTOOLS_CENUMITM_HXX
173 
174