LibreOffice Module svl (master) 1
cenumitm.cxx
Go to the documentation of this file.
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 <com/sun/star/uno/Any.hxx>
21#include <svl/cenumitm.hxx>
22#include <svl/eitem.hxx>
23
25#include <libxml/xmlwriter.h>
26#include <sal/log.hxx>
27
28
29// virtual
31{
32 SAL_WARN_IF(!SfxPoolItem::operator ==(rItem), "svl.items", "unequal type, with ID/pos " << Which() );
33 return GetEnumValue()
34 == static_cast< const SfxEnumItemInterface * >(&rItem)->
36}
37
38// virtual
40 MapUnit, OUString & rText,
41 const IntlWrapper&) const
42{
43 rText = OUString::number( GetEnumValue() );
44 return true;
45}
46
47// virtual
49 const
50{
51 rVal <<= sal_Int32(GetEnumValue());
52 return true;
53}
54
55// virtual
56bool SfxEnumItemInterface::PutValue(const css::uno::Any& rVal,
58{
59 sal_Int32 nTheValue = 0;
60
61 if ( ::cppu::enum2int( nTheValue, rVal ) )
62 {
63 SetEnumValue(sal_uInt16(nTheValue));
64 return true;
65 }
66 SAL_WARN("svl.items", "SfxEnumItemInterface::PutValue(): Wrong type");
67 return false;
68}
69
70// virtual
72{
73 return false;
74}
75
76// virtual
78{
79 return false;
80}
81
82// virtual
84{}
85
87{
88 return new SfxBoolItem();
89}
90
91// virtual
92bool SfxBoolItem::operator ==(const SfxPoolItem & rItem) const
93{
94 assert(SfxPoolItem::operator==(rItem));
95 return m_bValue == static_cast< SfxBoolItem const * >(&rItem)->m_bValue;
96}
97
98// virtual
101 OUString & rText,
102 const IntlWrapper&) const
103{
105 return true;
106}
107
109{
110 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SfxBoolItem"));
111 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(GetValueTextByVal(m_bValue).toUtf8().getStr()));
112 SfxPoolItem::dumpAsXml(pWriter);
113 (void)xmlTextWriterEndElement(pWriter);
114}
115
116// virtual
117bool SfxBoolItem::QueryValue(css::uno::Any& rVal, sal_uInt8) const
118{
119 rVal <<= m_bValue;
120 return true;
121}
122
123// virtual
124bool SfxBoolItem::PutValue(const css::uno::Any& rVal, sal_uInt8)
125{
126 bool bTheValue = bool();
127 if (rVal >>= bTheValue)
128 {
129 m_bValue = bTheValue;
130 return true;
131 }
132 SAL_WARN("svl.items", "SfxBoolItem::PutValue(): Wrong type");
133 return false;
134}
135
136// virtual
138{
139 return new SfxBoolItem(*this);
140}
141
142// virtual
143OUString SfxBoolItem::GetValueTextByVal(bool bTheValue) const
144{
145 return bTheValue ? OUString("TRUE") : OUString("FALSE");
146}
147
148/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool operator==(const SfxPoolItem &rItem) const override
Definition: cenumitm.cxx:92
bool m_bValue
Definition: eitem.hxx:70
virtual OUString GetValueTextByVal(bool bTheValue) const
Definition: cenumitm.cxx:143
virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString &rText, const IntlWrapper &) const override
This virtual method allows to get a textual representation of the value for the SfxPoolItem subclasse...
Definition: cenumitm.cxx:99
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: cenumitm.cxx:108
SfxBoolItem(sal_uInt16 const nWhich=0, bool const bValue=false)
Definition: eitem.hxx:75
static SfxPoolItem * CreateDefault()
Definition: cenumitm.cxx:86
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8) override
Definition: cenumitm.cxx:124
virtual SfxBoolItem * Clone(SfxItemPool *=nullptr) const override
Definition: cenumitm.cxx:137
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8=0) const override
Definition: cenumitm.cxx:117
virtual sal_uInt16 GetEnumValue() const =0
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8) override
Definition: cenumitm.cxx:56
virtual bool HasBoolValue() const
Definition: cenumitm.cxx:71
virtual bool operator==(const SfxPoolItem &rItem) const override
Definition: cenumitm.cxx:30
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8=0) const override
Definition: cenumitm.cxx:48
virtual void SetBoolValue(bool bValue)
Definition: cenumitm.cxx:83
virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString &rText, const IntlWrapper &) const override
This virtual method allows to get a textual representation of the value for the SfxPoolItem subclasse...
Definition: cenumitm.cxx:39
virtual void SetEnumValue(sal_uInt16 nValue)=0
virtual bool GetBoolValue() const
Definition: cenumitm.cxx:77
Base class for providers of defaults of SfxPoolItems.
Definition: itempool.hxx:51
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: poolitem.cxx:534
sal_uInt16 Which() const
Definition: poolitem.hxx:149
struct _xmlTextWriter * xmlTextWriterPtr
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
MapUnit
SfxItemPresentation
Definition: poolitem.hxx:72
unsigned char sal_uInt8