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