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 namespace ::oox::core;
31 : using namespace ::com::sun::star::uno;
32 : using namespace ::com::sun::star::xml::sax;
33 : using namespace ::com::sun::star::awt;
34 :
35 : namespace oox { namespace drawingml {
36 :
37 : // CT_TextCharacterProperties
38 604 : TextCharacterPropertiesContext::TextCharacterPropertiesContext(
39 : ContextHandler2Helper& rParent,
40 : const AttributeList& rAttribs,
41 : TextCharacterProperties& rTextCharacterProperties )
42 : : ContextHandler2( rParent )
43 604 : , mrTextCharacterProperties( rTextCharacterProperties )
44 : {
45 604 : if ( rAttribs.hasAttribute( XML_lang ) )
46 315 : mrTextCharacterProperties.moLang = rAttribs.getString( XML_lang );
47 604 : if ( rAttribs.hasAttribute( XML_sz ) )
48 311 : mrTextCharacterProperties.moHeight = rAttribs.getInteger( XML_sz );
49 604 : if ( rAttribs.hasAttribute( XML_spc ) )
50 0 : mrTextCharacterProperties.moSpacing = rAttribs.getInteger( XML_spc );
51 604 : if ( rAttribs.hasAttribute( XML_u ) )
52 27 : mrTextCharacterProperties.moUnderline = rAttribs.getToken( XML_u );
53 604 : if ( rAttribs.hasAttribute( XML_strike ) )
54 24 : mrTextCharacterProperties.moStrikeout = rAttribs.getToken( XML_strike );
55 :
56 : // mrTextCharacterProperties.moCaseMap = rAttribs.getToken( XML_cap );
57 604 : if ( rAttribs.hasAttribute( XML_b ) )
58 65 : mrTextCharacterProperties.moBold = rAttribs.getBool( XML_b );
59 604 : if ( rAttribs.hasAttribute( XML_i ) )
60 41 : mrTextCharacterProperties.moItalic = rAttribs.getBool( XML_i );
61 :
62 : // TODO
63 : /* todo: we need to be able to iterate over the XFastAttributes
64 :
65 : // ST_TextNonNegativePoint
66 : const OUString sCharKerning( "CharKerning" );
67 : //case A_TOKEN( kern ):
68 :
69 : // ST_TextLanguageID
70 : OUString sAltLang = rAttribs.getString( XML_altLang ).get();
71 :
72 : case A_TOKEN( kumimoji ): // xsd:boolean
73 : break;
74 : case A_TOKEN( spc ): // ST_TextPoint
75 : case A_TOKEN( normalizeH ): // xsd:boolean
76 : case A_TOKEN( baseline ): // ST_Percentage
77 : case A_TOKEN( noProof ): // xsd:boolean
78 : case A_TOKEN( dirty ): // xsd:boolean
79 : case A_TOKEN( err ): // xsd:boolean
80 : case A_TOKEN( smtClean ): // xsd:boolean
81 : case A_TOKEN( smtId ): // xsd:unsignedInt
82 : break;
83 : */
84 :
85 604 : }
86 :
87 1208 : TextCharacterPropertiesContext::~TextCharacterPropertiesContext()
88 : {
89 1208 : }
90 :
91 1190 : ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
92 : {
93 1190 : switch( aElementToken )
94 : {
95 : // TODO unsupported yet
96 : // case A_TOKEN( ln ): // CT_LineProperties
97 : // return new LinePropertiesContext( getHandler(), rAttribs, maTextOutlineProperties );
98 :
99 : case A_TOKEN( solidFill ): // EG_FillProperties
100 288 : return new ColorContext( *this, mrTextCharacterProperties.maCharColor );
101 :
102 : // EG_EffectProperties
103 : case A_TOKEN( effectDag ): // CT_EffectContainer 5.1.10.25
104 : case A_TOKEN( effectLst ): // CT_EffectList 5.1.10.26
105 41 : break;
106 :
107 : case A_TOKEN( highlight ): // CT_Color
108 0 : return new ColorContext( *this, mrTextCharacterProperties.maHighlightColor );
109 :
110 : // EG_TextUnderlineLine
111 : case A_TOKEN( uLnTx ): // CT_TextUnderlineLineFollowText
112 0 : mrTextCharacterProperties.moUnderlineLineFollowText = true;
113 0 : break;
114 : // TODO unsupported yet
115 : // case A_TOKEN( uLn ): // CT_LineProperties
116 : // return new LinePropertiesContext( getHandler(), rAttribs, maUnderlineProperties );
117 :
118 : // EG_TextUnderlineFill
119 : case A_TOKEN( uFillTx ): // CT_TextUnderlineFillFollowText
120 0 : mrTextCharacterProperties.moUnderlineFillFollowText = true;
121 0 : break;
122 : case A_TOKEN( uFill ): // CT_TextUnderlineFillGroupWrapper->EG_FillProperties (not supported)
123 0 : return new SimpleFillPropertiesContext( *this, mrTextCharacterProperties.maUnderlineColor );
124 :
125 : // CT_FontCollection
126 : case A_TOKEN( latin ): // CT_TextFont
127 291 : mrTextCharacterProperties.maLatinFont.setAttributes( rAttribs );
128 291 : break;
129 : case A_TOKEN( ea ): // CT_TextFont
130 191 : mrTextCharacterProperties.maAsianFont.setAttributes( rAttribs );
131 191 : break;
132 : case A_TOKEN( cs ): // CT_TextFont
133 220 : mrTextCharacterProperties.maComplexFont.setAttributes( rAttribs );
134 220 : break;
135 : case A_TOKEN( sym ): // CT_TextFont
136 0 : mrTextCharacterProperties.maSymbolFont.setAttributes( rAttribs );
137 0 : break;
138 :
139 : case A_TOKEN( hlinkClick ): // CT_Hyperlink
140 : case A_TOKEN( hlinkMouseOver ): // CT_Hyperlink
141 0 : return new HyperLinkContext( *this, rAttribs, mrTextCharacterProperties.maHyperlinkPropertyMap );
142 : }
143 :
144 902 : return this;
145 : }
146 :
147 : } }
148 :
149 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|