1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cenumitm.hxx,v $
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>
38 #ifndef _SFXPOOLITEM_HXX
39 #include <bf_svtools/poolitem.hxx>
44 //============================================================================
45 DBG_NAMEEX(SfxEnumItemInterface
)
47 class SfxEnumItemInterface
: public SfxPoolItem
50 SfxEnumItemInterface(USHORT which
): SfxPoolItem(which
) {}
52 SfxEnumItemInterface(const SfxEnumItemInterface
& rItem
):
58 virtual int operator ==(const SfxPoolItem
& rItem
) const;
60 virtual SfxItemPresentation
GetPresentation(SfxItemPresentation
,
61 SfxMapUnit
, SfxMapUnit
,
63 const ::IntlWrapper
* = 0)
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.
78 /// @descr This method is implemented using GetValueCount() and
79 /// GetValueByPos(). Derived classes may replace this with a more
80 /// efficient implementation.
82 /// @param nValue Some value.
84 /// @return The position of nValue within this enumeration, or USHRT_MAX
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
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
) {}
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
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
,
163 const ::IntlWrapper
* = 0)
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