/src/libreoffice/editeng/source/items/textitem.cxx
Line | Count | Source (jump to first uncovered line) |
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 <com/sun/star/style/CaseMap.hpp> |
21 | | #include <com/sun/star/awt/FontDescriptor.hpp> |
22 | | #include <com/sun/star/frame/status/FontHeight.hpp> |
23 | | #include <math.h> |
24 | | #include <sal/log.hxx> |
25 | | #include <o3tl/safeint.hxx> |
26 | | #include <osl/diagnose.h> |
27 | | #include <comphelper/configuration.hxx> |
28 | | #include <unotools/fontdefs.hxx> |
29 | | #include <unotools/intlwrapper.hxx> |
30 | | #include <unotools/syslocale.hxx> |
31 | | #include <utility> |
32 | | #include <vcl/outdev.hxx> |
33 | | #include <vcl/unohelp.hxx> |
34 | | #include <svtools/unitconv.hxx> |
35 | | |
36 | | #include <editeng/editids.hrc> |
37 | | #include <editeng/editrids.hrc> |
38 | | #include <tools/bigint.hxx> |
39 | | #include <tools/mapunit.hxx> |
40 | | #include <tools/UnitConversion.hxx> |
41 | | |
42 | | #include <rtl/math.hxx> |
43 | | #include <rtl/ustring.hxx> |
44 | | #include <i18nlangtag/languagetag.hxx> |
45 | | #include <svl/itemset.hxx> |
46 | | |
47 | | #include <svtools/langtab.hxx> |
48 | | #include <svl/itempool.hxx> |
49 | | #include <svtools/ctrltool.hxx> |
50 | | #include <com/sun/star/awt/FontSlant.hpp> |
51 | | #include <com/sun/star/lang/Locale.hpp> |
52 | | #include <com/sun/star/text/FontEmphasis.hpp> |
53 | | #include <editeng/rsiditem.hxx> |
54 | | #include <editeng/memberids.h> |
55 | | #include <editeng/flstitem.hxx> |
56 | | #include <editeng/fontitem.hxx> |
57 | | #include <editeng/postitem.hxx> |
58 | | #include <editeng/wghtitem.hxx> |
59 | | #include <editeng/fhgtitem.hxx> |
60 | | #include <editeng/udlnitem.hxx> |
61 | | #include <editeng/crossedoutitem.hxx> |
62 | | #include <editeng/shdditem.hxx> |
63 | | #include <editeng/autokernitem.hxx> |
64 | | #include <editeng/wrlmitem.hxx> |
65 | | #include <editeng/contouritem.hxx> |
66 | | #include <editeng/colritem.hxx> |
67 | | #include <editeng/kernitem.hxx> |
68 | | #include <editeng/cmapitem.hxx> |
69 | | #include <editeng/escapementitem.hxx> |
70 | | #include <editeng/langitem.hxx> |
71 | | #include <editeng/nhypitem.hxx> |
72 | | #include <editeng/blinkitem.hxx> |
73 | | #include <editeng/emphasismarkitem.hxx> |
74 | | #include <editeng/twolinesitem.hxx> |
75 | | #include <editeng/scriptsetitem.hxx> |
76 | | #include <editeng/charrotateitem.hxx> |
77 | | #include <editeng/charscaleitem.hxx> |
78 | | #include <editeng/charreliefitem.hxx> |
79 | | #include <editeng/rubyitem.hxx> |
80 | | #include <editeng/itemtype.hxx> |
81 | | #include <editeng/scripthintitem.hxx> |
82 | | #include <editeng/eerdll.hxx> |
83 | | #include <docmodel/color/ComplexColorJSON.hxx> |
84 | | #include <docmodel/uno/UnoComplexColor.hxx> |
85 | | #include <docmodel/color/ComplexColor.hxx> |
86 | | #include <libxml/xmlwriter.h> |
87 | | #include <unordered_map> |
88 | | |
89 | | using namespace ::com::sun::star; |
90 | | using namespace ::com::sun::star::text; |
91 | | |
92 | 0 | SfxPoolItem* SvxFontItem::CreateDefault() {return new SvxFontItem(0);} |
93 | 0 | SfxPoolItem* SvxPostureItem::CreateDefault() { return new SvxPostureItem(ITALIC_NONE, 0);} |
94 | 0 | SfxPoolItem* SvxWeightItem::CreateDefault() {return new SvxWeightItem(WEIGHT_NORMAL, 0);} |
95 | 0 | SfxPoolItem* SvxFontHeightItem::CreateDefault() {return new SvxFontHeightItem(240, 100, 0);} |
96 | 0 | SfxPoolItem* SvxUnderlineItem::CreateDefault() {return new SvxUnderlineItem(LINESTYLE_NONE, 0);} |
97 | 0 | SfxPoolItem* SvxOverlineItem::CreateDefault() {return new SvxOverlineItem(LINESTYLE_NONE, 0);} |
98 | 0 | SfxPoolItem* SvxCrossedOutItem::CreateDefault() {return new SvxCrossedOutItem(STRIKEOUT_NONE, 0);} |
99 | 0 | SfxPoolItem* SvxShadowedItem::CreateDefault() {return new SvxShadowedItem(false, 0);} |
100 | 0 | SfxPoolItem* SvxAutoKernItem::CreateDefault() {return new SvxAutoKernItem(false, 0);} |
101 | 0 | SfxPoolItem* SvxWordLineModeItem::CreateDefault() {return new SvxWordLineModeItem(false, 0);} |
102 | 0 | SfxPoolItem* SvxContourItem::CreateDefault() {return new SvxContourItem(false, 0);} |
103 | 0 | SfxPoolItem* SvxColorItem::CreateDefault() {return new SvxColorItem(0);} |
104 | 0 | SfxPoolItem* SvxKerningItem::CreateDefault() {return new SvxKerningItem(0, 0);} |
105 | 0 | SfxPoolItem* SvxCaseMapItem::CreateDefault() {return new SvxCaseMapItem(SvxCaseMap::NotMapped, 0);} |
106 | 0 | SfxPoolItem* SvxEscapementItem::CreateDefault() {return new SvxEscapementItem(0);} |
107 | 0 | SfxPoolItem* SvxLanguageItem::CreateDefault() {return new SvxLanguageItem(LANGUAGE_GERMAN, 0);} |
108 | 0 | SfxPoolItem* SvxEmphasisMarkItem::CreateDefault() {return new SvxEmphasisMarkItem(FontEmphasisMark::NONE, TypedWhichId<SvxEmphasisMarkItem>(0));} |
109 | 0 | SfxPoolItem* SvxCharRotateItem::CreateDefault() {return new SvxCharRotateItem(0_deg10, false, TypedWhichId<SvxCharRotateItem>(0));} |
110 | 0 | SfxPoolItem* SvxCharScaleWidthItem::CreateDefault() {return new SvxCharScaleWidthItem(100, TypedWhichId<SvxCharScaleWidthItem>(0));} |
111 | 0 | SfxPoolItem* SvxCharReliefItem::CreateDefault() {return new SvxCharReliefItem(FontRelief::NONE, 0);} |
112 | | |
113 | | // class SvxFontListItem ------------------------------------------------- |
114 | | |
115 | | SvxFontListItem::SvxFontListItem( const FontList* pFontLst, |
116 | | const sal_uInt16 nId ) : |
117 | 226k | SfxPoolItem( nId ), |
118 | 226k | pFontList( pFontLst ) |
119 | 226k | { |
120 | 226k | if ( pFontList ) |
121 | 226k | { |
122 | 226k | sal_Int32 nCount = pFontList->GetFontNameCount(); |
123 | 226k | aFontNameSeq.realloc( nCount ); |
124 | 226k | auto pFontNameSeq = aFontNameSeq.getArray(); |
125 | | |
126 | 904k | for ( sal_Int32 i = 0; i < nCount; i++ ) |
127 | 678k | pFontNameSeq[i] = pFontList->GetFontName(i).GetFamilyName(); |
128 | 226k | } |
129 | 226k | } |
130 | | |
131 | | SvxFontListItem* SvxFontListItem::Clone( SfxItemPool* ) const |
132 | 226k | { |
133 | 226k | return new SvxFontListItem( *this ); |
134 | 226k | } |
135 | | |
136 | | bool SvxFontListItem::operator==( const SfxPoolItem& rAttr ) const |
137 | 0 | { |
138 | 0 | assert(SfxPoolItem::operator==(rAttr)); |
139 | |
|
140 | 0 | return( pFontList == static_cast<const SvxFontListItem&>(rAttr).pFontList ); |
141 | 0 | } |
142 | | |
143 | | bool SvxFontListItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const |
144 | 0 | { |
145 | 0 | rVal <<= aFontNameSeq; |
146 | 0 | return true; |
147 | 0 | } |
148 | | |
149 | | |
150 | | bool SvxFontListItem::GetPresentation |
151 | | ( |
152 | | SfxItemPresentation /*ePres*/, |
153 | | MapUnit /*eCoreUnit*/, |
154 | | MapUnit /*ePresUnit*/, |
155 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
156 | | ) const |
157 | 0 | { |
158 | 0 | rText.clear(); |
159 | 0 | return false; |
160 | 0 | } |
161 | | |
162 | | // class SvxFontItem ----------------------------------------------------- |
163 | | |
164 | | ItemInstanceManager* SvxFontItem::getItemInstanceManager() const |
165 | 10.2M | { |
166 | 10.2M | static HashedItemInstanceManager aInstanceManager(ItemType()); |
167 | 10.2M | return &aInstanceManager; |
168 | 10.2M | } |
169 | | |
170 | | size_t SvxFontItem::hashCode() const |
171 | 12.0M | { |
172 | 12.0M | std::size_t seed(0); |
173 | 12.0M | o3tl::hash_combine(seed, Which()); |
174 | 12.0M | o3tl::hash_combine(seed, GetFamilyName().hashCode()); |
175 | 12.0M | o3tl::hash_combine(seed, GetStyleName().hashCode()); |
176 | 12.0M | o3tl::hash_combine(seed, GetFamily()); |
177 | 12.0M | o3tl::hash_combine(seed, GetPitch()); |
178 | 12.0M | o3tl::hash_combine(seed, GetCharSet()); |
179 | 12.0M | return seed; |
180 | 12.0M | } |
181 | | |
182 | | SvxFontItem::SvxFontItem( |
183 | | const sal_uInt16 nId) |
184 | 956k | : SfxPoolItem( nId ) |
185 | 956k | , aFamilyName() |
186 | 956k | , aStyleName() |
187 | 956k | , eFamily(FAMILY_SWISS) |
188 | 956k | , ePitch(PITCH_VARIABLE) |
189 | 956k | , eTextEncoding(RTL_TEXTENCODING_DONTKNOW) |
190 | 956k | { |
191 | 956k | } |
192 | | |
193 | | SvxFontItem::SvxFontItem( |
194 | | const FontFamily eFam, |
195 | | OUString aName, |
196 | | OUString aStName, |
197 | | const FontPitch eFontPitch, |
198 | | const rtl_TextEncoding eFontTextEncoding, |
199 | | const sal_uInt16 nId) |
200 | 3.11M | : SfxPoolItem( nId ) |
201 | 3.11M | , aFamilyName(std::move(aName)) |
202 | 3.11M | , aStyleName(std::move(aStName)) |
203 | 3.11M | , eFamily(eFam) |
204 | 3.11M | , ePitch(eFontPitch) |
205 | 3.11M | , eTextEncoding(eFontTextEncoding) |
206 | 3.11M | { |
207 | 3.11M | } |
208 | | |
209 | | bool SvxFontItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
210 | 454k | { |
211 | 454k | nMemberId &= ~CONVERT_TWIPS; |
212 | 454k | switch(nMemberId) |
213 | 454k | { |
214 | 0 | case 0: |
215 | 0 | { |
216 | 0 | css::awt::FontDescriptor aFontDescriptor; |
217 | 0 | aFontDescriptor.Name = aFamilyName; |
218 | 0 | aFontDescriptor.StyleName = aStyleName; |
219 | 0 | aFontDescriptor.Family = static_cast<sal_Int16>(eFamily); |
220 | 0 | aFontDescriptor.CharSet = static_cast<sal_Int16>(eTextEncoding); |
221 | 0 | aFontDescriptor.Pitch = static_cast<sal_Int16>(ePitch); |
222 | 0 | rVal <<= aFontDescriptor; |
223 | 0 | } |
224 | 0 | break; |
225 | 104k | case MID_FONT_FAMILY_NAME: |
226 | 104k | rVal <<= aFamilyName; |
227 | 104k | break; |
228 | 34.9k | case MID_FONT_STYLE_NAME: |
229 | 34.9k | rVal <<= aStyleName; |
230 | 34.9k | break; |
231 | 104k | case MID_FONT_FAMILY : rVal <<= static_cast<sal_Int16>(eFamily); break; |
232 | 105k | case MID_FONT_CHAR_SET : rVal <<= static_cast<sal_Int16>(eTextEncoding); break; |
233 | 104k | case MID_FONT_PITCH : rVal <<= static_cast<sal_Int16>(ePitch); break; |
234 | 454k | } |
235 | 454k | return true; |
236 | 454k | } |
237 | | |
238 | | bool SvxFontItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId) |
239 | 1.51M | { |
240 | 1.51M | nMemberId &= ~CONVERT_TWIPS; |
241 | 1.51M | switch(nMemberId) |
242 | 1.51M | { |
243 | 0 | case 0: |
244 | 0 | { |
245 | 0 | css::awt::FontDescriptor aFontDescriptor; |
246 | 0 | if ( !( rVal >>= aFontDescriptor )) |
247 | 0 | return false; |
248 | | |
249 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
250 | 0 | aFamilyName = aFontDescriptor.Name; |
251 | 0 | aStyleName = aFontDescriptor.StyleName; |
252 | 0 | eFamily = static_cast<FontFamily>(aFontDescriptor.Family); |
253 | 0 | eTextEncoding = static_cast<rtl_TextEncoding>(aFontDescriptor.CharSet); |
254 | 0 | ePitch = static_cast<FontPitch>(aFontDescriptor.Pitch); |
255 | 0 | } |
256 | 0 | break; |
257 | 641k | case MID_FONT_FAMILY_NAME : |
258 | 641k | { |
259 | 641k | OUString aStr; |
260 | 641k | if(!(rVal >>= aStr)) |
261 | 0 | return false; |
262 | 641k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
263 | 641k | aFamilyName = aStr; |
264 | 641k | } |
265 | 0 | break; |
266 | 64.2k | case MID_FONT_STYLE_NAME: |
267 | 64.2k | { |
268 | 64.2k | OUString aStr; |
269 | 64.2k | if(!(rVal >>= aStr)) |
270 | 0 | return false; |
271 | 64.2k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
272 | 64.2k | aStyleName = aStr; |
273 | 64.2k | } |
274 | 0 | break; |
275 | 389k | case MID_FONT_FAMILY : |
276 | 389k | { |
277 | 389k | sal_Int16 nFamily = sal_Int16(); |
278 | 389k | if(!(rVal >>= nFamily)) |
279 | 0 | return false; |
280 | 389k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
281 | 389k | eFamily = static_cast<FontFamily>(nFamily); |
282 | 389k | } |
283 | 0 | break; |
284 | 127k | case MID_FONT_CHAR_SET : |
285 | 127k | { |
286 | 127k | sal_Int16 nSet = sal_Int16(); |
287 | 127k | if(!(rVal >>= nSet)) |
288 | 2 | return false; |
289 | 127k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
290 | 127k | eTextEncoding = static_cast<rtl_TextEncoding>(nSet); |
291 | 127k | } |
292 | 0 | break; |
293 | 293k | case MID_FONT_PITCH : |
294 | 293k | { |
295 | 293k | sal_Int16 nPitch = sal_Int16(); |
296 | 293k | if(!(rVal >>= nPitch)) |
297 | 0 | return false; |
298 | 293k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
299 | 293k | ePitch = static_cast<FontPitch>(nPitch); |
300 | 293k | } |
301 | 0 | break; |
302 | 1.51M | } |
303 | 1.51M | return true; |
304 | 1.51M | } |
305 | | |
306 | | void SvxFontItem::SetFamilyName(const OUString& rFamilyName) |
307 | 560k | { |
308 | 560k | if (aFamilyName == rFamilyName) |
309 | 0 | return; |
310 | | |
311 | 560k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
312 | 560k | aFamilyName = rFamilyName; |
313 | 560k | } |
314 | | |
315 | | void SvxFontItem::SetStyleName(const OUString &rStyleName) |
316 | 506k | { |
317 | 506k | if (aStyleName == rStyleName) |
318 | 506k | return; |
319 | | |
320 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
321 | 0 | aStyleName = rStyleName; |
322 | 0 | } |
323 | | |
324 | | void SvxFontItem::SetFamily(FontFamily _eFamily) |
325 | 506k | { |
326 | 506k | if (eFamily == _eFamily) |
327 | 0 | return; |
328 | | |
329 | 506k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
330 | 506k | eFamily = _eFamily; |
331 | 506k | } |
332 | | |
333 | | void SvxFontItem::SetPitch(FontPitch _ePitch) |
334 | 506k | { |
335 | 506k | if (ePitch == _ePitch) |
336 | 506k | return; |
337 | | |
338 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
339 | 0 | ePitch = _ePitch; |
340 | 0 | } |
341 | | |
342 | | void SvxFontItem::SetCharSet(rtl_TextEncoding _eEncoding) |
343 | 506k | { |
344 | 506k | if (eTextEncoding == _eEncoding) |
345 | 0 | return; |
346 | | |
347 | 506k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
348 | 506k | eTextEncoding = _eEncoding; |
349 | 506k | } |
350 | | |
351 | | bool SvxFontItem::operator==( const SfxPoolItem& rAttr ) const |
352 | 16.4M | { |
353 | 16.4M | if (this == &rAttr) |
354 | 2.91M | return true; |
355 | | |
356 | 13.5M | assert(SfxPoolItem::operator==(rAttr)); |
357 | 13.5M | const SvxFontItem& rItem(static_cast<const SvxFontItem&>(rAttr)); |
358 | 13.5M | bool bRet = ( eFamily == rItem.eFamily && |
359 | 13.5M | aFamilyName == rItem.aFamilyName && |
360 | 13.5M | aStyleName == rItem.aStyleName ); |
361 | | |
362 | 13.5M | if ( bRet ) |
363 | 11.4M | { |
364 | 11.4M | if ( ePitch != rItem.ePitch || eTextEncoding != rItem.eTextEncoding ) |
365 | 360k | { |
366 | 360k | bRet = false; |
367 | 360k | SAL_INFO( "editeng.items", "FontItem::operator==(): only pitch or rtl_TextEncoding different "); |
368 | 360k | } |
369 | 11.4M | } |
370 | | |
371 | 13.5M | return bRet; |
372 | 13.5M | } |
373 | | |
374 | | SvxFontItem* SvxFontItem::Clone( SfxItemPool * ) const |
375 | 7.79M | { |
376 | 7.79M | return new SvxFontItem( *this ); |
377 | 7.79M | } |
378 | | |
379 | | bool SvxFontItem::GetPresentation |
380 | | ( |
381 | | SfxItemPresentation /*ePres*/, |
382 | | MapUnit /*eCoreUnit*/, |
383 | | MapUnit /*ePresUnit*/, |
384 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
385 | | ) const |
386 | 0 | { |
387 | 0 | rText = aFamilyName; |
388 | 0 | return true; |
389 | 0 | } |
390 | | |
391 | | |
392 | | void SvxFontItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
393 | 0 | { |
394 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxFontItem")); |
395 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
396 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("familyName"), BAD_CAST(aFamilyName.toUtf8().getStr())); |
397 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("styleName"), BAD_CAST(aStyleName.toUtf8().getStr())); |
398 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("family"), BAD_CAST(OString::number(eFamily).getStr())); |
399 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("pitch"), BAD_CAST(OString::number(ePitch).getStr())); |
400 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("textEncoding"), BAD_CAST(OString::number(eTextEncoding).getStr())); |
401 | 0 | (void)xmlTextWriterEndElement(pWriter); |
402 | 0 | } |
403 | | |
404 | | // class SvxPostureItem -------------------------------------------------- |
405 | | |
406 | | ItemInstanceManager* SvxPostureItem::getItemInstanceManager() const |
407 | 6.30M | { |
408 | 6.30M | static HashedItemInstanceManager aInstanceManager(ItemType()); |
409 | 6.30M | return &aInstanceManager; |
410 | 6.30M | } |
411 | | |
412 | | SvxPostureItem::SvxPostureItem( const FontItalic ePosture, const sal_uInt16 nId ) : |
413 | 4.86M | SfxEnumItem( nId, ePosture ) |
414 | 4.86M | { |
415 | 4.86M | } |
416 | | |
417 | | SvxPostureItem* SvxPostureItem::Clone( SfxItemPool * ) const |
418 | 3.18M | { |
419 | 3.18M | return new SvxPostureItem( *this ); |
420 | 3.18M | } |
421 | | |
422 | | |
423 | | bool SvxPostureItem::GetPresentation |
424 | | ( |
425 | | SfxItemPresentation /*ePres*/, |
426 | | MapUnit /*eCoreUnit*/, |
427 | | MapUnit /*ePresUnit*/, |
428 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
429 | | ) const |
430 | 0 | { |
431 | 0 | rText = GetValueTextByPos( GetValue() ); |
432 | 0 | return true; |
433 | 0 | } |
434 | | |
435 | | |
436 | | OUString SvxPostureItem::GetValueTextByPos( sal_uInt16 nPos ) |
437 | 0 | { |
438 | 0 | DBG_ASSERT( nPos <= sal_uInt16(ITALIC_NORMAL), "enum overflow!" ); |
439 | |
|
440 | 0 | FontItalic eItalic = static_cast<FontItalic>(nPos); |
441 | 0 | TranslateId pId; |
442 | |
|
443 | 0 | switch ( eItalic ) |
444 | 0 | { |
445 | 0 | case ITALIC_NONE: pId = RID_SVXITEMS_ITALIC_NONE; break; |
446 | 0 | case ITALIC_OBLIQUE: pId = RID_SVXITEMS_ITALIC_OBLIQUE; break; |
447 | 0 | case ITALIC_NORMAL: pId = RID_SVXITEMS_ITALIC_NORMAL; break; |
448 | 0 | default: ;//prevent warning |
449 | 0 | } |
450 | | |
451 | 0 | return pId ? EditResId(pId) : OUString(); |
452 | 0 | } |
453 | | |
454 | | bool SvxPostureItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
455 | 36.4k | { |
456 | 36.4k | nMemberId &= ~CONVERT_TWIPS; |
457 | 36.4k | switch( nMemberId ) |
458 | 36.4k | { |
459 | 0 | case MID_ITALIC: |
460 | 0 | rVal <<= GetBoolValue(); |
461 | 0 | break; |
462 | 36.4k | case MID_POSTURE: |
463 | 36.4k | rVal <<= vcl::unohelper::ConvertFontSlant(GetValue()); |
464 | 36.4k | break; |
465 | 36.4k | } |
466 | 36.4k | return true; |
467 | 36.4k | } |
468 | | |
469 | | bool SvxPostureItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
470 | 1.51M | { |
471 | 1.51M | nMemberId &= ~CONVERT_TWIPS; |
472 | 1.51M | switch( nMemberId ) |
473 | 1.51M | { |
474 | 0 | case MID_ITALIC: |
475 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
476 | 0 | SetBoolValue(Any2Bool(rVal)); |
477 | 0 | break; |
478 | 1.51M | case MID_POSTURE: |
479 | 1.51M | { |
480 | 1.51M | awt::FontSlant eSlant; |
481 | 1.51M | if(!(rVal >>= eSlant)) |
482 | 0 | { |
483 | 0 | sal_Int32 nValue = 0; |
484 | 0 | if(!(rVal >>= nValue)) |
485 | 0 | return false; |
486 | | |
487 | 0 | eSlant = static_cast<awt::FontSlant>(nValue); |
488 | 0 | } |
489 | 1.51M | ASSERT_CHANGE_REFCOUNTED_ITEM; |
490 | 1.51M | SetValue(vcl::unohelper::ConvertFontSlant(eSlant)); |
491 | 1.51M | } |
492 | 1.51M | } |
493 | 1.51M | return true; |
494 | 1.51M | } |
495 | | |
496 | | bool SvxPostureItem::HasBoolValue() const |
497 | 0 | { |
498 | 0 | return true; |
499 | 0 | } |
500 | | |
501 | | bool SvxPostureItem::GetBoolValue() const |
502 | 0 | { |
503 | 0 | return ( GetValue() >= ITALIC_OBLIQUE ); |
504 | 0 | } |
505 | | |
506 | | void SvxPostureItem::SetBoolValue( bool bVal ) |
507 | 0 | { |
508 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
509 | 0 | SetValue( bVal ? ITALIC_NORMAL : ITALIC_NONE ); |
510 | 0 | } |
511 | | |
512 | | void SvxPostureItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
513 | 0 | { |
514 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxPostureItem")); |
515 | 0 | (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("whichId"), "%d", Which()); |
516 | 0 | (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("value"), "%d", GetValue()); |
517 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr())); |
518 | 0 | (void)xmlTextWriterEndElement(pWriter); |
519 | 0 | } |
520 | | |
521 | | // class SvxWeightItem --------------------------------------------------- |
522 | | |
523 | | ItemInstanceManager* SvxWeightItem::getItemInstanceManager() const |
524 | 6.76M | { |
525 | 6.76M | static DefaultItemInstanceManager aInstanceManager(ItemType()); |
526 | 6.76M | return &aInstanceManager; |
527 | 6.76M | } |
528 | | |
529 | | SvxWeightItem::SvxWeightItem( const FontWeight eWght, const sal_uInt16 nId ) : |
530 | 5.26M | SfxEnumItem( nId, eWght ) |
531 | 5.26M | { |
532 | 5.26M | } |
533 | | |
534 | | |
535 | | bool SvxWeightItem::HasBoolValue() const |
536 | 0 | { |
537 | 0 | return true; |
538 | 0 | } |
539 | | |
540 | | |
541 | | bool SvxWeightItem::GetBoolValue() const |
542 | 0 | { |
543 | 0 | return GetValue() >= WEIGHT_BOLD; |
544 | 0 | } |
545 | | |
546 | | |
547 | | void SvxWeightItem::SetBoolValue( bool bVal ) |
548 | 0 | { |
549 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
550 | 0 | SetValue( bVal ? WEIGHT_BOLD : WEIGHT_NORMAL ); |
551 | 0 | } |
552 | | |
553 | | |
554 | | SvxWeightItem* SvxWeightItem::Clone( SfxItemPool * ) const |
555 | 4.20M | { |
556 | 4.20M | return new SvxWeightItem( *this ); |
557 | 4.20M | } |
558 | | |
559 | | bool SvxWeightItem::GetPresentation |
560 | | ( |
561 | | SfxItemPresentation /*ePres*/, |
562 | | MapUnit /*eCoreUnit*/, |
563 | | MapUnit /*ePresUnit*/, |
564 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
565 | | ) const |
566 | 0 | { |
567 | 0 | rText = GetValueTextByPos( GetValue() ); |
568 | 0 | return true; |
569 | 0 | } |
570 | | |
571 | | OUString SvxWeightItem::GetValueTextByPos( sal_uInt16 nPos ) |
572 | 0 | { |
573 | 0 | static TranslateId RID_SVXITEMS_WEIGHTS[] = |
574 | 0 | { |
575 | 0 | RID_SVXITEMS_WEIGHT_DONTKNOW, |
576 | 0 | RID_SVXITEMS_WEIGHT_THIN, |
577 | 0 | RID_SVXITEMS_WEIGHT_ULTRALIGHT, |
578 | 0 | RID_SVXITEMS_WEIGHT_LIGHT, |
579 | 0 | RID_SVXITEMS_WEIGHT_SEMILIGHT, |
580 | 0 | RID_SVXITEMS_WEIGHT_NORMAL, |
581 | 0 | RID_SVXITEMS_WEIGHT_MEDIUM, |
582 | 0 | RID_SVXITEMS_WEIGHT_SEMIBOLD, |
583 | 0 | RID_SVXITEMS_WEIGHT_BOLD, |
584 | 0 | RID_SVXITEMS_WEIGHT_ULTRABOLD, |
585 | 0 | RID_SVXITEMS_WEIGHT_BLACK |
586 | 0 | }; |
587 | |
|
588 | 0 | static_assert(std::size(RID_SVXITEMS_WEIGHTS) - 1 == WEIGHT_BLACK, "must match"); |
589 | 0 | assert(nPos <= sal_uInt16(WEIGHT_BLACK) && "enum overflow!" ); |
590 | 0 | return EditResId(RID_SVXITEMS_WEIGHTS[nPos]); |
591 | 0 | } |
592 | | |
593 | | bool SvxWeightItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
594 | 36.9k | { |
595 | 36.9k | nMemberId &= ~CONVERT_TWIPS; |
596 | 36.9k | switch( nMemberId ) |
597 | 36.9k | { |
598 | 0 | case MID_BOLD : |
599 | 0 | rVal <<= GetBoolValue(); |
600 | 0 | break; |
601 | 36.9k | case MID_WEIGHT: |
602 | 36.9k | { |
603 | 36.9k | rVal <<= vcl::unohelper::ConvertFontWeight( GetValue() ); |
604 | 36.9k | } |
605 | 36.9k | break; |
606 | 36.9k | } |
607 | 36.9k | return true; |
608 | 36.9k | } |
609 | | |
610 | | bool SvxWeightItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
611 | 1.64M | { |
612 | 1.64M | nMemberId &= ~CONVERT_TWIPS; |
613 | 1.64M | switch( nMemberId ) |
614 | 1.64M | { |
615 | 0 | case MID_BOLD : |
616 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
617 | 0 | SetBoolValue(Any2Bool(rVal)); |
618 | 0 | break; |
619 | 1.64M | case MID_WEIGHT: |
620 | 1.64M | { |
621 | 1.64M | double fValue = 0; |
622 | 1.64M | if(!(rVal >>= fValue)) |
623 | 0 | { |
624 | 0 | sal_Int32 nValue = 0; |
625 | 0 | if(!(rVal >>= nValue)) |
626 | 0 | return false; |
627 | 0 | fValue = static_cast<float>(nValue); |
628 | 0 | } |
629 | 1.64M | ASSERT_CHANGE_REFCOUNTED_ITEM; |
630 | 1.64M | SetValue( vcl::unohelper::ConvertFontWeight(static_cast<float>(fValue)) ); |
631 | 1.64M | } |
632 | 0 | break; |
633 | 1.64M | } |
634 | 1.64M | return true; |
635 | 1.64M | } |
636 | | |
637 | | void SvxWeightItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
638 | 0 | { |
639 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxWeightItem")); |
640 | 0 | (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("whichId"), "%d", Which()); |
641 | 0 | (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("value"), "%d", GetValue()); |
642 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(GetValueTextByPos(GetValue()).toUtf8().getStr())); |
643 | 0 | (void)xmlTextWriterEndElement(pWriter); |
644 | 0 | } |
645 | | |
646 | | // class SvxScriptHintItem --------------------------------------------------- |
647 | | |
648 | | ItemInstanceManager* SvxScriptHintItem::getItemInstanceManager() const |
649 | 0 | { |
650 | 0 | static DefaultItemInstanceManager aInstanceManager(ItemType()); |
651 | 0 | return &aInstanceManager; |
652 | 0 | } |
653 | | |
654 | | SvxScriptHintItem::SvxScriptHintItem(const sal_uInt16 nId) |
655 | 33 | : SfxEnumItem(nId, i18nutil::ScriptHintType::Automatic) |
656 | 33 | { |
657 | 33 | } |
658 | | |
659 | | SvxScriptHintItem::SvxScriptHintItem(i18nutil::ScriptHintType eType, const sal_uInt16 nId) |
660 | 0 | : SfxEnumItem(nId, eType) |
661 | 0 | { |
662 | 0 | } |
663 | | |
664 | | SvxScriptHintItem* SvxScriptHintItem::Clone(SfxItemPool*) const |
665 | 0 | { |
666 | 0 | return new SvxScriptHintItem(*this); |
667 | 0 | } |
668 | | |
669 | | bool SvxScriptHintItem::GetPresentation(SfxItemPresentation /*ePres*/, MapUnit /*eCoreUnit*/, |
670 | | MapUnit /*ePresUnit*/, OUString& rText, |
671 | | const IntlWrapper& /*rIntl*/) const |
672 | 0 | { |
673 | 0 | rText = GetValueText(GetValue()); |
674 | 0 | return true; |
675 | 0 | } |
676 | | |
677 | | OUString SvxScriptHintItem::GetValueText(i18nutil::ScriptHintType eValue) |
678 | 0 | { |
679 | 0 | static const std::array<TranslateId, 5> RID_SVXITEMS_TYPES{ |
680 | 0 | { RID_SVXITEMS_SCRIPTHINTVAL_AUTO, RID_SVXITEMS_SCRIPTHINTVAL_IGNORE, |
681 | 0 | RID_SVXITEMS_SCRIPTHINTVAL_LATIN, RID_SVXITEMS_SCRIPTHINTVAL_ASIAN, |
682 | 0 | RID_SVXITEMS_SCRIPTHINTVAL_COMPLEX } |
683 | 0 | }; |
684 | |
|
685 | 0 | return EditResId(RID_SVXITEMS_TYPES.at(static_cast<size_t>(eValue))); |
686 | 0 | } |
687 | | |
688 | | bool SvxScriptHintItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const |
689 | 0 | { |
690 | 0 | nMemberId &= ~CONVERT_TWIPS; |
691 | 0 | switch (nMemberId) |
692 | 0 | { |
693 | 0 | case MID_SCRIPTHINT: |
694 | 0 | rVal <<= static_cast<sal_uInt16>(GetValue()); |
695 | 0 | break; |
696 | 0 | } |
697 | | |
698 | 0 | return true; |
699 | 0 | } |
700 | | |
701 | | bool SvxScriptHintItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) |
702 | 0 | { |
703 | 0 | sal_uInt16 nValue = 0; |
704 | |
|
705 | 0 | nMemberId &= ~CONVERT_TWIPS; |
706 | 0 | switch (nMemberId) |
707 | 0 | { |
708 | 0 | case MID_SCRIPTHINT: |
709 | 0 | if (!(rVal >>= nValue)) |
710 | 0 | { |
711 | 0 | return false; |
712 | 0 | } |
713 | | |
714 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
715 | 0 | SetValue(i18nutil::ScriptHintType{ nValue }); |
716 | 0 | break; |
717 | 0 | } |
718 | | |
719 | 0 | return true; |
720 | 0 | } |
721 | | |
722 | | void SvxScriptHintItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
723 | 0 | { |
724 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxScriptHintItem")); |
725 | 0 | (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("whichId"), "%d", Which()); |
726 | 0 | (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("value"), "%d", |
727 | 0 | static_cast<int>(GetValue())); |
728 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), |
729 | 0 | BAD_CAST(GetValueText(GetValue()).toUtf8().getStr())); |
730 | 0 | (void)xmlTextWriterEndElement(pWriter); |
731 | 0 | } |
732 | | |
733 | | // class SvxFontHeightItem ----------------------------------------------- |
734 | | |
735 | | ItemInstanceManager* SvxFontHeightItem::getItemInstanceManager() const |
736 | 17.3M | { |
737 | 17.3M | static HashedItemInstanceManager aInstanceManager(ItemType()); |
738 | 17.3M | return &aInstanceManager; |
739 | 17.3M | } |
740 | | |
741 | | size_t SvxFontHeightItem::hashCode() const |
742 | 20.7M | { |
743 | 20.7M | std::size_t seed(0); |
744 | 20.7M | o3tl::hash_combine(seed, Which()); |
745 | 20.7M | o3tl::hash_combine(seed, GetHeight()); |
746 | 20.7M | o3tl::hash_combine(seed, GetProp()); |
747 | 20.7M | o3tl::hash_combine(seed, GetPropUnit()); |
748 | 20.7M | return seed; |
749 | 20.7M | } |
750 | | |
751 | | SvxFontHeightItem::SvxFontHeightItem( const sal_uInt32 nSz, |
752 | | const sal_uInt16 nPrp, |
753 | | const sal_uInt16 nId ) : |
754 | 11.3M | SfxPoolItem( nId ) |
755 | 11.3M | { |
756 | 11.3M | SetHeight( nSz,nPrp ); // calculate in percentage |
757 | 11.3M | } |
758 | | |
759 | | SvxFontHeightItem* SvxFontHeightItem::Clone( SfxItemPool * ) const |
760 | 6.92M | { |
761 | 6.92M | return new SvxFontHeightItem( *this ); |
762 | 6.92M | } |
763 | | |
764 | | bool SvxFontHeightItem::operator==( const SfxPoolItem& rItem ) const |
765 | 29.6M | { |
766 | 29.6M | assert(SfxPoolItem::operator==(rItem)); |
767 | 29.6M | return GetHeight() == static_cast<const SvxFontHeightItem&>(rItem).GetHeight() && |
768 | 29.6M | GetProp() == static_cast<const SvxFontHeightItem&>(rItem).GetProp() && |
769 | 29.6M | GetPropUnit() == static_cast<const SvxFontHeightItem&>(rItem).GetPropUnit(); |
770 | 29.6M | } |
771 | | |
772 | | bool SvxFontHeightItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
773 | 91.4k | { |
774 | | // In StarOne is the uno::Any always 1/100mm. Through the MemberId it is |
775 | | // controlled if the value in the Item should be 1/100mm or Twips. |
776 | | |
777 | 91.4k | bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); |
778 | 91.4k | nMemberId &= ~CONVERT_TWIPS; |
779 | 91.4k | switch( nMemberId ) |
780 | 91.4k | { |
781 | 0 | case 0: |
782 | 0 | { |
783 | 0 | css::frame::status::FontHeight aFontHeight; |
784 | | |
785 | | // Point (i.e. Twips) is asked for, thus re-calculate if |
786 | | // CONVERT_TWIPS is not set. |
787 | 0 | if( bConvert ) |
788 | 0 | { |
789 | 0 | aFontHeight.Height = o3tl::convert<double>(nHeight, o3tl::Length::twip, o3tl::Length::pt); |
790 | 0 | } |
791 | 0 | else |
792 | 0 | { |
793 | 0 | double fPoints = o3tl::convert<double>(nHeight, o3tl::Length::mm100, o3tl::Length::pt); |
794 | 0 | aFontHeight.Height = rtl::math::round(fPoints, 1); |
795 | 0 | } |
796 | |
|
797 | 0 | aFontHeight.Prop = MapUnit::MapRelative == ePropUnit ? nProp : 100; |
798 | |
|
799 | 0 | float fRet = nProp; |
800 | 0 | switch( ePropUnit ) |
801 | 0 | { |
802 | 0 | case MapUnit::MapRelative: |
803 | 0 | fRet = 0.; |
804 | 0 | break; |
805 | 0 | case MapUnit::Map100thMM: |
806 | 0 | fRet = o3tl::convert(fRet, o3tl::Length::mm100, o3tl::Length::pt); |
807 | 0 | break; |
808 | 0 | case MapUnit::MapPoint: |
809 | |
|
810 | 0 | break; |
811 | 0 | case MapUnit::MapTwip: |
812 | 0 | fRet = o3tl::convert(fRet, o3tl::Length::twip, o3tl::Length::pt); |
813 | 0 | break; |
814 | 0 | default: ;//prevent warning |
815 | 0 | } |
816 | 0 | aFontHeight.Diff = fRet; |
817 | 0 | rVal <<= aFontHeight; |
818 | 0 | } |
819 | 0 | break; |
820 | 91.4k | case MID_FONTHEIGHT: |
821 | 91.4k | { |
822 | | // Point (i.e. Twips) is asked for, thus re-calculate if |
823 | | // CONVERT_TWIPS is not set. |
824 | 91.4k | if( bConvert ) |
825 | 37.1k | { |
826 | 37.1k | rVal <<= static_cast<float>(o3tl::convert<double>(nHeight, o3tl::Length::twip, o3tl::Length::pt)); |
827 | 37.1k | } |
828 | 54.3k | else |
829 | 54.3k | { |
830 | 54.3k | double fPoints = o3tl::convert<double>(nHeight, o3tl::Length::mm100, o3tl::Length::pt); |
831 | 54.3k | rVal <<= static_cast<float>(::rtl::math::round(fPoints, 1)); |
832 | 54.3k | } |
833 | 91.4k | } |
834 | 91.4k | break; |
835 | 0 | case MID_FONTHEIGHT_PROP: |
836 | 0 | rVal <<= static_cast<sal_Int16>(MapUnit::MapRelative == ePropUnit ? nProp : 100); |
837 | 0 | break; |
838 | 0 | case MID_FONTHEIGHT_DIFF: |
839 | 0 | { |
840 | 0 | float fRet = nProp; |
841 | 0 | switch( ePropUnit ) |
842 | 0 | { |
843 | 0 | case MapUnit::MapRelative: |
844 | 0 | fRet = 0.; |
845 | 0 | break; |
846 | 0 | case MapUnit::Map100thMM: |
847 | 0 | fRet = o3tl::convert(fRet, o3tl::Length::mm100, o3tl::Length::pt); |
848 | 0 | break; |
849 | 0 | case MapUnit::MapPoint: |
850 | |
|
851 | 0 | break; |
852 | 0 | case MapUnit::MapTwip: |
853 | 0 | fRet = o3tl::convert(fRet, o3tl::Length::twip, o3tl::Length::pt); |
854 | 0 | break; |
855 | 0 | default: ;//prevent warning |
856 | 0 | } |
857 | 0 | rVal <<= fRet; |
858 | 0 | } |
859 | 0 | break; |
860 | 91.4k | } |
861 | 91.4k | return true; |
862 | 91.4k | } |
863 | | |
864 | | // Try to reconstruct the original height input value from the modified height |
865 | | // and the prop data; this seems somewhat futile given the various ways how the |
866 | | // modified height is calculated (with and without conversion between twips and |
867 | | // 100th mm; with an additional eCoreMetric input in one of the SetHeight |
868 | | // overloads), and indeed known to occasionally produce nRet values that would |
869 | | // be negative, so just guard against negative results here and throw the hands |
870 | | // up in despair: |
871 | | static sal_uInt32 lcl_GetRealHeight_Impl(sal_uInt32 nHeight, sal_uInt16 nProp, MapUnit eProp, bool bCoreInTwip) |
872 | 3.67k | { |
873 | 3.67k | sal_uInt32 nRet = nHeight; |
874 | 3.67k | short nDiff = 0; |
875 | 3.67k | switch( eProp ) |
876 | 3.67k | { |
877 | 3.67k | case MapUnit::MapRelative: |
878 | 3.67k | if (nProp) |
879 | 3.67k | { |
880 | 3.67k | nRet *= 100; |
881 | 3.67k | nRet /= nProp; |
882 | 3.67k | } |
883 | 3.67k | break; |
884 | 0 | case MapUnit::MapPoint: |
885 | 0 | { |
886 | 0 | short nTemp = static_cast<short>(nProp); |
887 | 0 | nDiff = nTemp * 20; |
888 | 0 | if(!bCoreInTwip) |
889 | 0 | nDiff = static_cast<short>(convertTwipToMm100(nDiff)); |
890 | 0 | break; |
891 | 0 | } |
892 | 0 | case MapUnit::Map100thMM: |
893 | 0 | case MapUnit::MapTwip: |
894 | | // In both cases, the units match core |
895 | 0 | nDiff = static_cast<short>(nProp); |
896 | 0 | break; |
897 | 0 | default: |
898 | 0 | break; |
899 | 3.67k | } |
900 | 3.67k | nRet = (nDiff < 0 || nRet >= o3tl::make_unsigned(nDiff)) |
901 | 3.67k | ? nRet - nDiff : 0; |
902 | | //TODO: overflow in case nDiff < 0 and nRet - nDiff > SAL_MAX_UINT32 |
903 | | |
904 | 3.67k | return nRet; |
905 | 3.67k | } |
906 | | |
907 | | bool SvxFontHeightItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
908 | 1.36M | { |
909 | 1.36M | bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); |
910 | 1.36M | nMemberId &= ~CONVERT_TWIPS; |
911 | 1.36M | switch( nMemberId ) |
912 | 1.36M | { |
913 | 0 | case 0: |
914 | 0 | { |
915 | 0 | css::frame::status::FontHeight aFontHeight; |
916 | 0 | if ( rVal >>= aFontHeight ) |
917 | 0 | { |
918 | | // Height |
919 | 0 | ePropUnit = MapUnit::MapRelative; |
920 | 0 | nProp = 100; |
921 | 0 | double fPoint = aFontHeight.Height; |
922 | 0 | if( fPoint < 0. || fPoint > 10000. ) |
923 | 0 | return false; |
924 | | |
925 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
926 | 0 | nHeight = static_cast<tools::Long>( fPoint * 20.0 + 0.5 ); // Twips |
927 | 0 | if (!bConvert) |
928 | 0 | nHeight = convertTwipToMm100(nHeight); // Convert, if the item contains 1/100mm |
929 | |
|
930 | 0 | nProp = aFontHeight.Prop; |
931 | 0 | } |
932 | 0 | else |
933 | 0 | return false; |
934 | 0 | } |
935 | 0 | break; |
936 | 1.36M | case MID_FONTHEIGHT: |
937 | 1.36M | { |
938 | 1.36M | ePropUnit = MapUnit::MapRelative; |
939 | 1.36M | nProp = 100; |
940 | 1.36M | double fPoint = 0; |
941 | 1.36M | if(!(rVal >>= fPoint)) |
942 | 0 | { |
943 | 0 | sal_Int32 nValue = 0; |
944 | 0 | if(!(rVal >>= nValue)) |
945 | 0 | return false; |
946 | 0 | fPoint = static_cast<float>(nValue); |
947 | 0 | } |
948 | | |
949 | 1.36M | if (fPoint < 0. || fPoint > 10000.) |
950 | 2.29k | return false; |
951 | 1.36M | static bool bFuzzing = comphelper::IsFuzzing(); |
952 | 1.36M | if (bFuzzing && fPoint > 120) |
953 | 191 | { |
954 | 191 | SAL_WARN("editeng.items", "SvxFontHeightItem ignoring font size of " << fPoint << " for performance"); |
955 | 191 | return false; |
956 | 191 | } |
957 | | |
958 | 1.36M | ASSERT_CHANGE_REFCOUNTED_ITEM; |
959 | 1.36M | nHeight = static_cast<tools::Long>( fPoint * 20.0 + 0.5 ); // Twips |
960 | 1.36M | if (!bConvert) |
961 | 838k | nHeight = convertTwipToMm100(nHeight); // Convert, if the item contains 1/100mm |
962 | 1.36M | } |
963 | 0 | break; |
964 | 3.67k | case MID_FONTHEIGHT_PROP: |
965 | 3.67k | { |
966 | 3.67k | sal_Int16 nNew = sal_Int16(); |
967 | 3.67k | if(!(rVal >>= nNew)) |
968 | 0 | return true; |
969 | | |
970 | 3.67k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
971 | 3.67k | nHeight = lcl_GetRealHeight_Impl(nHeight, nProp, ePropUnit, bConvert); |
972 | | |
973 | 3.67k | nHeight *= nNew; |
974 | 3.67k | nHeight /= 100; |
975 | 3.67k | nProp = nNew; |
976 | 3.67k | ePropUnit = MapUnit::MapRelative; |
977 | 3.67k | } |
978 | 0 | break; |
979 | 0 | case MID_FONTHEIGHT_DIFF: |
980 | 0 | { |
981 | 0 | nHeight = lcl_GetRealHeight_Impl(nHeight, nProp, ePropUnit, bConvert); |
982 | 0 | float fValue = 0; |
983 | 0 | if(!(rVal >>= fValue)) |
984 | 0 | { |
985 | 0 | sal_Int32 nValue = 0; |
986 | 0 | if(!(rVal >>= nValue)) |
987 | 0 | return false; |
988 | 0 | fValue = static_cast<float>(nValue); |
989 | 0 | } |
990 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
991 | 0 | sal_Int16 nCoreDiffValue = static_cast<sal_Int16>(fValue * 20.); |
992 | 0 | nHeight += bConvert ? nCoreDiffValue : convertTwipToMm100(nCoreDiffValue); |
993 | 0 | nProp = static_cast<sal_uInt16>(static_cast<sal_Int16>(fValue)); |
994 | 0 | ePropUnit = MapUnit::MapPoint; |
995 | 0 | } |
996 | 0 | break; |
997 | 1.36M | } |
998 | 1.36M | return true; |
999 | 1.36M | } |
1000 | | |
1001 | | |
1002 | | bool SvxFontHeightItem::GetPresentation |
1003 | | ( |
1004 | | SfxItemPresentation /*ePres*/, |
1005 | | MapUnit eCoreUnit, |
1006 | | MapUnit /*ePresUnit*/, |
1007 | | OUString& rText, const IntlWrapper& rIntl |
1008 | | ) const |
1009 | 0 | { |
1010 | 0 | if( MapUnit::MapRelative != ePropUnit ) |
1011 | 0 | { |
1012 | 0 | rText = OUString::number( static_cast<short>(nProp) ) + |
1013 | 0 | " " + EditResId( GetMetricId( ePropUnit ) ); |
1014 | 0 | if( 0 <= static_cast<short>(nProp) ) |
1015 | 0 | rText = "+" + rText; |
1016 | 0 | } |
1017 | 0 | else if( 100 == nProp ) |
1018 | 0 | { |
1019 | 0 | rText = GetMetricText( static_cast<tools::Long>(nHeight), |
1020 | 0 | eCoreUnit, MapUnit::MapPoint, &rIntl ) + |
1021 | 0 | " " + EditResId(GetMetricId(MapUnit::MapPoint)); |
1022 | 0 | } |
1023 | 0 | else |
1024 | 0 | rText = OUString::number( nProp ) + "%"; |
1025 | 0 | return true; |
1026 | 0 | } |
1027 | | |
1028 | | |
1029 | | void SvxFontHeightItem::ScaleMetrics( tools::Long nMult, tools::Long nDiv ) |
1030 | 0 | { |
1031 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1032 | 0 | nHeight = static_cast<sal_uInt32>(BigInt::Scale( nHeight, nMult, nDiv )); |
1033 | 0 | } |
1034 | | |
1035 | | |
1036 | | bool SvxFontHeightItem::HasMetrics() const |
1037 | 0 | { |
1038 | 0 | return true; |
1039 | 0 | } |
1040 | | |
1041 | | void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight, const sal_uInt16 nNewProp, |
1042 | | MapUnit eUnit ) |
1043 | 11.8M | { |
1044 | 11.8M | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1045 | | |
1046 | 11.8M | if( MapUnit::MapRelative != eUnit ) |
1047 | 0 | nHeight = nNewHeight + ::ItemToControl( short(nNewProp), eUnit, |
1048 | 0 | FieldUnit::TWIP ); |
1049 | 11.8M | else if( 100 != nNewProp ) |
1050 | 2.56k | nHeight = sal_uInt32(( nNewHeight * nNewProp ) / 100 ); |
1051 | 11.8M | else |
1052 | 11.8M | nHeight = nNewHeight; |
1053 | | |
1054 | 11.8M | nProp = nNewProp; |
1055 | 11.8M | ePropUnit = eUnit; |
1056 | 11.8M | } |
1057 | | |
1058 | | void SvxFontHeightItem::SetHeight( sal_uInt32 nNewHeight, sal_uInt16 nNewProp, |
1059 | | MapUnit eMetric, MapUnit eCoreMetric ) |
1060 | 0 | { |
1061 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1062 | |
|
1063 | 0 | if( MapUnit::MapRelative != eMetric ) |
1064 | 0 | nHeight = nNewHeight + |
1065 | 0 | ::ControlToItem( ::ItemToControl(static_cast<short>(nNewProp), eMetric, |
1066 | 0 | FieldUnit::TWIP ), FieldUnit::TWIP, |
1067 | 0 | eCoreMetric ); |
1068 | 0 | else if( 100 != nNewProp ) |
1069 | 0 | nHeight = sal_uInt32(( nNewHeight * nNewProp ) / 100 ); |
1070 | 0 | else |
1071 | 0 | nHeight = nNewHeight; |
1072 | |
|
1073 | 0 | nProp = nNewProp; |
1074 | 0 | ePropUnit = eMetric; |
1075 | 0 | } |
1076 | | |
1077 | | void SvxFontHeightItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
1078 | 0 | { |
1079 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxFontHeightItem")); |
1080 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
1081 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("height"), BAD_CAST(OString::number(nHeight).getStr())); |
1082 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("prop"), BAD_CAST(OString::number(nProp).getStr())); |
1083 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("propUnit"), BAD_CAST(OString::number(static_cast<int>(ePropUnit)).getStr())); |
1084 | 0 | (void)xmlTextWriterEndElement(pWriter); |
1085 | 0 | } |
1086 | | |
1087 | | // class SvxTextLineItem ------------------------------------------------ |
1088 | | |
1089 | | SvxTextLineItem::SvxTextLineItem( const FontLineStyle eSt, const sal_uInt16 nId ) |
1090 | 1.12M | : SfxEnumItem(nId, eSt) |
1091 | 1.12M | , maColor(COL_TRANSPARENT) |
1092 | 1.12M | { |
1093 | 1.12M | } |
1094 | | |
1095 | | |
1096 | | bool SvxTextLineItem::HasBoolValue() const |
1097 | 0 | { |
1098 | 0 | return true; |
1099 | 0 | } |
1100 | | |
1101 | | |
1102 | | bool SvxTextLineItem::GetBoolValue() const |
1103 | 0 | { |
1104 | 0 | return GetValue() != LINESTYLE_NONE; |
1105 | 0 | } |
1106 | | |
1107 | | |
1108 | | void SvxTextLineItem::SetBoolValue( bool bVal ) |
1109 | 0 | { |
1110 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1111 | 0 | SetValue( bVal ? LINESTYLE_SINGLE : LINESTYLE_NONE ); |
1112 | 0 | } |
1113 | | |
1114 | | SvxTextLineItem* SvxTextLineItem::Clone( SfxItemPool * ) const |
1115 | 0 | { |
1116 | 0 | return new SvxTextLineItem( *this ); |
1117 | 0 | } |
1118 | | |
1119 | | |
1120 | | bool SvxTextLineItem::GetPresentation |
1121 | | ( |
1122 | | SfxItemPresentation /*ePres*/, |
1123 | | MapUnit /*eCoreUnit*/, |
1124 | | MapUnit /*ePresUnit*/, |
1125 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
1126 | | ) const |
1127 | 0 | { |
1128 | 0 | rText = GetValueTextByPos( GetValue() ); |
1129 | 0 | if( !maColor.IsTransparent() ) |
1130 | 0 | rText += cpDelim + ::GetColorString(maColor); |
1131 | 0 | return true; |
1132 | 0 | } |
1133 | | |
1134 | | |
1135 | | OUString SvxTextLineItem::GetValueTextByPos( sal_uInt16 /*nPos*/ ) const |
1136 | 0 | { |
1137 | 0 | OSL_FAIL("SvxTextLineItem::GetValueTextByPos: Pure virtual method"); |
1138 | 0 | return OUString(); |
1139 | 0 | } |
1140 | | |
1141 | | bool SvxTextLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
1142 | 33.0k | { |
1143 | 33.0k | nMemberId &= ~CONVERT_TWIPS; |
1144 | 33.0k | switch(nMemberId) |
1145 | 33.0k | { |
1146 | 0 | case MID_TEXTLINED: |
1147 | 0 | rVal <<= GetBoolValue(); |
1148 | 0 | break; |
1149 | 11.0k | case MID_TL_STYLE: |
1150 | 11.0k | rVal <<= static_cast<sal_Int16>(GetValue()); |
1151 | 11.0k | break; |
1152 | 11.0k | case MID_TL_COLOR: |
1153 | 11.0k | rVal <<= maColor; |
1154 | 11.0k | break; |
1155 | 0 | case MID_TL_COMPLEX_COLOR: |
1156 | 0 | { |
1157 | 0 | auto xComplexColor = model::color::createXComplexColor(maComplexColor); |
1158 | 0 | rVal <<= xComplexColor; |
1159 | 0 | break; |
1160 | 0 | } |
1161 | 11.0k | case MID_TL_HASCOLOR: |
1162 | 11.0k | rVal <<= maColor.GetAlpha() == 255; |
1163 | 11.0k | break; |
1164 | 33.0k | } |
1165 | 33.0k | return true; |
1166 | 33.0k | } |
1167 | | |
1168 | | bool SvxTextLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
1169 | 1.40M | { |
1170 | 1.40M | nMemberId &= ~CONVERT_TWIPS; |
1171 | 1.40M | bool bRet = true; |
1172 | 1.40M | switch(nMemberId) |
1173 | 1.40M | { |
1174 | 0 | case MID_TEXTLINED: |
1175 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1176 | 0 | SetBoolValue(Any2Bool(rVal)); |
1177 | 0 | break; |
1178 | 498k | case MID_TL_STYLE: |
1179 | 498k | { |
1180 | 498k | sal_Int32 nValue = 0; |
1181 | 498k | if(!(rVal >>= nValue)) |
1182 | 0 | bRet = false; |
1183 | 498k | else |
1184 | 498k | { |
1185 | 498k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1186 | 498k | SetValue(static_cast<FontLineStyle>(nValue)); |
1187 | 498k | } |
1188 | 498k | } |
1189 | 498k | break; |
1190 | 450k | case MID_TL_COLOR: |
1191 | 450k | { |
1192 | 450k | Color nCol; |
1193 | 450k | if( !( rVal >>= nCol ) ) |
1194 | 0 | bRet = false; |
1195 | 450k | else |
1196 | 450k | { |
1197 | | // Keep transparence, because it contains the information |
1198 | | // whether the font color or the stored color should be used |
1199 | 450k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1200 | 450k | sal_uInt8 nAlpha = maColor.GetAlpha(); |
1201 | 450k | maColor = nCol; |
1202 | 450k | maColor.SetAlpha( nAlpha ); |
1203 | 450k | } |
1204 | 450k | } |
1205 | 450k | break; |
1206 | 0 | case MID_TL_COMPLEX_COLOR: |
1207 | 0 | { |
1208 | 0 | css::uno::Reference<css::util::XComplexColor> xComplexColor; |
1209 | 0 | if (!(rVal >>= xComplexColor)) |
1210 | 0 | return false; |
1211 | | |
1212 | 0 | if (xComplexColor.is()) |
1213 | 0 | { |
1214 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1215 | 0 | maComplexColor = model::color::getFromXComplexColor(xComplexColor); |
1216 | 0 | } |
1217 | 0 | } |
1218 | 0 | break; |
1219 | 454k | case MID_TL_HASCOLOR: |
1220 | 454k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1221 | 454k | maColor.SetAlpha( Any2Bool( rVal ) ? 255 : 0 ); |
1222 | 454k | break; |
1223 | 1.40M | } |
1224 | 1.40M | return bRet; |
1225 | 1.40M | } |
1226 | | |
1227 | | bool SvxTextLineItem::operator==( const SfxPoolItem& rItem ) const |
1228 | 5.16M | { |
1229 | 5.16M | return SfxEnumItem::operator==( rItem ) && |
1230 | 5.16M | maColor == static_cast<const SvxTextLineItem&>(rItem).maColor && |
1231 | 5.16M | maComplexColor == static_cast<const SvxTextLineItem&>(rItem).maComplexColor; |
1232 | 5.16M | } |
1233 | | |
1234 | | // class SvxUnderlineItem ------------------------------------------------ |
1235 | | |
1236 | | ItemInstanceManager* SvxUnderlineItem::getItemInstanceManager() const |
1237 | 1.90M | { |
1238 | 1.90M | static DefaultItemInstanceManager aInstanceManager(ItemType()); |
1239 | 1.90M | return &aInstanceManager; |
1240 | 1.90M | } |
1241 | | |
1242 | | SvxUnderlineItem::SvxUnderlineItem( const FontLineStyle eSt, const sal_uInt16 nId ) |
1243 | 726k | : SvxTextLineItem( eSt, nId ) |
1244 | 726k | { |
1245 | 726k | } |
1246 | | |
1247 | | SvxUnderlineItem* SvxUnderlineItem::Clone( SfxItemPool * ) const |
1248 | 2.86M | { |
1249 | 2.86M | return new SvxUnderlineItem( *this ); |
1250 | 2.86M | } |
1251 | | |
1252 | | OUString SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos ) const |
1253 | 0 | { |
1254 | 0 | static TranslateId RID_SVXITEMS_UL[] = |
1255 | 0 | { |
1256 | 0 | RID_SVXITEMS_UL_NONE, |
1257 | 0 | RID_SVXITEMS_UL_SINGLE, |
1258 | 0 | RID_SVXITEMS_UL_DOUBLE, |
1259 | 0 | RID_SVXITEMS_UL_DOTTED, |
1260 | 0 | RID_SVXITEMS_UL_DONTKNOW, |
1261 | 0 | RID_SVXITEMS_UL_DASH, |
1262 | 0 | RID_SVXITEMS_UL_LONGDASH, |
1263 | 0 | RID_SVXITEMS_UL_DASHDOT, |
1264 | 0 | RID_SVXITEMS_UL_DASHDOTDOT, |
1265 | 0 | RID_SVXITEMS_UL_SMALLWAVE, |
1266 | 0 | RID_SVXITEMS_UL_WAVE, |
1267 | 0 | RID_SVXITEMS_UL_DOUBLEWAVE, |
1268 | 0 | RID_SVXITEMS_UL_BOLD, |
1269 | 0 | RID_SVXITEMS_UL_BOLDDOTTED, |
1270 | 0 | RID_SVXITEMS_UL_BOLDDASH, |
1271 | 0 | RID_SVXITEMS_UL_BOLDLONGDASH, |
1272 | 0 | RID_SVXITEMS_UL_BOLDDASHDOT, |
1273 | 0 | RID_SVXITEMS_UL_BOLDDASHDOTDOT, |
1274 | 0 | RID_SVXITEMS_UL_BOLDWAVE |
1275 | 0 | }; |
1276 | 0 | static_assert(std::size(RID_SVXITEMS_UL) - 1 == LINESTYLE_BOLDWAVE, "must match"); |
1277 | 0 | assert(nPos <= sal_uInt16(LINESTYLE_BOLDWAVE) && "enum overflow!"); |
1278 | 0 | return EditResId(RID_SVXITEMS_UL[nPos]); |
1279 | 0 | } |
1280 | | |
1281 | | // class SvxOverlineItem ------------------------------------------------ |
1282 | | |
1283 | | ItemInstanceManager* SvxOverlineItem::getItemInstanceManager() const |
1284 | 1.52M | { |
1285 | 1.52M | static DefaultItemInstanceManager aInstanceManager(ItemType()); |
1286 | 1.52M | return &aInstanceManager; |
1287 | 1.52M | } |
1288 | | |
1289 | | SvxOverlineItem::SvxOverlineItem( const FontLineStyle eSt, const sal_uInt16 nId ) |
1290 | 397k | : SvxTextLineItem( eSt, nId ) |
1291 | 397k | { |
1292 | 397k | } |
1293 | | |
1294 | | SvxOverlineItem* SvxOverlineItem::Clone( SfxItemPool * ) const |
1295 | 1.15M | { |
1296 | 1.15M | return new SvxOverlineItem( *this ); |
1297 | 1.15M | } |
1298 | | |
1299 | | OUString SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos ) const |
1300 | 0 | { |
1301 | 0 | static TranslateId RID_SVXITEMS_OL[] = |
1302 | 0 | { |
1303 | 0 | RID_SVXITEMS_OL_NONE, |
1304 | 0 | RID_SVXITEMS_OL_SINGLE, |
1305 | 0 | RID_SVXITEMS_OL_DOUBLE, |
1306 | 0 | RID_SVXITEMS_OL_DOTTED, |
1307 | 0 | RID_SVXITEMS_OL_DONTKNOW, |
1308 | 0 | RID_SVXITEMS_OL_DASH, |
1309 | 0 | RID_SVXITEMS_OL_LONGDASH, |
1310 | 0 | RID_SVXITEMS_OL_DASHDOT, |
1311 | 0 | RID_SVXITEMS_OL_DASHDOTDOT, |
1312 | 0 | RID_SVXITEMS_OL_SMALLWAVE, |
1313 | 0 | RID_SVXITEMS_OL_WAVE, |
1314 | 0 | RID_SVXITEMS_OL_DOUBLEWAVE, |
1315 | 0 | RID_SVXITEMS_OL_BOLD, |
1316 | 0 | RID_SVXITEMS_OL_BOLDDOTTED, |
1317 | 0 | RID_SVXITEMS_OL_BOLDDASH, |
1318 | 0 | RID_SVXITEMS_OL_BOLDLONGDASH, |
1319 | 0 | RID_SVXITEMS_OL_BOLDDASHDOT, |
1320 | 0 | RID_SVXITEMS_OL_BOLDDASHDOTDOT, |
1321 | 0 | RID_SVXITEMS_OL_BOLDWAVE |
1322 | 0 | }; |
1323 | 0 | static_assert(std::size(RID_SVXITEMS_OL) - 1 == LINESTYLE_BOLDWAVE, "must match"); |
1324 | 0 | assert(nPos <= sal_uInt16(LINESTYLE_BOLDWAVE) && "enum overflow!"); |
1325 | 0 | return EditResId(RID_SVXITEMS_OL[nPos]); |
1326 | 0 | } |
1327 | | |
1328 | | // class SvxCrossedOutItem ----------------------------------------------- |
1329 | | |
1330 | | ItemInstanceManager* SvxCrossedOutItem::getItemInstanceManager() const |
1331 | 1.81M | { |
1332 | 1.81M | static DefaultItemInstanceManager aInstanceManager(ItemType()); |
1333 | 1.81M | return &aInstanceManager; |
1334 | 1.81M | } |
1335 | | |
1336 | | SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt, const sal_uInt16 nId ) |
1337 | 1.65M | : SfxEnumItem( nId, eSt ) |
1338 | 1.65M | { |
1339 | 1.65M | } |
1340 | | |
1341 | | |
1342 | | bool SvxCrossedOutItem::HasBoolValue() const |
1343 | 0 | { |
1344 | 0 | return true; |
1345 | 0 | } |
1346 | | |
1347 | | |
1348 | | bool SvxCrossedOutItem::GetBoolValue() const |
1349 | 0 | { |
1350 | 0 | return GetValue() != STRIKEOUT_NONE; |
1351 | 0 | } |
1352 | | |
1353 | | |
1354 | | void SvxCrossedOutItem::SetBoolValue( bool bVal ) |
1355 | 0 | { |
1356 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1357 | 0 | SetValue( bVal ? STRIKEOUT_SINGLE : STRIKEOUT_NONE ); |
1358 | 0 | } |
1359 | | |
1360 | | |
1361 | | SvxCrossedOutItem* SvxCrossedOutItem::Clone( SfxItemPool * ) const |
1362 | 848k | { |
1363 | 848k | return new SvxCrossedOutItem( *this ); |
1364 | 848k | } |
1365 | | |
1366 | | bool SvxCrossedOutItem::GetPresentation |
1367 | | ( |
1368 | | SfxItemPresentation /*ePres*/, |
1369 | | MapUnit /*eCoreUnit*/, |
1370 | | MapUnit /*ePresUnit*/, |
1371 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
1372 | | ) const |
1373 | 0 | { |
1374 | 0 | rText = GetValueTextByPos( GetValue() ); |
1375 | 0 | return true; |
1376 | 0 | } |
1377 | | |
1378 | | OUString SvxCrossedOutItem::GetValueTextByPos( sal_uInt16 nPos ) |
1379 | 0 | { |
1380 | 0 | static TranslateId RID_SVXITEMS_STRIKEOUT[] = |
1381 | 0 | { |
1382 | 0 | RID_SVXITEMS_STRIKEOUT_NONE, |
1383 | 0 | RID_SVXITEMS_STRIKEOUT_SINGLE, |
1384 | 0 | RID_SVXITEMS_STRIKEOUT_DOUBLE, |
1385 | 0 | RID_SVXITEMS_STRIKEOUT_DONTKNOW, |
1386 | 0 | RID_SVXITEMS_STRIKEOUT_BOLD, |
1387 | 0 | RID_SVXITEMS_STRIKEOUT_SLASH, |
1388 | 0 | RID_SVXITEMS_STRIKEOUT_X |
1389 | 0 | }; |
1390 | 0 | static_assert(std::size(RID_SVXITEMS_STRIKEOUT) - 1 == STRIKEOUT_X, "must match"); |
1391 | 0 | assert(nPos <= sal_uInt16(STRIKEOUT_X) && "enum overflow!"); |
1392 | 0 | return EditResId(RID_SVXITEMS_STRIKEOUT[nPos]); |
1393 | 0 | } |
1394 | | |
1395 | | bool SvxCrossedOutItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
1396 | 12.3k | { |
1397 | 12.3k | nMemberId &= ~CONVERT_TWIPS; |
1398 | 12.3k | switch(nMemberId) |
1399 | 12.3k | { |
1400 | 0 | case MID_CROSSED_OUT: |
1401 | 0 | rVal <<= GetBoolValue(); |
1402 | 0 | break; |
1403 | 12.3k | case MID_CROSS_OUT: |
1404 | 12.3k | rVal <<= static_cast<sal_Int16>(GetValue()); |
1405 | 12.3k | break; |
1406 | 12.3k | } |
1407 | 12.3k | return true; |
1408 | 12.3k | } |
1409 | | |
1410 | | bool SvxCrossedOutItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
1411 | 485k | { |
1412 | 485k | nMemberId &= ~CONVERT_TWIPS; |
1413 | 485k | switch(nMemberId) |
1414 | 485k | { |
1415 | 0 | case MID_CROSSED_OUT: |
1416 | 0 | SetBoolValue(Any2Bool(rVal)); |
1417 | 0 | break; |
1418 | 485k | case MID_CROSS_OUT: |
1419 | 485k | { |
1420 | 485k | sal_Int32 nValue = 0; |
1421 | 485k | if(!(rVal >>= nValue)) |
1422 | 0 | return false; |
1423 | 485k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1424 | 485k | SetValue(static_cast<FontStrikeout>(nValue)); |
1425 | 485k | } |
1426 | 0 | break; |
1427 | 485k | } |
1428 | 485k | return true; |
1429 | 485k | } |
1430 | | // class SvxShadowedItem ------------------------------------------------- |
1431 | | |
1432 | | SvxShadowedItem::SvxShadowedItem( const bool bShadowed, const sal_uInt16 nId ) : |
1433 | 1.55M | SfxBoolItem( nId, bShadowed ) |
1434 | 1.55M | { |
1435 | 1.55M | } |
1436 | | |
1437 | | SvxShadowedItem* SvxShadowedItem::Clone( SfxItemPool * ) const |
1438 | 555k | { |
1439 | 555k | return new SvxShadowedItem( *this ); |
1440 | 555k | } |
1441 | | |
1442 | | bool SvxShadowedItem::GetPresentation |
1443 | | ( |
1444 | | SfxItemPresentation /*ePres*/, |
1445 | | MapUnit /*eCoreUnit*/, |
1446 | | MapUnit /*ePresUnit*/, |
1447 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
1448 | | ) const |
1449 | 0 | { |
1450 | 0 | TranslateId pId = RID_SVXITEMS_SHADOWED_FALSE; |
1451 | |
|
1452 | 0 | if ( GetValue() ) |
1453 | 0 | pId = RID_SVXITEMS_SHADOWED_TRUE; |
1454 | 0 | rText = EditResId(pId); |
1455 | 0 | return true; |
1456 | 0 | } |
1457 | | |
1458 | | // class SvxAutoKernItem ------------------------------------------------- |
1459 | | |
1460 | | SvxAutoKernItem::SvxAutoKernItem( const bool bAutoKern, const sal_uInt16 nId ) : |
1461 | 475k | SfxBoolItem( nId, bAutoKern ) |
1462 | 475k | { |
1463 | 475k | } |
1464 | | |
1465 | | SvxAutoKernItem* SvxAutoKernItem::Clone( SfxItemPool * ) const |
1466 | 483k | { |
1467 | 483k | return new SvxAutoKernItem( *this ); |
1468 | 483k | } |
1469 | | |
1470 | | bool SvxAutoKernItem::GetPresentation |
1471 | | ( |
1472 | | SfxItemPresentation /*ePres*/, |
1473 | | MapUnit /*eCoreUnit*/, |
1474 | | MapUnit /*ePresUnit*/, |
1475 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
1476 | | ) const |
1477 | 0 | { |
1478 | 0 | TranslateId pId = RID_SVXITEMS_AUTOKERN_FALSE; |
1479 | |
|
1480 | 0 | if ( GetValue() ) |
1481 | 0 | pId = RID_SVXITEMS_AUTOKERN_TRUE; |
1482 | 0 | rText = EditResId(pId); |
1483 | 0 | return true; |
1484 | 0 | } |
1485 | | |
1486 | | // class SvxWordLineModeItem --------------------------------------------- |
1487 | | |
1488 | | SvxWordLineModeItem::SvxWordLineModeItem( const bool bWordLineMode, |
1489 | | const sal_uInt16 nId ) : |
1490 | 1.12M | SfxBoolItem( nId, bWordLineMode ) |
1491 | 1.12M | { |
1492 | 1.12M | } |
1493 | | |
1494 | | SvxWordLineModeItem* SvxWordLineModeItem::Clone( SfxItemPool * ) const |
1495 | 158k | { |
1496 | 158k | return new SvxWordLineModeItem( *this ); |
1497 | 158k | } |
1498 | | |
1499 | | bool SvxWordLineModeItem::GetPresentation |
1500 | | ( |
1501 | | SfxItemPresentation /*ePres*/, |
1502 | | MapUnit /*eCoreUnit*/, |
1503 | | MapUnit /*ePresUnit*/, |
1504 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
1505 | | ) const |
1506 | 0 | { |
1507 | 0 | TranslateId pId = RID_SVXITEMS_WORDLINE_FALSE; |
1508 | |
|
1509 | 0 | if ( GetValue() ) |
1510 | 0 | pId = RID_SVXITEMS_WORDLINE_TRUE; |
1511 | 0 | rText = EditResId(pId); |
1512 | 0 | return true; |
1513 | 0 | } |
1514 | | |
1515 | | // class SvxContourItem -------------------------------------------------- |
1516 | | |
1517 | | SvxContourItem::SvxContourItem( const bool bContoured, const sal_uInt16 nId ) : |
1518 | 1.55M | SfxBoolItem( nId, bContoured ) |
1519 | 1.55M | { |
1520 | 1.55M | } |
1521 | | |
1522 | | SvxContourItem* SvxContourItem::Clone( SfxItemPool * ) const |
1523 | 835k | { |
1524 | 835k | return new SvxContourItem( *this ); |
1525 | 835k | } |
1526 | | |
1527 | | bool SvxContourItem::GetPresentation |
1528 | | ( |
1529 | | SfxItemPresentation /*ePres*/, |
1530 | | MapUnit /*eCoreUnit*/, |
1531 | | MapUnit /*ePresUnit*/, |
1532 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
1533 | | ) const |
1534 | 0 | { |
1535 | 0 | TranslateId pId = RID_SVXITEMS_CONTOUR_FALSE; |
1536 | |
|
1537 | 0 | if ( GetValue() ) |
1538 | 0 | pId = RID_SVXITEMS_CONTOUR_TRUE; |
1539 | 0 | rText = EditResId(pId); |
1540 | 0 | return true; |
1541 | 0 | } |
1542 | | |
1543 | | // class SvxColorItem ---------------------------------------------------- |
1544 | | SvxColorItem::SvxColorItem( const sal_uInt16 nId ) : |
1545 | 151k | SfxPoolItem(nId), |
1546 | 151k | mColor( COL_BLACK ) |
1547 | 151k | { |
1548 | 151k | } |
1549 | | |
1550 | | SvxColorItem::SvxColorItem( const Color& rCol, const sal_uInt16 nId ) : |
1551 | 1.64M | SfxPoolItem( nId ), |
1552 | 1.64M | mColor( rCol ) |
1553 | 1.64M | { |
1554 | 1.64M | } |
1555 | | |
1556 | | SvxColorItem::SvxColorItem(Color const& rColor, model::ComplexColor const& rComplexColor, const sal_uInt16 nId) |
1557 | 117k | : SfxPoolItem(nId) |
1558 | 117k | , mColor(rColor) |
1559 | 117k | , maComplexColor(rComplexColor) |
1560 | 117k | { |
1561 | 117k | } |
1562 | | |
1563 | | SvxColorItem::~SvxColorItem() |
1564 | 5.24M | { |
1565 | 5.24M | } |
1566 | | |
1567 | | bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const |
1568 | 5.52M | { |
1569 | 5.52M | assert(SfxPoolItem::operator==(rAttr)); |
1570 | 5.52M | const SvxColorItem& rColorItem = static_cast<const SvxColorItem&>(rAttr); |
1571 | | |
1572 | 5.52M | return mColor == rColorItem.mColor && |
1573 | 5.52M | maComplexColor == rColorItem.maComplexColor; |
1574 | 5.52M | } |
1575 | | |
1576 | | size_t SvxColorItem::hashCode() const |
1577 | 3.30M | { |
1578 | 3.30M | std::size_t seed(0); |
1579 | 3.30M | o3tl::hash_combine(seed, static_cast<sal_Int32>(mColor)); |
1580 | 3.30M | o3tl::hash_combine(seed, maComplexColor); |
1581 | 3.30M | return seed; |
1582 | 3.30M | } |
1583 | | |
1584 | | bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
1585 | 31.6k | { |
1586 | 31.6k | nMemberId &= ~CONVERT_TWIPS; |
1587 | 31.6k | switch (nMemberId) |
1588 | 31.6k | { |
1589 | 574 | case MID_COLOR_ALPHA: |
1590 | 574 | { |
1591 | 574 | auto fTransparency = static_cast<double>(255 - mColor.GetAlpha()) * 100 / 255; |
1592 | 574 | rVal <<= static_cast<sal_Int16>(basegfx::fround(fTransparency)); |
1593 | 574 | break; |
1594 | 0 | } |
1595 | 0 | case MID_GRAPHIC_TRANSPARENT: |
1596 | 0 | { |
1597 | 0 | rVal <<= mColor.GetAlpha() == 0; |
1598 | 0 | break; |
1599 | 0 | } |
1600 | 574 | case MID_COLOR_THEME_INDEX: |
1601 | 574 | { |
1602 | 574 | rVal <<= sal_Int16(maComplexColor.getThemeColorType()); |
1603 | 574 | break; |
1604 | 0 | } |
1605 | 574 | case MID_COLOR_TINT_OR_SHADE: |
1606 | 574 | { |
1607 | 574 | sal_Int16 nValue = 0; |
1608 | 574 | for (auto const& rTransform : maComplexColor.getTransformations()) |
1609 | 0 | { |
1610 | 0 | if (rTransform.meType == model::TransformationType::Tint) |
1611 | 0 | nValue = rTransform.mnValue; |
1612 | 0 | else if (rTransform.meType == model::TransformationType::Shade) |
1613 | 0 | nValue = -rTransform.mnValue; |
1614 | 0 | } |
1615 | 574 | rVal <<= nValue; |
1616 | 574 | break; |
1617 | 0 | } |
1618 | 0 | case MID_COLOR_LUM_MOD: |
1619 | 0 | { |
1620 | 0 | sal_Int16 nValue = 10000; |
1621 | 0 | for (auto const& rTransform : maComplexColor.getTransformations()) |
1622 | 0 | { |
1623 | 0 | if (rTransform.meType == model::TransformationType::LumMod) |
1624 | 0 | nValue = rTransform.mnValue; |
1625 | 0 | } |
1626 | 0 | rVal <<= nValue; |
1627 | 0 | break; |
1628 | 0 | } |
1629 | 0 | case MID_COLOR_LUM_OFF: |
1630 | 0 | { |
1631 | 0 | sal_Int16 nValue = 0; |
1632 | 0 | for (auto const& rTransform : maComplexColor.getTransformations()) |
1633 | 0 | { |
1634 | 0 | if (rTransform.meType == model::TransformationType::LumOff) |
1635 | 0 | nValue = rTransform.mnValue; |
1636 | 0 | } |
1637 | 0 | rVal <<= nValue; |
1638 | 0 | break; |
1639 | 0 | } |
1640 | 0 | case MID_COMPLEX_COLOR_JSON: |
1641 | 0 | { |
1642 | 0 | rVal <<= OStringToOUString(model::color::convertToJSON(maComplexColor), RTL_TEXTENCODING_UTF8); |
1643 | 0 | break; |
1644 | 0 | } |
1645 | 17.1k | case MID_COMPLEX_COLOR: |
1646 | 17.1k | { |
1647 | 17.1k | auto xComplexColor = model::color::createXComplexColor(maComplexColor); |
1648 | 17.1k | rVal <<= xComplexColor; |
1649 | 17.1k | break; |
1650 | 0 | } |
1651 | 12.8k | case MID_COLOR_RGB: |
1652 | 12.8k | default: |
1653 | 12.8k | { |
1654 | 12.8k | rVal <<= mColor; |
1655 | 12.8k | break; |
1656 | 12.8k | } |
1657 | 31.6k | } |
1658 | 31.6k | return true; |
1659 | 31.6k | } |
1660 | | |
1661 | | bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
1662 | 1.11M | { |
1663 | 1.11M | ASSERT_CHANGE_REFCOUNTED_ITEM; |
1664 | 1.11M | nMemberId &= ~CONVERT_TWIPS; |
1665 | 1.11M | switch(nMemberId) |
1666 | 1.11M | { |
1667 | 574 | case MID_COLOR_ALPHA: |
1668 | 574 | { |
1669 | 574 | sal_Int16 nTransparency = 0; |
1670 | 574 | bool bRet = rVal >>= nTransparency; |
1671 | 574 | if (bRet) |
1672 | 574 | { |
1673 | 574 | auto fTransparency = static_cast<double>(nTransparency) * 255 / 100; |
1674 | 574 | mColor.SetAlpha(255 - static_cast<sal_uInt8>(basegfx::fround(fTransparency))); |
1675 | 574 | } |
1676 | 574 | return bRet; |
1677 | 0 | } |
1678 | 0 | case MID_GRAPHIC_TRANSPARENT: |
1679 | 0 | { |
1680 | 0 | mColor.SetAlpha( Any2Bool( rVal ) ? 0 : 255 ); |
1681 | 0 | return true; |
1682 | 0 | } |
1683 | 574 | case MID_COLOR_THEME_INDEX: |
1684 | 574 | { |
1685 | 574 | sal_Int16 nIndex = -1; |
1686 | 574 | if (!(rVal >>= nIndex)) |
1687 | 0 | return false; |
1688 | 574 | maComplexColor.setThemeColor(model::convertToThemeColorType(nIndex)); |
1689 | 574 | } |
1690 | 0 | break; |
1691 | 574 | case MID_COLOR_TINT_OR_SHADE: |
1692 | 574 | { |
1693 | 574 | sal_Int16 nTintShade = 0; |
1694 | 574 | if (!(rVal >>= nTintShade)) |
1695 | 0 | return false; |
1696 | | |
1697 | 574 | maComplexColor.removeTransformations(model::TransformationType::Tint); |
1698 | 574 | maComplexColor.removeTransformations(model::TransformationType::Shade); |
1699 | | |
1700 | 574 | if (nTintShade > 0) |
1701 | 0 | maComplexColor.addTransformation({model::TransformationType::Tint, nTintShade}); |
1702 | 574 | else if (nTintShade < 0) |
1703 | 0 | { |
1704 | 0 | sal_Int16 nShade = o3tl::narrowing<sal_Int16>(-nTintShade); |
1705 | 0 | maComplexColor.addTransformation({model::TransformationType::Shade, nShade}); |
1706 | 0 | } |
1707 | 574 | } |
1708 | 0 | break; |
1709 | 0 | case MID_COLOR_LUM_MOD: |
1710 | 0 | { |
1711 | 0 | sal_Int16 nLumMod = 10000; |
1712 | 0 | if (!(rVal >>= nLumMod)) |
1713 | 0 | return false; |
1714 | 0 | maComplexColor.removeTransformations(model::TransformationType::LumMod); |
1715 | 0 | maComplexColor.addTransformation({model::TransformationType::LumMod, nLumMod}); |
1716 | 0 | } |
1717 | 0 | break; |
1718 | 0 | case MID_COLOR_LUM_OFF: |
1719 | 0 | { |
1720 | 0 | sal_Int16 nLumOff = 0; |
1721 | 0 | if (!(rVal >>= nLumOff)) |
1722 | 0 | return false; |
1723 | 0 | maComplexColor.removeTransformations(model::TransformationType::LumOff); |
1724 | 0 | maComplexColor.addTransformation({model::TransformationType::LumOff, nLumOff}); |
1725 | 0 | } |
1726 | 0 | break; |
1727 | 0 | case MID_COMPLEX_COLOR_JSON: |
1728 | 0 | { |
1729 | 0 | OUString sComplexColorJson; |
1730 | 0 | if (!(rVal >>= sComplexColorJson)) |
1731 | 0 | return false; |
1732 | | |
1733 | 0 | if (sComplexColorJson.isEmpty()) |
1734 | 0 | return false; |
1735 | | |
1736 | 0 | OString aJSON = OUStringToOString(sComplexColorJson, RTL_TEXTENCODING_ASCII_US); |
1737 | 0 | if (!model::color::convertFromJSON(aJSON, maComplexColor)) |
1738 | 0 | return false; |
1739 | 0 | } |
1740 | 0 | break; |
1741 | 304k | case MID_COMPLEX_COLOR: |
1742 | 304k | { |
1743 | 304k | css::uno::Reference<css::util::XComplexColor> xComplexColor; |
1744 | 304k | if (!(rVal >>= xComplexColor)) |
1745 | 0 | return false; |
1746 | | |
1747 | 304k | if (xComplexColor.is()) |
1748 | 304k | maComplexColor = model::color::getFromXComplexColor(xComplexColor); |
1749 | 304k | } |
1750 | 0 | break; |
1751 | 804k | case MID_COLOR_RGB: |
1752 | 804k | default: |
1753 | 804k | { |
1754 | 804k | if (!(rVal >>= mColor)) |
1755 | 584 | return false; |
1756 | 804k | } |
1757 | 803k | break; |
1758 | 1.11M | } |
1759 | 1.10M | return true; |
1760 | 1.11M | } |
1761 | | |
1762 | | SvxColorItem* SvxColorItem::Clone( SfxItemPool * ) const |
1763 | 3.17M | { |
1764 | 3.17M | return new SvxColorItem( *this ); |
1765 | 3.17M | } |
1766 | | |
1767 | | bool SvxColorItem::GetPresentation |
1768 | | ( |
1769 | | SfxItemPresentation /*ePres*/, |
1770 | | MapUnit /*eCoreUnit*/, |
1771 | | MapUnit /*ePresUnit*/, |
1772 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
1773 | | ) const |
1774 | 0 | { |
1775 | 0 | rText = ::GetColorString( mColor ); |
1776 | 0 | return true; |
1777 | 0 | } |
1778 | | |
1779 | | void SvxColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
1780 | 0 | { |
1781 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxColorItem")); |
1782 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
1783 | |
|
1784 | 0 | std::stringstream ss; |
1785 | 0 | ss << mColor; |
1786 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(ss.str().c_str())); |
1787 | |
|
1788 | 0 | OUString aStr; |
1789 | 0 | IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag()); |
1790 | 0 | GetPresentation( SfxItemPresentation::Complete, MapUnit::Map100thMM, MapUnit::Map100thMM, aStr, aIntlWrapper); |
1791 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(OUStringToOString(aStr, RTL_TEXTENCODING_UTF8).getStr())); |
1792 | |
|
1793 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("complex-color")); |
1794 | |
|
1795 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), |
1796 | 0 | BAD_CAST(OString::number(sal_Int16(maComplexColor.getType())).getStr())); |
1797 | |
|
1798 | 0 | for (auto const& rTransform : maComplexColor.getTransformations()) |
1799 | 0 | { |
1800 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("transformation")); |
1801 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), |
1802 | 0 | BAD_CAST(OString::number(sal_Int16(rTransform.meType)).getStr())); |
1803 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
1804 | 0 | BAD_CAST(OString::number(rTransform.mnValue).getStr())); |
1805 | 0 | (void)xmlTextWriterEndElement(pWriter); |
1806 | 0 | } |
1807 | |
|
1808 | 0 | (void)xmlTextWriterEndElement(pWriter); |
1809 | |
|
1810 | 0 | (void)xmlTextWriterEndElement(pWriter); |
1811 | 0 | } |
1812 | | |
1813 | | // class SvxKerningItem -------------------------------------------------- |
1814 | | |
1815 | | SvxKerningItem::SvxKerningItem( const short nKern, const sal_uInt16 nId ) : |
1816 | 20.9k | SfxInt16Item( nId, nKern ) |
1817 | 20.9k | { |
1818 | 20.9k | } |
1819 | | |
1820 | | SvxKerningItem* SvxKerningItem::Clone( SfxItemPool * ) const |
1821 | 530k | { |
1822 | 530k | return new SvxKerningItem( *this ); |
1823 | 530k | } |
1824 | | |
1825 | | void SvxKerningItem::ScaleMetrics( tools::Long nMult, tools::Long nDiv ) |
1826 | 0 | { |
1827 | 0 | SetValue( static_cast<sal_Int16>(BigInt::Scale( GetValue(), nMult, nDiv )) ); |
1828 | 0 | } |
1829 | | |
1830 | | |
1831 | | bool SvxKerningItem::HasMetrics() const |
1832 | 0 | { |
1833 | 0 | return true; |
1834 | 0 | } |
1835 | | |
1836 | | |
1837 | | bool SvxKerningItem::GetPresentation |
1838 | | ( |
1839 | | SfxItemPresentation ePres, |
1840 | | MapUnit eCoreUnit, |
1841 | | MapUnit /*ePresUnit*/, |
1842 | | OUString& rText, const IntlWrapper& rIntl |
1843 | | ) const |
1844 | 0 | { |
1845 | 0 | switch ( ePres ) |
1846 | 0 | { |
1847 | 0 | case SfxItemPresentation::Nameless: |
1848 | 0 | rText = GetMetricText( static_cast<tools::Long>(GetValue()), eCoreUnit, MapUnit::MapPoint, &rIntl ) + |
1849 | 0 | " " + EditResId(GetMetricId(MapUnit::MapPoint)); |
1850 | 0 | return true; |
1851 | 0 | case SfxItemPresentation::Complete: |
1852 | 0 | { |
1853 | 0 | rText = EditResId(RID_SVXITEMS_KERNING_COMPLETE); |
1854 | 0 | TranslateId pId; |
1855 | |
|
1856 | 0 | if ( GetValue() > 0 ) |
1857 | 0 | pId = RID_SVXITEMS_KERNING_EXPANDED; |
1858 | 0 | else if ( GetValue() < 0 ) |
1859 | 0 | pId = RID_SVXITEMS_KERNING_CONDENSED; |
1860 | |
|
1861 | 0 | if (pId) |
1862 | 0 | rText += EditResId(pId); |
1863 | 0 | rText += GetMetricText( static_cast<tools::Long>(GetValue()), eCoreUnit, MapUnit::MapPoint, &rIntl ) + |
1864 | 0 | " " + EditResId(GetMetricId(MapUnit::MapPoint)); |
1865 | 0 | return true; |
1866 | 0 | } |
1867 | 0 | default: ; //prevent warning |
1868 | 0 | } |
1869 | 0 | return false; |
1870 | 0 | } |
1871 | | |
1872 | | bool SvxKerningItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
1873 | 0 | { |
1874 | 0 | sal_Int16 nVal = GetValue(); |
1875 | 0 | if(nMemberId & CONVERT_TWIPS) |
1876 | 0 | nVal = static_cast<sal_Int16>(convertTwipToMm100(nVal)); |
1877 | 0 | rVal <<= nVal; |
1878 | 0 | return true; |
1879 | 0 | } |
1880 | | |
1881 | | bool SvxKerningItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId) |
1882 | 464k | { |
1883 | 464k | sal_Int16 nVal = sal_Int16(); |
1884 | 464k | if(!(rVal >>= nVal)) |
1885 | 0 | return false; |
1886 | 464k | if(nMemberId & CONVERT_TWIPS) |
1887 | 13.8k | nVal = o3tl::toTwips(nVal, o3tl::Length::mm100); |
1888 | 464k | SetValue(nVal); |
1889 | 464k | return true; |
1890 | 464k | } |
1891 | | |
1892 | | // class SvxCaseMapItem -------------------------------------------------- |
1893 | | |
1894 | | SvxCaseMapItem::SvxCaseMapItem( const SvxCaseMap eMap, const sal_uInt16 nId ) : |
1895 | 393k | SfxEnumItem( nId, eMap ) |
1896 | 393k | { |
1897 | 393k | } |
1898 | | |
1899 | | SvxCaseMapItem* SvxCaseMapItem::Clone( SfxItemPool * ) const |
1900 | 779k | { |
1901 | 779k | return new SvxCaseMapItem( *this ); |
1902 | 779k | } |
1903 | | |
1904 | | bool SvxCaseMapItem::GetPresentation |
1905 | | ( |
1906 | | SfxItemPresentation /*ePres*/, |
1907 | | MapUnit /*eCoreUnit*/, |
1908 | | MapUnit /*ePresUnit*/, |
1909 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
1910 | | ) const |
1911 | 0 | { |
1912 | 0 | rText = GetValueTextByPos( static_cast<sal_uInt16>(GetValue()) ); |
1913 | 0 | return true; |
1914 | 0 | } |
1915 | | |
1916 | | OUString SvxCaseMapItem::GetValueTextByPos( sal_uInt16 nPos ) |
1917 | 0 | { |
1918 | 0 | static TranslateId RID_SVXITEMS_CASEMAP[] = |
1919 | 0 | { |
1920 | 0 | RID_SVXITEMS_CASEMAP_NONE, |
1921 | 0 | RID_SVXITEMS_CASEMAP_UPPERCASE, |
1922 | 0 | RID_SVXITEMS_CASEMAP_LOWERCASE, |
1923 | 0 | RID_SVXITEMS_CASEMAP_TITLE, |
1924 | 0 | RID_SVXITEMS_CASEMAP_SMALLCAPS |
1925 | 0 | }; |
1926 | |
|
1927 | 0 | static_assert(std::size(RID_SVXITEMS_CASEMAP) == size_t(SvxCaseMap::End), "must match"); |
1928 | 0 | assert(nPos < sal_uInt16(SvxCaseMap::End) && "enum overflow!"); |
1929 | 0 | return EditResId(RID_SVXITEMS_CASEMAP[nPos]); |
1930 | 0 | } |
1931 | | |
1932 | | bool SvxCaseMapItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const |
1933 | 1.36k | { |
1934 | 1.36k | sal_Int16 nRet = style::CaseMap::NONE; |
1935 | 1.36k | switch( GetValue() ) |
1936 | 1.36k | { |
1937 | 0 | case SvxCaseMap::Uppercase : nRet = style::CaseMap::UPPERCASE; break; |
1938 | 0 | case SvxCaseMap::Lowercase : nRet = style::CaseMap::LOWERCASE; break; |
1939 | 0 | case SvxCaseMap::Capitalize : nRet = style::CaseMap::TITLE ; break; |
1940 | 32 | case SvxCaseMap::SmallCaps: nRet = style::CaseMap::SMALLCAPS; break; |
1941 | 1.33k | default: break; |
1942 | 1.36k | } |
1943 | 1.36k | rVal <<= nRet; |
1944 | 1.36k | return true; |
1945 | 1.36k | } |
1946 | | |
1947 | | bool SvxCaseMapItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) |
1948 | 455k | { |
1949 | 455k | sal_uInt16 nVal = sal_uInt16(); |
1950 | 455k | if(!(rVal >>= nVal)) |
1951 | 0 | return false; |
1952 | | |
1953 | 455k | SvxCaseMap eVal; |
1954 | 455k | switch( nVal ) |
1955 | 455k | { |
1956 | 454k | case style::CaseMap::NONE : eVal = SvxCaseMap::NotMapped; break; |
1957 | 1.43k | case style::CaseMap::UPPERCASE: eVal = SvxCaseMap::Uppercase; break; |
1958 | 0 | case style::CaseMap::LOWERCASE: eVal = SvxCaseMap::Lowercase; break; |
1959 | 0 | case style::CaseMap::TITLE : eVal = SvxCaseMap::Capitalize; break; |
1960 | 332 | case style::CaseMap::SMALLCAPS: eVal = SvxCaseMap::SmallCaps; break; |
1961 | 0 | default: return false; |
1962 | 455k | } |
1963 | 455k | SetValue(eVal); |
1964 | 455k | return true; |
1965 | 455k | } |
1966 | | |
1967 | | // class SvxEscapementItem ----------------------------------------------- |
1968 | | |
1969 | | SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId ) : |
1970 | 186 | SfxPoolItem( nId ), |
1971 | | |
1972 | 186 | nEsc ( 0 ), |
1973 | 186 | nProp ( 100 ) |
1974 | 186 | { |
1975 | 186 | } |
1976 | | |
1977 | | |
1978 | | SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape, |
1979 | | const sal_uInt16 nId ) : |
1980 | 14.5k | SfxPoolItem( nId ), |
1981 | 14.5k | nProp( 100 ) |
1982 | 14.5k | { |
1983 | 14.5k | SetEscapement( eEscape ); |
1984 | 14.5k | if( nEsc ) |
1985 | 1.35k | nProp = DFLT_ESC_PROP; |
1986 | 14.5k | } |
1987 | | |
1988 | | |
1989 | | SvxEscapementItem::SvxEscapementItem( const short _nEsc, |
1990 | | const sal_uInt8 _nProp, |
1991 | | const sal_uInt16 nId ) : |
1992 | 164k | SfxPoolItem( nId ), |
1993 | 164k | nEsc ( _nEsc ), |
1994 | 164k | nProp ( _nProp ) |
1995 | 164k | { |
1996 | 164k | } |
1997 | | |
1998 | | bool SvxEscapementItem::operator==( const SfxPoolItem& rAttr ) const |
1999 | 2.65M | { |
2000 | 2.65M | assert(SfxPoolItem::operator==(rAttr)); |
2001 | | |
2002 | 2.65M | return( nEsc == static_cast<const SvxEscapementItem&>(rAttr).nEsc && |
2003 | 2.65M | nProp == static_cast<const SvxEscapementItem&>(rAttr).nProp ); |
2004 | 2.65M | } |
2005 | | |
2006 | | SvxEscapementItem* SvxEscapementItem::Clone( SfxItemPool * ) const |
2007 | 1.12M | { |
2008 | 1.12M | return new SvxEscapementItem( *this ); |
2009 | 1.12M | } |
2010 | | |
2011 | | bool SvxEscapementItem::GetPresentation |
2012 | | ( |
2013 | | SfxItemPresentation /*ePres*/, |
2014 | | MapUnit /*eCoreUnit*/, |
2015 | | MapUnit /*ePresUnit*/, |
2016 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
2017 | | ) const |
2018 | 0 | { |
2019 | 0 | static constexpr TranslateId RID_SVXITEMS_ESCAPEMENT[] = |
2020 | 0 | { |
2021 | 0 | RID_SVXITEMS_ESCAPEMENT_OFF, |
2022 | 0 | RID_SVXITEMS_ESCAPEMENT_SUPER, |
2023 | 0 | RID_SVXITEMS_ESCAPEMENT_SUB |
2024 | 0 | }; |
2025 | |
|
2026 | 0 | SvxEscapement pos = GetEscapement(); |
2027 | 0 | static_assert(std::size(RID_SVXITEMS_ESCAPEMENT) == size_t(SvxEscapement::End), "must match"); |
2028 | 0 | assert(pos < SvxEscapement::End && "enum overflow!"); |
2029 | 0 | rText = EditResId(RID_SVXITEMS_ESCAPEMENT[static_cast<size_t>(pos)]); |
2030 | |
|
2031 | 0 | if ( nEsc != 0 ) |
2032 | 0 | { |
2033 | 0 | if( DFLT_ESC_AUTO_SUPER == nEsc || DFLT_ESC_AUTO_SUB == nEsc ) |
2034 | 0 | rText += EditResId(RID_SVXITEMS_ESCAPEMENT_AUTO); |
2035 | 0 | else |
2036 | 0 | rText += OUString::number( nEsc ) + "%"; |
2037 | 0 | } |
2038 | 0 | return true; |
2039 | 0 | } |
2040 | | |
2041 | | SvxEscapement SvxEscapementItem::GetEscapement() const |
2042 | 902k | { |
2043 | 902k | if ( nEsc < 0 ) |
2044 | 48.1k | return SvxEscapement::Subscript; |
2045 | 854k | else if ( nEsc > 0 ) |
2046 | 43.1k | return SvxEscapement::Superscript; |
2047 | 811k | return SvxEscapement::Off; |
2048 | 902k | } |
2049 | | |
2050 | | bool SvxEscapementItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
2051 | 0 | { |
2052 | 0 | nMemberId &= ~CONVERT_TWIPS; |
2053 | 0 | switch(nMemberId) |
2054 | 0 | { |
2055 | 0 | case MID_ESC: |
2056 | 0 | rVal <<= static_cast<sal_Int16>(nEsc); |
2057 | 0 | break; |
2058 | 0 | case MID_ESC_HEIGHT: |
2059 | 0 | rVal <<= static_cast<sal_Int8>(nProp); |
2060 | 0 | break; |
2061 | 0 | case MID_AUTO_ESC: |
2062 | 0 | rVal <<= (DFLT_ESC_AUTO_SUB == nEsc || DFLT_ESC_AUTO_SUPER == nEsc); |
2063 | 0 | break; |
2064 | 0 | } |
2065 | 0 | return true; |
2066 | 0 | } |
2067 | | |
2068 | | bool SvxEscapementItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
2069 | 997k | { |
2070 | 997k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
2071 | 997k | nMemberId &= ~CONVERT_TWIPS; |
2072 | 997k | switch(nMemberId) |
2073 | 997k | { |
2074 | 498k | case MID_ESC: |
2075 | 498k | { |
2076 | 498k | sal_Int16 nVal = sal_Int16(); |
2077 | 498k | if( (rVal >>= nVal) && (std::abs(nVal) <= MAX_ESC_POS+1)) |
2078 | 498k | nEsc = nVal; |
2079 | 0 | else |
2080 | 0 | return false; |
2081 | 498k | } |
2082 | 498k | break; |
2083 | 498k | case MID_ESC_HEIGHT: |
2084 | 498k | { |
2085 | 498k | sal_Int8 nVal = sal_Int8(); |
2086 | 498k | if( (rVal >>= nVal) && (nVal <= 100)) |
2087 | 498k | nProp = nVal; |
2088 | 3 | else |
2089 | 3 | return false; |
2090 | 498k | } |
2091 | 498k | break; |
2092 | 498k | case MID_AUTO_ESC: |
2093 | 0 | { |
2094 | 0 | bool bVal = Any2Bool(rVal); |
2095 | 0 | if(bVal) |
2096 | 0 | { |
2097 | 0 | if(nEsc < 0) |
2098 | 0 | nEsc = DFLT_ESC_AUTO_SUB; |
2099 | 0 | else |
2100 | 0 | nEsc = DFLT_ESC_AUTO_SUPER; |
2101 | 0 | } |
2102 | 0 | else |
2103 | 0 | if(DFLT_ESC_AUTO_SUPER == nEsc ) |
2104 | 0 | --nEsc; |
2105 | 0 | else if(DFLT_ESC_AUTO_SUB == nEsc) |
2106 | 0 | ++nEsc; |
2107 | 0 | } |
2108 | 0 | break; |
2109 | 997k | } |
2110 | 997k | return true; |
2111 | 997k | } |
2112 | | |
2113 | | // class SvxLanguageItem ------------------------------------------------- |
2114 | | |
2115 | | ItemInstanceManager* SvxLanguageItem::getItemInstanceManager() const |
2116 | 7.49M | { |
2117 | 7.49M | static DefaultItemInstanceManager aInstanceManager(ItemType()); |
2118 | 7.49M | return &aInstanceManager; |
2119 | 7.49M | } |
2120 | | |
2121 | | SvxLanguageItem::SvxLanguageItem( const LanguageType eLang, const sal_uInt16 nId ) |
2122 | 5.30M | : SvxLanguageItem_Base( nId , eLang ) |
2123 | 5.30M | { |
2124 | 5.30M | } |
2125 | | |
2126 | | |
2127 | | SvxLanguageItem* SvxLanguageItem::Clone( SfxItemPool * ) const |
2128 | 2.67M | { |
2129 | 2.67M | return new SvxLanguageItem( *this ); |
2130 | 2.67M | } |
2131 | | |
2132 | | bool SvxLanguageItem::GetPresentation |
2133 | | ( |
2134 | | SfxItemPresentation /*ePres*/, |
2135 | | MapUnit /*eCoreUnit*/, |
2136 | | MapUnit /*ePresUnit*/, |
2137 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
2138 | | ) const |
2139 | 0 | { |
2140 | 0 | rText = SvtLanguageTable::GetLanguageString( GetValue() ); |
2141 | 0 | return true; |
2142 | 0 | } |
2143 | | |
2144 | | bool SvxLanguageItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
2145 | 1.38k | { |
2146 | 1.38k | nMemberId &= ~CONVERT_TWIPS; |
2147 | 1.38k | switch(nMemberId) |
2148 | 1.38k | { |
2149 | 0 | case MID_LANG_INT: // for basic conversions! |
2150 | 0 | rVal <<= static_cast<sal_Int16>(static_cast<sal_uInt16>(GetValue())); |
2151 | 0 | break; |
2152 | 1.38k | case MID_LANG_LOCALE: |
2153 | 1.38k | lang::Locale aRet( LanguageTag::convertToLocale( GetValue(), false)); |
2154 | 1.38k | rVal <<= aRet; |
2155 | 1.38k | break; |
2156 | 1.38k | } |
2157 | 1.38k | return true; |
2158 | 1.38k | } |
2159 | | |
2160 | | bool SvxLanguageItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
2161 | 234k | { |
2162 | 234k | nMemberId &= ~CONVERT_TWIPS; |
2163 | 234k | switch(nMemberId) |
2164 | 234k | { |
2165 | 0 | case MID_LANG_INT: // for basic conversions! |
2166 | 0 | { |
2167 | 0 | sal_Int32 nValue = 0; |
2168 | 0 | if(!(rVal >>= nValue)) |
2169 | 0 | return false; |
2170 | | |
2171 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
2172 | 0 | SetValue(LanguageType(nValue)); |
2173 | 0 | } |
2174 | 0 | break; |
2175 | 234k | case MID_LANG_LOCALE: |
2176 | 234k | { |
2177 | 234k | lang::Locale aLocale; |
2178 | 234k | if(!(rVal >>= aLocale)) |
2179 | 0 | return false; |
2180 | | |
2181 | 234k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
2182 | 234k | SetValue( LanguageTag::convertToLanguageType( aLocale, false)); |
2183 | 234k | } |
2184 | 0 | break; |
2185 | 234k | } |
2186 | 234k | return true; |
2187 | 234k | } |
2188 | | |
2189 | | // class SvxNoHyphenItem ------------------------------------------------- |
2190 | | |
2191 | | SvxNoHyphenItem::SvxNoHyphenItem( const bool bNoHyphen, const sal_uInt16 nId ) : |
2192 | 9 | SfxBoolItem( nId, bNoHyphen ) |
2193 | 9 | { |
2194 | 9 | } |
2195 | | |
2196 | | SvxNoHyphenItem* SvxNoHyphenItem::Clone( SfxItemPool* ) const |
2197 | 0 | { |
2198 | 0 | return new SvxNoHyphenItem( *this ); |
2199 | 0 | } |
2200 | | |
2201 | | bool SvxNoHyphenItem::GetPresentation |
2202 | | ( |
2203 | | SfxItemPresentation /*ePres*/, |
2204 | | MapUnit /*eCoreUnit*/, |
2205 | | MapUnit /*ePresUnit*/, |
2206 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
2207 | | ) const |
2208 | 0 | { |
2209 | 0 | if ( GetValue() ) |
2210 | 0 | rText = EditResId(RID_SVXITEMS_NOHYPHENATION_TRUE); |
2211 | 0 | else |
2212 | 0 | rText.clear(); |
2213 | |
|
2214 | 0 | return GetValue(); |
2215 | 0 | } |
2216 | | |
2217 | | /* |
2218 | | * Dummy item for ToolBox controls: |
2219 | | * |
2220 | | */ |
2221 | | |
2222 | | |
2223 | | // class SvxBlinkItem ------------------------------------------------- |
2224 | | |
2225 | | |
2226 | | SvxBlinkItem::SvxBlinkItem( const bool bBlink, const sal_uInt16 nId ) : |
2227 | 4.67k | SfxBoolItem( nId, bBlink ) |
2228 | 4.67k | { |
2229 | 4.67k | } |
2230 | | |
2231 | | SvxBlinkItem* SvxBlinkItem::Clone( SfxItemPool * ) const |
2232 | 25.3k | { |
2233 | 25.3k | return new SvxBlinkItem( *this ); |
2234 | 25.3k | } |
2235 | | |
2236 | | bool SvxBlinkItem::GetPresentation |
2237 | | ( |
2238 | | SfxItemPresentation /*ePres*/, |
2239 | | MapUnit /*eCoreUnit*/, |
2240 | | MapUnit /*ePresUnit*/, |
2241 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
2242 | | ) const |
2243 | 0 | { |
2244 | 0 | TranslateId pId = RID_SVXITEMS_BLINK_FALSE; |
2245 | |
|
2246 | 0 | if ( GetValue() ) |
2247 | 0 | pId = RID_SVXITEMS_BLINK_TRUE; |
2248 | 0 | rText = EditResId(pId); |
2249 | 0 | return true; |
2250 | 0 | } |
2251 | | |
2252 | | // class SvxEmphaisMarkItem --------------------------------------------------- |
2253 | | |
2254 | | ItemInstanceManager* SvxEmphasisMarkItem::getItemInstanceManager() const |
2255 | 1.51M | { |
2256 | 1.51M | static DefaultItemInstanceManager aInstanceManager(ItemType()); |
2257 | 1.51M | return &aInstanceManager; |
2258 | 1.51M | } |
2259 | | |
2260 | | SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue, |
2261 | | TypedWhichId<SvxEmphasisMarkItem> nId ) |
2262 | 1.36M | : SfxUInt16Item( nId, static_cast<sal_uInt16>(nValue) ) |
2263 | 1.36M | { |
2264 | 1.36M | } |
2265 | | |
2266 | | SvxEmphasisMarkItem* SvxEmphasisMarkItem::Clone( SfxItemPool * ) const |
2267 | 152k | { |
2268 | 152k | return new SvxEmphasisMarkItem( *this ); |
2269 | 152k | } |
2270 | | |
2271 | | bool SvxEmphasisMarkItem::GetPresentation |
2272 | | ( |
2273 | | SfxItemPresentation /*ePres*/, |
2274 | | MapUnit /*eCoreUnit*/, |
2275 | | MapUnit /*ePresUnit*/, |
2276 | | OUString& rText, |
2277 | | const IntlWrapper& /*rIntl*/ |
2278 | | ) const |
2279 | 0 | { |
2280 | 0 | static TranslateId RID_SVXITEMS_EMPHASIS[] = |
2281 | 0 | { |
2282 | 0 | RID_SVXITEMS_EMPHASIS_NONE_STYLE, |
2283 | 0 | RID_SVXITEMS_EMPHASIS_DOT_STYLE, |
2284 | 0 | RID_SVXITEMS_EMPHASIS_CIRCLE_STYLE, |
2285 | 0 | RID_SVXITEMS_EMPHASIS_DISC_STYLE, |
2286 | 0 | RID_SVXITEMS_EMPHASIS_ACCENT_STYLE |
2287 | 0 | }; |
2288 | |
|
2289 | 0 | FontEmphasisMark nVal = GetEmphasisMark(); |
2290 | 0 | rText = EditResId(RID_SVXITEMS_EMPHASIS[ |
2291 | 0 | static_cast<sal_uInt16>(static_cast<FontEmphasisMark>( nVal & FontEmphasisMark::Style ))]); |
2292 | 0 | TranslateId pId = ( FontEmphasisMark::PosAbove & nVal ) |
2293 | 0 | ? RID_SVXITEMS_EMPHASIS_ABOVE_POS |
2294 | 0 | : ( FontEmphasisMark::PosBelow & nVal ) |
2295 | 0 | ? RID_SVXITEMS_EMPHASIS_BELOW_POS |
2296 | 0 | : TranslateId(); |
2297 | 0 | if( pId ) |
2298 | 0 | rText += EditResId( pId ); |
2299 | 0 | return true; |
2300 | 0 | } |
2301 | | |
2302 | | bool SvxEmphasisMarkItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const |
2303 | 0 | { |
2304 | 0 | nMemberId &= ~CONVERT_TWIPS; |
2305 | 0 | switch( nMemberId ) |
2306 | 0 | { |
2307 | 0 | case MID_EMPHASIS: |
2308 | 0 | { |
2309 | 0 | FontEmphasisMark nValue = GetEmphasisMark(); |
2310 | 0 | sal_Int16 nRet = 0; |
2311 | 0 | switch(nValue & FontEmphasisMark::Style) |
2312 | 0 | { |
2313 | 0 | case FontEmphasisMark::NONE : nRet = FontEmphasis::NONE; break; |
2314 | 0 | case FontEmphasisMark::Dot : nRet = FontEmphasis::DOT_ABOVE; break; |
2315 | 0 | case FontEmphasisMark::Circle : nRet = FontEmphasis::CIRCLE_ABOVE; break; |
2316 | 0 | case FontEmphasisMark::Disc : nRet = FontEmphasis::DISK_ABOVE; break; |
2317 | 0 | case FontEmphasisMark::Accent : nRet = FontEmphasis::ACCENT_ABOVE; break; |
2318 | 0 | default: break; |
2319 | 0 | } |
2320 | 0 | if(nRet && nValue & FontEmphasisMark::PosBelow) |
2321 | 0 | nRet += 10; |
2322 | 0 | rVal <<= nRet; |
2323 | 0 | } |
2324 | 0 | break; |
2325 | 0 | } |
2326 | 0 | return true; |
2327 | 0 | } |
2328 | | |
2329 | | bool SvxEmphasisMarkItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) |
2330 | 1.41k | { |
2331 | 1.41k | nMemberId &= ~CONVERT_TWIPS; |
2332 | 1.41k | switch( nMemberId ) |
2333 | 1.41k | { |
2334 | 1.41k | case MID_EMPHASIS: |
2335 | 1.41k | { |
2336 | 1.41k | sal_Int32 nValue = -1; |
2337 | 1.41k | rVal >>= nValue; |
2338 | 1.41k | FontEmphasisMark nMark; |
2339 | 1.41k | switch(nValue) |
2340 | 1.41k | { |
2341 | 1.41k | case FontEmphasis::NONE : nMark = FontEmphasisMark::NONE; break; |
2342 | 0 | case FontEmphasis::DOT_ABOVE : nMark = FontEmphasisMark::Dot|FontEmphasisMark::PosAbove; break; |
2343 | 0 | case FontEmphasis::CIRCLE_ABOVE: nMark = FontEmphasisMark::Circle|FontEmphasisMark::PosAbove; break; |
2344 | 0 | case FontEmphasis::DISK_ABOVE : nMark = FontEmphasisMark::Disc|FontEmphasisMark::PosAbove; break; |
2345 | 0 | case FontEmphasis::ACCENT_ABOVE: nMark = FontEmphasisMark::Accent|FontEmphasisMark::PosAbove; break; |
2346 | 0 | case FontEmphasis::DOT_BELOW : nMark = FontEmphasisMark::Dot|FontEmphasisMark::PosBelow; break; |
2347 | 0 | case FontEmphasis::CIRCLE_BELOW: nMark = FontEmphasisMark::Circle|FontEmphasisMark::PosBelow; break; |
2348 | 0 | case FontEmphasis::DISK_BELOW : nMark = FontEmphasisMark::Disc|FontEmphasisMark::PosBelow; break; |
2349 | 0 | case FontEmphasis::ACCENT_BELOW: nMark = FontEmphasisMark::Accent|FontEmphasisMark::PosBelow; break; |
2350 | 0 | default: return false; |
2351 | 1.41k | } |
2352 | 1.41k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
2353 | 1.41k | SetValue( static_cast<sal_Int16>(nMark) ); |
2354 | 1.41k | } |
2355 | 0 | break; |
2356 | 1.41k | } |
2357 | 1.41k | return true; |
2358 | 1.41k | } |
2359 | | |
2360 | | /************************************************************************* |
2361 | | |* class SvxTwoLinesItem |
2362 | | *************************************************************************/ |
2363 | | |
2364 | | SvxTwoLinesItem::SvxTwoLinesItem( bool bFlag, sal_Unicode nStartBracket, |
2365 | | sal_Unicode nEndBracket, sal_uInt16 nW ) |
2366 | 36 | : SfxPoolItem( nW ), |
2367 | 36 | cStartBracket( nStartBracket ), cEndBracket( nEndBracket ), bOn( bFlag ) |
2368 | 36 | { |
2369 | 36 | } |
2370 | | |
2371 | | SvxTwoLinesItem::~SvxTwoLinesItem() |
2372 | 831 | { |
2373 | 831 | } |
2374 | | |
2375 | | bool SvxTwoLinesItem::operator==( const SfxPoolItem& rAttr ) const |
2376 | 507 | { |
2377 | 507 | assert(SfxPoolItem::operator==(rAttr)); |
2378 | 507 | return bOn == static_cast<const SvxTwoLinesItem&>(rAttr).bOn && |
2379 | 507 | cStartBracket == static_cast<const SvxTwoLinesItem&>(rAttr).cStartBracket && |
2380 | 507 | cEndBracket == static_cast<const SvxTwoLinesItem&>(rAttr).cEndBracket; |
2381 | 507 | } |
2382 | | |
2383 | | SvxTwoLinesItem* SvxTwoLinesItem::Clone( SfxItemPool* ) const |
2384 | 795 | { |
2385 | 795 | return new SvxTwoLinesItem( *this ); |
2386 | 795 | } |
2387 | | |
2388 | | bool SvxTwoLinesItem::QueryValue( css::uno::Any& rVal, |
2389 | | sal_uInt8 nMemberId ) const |
2390 | 0 | { |
2391 | 0 | nMemberId &= ~CONVERT_TWIPS; |
2392 | 0 | bool bRet = true; |
2393 | 0 | switch( nMemberId ) |
2394 | 0 | { |
2395 | 0 | case MID_TWOLINES: |
2396 | 0 | rVal <<= bOn; |
2397 | 0 | break; |
2398 | 0 | case MID_START_BRACKET: |
2399 | 0 | { |
2400 | 0 | OUString s; |
2401 | 0 | if( cStartBracket ) |
2402 | 0 | s = OUString( cStartBracket ); |
2403 | 0 | rVal <<= s; |
2404 | 0 | } |
2405 | 0 | break; |
2406 | 0 | case MID_END_BRACKET: |
2407 | 0 | { |
2408 | 0 | OUString s; |
2409 | 0 | if( cEndBracket ) |
2410 | 0 | s = OUString( cEndBracket ); |
2411 | 0 | rVal <<= s; |
2412 | 0 | } |
2413 | 0 | break; |
2414 | 0 | default: |
2415 | 0 | bRet = false; |
2416 | 0 | break; |
2417 | 0 | } |
2418 | 0 | return bRet; |
2419 | 0 | } |
2420 | | |
2421 | | bool SvxTwoLinesItem::PutValue( const css::uno::Any& rVal, |
2422 | | sal_uInt8 nMemberId ) |
2423 | 0 | { |
2424 | 0 | nMemberId &= ~CONVERT_TWIPS; |
2425 | 0 | bool bRet = false; |
2426 | 0 | OUString s; |
2427 | 0 | switch( nMemberId ) |
2428 | 0 | { |
2429 | 0 | case MID_TWOLINES: |
2430 | 0 | bOn = Any2Bool( rVal ); |
2431 | 0 | bRet = true; |
2432 | 0 | break; |
2433 | 0 | case MID_START_BRACKET: |
2434 | 0 | if( rVal >>= s ) |
2435 | 0 | { |
2436 | 0 | cStartBracket = s.isEmpty() ? 0 : s[ 0 ]; |
2437 | 0 | bRet = true; |
2438 | 0 | } |
2439 | 0 | break; |
2440 | 0 | case MID_END_BRACKET: |
2441 | 0 | if( rVal >>= s ) |
2442 | 0 | { |
2443 | 0 | cEndBracket = s.isEmpty() ? 0 : s[ 0 ]; |
2444 | 0 | bRet = true; |
2445 | 0 | } |
2446 | 0 | break; |
2447 | 0 | } |
2448 | 0 | return bRet; |
2449 | 0 | } |
2450 | | |
2451 | | bool SvxTwoLinesItem::GetPresentation( SfxItemPresentation /*ePres*/, |
2452 | | MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/, |
2453 | | OUString &rText, const IntlWrapper& /*rIntl*/ ) const |
2454 | 0 | { |
2455 | 0 | if( !GetValue() ) |
2456 | 0 | rText = EditResId( RID_SVXITEMS_TWOLINES_OFF ); |
2457 | 0 | else |
2458 | 0 | { |
2459 | 0 | rText = EditResId( RID_SVXITEMS_TWOLINES ); |
2460 | 0 | if( GetStartBracket() ) |
2461 | 0 | rText = OUStringChar(GetStartBracket()) + rText; |
2462 | 0 | if( GetEndBracket() ) |
2463 | 0 | rText += OUStringChar(GetEndBracket()); |
2464 | 0 | } |
2465 | 0 | return true; |
2466 | 0 | } |
2467 | | |
2468 | | |
2469 | | /************************************************************************* |
2470 | | |* class SvxTextRotateItem |
2471 | | *************************************************************************/ |
2472 | | |
2473 | | SvxTextRotateItem::SvxTextRotateItem(Degree10 nValue, TypedWhichId<SvxTextRotateItem> nW) |
2474 | 838 | : SfxUInt16Item(nW, nValue.get()) |
2475 | 838 | { |
2476 | 838 | } |
2477 | | |
2478 | | SvxTextRotateItem* SvxTextRotateItem::Clone(SfxItemPool*) const |
2479 | 0 | { |
2480 | 0 | return new SvxTextRotateItem(*this); |
2481 | 0 | } |
2482 | | |
2483 | | bool SvxTextRotateItem::GetPresentation( |
2484 | | SfxItemPresentation /*ePres*/, |
2485 | | MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/, |
2486 | | OUString &rText, const IntlWrapper&) const |
2487 | 0 | { |
2488 | 0 | if (!GetValue()) |
2489 | 0 | rText = EditResId(RID_SVXITEMS_TEXTROTATE_OFF); |
2490 | 0 | else |
2491 | 0 | { |
2492 | 0 | rText = EditResId(RID_SVXITEMS_TEXTROTATE); |
2493 | 0 | rText = rText.replaceFirst("$(ARG1)", |
2494 | 0 | OUString::number(toDegrees(GetValue()))); |
2495 | 0 | } |
2496 | 0 | return true; |
2497 | 0 | } |
2498 | | |
2499 | | bool SvxTextRotateItem::QueryValue(css::uno::Any& rVal, |
2500 | | sal_uInt8 nMemberId) const |
2501 | 0 | { |
2502 | 0 | nMemberId &= ~CONVERT_TWIPS; |
2503 | 0 | bool bRet = true; |
2504 | 0 | switch (nMemberId) |
2505 | 0 | { |
2506 | 0 | case MID_ROTATE: |
2507 | 0 | rVal <<= static_cast<sal_Int16>(GetValue()); |
2508 | 0 | break; |
2509 | 0 | default: |
2510 | 0 | bRet = false; |
2511 | 0 | break; |
2512 | 0 | } |
2513 | 0 | return bRet; |
2514 | 0 | } |
2515 | | |
2516 | | bool SvxTextRotateItem::PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) |
2517 | 199 | { |
2518 | 199 | nMemberId &= ~CONVERT_TWIPS; |
2519 | 199 | bool bRet = true; |
2520 | 199 | switch (nMemberId) |
2521 | 199 | { |
2522 | 199 | case MID_ROTATE: |
2523 | 199 | { |
2524 | 199 | sal_Int16 nVal = 0; |
2525 | 199 | if ((rVal >>= nVal) && (0 == nVal || 900 == nVal || 2700 == nVal)) |
2526 | 199 | SetValue(Degree10(nVal)); |
2527 | 0 | else |
2528 | 0 | bRet = false; |
2529 | 199 | break; |
2530 | 0 | } |
2531 | 0 | default: |
2532 | 0 | bRet = false; |
2533 | 199 | } |
2534 | 199 | return bRet; |
2535 | 199 | } |
2536 | | |
2537 | | void SvxTextRotateItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
2538 | 0 | { |
2539 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxTextRotateItem")); |
2540 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
2541 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue().get()).getStr())); |
2542 | 0 | (void)xmlTextWriterEndElement(pWriter); |
2543 | 0 | } |
2544 | | |
2545 | | |
2546 | | /************************************************************************* |
2547 | | |* class SvxCharRotateItem |
2548 | | *************************************************************************/ |
2549 | | |
2550 | | SvxCharRotateItem::SvxCharRotateItem( Degree10 nValue, |
2551 | | bool bFitIntoLine, |
2552 | | TypedWhichId<SvxCharRotateItem> nW ) |
2553 | 820 | : SvxTextRotateItem(nValue, nW), |
2554 | 820 | bFitToLine( bFitIntoLine ) |
2555 | 820 | { |
2556 | 820 | } |
2557 | | |
2558 | | SvxCharRotateItem* SvxCharRotateItem::Clone( SfxItemPool* ) const |
2559 | 3.52k | { |
2560 | 3.52k | return new SvxCharRotateItem( *this ); |
2561 | 3.52k | } |
2562 | | |
2563 | | bool SvxCharRotateItem::GetPresentation( |
2564 | | SfxItemPresentation /*ePres*/, |
2565 | | MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/, |
2566 | | OUString &rText, const IntlWrapper&) const |
2567 | 0 | { |
2568 | 0 | if( !GetValue() ) |
2569 | 0 | rText = EditResId( RID_SVXITEMS_CHARROTATE_OFF ); |
2570 | 0 | else |
2571 | 0 | { |
2572 | 0 | rText = EditResId( RID_SVXITEMS_CHARROTATE ); |
2573 | 0 | rText = rText.replaceFirst( "$(ARG1)", |
2574 | 0 | OUString::number( toDegrees(GetValue()) )); |
2575 | 0 | if( IsFitToLine() ) |
2576 | 0 | rText += EditResId( RID_SVXITEMS_CHARROTATE_FITLINE ); |
2577 | 0 | } |
2578 | 0 | return true; |
2579 | 0 | } |
2580 | | |
2581 | | bool SvxCharRotateItem::QueryValue( css::uno::Any& rVal, |
2582 | | sal_uInt8 nMemberId ) const |
2583 | 0 | { |
2584 | 0 | bool bRet = true; |
2585 | 0 | switch(nMemberId & ~CONVERT_TWIPS) |
2586 | 0 | { |
2587 | 0 | case MID_ROTATE: |
2588 | 0 | SvxTextRotateItem::QueryValue(rVal, nMemberId); |
2589 | 0 | break; |
2590 | 0 | case MID_FITTOLINE: |
2591 | 0 | rVal <<= IsFitToLine(); |
2592 | 0 | break; |
2593 | 0 | default: |
2594 | 0 | bRet = false; |
2595 | 0 | break; |
2596 | 0 | } |
2597 | 0 | return bRet; |
2598 | 0 | } |
2599 | | |
2600 | | bool SvxCharRotateItem::PutValue( const css::uno::Any& rVal, |
2601 | | sal_uInt8 nMemberId ) |
2602 | 396 | { |
2603 | 396 | bool bRet = true; |
2604 | 396 | switch(nMemberId & ~CONVERT_TWIPS) |
2605 | 396 | { |
2606 | 199 | case MID_ROTATE: |
2607 | 199 | { |
2608 | 199 | bRet = SvxTextRotateItem::PutValue(rVal, nMemberId); |
2609 | 199 | break; |
2610 | 0 | } |
2611 | | |
2612 | 197 | case MID_FITTOLINE: |
2613 | 197 | SetFitToLine( Any2Bool( rVal ) ); |
2614 | 197 | break; |
2615 | 0 | default: |
2616 | 0 | bRet = false; |
2617 | 396 | } |
2618 | 396 | return bRet; |
2619 | 396 | } |
2620 | | |
2621 | | bool SvxCharRotateItem::operator==( const SfxPoolItem& rItem ) const |
2622 | 4.87k | { |
2623 | 4.87k | assert(SfxPoolItem::operator==(rItem)); |
2624 | 4.87k | return SvxTextRotateItem::operator==( rItem ) && |
2625 | 4.87k | IsFitToLine() == static_cast<const SvxCharRotateItem&>(rItem).IsFitToLine(); |
2626 | 4.87k | } |
2627 | | |
2628 | | void SvxCharRotateItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
2629 | 0 | { |
2630 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxCharRotateItem")); |
2631 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); |
2632 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue().get()).getStr())); |
2633 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("fitToLine"), BAD_CAST(OString::boolean(IsFitToLine()).getStr())); |
2634 | 0 | (void)xmlTextWriterEndElement(pWriter); |
2635 | 0 | } |
2636 | | |
2637 | | /************************************************************************* |
2638 | | |* class SvxCharScaleItem |
2639 | | *************************************************************************/ |
2640 | | |
2641 | | SvxCharScaleWidthItem::SvxCharScaleWidthItem( sal_uInt16 nValue, |
2642 | | TypedWhichId<SvxCharScaleWidthItem> nW ) |
2643 | 3.68k | : SfxUInt16Item( nW, nValue ) |
2644 | 3.68k | { |
2645 | 3.68k | } |
2646 | | |
2647 | | SvxCharScaleWidthItem* SvxCharScaleWidthItem::Clone( SfxItemPool* ) const |
2648 | 9.30k | { |
2649 | 9.30k | return new SvxCharScaleWidthItem( *this ); |
2650 | 9.30k | } |
2651 | | |
2652 | | bool SvxCharScaleWidthItem::GetPresentation( |
2653 | | SfxItemPresentation /*ePres*/, |
2654 | | MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/, |
2655 | | OUString &rText, const IntlWrapper&) const |
2656 | 0 | { |
2657 | 0 | if( !GetValue() ) |
2658 | 0 | rText = EditResId( RID_SVXITEMS_CHARSCALE_OFF ); |
2659 | 0 | else |
2660 | 0 | { |
2661 | 0 | rText = EditResId( RID_SVXITEMS_CHARSCALE ); |
2662 | 0 | rText = rText.replaceFirst( "$(ARG1)", |
2663 | 0 | OUString::number( GetValue() )); |
2664 | 0 | } |
2665 | 0 | return true; |
2666 | 0 | } |
2667 | | |
2668 | | bool SvxCharScaleWidthItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) |
2669 | 921 | { |
2670 | | // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w) |
2671 | | // where we still want this to be a sal_Int16 |
2672 | 921 | sal_Int16 nValue = sal_Int16(); |
2673 | 921 | if (rVal >>= nValue) |
2674 | 921 | { |
2675 | 921 | SetValue( static_cast<sal_uInt16>(nValue) ); |
2676 | 921 | return true; |
2677 | 921 | } |
2678 | | |
2679 | 0 | SAL_WARN("editeng.items", "SvxCharScaleWidthItem::PutValue - Wrong type!" ); |
2680 | 0 | return false; |
2681 | 0 | } |
2682 | | |
2683 | | bool SvxCharScaleWidthItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const |
2684 | 0 | { |
2685 | | // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w) |
2686 | | // where we still want this to be a sal_Int16 |
2687 | 0 | rVal <<= static_cast<sal_Int16>(GetValue()); |
2688 | 0 | return true; |
2689 | 0 | } |
2690 | | |
2691 | | /************************************************************************* |
2692 | | |* class SvxCharReliefItem |
2693 | | *************************************************************************/ |
2694 | | |
2695 | | ItemInstanceManager* SvxCharReliefItem::getItemInstanceManager() const |
2696 | 1.55M | { |
2697 | 1.55M | static DefaultItemInstanceManager aInstanceManager(ItemType()); |
2698 | 1.55M | return &aInstanceManager; |
2699 | 1.55M | } |
2700 | | |
2701 | | SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue, |
2702 | | const sal_uInt16 nId ) |
2703 | 1.42M | : SfxEnumItem( nId, eValue ) |
2704 | 1.42M | { |
2705 | 1.42M | } |
2706 | | |
2707 | | SvxCharReliefItem* SvxCharReliefItem::Clone( SfxItemPool * ) const |
2708 | 150k | { |
2709 | 150k | return new SvxCharReliefItem( *this ); |
2710 | 150k | } |
2711 | | |
2712 | | static TranslateId RID_SVXITEMS_RELIEF[] = |
2713 | | { |
2714 | | RID_SVXITEMS_RELIEF_NONE, |
2715 | | RID_SVXITEMS_RELIEF_EMBOSSED, |
2716 | | RID_SVXITEMS_RELIEF_ENGRAVED |
2717 | | }; |
2718 | | |
2719 | | OUString SvxCharReliefItem::GetValueTextByPos(sal_uInt16 nPos) |
2720 | 0 | { |
2721 | 0 | assert(nPos < std::size(RID_SVXITEMS_RELIEF) && "enum overflow"); |
2722 | 0 | return EditResId(RID_SVXITEMS_RELIEF[nPos]); |
2723 | 0 | } |
2724 | | |
2725 | | bool SvxCharReliefItem::GetPresentation |
2726 | | ( |
2727 | | SfxItemPresentation /*ePres*/, |
2728 | | MapUnit /*eCoreUnit*/, |
2729 | | MapUnit /*ePresUnit*/, |
2730 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
2731 | | ) const |
2732 | 0 | { |
2733 | 0 | rText = GetValueTextByPos( static_cast<sal_uInt16>(GetValue()) ); |
2734 | 0 | return true; |
2735 | 0 | } |
2736 | | |
2737 | | bool SvxCharReliefItem::PutValue( const css::uno::Any& rVal, |
2738 | | sal_uInt8 nMemberId ) |
2739 | 1.40k | { |
2740 | 1.40k | nMemberId &= ~CONVERT_TWIPS; |
2741 | 1.40k | bool bRet = true; |
2742 | 1.40k | switch( nMemberId ) |
2743 | 1.40k | { |
2744 | 1.40k | case MID_RELIEF: |
2745 | 1.40k | { |
2746 | 1.40k | sal_Int16 nVal = -1; |
2747 | 1.40k | rVal >>= nVal; |
2748 | 1.40k | if(nVal >= 0 && nVal <= sal_Int16(FontRelief::Engraved)) |
2749 | 1.40k | { |
2750 | 1.40k | ASSERT_CHANGE_REFCOUNTED_ITEM; |
2751 | 1.40k | SetValue( static_cast<FontRelief>(nVal) ); |
2752 | 1.40k | } |
2753 | 0 | else |
2754 | 0 | bRet = false; |
2755 | 1.40k | } |
2756 | 1.40k | break; |
2757 | 0 | default: |
2758 | 0 | bRet = false; |
2759 | 0 | break; |
2760 | 1.40k | } |
2761 | 1.40k | return bRet; |
2762 | 1.40k | } |
2763 | | |
2764 | | bool SvxCharReliefItem::QueryValue( css::uno::Any& rVal, |
2765 | | sal_uInt8 nMemberId ) const |
2766 | 1.36k | { |
2767 | 1.36k | nMemberId &= ~CONVERT_TWIPS; |
2768 | 1.36k | bool bRet = true; |
2769 | 1.36k | switch( nMemberId ) |
2770 | 1.36k | { |
2771 | 1.36k | case MID_RELIEF: |
2772 | 1.36k | rVal <<= static_cast<sal_Int16>(GetValue()); |
2773 | 1.36k | break; |
2774 | 0 | default: |
2775 | 0 | bRet = false; |
2776 | 0 | break; |
2777 | 1.36k | } |
2778 | 1.36k | return bRet; |
2779 | 1.36k | } |
2780 | | |
2781 | | /************************************************************************* |
2782 | | |* class SvxScriptSetItem |
2783 | | *************************************************************************/ |
2784 | | |
2785 | | SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId, SfxItemPool& rPool ) |
2786 | 0 | : SfxSetItem( nSlotId, SfxItemSet( rPool, |
2787 | 0 | svl::Items<SID_ATTR_CHAR_FONT, SID_ATTR_CHAR_FONT> ) ) |
2788 | 0 | { |
2789 | 0 | sal_uInt16 nLatin, nAsian, nComplex; |
2790 | 0 | GetWhichIds( nLatin, nAsian, nComplex ); |
2791 | 0 | GetItemSet().MergeRange( nLatin, nLatin ); |
2792 | 0 | GetItemSet().MergeRange( nAsian, nAsian ); |
2793 | 0 | GetItemSet().MergeRange( nComplex, nComplex ); |
2794 | 0 | } |
2795 | | |
2796 | | SvxScriptSetItem* SvxScriptSetItem::Clone( SfxItemPool * ) const |
2797 | 0 | { |
2798 | 0 | SvxScriptSetItem* p = new SvxScriptSetItem( Which(), *GetItemSet().GetPool() ); |
2799 | 0 | p->GetItemSet().Put( GetItemSet(), false ); |
2800 | 0 | return p; |
2801 | 0 | } |
2802 | | |
2803 | | const SfxPoolItem* SvxScriptSetItem::GetItemOfScriptSet( |
2804 | | const SfxItemSet& rSet, sal_uInt16 nId ) |
2805 | 0 | { |
2806 | 0 | const SfxPoolItem* pI; |
2807 | 0 | SfxItemState eSt = rSet.GetItemState( nId, false, &pI ); |
2808 | 0 | if( SfxItemState::SET != eSt ) |
2809 | 0 | pI = SfxItemState::DEFAULT == eSt ? &rSet.Get( nId ) : nullptr; |
2810 | 0 | return pI; |
2811 | 0 | } |
2812 | | |
2813 | | const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId, const SfxItemSet& rSet, SvtScriptType nScript ) |
2814 | 0 | { |
2815 | 0 | sal_uInt16 nLatin, nAsian, nComplex; |
2816 | 0 | GetWhichIds( nSlotId, rSet, nLatin, nAsian, nComplex ); |
2817 | |
|
2818 | 0 | const SfxPoolItem *pRet, *pAsn, *pCmplx; |
2819 | 0 | if (nScript == SvtScriptType::ASIAN) |
2820 | 0 | { |
2821 | 0 | pRet = GetItemOfScriptSet( rSet, nAsian ); |
2822 | 0 | } else if (nScript == SvtScriptType::COMPLEX) |
2823 | 0 | { |
2824 | 0 | pRet = GetItemOfScriptSet( rSet, nComplex ); |
2825 | 0 | } else if (nScript == (SvtScriptType::LATIN|SvtScriptType::ASIAN)) |
2826 | 0 | { |
2827 | 0 | if( nullptr == (pRet = GetItemOfScriptSet( rSet, nLatin )) || |
2828 | 0 | nullptr == (pAsn = GetItemOfScriptSet( rSet, nAsian )) || |
2829 | 0 | *pRet != *pAsn ) |
2830 | 0 | pRet = nullptr; |
2831 | 0 | } else if (nScript == (SvtScriptType::LATIN|SvtScriptType::COMPLEX)) |
2832 | 0 | { |
2833 | 0 | if( nullptr == (pRet = GetItemOfScriptSet( rSet, nLatin )) || |
2834 | 0 | nullptr == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) || |
2835 | 0 | *pRet != *pCmplx ) |
2836 | 0 | pRet = nullptr; |
2837 | 0 | } else if (nScript == (SvtScriptType::ASIAN|SvtScriptType::COMPLEX)) |
2838 | 0 | { |
2839 | 0 | if( nullptr == (pRet = GetItemOfScriptSet( rSet, nAsian )) || |
2840 | 0 | nullptr == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) || |
2841 | 0 | *pRet != *pCmplx ) |
2842 | 0 | pRet = nullptr; |
2843 | 0 | } else if (nScript == (SvtScriptType::LATIN|SvtScriptType::ASIAN|SvtScriptType::COMPLEX)) |
2844 | 0 | { |
2845 | 0 | if( nullptr == (pRet = GetItemOfScriptSet( rSet, nLatin )) || |
2846 | 0 | nullptr == (pAsn = GetItemOfScriptSet( rSet, nAsian )) || |
2847 | 0 | nullptr == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) || |
2848 | 0 | *pRet != *pAsn || *pRet != *pCmplx ) |
2849 | 0 | pRet = nullptr; |
2850 | 0 | } else { |
2851 | | //no one valid -> match to latin |
2852 | 0 | pRet = GetItemOfScriptSet( rSet, nLatin ); |
2853 | 0 | } |
2854 | 0 | return pRet; |
2855 | 0 | } |
2856 | | |
2857 | | const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( SvtScriptType nScript ) const |
2858 | 0 | { |
2859 | 0 | return GetItemOfScript( Which(), GetItemSet(), nScript ); |
2860 | 0 | } |
2861 | | |
2862 | | void SvxScriptSetItem::PutItemForScriptType( SvtScriptType nScriptType, |
2863 | | const SfxPoolItem& rItem ) |
2864 | 0 | { |
2865 | 0 | sal_uInt16 nLatin, nAsian, nComplex; |
2866 | 0 | GetWhichIds( nLatin, nAsian, nComplex ); |
2867 | |
|
2868 | 0 | if( SvtScriptType::LATIN & nScriptType ) |
2869 | 0 | { |
2870 | 0 | GetItemSet().Put( rItem.CloneSetWhich(nLatin) ); |
2871 | 0 | } |
2872 | 0 | if( SvtScriptType::ASIAN & nScriptType ) |
2873 | 0 | { |
2874 | 0 | GetItemSet().Put( rItem.CloneSetWhich(nAsian) ); |
2875 | 0 | } |
2876 | 0 | if( SvtScriptType::COMPLEX & nScriptType ) |
2877 | 0 | { |
2878 | 0 | GetItemSet().Put( rItem.CloneSetWhich(nComplex) ); |
2879 | 0 | } |
2880 | 0 | } |
2881 | | |
2882 | | void SvxScriptSetItem::GetWhichIds( sal_uInt16 nSlotId, const SfxItemSet& rSet, sal_uInt16& rLatin, sal_uInt16& rAsian, sal_uInt16& rComplex ) |
2883 | 0 | { |
2884 | 0 | const SfxItemPool& rPool = *rSet.GetPool(); |
2885 | 0 | GetSlotIds( nSlotId, rLatin, rAsian, rComplex ); |
2886 | 0 | rLatin = rPool.GetWhichIDFromSlotID( rLatin ); |
2887 | 0 | rAsian = rPool.GetWhichIDFromSlotID( rAsian ); |
2888 | 0 | rComplex = rPool.GetWhichIDFromSlotID( rComplex ); |
2889 | 0 | } |
2890 | | |
2891 | | void SvxScriptSetItem::GetWhichIds( sal_uInt16& rLatin, sal_uInt16& rAsian, |
2892 | | sal_uInt16& rComplex ) const |
2893 | 0 | { |
2894 | 0 | GetWhichIds( Which(), GetItemSet(), rLatin, rAsian, rComplex ); |
2895 | 0 | } |
2896 | | |
2897 | | void SvxScriptSetItem::GetSlotIds( sal_uInt16 nSlotId, sal_uInt16& rLatin, |
2898 | | sal_uInt16& rAsian, sal_uInt16& rComplex ) |
2899 | 0 | { |
2900 | 0 | switch( nSlotId ) |
2901 | 0 | { |
2902 | 0 | default: |
2903 | 0 | SAL_WARN( "editeng.items", "wrong SlotId for class SvxScriptSetItem" ); |
2904 | 0 | [[fallthrough]]; // default to font - Id Range !! |
2905 | |
|
2906 | 0 | case SID_ATTR_CHAR_FONT: |
2907 | 0 | rLatin = SID_ATTR_CHAR_FONT; |
2908 | 0 | rAsian = SID_ATTR_CHAR_CJK_FONT; |
2909 | 0 | rComplex = SID_ATTR_CHAR_CTL_FONT; |
2910 | 0 | break; |
2911 | 0 | case SID_ATTR_CHAR_FONTHEIGHT: |
2912 | 0 | rLatin = SID_ATTR_CHAR_FONTHEIGHT; |
2913 | 0 | rAsian = SID_ATTR_CHAR_CJK_FONTHEIGHT; |
2914 | 0 | rComplex = SID_ATTR_CHAR_CTL_FONTHEIGHT; |
2915 | 0 | break; |
2916 | 0 | case SID_ATTR_CHAR_WEIGHT: |
2917 | 0 | rLatin = SID_ATTR_CHAR_WEIGHT; |
2918 | 0 | rAsian = SID_ATTR_CHAR_CJK_WEIGHT; |
2919 | 0 | rComplex = SID_ATTR_CHAR_CTL_WEIGHT; |
2920 | 0 | break; |
2921 | 0 | case SID_ATTR_CHAR_POSTURE: |
2922 | 0 | rLatin = SID_ATTR_CHAR_POSTURE; |
2923 | 0 | rAsian = SID_ATTR_CHAR_CJK_POSTURE; |
2924 | 0 | rComplex = SID_ATTR_CHAR_CTL_POSTURE; |
2925 | 0 | break; |
2926 | 0 | case SID_ATTR_CHAR_LANGUAGE: |
2927 | 0 | rLatin = SID_ATTR_CHAR_LANGUAGE; |
2928 | 0 | rAsian = SID_ATTR_CHAR_CJK_LANGUAGE; |
2929 | 0 | rComplex = SID_ATTR_CHAR_CTL_LANGUAGE; |
2930 | 0 | break; |
2931 | 0 | case SID_ATTR_CHAR_SHADOWED: |
2932 | 0 | rLatin = SID_ATTR_CHAR_SHADOWED; |
2933 | 0 | rAsian = SID_ATTR_CHAR_SHADOWED; |
2934 | 0 | rComplex = SID_ATTR_CHAR_SHADOWED; |
2935 | 0 | break; |
2936 | 0 | case SID_ATTR_CHAR_STRIKEOUT: |
2937 | 0 | rLatin = SID_ATTR_CHAR_STRIKEOUT; |
2938 | 0 | rAsian = SID_ATTR_CHAR_STRIKEOUT; |
2939 | 0 | rComplex = SID_ATTR_CHAR_STRIKEOUT; |
2940 | 0 | break; |
2941 | 0 | } |
2942 | 0 | } |
2943 | | |
2944 | | void GetDefaultFonts( SvxFontItem& rLatin, SvxFontItem& rAsian, SvxFontItem& rComplex ) |
2945 | 2.87k | { |
2946 | 2.87k | const sal_uInt16 nItemCnt = 3; |
2947 | | |
2948 | 2.87k | static struct |
2949 | 2.87k | { |
2950 | 2.87k | DefaultFontType nFontType; |
2951 | 2.87k | LanguageType nLanguage; |
2952 | 2.87k | } |
2953 | 2.87k | const aOutTypeArr[ nItemCnt ] = |
2954 | 2.87k | { |
2955 | 2.87k | { DefaultFontType::LATIN_TEXT, LANGUAGE_ENGLISH_US }, |
2956 | 2.87k | { DefaultFontType::CJK_TEXT, LANGUAGE_ENGLISH_US }, |
2957 | 2.87k | { DefaultFontType::CTL_TEXT, LANGUAGE_ARABIC_SAUDI_ARABIA } |
2958 | 2.87k | }; |
2959 | | |
2960 | 2.87k | SvxFontItem* aItemArr[ nItemCnt ] = { &rLatin, &rAsian, &rComplex }; |
2961 | | |
2962 | 11.5k | for ( sal_uInt16 n = 0; n < nItemCnt; ++n ) |
2963 | 8.63k | { |
2964 | 8.63k | vcl::Font aFont( OutputDevice::GetDefaultFont( aOutTypeArr[ n ].nFontType, |
2965 | 8.63k | aOutTypeArr[ n ].nLanguage, |
2966 | 8.63k | GetDefaultFontFlags::OnlyOne ) ); |
2967 | 8.63k | SvxFontItem* pItem = aItemArr[ n ]; |
2968 | 8.63k | pItem->SetFamily( aFont.GetFamilyTypeMaybeAskConfig() ); |
2969 | 8.63k | pItem->SetFamilyName( aFont.GetFamilyName() ); |
2970 | 8.63k | pItem->SetStyleName( OUString() ); |
2971 | 8.63k | pItem->SetPitch( aFont.GetPitchMaybeAskConfig()); |
2972 | 8.63k | pItem->SetCharSet(aFont.GetCharSet()); |
2973 | 8.63k | } |
2974 | 2.87k | } |
2975 | | |
2976 | | // class SvxRsidItem ----------------------------------------------------- |
2977 | | |
2978 | | ItemInstanceManager* SvxRsidItem::getItemInstanceManager() const |
2979 | 2.85k | { |
2980 | 2.85k | static HashedItemInstanceManager aInstanceManager(ItemType()); |
2981 | 2.85k | return &aInstanceManager; |
2982 | 2.85k | } |
2983 | | |
2984 | | bool SvxRsidItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const |
2985 | 0 | { |
2986 | 0 | rVal <<= GetValue(); |
2987 | 0 | return true; |
2988 | 0 | } |
2989 | | |
2990 | | bool SvxRsidItem::PutValue( const uno::Any& rVal, sal_uInt8 ) |
2991 | 1.68k | { |
2992 | 1.68k | sal_uInt32 nRsid = 0; |
2993 | 1.68k | if( !( rVal >>= nRsid ) ) |
2994 | 0 | return false; |
2995 | | |
2996 | 1.68k | SetValue( nRsid ); |
2997 | 1.68k | return true; |
2998 | 1.68k | } |
2999 | | |
3000 | | SvxRsidItem* SvxRsidItem::Clone( SfxItemPool * ) const |
3001 | 3.69k | { |
3002 | 3.69k | return new SvxRsidItem( *this ); |
3003 | 3.69k | } |
3004 | | |
3005 | | bool SvxRsidItem::GetPresentation |
3006 | | ( |
3007 | | SfxItemPresentation /*ePres*/, |
3008 | | MapUnit /*eCoreUnit*/, |
3009 | | MapUnit /*ePresUnit*/, |
3010 | | OUString& rText, const IntlWrapper& /*rIntl*/ |
3011 | | ) const |
3012 | 0 | { |
3013 | 0 | rText.clear(); |
3014 | 0 | return false; |
3015 | 0 | } |
3016 | | |
3017 | | void SvxRsidItem::dumpAsXml(xmlTextWriterPtr pWriter) const |
3018 | 0 | { |
3019 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxRsidItem")); |
3020 | 0 | (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("whichId"), "%d", Which()); |
3021 | 0 | (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("value"), "%" SAL_PRIuUINT32, GetValue()); |
3022 | 0 | (void)xmlTextWriterEndElement(pWriter); |
3023 | 0 | } |
3024 | | |
3025 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |