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 "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:
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 );
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
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;
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;
119 case A_TOKEN( uFill
): // CT_TextUnderlineFillGroupWrapper->EG_FillProperties (not supported)
120 return new SimpleFillPropertiesContext( *this, mrTextCharacterProperties
.maUnderlineColor
);
123 case A_TOKEN( latin
): // CT_TextFont
124 mrTextCharacterProperties
.maLatinFont
.setAttributes( rAttribs
);
126 case A_TOKEN( ea
): // CT_TextFont
127 mrTextCharacterProperties
.maAsianFont
.setAttributes( rAttribs
);
129 case A_TOKEN( cs
): // CT_TextFont
130 mrTextCharacterProperties
.maComplexFont
.setAttributes( rAttribs
);
132 case A_TOKEN( sym
): // CT_TextFont
133 mrTextCharacterProperties
.maSymbolFont
.setAttributes( rAttribs
);
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()));
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
.maFillProperties
.maFillColor
.setSrgbClr(rAttribs
.getIntegerHex(W_TOKEN(val
)).get());
177 mrTextCharacterProperties
.maFillProperties
.moFillType
.set(XML_solidFill
);
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;
188 case W_TOKEN( szCs
):
190 case W_TOKEN( caps
):
192 if( rAttribs
.getBool(W_TOKEN( val
), true) )
193 mrTextCharacterProperties
.moCaseMap
= XML_all
;
195 mrTextCharacterProperties
.moCaseMap
= XML_none
;
198 case W_TOKEN( smallCaps
):
200 if( rAttribs
.getBool(W_TOKEN( val
), true) )
201 mrTextCharacterProperties
.moCaseMap
= XML_small
;
203 mrTextCharacterProperties
.moCaseMap
= XML_none
;
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
);
223 SAL_WARN("oox", "TextCharacterPropertiesContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken
));
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */