update dev300-m58
[ooovba.git] / svtools / source / items1 / visitem.cxx
blob81ccea901ba3a283a9fcd439659a45e3160068b6
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: visitem.cxx,v $
10 * $Revision: 1.7 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #include <svtools/visitem.hxx>
34 #include <com/sun/star/uno/Any.hxx>
35 #include <tools/stream.hxx>
37 //============================================================================
39 // class SfxVisibilityItem
41 //============================================================================
43 DBG_NAME(SfxVisibilityItem)
45 //============================================================================
46 TYPEINIT1_AUTOFACTORY(SfxVisibilityItem, SfxPoolItem);
48 //============================================================================
49 SfxVisibilityItem::SfxVisibilityItem(USHORT which, SvStream & rStream):
50 SfxPoolItem(which)
52 DBG_CTOR(SfxVisibilityItem, 0);
53 sal_Bool bValue = 0;
54 rStream >> bValue;
55 m_nValue.bVisible = bValue;
58 //============================================================================
59 // virtual
60 int SfxVisibilityItem::operator ==(const SfxPoolItem & rItem) const
62 DBG_CHKTHIS(SfxVisibilityItem, 0);
63 DBG_ASSERT(SfxPoolItem::operator ==(rItem), "unequal type");
64 return m_nValue.bVisible == SAL_STATIC_CAST(const SfxVisibilityItem *, &rItem)->
65 m_nValue.bVisible;
68 //============================================================================
69 // virtual
70 int SfxVisibilityItem::Compare(const SfxPoolItem & rWith) const
72 DBG_ASSERT(rWith.ISA(SfxVisibilityItem), "SfxVisibilityItem::Compare(): Bad type");
73 return m_nValue.bVisible == static_cast< SfxVisibilityItem const * >(&rWith)->m_nValue.bVisible ?
74 0 : m_nValue.bVisible ? -1 : 1;
77 //============================================================================
78 // virtual
79 SfxItemPresentation SfxVisibilityItem::GetPresentation(SfxItemPresentation,
80 SfxMapUnit, SfxMapUnit,
81 XubString & rText,
82 const IntlWrapper *) const
84 rText = GetValueTextByVal(m_nValue.bVisible);
85 return SFX_ITEM_PRESENTATION_NAMELESS;
89 //============================================================================
90 // virtual
91 BOOL SfxVisibilityItem::QueryValue(com::sun::star::uno::Any& rVal,BYTE) const
93 rVal <<= m_nValue;
94 return TRUE;
97 //============================================================================
98 // virtual
99 BOOL SfxVisibilityItem::PutValue(const com::sun::star::uno::Any& rVal,BYTE)
101 if (rVal >>= m_nValue)
102 return TRUE;
104 DBG_ERROR( "SfxInt16Item::PutValue - Wrong type!" );
105 return FALSE;
108 //============================================================================
109 // virtual
110 SfxPoolItem * SfxVisibilityItem::Create(SvStream & rStream, USHORT) const
112 DBG_CHKTHIS(SfxVisibilityItem, 0);
113 return new SfxVisibilityItem(Which(), rStream);
116 //============================================================================
117 // virtual
118 SvStream & SfxVisibilityItem::Store(SvStream & rStream, USHORT) const
120 DBG_CHKTHIS(SfxVisibilityItem, 0);
121 rStream << m_nValue.bVisible;
122 return rStream;
125 //============================================================================
126 // virtual
127 SfxPoolItem * SfxVisibilityItem::Clone(SfxItemPool *) const
129 DBG_CHKTHIS(SfxVisibilityItem, 0);
130 return new SfxVisibilityItem(*this);
133 //============================================================================
134 // virtual
135 USHORT SfxVisibilityItem::GetValueCount() const
137 return 2;
140 //============================================================================
141 // virtual
142 UniString SfxVisibilityItem::GetValueTextByVal(BOOL bTheValue) const
144 return
145 bTheValue ?
146 UniString::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("TRUE")) :
147 UniString::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("FALSE"));