LibreOffice Module oox (master) 1
textcharacterpropertiescontext.cxx
Go to the documentation of this file.
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
21
28#include "hyperlinkcontext.hxx"
29#include <oox/token/namespaces.hxx>
30#include <oox/token/tokens.hxx>
31#include <sax/fastattribs.hxx>
32
33#include <sal/log.hxx>
34
35using namespace ::oox::core;
36using namespace ::com::sun::star::uno;
37using namespace ::com::sun::star::xml::sax;
38using namespace ::com::sun::star::awt;
39
40namespace oox::drawingml {
41
42// CT_TextCharacterProperties
44 ContextHandler2Helper const & rParent,
45 const AttributeList& rAttribs,
46 TextCharacterProperties& rTextCharacterProperties )
47: ContextHandler2( rParent )
48, mrTextCharacterProperties( rTextCharacterProperties )
49{
50 int nVisualTokenAmount = sax_fastparser::castToFastAttributeList(
51 rAttribs.getFastAttributeList() ).getFastAttributeTokens().size();
52
53 if ( rAttribs.hasAttribute( XML_lang ) )
54 {
55 mrTextCharacterProperties.moLang = rAttribs.getString( XML_lang );
56 --nVisualTokenAmount; // Not a visual attribute
57 }
58 if ( rAttribs.hasAttribute( XML_altLang ))
59 {
60 --nVisualTokenAmount; // Not a visual attribute
61 }
62 if ( rAttribs.hasAttribute( XML_sz ) )
64 if ( rAttribs.hasAttribute( XML_spc ) )
66 if ( rAttribs.hasAttribute( XML_u ) )
68 if ( rAttribs.hasAttribute( XML_strike ) )
69 mrTextCharacterProperties.moStrikeout = rAttribs.getToken( XML_strike );
70 if ( rAttribs.hasAttribute( XML_baseline ) && rAttribs.getInteger( XML_baseline, 0 ) != 0 )
71 mrTextCharacterProperties.moBaseline = rAttribs.getInteger( XML_baseline );
72
73 if ( rAttribs.hasAttribute( XML_b ) )
74 mrTextCharacterProperties.moBold = rAttribs.getBool( XML_b );
75 if ( rAttribs.hasAttribute( XML_i ) )
76 mrTextCharacterProperties.moItalic = rAttribs.getBool( XML_i );
77 if( rAttribs.hasAttribute( XML_cap ) )
78 mrTextCharacterProperties.moCaseMap = rAttribs.getToken( XML_cap );
79 if ( rAttribs.hasAttribute( XML_dirty ) )
80 {
81 --nVisualTokenAmount; // Not a visual attribute
82 }
83 if ( rAttribs.hasAttribute( XML_smtClean ) )
84 {
85 --nVisualTokenAmount; // Not a visual attribute
86 }
87
88 if ( nVisualTokenAmount > 0 )
90
91 /* TODO / unhandled so far:
92 A_TOKEN( kern )
93 XML_altLang
94 A_TOKEN( kumimoji )
95 A_TOKEN( spc )
96 A_TOKEN( normalizeH )
97 A_TOKEN( noProof )
98 A_TOKEN( dirty )
99 A_TOKEN( err )
100 A_TOKEN( smtClean )
101 A_TOKEN( smtId )
102 */
103}
104
106{
107}
108
110{
111 if( aElementToken != A_TOKEN(lang) )
113
114 switch( aElementToken )
115 {
116 case A_TOKEN(ln): // CT_LineProperties
117 // TODO still largely unsupported
121 // EG_FillProperties
122 case A_TOKEN( noFill ):
123 case A_TOKEN( solidFill ):
124 case A_TOKEN( gradFill ):
125 case A_TOKEN( pattFill ):
127 // EG_EffectProperties
128 case A_TOKEN( effectDag ): // CT_EffectContainer 5.1.10.25
129 case A_TOKEN( effectLst ): // CT_EffectList 5.1.10.26
130 break;
131 case A_TOKEN( highlight ): // CT_Color
133 case W_TOKEN( highlight ):
135 break;
136 // EG_TextUnderlineLine
137 case A_TOKEN( uLnTx ): // CT_TextUnderlineLineFollowText
139 break;
140// TODO unsupported yet
141// case A_TOKEN( uLn ): // CT_LineProperties
142// return new LinePropertiesContext( getHandler(), rAttribs, maUnderlineProperties );
143
144 // EG_TextUnderlineFill
145 case A_TOKEN( uFillTx ): // CT_TextUnderlineFillFollowText
147 break;
148 case A_TOKEN( uFill ): // CT_TextUnderlineFillGroupWrapper->EG_FillProperties (not supported)
150
151 // CT_FontCollection
152 case A_TOKEN( latin ): // CT_TextFont
154 break;
155 case A_TOKEN( ea ): // CT_TextFont
157 break;
158 case A_TOKEN( cs ): // CT_TextFont
160 break;
161 case A_TOKEN( sym ): // CT_TextFont
163 break;
164
165 case A_TOKEN( hlinkClick ): // CT_Hyperlink
166 case A_TOKEN( hlinkMouseOver ): // CT_Hyperlink
168 case W_TOKEN( rFonts ):
169 if( rAttribs.hasAttribute(W_TOKEN(ascii)) )
170 {
172 }
173 if (rAttribs.hasAttribute(W_TOKEN(asciiTheme)))
174 {
176 }
177 if( rAttribs.hasAttribute(W_TOKEN(cs)) )
178 {
180 }
181 if (rAttribs.hasAttribute(W_TOKEN(cstheme)))
182 {
184 }
185 if( rAttribs.hasAttribute(W_TOKEN(eastAsia)) )
186 {
188 }
189 if (rAttribs.hasAttribute(W_TOKEN(eastAsiaTheme)))
190 {
192 }
193 break;
194 case W_TOKEN( u ):
195 {
196 // If you add here, check if it is in drawingmltypes.cxx 113.
197 auto attrib = rAttribs.getStringDefaulted(W_TOKEN(val));
198 if (attrib == "single" || attrib == "words") // TODO: implement words properly. Now it is a single line.
200 else if (attrib == "wavyHeavy")
202 else if (attrib == "wavyDouble")
204 else if (attrib == "wave")
206 else if (attrib == "thick")
208 else if (attrib == "dottedHeavy")
209 mrTextCharacterProperties.moUnderline = XML_dottedHeavy;
210 else if (attrib == "dotted")
212 else if (attrib == "dashDotDotHeavy")
213 mrTextCharacterProperties.moUnderline = XML_dotDotDashHeavy;
214 else if (attrib == "dotDotDash")
215 mrTextCharacterProperties.moUnderline = XML_dotDotDash;
216 else if (attrib == "dashDotHeavy")
217 mrTextCharacterProperties.moUnderline = XML_dotDashHeavy;
218 else if (attrib == "dotDash")
220 else if (attrib == "double")
222 else if (attrib == "dashLongHeavy")
223 mrTextCharacterProperties.moUnderline = XML_dashLongHeavy;
224 else if (attrib == "dashLong")
226 else if (attrib == "dashedHeavy")
228 else if (attrib == "dash")
230 else if (attrib == "none")
232 auto colorAttrib = rAttribs.getIntegerHex(W_TOKEN(color));
233 if (colorAttrib.has_value())
234 {
235 oox::drawingml::Color theColor;
236 theColor.setSrgbClr(colorAttrib.value());
238 }
239 break;
240 }
241 case W_TOKEN( spacing ):
242 {
243 auto attrib = rAttribs.getInteger(W_TOKEN( val ), 0);
245 break;
246 }
247 case W_TOKEN( b ):
248 mrTextCharacterProperties.moBold = rAttribs.getBool(W_TOKEN( val ), true);
249 break;
250 case W_TOKEN( i ):
251 mrTextCharacterProperties.moItalic = rAttribs.getBool(W_TOKEN( val ), true);
252 break;
253 case W_TOKEN( bCs ):
254 break;
255 case W_TOKEN( strike ):
256 if (rAttribs.getBool(W_TOKEN(val), true))
258 break;
259 case W_TOKEN( dstrike ):
260 if (rAttribs.getBool(W_TOKEN(val), true))
262 break;
263 case W_TOKEN( color ):
264 if (rAttribs.getInteger(W_TOKEN(val)).has_value())
265 {
268 }
269 break;
270 case W_TOKEN( sz ):
271 if (rAttribs.getInteger(W_TOKEN(val)).has_value())
272 {
273 sal_Int32 nVal = rAttribs.getInteger(W_TOKEN(val), 0);
274 // wml has half points, dml has hundred points
276 }
277 break;
278 case W_TOKEN( szCs ):
279 break;
280 case W_TOKEN( caps ):
281 {
282 if( rAttribs.getBool(W_TOKEN( val ), true) )
284 else
286 }
287 break;
288 case W_TOKEN( smallCaps ):
289 {
290 if( rAttribs.getBool(W_TOKEN( val ), true) )
292 else
294 }
295 break;
296 case W_TOKEN(vertAlign):
297 {
298 // Map wordprocessingML <w:vertAlign w:val="..."/> to drawingML
299 // <a:rPr baseline="...">.
300 sal_Int32 nVal = rAttribs.getToken(W_TOKEN(val), 0);
301 if (nVal == XML_superscript)
303 else if (nVal == XML_subscript)
305 break;
306 }
307 case W_TOKEN(lang):
308 mrTextCharacterProperties.moLang = rAttribs.getStringDefaulted(W_TOKEN(val));
309 break;
310 case OOX_TOKEN(w14, glow):
311 case OOX_TOKEN(w14, shadow):
312 case OOX_TOKEN(w14, reflection):
313 case OOX_TOKEN(w14, textOutline):
314 case OOX_TOKEN(w14, textFill):
315 case OOX_TOKEN(w14, scene3d):
316 case OOX_TOKEN(w14, props3d):
317 case OOX_TOKEN(w14, ligatures):
318 case OOX_TOKEN(w14, numForm):
319 case OOX_TOKEN(w14, numSpacing):
320 case OOX_TOKEN(w14, stylisticSets):
321 case OOX_TOKEN(w14, cntxtAlts):
322 {
323 return new TextEffectsContext( *this, aElementToken, mrTextCharacterProperties.maTextEffectsProperties );
324 }
325 break;
326 default:
327 SAL_WARN("oox", "TextCharacterPropertiesContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
328 break;
329 }
330
331 return this;
332}
333
334}
335
336/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to attribute values of an element.
oox::drawingml::Color getHighlightColor(sal_Int32 nAttrToken) const
Returns the Color object of highlight of the text.
OUString getStringDefaulted(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute, returns an empty string if attribute not present...
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
std::optional< sal_Int32 > getIntegerHex(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (hexadecimal).
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
const css::uno::Reference< css::xml::sax::XFastAttributeList > & getFastAttributeList() const
Returns the wrapped com.sun.star.xml.sax.XFastAttributeList object.
std::optional< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
std::optional< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
Context handler for elements that contain a color value element (a:scrgbClr, a:srgbClr,...
void setSrgbClr(sal_Int32 nRgb)
Sets an RGB value (hexadecimal RRGGBB) from the a:srgbClr element.
Definition: color.cxx:260
::oox::core::ContextHandlerRef createFillContext(::oox::core::ContextHandler2Helper const &rParent, sal_Int32 nElement, const ::oox::AttributeList &rAttribs, FillProperties &rFillProps)
Context handler for elements that contain a fill property element (a:noFill, a:solidFill,...
TextCharacterPropertiesContext(::oox::core::ContextHandler2Helper const &rParent, const ::oox::AttributeList &rAttribs, TextCharacterProperties &rTextCharacterProperties)
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
void setAttributes(const AttributeList &rAttribs)
Sets attributes from the passed attribute list.
Definition: textfont.cxx:56
const std::vector< sal_Int32 > & getFastAttributeTokens() const
float u
#define SAL_WARN(area, stream)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XML_none
Color maFillColor
Fill type (OOXML token).
std::optional< sal_Int32 > moFillType
std::vector< css::beans::PropertyValue > maTextEffectsProperties
bool mbHasVisualRunProperties
Set if there was a property set that alters run visually during import.
std::optional< LineProperties > moTextOutlineProperties