LibreOffice Module sw (master) 1
uiitems.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21#include <editeng/itemtype.hxx>
23#include <unosett.hxx>
24
25#include <swtypes.hxx>
26#include <cmdid.h>
27#include <uiitems.hxx>
28
29#include <strings.hrc>
30#include <unomid.h>
31#include <numrule.hxx>
32
33#include <editeng/eerdll.hxx>
34
35using namespace ::com::sun::star;
36using namespace ::com::sun::star::uno;
37
40 m_aFootnoteInfo(rInfo)
41{
42}
43
45{
46}
47
49{
50 return new SwPageFootnoteInfoItem( *this );
51}
52
54{
55 return SfxPoolItem::operator==(rAttr)
56 && m_aFootnoteInfo == static_cast<const SwPageFootnoteInfoItem&>(rAttr).m_aFootnoteInfo;
57}
58
60(
61 SfxItemPresentation /*ePres*/,
62 MapUnit eCoreUnit,
63 MapUnit ePresUnit,
64 OUString& rText,
65 const IntlWrapper& rIntl
66) const
67{
68 const SwTwips nHght = GetPageFootnoteInfo().GetHeight();
69 if ( nHght )
70 {
71 rText = SwResId( STR_MAX_FTN_HEIGHT ) + " " +
72 ::GetMetricText( nHght, eCoreUnit, ePresUnit, &rIntl ) + " " +
73 EditResId( ::GetMetricId( ePresUnit ) );
74 }
75 return true;
76}
77
78bool SwPageFootnoteInfoItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
79{
80 bool bRet = true;
81 switch(nMemberId & ~CONVERT_TWIPS)
82 {
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;
87 {
88 Fraction aTmp( 100, 1 );
89 aTmp *= m_aFootnoteInfo.GetWidth();
90 rVal <<= static_cast<sal_Int8>(static_cast<tools::Long>(aTmp));
91 }
92 break;
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;
97 {
98 switch ( m_aFootnoteInfo.GetLineStyle( ) )
99 {
100 default:
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;
105 }
106 break;
107 }
108 default:
109 bRet = false;
110 }
111 return bRet;
112}
113
114bool SwPageFootnoteInfoItem::PutValue(const Any& rVal, sal_uInt8 nMemberId)
115{
116 sal_Int32 nSet32 = 0;
117 Color aColor;
118 bool bRet = true;
119 switch(nMemberId & ~CONVERT_TWIPS)
120 {
121 case MID_LINE_COLOR :
122 rVal >>= aColor;
124 break;
125 case MID_FTN_HEIGHT:
126 case MID_LINE_TEXT_DIST :
128 rVal >>= nSet32;
129 if(nSet32 < 0)
130 bRet = false;
131 else
132 {
133 nSet32 = o3tl::toTwips(nSet32, o3tl::Length::mm100);
134 switch(nMemberId & ~CONVERT_TWIPS)
135 {
136 case MID_FTN_HEIGHT: m_aFootnoteInfo.SetHeight(nSet32); break;
139 }
140 }
141 break;
142 case MID_LINE_WEIGHT :
143 {
144 sal_Int16 nSet = 0;
145 rVal >>= nSet;
146 if(nSet >= 0)
148 else
149 bRet = false;
150 }
151 break;
152 case MID_LINE_RELWIDTH :
153 {
154 sal_Int8 nSet = 0;
155 rVal >>= nSet;
156 if(nSet < 0)
157 bRet = false;
158 else
160 }
161 break;
162 case MID_LINE_ADJUST :
163 {
164 sal_Int16 nSet = 0;
165 rVal >>= nSet;
166 if(nSet >= 0 && nSet < 3) //text::HorizontalAdjust
167 m_aFootnoteInfo.SetAdj(static_cast<css::text::HorizontalAdjust>(nSet));
168 else
169 bRet = false;
170 }
171 break;
173 {
174 SvxBorderLineStyle eStyle = SvxBorderLineStyle::NONE;
175 sal_Int8 nSet = 0;
176 rVal >>= nSet;
177 switch ( nSet )
178 {
179 case 1: eStyle = SvxBorderLineStyle::SOLID; break;
180 case 2: eStyle = SvxBorderLineStyle::DOTTED; break;
181 case 3: eStyle = SvxBorderLineStyle::DASHED; break;
182 default: break;
183 }
185 }
186 break;
187 default:
188 bRet = false;
189 }
190 return bRet;
191}
192
193SwPtrItem::SwPtrItem( const sal_uInt16 nId, void* pPtr ) :
194 SfxPoolItem( nId ),
195 m_pMisc(pPtr)
196{
197}
198
199// Cloning
200
202{
203 return new SwPtrItem( *this );
204}
205
206bool SwPtrItem::operator==( const SfxPoolItem& rAttr ) const
207{
208 return SfxPoolItem::operator==(rAttr)
209 && m_pMisc == static_cast<const SwPtrItem&>(rAttr).m_pMisc;
210}
211
212// SwUINumRuleItem for the NumTabPages of the FormatNumRule/Styleists
213
215 : SfxPoolItem( FN_PARAM_ACT_NUMBER ), m_pRule( new SwNumRule( rRul ) )
216{
217}
218
220 : SfxPoolItem( rItem ),
221 m_pRule( new SwNumRule( *rItem.m_pRule ))
222{
223}
224
226{
227}
228
230{
231 return new SwUINumRuleItem( *this );
232}
233
234bool SwUINumRuleItem::operator==( const SfxPoolItem& rAttr ) const
235{
236 return SfxPoolItem::operator==(rAttr)
237 && *m_pRule == *static_cast<const SwUINumRuleItem&>(rAttr).m_pRule;
238}
239
240bool SwUINumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
241{
242 uno::Reference< container::XIndexReplace >xRules = new SwXNumberingRules(*m_pRule);
243 rVal <<= xRules;
244 return true;
245}
246bool SwUINumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
247{
248 uno::Reference< container::XIndexReplace> xRulesRef;
249 if(rVal >>= xRulesRef)
250 {
251 auto pSwXRules = comphelper::getFromUnoTunnel<SwXNumberingRules>(xRulesRef);
252 if(pSwXRules)
253 {
254 *m_pRule = *pSwXRules->GetNumRule();
255 }
256 }
257 return true;
258}
259
260SwPaMItem::SwPaMItem( const sal_uInt16 nId, SwPaM* pPaM ) :
261 SfxPoolItem( nId ),
262 m_pPaM(pPaM)
263{
264}
265
267{
268 return new SwPaMItem( *this );
269}
270
271bool SwPaMItem::operator==( const SfxPoolItem& rAttr ) const
272{
273 return SfxPoolItem::operator==(rAttr)
274 && m_pPaM == static_cast<const SwPaMItem&>(rAttr).m_pPaM;
275}
276
277/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr auto convertTwipToMm100(N n)
SvxBorderLineStyle
virtual bool operator==(const SfxPoolItem &) const=0
virtual SwPaMItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: uiitems.cxx:266
SwPaM * m_pPaM
Definition: uiitems.hxx:95
SwPaMItem(const sal_uInt16 nId, SwPaM *pPaM)
Definition: uiitems.cxx:260
virtual bool operator==(const SfxPoolItem &) const override
Definition: uiitems.cxx:271
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
SwPageFootnoteInfo & GetPageFootnoteInfo()
Definition: uiitems.hxx:57
virtual bool operator==(const SfxPoolItem &) const override
Definition: uiitems.cxx:53
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: uiitems.cxx:114
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: uiitems.cxx:78
SwPageFootnoteInfoItem(SwPageFootnoteInfo const &rInfo)
Definition: uiitems.cxx:38
SwPageFootnoteInfo m_aFootnoteInfo
Definition: uiitems.hxx:34
virtual SwPageFootnoteInfoItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: uiitems.cxx:48
virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText, const IntlWrapper &rIntl) const override
Definition: uiitems.cxx:60
virtual ~SwPageFootnoteInfoItem() override
Definition: uiitems.cxx:44
Footnote information.
Definition: pagedesc.hxx:49
SwTwips GetHeight() const
Definition: pagedesc.hxx:61
sal_uLong GetLineWidth() const
Definition: pagedesc.hxx:62
SwTwips GetTopDist() const
Definition: pagedesc.hxx:67
void SetBottomDist(SwTwips const nNew)
Definition: pagedesc.hxx:77
void SetWidth(const Fraction &rNew)
Definition: pagedesc.hxx:74
void SetLineWidth(sal_uLong const nSet)
Definition: pagedesc.hxx:71
css::text::HorizontalAdjust GetAdj() const
Definition: pagedesc.hxx:66
void SetLineStyle(SvxBorderLineStyle const eSet)
Definition: pagedesc.hxx:72
void SetAdj(css::text::HorizontalAdjust const eNew)
Definition: pagedesc.hxx:75
const Color & GetLineColor() const
Definition: pagedesc.hxx:63
void SetHeight(SwTwips const nNew)
Definition: pagedesc.hxx:70
void SetTopDist(SwTwips const nNew)
Definition: pagedesc.hxx:76
SwTwips GetBottomDist() const
Definition: pagedesc.hxx:68
void SetLineColor(const Color &rCol)
Definition: pagedesc.hxx:73
const Fraction & GetWidth() const
Definition: pagedesc.hxx:65
SvxBorderLineStyle GetLineStyle() const
Definition: pagedesc.hxx:64
SwPtrItem(const sal_uInt16 nId, void *pPtr)
Definition: uiitems.cxx:193
void * m_pMisc
Definition: uiitems.hxx:63
virtual SwPtrItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: uiitems.cxx:201
virtual bool operator==(const SfxPoolItem &) const override
Definition: uiitems.cxx:206
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: uiitems.cxx:246
virtual ~SwUINumRuleItem() override
Definition: uiitems.cxx:225
virtual SwUINumRuleItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: uiitems.cxx:229
std::unique_ptr< SwNumRule > m_pRule
Definition: uiitems.hxx:76
virtual bool operator==(const SfxPoolItem &) const override
Definition: uiitems.cxx:234
SwUINumRuleItem(const SwNumRule &rRule)
Definition: uiitems.cxx:214
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: uiitems.cxx:240
#define FN_PARAM_ACT_NUMBER
Definition: cmdid.h:817
#define FN_PARAM_FTN_INFO
Definition: cmdid.h:791
OUString EditResId(TranslateId aId)
MapUnit
constexpr auto toTwips(N number, Length from)
long Long
sal_Int16 nId
SfxItemPresentation
#define CONVERT_TWIPS
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
tools::Long SwTwips
Definition: swtypes.hxx:51
unsigned char sal_uInt8
signed char sal_Int8
#define MID_LINE_TEXT_DIST
Definition: unomid.h:108
#define MID_LINE_RELWIDTH
Definition: unomid.h:106
#define MID_LINE_ADJUST
Definition: unomid.h:107
#define MID_FTN_LINE_STYLE
Definition: unomid.h:110
#define MID_LINE_COLOR
Definition: unomid.h:105
#define MID_LINE_WEIGHT
Definition: unomid.h:104
#define MID_LINE_FOOTNOTE_DIST
Definition: unomid.h:109
#define MID_FTN_HEIGHT
Definition: unomid.h:103