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/tablestylecontext.hxx"
31 #include "oox/drawingml/table/tablebackgroundstylecontext.hxx"
32 #include "oox/drawingml/table/tablepartstylecontext.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 TableStyleContext::TableStyleContext( ContextHandler& rParent,
43 	const Reference< XFastAttributeList >& xAttribs, TableStyle& rTableStyle )
44 : ContextHandler( rParent )
45 , mrTableStyle( rTableStyle )
46 {
47 	mrTableStyle.getStyleId() = xAttribs->getOptionalValue( XML_styleId );
48 	mrTableStyle.getStyleName() = xAttribs->getOptionalValue( XML_styleName );
49 }
50 
51 TableStyleContext::~TableStyleContext()
52 {
53 }
54 
55 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
56 TableStyleContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Reference< xml::sax::XFastAttributeList >& /* xAttribs */ )
57 	throw ( xml::sax::SAXException, uno::RuntimeException)
58 {
59 	uno::Reference< xml::sax::XFastContextHandler > xRet;
60 
61 	switch( aElementToken )
62 	{
63 		case A_TOKEN( tblBg ):		// CT_TableBackgroundStyle
64 			xRet = new TableBackgroundStyleContext( *this, mrTableStyle );
65 			break;
66 		case A_TOKEN( wholeTbl ):	// CT_TablePartStyle
67 			xRet = new TablePartStyleContext( *this, mrTableStyle.getWholeTbl() );
68 			break;
69 		case A_TOKEN( band1H ):		// CT_TablePartStyle
70 			xRet = new TablePartStyleContext( *this, mrTableStyle.getBand1H() );
71 			break;
72 		case A_TOKEN( band2H ):		// CT_TablePartStyle
73 			xRet = new TablePartStyleContext( *this, mrTableStyle.getBand2H() );
74 			break;
75 		case A_TOKEN( band1V ):		// CT_TablePartStyle
76 			xRet = new TablePartStyleContext( *this, mrTableStyle.getBand1V() );
77 			break;
78 		case A_TOKEN( band2V ):		// CT_TablePartStyle
79 			xRet = new TablePartStyleContext( *this, mrTableStyle.getBand2V() );
80 			break;
81 		case A_TOKEN( lastCol ):	// CT_TablePartStyle
82 			xRet = new TablePartStyleContext( *this, mrTableStyle.getLastCol() );
83 			break;
84 		case A_TOKEN( firstCol ):	// CT_TablePartStyle
85 			xRet = new TablePartStyleContext( *this, mrTableStyle.getFirstCol() );
86 			break;
87 		case A_TOKEN( lastRow ):	// CT_TablePartStyle
88 			xRet = new TablePartStyleContext( *this, mrTableStyle.getLastRow() );
89 			break;
90 		case A_TOKEN( seCell ):		// CT_TablePartStyle
91 			xRet = new TablePartStyleContext( *this, mrTableStyle.getSeCell() );
92 			break;
93 		case A_TOKEN( swCell ):		// CT_TablePartStyle
94 			xRet = new TablePartStyleContext( *this, mrTableStyle.getSwCell() );
95 			break;
96 		case A_TOKEN( firstRow ):	// CT_TablePartStyle
97 			xRet = new TablePartStyleContext( *this, mrTableStyle.getFirstRow() );
98 			break;
99 		case A_TOKEN( neCell ):		// CT_TablePartStyle
100 			xRet = new TablePartStyleContext( *this, mrTableStyle.getNeCell() );
101 			break;
102 		case A_TOKEN( nwCell ):		// CT_TablePartStyle
103 			xRet = new TablePartStyleContext( *this, mrTableStyle.getNwCell() );
104 			break;
105 		case A_TOKEN( extLst ):		// CT_OfficeArtExtensionList
106 			break;
107 	}
108 	if( !xRet.is() )
109 	{
110         uno::Reference<XFastContextHandler> xTmp(this);
111 		xRet.set( xTmp );
112 	}
113 	return xRet;
114 }
115 
116 } } }
117