1*ca5ec200SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ca5ec200SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ca5ec200SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ca5ec200SAndrew Rist  * distributed with this work for additional information
6*ca5ec200SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ca5ec200SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ca5ec200SAndrew Rist  * "License"); you may not use this file except in compliance
9*ca5ec200SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ca5ec200SAndrew Rist  *
11*ca5ec200SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ca5ec200SAndrew Rist  *
13*ca5ec200SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ca5ec200SAndrew Rist  * software distributed under the License is distributed on an
15*ca5ec200SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ca5ec200SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ca5ec200SAndrew Rist  * specific language governing permissions and limitations
18*ca5ec200SAndrew Rist  * under the License.
19*ca5ec200SAndrew Rist  *
20*ca5ec200SAndrew Rist  *************************************************************/
21*ca5ec200SAndrew Rist 
22*ca5ec200SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "oox/drawingml/textcharacterpropertiescontext.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "oox/helper/attributelist.hxx"
27cdf0e10cSrcweir #include "oox/drawingml/drawingmltypes.hxx"
28cdf0e10cSrcweir #include "oox/drawingml/colorchoicecontext.hxx"
29cdf0e10cSrcweir #include "oox/drawingml/lineproperties.hxx"
30cdf0e10cSrcweir #include "oox/drawingml/textparagraphproperties.hxx"
31cdf0e10cSrcweir #include "oox/core/relations.hxx"
32cdf0e10cSrcweir #include "hyperlinkcontext.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir using ::rtl::OUString;
35cdf0e10cSrcweir using namespace ::oox::core;
36cdf0e10cSrcweir using namespace ::com::sun::star::uno;
37cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax;
38cdf0e10cSrcweir using namespace ::com::sun::star::awt;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace oox { namespace drawingml {
41cdf0e10cSrcweir 
42cdf0e10cSrcweir // --------------------------------------------------------------------
43cdf0e10cSrcweir 
44cdf0e10cSrcweir // CT_TextCharacterProperties
TextCharacterPropertiesContext(ContextHandler & rParent,const Reference<XFastAttributeList> & rXAttributes,TextCharacterProperties & rTextCharacterProperties)45cdf0e10cSrcweir TextCharacterPropertiesContext::TextCharacterPropertiesContext(
46cdf0e10cSrcweir         ContextHandler& rParent,
47cdf0e10cSrcweir         const Reference< XFastAttributeList >& rXAttributes,
48cdf0e10cSrcweir         TextCharacterProperties& rTextCharacterProperties )
49cdf0e10cSrcweir : ContextHandler( rParent )
50cdf0e10cSrcweir , mrTextCharacterProperties( rTextCharacterProperties )
51cdf0e10cSrcweir {
52cdf0e10cSrcweir     AttributeList aAttribs( rXAttributes );
53cdf0e10cSrcweir 	if ( aAttribs.hasAttribute( XML_lang ) )
54cdf0e10cSrcweir 		mrTextCharacterProperties.moLang = aAttribs.getString( XML_lang );
55cdf0e10cSrcweir 	if ( aAttribs.hasAttribute( XML_sz ) )
56cdf0e10cSrcweir 		mrTextCharacterProperties.moHeight = aAttribs.getInteger( XML_sz );
57cdf0e10cSrcweir 	if ( aAttribs.hasAttribute( XML_u ) )
58cdf0e10cSrcweir 		mrTextCharacterProperties.moUnderline = aAttribs.getToken( XML_u );
59cdf0e10cSrcweir 	if ( aAttribs.hasAttribute( XML_strike ) )
60cdf0e10cSrcweir 		mrTextCharacterProperties.moStrikeout = aAttribs.getToken( XML_strike );
61cdf0e10cSrcweir 
62cdf0e10cSrcweir //  mrTextCharacterProperties.moCaseMap     = aAttribs.getToken( XML_cap );
63cdf0e10cSrcweir 	if ( aAttribs.hasAttribute( XML_b ) )
64cdf0e10cSrcweir 		mrTextCharacterProperties.moBold = aAttribs.getBool( XML_b );
65cdf0e10cSrcweir 	if ( aAttribs.hasAttribute( XML_i ) )
66cdf0e10cSrcweir 		mrTextCharacterProperties.moItalic = aAttribs.getBool( XML_i );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir // TODO
69cdf0e10cSrcweir /*	 todo: we need to be able to iterate over the XFastAttributes
70cdf0e10cSrcweir 
71cdf0e10cSrcweir   // ST_TextNonNegativePoint
72cdf0e10cSrcweir     const OUString sCharKerning( CREATE_OUSTRING( "CharKerning" ) );
73cdf0e10cSrcweir 	//case A_TOKEN( kern ):
74cdf0e10cSrcweir 
75cdf0e10cSrcweir   // ST_TextLanguageID
76cdf0e10cSrcweir 	OUString sAltLang = rXAttributes->getOptionalValue( XML_altLang );
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 		case A_TOKEN( kumimoji ):		// xsd:boolean
79cdf0e10cSrcweir 			break;
80cdf0e10cSrcweir 		case A_TOKEN( spc ):			// ST_TextPoint
81cdf0e10cSrcweir 		case A_TOKEN( normalizeH ):		// xsd:boolean
82cdf0e10cSrcweir 		case A_TOKEN( baseline ):		// ST_Percentage
83cdf0e10cSrcweir 		case A_TOKEN( noProof ):		// xsd:boolean
84cdf0e10cSrcweir 		case A_TOKEN( dirty ):			// xsd:boolean
85cdf0e10cSrcweir 		case A_TOKEN( err ):			// xsd:boolean
86cdf0e10cSrcweir 		case A_TOKEN( smtClean ):		// xsd:boolean
87cdf0e10cSrcweir 		case A_TOKEN( smtId ):			// xsd:unsignedInt
88cdf0e10cSrcweir 			break;
89cdf0e10cSrcweir */
90cdf0e10cSrcweir 
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
~TextCharacterPropertiesContext()93cdf0e10cSrcweir TextCharacterPropertiesContext::~TextCharacterPropertiesContext()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir // --------------------------------------------------------------------
98cdf0e10cSrcweir 
endFastElement(sal_Int32)99cdf0e10cSrcweir void TextCharacterPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir // --------------------------------------------------------------------
104cdf0e10cSrcweir 
createFastChildContext(sal_Int32 aElementToken,const Reference<XFastAttributeList> & xAttributes)105cdf0e10cSrcweir Reference< XFastContextHandler > TextCharacterPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttributes ) throw (SAXException, RuntimeException)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir     AttributeList aAttribs( xAttributes );
108cdf0e10cSrcweir 	Reference< XFastContextHandler > xRet;
109cdf0e10cSrcweir 	switch( aElementToken )
110cdf0e10cSrcweir 	{
111cdf0e10cSrcweir // TODO unsupported yet
112cdf0e10cSrcweir //        case A_TOKEN( ln ):         // CT_LineProperties
113cdf0e10cSrcweir //            xRet.set( new LinePropertiesContext( getHandler(), xAttributes, maTextOutlineProperties ) );
114cdf0e10cSrcweir //        break;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir         case A_TOKEN( solidFill ):  // EG_FillProperties
117cdf0e10cSrcweir             xRet.set( new ColorContext( *this, mrTextCharacterProperties.maCharColor ) );
118cdf0e10cSrcweir         break;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir         // EG_EffectProperties
121cdf0e10cSrcweir         case A_TOKEN( effectDag ):  // CT_EffectContainer 5.1.10.25
122cdf0e10cSrcweir         case A_TOKEN( effectLst ):  // CT_EffectList 5.1.10.26
123cdf0e10cSrcweir         break;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         case A_TOKEN( highlight ):  // CT_Color
126cdf0e10cSrcweir             xRet.set( new ColorContext( *this, mrTextCharacterProperties.maHighlightColor ) );
127cdf0e10cSrcweir         break;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 		// EG_TextUnderlineLine
130cdf0e10cSrcweir         case A_TOKEN( uLnTx ):      // CT_TextUnderlineLineFollowText
131cdf0e10cSrcweir             mrTextCharacterProperties.moUnderlineLineFollowText = true;
132cdf0e10cSrcweir         break;
133cdf0e10cSrcweir // TODO unsupported yet
134cdf0e10cSrcweir //        case A_TOKEN( uLn ):        // CT_LineProperties
135cdf0e10cSrcweir //            xRet.set( new LinePropertiesContext( getHandler(), xAttributes, maUnderlineProperties ) );
136cdf0e10cSrcweir //        break;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 		// EG_TextUnderlineFill
139cdf0e10cSrcweir         case A_TOKEN( uFillTx ):    // CT_TextUnderlineFillFollowText
140cdf0e10cSrcweir             mrTextCharacterProperties.moUnderlineFillFollowText = true;
141cdf0e10cSrcweir         break;
142cdf0e10cSrcweir         case A_TOKEN( uFill ):      // CT_TextUnderlineFillGroupWrapper->EG_FillProperties (not supported)
143cdf0e10cSrcweir             xRet.set( new SimpleFillPropertiesContext( *this, mrTextCharacterProperties.maUnderlineColor ) );
144cdf0e10cSrcweir         break;
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 		// CT_FontCollection
147cdf0e10cSrcweir         case A_TOKEN( latin ):      // CT_TextFont
148cdf0e10cSrcweir             mrTextCharacterProperties.maLatinFont.setAttributes( aAttribs );
149cdf0e10cSrcweir         break;
150cdf0e10cSrcweir         case A_TOKEN( ea ):         // CT_TextFont
151cdf0e10cSrcweir             mrTextCharacterProperties.maAsianFont.setAttributes( aAttribs );
152cdf0e10cSrcweir         break;
153cdf0e10cSrcweir         case A_TOKEN( cs ):         // CT_TextFont
154cdf0e10cSrcweir             mrTextCharacterProperties.maComplexFont.setAttributes( aAttribs );
155cdf0e10cSrcweir         break;
156cdf0e10cSrcweir         case A_TOKEN( sym ):        // CT_TextFont
157cdf0e10cSrcweir             mrTextCharacterProperties.maSymbolFont.setAttributes( aAttribs );
158cdf0e10cSrcweir         break;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir         case A_TOKEN( hlinkClick ):     // CT_Hyperlink
161cdf0e10cSrcweir         case A_TOKEN( hlinkMouseOver ): // CT_Hyperlink
162cdf0e10cSrcweir             xRet.set( new HyperLinkContext( *this, xAttributes,  mrTextCharacterProperties.maHyperlinkPropertyMap ) );
163cdf0e10cSrcweir         break;
164cdf0e10cSrcweir 	}
165cdf0e10cSrcweir     if( !xRet.is() )
166cdf0e10cSrcweir         xRet.set( this );
167cdf0e10cSrcweir 	return xRet;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir // --------------------------------------------------------------------
171cdf0e10cSrcweir 
172cdf0e10cSrcweir } }
173cdf0e10cSrcweir 
174