tdf#144694 In direct SQL dialog, activate options 'Run SQL command
[LibreOffice.git] / oox / source / ppt / soundactioncontext.cxx
blob075c9a2235e44f3d97431ae04958e18be8f4d218
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 <com/sun/star/io/XInputStream.hpp>
26 #include <oox/helper/attributelist.hxx>
27 #include <oox/helper/propertymap.hxx>
28 #include <drawingml/embeddedwavaudiofile.hxx>
29 #include <oox/token/namespaces.hxx>
30 #include <oox/token/properties.hxx>
31 #include <oox/token/tokens.hxx>
32 #include <oox/core/xmlfilterbase.hxx>
33 #include <avmedia/mediaitem.hxx>
35 using namespace ::oox::core;
36 using namespace ::com::sun::star::uno;
38 namespace oox::ppt {
40 SoundActionContext::SoundActionContext( FragmentHandler2 const & rParent, PropertyMap & aProperties ) noexcept
41 : FragmentHandler2( rParent )
42 , maSlideProperties( aProperties )
43 , mbHasStartSound( false )
44 , mbLoopSound( false )
45 , mbStopSound( false )
49 SoundActionContext::~SoundActionContext() noexcept
53 void SoundActionContext::onEndElement()
55 if ( !isCurrentElement( PPT_TOKEN( sndAc ) ) )
56 return;
58 if( !mbHasStartSound )
59 return;
61 OUString url;
62 #if HAVE_FEATURE_AVMEDIA
63 if ( !msSndName.isEmpty() )
65 Reference<css::io::XInputStream>
66 xInputStream = getFilter().openInputStream(msSndName);
67 if (xInputStream.is())
69 ::avmedia::EmbedMedia(getFilter().getModel(), msSndName, url, xInputStream);
70 xInputStream->closeInput();
73 #endif
74 if ( !url.isEmpty() )
76 maSlideProperties.setProperty( PROP_Sound, url);
77 maSlideProperties.setProperty( PROP_SoundOn, true);
81 ::oox::core::ContextHandlerRef SoundActionContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
83 switch( aElementToken )
85 case PPT_TOKEN( snd ):
86 if( mbHasStartSound )
88 msSndName = drawingml::getEmbeddedWAVAudioFile( getRelations(), rAttribs );
90 return this;
91 case PPT_TOKEN( endSnd ):
92 // CT_Empty
93 mbStopSound = true;
94 return this;
95 case PPT_TOKEN( stSnd ):
96 mbHasStartSound = true;
97 mbLoopSound = rAttribs.getBool( XML_loop, false );
98 return this;
99 default:
100 break;
103 return this;
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */