Add 'reference' to the iterator_traits, needed by LegacyIterator reqs
[LibreOffice.git] / svl / source / items / grabbagitem.cxx
blob39ee566866b34de9efdbc3310d942091e5b4cb58
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 <com/sun/star/beans/PropertyValue.hpp>
15 #include <com/sun/star/uno/Sequence.hxx>
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 return SfxPoolItem::operator==(rItem)
31 && m_aMap == static_cast<const SfxGrabBagItem*>(&rItem)->m_aMap;
34 SfxGrabBagItem* SfxGrabBagItem::Clone(SfxItemPool* /*pPool*/) const
36 return new SfxGrabBagItem(*this);
39 bool SfxGrabBagItem::PutValue(const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
41 uno::Sequence<beans::PropertyValue> aValue;
42 if (rVal >>= aValue)
44 m_aMap.clear();
45 for (beans::PropertyValue const& aPropertyValue : std::as_const(aValue))
47 m_aMap[aPropertyValue.Name] = aPropertyValue.Value;
49 return true;
52 SAL_WARN("svl", "SfxGrabBagItem::PutValue: wrong type");
53 return false;
56 bool SfxGrabBagItem::QueryValue(uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
58 uno::Sequence<beans::PropertyValue> aValue(m_aMap.size());
59 beans::PropertyValue* pValue = aValue.getArray();
60 for (const auto& i : m_aMap)
62 pValue[0].Name = i.first;
63 pValue[0].Value = i.second;
64 ++pValue;
66 rVal <<= aValue;
67 return true;
70 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */