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