Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / tools / CharacterProperties.cxx
blobbf44c6a4c08f49f2518ad654315ab32d57259271
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <CharacterProperties.hxx>
22 #include <com/sun/star/beans/XMultiPropertySet.hpp>
23 #include <com/sun/star/beans/PropertyAttribute.hpp>
24 #include <com/sun/star/awt/FontSlant.hpp>
25 #include <com/sun/star/lang/Locale.hpp>
27 #include <com/sun/star/awt/FontUnderline.hpp>
28 #include <com/sun/star/awt/FontWeight.hpp>
29 #include <com/sun/star/text/FontRelief.hpp>
30 #include <com/sun/star/text/FontEmphasis.hpp>
31 #include <com/sun/star/awt/FontStrikeout.hpp>
32 #include <com/sun/star/text/WritingMode2.hpp>
33 #include <com/sun/star/i18n/ScriptType.hpp>
34 #include <osl/diagnose.h>
35 #include <unotools/lingucfg.hxx>
36 #include <i18nlangtag/mslangid.hxx>
37 #include <i18nlangtag/languagetag.hxx>
38 #include <tools/color.hxx>
39 #include <vcl/outdev.hxx>
40 #include <vcl/svapp.hxx>
42 using namespace ::com::sun::star;
44 using ::com::sun::star::beans::Property;
46 namespace chart
49 void CharacterProperties::AddPropertiesToVector(
50 std::vector< Property > & rOutProperties )
52 // CharacterProperties
53 rOutProperties.emplace_back( "CharFontName",
54 PROP_CHAR_FONT_NAME,
55 cppu::UnoType<OUString>::get(),
56 beans::PropertyAttribute::BOUND
57 | beans::PropertyAttribute::MAYBEDEFAULT );
58 rOutProperties.emplace_back( "CharFontStyleName",
59 PROP_CHAR_FONT_STYLE_NAME,
60 cppu::UnoType<OUString>::get(),
61 beans::PropertyAttribute::BOUND
62 | beans::PropertyAttribute::MAYBEDEFAULT
63 | beans::PropertyAttribute::MAYBEVOID );
64 // CharFontFamily (see awt.FontFamily)
65 rOutProperties.emplace_back( "CharFontFamily",
66 PROP_CHAR_FONT_FAMILY,
67 cppu::UnoType<sal_Int16>::get(),
68 beans::PropertyAttribute::BOUND
69 | beans::PropertyAttribute::MAYBEDEFAULT );
70 // CharFontCharSet (see awt.CharSet)
71 rOutProperties.emplace_back( "CharFontCharSet",
72 PROP_CHAR_FONT_CHAR_SET,
73 cppu::UnoType<sal_Int16>::get(),
74 beans::PropertyAttribute::BOUND
75 | beans::PropertyAttribute::MAYBEDEFAULT );
76 // CharFontPitch (see awt.FontPitch)
77 rOutProperties.emplace_back( "CharFontPitch",
78 PROP_CHAR_FONT_PITCH,
79 cppu::UnoType<sal_Int16>::get(),
80 beans::PropertyAttribute::BOUND
81 | beans::PropertyAttribute::MAYBEDEFAULT );
82 // CharColor
83 rOutProperties.emplace_back( "CharColor",
84 PROP_CHAR_COLOR,
85 cppu::UnoType<sal_Int32>::get(),
86 beans::PropertyAttribute::BOUND
87 | beans::PropertyAttribute::MAYBEDEFAULT );
88 // CharEscapement
89 rOutProperties.emplace_back( "CharEscapement",
90 PROP_CHAR_ESCAPEMENT,
91 cppu::UnoType<sal_Int16>::get(),
92 beans::PropertyAttribute::BOUND
93 | beans::PropertyAttribute::MAYBEVOID );
94 // CharHeight
95 rOutProperties.emplace_back( "CharHeight",
96 PROP_CHAR_CHAR_HEIGHT,
97 cppu::UnoType<float>::get(),
98 beans::PropertyAttribute::BOUND
99 | beans::PropertyAttribute::MAYBEDEFAULT );
100 // CharUnderline (see awt.FontUnderline)
101 rOutProperties.emplace_back( "CharUnderline",
102 PROP_CHAR_UNDERLINE,
103 cppu::UnoType<sal_Int16>::get(),
104 beans::PropertyAttribute::BOUND
105 | beans::PropertyAttribute::MAYBEDEFAULT );
106 // CharUnderlineColor
107 rOutProperties.emplace_back( "CharUnderlineColor",
108 PROP_CHAR_UNDERLINE_COLOR,
109 cppu::UnoType<sal_Int32>::get(),
110 beans::PropertyAttribute::BOUND
111 | beans::PropertyAttribute::MAYBEDEFAULT
112 | beans::PropertyAttribute::MAYBEVOID );
113 // CharUnderlineHasColor
114 rOutProperties.emplace_back( "CharUnderlineHasColor",
115 PROP_CHAR_UNDERLINE_HAS_COLOR,
116 cppu::UnoType<bool>::get(),
117 beans::PropertyAttribute::BOUND
118 | beans::PropertyAttribute::MAYBEDEFAULT );
119 // CharOverline (see awt.FontUnderline)
120 rOutProperties.emplace_back( "CharOverline",
121 PROP_CHAR_OVERLINE,
122 cppu::UnoType<sal_Int16>::get(),
123 beans::PropertyAttribute::BOUND
124 | beans::PropertyAttribute::MAYBEDEFAULT );
125 // CharOverlineColor
126 rOutProperties.emplace_back( "CharOverlineColor",
127 PROP_CHAR_OVERLINE_COLOR,
128 cppu::UnoType<sal_Int32>::get(),
129 beans::PropertyAttribute::BOUND
130 | beans::PropertyAttribute::MAYBEDEFAULT
131 | beans::PropertyAttribute::MAYBEVOID );
132 // CharOverlineHasColor
133 rOutProperties.emplace_back( "CharOverlineHasColor",
134 PROP_CHAR_OVERLINE_HAS_COLOR,
135 cppu::UnoType<bool>::get(),
136 beans::PropertyAttribute::BOUND
137 | beans::PropertyAttribute::MAYBEDEFAULT );
138 // CharWeight (see awt.FontWeight)
139 rOutProperties.emplace_back( "CharWeight",
140 PROP_CHAR_WEIGHT,
141 cppu::UnoType<float>::get(),
142 beans::PropertyAttribute::BOUND
143 | beans::PropertyAttribute::MAYBEDEFAULT );
144 // CharPosture
145 rOutProperties.emplace_back( "CharPosture",
146 PROP_CHAR_POSTURE,
147 cppu::UnoType<awt::FontSlant>::get(),
148 beans::PropertyAttribute::BOUND
149 | beans::PropertyAttribute::MAYBEDEFAULT );
150 rOutProperties.emplace_back( "CharAutoKerning",
151 PROP_CHAR_AUTO_KERNING,
152 cppu::UnoType<bool>::get(),
153 beans::PropertyAttribute::BOUND
154 | beans::PropertyAttribute::MAYBEDEFAULT
155 | beans::PropertyAttribute::MAYBEVOID );
156 rOutProperties.emplace_back( "CharKerning",
157 PROP_CHAR_KERNING,
158 cppu::UnoType<sal_Int16>::get(),
159 beans::PropertyAttribute::BOUND
160 | beans::PropertyAttribute::MAYBEDEFAULT
161 | beans::PropertyAttribute::MAYBEVOID );
162 // CharEscapementHeight
163 rOutProperties.emplace_back( "CharEscapementHeight",
164 PROP_CHAR_ESCAPEMENT_HEIGHT,
165 cppu::UnoType<sal_Int8>::get(),
166 beans::PropertyAttribute::BOUND
167 | beans::PropertyAttribute::MAYBEVOID );
168 // CharStrikeout (see awt.FontStrikeout)
169 rOutProperties.emplace_back( "CharStrikeout",
170 PROP_CHAR_STRIKE_OUT,
171 cppu::UnoType<sal_Int16>::get(),
172 beans::PropertyAttribute::BOUND
173 | beans::PropertyAttribute::MAYBEDEFAULT );
174 // CharWordMode
175 rOutProperties.emplace_back( "CharWordMode",
176 PROP_CHAR_WORD_MODE,
177 cppu::UnoType<bool>::get(),
178 beans::PropertyAttribute::BOUND
179 | beans::PropertyAttribute::MAYBEDEFAULT );
180 // CharLocale
181 rOutProperties.emplace_back( "CharLocale",
182 PROP_CHAR_LOCALE,
183 cppu::UnoType<lang::Locale>::get(),
184 //#i111967# no PropertyChangeEvent is fired on change so far
185 beans::PropertyAttribute::MAYBEDEFAULT );
186 // CharShadowed
187 rOutProperties.emplace_back( "CharShadowed",
188 PROP_CHAR_SHADOWED,
189 cppu::UnoType<bool>::get(),
190 beans::PropertyAttribute::BOUND
191 | beans::PropertyAttribute::MAYBEDEFAULT );
192 // CharContoured
193 rOutProperties.emplace_back( "CharContoured",
194 PROP_CHAR_CONTOURED,
195 cppu::UnoType<bool>::get(),
196 beans::PropertyAttribute::BOUND
197 | beans::PropertyAttribute::MAYBEDEFAULT );
198 // CharRelief (see text.FontRelief)
199 rOutProperties.emplace_back( "CharRelief",
200 PROP_CHAR_RELIEF,
201 cppu::UnoType<sal_Int16>::get(),
202 beans::PropertyAttribute::BOUND
203 | beans::PropertyAttribute::MAYBEDEFAULT );
205 // CharEmphasize (see text.FontEmphasis)
206 rOutProperties.emplace_back( "CharEmphasis",
207 PROP_CHAR_EMPHASIS,
208 cppu::UnoType<sal_Int16>::get(),
209 beans::PropertyAttribute::BOUND
210 | beans::PropertyAttribute::MAYBEDEFAULT );
211 // CharacterPropertiesAsian
213 // CharFontNameAsian
214 rOutProperties.emplace_back( "CharFontNameAsian",
215 PROP_CHAR_ASIAN_FONT_NAME,
216 cppu::UnoType<OUString>::get(),
217 beans::PropertyAttribute::BOUND
218 | beans::PropertyAttribute::MAYBEDEFAULT );
219 // CharFontStyleNameAsian
220 rOutProperties.emplace_back( "CharFontStyleNameAsian",
221 PROP_CHAR_ASIAN_FONT_STYLE_NAME,
222 cppu::UnoType<OUString>::get(),
223 beans::PropertyAttribute::BOUND
224 | beans::PropertyAttribute::MAYBEDEFAULT
225 | beans::PropertyAttribute::MAYBEVOID );
226 // CharFontFamilyAsian (see awt.FontFamily)
227 rOutProperties.emplace_back( "CharFontFamilyAsian",
228 PROP_CHAR_ASIAN_FONT_FAMILY,
229 cppu::UnoType<sal_Int16>::get(),
230 beans::PropertyAttribute::BOUND
231 | beans::PropertyAttribute::MAYBEDEFAULT );
232 // CharFontCharSetAsian (see awt.CharSet)
233 rOutProperties.emplace_back( "CharFontCharSetAsian",
234 PROP_CHAR_ASIAN_CHAR_SET,
235 cppu::UnoType<sal_Int16>::get(),
236 beans::PropertyAttribute::BOUND
237 | beans::PropertyAttribute::MAYBEDEFAULT );
238 // CharFontPitchAsian (see awt.FontPitch)
239 rOutProperties.emplace_back( "CharFontPitchAsian",
240 PROP_CHAR_ASIAN_FONT_PITCH,
241 cppu::UnoType<sal_Int16>::get(),
242 beans::PropertyAttribute::BOUND
243 | beans::PropertyAttribute::MAYBEDEFAULT );
244 // CharHeightAsian
245 rOutProperties.emplace_back( "CharHeightAsian",
246 PROP_CHAR_ASIAN_CHAR_HEIGHT,
247 cppu::UnoType<float>::get(),
248 beans::PropertyAttribute::BOUND
249 | beans::PropertyAttribute::MAYBEDEFAULT );
250 // CharWeightAsian
251 rOutProperties.emplace_back( "CharWeightAsian",
252 PROP_CHAR_ASIAN_WEIGHT,
253 cppu::UnoType<float>::get(),
254 beans::PropertyAttribute::BOUND
255 | beans::PropertyAttribute::MAYBEDEFAULT );
256 // CharPostureAsian
257 rOutProperties.emplace_back( "CharPostureAsian",
258 PROP_CHAR_ASIAN_POSTURE,
259 cppu::UnoType<awt::FontSlant>::get(),
260 beans::PropertyAttribute::BOUND
261 | beans::PropertyAttribute::MAYBEDEFAULT );
262 // CharLocaleAsian
263 rOutProperties.emplace_back( "CharLocaleAsian",
264 PROP_CHAR_ASIAN_LOCALE,
265 cppu::UnoType<lang::Locale>::get(),
266 //#i111967# no PropertyChangeEvent is fired on change so far
267 beans::PropertyAttribute::MAYBEDEFAULT );
269 // CharacterPropertiesComplex
271 // CharFontNameComplex
272 rOutProperties.emplace_back( "CharFontNameComplex",
273 PROP_CHAR_COMPLEX_FONT_NAME,
274 cppu::UnoType<OUString>::get(),
275 beans::PropertyAttribute::BOUND
276 | beans::PropertyAttribute::MAYBEDEFAULT );
277 // CharFontStyleNameComplex
278 rOutProperties.emplace_back( "CharFontStyleNameComplex",
279 PROP_CHAR_COMPLEX_FONT_STYLE_NAME,
280 cppu::UnoType<OUString>::get(),
281 beans::PropertyAttribute::BOUND
282 | beans::PropertyAttribute::MAYBEDEFAULT
283 | beans::PropertyAttribute::MAYBEVOID );
284 // CharFontFamilyComplex (see awt.FontFamily)
285 rOutProperties.emplace_back( "CharFontFamilyComplex",
286 PROP_CHAR_COMPLEX_FONT_FAMILY,
287 cppu::UnoType<sal_Int16>::get(),
288 beans::PropertyAttribute::BOUND
289 | beans::PropertyAttribute::MAYBEDEFAULT );
290 // CharFontCharSetComplex (see awt.CharSet)
291 rOutProperties.emplace_back( "CharFontCharSetComplex",
292 PROP_CHAR_COMPLEX_CHAR_SET,
293 cppu::UnoType<sal_Int16>::get(),
294 beans::PropertyAttribute::BOUND
295 | beans::PropertyAttribute::MAYBEDEFAULT );
296 // CharFontPitchComplex (see awt.FontPitch)
297 rOutProperties.emplace_back( "CharFontPitchComplex",
298 PROP_CHAR_COMPLEX_FONT_PITCH,
299 cppu::UnoType<sal_Int16>::get(),
300 beans::PropertyAttribute::BOUND
301 | beans::PropertyAttribute::MAYBEDEFAULT );
302 // CharHeightComplex
303 rOutProperties.emplace_back( "CharHeightComplex",
304 PROP_CHAR_COMPLEX_CHAR_HEIGHT,
305 cppu::UnoType<float>::get(),
306 beans::PropertyAttribute::BOUND
307 | beans::PropertyAttribute::MAYBEDEFAULT );
308 // CharWeightComplex
309 rOutProperties.emplace_back( "CharWeightComplex",
310 PROP_CHAR_COMPLEX_WEIGHT,
311 cppu::UnoType<float>::get(),
312 beans::PropertyAttribute::BOUND
313 | beans::PropertyAttribute::MAYBEDEFAULT );
314 // CharPostureComplex
315 rOutProperties.emplace_back( "CharPostureComplex",
316 PROP_CHAR_COMPLEX_POSTURE,
317 cppu::UnoType<awt::FontSlant>::get(),
318 beans::PropertyAttribute::BOUND
319 | beans::PropertyAttribute::MAYBEDEFAULT );
320 // CharLocaleComplex
321 rOutProperties.emplace_back( "CharLocaleComplex",
322 PROP_CHAR_COMPLEX_LOCALE,
323 cppu::UnoType<lang::Locale>::get(),
324 //#i111967# no PropertyChangeEvent is fired on change so far
325 beans::PropertyAttribute::MAYBEDEFAULT );
327 // Writing Mode left to right vs right to left
328 rOutProperties.emplace_back( "WritingMode",
329 PROP_WRITING_MODE,
330 cppu::UnoType<sal_Int16>::get(), /*css::text::WritingMode2*/
331 beans::PropertyAttribute::BOUND
332 | beans::PropertyAttribute::MAYBEDEFAULT );
334 rOutProperties.emplace_back( "ParaIsCharacterDistance",
335 PROP_PARA_IS_CHARACTER_DISTANCE,
336 cppu::UnoType<bool>::get(),
337 beans::PropertyAttribute::BOUND
338 | beans::PropertyAttribute::MAYBEDEFAULT );
341 void CharacterProperties::AddDefaultsToMap(
342 ::chart::tPropertyValueMap & rOutMap )
344 SolarMutexGuard aGuard;
345 const float fDefaultFontHeight = 13.0;
347 SvtLinguConfig aLinguConfig;
348 lang::Locale aDefaultLocale;
349 aLinguConfig.GetProperty(u"DefaultLocale") >>= aDefaultLocale;
350 lang::Locale aDefaultLocale_CJK;
351 aLinguConfig.GetProperty(u"DefaultLocale_CJK") >>= aDefaultLocale_CJK;
352 lang::Locale aDefaultLocale_CTL;
353 aLinguConfig.GetProperty(u"DefaultLocale_CTL") >>= aDefaultLocale_CTL;
355 using namespace ::com::sun::star::i18n::ScriptType;
356 LanguageType nLang;
357 nLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aDefaultLocale, false), LATIN);
358 vcl::Font aFont = OutputDevice::GetDefaultFont( DefaultFontType::LATIN_SPREADSHEET, nLang, GetDefaultFontFlags::OnlyOne );
359 nLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aDefaultLocale_CJK, false), ASIAN);
360 vcl::Font aFontCJK = OutputDevice::GetDefaultFont( DefaultFontType::CJK_SPREADSHEET, nLang, GetDefaultFontFlags::OnlyOne );
361 nLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aDefaultLocale_CTL, false), COMPLEX);
362 vcl::Font aFontCTL = OutputDevice::GetDefaultFont( DefaultFontType::CTL_SPREADSHEET, nLang, GetDefaultFontFlags::OnlyOne );
364 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FONT_NAME, aFont.GetFamilyName() );
365 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FONT_STYLE_NAME, aFont.GetStyleName() );
366 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FONT_FAMILY, sal_Int16(aFont.GetFamilyType()) );//awt::FontFamily::SWISS
367 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FONT_CHAR_SET, sal_Int16(aFont.GetCharSet()) );//use awt::CharSet::DONTKNOW instead of SYSTEM to avoid assertion issue 50249
368 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FONT_PITCH, sal_Int16(aFont.GetPitch()) );//awt::FontPitch::VARIABLE
369 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COLOR, COL_AUTO ); //automatic color
370 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_CHAR_HEIGHT, fDefaultFontHeight );
371 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_UNDERLINE, awt::FontUnderline::NONE );
372 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_UNDERLINE_COLOR, COL_AUTO ); //automatic color
373 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_UNDERLINE_HAS_COLOR, false );
374 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_OVERLINE, awt::FontUnderline::NONE );
375 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_OVERLINE_COLOR, COL_AUTO ); //automatic color
376 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_OVERLINE_HAS_COLOR, false );
377 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_WEIGHT, awt::FontWeight::NORMAL );
378 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_POSTURE, awt::FontSlant_NONE );
379 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_AUTO_KERNING, true );
380 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_KERNING, sal_Int16(0) );
381 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_STRIKE_OUT, awt::FontStrikeout::NONE );
382 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_WORD_MODE, false );
383 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_LOCALE, aDefaultLocale );
384 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_SHADOWED, false );
385 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_CONTOURED, false );
386 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_RELIEF, text::FontRelief::NONE );
387 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_EMPHASIS, text::FontEmphasis::NONE );
389 // Asian (com.sun.star.style.CharacterPropertiesAsian)
390 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultFontHeight );
391 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_WEIGHT, awt::FontWeight::NORMAL );
392 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_POSTURE, awt::FontSlant_NONE );
393 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_LOCALE, aDefaultLocale_CJK );
394 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_FONT_NAME, aFontCJK.GetFamilyName() );
395 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_FONT_STYLE_NAME, aFontCJK.GetStyleName() );
396 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_FONT_FAMILY, sal_Int16(aFontCJK.GetFamilyType()) );
397 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_CHAR_SET, sal_Int16(aFontCJK.GetCharSet()) );
398 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_FONT_PITCH, sal_Int16(aFontCJK.GetPitch()) );
400 // Complex Text Layout (com.sun.star.style.CharacterPropertiesComplex)
401 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultFontHeight );
402 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_WEIGHT, awt::FontWeight::NORMAL );
403 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_POSTURE, awt::FontSlant_NONE );
404 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_LOCALE, aDefaultLocale_CTL );
405 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_FONT_NAME, aFontCTL.GetFamilyName() );
406 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_FONT_STYLE_NAME, aFontCTL.GetStyleName() );
407 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_FONT_FAMILY, sal_Int16(aFontCTL.GetFamilyType()) );
408 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_CHAR_SET, sal_Int16(aFontCTL.GetCharSet()) );
409 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_FONT_PITCH, sal_Int16(aFontCTL.GetPitch()) );
411 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_WRITING_MODE, sal_Int16( css::text::WritingMode2::PAGE ) );
412 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_PARA_IS_CHARACTER_DISTANCE, true );
415 bool CharacterProperties::IsCharacterPropertyHandle( sal_Int32 nHandle )
417 return ( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle &&
418 nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP );
421 awt::FontDescriptor CharacterProperties::createFontDescriptorFromPropertySet(
422 const uno::Reference< beans::XMultiPropertySet > & xMultiPropSet )
424 awt::FontDescriptor aResult;
425 // Note: keep this sorted!
426 uno::Sequence< OUString > aPropNameSeq{
427 "CharFontCharSet", // CharSet
428 "CharFontFamily", // Family
429 "CharFontName", // Name
430 "CharFontPitch", // Pitch
431 "CharFontStyleName", // StyleName
432 "CharHeight", // Height
433 "CharPosture", // Slant
434 "CharStrikeout", // Strikeout
435 "CharUnderline", // Underline
436 "CharWeight", // Weight
437 "CharWordMode"}; // WordLineMode
438 uno::Sequence< uno::Any > aValues( xMultiPropSet->getPropertyValues( aPropNameSeq ));
440 sal_Int32 i=0;
441 // Note keep this sorted according to the list above (comments are the fieldnames)
442 aValues[ i++ ] >>= aResult.CharSet;
443 aValues[ i++ ] >>= aResult.Family;
444 aValues[ i++ ] >>= aResult.Name;
445 aValues[ i++ ] >>= aResult.Pitch;
446 aValues[ i++ ] >>= aResult.StyleName;
447 float fCharHeight = 0;
448 aValues[ i++ ] >>= fCharHeight;
449 aResult.Height = static_cast< sal_Int16 >( fCharHeight );
450 aValues[ i++ ] >>= aResult.Slant;
451 aValues[ i++ ] >>= aResult.Strikeout;
452 aValues[ i++ ] >>= aResult.Underline;
453 aValues[ i++ ] >>= aResult.Weight;
454 aValues[ i++ ] >>= aResult.WordLineMode;
455 OSL_ASSERT( i == aValues.getLength());
457 return aResult;
460 } // namespace chart
462 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */