LCOV - code coverage report
Current view: top level - sw/source/core/attr - fmtwrapinfluenceonobjpos.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 39 46 84.8 %
Date: 2014-11-03 Functions: 14 16 87.5 %
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       15491 : TYPEINIT1(SwFmtWrapInfluenceOnObjPos, SfxPoolItem);
      27             : 
      28       15278 : SwFmtWrapInfluenceOnObjPos::SwFmtWrapInfluenceOnObjPos( sal_Int16 _nWrapInfluenceOnPosition )
      29             :     : SfxPoolItem( RES_WRAP_INFLUENCE_ON_OBJPOS ),
      30       15278 :     mnWrapInfluenceOnPosition( _nWrapInfluenceOnPosition )
      31             : {
      32       15278 : }
      33             : 
      34        2044 : SwFmtWrapInfluenceOnObjPos::SwFmtWrapInfluenceOnObjPos( const SwFmtWrapInfluenceOnObjPos& _rCpy )
      35             :     : SfxPoolItem( RES_WRAP_INFLUENCE_ON_OBJPOS ),
      36        2044 :     mnWrapInfluenceOnPosition( _rCpy.GetWrapInfluenceOnObjPos() )
      37             : {
      38        2044 : }
      39             : 
      40       34616 : SwFmtWrapInfluenceOnObjPos::~SwFmtWrapInfluenceOnObjPos()
      41             : {
      42       34616 : }
      43             : 
      44           0 : SwFmtWrapInfluenceOnObjPos& SwFmtWrapInfluenceOnObjPos::operator=( const SwFmtWrapInfluenceOnObjPos& _rSource )
      45             : {
      46           0 :     mnWrapInfluenceOnPosition = _rSource.GetWrapInfluenceOnObjPos();
      47             : 
      48           0 :     return *this;
      49             : }
      50             : 
      51        2036 : bool SwFmtWrapInfluenceOnObjPos::operator==( const SfxPoolItem& rAttr ) const
      52             : {
      53             :     assert(SfxPoolItem::operator==(rAttr));
      54        2036 :     return ( mnWrapInfluenceOnPosition ==
      55             :                     static_cast<const SwFmtWrapInfluenceOnObjPos&>(rAttr).
      56        2036 :                                                 GetWrapInfluenceOnObjPos() );
      57             : }
      58             : 
      59        2044 : SfxPoolItem* SwFmtWrapInfluenceOnObjPos::Clone( SfxItemPool * ) const
      60             : {
      61        2044 :     return new SwFmtWrapInfluenceOnObjPos(*this);
      62             : }
      63             : 
      64          14 : bool SwFmtWrapInfluenceOnObjPos::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
      65             : {
      66          14 :     nMemberId &= ~CONVERT_TWIPS;
      67          14 :     bool bRet = true;
      68          14 :     if( nMemberId == MID_WRAP_INFLUENCE )
      69             :     {
      70          14 :         rVal <<= GetWrapInfluenceOnObjPos();
      71             :     }
      72             :     else
      73             :     {
      74             :         OSL_FAIL( "<SwFmtWrapInfluenceOnObjPos::QueryValue()> - unknown MemberId" );
      75           0 :         bRet = false;
      76             :     }
      77          14 :     return bRet;
      78             : }
      79             : 
      80          58 : bool SwFmtWrapInfluenceOnObjPos::PutValue( const Any& rVal, sal_uInt8 nMemberId )
      81             : {
      82          58 :     nMemberId &= ~CONVERT_TWIPS;
      83          58 :     bool bRet = false;
      84             : 
      85          58 :     if( nMemberId == MID_WRAP_INFLUENCE )
      86             :     {
      87          58 :         sal_Int16 nNewWrapInfluence = 0;
      88          58 :         rVal >>= nNewWrapInfluence;
      89             :         // #i35017# - constant names have changed and <ITERATIVE> has been added
      90         116 :         if ( nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
      91          58 :              nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_CONCURRENT ||
      92           0 :              nNewWrapInfluence == text::WrapInfluenceOnPosition::ITERATIVE )
      93             :         {
      94          58 :             SetWrapInfluenceOnObjPos( nNewWrapInfluence );
      95          58 :             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          58 :     return bRet;
     107             : }
     108             : 
     109          58 : void SwFmtWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos( sal_Int16 _nWrapInfluenceOnPosition )
     110             : {
     111             :     // #i35017# - constant names have changed and consider new value <ITERATIVE>
     112          58 :     if ( _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
     113           0 :          _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_CONCURRENT ||
     114             :          _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
     115             :     {
     116          58 :         mnWrapInfluenceOnPosition = _nWrapInfluenceOnPosition;
     117             :     }
     118             :     else
     119             :     {
     120             :         OSL_FAIL( "<SwFmtWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos(..)> - invalid attribute value" );
     121             :     }
     122          58 : }
     123             : 
     124             : // #i35017# - add parameter <_bIterativeAsOnceConcurrent> to control, if
     125             : // value <ITERATIVE> has to be treated as <ONCE_CONCURRENT>
     126       10736 : sal_Int16 SwFmtWrapInfluenceOnObjPos::GetWrapInfluenceOnObjPos(
     127             :                                 const bool _bIterativeAsOnceConcurrent ) const
     128             : {
     129       10736 :     sal_Int16 nWrapInfluenceOnPosition( mnWrapInfluenceOnPosition );
     130             : 
     131       10736 :     if ( _bIterativeAsOnceConcurrent &&
     132             :          nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
     133             :     {
     134           0 :         nWrapInfluenceOnPosition = text::WrapInfluenceOnPosition::ONCE_CONCURRENT;
     135             :     }
     136             : 
     137       10736 :     return nWrapInfluenceOnPosition;
     138             : }
     139             : 
     140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10