GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / svl / source / items / grabbagitem.cxx
blob23ab2bd067189048314725ab58f2d069c37414ea
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 <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) :
29 SfxPoolItem( nWhich )
31 if (pMap)
32 m_aMap = *pMap;
35 SfxGrabBagItem::SfxGrabBagItem(const SfxGrabBagItem& rItem) :
36 SfxPoolItem(rItem),
37 m_aMap(rItem.m_aMap)
41 SfxGrabBagItem::~SfxGrabBagItem()
45 void SfxGrabBagItem::SetGrabBag(const std::map<OUString, uno::Any>& rMap)
47 m_aMap = rMap;
50 const std::map<OUString, uno::Any>& SfxGrabBagItem::GetGrabBag() const
52 return m_aMap;
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 )
72 m_aMap.clear();
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;
79 return true;
82 SAL_WARN("svl", "SfxGrabBagItem::PutValue: wrong type");
83 return false;
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;
94 ++pValue;
96 rVal = uno::makeAny(aValue);
97 return true;
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */