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