LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/attr - fmtwrapinfluenceonobjpos.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 31 42 73.8 %
Date: 2012-12-27 Functions: 13 16 81.2 %
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 <fmtwrapinfluenceonobjpos.hxx>
      21             : #include <unomid.h>
      22             : 
      23             : using namespace ::com::sun::star;
      24             : using namespace ::com::sun::star::uno;
      25             : 
      26         337 : TYPEINIT1(SwFmtWrapInfluenceOnObjPos, SfxPoolItem);
      27             : 
      28         426 : SwFmtWrapInfluenceOnObjPos::SwFmtWrapInfluenceOnObjPos( sal_Int16 _nWrapInfluenceOnPosition )
      29             :     : SfxPoolItem( RES_WRAP_INFLUENCE_ON_OBJPOS ),
      30         426 :     mnWrapInfluenceOnPosition( _nWrapInfluenceOnPosition )
      31             : {
      32         426 : }
      33             : 
      34          51 : SwFmtWrapInfluenceOnObjPos::SwFmtWrapInfluenceOnObjPos( const SwFmtWrapInfluenceOnObjPos& _rCpy )
      35             :     : SfxPoolItem( RES_WRAP_INFLUENCE_ON_OBJPOS ),
      36          51 :     mnWrapInfluenceOnPosition( _rCpy.GetWrapInfluenceOnObjPos() )
      37             : {
      38          51 : }
      39             : 
      40         905 : SwFmtWrapInfluenceOnObjPos::~SwFmtWrapInfluenceOnObjPos()
      41             : {
      42         905 : }
      43             : 
      44           0 : SwFmtWrapInfluenceOnObjPos& SwFmtWrapInfluenceOnObjPos::operator=( const SwFmtWrapInfluenceOnObjPos& _rSource )
      45             : {
      46           0 :     mnWrapInfluenceOnPosition = _rSource.GetWrapInfluenceOnObjPos();
      47             : 
      48           0 :     return *this;
      49             : }
      50             : 
      51          14 : int SwFmtWrapInfluenceOnObjPos::operator==( const SfxPoolItem& _rAttr ) const
      52             : {
      53             :     OSL_ENSURE( SfxPoolItem::operator==( _rAttr ), "no matching attributes" );
      54             :     return ( mnWrapInfluenceOnPosition ==
      55             :                     static_cast<const SwFmtWrapInfluenceOnObjPos&>(_rAttr).
      56          14 :                                                 GetWrapInfluenceOnObjPos() );
      57             : }
      58             : 
      59          51 : SfxPoolItem* SwFmtWrapInfluenceOnObjPos::Clone( SfxItemPool * ) const
      60             : {
      61          51 :     return new SwFmtWrapInfluenceOnObjPos(*this);
      62             : }
      63             : 
      64           0 : bool SwFmtWrapInfluenceOnObjPos::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
      65             : {
      66           0 :     nMemberId &= ~CONVERT_TWIPS;
      67           0 :     bool bRet = true;
      68           0 :     if( nMemberId == MID_WRAP_INFLUENCE )
      69             :     {
      70           0 :         rVal <<= GetWrapInfluenceOnObjPos();
      71             :     }
      72             :     else
      73             :     {
      74             :         OSL_FAIL( "<SwFmtWrapInfluenceOnObjPos::QueryValue()> - unknown MemberId" );
      75           0 :         bRet = false;
      76             :     }
      77           0 :     return bRet;
      78             : }
      79             : 
      80           1 : bool SwFmtWrapInfluenceOnObjPos::PutValue( const Any& rVal, sal_uInt8 nMemberId )
      81             : {
      82           1 :     nMemberId &= ~CONVERT_TWIPS;
      83           1 :     bool bRet = false;
      84             : 
      85           1 :     if( nMemberId == MID_WRAP_INFLUENCE )
      86             :     {
      87           1 :         sal_Int16 nNewWrapInfluence = 0;
      88           1 :         rVal >>= nNewWrapInfluence;
      89             :         // #i35017# - constant names have changed and <ITERATIVE> has been added
      90           1 :         if ( nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
      91             :              nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_CONCURRENT ||
      92             :              nNewWrapInfluence == text::WrapInfluenceOnPosition::ITERATIVE )
      93             :         {
      94           1 :             SetWrapInfluenceOnObjPos( nNewWrapInfluence );
      95           1 :             bRet = true;
      96             :         }
      97             :         else
      98             :         {
      99             :             OSL_FAIL( "<SwFmtWrapInfluenceOnObjPos::PutValue(..)> - invalid attribute value" );
     100             :         }
     101             :     }
     102             :     else
     103             :     {
     104             :         OSL_FAIL( "<SwFmtWrapInfluenceOnObjPos::PutValue(..)> - unknown MemberId" );
     105             :     }
     106           1 :     return bRet;
     107             : }
     108             : 
     109           1 : void SwFmtWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos( sal_Int16 _nWrapInfluenceOnPosition )
     110             : {
     111             :     // #i35017# - constant names have changed and consider new value <ITERATIVE>
     112           1 :     if ( _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
     113             :          _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_CONCURRENT ||
     114             :          _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
     115             :     {
     116           1 :         mnWrapInfluenceOnPosition = _nWrapInfluenceOnPosition;
     117             :     }
     118             :     else
     119             :     {
     120             :         OSL_FAIL( "<SwFmtWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos(..)> - invalid attribute value" );
     121             :     }
     122           1 : }
     123             : 
     124             : // #i35017# - add parameter <_bIterativeAsOnceConcurrent> to control, if
     125             : // value <ITERATIVE> has to be treated as <ONCE_CONCURRENT>
     126          98 : sal_Int16 SwFmtWrapInfluenceOnObjPos::GetWrapInfluenceOnObjPos(
     127             :                                 const bool _bIterativeAsOnceConcurrent ) const
     128             : {
     129          98 :     sal_Int16 nWrapInfluenceOnPosition( mnWrapInfluenceOnPosition );
     130             : 
     131          98 :     if ( _bIterativeAsOnceConcurrent &&
     132             :          nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
     133             :     {
     134           0 :         nWrapInfluenceOnPosition = text::WrapInfluenceOnPosition::ONCE_CONCURRENT;
     135             :     }
     136             : 
     137          98 :     return nWrapInfluenceOnPosition;
     138             : }
     139             : 
     140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10