1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <editeng/itemtype.hxx>
21 #include <unosett.hxx>
23 #include "swtypes.hxx"
25 #include "uiitems.hxx"
28 #include "attrdesc.hrc"
30 #include <numrule.hxx>
32 using namespace ::com::sun::star
;
33 using namespace ::com::sun::star::uno
;
35 SwPageFtnInfoItem::SwPageFtnInfoItem( const sal_uInt16 nId
, SwPageFtnInfo
& rInfo
) :
41 SwPageFtnInfoItem::SwPageFtnInfoItem( const SwPageFtnInfoItem
& rItem
) :
43 aFtnInfo(rItem
.GetPageFtnInfo())
47 SwPageFtnInfoItem::~SwPageFtnInfoItem()
51 SfxPoolItem
* SwPageFtnInfoItem::Clone( SfxItemPool
* /*pPool*/ ) const
53 return new SwPageFtnInfoItem( *this );
56 int SwPageFtnInfoItem::operator==( const SfxPoolItem
& rAttr
) const
58 OSL_ENSURE( Which() == rAttr
.Which(), "no equal attributes" );
59 return ( aFtnInfo
== ((SwPageFtnInfoItem
&)rAttr
).GetPageFtnInfo());
62 SfxItemPresentation
SwPageFtnInfoItem::GetPresentation
64 SfxItemPresentation ePres
,
68 const IntlWrapper
* pIntl
73 case SFX_ITEM_PRESENTATION_NONE
:
75 return SFX_ITEM_PRESENTATION_NONE
;
76 case SFX_ITEM_PRESENTATION_NAMELESS
:
77 case SFX_ITEM_PRESENTATION_COMPLETE
:
79 sal_uInt16 nHght
= (sal_uInt16
) GetPageFtnInfo().GetHeight();
82 rText
= SW_RESSTR( STR_MAX_FTN_HEIGHT
) + " " +
83 ::GetMetricText( nHght
, eCoreUnit
, ePresUnit
, pIntl
) +
84 ::GetSvxString( ::GetMetricId( ePresUnit
) );
88 default:; //prevent warning
90 return SFX_ITEM_PRESENTATION_NONE
;
93 bool SwPageFtnInfoItem::QueryValue( Any
& rVal
, sal_uInt8 nMemberId
) const
96 switch(nMemberId
& ~CONVERT_TWIPS
)
98 case MID_FTN_HEIGHT
: rVal
<<= (sal_Int32
)TWIP_TO_MM100(aFtnInfo
.GetHeight());break;
99 case MID_LINE_WEIGHT
: rVal
<<= (sal_Int16
)TWIP_TO_MM100_UNSIGNED(aFtnInfo
.GetLineWidth());break;
100 case MID_LINE_COLOR
: rVal
<<= (sal_Int32
)aFtnInfo
.GetLineColor().GetColor();break;
101 case MID_LINE_RELWIDTH
:
103 Fraction
aTmp( 100, 1 );
104 aTmp
*= aFtnInfo
.GetWidth();
105 rVal
<<= (sal_Int8
)(long)aTmp
;
108 case MID_LINE_ADJUST
: rVal
<<= (sal_Int16
)aFtnInfo
.GetAdj();break;//text::HorizontalAdjust
109 case MID_LINE_TEXT_DIST
: rVal
<<= (sal_Int32
)TWIP_TO_MM100(aFtnInfo
.GetTopDist());break;
110 case MID_LINE_FOOTNOTE_DIST
: rVal
<<= (sal_Int32
)TWIP_TO_MM100(aFtnInfo
.GetBottomDist());break;
111 case MID_FTN_LINE_STYLE
:
113 switch ( aFtnInfo
.GetLineStyle( ) )
116 case table::BorderLineStyle::NONE
: rVal
<<= sal_Int8(0); break;
117 case table::BorderLineStyle::SOLID
: rVal
<<= sal_Int8(1); break;
118 case table::BorderLineStyle::DOTTED
: rVal
<<= sal_Int8(2); break;
119 case table::BorderLineStyle::DASHED
: rVal
<<= sal_Int8(3); break;
129 bool SwPageFtnInfoItem::PutValue(const Any
& rVal
, sal_uInt8 nMemberId
)
131 sal_Int32 nSet32
= 0;
133 switch(nMemberId
& ~CONVERT_TWIPS
)
135 case MID_LINE_COLOR
:
137 aFtnInfo
.SetLineColor(nSet32
);
140 case MID_LINE_TEXT_DIST
:
141 case MID_LINE_FOOTNOTE_DIST
:
147 nSet32
= MM100_TO_TWIP(nSet32
);
148 switch(nMemberId
& ~CONVERT_TWIPS
)
150 case MID_FTN_HEIGHT
: aFtnInfo
.SetHeight(nSet32
); break;
151 case MID_LINE_TEXT_DIST
: aFtnInfo
.SetTopDist(nSet32
);break;
152 case MID_LINE_FOOTNOTE_DIST
: aFtnInfo
.SetBottomDist(nSet32
);break;
156 case MID_LINE_WEIGHT
:
161 aFtnInfo
.SetLineWidth(MM100_TO_TWIP(nSet
));
166 case MID_LINE_RELWIDTH
:
173 aFtnInfo
.SetWidth(Fraction(nSet
, 100));
176 case MID_LINE_ADJUST
:
180 if(nSet
>= 0 && nSet
< 3) //text::HorizontalAdjust
181 aFtnInfo
.SetAdj((SwFtnAdj
)nSet
);
185 case MID_FTN_LINE_STYLE
:
187 ::editeng::SvxBorderStyle eStyle
= table::BorderLineStyle::NONE
;
192 case 1: eStyle
= table::BorderLineStyle::SOLID
; break;
193 case 2: eStyle
= table::BorderLineStyle::DOTTED
; break;
194 case 3: eStyle
= table::BorderLineStyle::DASHED
; break;
197 aFtnInfo
.SetLineStyle( eStyle
);
206 SwPtrItem::SwPtrItem( const sal_uInt16 nId
, void* pPtr
) :
214 SwPtrItem::SwPtrItem( const SwPtrItem
& rItem
) : SfxPoolItem( rItem
)
221 SfxPoolItem
* SwPtrItem::Clone( SfxItemPool
* /*pPool*/ ) const
223 return new SwPtrItem( *this );
226 int SwPtrItem::operator==( const SfxPoolItem
& rAttr
) const
228 OSL_ENSURE( SfxPoolItem::operator==(rAttr
), "unequal types" );
229 const SwPtrItem
& rItem
= (SwPtrItem
&)rAttr
;
230 return ( pMisc
== rItem
.pMisc
);
233 // SwUINumRuleItem for the NumTabPages of the FormatNumRule/Styleists
235 SwUINumRuleItem::SwUINumRuleItem( const SwNumRule
& rRul
, const sal_uInt16 nId
)
236 : SfxPoolItem( nId
), pRule( new SwNumRule( rRul
) )
240 SwUINumRuleItem::SwUINumRuleItem( const SwUINumRuleItem
& rItem
)
241 : SfxPoolItem( rItem
),
242 pRule( new SwNumRule( *rItem
.pRule
))
246 SwUINumRuleItem::~SwUINumRuleItem()
251 SfxPoolItem
* SwUINumRuleItem::Clone( SfxItemPool
* /*pPool*/ ) const
253 return new SwUINumRuleItem( *this );
256 int SwUINumRuleItem::operator==( const SfxPoolItem
& rAttr
) const
258 OSL_ENSURE( SfxPoolItem::operator==(rAttr
), "unequal types" );
259 return *pRule
== *((SwUINumRuleItem
&)rAttr
).pRule
;
262 bool SwUINumRuleItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
264 uno::Reference
< container::XIndexReplace
>xRules
= new SwXNumberingRules(*pRule
);
265 rVal
.setValue(&xRules
, ::getCppuType((uno::Reference
< container::XIndexReplace
>*)0));
268 bool SwUINumRuleItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
270 uno::Reference
< container::XIndexReplace
> xRulesRef
;
271 if(rVal
>>= xRulesRef
)
273 uno::Reference
< lang::XUnoTunnel
> xTunnel(xRulesRef
, uno::UNO_QUERY
);
274 SwXNumberingRules
* pSwXRules
= xTunnel
.is() ? reinterpret_cast<SwXNumberingRules
*>(
275 xTunnel
->getSomething(SwXNumberingRules::getUnoTunnelId())) : 0;
278 *pRule
= *pSwXRules
->GetNumRule();
284 SwBackgroundDestinationItem::SwBackgroundDestinationItem(sal_uInt16 _nWhich
, sal_uInt16 nValue
) :
285 SfxUInt16Item(_nWhich
, nValue
)
289 SfxPoolItem
* SwBackgroundDestinationItem::Clone( SfxItemPool
* /*pPool*/ ) const
291 return new SwBackgroundDestinationItem(Which(), GetValue());
294 SwPaMItem::SwPaMItem( const sal_uInt16 nId
, SwPaM
* pPaM
) :
300 SwPaMItem::SwPaMItem( const SwPaMItem
& rItem
) : SfxPoolItem( rItem
)
302 m_pPaM
= rItem
.m_pPaM
;
305 SfxPoolItem
* SwPaMItem::Clone( SfxItemPool
* /*pPool*/ ) const
307 return new SwPaMItem( *this );
310 int SwPaMItem::operator==( const SfxPoolItem
& rAttr
) const
312 OSL_ENSURE( SfxPoolItem::operator==(rAttr
), "unequal types" );
313 const SwPaMItem
& rItem
= (SwPaMItem
&)rAttr
;
314 return ( m_pPaM
== rItem
.m_pPaM
);
317 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */