LCOV - code coverage report
Current view: top level - sfx2/source/doc - zoomitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 54 64 84.4 %
Date: 2012-08-25 Functions: 13 15 86.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 48 92 52.2 %

           Branch data     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 <tools/stream.hxx>
      21                 :            : #include <basic/sbxvar.hxx>
      22                 :            : 
      23                 :            : #include <sfx2/zoomitem.hxx>
      24                 :            : #include <com/sun/star/uno/Sequence.hxx>
      25                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      26                 :            : 
      27                 :            : // -----------------------------------------------------------------------
      28                 :            : 
      29 [ +  + ][ +  + ]:      32614 : TYPEINIT1_FACTORY(SvxZoomItem,SfxUInt16Item, new SvxZoomItem);
                 [ +  - ]
      30                 :            : 
      31                 :            : #define ZOOM_PARAM_VALUE    "Value"
      32                 :            : #define ZOOM_PARAM_VALUESET "ValueSet"
      33                 :            : #define ZOOM_PARAM_TYPE     "Type"
      34                 :            : #define ZOOM_PARAMS         3
      35                 :            : 
      36                 :            : // -----------------------------------------------------------------------
      37                 :            : 
      38                 :       4807 : SvxZoomItem::SvxZoomItem
      39                 :            : (
      40                 :            :     SvxZoomType eZoomType,
      41                 :            :     sal_uInt16      nVal,
      42                 :            :     sal_uInt16      _nWhich
      43                 :            : )
      44                 :            : :   SfxUInt16Item( _nWhich, nVal ),
      45                 :            :     nValueSet( SVX_ZOOM_ENABLE_ALL ),
      46                 :       4807 :     eType( eZoomType )
      47                 :            : {
      48                 :       4807 : }
      49                 :            : 
      50                 :            : // -----------------------------------------------------------------------
      51                 :            : 
      52                 :       6453 : SvxZoomItem::SvxZoomItem( const SvxZoomItem& rOrig )
      53                 :       6453 : :   SfxUInt16Item( rOrig.Which(), rOrig.GetValue() ),
      54                 :       6453 :     nValueSet( rOrig.GetValueSet() ),
      55                 :      12906 :     eType( rOrig.GetType() )
      56                 :            : {
      57                 :       6453 : }
      58                 :            : 
      59                 :            : // -----------------------------------------------------------------------
      60                 :            : 
      61                 :      11246 : SvxZoomItem::~SvxZoomItem()
      62                 :            : {
      63         [ -  + ]:      19762 : }
      64                 :            : 
      65                 :            : // -----------------------------------------------------------------------
      66                 :            : 
      67                 :       6453 : SfxPoolItem* SvxZoomItem::Clone( SfxItemPool * /*pPool*/ ) const
      68                 :            : {
      69         [ +  - ]:       6453 :     return new SvxZoomItem( *this );
      70                 :            : }
      71                 :            : 
      72                 :            : // -----------------------------------------------------------------------
      73                 :            : 
      74                 :          0 : SfxPoolItem* SvxZoomItem::Create( SvStream& rStrm, sal_uInt16 /*nVersion*/ ) const
      75                 :            : {
      76                 :            :     sal_uInt16 nValue;
      77                 :            :     sal_uInt16 nValSet;
      78                 :            :     sal_Int8 nType;
      79 [ #  # ][ #  # ]:          0 :     rStrm >> nValue >> nValSet >> nType;
                 [ #  # ]
      80 [ #  # ][ #  # ]:          0 :     SvxZoomItem* pNew = new SvxZoomItem( (SvxZoomType)nType, nValue, Which() );
      81                 :          0 :     pNew->SetValueSet( nValSet );
      82                 :          0 :     return pNew;
      83                 :            : }
      84                 :            : 
      85                 :            : // -----------------------------------------------------------------------
      86                 :            : 
      87                 :          0 : SvStream& SvxZoomItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
      88                 :            : {
      89                 :          0 :     rStrm << (sal_uInt16)GetValue()
      90                 :          0 :           << nValueSet
      91                 :          0 :           << (sal_Int8)eType;
      92                 :          0 :     return rStrm;
      93                 :            : }
      94                 :            : 
      95                 :            : // -----------------------------------------------------------------------
      96                 :            : 
      97                 :        222 : int SvxZoomItem::operator==( const SfxPoolItem& rAttr ) const
      98                 :            : {
      99                 :            :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
     100                 :            : 
     101                 :        222 :     SvxZoomItem& rItem = (SvxZoomItem&)rAttr;
     102                 :            : 
     103                 :        222 :     return ( GetValue() == rItem.GetValue()     &&
     104                 :        200 :              nValueSet  == rItem.GetValueSet()  &&
     105         [ +  - ]:        422 :              eType      == rItem.GetType()          );
           [ +  +  +  + ]
     106                 :            : }
     107                 :            : 
     108                 :       2788 : bool SvxZoomItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const
     109                 :            : {
     110                 :            : //  sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     111                 :       2788 :     nMemberId &= ~CONVERT_TWIPS;
     112                 :            : 
     113                 :            :     assert(nMemberId == 0);
     114                 :            : 
     115         [ +  - ]:       2788 :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq( ZOOM_PARAMS );
     116 [ +  - ][ +  - ]:       2788 :     aSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOM_PARAM_VALUE ));
     117 [ +  - ][ +  - ]:       2788 :     aSeq[0].Value <<= sal_Int32( GetValue() );
     118 [ +  - ][ +  - ]:       2788 :     aSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOM_PARAM_VALUESET ));
     119 [ +  - ][ +  - ]:       2788 :     aSeq[1].Value <<= sal_Int16( nValueSet );
     120 [ +  - ][ +  - ]:       2788 :     aSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOM_PARAM_TYPE ));
     121 [ +  - ][ +  - ]:       2788 :     aSeq[2].Value <<= sal_Int16( eType );
     122         [ +  - ]:       2788 :     rVal <<= aSeq;
     123                 :            : 
     124         [ +  - ]:       2788 :     return true;
     125                 :            : }
     126                 :            : 
     127                 :       1829 : bool SvxZoomItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId )
     128                 :            : {
     129                 :       1829 :     nMemberId &= ~CONVERT_TWIPS;
     130                 :            :     assert(nMemberId == 0);
     131                 :            : 
     132         [ +  - ]:       1829 :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq;
     133 [ +  - ][ +  - ]:       1829 :     if (( rVal >>= aSeq ) && ( aSeq.getLength() == ZOOM_PARAMS ))
         [ +  - ][ +  - ]
     134                 :            :     {
     135                 :       1829 :         sal_Int32 nValueTmp( 0 );
     136                 :       1829 :         sal_Int16 nValueSetTmp( 0 );
     137                 :       1829 :         sal_Int16 nTypeTmp( 0 );
     138                 :       1829 :         sal_Bool  bAllConverted( sal_True );
     139                 :       1829 :         sal_Int16 nConvertedCount( 0 );
     140         [ +  + ]:       7316 :         for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
     141                 :            :         {
     142 [ +  - ][ +  + ]:       5487 :             if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_VALUE ))
     143                 :            :             {
     144         [ +  - ]:       1829 :                 bAllConverted &= ( aSeq[i].Value >>= nValueTmp );
     145                 :       1829 :                 ++nConvertedCount;
     146                 :            :             }
     147 [ +  - ][ +  + ]:       3658 :             else if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_VALUESET ))
     148                 :            :             {
     149         [ +  - ]:       1829 :                 bAllConverted &= ( aSeq[i].Value >>= nValueSetTmp );
     150                 :       1829 :                 ++nConvertedCount;
     151                 :            :             }
     152 [ +  - ][ +  - ]:       1829 :             else if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_TYPE ))
     153                 :            :             {
     154         [ +  - ]:       1829 :                 bAllConverted &= ( aSeq[i].Value >>= nTypeTmp );
     155                 :       1829 :                 ++nConvertedCount;
     156                 :            :             }
     157                 :            :         }
     158                 :            : 
     159 [ +  - ][ +  - ]:       1829 :         if ( bAllConverted && nConvertedCount == ZOOM_PARAMS )
     160                 :            :         {
     161                 :       1829 :             SetValue( (sal_uInt16)nValueTmp );
     162                 :       1829 :             nValueSet = nValueSetTmp;
     163                 :       1829 :             eType = SvxZoomType( nTypeTmp );
     164                 :       1829 :             return true;
     165                 :            :         }
     166                 :            :     }
     167                 :            : 
     168         [ +  - ]:       1829 :     return false;
     169                 :            : }
     170                 :            : 
     171                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10