diff options
Diffstat (limited to 'slideshow/source/engine/slideshowimpl.cxx')
-rw-r--r-- | slideshow/source/engine/slideshowimpl.cxx | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/slideshow/source/engine/slideshowimpl.cxx b/slideshow/source/engine/slideshowimpl.cxx index b2437e4b147d..177ff07dfb1b 100644 --- a/slideshow/source/engine/slideshowimpl.cxx +++ b/slideshow/source/engine/slideshowimpl.cxx @@ -30,6 +30,7 @@ #include <comphelper/anytostring.hxx> #include <comphelper/scopeguard.hxx> #include <comphelper/servicedecl.hxx> +#include <comphelper/storagehelper.hxx> #include <cppcanvas/spritecanvas.hxx> #include <cppcanvas/vclfactory.hxx> @@ -68,6 +69,7 @@ #include <com/sun/star/drawing/XLayerSupplier.hpp> #include <com/sun/star/drawing/XLayerManager.hpp> #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/document/XStorageBasedDocument.hpp> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/loader/CannotActivateFactoryException.hpp> @@ -78,6 +80,7 @@ #include <usereventqueue.hxx> #include <eventqueue.hxx> #include <cursormanager.hxx> +#include <mediafilemanager.hxx> #include <slideshowcontext.hxx> #include <activitiesqueue.hxx> #include <activitiesfactory.hxx> @@ -209,6 +212,7 @@ typedef ::std::map< css::uno::Reference< class SlideShowImpl : private cppu::BaseMutex, public CursorManager, + public MediaFileManager, public SlideShowImplBase { public: @@ -271,6 +275,9 @@ public: */ bool handleAnimationEvent( const AnimationNodeSharedPtr& rNode ); + /** Obtain a MediaTempFile for the specified url. */ + virtual std::shared_ptr<avmedia::MediaTempFile> getMediaTempFile(const OUString& aUrl) override; + private: // XSlideShow: virtual sal_Bool SAL_CALL nextEffect() override; @@ -460,6 +467,8 @@ private: uno::Reference<drawing::XDrawPage> mxPrefetchSlide; /// save the XDrawPagesSupplier to retrieve polygons uno::Reference<drawing::XDrawPagesSupplier> mxDrawPagesSupplier; + /// Used by MediaFileManager, for media files with package url. + uno::Reference<document::XStorageBasedDocument> mxSBD; /// slide animation to be prefetched: uno::Reference<animations::XAnimationNode> mxPrefetchAnimationNode; @@ -572,6 +581,7 @@ SlideShowImpl::SlideShowImpl( mpPrefetchSlide(), mxPrefetchSlide(), mxDrawPagesSupplier(), + mxSBD(), mxPrefetchAnimationNode(), mnCurrentCursor(awt::SystemPointer::ARROW), mnWaitSymbolRequestCount(0), @@ -710,7 +720,7 @@ SoundPlayerSharedPtr SlideShowImpl::resetSlideTransitionSound( const uno::Any& r try { mpCurrentSlideTransitionSound = SoundPlayer::create( - maEventMultiplexer, url, mxComponentContext ); + maEventMultiplexer, url, mxComponentContext, *this); mpCurrentSlideTransitionSound->setPlaybackLoop( bLoopSound ); } catch (lang::NoSupportException const&) @@ -894,6 +904,7 @@ SlideSharedPtr SlideShowImpl::makeSlide( maActivitiesQueue, maUserEventQueue, *this, + *this, maViewContainer, mxComponentContext, maShapeEventListeners, @@ -1055,6 +1066,7 @@ void SlideShowImpl::displaySlide( DBG_TESTSOLARMUTEX(); mxDrawPagesSupplier = xDrawPages; + mxSBD = uno::Reference<document::XStorageBasedDocument>(mxDrawPagesSupplier, uno::UNO_QUERY); stopShow(); // MUST call that: results in // maUserEventQueue.clear(). What's more, @@ -1686,6 +1698,7 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty ) maActivitiesQueue, maUserEventQueue, *this, + *this, maViewContainer, mxComponentContext) ); } @@ -2332,6 +2345,37 @@ bool SlideShowImpl::handleAnimationEvent( const AnimationNodeSharedPtr& rNode ) return true; } +std::shared_ptr<avmedia::MediaTempFile> SlideShowImpl::getMediaTempFile(const OUString& aUrl) +{ + std::shared_ptr<avmedia::MediaTempFile> aRet; + + if (!mxSBD.is()) + return aRet; + + comphelper::LifecycleProxy aProxy; + uno::Reference<io::XStream> xStream = + comphelper::OStorageHelper::GetStreamAtPackageURL(mxSBD->getDocumentStorage(), aUrl, + css::embed::ElementModes::READ, aProxy); + + uno::Reference<io::XInputStream> xInStream = xStream->getInputStream(); + if (xInStream.is()) + { + sal_Int32 nLastDot = aUrl.lastIndexOf('.'); + sal_Int32 nLastSlash = aUrl.lastIndexOf('/'); + OUString sDesiredExtension; + if (nLastDot > nLastSlash && nLastDot+1 < aUrl.getLength()) + sDesiredExtension = aUrl.copy(nLastDot); + + OUString sTempUrl; + if (::avmedia::CreateMediaTempFile(xInStream, sTempUrl, sDesiredExtension)) + aRet.reset(new avmedia::MediaTempFile(sTempUrl)); + + xInStream->closeInput(); + } + + return aRet; +} + //===== FrameSynchronization ================================================== FrameSynchronization::FrameSynchronization (const double nFrameDuration) |