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 "oox/drawingml/table/tablestylelistfragmenthandler.hxx"
25 #include "oox/drawingml/table/tablestylecontext.hxx"
26 
27 using ::rtl::OUString;
28 using namespace ::oox::core;
29 
30 using rtl::OUString;
31 using namespace ::com::sun::star;
32 using namespace ::oox::core;
33 using namespace ::oox::drawingml;
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::xml::sax;
36 
37 namespace oox {
38 namespace drawingml {
39 namespace table {
40 
41 // ============================================================================
42 
TableStyleListFragmentHandler(XmlFilterBase & rFilter,const OUString & rFragmentPath,TableStyleList & rTableStyleList)43 TableStyleListFragmentHandler::TableStyleListFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath, TableStyleList& rTableStyleList ):
44 FragmentHandler2( rFilter, rFragmentPath ),
45 mrTableStyleList( rTableStyleList )
46 {
47 }
48 
~TableStyleListFragmentHandler()49 TableStyleListFragmentHandler::~TableStyleListFragmentHandler()
50 {
51 }
52 
53 // CT_TableStyleList
createFastChildContext(sal_Int32 aElementToken,const Reference<XFastAttributeList> & xAttribs)54 Reference< XFastContextHandler > TableStyleListFragmentHandler::createFastChildContext(
55 	sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs )
56 		throw ( SAXException, RuntimeException )
57 {
58 	Reference< XFastContextHandler > xRet;
59 	switch( aElementToken )
60 	{
61 		case A_TOKEN( tblStyleLst ):	// CT_TableStyleList
62 			mrTableStyleList.getDefaultStyleId() = xAttribs->getOptionalValue( XML_def );
63 			break;
64 		case A_TOKEN( tblStyle ):		// CT_TableStyle
65 			std::vector< TableStyle >& rTableStyles = mrTableStyleList.getTableStyles();
66 			rTableStyles.resize( rTableStyles.size() + 1 );
67 			xRet = new TableStyleContext( *this, xAttribs, rTableStyles.back() );
68 			break;
69 	}
70 	if ( !xRet.is() )
71         xRet = getFastContextHandler();
72 	return xRet;
73 }
74 
75 // ============================================================================
76 
77 } // namespace table
78 } // namespace drawingml
79 } // namespace oox
80 
81