Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / oox / source / ppt / soundactioncontext.cxx
blob06d416982e258448967fe9da7eb0ac9439e32169
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <config_features.h>
22 #include <oox/ppt/soundactioncontext.hxx>
24 #include <cppuhelper/exc_hlp.hxx>
26 #include <com/sun/star/io/XInputStream.hpp>
28 #include <oox/helper/attributelist.hxx>
29 #include <oox/helper/propertymap.hxx>
30 #include <drawingml/embeddedwavaudiofile.hxx>
31 #include <oox/token/namespaces.hxx>
32 #include <oox/token/properties.hxx>
33 #include <oox/token/tokens.hxx>
34 #include <oox/core/xmlfilterbase.hxx>
35 #include <avmedia/mediaitem.hxx>
37 using namespace ::oox::core;
38 using namespace ::com::sun::star::xml::sax;
39 using namespace ::com::sun::star::uno;
41 namespace oox { namespace ppt {
43 SoundActionContext::SoundActionContext( FragmentHandler2 const & rParent, PropertyMap & aProperties ) throw()
44 : FragmentHandler2( rParent )
45 , maSlideProperties( aProperties )
46 , mbHasStartSound( false )
47 , mbLoopSound( false )
48 , mbStopSound( false )
52 SoundActionContext::~SoundActionContext() throw()
56 void SoundActionContext::onEndElement()
58 if ( isCurrentElement( PPT_TOKEN( sndAc ) ) )
60 if( mbHasStartSound )
62 OUString url;
63 #if HAVE_FEATURE_AVMEDIA
64 if ( !msSndName.isEmpty() )
66 Reference<css::io::XInputStream>
67 xInputStream = getFilter().openInputStream(msSndName);
68 if (xInputStream.is())
70 ::avmedia::EmbedMedia(getFilter().getModel(), msSndName, url, xInputStream);
71 xInputStream->closeInput();
74 #endif
75 if ( !url.isEmpty() )
77 maSlideProperties.setProperty( PROP_Sound, url);
78 maSlideProperties.setProperty( PROP_SoundOn, true);
84 ::oox::core::ContextHandlerRef SoundActionContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
86 switch( aElementToken )
88 case PPT_TOKEN( snd ):
89 if( mbHasStartSound )
91 msSndName = drawingml::getEmbeddedWAVAudioFile( getRelations(), rAttribs );
93 return this;
94 case PPT_TOKEN( endSnd ):
95 // CT_Empty
96 mbStopSound = true;
97 return this;
98 case PPT_TOKEN( stSnd ):
99 mbHasStartSound = true;
100 mbLoopSound = rAttribs.getBool( XML_loop, false );
101 return this;
102 default:
103 break;
106 return this;
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */