Line data Source code
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 "oox/drawingml/textcharacterproperties.hxx"
21 : #include <com/sun/star/lang/Locale.hpp>
22 : #include <com/sun/star/awt/FontSlant.hpp>
23 : #include <com/sun/star/awt/FontWeight.hpp>
24 : #include <i18nlangtag/languagetag.hxx>
25 : #include "oox/helper/helper.hxx"
26 : #include "oox/helper/propertyset.hxx"
27 : #include "oox/core/xmlfilterbase.hxx"
28 : #include "oox/drawingml/drawingmltypes.hxx"
29 : #include "oox/token/tokens.hxx"
30 :
31 : using ::oox::core::XmlFilterBase;
32 : using namespace ::com::sun::star;
33 : using namespace ::com::sun::star::uno;
34 : using namespace ::com::sun::star::beans;
35 :
36 : namespace oox {
37 : namespace drawingml {
38 :
39 : // ============================================================================
40 :
41 9321 : void TextCharacterProperties::assignUsed( const TextCharacterProperties& rSourceProps )
42 : {
43 : // overwrite all properties exisiting in rSourceProps
44 9321 : maHyperlinkPropertyMap.insert( rSourceProps.maHyperlinkPropertyMap.begin(), rSourceProps.maHyperlinkPropertyMap.end() );
45 9321 : maLatinFont.assignIfUsed( rSourceProps.maLatinFont );
46 9321 : maAsianFont.assignIfUsed( rSourceProps.maAsianFont );
47 9321 : maComplexFont.assignIfUsed( rSourceProps.maComplexFont );
48 9321 : maSymbolFont.assignIfUsed( rSourceProps.maSymbolFont );
49 9321 : maCharColor.assignIfUsed( rSourceProps.maCharColor );
50 9321 : maHighlightColor.assignIfUsed( rSourceProps.maHighlightColor );
51 9321 : maUnderlineColor.assignIfUsed( rSourceProps.maUnderlineColor );
52 9321 : moHeight.assignIfUsed( rSourceProps.moHeight );
53 9321 : moSpacing.assignIfUsed( rSourceProps.moSpacing );
54 9321 : moUnderline.assignIfUsed( rSourceProps.moUnderline );
55 9321 : moStrikeout.assignIfUsed( rSourceProps.moStrikeout );
56 9321 : moCaseMap.assignIfUsed( rSourceProps.moCaseMap );
57 9321 : moBold.assignIfUsed( rSourceProps.moBold );
58 9321 : moItalic.assignIfUsed( rSourceProps.moItalic );
59 9321 : moUnderlineLineFollowText.assignIfUsed( rSourceProps.moUnderlineLineFollowText );
60 9321 : moUnderlineFillFollowText.assignIfUsed( rSourceProps.moUnderlineFillFollowText );
61 9321 : }
62 :
63 292 : void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFilterBase& rFilter, bool bUseOptional ) const
64 : {
65 292 : OUString aFontName;
66 292 : sal_Int16 nFontPitch = 0;
67 292 : sal_Int16 nFontFamily = 0;
68 :
69 292 : if( maLatinFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ) )
70 : {
71 259 : rPropMap[ PROP_CharFontName ] <<= aFontName;
72 259 : rPropMap[ PROP_CharFontPitch ] <<= nFontPitch;
73 259 : rPropMap[ PROP_CharFontFamily ] <<= nFontFamily;
74 : }
75 :
76 292 : if( maAsianFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ) )
77 : {
78 28 : rPropMap[ PROP_CharFontNameAsian ] <<= aFontName;
79 28 : rPropMap[ PROP_CharFontPitchAsian ] <<= nFontFamily;
80 28 : rPropMap[ PROP_CharFontFamilyAsian ] <<= nFontPitch;
81 : }
82 :
83 292 : if( maComplexFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ) )
84 : {
85 120 : rPropMap[ PROP_CharFontNameComplex ] <<= aFontName;
86 120 : rPropMap[ PROP_CharFontPitchComplex ] <<= nFontPitch;
87 120 : rPropMap[ PROP_CharFontFamilyComplex ] <<= nFontFamily;
88 : }
89 :
90 : // symbolfont, will now be ... textrun.cxx ... ausgewertet !!!i#113673
91 :
92 292 : if( maCharColor.isUsed() )
93 256 : rPropMap[ PROP_CharColor ] <<= maCharColor.getColor( rFilter.getGraphicHelper() );
94 :
95 292 : if( moLang.has() && !moLang.get().isEmpty() )
96 : {
97 28 : lang::Locale aLocale( LanguageTag( moLang.get()).getLocale());
98 28 : rPropMap[ PROP_CharLocale ] <<= aLocale;
99 28 : rPropMap[ PROP_CharLocaleAsian ] <<= aLocale;
100 28 : rPropMap[ PROP_CharLocaleComplex ] <<= aLocale;
101 : }
102 :
103 292 : if( moHeight.has() )
104 : {
105 255 : float fHeight = GetFontHeight( moHeight.get() );
106 255 : rPropMap[ PROP_CharHeight ] <<= fHeight;
107 255 : rPropMap[ PROP_CharHeightAsian ] <<= fHeight;
108 255 : rPropMap[ PROP_CharHeightComplex ] <<= fHeight;
109 : }
110 :
111 292 : rPropMap[ PROP_CharKerning ] <<= (sal_Int16) GetTextSpacingPoint( moSpacing.get( 0 ) );
112 :
113 292 : rPropMap[ PROP_CharUnderline ] <<= GetFontUnderline( moUnderline.get( XML_none ) );
114 292 : rPropMap[ PROP_CharStrikeout ] <<= GetFontStrikeout( moStrikeout.get( XML_noStrike ) );
115 292 : rPropMap[ PROP_CharCaseMap ] <<= GetCaseMap( moCaseMap.get( XML_none ) );
116 :
117 292 : if( !bUseOptional || moBold.has() ) {
118 292 : float fWeight = moBold.get( false ) ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL;
119 292 : rPropMap[ PROP_CharWeight ] <<= fWeight;
120 292 : rPropMap[ PROP_CharWeightAsian ] <<= fWeight;
121 292 : rPropMap[ PROP_CharWeightComplex ] <<= fWeight;
122 : }
123 :
124 292 : if( !bUseOptional || moItalic.has() ) {
125 292 : awt::FontSlant eSlant = moItalic.get( false ) ? awt::FontSlant_ITALIC : awt::FontSlant_NONE;
126 292 : rPropMap[ PROP_CharPosture ] <<= eSlant;
127 292 : rPropMap[ PROP_CharPostureAsian ] <<= eSlant;
128 292 : rPropMap[ PROP_CharPostureComplex ] <<= eSlant;
129 : }
130 :
131 292 : bool bUnderlineFillFollowText = moUnderlineFillFollowText.get( false );
132 292 : if( moUnderline.has() && maUnderlineColor.isUsed() && !bUnderlineFillFollowText )
133 : {
134 0 : rPropMap[ PROP_CharUnderlineHasColor ] <<= true;
135 0 : rPropMap[ PROP_CharUnderlineColor ] <<= maUnderlineColor.getColor( rFilter.getGraphicHelper() );
136 292 : }
137 292 : }
138 :
139 292 : void TextCharacterProperties::pushToPropSet( PropertySet& rPropSet, const XmlFilterBase& rFilter, bool bUseOptional ) const
140 : {
141 292 : PropertyMap aPropMap;
142 292 : pushToPropMap( aPropMap, rFilter, bUseOptional );
143 292 : rPropSet.setProperties( aPropMap );
144 292 : }
145 :
146 6 : float TextCharacterProperties::getCharHeightPoints( float fDefault ) const
147 : {
148 6 : return moHeight.has() ? GetFontHeight( moHeight.get() ) : fDefault;
149 : }
150 :
151 : // ============================================================================
152 :
153 : } // namespace drawingml
154 141 : } // namespace oox
155 :
156 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|