LCOV - code coverage report
Current view: top level - sfx2/source/doc - zoomitem.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 85 0.0 %
Date: 2014-04-14 Functions: 0 15 0.0 %
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 <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             : #include <sfx2/sfx.hrc>
      27             : 
      28             : 
      29           0 : 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           0 : 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           0 :     eType( eZoomType )
      47             : {
      48           0 : }
      49             : 
      50             : 
      51             : 
      52           0 : SvxZoomItem::SvxZoomItem( const SvxZoomItem& rOrig )
      53           0 : :   SfxUInt16Item( rOrig.Which(), rOrig.GetValue() ),
      54           0 :     nValueSet( rOrig.GetValueSet() ),
      55           0 :     eType( rOrig.GetType() )
      56             : {
      57           0 : }
      58             : 
      59             : 
      60             : 
      61           0 : SvxZoomItem::~SvxZoomItem()
      62             : {
      63           0 : }
      64             : 
      65             : 
      66             : 
      67           0 : SfxPoolItem* SvxZoomItem::Clone( SfxItemPool * /*pPool*/ ) const
      68             : {
      69           0 :     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.ReadUInt16( nValue ).ReadUInt16( nValSet ).ReadSChar( 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.WriteUInt16( (sal_uInt16)GetValue() )
      90           0 :          .WriteUInt16( nValueSet )
      91           0 :          .WriteSChar( (sal_Int8)eType );
      92           0 :     return rStrm;
      93             : }
      94             : 
      95             : 
      96             : 
      97           0 : bool SvxZoomItem::operator==( const SfxPoolItem& rAttr ) const
      98             : {
      99             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
     100             : 
     101           0 :     SvxZoomItem& rItem = (SvxZoomItem&)rAttr;
     102             : 
     103           0 :     return ( GetValue() == rItem.GetValue()     &&
     104           0 :              nValueSet  == rItem.GetValueSet()  &&
     105           0 :              eType      == rItem.GetType()          );
     106             : }
     107             : 
     108           0 : bool SvxZoomItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const
     109             : {
     110           0 :     nMemberId &= ~CONVERT_TWIPS;
     111           0 :     switch( nMemberId )
     112             :     {
     113             :         case 0:
     114             :         {
     115           0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq( ZOOM_PARAMS );
     116           0 :             aSeq[0].Name = OUString( ZOOM_PARAM_VALUE );
     117           0 :             aSeq[0].Value <<= sal_Int32( GetValue() );
     118           0 :             aSeq[1].Name = OUString( ZOOM_PARAM_VALUESET );
     119           0 :             aSeq[1].Value <<= sal_Int16( nValueSet );
     120           0 :             aSeq[2].Name = OUString( ZOOM_PARAM_TYPE );
     121           0 :             aSeq[2].Value <<= sal_Int16( eType );
     122           0 :             rVal <<= aSeq;
     123           0 :             break;
     124             :         }
     125             : 
     126           0 :         case MID_VALUE: rVal <<= (sal_Int32) GetValue(); break;
     127           0 :         case MID_VALUESET: rVal <<= (sal_Int16) nValueSet; break;
     128           0 :         case MID_TYPE: rVal <<= (sal_Int16) eType; break;
     129             :         default:
     130             :             OSL_FAIL("sfx2::SvxZoomItem::QueryValue(), Wrong MemberId!");
     131           0 :             return false;
     132             :     }
     133             : 
     134           0 :     return true;
     135             : }
     136             : 
     137           0 : bool SvxZoomItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId )
     138             : {
     139           0 :     nMemberId &= ~CONVERT_TWIPS;
     140           0 :     switch( nMemberId )
     141             :     {
     142             :         case 0:
     143             :         {
     144           0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq;
     145           0 :             if (( rVal >>= aSeq ) && ( aSeq.getLength() == ZOOM_PARAMS ))
     146             :             {
     147           0 :                 sal_Int32 nValueTmp( 0 );
     148           0 :                 sal_Int16 nValueSetTmp( 0 );
     149           0 :                 sal_Int16 nTypeTmp( 0 );
     150           0 :                 bool bAllConverted( true );
     151           0 :                 sal_Int16 nConvertedCount( 0 );
     152           0 :                 for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
     153             :                 {
     154           0 :                     if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_VALUE ))
     155             :                     {
     156           0 :                         bAllConverted &= ( aSeq[i].Value >>= nValueTmp );
     157           0 :                         ++nConvertedCount;
     158             :                     }
     159           0 :                     else if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_VALUESET ))
     160             :                     {
     161           0 :                         bAllConverted &= ( aSeq[i].Value >>= nValueSetTmp );
     162           0 :                         ++nConvertedCount;
     163             :                     }
     164           0 :                     else if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_TYPE ))
     165             :                     {
     166           0 :                         bAllConverted &= ( aSeq[i].Value >>= nTypeTmp );
     167           0 :                         ++nConvertedCount;
     168             :                     }
     169             :                 }
     170             : 
     171           0 :                 if ( bAllConverted && nConvertedCount == ZOOM_PARAMS )
     172             :                 {
     173           0 :                     SetValue( (sal_uInt16)nValueTmp );
     174           0 :                     nValueSet = nValueSetTmp;
     175           0 :                     eType = SvxZoomType( nTypeTmp );
     176           0 :                     return true;
     177             :                 }
     178             :             }
     179           0 :             return false;
     180             :         }
     181             :         case MID_VALUE:
     182             :         {
     183           0 :             sal_Int32 nVal = 0;
     184           0 :             if ( rVal >>= nVal )
     185             :             {
     186           0 :                 SetValue( (sal_uInt16)nVal );
     187           0 :                 return true;
     188             :             }
     189             :             else
     190           0 :                 return false;
     191             :         }
     192             : 
     193             :         case MID_VALUESET:
     194             :         case MID_TYPE:
     195             :         {
     196           0 :             sal_Int16 nVal = sal_Int16();
     197           0 :             if ( rVal >>= nVal )
     198             :             {
     199           0 :                 if ( nMemberId == MID_VALUESET )
     200           0 :                     nValueSet = (sal_Int16) nVal;
     201           0 :                 else if ( nMemberId == MID_TYPE )
     202           0 :                     eType = SvxZoomType( (sal_Int16) nVal );
     203           0 :                 return true;
     204             :             }
     205             :             else
     206           0 :                 return false;
     207             :         }
     208             : 
     209             :         default:
     210             :             OSL_FAIL("sfx2::SvxZoomItem::PutValue(), Wrong MemberId!");
     211           0 :             return false;
     212             :     }
     213             : }
     214             : 
     215             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10