sync master with lastest vba changes
[ooovba.git] / binfilter / inc / bf_svtools / cenumitm.hxx
blob2031e3dcaa45e8756370ce7f01c8e42b79603ef5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cenumitm.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVTOOLS_CENUMITM_HXX
32 #define _SVTOOLS_CENUMITM_HXX
34 #ifndef _TOOLS_DEBUG_HXX
35 #include <tools/debug.hxx>
36 #endif
38 #ifndef _SFXPOOLITEM_HXX
39 #include <bf_svtools/poolitem.hxx>
40 #endif
42 namespace binfilter {
44 //============================================================================
45 DBG_NAMEEX(SfxEnumItemInterface)
47 class SfxEnumItemInterface: public SfxPoolItem
49 protected:
50 SfxEnumItemInterface(USHORT which): SfxPoolItem(which) {}
52 SfxEnumItemInterface(const SfxEnumItemInterface & rItem):
53 SfxPoolItem(rItem) {}
55 public:
56 TYPEINFO();
58 virtual int operator ==(const SfxPoolItem & rItem) const;
60 virtual SfxItemPresentation GetPresentation(SfxItemPresentation,
61 SfxMapUnit, SfxMapUnit,
62 XubString & rText,
63 const ::IntlWrapper * = 0)
64 const;
66 virtual BOOL QueryValue(::com::sun::star::uno::Any & rVal, BYTE = 0) const;
68 virtual BOOL PutValue(const ::com::sun::star::uno::Any & rVal, BYTE = 0);
70 virtual USHORT GetValueCount() const = 0;
72 virtual XubString GetValueTextByPos(USHORT nPos) const;
74 virtual USHORT GetValueByPos(USHORT nPos) const;
76 /// Return the position of some value within this enumeration.
77 ///
78 /// @descr This method is implemented using GetValueCount() and
79 /// GetValueByPos(). Derived classes may replace this with a more
80 /// efficient implementation.
81 ///
82 /// @param nValue Some value.
83 ///
84 /// @return The position of nValue within this enumeration, or USHRT_MAX
85 /// if not included.
86 virtual USHORT GetPosByValue(USHORT nValue) const;
88 virtual BOOL IsEnabled(USHORT nValue) const;
90 virtual USHORT GetEnumValue() const = 0;
92 virtual void SetEnumValue(USHORT nValue) = 0;
94 virtual int HasBoolValue() const;
96 virtual BOOL GetBoolValue() const;
98 virtual void SetBoolValue(BOOL bValue);
101 //============================================================================
102 DBG_NAMEEX(CntEnumItem)
104 class CntEnumItem: public SfxEnumItemInterface
106 USHORT m_nValue;
108 protected:
109 CntEnumItem(USHORT which = 0, USHORT nTheValue = 0):
110 SfxEnumItemInterface(which), m_nValue(nTheValue) {}
112 CntEnumItem(USHORT which, SvStream & rStream);
114 CntEnumItem(const CntEnumItem & rItem):
115 SfxEnumItemInterface(rItem), m_nValue(rItem.m_nValue) {}
117 public:
118 TYPEINFO();
120 virtual SvStream & Store(SvStream & rStream, USHORT) const;
122 virtual USHORT GetEnumValue() const;
124 virtual void SetEnumValue(USHORT nTheValue);
126 USHORT GetValue() const { return m_nValue; }
128 inline void SetValue(USHORT nTheValue);
131 inline void CntEnumItem::SetValue(USHORT nTheValue)
133 DBG_ASSERT(GetRefCount() == 0, "CntEnumItem::SetValue(): Pooled item");
134 m_nValue = nTheValue;
137 //============================================================================
138 DBG_NAMEEX(CntBoolItem)
140 class CntBoolItem: public SfxPoolItem
142 BOOL m_bValue;
144 public:
145 TYPEINFO();
147 CntBoolItem(USHORT which = 0, BOOL bTheValue = FALSE):
148 SfxPoolItem(which), m_bValue(bTheValue) {}
150 CntBoolItem(USHORT nWhich, SvStream & rStream);
152 CntBoolItem(const CntBoolItem & rItem):
153 SfxPoolItem(rItem), m_bValue(rItem.m_bValue) {}
155 virtual int operator ==(const SfxPoolItem & rItem) const;
157 using SfxPoolItem::Compare;
158 virtual int Compare(const SfxPoolItem & rWith) const;
160 virtual SfxItemPresentation GetPresentation(SfxItemPresentation,
161 SfxMapUnit, SfxMapUnit,
162 UniString & rText,
163 const ::IntlWrapper * = 0)
164 const;
166 virtual BOOL QueryValue(::com::sun::star::uno::Any& rVal, BYTE = 0) const;
168 virtual BOOL PutValue(const ::com::sun::star::uno::Any& rVal, BYTE = 0);
170 virtual SfxPoolItem * Create(SvStream & rStream, USHORT) const;
172 virtual SvStream & Store(SvStream & rStream, USHORT) const;
174 virtual SfxPoolItem * Clone(SfxItemPool * = 0) const;
176 virtual USHORT GetValueCount() const;
178 virtual UniString GetValueTextByVal(BOOL bTheValue) const;
180 BOOL GetValue() const { return m_bValue; }
182 void SetValue(BOOL bTheValue) { m_bValue = bTheValue; }
187 #endif // _SVTOOLS_CENUMITM_HXX