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