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

          Line data    Source code
       1             : /*
       2             :  * This file is part of the LibreOffice project.
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * This file incorporates work covered by the following license notice:
       9             :  *
      10             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      11             :  *   contributor license agreements. See the NOTICE file distributed
      12             :  *   with this work for additional information regarding copyright
      13             :  *   ownership. The ASF licenses this file to you under the Apache
      14             :  *   License, Version 2.0 (the "License"); you may not use this file
      15             :  *   except in compliance with the License. You may obtain a copy of
      16             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      17             :  */
      18             : 
      19             : #include <svx/galleryitem.hxx>
      20             : #include <com/sun/star/gallery/GalleryItemType.hpp>
      21             : #include <com/sun/star/beans/PropertyValue.hpp>
      22             : #include <com/sun/star/uno/Sequence.hxx>
      23             : 
      24             : 
      25           0 : TYPEINIT1_AUTOFACTORY( SvxGalleryItem, SfxPoolItem );
      26             : 
      27           0 : SvxGalleryItem::SvxGalleryItem()
      28           0 :     : m_nType( css::gallery::GalleryItemType::EMPTY )
      29             : {
      30           0 : }
      31             : 
      32           0 : SvxGalleryItem::SvxGalleryItem( const SvxGalleryItem &rItem )
      33             :     : SfxPoolItem( rItem )
      34             :     , m_nType( rItem.m_nType )
      35             :     , m_aURL( rItem.m_aURL )
      36             :     , m_xDrawing( rItem.m_xDrawing )
      37           0 :     , m_xGraphic( rItem.m_xGraphic )
      38             : {
      39           0 : }
      40             : 
      41           0 : SvxGalleryItem::~SvxGalleryItem()
      42             : {
      43           0 : }
      44             : 
      45           0 : bool SvxGalleryItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /* nMemberId */ ) const
      46             : {
      47           0 :     css::uno::Sequence< css::beans::PropertyValue > aSeq( SVXGALLERYITEM_PARAMS );
      48             : 
      49           0 :     aSeq[0].Name = SVXGALLERYITEM_TYPE;
      50           0 :     aSeq[0].Value <<= m_nType;
      51           0 :     aSeq[1].Name = SVXGALLERYITEM_URL;
      52           0 :     aSeq[1].Value <<= m_aURL;
      53           0 :     aSeq[2].Name = SVXGALLERYITEM_FILTER;
      54           0 :     aSeq[2].Value <<= m_aURL;
      55           0 :     aSeq[3].Name = SVXGALLERYITEM_DRAWING;
      56           0 :     aSeq[3].Value <<= m_xDrawing;
      57           0 :     aSeq[4].Name = SVXGALLERYITEM_GRAPHIC;
      58           0 :     aSeq[4].Value <<= m_xGraphic;
      59             : 
      60           0 :     rVal <<= aSeq;
      61             : 
      62           0 :     return true;
      63             : }
      64             : 
      65           0 : bool SvxGalleryItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /* nMemberId */)
      66             : {
      67           0 :     css::uno::Sequence< css::beans::PropertyValue > aSeq;
      68             : 
      69           0 :     if ( !( rVal >>= aSeq ) || ( aSeq.getLength() < SVXGALLERYITEM_PARAMS ) )
      70           0 :         return false;
      71             : 
      72           0 :     int nConverted(0);
      73           0 :     bool bAllConverted( true );
      74             : 
      75           0 :     sal_Int8 nType(0);
      76           0 :     rtl::OUString aURL, aFilterName;
      77           0 :     css::uno::Reference< css::lang::XComponent > xDrawing;
      78           0 :     css::uno::Reference< css::graphic::XGraphic > xGraphic;
      79             : 
      80           0 :     const css::beans::PropertyValue *pProp = aSeq.getConstArray();
      81           0 :     const css::beans::PropertyValue *pEnd = pProp + aSeq.getLength();
      82           0 :     for ( ; pProp != pEnd; pProp++ )
      83             :     {
      84           0 :         if ( pProp->Name == SVXGALLERYITEM_TYPE )
      85             :         {
      86           0 :             bAllConverted &= ( pProp->Value >>= nType );
      87           0 :             ++nConverted;
      88             :         }
      89           0 :         else if ( pProp->Name == SVXGALLERYITEM_URL )
      90             :         {
      91           0 :             bAllConverted &= ( pProp->Value >>= aURL );
      92           0 :             ++nConverted;
      93             :         }
      94           0 :         else if ( pProp->Name == SVXGALLERYITEM_FILTER )
      95             :         {
      96           0 :             bAllConverted &= ( pProp->Value >>= aFilterName );
      97           0 :             ++nConverted;
      98             :         }
      99           0 :         else if ( pProp->Name == SVXGALLERYITEM_DRAWING )
     100             :         {
     101           0 :             bAllConverted &= ( pProp->Value >>= xDrawing );
     102           0 :             ++nConverted;
     103             :         }
     104           0 :         else if ( pProp->Name == SVXGALLERYITEM_GRAPHIC )
     105             :         {
     106           0 :             bAllConverted &= ( pProp->Value >>= xGraphic );
     107           0 :             ++nConverted;
     108             :         }
     109             :     }
     110             : 
     111           0 :     if ( !bAllConverted || nConverted != SVXGALLERYITEM_PARAMS )
     112           0 :         return false;
     113             : 
     114           0 :     m_nType = nType;
     115           0 :     m_aURL = aURL;
     116           0 :     m_aFilterName = aFilterName;
     117           0 :     m_xDrawing = xDrawing;
     118           0 :     m_xGraphic = xGraphic;
     119             : 
     120           0 :     return true;
     121             : }
     122             : 
     123           0 : bool SvxGalleryItem::operator==( const SfxPoolItem& rAttr ) const
     124             : {
     125             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
     126             : 
     127           0 :     const SvxGalleryItem& rItem = static_cast<const SvxGalleryItem&>(rAttr);
     128             : 
     129           0 :     return m_nType  == rItem.m_nType &&
     130           0 :             m_aURL      == rItem.m_aURL &&
     131           0 :             m_xDrawing  == rItem.m_xDrawing &&
     132           0 :             m_xGraphic  == rItem.m_xGraphic;
     133             : }
     134             : 
     135           0 : SfxPoolItem* SvxGalleryItem::Clone( SfxItemPool * ) const
     136             : {
     137           0 :     return new SvxGalleryItem( *this );
     138             : }
     139             : 
     140           0 : SvStream& SvxGalleryItem::Store( SvStream& rStream, sal_uInt16 /*nItemVersion*/ ) const
     141             : {
     142           0 :     return rStream;
     143             : }
     144             : 
     145           0 : SfxPoolItem* SvxGalleryItem::Create(SvStream& , sal_uInt16) const
     146             : {
     147           0 :     return 0;
     148             : }

Generated by: LCOV version 1.10