LCOV - code coverage report
Current view: top level - svx/source/items - clipfmtitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 43 68 63.2 %
Date: 2012-08-25 Functions: 17 21 81.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 28 94 29.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <svx/clipfmtitem.hxx>
      30                 :            : #include <com/sun/star/frame/status/ClipboardFormats.hpp>
      31                 :            : 
      32                 :            : #include <boost/ptr_container/ptr_vector.hpp>
      33                 :            : 
      34                 :       9995 : struct SvxClipboardFmtItem_Impl
      35                 :            : {
      36                 :            :     boost::ptr_vector< boost::nullable<rtl::OUString> > aFmtNms;
      37                 :            :     std::vector<sal_uIntPtr> aFmtIds;
      38                 :            : 
      39         [ +  - ]:       4080 :     SvxClipboardFmtItem_Impl() {}
      40                 :            :     SvxClipboardFmtItem_Impl( const SvxClipboardFmtItem_Impl& );
      41                 :            : };
      42                 :            : 
      43 [ -  + ][ -  + ]:      12962 : TYPEINIT1_FACTORY( SvxClipboardFmtItem, SfxPoolItem , new  SvxClipboardFmtItem(0));
                 [ +  - ]
      44                 :            : 
      45                 :       5923 : SvxClipboardFmtItem_Impl::SvxClipboardFmtItem_Impl(
      46                 :            :                             const SvxClipboardFmtItem_Impl& rCpy )
      47                 :            :     : aFmtNms(rCpy.aFmtNms)
      48         [ +  - ]:       5923 :     , aFmtIds(rCpy.aFmtIds)
      49                 :            : {
      50                 :       5923 : }
      51                 :            : 
      52                 :       4080 : SvxClipboardFmtItem::SvxClipboardFmtItem( sal_uInt16 nId )
      53 [ +  - ][ +  - ]:       4080 :     : SfxPoolItem( nId ), pImpl( new SvxClipboardFmtItem_Impl )
      54                 :            : {
      55                 :       4080 : }
      56                 :            : 
      57                 :       5923 : SvxClipboardFmtItem::SvxClipboardFmtItem( const SvxClipboardFmtItem& rCpy )
      58                 :       5923 :     : SfxPoolItem( rCpy.Which() ),
      59 [ +  - ][ +  - ]:       5923 :     pImpl( new SvxClipboardFmtItem_Impl( *rCpy.pImpl ) )
      60                 :            : {
      61                 :       5923 : }
      62                 :            : 
      63                 :       9995 : SvxClipboardFmtItem::~SvxClipboardFmtItem()
      64                 :            : {
      65 [ +  - ][ +  - ]:       9995 :     delete pImpl;
      66         [ -  + ]:      17205 : }
      67                 :            : 
      68                 :       1295 : bool SvxClipboardFmtItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
      69                 :            : {
      70         [ +  - ]:       1295 :     sal_uInt16 nCount = Count();
      71                 :            : 
      72         [ +  - ]:       1295 :     ::com::sun::star::frame::status::ClipboardFormats aClipFormats;
      73                 :            : 
      74         [ +  - ]:       1295 :     aClipFormats.Identifiers.realloc( nCount );
      75         [ +  - ]:       1295 :     aClipFormats.Names.realloc( nCount );
      76         [ -  + ]:       1295 :     for ( sal_uInt16 n=0; n < nCount; n++ )
      77                 :            :     {
      78 [ #  # ][ #  # ]:          0 :         aClipFormats.Identifiers[n] = (sal_Int64)GetClipbrdFormatId( n );
      79 [ #  # ][ #  # ]:          0 :         aClipFormats.Names[n] = GetClipbrdFormatName( n );
      80                 :            :     }
      81                 :            : 
      82         [ +  - ]:       1295 :     rVal <<= aClipFormats;
      83         [ +  - ]:       1295 :     return true;
      84                 :            : }
      85                 :            : 
      86                 :       1295 : bool SvxClipboardFmtItem::PutValue( const ::com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
      87                 :            : {
      88         [ +  - ]:       1295 :     ::com::sun::star::frame::status::ClipboardFormats aClipFormats;
      89 [ +  - ][ +  - ]:       1295 :     if ( rVal >>= aClipFormats )
      90                 :            :     {
      91                 :       1295 :         sal_uInt16 nCount = sal_uInt16( aClipFormats.Identifiers.getLength() );
      92                 :            : 
      93                 :       1295 :         pImpl->aFmtIds.clear();
      94         [ +  - ]:       1295 :         pImpl->aFmtNms.clear();
      95         [ -  + ]:       1295 :         for ( sal_uInt16 n=0; n < nCount; ++n )
      96 [ #  # ][ #  # ]:          0 :             AddClipbrdFormat( sal_uIntPtr( aClipFormats.Identifiers[n] ), aClipFormats.Names[n], n );
                 [ #  # ]
      97                 :            : 
      98                 :       1295 :         return true;
      99                 :            :     }
     100                 :            : 
     101         [ +  - ]:       1295 :     return false;
     102                 :            : }
     103                 :            : 
     104                 :       1490 : int SvxClipboardFmtItem::operator==( const SfxPoolItem& rComp ) const
     105                 :            : {
     106                 :       1490 :     const SvxClipboardFmtItem& rCmp = (SvxClipboardFmtItem&)rComp;
     107         [ -  + ]:       1490 :     if(rCmp.pImpl->aFmtNms.size() != pImpl->aFmtNms.size())
     108                 :          0 :         return 0;
     109                 :            : 
     110                 :       1490 :     int nRet = 1;
     111         [ -  + ]:       1490 :     for( sal_uInt16 n = 0, nEnd = rCmp.pImpl->aFmtNms.size(); n < nEnd; ++n )
     112                 :            :     {
     113   [ #  #  #  #  :          0 :         if( pImpl->aFmtIds[ n ] != rCmp.pImpl->aFmtIds[ n ] ||
             #  #  #  # ]
                 [ #  # ]
     114                 :          0 :             ( pImpl->aFmtNms.is_null(n) ^ rCmp.pImpl->aFmtNms.is_null(n) ) ||
     115                 :          0 :             ( !pImpl->aFmtNms.is_null(n) && pImpl->aFmtNms[n] != rCmp.pImpl->aFmtNms[n] ) )
     116                 :            :         {
     117                 :          0 :             nRet = 0;
     118                 :          0 :             break;
     119                 :            :         }
     120                 :            :     }
     121                 :            : 
     122                 :       1490 :     return nRet;
     123                 :            : }
     124                 :            : 
     125                 :       5923 : SfxPoolItem* SvxClipboardFmtItem::Clone( SfxItemPool * /*pPool*/ ) const
     126                 :            : {
     127         [ +  - ]:       5923 :     return new SvxClipboardFmtItem( *this );
     128                 :            : }
     129                 :            : 
     130                 :          0 : void SvxClipboardFmtItem::AddClipbrdFormat( sal_uIntPtr nId, sal_uInt16 nPos )
     131                 :            : {
     132         [ #  # ]:          0 :     if( nPos > pImpl->aFmtNms.size() )
     133                 :          0 :         nPos = pImpl->aFmtNms.size();
     134                 :            : 
     135                 :          0 :     pImpl->aFmtNms.insert(pImpl->aFmtNms.begin() + nPos, 0);
     136 [ #  # ][ #  # ]:          0 :     pImpl->aFmtIds.insert( pImpl->aFmtIds.begin()+nPos, nId );
     137                 :          0 : }
     138                 :            : 
     139                 :          0 : void SvxClipboardFmtItem::AddClipbrdFormat( sal_uIntPtr nId, const rtl::OUString& rName,
     140                 :            :                             sal_uInt16 nPos )
     141                 :            : {
     142         [ #  # ]:          0 :     if( nPos > pImpl->aFmtNms.size() )
     143                 :          0 :         nPos = pImpl->aFmtNms.size();
     144                 :            : 
     145                 :          0 :     pImpl->aFmtNms.insert(pImpl->aFmtNms.begin() + nPos, new rtl::OUString(rName));
     146 [ #  # ][ #  # ]:          0 :     pImpl->aFmtIds.insert( pImpl->aFmtIds.begin()+nPos, nId );
     147                 :          0 : }
     148                 :            : 
     149                 :       1295 : sal_uInt16 SvxClipboardFmtItem::Count() const
     150                 :            : {
     151                 :       1295 :     return pImpl->aFmtIds.size();
     152                 :            : }
     153                 :            : 
     154                 :          0 : sal_uIntPtr SvxClipboardFmtItem::GetClipbrdFormatId( sal_uInt16 nPos ) const
     155                 :            : {
     156                 :          0 :     return pImpl->aFmtIds[ nPos ];
     157                 :            : }
     158                 :            : 
     159                 :          0 : const rtl::OUString SvxClipboardFmtItem::GetClipbrdFormatName( sal_uInt16 nPos ) const
     160                 :            : {
     161         [ #  # ]:          0 :     return pImpl->aFmtNms.is_null(nPos) ? rtl::OUString() : pImpl->aFmtNms[nPos];
     162                 :            : }
     163                 :            : 
     164                 :            : 
     165                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10