1*40df464eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*40df464eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*40df464eSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*40df464eSAndrew Rist * distributed with this work for additional information
6*40df464eSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*40df464eSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*40df464eSAndrew Rist * "License"); you may not use this file except in compliance
9*40df464eSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*40df464eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*40df464eSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*40df464eSAndrew Rist * software distributed under the License is distributed on an
15*40df464eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*40df464eSAndrew Rist * KIND, either express or implied. See the License for the
17*40df464eSAndrew Rist * specific language governing permissions and limitations
18*40df464eSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*40df464eSAndrew Rist *************************************************************/
21*40df464eSAndrew Rist
22*40df464eSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svl.hxx"
26cdf0e10cSrcweir #include <svl/visitem.hxx>
27cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
28cdf0e10cSrcweir #include <tools/stream.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir //============================================================================
31cdf0e10cSrcweir //
32cdf0e10cSrcweir // class SfxVisibilityItem
33cdf0e10cSrcweir //
34cdf0e10cSrcweir //============================================================================
35cdf0e10cSrcweir
36cdf0e10cSrcweir DBG_NAME(SfxVisibilityItem)
37cdf0e10cSrcweir
38cdf0e10cSrcweir //============================================================================
39cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxVisibilityItem, SfxPoolItem);
40cdf0e10cSrcweir
41cdf0e10cSrcweir //============================================================================
SfxVisibilityItem(sal_uInt16 which,SvStream & rStream)42cdf0e10cSrcweir SfxVisibilityItem::SfxVisibilityItem(sal_uInt16 which, SvStream & rStream):
43cdf0e10cSrcweir SfxPoolItem(which)
44cdf0e10cSrcweir {
45cdf0e10cSrcweir DBG_CTOR(SfxVisibilityItem, 0);
46cdf0e10cSrcweir sal_Bool bValue = 0;
47cdf0e10cSrcweir rStream >> bValue;
48cdf0e10cSrcweir m_nValue.bVisible = bValue;
49cdf0e10cSrcweir }
50cdf0e10cSrcweir
51cdf0e10cSrcweir //============================================================================
52cdf0e10cSrcweir // virtual
operator ==(const SfxPoolItem & rItem) const53cdf0e10cSrcweir int SfxVisibilityItem::operator ==(const SfxPoolItem & rItem) const
54cdf0e10cSrcweir {
55cdf0e10cSrcweir DBG_CHKTHIS(SfxVisibilityItem, 0);
56cdf0e10cSrcweir DBG_ASSERT(SfxPoolItem::operator ==(rItem), "unequal type");
57cdf0e10cSrcweir return m_nValue.bVisible == SAL_STATIC_CAST(const SfxVisibilityItem *, &rItem)->
58cdf0e10cSrcweir m_nValue.bVisible;
59cdf0e10cSrcweir }
60cdf0e10cSrcweir
61cdf0e10cSrcweir //============================================================================
62cdf0e10cSrcweir // virtual
Compare(const SfxPoolItem & rWith) const63cdf0e10cSrcweir int SfxVisibilityItem::Compare(const SfxPoolItem & rWith) const
64cdf0e10cSrcweir {
65cdf0e10cSrcweir DBG_ASSERT(rWith.ISA(SfxVisibilityItem), "SfxVisibilityItem::Compare(): Bad type");
66cdf0e10cSrcweir return m_nValue.bVisible == static_cast< SfxVisibilityItem const * >(&rWith)->m_nValue.bVisible ?
67cdf0e10cSrcweir 0 : m_nValue.bVisible ? -1 : 1;
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
70cdf0e10cSrcweir //============================================================================
71cdf0e10cSrcweir // virtual
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const72cdf0e10cSrcweir SfxItemPresentation SfxVisibilityItem::GetPresentation(SfxItemPresentation,
73cdf0e10cSrcweir SfxMapUnit, SfxMapUnit,
74cdf0e10cSrcweir XubString & rText,
75cdf0e10cSrcweir const IntlWrapper *) const
76cdf0e10cSrcweir {
77cdf0e10cSrcweir rText = GetValueTextByVal(m_nValue.bVisible);
78cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NAMELESS;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
81cdf0e10cSrcweir
82cdf0e10cSrcweir //============================================================================
83cdf0e10cSrcweir // virtual
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const84cdf0e10cSrcweir sal_Bool SfxVisibilityItem::QueryValue(com::sun::star::uno::Any& rVal,sal_uInt8) const
85cdf0e10cSrcweir {
86cdf0e10cSrcweir rVal <<= m_nValue;
87cdf0e10cSrcweir return sal_True;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir
90cdf0e10cSrcweir //============================================================================
91cdf0e10cSrcweir // virtual
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)92cdf0e10cSrcweir sal_Bool SfxVisibilityItem::PutValue(const com::sun::star::uno::Any& rVal,sal_uInt8)
93cdf0e10cSrcweir {
94cdf0e10cSrcweir if (rVal >>= m_nValue)
95cdf0e10cSrcweir return sal_True;
96cdf0e10cSrcweir
97cdf0e10cSrcweir DBG_ERROR( "SfxInt16Item::PutValue - Wrong type!" );
98cdf0e10cSrcweir return sal_False;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
101cdf0e10cSrcweir //============================================================================
102cdf0e10cSrcweir // virtual
Create(SvStream & rStream,sal_uInt16) const103cdf0e10cSrcweir SfxPoolItem * SfxVisibilityItem::Create(SvStream & rStream, sal_uInt16) const
104cdf0e10cSrcweir {
105cdf0e10cSrcweir DBG_CHKTHIS(SfxVisibilityItem, 0);
106cdf0e10cSrcweir return new SfxVisibilityItem(Which(), rStream);
107cdf0e10cSrcweir }
108cdf0e10cSrcweir
109cdf0e10cSrcweir //============================================================================
110cdf0e10cSrcweir // virtual
Store(SvStream & rStream,sal_uInt16) const111cdf0e10cSrcweir SvStream & SfxVisibilityItem::Store(SvStream & rStream, sal_uInt16) const
112cdf0e10cSrcweir {
113cdf0e10cSrcweir DBG_CHKTHIS(SfxVisibilityItem, 0);
114cdf0e10cSrcweir rStream << m_nValue.bVisible;
115cdf0e10cSrcweir return rStream;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
118cdf0e10cSrcweir //============================================================================
119cdf0e10cSrcweir // virtual
Clone(SfxItemPool *) const120cdf0e10cSrcweir SfxPoolItem * SfxVisibilityItem::Clone(SfxItemPool *) const
121cdf0e10cSrcweir {
122cdf0e10cSrcweir DBG_CHKTHIS(SfxVisibilityItem, 0);
123cdf0e10cSrcweir return new SfxVisibilityItem(*this);
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir //============================================================================
127cdf0e10cSrcweir // virtual
GetValueCount() const128cdf0e10cSrcweir sal_uInt16 SfxVisibilityItem::GetValueCount() const
129cdf0e10cSrcweir {
130cdf0e10cSrcweir return 2;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
133cdf0e10cSrcweir //============================================================================
134cdf0e10cSrcweir // virtual
GetValueTextByVal(sal_Bool bTheValue) const135cdf0e10cSrcweir UniString SfxVisibilityItem::GetValueTextByVal(sal_Bool bTheValue) const
136cdf0e10cSrcweir {
137cdf0e10cSrcweir return
138cdf0e10cSrcweir bTheValue ?
139cdf0e10cSrcweir UniString::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("sal_True")) :
140cdf0e10cSrcweir UniString::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("sal_False"));
141cdf0e10cSrcweir }
142