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 <osl/diagnose.h>
29 
30 #include "oox/drawingml/table/tablebackgroundstylecontext.hxx"
31 #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
32 #include "oox/helper/attributelist.hxx"
33 
34 using namespace ::oox::core;
35 using namespace ::com::sun::star;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::xml::sax;
38 using ::rtl::OUString;
39 
40 namespace oox { namespace drawingml { namespace table {
41 
42 TableBackgroundStyleContext::TableBackgroundStyleContext( ContextHandler& rParent, TableStyle& rTableStyle )
43 : ContextHandler( rParent )
44 , mrTableStyle( rTableStyle )
45 {
46 }
47 
48 TableBackgroundStyleContext::~TableBackgroundStyleContext()
49 {
50 }
51 
52 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
53 TableBackgroundStyleContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
54 	throw ( xml::sax::SAXException, uno::RuntimeException)
55 {
56 	uno::Reference< xml::sax::XFastContextHandler > xRet;
57 
58     AttributeList aAttribs( xAttribs );
59 	switch( aElementToken )
60 	{
61 		// EG_ThemeableFillStyle (choice)
62 		case A_TOKEN( fill ):		// CT_FillProperties
63 			{
64                 boost::shared_ptr< FillProperties >& rxFillProperties = mrTableStyle.getBackgroundFillProperties();
65                 rxFillProperties.reset( new FillProperties );
66                 xRet.set( new FillPropertiesContext( *this, *rxFillProperties ) );
67 			}
68 			break;
69 		case A_TOKEN( fillRef ):	// CT_StyleMatrixReference
70             {
71                 ShapeStyleRef& rStyleRef = mrTableStyle.getBackgroundFillStyleRef();
72                 rStyleRef.mnThemedIdx = aAttribs.getInteger( XML_idx, 0 );
73                 xRet.set( new ColorContext( *this, rStyleRef.maPhClr ) );
74             }
75 			break;
76 
77 		// EG_ThemeableEffectStyle (choice)
78 		case A_TOKEN( effect ):		// CT_EffectProperties
79 			break;
80 		case A_TOKEN( effectRef ):	// CT_StyleMatrixReference
81 			break;
82 	}
83 	if( !xRet.is() )
84 	{
85         uno::Reference<XFastContextHandler> xTmp(this);
86 		xRet.set( xTmp );
87 	}
88 	return xRet;
89 }
90 
91 } } }
92