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

Generated by: LCOV version 1.10