update dev300-m58
[ooovba.git] / oox / source / drawingml / textcharacterpropertiescontext.cxx
blob580cd59db23c04798f33386b71f699a4c7b983a0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textcharacterpropertiescontext.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/drawingml/textcharacterpropertiescontext.hxx"
33 #include "oox/helper/attributelist.hxx"
34 #include "oox/drawingml/drawingmltypes.hxx"
35 #include "oox/drawingml/colorchoicecontext.hxx"
36 #include "oox/drawingml/lineproperties.hxx"
37 #include "oox/drawingml/textparagraphproperties.hxx"
38 #include "oox/core/namespaces.hxx"
39 #include "oox/core/relations.hxx"
40 #include "hyperlinkcontext.hxx"
41 #include "tokens.hxx"
43 using ::rtl::OUString;
44 using namespace ::oox::core;
45 using namespace ::com::sun::star::uno;
46 using namespace ::com::sun::star::xml::sax;
47 using namespace ::com::sun::star::awt;
49 namespace oox { namespace drawingml {
51 // --------------------------------------------------------------------
53 // CT_TextCharacterProperties
54 TextCharacterPropertiesContext::TextCharacterPropertiesContext(
55 ContextHandler& rParent,
56 const Reference< XFastAttributeList >& rXAttributes,
57 TextCharacterProperties& rTextCharacterProperties )
58 : ContextHandler( rParent )
59 , mrTextCharacterProperties( rTextCharacterProperties )
61 AttributeList aAttribs( rXAttributes );
62 mrTextCharacterProperties.moLang = aAttribs.getString( XML_lang );
63 mrTextCharacterProperties.moHeight = aAttribs.getInteger( XML_sz );
64 mrTextCharacterProperties.moUnderline = aAttribs.getToken( XML_u );
65 mrTextCharacterProperties.moStrikeout = aAttribs.getToken( XML_strike );
66 // mrTextCharacterProperties.moCaseMap = aAttribs.getToken( XML_cap );
67 mrTextCharacterProperties.moBold = aAttribs.getBool( XML_b );
68 mrTextCharacterProperties.moItalic = aAttribs.getBool( XML_i );
70 // TODO
71 /* todo: we need to be able to iterate over the XFastAttributes
73 // ST_TextNonNegativePoint
74 const OUString sCharKerning( CREATE_OUSTRING( "CharKerning" ) );
75 //case NMSP_DRAWINGML|XML_kern:
77 // ST_TextLanguageID
78 OUString sAltLang = rXAttributes->getOptionalValue( XML_altLang );
80 case NMSP_DRAWINGML|XML_kumimoji: // xsd:boolean
81 break;
82 case NMSP_DRAWINGML|XML_spc: // ST_TextPoint
83 case NMSP_DRAWINGML|XML_normalizeH: // xsd:boolean
84 case NMSP_DRAWINGML|XML_baseline: // ST_Percentage
85 case NMSP_DRAWINGML|XML_noProof: // xsd:boolean
86 case NMSP_DRAWINGML|XML_dirty: // xsd:boolean
87 case NMSP_DRAWINGML|XML_err: // xsd:boolean
88 case NMSP_DRAWINGML|XML_smtClean: // xsd:boolean
89 case NMSP_DRAWINGML|XML_smtId: // xsd:unsignedInt
90 break;
95 TextCharacterPropertiesContext::~TextCharacterPropertiesContext()
99 // --------------------------------------------------------------------
101 void TextCharacterPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
105 // --------------------------------------------------------------------
107 Reference< XFastContextHandler > TextCharacterPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttributes ) throw (SAXException, RuntimeException)
109 AttributeList aAttribs( xAttributes );
110 Reference< XFastContextHandler > xRet;
111 switch( aElementToken )
113 // TODO unsupported yet
114 // case NMSP_DRAWINGML|XML_ln: // CT_LineProperties
115 // xRet.set( new LinePropertiesContext( getHandler(), xAttributes, maTextOutlineProperties ) );
116 // break;
118 case NMSP_DRAWINGML|XML_solidFill: // EG_FillProperties
119 xRet.set( new ColorContext( *this, mrTextCharacterProperties.maCharColor ) );
120 break;
122 // EG_EffectProperties
123 case NMSP_DRAWINGML|XML_effectDag: // CT_EffectContainer 5.1.10.25
124 case NMSP_DRAWINGML|XML_effectLst: // CT_EffectList 5.1.10.26
125 break;
127 case NMSP_DRAWINGML|XML_highlight: // CT_Color
128 xRet.set( new ColorContext( *this, mrTextCharacterProperties.maHighlightColor ) );
129 break;
131 // EG_TextUnderlineLine
132 case NMSP_DRAWINGML|XML_uLnTx: // CT_TextUnderlineLineFollowText
133 mrTextCharacterProperties.moUnderlineLineFollowText = true;
134 break;
135 // TODO unsupported yet
136 // case NMSP_DRAWINGML|XML_uLn: // CT_LineProperties
137 // xRet.set( new LinePropertiesContext( getHandler(), xAttributes, maUnderlineProperties ) );
138 // break;
140 // EG_TextUnderlineFill
141 case NMSP_DRAWINGML|XML_uFillTx: // CT_TextUnderlineFillFollowText
142 mrTextCharacterProperties.moUnderlineFillFollowText = true;
143 break;
144 case NMSP_DRAWINGML|XML_uFill: // CT_TextUnderlineFillGroupWrapper->EG_FillProperties (not supported)
145 xRet.set( new SimpleFillPropertiesContext( *this, mrTextCharacterProperties.maUnderlineColor ) );
146 break;
148 // CT_FontCollection
149 case NMSP_DRAWINGML|XML_latin: // CT_TextFont
150 mrTextCharacterProperties.maLatinFont.setAttributes( aAttribs );
151 break;
152 case NMSP_DRAWINGML|XML_ea: // CT_TextFont
153 mrTextCharacterProperties.maAsianFont.setAttributes( aAttribs );
154 break;
155 case NMSP_DRAWINGML|XML_cs: // CT_TextFont
156 mrTextCharacterProperties.maComplexFont.setAttributes( aAttribs );
157 break;
158 case NMSP_DRAWINGML|XML_sym: // CT_TextFont
159 mrTextCharacterProperties.maSymbolFont.setAttributes( aAttribs );
160 break;
162 case NMSP_DRAWINGML|XML_hlinkClick: // CT_Hyperlink
163 case NMSP_DRAWINGML|XML_hlinkMouseOver: // CT_Hyperlink
164 xRet.set( new HyperLinkContext( *this, xAttributes, mrTextCharacterProperties.maHyperlinkPropertyMap ) );
165 break;
167 if( !xRet.is() )
168 xRet.set( this );
169 return xRet;
172 // --------------------------------------------------------------------