1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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>
16 #include <o3tl/hash_combine.hxx>
18 using namespace com::sun::star
;
20 SfxGrabBagItem::SfxGrabBagItem()
25 SfxGrabBagItem::SfxGrabBagItem(sal_uInt16 nWhich
)
30 SfxGrabBagItem::SfxGrabBagItem(sal_uInt16 nWhich
, std::map
<OUString
, css::uno::Any
> aMap
)
32 , m_aMap(std::move(aMap
))
36 SfxGrabBagItem::~SfxGrabBagItem() = default;
38 bool SfxGrabBagItem::operator==(const SfxPoolItem
& rItem
) const
40 return SfxPoolItem::operator==(rItem
)
41 && m_aMap
== static_cast<const SfxGrabBagItem
*>(&rItem
)->m_aMap
;
44 size_t SfxGrabBagItem::hashCode() const
47 for (const auto& rPair
: m_aMap
)
48 o3tl::hash_combine(seed
, rPair
.first
.hashCode());
52 SfxGrabBagItem
* SfxGrabBagItem::Clone(SfxItemPool
* /*pPool*/) const
54 return new SfxGrabBagItem(*this);
57 bool SfxGrabBagItem::PutValue(const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
59 ASSERT_CHANGE_REFCOUNTED_ITEM
;
60 uno::Sequence
<beans::PropertyValue
> aValue
;
64 for (beans::PropertyValue
const& aPropertyValue
: aValue
)
66 m_aMap
[aPropertyValue
.Name
] = aPropertyValue
.Value
;
71 SAL_WARN("svl", "SfxGrabBagItem::PutValue: wrong type");
75 bool SfxGrabBagItem::QueryValue(uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
77 uno::Sequence
<beans::PropertyValue
> aValue(m_aMap
.size());
78 beans::PropertyValue
* pValue
= aValue
.getArray();
79 for (const auto& i
: m_aMap
)
81 pValue
[0].Name
= i
.first
;
82 pValue
[0].Value
= i
.second
;
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */