1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: uiitems.cxx,v $
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"
40 #include "uiitems.hxx"
43 #include "attrdesc.hrc"
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
[] = {
62 #define FTN_LINE_STYLE_COUNT 5
65 SwPageFtnInfoItem::SwPageFtnInfoItem( const USHORT nId
, SwPageFtnInfo
& rInfo
) :
72 SwPageFtnInfoItem::SwPageFtnInfoItem( const SwPageFtnInfoItem
& 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
,
103 const IntlWrapper
* pIntl
108 case SFX_ITEM_PRESENTATION_NONE
:
110 return SFX_ITEM_PRESENTATION_NONE
;
111 case SFX_ITEM_PRESENTATION_NAMELESS
:
112 case SFX_ITEM_PRESENTATION_COMPLETE
:
114 USHORT nHght
= (USHORT
) GetPageFtnInfo().GetHeight();
117 rText
= SW_RESSTR( STR_MAX_FTN_HEIGHT
);
119 rText
+= ::GetMetricText( nHght
, eCoreUnit
, ePresUnit
, pIntl
);
120 rText
+= ::GetSvxString( ::GetMetricId( ePresUnit
) );
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
;
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;
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
:
165 aFtnInfo
.SetLineColor(nSet32
);
168 case MID_LINE_TEXT_DIST
:
169 case MID_LINE_FOOTNOTE_DIST
:
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;
184 case MID_LINE_WEIGHT
:
189 aFtnInfo
.SetLineWidth(MM100_TO_TWIP(nSet
));
194 case MID_LINE_RELWIDTH
:
201 aFtnInfo
.SetWidth(Fraction(nSet
, 100));
204 case MID_LINE_ADJUST
:
208 if(nSet
>= 0 && nSet
< 3) //text::HorizontalAdjust
209 aFtnInfo
.SetAdj((SwFtnAdj
)nSet
);
220 SwPtrItem::SwPtrItem( const USHORT nId
, void* pPtr
) :
226 /*--------------------------------------------------------------------
227 Beschreibung: Copy-Konstruktor
228 --------------------------------------------------------------------*/
231 SwPtrItem::SwPtrItem( const SwPtrItem
& rItem
) : SfxPoolItem( rItem
)
236 /*--------------------------------------------------------------------
238 --------------------------------------------------------------------*/
241 SfxPoolItem
* SwPtrItem::Clone( SfxItemPool
* /*pPool*/ ) const
243 return new SwPtrItem( *this );
246 /*--------------------------------------------------------------------
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()
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));
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;
306 *pRule
= *pSwXRules
->GetNumRule();
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());