bump product version to 4.1.6.2
[LibreOffice.git] / oox / source / drawingml / textcharacterproperties.cxx
blob13ccfb8c95b8506078748313433143409e77ad18
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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 <editeng/escapementitem.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"
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;
36 namespace oox {
37 namespace drawingml {
39 // ============================================================================
41 void TextCharacterProperties::assignUsed( const TextCharacterProperties& rSourceProps )
43 // overwrite all properties exisiting in rSourceProps
44 maHyperlinkPropertyMap.insert( rSourceProps.maHyperlinkPropertyMap.begin(), rSourceProps.maHyperlinkPropertyMap.end() );
45 maLatinFont.assignIfUsed( rSourceProps.maLatinFont );
46 maAsianFont.assignIfUsed( rSourceProps.maAsianFont );
47 maComplexFont.assignIfUsed( rSourceProps.maComplexFont );
48 maSymbolFont.assignIfUsed( rSourceProps.maSymbolFont );
49 maCharColor.assignIfUsed( rSourceProps.maCharColor );
50 maHighlightColor.assignIfUsed( rSourceProps.maHighlightColor );
51 maUnderlineColor.assignIfUsed( rSourceProps.maUnderlineColor );
52 moHeight.assignIfUsed( rSourceProps.moHeight );
53 moSpacing.assignIfUsed( rSourceProps.moSpacing );
54 moUnderline.assignIfUsed( rSourceProps.moUnderline );
55 moBaseline.assignIfUsed( rSourceProps.moBaseline );
56 moStrikeout.assignIfUsed( rSourceProps.moStrikeout );
57 moCaseMap.assignIfUsed( rSourceProps.moCaseMap );
58 moBold.assignIfUsed( rSourceProps.moBold );
59 moItalic.assignIfUsed( rSourceProps.moItalic );
60 moUnderlineLineFollowText.assignIfUsed( rSourceProps.moUnderlineLineFollowText );
61 moUnderlineFillFollowText.assignIfUsed( rSourceProps.moUnderlineFillFollowText );
64 void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFilterBase& rFilter, bool bUseOptional ) const
66 OUString aFontName;
67 sal_Int16 nFontPitch = 0;
68 sal_Int16 nFontFamily = 0;
70 if( maLatinFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ) )
72 rPropMap[ PROP_CharFontName ] <<= aFontName;
73 rPropMap[ PROP_CharFontPitch ] <<= nFontPitch;
74 rPropMap[ PROP_CharFontFamily ] <<= nFontFamily;
77 if( maAsianFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ) )
79 rPropMap[ PROP_CharFontNameAsian ] <<= aFontName;
80 rPropMap[ PROP_CharFontPitchAsian ] <<= nFontFamily;
81 rPropMap[ PROP_CharFontFamilyAsian ] <<= nFontPitch;
84 if( maComplexFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter ) )
86 rPropMap[ PROP_CharFontNameComplex ] <<= aFontName;
87 rPropMap[ PROP_CharFontPitchComplex ] <<= nFontPitch;
88 rPropMap[ PROP_CharFontFamilyComplex ] <<= nFontFamily;
91 // symbolfont, will now be ... textrun.cxx ... ausgewertet !!!i#113673
93 if( maCharColor.isUsed() )
94 rPropMap[ PROP_CharColor ] <<= maCharColor.getColor( rFilter.getGraphicHelper() );
96 if( moLang.has() && !moLang.get().isEmpty() )
98 lang::Locale aLocale;
99 sal_Int32 nSepPos = moLang.get().indexOf( sal_Unicode( '-' ), 0 );
100 if ( nSepPos >= 0 )
102 aLocale.Language = moLang.get().copy( 0, nSepPos );
103 aLocale.Country = moLang.get().copy( nSepPos + 1 );
105 else
107 aLocale.Language = moLang.get();
109 rPropMap[ PROP_CharLocale ] <<= aLocale;
110 rPropMap[ PROP_CharLocaleAsian ] <<= aLocale;
111 rPropMap[ PROP_CharLocaleComplex ] <<= aLocale;
114 if( moHeight.has() )
116 float fHeight = GetFontHeight( moHeight.get() );
117 rPropMap[ PROP_CharHeight ] <<= fHeight;
118 rPropMap[ PROP_CharHeightAsian ] <<= fHeight;
119 rPropMap[ PROP_CharHeightComplex ] <<= fHeight;
122 rPropMap[ PROP_CharKerning ] <<= (sal_Int16) GetTextSpacingPoint( moSpacing.get( 0 ) );
124 rPropMap[ PROP_CharUnderline ] <<= GetFontUnderline( moUnderline.get( XML_none ) );
125 rPropMap[ PROP_CharStrikeout ] <<= GetFontStrikeout( moStrikeout.get( XML_noStrike ) );
126 rPropMap[ PROP_CharCaseMap ] <<= GetCaseMap( moCaseMap.get( XML_none ) );
128 if( moBaseline.has() ) {
129 rPropMap[ PROP_CharEscapement ] <<= sal_Int16(moBaseline.get( 0 ) / 1000);
130 rPropMap[ PROP_CharEscapementHeight ] <<= sal_Int8(DFLT_ESC_PROP);
133 if( !bUseOptional || moBold.has() ) {
134 float fWeight = moBold.get( false ) ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL;
135 rPropMap[ PROP_CharWeight ] <<= fWeight;
136 rPropMap[ PROP_CharWeightAsian ] <<= fWeight;
137 rPropMap[ PROP_CharWeightComplex ] <<= fWeight;
140 if( !bUseOptional || moItalic.has() ) {
141 awt::FontSlant eSlant = moItalic.get( false ) ? awt::FontSlant_ITALIC : awt::FontSlant_NONE;
142 rPropMap[ PROP_CharPosture ] <<= eSlant;
143 rPropMap[ PROP_CharPostureAsian ] <<= eSlant;
144 rPropMap[ PROP_CharPostureComplex ] <<= eSlant;
147 bool bUnderlineFillFollowText = moUnderlineFillFollowText.get( false );
148 if( moUnderline.has() && maUnderlineColor.isUsed() && !bUnderlineFillFollowText )
150 rPropMap[ PROP_CharUnderlineHasColor ] <<= true;
151 rPropMap[ PROP_CharUnderlineColor ] <<= maUnderlineColor.getColor( rFilter.getGraphicHelper() );
155 void TextCharacterProperties::pushToPropSet( PropertySet& rPropSet, const XmlFilterBase& rFilter, bool bUseOptional ) const
157 PropertyMap aPropMap;
158 pushToPropMap( aPropMap, rFilter, bUseOptional );
159 rPropSet.setProperties( aPropMap );
162 float TextCharacterProperties::getCharHeightPoints( float fDefault ) const
164 return moHeight.has() ? GetFontHeight( moHeight.get() ) : fDefault;
167 // ============================================================================
169 } // namespace drawingml
170 } // namespace oox
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */