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 <osl/diagnose.h>
25
26 #include "oox/drawingml/table/tablestyletextstylecontext.hxx"
27 #include "oox/drawingml/colorchoicecontext.hxx"
28 #include "oox/helper/attributelist.hxx"
29
30 using namespace ::oox::core;
31 using namespace ::com::sun::star;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::xml::sax;
34 using ::rtl::OUString;
35
36 namespace oox { namespace drawingml { namespace table {
37
TableStyleTextStyleContext(ContextHandler & rParent,const Reference<XFastAttributeList> & xAttribs,TableStylePart & rTableStylePart)38 TableStyleTextStyleContext::TableStyleTextStyleContext( ContextHandler& rParent,
39 const Reference< XFastAttributeList >& xAttribs, TableStylePart& rTableStylePart )
40 : ContextHandler( rParent )
41 , mrTableStylePart( rTableStylePart )
42 {
43 sal_Int32 nB = xAttribs->getOptionalValueToken( XML_b, XML_def );
44 if ( nB == XML_on )
45 mrTableStylePart.getTextBoldStyle() = ::boost::optional< sal_Bool >( sal_True );
46 else if ( nB == XML_off )
47 mrTableStylePart.getTextBoldStyle() = ::boost::optional< sal_Bool >( sal_False );
48
49 sal_Int32 nI = xAttribs->getOptionalValueToken( XML_i, XML_def );
50 if ( nI == XML_on )
51 mrTableStylePart.getTextItalicStyle() = ::boost::optional< sal_Bool >( sal_True );
52 else if ( nI == XML_off )
53 mrTableStylePart.getTextItalicStyle() = ::boost::optional< sal_Bool >( sal_False );
54 }
55
~TableStyleTextStyleContext()56 TableStyleTextStyleContext::~TableStyleTextStyleContext()
57 {
58 }
59
60 // CT_TableStyleTextStyle
61 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
createFastChildContext(::sal_Int32 aElementToken,const uno::Reference<xml::sax::XFastAttributeList> & xAttribs)62 TableStyleTextStyleContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
63 {
64 uno::Reference< xml::sax::XFastContextHandler > xRet;
65 AttributeList aAttribs( xAttribs );
66
67 switch( aElementToken )
68 {
69 // EG_ThemeableFontStyles (choice)
70 case A_TOKEN( font ): // CT_FontCollection
71 xRet.set( this );
72 break;
73 case A_TOKEN( ea ): // CT_TextFont
74 mrTableStylePart.getAsianFont().setAttributes( aAttribs );
75 return 0;
76 case A_TOKEN( cs ): // CT_TextFont
77 mrTableStylePart.getComplexFont().setAttributes( aAttribs );
78 return 0;
79 case A_TOKEN( sym ): // CT_TextFont
80 mrTableStylePart.getSymbolFont().setAttributes( aAttribs );
81 return 0;
82 case A_TOKEN( latin ): // CT_TextFont
83 mrTableStylePart.getLatinFont().setAttributes( aAttribs );
84 return 0;
85
86 case A_TOKEN( fontRef ): // CT_FontReference
87 {
88 ShapeStyleRef& rFontStyle = mrTableStylePart.getStyleRefs()[ XML_fontRef ];
89 rFontStyle.mnThemedIdx = aAttribs.getToken( XML_idx, XML_none );
90 xRet.set( new ColorContext( *this, rFontStyle.maPhClr ) );
91 }
92 break;
93
94 case A_TOKEN( extLst ): // CT_OfficeArtExtensionList
95 break;
96 }
97 if( !xRet.is() )
98 xRet.set( new ColorValueContext( *this, mrTableStylePart.getTextColor() ) );
99
100 return xRet;
101 }
102
103 } } }
104