Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / oox / source / drawingml / textcharacterpropertiescontext.cxx
blob84ba8a044d0ed0b184ba2c8a8ba2b2f76b4308d6
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 "drawingml/textcharacterpropertiescontext.hxx"
22 #include "oox/helper/attributelist.hxx"
23 #include "oox/drawingml/drawingmltypes.hxx"
24 #include "drawingml/colorchoicecontext.hxx"
25 #include "drawingml/texteffectscontext.hxx"
26 #include "drawingml/lineproperties.hxx"
27 #include "drawingml/textparagraphproperties.hxx"
28 #include "oox/core/relations.hxx"
29 #include "hyperlinkcontext.hxx"
30 #include <oox/token/namespaces.hxx>
31 #include <oox/token/tokens.hxx>
33 using namespace ::oox::core;
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::xml::sax;
36 using namespace ::com::sun::star::awt;
38 namespace oox { namespace drawingml {
40 // CT_TextCharacterProperties
41 TextCharacterPropertiesContext::TextCharacterPropertiesContext(
42 ContextHandler2Helper& rParent,
43 const AttributeList& rAttribs,
44 TextCharacterProperties& rTextCharacterProperties )
45 : ContextHandler2( rParent )
46 , mrTextCharacterProperties( rTextCharacterProperties )
48 if ( rAttribs.hasAttribute( XML_lang ) )
49 mrTextCharacterProperties.moLang = rAttribs.getString( XML_lang );
50 if ( rAttribs.hasAttribute( XML_sz ) )
51 mrTextCharacterProperties.moHeight = rAttribs.getInteger( XML_sz );
52 if ( rAttribs.hasAttribute( XML_spc ) )
53 mrTextCharacterProperties.moSpacing = rAttribs.getInteger( XML_spc );
54 if ( rAttribs.hasAttribute( XML_u ) )
55 mrTextCharacterProperties.moUnderline = rAttribs.getToken( XML_u );
56 if ( rAttribs.hasAttribute( XML_strike ) )
57 mrTextCharacterProperties.moStrikeout = rAttribs.getToken( XML_strike );
58 if ( rAttribs.hasAttribute( XML_baseline ) && rAttribs.getInteger( XML_baseline ).get() != 0 )
59 mrTextCharacterProperties.moBaseline = rAttribs.getInteger( XML_baseline );
61 if ( rAttribs.hasAttribute( XML_b ) )
62 mrTextCharacterProperties.moBold = rAttribs.getBool( XML_b );
63 if ( rAttribs.hasAttribute( XML_i ) )
64 mrTextCharacterProperties.moItalic = rAttribs.getBool( XML_i );
65 if( rAttribs.hasAttribute( XML_cap ) )
66 mrTextCharacterProperties.moCaseMap = rAttribs.getToken( XML_cap );
68 /* TODO / unhandled so far:
69 A_TOKEN( kern )
70 XML_altLang
71 A_TOKEN( kumimoji )
72 A_TOKEN( spc )
73 A_TOKEN( normalizeH )
74 A_TOKEN( noProof )
75 A_TOKEN( dirty )
76 A_TOKEN( err )
77 A_TOKEN( smtClean )
78 A_TOKEN( smtId )
82 TextCharacterPropertiesContext::~TextCharacterPropertiesContext()
86 ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
88 switch( aElementToken )
90 // TODO unsupported yet
91 // case A_TOKEN( ln ): // CT_LineProperties
92 // return new LinePropertiesContext( getHandler(), rAttribs, maTextOutlineProperties );
93 // EG_FillProperties
94 case A_TOKEN( noFill ):
95 case A_TOKEN( solidFill ):
96 case A_TOKEN( gradFill ):
97 case A_TOKEN( pattFill ):
98 return FillPropertiesContext::createFillContext( *this, aElementToken, rAttribs, mrTextCharacterProperties.maFillProperties );
99 // EG_EffectProperties
100 case A_TOKEN( effectDag ): // CT_EffectContainer 5.1.10.25
101 case A_TOKEN( effectLst ): // CT_EffectList 5.1.10.26
102 break;
104 case A_TOKEN( highlight ): // CT_Color
105 return new ColorContext( *this, mrTextCharacterProperties.maHighlightColor );
107 // EG_TextUnderlineLine
108 case A_TOKEN( uLnTx ): // CT_TextUnderlineLineFollowText
109 mrTextCharacterProperties.moUnderlineLineFollowText = true;
110 break;
111 // TODO unsupported yet
112 // case A_TOKEN( uLn ): // CT_LineProperties
113 // return new LinePropertiesContext( getHandler(), rAttribs, maUnderlineProperties );
115 // EG_TextUnderlineFill
116 case A_TOKEN( uFillTx ): // CT_TextUnderlineFillFollowText
117 mrTextCharacterProperties.moUnderlineFillFollowText = true;
118 break;
119 case A_TOKEN( uFill ): // CT_TextUnderlineFillGroupWrapper->EG_FillProperties (not supported)
120 return new SimpleFillPropertiesContext( *this, mrTextCharacterProperties.maUnderlineColor );
122 // CT_FontCollection
123 case A_TOKEN( latin ): // CT_TextFont
124 mrTextCharacterProperties.maLatinFont.setAttributes( rAttribs );
125 break;
126 case A_TOKEN( ea ): // CT_TextFont
127 mrTextCharacterProperties.maAsianFont.setAttributes( rAttribs );
128 break;
129 case A_TOKEN( cs ): // CT_TextFont
130 mrTextCharacterProperties.maComplexFont.setAttributes( rAttribs );
131 break;
132 case A_TOKEN( sym ): // CT_TextFont
133 mrTextCharacterProperties.maSymbolFont.setAttributes( rAttribs );
134 break;
136 case A_TOKEN( hlinkClick ): // CT_Hyperlink
137 case A_TOKEN( hlinkMouseOver ): // CT_Hyperlink
138 return new HyperLinkContext( *this, rAttribs, mrTextCharacterProperties.maHyperlinkPropertyMap );
139 case W_TOKEN( rFonts ):
140 if( rAttribs.hasAttribute(W_TOKEN(ascii)) )
142 mrTextCharacterProperties.maLatinFont.setAttributes(rAttribs.getString(W_TOKEN(ascii), OUString()));
144 if (rAttribs.hasAttribute(W_TOKEN(asciiTheme)))
146 mrTextCharacterProperties.maLatinThemeFont.setAttributes(rAttribs.getString(W_TOKEN(asciiTheme), OUString()));
148 if( rAttribs.hasAttribute(W_TOKEN(cs)) )
150 mrTextCharacterProperties.maComplexFont.setAttributes(rAttribs.getString(W_TOKEN(cs), OUString()));
152 if (rAttribs.hasAttribute(W_TOKEN(cstheme)))
154 mrTextCharacterProperties.maComplexThemeFont.setAttributes(rAttribs.getString(W_TOKEN(cstheme), OUString()));
156 if( rAttribs.hasAttribute(W_TOKEN(eastAsia)) )
158 mrTextCharacterProperties.maAsianFont.setAttributes(rAttribs.getString(W_TOKEN(eastAsia), OUString()));
160 if (rAttribs.hasAttribute(W_TOKEN(eastAsiaTheme)))
162 mrTextCharacterProperties.maAsianThemeFont.setAttributes(rAttribs.getString(W_TOKEN(eastAsiaTheme), OUString()));
164 break;
165 case W_TOKEN( b ):
166 mrTextCharacterProperties.moBold = rAttribs.getBool(W_TOKEN( val ), true);
167 break;
168 case W_TOKEN( i ):
169 mrTextCharacterProperties.moItalic = rAttribs.getBool(W_TOKEN( val ), true);
170 break;
171 case W_TOKEN( bCs ):
172 break;
173 case W_TOKEN( color ):
174 if (rAttribs.getInteger(W_TOKEN(val)).has())
176 mrTextCharacterProperties.maFillProperties.maFillColor.setSrgbClr(rAttribs.getIntegerHex(W_TOKEN(val)).get());
177 mrTextCharacterProperties.maFillProperties.moFillType.set(XML_solidFill);
179 break;
180 case W_TOKEN( sz ):
181 if (rAttribs.getInteger(W_TOKEN(val)).has())
183 sal_Int32 nVal = rAttribs.getInteger(W_TOKEN(val)).get();
184 // wml has half points, dml has hundred points
185 mrTextCharacterProperties.moHeight = nVal * 50;
187 break;
188 case W_TOKEN( szCs ):
189 break;
190 case W_TOKEN( caps ):
192 if( rAttribs.getBool(W_TOKEN( val ), true) )
193 mrTextCharacterProperties.moCaseMap = XML_all;
194 else
195 mrTextCharacterProperties.moCaseMap = XML_none;
197 break;
198 case W_TOKEN( smallCaps ):
200 if( rAttribs.getBool(W_TOKEN( val ), true) )
201 mrTextCharacterProperties.moCaseMap = XML_small;
202 else
203 mrTextCharacterProperties.moCaseMap = XML_none;
205 break;
206 case OOX_TOKEN(w14, glow):
207 case OOX_TOKEN(w14, shadow):
208 case OOX_TOKEN(w14, reflection):
209 case OOX_TOKEN(w14, textOutline):
210 case OOX_TOKEN(w14, textFill):
211 case OOX_TOKEN(w14, scene3d):
212 case OOX_TOKEN(w14, props3d):
213 case OOX_TOKEN(w14, ligatures):
214 case OOX_TOKEN(w14, numForm):
215 case OOX_TOKEN(w14, numSpacing):
216 case OOX_TOKEN(w14, stylisticSets):
217 case OOX_TOKEN(w14, cntxtAlts):
219 return new TextEffectsContext( *this, aElementToken, mrTextCharacterProperties.maTextEffectsProperties );
221 break;
222 default:
223 SAL_WARN("oox", "TextCharacterPropertiesContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
224 break;
227 return this;
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */