Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <svl/visitem.hxx>
21 : #include <com/sun/star/uno/Any.hxx>
22 : #include <osl/diagnose.h>
23 : #include <tools/stream.hxx>
24 :
25 44355 : TYPEINIT1_AUTOFACTORY(SfxVisibilityItem, SfxPoolItem);
26 :
27 0 : SfxVisibilityItem::SfxVisibilityItem(sal_uInt16 which, SvStream & rStream):
28 0 : SfxPoolItem(which)
29 : {
30 0 : bool bValue = false;
31 0 : rStream.ReadCharAsBool( bValue );
32 0 : m_nValue.bVisible = bValue;
33 0 : }
34 :
35 : // virtual
36 0 : bool SfxVisibilityItem::operator ==(const SfxPoolItem & rItem) const
37 : {
38 : DBG_ASSERT(SfxPoolItem::operator ==(rItem), "unequal type");
39 0 : return m_nValue.bVisible == (static_cast< const SfxVisibilityItem * >(&rItem))->
40 0 : m_nValue.bVisible;
41 : }
42 :
43 : // virtual
44 0 : int SfxVisibilityItem::Compare(const SfxPoolItem & rWith) const
45 : {
46 : DBG_ASSERT(rWith.ISA(SfxVisibilityItem), "SfxVisibilityItem::Compare(): Bad type");
47 0 : return m_nValue.bVisible == static_cast< SfxVisibilityItem const * >(&rWith)->m_nValue.bVisible ?
48 0 : 0 : m_nValue.bVisible ? -1 : 1;
49 : }
50 :
51 : // virtual
52 0 : bool SfxVisibilityItem::GetPresentation(SfxItemPresentation,
53 : SfxMapUnit, SfxMapUnit,
54 : OUString & rText,
55 : const IntlWrapper *) const
56 : {
57 0 : rText = GetValueTextByVal(m_nValue.bVisible);
58 0 : return true;
59 : }
60 :
61 :
62 : // virtual
63 0 : bool SfxVisibilityItem::QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8) const
64 : {
65 0 : rVal <<= m_nValue;
66 0 : return true;
67 : }
68 :
69 : // virtual
70 0 : bool SfxVisibilityItem::PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8)
71 : {
72 0 : if (rVal >>= m_nValue)
73 0 : return true;
74 :
75 : OSL_FAIL( "SfxInt16Item::PutValue - Wrong type!" );
76 0 : return false;
77 : }
78 :
79 : // virtual
80 0 : SfxPoolItem * SfxVisibilityItem::Create(SvStream & rStream, sal_uInt16) const
81 : {
82 0 : return new SfxVisibilityItem(Which(), rStream);
83 : }
84 :
85 : // virtual
86 0 : SvStream & SfxVisibilityItem::Store(SvStream & rStream, sal_uInt16) const
87 : {
88 0 : rStream.WriteUChar( m_nValue.bVisible );
89 0 : return rStream;
90 : }
91 :
92 : // virtual
93 0 : SfxPoolItem * SfxVisibilityItem::Clone(SfxItemPool *) const
94 : {
95 0 : return new SfxVisibilityItem(*this);
96 : }
97 :
98 : // virtual
99 0 : OUString SfxVisibilityItem::GetValueTextByVal(bool bTheValue) const
100 : {
101 0 : return bTheValue ? OUString("TRUE") : OUString("FALSE");
102 : }
103 :
104 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|