merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / utlui / uiitems.cxx
blob9d68727158c19368bd0a7a1b2f3e87ee4f0265e6
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: uiitems.cxx,v $
10 * $Revision: 1.14 $
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"
35 #include <svx/itemtype.hxx>
36 #include <unosett.hxx>
38 #include "swtypes.hxx"
39 #include "cmdid.h"
40 #include "uiitems.hxx"
42 #include "utlui.hrc"
43 #include "attrdesc.hrc"
44 #ifndef _UNOMID_H
45 #include <unomid.h>
46 #endif
47 #include <numrule.hxx>
49 using namespace ::com::sun::star;
50 using namespace ::com::sun::star::uno;
52 // Breitenangaben der Fussnotenlinien, mit TabPage abstimmen
53 static const USHORT __FAR_DATA nFtnLines[] = {
55 10,
56 50,
57 80,
58 100,
59 150
62 #define FTN_LINE_STYLE_COUNT 5
65 SwPageFtnInfoItem::SwPageFtnInfoItem( const USHORT nId, SwPageFtnInfo& rInfo) :
66 SfxPoolItem( nId ),
67 aFtnInfo(rInfo)
72 SwPageFtnInfoItem::SwPageFtnInfoItem( const SwPageFtnInfoItem& rItem ) :
73 SfxPoolItem( rItem ),
74 aFtnInfo(rItem.GetPageFtnInfo())
79 SwPageFtnInfoItem::~SwPageFtnInfoItem()
84 SfxPoolItem* SwPageFtnInfoItem::Clone( SfxItemPool * /*pPool*/ ) const
86 return new SwPageFtnInfoItem( *this );
90 int SwPageFtnInfoItem::operator==( const SfxPoolItem& rAttr ) const
92 DBG_ASSERT( Which() == rAttr.Which(), "keine gleichen Attribute" );
93 return ( aFtnInfo == ((SwPageFtnInfoItem&)rAttr).GetPageFtnInfo());
97 SfxItemPresentation SwPageFtnInfoItem::GetPresentation
99 SfxItemPresentation ePres,
100 SfxMapUnit eCoreUnit,
101 SfxMapUnit ePresUnit,
102 String& rText,
103 const IntlWrapper* pIntl
104 ) const
106 switch ( ePres )
108 case SFX_ITEM_PRESENTATION_NONE:
109 rText.Erase();
110 return SFX_ITEM_PRESENTATION_NONE;
111 case SFX_ITEM_PRESENTATION_NAMELESS:
112 case SFX_ITEM_PRESENTATION_COMPLETE:
114 USHORT nHght = (USHORT) GetPageFtnInfo().GetHeight();
115 if ( nHght )
117 rText = SW_RESSTR( STR_MAX_FTN_HEIGHT );
118 rText += ' ';
119 rText += ::GetMetricText( nHght, eCoreUnit, ePresUnit, pIntl );
120 rText += ::GetSvxString( ::GetMetricId( ePresUnit ) );
122 return ePres;
124 default:; //prevent warning
126 return SFX_ITEM_PRESENTATION_NONE;
128 /* -----------------------------26.04.01 12:25--------------------------------
130 ---------------------------------------------------------------------------*/
131 BOOL SwPageFtnInfoItem::QueryValue( Any& rVal, BYTE nMemberId ) const
133 sal_Bool bRet = sal_True;
134 switch(nMemberId & ~CONVERT_TWIPS)
136 case MID_FTN_HEIGHT : rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetHeight());break;
137 case MID_LINE_WEIGHT : rVal <<= (sal_Int16)TWIP_TO_MM100_UNSIGNED(aFtnInfo.GetLineWidth());break;
138 case MID_LINE_COLOR : rVal <<= (sal_Int32)aFtnInfo.GetLineColor().GetColor();break;
139 case MID_LINE_RELWIDTH :
141 Fraction aTmp( 100, 1 );
142 aTmp *= aFtnInfo.GetWidth();
143 rVal <<= (sal_Int8)(long)aTmp;
145 break;
146 case MID_LINE_ADJUST : rVal <<= (sal_Int16)aFtnInfo.GetAdj();break;//text::HorizontalAdjust
147 case MID_LINE_TEXT_DIST : rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetTopDist());break;
148 case MID_LINE_FOOTNOTE_DIST: rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetBottomDist());break;
149 default:
150 bRet = sal_False;
152 return bRet;
154 /* -----------------------------26.04.01 12:26--------------------------------
156 ---------------------------------------------------------------------------*/
157 BOOL SwPageFtnInfoItem::PutValue(const Any& rVal, BYTE nMemberId)
159 sal_Int32 nSet32 = 0;
160 sal_Bool bRet = sal_True;
161 switch(nMemberId & ~CONVERT_TWIPS)
163 case MID_LINE_COLOR :
164 rVal >>= nSet32;
165 aFtnInfo.SetLineColor(nSet32);
166 break;
167 case MID_FTN_HEIGHT:
168 case MID_LINE_TEXT_DIST :
169 case MID_LINE_FOOTNOTE_DIST:
170 rVal >>= nSet32;
171 if(nSet32 < 0)
172 bRet = sal_False;
173 else
175 nSet32 = MM100_TO_TWIP(nSet32);
176 switch(nMemberId & ~CONVERT_TWIPS)
178 case MID_FTN_HEIGHT: aFtnInfo.SetHeight(nSet32); break;
179 case MID_LINE_TEXT_DIST: aFtnInfo.SetTopDist(nSet32);break;
180 case MID_LINE_FOOTNOTE_DIST: aFtnInfo.SetBottomDist(nSet32);break;
183 break;
184 case MID_LINE_WEIGHT :
186 sal_Int16 nSet = 0;
187 rVal >>= nSet;
188 if(nSet >= 0)
189 aFtnInfo.SetLineWidth(MM100_TO_TWIP(nSet));
190 else
191 bRet = sal_False;
193 break;
194 case MID_LINE_RELWIDTH :
196 sal_Int8 nSet = 0;
197 rVal >>= nSet;
198 if(nSet < 0)
199 bRet = sal_False;
200 else
201 aFtnInfo.SetWidth(Fraction(nSet, 100));
203 break;
204 case MID_LINE_ADJUST :
206 sal_Int16 nSet = 0;
207 rVal >>= nSet;
208 if(nSet >= 0 && nSet < 3) //text::HorizontalAdjust
209 aFtnInfo.SetAdj((SwFtnAdj)nSet);
210 else
211 bRet = sal_False;
213 break;
214 default:
215 bRet = sal_False;
217 return bRet;
220 SwPtrItem::SwPtrItem( const USHORT nId, void* pPtr ) :
221 SfxPoolItem( nId ),
222 pMisc(pPtr)
226 /*--------------------------------------------------------------------
227 Beschreibung: Copy-Konstruktor
228 --------------------------------------------------------------------*/
231 SwPtrItem::SwPtrItem( const SwPtrItem& rItem ) : SfxPoolItem( rItem )
233 pMisc = rItem.pMisc;
236 /*--------------------------------------------------------------------
237 Beschreibung: Clonen
238 --------------------------------------------------------------------*/
241 SfxPoolItem* SwPtrItem::Clone( SfxItemPool * /*pPool*/ ) const
243 return new SwPtrItem( *this );
246 /*--------------------------------------------------------------------
247 Beschreibung:
248 --------------------------------------------------------------------*/
251 int SwPtrItem::operator==( const SfxPoolItem& rAttr ) const
253 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
254 const SwPtrItem& rItem = (SwPtrItem&)rAttr;
255 return ( pMisc == rItem.pMisc );
259 /*-----------------12.11.97 12:55-------------------------------
260 SwUINumRuleItem fuer die NumTabPages der FormatNumRule/Stylisten
261 ---------------------------------------------------------------*/
262 SwUINumRuleItem::SwUINumRuleItem( const SwNumRule& rRul, const USHORT nId )
263 : SfxPoolItem( nId ), pRule( new SwNumRule( rRul ) )
267 SwUINumRuleItem::SwUINumRuleItem( const SwUINumRuleItem& rItem )
268 : SfxPoolItem( rItem ),
269 pRule( new SwNumRule( *rItem.pRule ))
273 SwUINumRuleItem::~SwUINumRuleItem()
275 delete pRule;
279 SfxPoolItem* SwUINumRuleItem::Clone( SfxItemPool * /*pPool*/ ) const
281 return new SwUINumRuleItem( *this );
284 int SwUINumRuleItem::operator==( const SfxPoolItem& rAttr ) const
286 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
287 return *pRule == *((SwUINumRuleItem&)rAttr).pRule;
290 BOOL SwUINumRuleItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/ ) const
292 uno::Reference< container::XIndexReplace >xRules = new SwXNumberingRules(*pRule);
293 rVal.setValue(&xRules, ::getCppuType((uno::Reference< container::XIndexReplace>*)0));
294 return TRUE;
296 BOOL SwUINumRuleItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/ )
298 uno::Reference< container::XIndexReplace> xRulesRef;
299 if(rVal >>= xRulesRef)
301 uno::Reference< lang::XUnoTunnel > xTunnel(xRulesRef, uno::UNO_QUERY);
302 SwXNumberingRules* pSwXRules = xTunnel.is() ? reinterpret_cast<SwXNumberingRules*>(
303 xTunnel->getSomething(SwXNumberingRules::getUnoTunnelId())) : 0;
304 if(pSwXRules)
306 *pRule = *pSwXRules->GetNumRule();
309 return TRUE;
311 /* -----------------17.06.98 17:43-------------------
313 * --------------------------------------------------*/
314 SwBackgroundDestinationItem::SwBackgroundDestinationItem(USHORT _nWhich, USHORT nValue) :
315 SfxUInt16Item(_nWhich, nValue)
318 /* -----------------17.06.98 17:44-------------------
320 * --------------------------------------------------*/
321 SfxPoolItem* SwBackgroundDestinationItem::Clone( SfxItemPool * /*pPool*/ ) const
323 return new SwBackgroundDestinationItem(Which(), GetValue());