Update ooo320-m1
[ooovba.git] / sw / source / core / attr / fmtwrapinfluenceonobjpos.cxx
blobda3f7b25fcb9f81d59c46f2c22ff588a18d69d17
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmtwrapinfluenceonobjpos.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <fmtwrapinfluenceonobjpos.hxx>
35 #ifndef _UNOMID_H
36 #include <unomid.h>
37 #endif
39 using namespace ::com::sun::star;
40 using namespace ::com::sun::star::uno;
42 TYPEINIT1(SwFmtWrapInfluenceOnObjPos, SfxPoolItem);
44 SwFmtWrapInfluenceOnObjPos::SwFmtWrapInfluenceOnObjPos(
45 sal_Int16 _nWrapInfluenceOnPosition )
46 : SfxPoolItem( RES_WRAP_INFLUENCE_ON_OBJPOS ),
47 mnWrapInfluenceOnPosition( _nWrapInfluenceOnPosition )
51 SwFmtWrapInfluenceOnObjPos::SwFmtWrapInfluenceOnObjPos(
52 const SwFmtWrapInfluenceOnObjPos& _rCpy )
53 : SfxPoolItem( RES_WRAP_INFLUENCE_ON_OBJPOS ),
54 mnWrapInfluenceOnPosition( _rCpy.GetWrapInfluenceOnObjPos() )
58 SwFmtWrapInfluenceOnObjPos::~SwFmtWrapInfluenceOnObjPos()
62 SwFmtWrapInfluenceOnObjPos& SwFmtWrapInfluenceOnObjPos::operator=(
63 const SwFmtWrapInfluenceOnObjPos& _rSource )
65 mnWrapInfluenceOnPosition = _rSource.GetWrapInfluenceOnObjPos();
67 return *this;
70 int SwFmtWrapInfluenceOnObjPos::operator==( const SfxPoolItem& _rAttr ) const
72 ASSERT( SfxPoolItem::operator==( _rAttr ), "keine gleichen Attribute" );
73 return ( mnWrapInfluenceOnPosition ==
74 static_cast<const SwFmtWrapInfluenceOnObjPos&>(_rAttr).
75 GetWrapInfluenceOnObjPos() );
78 SfxPoolItem* SwFmtWrapInfluenceOnObjPos::Clone( SfxItemPool * ) const
80 return new SwFmtWrapInfluenceOnObjPos(*this);
83 BOOL SwFmtWrapInfluenceOnObjPos::QueryValue( Any& rVal, BYTE nMemberId ) const
85 nMemberId &= ~CONVERT_TWIPS;
86 sal_Bool bRet = sal_True;
87 switch ( nMemberId )
89 case MID_WRAP_INFLUENCE:
91 rVal <<= GetWrapInfluenceOnObjPos();
93 break;
94 default:
95 ASSERT( false, "<SwFmtWrapInfluenceOnObjPos::QueryValue()> - unknown MemberId" );
96 bRet = sal_False;
99 return bRet;
102 BOOL SwFmtWrapInfluenceOnObjPos::PutValue( const Any& rVal, BYTE nMemberId )
104 nMemberId &= ~CONVERT_TWIPS;
105 sal_Bool bRet = sal_True;
107 switch ( nMemberId )
109 case MID_WRAP_INFLUENCE:
111 sal_Int16 nNewWrapInfluence = 0;
112 rVal >>= nNewWrapInfluence;
113 // --> OD 2004-10-18 #i35017# - constant names have changed and
114 // <ITERATIVE> has been added
115 if ( nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
116 nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_CONCURRENT ||
117 nNewWrapInfluence == text::WrapInfluenceOnPosition::ITERATIVE )
118 // <--
120 SetWrapInfluenceOnObjPos( nNewWrapInfluence );
122 else
124 ASSERT( false, "<SwFmtWrapInfluenceOnObjPos::PutValue(..)> - invalid attribute value" );
125 bRet = sal_False;
128 break;
129 default:
130 ASSERT( false, "<SwFmtWrapInfluenceOnObjPos::QueryValue()> - unknown MemberId" );
131 bRet = sal_False;
134 return bRet;
137 void SwFmtWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos( sal_Int16 _nWrapInfluenceOnPosition )
139 // --> OD 2004-10-18 #i35017# - constant names have changed and consider
140 // new value <ITERATIVE>
141 if ( _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
142 _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_CONCURRENT ||
143 _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
144 // <--
146 mnWrapInfluenceOnPosition = _nWrapInfluenceOnPosition;
148 else
150 ASSERT( false, "<SwFmtWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos(..)> - invalid attribute value" );
154 // --> OD 2004-10-18 #i35017# - add parameter <_bIterativeAsOnceConcurrent>
155 // to control, if value <ITERATIVE> has to be treated as <ONCE_CONCURRENT>
156 sal_Int16 SwFmtWrapInfluenceOnObjPos::GetWrapInfluenceOnObjPos(
157 const bool _bIterativeAsOnceConcurrent ) const
159 sal_Int16 nWrapInfluenceOnPosition( mnWrapInfluenceOnPosition );
161 if ( _bIterativeAsOnceConcurrent &&
162 nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
164 nWrapInfluenceOnPosition = text::WrapInfluenceOnPosition::ONCE_CONCURRENT;
167 return nWrapInfluenceOnPosition;
169 // <--