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 <svl/poolitem.hxx>
12 #include <com/sun/star/uno/Any.hxx>
13 #include <com/sun/star/uno/Sequence.hxx>
14 #include <comphelper/sequence.hxx>
16 #include <com/sun/star/beans/PropertyValue.hpp>
18 DBG_NAME(SfxGrabBagItem
)
20 TYPEINIT1_AUTOFACTORY(SfxGrabBagItem
, SfxPoolItem
);
22 using namespace com::sun::star
;
24 SfxGrabBagItem::SfxGrabBagItem()
28 SfxGrabBagItem::SfxGrabBagItem(sal_uInt16 nWhich
, const std::map
<OUString
, uno::Any
> *pMap
) :
35 SfxGrabBagItem::SfxGrabBagItem(const SfxGrabBagItem
& rItem
) :
41 SfxGrabBagItem::~SfxGrabBagItem()
45 void SfxGrabBagItem::SetGrabBag(const std::map
<OUString
, uno::Any
>& rMap
)
50 const std::map
<OUString
, uno::Any
>& SfxGrabBagItem::GetGrabBag() const
55 int SfxGrabBagItem::operator==(const SfxPoolItem
& rItem
) const
57 SfxGrabBagItem
* pItem
= (SfxGrabBagItem
*)&rItem
;
59 return m_aMap
== pItem
->m_aMap
;
62 SfxPoolItem
* SfxGrabBagItem::Clone(SfxItemPool
* /*pPool*/) const
64 return new SfxGrabBagItem(*this);
67 bool SfxGrabBagItem::PutValue(const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
69 uno::Sequence
<beans::PropertyValue
> aValue
;
70 if ( rVal
>>= aValue
)
73 comphelper::OSequenceIterator
<beans::PropertyValue
> i(aValue
);
74 while (i
.hasMoreElements())
76 beans::PropertyValue aPropertyValue
= i
.nextElement().get
<beans::PropertyValue
>();
77 m_aMap
[aPropertyValue
.Name
] = aPropertyValue
.Value
;
82 SAL_WARN("svl", "SfxGrabBagItem::PutValue: wrong type");
86 bool SfxGrabBagItem::QueryValue(uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
88 uno::Sequence
<beans::PropertyValue
> aValue(m_aMap
.size());
89 beans::PropertyValue
* pValue
= aValue
.getArray();
90 for (std::map
<OUString
, com::sun::star::uno::Any
>::const_iterator i
= m_aMap
.begin(); i
!= m_aMap
.end(); ++i
)
92 pValue
[0].Name
= i
->first
;
93 pValue
[0].Value
= i
->second
;
96 rVal
= uno::makeAny(aValue
);
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */