xref: /aoo41x/main/sw/source/ui/utlui/uiitems.cxx (revision ae2dc0fa)
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 
27 
28 #include <editeng/itemtype.hxx>
29 #include <unosett.hxx>
30 
31 #include "swtypes.hxx"
32 #include "cmdid.h"
33 #include "uiitems.hxx"
34 
35 #include "utlui.hrc"
36 #include "attrdesc.hrc"
37 #ifndef _UNOMID_H
38 #include <unomid.h>
39 #endif
40 #include <numrule.hxx>
41 
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::uno;
44 
45 // Breitenangaben der Fussnotenlinien, mit TabPage abstimmen
46 static const sal_uInt16 __FAR_DATA nFtnLines[] = {
47 	0,
48 	10,
49 	50,
50 	80,
51 	100,
52 	150
53 };
54 
55 #define FTN_LINE_STYLE_COUNT 5
56 
57 
SwPageFtnInfoItem(const sal_uInt16 nId,SwPageFtnInfo & rInfo)58 SwPageFtnInfoItem::SwPageFtnInfoItem( const sal_uInt16 nId, SwPageFtnInfo& rInfo) :
59 	SfxPoolItem( nId ),
60 	aFtnInfo(rInfo)
61 {
62 }
63 
64 
SwPageFtnInfoItem(const SwPageFtnInfoItem & rItem)65 SwPageFtnInfoItem::SwPageFtnInfoItem( const SwPageFtnInfoItem& rItem ) :
66 	SfxPoolItem( rItem ),
67 	aFtnInfo(rItem.GetPageFtnInfo())
68 {
69 }
70 
71 
~SwPageFtnInfoItem()72  SwPageFtnInfoItem::~SwPageFtnInfoItem()
73 {
74 }
75 
76 
Clone(SfxItemPool *) const77 SfxPoolItem*  SwPageFtnInfoItem::Clone( SfxItemPool * /*pPool*/ ) const
78 {
79 	return new SwPageFtnInfoItem( *this );
80 }
81 
82 
operator ==(const SfxPoolItem & rAttr) const83 int  SwPageFtnInfoItem::operator==( const SfxPoolItem& rAttr ) const
84 {
85 	DBG_ASSERT( Which() == rAttr.Which(), "keine gleichen Attribute" );
86 	return ( aFtnInfo == ((SwPageFtnInfoItem&)rAttr).GetPageFtnInfo());
87 }
88 
89 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,String & rText,const IntlWrapper * pIntl) const90 SfxItemPresentation  SwPageFtnInfoItem::GetPresentation
91 (
92 	SfxItemPresentation ePres,
93 	SfxMapUnit			eCoreUnit,
94 	SfxMapUnit			ePresUnit,
95 	String& 			rText,
96     const IntlWrapper*    pIntl
97 )	const
98 {
99 	switch ( ePres )
100 	{
101 		case SFX_ITEM_PRESENTATION_NONE:
102 			rText.Erase();
103 			return SFX_ITEM_PRESENTATION_NONE;
104 		case SFX_ITEM_PRESENTATION_NAMELESS:
105 		case SFX_ITEM_PRESENTATION_COMPLETE:
106 		{
107 			sal_uInt16 nHght = (sal_uInt16) GetPageFtnInfo().GetHeight();
108 			if ( nHght )
109 			{
110 				rText = SW_RESSTR( STR_MAX_FTN_HEIGHT );
111 				rText += ' ';
112                 rText += ::GetMetricText( nHght, eCoreUnit, ePresUnit, pIntl );
113 				rText += sal_Unicode(' ');
114 				rText += ::GetSvxString( ::GetMetricId( ePresUnit ) );
115 			}
116 			return ePres;
117 		}
118         default:; //prevent warning
119 	}
120 	return SFX_ITEM_PRESENTATION_NONE;
121 }
122 /* -----------------------------26.04.01 12:25--------------------------------
123 
124  ---------------------------------------------------------------------------*/
QueryValue(Any & rVal,sal_uInt8 nMemberId) const125 sal_Bool SwPageFtnInfoItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
126 {
127     sal_Bool bRet = sal_True;
128     switch(nMemberId & ~CONVERT_TWIPS)
129     {
130         case MID_FTN_HEIGHT        :     rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetHeight());break;
131         case MID_LINE_WEIGHT       :     rVal <<= (sal_Int16)TWIP_TO_MM100_UNSIGNED(aFtnInfo.GetLineWidth());break;
132         case MID_LINE_COLOR        :     rVal <<= (sal_Int32)aFtnInfo.GetLineColor().GetColor();break;
133         case MID_LINE_RELWIDTH     :
134         {
135             Fraction aTmp( 100, 1 );
136             aTmp *= aFtnInfo.GetWidth();
137             rVal <<= (sal_Int8)(long)aTmp;
138         }
139         break;
140         case MID_LINE_ADJUST       :     rVal <<= (sal_Int16)aFtnInfo.GetAdj();break;//text::HorizontalAdjust
141         case MID_LINE_TEXT_DIST    :     rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetTopDist());break;
142         case MID_LINE_FOOTNOTE_DIST:     rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetBottomDist());break;
143         default:
144             bRet = sal_False;
145     }
146     return bRet;
147 }
148 /* -----------------------------26.04.01 12:26--------------------------------
149 
150  ---------------------------------------------------------------------------*/
PutValue(const Any & rVal,sal_uInt8 nMemberId)151 sal_Bool SwPageFtnInfoItem::PutValue(const Any& rVal, sal_uInt8 nMemberId)
152 {
153     sal_Int32 nSet32 = 0;
154     sal_Bool bRet = sal_True;
155     switch(nMemberId  & ~CONVERT_TWIPS)
156     {
157         case MID_LINE_COLOR        :
158             rVal >>= nSet32;
159             aFtnInfo.SetLineColor(nSet32);
160         break;
161         case MID_FTN_HEIGHT:
162         case MID_LINE_TEXT_DIST    :
163         case MID_LINE_FOOTNOTE_DIST:
164                 rVal >>= nSet32;
165                 if(nSet32 < 0)
166                     bRet = sal_False;
167                 else
168                 {
169                     nSet32 = MM100_TO_TWIP(nSet32);
170                     switch(nMemberId & ~CONVERT_TWIPS)
171                     {
172                         case MID_FTN_HEIGHT:            aFtnInfo.SetHeight(nSet32);    break;
173                         case MID_LINE_TEXT_DIST:        aFtnInfo.SetTopDist(nSet32);break;
174                         case MID_LINE_FOOTNOTE_DIST:    aFtnInfo.SetBottomDist(nSet32);break;
175                     }
176                 }
177         break;
178         case MID_LINE_WEIGHT       :
179         {
180             sal_Int16 nSet = 0;
181             rVal >>= nSet;
182             if(nSet >= 0)
183                 aFtnInfo.SetLineWidth(MM100_TO_TWIP(nSet));
184             else
185                 bRet = sal_False;
186         }
187         break;
188         case MID_LINE_RELWIDTH     :
189         {
190             sal_Int8 nSet = 0;
191             rVal >>= nSet;
192             if(nSet < 0)
193                 bRet = sal_False;
194             else
195                 aFtnInfo.SetWidth(Fraction(nSet, 100));
196         }
197         break;
198         case MID_LINE_ADJUST       :
199         {
200             sal_Int16 nSet = 0;
201             rVal >>= nSet;
202             if(nSet >= 0 && nSet < 3) //text::HorizontalAdjust
203                 aFtnInfo.SetAdj((SwFtnAdj)nSet);
204             else
205                 bRet = sal_False;
206         }
207         break;
208         default:
209             bRet = sal_False;
210     }
211     return bRet;
212 }
213 
SwPtrItem(const sal_uInt16 nId,void * pPtr)214 SwPtrItem::SwPtrItem( const sal_uInt16 nId, void* pPtr ) :
215 	SfxPoolItem( nId ),
216 	pMisc(pPtr)
217 {
218 }
219 
220 /*--------------------------------------------------------------------
221 	Beschreibung: Copy-Konstruktor
222  --------------------------------------------------------------------*/
223 
224 
SwPtrItem(const SwPtrItem & rItem)225 SwPtrItem::SwPtrItem( const SwPtrItem& rItem ) : SfxPoolItem( rItem )
226 {
227 	pMisc = rItem.pMisc;
228 }
229 
230 /*--------------------------------------------------------------------
231 	Beschreibung: Clonen
232  --------------------------------------------------------------------*/
233 
234 
Clone(SfxItemPool *) const235 SfxPoolItem* SwPtrItem::Clone( SfxItemPool * /*pPool*/ ) const
236 {
237 	return new SwPtrItem( *this );
238 }
239 
240 /*--------------------------------------------------------------------
241 	Beschreibung:
242  --------------------------------------------------------------------*/
243 
244 
operator ==(const SfxPoolItem & rAttr) const245 int SwPtrItem::operator==( const SfxPoolItem& rAttr ) const
246 {
247 	DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
248 	const SwPtrItem& rItem = (SwPtrItem&)rAttr;
249 	return ( pMisc == rItem.pMisc );
250 }
251 
252 
253 /*-----------------12.11.97 12:55-------------------------------
254  SwUINumRuleItem fuer die NumTabPages der FormatNumRule/Stylisten
255 ---------------------------------------------------------------*/
SwUINumRuleItem(const SwNumRule & rRul,const sal_uInt16 nId)256 SwUINumRuleItem::SwUINumRuleItem( const SwNumRule& rRul, const sal_uInt16 nId )
257 	: SfxPoolItem( nId ), pRule( new SwNumRule( rRul ) )
258 {
259 }
260 
SwUINumRuleItem(const SwUINumRuleItem & rItem)261 SwUINumRuleItem::SwUINumRuleItem( const SwUINumRuleItem& rItem )
262 	: SfxPoolItem( rItem ),
263 	pRule( new SwNumRule( *rItem.pRule ))
264 {
265 }
266 
~SwUINumRuleItem()267  SwUINumRuleItem::~SwUINumRuleItem()
268 {
269 	delete pRule;
270 }
271 
272 
Clone(SfxItemPool *) const273 SfxPoolItem*  SwUINumRuleItem::Clone( SfxItemPool * /*pPool*/ ) const
274 {
275 	return new SwUINumRuleItem( *this );
276 }
277 
operator ==(const SfxPoolItem & rAttr) const278 int  SwUINumRuleItem::operator==( const SfxPoolItem& rAttr ) const
279 {
280 	DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
281 	return *pRule == *((SwUINumRuleItem&)rAttr).pRule;
282 }
283 
QueryValue(uno::Any & rVal,sal_uInt8) const284 sal_Bool SwUINumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
285 {
286 	uno::Reference< container::XIndexReplace >xRules = new SwXNumberingRules(*pRule);
287 	rVal.setValue(&xRules, ::getCppuType((uno::Reference< container::XIndexReplace>*)0));
288 	return sal_True;
289 }
PutValue(const uno::Any & rVal,sal_uInt8)290 sal_Bool SwUINumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
291 {
292     uno::Reference< container::XIndexReplace> xRulesRef;
293     if(rVal >>= xRulesRef)
294 	{
295         uno::Reference< lang::XUnoTunnel > xTunnel(xRulesRef, uno::UNO_QUERY);
296         SwXNumberingRules* pSwXRules = xTunnel.is() ? reinterpret_cast<SwXNumberingRules*>(
297                     xTunnel->getSomething(SwXNumberingRules::getUnoTunnelId())) : 0;
298 		if(pSwXRules)
299 		{
300 			*pRule = *pSwXRules->GetNumRule();
301 		}
302 	}
303 	return sal_True;
304 }
305 /* -----------------17.06.98 17:43-------------------
306  *
307  * --------------------------------------------------*/
SwBackgroundDestinationItem(sal_uInt16 _nWhich,sal_uInt16 nValue)308 SwBackgroundDestinationItem::SwBackgroundDestinationItem(sal_uInt16  _nWhich, sal_uInt16 nValue) :
309     SfxUInt16Item(_nWhich, nValue)
310 {
311 }
312 /* -----------------17.06.98 17:44-------------------
313  *
314  * --------------------------------------------------*/
Clone(SfxItemPool *) const315 SfxPoolItem*     SwBackgroundDestinationItem::Clone( SfxItemPool * /*pPool*/ ) const
316 {
317 	return new SwBackgroundDestinationItem(Which(), GetValue());
318 }
319 
320 
321 
322