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: visitem.cxx,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 // 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
):
52 DBG_CTOR(SfxVisibilityItem
, 0);
55 m_nValue
.bVisible
= bValue
;
58 //============================================================================
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
)->
68 //============================================================================
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 //============================================================================
79 SfxItemPresentation
SfxVisibilityItem::GetPresentation(SfxItemPresentation
,
80 SfxMapUnit
, SfxMapUnit
,
82 const IntlWrapper
*) const
84 rText
= GetValueTextByVal(m_nValue
.bVisible
);
85 return SFX_ITEM_PRESENTATION_NAMELESS
;
89 //============================================================================
91 BOOL
SfxVisibilityItem::QueryValue(com::sun::star::uno::Any
& rVal
,BYTE
) const
97 //============================================================================
99 BOOL
SfxVisibilityItem::PutValue(const com::sun::star::uno::Any
& rVal
,BYTE
)
101 if (rVal
>>= m_nValue
)
104 DBG_ERROR( "SfxInt16Item::PutValue - Wrong type!" );
108 //============================================================================
110 SfxPoolItem
* SfxVisibilityItem::Create(SvStream
& rStream
, USHORT
) const
112 DBG_CHKTHIS(SfxVisibilityItem
, 0);
113 return new SfxVisibilityItem(Which(), rStream
);
116 //============================================================================
118 SvStream
& SfxVisibilityItem::Store(SvStream
& rStream
, USHORT
) const
120 DBG_CHKTHIS(SfxVisibilityItem
, 0);
121 rStream
<< m_nValue
.bVisible
;
125 //============================================================================
127 SfxPoolItem
* SfxVisibilityItem::Clone(SfxItemPool
*) const
129 DBG_CHKTHIS(SfxVisibilityItem
, 0);
130 return new SfxVisibilityItem(*this);
133 //============================================================================
135 USHORT
SfxVisibilityItem::GetValueCount() const
140 //============================================================================
142 UniString
SfxVisibilityItem::GetValueTextByVal(BOOL bTheValue
) const
146 UniString::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("TRUE")) :
147 UniString::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("FALSE"));