LCOV - code coverage report
Current view: top level - svx/source/items - viewlayoutitem.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 66 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             : 
      22             : #include <svx/viewlayoutitem.hxx>
      23             : #include <com/sun/star/uno/Sequence.hxx>
      24             : #include <com/sun/star/beans/PropertyValue.hpp>
      25             : 
      26             : 
      27             : 
      28           0 : TYPEINIT1_FACTORY(SvxViewLayoutItem,SfxUInt16Item, new SvxViewLayoutItem);
      29             : 
      30             : #define VIEWLAYOUT_PARAM_COLUMNS    "Columns"
      31             : #define VIEWLAYOUT_PARAM_BOOKMODE   "BookMode"
      32             : #define VIEWLAYOUT_PARAMS           2
      33             : 
      34             : 
      35             : 
      36           0 : SvxViewLayoutItem::SvxViewLayoutItem
      37             : (
      38             :     sal_uInt16      nColumns,
      39             :     bool        bBookMode,
      40             :     sal_uInt16  _nWhich
      41             : )
      42             : :   SfxUInt16Item( _nWhich, nColumns ),
      43           0 :     mbBookMode( bBookMode )
      44             : {
      45           0 : }
      46             : 
      47             : 
      48             : 
      49           0 : SvxViewLayoutItem::SvxViewLayoutItem( const SvxViewLayoutItem& rOrig )
      50           0 : :   SfxUInt16Item( rOrig.Which(), rOrig.GetValue() ),
      51           0 :     mbBookMode( rOrig.IsBookMode() )
      52             : {
      53           0 : }
      54             : 
      55             : 
      56             : 
      57           0 : SvxViewLayoutItem::~SvxViewLayoutItem()
      58             : {
      59           0 : }
      60             : 
      61             : 
      62             : 
      63           0 : SfxPoolItem* SvxViewLayoutItem::Clone( SfxItemPool * /*pPool*/ ) const
      64             : {
      65           0 :     return new SvxViewLayoutItem( *this );
      66             : }
      67             : 
      68             : 
      69             : 
      70           0 : SfxPoolItem* SvxViewLayoutItem::Create( SvStream& /*rStrm*/, sal_uInt16 /*nVersion*/ ) const
      71             : {
      72           0 :     return 0;
      73             : }
      74             : 
      75             : 
      76             : 
      77           0 : SvStream& SvxViewLayoutItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
      78             : {
      79           0 :     return rStrm;
      80             : }
      81             : 
      82             : 
      83             : 
      84           0 : bool SvxViewLayoutItem::operator==( const SfxPoolItem& rAttr ) const
      85             : {
      86             :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
      87             : 
      88           0 :     SvxViewLayoutItem& rItem = (SvxViewLayoutItem&)rAttr;
      89             : 
      90           0 :     return ( GetValue() == rItem.GetValue()     &&
      91           0 :              mbBookMode == rItem.IsBookMode() );
      92             : }
      93             : 
      94           0 : bool SvxViewLayoutItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const
      95             : {
      96           0 :     nMemberId &= ~CONVERT_TWIPS;
      97           0 :     switch ( nMemberId )
      98             :     {
      99             :         case 0 :
     100             :         {
     101           0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq( VIEWLAYOUT_PARAMS );
     102           0 :             aSeq[0].Name = OUString( VIEWLAYOUT_PARAM_COLUMNS );
     103           0 :             aSeq[0].Value <<= sal_Int32( GetValue() );
     104           0 :             aSeq[1].Name = OUString( VIEWLAYOUT_PARAM_BOOKMODE );
     105           0 :             aSeq[1].Value <<= sal_Bool( mbBookMode );
     106           0 :             rVal <<= aSeq;
     107             :         }
     108           0 :         break;
     109             : 
     110           0 :         case MID_VIEWLAYOUT_COLUMNS : rVal <<= (sal_Int32) GetValue(); break;
     111           0 :         case MID_VIEWLAYOUT_BOOKMODE: rVal <<= (sal_Bool) mbBookMode; break;
     112             :         default:
     113             :             OSL_FAIL("svx::SvxViewLayoutItem::QueryValue(), Wrong MemberId!");
     114           0 :             return false;
     115             :     }
     116             : 
     117           0 :     return true;
     118             : }
     119             : 
     120           0 : bool SvxViewLayoutItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId )
     121             : {
     122           0 :     nMemberId &= ~CONVERT_TWIPS;
     123           0 :     switch ( nMemberId )
     124             :     {
     125             :         case 0 :
     126             :         {
     127           0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq;
     128           0 :             if (( rVal >>= aSeq ) && ( aSeq.getLength() == VIEWLAYOUT_PARAMS ))
     129             :             {
     130           0 :                 sal_Int32 nColumns( 0 );
     131           0 :                 sal_Bool  bBookMode = sal_False;
     132           0 :                 bool bAllConverted( true );
     133           0 :                 sal_Int16 nConvertedCount( 0 );
     134           0 :                 for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
     135             :                 {
     136           0 :                     if ( aSeq[i].Name.equalsAscii( VIEWLAYOUT_PARAM_COLUMNS ))
     137             :                     {
     138           0 :                         bAllConverted &= ( aSeq[i].Value >>= nColumns );
     139           0 :                         ++nConvertedCount;
     140             :                     }
     141           0 :                     else if ( aSeq[i].Name.equalsAscii( VIEWLAYOUT_PARAM_BOOKMODE ))
     142             :                     {
     143           0 :                         bAllConverted &= ( aSeq[i].Value >>= bBookMode );
     144           0 :                         ++nConvertedCount;
     145             :                     }
     146             :                 }
     147             : 
     148           0 :                 if ( bAllConverted && nConvertedCount == VIEWLAYOUT_PARAMS )
     149             :                 {
     150           0 :                     SetValue( (sal_uInt16)nColumns );
     151           0 :                     mbBookMode = bBookMode;
     152           0 :                     return true;
     153             :                 }
     154             :             }
     155             : 
     156           0 :             return false;
     157             :         }
     158             : 
     159             :         case MID_VIEWLAYOUT_COLUMNS:
     160             :         {
     161           0 :             sal_Int32 nVal = 0;
     162           0 :             if ( rVal >>= nVal )
     163             :             {
     164           0 :                 SetValue( (sal_uInt16)nVal );
     165           0 :                 return true;
     166             :             }
     167             :             else
     168           0 :                 return false;
     169             :         }
     170             : 
     171             :         case MID_VIEWLAYOUT_BOOKMODE:
     172             :         {
     173           0 :             sal_Bool bBookMode = sal_False;
     174           0 :             if ( rVal >>= bBookMode )
     175             :             {
     176           0 :                 mbBookMode = bBookMode;
     177           0 :                 return true;
     178             :             }
     179             :             else
     180           0 :                 return false;
     181             :         }
     182             : 
     183             :         default:
     184             :             OSL_FAIL("svx::SvxViewLayoutItem::PutValue(), Wrong MemberId!");
     185           0 :             return false;
     186             :     }
     187             : }
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10