Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #include "oox/drawingml/textcharacterpropertiescontext.hxx"
21 : :
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"
29 : :
30 : : using ::rtl::OUString;
31 : : using namespace ::oox::core;
32 : : using namespace ::com::sun::star::uno;
33 : : using namespace ::com::sun::star::xml::sax;
34 : : using namespace ::com::sun::star::awt;
35 : :
36 : : namespace oox { namespace drawingml {
37 : :
38 : : // --------------------------------------------------------------------
39 : :
40 : : // CT_TextCharacterProperties
41 : 588 : TextCharacterPropertiesContext::TextCharacterPropertiesContext(
42 : : ContextHandler& rParent,
43 : : const Reference< XFastAttributeList >& rXAttributes,
44 : : TextCharacterProperties& rTextCharacterProperties )
45 : : : ContextHandler( rParent )
46 : 588 : , mrTextCharacterProperties( rTextCharacterProperties )
47 : : {
48 [ + - ]: 588 : AttributeList aAttribs( rXAttributes );
49 [ + - ][ + + ]: 588 : if ( aAttribs.hasAttribute( XML_lang ) )
50 [ + - ]: 288 : mrTextCharacterProperties.moLang = aAttribs.getString( XML_lang );
51 [ + - ][ + + ]: 588 : if ( aAttribs.hasAttribute( XML_sz ) )
52 [ + - ]: 243 : mrTextCharacterProperties.moHeight = aAttribs.getInteger( XML_sz );
53 [ + - ][ - + ]: 588 : if ( aAttribs.hasAttribute( XML_spc ) )
54 [ # # ]: 0 : mrTextCharacterProperties.moSpacing = aAttribs.getInteger( XML_spc );
55 [ + - ][ + + ]: 588 : if ( aAttribs.hasAttribute( XML_u ) )
56 [ + - ]: 6 : mrTextCharacterProperties.moUnderline = aAttribs.getToken( XML_u );
57 [ + - ][ - + ]: 588 : if ( aAttribs.hasAttribute( XML_strike ) )
58 [ # # ]: 0 : mrTextCharacterProperties.moStrikeout = aAttribs.getToken( XML_strike );
59 : :
60 : : // mrTextCharacterProperties.moCaseMap = aAttribs.getToken( XML_cap );
61 [ + - ][ + + ]: 588 : if ( aAttribs.hasAttribute( XML_b ) )
62 [ + - ]: 3 : mrTextCharacterProperties.moBold = aAttribs.getBool( XML_b );
63 [ + - ][ - + ]: 588 : if ( aAttribs.hasAttribute( XML_i ) )
64 [ # # ][ + - ]: 588 : mrTextCharacterProperties.moItalic = aAttribs.getBool( XML_i );
65 : :
66 : : // TODO
67 : : /* todo: we need to be able to iterate over the XFastAttributes
68 : :
69 : : // ST_TextNonNegativePoint
70 : : const OUString sCharKerning( CREATE_OUSTRING( "CharKerning" ) );
71 : : //case A_TOKEN( kern ):
72 : :
73 : : // ST_TextLanguageID
74 : : OUString sAltLang = rXAttributes->getOptionalValue( XML_altLang );
75 : :
76 : : case A_TOKEN( kumimoji ): // xsd:boolean
77 : : break;
78 : : case A_TOKEN( spc ): // ST_TextPoint
79 : : case A_TOKEN( normalizeH ): // xsd:boolean
80 : : case A_TOKEN( baseline ): // ST_Percentage
81 : : case A_TOKEN( noProof ): // xsd:boolean
82 : : case A_TOKEN( dirty ): // xsd:boolean
83 : : case A_TOKEN( err ): // xsd:boolean
84 : : case A_TOKEN( smtClean ): // xsd:boolean
85 : : case A_TOKEN( smtId ): // xsd:unsignedInt
86 : : break;
87 : : */
88 : :
89 : 588 : }
90 : :
91 : 588 : TextCharacterPropertiesContext::~TextCharacterPropertiesContext()
92 : : {
93 [ - + ]: 1176 : }
94 : :
95 : : // --------------------------------------------------------------------
96 : :
97 : 1092 : void TextCharacterPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
98 : : {
99 : 1092 : }
100 : :
101 : : // --------------------------------------------------------------------
102 : :
103 : 720 : Reference< XFastContextHandler > TextCharacterPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttributes ) throw (SAXException, RuntimeException)
104 : : {
105 [ + - ]: 720 : AttributeList aAttribs( xAttributes );
106 : 720 : Reference< XFastContextHandler > xRet;
107 [ + - - - : 720 : switch( aElementToken )
- - + + +
- - - ]
108 : : {
109 : : // TODO unsupported yet
110 : : // case A_TOKEN( ln ): // CT_LineProperties
111 : : // xRet.set( new LinePropertiesContext( getHandler(), xAttributes, maTextOutlineProperties ) );
112 : : // break;
113 : :
114 : : case A_TOKEN( solidFill ): // EG_FillProperties
115 [ + - ][ + - ]: 216 : xRet.set( new ColorContext( *this, mrTextCharacterProperties.maCharColor ) );
[ + - ]
116 : 216 : break;
117 : :
118 : : // EG_EffectProperties
119 : : case A_TOKEN( effectDag ): // CT_EffectContainer 5.1.10.25
120 : : case A_TOKEN( effectLst ): // CT_EffectList 5.1.10.26
121 : 0 : break;
122 : :
123 : : case A_TOKEN( highlight ): // CT_Color
124 [ # # ][ # # ]: 0 : xRet.set( new ColorContext( *this, mrTextCharacterProperties.maHighlightColor ) );
[ # # ]
125 : 0 : break;
126 : :
127 : : // EG_TextUnderlineLine
128 : : case A_TOKEN( uLnTx ): // CT_TextUnderlineLineFollowText
129 [ # # ]: 0 : mrTextCharacterProperties.moUnderlineLineFollowText = true;
130 : 0 : break;
131 : : // TODO unsupported yet
132 : : // case A_TOKEN( uLn ): // CT_LineProperties
133 : : // xRet.set( new LinePropertiesContext( getHandler(), xAttributes, maUnderlineProperties ) );
134 : : // break;
135 : :
136 : : // EG_TextUnderlineFill
137 : : case A_TOKEN( uFillTx ): // CT_TextUnderlineFillFollowText
138 [ # # ]: 0 : mrTextCharacterProperties.moUnderlineFillFollowText = true;
139 : 0 : break;
140 : : case A_TOKEN( uFill ): // CT_TextUnderlineFillGroupWrapper->EG_FillProperties (not supported)
141 [ # # ][ # # ]: 0 : xRet.set( new SimpleFillPropertiesContext( *this, mrTextCharacterProperties.maUnderlineColor ) );
[ # # ]
142 : 0 : break;
143 : :
144 : : // CT_FontCollection
145 : : case A_TOKEN( latin ): // CT_TextFont
146 [ + - ]: 168 : mrTextCharacterProperties.maLatinFont.setAttributes( aAttribs );
147 : 168 : break;
148 : : case A_TOKEN( ea ): // CT_TextFont
149 [ + - ]: 168 : mrTextCharacterProperties.maAsianFont.setAttributes( aAttribs );
150 : 168 : break;
151 : : case A_TOKEN( cs ): // CT_TextFont
152 [ + - ]: 168 : mrTextCharacterProperties.maComplexFont.setAttributes( aAttribs );
153 : 168 : break;
154 : : case A_TOKEN( sym ): // CT_TextFont
155 [ # # ]: 0 : mrTextCharacterProperties.maSymbolFont.setAttributes( aAttribs );
156 : 0 : break;
157 : :
158 : : case A_TOKEN( hlinkClick ): // CT_Hyperlink
159 : : case A_TOKEN( hlinkMouseOver ): // CT_Hyperlink
160 [ # # ][ # # ]: 0 : xRet.set( new HyperLinkContext( *this, xAttributes, mrTextCharacterProperties.maHyperlinkPropertyMap ) );
[ # # ]
161 : 0 : break;
162 : : }
163 [ + + ]: 720 : if( !xRet.is() )
164 [ + - ]: 504 : xRet.set( this );
165 [ + - ]: 720 : return xRet;
166 : : }
167 : :
168 : : // --------------------------------------------------------------------
169 : :
170 : : } }
171 : :
172 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|