xref: /trunk/main/oox/source/drawingml/textcharacterpropertiescontext.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "oox/drawingml/textcharacterpropertiescontext.hxx"
29 
30 #include "oox/helper/attributelist.hxx"
31 #include "oox/drawingml/drawingmltypes.hxx"
32 #include "oox/drawingml/colorchoicecontext.hxx"
33 #include "oox/drawingml/lineproperties.hxx"
34 #include "oox/drawingml/textparagraphproperties.hxx"
35 #include "oox/core/relations.hxx"
36 #include "hyperlinkcontext.hxx"
37 
38 using ::rtl::OUString;
39 using namespace ::oox::core;
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::xml::sax;
42 using namespace ::com::sun::star::awt;
43 
44 namespace oox { namespace drawingml {
45 
46 // --------------------------------------------------------------------
47 
48 // CT_TextCharacterProperties
49 TextCharacterPropertiesContext::TextCharacterPropertiesContext(
50         ContextHandler& rParent,
51         const Reference< XFastAttributeList >& rXAttributes,
52         TextCharacterProperties& rTextCharacterProperties )
53 : ContextHandler( rParent )
54 , mrTextCharacterProperties( rTextCharacterProperties )
55 {
56     AttributeList aAttribs( rXAttributes );
57     if ( aAttribs.hasAttribute( XML_lang ) )
58         mrTextCharacterProperties.moLang = aAttribs.getString( XML_lang );
59     if ( aAttribs.hasAttribute( XML_sz ) )
60         mrTextCharacterProperties.moHeight = aAttribs.getInteger( XML_sz );
61     if ( aAttribs.hasAttribute( XML_u ) )
62         mrTextCharacterProperties.moUnderline = aAttribs.getToken( XML_u );
63     if ( aAttribs.hasAttribute( XML_strike ) )
64         mrTextCharacterProperties.moStrikeout = aAttribs.getToken( XML_strike );
65 
66 //  mrTextCharacterProperties.moCaseMap     = aAttribs.getToken( XML_cap );
67     if ( aAttribs.hasAttribute( XML_b ) )
68         mrTextCharacterProperties.moBold = aAttribs.getBool( XML_b );
69     if ( aAttribs.hasAttribute( XML_i ) )
70         mrTextCharacterProperties.moItalic = aAttribs.getBool( XML_i );
71 
72 // TODO
73 /*   todo: we need to be able to iterate over the XFastAttributes
74 
75   // ST_TextNonNegativePoint
76     const OUString sCharKerning( CREATE_OUSTRING( "CharKerning" ) );
77     //case A_TOKEN( kern ):
78 
79   // ST_TextLanguageID
80     OUString sAltLang = rXAttributes->getOptionalValue( XML_altLang );
81 
82         case A_TOKEN( kumimoji ):       // xsd:boolean
83             break;
84         case A_TOKEN( spc ):            // ST_TextPoint
85         case A_TOKEN( normalizeH ):     // xsd:boolean
86         case A_TOKEN( baseline ):       // ST_Percentage
87         case A_TOKEN( noProof ):        // xsd:boolean
88         case A_TOKEN( dirty ):          // xsd:boolean
89         case A_TOKEN( err ):            // xsd:boolean
90         case A_TOKEN( smtClean ):       // xsd:boolean
91         case A_TOKEN( smtId ):          // xsd:unsignedInt
92             break;
93 */
94 
95 }
96 
97 TextCharacterPropertiesContext::~TextCharacterPropertiesContext()
98 {
99 }
100 
101 // --------------------------------------------------------------------
102 
103 void TextCharacterPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
104 {
105 }
106 
107 // --------------------------------------------------------------------
108 
109 Reference< XFastContextHandler > TextCharacterPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttributes ) throw (SAXException, RuntimeException)
110 {
111     AttributeList aAttribs( xAttributes );
112     Reference< XFastContextHandler > xRet;
113     switch( aElementToken )
114     {
115 // TODO unsupported yet
116 //        case A_TOKEN( ln ):         // CT_LineProperties
117 //            xRet.set( new LinePropertiesContext( getHandler(), xAttributes, maTextOutlineProperties ) );
118 //        break;
119 
120         case A_TOKEN( solidFill ):  // EG_FillProperties
121             xRet.set( new ColorContext( *this, mrTextCharacterProperties.maCharColor ) );
122         break;
123 
124         // EG_EffectProperties
125         case A_TOKEN( effectDag ):  // CT_EffectContainer 5.1.10.25
126         case A_TOKEN( effectLst ):  // CT_EffectList 5.1.10.26
127         break;
128 
129         case A_TOKEN( highlight ):  // CT_Color
130             xRet.set( new ColorContext( *this, mrTextCharacterProperties.maHighlightColor ) );
131         break;
132 
133         // EG_TextUnderlineLine
134         case A_TOKEN( uLnTx ):      // CT_TextUnderlineLineFollowText
135             mrTextCharacterProperties.moUnderlineLineFollowText = true;
136         break;
137 // TODO unsupported yet
138 //        case A_TOKEN( uLn ):        // CT_LineProperties
139 //            xRet.set( new LinePropertiesContext( getHandler(), xAttributes, maUnderlineProperties ) );
140 //        break;
141 
142         // EG_TextUnderlineFill
143         case A_TOKEN( uFillTx ):    // CT_TextUnderlineFillFollowText
144             mrTextCharacterProperties.moUnderlineFillFollowText = true;
145         break;
146         case A_TOKEN( uFill ):      // CT_TextUnderlineFillGroupWrapper->EG_FillProperties (not supported)
147             xRet.set( new SimpleFillPropertiesContext( *this, mrTextCharacterProperties.maUnderlineColor ) );
148         break;
149 
150         // CT_FontCollection
151         case A_TOKEN( latin ):      // CT_TextFont
152             mrTextCharacterProperties.maLatinFont.setAttributes( aAttribs );
153         break;
154         case A_TOKEN( ea ):         // CT_TextFont
155             mrTextCharacterProperties.maAsianFont.setAttributes( aAttribs );
156         break;
157         case A_TOKEN( cs ):         // CT_TextFont
158             mrTextCharacterProperties.maComplexFont.setAttributes( aAttribs );
159         break;
160         case A_TOKEN( sym ):        // CT_TextFont
161             mrTextCharacterProperties.maSymbolFont.setAttributes( aAttribs );
162         break;
163 
164         case A_TOKEN( hlinkClick ):     // CT_Hyperlink
165         case A_TOKEN( hlinkMouseOver ): // CT_Hyperlink
166             xRet.set( new HyperLinkContext( *this, xAttributes,  mrTextCharacterProperties.maHyperlinkPropertyMap ) );
167         break;
168     }
169     if( !xRet.is() )
170         xRet.set( this );
171     return xRet;
172 }
173 
174 // --------------------------------------------------------------------
175 
176 } }
177 
178