LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/items - galleryitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 84 1.2 %
Date: 2013-07-09 Functions: 1 16 6.2 %
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             : namespace css = ::com::sun::star;
      25             : 
      26             : DBG_NAMEEX( SvxGalleryItem )
      27             : DBG_NAME( SvxGalleryItem )
      28             : 
      29          75 : TYPEINIT1_AUTOFACTORY( SvxGalleryItem, SfxPoolItem );
      30             : 
      31           0 : SvxGalleryItem::SvxGalleryItem()
      32             :     : m_nType( css::gallery::GalleryItemType::EMPTY )
      33           0 :     , m_bIsLink( sal_False )
      34             : {
      35             :     DBG_CTOR(SvxGalleryItem, 0);
      36           0 : }
      37             : 
      38           0 : SvxGalleryItem::SvxGalleryItem( const SvxGalleryItem &rItem )
      39             :     : SfxPoolItem( rItem )
      40             :     , m_nType( rItem.m_nType )
      41             :     , m_bIsLink( rItem.m_bIsLink )
      42             :     , m_aURL( rItem.m_aURL )
      43             :     , m_xDrawing( rItem.m_xDrawing )
      44           0 :     , m_xGraphic( rItem.m_xGraphic )
      45             : {
      46             :     DBG_CTOR(SvxGalleryItem, 0);
      47           0 : }
      48             : 
      49           0 : SvxGalleryItem::SvxGalleryItem(
      50             :     const ::sal_uInt16 nId )
      51             :     : SfxPoolItem( nId )
      52             :     , m_nType( css::gallery::GalleryItemType::EMPTY )
      53           0 :     , m_bIsLink( sal_False )
      54             : {
      55             :     DBG_CTOR(SvxGalleryItem, 0);
      56           0 : }
      57             : 
      58           0 : SvxGalleryItem::~SvxGalleryItem()
      59             : {
      60             :     DBG_DTOR(SvxGalleryItem, 0);
      61           0 : }
      62             : 
      63           0 : bool SvxGalleryItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /* nMemberId */ ) const
      64             : {
      65           0 :     css::uno::Sequence< css::beans::PropertyValue > aSeq( SVXGALLERYITEM_PARAMS );
      66             : 
      67           0 :     aSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVXGALLERYITEM_TYPE ));
      68           0 :     aSeq[0].Value <<= m_nType;
      69           0 :     aSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVXGALLERYITEM_LINK ));
      70           0 :     aSeq[1].Value <<= m_bIsLink;
      71           0 :     aSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVXGALLERYITEM_URL ));
      72           0 :     aSeq[2].Value <<= m_aURL;
      73           0 :     aSeq[3].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVXGALLERYITEM_FILTER ));
      74           0 :     aSeq[3].Value <<= m_aURL;
      75           0 :     aSeq[4].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVXGALLERYITEM_DRAWING ));
      76           0 :     aSeq[4].Value <<= m_xDrawing;
      77           0 :     aSeq[5].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVXGALLERYITEM_GRAPHIC ));
      78           0 :     aSeq[5].Value <<= m_xGraphic;
      79             : 
      80           0 :     rVal <<= aSeq;
      81             : 
      82           0 :     return true;
      83             : }
      84             : 
      85           0 : bool SvxGalleryItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /* nMemberId */)
      86             : {
      87           0 :     css::uno::Sequence< css::beans::PropertyValue > aSeq;
      88             : 
      89           0 :     if ( !( rVal >>= aSeq ) || ( aSeq.getLength() < SVXGALLERYITEM_PARAMS ) )
      90           0 :         return false;
      91             : 
      92           0 :     int nConverted(0);
      93           0 :     sal_Bool bAllConverted( sal_True );
      94           0 :     sal_Bool bIsSetType( sal_False );
      95             : 
      96           0 :     sal_Int8 nType(0);
      97           0 :     sal_Bool bIsLink( sal_False );
      98           0 :     rtl::OUString aURL, aFilterName;
      99           0 :     css::uno::Reference< css::lang::XComponent > xDrawing;
     100           0 :     css::uno::Reference< css::graphic::XGraphic > xGraphic;
     101             : 
     102           0 :     const css::beans::PropertyValue *pProp = aSeq.getConstArray();
     103           0 :     const css::beans::PropertyValue *pEnd = pProp + aSeq.getLength();
     104           0 :     for ( ; pProp != pEnd; pProp++ )
     105             :     {
     106           0 :         if ( pProp->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SVXGALLERYITEM_TYPE ) ) )
     107             :         {
     108           0 :             bAllConverted &= bIsSetType = ( pProp->Value >>= nType );
     109           0 :             ++nConverted;
     110             :         }
     111           0 :         else if ( pProp->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SVXGALLERYITEM_LINK ) ) )
     112             :         {
     113           0 :             bAllConverted &= ( pProp->Value >>= bIsLink );
     114           0 :             ++nConverted;
     115             :         }
     116           0 :         else if ( pProp->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SVXGALLERYITEM_URL ) ) )
     117             :         {
     118           0 :             bAllConverted &= ( pProp->Value >>= aURL );
     119           0 :             ++nConverted;
     120             :         }
     121           0 :         else if ( pProp->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SVXGALLERYITEM_FILTER ) ) )
     122             :         {
     123           0 :             bAllConverted &= ( pProp->Value >>= aFilterName );
     124           0 :             ++nConverted;
     125             :         }
     126           0 :         else if ( pProp->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SVXGALLERYITEM_DRAWING ) ) )
     127             :         {
     128           0 :             bAllConverted &= ( pProp->Value >>= xDrawing );
     129           0 :             ++nConverted;
     130             :         }
     131           0 :         else if ( pProp->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SVXGALLERYITEM_GRAPHIC ) ) )
     132             :         {
     133           0 :             bAllConverted &= ( pProp->Value >>= xGraphic );
     134           0 :             ++nConverted;
     135             :         }
     136             :     }
     137             : 
     138           0 :     if ( !bAllConverted || nConverted != SVXGALLERYITEM_PARAMS )
     139           0 :         return false;
     140             : 
     141           0 :     m_nType = nType;
     142           0 :     m_bIsLink = bIsLink;
     143           0 :     m_aURL = aURL;
     144           0 :     m_aFilterName = aFilterName;
     145           0 :     m_xDrawing = xDrawing;
     146           0 :     m_xGraphic = xGraphic;
     147             : 
     148           0 :     return true;
     149             : }
     150             : 
     151           0 : int SvxGalleryItem::operator==( const SfxPoolItem& rAttr ) const
     152             : {
     153             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
     154             : 
     155           0 :     const SvxGalleryItem& rItem = static_cast<const SvxGalleryItem&>(rAttr);
     156             : 
     157           0 :     int bRet = m_nType  == rItem.m_nType &&
     158           0 :             m_bIsLink   == rItem.m_bIsLink &&
     159           0 :             m_aURL      == rItem.m_aURL &&
     160           0 :             m_xDrawing  == rItem.m_xDrawing &&
     161           0 :             m_xGraphic  == rItem.m_xGraphic;
     162             : 
     163           0 :     return bRet;
     164             : }
     165             : 
     166           0 : SfxPoolItem* SvxGalleryItem::Clone( SfxItemPool * ) const
     167             : {
     168           0 :     return new SvxGalleryItem( *this );
     169             : }
     170             : 
     171           0 : SvStream& SvxGalleryItem::Store( SvStream& rStream, sal_uInt16 /*nItemVersion*/ ) const
     172             : {
     173           0 :     return rStream;
     174             : }
     175             : 
     176           0 : SfxPoolItem* SvxGalleryItem::Create(SvStream& , sal_uInt16) const
     177             : {
     178           0 :     return 0;
     179             : }

Generated by: LCOV version 1.10