merge the formfield patch from ooo-build
[ooovba.git] / oox / source / ppt / soundactioncontext.cxx
blob26e56ba2cf2f76b6a7a0b6563c40a9ff2df0dd47
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: soundactioncontext.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/ppt/soundactioncontext.hxx"
33 #include "comphelper/anytostring.hxx"
34 #include "cppuhelper/exc_hlp.hxx"
36 #include "oox/helper/attributelist.hxx"
37 #include "oox/helper/propertymap.hxx"
38 #include "oox/core/namespaces.hxx"
39 #include "oox/drawingml/embeddedwavaudiofile.hxx"
40 #include "properties.hxx"
41 #include "tokens.hxx"
43 using rtl::OUString;
44 using namespace ::oox::core;
45 using namespace ::com::sun::star::xml::sax;
46 using namespace ::com::sun::star::uno;
49 namespace oox { namespace ppt {
52 SoundActionContext::SoundActionContext( ContextHandler& rParent, PropertyMap & aProperties ) throw()
53 : ContextHandler( rParent )
54 , maSlideProperties( aProperties )
55 , mbHasStartSound( false )
56 , mbLoopSound( false )
57 , mbStopSound( false )
62 SoundActionContext::~SoundActionContext() throw()
67 void SoundActionContext::endFastElement( sal_Int32 aElement ) throw (SAXException, RuntimeException)
69 if ( aElement == ( NMSP_PPT|XML_sndAc ) )
71 if( mbHasStartSound )
73 OUString url;
74 // TODO this is very wrong
75 if ( msSndName.getLength() != 0 )
77 // try the builtIn version
78 url = msSndName;
80 #if 0 // OOo does not support embedded data yet
81 else if ( msEmbedded.getLength() != 0 )
83 RelationsRef xRel = getHandler()->getRelations();
84 url = xRel->getRelationById( msEmbedded )->msTarget;
86 else if ( msLink.getLength() != 0 )
88 url = msLink;
90 #endif
91 if ( url.getLength() != 0 )
93 maSlideProperties[ PROP_Sound ] <<= url;
94 maSlideProperties[ PROP_SoundOn ] <<= sal_True;
97 // else if( mbStopSound )
98 // {
99 // maSlideProperties[ CREATE_OUSTRING( "" ) ] = Any( sal_True );
100 // }
105 Reference< XFastContextHandler > SoundActionContext::createFastChildContext( ::sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
107 Reference< XFastContextHandler > xRet;
108 AttributeList attribs(xAttribs);
110 switch( aElement )
112 case NMSP_PPT|XML_snd:
113 if( mbHasStartSound )
115 drawingml::EmbeddedWAVAudioFile aAudio;
116 drawingml::getEmbeddedWAVAudioFile( getRelations(), xAttribs, aAudio);
118 msSndName = ( aAudio.mbBuiltIn ? aAudio.msName : aAudio.msEmbed );
120 break;
121 case NMSP_PPT|XML_endSnd:
122 // CT_Empty
123 mbStopSound = true;
124 break;
125 case NMSP_PPT|XML_stSnd:
126 mbHasStartSound = true;
127 mbLoopSound = attribs.getBool( XML_loop, false );
128 default:
129 break;
132 if( !xRet.is() )
133 xRet.set( this );
135 return xRet;