1*ca5ec200SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ca5ec200SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ca5ec200SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ca5ec200SAndrew Rist  * distributed with this work for additional information
6*ca5ec200SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ca5ec200SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ca5ec200SAndrew Rist  * "License"); you may not use this file except in compliance
9*ca5ec200SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ca5ec200SAndrew Rist  *
11*ca5ec200SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ca5ec200SAndrew Rist  *
13*ca5ec200SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ca5ec200SAndrew Rist  * software distributed under the License is distributed on an
15*ca5ec200SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ca5ec200SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ca5ec200SAndrew Rist  * specific language governing permissions and limitations
18*ca5ec200SAndrew Rist  * under the License.
19*ca5ec200SAndrew Rist  *
20*ca5ec200SAndrew Rist  *************************************************************/
21*ca5ec200SAndrew Rist 
22*ca5ec200SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include <osl/diagnose.h>
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "oox/drawingml/table/tablestyletextstylecontext.hxx"
27cdf0e10cSrcweir #include "oox/drawingml/colorchoicecontext.hxx"
28cdf0e10cSrcweir #include "oox/helper/attributelist.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir using namespace ::oox::core;
31cdf0e10cSrcweir using namespace ::com::sun::star;
32cdf0e10cSrcweir using namespace ::com::sun::star::uno;
33cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax;
34cdf0e10cSrcweir using ::rtl::OUString;
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace oox { namespace drawingml { namespace table {
37cdf0e10cSrcweir 
TableStyleTextStyleContext(ContextHandler & rParent,const Reference<XFastAttributeList> & xAttribs,TableStylePart & rTableStylePart)38cdf0e10cSrcweir TableStyleTextStyleContext::TableStyleTextStyleContext( ContextHandler& rParent,
39cdf0e10cSrcweir 	const Reference< XFastAttributeList >& xAttribs, TableStylePart& rTableStylePart )
40cdf0e10cSrcweir : ContextHandler( rParent )
41cdf0e10cSrcweir , mrTableStylePart( rTableStylePart )
42cdf0e10cSrcweir {
43cdf0e10cSrcweir 	sal_Int32 nB = xAttribs->getOptionalValueToken( XML_b, XML_def );
44cdf0e10cSrcweir 	if ( nB == XML_on )
45cdf0e10cSrcweir 		mrTableStylePart.getTextBoldStyle() = ::boost::optional< sal_Bool >( sal_True );
46cdf0e10cSrcweir 	else if ( nB == XML_off )
47cdf0e10cSrcweir 		mrTableStylePart.getTextBoldStyle() = ::boost::optional< sal_Bool >( sal_False );
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	sal_Int32 nI = xAttribs->getOptionalValueToken( XML_i, XML_def );
50cdf0e10cSrcweir 	if ( nI == XML_on )
51cdf0e10cSrcweir 		mrTableStylePart.getTextItalicStyle() = ::boost::optional< sal_Bool >( sal_True );
52cdf0e10cSrcweir 	else if ( nI == XML_off )
53cdf0e10cSrcweir 		mrTableStylePart.getTextItalicStyle() = ::boost::optional< sal_Bool >( sal_False );
54cdf0e10cSrcweir }
55cdf0e10cSrcweir 
~TableStyleTextStyleContext()56cdf0e10cSrcweir TableStyleTextStyleContext::~TableStyleTextStyleContext()
57cdf0e10cSrcweir {
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
60cdf0e10cSrcweir // CT_TableStyleTextStyle
61cdf0e10cSrcweir uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
createFastChildContext(::sal_Int32 aElementToken,const uno::Reference<xml::sax::XFastAttributeList> & xAttribs)62cdf0e10cSrcweir TableStyleTextStyleContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
63cdf0e10cSrcweir 	throw ( xml::sax::SAXException, uno::RuntimeException)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 	uno::Reference< xml::sax::XFastContextHandler > xRet;
66cdf0e10cSrcweir     AttributeList aAttribs( xAttribs );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 	switch( aElementToken )
69cdf0e10cSrcweir 	{
70cdf0e10cSrcweir 		// EG_ThemeableFontStyles (choice)
71cdf0e10cSrcweir 		case A_TOKEN( font ):		// CT_FontCollection
72cdf0e10cSrcweir 			xRet.set( this );
73cdf0e10cSrcweir 			break;
74cdf0e10cSrcweir 		case A_TOKEN( ea ):				// CT_TextFont
75cdf0e10cSrcweir             mrTableStylePart.getAsianFont().setAttributes( aAttribs );
76cdf0e10cSrcweir             return 0;
77cdf0e10cSrcweir 		case A_TOKEN( cs ):				// CT_TextFont
78cdf0e10cSrcweir             mrTableStylePart.getComplexFont().setAttributes( aAttribs );
79cdf0e10cSrcweir             return 0;
80cdf0e10cSrcweir 		case A_TOKEN( sym ):			// CT_TextFont
81cdf0e10cSrcweir             mrTableStylePart.getSymbolFont().setAttributes( aAttribs );
82cdf0e10cSrcweir             return 0;
83cdf0e10cSrcweir 		case A_TOKEN( latin ):			// CT_TextFont
84cdf0e10cSrcweir             mrTableStylePart.getLatinFont().setAttributes( aAttribs );
85cdf0e10cSrcweir             return 0;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 		case A_TOKEN( fontRef ):	// CT_FontReference
88cdf0e10cSrcweir             {
89cdf0e10cSrcweir                 ShapeStyleRef& rFontStyle = mrTableStylePart.getStyleRefs()[ XML_fontRef ];
90cdf0e10cSrcweir                 rFontStyle.mnThemedIdx = aAttribs.getToken( XML_idx, XML_none );
91cdf0e10cSrcweir                 xRet.set( new ColorContext( *this, rFontStyle.maPhClr ) );
92cdf0e10cSrcweir             }
93cdf0e10cSrcweir 			break;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 		case A_TOKEN( extLst ):		// CT_OfficeArtExtensionList
96cdf0e10cSrcweir 			break;
97cdf0e10cSrcweir 	}
98cdf0e10cSrcweir 	if( !xRet.is() )
99cdf0e10cSrcweir         xRet.set( new ColorValueContext( *this, mrTableStylePart.getTextColor() ) );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	return xRet;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir } } }
105