1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "oox/drawingml/lineproperties.hxx"
27 #include "drawingml/textparagraphproperties.hxx"
28 #include "oox/core/relations.hxx"
29 #include "hyperlinkcontext.hxx"
31 using namespace ::oox::core
;
32 using namespace ::com::sun::star::uno
;
33 using namespace ::com::sun::star::xml::sax
;
34 using namespace ::com::sun::star::awt
;
36 namespace oox
{ namespace drawingml
{
38 // CT_TextCharacterProperties
39 TextCharacterPropertiesContext::TextCharacterPropertiesContext(
40 ContextHandler2Helper
& rParent
,
41 const AttributeList
& rAttribs
,
42 TextCharacterProperties
& rTextCharacterProperties
)
43 : ContextHandler2( rParent
)
44 , mrTextCharacterProperties( rTextCharacterProperties
)
46 if ( rAttribs
.hasAttribute( XML_lang
) )
47 mrTextCharacterProperties
.moLang
= rAttribs
.getString( XML_lang
);
48 if ( rAttribs
.hasAttribute( XML_sz
) )
49 mrTextCharacterProperties
.moHeight
= rAttribs
.getInteger( XML_sz
);
50 if ( rAttribs
.hasAttribute( XML_spc
) )
51 mrTextCharacterProperties
.moSpacing
= rAttribs
.getInteger( XML_spc
);
52 if ( rAttribs
.hasAttribute( XML_u
) )
53 mrTextCharacterProperties
.moUnderline
= rAttribs
.getToken( XML_u
);
54 if ( rAttribs
.hasAttribute( XML_strike
) )
55 mrTextCharacterProperties
.moStrikeout
= rAttribs
.getToken( XML_strike
);
56 if ( rAttribs
.hasAttribute( XML_baseline
) && rAttribs
.getInteger( XML_baseline
).get() != 0 )
57 mrTextCharacterProperties
.moBaseline
= rAttribs
.getInteger( XML_baseline
);
59 if ( rAttribs
.hasAttribute( XML_b
) )
60 mrTextCharacterProperties
.moBold
= rAttribs
.getBool( XML_b
);
61 if ( rAttribs
.hasAttribute( XML_i
) )
62 mrTextCharacterProperties
.moItalic
= rAttribs
.getBool( XML_i
);
63 if( rAttribs
.hasAttribute( XML_cap
) )
64 mrTextCharacterProperties
.moCaseMap
= rAttribs
.getToken( XML_cap
);
66 /* TODO / unhandled so far:
80 TextCharacterPropertiesContext::~TextCharacterPropertiesContext()
84 ContextHandlerRef
TextCharacterPropertiesContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
86 switch( aElementToken
)
88 // TODO unsupported yet
89 // case A_TOKEN( ln ): // CT_LineProperties
90 // return new LinePropertiesContext( getHandler(), rAttribs, maTextOutlineProperties );
92 case A_TOKEN( solidFill
): // EG_FillProperties
93 return new ColorContext( *this, mrTextCharacterProperties
.maCharColor
);
95 // EG_EffectProperties
96 case A_TOKEN( effectDag
): // CT_EffectContainer 5.1.10.25
97 case A_TOKEN( effectLst
): // CT_EffectList 5.1.10.26
100 case A_TOKEN( highlight
): // CT_Color
101 return new ColorContext( *this, mrTextCharacterProperties
.maHighlightColor
);
103 // EG_TextUnderlineLine
104 case A_TOKEN( uLnTx
): // CT_TextUnderlineLineFollowText
105 mrTextCharacterProperties
.moUnderlineLineFollowText
= true;
107 // TODO unsupported yet
108 // case A_TOKEN( uLn ): // CT_LineProperties
109 // return new LinePropertiesContext( getHandler(), rAttribs, maUnderlineProperties );
111 // EG_TextUnderlineFill
112 case A_TOKEN( uFillTx
): // CT_TextUnderlineFillFollowText
113 mrTextCharacterProperties
.moUnderlineFillFollowText
= true;
115 case A_TOKEN( uFill
): // CT_TextUnderlineFillGroupWrapper->EG_FillProperties (not supported)
116 return new SimpleFillPropertiesContext( *this, mrTextCharacterProperties
.maUnderlineColor
);
119 case A_TOKEN( latin
): // CT_TextFont
120 mrTextCharacterProperties
.maLatinFont
.setAttributes( rAttribs
);
122 case A_TOKEN( ea
): // CT_TextFont
123 mrTextCharacterProperties
.maAsianFont
.setAttributes( rAttribs
);
125 case A_TOKEN( cs
): // CT_TextFont
126 mrTextCharacterProperties
.maComplexFont
.setAttributes( rAttribs
);
128 case A_TOKEN( sym
): // CT_TextFont
129 mrTextCharacterProperties
.maSymbolFont
.setAttributes( rAttribs
);
132 case A_TOKEN( hlinkClick
): // CT_Hyperlink
133 case A_TOKEN( hlinkMouseOver
): // CT_Hyperlink
134 return new HyperLinkContext( *this, rAttribs
, mrTextCharacterProperties
.maHyperlinkPropertyMap
);
136 case A_TOKEN( gradFill
):
137 return new GradientFillContext( *this, rAttribs
, mrTextCharacterProperties
.maGradientProps
);
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()));
166 mrTextCharacterProperties
.moBold
= rAttribs
.getBool(W_TOKEN( val
), true);
169 mrTextCharacterProperties
.moItalic
= rAttribs
.getBool(W_TOKEN( val
), true);
173 case W_TOKEN( color
):
174 if (rAttribs
.getInteger(W_TOKEN(val
)).has())
176 mrTextCharacterProperties
.maCharColor
.setSrgbClr(rAttribs
.getIntegerHex(W_TOKEN(val
)).get());
180 if (rAttribs
.getInteger(W_TOKEN(val
)).has())
182 sal_Int32 nVal
= rAttribs
.getInteger(W_TOKEN(val
)).get();
183 // wml has half points, dml has hundred points
184 mrTextCharacterProperties
.moHeight
= nVal
* 50;
187 case W_TOKEN( szCs
):
189 case W_TOKEN( caps
):
191 if( rAttribs
.getBool(W_TOKEN( val
), true) )
192 mrTextCharacterProperties
.moCaseMap
= XML_all
;
194 mrTextCharacterProperties
.moCaseMap
= XML_none
;
197 case W_TOKEN( smallCaps
):
199 if( rAttribs
.getBool(W_TOKEN( val
), true) )
200 mrTextCharacterProperties
.moCaseMap
= XML_small
;
202 mrTextCharacterProperties
.moCaseMap
= XML_none
;
205 case OOX_TOKEN(w14
, glow
):
206 case OOX_TOKEN(w14
, shadow
):
207 case OOX_TOKEN(w14
, reflection
):
208 case OOX_TOKEN(w14
, textOutline
):
209 case OOX_TOKEN(w14
, textFill
):
210 case OOX_TOKEN(w14
, scene3d
):
211 case OOX_TOKEN(w14
, props3d
):
212 case OOX_TOKEN(w14
, ligatures
):
213 case OOX_TOKEN(w14
, numForm
):
214 case OOX_TOKEN(w14
, numSpacing
):
215 case OOX_TOKEN(w14
, stylisticSets
):
216 case OOX_TOKEN(w14
, cntxtAlts
):
218 return new TextEffectsContext( *this, aElementToken
, mrTextCharacterProperties
.maTextEffectsProperties
);
222 SAL_WARN("oox", "TextCharacterPropertiesContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken
));
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */