/src/libreoffice/sw/source/uibase/utlui/uiitems.cxx
Line | Count | Source |
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 | | |
20 | | #include <comphelper/servicehelper.hxx> |
21 | | #include <editeng/itemtype.hxx> |
22 | | #include <tools/UnitConversion.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 | | |
35 | | using namespace ::com::sun::star; |
36 | | using namespace ::com::sun::star::uno; |
37 | | |
38 | | SwPageFootnoteInfoItem::SwPageFootnoteInfoItem( SwPageFootnoteInfo const & rInfo) : |
39 | 248k | SfxPoolItem( FN_PARAM_FTN_INFO ), |
40 | 248k | m_aFootnoteInfo(rInfo) |
41 | 248k | { |
42 | 248k | } |
43 | | |
44 | | SwPageFootnoteInfoItem::~SwPageFootnoteInfoItem() |
45 | 886k | { |
46 | 886k | } |
47 | | |
48 | | SwPageFootnoteInfoItem* SwPageFootnoteInfoItem::Clone( SfxItemPool * /*pPool*/ ) const |
49 | 638k | { |
50 | 638k | return new SwPageFootnoteInfoItem( *this ); |
51 | 638k | } |
52 | | |
53 | | bool SwPageFootnoteInfoItem::operator==( const SfxPoolItem& rAttr ) const |
54 | 28.8k | { |
55 | 28.8k | return SfxPoolItem::operator==(rAttr) |
56 | 28.8k | && m_aFootnoteInfo == static_cast<const SwPageFootnoteInfoItem&>(rAttr).m_aFootnoteInfo; |
57 | 28.8k | } |
58 | | |
59 | | bool SwPageFootnoteInfoItem::GetPresentation |
60 | | ( |
61 | | SfxItemPresentation /*ePres*/, |
62 | | MapUnit eCoreUnit, |
63 | | MapUnit ePresUnit, |
64 | | OUString& rText, |
65 | | const IntlWrapper& rIntl |
66 | | ) const |
67 | 0 | { |
68 | 0 | const SwTwips nHght = GetPageFootnoteInfo().GetHeight().as_twip<SwTwips>(); |
69 | 0 | if ( nHght ) |
70 | 0 | { |
71 | 0 | rText = SwResId( STR_MAX_FTN_HEIGHT ) + " " + |
72 | 0 | ::GetMetricText( nHght, eCoreUnit, ePresUnit, &rIntl ) + " " + |
73 | 0 | EditResId( ::GetMetricId( ePresUnit ) ); |
74 | 0 | } |
75 | 0 | return true; |
76 | 0 | } |
77 | | |
78 | | bool SwPageFootnoteInfoItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const |
79 | 608 | { |
80 | 608 | bool bRet = true; |
81 | 608 | switch(nMemberId & ~CONVERT_TWIPS) |
82 | 608 | { |
83 | 76 | case MID_FTN_HEIGHT: rVal <<= m_aFootnoteInfo.GetHeight().as_hmm<sal_Int32>(); break; |
84 | 76 | case MID_LINE_WEIGHT : rVal <<= static_cast<sal_Int16>(convertTwipToMm100(m_aFootnoteInfo.GetLineWidth()));break; |
85 | 76 | case MID_LINE_COLOR : rVal <<= m_aFootnoteInfo.GetLineColor();break; |
86 | 76 | case MID_LINE_RELWIDTH : |
87 | 76 | { |
88 | 76 | auto nTmp = std::round(m_aFootnoteInfo.GetWidth() * 100); |
89 | 76 | rVal <<= static_cast<sal_Int8>(nTmp); |
90 | 76 | } |
91 | 76 | break; |
92 | 76 | case MID_LINE_ADJUST : rVal <<= static_cast<sal_Int16>(m_aFootnoteInfo.GetAdj());break;//text::HorizontalAdjust |
93 | 76 | case MID_LINE_TEXT_DIST: rVal <<= m_aFootnoteInfo.GetTopDist().as_hmm<sal_Int32>(); break; |
94 | 76 | case MID_LINE_FOOTNOTE_DIST: rVal <<= m_aFootnoteInfo.GetBottomDist().as_hmm<sal_Int32>(); break; |
95 | 76 | case MID_FTN_LINE_STYLE : |
96 | 76 | { |
97 | 76 | switch ( m_aFootnoteInfo.GetLineStyle( ) ) |
98 | 76 | { |
99 | 0 | default: |
100 | 0 | case SvxBorderLineStyle::NONE : rVal <<= sal_Int8(0); break; |
101 | 76 | case SvxBorderLineStyle::SOLID: rVal <<= sal_Int8(1); break; |
102 | 0 | case SvxBorderLineStyle::DOTTED: rVal <<= sal_Int8(2); break; |
103 | 0 | case SvxBorderLineStyle::DASHED: rVal <<= sal_Int8(3); break; |
104 | 76 | } |
105 | 76 | break; |
106 | 76 | } |
107 | 76 | default: |
108 | 0 | bRet = false; |
109 | 608 | } |
110 | 608 | return bRet; |
111 | 608 | } |
112 | | |
113 | | bool SwPageFootnoteInfoItem::PutValue(const Any& rVal, sal_uInt8 nMemberId) |
114 | 16.5k | { |
115 | 16.5k | sal_Int32 nSet32 = 0; |
116 | 16.5k | Color aColor; |
117 | 16.5k | bool bRet = true; |
118 | 16.5k | switch(nMemberId & ~CONVERT_TWIPS) |
119 | 16.5k | { |
120 | 2.02k | case MID_LINE_COLOR : |
121 | 2.02k | rVal >>= aColor; |
122 | 2.02k | m_aFootnoteInfo.SetLineColor(aColor); |
123 | 2.02k | break; |
124 | 2.26k | case MID_FTN_HEIGHT: |
125 | 4.28k | case MID_LINE_TEXT_DIST : |
126 | 6.31k | case MID_LINE_FOOTNOTE_DIST: |
127 | 6.31k | rVal >>= nSet32; |
128 | 6.31k | if(nSet32 < 0) |
129 | 0 | bRet = false; |
130 | 6.31k | else |
131 | 6.31k | { |
132 | 6.31k | switch (nMemberId & ~CONVERT_TWIPS) |
133 | 6.31k | { |
134 | 2.26k | case MID_FTN_HEIGHT: m_aFootnoteInfo.SetHeight(gfx::Length::hmm(nSet32)); break; |
135 | 2.02k | case MID_LINE_TEXT_DIST: m_aFootnoteInfo.SetTopDist(gfx::Length::hmm(nSet32)); break; |
136 | 2.02k | case MID_LINE_FOOTNOTE_DIST: m_aFootnoteInfo.SetBottomDist(gfx::Length::hmm(nSet32)); break; |
137 | 6.31k | } |
138 | 6.31k | } |
139 | 6.31k | break; |
140 | 6.31k | case MID_LINE_WEIGHT : |
141 | 2.02k | { |
142 | 2.02k | sal_Int16 nSet = 0; |
143 | 2.02k | rVal >>= nSet; |
144 | 2.02k | if(nSet >= 0) |
145 | 1.96k | m_aFootnoteInfo.SetLineWidth(o3tl::toTwips(nSet, o3tl::Length::mm100)); |
146 | 52 | else |
147 | 52 | bRet = false; |
148 | 2.02k | } |
149 | 2.02k | break; |
150 | 2.14k | case MID_LINE_RELWIDTH : |
151 | 2.14k | { |
152 | 2.14k | sal_Int8 nSet = 0; |
153 | 2.14k | rVal >>= nSet; |
154 | 2.14k | if(nSet < 0) |
155 | 16 | bRet = false; |
156 | 2.12k | else |
157 | 2.12k | m_aFootnoteInfo.SetWidth(double(nSet) / 100); |
158 | 2.14k | } |
159 | 2.14k | break; |
160 | 2.06k | case MID_LINE_ADJUST : |
161 | 2.06k | { |
162 | 2.06k | sal_Int16 nSet = 0; |
163 | 2.06k | rVal >>= nSet; |
164 | 2.06k | if(nSet >= 0 && nSet < 3) //text::HorizontalAdjust |
165 | 2.06k | m_aFootnoteInfo.SetAdj(static_cast<css::text::HorizontalAdjust>(nSet)); |
166 | 0 | else |
167 | 0 | bRet = false; |
168 | 2.06k | } |
169 | 2.06k | break; |
170 | 2.02k | case MID_FTN_LINE_STYLE: |
171 | 2.02k | { |
172 | 2.02k | SvxBorderLineStyle eStyle = SvxBorderLineStyle::NONE; |
173 | 2.02k | sal_Int8 nSet = 0; |
174 | 2.02k | rVal >>= nSet; |
175 | 2.02k | switch ( nSet ) |
176 | 2.02k | { |
177 | 1.47k | case 1: eStyle = SvxBorderLineStyle::SOLID; break; |
178 | 0 | case 2: eStyle = SvxBorderLineStyle::DOTTED; break; |
179 | 0 | case 3: eStyle = SvxBorderLineStyle::DASHED; break; |
180 | 546 | default: break; |
181 | 2.02k | } |
182 | 2.02k | m_aFootnoteInfo.SetLineStyle( eStyle ); |
183 | 2.02k | } |
184 | 0 | break; |
185 | 0 | default: |
186 | 0 | bRet = false; |
187 | 16.5k | } |
188 | 16.5k | return bRet; |
189 | 16.5k | } |
190 | | |
191 | | SwPtrItem::SwPtrItem( const sal_uInt16 nId, void* pPtr ) : |
192 | 0 | SfxPoolItem( nId ), |
193 | 0 | m_pMisc(pPtr) |
194 | 0 | { |
195 | 0 | } |
196 | | |
197 | | // Cloning |
198 | | |
199 | | SwPtrItem* SwPtrItem::Clone( SfxItemPool * /*pPool*/ ) const |
200 | 0 | { |
201 | 0 | return new SwPtrItem( *this ); |
202 | 0 | } |
203 | | |
204 | | bool SwPtrItem::operator==( const SfxPoolItem& rAttr ) const |
205 | 0 | { |
206 | 0 | return SfxPoolItem::operator==(rAttr) |
207 | 0 | && m_pMisc == static_cast<const SwPtrItem&>(rAttr).m_pMisc; |
208 | 0 | } |
209 | | |
210 | | // SwUINumRuleItem for the NumTabPages of the FormatNumRule/Styleists |
211 | | |
212 | | SwUINumRuleItem::SwUINumRuleItem( const SwNumRule& rRul ) |
213 | 0 | : SfxPoolItem( FN_PARAM_ACT_NUMBER ) |
214 | 0 | , m_pRule( new SwNumRule( rRul ) ) |
215 | 0 | { |
216 | 0 | } |
217 | | |
218 | | SwUINumRuleItem::SwUINumRuleItem( const SwUINumRuleItem& rItem ) |
219 | 0 | : SfxPoolItem( rItem ), |
220 | 0 | m_pRule( new SwNumRule( *rItem.m_pRule )) |
221 | 0 | { |
222 | 0 | } |
223 | | |
224 | | SwUINumRuleItem::~SwUINumRuleItem() |
225 | 0 | { |
226 | 0 | } |
227 | | |
228 | | SwUINumRuleItem* SwUINumRuleItem::Clone( SfxItemPool * /*pPool*/ ) const |
229 | 0 | { |
230 | 0 | return new SwUINumRuleItem( *this ); |
231 | 0 | } |
232 | | |
233 | | bool SwUINumRuleItem::operator==( const SfxPoolItem& rAttr ) const |
234 | 0 | { |
235 | 0 | return SfxPoolItem::operator==(rAttr) |
236 | 0 | && *m_pRule == *static_cast<const SwUINumRuleItem&>(rAttr).m_pRule; |
237 | 0 | } |
238 | | |
239 | | bool SwUINumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const |
240 | 0 | { |
241 | 0 | uno::Reference< container::XIndexReplace >xRules = new SwXNumberingRules(*m_pRule); |
242 | 0 | rVal <<= xRules; |
243 | 0 | return true; |
244 | 0 | } |
245 | | bool SwUINumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) |
246 | 0 | { |
247 | 0 | uno::Reference< container::XIndexReplace> xRulesRef; |
248 | 0 | if(rVal >>= xRulesRef) |
249 | 0 | { |
250 | 0 | auto pSwXRules = dynamic_cast<SwXNumberingRules*>(xRulesRef.get()); |
251 | 0 | if(pSwXRules) |
252 | 0 | { |
253 | 0 | *m_pRule = *pSwXRules->GetNumRule(); |
254 | 0 | } |
255 | 0 | } |
256 | 0 | return true; |
257 | 0 | } |
258 | | |
259 | | SwPaMItem::SwPaMItem( const sal_uInt16 nId, SwPaM* pPaM ) : |
260 | 0 | SfxPoolItem( nId ), |
261 | 0 | m_pPaM(pPaM) |
262 | 0 | { |
263 | 0 | } |
264 | | |
265 | | SwPaMItem* SwPaMItem::Clone( SfxItemPool * /*pPool*/ ) const |
266 | 0 | { |
267 | 0 | return new SwPaMItem( *this ); |
268 | 0 | } |
269 | | |
270 | | bool SwPaMItem::operator==( const SfxPoolItem& rAttr ) const |
271 | 0 | { |
272 | 0 | return SfxPoolItem::operator==(rAttr) |
273 | 0 | && m_pPaM == static_cast<const SwPaMItem&>(rAttr).m_pPaM; |
274 | 0 | } |
275 | | |
276 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |