[Libreoffice-commits] core.git: 5 commits - avmedia/Library_avmedia.mk avmedia/source include/avmedia svx/source
Stephan Bergmann
sbergman at redhat.com
Mon Nov 18 08:02:58 PST 2013
avmedia/Library_avmedia.mk | 1
avmedia/source/framework/mediacontrol.cxx | 2
avmedia/source/framework/mediaplayer.cxx | 21 -
avmedia/source/viewer/mediaevent_impl.cxx | 2
avmedia/source/viewer/mediawindow.cxx | 36 --
avmedia/source/viewer/mediawindow_impl.cxx | 314 ++++++++++++++++++-
avmedia/source/viewer/mediawindow_impl.hxx | 66 +++-
avmedia/source/viewer/mediawindowbase_impl.cxx | 412 -------------------------
avmedia/source/viewer/mediawindowbase_impl.hxx | 121 -------
include/avmedia/mediaplayer.hxx | 26 -
include/avmedia/mediawindow.hxx | 3
svx/source/gallery2/galctrl.cxx | 4
12 files changed, 396 insertions(+), 612 deletions(-)
New commits:
commit df4adcc47a5cfad9e6562162ae6eb28a2271f344
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Nov 18 17:01:53 2013 +0100
Fix debug output
Change-Id: I785a3f223bd8897466f9402125df2da07615cd50
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx
index cb513dc..711eb48 100644
--- a/avmedia/source/viewer/mediawindow_impl.cxx
+++ b/avmedia/source/viewer/mediawindow_impl.cxx
@@ -239,8 +239,8 @@ uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString&
"failed to create media player service " << aServiceName );
} catch ( const uno::Exception &e ) {
SAL_WARN( "avmedia",
- "couldn't create media player " AVMEDIA_MANAGER_SERVICE_NAME
- ", exception '" << e.Message << '\'');
+ "couldn't create media player " << aServiceName
+ << ", exception '" << e.Message << '\'');
}
}
commit 929baba5f08a59aeaf460d7c6b76238aca6c5d67
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Nov 18 17:01:35 2013 +0100
Simplify MediaWindow::mpImpl
Change-Id: Ia466a08a8135a7f2e43278354c767be3a063550a
diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx
index 183a955..45c9901 100644
--- a/avmedia/source/viewer/mediawindow.cxx
+++ b/avmedia/source/viewer/mediawindow.cxx
@@ -52,19 +52,13 @@ MediaWindow::MediaWindow( Window* parent, bool bInternalMediaControl ) :
// -------------------------------------------------------------------------
-MediaWindow::~MediaWindow()
-{
- mpImpl->cleanUp();
- delete mpImpl;
- mpImpl = NULL;
-}
+MediaWindow::~MediaWindow() {}
// -------------------------------------------------------------------------
void MediaWindow::setURL( const OUString& rURL )
{
- if( mpImpl )
- mpImpl->setURL( rURL, OUString() );
+ mpImpl->setURL( rURL, OUString() );
}
// -------------------------------------------------------------------------
@@ -78,7 +72,7 @@ const OUString& MediaWindow::getURL() const
bool MediaWindow::isValid() const
{
- return( mpImpl != NULL && mpImpl->isValid() );
+ return mpImpl->isValid();
}
// -------------------------------------------------------------------------
@@ -148,64 +142,56 @@ Size MediaWindow::getPreferredSize() const
void MediaWindow::setPosSize( const Rectangle& rNewRect )
{
- if( mpImpl )
- {
- mpImpl->setPosSize( rNewRect );
- }
+ mpImpl->setPosSize( rNewRect );
}
// -------------------------------------------------------------------------
void MediaWindow::setPointer( const Pointer& rPointer )
{
- if( mpImpl )
- mpImpl->setPointer( rPointer );
+ mpImpl->setPointer( rPointer );
}
// -------------------------------------------------------------------------
bool MediaWindow::start()
{
- return( mpImpl != NULL && mpImpl->start() );
+ return mpImpl->start();
}
// -------------------------------------------------------------------------
void MediaWindow::updateMediaItem( MediaItem& rItem ) const
{
- if( mpImpl )
- mpImpl->updateMediaItem( rItem );
+ mpImpl->updateMediaItem( rItem );
}
// -------------------------------------------------------------------------
void MediaWindow::executeMediaItem( const MediaItem& rItem )
{
- if( mpImpl )
- mpImpl->executeMediaItem( rItem );
+ mpImpl->executeMediaItem( rItem );
}
// -------------------------------------------------------------------------
void MediaWindow::show()
{
- if( mpImpl )
- mpImpl->Show();
+ mpImpl->Show();
}
// -------------------------------------------------------------------------
void MediaWindow::hide()
{
- if( mpImpl )
- mpImpl->Hide();
+ mpImpl->Hide();
}
// -------------------------------------------------------------------------
Window* MediaWindow::getWindow() const
{
- return mpImpl;
+ return mpImpl.get();
}
// -------------------------------------------------------------------------
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx
index aa402b3..cb513dc 100644
--- a/avmedia/source/viewer/mediawindow_impl.cxx
+++ b/avmedia/source/viewer/mediawindow_impl.cxx
@@ -176,15 +176,6 @@ MediaWindowImpl::MediaWindowImpl( Window* pParent, MediaWindow* pMediaWindow, bo
MediaWindowImpl::~MediaWindowImpl()
{
- delete mpEmptyBmpEx;
- delete mpAudioBmpEx;
- delete mpMediaWindowControl;
-}
-
-// ---------------------------------------------------------------------
-
-void MediaWindowImpl::cleanUp()
-{
uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() );
mpEvents->cleanUp();
@@ -209,6 +200,10 @@ void MediaWindowImpl::cleanUp()
mxPlayer.clear();
mpMediaWindow = NULL;
+
+ delete mpEmptyBmpEx;
+ delete mpAudioBmpEx;
+ delete mpMediaWindowControl;
}
uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString& rURL )
diff --git a/avmedia/source/viewer/mediawindow_impl.hxx b/avmedia/source/viewer/mediawindow_impl.hxx
index 9c9d814..f26cd87 100644
--- a/avmedia/source/viewer/mediawindow_impl.hxx
+++ b/avmedia/source/viewer/mediawindow_impl.hxx
@@ -91,8 +91,6 @@ namespace avmedia
MediaWindowImpl( Window* parent, MediaWindow* pMediaWindow, bool bInternalMediaControl );
virtual ~MediaWindowImpl();
- void cleanUp();
-
static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const OUString& rURL );
void setURL( const OUString& rURL, OUString const& rTempURL );
diff --git a/include/avmedia/mediawindow.hxx b/include/avmedia/mediawindow.hxx
index 92bd696..74ef95d 100644
--- a/include/avmedia/mediawindow.hxx
+++ b/include/avmedia/mediawindow.hxx
@@ -22,6 +22,7 @@
#include <memory>
#include <vector>
+#include <boost/scoped_ptr.hpp>
#include <tools/gen.hxx>
#include <com/sun/star/media/ZoomLevel.hpp>
#include <com/sun/star/media/XPlayer.hpp>
@@ -118,7 +119,7 @@ namespace avmedia
AVMEDIA_DLLPRIVATE MediaWindow& operator =( const MediaWindow& );
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxIFace;
- priv::MediaWindowImpl* mpImpl;
+ boost::scoped_ptr<priv::MediaWindowImpl> mpImpl;
};
}
commit 110bbaf0443acb9a4bfbbb7c8019442a99618347
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Nov 18 16:03:05 2013 +0100
Remove bogus comment
Change-Id: I236e5f3797750f78047957c3dd9984c687ffa0ab
diff --git a/avmedia/source/viewer/mediaevent_impl.cxx b/avmedia/source/viewer/mediaevent_impl.cxx
index 3bc5247..cfe9609 100644
--- a/avmedia/source/viewer/mediaevent_impl.cxx
+++ b/avmedia/source/viewer/mediaevent_impl.cxx
@@ -25,8 +25,6 @@
using namespace ::com::sun::star;
-/* Definition of MediaWindowImpl class */
-
namespace avmedia { namespace priv {
// ---------------------------
// - MediaEventListenersImpl -
commit 6f405e15ec889c09052048b43753bb6a6210d605
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Nov 18 16:01:12 2013 +0100
Fold MediaWindowBaseImpl into MediaWindowImpl
Change-Id: Ie6366d8b1facb39a5f44279f0c49a229b019bcaa
diff --git a/avmedia/Library_avmedia.mk b/avmedia/Library_avmedia.mk
index eb87e6c..3c723f1 100644
--- a/avmedia/Library_avmedia.mk
+++ b/avmedia/Library_avmedia.mk
@@ -49,7 +49,6 @@ $(eval $(call gb_Library_add_exception_objects,avmedia,\
avmedia/source/framework/mediatoolbox \
avmedia/source/framework/soundhandler \
avmedia/source/viewer/mediaevent_impl \
- avmedia/source/viewer/mediawindowbase_impl \
avmedia/source/viewer/mediawindow \
avmedia/source/viewer/mediawindow_impl \
))
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx
index 32ad2de..aa402b3 100644
--- a/avmedia/source/viewer/mediawindow_impl.cxx
+++ b/avmedia/source/viewer/mediawindow_impl.cxx
@@ -25,11 +25,15 @@
#include <algorithm>
#include <cmath>
+
+#include <comphelper/processfactory.hxx>
#include <osl/mutex.hxx>
+#include <tools/urlobj.hxx>
#include <vcl/svapp.hxx>
#include <com/sun/star/awt/SystemPointer.hpp>
#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/media/XManager.hpp>
using namespace ::com::sun::star;
@@ -148,9 +152,9 @@ void MediaChildWindow::Command( const CommandEvent& rCEvt )
MediaWindowImpl::MediaWindowImpl( Window* pParent, MediaWindow* pMediaWindow, bool bInternalMediaControl ) :
Control( pParent ),
- MediaWindowBaseImpl( pMediaWindow ),
DropTargetHelper( this ),
DragSourceHelper( this ),
+ mpMediaWindow( pMediaWindow ),
mxEventsIf( static_cast< ::cppu::OWeakObject* >( mpEvents = new MediaEventListenersImpl( maChildWindow ) ) ),
maChildWindow( this ),
mpMediaWindowControl( bInternalMediaControl ? new MediaWindowControl( this ) : NULL ),
@@ -198,10 +202,301 @@ void MediaWindowImpl::cleanUp()
setPlayerWindow( NULL );
}
- MediaWindowBaseImpl::cleanUp();
+ uno::Reference< lang::XComponent > xComponent( mxPlayer, uno::UNO_QUERY );
+ if( xComponent.is() ) // this stops the player
+ xComponent->dispose();
+
+ mxPlayer.clear();
+
+ mpMediaWindow = NULL;
}
-// ---------------------------------------------------------------------
+uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString& rURL )
+{
+ uno::Reference< media::XPlayer > xPlayer;
+ uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
+
+ static const char * aServiceManagers[] = {
+ AVMEDIA_MANAGER_SERVICE_PREFERRED,
+ AVMEDIA_MANAGER_SERVICE_NAME,
+// a fallback path just for gstreamer which has
+// two significant versions deployed at once ...
+#ifdef AVMEDIA_MANAGER_SERVICE_NAME_OLD
+ AVMEDIA_MANAGER_SERVICE_NAME_OLD
+#endif
+ };
+
+ for( sal_uInt32 i = 0; !xPlayer.is() && i < SAL_N_ELEMENTS( aServiceManagers ); ++i )
+ {
+ const OUString aServiceName( aServiceManagers[ i ],
+ strlen( aServiceManagers[ i ] ),
+ RTL_TEXTENCODING_ASCII_US );
+
+ try {
+ uno::Reference< media::XManager > xManager (
+ xContext->getServiceManager()->createInstanceWithContext(aServiceName, xContext),
+ uno::UNO_QUERY );
+ if( xManager.is() )
+ xPlayer = uno::Reference< media::XPlayer >( xManager->createPlayer( rURL ),
+ uno::UNO_QUERY );
+ else
+ SAL_WARN( "avmedia",
+ "failed to create media player service " << aServiceName );
+ } catch ( const uno::Exception &e ) {
+ SAL_WARN( "avmedia",
+ "couldn't create media player " AVMEDIA_MANAGER_SERVICE_NAME
+ ", exception '" << e.Message << '\'');
+ }
+ }
+
+ return xPlayer;
+}
+
+void MediaWindowImpl::setURL( const OUString& rURL,
+ OUString const& rTempURL)
+{
+ if( rURL != getURL() )
+ {
+ if( mxPlayer.is() )
+ mxPlayer->stop();
+
+ if( mxPlayerWindow.is() )
+ {
+ mxPlayerWindow->setVisible( false );
+ mxPlayerWindow.clear();
+ }
+
+ mxPlayer.clear();
+ mTempFileURL = OUString();
+
+ if (!rTempURL.isEmpty())
+ {
+ maFileURL = rURL;
+ mTempFileURL = rTempURL;
+ }
+ else
+ {
+ INetURLObject aURL( rURL );
+
+ if (aURL.GetProtocol() != INET_PROT_NOT_VALID)
+ maFileURL = aURL.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS);
+ else
+ maFileURL = rURL;
+ }
+
+ mxPlayer = createPlayer(
+ (!mTempFileURL.isEmpty()) ? mTempFileURL : maFileURL );
+ onURLChanged();
+ }
+}
+
+const OUString& MediaWindowImpl::getURL() const
+{
+ return maFileURL;
+}
+
+bool MediaWindowImpl::isValid() const
+{
+ return( getPlayer().is() );
+}
+
+Size MediaWindowImpl::getPreferredSize() const
+{
+ Size aRet;
+
+ if( mxPlayer.is() )
+ {
+ awt::Size aPrefSize( mxPlayer->getPreferredPlayerWindowSize() );
+
+ aRet.Width() = aPrefSize.Width;
+ aRet.Height() = aPrefSize.Height;
+ }
+
+ return aRet;
+}
+
+bool MediaWindowImpl::start()
+{
+ return( mxPlayer.is() ? ( mxPlayer->start(), true ) : false );
+}
+
+void MediaWindowImpl::updateMediaItem( MediaItem& rItem ) const
+{
+ if( isPlaying() )
+ rItem.setState( ( getRate() > 1.0 ) ? MEDIASTATE_PLAYFFW : MEDIASTATE_PLAY );
+ else
+ rItem.setState( ( 0.0 == getMediaTime() ) ? MEDIASTATE_STOP : MEDIASTATE_PAUSE );
+
+ rItem.setDuration( getDuration() );
+ rItem.setTime( getMediaTime() );
+ rItem.setLoop( isPlaybackLoop() );
+ rItem.setMute( isMute() );
+ rItem.setVolumeDB( getVolumeDB() );
+ rItem.setZoom( getZoom() );
+ rItem.setURL( getURL(), &mTempFileURL );
+}
+
+void MediaWindowImpl::executeMediaItem( const MediaItem& rItem )
+{
+ const sal_uInt32 nMaskSet = rItem.getMaskSet();
+
+ // set URL first
+ if( nMaskSet & AVMEDIA_SETMASK_URL )
+ setURL( rItem.getURL(), rItem.getTempURL() );
+
+ // set different states next
+ if( nMaskSet & AVMEDIA_SETMASK_TIME )
+ setMediaTime( ::std::min( rItem.getTime(), getDuration() ) );
+
+ if( nMaskSet & AVMEDIA_SETMASK_LOOP )
+ setPlaybackLoop( rItem.isLoop() );
+
+ if( nMaskSet & AVMEDIA_SETMASK_MUTE )
+ setMute( rItem.isMute() );
+
+ if( nMaskSet & AVMEDIA_SETMASK_VOLUMEDB )
+ setVolumeDB( rItem.getVolumeDB() );
+
+ if( nMaskSet & AVMEDIA_SETMASK_ZOOM )
+ setZoom( rItem.getZoom() );
+
+ // set play state at last
+ if( nMaskSet & AVMEDIA_SETMASK_STATE )
+ {
+ switch( rItem.getState() )
+ {
+ case( MEDIASTATE_PLAY ):
+ case( MEDIASTATE_PLAYFFW ):
+ {
+
+ if( !isPlaying() )
+ start();
+ }
+ break;
+
+ case( MEDIASTATE_PAUSE ):
+ {
+ if( isPlaying() )
+ stop();
+ }
+ break;
+
+ case( MEDIASTATE_STOP ):
+ {
+ if( isPlaying() )
+ {
+ setMediaTime( 0.0 );
+ stop();
+ setMediaTime( 0.0 );
+ }
+ }
+ break;
+ }
+ }
+}
+
+bool MediaWindowImpl::setZoom( ::com::sun::star::media::ZoomLevel eLevel )
+{
+ return( mxPlayerWindow.is() ? mxPlayerWindow->setZoomLevel( eLevel ) : false );
+}
+
+::com::sun::star::media::ZoomLevel MediaWindowImpl::getZoom() const
+{
+ return( mxPlayerWindow.is() ? mxPlayerWindow->getZoomLevel() : media::ZoomLevel_NOT_AVAILABLE );
+}
+
+void MediaWindowImpl::stop()
+{
+ if( mxPlayer.is() )
+ mxPlayer->stop();
+}
+
+bool MediaWindowImpl::isPlaying() const
+{
+ return( mxPlayer.is() && mxPlayer->isPlaying() );
+}
+
+double MediaWindowImpl::getDuration() const
+{
+ return( mxPlayer.is() ? mxPlayer->getDuration() : 0.0 );
+}
+
+void MediaWindowImpl::setMediaTime( double fTime )
+{
+ if( mxPlayer.is() )
+ mxPlayer->setMediaTime( fTime );
+}
+
+double MediaWindowImpl::getMediaTime() const
+{
+ return( mxPlayer.is() ? mxPlayer->getMediaTime() : 0.0 );
+}
+
+double MediaWindowImpl::getRate() const
+{
+ return( mxPlayer.is() ? mxPlayer->getRate() : 0.0 );
+}
+
+void MediaWindowImpl::setPlaybackLoop( bool bSet )
+{
+ if( mxPlayer.is() )
+ mxPlayer->setPlaybackLoop( bSet );
+}
+
+bool MediaWindowImpl::isPlaybackLoop() const
+{
+ return( mxPlayer.is() ? mxPlayer->isPlaybackLoop() : false );
+}
+
+void MediaWindowImpl::setMute( bool bSet )
+{
+ if( mxPlayer.is() )
+ mxPlayer->setMute( bSet );
+}
+
+bool MediaWindowImpl::isMute() const
+{
+ return( mxPlayer.is() ? mxPlayer->isMute() : false );
+}
+
+void MediaWindowImpl::setVolumeDB( sal_Int16 nVolumeDB )
+{
+ if( mxPlayer.is() )
+ mxPlayer->setVolumeDB( nVolumeDB );
+}
+
+sal_Int16 MediaWindowImpl::getVolumeDB() const
+{
+ return( mxPlayer.is() ? mxPlayer->getVolumeDB() : 0 );
+}
+
+void MediaWindowImpl::stopPlayingInternal( bool bStop )
+{
+ if( isPlaying() )
+ {
+ bStop ? mxPlayer->stop() : mxPlayer->start();
+ }
+}
+
+MediaWindow* MediaWindowImpl::getMediaWindow() const
+{
+ return mpMediaWindow;
+}
+
+uno::Reference< media::XPlayer > MediaWindowImpl::getPlayer() const
+{
+ return mxPlayer;
+}
+
+void MediaWindowImpl::setPlayerWindow( const uno::Reference< media::XPlayerWindow >& rxPlayerWindow )
+{
+ mxPlayerWindow = rxPlayerWindow;
+}
+
+uno::Reference< media::XPlayerWindow > MediaWindowImpl::getPlayerWindow() const
+{
+ return mxPlayerWindow;
+}
void MediaWindowImpl::onURLChanged()
{
diff --git a/avmedia/source/viewer/mediawindow_impl.hxx b/avmedia/source/viewer/mediawindow_impl.hxx
index fe79317..9c9d814 100644
--- a/avmedia/source/viewer/mediawindow_impl.hxx
+++ b/avmedia/source/viewer/mediawindow_impl.hxx
@@ -23,13 +23,18 @@
#include <svtools/transfer.hxx>
#include <vcl/syschild.hxx>
-#include "mediawindowbase_impl.hxx"
#include "mediacontrol.hxx"
+namespace com { namespace sun { namespace star { namespace media {
+ class XPlayer;
+ class XPlayerWindow;
+} } } }
class BitmapEx;
namespace avmedia
{
+ class MediaWindow;
+
namespace priv
{
// ----------------------
@@ -77,7 +82,6 @@ namespace avmedia
class MediaEventListenersImpl;
class MediaWindowImpl : public Control,
- public MediaWindowBaseImpl,
public DropTargetHelper,
public DragSourceHelper
@@ -87,16 +91,28 @@ namespace avmedia
MediaWindowImpl( Window* parent, MediaWindow* pMediaWindow, bool bInternalMediaControl );
virtual ~MediaWindowImpl();
- virtual void cleanUp();
- virtual void onURLChanged();
+ void cleanUp();
- public:
+ static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const OUString& rURL );
+
+ void setURL( const OUString& rURL, OUString const& rTempURL );
+
+ const OUString& getURL() const;
+
+ bool isValid() const;
+
+ Size getPreferredSize() const;
+
+ bool start();
+
+ void updateMediaItem( MediaItem& rItem ) const;
+ void executeMediaItem( const MediaItem& rItem );
void setPosSize( const Rectangle& rRect );
void setPointer( const Pointer& rPointer );
- protected:
+ private:
// Window
virtual void MouseMove( const MouseEvent& rMEvt );
@@ -117,7 +133,45 @@ namespace avmedia
// DragSourceHelper
virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
- private:
+ bool setZoom( ::com::sun::star::media::ZoomLevel eLevel );
+ ::com::sun::star::media::ZoomLevel getZoom() const;
+
+ void stop();
+
+ bool isPlaying() const;
+
+ double getDuration() const;
+
+ void setMediaTime( double fTime );
+ double getMediaTime() const;
+
+ double getRate() const;
+
+ void setPlaybackLoop( bool bSet );
+ bool isPlaybackLoop() const;
+
+ void setMute( bool bSet );
+ bool isMute() const;
+
+ void setVolumeDB( sal_Int16 nVolumeDB );
+ sal_Int16 getVolumeDB() const;
+
+ void stopPlayingInternal( bool );
+
+ MediaWindow* getMediaWindow() const;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > getPlayer() const;
+
+ void setPlayerWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow >& rxPlayerWindow );
+ ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > getPlayerWindow() const;
+
+ void onURLChanged();
+
+ OUString maFileURL;
+ OUString mTempFileURL;
+ ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > mxPlayerWindow;
+ MediaWindow* mpMediaWindow;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxEventsIf;
MediaEventListenersImpl* mpEvents;
diff --git a/avmedia/source/viewer/mediawindowbase_impl.cxx b/avmedia/source/viewer/mediawindowbase_impl.cxx
deleted file mode 100644
index e8b4e89..0000000
--- a/avmedia/source/viewer/mediawindowbase_impl.cxx
+++ /dev/null
@@ -1,412 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "mediawindowbase_impl.hxx"
-#include <avmedia/mediaitem.hxx>
-#include "mediamisc.hxx"
-#include "mediawindow.hrc"
-#include <rtl/ustring.hxx>
-#include <tools/urlobj.hxx>
-#include <comphelper/processfactory.hxx>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/media/XManager.hpp>
-
-using namespace ::com::sun::star;
-
-namespace avmedia { namespace priv {
-
-// -----------------------
-// - MediaWindowBaseImpl -
-// -----------------------
-
-
-MediaWindowBaseImpl::MediaWindowBaseImpl( MediaWindow* pMediaWindow )
- : mpMediaWindow( pMediaWindow )
-{
-}
-
-// ---------------------------------------------------------------------
-
-MediaWindowBaseImpl::~MediaWindowBaseImpl()
-{
-}
-
-// -------------------------------------------------------------------------
-
-uno::Reference< media::XPlayer > MediaWindowBaseImpl::createPlayer( const OUString& rURL )
-{
- uno::Reference< media::XPlayer > xPlayer;
- uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
-
- static const char * aServiceManagers[] = {
- AVMEDIA_MANAGER_SERVICE_PREFERRED,
- AVMEDIA_MANAGER_SERVICE_NAME,
-// a fallback path just for gstreamer which has
-// two significant versions deployed at once ...
-#ifdef AVMEDIA_MANAGER_SERVICE_NAME_OLD
- AVMEDIA_MANAGER_SERVICE_NAME_OLD
-#endif
- };
-
- for( sal_uInt32 i = 0; !xPlayer.is() && i < SAL_N_ELEMENTS( aServiceManagers ); ++i )
- {
- const OUString aServiceName( aServiceManagers[ i ],
- strlen( aServiceManagers[ i ] ),
- RTL_TEXTENCODING_ASCII_US );
-
- try {
- uno::Reference< media::XManager > xManager (
- xContext->getServiceManager()->createInstanceWithContext(aServiceName, xContext),
- uno::UNO_QUERY );
- if( xManager.is() )
- xPlayer = uno::Reference< media::XPlayer >( xManager->createPlayer( rURL ),
- uno::UNO_QUERY );
- else
- SAL_WARN( "avmedia",
- "failed to create media player service " << aServiceName );
- } catch ( const uno::Exception &e ) {
- SAL_WARN( "avmedia",
- "couldn't create media player " AVMEDIA_MANAGER_SERVICE_NAME
- ", exception '" << e.Message << '\'');
- }
- }
-
- return xPlayer;
-}
-
-void MediaWindowBaseImpl::setURL( const OUString& rURL,
- OUString const& rTempURL)
-{
- if( rURL != getURL() )
- {
- if( mxPlayer.is() )
- mxPlayer->stop();
-
- if( mxPlayerWindow.is() )
- {
- mxPlayerWindow->setVisible( false );
- mxPlayerWindow.clear();
- }
-
- mxPlayer.clear();
- mTempFileURL = OUString();
-
- if (!rTempURL.isEmpty())
- {
- maFileURL = rURL;
- mTempFileURL = rTempURL;
- }
- else
- {
- INetURLObject aURL( rURL );
-
- if (aURL.GetProtocol() != INET_PROT_NOT_VALID)
- maFileURL = aURL.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS);
- else
- maFileURL = rURL;
- }
-
- mxPlayer = createPlayer(
- (!mTempFileURL.isEmpty()) ? mTempFileURL : maFileURL );
- onURLChanged();
- }
-}
-
-// ---------------------------------------------------------------------
-
-void MediaWindowBaseImpl::onURLChanged()
-{
-}
-
-// ---------------------------------------------------------------------
-
-const OUString& MediaWindowBaseImpl::getURL() const
-{
- return maFileURL;
-}
-
-// ---------------------------------------------------------------------
-
-bool MediaWindowBaseImpl::isValid() const
-{
- return( getPlayer().is() );
-}
-
-// ---------------------------------------------------------------------
-
-void MediaWindowBaseImpl::stopPlayingInternal( bool bStop )
-{
- if( isPlaying() )
- {
- bStop ? mxPlayer->stop() : mxPlayer->start();
- }
-}
-
-// ---------------------------------------------------------------------
-
-MediaWindow* MediaWindowBaseImpl::getMediaWindow() const
-{
- return mpMediaWindow;
-}
-
-// ---------------------------------------------------------------------
-
-uno::Reference< media::XPlayer > MediaWindowBaseImpl::getPlayer() const
-{
- return mxPlayer;
-}
-
-// ---------------------------------------------------------------------
-
-uno::Reference< media::XPlayerWindow > MediaWindowBaseImpl::getPlayerWindow() const
-{
- return mxPlayerWindow;
-}
-
-// ---------------------------------------------------------------------
-
-void MediaWindowBaseImpl::setPlayerWindow( const uno::Reference< media::XPlayerWindow >& rxPlayerWindow )
-{
- mxPlayerWindow = rxPlayerWindow;
-}
-
-// ---------------------------------------------------------------------
-
-void MediaWindowBaseImpl::cleanUp()
-{
- uno::Reference< lang::XComponent > xComponent( mxPlayer, uno::UNO_QUERY );
- if( xComponent.is() ) // this stops the player
- xComponent->dispose();
-
- mxPlayer.clear();
-
- mpMediaWindow = NULL;
-}
-
-// ---------------------------------------------------------------------
-
-Size MediaWindowBaseImpl::getPreferredSize() const
-{
- Size aRet;
-
- if( mxPlayer.is() )
- {
- awt::Size aPrefSize( mxPlayer->getPreferredPlayerWindowSize() );
-
- aRet.Width() = aPrefSize.Width;
- aRet.Height() = aPrefSize.Height;
- }
-
- return aRet;
-}
-
-// ---------------------------------------------------------------------
-
-bool MediaWindowBaseImpl::setZoom( ::com::sun::star::media::ZoomLevel eLevel )
-{
- return( mxPlayerWindow.is() ? mxPlayerWindow->setZoomLevel( eLevel ) : false );
-}
-
-// -------------------------------------------------------------------------
-
-::com::sun::star::media::ZoomLevel MediaWindowBaseImpl::getZoom() const
-{
- return( mxPlayerWindow.is() ? mxPlayerWindow->getZoomLevel() : media::ZoomLevel_NOT_AVAILABLE );
-}
-
-// ---------------------------------------------------------------------
-
-bool MediaWindowBaseImpl::start()
-{
- return( mxPlayer.is() ? ( mxPlayer->start(), true ) : false );
-}
-
-// ---------------------------------------------------------------------
-
-void MediaWindowBaseImpl::stop()
-{
- if( mxPlayer.is() )
- mxPlayer->stop();
-}
-
-// ---------------------------------------------------------------------
-
-bool MediaWindowBaseImpl::isPlaying() const
-{
- return( mxPlayer.is() && mxPlayer->isPlaying() );
-}
-
-// ---------------------------------------------------------------------
-
-double MediaWindowBaseImpl::getDuration() const
-{
- return( mxPlayer.is() ? mxPlayer->getDuration() : 0.0 );
-}
-
-// ---------------------------------------------------------------------
-
-void MediaWindowBaseImpl::setMediaTime( double fTime )
-{
- if( mxPlayer.is() )
- mxPlayer->setMediaTime( fTime );
-}
-
-// ---------------------------------------------------------------------
-
-double MediaWindowBaseImpl::getMediaTime() const
-{
- return( mxPlayer.is() ? mxPlayer->getMediaTime() : 0.0 );
-}
-
-// ---------------------------------------------------------------------
-
-double MediaWindowBaseImpl::getRate() const
-{
- return( mxPlayer.is() ? mxPlayer->getRate() : 0.0 );
-}
-
-// ---------------------------------------------------------------------
-
-void MediaWindowBaseImpl::setPlaybackLoop( bool bSet )
-{
- if( mxPlayer.is() )
- mxPlayer->setPlaybackLoop( bSet );
-}
-
-// ---------------------------------------------------------------------
-
-bool MediaWindowBaseImpl::isPlaybackLoop() const
-{
- return( mxPlayer.is() ? mxPlayer->isPlaybackLoop() : false );
-}
-
-// ---------------------------------------------------------------------
-
-void MediaWindowBaseImpl::setMute( bool bSet )
-{
- if( mxPlayer.is() )
- mxPlayer->setMute( bSet );
-}
-
-// ---------------------------------------------------------------------
-
-bool MediaWindowBaseImpl::isMute() const
-{
- return( mxPlayer.is() ? mxPlayer->isMute() : false );
-}
-
-// ---------------------------------------------------------------------
-
-void MediaWindowBaseImpl::setVolumeDB( sal_Int16 nVolumeDB )
-{
- if( mxPlayer.is() )
- mxPlayer->setVolumeDB( nVolumeDB );
-}
-
-// ---------------------------------------------------------------------
-
-sal_Int16 MediaWindowBaseImpl::getVolumeDB() const
-{
- return( mxPlayer.is() ? mxPlayer->getVolumeDB() : 0 );
-}
-
-// -------------------------------------------------------------------------
-
-void MediaWindowBaseImpl::updateMediaItem( MediaItem& rItem ) const
-{
- if( isPlaying() )
- rItem.setState( ( getRate() > 1.0 ) ? MEDIASTATE_PLAYFFW : MEDIASTATE_PLAY );
- else
- rItem.setState( ( 0.0 == getMediaTime() ) ? MEDIASTATE_STOP : MEDIASTATE_PAUSE );
-
- rItem.setDuration( getDuration() );
- rItem.setTime( getMediaTime() );
- rItem.setLoop( isPlaybackLoop() );
- rItem.setMute( isMute() );
- rItem.setVolumeDB( getVolumeDB() );
- rItem.setZoom( getZoom() );
- rItem.setURL( getURL(), &mTempFileURL );
-}
-
-// -------------------------------------------------------------------------
-
-void MediaWindowBaseImpl::executeMediaItem( const MediaItem& rItem )
-{
- const sal_uInt32 nMaskSet = rItem.getMaskSet();
-
- // set URL first
- if( nMaskSet & AVMEDIA_SETMASK_URL )
- setURL( rItem.getURL(), rItem.getTempURL() );
-
- // set different states next
- if( nMaskSet & AVMEDIA_SETMASK_TIME )
- setMediaTime( ::std::min( rItem.getTime(), getDuration() ) );
-
- if( nMaskSet & AVMEDIA_SETMASK_LOOP )
- setPlaybackLoop( rItem.isLoop() );
-
- if( nMaskSet & AVMEDIA_SETMASK_MUTE )
- setMute( rItem.isMute() );
-
- if( nMaskSet & AVMEDIA_SETMASK_VOLUMEDB )
- setVolumeDB( rItem.getVolumeDB() );
-
- if( nMaskSet & AVMEDIA_SETMASK_ZOOM )
- setZoom( rItem.getZoom() );
-
- // set play state at last
- if( nMaskSet & AVMEDIA_SETMASK_STATE )
- {
- switch( rItem.getState() )
- {
- case( MEDIASTATE_PLAY ):
- case( MEDIASTATE_PLAYFFW ):
- {
-
- if( !isPlaying() )
- start();
- }
- break;
-
- case( MEDIASTATE_PAUSE ):
- {
- if( isPlaying() )
- stop();
- }
- break;
-
- case( MEDIASTATE_STOP ):
- {
- if( isPlaying() )
- {
- setMediaTime( 0.0 );
- stop();
- setMediaTime( 0.0 );
- }
- }
- break;
- }
- }
-}
-
-} // namespace priv
-} // namespace avemdia
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/viewer/mediawindowbase_impl.hxx b/avmedia/source/viewer/mediawindowbase_impl.hxx
deleted file mode 100644
index a13136c..0000000
--- a/avmedia/source/viewer/mediawindowbase_impl.hxx
+++ /dev/null
@@ -1,121 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef AVMEDIA_MEDIAWINDOWBASE_IMPL_HXX
-#define AVMEDIA_MEDIAWINDOWBASE_IMPL_HXX
-
-#include <avmedia/mediawindow.hxx>
-
-#include <com/sun/star/media/XPlayer.hpp>
-#include <com/sun/star/media/XPlayerWindow.hpp>
-
-
-namespace avmedia
-{
- namespace priv
- {
- // --------------
- // - UpdateMode -
- // --------------
-
- enum UpdateMode
- {
- UPDATEMODE_SYNC_STATUSBAR = 0,
- UPDATEMODE_SYNC_PLAYER = 1,
- UPDATEMODE_SYNC_NONE = 2
- };
-
- // -----------------------
- // - MediaWindowBaseImpl -
- // -----------------------
-
- class MediaWindowBaseImpl
- {
- public:
-
- MediaWindowBaseImpl( MediaWindow* pMediaWindow );
- virtual ~MediaWindowBaseImpl();
-
- virtual void cleanUp();
- virtual void onURLChanged();
-
- static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const OUString& rURL );
-
- void setURL( const OUString& rURL, OUString const& rTempURL );
-
- const OUString& getURL() const;
-
- bool isValid() const;
-
- Size getPreferredSize() const;
-
- bool setZoom( ::com::sun::star::media::ZoomLevel eLevel );
- ::com::sun::star::media::ZoomLevel getZoom() const;
-
- bool start();
- void stop();
-
- bool isPlaying() const;
-
- double getDuration() const;
-
- void setMediaTime( double fTime );
- double getMediaTime() const;
-
- double getRate() const;
-
- void setPlaybackLoop( bool bSet );
- bool isPlaybackLoop() const;
-
- void setFixedAspectRatio( bool bSet );
- bool isFixedAspectRatio() const;
-
- void setMute( bool bSet );
- bool isMute() const;
-
- void setVolumeDB( sal_Int16 nVolumeDB );
- sal_Int16 getVolumeDB() const;
-
- void updateMediaItem( MediaItem& rItem ) const;
- void executeMediaItem( const MediaItem& rItem );
-
- protected:
-
- void stopPlayingInternal( bool );
-
- MediaWindow* getMediaWindow() const;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > getPlayer() const;
-
- void setPlayerWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow >& rxPlayerWindow );
- ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > getPlayerWindow() const;
-
- private:
- OUString maFileURL;
- OUString mTempFileURL;
- ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer;
- ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > mxPlayerWindow;
- MediaWindow* mpMediaWindow;
- };
- }
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit c37d7f0d50efbcf1c4ea25c54e7280b2989c35f7
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Nov 18 13:41:36 2013 +0100
avmedia::getMediaFloater clean-up
Change-Id: I76dcf42267cbb1f028d0501471b569fa6b7b91d5
diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx
index 09355e1..5d6497c 100644
--- a/avmedia/source/framework/mediacontrol.cxx
+++ b/avmedia/source/framework/mediacontrol.cxx
@@ -507,7 +507,7 @@ IMPL_LINK( MediaControl, implSelectHdl, ToolBox*, p )
case( AVMEDIA_TOOLBOXITEM_INSERT ):
{
- MediaFloater* pFloater = AVMEDIA_MEDIAWINDOW();
+ MediaFloater* pFloater = avmedia::getMediaFloater();
if( pFloater )
pFloater->dispatchCurrentURL();
diff --git a/avmedia/source/framework/mediaplayer.cxx b/avmedia/source/framework/mediaplayer.cxx
index 77570ea..e5b35d3 100644
--- a/avmedia/source/framework/mediaplayer.cxx
+++ b/avmedia/source/framework/mediaplayer.cxx
@@ -68,7 +68,6 @@ MediaFloater::MediaFloater( SfxBindings* _pBindings, SfxChildWindow* pCW, Window
SetPosSizePixel( Point( 0, 0 ), aSize );
SetMinOutputSizePixel( aSize );
SetText( OUString( AVMEDIA_RESID( AVMEDIA_STR_MEDIAPLAYER ) ) );
- implInit();
mpMediaWindow->show();
}
@@ -80,12 +79,6 @@ MediaFloater::~MediaFloater()
mpMediaWindow = NULL;
}
-// -----------------------------------------------------------------------------
-
-void MediaFloater::implInit()
-{
-}
-
// -------------------------------------------------------------------------
void MediaFloater::Resize()
@@ -136,21 +129,17 @@ void MediaFloater::setURL( const OUString& rURL, bool bPlayImmediately )
// -----------------------------------------------------------------------------
-const OUString& MediaFloater::getURL() const
-{
- static const OUString aEmptyStr;
- return( mpMediaWindow ? mpMediaWindow->getURL() : aEmptyStr );
-}
-
-// -----------------------------------------------------------------------------
-
void MediaFloater::dispatchCurrentURL()
{
SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
if( pDispatcher )
{
- const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, getURL() );
+ OUString url;
+ if (mpMediaWindow != 0) {
+ url = mpMediaWindow->getURL();
+ }
+ const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, url );
pDispatcher->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_RECORD, &aMediaURLItem, 0L );
}
}
diff --git a/include/avmedia/mediaplayer.hxx b/include/avmedia/mediaplayer.hxx
index ce10455..bd7706c 100644
--- a/include/avmedia/mediaplayer.hxx
+++ b/include/avmedia/mediaplayer.hxx
@@ -22,14 +22,9 @@
#include <sfx2/ctrlitem.hxx>
#include <sfx2/dockwin.hxx>
+#include <sfx2/viewfrm.hxx>
#include <avmedia/avmediadllapi.h>
-#define AVMEDIA_MEDIAWINDOW() \
-(static_cast< ::avmedia::MediaFloater* >( ( \
-SfxViewFrame::Current() && SfxViewFrame::Current()->GetChildWindow(::avmedia::MediaPlayer::GetChildWindowId())) ? \
-SfxViewFrame::Current()->GetChildWindow(::avmedia::MediaPlayer::GetChildWindowId())->GetWindow() : \
-NULL))
-
namespace avmedia
{
@@ -52,23 +47,30 @@ public:
~MediaFloater();
void setURL( const OUString& rURL, bool bPlayImmediately );
- const OUString& getURL() const;
void dispatchCurrentURL();
-protected:
+private:
virtual void Resize();
virtual void ToggleFloatingMode();
-private:
-
MediaWindow* mpMediaWindow;
Size maLastSize;
-
- AVMEDIA_DLLPRIVATE void implInit();
};
+inline MediaFloater * getMediaFloater() {
+ SfxViewFrame * cur = SfxViewFrame::Current();
+ if (cur != 0) {
+ SfxChildWindow * win = cur->GetChildWindow(
+ MediaPlayer::GetChildWindowId());
+ if (win != 0) {
+ return static_cast<MediaFloater *>(win->GetWindow());
+ }
+ }
+ return 0;
+}
+
}
#endif
diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx
index 4a85e5a..f600d3d 100644
--- a/svx/source/gallery2/galctrl.cxx
+++ b/svx/source/gallery2/galctrl.cxx
@@ -245,12 +245,12 @@ void GalleryPreview::PreviewMedia( const INetURLObject& rURL )
{
if( rURL.GetProtocol() != INET_PROT_NOT_VALID )
{
- ::avmedia::MediaFloater* pFloater = AVMEDIA_MEDIAWINDOW();
+ ::avmedia::MediaFloater* pFloater = avmedia::getMediaFloater();
if( !pFloater )
{
SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute( SID_AVMEDIA_PLAYER, SFX_CALLMODE_SYNCHRON );
- pFloater = AVMEDIA_MEDIAWINDOW();
+ pFloater = avmedia::getMediaFloater();
}
if( pFloater )
More information about the Libreoffice-commits
mailing list