1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include <fmtwrapinfluenceonobjpos.hxx>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #ifndef _UNOMID_H
29cdf0e10cSrcweir #include <unomid.h>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir 
32cdf0e10cSrcweir using namespace ::com::sun::star;
33cdf0e10cSrcweir using namespace ::com::sun::star::uno;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir TYPEINIT1(SwFmtWrapInfluenceOnObjPos, SfxPoolItem);
36cdf0e10cSrcweir 
SwFmtWrapInfluenceOnObjPos(sal_Int16 _nWrapInfluenceOnPosition)37cdf0e10cSrcweir SwFmtWrapInfluenceOnObjPos::SwFmtWrapInfluenceOnObjPos(
38cdf0e10cSrcweir                                             sal_Int16 _nWrapInfluenceOnPosition )
39cdf0e10cSrcweir     : SfxPoolItem( RES_WRAP_INFLUENCE_ON_OBJPOS ),
40cdf0e10cSrcweir     mnWrapInfluenceOnPosition( _nWrapInfluenceOnPosition )
41cdf0e10cSrcweir {
42cdf0e10cSrcweir }
43cdf0e10cSrcweir 
SwFmtWrapInfluenceOnObjPos(const SwFmtWrapInfluenceOnObjPos & _rCpy)44cdf0e10cSrcweir SwFmtWrapInfluenceOnObjPos::SwFmtWrapInfluenceOnObjPos(
45cdf0e10cSrcweir                                         const SwFmtWrapInfluenceOnObjPos& _rCpy )
46cdf0e10cSrcweir     : SfxPoolItem( RES_WRAP_INFLUENCE_ON_OBJPOS ),
47cdf0e10cSrcweir     mnWrapInfluenceOnPosition( _rCpy.GetWrapInfluenceOnObjPos() )
48cdf0e10cSrcweir {
49cdf0e10cSrcweir }
50cdf0e10cSrcweir 
~SwFmtWrapInfluenceOnObjPos()51cdf0e10cSrcweir SwFmtWrapInfluenceOnObjPos::~SwFmtWrapInfluenceOnObjPos()
52cdf0e10cSrcweir {
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
operator =(const SwFmtWrapInfluenceOnObjPos & _rSource)55cdf0e10cSrcweir SwFmtWrapInfluenceOnObjPos& SwFmtWrapInfluenceOnObjPos::operator=(
56cdf0e10cSrcweir                                     const SwFmtWrapInfluenceOnObjPos& _rSource )
57cdf0e10cSrcweir {
58cdf0e10cSrcweir     mnWrapInfluenceOnPosition = _rSource.GetWrapInfluenceOnObjPos();
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     return *this;
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
operator ==(const SfxPoolItem & _rAttr) const63cdf0e10cSrcweir int SwFmtWrapInfluenceOnObjPos::operator==( const SfxPoolItem& _rAttr ) const
64cdf0e10cSrcweir {
65cdf0e10cSrcweir     ASSERT( SfxPoolItem::operator==( _rAttr ), "keine gleichen Attribute" );
66cdf0e10cSrcweir     return ( mnWrapInfluenceOnPosition ==
67cdf0e10cSrcweir                     static_cast<const SwFmtWrapInfluenceOnObjPos&>(_rAttr).
68cdf0e10cSrcweir                                                 GetWrapInfluenceOnObjPos() );
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
Clone(SfxItemPool *) const71cdf0e10cSrcweir SfxPoolItem* SwFmtWrapInfluenceOnObjPos::Clone( SfxItemPool * ) const
72cdf0e10cSrcweir {
73cdf0e10cSrcweir     return new SwFmtWrapInfluenceOnObjPos(*this);
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
QueryValue(Any & rVal,sal_uInt8 nMemberId) const76cdf0e10cSrcweir sal_Bool SwFmtWrapInfluenceOnObjPos::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
77cdf0e10cSrcweir {
78cdf0e10cSrcweir     nMemberId &= ~CONVERT_TWIPS;
79cdf0e10cSrcweir     sal_Bool bRet = sal_True;
80cdf0e10cSrcweir     switch ( nMemberId )
81cdf0e10cSrcweir     {
82cdf0e10cSrcweir         case MID_WRAP_INFLUENCE:
83cdf0e10cSrcweir         {
84cdf0e10cSrcweir             rVal <<= GetWrapInfluenceOnObjPos();
85cdf0e10cSrcweir         }
86cdf0e10cSrcweir         break;
87cdf0e10cSrcweir         default:
88cdf0e10cSrcweir             ASSERT( false, "<SwFmtWrapInfluenceOnObjPos::QueryValue()> - unknown MemberId" );
89cdf0e10cSrcweir             bRet = sal_False;
90cdf0e10cSrcweir     }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     return bRet;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
PutValue(const Any & rVal,sal_uInt8 nMemberId)95cdf0e10cSrcweir sal_Bool SwFmtWrapInfluenceOnObjPos::PutValue( const Any& rVal, sal_uInt8 nMemberId )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     nMemberId &= ~CONVERT_TWIPS;
98cdf0e10cSrcweir     sal_Bool bRet = sal_True;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     switch ( nMemberId )
101cdf0e10cSrcweir     {
102cdf0e10cSrcweir         case MID_WRAP_INFLUENCE:
103cdf0e10cSrcweir         {
104cdf0e10cSrcweir             sal_Int16 nNewWrapInfluence = 0;
105cdf0e10cSrcweir             rVal >>= nNewWrapInfluence;
106cdf0e10cSrcweir             // --> OD 2004-10-18 #i35017# - constant names have changed and
107cdf0e10cSrcweir             // <ITERATIVE> has been added
108cdf0e10cSrcweir             if ( nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
109cdf0e10cSrcweir                  nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_CONCURRENT ||
110cdf0e10cSrcweir                  nNewWrapInfluence == text::WrapInfluenceOnPosition::ITERATIVE )
111cdf0e10cSrcweir             // <--
112cdf0e10cSrcweir             {
113cdf0e10cSrcweir                 SetWrapInfluenceOnObjPos( nNewWrapInfluence );
114cdf0e10cSrcweir             }
115cdf0e10cSrcweir             else
116cdf0e10cSrcweir             {
117cdf0e10cSrcweir                 ASSERT( false, "<SwFmtWrapInfluenceOnObjPos::PutValue(..)> - invalid attribute value" );
118cdf0e10cSrcweir                 bRet = sal_False;
119cdf0e10cSrcweir             }
120cdf0e10cSrcweir         }
121cdf0e10cSrcweir         break;
122cdf0e10cSrcweir         default:
123cdf0e10cSrcweir             ASSERT( false, "<SwFmtWrapInfluenceOnObjPos::QueryValue()> - unknown MemberId" );
124cdf0e10cSrcweir             bRet = sal_False;
125cdf0e10cSrcweir     }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     return bRet;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
SetWrapInfluenceOnObjPos(sal_Int16 _nWrapInfluenceOnPosition)130cdf0e10cSrcweir void SwFmtWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos( sal_Int16 _nWrapInfluenceOnPosition )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir     // --> OD 2004-10-18 #i35017# - constant names have changed and consider
133cdf0e10cSrcweir     // new value <ITERATIVE>
134cdf0e10cSrcweir     if ( _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
135cdf0e10cSrcweir          _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_CONCURRENT ||
136cdf0e10cSrcweir          _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
137cdf0e10cSrcweir     // <--
138cdf0e10cSrcweir     {
139cdf0e10cSrcweir         mnWrapInfluenceOnPosition = _nWrapInfluenceOnPosition;
140cdf0e10cSrcweir     }
141cdf0e10cSrcweir     else
142cdf0e10cSrcweir     {
143cdf0e10cSrcweir         ASSERT( false, "<SwFmtWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos(..)> - invalid attribute value" );
144cdf0e10cSrcweir     }
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir // --> OD 2004-10-18 #i35017# - add parameter <_bIterativeAsOnceConcurrent>
148cdf0e10cSrcweir // to control, if value <ITERATIVE> has to be treated as <ONCE_CONCURRENT>
GetWrapInfluenceOnObjPos(const bool _bIterativeAsOnceConcurrent) const149cdf0e10cSrcweir sal_Int16 SwFmtWrapInfluenceOnObjPos::GetWrapInfluenceOnObjPos(
150cdf0e10cSrcweir                                 const bool _bIterativeAsOnceConcurrent ) const
151cdf0e10cSrcweir {
152cdf0e10cSrcweir     sal_Int16 nWrapInfluenceOnPosition( mnWrapInfluenceOnPosition );
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     if ( _bIterativeAsOnceConcurrent &&
155cdf0e10cSrcweir          nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
156cdf0e10cSrcweir     {
157cdf0e10cSrcweir         nWrapInfluenceOnPosition = text::WrapInfluenceOnPosition::ONCE_CONCURRENT;
158cdf0e10cSrcweir     }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     return nWrapInfluenceOnPosition;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir // <--
163