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 <comphelper/servicehelper.hxx>
21 #include <editeng/itemtype.hxx>
22 #include <tools/UnitConversion.hxx>
23 #include <unosett.hxx>
25 #include <swtypes.hxx>
27 #include <uiitems.hxx>
29 #include <strings.hrc>
31 #include <numrule.hxx>
33 #include <editeng/eerdll.hxx>
35 using namespace ::com::sun::star
;
36 using namespace ::com::sun::star::uno
;
38 SwPageFootnoteInfoItem::SwPageFootnoteInfoItem( SwPageFootnoteInfo
const & rInfo
) :
39 SfxPoolItem( FN_PARAM_FTN_INFO
),
40 m_aFootnoteInfo(rInfo
)
44 SwPageFootnoteInfoItem::~SwPageFootnoteInfoItem()
48 SwPageFootnoteInfoItem
* SwPageFootnoteInfoItem::Clone( SfxItemPool
* /*pPool*/ ) const
50 return new SwPageFootnoteInfoItem( *this );
53 bool SwPageFootnoteInfoItem::operator==( const SfxPoolItem
& rAttr
) const
55 return SfxPoolItem::operator==(rAttr
)
56 && m_aFootnoteInfo
== static_cast<const SwPageFootnoteInfoItem
&>(rAttr
).m_aFootnoteInfo
;
59 bool SwPageFootnoteInfoItem::GetPresentation
61 SfxItemPresentation
/*ePres*/,
65 const IntlWrapper
& rIntl
68 const SwTwips nHght
= GetPageFootnoteInfo().GetHeight();
71 rText
= SwResId( STR_MAX_FTN_HEIGHT
) + " " +
72 ::GetMetricText( nHght
, eCoreUnit
, ePresUnit
, &rIntl
) + " " +
73 EditResId( ::GetMetricId( ePresUnit
) );
78 bool SwPageFootnoteInfoItem::QueryValue( Any
& rVal
, sal_uInt8 nMemberId
) const
81 switch(nMemberId
& ~CONVERT_TWIPS
)
83 case MID_FTN_HEIGHT
: rVal
<<= static_cast<sal_Int32
>(convertTwipToMm100(m_aFootnoteInfo
.GetHeight()));break;
84 case MID_LINE_WEIGHT
: rVal
<<= static_cast<sal_Int16
>(convertTwipToMm100(m_aFootnoteInfo
.GetLineWidth()));break;
85 case MID_LINE_COLOR
: rVal
<<= m_aFootnoteInfo
.GetLineColor();break;
86 case MID_LINE_RELWIDTH
:
88 Fraction
aTmp( 100, 1 );
89 aTmp
*= m_aFootnoteInfo
.GetWidth();
90 rVal
<<= static_cast<sal_Int8
>(static_cast<tools::Long
>(aTmp
));
93 case MID_LINE_ADJUST
: rVal
<<= static_cast<sal_Int16
>(m_aFootnoteInfo
.GetAdj());break;//text::HorizontalAdjust
94 case MID_LINE_TEXT_DIST
: rVal
<<= static_cast<sal_Int32
>(convertTwipToMm100(m_aFootnoteInfo
.GetTopDist()));break;
95 case MID_LINE_FOOTNOTE_DIST
: rVal
<<= static_cast<sal_Int32
>(convertTwipToMm100(m_aFootnoteInfo
.GetBottomDist()));break;
96 case MID_FTN_LINE_STYLE
:
98 switch ( m_aFootnoteInfo
.GetLineStyle( ) )
101 case SvxBorderLineStyle::NONE
: rVal
<<= sal_Int8(0); break;
102 case SvxBorderLineStyle::SOLID
: rVal
<<= sal_Int8(1); break;
103 case SvxBorderLineStyle::DOTTED
: rVal
<<= sal_Int8(2); break;
104 case SvxBorderLineStyle::DASHED
: rVal
<<= sal_Int8(3); break;
114 bool SwPageFootnoteInfoItem::PutValue(const Any
& rVal
, sal_uInt8 nMemberId
)
116 sal_Int32 nSet32
= 0;
119 switch(nMemberId
& ~CONVERT_TWIPS
)
121 case MID_LINE_COLOR
:
123 m_aFootnoteInfo
.SetLineColor(aColor
);
126 case MID_LINE_TEXT_DIST
:
127 case MID_LINE_FOOTNOTE_DIST
:
133 nSet32
= o3tl::toTwips(nSet32
, o3tl::Length::mm100
);
134 switch(nMemberId
& ~CONVERT_TWIPS
)
136 case MID_FTN_HEIGHT
: m_aFootnoteInfo
.SetHeight(nSet32
); break;
137 case MID_LINE_TEXT_DIST
: m_aFootnoteInfo
.SetTopDist(nSet32
);break;
138 case MID_LINE_FOOTNOTE_DIST
: m_aFootnoteInfo
.SetBottomDist(nSet32
);break;
142 case MID_LINE_WEIGHT
:
147 m_aFootnoteInfo
.SetLineWidth(o3tl::toTwips(nSet
, o3tl::Length::mm100
));
152 case MID_LINE_RELWIDTH
:
159 m_aFootnoteInfo
.SetWidth(Fraction(nSet
, 100));
162 case MID_LINE_ADJUST
:
166 if(nSet
>= 0 && nSet
< 3) //text::HorizontalAdjust
167 m_aFootnoteInfo
.SetAdj(static_cast<css::text::HorizontalAdjust
>(nSet
));
172 case MID_FTN_LINE_STYLE
:
174 SvxBorderLineStyle eStyle
= SvxBorderLineStyle::NONE
;
179 case 1: eStyle
= SvxBorderLineStyle::SOLID
; break;
180 case 2: eStyle
= SvxBorderLineStyle::DOTTED
; break;
181 case 3: eStyle
= SvxBorderLineStyle::DASHED
; break;
184 m_aFootnoteInfo
.SetLineStyle( eStyle
);
193 SwPtrItem::SwPtrItem( const sal_uInt16 nId
, void* pPtr
) :
201 SwPtrItem
* SwPtrItem::Clone( SfxItemPool
* /*pPool*/ ) const
203 return new SwPtrItem( *this );
206 bool SwPtrItem::operator==( const SfxPoolItem
& rAttr
) const
208 return SfxPoolItem::operator==(rAttr
)
209 && m_pMisc
== static_cast<const SwPtrItem
&>(rAttr
).m_pMisc
;
212 // SwUINumRuleItem for the NumTabPages of the FormatNumRule/Styleists
214 SwUINumRuleItem::SwUINumRuleItem( const SwNumRule
& rRul
)
215 : SfxPoolItem( FN_PARAM_ACT_NUMBER
), m_pRule( new SwNumRule( rRul
) )
219 SwUINumRuleItem::SwUINumRuleItem( const SwUINumRuleItem
& rItem
)
220 : SfxPoolItem( rItem
),
221 m_pRule( new SwNumRule( *rItem
.m_pRule
))
225 SwUINumRuleItem::~SwUINumRuleItem()
229 SwUINumRuleItem
* SwUINumRuleItem::Clone( SfxItemPool
* /*pPool*/ ) const
231 return new SwUINumRuleItem( *this );
234 bool SwUINumRuleItem::operator==( const SfxPoolItem
& rAttr
) const
236 return SfxPoolItem::operator==(rAttr
)
237 && *m_pRule
== *static_cast<const SwUINumRuleItem
&>(rAttr
).m_pRule
;
240 bool SwUINumRuleItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
242 uno::Reference
< container::XIndexReplace
>xRules
= new SwXNumberingRules(*m_pRule
);
246 bool SwUINumRuleItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
248 uno::Reference
< container::XIndexReplace
> xRulesRef
;
249 if(rVal
>>= xRulesRef
)
251 auto pSwXRules
= dynamic_cast<SwXNumberingRules
*>(xRulesRef
.get());
254 *m_pRule
= *pSwXRules
->GetNumRule();
260 SwPaMItem::SwPaMItem( const sal_uInt16 nId
, SwPaM
* pPaM
) :
266 SwPaMItem
* SwPaMItem::Clone( SfxItemPool
* /*pPool*/ ) const
268 return new SwPaMItem( *this );
271 bool SwPaMItem::operator==( const SfxPoolItem
& rAttr
) const
273 return SfxPoolItem::operator==(rAttr
)
274 && m_pPaM
== static_cast<const SwPaMItem
&>(rAttr
).m_pPaM
;
277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */