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