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 "customshowlistcontext.hxx"
25 
26 using namespace ::oox::core;
27 using namespace ::com::sun::star::uno;
28 using namespace ::com::sun::star::xml::sax;
29 
30 namespace oox { namespace ppt {
31 
32 class CustomShowContext : public ::oox::core::ContextHandler
33 {
34 	CustomShow mrCustomShow;
35 
36 public:
37     CustomShowContext( ::oox::core::ContextHandler& rParent,
38 		const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs,
39 			CustomShow& rCustomShow );
40 	~CustomShowContext( );
41 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL
42 		createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ )
43 			throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
44 };
45 
CustomShowContext(ContextHandler & rParent,const Reference<XFastAttributeList> & rxAttribs,CustomShow & rCustomShow)46 CustomShowContext::CustomShowContext( ContextHandler& rParent,
47 	const Reference< XFastAttributeList >& rxAttribs,
48 		CustomShow& rCustomShow )
49 : ContextHandler( rParent )
50 , mrCustomShow( rCustomShow )
51 {
52 	mrCustomShow.maName = rxAttribs->getOptionalValue( XML_name );
53 	mrCustomShow.mnId = rxAttribs->getOptionalValue( XML_id );
54 }
55 
~CustomShowContext()56 CustomShowContext::~CustomShowContext( )
57 {
58 }
59 
createFastChildContext(sal_Int32 aElementToken,const Reference<XFastAttributeList> & xAttribs)60 Reference< XFastContextHandler > SAL_CALL CustomShowContext::createFastChildContext( sal_Int32 aElementToken,
61 	const Reference< XFastAttributeList >& xAttribs )
62 		throw ( SAXException, RuntimeException )
63 {
64 	Reference< XFastContextHandler > xRet;
65 	switch( aElementToken )
66 	{
67 		case PPT_TOKEN( sld ) :
68 			mrCustomShow.maSldLst.push_back( xAttribs->getOptionalValue( R_TOKEN( id ) ) );
69 		default:
70 		break;
71 	}
72 	if( !xRet.is() )
73 		xRet.set( this );
74 
75 	return xRet;
76 }
77 
78 //---------------------------------------------------------------------------
79 
CustomShowListContext(ContextHandler & rParent,std::vector<CustomShow> & rCustomShowList)80 CustomShowListContext::CustomShowListContext( ContextHandler& rParent,
81 	std::vector< CustomShow >& rCustomShowList )
82 : ContextHandler( rParent )
83 , mrCustomShowList( rCustomShowList )
84 {
85 }
86 
~CustomShowListContext()87 CustomShowListContext::~CustomShowListContext( )
88 {
89 }
90 
createFastChildContext(sal_Int32 aElementToken,const Reference<XFastAttributeList> & xAttribs)91 Reference< XFastContextHandler > SAL_CALL CustomShowListContext::createFastChildContext( sal_Int32 aElementToken,
92 	const Reference< XFastAttributeList >& xAttribs )
93 		throw ( SAXException, RuntimeException )
94 {
95 	Reference< XFastContextHandler > xRet;
96 	switch( aElementToken )
97 	{
98 		case PPT_TOKEN( custShow ) :
99 		{
100 			CustomShow aCustomShow;
101 			mrCustomShowList.push_back( aCustomShow );
102             xRet = new CustomShowContext( *this, xAttribs, mrCustomShowList.back() );
103 		}
104 		default:
105 		break;
106 	}
107 	if( !xRet.is() )
108 		xRet.set( this );
109 
110 	return xRet;
111 }
112 
113 
114 } }
115