LCOV - code coverage report
Current view: top level - svx/source/items - zoomslideritem.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 104 0.0 %
Date: 2014-04-14 Functions: 0 17 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             : 
      22             : #include <svx/zoomslideritem.hxx>
      23             : #include <com/sun/star/beans/PropertyValue.hpp>
      24             : 
      25             : 
      26             : 
      27           0 : TYPEINIT1_FACTORY(SvxZoomSliderItem,SfxUInt16Item, new SvxZoomSliderItem);
      28             : 
      29             : #define ZOOMSLIDER_PARAM_CURRENTZOOM    "Columns"
      30             : #define ZOOMSLIDER_PARAM_SNAPPINGPOINTS "SnappingPoints"
      31             : #define ZOOMSLIDER_PARAM_MINZOOM        "MinValue"
      32             : #define ZOOMSLIDER_PARAM_MAXZOOM        "MaxValue"
      33             : #define ZOOMSLIDER_PARAMS           4
      34             : 
      35             : 
      36             : 
      37           0 : SvxZoomSliderItem::SvxZoomSliderItem( sal_uInt16 nCurrentZoom, sal_uInt16 nMinZoom, sal_uInt16 nMaxZoom, sal_uInt16 _nWhich )
      38           0 : :   SfxUInt16Item( _nWhich, nCurrentZoom ), mnMinZoom( nMinZoom ), mnMaxZoom( nMaxZoom )
      39             : {
      40           0 : }
      41             : 
      42             : 
      43             : 
      44           0 : SvxZoomSliderItem::SvxZoomSliderItem( const SvxZoomSliderItem& rOrig )
      45           0 : : SfxUInt16Item( rOrig.Which(), rOrig.GetValue() )
      46             : , maValues( rOrig.maValues )
      47             : , mnMinZoom( rOrig.mnMinZoom )
      48           0 : , mnMaxZoom( rOrig.mnMaxZoom )
      49             : {
      50           0 : }
      51             : 
      52             : 
      53             : 
      54           0 : SvxZoomSliderItem::~SvxZoomSliderItem()
      55             : {
      56           0 : }
      57             : 
      58             : 
      59             : 
      60           0 : SfxPoolItem* SvxZoomSliderItem::Clone( SfxItemPool * /*pPool*/ ) const
      61             : {
      62           0 :     return new SvxZoomSliderItem( *this );
      63             : }
      64             : 
      65             : 
      66             : 
      67           0 : SfxPoolItem* SvxZoomSliderItem::Create( SvStream& /*rStrm*/, sal_uInt16 /*nVersion*/ ) const
      68             : {
      69           0 :     return 0;
      70             : }
      71             : 
      72             : 
      73             : 
      74           0 : SvStream& SvxZoomSliderItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
      75             : {
      76           0 :     return rStrm;
      77             : }
      78             : 
      79             : 
      80             : 
      81           0 : bool SvxZoomSliderItem::operator==( const SfxPoolItem& rAttr ) const
      82             : {
      83             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
      84             : 
      85           0 :     SvxZoomSliderItem& rItem = (SvxZoomSliderItem&)rAttr;
      86             : 
      87           0 :     return ( GetValue() == rItem.GetValue() && maValues == rItem.maValues &&
      88           0 :              mnMinZoom == rItem.mnMinZoom && mnMaxZoom == rItem.mnMaxZoom );
      89             : }
      90             : 
      91           0 : bool SvxZoomSliderItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const
      92             : {
      93           0 :     nMemberId &= ~CONVERT_TWIPS;
      94           0 :     switch ( nMemberId )
      95             :     {
      96             :         case 0 :
      97             :             {
      98           0 :                 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq( ZOOMSLIDER_PARAMS );
      99           0 :                 aSeq[0].Name = OUString( ZOOMSLIDER_PARAM_CURRENTZOOM );
     100           0 :                 aSeq[0].Value <<= sal_Int32( GetValue() );
     101           0 :                 aSeq[1].Name = OUString( ZOOMSLIDER_PARAM_SNAPPINGPOINTS );
     102           0 :                 aSeq[1].Value <<= maValues;
     103           0 :                 aSeq[2].Name = OUString( ZOOMSLIDER_PARAM_MINZOOM );
     104           0 :                 aSeq[2].Value <<= mnMinZoom;
     105           0 :                 aSeq[3].Name = OUString( ZOOMSLIDER_PARAM_MAXZOOM );
     106           0 :                 aSeq[3].Value <<= mnMaxZoom;
     107           0 :                 rVal <<= aSeq;
     108             :             }
     109           0 :             break;
     110             : 
     111             :         case MID_ZOOMSLIDER_CURRENTZOOM :
     112             :             {
     113           0 :                 rVal <<= (sal_Int32) GetValue();
     114             :             }
     115           0 :             break;
     116             :         case MID_ZOOMSLIDER_SNAPPINGPOINTS:
     117             :             {
     118           0 :                  rVal <<= maValues;
     119             :             }
     120           0 :             break;
     121             :         case MID_ZOOMSLIDER_MINZOOM:
     122             :             {
     123           0 :                 rVal <<= mnMinZoom;
     124             :             }
     125           0 :             break;
     126             :         case MID_ZOOMSLIDER_MAXZOOM:
     127             :             {
     128           0 :                 rVal <<= mnMaxZoom;
     129             :             }
     130           0 :             break;
     131             :         default:
     132             :             OSL_FAIL("svx::SvxZoomSliderItem::QueryValue(), Wrong MemberId!");
     133           0 :             return false;
     134             :     }
     135             : 
     136           0 :     return true;
     137             : }
     138             : 
     139           0 : bool SvxZoomSliderItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId )
     140             : {
     141           0 :     nMemberId &= ~CONVERT_TWIPS;
     142           0 :     switch ( nMemberId )
     143             :     {
     144             :         case 0 :
     145             :             {
     146           0 :                 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq;
     147           0 :                 if (( rVal >>= aSeq ) && ( aSeq.getLength() == ZOOMSLIDER_PARAMS ))
     148             :                 {
     149           0 :                     sal_Int32 nCurrentZoom( 0 );
     150           0 :                     com::sun::star::uno::Sequence < sal_Int32 > aValues;
     151             : 
     152           0 :                     bool bAllConverted( true );
     153           0 :                     sal_Int16 nConvertedCount( 0 );
     154           0 :                     sal_Int32 nMinZoom( 0 ), nMaxZoom( 0 );
     155             : 
     156           0 :                     for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
     157             :                     {
     158           0 :                         if ( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_CURRENTZOOM ))
     159             :                         {
     160           0 :                             bAllConverted &= ( aSeq[i].Value >>= nCurrentZoom );
     161           0 :                             ++nConvertedCount;
     162             :                         }
     163           0 :                         else if ( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_SNAPPINGPOINTS ))
     164             :                         {
     165           0 :                             bAllConverted &= ( aSeq[i].Value >>= aValues );
     166           0 :                             ++nConvertedCount;
     167             :                         }
     168           0 :                         else if( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_MINZOOM ) )
     169             :                         {
     170           0 :                             bAllConverted &= ( aSeq[i].Value >>= nMinZoom );
     171           0 :                             ++nConvertedCount;
     172             :                         }
     173           0 :                         else if( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_MAXZOOM ) )
     174             :                         {
     175           0 :                             bAllConverted &= ( aSeq[i].Value >>= nMaxZoom );
     176           0 :                             ++nConvertedCount;
     177             :                         }
     178             :                     }
     179             : 
     180           0 :                     if ( bAllConverted && nConvertedCount == ZOOMSLIDER_PARAMS )
     181             :                     {
     182           0 :                         SetValue( (sal_uInt16)nCurrentZoom );
     183           0 :                         maValues = aValues;
     184           0 :                         mnMinZoom = sal::static_int_cast< sal_uInt16 >( nMinZoom );
     185           0 :                         mnMaxZoom = sal::static_int_cast< sal_uInt16 >( nMaxZoom );
     186             : 
     187           0 :                         return true;
     188           0 :                     }
     189             :                 }
     190             : 
     191           0 :                 return false;
     192             :             }
     193             : 
     194             :         case MID_ZOOMSLIDER_CURRENTZOOM:
     195             :             {
     196           0 :                 sal_Int32 nVal = 0;
     197           0 :                 if ( rVal >>= nVal )
     198             :                 {
     199           0 :                     SetValue( (sal_uInt16)nVal );
     200           0 :                     return true;
     201             :                 }
     202             :                 else
     203           0 :                     return false;
     204             :             }
     205             : 
     206             :         case MID_ZOOMSLIDER_SNAPPINGPOINTS:
     207             :             {
     208           0 :                 com::sun::star::uno::Sequence < sal_Int32 > aValues;
     209           0 :                 if ( rVal >>= aValues )
     210             :                 {
     211           0 :                     maValues = aValues;
     212           0 :                     return true;
     213             :                 }
     214             :                 else
     215           0 :                     return false;
     216             :             }
     217             :         case MID_ZOOMSLIDER_MINZOOM:
     218             :             {
     219           0 :                 sal_Int32 nVal = 0;
     220           0 :                 if( rVal >>= nVal )
     221             :                 {
     222           0 :                     mnMinZoom = (sal_uInt16)nVal;
     223           0 :                     return true;
     224             :                 }
     225             :                 else
     226           0 :                     return false;
     227             :             }
     228             :         case MID_ZOOMSLIDER_MAXZOOM:
     229             :             {
     230           0 :                 sal_Int32 nVal = 0;
     231           0 :                 if( rVal >>= nVal )
     232             :                 {
     233           0 :                     mnMaxZoom = (sal_uInt16)nVal;
     234           0 :                     return true;
     235             :                 }
     236             :                 else
     237           0 :                     return false;
     238             :             }
     239             :         default:
     240             :             OSL_FAIL("svx::SvxZoomSliderItem::PutValue(), Wrong MemberId!");
     241           0 :             return false;
     242             :     }
     243             : }
     244             : 
     245           0 : void SvxZoomSliderItem::AddSnappingPoint( sal_Int32 nNew )
     246             : {
     247           0 :     const sal_Int32 nValues = maValues.getLength();
     248           0 :     maValues.realloc(  nValues + 1 );
     249           0 :     sal_Int32* pValues = maValues.getArray();
     250           0 :     pValues[ nValues ] = nNew;
     251           0 : }
     252             : 
     253           0 : const com::sun::star::uno::Sequence < sal_Int32 >& SvxZoomSliderItem::GetSnappingPoints() const
     254             : {
     255           0 :     return maValues;
     256             : }
     257             : 
     258             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10