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