1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 #include "CharacterProperties.hxx"
27 #include "ContainerHelper.hxx"
28 #include "macros.hxx"
29 
30 #include <com/sun/star/beans/PropertyAttribute.hpp>
31 #include <com/sun/star/style/XStyle.hpp>
32 #include <com/sun/star/awt/FontSlant.hpp>
33 #include <com/sun/star/lang/Locale.hpp>
34 
35 #include <com/sun/star/awt/FontFamily.hpp>
36 #include <com/sun/star/awt/CharSet.hpp>
37 #include <com/sun/star/awt/FontPitch.hpp>
38 #include <com/sun/star/awt/FontUnderline.hpp>
39 #include <com/sun/star/awt/FontWeight.hpp>
40 #include <com/sun/star/awt/FontSlant.hpp>
41 #include <com/sun/star/style/CaseMap.hpp>
42 #include <com/sun/star/text/FontRelief.hpp>
43 #include <com/sun/star/text/FontEmphasis.hpp>
44 #include <com/sun/star/text/RubyAdjust.hpp>
45 #include <com/sun/star/awt/FontStrikeout.hpp>
46 #include <com/sun/star/text/WritingMode2.hpp>
47 #include <com/sun/star/i18n/ScriptType.hpp>
48 
49 #include <comphelper/InlineContainer.hxx>
50 
51 
52 // header for struct SvtLinguConfig
53 #ifndef _SVTOOLS_LINGUCFG_HXX_
54 #include <unotools/lingucfg.hxx>
55 #endif
56 #ifndef INCLUDED_I18NPOOL_MSLANGID_HXX
57 #include <i18npool/mslangid.hxx>
58 #endif
59 #ifndef _SV_OUTDEV_HXX
60 #include <vcl/outdev.hxx>
61 #endif
62 
63 using namespace ::com::sun::star;
64 
65 using ::com::sun::star::beans::Property;
66 
67 using ::rtl::OUString;
68 
69 namespace chart
70 {
71 
AddPropertiesToVector(::std::vector<Property> & rOutProperties)72 void CharacterProperties::AddPropertiesToVector(
73     ::std::vector< Property > & rOutProperties )
74 {
75     // CharacterProperties
76     rOutProperties.push_back(
77         Property( C2U( "CharFontName" ),
78                   PROP_CHAR_FONT_NAME,
79                   ::getCppuType( reinterpret_cast< const OUString * >(0)),
80                   beans::PropertyAttribute::BOUND
81                   | beans::PropertyAttribute::MAYBEDEFAULT ));
82     rOutProperties.push_back(
83         Property( C2U( "CharFontStyleName" ),
84                   PROP_CHAR_FONT_STYLE_NAME,
85                   ::getCppuType( reinterpret_cast< const  OUString * >(0)),
86                   beans::PropertyAttribute::BOUND
87                   | beans::PropertyAttribute::MAYBEDEFAULT
88                   | beans::PropertyAttribute::MAYBEVOID ));
89     // CharFontFamily (see awt.FontFamily)
90     rOutProperties.push_back(
91         Property( C2U( "CharFontFamily" ),
92                   PROP_CHAR_FONT_FAMILY,
93                   ::getCppuType( reinterpret_cast< const  sal_Int16 * >(0)),
94                   beans::PropertyAttribute::BOUND
95                   | beans::PropertyAttribute::MAYBEDEFAULT ));
96     // CharFontCharSet (see awt.CharSet)
97     rOutProperties.push_back(
98         Property( C2U( "CharFontCharSet" ),
99                   PROP_CHAR_FONT_CHAR_SET,
100                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
101                   beans::PropertyAttribute::BOUND
102                   | beans::PropertyAttribute::MAYBEDEFAULT ));
103     // CharFontPitch (see awt.FontPitch)
104     rOutProperties.push_back(
105         Property( C2U( "CharFontPitch" ),
106                   PROP_CHAR_FONT_PITCH,
107                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
108                   beans::PropertyAttribute::BOUND
109                   | beans::PropertyAttribute::MAYBEDEFAULT ));
110     // CharColor
111     rOutProperties.push_back(
112         Property( C2U( "CharColor" ),
113                   PROP_CHAR_COLOR,
114                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
115                   beans::PropertyAttribute::BOUND
116                   | beans::PropertyAttribute::MAYBEDEFAULT ));
117     // CharBackColor
118 //     rOutProperties.push_back(
119 //         Property( C2U( "CharBackColor" ),
120 //                   PROP_CHAR_BACKGROUND_COLOR,
121 //                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
122 //                   beans::PropertyAttribute::BOUND
123 //                   | beans::PropertyAttribute::MAYBEDEFAULT));
124     // CharEscapement
125     rOutProperties.push_back(
126         Property( C2U( "CharEscapement" ),
127                   PROP_CHAR_ESCAPEMENT,
128                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
129                   beans::PropertyAttribute::BOUND
130                   | beans::PropertyAttribute::MAYBEVOID ));
131     // CharHeight
132     rOutProperties.push_back(
133         Property( C2U( "CharHeight" ),
134                   PROP_CHAR_CHAR_HEIGHT,
135                   ::getCppuType( reinterpret_cast< const float * >(0)),
136                   beans::PropertyAttribute::BOUND
137                   | beans::PropertyAttribute::MAYBEDEFAULT ));
138     // CharUnderline (see awt.FontUnderline)
139     rOutProperties.push_back(
140         Property( C2U( "CharUnderline" ),
141                   PROP_CHAR_UNDERLINE,
142                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
143                   beans::PropertyAttribute::BOUND
144                   | beans::PropertyAttribute::MAYBEDEFAULT ));
145     // CharUnderlineColor
146     rOutProperties.push_back(
147         Property( C2U( "CharUnderlineColor" ),
148                   PROP_CHAR_UNDERLINE_COLOR,
149                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
150                   beans::PropertyAttribute::BOUND
151                   | beans::PropertyAttribute::MAYBEDEFAULT
152                   | beans::PropertyAttribute::MAYBEVOID ));
153     // CharUnderlineHasColor
154     rOutProperties.push_back(
155         Property( C2U( "CharUnderlineHasColor" ),
156                   PROP_CHAR_UNDERLINE_HAS_COLOR,
157                   ::getBooleanCppuType(),
158                   beans::PropertyAttribute::BOUND
159                   | beans::PropertyAttribute::MAYBEDEFAULT ));
160     // CharOverline (see awt.FontUnderline)
161     rOutProperties.push_back(
162         Property( C2U( "CharOverline" ),
163                   PROP_CHAR_OVERLINE,
164                   ::getCppuType( reinterpret_cast< const sal_Int16* >( 0 ) ),
165                   beans::PropertyAttribute::BOUND
166                   | beans::PropertyAttribute::MAYBEDEFAULT ) );
167     // CharOverlineColor
168     rOutProperties.push_back(
169         Property( C2U( "CharOverlineColor" ),
170                   PROP_CHAR_OVERLINE_COLOR,
171                   ::getCppuType( reinterpret_cast< const sal_Int32* >( 0 ) ),
172                   beans::PropertyAttribute::BOUND
173                   | beans::PropertyAttribute::MAYBEDEFAULT
174                   | beans::PropertyAttribute::MAYBEVOID ) );
175     // CharOverlineHasColor
176     rOutProperties.push_back(
177         Property( C2U( "CharOverlineHasColor" ),
178                   PROP_CHAR_OVERLINE_HAS_COLOR,
179                   ::getBooleanCppuType(),
180                   beans::PropertyAttribute::BOUND
181                   | beans::PropertyAttribute::MAYBEDEFAULT ) );
182     // CharWeight (see awt.FontWeight)
183     rOutProperties.push_back(
184         Property( C2U( "CharWeight" ),
185                   PROP_CHAR_WEIGHT,
186                   ::getCppuType( reinterpret_cast< const float * >(0)),
187                   beans::PropertyAttribute::BOUND
188                   | beans::PropertyAttribute::MAYBEDEFAULT ));
189     // CharPosture
190     rOutProperties.push_back(
191         Property( C2U( "CharPosture" ),
192                   PROP_CHAR_POSTURE,
193                   ::getCppuType( reinterpret_cast< const awt::FontSlant * >(0)),
194                   beans::PropertyAttribute::BOUND
195                   | beans::PropertyAttribute::MAYBEDEFAULT ));
196     rOutProperties.push_back(
197         Property( C2U( "CharAutoKerning" ),
198                   PROP_CHAR_AUTO_KERNING,
199                   ::getBooleanCppuType(),
200                   beans::PropertyAttribute::BOUND
201                   | beans::PropertyAttribute::MAYBEDEFAULT
202                   | beans::PropertyAttribute::MAYBEVOID ));
203     rOutProperties.push_back(
204         Property( C2U( "CharKerning" ),
205                   PROP_CHAR_KERNING,
206                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
207                   beans::PropertyAttribute::BOUND
208                   | beans::PropertyAttribute::MAYBEDEFAULT
209                   | beans::PropertyAttribute::MAYBEVOID ));
210     // CharCaseMap (see style.CaseMap)
211 //     rOutProperties.push_back(
212 //         Property( C2U( "CharCaseMap" ),
213 //                   PROP_CHAR_CASE_MAPPING,
214 //                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
215 //                   beans::PropertyAttribute::BOUND
216 //                   | beans::PropertyAttribute::MAYBEDEFAULT ));
217 
218 
219     // CharRotation
220 //     rOutProperties.push_back(
221 //         Property( C2U( "CharRotation" ),
222 //                   PROP_CHAR_ROTATION,
223 //                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
224 //                   beans::PropertyAttribute::BOUND
225 //                   | beans::PropertyAttribute::MAYBEDEFAULT ));
226 
227 //     // CharScaleWidth
228 //     rOutProperties.push_back(
229 //         Property( C2U( "CharScaleWidth" ),
230 //                   PROP_CHAR_SCALE_WIDTH,
231 //                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
232 //                   beans::PropertyAttribute::BOUND
233 //                   | beans::PropertyAttribute::MAYBEDEFAULT ));
234     // CharEscapementHeight
235     rOutProperties.push_back(
236         Property( C2U( "CharEscapementHeight" ),
237                   PROP_CHAR_ESCAPEMENT_HEIGHT,
238                   ::getCppuType( reinterpret_cast< const sal_Int8 * >(0)),
239                   beans::PropertyAttribute::BOUND
240                   | beans::PropertyAttribute::MAYBEVOID ));
241 
242     // CharCrossedOut
243 //     rOutProperties.push_back(
244 //         Property( C2U( "CharCrossedOut" ),
245 //                   PROP_CHAR_CROSSED_OUT,
246 //                   ::getBooleanCppuType(),
247 //                   beans::PropertyAttribute::BOUND
248 //                   | beans::PropertyAttribute::MAYBEDEFAULT ));
249     // CharStrikeout (see awt.FontStrikeout)
250     rOutProperties.push_back(
251         Property( C2U( "CharStrikeout" ),
252                   PROP_CHAR_STRIKE_OUT,
253                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
254                   beans::PropertyAttribute::BOUND
255                   | beans::PropertyAttribute::MAYBEDEFAULT ));
256     // CharWordMode
257     rOutProperties.push_back(
258         Property( C2U( "CharWordMode" ),
259                   PROP_CHAR_WORD_MODE,
260                   ::getBooleanCppuType(),
261                   beans::PropertyAttribute::BOUND
262                   | beans::PropertyAttribute::MAYBEDEFAULT ));
263     // CharFlash
264 //     rOutProperties.push_back(
265 //         Property( C2U( "CharFlash" ),
266 //                   PROP_CHAR_FLASH,
267 //                   ::getBooleanCppuType(),
268 //                   beans::PropertyAttribute::BOUND
269 //                   | beans::PropertyAttribute::MAYBEDEFAULT ));
270     // CharLocale
271     rOutProperties.push_back(
272         Property( C2U( "CharLocale" ),
273                   PROP_CHAR_LOCALE,
274                   ::getCppuType( reinterpret_cast< const lang::Locale * >(0)),
275                   //#i111967# no PropertyChangeEvent is fired on change so far
276                   beans::PropertyAttribute::MAYBEDEFAULT ));
277     // CharShadowed
278     rOutProperties.push_back(
279         Property( C2U( "CharShadowed" ),
280                   PROP_CHAR_SHADOWED,
281                   ::getBooleanCppuType(),
282                   beans::PropertyAttribute::BOUND
283                   | beans::PropertyAttribute::MAYBEDEFAULT ));
284     // CharContoured
285     rOutProperties.push_back(
286         Property( C2U( "CharContoured" ),
287                   PROP_CHAR_CONTOURED,
288                   ::getBooleanCppuType(),
289                   beans::PropertyAttribute::BOUND
290                   | beans::PropertyAttribute::MAYBEDEFAULT ));
291     // CharRelief (see text.FontRelief)
292     rOutProperties.push_back(
293         Property( C2U( "CharRelief" ),
294                   PROP_CHAR_RELIEF,
295                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
296                   beans::PropertyAttribute::BOUND
297                   | beans::PropertyAttribute::MAYBEDEFAULT ));
298 
299     // CharEmphasize (see text.FontEmphasis)
300     rOutProperties.push_back(
301         Property( C2U( "CharEmphasis" ),
302                   PROP_CHAR_EMPHASIS,
303                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
304                   beans::PropertyAttribute::BOUND
305                   | beans::PropertyAttribute::MAYBEDEFAULT ));
306 //     // RubyText
307 //     rOutProperties.push_back(
308 //         Property( C2U( "RubyText" ),
309 //                   PROP_CHAR_RUBY_TEXT,
310 //                   ::getCppuType( reinterpret_cast< const OUString * >(0)),
311 //                   beans::PropertyAttribute::BOUND
312 //                   | beans::PropertyAttribute::MAYBEDEFAULT ));
313 //     // RubyAdjust (see text.RubyAdjust)
314 //     rOutProperties.push_back(
315 //         Property( C2U( "RubyAdjust" ),
316 //                   PROP_CHAR_RUBY_ADJUST,
317 //                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
318 //                   beans::PropertyAttribute::BOUND
319 //                   | beans::PropertyAttribute::MAYBEDEFAULT ));
320 //     // RubyCharStyleName
321 //     rOutProperties.push_back(
322 //         Property( C2U( "RubyStyleName" ),
323 //                   PROP_CHAR_RUBY_STYLE_NAME,
324 //                   ::getCppuType( reinterpret_cast< const OUString * >(0)),
325 //                   beans::PropertyAttribute::BOUND
326 //                   | beans::PropertyAttribute::MAYBEDEFAULT ));
327 //     // RubyIsAbove
328 //     rOutProperties.push_back(
329 //         Property( C2U( "RubyIsAbove" ),
330 //                   PROP_CHAR_RUBY_IS_ABOVE,
331 //                   ::getBooleanCppuType(),
332 //                   beans::PropertyAttribute::BOUND
333 //                   | beans::PropertyAttribute::MAYBEDEFAULT ));
334 //     // CharNoHyphenation
335 //     rOutProperties.push_back(
336 //         Property( C2U( "InhibitHyphenation" ),
337 //                   PROP_CHAR_INHIBIT_HYPHENATION,
338 //                   ::getBooleanCppuType(),
339 //                   beans::PropertyAttribute::BOUND
340 //                   | beans::PropertyAttribute::MAYBEDEFAULT ));
341 
342     // CharacterPropertiesAsian
343     // =====
344     // CharFontNameAsian
345     rOutProperties.push_back(
346         Property( C2U( "CharFontNameAsian" ),
347                   PROP_CHAR_ASIAN_FONT_NAME,
348                   ::getCppuType( reinterpret_cast< const OUString * >(0)),
349                   beans::PropertyAttribute::BOUND
350                   | beans::PropertyAttribute::MAYBEDEFAULT ));
351     // CharFontStyleNameAsian
352     rOutProperties.push_back(
353         Property( C2U( "CharFontStyleNameAsian" ),
354                   PROP_CHAR_ASIAN_FONT_STYLE_NAME,
355                   ::getCppuType( reinterpret_cast< const OUString * >(0)),
356                   beans::PropertyAttribute::BOUND
357                   | beans::PropertyAttribute::MAYBEDEFAULT
358                   | beans::PropertyAttribute::MAYBEVOID ));
359     // CharFontFamilyAsian (see awt.FontFamily)
360     rOutProperties.push_back(
361         Property( C2U( "CharFontFamilyAsian" ),
362                   PROP_CHAR_ASIAN_FONT_FAMILY,
363                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
364                   beans::PropertyAttribute::BOUND
365                   | beans::PropertyAttribute::MAYBEDEFAULT ));
366     // CharFontCharSetAsian (see awt.CharSet)
367     rOutProperties.push_back(
368         Property( C2U( "CharFontCharSetAsian" ),
369                   PROP_CHAR_ASIAN_CHAR_SET,
370                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
371                   beans::PropertyAttribute::BOUND
372                   | beans::PropertyAttribute::MAYBEDEFAULT ));
373     // CharFontPitchAsian (see awt.FontPitch)
374     rOutProperties.push_back(
375         Property( C2U( "CharFontPitchAsian" ),
376                   PROP_CHAR_ASIAN_FONT_PITCH,
377                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
378                   beans::PropertyAttribute::BOUND
379                   | beans::PropertyAttribute::MAYBEDEFAULT ));
380     // CharHeightAsian
381     rOutProperties.push_back(
382         Property( C2U( "CharHeightAsian" ),
383                   PROP_CHAR_ASIAN_CHAR_HEIGHT,
384                   ::getCppuType( reinterpret_cast< const float * >(0)),
385                   beans::PropertyAttribute::BOUND
386                   | beans::PropertyAttribute::MAYBEDEFAULT ));
387     // CharWeightAsian
388     rOutProperties.push_back(
389         Property( C2U( "CharWeightAsian" ),
390                   PROP_CHAR_ASIAN_WEIGHT,
391                   ::getCppuType( reinterpret_cast< const float * >(0)),
392                   beans::PropertyAttribute::BOUND
393                   | beans::PropertyAttribute::MAYBEDEFAULT ));
394     // CharPostureAsian
395     rOutProperties.push_back(
396         Property( C2U( "CharPostureAsian" ),
397                   PROP_CHAR_ASIAN_POSTURE,
398                   ::getCppuType( reinterpret_cast< const awt::FontSlant * >(0)),
399                   beans::PropertyAttribute::BOUND
400                   | beans::PropertyAttribute::MAYBEDEFAULT ));
401     // CharLocaleAsian
402     rOutProperties.push_back(
403         Property( C2U( "CharLocaleAsian" ),
404                   PROP_CHAR_ASIAN_LOCALE,
405                   ::getCppuType( reinterpret_cast< const lang::Locale * >(0)),
406                   //#i111967# no PropertyChangeEvent is fired on change so far
407                   beans::PropertyAttribute::MAYBEDEFAULT ));
408 
409     // CharacterPropertiesComplex
410     // ===
411     // CharFontNameComplex
412     rOutProperties.push_back(
413         Property( C2U( "CharFontNameComplex" ),
414                   PROP_CHAR_COMPLEX_FONT_NAME,
415                   ::getCppuType( reinterpret_cast< const OUString * >(0)),
416                   beans::PropertyAttribute::BOUND
417                   | beans::PropertyAttribute::MAYBEDEFAULT ));
418     // CharFontStyleNameComplex
419     rOutProperties.push_back(
420         Property( C2U( "CharFontStyleNameComplex" ),
421                   PROP_CHAR_COMPLEX_FONT_STYLE_NAME,
422                   ::getCppuType( reinterpret_cast< const OUString * >(0)),
423                   beans::PropertyAttribute::BOUND
424                   | beans::PropertyAttribute::MAYBEDEFAULT
425                   | beans::PropertyAttribute::MAYBEVOID ));
426     // CharFontFamilyComplex (see awt.FontFamily)
427     rOutProperties.push_back(
428         Property( C2U( "CharFontFamilyComplex" ),
429                   PROP_CHAR_COMPLEX_FONT_FAMILY,
430                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
431                   beans::PropertyAttribute::BOUND
432                   | beans::PropertyAttribute::MAYBEDEFAULT ));
433     // CharFontCharSetComplex (see awt.CharSet)
434     rOutProperties.push_back(
435         Property( C2U( "CharFontCharSetComplex" ),
436                   PROP_CHAR_COMPLEX_CHAR_SET,
437                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
438                   beans::PropertyAttribute::BOUND
439                   | beans::PropertyAttribute::MAYBEDEFAULT ));
440     // CharFontPitchComplex (see awt.FontPitch)
441     rOutProperties.push_back(
442         Property( C2U( "CharFontPitchComplex" ),
443                   PROP_CHAR_COMPLEX_FONT_PITCH,
444                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
445                   beans::PropertyAttribute::BOUND
446                   | beans::PropertyAttribute::MAYBEDEFAULT ));
447     // CharHeightComplex
448     rOutProperties.push_back(
449         Property( C2U( "CharHeightComplex" ),
450                   PROP_CHAR_COMPLEX_CHAR_HEIGHT,
451                   ::getCppuType( reinterpret_cast< const float * >(0)),
452                   beans::PropertyAttribute::BOUND
453                   | beans::PropertyAttribute::MAYBEDEFAULT ));
454     // CharWeightComplex
455     rOutProperties.push_back(
456         Property( C2U( "CharWeightComplex" ),
457                   PROP_CHAR_COMPLEX_WEIGHT,
458                   ::getCppuType( reinterpret_cast< const float * >(0)),
459                   beans::PropertyAttribute::BOUND
460                   | beans::PropertyAttribute::MAYBEDEFAULT ));
461     // CharPostureComplex
462     rOutProperties.push_back(
463         Property( C2U( "CharPostureComplex" ),
464                   PROP_CHAR_COMPLEX_POSTURE,
465                   ::getCppuType( reinterpret_cast< const awt::FontSlant * >(0)),
466                   beans::PropertyAttribute::BOUND
467                   | beans::PropertyAttribute::MAYBEDEFAULT ));
468     // CharLocaleComplex
469     rOutProperties.push_back(
470         Property( C2U( "CharLocaleComplex" ),
471                   PROP_CHAR_COMPLEX_LOCALE,
472                   ::getCppuType( reinterpret_cast< const lang::Locale * >(0)),
473                   //#i111967# no PropertyChangeEvent is fired on change so far
474                   beans::PropertyAttribute::MAYBEDEFAULT ));
475 
476     // Writing Mode left to right vs right to left
477     rOutProperties.push_back(
478         Property( C2U( "WritingMode" ),
479                   PROP_WRITING_MODE,
480                   ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)), /*com::sun::star::text::WritingMode2*/
481                   beans::PropertyAttribute::BOUND
482                   | beans::PropertyAttribute::MAYBEDEFAULT ));
483 
484     rOutProperties.push_back(
485         Property( C2U( "ParaIsCharacterDistance" ),
486                   PROP_PARA_IS_CHARACTER_DISTANCE,
487                   ::getBooleanCppuType(),
488                   beans::PropertyAttribute::BOUND
489                   | beans::PropertyAttribute::MAYBEDEFAULT ));
490 }
491 
AddDefaultsToMap(::chart::tPropertyValueMap & rOutMap)492 void CharacterProperties::AddDefaultsToMap(
493     ::chart::tPropertyValueMap & rOutMap )
494 {
495     const float fDefaultFontHeight = 13.0;
496 
497     SvtLinguConfig aLinguConfig;
498     lang::Locale aDefaultLocale;
499     aLinguConfig.GetProperty(C2U("DefaultLocale")) >>= aDefaultLocale;
500     lang::Locale aDefaultLocale_CJK;
501     aLinguConfig.GetProperty(C2U("DefaultLocale_CJK")) >>= aDefaultLocale_CJK;
502     lang::Locale aDefaultLocale_CTL;
503     aLinguConfig.GetProperty(C2U("DefaultLocale_CTL")) >>= aDefaultLocale_CTL;
504 
505     using namespace ::com::sun::star::i18n::ScriptType;
506     LanguageType nLang;
507     nLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aDefaultLocale), LATIN);
508     Font aFont = OutputDevice::GetDefaultFont( DEFAULTFONT_LATIN_SPREADSHEET, nLang, DEFAULTFONT_FLAGS_ONLYONE, 0 );
509     nLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage( aDefaultLocale_CJK), ASIAN);
510     Font aFontCJK = OutputDevice::GetDefaultFont( DEFAULTFONT_CJK_SPREADSHEET, nLang, DEFAULTFONT_FLAGS_ONLYONE, 0 );
511     nLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage( aDefaultLocale_CTL), COMPLEX);
512     Font aFontCTL = OutputDevice::GetDefaultFont( DEFAULTFONT_CTL_SPREADSHEET, nLang, DEFAULTFONT_FLAGS_ONLYONE, 0 );
513 
514     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FONT_NAME, OUString( aFont.GetName() ) );
515     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FONT_STYLE_NAME, OUString(aFont.GetStyleName()) );
516     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FONT_FAMILY, sal_Int16(aFont.GetFamily()) );//awt::FontFamily::SWISS
517     ::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
518     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FONT_PITCH, sal_Int16(aFont.GetPitch()) );//awt::FontPitch::VARIABLE
519     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_CHAR_COLOR, -1 ); //automatic color (COL_AUTO)
520     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_CHAR_HEIGHT, fDefaultFontHeight );
521     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_UNDERLINE, awt::FontUnderline::NONE );
522     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_CHAR_UNDERLINE_COLOR, -1 ); //automatic color (COL_AUTO)
523     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_UNDERLINE_HAS_COLOR, false );
524     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_OVERLINE, awt::FontUnderline::NONE );
525     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_CHAR_OVERLINE_COLOR, -1 ); //automatic color (COL_AUTO)
526     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_OVERLINE_HAS_COLOR, false );
527     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_WEIGHT, awt::FontWeight::NORMAL );
528     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_POSTURE, awt::FontSlant_NONE );
529     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_AUTO_KERNING, true );
530     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_CHAR_KERNING, 0 );
531 
532 //     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_CASE_MAPPING, style::CaseMap::NONE );
533 //     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_CHAR_ROTATION, 0 );
534 //     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_CHAR_SCALE_WIDTH, 71 );
535 
536 //     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_CROSSED_OUT, false );
537     ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_CHAR_STRIKE_OUT, awt::FontStrikeout::NONE );
538     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_WORD_MODE, false );
539 //     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_FLASH, false );
540 
541     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_LOCALE, aDefaultLocale );
542     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_SHADOWED, false );
543     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_CONTOURED, false );
544     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_RELIEF, text::FontRelief::NONE );
545 
546     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_EMPHASIS, text::FontEmphasis::NONE );
547 
548 //     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_RUBY_ADJUST, text::RubyAdjust_INDENT_BLOCK );
549 //     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_RUBY_STYLE_NAME, ?? );
550 //     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_RUBY_IS_ABOVE, true );
551 //     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_INHIBIT_HYPHENATION, false );
552 
553     // Asian (com.sun.star.style.CharacterPropertiesAsian)
554     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultFontHeight );
555     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_WEIGHT, awt::FontWeight::NORMAL );
556     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_POSTURE, awt::FontSlant_NONE );
557     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_LOCALE, aDefaultLocale_CJK );
558     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_FONT_NAME, OUString( aFontCJK.GetName() ) );
559     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_FONT_STYLE_NAME, OUString(aFontCJK.GetStyleName()) );
560     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_FONT_FAMILY, sal_Int16(aFontCJK.GetFamily()) );
561     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_CHAR_SET, sal_Int16(aFontCJK.GetCharSet()) );
562     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_ASIAN_FONT_PITCH, sal_Int16(aFontCJK.GetPitch()) );
563 
564     // Complex Text Layout (com.sun.star.style.CharacterPropertiesComplex)
565     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultFontHeight );
566     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_WEIGHT, awt::FontWeight::NORMAL );
567     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_POSTURE, awt::FontSlant_NONE );
568     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_LOCALE, aDefaultLocale_CTL );
569     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_FONT_NAME, OUString( aFontCTL.GetName() ) );
570     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_FONT_STYLE_NAME, OUString(aFontCTL.GetStyleName()) );
571     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_FONT_FAMILY, sal_Int16(aFontCTL.GetFamily()) );
572     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_CHAR_SET, sal_Int16(aFontCTL.GetCharSet()) );
573     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CHAR_COMPLEX_FONT_PITCH, sal_Int16(aFontCTL.GetPitch()) );
574 
575     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_WRITING_MODE, sal_Int16( com::sun::star::text::WritingMode2::PAGE ) );
576     ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_PARA_IS_CHARACTER_DISTANCE, sal_True );
577 }
578 
IsCharacterPropertyHandle(sal_Int32 nHandle)579 bool CharacterProperties::IsCharacterPropertyHandle( sal_Int32 nHandle )
580 {
581     return ( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle &&
582              nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP );
583 }
584 
createFontDescriptorFromPropertySet(const uno::Reference<beans::XMultiPropertySet> & xMultiPropSet)585 awt::FontDescriptor CharacterProperties::createFontDescriptorFromPropertySet(
586     const uno::Reference< beans::XMultiPropertySet > & xMultiPropSet )
587 {
588     awt::FontDescriptor aResult;
589     // Note: keep this sorted!
590     ::comphelper::MakeVector< OUString > aPropNames
591         ( C2U("CharFontCharSet"));                // CharSet
592     aPropNames
593         ( C2U("CharFontFamily"))                  // Family
594         ( C2U("CharFontName"))                    // Name
595         ( C2U("CharFontPitch"))                   // Pitch
596         ( C2U("CharFontStyleName"))               // StyleName
597         ( C2U("CharHeight"))                      // Height
598         ( C2U("CharPosture"))                     // Slant
599         ( C2U("CharStrikeout"))                   // Strikeout
600         ( C2U("CharUnderline"))                   // Underline
601         ( C2U("CharWeight"))                      // Weight
602         ( C2U("CharWordMode"))                    // WordLineMode
603         ;
604 
605     uno::Sequence< OUString > aPropNameSeq( ContainerHelper::ContainerToSequence( aPropNames ));
606     uno::Sequence< uno::Any > aValues( xMultiPropSet->getPropertyValues( aPropNameSeq ));
607 
608     sal_Int32 i=0;
609     // Note keep this sorted according to the list above (comments are the fieldnames)
610     aValues[ i++ ]  >>= aResult.CharSet;
611     aValues[ i++ ]  >>= aResult.Family;
612     aValues[ i++ ]  >>= aResult.Name;
613     aValues[ i++ ]  >>= aResult.Pitch;
614     aValues[ i++ ]  >>= aResult.StyleName;
615     float fCharHeight = 0;
616     aValues[ i++ ]  >>= fCharHeight;
617     aResult.Height = static_cast< sal_Int16 >( fCharHeight );
618     aValues[ i++ ]  >>= aResult.Slant;
619     aValues[ i++ ]  >>= aResult.Strikeout;
620     aValues[ i++ ]  >>= aResult.Underline;
621     aValues[ i++ ]  >>= aResult.Weight;
622     aValues[ i++ ]  >>= aResult.WordLineMode;
623     OSL_ASSERT( i == aValues.getLength());
624 
625     return aResult;
626 }
627 
628 } //  namespace chart
629