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