bump product version to 6.3.0.0.beta1
[LibreOffice.git] / svl / source / items / cenumitm.cxx
blob6646647d763e7dd4aa5a66a94e10087f24a422de
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/uno/Any.hxx>
21 #include <tools/stream.hxx>
22 #include <svl/cenumitm.hxx>
23 #include <svl/eitem.hxx>
25 #include <comphelper/extract.hxx>
26 #include <libxml/xmlwriter.h>
27 #include <sal/log.hxx>
30 // virtual
31 bool SfxEnumItemInterface::operator ==(const SfxPoolItem & rItem) const
33 SAL_WARN_IF(!SfxPoolItem::operator ==(rItem), "svl.items", "unequal type, with ID/pos " << Which() );
34 return GetEnumValue()
35 == static_cast< const SfxEnumItemInterface * >(&rItem)->
36 GetEnumValue();
39 // virtual
40 bool SfxEnumItemInterface::GetPresentation(SfxItemPresentation, MapUnit,
41 MapUnit, OUString & rText,
42 const IntlWrapper&) const
44 rText = OUString::number( GetEnumValue() );
45 return true;
48 // virtual
49 bool SfxEnumItemInterface::QueryValue(css::uno::Any& rVal, sal_uInt8)
50 const
52 rVal <<= sal_Int32(GetEnumValue());
53 return true;
56 // virtual
57 bool SfxEnumItemInterface::PutValue(const css::uno::Any& rVal,
58 sal_uInt8)
60 sal_Int32 nTheValue = 0;
62 if ( ::cppu::enum2int( nTheValue, rVal ) )
64 SetEnumValue(sal_uInt16(nTheValue));
65 return true;
67 SAL_WARN("svl.items", "SfxEnumItemInterface::PutValue(): Wrong type");
68 return false;
71 // virtual
72 bool SfxEnumItemInterface::HasBoolValue() const
74 return false;
77 // virtual
78 bool SfxEnumItemInterface::GetBoolValue() const
80 return false;
83 // virtual
84 void SfxEnumItemInterface::SetBoolValue(bool)
87 SfxPoolItem* SfxBoolItem::CreateDefault()
89 return new SfxBoolItem();
92 // virtual
93 bool SfxBoolItem::operator ==(const SfxPoolItem & rItem) const
95 assert(dynamic_cast<const SfxBoolItem*>(&rItem) != nullptr);
96 return m_bValue == static_cast< SfxBoolItem const * >(&rItem)->m_bValue;
99 // virtual
100 bool SfxBoolItem::GetPresentation(SfxItemPresentation,
101 MapUnit, MapUnit,
102 OUString & rText,
103 const IntlWrapper&) const
105 rText = GetValueTextByVal(m_bValue);
106 return true;
109 void SfxBoolItem::dumpAsXml(xmlTextWriterPtr pWriter) const
111 xmlTextWriterStartElement(pWriter, BAD_CAST("SfxBoolItem"));
112 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
113 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(GetValueTextByVal(m_bValue).toUtf8().getStr()));
114 xmlTextWriterEndElement(pWriter);
117 // virtual
118 bool SfxBoolItem::QueryValue(css::uno::Any& rVal, sal_uInt8) const
120 rVal <<= m_bValue;
121 return true;
124 // virtual
125 bool SfxBoolItem::PutValue(const css::uno::Any& rVal, sal_uInt8)
127 bool bTheValue = bool();
128 if (rVal >>= bTheValue)
130 m_bValue = bTheValue;
131 return true;
133 SAL_WARN("svl.items", "SfxBoolItem::PutValue(): Wrong type");
134 return false;
137 // virtual
138 SfxPoolItem * SfxBoolItem::Clone(SfxItemPool *) const
140 return new SfxBoolItem(*this);
143 // virtual
144 OUString SfxBoolItem::GetValueTextByVal(bool bTheValue) const
146 return bTheValue ? OUString("TRUE") : OUString("FALSE");
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */