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