nss: upgrade to release 3.73
[LibreOffice.git] / svl / source / items / cenumitm.cxx
blob3d0b7e581d522c5edd00c60ae0390d1f00a3a779
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 <svl/cenumitm.hxx>
22 #include <svl/eitem.hxx>
24 #include <comphelper/extract.hxx>
25 #include <libxml/xmlwriter.h>
26 #include <sal/log.hxx>
29 // virtual
30 bool SfxEnumItemInterface::operator ==(const SfxPoolItem & rItem) const
32 SAL_WARN_IF(!SfxPoolItem::operator ==(rItem), "svl.items", "unequal type, with ID/pos " << Which() );
33 return GetEnumValue()
34 == static_cast< const SfxEnumItemInterface * >(&rItem)->
35 GetEnumValue();
38 // virtual
39 bool SfxEnumItemInterface::GetPresentation(SfxItemPresentation, MapUnit,
40 MapUnit, OUString & rText,
41 const IntlWrapper&) const
43 rText = OUString::number( GetEnumValue() );
44 return true;
47 // virtual
48 bool SfxEnumItemInterface::QueryValue(css::uno::Any& rVal, sal_uInt8)
49 const
51 rVal <<= sal_Int32(GetEnumValue());
52 return true;
55 // virtual
56 bool SfxEnumItemInterface::PutValue(const css::uno::Any& rVal,
57 sal_uInt8)
59 sal_Int32 nTheValue = 0;
61 if ( ::cppu::enum2int( nTheValue, rVal ) )
63 SetEnumValue(sal_uInt16(nTheValue));
64 return true;
66 SAL_WARN("svl.items", "SfxEnumItemInterface::PutValue(): Wrong type");
67 return false;
70 // virtual
71 bool SfxEnumItemInterface::HasBoolValue() const
73 return false;
76 // virtual
77 bool SfxEnumItemInterface::GetBoolValue() const
79 return false;
82 // virtual
83 void SfxEnumItemInterface::SetBoolValue(bool)
86 SfxPoolItem* SfxBoolItem::CreateDefault()
88 return new SfxBoolItem();
91 // virtual
92 bool SfxBoolItem::operator ==(const SfxPoolItem & rItem) const
94 assert(dynamic_cast<const SfxBoolItem*>(&rItem) != nullptr);
95 return m_bValue == static_cast< SfxBoolItem const * >(&rItem)->m_bValue;
98 // virtual
99 bool SfxBoolItem::GetPresentation(SfxItemPresentation,
100 MapUnit, MapUnit,
101 OUString & rText,
102 const IntlWrapper&) const
104 rText = GetValueTextByVal(m_bValue);
105 return true;
108 void SfxBoolItem::dumpAsXml(xmlTextWriterPtr pWriter) const
110 xmlTextWriterStartElement(pWriter, BAD_CAST("SfxBoolItem"));
111 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
112 xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(GetValueTextByVal(m_bValue).toUtf8().getStr()));
113 xmlTextWriterEndElement(pWriter);
116 // virtual
117 bool SfxBoolItem::QueryValue(css::uno::Any& rVal, sal_uInt8) const
119 rVal <<= m_bValue;
120 return true;
123 // virtual
124 bool SfxBoolItem::PutValue(const css::uno::Any& rVal, sal_uInt8)
126 bool bTheValue = bool();
127 if (rVal >>= bTheValue)
129 m_bValue = bTheValue;
130 return true;
132 SAL_WARN("svl.items", "SfxBoolItem::PutValue(): Wrong type");
133 return false;
136 // virtual
137 SfxBoolItem* SfxBoolItem::Clone(SfxItemPool *) const
139 return new SfxBoolItem(*this);
142 // virtual
143 OUString SfxBoolItem::GetValueTextByVal(bool bTheValue) const
145 return bTheValue ? OUString("TRUE") : OUString("FALSE");
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */