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