LCOV - code coverage report
Current view: top level - svl/source/items - grabbagitem.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 40 0.0 %
Date: 2014-04-14 Functions: 0 15 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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             :  */
       9             : 
      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>
      15             : 
      16             : #include <com/sun/star/beans/PropertyValue.hpp>
      17             : 
      18           0 : TYPEINIT1_AUTOFACTORY(SfxGrabBagItem, SfxPoolItem);
      19             : 
      20             : using namespace com::sun::star;
      21             : 
      22           0 : SfxGrabBagItem::SfxGrabBagItem()
      23             : {
      24           0 : }
      25             : 
      26           0 : SfxGrabBagItem::SfxGrabBagItem(sal_uInt16 nWhich, const std::map<OUString, uno::Any>* pMap) :
      27           0 :     SfxPoolItem(nWhich)
      28             : {
      29           0 :     if (pMap)
      30           0 :         m_aMap = *pMap;
      31           0 : }
      32             : 
      33           0 : SfxGrabBagItem::SfxGrabBagItem(const SfxGrabBagItem& rItem) :
      34             :     SfxPoolItem(rItem),
      35           0 :     m_aMap(rItem.m_aMap)
      36             : {
      37           0 : }
      38             : 
      39           0 : SfxGrabBagItem::~SfxGrabBagItem()
      40             : {
      41           0 : }
      42             : 
      43           0 : const std::map<OUString, uno::Any>& SfxGrabBagItem::GetGrabBag() const
      44             : {
      45           0 :     return m_aMap;
      46             : }
      47             : 
      48           0 : bool SfxGrabBagItem::operator==(const SfxPoolItem& rItem) const
      49             : {
      50           0 :     SfxGrabBagItem* pItem = (SfxGrabBagItem*)&rItem;
      51             : 
      52           0 :     return m_aMap == pItem->m_aMap;
      53             : }
      54             : 
      55           0 : SfxPoolItem* SfxGrabBagItem::Clone(SfxItemPool* /*pPool*/) const
      56             : {
      57           0 :     return new SfxGrabBagItem(*this);
      58             : }
      59             : 
      60           0 : bool SfxGrabBagItem::PutValue(const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
      61             : {
      62           0 :     uno::Sequence<beans::PropertyValue> aValue;
      63           0 :     if (rVal >>= aValue)
      64             :     {
      65           0 :         m_aMap.clear();
      66           0 :         comphelper::OSequenceIterator<beans::PropertyValue> i(aValue);
      67           0 :         while (i.hasMoreElements())
      68             :         {
      69           0 :             beans::PropertyValue aPropertyValue = i.nextElement().get<beans::PropertyValue>();
      70           0 :             m_aMap[aPropertyValue.Name] = aPropertyValue.Value;
      71           0 :         }
      72           0 :         return true;
      73             :     }
      74             : 
      75             :     SAL_WARN("svl", "SfxGrabBagItem::PutValue: wrong type");
      76           0 :     return false;
      77             : }
      78             : 
      79           0 : bool SfxGrabBagItem::QueryValue(uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
      80             : {
      81           0 :     uno::Sequence<beans::PropertyValue> aValue(m_aMap.size());
      82           0 :     beans::PropertyValue* pValue = aValue.getArray();
      83           0 :     for (std::map<OUString, com::sun::star::uno::Any>::const_iterator i = m_aMap.begin(); i != m_aMap.end(); ++i)
      84             :     {
      85           0 :         pValue[0].Name = i->first;
      86           0 :         pValue[0].Value = i->second;
      87           0 :         ++pValue;
      88             :     }
      89           0 :     rVal = uno::makeAny(aValue);
      90           0 :     return true;
      91             : }
      92             : 
      93             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10