avmedia: Implement "block untrusted referer links" feature

See f0a9ca24fd4bf79cac908bf0d6fdb8905dc504db "rhbz#887420 Implement 'block
untrusted referer links' feature" for details.  This adds some further /*TODO?*/
comments, and one known problem (marked /*TODO!*/) is that movies/sounds are not
blocked during a slideshow presentation.

Change-Id: Ib2d0c7e4f7b02c4bdec0d8a90cee5e7e1bee8325
This commit is contained in:
Stephan Bergmann 2013-11-20 14:43:45 +01:00
parent ba1c6c94fc
commit 5668e73beb
43 changed files with 183 additions and 95 deletions

View File

@ -494,11 +494,11 @@ IMPL_LINK( MediaControl, implSelectHdl, ToolBox*, p )
if (::avmedia::MediaWindow::executeMediaURLDialog(
GetParent(), aURL, 0))
{
if( !::avmedia::MediaWindow::isMediaURL( aURL, true ) )
if( !::avmedia::MediaWindow::isMediaURL( aURL, ""/*TODO?*/, true ) )
::avmedia::MediaWindow::executeFormatErrorBox( this );
else
{
aExecItem.setURL( aURL, "" );
aExecItem.setURL( aURL, "", ""/*TODO?*/ );
aExecItem.setState( MEDIASTATE_PLAY );
}
}

View File

@ -53,6 +53,7 @@ struct MediaItem::Impl
{
OUString m_URL;
OUString m_TempFileURL;
OUString m_Referer;
sal_uInt32 m_nMaskSet;
MediaState m_eState;
double m_fTime;
@ -76,6 +77,7 @@ struct MediaItem::Impl
Impl(Impl const& rOther)
: m_URL( rOther.m_URL )
, m_TempFileURL( rOther.m_TempFileURL )
, m_Referer( rOther.m_Referer )
, m_nMaskSet( rOther.m_nMaskSet )
, m_eState( rOther.m_eState )
, m_fTime( rOther.m_fTime )
@ -118,6 +120,7 @@ int MediaItem::operator==( const SfxPoolItem& rItem ) const
MediaItem const& rOther(static_cast< const MediaItem& >(rItem));
return m_pImpl->m_nMaskSet == rOther.m_pImpl->m_nMaskSet
&& m_pImpl->m_URL == rOther.m_pImpl->m_URL
&& m_pImpl->m_Referer == rOther.m_pImpl->m_Referer
&& m_pImpl->m_eState == rOther.m_pImpl->m_eState
&& m_pImpl->m_fDuration == rOther.m_pImpl->m_fDuration
&& m_pImpl->m_fTime == rOther.m_pImpl->m_fTime
@ -202,7 +205,7 @@ void MediaItem::merge( const MediaItem& rMediaItem )
const sal_uInt32 nMaskSet = rMediaItem.getMaskSet();
if( AVMEDIA_SETMASK_URL & nMaskSet )
setURL( rMediaItem.getURL(), rMediaItem.getTempURL() );
setURL( rMediaItem.getURL(), rMediaItem.getTempURL(), rMediaItem.getReferer() );
if( AVMEDIA_SETMASK_STATE & nMaskSet )
setState( rMediaItem.getState() );
@ -235,11 +238,12 @@ sal_uInt32 MediaItem::getMaskSet() const
//------------------------------------------------------------------------
void MediaItem::setURL( const OUString& rURL, const OUString& rTempURL )
void MediaItem::setURL( const OUString& rURL, const OUString& rTempURL, const OUString& rReferer )
{
m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_URL;
m_pImpl->m_URL = rURL;
m_pImpl->m_TempFileURL = rTempURL;
m_pImpl->m_Referer = rReferer;
}
//------------------------------------------------------------------------
@ -254,6 +258,11 @@ const OUString& MediaItem::getTempURL() const
return m_pImpl->m_TempFileURL;
}
const OUString& MediaItem::getReferer() const
{
return m_pImpl->m_Referer;
}
//------------------------------------------------------------------------
void MediaItem::setState( MediaState eState )

View File

@ -116,11 +116,11 @@ void MediaFloater::ToggleFloatingMode()
// -----------------------------------------------------------------------------
void MediaFloater::setURL( const OUString& rURL, bool bPlayImmediately )
void MediaFloater::setURL( const OUString& rURL, const OUString& rReferer, bool bPlayImmediately )
{
if( mpMediaWindow )
{
mpMediaWindow->setURL( rURL );
mpMediaWindow->setURL( rURL, rReferer );
if( mpMediaWindow->isValid() && bPlayImmediately )
mpMediaWindow->start();

View File

@ -264,11 +264,11 @@ void SAL_CALL SoundHandler::dispatchWithNotification(const css::util::URL&
// SAFE {
const ::osl::MutexGuard aLock( m_aLock );
utl::MediaDescriptor aDescriptor(lDescriptor);
{
//close streams otherwise on windows we can't reopen the file in the
//media player when we pass the url to directx as it'll already be open
utl::MediaDescriptor aDescriptor(lDescriptor);
css::uno::Reference< css::io::XInputStream > xInputStream =
aDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_INPUTSTREAM(),
css::uno::Reference< css::io::XInputStream >());
@ -290,7 +290,7 @@ void SAL_CALL SoundHandler::dispatchWithNotification(const css::util::URL&
try
{
m_bError = false;
m_xPlayer.set( avmedia::MediaWindow::createPlayer( aURL.Complete ), css::uno::UNO_QUERY_THROW );
m_xPlayer.set( avmedia::MediaWindow::createPlayer( aURL.Complete, aDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_REFERRER(), OUString()) ), css::uno::UNO_QUERY_THROW );
// OK- we can start async playing ...
// Count this request and initialize self-holder against dieing by uno ref count ...
m_xSelfHold = css::uno::Reference< css::uno::XInterface >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
@ -346,10 +346,11 @@ OUString SAL_CALL SoundHandler::detect( css::uno::Sequence< css::beans::Property
// Analyze given descriptor to find filename or input stream or ...
utl::MediaDescriptor aDescriptor(lDescriptor);
OUString sURL = aDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_URL(), OUString());
OUString sReferer = aDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_REFERRER(), OUString());
if (
(sURL.getLength() ) &&
(avmedia::MediaWindow::isMediaURL(sURL))
(avmedia::MediaWindow::isMediaURL(sURL, sReferer))
)
{
// If the file type is supported depends on the OS, so...

View File

@ -56,9 +56,9 @@ MediaWindow::~MediaWindow() {}
// -------------------------------------------------------------------------
void MediaWindow::setURL( const OUString& rURL )
void MediaWindow::setURL( const OUString& rURL, const OUString& rReferer )
{
mpImpl->setURL( rURL, OUString() );
mpImpl->setURL( rURL, OUString(), rReferer );
}
// -------------------------------------------------------------------------
@ -328,7 +328,7 @@ void MediaWindow::executeFormatErrorBox( Window* pParent )
// -------------------------------------------------------------------------
bool MediaWindow::isMediaURL( const OUString& rURL, bool bDeep, Size* pPreferredSizePixel )
bool MediaWindow::isMediaURL( const OUString& rURL, const OUString& rReferer, bool bDeep, Size* pPreferredSizePixel )
{
const INetURLObject aURL( rURL );
bool bRet = false;
@ -340,7 +340,8 @@ bool MediaWindow::isMediaURL( const OUString& rURL, bool bDeep, Size* pPreferred
try
{
uno::Reference< media::XPlayer > xPlayer( priv::MediaWindowImpl::createPlayer(
aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) );
aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ),
rReferer ) );
if( xPlayer.is() )
{
@ -383,18 +384,19 @@ bool MediaWindow::isMediaURL( const OUString& rURL, bool bDeep, Size* pPreferred
// -------------------------------------------------------------------------
uno::Reference< media::XPlayer > MediaWindow::createPlayer( const OUString& rURL )
uno::Reference< media::XPlayer > MediaWindow::createPlayer( const OUString& rURL, const OUString& rReferer )
{
return priv::MediaWindowImpl::createPlayer( rURL );
return priv::MediaWindowImpl::createPlayer( rURL, rReferer );
}
// -------------------------------------------------------------------------
uno::Reference< graphic::XGraphic > MediaWindow::grabFrame( const OUString& rURL,
const OUString& rReferer,
bool bAllowToCreateReplacementGraphic,
double fMediaTime )
{
uno::Reference< media::XPlayer > xPlayer( createPlayer( rURL ) );
uno::Reference< media::XPlayer > xPlayer( createPlayer( rURL, rReferer ) );
uno::Reference< graphic::XGraphic > xRet;
::std::auto_ptr< Graphic > apGraphic;

View File

@ -29,6 +29,7 @@
#include <comphelper/processfactory.hxx>
#include <osl/mutex.hxx>
#include <tools/urlobj.hxx>
#include <unotools/securityoptions.hxx>
#include <vcl/svapp.hxx>
#include <com/sun/star/awt/SystemPointer.hpp>
@ -204,9 +205,13 @@ MediaWindowImpl::~MediaWindowImpl()
delete mpMediaWindowControl;
}
uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString& rURL )
uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString& rURL, const OUString& rReferer )
{
uno::Reference< media::XPlayer > xPlayer;
if (SvtSecurityOptions().isUntrustedReferer(rReferer)) {
return xPlayer;
}
uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
static const char * aServiceManagers[] = {
@ -246,7 +251,7 @@ uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString&
}
void MediaWindowImpl::setURL( const OUString& rURL,
OUString const& rTempURL)
OUString const& rTempURL, OUString const& rReferer)
{
if( rURL != getURL() )
{
@ -278,7 +283,7 @@ void MediaWindowImpl::setURL( const OUString& rURL,
}
mxPlayer = createPlayer(
(!mTempFileURL.isEmpty()) ? mTempFileURL : maFileURL );
(!mTempFileURL.isEmpty()) ? mTempFileURL : maFileURL, rReferer );
onURLChanged();
}
}
@ -326,7 +331,7 @@ void MediaWindowImpl::updateMediaItem( MediaItem& rItem ) const
rItem.setMute( isMute() );
rItem.setVolumeDB( getVolumeDB() );
rItem.setZoom( getZoom() );
rItem.setURL( getURL(), mTempFileURL );
rItem.setURL( getURL(), mTempFileURL, ""/*TODO?*/ );
}
void MediaWindowImpl::executeMediaItem( const MediaItem& rItem )
@ -335,7 +340,7 @@ void MediaWindowImpl::executeMediaItem( const MediaItem& rItem )
// set URL first
if( nMaskSet & AVMEDIA_SETMASK_URL )
setURL( rItem.getURL(), rItem.getTempURL() );
setURL( rItem.getURL(), rItem.getTempURL(), rItem.getReferer() );
// set different states next
if( nMaskSet & AVMEDIA_SETMASK_TIME )

View File

@ -91,9 +91,9 @@ namespace avmedia
MediaWindowImpl( Window* parent, MediaWindow* pMediaWindow, bool bInternalMediaControl );
virtual ~MediaWindowImpl();
static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const OUString& rURL );
static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const OUString& rURL, const OUString& rReferer );
void setURL( const OUString& rURL, OUString const& rTempURL );
void setURL( const OUString& rURL, OUString const& rTempURL, OUString const& rReferer );
const OUString& getURL() const;

View File

@ -1109,9 +1109,9 @@ void TPGalleryThemeProperties::DoPreview()
ErrorHandler::HandleError( ERRCODE_IO_NOTEXISTSPATH );
GetParent()->EnterWait();
}
else if( ::avmedia::MediaWindow::isMediaURL( _aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) )
else if( ::avmedia::MediaWindow::isMediaURL( _aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ), "" ) )
{
xMediaPlayer = ::avmedia::MediaWindow::createPlayer( _aURL.GetMainURL( INetURLObject::NO_DECODE ) );
xMediaPlayer = ::avmedia::MediaWindow::createPlayer( _aURL.GetMainURL( INetURLObject::NO_DECODE ), "" );
if( xMediaPlayer.is() )
xMediaPlayer->start();
}

View File

@ -106,11 +106,14 @@ public:
::com::sun::star::media::ZoomLevel getZoom() const;
void setURL( const OUString& rURL,
const OUString& rTempURL);
const OUString& rTempURL,
const OUString& rReferer);
const OUString& getURL() const;
const OUString& getTempURL() const;
const OUString& getReferer() const;
private:
struct Impl;

View File

@ -46,7 +46,7 @@ public:
MediaFloater( SfxBindings* pBindings, SfxChildWindow* pCW, Window* pParent );
~MediaFloater();
void setURL( const OUString& rURL, bool bPlayImmediately );
void setURL( const OUString& rURL, const OUString& rReferer, bool bPlayImmediately );
void dispatchCurrentURL();

View File

@ -57,7 +57,7 @@ namespace avmedia
MediaWindow( Window* parent, bool bInternalMediaControl );
virtual ~MediaWindow();
void setURL( const OUString& rURL );
void setURL( const OUString& rURL, const OUString& rReferer );
const OUString& getURL() const;
bool isValid() const;
@ -101,11 +101,11 @@ namespace avmedia
static bool executeMediaURLDialog( Window* pParent,
OUString& rURL, bool *const o_pbLink );
static void executeFormatErrorBox( Window* pParent );
static bool isMediaURL( const OUString& rURL, bool bDeep = false, Size* pPreferredSizePixel = NULL );
static bool isMediaURL( const OUString& rURL, const OUString& rReferer, bool bDeep = false, Size* pPreferredSizePixel = NULL );
static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const OUString& rURL );
static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const OUString& rURL, const OUString& rReferer );
static ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > grabFrame( const OUString& rURL,
static ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > grabFrame( const OUString& rURL, const OUString& rReferer,
bool bAllowToCreateReplacementGraphic = false,
double fMediaTime = AVMEDIA_FRAMEGRABBER_DEFAULTFRAME );

View File

@ -60,7 +60,7 @@ public:
public:
void setURL( const OUString& rURL );
void setURL( const OUString& rURL, const OUString& rReferer );
const OUString& getURL() const;
void setMediaProperties( const ::avmedia::MediaItem& rState );

View File

@ -38,7 +38,7 @@ class SfxItemPool;
* Creates a StarOffice API wrapper with the given type and inventor
* Deprecated: This will be replaced with a function returning XShape.
*/
SVX_DLLPUBLIC SvxShape* CreateSvxShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt32 nInventor ) throw();
SVX_DLLPUBLIC SvxShape* CreateSvxShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt32 nInventor, OUString const & referer ) throw();
/** Returns a StarOffice API wrapper for the given SdrObject */
SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > GetXShapeForSdrObject( SdrObject* pObj ) throw ();

View File

@ -857,13 +857,16 @@ public:
class SvxMediaShape : public SvxShape
{
public:
SvxMediaShape( SdrObject* pObj ) throw();
SvxMediaShape( SdrObject* pObj, OUString const & referer ) throw();
virtual ~SvxMediaShape() throw();
protected:
// overide these for special property handling in subcasses. Return true if property is handled
virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
virtual bool getPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
private:
OUString referer_;
};
#endif

View File

@ -106,6 +106,10 @@ private:
com::sun::star::uno::Reference<com::sun::star::uno::XAggregation> GetFormatter();
void HandleCalculateEvents();
css::uno::Reference<css::uno::XInterface> create(
OUString const & aServiceSpecifier,
css::uno::Sequence<css::uno::Any> const * arguments);
OUString maBuildId;
protected:
const SfxItemPropertySet& GetPropertySet() const { return aPropSet; }

View File

@ -192,7 +192,7 @@ static void lcl_InsertMedia( const OUString& rMediaURL, bool bApi,
SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aInsertPos, aSize ) );
pObj->SetModel(pData->GetDocument()->GetDrawLayer()); // set before setURL
pObj->setURL( realURL );
pObj->setURL( realURL, ""/*TODO?*/ );
pView->InsertObjectAtView( pObj, *pPV, bApi ? SDRINSERT_DONTMARK : 0 );
}
@ -338,7 +338,7 @@ FuInsertMedia::FuInsertMedia( ScTabViewShell* pViewSh,
if( pWin )
pWin->EnterWait();
if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) )
if( !::avmedia::MediaWindow::isMediaURL( aURL, ""/*TODO?*/, true, &aPrefSize ) )
{
if( pWin )
pWin->LeaveWait();

View File

@ -1908,11 +1908,10 @@ SC_IMPL_DUMMY_PROPERTY_LISTENER( ScModelObj )
// XMultiServiceFactory
uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstance(
const OUString& aServiceSpecifier )
throw(uno::Exception, uno::RuntimeException)
css::uno::Reference<css::uno::XInterface> ScModelObj::create(
OUString const & aServiceSpecifier,
css::uno::Sequence<css::uno::Any> const * arguments)
{
SolarMutexGuard aGuard;
uno::Reference<uno::XInterface> xRet;
OUString aNameStr(aServiceSpecifier);
sal_uInt16 nType = ScServiceProvider::GetProviderType(aNameStr);
@ -1966,7 +1965,10 @@ uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstance(
try
{
xRet.set(SvxFmMSFactory::createInstance(aServiceSpecifier));
xRet = arguments == 0
? SvxFmMSFactory::createInstance(aServiceSpecifier)
: SvxFmMSFactory::createInstanceWithArguments(
aServiceSpecifier, *arguments);
// extra block to force deletion of the temporary before ScShapeObj ctor (setDelegator)
}
catch ( lang::ServiceNotRegisteredException & )
@ -1987,6 +1989,14 @@ uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstance(
return xRet;
}
uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstance(
const OUString& aServiceSpecifier )
throw(uno::Exception, uno::RuntimeException)
{
SolarMutexGuard aGuard;
return create(aServiceSpecifier, 0);
}
uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstanceWithArguments(
const OUString& ServiceSpecifier,
const uno::Sequence<uno::Any>& aArgs )
@ -1995,7 +2005,7 @@ uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstanceWithArguments
//! unterscheiden zwischen eigenen Services und denen vom Drawing-Layer?
SolarMutexGuard aGuard;
uno::Reference<uno::XInterface> xInt(createInstance(ServiceSpecifier));
uno::Reference<uno::XInterface> xInt(create(ServiceSpecifier, &aArgs));
if ( aArgs.getLength() )
{

View File

@ -88,7 +88,7 @@ void ScTabViewShell::InsertURLButton( const OUString& rName, const OUString& rUR
aAny <<= eButtonType;
xPropSet->setPropertyValue("ButtonType", aAny );
if ( ::avmedia::MediaWindow::isMediaURL( rURL ) )
if ( ::avmedia::MediaWindow::isMediaURL( rURL, ""/*TODO?*/ ) )
{
aAny <<= sal_True;
xPropSet->setPropertyValue("DispatchURLInternal", aAny );

View File

@ -588,7 +588,7 @@ sal_Bool ScViewFunc::PasteFile( const Point& rPos, const OUString& rFile, sal_Bo
OUString aStrURL = aURL.GetMainURL( INetURLObject::NO_DECODE );
// is it a media URL?
if( ::avmedia::MediaWindow::isMediaURL( aStrURL ) )
if( ::avmedia::MediaWindow::isMediaURL( aStrURL, ""/*TODO?*/ ) )
{
const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, aStrURL );
return sal_Bool( 0 != GetViewData()->GetDispatcher().Execute(

View File

@ -2667,7 +2667,7 @@ SdrObject* ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
}
SdrObject::Free( pObj ), pObj = pMediaObj; // SJ: hoping that pObj is not inserted in any list
pMediaObj->setURL( aMediaURL );
pMediaObj->setURL( aMediaURL, ""/*TODO?*/ );
}
}
}

View File

@ -1680,7 +1680,7 @@ void CustomAnimationEffectTabPage::onSoundPreview()
if( nPos >= 2 ) try
{
const OUString aSoundURL( maSoundList[ nPos-2 ] );
mxPlayer.set( avmedia::MediaWindow::createPlayer( aSoundURL ), uno::UNO_QUERY_THROW );
mxPlayer.set( avmedia::MediaWindow::createPlayer( aSoundURL, "" ), uno::UNO_QUERY_THROW );
mxPlayer->start();
}
catch( uno::Exception& )

View File

@ -139,7 +139,7 @@ IMPL_LINK_NOARG(SdFileDialog_Imp, PlayMusicHdl)
{
try
{
mxPlayer.set( avmedia::MediaWindow::createPlayer( aUrl ), css::uno::UNO_QUERY_THROW );
mxPlayer.set( avmedia::MediaWindow::createPlayer( aUrl, "" ), css::uno::UNO_QUERY_THROW );
mxPlayer->start();
maUpdateTimer.SetTimeout( 100 );
maUpdateTimer.Start();

View File

@ -692,7 +692,7 @@ void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
if( mpWindow )
mpWindow->EnterWait();
if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) )
if( !::avmedia::MediaWindow::isMediaURL( aURL, "", true, &aPrefSize ) )
{
if( mpWindow )
mpWindow->LeaveWait();

View File

@ -1266,7 +1266,7 @@ sal_Bool FuSelection::AnimateObj(SdrObject* pObj, const Point& rPos)
{
try
{
mxPlayer.set( avmedia::MediaWindow::createPlayer( pInfo->GetBookmark()), uno::UNO_QUERY_THROW );
mxPlayer.set( avmedia::MediaWindow::createPlayer( pInfo->GetBookmark(), ""/*TODO?*/), uno::UNO_QUERY_THROW );
mxPlayer->start();
}
catch( uno::Exception& )

View File

@ -87,6 +87,9 @@ private:
SdDrawDocument* mpDoc;
bool mbDisposed;
css::uno::Reference<css::uno::XInterface> create(
OUString const & aServiceSpecifier, OUString const & referer);
SdPage* InsertSdPage( sal_uInt16 nPage, sal_Bool bDuplicate = sal_False ) throw();
const sal_Bool mbImpressDoc;
@ -179,6 +182,11 @@ public:
// XMultiServiceFactory ( SvxFmMSFactory )
virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
virtual css::uno::Reference<css::uno::XInterface> SAL_CALL
createInstanceWithArguments(
OUString const & ServiceSpecifier,
css::uno::Sequence<css::uno::Any> const & Arguments)
throw (css::uno::Exception, css::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
// XServiceInfo

View File

@ -1562,7 +1562,7 @@ void SlideshowImpl::click( const Reference< XShape >& xShape, const ::com::sun::
{
try
{
mxPlayer.set(avmedia::MediaWindow::createPlayer(pEvent->maStrBookmark), uno::UNO_QUERY_THROW );
mxPlayer.set(avmedia::MediaWindow::createPlayer(pEvent->maStrBookmark, ""/*TODO?*/), uno::UNO_QUERY_THROW );
mxPlayer->start();
}
catch( uno::Exception& )

View File

@ -815,8 +815,9 @@ uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::getHandoutMast
}
// XMultiServiceFactory ( SvxFmMSFactory )
uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( const OUString& aServiceSpecifier )
throw(uno::Exception, uno::RuntimeException)
css::uno::Reference<css::uno::XInterface> SdXImpressDocument::create(
OUString const & aServiceSpecifier, OUString const & referer)
{
::SolarMutexGuard aGuard;
@ -1049,7 +1050,7 @@ uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( c
}
// create the API wrapper
pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor );
pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor, referer );
// set shape type
if( pShape && !mbClipBoard )
@ -1059,7 +1060,7 @@ uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( c
}
else if ( aServiceSpecifier == "com.sun.star.drawing.TableShape" )
{
SvxShape* pShape = CreateSvxShapeByTypeAndInventor( OBJ_TABLE, SdrInventor );
SvxShape* pShape = CreateSvxShapeByTypeAndInventor( OBJ_TABLE, SdrInventor, referer );
if( pShape && !mbClipBoard )
pShape->SetShapeType(aServiceSpecifier);
@ -1082,6 +1083,28 @@ uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( c
return xRet;
}
uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( const OUString& aServiceSpecifier )
throw(uno::Exception, uno::RuntimeException)
{
return create(aServiceSpecifier, "");
}
css::uno::Reference<css::uno::XInterface>
SdXImpressDocument::createInstanceWithArguments(
OUString const & ServiceSpecifier,
css::uno::Sequence<css::uno::Any> const & Arguments)
throw (css::uno::Exception, css::uno::RuntimeException)
{
OUString arg;
if (ServiceSpecifier == "com.sun.star.presentation.MediaShape"
&& Arguments.getLength() == 1 && (Arguments[0] >>= arg))
{
return create(ServiceSpecifier, arg);
}
return SvxFmMSFactory::createInstanceWithArguments(
ServiceSpecifier, Arguments);
}
uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getAvailableServiceNames()
throw(uno::RuntimeException)
{

View File

@ -1559,7 +1559,7 @@ void DrawViewShell::InsertURLButton(const OUString& rURL, const OUString& rText,
xPropSet->setPropertyValue("TargetFrame" , Any( rTarget ) );
xPropSet->setPropertyValue( "ButtonType" , Any( form::FormButtonType_URL ) );
if ( ::avmedia::MediaWindow::isMediaURL( rURL ) )
if ( ::avmedia::MediaWindow::isMediaURL( rURL, ""/*TODO?*/ ) )
{
xPropSet->setPropertyValue( "DispatchURLInternal" , Any( sal_True ) );
}
@ -1594,7 +1594,7 @@ void DrawViewShell::InsertURLButton(const OUString& rURL, const OUString& rText,
xPropSet->setPropertyValue( "TargetFrame" , Any( rTarget ) );
xPropSet->setPropertyValue( "ButtonType" , Any( form::FormButtonType_URL ) );
if ( ::avmedia::MediaWindow::isMediaURL( rURL ) )
if ( ::avmedia::MediaWindow::isMediaURL( rURL, ""/*TODO?*/ ) )
xPropSet->setPropertyValue( "DispatchURLInternal" , Any( sal_True ) );
Point aPos;

View File

@ -301,7 +301,7 @@ SdrMediaObj* View::InsertMediaURL( const OUString& rMediaURL, sal_Int8& rAction,
if( mnAction == DND_ACTION_LINK && pPickObj && pPV && pPickObj->ISA( SdrMediaObj ) )
{
pNewMediaObj = static_cast< SdrMediaObj* >( pPickObj->Clone() );
pNewMediaObj->setURL( realURL );
pNewMediaObj->setURL( realURL, ""/*TODO?*/ );
BegUndo(SD_RESSTR(STR_UNDO_DRAGDROP));
ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
@ -332,7 +332,12 @@ SdrMediaObj* View::InsertMediaURL( const OUString& rMediaURL, sal_Int8& rAction,
else
InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER );
pNewMediaObj->setURL( realURL );
OUString referer;
DrawDocShell * sh = GetDocSh();
if (sh != 0 && sh->HasName()) {
referer = sh->GetMedium()->GetName();
}
pNewMediaObj->setURL( realURL, referer );
if( pPickObj )
{
@ -379,7 +384,7 @@ IMPL_LINK_NOARG(View, DropInsertFileHdl)
aCurrentDropFile = aURL.GetMainURL( INetURLObject::NO_DECODE );
if( !::avmedia::MediaWindow::isMediaURL( aCurrentDropFile ) )
if( !::avmedia::MediaWindow::isMediaURL( aCurrentDropFile, ""/*TODO?*/ ) )
{
if( !rGraphicFilter.ImportGraphic( aGraphic, aURL ) )
{
@ -440,8 +445,8 @@ IMPL_LINK_NOARG(View, DropInsertFileHdl)
{
Size aPrefSize;
if( ::avmedia::MediaWindow::isMediaURL( aCurrentDropFile ) &&
::avmedia::MediaWindow::isMediaURL( aCurrentDropFile, true, &aPrefSize ) )
if( ::avmedia::MediaWindow::isMediaURL( aCurrentDropFile, ""/*TODO?*/ ) &&
::avmedia::MediaWindow::isMediaURL( aCurrentDropFile, ""/*TODO?*/, true, &aPrefSize ) )
{
if( aPrefSize.Width() && aPrefSize.Height() )
{

View File

@ -407,7 +407,7 @@ namespace slideshow
{
if( !rMediaURL.isEmpty() )
{
mxPlayer.set( avmedia::MediaWindow::createPlayer( rMediaURL ),
mxPlayer.set( avmedia::MediaWindow::createPlayer( rMediaURL, ""/*TODO!*/ ),
uno::UNO_QUERY );
}
}

View File

@ -99,7 +99,7 @@ namespace slideshow
{
const INetURLObject aURL( rSoundURL );
mxPlayer.set( avmedia::MediaWindow::createPlayer(
aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ),
aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ), ""/*TODO!*/ ),
uno::UNO_QUERY);
}
catch( uno::RuntimeException& )

View File

@ -73,7 +73,7 @@ bool GalleryPreview::SetGraphic( const INetURLObject& _aURL )
{
bool bRet = true;
Graphic aGraphic;
if( ::avmedia::MediaWindow::isMediaURL( _aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) )
if( ::avmedia::MediaWindow::isMediaURL( _aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ), "" ) )
{
aGraphic = BitmapEx( GAL_RES( RID_SVXBMP_GALLERY_MEDIA ) );
}
@ -254,7 +254,7 @@ void GalleryPreview::PreviewMedia( const INetURLObject& rURL )
}
if( pFloater )
pFloater->setURL( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ), true );
pFloater->setURL( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ), "", true );
}
}

View File

@ -1111,7 +1111,7 @@ sal_Bool GalleryTheme::InsertURL( const INetURLObject& rURL, sal_uIntPtr nInsert
else
pNewObj = (SgaObject*) new SgaObjectBmp( aGraphic, rURL, aFormat );
}
else if( ::avmedia::MediaWindow::isMediaURL( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) )
else if( ::avmedia::MediaWindow::isMediaURL( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ), ""/*TODO?*/ ) )
pNewObj = (SgaObject*) new SgaObjectSound( rURL );
if( pNewObj && InsertObject( *pNewObj, nInsertPos ) )

View File

@ -189,7 +189,7 @@ uno::Reference< graphic::XGraphic > SdrMediaObj::getSnapshot()
OUString aRealURL = m_pImpl->m_MediaProperties.getTempURL();
if( aRealURL.isEmpty() )
aRealURL = m_pImpl->m_MediaProperties.getURL();
m_pImpl->m_xCachedSnapshot = avmedia::MediaWindow::grabFrame( aRealURL, true );
m_pImpl->m_xCachedSnapshot = avmedia::MediaWindow::grabFrame( aRealURL, m_pImpl->m_MediaProperties.getReferer(), true );
}
return m_pImpl->m_xCachedSnapshot;
}
@ -242,11 +242,11 @@ void SdrMediaObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly /
// ------------------------------------------------------------------------------
void SdrMediaObj::setURL( const OUString& rURL)
void SdrMediaObj::setURL( const OUString& rURL, const OUString& rReferer )
{
::avmedia::MediaItem aURLItem;
aURLItem.setURL( rURL, "" );
aURLItem.setURL( rURL, "", rReferer );
setMediaProperties( aURLItem );
}
@ -374,24 +374,24 @@ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProper
if (bSuccess)
{
m_pImpl->m_pTempFile.reset(new MediaTempFile(tempFileURL));
m_pImpl->m_MediaProperties.setURL(url, tempFileURL);
m_pImpl->m_MediaProperties.setURL(url, tempFileURL, rNewProperties.getReferer());
}
else // this case is for Clone via operator=
{
m_pImpl->m_pTempFile.reset();
m_pImpl->m_MediaProperties.setURL("", "");
m_pImpl->m_MediaProperties.setURL("", "", "");
}
}
else
{
m_pImpl->m_MediaProperties.setURL(url,
rNewProperties.getTempURL());
rNewProperties.getTempURL(), rNewProperties.getReferer());
}
}
else
{
m_pImpl->m_pTempFile.reset();
m_pImpl->m_MediaProperties.setURL(url, "");
m_pImpl->m_MediaProperties.setURL(url, "", rNewProperties.getReferer());
}
bBroadcastChanged = true;
}

View File

@ -216,7 +216,8 @@ uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstanceWi
throw( uno::Exception, uno::RuntimeException )
{
OUString arg;
if (ServiceSpecifier == "com.sun.star.drawing.GraphicObjectShape"
if ((ServiceSpecifier == "com.sun.star.drawing.GraphicObjectShape"
|| ServiceSpecifier == "com.sun.star.drawing.MediaShape")
&& Arguments.getLength() == 1 && (Arguments[0] >>= arg))
{
return create(ServiceSpecifier, arg);
@ -508,7 +509,7 @@ uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawingModel::createInstance( c
}
// create the API wrapper
pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor );
pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor, "" );
// set shape type
if( pShape )

View File

@ -735,7 +735,7 @@ SvxShape* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt3
pRet = new SvxCustomShape( pObj );
break;
case OBJ_MEDIA:
pRet = new SvxMediaShape( pObj );
pRet = new SvxMediaShape( pObj, referer );
break;
case OBJ_TABLE:
pRet = new SvxTableShape( pObj );
@ -826,9 +826,9 @@ uno::Sequence< OUString > SAL_CALL SvxDrawPage::getSupportedServiceNames() throw
return aSeq;
}
SvxShape* CreateSvxShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt32 nInventor ) throw()
SvxShape* CreateSvxShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt32 nInventor, OUString const & referer ) throw()
{
return SvxDrawPage::CreateShapeByTypeAndInventor( nType, nInventor );
return SvxDrawPage::CreateShapeByTypeAndInventor( nType, nInventor, 0, 0, referer );
}
void SvxDrawPage::ChangeModel( SdrModel* pNewModel )

View File

@ -789,8 +789,9 @@ bool SvxFrameShape::getPropertyValueImpl( const OUString& rName, const SfxItemPr
* *
***********************************************************************/
SvxMediaShape::SvxMediaShape( SdrObject* pObj ) throw()
: SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_MEDIA), getSvxMapProvider().GetPropertySet(SVXMAP_MEDIA, SdrObject::GetGlobalDrawObjectItemPool()) )
SvxMediaShape::SvxMediaShape( SdrObject* pObj, OUString const & referer ) throw()
: SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_MEDIA), getSvxMapProvider().GetPropertySet(SVXMAP_MEDIA, SdrObject::GetGlobalDrawObjectItemPool()) ),
referer_(referer)
{
SetShapeType( OUString( "com.sun.star.drawing.MediaShape" ) );
}
@ -818,7 +819,7 @@ bool SvxMediaShape::setPropertyValueImpl( const OUString& rName, const SfxItemPr
if( rValue >>= aURL )
{
bOk = true;
aItem.setURL( aURL, "" );
aItem.setURL( aURL, "", referer_ );
}
}
break;

View File

@ -216,6 +216,10 @@ private:
void GetBodyText();
void GetNumberFormatter();
css::uno::Reference<css::uno::XInterface> create(
OUString const & rServiceName,
css::uno::Sequence<css::uno::Any> const * arguments);
// used for XRenderable implementation
SfxViewShell * GuessViewShell( /* out */ bool &rbIsSwSrcView, const css::uno::Reference< css::frame::XController > xController = css::uno::Reference< css::frame::XController >() );
SwDoc * GetRenderDoc( SfxViewShell *&rpView, const css::uno::Any& rSelection, bool bIsPDFExport );

View File

@ -2478,7 +2478,7 @@ int SwTransferable::_PasteFileName( TransferableDataHelper& rData,
aMediaURL.SetSmartURL( sFile );
const OUString aMediaURLStr( aMediaURL.GetMainURL( INetURLObject::NO_DECODE ) );
if( ::avmedia::MediaWindow::isMediaURL( aMediaURLStr ) )
if( ::avmedia::MediaWindow::isMediaURL( aMediaURLStr, ""/*TODO?*/ ) )
{
const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, aMediaURLStr );
rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(

View File

@ -86,7 +86,7 @@ bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
if( pWindow )
pWindow->EnterWait();
if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) )
if( !::avmedia::MediaWindow::isMediaURL( aURL, "", true, &aPrefSize ) )
{
if( pWindow )
pWindow->LeaveWait();
@ -138,7 +138,7 @@ bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aPos, aSize ) );
pObj->SetModel(rSh.GetDoc()->GetDrawModel()); // set before setURL
pObj->setURL( realURL );
pObj->setURL( realURL, "" );
rSh.EnterStdMode();
rSh.SwFEShell::InsertDrawObj( *pObj, aPos );
bRet = true;

View File

@ -104,7 +104,7 @@ void SwBaseShell::InsertURLButton(const OUString& rURL, const OUString& rTarget,
aTmp.setValue( &eButtonType, ::getCppuType((const form::FormButtonType*)0));
xPropSet->setPropertyValue( "ButtonType", aTmp );
if ( ::avmedia::MediaWindow::isMediaURL( rURL ) )
if ( ::avmedia::MediaWindow::isMediaURL( rURL, ""/*TODO?*/ ) )
{
// #105638# OJ
aTmp <<= sal_True;

View File

@ -1631,8 +1631,9 @@ void SwXTextDocument::InitNewDoc()
}
#define COM_SUN_STAR__DRAWING_LENGTH 13
Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName)
throw( Exception, RuntimeException )
css::uno::Reference<css::uno::XInterface> SwXTextDocument::create(
OUString const & rServiceName,
css::uno::Sequence<css::uno::Any> const * arguments)
{
SolarMutexGuard aGuard;
if(!IsValid())
@ -1715,7 +1716,10 @@ Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServic
aTmpServiceName = "com.sun.star.drawing.OLE2Shape";
}
//here search for the draw service
Reference< XInterface > xTmp = SvxFmMSFactory::createInstance(aTmpServiceName);
Reference< XInterface > xTmp = arguments == 0
? SvxFmMSFactory::createInstance(aTmpServiceName)
: SvxFmMSFactory::createInstanceWithArguments(
aTmpServiceName, *arguments);
if(bShape)
{
nIndex = COM_SUN_STAR__DRAWING_LENGTH;
@ -1735,15 +1739,18 @@ Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServic
return xRet;
}
Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName)
throw( Exception, RuntimeException )
{
return create(rServiceName, 0);
}
Reference< XInterface > SwXTextDocument::createInstanceWithArguments(
const OUString& ServiceSpecifier,
const Sequence< Any >& /*Arguments*/)
const Sequence< Any >& Arguments)
throw( Exception, RuntimeException )
{
Reference< XInterface > xInt = createInstance(ServiceSpecifier);
// The Any-Sequence is for initializing objects that are dependent
// on parameters necessarily - so far we have not.
return xInt;
return create(ServiceSpecifier, &Arguments);
}
Sequence< OUString > SwXTextDocument::getAvailableServiceNames(void)

View File

@ -494,7 +494,9 @@ void SdXMLShapeContext::AddShape(OUString const & serviceName)
{
xShape = uno::Reference< drawing::XShape >(xServiceFact->createInstance("com.sun.star.drawing.temporaryForXMLImportOLE2Shape"), uno::UNO_QUERY);
}
else if (serviceName == "com.sun.star.drawing.GraphicObjectShape")
else if (serviceName == "com.sun.star.drawing.GraphicObjectShape"
|| serviceName == "com.sun.star.drawing.MediaShape"
|| serviceName == "com.sun.star.presentation.MediaShape")
{
css::uno::Sequence<css::uno::Any> args(1);
args[0] <<= GetImport().GetDocumentBase();