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 "oox/drawingml/textcharacterpropertiescontext.hxx"
22 #include "oox/helper/attributelist.hxx"
23 #include "oox/drawingml/drawingmltypes.hxx"
24 #include "oox/drawingml/colorchoicecontext.hxx"
25 #include "oox/drawingml/lineproperties.hxx"
26 #include "oox/drawingml/textparagraphproperties.hxx"
27 #include "oox/core/relations.hxx"
28 #include "hyperlinkcontext.hxx"
30 using namespace ::oox::core
;
31 using namespace ::com::sun::star::uno
;
32 using namespace ::com::sun::star::xml::sax
;
33 using namespace ::com::sun::star::awt
;
35 namespace oox
{ namespace drawingml
{
37 // --------------------------------------------------------------------
39 // CT_TextCharacterProperties
40 TextCharacterPropertiesContext::TextCharacterPropertiesContext(
41 ContextHandler
& rParent
,
42 const Reference
< XFastAttributeList
>& rXAttributes
,
43 TextCharacterProperties
& rTextCharacterProperties
)
44 : ContextHandler( rParent
)
45 , mrTextCharacterProperties( rTextCharacterProperties
)
47 AttributeList
aAttribs( rXAttributes
);
48 if ( aAttribs
.hasAttribute( XML_lang
) )
49 mrTextCharacterProperties
.moLang
= aAttribs
.getString( XML_lang
);
50 if ( aAttribs
.hasAttribute( XML_sz
) )
51 mrTextCharacterProperties
.moHeight
= aAttribs
.getInteger( XML_sz
);
52 if ( aAttribs
.hasAttribute( XML_spc
) )
53 mrTextCharacterProperties
.moSpacing
= aAttribs
.getInteger( XML_spc
);
54 if ( aAttribs
.hasAttribute( XML_u
) )
55 mrTextCharacterProperties
.moUnderline
= aAttribs
.getToken( XML_u
);
56 if ( aAttribs
.hasAttribute( XML_strike
) )
57 mrTextCharacterProperties
.moStrikeout
= aAttribs
.getToken( XML_strike
);
58 if ( aAttribs
.hasAttribute( XML_baseline
) )
59 mrTextCharacterProperties
.moBaseline
= aAttribs
.getInteger( XML_baseline
);
61 if ( aAttribs
.hasAttribute( XML_b
) )
62 mrTextCharacterProperties
.moBold
= aAttribs
.getBool( XML_b
);
63 if ( aAttribs
.hasAttribute( XML_i
) )
64 mrTextCharacterProperties
.moItalic
= aAttribs
.getBool( XML_i
);
66 /* TODO / unhandled so far:
81 TextCharacterPropertiesContext::~TextCharacterPropertiesContext()
85 // --------------------------------------------------------------------
87 void TextCharacterPropertiesContext::endFastElement( sal_Int32
) throw (SAXException
, RuntimeException
)
91 // --------------------------------------------------------------------
93 Reference
< XFastContextHandler
> TextCharacterPropertiesContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttributes
) throw (SAXException
, RuntimeException
)
95 AttributeList
aAttribs( xAttributes
);
96 Reference
< XFastContextHandler
> xRet
;
97 switch( aElementToken
)
99 // TODO unsupported yet
100 // case A_TOKEN( ln ): // CT_LineProperties
101 // xRet.set( new LinePropertiesContext( getHandler(), xAttributes, maTextOutlineProperties ) );
104 case A_TOKEN( solidFill
): // EG_FillProperties
105 xRet
.set( new ColorContext( *this, mrTextCharacterProperties
.maCharColor
) );
108 // EG_EffectProperties
109 case A_TOKEN( effectDag
): // CT_EffectContainer 5.1.10.25
110 case A_TOKEN( effectLst
): // CT_EffectList 5.1.10.26
113 case A_TOKEN( highlight
): // CT_Color
114 xRet
.set( new ColorContext( *this, mrTextCharacterProperties
.maHighlightColor
) );
117 // EG_TextUnderlineLine
118 case A_TOKEN( uLnTx
): // CT_TextUnderlineLineFollowText
119 mrTextCharacterProperties
.moUnderlineLineFollowText
= true;
121 // TODO unsupported yet
122 // case A_TOKEN( uLn ): // CT_LineProperties
123 // xRet.set( new LinePropertiesContext( getHandler(), xAttributes, maUnderlineProperties ) );
126 // EG_TextUnderlineFill
127 case A_TOKEN( uFillTx
): // CT_TextUnderlineFillFollowText
128 mrTextCharacterProperties
.moUnderlineFillFollowText
= true;
130 case A_TOKEN( uFill
): // CT_TextUnderlineFillGroupWrapper->EG_FillProperties (not supported)
131 xRet
.set( new SimpleFillPropertiesContext( *this, mrTextCharacterProperties
.maUnderlineColor
) );
135 case A_TOKEN( latin
): // CT_TextFont
136 mrTextCharacterProperties
.maLatinFont
.setAttributes( aAttribs
);
138 case A_TOKEN( ea
): // CT_TextFont
139 mrTextCharacterProperties
.maAsianFont
.setAttributes( aAttribs
);
141 case A_TOKEN( cs
): // CT_TextFont
142 mrTextCharacterProperties
.maComplexFont
.setAttributes( aAttribs
);
144 case A_TOKEN( sym
): // CT_TextFont
145 mrTextCharacterProperties
.maSymbolFont
.setAttributes( aAttribs
);
148 case A_TOKEN( hlinkClick
): // CT_Hyperlink
149 case A_TOKEN( hlinkMouseOver
): // CT_Hyperlink
150 xRet
.set( new HyperLinkContext( *this, xAttributes
, mrTextCharacterProperties
.maHyperlinkPropertyMap
) );
158 // --------------------------------------------------------------------
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */