LCOV - code coverage report
Current view: top level - svl/source/items - grabbagitem.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 38 40 95.0 %
Date: 2014-04-11 Functions: 14 15 93.3 %
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      181646 : TYPEINIT1_AUTOFACTORY(SfxGrabBagItem, SfxPoolItem);
      19             : 
      20             : using namespace com::sun::star;
      21             : 
      22       25673 : SfxGrabBagItem::SfxGrabBagItem()
      23             : {
      24       25673 : }
      25             : 
      26         186 : SfxGrabBagItem::SfxGrabBagItem(sal_uInt16 nWhich, const std::map<OUString, uno::Any>* pMap) :
      27         186 :     SfxPoolItem(nWhich)
      28             : {
      29         186 :     if (pMap)
      30           0 :         m_aMap = *pMap;
      31         186 : }
      32             : 
      33       31814 : SfxGrabBagItem::SfxGrabBagItem(const SfxGrabBagItem& rItem) :
      34             :     SfxPoolItem(rItem),
      35       31814 :     m_aMap(rItem.m_aMap)
      36             : {
      37       31814 : }
      38             : 
      39      115314 : SfxGrabBagItem::~SfxGrabBagItem()
      40             : {
      41      115314 : }
      42             : 
      43        6632 : const std::map<OUString, uno::Any>& SfxGrabBagItem::GetGrabBag() const
      44             : {
      45        6632 :     return m_aMap;
      46             : }
      47             : 
      48      145801 : bool SfxGrabBagItem::operator==(const SfxPoolItem& rItem) const
      49             : {
      50      145801 :     SfxGrabBagItem* pItem = (SfxGrabBagItem*)&rItem;
      51             : 
      52      145801 :     return m_aMap == pItem->m_aMap;
      53             : }
      54             : 
      55       31814 : SfxPoolItem* SfxGrabBagItem::Clone(SfxItemPool* /*pPool*/) const
      56             : {
      57       31814 :     return new SfxGrabBagItem(*this);
      58             : }
      59             : 
      60       49781 : bool SfxGrabBagItem::PutValue(const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
      61             : {
      62       49781 :     uno::Sequence<beans::PropertyValue> aValue;
      63       49781 :     if (rVal >>= aValue)
      64             :     {
      65       49781 :         m_aMap.clear();
      66       49781 :         comphelper::OSequenceIterator<beans::PropertyValue> i(aValue);
      67      264927 :         while (i.hasMoreElements())
      68             :         {
      69      165365 :             beans::PropertyValue aPropertyValue = i.nextElement().get<beans::PropertyValue>();
      70      165365 :             m_aMap[aPropertyValue.Name] = aPropertyValue.Value;
      71      165365 :         }
      72       49781 :         return true;
      73             :     }
      74             : 
      75             :     SAL_WARN("svl", "SfxGrabBagItem::PutValue: wrong type");
      76           0 :     return false;
      77             : }
      78             : 
      79       14495 : bool SfxGrabBagItem::QueryValue(uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
      80             : {
      81       14495 :     uno::Sequence<beans::PropertyValue> aValue(m_aMap.size());
      82       14495 :     beans::PropertyValue* pValue = aValue.getArray();
      83       78011 :     for (std::map<OUString, com::sun::star::uno::Any>::const_iterator i = m_aMap.begin(); i != m_aMap.end(); ++i)
      84             :     {
      85       63516 :         pValue[0].Name = i->first;
      86       63516 :         pValue[0].Value = i->second;
      87       63516 :         ++pValue;
      88             :     }
      89       14495 :     rVal = uno::makeAny(aValue);
      90       14495 :     return true;
      91             : }
      92             : 
      93             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10