Commits

Anonymous committed f4d861a

initial media file embedding

  • Participants
  • Parent commits ccdb8c8

Comments (0)

Files changed (45)

avmedia/inc/avmedia/mediawindow.hxx

 
 namespace avmedia
 {
-    typedef ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > FilterNameVector;
+	struct FilterInfo
+	{
+		::rtl::OUString msFilterName;
+		::rtl::OUString msExtensions;
+		::rtl::OUString msMimeType;
+
+		FilterInfo() {}
+		FilterInfo( const ::rtl::OUString& sFilterName, const ::rtl::OUString& sExtensions, const ::rtl::OUString& sMimeType ) : msFilterName( sFilterName ), msExtensions( sExtensions ), msMimeType( sMimeType ) {}
+		FilterInfo( const FilterInfo& r ) : msFilterName( r.msFilterName ), msExtensions( r.msExtensions ), msMimeType( r.msMimeType ) {}
+		FilterInfo( const sal_Char* psFilterName, const sal_Char* psExtensions, const sal_Char* psMimeType )
+			: msFilterName( ::rtl::OUString::createFromAscii( psFilterName ) ), msExtensions( ::rtl::OUString::createFromAscii( psExtensions ) ), msMimeType( ::rtl::OUString::createFromAscii( psMimeType ) ) {}
+	};
+
+    typedef ::std::vector< FilterInfo > FilterNameVector;
 
     class MediaItem;
 
     public:
 
         static void         getMediaFilters( FilterNameVector& rFilterNameVector );
+		static bool			getMediaFilterForURL( const ::rtl::OUString& rURL, FilterInfo& rFilterInfo );
+
         static bool         executeMediaURLDialog( Window* pParent, ::rtl::OUString& rURL, bool bInsertDialog = true );
+
+
+        static bool         executeInsertMediaURLDialog( Window* pParent, ::rtl::OUString& rURL, sal_Bool& rLink );
+        static bool         executeOpenMediaURLDialog( Window* pParent, ::rtl::OUString& rURL );
+
+
         static void         executeFormatErrorBox( Window* pParent );
         static bool         isMediaURL( const ::rtl::OUString& rURL, bool bDeep = false, Size* pPreferredSizePixel = NULL );
 
                                                                                                   double fMediaTime = AVMEDIA_FRAMEGRABBER_DEFAULTFRAME );
 
     private:
+        static bool         executeMediaURLDialogImpl( Window* pParent, ::rtl::OUString& rURL, sal_Bool& rLink, bool bInsertDialog );
 
                     // default: disabled copy/assignment
         MediaWindow(const MediaWindow&);

avmedia/source/framework/mediacontrol.cxx

 			{
 				::rtl::OUString aURL;
 			
-				 if( ::avmedia::MediaWindow::executeMediaURLDialog( GetParent(), aURL, false ) )
+				 if( ::avmedia::MediaWindow::executeOpenMediaURLDialog( GetParent(), aURL ) )
 				 {
 				 	if( !::avmedia::MediaWindow::isMediaURL( aURL, true ) )
 						::avmedia::MediaWindow::executeFormatErrorBox( this );

avmedia/source/viewer/mediawindow.cxx

 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/media/XManager.hpp>
 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
 
 #define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME_MEDIATIME 3.0
 
 
 // -------------------------------------------------------------------------
 
+static const char** GetFiltersImpl()
+{
+	static const char* aFilters[] = {   "AIF Audio",			"aif;aiff",								"audio/aiff",
+										"AU Audio",				"au",									"audio/basic",
+										"AVI",					"avi",									"video/avi",
+										"CD Audio",				"cda",									"application/x-cda",
+										"MIDI Audio",			"mid;midi;kar",							"audio/midi",
+										"MPEG Audio",			"mp2;mp3;mpa",							"audio/mpeg",
+										"MPEG Video",			"mpg;mpeg;mpv;mp4;mpe;mpa;m1v;m2v;mpe",	"video/mpeg",
+										"Ogg Audio",			"oga;ogg",								"audio/ogg",
+										"Ogg Video",			"ogv",									"video/ogg",
+										"Matroska Audio",		"mka",									"audio/x-matroska",
+										"Matroska Video",		"mkv",									"video/x-matroska",
+										"Quicktime Video",		"mov;moov",								"video/quicktime",
+										"Vivo Video",			"viv;vivo",								"video/vivo",
+										"WAVE Audio",			"wav",									"audio/wav",
+										0, };
+	return &aFilters[0];
+}
+
+
 void MediaWindow::getMediaFilters( FilterNameVector& rFilterNameVector )
 {
-    static const char* pFilters[] = {   "AIF Audio", "aif;aiff",
-                                        "AU Audio", "au",
-                                        "AVI", "avi",
-                                        "CD Audio", "cda",
-                                        "MIDI Audio", "mid;midi",
-                                        "MPEG Audio", "mp2;mp3;mpa",
-                                        "MPEG Video", "mpg;mpeg;mpv;mp4",
-                                        "Ogg bitstream", "ogg",
-                                        "Quicktime Video", "mov",
-                                        "Vivo Video", "viv",
-                                        "WAVE Audio", "wav" };
-    
-    unsigned int i;
-	for( i = 0; i < ( sizeof( pFilters ) / sizeof( char* ) ); i += 2 )
-    {
-        rFilterNameVector.push_back( ::std::make_pair< ::rtl::OUString, ::rtl::OUString >( 
-                                        ::rtl::OUString::createFromAscii( pFilters[ i ] ),
-                                        ::rtl::OUString::createFromAscii( pFilters[ i + 1 ] ) ) );
+    const char** pFilters = GetFiltersImpl();
+
+	while( *pFilters )
+	{
+        rFilterNameVector.push_back( FilterInfo( ::rtl::OUString::createFromAscii( pFilters[0] ),
+												 ::rtl::OUString::createFromAscii( pFilters[1] ),
+												 ::rtl::OUString::createFromAscii( pFilters[2] ) ) );
+		pFilters += 3;
     }
 }
 
 // -------------------------------------------------------------------------
 
-bool MediaWindow::executeMediaURLDialog( Window* /* pParent */, ::rtl::OUString& rURL, bool bInsertDialog )
+bool MediaWindow::getMediaFilterForURL( const ::rtl::OUString& rURL, FilterInfo& rFilterInfo )
 {
-    ::sfx2::FileDialogHelper        aDlg( com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
+	const INetURLObject aURL( rURL );
+	
+	String aExtension( aURL.getExtension() );
+	if( aExtension.Len() != 0 )
+	{
+		const char** pFilters = GetFiltersImpl();
+
+		while( *pFilters )
+		{
+
+			USHORT nPos = 0;
+			do
+			{
+				String sFilterExtensions( String::CreateFromAscii( pFilters[1] ) );
+				String sFilterExt = sFilterExtensions.GetToken( 0, ';', nPos );
+				if( sFilterExt.EqualsIgnoreCaseAscii( aExtension ) )
+				{
+					rFilterInfo = FilterInfo( ::rtl::OUString::createFromAscii( pFilters[0] ), sFilterExtensions, ::rtl::OUString::createFromAscii( pFilters[2]) );
+
+					return true;
+				}
+			}
+			while( nPos != STRING_NOTFOUND );
+
+			pFilters += 3;
+		}
+	}
+
+	return false;
+}
+
+// -------------------------------------------------------------------------
+
+bool MediaWindow::executeInsertMediaURLDialog( Window* pParent, ::rtl::OUString& rURL, sal_Bool& rLink )
+{
+    return executeMediaURLDialogImpl( pParent, rURL, rLink, true );
+}
+
+// -------------------------------------------------------------------------
+
+bool MediaWindow::executeOpenMediaURLDialog( Window* pParent, ::rtl::OUString& rURL )
+{
+    sal_Bool aLink = sal_True;
+    return executeMediaURLDialogImpl( pParent, rURL, aLink, false );
+}
+
+// -------------------------------------------------------------------------
+
+bool MediaWindow::executeMediaURLDialogImpl( Window* /* pParent */, ::rtl::OUString& rURL, sal_Bool& rLink, bool bInsertDialog )
+{
+    ::sfx2::FileDialogHelper        aDlg( bInsertDialog ? ui::dialogs::TemplateDescription::FILEOPEN_LINK : ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
     static const ::rtl::OUString    aWildcard( RTL_CONSTASCII_USTRINGPARAM( "*." ) );
     FilterNameVector                aFilters;
     const ::rtl::OUString           aSeparator( RTL_CONSTASCII_USTRINGPARAM( ";" ) );
             if( aAllTypes.getLength() )
                 aAllTypes += aSeparator;
         
-            ( aAllTypes += aWildcard ) += aFilters[ i ].second.getToken( 0, ';', nIndex );
+            ( aAllTypes += aWildcard ) += aFilters[ i ].msExtensions.getToken( 0, ';', nIndex );
         }
     }
     
             if( aTypes.getLength() )
                 aTypes += aSeparator;
         
-            ( aTypes += aWildcard ) += aFilters[ i ].second.getToken( 0, ';', nIndex );
+            ( aTypes += aWildcard ) += aFilters[ i ].msExtensions.getToken( 0, ';', nIndex );
         }
         
         // add single filters
-        aDlg.AddFilter( aFilters[ i ].first, aTypes );
+        aDlg.AddFilter( aFilters[ i ].msFilterName, aTypes );
     }
 
     // add filter for all types
     aDlg.AddFilter( AVMEDIA_RESID( AVMEDIA_STR_ALL_FILES ), String( RTL_CONSTASCII_USTRINGPARAM( "*.*" ) ) );
-        
+               
     if( aDlg.Execute() == ERRCODE_NONE )
     {
         const INetURLObject aURL( aDlg.GetPath() );
-        rURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+        rURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );                
+
+        if( bInsertDialog )
+        {
+            // return the link checkbox in the dialog
+            uno::Reference< ui::dialogs::XFilePickerControlAccess > xController( aDlg.GetFilePicker(), uno::UNO_QUERY);
+            if ( xController.is() )
+            {
+                xController->getValue(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0) >>= rLink;
+            }
+       }
     }
     else if( rURL.getLength() )
         rURL = ::rtl::OUString();
             {
                 for( sal_Int32 nIndex = 0; nIndex >= 0 && !bRet; )
                 {
-                    if( aExt.equalsIgnoreAsciiCase( aFilters[ i ].second.getToken( 0, ';', nIndex ) ) )
+                    if( aExt.equalsIgnoreAsciiCase( aFilters[ i ].msExtensions.getToken( 0, ';', nIndex ) ) )
                         bRet = true;
                 }
             }

avmedia/source/viewer/mediawindow.hrc

 #define AVMEDIA_BMP_EMPTYLOGO			20001
 
 #define AVMEDIA_ERR_URL					21000
+

fpicker/source/aqua/ControlHelper.cxx

         case FILESAVE_AUTOEXTENSION:
             m_bToggleVisibility[AUTOEXTENSION] = true;
             break;
+        case FILEOPEN_LINK:
+            m_bToggleVisibility[LINK] = true;
+            break;
     }
 
     createControls();

fpicker/source/aqua/SalAquaFilePicker.cxx

             m_nDialogType = NAVIGATIONSERVICES_OPEN;
             OSL_TRACE( "Template: FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE" );
             break;
+        case FILEOPEN_LINK:
+            m_nDialogType = NAVIGATIONSERVICES_OPEN;
+            OSL_TRACE( "Template: FILEOPEN_LINK" );
+            break;
         case FILEOPEN_PLAY:
             m_nDialogType = NAVIGATIONSERVICES_OPEN;
             OSL_TRACE( "Template: FILEOPEN_PLAY" );

fpicker/source/office/OfficeFilePicker.cxx

 		nBits = WB_OPEN;
         rExtraBits = SFX_EXTRA_INSERTASLINK | SFX_EXTRA_SHOWPREVIEW | SFX_EXTRA_IMAGE_TEMPLATE;
 	}
+    else if ( m_nServiceType == TemplateDescription::FILEOPEN_LINK )
+	{
+		nBits = WB_OPEN;
+        rExtraBits = SFX_EXTRA_INSERTASLINK;
+	}
     else if ( m_nServiceType == TemplateDescription::FILEOPEN_PLAY )
 	{
 		nBits = WB_OPEN;

fpicker/source/unx/gnome/SalGtkFilePicker.cxx

 			mbListVisibility[IMAGE_TEMPLATE] = true;
 			// TODO
 		        break;
+		case FILEOPEN_LINK:
+			eAction = GTK_FILE_CHOOSER_ACTION_OPEN;
+			first_button_text = GTK_STOCK_OPEN;
+			mbToggleVisibility[LINK] = true;
+			// TODO
+		        break;		        
 		case FILEOPEN_PLAY:        
 			eAction = GTK_FILE_CHOOSER_ACTION_OPEN;
 			first_button_text = GTK_STOCK_OPEN;

fpicker/source/unx/kde4/KDE4FilePicker.cxx

             addCustomControl( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE );
             break;
 
+        case FILEOPEN_LINK:
+            addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_LINK );
+            break;
+
         case FILEOPEN_PLAY:        
             addCustomControl( ExtendedFilePickerElementIds::PUSHBUTTON_PLAY );
             break;

fpicker/source/win32/filepicker/FPServiceInfo.hxx

 #define TMPL95_FILESAVE_AUTOEXT                       9000
 #define TMPL2000_FILESAVE_AUTOEXT                     9001
 
+#define TMPL95_FILEOPEN_LINK                         10000
+#define TMPL2000_FILEOPEN_LINK                       10001
+
 // the service names
 #define FILE_PICKER_SERVICE_NAME  "com.sun.star.ui.dialogs.SystemFilePicker"
 

fpicker/source/win32/filepicker/FilePicker.cxx

             winResTemplateId = TMPL95_FILEOPEN_LINK_PREVIEW_BOX_ID;
         break;
 
-    case FILEOPEN_PLAY:        
+    case FILEOPEN_LINK:
+        if ( bIsWin2000 )
+            winResTemplateId = TMPL2000_FILEOPEN_LINK;
+        else
+            winResTemplateId = TMPL95_FILEOPEN_LINK;
+        break;
+
+   case FILEOPEN_PLAY:        
         if ( bIsWin2000 )
             winResTemplateId = TMPL2000_PLAY_PUSHBUTTON;
         else

fpicker/source/win32/filepicker/Fps.rc

     LTEXT           "",1119,0,0,277,38
 END
 
+10000 DIALOG DISCARDABLE  0, 0, 196, 29
+STYLE DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS
+FONT 8, "Andale Sans UI"
+BEGIN
+    CONTROL         "Als Link einf�gen",104,"Button",BS_AUTOCHECKBOX | 
+                    WS_TABSTOP,0,16,196,10
+    LTEXT           "",1119,0,0,196,16
+END
+
+10001 DIALOG DISCARDABLE  0, 0, 278, 54
+STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS
+FONT 8, "MS Shell Dlg"
+BEGIN
+    CONTROL         "Als Link einf�gen",104,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,130,38,144,14
+    LTEXT           "",1119,0,0,277,38
+END
 
 /////////////////////////////////////////////////////////////////////////////
 //

fpicker/source/win32/filepicker/VistaFilePicker.cxx

             nFeatures        |= FEATURE_IMAGETEMPLATE;
         }
         break;
+
+        case css::ui::dialogs::TemplateDescription::FILEOPEN_LINK :
+        {
+            bFileOpenDialog  = sal_True;
+            nFeatures        |= FEATURE_LINK;
+        }
+        break;
     
         case css::ui::dialogs::TemplateDescription::FILEOPEN_PLAY :
         {

fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx

 }
 
 //-----------------------------------------------------------------------------------------
-STDMETHODIMP VistaFilePickerEventHandler::OnFolderChanging(IFileDialog* pDialog,
-                                                           IShellItem*  pFolder)
+STDMETHODIMP VistaFilePickerEventHandler::OnFolderChanging(IFileDialog* /*pDialog*/,
+                                                           IShellItem*  /*pFolder*/)
 {
     return E_NOTIMPL;
 }
 
 //-----------------------------------------------------------------------------------------
-STDMETHODIMP VistaFilePickerEventHandler::OnFolderChange(IFileDialog* pDialog)
+STDMETHODIMP VistaFilePickerEventHandler::OnFolderChange(IFileDialog* /*pDialog*/)
 {
     impl_sendEvent(E_DIRECTORY_CHANGED, 0);
     return S_OK;
 }
 
 //-----------------------------------------------------------------------------------------
-STDMETHODIMP VistaFilePickerEventHandler::OnSelectionChange(IFileDialog* pDialog)
+STDMETHODIMP VistaFilePickerEventHandler::OnSelectionChange(IFileDialog* /*pDialog*/)
 {
     impl_sendEvent(E_FILE_SELECTION_CHANGED, 0);
     //lcl_updateVersionListDirectly(pDialog);
 }
 
 //-----------------------------------------------------------------------------------------
-STDMETHODIMP VistaFilePickerEventHandler::OnShareViolation(IFileDialog*                 pDialog  ,
-                                                           IShellItem*                  pItem    ,
-                                                           FDE_SHAREVIOLATION_RESPONSE* pResponse)
+STDMETHODIMP VistaFilePickerEventHandler::OnShareViolation(IFileDialog*                 /*pDialog*/  ,
+                                                           IShellItem*                  /*pItem*/    ,
+                                                           FDE_SHAREVIOLATION_RESPONSE* /*pResponse*/)
 {
     impl_sendEvent(E_CONTROL_STATE_CHANGED, css::ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER);
     return S_OK;
 }
 
 //-----------------------------------------------------------------------------------------
-STDMETHODIMP VistaFilePickerEventHandler::OnTypeChange(IFileDialog* pDialog)
+STDMETHODIMP VistaFilePickerEventHandler::OnTypeChange(IFileDialog* /*pDialog*/)
 {
 	/*
 	IFileDialogCustomize               *iCustomize;
 }
 
 //-----------------------------------------------------------------------------------------
-STDMETHODIMP VistaFilePickerEventHandler::OnOverwrite(IFileDialog*            pDialog  ,
-                                                      IShellItem*             pItem    ,
-                                                      FDE_OVERWRITE_RESPONSE* pResponse)
+STDMETHODIMP VistaFilePickerEventHandler::OnOverwrite(IFileDialog*            /*pDialog*/  ,
+                                                      IShellItem*             /*pItem*/    ,
+                                                      FDE_OVERWRITE_RESPONSE* /*pResponse*/)
 {
     return E_NOTIMPL;
 }
 
 //-----------------------------------------------------------------------------------------
-STDMETHODIMP VistaFilePickerEventHandler::OnItemSelected(IFileDialogCustomize* pCustomize,
+STDMETHODIMP VistaFilePickerEventHandler::OnItemSelected(IFileDialogCustomize* /*pCustomize*/,
                                                          DWORD                 nIDCtl    ,
-                                                         DWORD                 nIDItem   )
+                                                         DWORD                 /*nIDItem*/   )
 {
-    impl_sendEvent(E_CONTROL_STATE_CHANGED, nIDCtl);
+    impl_sendEvent(E_CONTROL_STATE_CHANGED, static_cast<sal_Int16>(nIDCtl));
     return S_OK;
 }
 
 //-----------------------------------------------------------------------------------------
-STDMETHODIMP VistaFilePickerEventHandler::OnButtonClicked(IFileDialogCustomize* pCustomize,
+STDMETHODIMP VistaFilePickerEventHandler::OnButtonClicked(IFileDialogCustomize* /*pCustomize*/,
                                                           DWORD                 nIDCtl    )
 {
-    impl_sendEvent(E_CONTROL_STATE_CHANGED, nIDCtl);
+    impl_sendEvent(E_CONTROL_STATE_CHANGED, static_cast<sal_Int16>(nIDCtl));
     return S_OK;
 }
 
 //-----------------------------------------------------------------------------------------
-STDMETHODIMP VistaFilePickerEventHandler::OnCheckButtonToggled(IFileDialogCustomize* pCustomize,
+STDMETHODIMP VistaFilePickerEventHandler::OnCheckButtonToggled(IFileDialogCustomize* /*pCustomize*/,
                                                                DWORD                 nIDCtl    ,
                                                                BOOL                  bChecked  )
 {
 	if (nIDCtl == css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION)
 		m_pInternalNotify->onAutoExtensionChanged(bChecked);
 
-    impl_sendEvent(E_CONTROL_STATE_CHANGED, nIDCtl);
+    impl_sendEvent(E_CONTROL_STATE_CHANGED, static_cast<sal_Int16>(nIDCtl));
     return S_OK;
 }
 
 //-----------------------------------------------------------------------------------------
-STDMETHODIMP VistaFilePickerEventHandler::OnControlActivating(IFileDialogCustomize* pCustomize,
+STDMETHODIMP VistaFilePickerEventHandler::OnControlActivating(IFileDialogCustomize* /*pCustomize*/,
                                                               DWORD                 nIDCtl    )
 {
-    impl_sendEvent(E_CONTROL_STATE_CHANGED, nIDCtl);
+    impl_sendEvent(E_CONTROL_STATE_CHANGED, static_cast<sal_Int16>(nIDCtl));
     return S_OK;
 }
 

fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx

         case css::ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE :
 			aGUID = CLIENTID_FILEOPEN_LINK_TEMPLATE;
 			break;
+
+        case css::ui::dialogs::TemplateDescription::FILEOPEN_LINK :
+			aGUID = CLIENTID_FILEOPEN_LINK;
+			break;
     
         case css::ui::dialogs::TemplateDescription::FILEOPEN_PLAY :
 			aGUID = CLIENTID_FILEOPEN_PLAY;

offapi/com/sun/star/ui/dialogs/TemplateDescription.idl

 	*/
 	const short FILESAVE_AUTOEXTENSION			               = 10;
 
+	//---------------------------------------------------------------------
+	/** A FileOpen dialog with additional controls.
+		<ul>
+			<li>A checkbox "Insert as link"
+		</ul>
+	*/
+	const short FILEOPEN_LINK                                  = 11;
+
 };	
 
 //=============================================================================

sd/source/core/drawdoc.cxx

 #endif
 #include <svtools/lingucfg.hxx>
 #include <svtools/linguprops.hxx>
+#include <svx/sdr/media/mediamanager.hxx>
 
 #include "eetext.hxx"
 #include "drawdoc.hxx"
 	if (mpDocSh)
 	{
 		SetSwapGraphics(TRUE);
+
+		rtl::Reference< sdr::media::MediaManager > xMediaManager( new sdr::media::MediaManager( mpDocSh ) );
+		SetMediaManager( xMediaManager );
 	}
 
 	// Masseinheit (von App) und Massstab (von SdMod) setzen

sd/source/ui/func/fuinsert.cxx

 void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
 {
 	::rtl::OUString 	aURL;
+	sal_Bool            bLinked = sal_False;
 	const SfxItemSet*	pReqArgs = rReq.GetArgs();
 	bool				bAPI = false;
 
 			aURL = pStringItem->GetValue();
 			bAPI = aURL.getLength();
 		}
+		
+		const SfxBoolItem* pBoolItem = dynamic_cast< const SfxBoolItem* >( &pReqArgs->Get( FN_PARAM_1 ) );
+		if( pBoolItem )
+		{
+		    bLinked = pBoolItem->GetValue() ? sal_True : sal_False;
+		}
 	}
 
-	if( bAPI || ::avmedia::MediaWindow::executeMediaURLDialog( mpWindow, aURL ) )
+	if( bAPI || ::avmedia::MediaWindow::executeInsertMediaURLDialog( mpWindow, aURL, bLinked ) )
 	{
 		Size aPrefSize;
 
 		{
 			Point	    aPos;
 			Size	    aSize;
-			sal_Int8    nAction = DND_ACTION_COPY;
+			sal_Int8    nAction = bLinked ? DND_ACTION_LINK : DND_ACTION_COPY;
 
 			if( aPrefSize.Width() && aPrefSize.Height() )
 			{

sd/source/ui/view/sdview4.cxx

 #ifndef _IMPGRF_HXX
 #include <svx/impgrf.hxx>
 #endif
+
 #include <sot/storage.hxx>
 #include <sfx2/app.hxx>
 #include <avmedia/mediawindow.hxx>
 			pPV = 0L;
 	}
 
-	if( !pPickObj && pPV )
-	{
-		SdrPageView* pPageView = pPV;
-		PickObj(rPos, getHitTolLog(), pPickObj, pPageView);
-	}
+    if( pPV )
+    {
+    
+	    if( !pPickObj )
+	    {
+		    SdrPageView* pPageView = pPV;
+		    PickObj(rPos, getHitTolLog(), pPickObj, pPageView);
+	    }
 
-	if( mnAction == DND_ACTION_LINK && pPickObj && pPV && pPickObj->ISA( SdrMediaObj ) )
-	{
-		pNewMediaObj = static_cast< SdrMediaObj* >( pPickObj->Clone() );
-		pNewMediaObj->setURL( rMediaURL );
+	    if( (mnAction == DND_ACTION_LINK) && pPickObj && pPickObj->ISA( SdrMediaObj ) )
+	    {
+		    pNewMediaObj = static_cast< SdrMediaObj* >( pPickObj->Clone() );
+		    pNewMediaObj->setURL( rMediaURL );
 
-    	BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
-		ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
-		EndUndo();
-	}
-	else if( pPV )
-	{
-    	pNewMediaObj = new SdrMediaObj( Rectangle( rPos, rSize ) );
-				
-		if( pPV && InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER ) )
-		    pNewMediaObj->setURL( rMediaURL );
+    	    BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
+		    ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
+		    EndUndo();
+	    }
+	    else
+	    {
+    	    pNewMediaObj = new SdrMediaObj( Rectangle( rPos, rSize ) );
+    				
+		    if( InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER ) )
+		        pNewMediaObj->setURL( rMediaURL );
+	    }
+
+		if( pNewMediaObj && (mnAction != DND_ACTION_LINK) )
+		{
+			// embed av target
+			pNewMediaObj->breakLink();
+		}
 	}
 
 	rAction = mnAction;

sfx2/inc/sfx2/lnkbase.hxx

 #define	OBJECT_CLIENT_FILE			0x90
 #define	OBJECT_CLIENT_GRF			0x91
 #define	OBJECT_CLIENT_OLE			0x92 // embedded link
+#define	OBJECT_CLIENT_AVMEDIA		0x93 // audio/video link
 
 enum sfxlink {
 	// Ole2 compatibel und persistent
 ]
 
 //--------------------------------------------------------------------------
-SfxVoidItem ImportDialog SID_IMPORT_DIALOG
-()
-[
-	/* flags: */
-	AutoUpdate = FALSE,
-	Cachable = Cachable,
-	FastCall = FALSE,
-	HasCoreId = FALSE,
-	HasDialog = FALSE,
-	ReadOnlyDoc = TRUE,
-	Toggle = FALSE,
-	Container = TRUE,
-	RecordAbsolute = FALSE,
-	RecordPerSet;
-	Asynchron;
-
-	/* config: */
-	AccelConfig = TRUE,
-	MenuConfig = TRUE,
-	StatusBarConfig = FALSE,
-	ToolBoxConfig = TRUE,
-	GroupId = GID_DOCUMENT;
-]
-
-//--------------------------------------------------------------------------
+SfxVoidItem ImportDialog SID_IMPORT_DIALOG
+()
+[
+	/* flags: */
+	AutoUpdate = FALSE,
+	Cachable = Cachable,
+	FastCall = FALSE,
+	HasCoreId = FALSE,
+	HasDialog = FALSE,
+	ReadOnlyDoc = TRUE,
+	Toggle = FALSE,
+	Container = TRUE,
+	RecordAbsolute = FALSE,
+	RecordPerSet;
+	Asynchron;
+
+	/* config: */
+	AccelConfig = TRUE,
+	MenuConfig = TRUE,
+	StatusBarConfig = FALSE,
+	ToolBoxConfig = TRUE,
+	GroupId = GID_DOCUMENT;
+]
+
+//--------------------------------------------------------------------------
 SfxVoidItem SaveConfiguration SID_SAVECONFIG
 (SfxStringItem FileName SID_CFGFILE)
 [
 ]
 
 SfxStringItem InsertAVMedia SID_INSERT_AVMEDIA
-()
+(SfxStringItem URL SID_INSERT_AVMEDIA,SfxBoolItem AsLink FN_PARAM_1)
 [
 	/* flags: */
 	AutoUpdate = FALSE,

sfx2/source/dialog/filedlghelper.cxx

 	mbPwdCheckBoxState		= sal_False;
 	mbSelection				= sal_False;
 	mbSelectionEnabled		= sal_True;
-
+    
+    bool bAddGraphicFilter  = false;
+   
 	// default settings
     m_nDontFlags = SFX_FILTER_INTERNAL | SFX_FILTER_NOTINFILEDLG | SFX_FILTER_NOTINSTALLED;
 	if( WB_OPEN == ( nFlags & WB_OPEN ) )
 				nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE;
 				mbHasPreview = sal_True;
 				mbHasLink = sal_True;
+				bAddGraphicFilter = true;
 
 				// aPreviewTimer
 				maPreViewTimer.SetTimeout( 500 );
 				nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW;
 				mbHasPreview = sal_True;
 				mbHasLink = sal_True;
+				bAddGraphicFilter = true;
 				// aPreviewTimer
 				maPreViewTimer.SetTimeout( 500 );
 				maPreViewTimer.SetTimeoutHdl( LINK( this, FileDialogHelper_Impl, TimeOutHdl_Impl ) );
-				break;
+				break;				
 
 			case FILESAVE_AUTOEXTENSION:
 				nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION;
 				mbIsSaveDlg = sal_True;
 				break;
 
+            case FILEOPEN_LINK:
+				nTemplateDescription = TemplateDescription::FILEOPEN_LINK;
+				mbHasLink = sal_True;
+				break;
+                
 			default:
 				DBG_ERRORFILE( "FileDialogHelper::ctor with unknown type" );
 				break;
 	if ( nFlags & SFXWB_MULTISELECTION )
 		mxFileDlg->setMultiSelectionMode( sal_True );
 
-	if ( mbHasLink )		// generate graphic filter only on demand
+	if ( bAddGraphicFilter )		// generate graphic filter only on demand
 		addGraphicFilter();
 
 	// Export dialog

sot/inc/sot/formats.hxx

 #define SOT_FORMATSTR_ID_STARMATH_8_TEMPLATE    ((ULONG)138)
 #define SOT_FORMATSTR_ID_STARBASE_8             ((ULONG)139)
 #define SOT_FORMATSTR_ID_HC_GDIMETAFILE         ((ULONG)140)
-#define SOT_FORMATSTR_ID_USER_END               SOT_FORMATSTR_ID_HC_GDIMETAFILE
+#define SOT_FORMATSTR_ID_AVMEDIA		        ((ULONG)141)
+#define SOT_FORMATSTR_ID_USER_END               SOT_FORMATSTR_ID_AVMEDIA
 
 #endif // _SOT_FORMATS_HXX
 

sot/source/base/exchange.cxx

             /*138 SOT_FORMATSTR_ID_STARMATH_8_TEMPLATE*/            { MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_TEMPLATE_ASCII, "Math 8 Template", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
             /*139 SOT_FORMATSTR_ID_STARBASE_8*/            { MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII, "StarBase 8", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
             /*140 SOT_FORMAT_GDIMETAFILE*/					{ "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"", "High Contrast GDIMetaFile", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
+			/*141 SOT_FORMAT_AVMEDIA*/						{ "application/vnd.sun.star.media", "Audio/Video", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) }
             };
 	    return &aInstance[0];
         }

svx/inc/svx/dialogs.hrc

 #define RID_SVXSTR_EVENT_FIELDMERGE							(RID_SVX_START + 1187)
 #define RID_SVXSTR_EVENT_FIELDMERGE_FINISHED				(RID_SVX_START + 1188)
 #define RID_SVXSTR_EVENT_LAYOUT_FINISHED					(RID_SVX_START + 1189)
-    // if you add here, remember to adjust RID_SVXSTR_NEXTFREE
+    
+#define RID_SVXSTR_AVMEDIALINK								(RID_SVX_START + 1190)
 
-#define RID_SVXSTR_NEXTFREE                                 (RID_SVX_START + 1190)
+// if you add here, remember to adjust RID_SVXSTR_NEXTFREE
+// DANGER: IF THERE IS A CONFLICT, PLEASER LOOK FOR DUPLICATE IDS AND RESOLVE THEM!
+#define RID_SVXSTR_NEXTFREE                                 (RID_SVX_START + 1191)
 
 // ----------------------------------------------------------------------------
 // if we have _a_lot_ time, we should group the resource ids by type, instead

svx/inc/svx/sdr/media/medialink.hxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: animationstate.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SDR_MEDIA_MEDIALINK_HXX
+#define _SDR_MEDIA_MEDIALINK_HXX
+
+#include <sal/types.h>
+#include <rtl/ref.hxx>
+#include <comphelper/weak.hxx>
+#include "svx/svxdllapi.h"
+
+//////////////////////////////////////////////////////////////////////////////
+// predeclarations
+
+namespace sdr {	namespace media {
+
+class MediaManager;
+
+class SVX_DLLPUBLIC MediaLink : public ::cppu::OWeakObject
+{
+public:
+    MediaLink( const rtl::Reference< MediaManager >& xManager, const rtl::OUString& rURL, bool bLinked );
+    ~MediaLink();
+
+    rtl::OUString getMediaURL() const { return msURL; }
+    rtl::OUString getTempFileURL() const { return msTempFileURL; }
+    rtl::OUString getOrCreateTempFileURL();
+    
+	rtl::OUString getMimeType() const { return msMimeType; }
+	rtl::OUString getFilterName() const { return msFilterName; }
+
+    bool isLinked() const { return mbLinked; }
+
+	MediaManager* getMediaManager() const { return mpManager; }
+
+private:
+	MediaManager* mpManager;
+    bool mbLinked;
+    rtl::OUString msURL;
+    rtl::OUString msTempFileURL;
+	rtl::OUString msMimeType;
+	rtl::OUString msFilterName;
+};
+
+typedef rtl::Reference< MediaLink > MediaLinkRef;
+
+} // end of namespace animation
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif //_SDR_MEDIA_MEDIALINK_HXX
+
+// eof

svx/inc/svx/sdr/media/mediamanager.hxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: animationstate.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SDR_MEDIA_MEDIAMANAGER_HXX
+#define _SDR_MEDIA_MEDIAMANAGER_HXX
+
+#include <hash_map>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <comphelper/weak.hxx>
+#include <svtools/lstner.hxx>
+#include <svx/sdr/media/medialink.hxx>
+
+class SfxObjectShell;
+
+//////////////////////////////////////////////////////////////////////////////
+// predeclarations
+
+namespace sdr {	namespace media	{
+
+typedef std::hash_map< ::rtl::OUString, MediaLinkRef, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > MediaLinkMap;
+
+class SVX_DLLPUBLIC MediaManager : public ::cppu::OWeakObject, public SfxListener
+{
+    friend class MediaLink;
+public:
+    MediaManager( SfxObjectShell* pObjectShell );
+    virtual ~MediaManager();
+    
+    void Dispose();
+    
+    MediaLinkRef    insertMediaStream( const rtl::OUString& rURL );
+    
+    MediaLinkRef    getMediaLink( const rtl::OUString& rURL );
+    
+	virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+private:
+	void SwitchPersistance(const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
+
+	void freeMediaLink( const MediaLinkRef& xLink );
+    
+    rtl::OUString createTemporaryCopy( const rtl::OUString& rURL );
+    
+	const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& getDocumentStorage();
+	com::sun::star::uno::Reference < com::sun::star::embed::XStorage > getMediaStorage();
+private:
+	SfxObjectShell* mpObjectShell;
+    MediaLinkMap maMediaLinkMap;
+    const rtl::OUString msPackagePrefix;
+	const rtl::OUString msMedia;
+	const rtl::OUString msMediaType;
+	const rtl::OUString msStorageMediaType;
+	com::sun::star::uno::Reference < com::sun::star::embed::XStorage > mxDocumentStorage;
+};
+
+	} // end of namespace animation
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif //_SDR_MEDIA_MEDIAMANAGER_HXX
+
+// eof

svx/inc/svx/svdmodel.hxx

 #include "svx/svxdllapi.h"
 
 #include <vos/ref.hxx>
+#include <rtl/ref.hxx>
 
 #if defined(UNX) || defined(WIN) || defined(WNT)
 #define DEGREE_CHAR ((sal_Unicode)176)   /* 0xB0 = Ansi */
 namespace comphelper{
     class IEmbeddedHelper;
 }
+
+namespace sdr { namespace media {
+    class MediaManager;
+} }
+
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
 #define SDR_SWAPGRAPHICSMODE_NONE		0x00000000
 
 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoModel();
 
+    void SetMediaManager( const rtl::Reference< sdr::media::MediaManager >& xManager );
+    
 private:
 	// Nicht implementiert:
 	SVX_DLLPRIVATE SdrModel(const SdrModel& rSrcModel);
 		also during the runtime of the Undo() and Redo() methods. */
 	bool IsUndoEnabled() const;
 
+    rtl::Reference< sdr::media::MediaManager > GetMediaManager();
 };
 
 typedef tools::WeakReference< SdrModel > SdrModelWeakRef;

svx/inc/svx/svdomedia.hxx

 #include <svx/svdorect.hxx>
 #include <avmedia/mediaitem.hxx>
 #include "svx/svxdllapi.h"
+#include "svx/sdr/media/medialink.hxx"
 
 class Graphic;
+class SdrMediaLink;
 
 namespace sdr { namespace contact { class ViewContactOfSdrMediaObj; } }
 
 class SVX_DLLPUBLIC SdrMediaObj : public SdrRectObj
 {
 	friend class ::sdr::contact::ViewContactOfSdrMediaObj;
+	friend class SdrMediaLink;
 
 public:
 
 
 		virtual void 				operator=(const SdrObject& rObj);
 
+		// embeds the av link
+		void						breakLink();
 public:
+        void                        setMediaLink( const ::rtl::Reference< sdr::media::MediaLink >& xMediaLink );        
+        const ::rtl::Reference< sdr::media::MediaLink >& getMediaLink() const { return mxMediaLink; }
 
+        /* deprecated, use media link above */
 		void						setURL( const ::rtl::OUString& rURL );
 		const ::rtl::OUString&		getURL() const;
 
         const Graphic&              getGraphic() const;
         void                        setGraphic( const Graphic* pGraphic = NULL );
 
+		virtual void				SetPage(SdrPage* pNewPage);
+		virtual void				SetModel(SdrModel* pNewModel);
+
 protected:
 
 		virtual void				mediaPropertiesChanged( const ::avmedia::MediaItem& rNewState );
 
+		virtual void				connect();
+		virtual void				disconnect();
+
 private:
+		// used by SdrMediaLink if link is changed
+		void UpdateURL( const ::rtl::OUString& rURL );
 
 		virtual ::sdr::contact::ViewContact* CreateObjectSpecificViewContact();
 
 		::avmedia::MediaItem		maMediaProperties;
         ::std::auto_ptr< Graphic >  mapGraphic;
+        ::rtl::Reference< sdr::media::MediaLink > mxMediaLink;
+		SdrMediaLink*				mpSdrMediaLink;
 };
 
 #endif //_SVDOMEDIA_HXX

svx/prj/build.lst

 sx	svx\source\sdr\contact					nmake	-	all	sx_contact sx_inc NULL
 sx	svx\source\sdr\event					nmake	-	all	sx_event sx_inc NULL
 sx	svx\source\sdr\animation				nmake	-	all	sx_animation sx_inc NULL
+sx	svx\source\sdr\media					nmake	-	all	sx_media sx_inc NULL
 sx	svx\source\sdr\overlay					nmake	-	all	sx_overlay sx_inc NULL
 sx	svx\source\smarttags					nmake	-	all	sx_smarttags sx_inc NULL
 sx	svx\source\stbctrls						nmake	-	all	sx_stbc sx_inc NULL
 sx	svx\source\customshapes					nmake	-	all sx_customshapes sx_inc NULL
 sx	svx\source\toolbars						nmake	-	all sx_toolbars sx_inc NULL
 sx      svx\source\cui                                                  nmake   -       all     sx_cui sx_inc NULL
-sx      svx\util                                                                nmake   -       all     sx_util sx_cui sx_3deng sx_dlg sx_draw sx_attribute sx_properties sx_contact sx_event sx_animation sx_primitive2d sx_primitive3d sx_overlay sx_eeng sx_fmcmp sx_form sx_gall sx_items sx_link sx_mnuc sx_msfilt sx_opt sx_outl sx_rtf sx_sdi sx_stbc sx_tbxc sx_undrw sx_unedt sx_ungal sx_xml sx_xout sx_accessibility sx_intro sx_customshapes sx_toolbars sx_table sx_smarttags NULL
+sx      svx\util                                                                nmake   -       all     sx_util sx_cui sx_3deng sx_dlg sx_draw sx_attribute sx_properties sx_contact sx_event sx_animation sx_primitive2d sx_primitive3d sx_overlay sx_eeng sx_fmcmp sx_form sx_gall sx_items sx_link sx_mnuc sx_msfilt sx_opt sx_outl sx_rtf sx_sdi sx_stbc sx_tbxc sx_undrw sx_unedt sx_ungal sx_xml sx_xout sx_accessibility sx_intro sx_customshapes sx_toolbars sx_table sx_smarttags sx_media NULL
 sx	svx\source\gengal						nmake	-	all	sx_gengal sx_util NULL
 mkdir: %_DEST%\inc%_EXT%\svx\sdr\table
 ..\inc\svx\sdr\table\tabledesign.hxx %_DEST%\inc%_EXT%\svx\sdr\table\tabledesign.hxx
 
+mkdir: %_DEST%\inc%_EXT%\svx\sdr\media
+..\inc\svx\sdr\media\medialink.hxx %_DEST%\inc%_EXT%\svx\sdr\media\medialink.hxx
+..\inc\svx\sdr\media\mediamanager.hxx %_DEST%\inc%_EXT%\svx\sdr\media\mediamanager.hxx
+
 ..\xml\SvxDrawPage.xml %_DEST%\xml%_EXT%\SvxDrawPage.xml
 ..\xml\SvxGraphicObject.xml %_DEST%\xml%_EXT%\SvxGraphicObject.xml
 ..\xml\SvxShape.xml %_DEST%\xml%_EXT%\SvxShape.xml

svx/source/cui/cuigaldlg.cxx

 			::rtl::OUString aFilterWildcard( aWildcard );
 
 			pFilterEntry = new FilterEntry;
-            pFilterEntry->aFilterName = aFilters[ l ].second.getToken( 0, ';', nIndex );
-            nFirstExtFilterPos = aCbbFileType.InsertEntry( addExtension( aFilters[ l ].first,
+            pFilterEntry->aFilterName = aFilters[ l ].msExtensions.getToken( 0, ';', nIndex );
+            nFirstExtFilterPos = aCbbFileType.InsertEntry( addExtension( aFilters[ l ].msFilterName,
                                                            aFilterWildcard += pFilterEntry->aFilterName ) );
 			aFilterEntryList.Insert( pFilterEntry, nFirstExtFilterPos );
         }
         {
 		    if ( aExtensions.Len() )
         		aExtensions += sal_Unicode( ';' );
-            ( aExtensions += String( aWildcard ) ) += String( aFilters[ k ].second.getToken( 0, ';', nIndex ) );
+            ( aExtensions += String( aWildcard ) ) += String( aFilters[ k ].msExtensions.getToken( 0, ';', nIndex ) );
 		}
 	 }
 

svx/source/cui/linkdlg.cxx

             Automatic().Disable();
             Manual().Check();
             Manual().Disable();
-			if( OBJECT_CLIENT_GRF == pLink->GetObjType() )
-				pLinkNm = 0, pFilter = &sLink;
+			if( (OBJECT_CLIENT_GRF == pLink->GetObjType()) || (OBJECT_CLIENT_AVMEDIA == pLink->GetObjType()) )
+			{
+				pLinkNm = 0;
+				pFilter = &sLink;
+			}
 		}
 		else
 		{
     USHORT nPos;
     SvBaseLink* pLink = GetSelEntry( &nPos );
 
-    if ( pLink != _pLink && _pLink && _pLink->WasLastEditOK() )
+    if ( /*pLink != _pLink &&*/ _pLink && _pLink->WasLastEditOK() )
     {
         // JP 09.01.98:
         // StarImpress/Draw tauschen die LinkObjecte selbst aus!
 	nWidthPixel -= SV_TAB_BORDER;
     XubString aTxt = Links().GetEllipsisString( sFileNm, nWidthPixel, TEXT_DRAW_PATHELLIPSIS );
 	INetURLObject aPath( sFileNm, INET_PROT_FILE );
-	String aFileName = aPath.getName();
+	String aFileName = aPath.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET, RTL_TEXTENCODING_UTF8);
 	if( aFileName.Len() > aTxt.Len() )
 		aTxt = aFileName;
 	else if( aTxt.Search( aFileName, aTxt.Len() - aFileName.Len() ) == STRING_NOTFOUND )
 
 	aEntry = aTxt;
 	aEntry += '\t';
-	if( OBJECT_CLIENT_GRF == rLink.GetObjType() )
+	if( (OBJECT_CLIENT_GRF == rLink.GetObjType()) || (OBJECT_CLIENT_AVMEDIA == rLink.GetObjType()) )
 		aEntry += sFilter;
 	else
 		aEntry += sLinkNm;

svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx

 
 ViewObjectContact& ViewContactOfSdrMediaObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
 {
-	return *( new ViewObjectContactOfSdrMediaObj( rObjectContact, *this, static_cast< SdrMediaObj& >( GetSdrObject() ).getMediaProperties() ) );
+    SdrMediaObj& rObj = static_cast< SdrMediaObj& >( GetSdrObject() );
+    
+    ::avmedia::MediaItem aMediaItem( rObj.getMediaProperties() );
+    
+    if( rObj.getMediaLink().is() && !rObj.getMediaLink()->isLinked() )
+        aMediaItem.setURL( rObj.getMediaLink()->getOrCreateTempFileURL() );
+
+	return *( new ViewObjectContactOfSdrMediaObj( rObjectContact, *this, aMediaItem ) );
 }
 
 // ------------------------------------------------------------------------------
 			static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->updateMediaItem(rItem);
 		}
 	}
+
+    SdrMediaObj& rObj = static_cast< SdrMediaObj& >( GetSdrObject() );   
+    if( rObj.getMediaLink().is() && !rObj.getMediaLink()->isLinked() )
+        rItem.setURL( rObj.getMediaLink()->getOrCreateTempFileURL() );
 }
 
 // ------------------------------------------------------------------------------
 {
 	const sal_uInt32 nCount(getViewObjectContactCount());
 
+	::avmedia::MediaItem aItem( rItem );
+    SdrMediaObj& rObj = static_cast< SdrMediaObj& >( GetSdrObject() );   
+    if( rObj.getMediaLink().is() && !rObj.getMediaLink()->isLinked() )
+        aItem.setURL( rObj.getMediaLink()->getOrCreateTempFileURL() );
+
 	for(sal_uInt32 a(0); a < nCount; a++)
 	{
 		ViewObjectContact* pCandidate = getViewObjectContact(a);
 
 		if(pCandidate)
 		{
-			static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->executeMediaItem(rItem);
+			static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->executeMediaItem(aItem);
 		}
 	}
 }

svx/source/sdr/media/makefile.mk

+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.6 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org.  If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=svx
+TARGET=media
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE :  settings.mk
+.INCLUDE :  $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+		$(SLO)$/mediamanager.obj
+
+.INCLUDE :  target.mk

svx/source/sdr/media/mediamanager.cxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: eventhandler.cxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svx.hxx"
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+
+#include <comphelper/storagehelper.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <avmedia/mediawindow.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include <tools/tempfile.hxx>
+#include <tools/stream.hxx>
+
+#include <sfx2/objsh.hxx>
+#include <sfx2/event.hxx>
+#include <sfx2/sfx.hrc>
+
+#include <svx/sdr/media/mediamanager.hxx>
+
+#include <memory>
+
+using ::rtl::OUString;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::embed;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::beans;
+
+namespace sdr { namespace media	{
+
+static bool KillFile( const OUString& aURL, const Reference< XMultiServiceFactory >& xFactory )
+{
+    if ( !xFactory.is() )
+        return sal_False;
+
+    sal_Bool bRet = sal_False;
+
+    try
+    {
+        Reference< XSimpleFileAccess > xAccess( xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY );
+        if( xAccess.is() )
+        {
+	        xAccess->kill( aURL );
+	        bRet = sal_True;
+        }
+    }
+    catch( Exception& e )
+    {
+        (void)e;
+         OSL_TRACE( "sdr::media::KillFile caught exception: %s",
+            rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());        
+    }
+
+    return bRet;
+}
+
+static OUString CreateTempFile( const OUString& aStreamURL, SvStream& rStream, const Reference< XMultiServiceFactory >& xFactory )
+{
+	OUString aTempURL;
+
+    const String aLeadingChars;
+    String aExtension;
+    sal_Int32 nIndex = aStreamURL.lastIndexOf( '.' );
+    if( nIndex != -1 )
+        aExtension = aStreamURL.copy( nIndex );
+        
+    TempFile aTmpFile( aLeadingChars, &aExtension );   
+	if( aTmpFile.IsValid() ) 
+    {
+        aTempURL = aTmpFile.GetName();
+        
+        SvFileStream aTempFile( aTempURL, STREAM_WRITE|STREAM_TRUNC );
+        
+        aTempFile << rStream;
+
+        if( aTempFile.GetError() != ERRCODE_NONE )
+        {
+            OSL_TRACE( "sdr::media::CreateTempFile error creating file: %ld", aTempFile.GetError() );
+            KillFile( aTempURL, xFactory );
+            aTempURL = OUString();
+        }        
+    }
+
+    return aTempURL;
+}
+
+// ------------------------------------------------------------------------------------------------
+
+MediaLink::MediaLink( const rtl::Reference< MediaManager >& xManager, const OUString& rURL, bool bLinked )
+: mpManager( xManager.get() )
+, mbLinked( bLinked )
+, msURL( rURL )
+{
+	if( mpManager )
+		mpManager->acquire();
+
+	avmedia::FilterInfo aFilterInfo;
+	avmedia::MediaWindow::getMediaFilterForURL( rURL, aFilterInfo );
+	msMimeType = aFilterInfo.msMimeType;
+	msFilterName = aFilterInfo.msFilterName;
+}
+
+MediaLink::~MediaLink()
+{
+    if( !msTempFileURL.getLength() == 0 )
+    {
+        Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() );
+        KillFile( msTempFileURL, xFactory );
+    }
+
+	if( mpManager )
+		mpManager->release();
+}
+
+rtl::OUString MediaLink::getOrCreateTempFileURL()
+{
+    if( mbLinked || !mpManager )
+        return msURL;
+
+    if( msTempFileURL.getLength() == 0 )
+    {
+        msTempFileURL = mpManager->createTemporaryCopy( msURL );
+    }
+    
+    return msTempFileURL;
+}
+
+// ------------------------------------------------------------------------------------------------
+
+
+MediaManager::MediaManager( SfxObjectShell* pObjectShell )
+: mpObjectShell( pObjectShell )
+, msPackagePrefix( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) )
+, msMedia( RTL_CONSTASCII_USTRINGPARAM( "Media" ))
+, msMediaType( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ))
+, msStorageMediaType( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.star.media" ))
+{
+	StartListening(*mpObjectShell,TRUE);
+}
+
+MediaManager::~MediaManager()
+{
+}
+
+void MediaManager::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+	if (rHint.IsA(TYPE(SfxEventHint)))
+	{
+        switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
+		{
+        case SFX_EVENT_STORAGECHANGED:
+			SwitchPersistance( mpObjectShell->GetStorage() );
+			break;
+		}
+	}
+
+	// todo: catch die and null mp
+}
+
+void MediaManager::Dispose()
+{
+    mxDocumentStorage.clear();
+	if( mpObjectShell )
+	{
+		EndListening(*mpObjectShell);
+		mpObjectShell = 0;
+	}
+}
+
+void MediaManager::SwitchPersistance(const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage )
+{
+	mxDocumentStorage = xStorage;
+	// todo: update/move existing media links?
+}
+
+const Reference< com::sun::star::embed::XStorage >& MediaManager::getDocumentStorage()
+{
+	if( !mxDocumentStorage.is() && mpObjectShell )
+	{
+		mxDocumentStorage = mpObjectShell->GetStorage();
+	}
+	return mxDocumentStorage;
+}
+
+
+Reference< XStorage > MediaManager::getMediaStorage()
+{
+	Reference< XStorage > xStorage( getDocumentStorage() );
+	if( xStorage.is() )
+	{
+		Reference< XNameAccess > xNameAccess( xStorage, UNO_QUERY_THROW );
+		bool bExisted = xNameAccess->hasByName( msMedia );
+		
+		xStorage = xStorage->openStorageElement( msMedia, ElementModes::WRITE );
+
+		if( !bExisted )
+		{
+			Reference< XPropertySet > xSet( xStorage, UNO_QUERY_THROW );
+			xSet->setPropertyValue( msMediaType, Any( msStorageMediaType ) );
+		}
+	}
+	return xStorage;
+}
+
+static void undup( OUString& rFileName )
+{
+	OUString sRet;
+
+	// first find pos of extension
+	sal_Int32 nExtensionPos = rFileName.lastIndexOf( '.' );
+	if( nExtensionPos == -1 )
+		nExtensionPos = rFileName.getLength();
+
+	// now check if there is already an 'name(index).ext' scheme
+	sal_Int32 nEndIndexPos = rFileName.lastIndexOf( ')', nExtensionPos );
+	
+	if( nEndIndexPos == (nExtensionPos - 1) )
+	{
+		sal_Int32 nBegIndexPos = rFileName.lastIndexOf( '(', nEndIndexPos );
+		if( nBegIndexPos != -1 )
+		{
+			// we found a (..)
+			OUString sIndex = rFileName.copy( nBegIndexPos+1, nEndIndexPos - nBegIndexPos - 1 );
+			sal_Int32 nIndex = sIndex.toInt32();
+			if( nIndex > 0 )
+			{
+				nIndex++;
+				sRet = rFileName.copy( 0, nBegIndexPos+1 );
+				sRet += OUString::valueOf( nIndex );
+				sRet += rFileName.copy( nEndIndexPos );
+				rFileName = sRet;
+				return;
+			}
+		}
+	}
+	
+	sRet = rFileName.copy( 0, nExtensionPos );
+	sRet += OUString( RTL_CONSTASCII_USTRINGPARAM( "(1)" ) );
+	sRet += rFileName.copy( nExtensionPos );
+
+	rFileName = sRet;
+}
+
+MediaLinkRef MediaManager::insertMediaStream( const rtl::OUString& rURL )
+{
+	OUString sURL( rURL );
+    try
+    {
+	    Reference< com::sun::star::embed::XStorage > xStorage( getMediaStorage(), UNO_QUERY_THROW );
+    
+		OUString sStreamName;
+
+		sal_Int32 nPos = rURL.lastIndexOf( '/' );
+		if( nPos == -1 )
+		{
+			sStreamName = rURL;
+		}
+		else
+		{
+			sStreamName = rURL.copy( nPos + 1 );
+		}
+
+		Reference< XNameAccess > xNameAccess( xStorage, UNO_QUERY_THROW );
+
+		bool bNeedsRename = false;
+		bool bAlreadyExists = false;
+		do
+		{		
+			if( xNameAccess->hasByName( sStreamName ) )
+			{
+				// todo sub element exists, if it is a stream check if it is identical
+/*				if( xStorage->isStreamElement( sStreamName ) )
+				{
+				}
+*/
+				undup( sStreamName );
+				bNeedsRename = true;
+			}
+			else
+			{
+				bNeedsRename = false;
+			}
+		}
+		while( bNeedsRename && !bAlreadyExists );
+       
+        Reference< XStream > xTargetStream( xStorage->openStreamElement( sStreamName, ElementModes::WRITE|ElementModes::TRUNCATE ), UNO_QUERY_THROW );
+
+		// todo: get mime type
+		Reference< XPropertySet >( xTargetStream, UNO_QUERY_THROW )->setPropertyValue( msMediaType, Any( msStorageMediaType ) );
+		{
+			std::auto_ptr< SvStream > pDstStream( ::utl::UcbStreamHelper::CreateStream( xTargetStream ) );
+			const String sSourceURL( rURL );
+			std::auto_ptr< SvStream > pSrcStream( ::utl::UcbStreamHelper::CreateStream( sSourceURL, STREAM_READ ) );
+
+			if( pDstStream.get() && pSrcStream.get() )
+			{
+				*pDstStream << *pSrcStream;
+			}
+		}
+
+		Reference< XTransactedObject > xTransaction( xStorage, UNO_QUERY );
+		if( xTransaction.is() )
+			xTransaction->commit();
+
+		sURL = msPackagePrefix;
+		sURL += msMedia;
+		sURL += OUString::createFromAscii( "/" );
+		sURL += sStreamName;    
+    }
+    catch( Exception& e )
+    {
+		(void)e;
+		DBG_ERROR(
+			rtl::OString("sdr::media::MediaManager::createTemporaryCopy(), exception caught: ") +
+			rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ) );
+    
+    }		
+			
+    return getMediaLink( sURL );
+}
+
+MediaLinkRef MediaManager::getMediaLink( const OUString& rURL )
+{
+    MediaLinkRef xRet;
+    
+    MediaLinkMap::iterator iter( maMediaLinkMap.find( rURL ) );
+    if( iter != maMediaLinkMap.end() )
+    {
+        xRet = (*iter).second;
+    }
+    else
+    {
+        const bool bLinked = !rURL.matchIgnoreAsciiCase( msPackagePrefix );
+        rtl::Reference< MediaManager > xThis( this );
+        xRet = MediaLinkRef( new MediaLink( xThis, rURL, bLinked ) );
+        maMediaLinkMap[ rURL ] = xRet;
+    }
+    return xRet;
+}
+
+void MediaManager::freeMediaLink( const MediaLinkRef& xLink )
+{
+    (void)xLink;
+}
+
+OUString MediaManager::createTemporaryCopy( const OUString& rURL )
+{
+    OUString aTempURL;
+    if( getDocumentStorage().is() )
+	{
+    
+        //TODO/MBA: binary format removed, needs testing
+		if( rURL.match( msPackagePrefix ) )
+		{
+		    sal_Int32 nPos = rURL.lastIndexOf( '/' ) ;
+
+            if( nPos != 1 ) try
+            {
+				const String aMediaStreamName( rURL.copy( nPos+1 ) );
+                const String aMediaStorageName( rURL.copy( msPackagePrefix.getLength(), nPos - msPackagePrefix.getLength() ) );
+
+                if( getDocumentStorage()->isStorageElement( aMediaStorageName ) )
+                {
+					Reference< XStorage > xPictureStorage( getDocumentStorage()->openStorageElement( aMediaStorageName, ElementModes::READ ) );
+					try
+					{
+						if( xPictureStorage.is() && xPictureStorage->isStreamElement( aMediaStreamName ) )
+						{
+							Reference< XStream > xStream = xPictureStorage->openStreamElement( aMediaStreamName, ElementModes::READ );
+							if( xStream.is() )
+							{
+								SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( xStream );
+								if( pStream )
+								{
+                                    Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() );
+								    aTempURL = CreateTempFile( rURL, *pStream, xFactory );
+									delete pStream;
+								}
+						    }
+						}
+					}
+					catch( NoSuchElementException& )
+					{
+					}
+                }
+			}
+			catch( Exception& e )
+			{
+				(void)e;
+				DBG_ERROR(
+					rtl::OString("sdr::media::MediaManager::createTemporaryCopy(), exception caught: ") +
+					rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ) );
+			}
+		}
+	}
+	
+	return aTempURL;
+}
+
+} // end of namespace mixer
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof

svx/source/svdraw/svdmodel.cxx

 #include <tools/urlobj.hxx>
 #include <unotools/ucbstreamhelper.hxx>
 
+#include <svx/sdr/media/mediamanager.hxx>
+
 #include <tools/string.hxx>
 #include <svtools/whiter.hxx>
 #include <svx/xit.hxx>
 	SfxUndoManager*	mpUndoManager;
 	SdrUndoFactory* mpUndoFactory;
 	bool mbAllowShapePropertyChangeListener;
+	rtl::Reference< sdr::media::MediaManager > mxMediaManager;
 };
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
 	DBG_DTOR(SdrModel,NULL);
 
+    if( mpImpl && mpImpl->mxMediaManager.is() )
+    {
+        mpImpl->mxMediaManager->Dispose();
+        mpImpl->mxMediaManager.clear();
+    }
+    
 	mbInDestruction = true;
 
 	Broadcast(SdrHint(HINT_MODELCLEARED));
 	return *pSeq;
 }
 
+
+void SdrModel::SetMediaManager( const rtl::Reference< sdr::media::MediaManager >& xManager )
+{
+    if( mpImpl )
+    {
+        mpImpl->mxMediaManager = xManager;
+    }
+}
+
+rtl::Reference< sdr::media::MediaManager > SdrModel::GetMediaManager()
+{
+    if( mpImpl )
+    {
+        return mpImpl->mxMediaManager;
+    }
+    else
+    {
+        return rtl::Reference< sdr::media::MediaManager >();
+    }
+}
+
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
 TYPEINIT1(SdrHint,SfxHint);

svx/source/svdraw/svdomedia.cxx

 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_svx.hxx"
 
-#include <svx/svdomedia.hxx>
+#include <sfx2/lnkbase.hxx>
+
+#include <avmedia/mediawindow.hxx>
+
+#include <sot/formats.hxx>
+
+#include "svx/sdr/contact/viewcontactofsdrmediaobj.hxx"
+#include "svx/sdr/media/MediaManager.hxx"
+#include "svx/svdmodel.hxx"
+#include "svx/svdomedia.hxx"
+#include "svx/linkmgr.hxx"
+
 #include "svdglob.hxx"
 #include "svdstr.hrc"
-#include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
-#include <avmedia/mediawindow.hxx>
+
+using ::rtl::OUString;
+
+// ----------------
+// - SdrMediaLink -
+// ----------------
+
+class SdrMediaLink : public sfx2::SvBaseLink
+{
+public:
+						SdrMediaLink(SdrMediaObj* pObj, ULONG nContentType);
+	virtual				~SdrMediaLink();
+
+	virtual void		Closed();
+	virtual void		DataChanged( const String& rMimeType, const ::com::sun::star::uno::Any & rValue );
+
+	bool				Connect() { return 0 != GetRealObject(); }
+
+private:
+	SdrObjectWeakRef mxMediaObj;
+};
+
+SdrMediaLink::SdrMediaLink(SdrMediaObj* pObj, ULONG nContentType)
+: ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, nContentType )
+, mxMediaObj(pObj)
+{
+	SetSynchron( FALSE );
+}
+
+SdrMediaLink::~SdrMediaLink()
+{
+}
+
+void SdrMediaLink::Closed()
+{
+	if( mxMediaObj.is() )
+	{
+		SdrMediaObj* pMediaObj = static_cast< SdrMediaObj* >( mxMediaObj.get() );
+		pMediaObj->mpSdrMediaLink = 0;
+		pMediaObj->breakLink();
+	}
+	SvBaseLink::Closed();
+}
+
+void SdrMediaLink::DataChanged( const String& /*rMimeType*/, const ::com::sun::star::uno::Any & rValue )
+{
+	if( mxMediaObj.is() )
+	{
+		OUString sNewURL;
+		if( rValue >>= sNewURL )
+		{
+			SdrMediaObj* pMediaObj = static_cast< SdrMediaObj* >( mxMediaObj.get() );
+			if( pMediaObj->getURL() != sNewURL )
+				pMediaObj->UpdateURL( sNewURL );
+		}
+		else
+		{
+			DBG_ERROR("SdrMediaLink::DataChanged(), unknown value type!");
+		}
+	}
+}
 
 // ---------------
 // - SdrMediaObj -
 // ------------------------------------------------------------------------------
 
 SdrMediaObj::SdrMediaObj()
+: mpSdrMediaLink( 0 )
 {
 }
 
 // ------------------------------------------------------------------------------
 
-SdrMediaObj::SdrMediaObj( const Rectangle& rRect ) :
-	SdrRectObj( rRect )
+SdrMediaObj::SdrMediaObj( const Rectangle& rRect )