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