bump product version to 6.3.0.0.beta1
[LibreOffice.git] / svl / source / items / grabbagitem.cxx
blobe5d04da41d7d22a7e3098673d63fdef0e5633601
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/.
8 */
10 #include <svl/grabbagitem.hxx>
11 #include <sal/config.h>
13 #include <sal/log.hxx>
14 #include <comphelper/sequence.hxx>
15 #include <com/sun/star/beans/PropertyValue.hpp>
17 using namespace com::sun::star;
19 SfxGrabBagItem::SfxGrabBagItem() = default;
21 SfxGrabBagItem::SfxGrabBagItem(sal_uInt16 nWhich)
22 : SfxPoolItem(nWhich)
26 SfxGrabBagItem::~SfxGrabBagItem() = default;
28 bool SfxGrabBagItem::operator==(const SfxPoolItem& rItem) const
30 auto pItem = static_cast<const SfxGrabBagItem*>(&rItem);
32 return m_aMap == pItem->m_aMap;
35 SfxPoolItem* SfxGrabBagItem::Clone(SfxItemPool* /*pPool*/) const
37 return new SfxGrabBagItem(*this);
40 bool SfxGrabBagItem::PutValue(const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
42 uno::Sequence<beans::PropertyValue> aValue;
43 if (rVal >>= aValue)
45 m_aMap.clear();
46 for (beans::PropertyValue const& aPropertyValue : aValue)
48 m_aMap[aPropertyValue.Name] = aPropertyValue.Value;
50 return true;
53 SAL_WARN("svl", "SfxGrabBagItem::PutValue: wrong type");
54 return false;
57 bool SfxGrabBagItem::QueryValue(uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
59 uno::Sequence<beans::PropertyValue> aValue(m_aMap.size());
60 beans::PropertyValue* pValue = aValue.getArray();
61 for (const auto& i : m_aMap)
63 pValue[0].Name = i.first;
64 pValue[0].Value = i.second;
65 ++pValue;
67 rVal <<= aValue;
68 return true;
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */