1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 #include <fmtwrapinfluenceonobjpos.hxx> 31 32 #ifndef _UNOMID_H 33 #include <unomid.h> 34 #endif 35 36 using namespace ::com::sun::star; 37 using namespace ::com::sun::star::uno; 38 39 TYPEINIT1(SwFmtWrapInfluenceOnObjPos, SfxPoolItem); 40 41 SwFmtWrapInfluenceOnObjPos::SwFmtWrapInfluenceOnObjPos( 42 sal_Int16 _nWrapInfluenceOnPosition ) 43 : SfxPoolItem( RES_WRAP_INFLUENCE_ON_OBJPOS ), 44 mnWrapInfluenceOnPosition( _nWrapInfluenceOnPosition ) 45 { 46 } 47 48 SwFmtWrapInfluenceOnObjPos::SwFmtWrapInfluenceOnObjPos( 49 const SwFmtWrapInfluenceOnObjPos& _rCpy ) 50 : SfxPoolItem( RES_WRAP_INFLUENCE_ON_OBJPOS ), 51 mnWrapInfluenceOnPosition( _rCpy.GetWrapInfluenceOnObjPos() ) 52 { 53 } 54 55 SwFmtWrapInfluenceOnObjPos::~SwFmtWrapInfluenceOnObjPos() 56 { 57 } 58 59 SwFmtWrapInfluenceOnObjPos& SwFmtWrapInfluenceOnObjPos::operator=( 60 const SwFmtWrapInfluenceOnObjPos& _rSource ) 61 { 62 mnWrapInfluenceOnPosition = _rSource.GetWrapInfluenceOnObjPos(); 63 64 return *this; 65 } 66 67 int SwFmtWrapInfluenceOnObjPos::operator==( const SfxPoolItem& _rAttr ) const 68 { 69 ASSERT( SfxPoolItem::operator==( _rAttr ), "keine gleichen Attribute" ); 70 return ( mnWrapInfluenceOnPosition == 71 static_cast<const SwFmtWrapInfluenceOnObjPos&>(_rAttr). 72 GetWrapInfluenceOnObjPos() ); 73 } 74 75 SfxPoolItem* SwFmtWrapInfluenceOnObjPos::Clone( SfxItemPool * ) const 76 { 77 return new SwFmtWrapInfluenceOnObjPos(*this); 78 } 79 80 sal_Bool SwFmtWrapInfluenceOnObjPos::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const 81 { 82 nMemberId &= ~CONVERT_TWIPS; 83 sal_Bool bRet = sal_True; 84 switch ( nMemberId ) 85 { 86 case MID_WRAP_INFLUENCE: 87 { 88 rVal <<= GetWrapInfluenceOnObjPos(); 89 } 90 break; 91 default: 92 ASSERT( false, "<SwFmtWrapInfluenceOnObjPos::QueryValue()> - unknown MemberId" ); 93 bRet = sal_False; 94 } 95 96 return bRet; 97 } 98 99 sal_Bool SwFmtWrapInfluenceOnObjPos::PutValue( const Any& rVal, sal_uInt8 nMemberId ) 100 { 101 nMemberId &= ~CONVERT_TWIPS; 102 sal_Bool bRet = sal_True; 103 104 switch ( nMemberId ) 105 { 106 case MID_WRAP_INFLUENCE: 107 { 108 sal_Int16 nNewWrapInfluence = 0; 109 rVal >>= nNewWrapInfluence; 110 // --> OD 2004-10-18 #i35017# - constant names have changed and 111 // <ITERATIVE> has been added 112 if ( nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE || 113 nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_CONCURRENT || 114 nNewWrapInfluence == text::WrapInfluenceOnPosition::ITERATIVE ) 115 // <-- 116 { 117 SetWrapInfluenceOnObjPos( nNewWrapInfluence ); 118 } 119 else 120 { 121 ASSERT( false, "<SwFmtWrapInfluenceOnObjPos::PutValue(..)> - invalid attribute value" ); 122 bRet = sal_False; 123 } 124 } 125 break; 126 default: 127 ASSERT( false, "<SwFmtWrapInfluenceOnObjPos::QueryValue()> - unknown MemberId" ); 128 bRet = sal_False; 129 } 130 131 return bRet; 132 } 133 134 void SwFmtWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos( sal_Int16 _nWrapInfluenceOnPosition ) 135 { 136 // --> OD 2004-10-18 #i35017# - constant names have changed and consider 137 // new value <ITERATIVE> 138 if ( _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE || 139 _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_CONCURRENT || 140 _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE ) 141 // <-- 142 { 143 mnWrapInfluenceOnPosition = _nWrapInfluenceOnPosition; 144 } 145 else 146 { 147 ASSERT( false, "<SwFmtWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos(..)> - invalid attribute value" ); 148 } 149 } 150 151 // --> OD 2004-10-18 #i35017# - add parameter <_bIterativeAsOnceConcurrent> 152 // to control, if value <ITERATIVE> has to be treated as <ONCE_CONCURRENT> 153 sal_Int16 SwFmtWrapInfluenceOnObjPos::GetWrapInfluenceOnObjPos( 154 const bool _bIterativeAsOnceConcurrent ) const 155 { 156 sal_Int16 nWrapInfluenceOnPosition( mnWrapInfluenceOnPosition ); 157 158 if ( _bIterativeAsOnceConcurrent && 159 nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE ) 160 { 161 nWrapInfluenceOnPosition = text::WrapInfluenceOnPosition::ONCE_CONCURRENT; 162 } 163 164 return nWrapInfluenceOnPosition; 165 } 166 // <-- 167