[ooo-build-commit] .: patches/dev300
Thorsten Behrens
thorsten at kemper.freedesktop.org
Thu Feb 4 05:56:53 PST 2010
patches/dev300/apply | 2
patches/dev300/cws-impressmedia01-backport.diff | 2662 ++++++++++++++++++++++++
2 files changed, 2664 insertions(+)
New commits:
commit 5d81300d520485bfdc440be0c2ac94dc709afd43
Author: Thorsten Behrens <tbehrens at novell.com>
Date: Thu Feb 4 14:53:10 2010 +0100
Backport of the media embedding feature for ooo320
* patches/dev300/apply: added the patch
* patches/dev300/cws-impressmedia01-backport.diff: cws backported to
ooo320 code line. builds & basically works. Lots of details to do
though. Upstream issue: i#83753
diff --git a/patches/dev300/apply b/patches/dev300/apply
index 5b4e1b3..e861cba 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -2601,6 +2601,8 @@ reduced-disable-auto-spellcheck.diff
[ Features ]
novell-win32-odma.diff, i#6885, i#32741, tml
+# embed generic media files inside odf docs
+cws-impressmedia01-backport.diff, i#83753, thorsten
[ VOSremoval ]
diff --git a/patches/dev300/cws-impressmedia01-backport.diff b/patches/dev300/cws-impressmedia01-backport.diff
new file mode 100644
index 0000000..033c218
--- /dev/null
+++ b/patches/dev300/cws-impressmedia01-backport.diff
@@ -0,0 +1,2662 @@
+Backport of impressmedia01 changes to ooo320
+
+From: Thorsten Behrens <tbehrens at novell.com>
+
+
+---
+
+ avmedia/inc/avmedia/mediawindow.hxx | 23 +
+ avmedia/source/framework/mediacontrol.cxx | 2
+ avmedia/source/viewer/mediawindow.cxx | 124 ++++--
+ avmedia/source/viewer/mediawindow.hrc | 1
+ fpicker/source/aqua/ControlHelper.cxx | 3
+ fpicker/source/aqua/SalAquaFilePicker.cxx | 4
+ fpicker/source/office/OfficeFilePicker.cxx | 5
+ fpicker/source/unx/gnome/SalGtkFilePicker.cxx | 6
+ fpicker/source/unx/kde4/KDE4FilePicker.cxx | 4
+ fpicker/source/win32/filepicker/FPServiceInfo.hxx | 3
+ fpicker/source/win32/filepicker/FilePicker.cxx | 9
+ fpicker/source/win32/filepicker/Fps.rc | 17 +
+ .../source/win32/filepicker/VistaFilePicker.cxx | 7
+ .../filepicker/VistaFilePickerEventHandler.cxx | 40 +-
+ .../win32/filepicker/VistaFilePickerImpl.cxx | 4
+ .../sun/star/ui/dialogs/TemplateDescription.idl | 8
+ sc/source/ui/drawfunc/fuins1.cxx | 16 +
+ sd/source/core/drawdoc.cxx | 4
+ sd/source/ui/func/fuinsert.cxx | 11
+ sd/source/ui/view/sdview4.cxx | 51 +-
+ sfx2/inc/sfx2/lnkbase.hxx | 1
+ sfx2/sdi/sfx.sdi | 52 +-
+ sfx2/source/dialog/filedlghelper.cxx | 15 +
+ sot/inc/sot/formats.hxx | 3
+ sot/source/base/exchange.cxx | 1
+ svx/inc/svx/dialogs.hrc | 7
+ svx/inc/svx/sdr/media/medialink.hxx | 81 ++++
+ svx/inc/svx/sdr/media/mediamanager.hxx | 90 ++++
+ svx/inc/svx/svdmodel.hxx | 9
+ svx/inc/svx/svdomedia.hxx | 18 +
+ svx/prj/build.lst | 3
+ svx/prj/d.lst | 4
+ svx/source/cui/cuigaldlg.cxx | 6
+ svx/source/cui/linkdlg.cxx | 13 -
+ .../sdr/contact/viewcontactofsdrmediaobj.cxx | 20 +
+ svx/source/sdr/media/makefile.mk | 48 ++
+ svx/source/sdr/media/mediamanager.cxx | 445 ++++++++++++++++++++
+ svx/source/svdraw/svdmodel.cxx | 30 +
+ svx/source/svdraw/svdomedia.cxx | 258 +++++++++++-
+ svx/source/svxlink/fileobj.cxx | 23 +
+ svx/source/svxlink/linkmgr.cxx | 17 -
+ svx/source/svxlink/linkmgr.src | 5
+ svx/util/makefile.mk | 3
+ sw/source/ui/shells/grfshex.cxx | 12 -
+ unotools/source/ucbhelper/XTempFile.hxx | 10
+ unotools/source/ucbhelper/xtempfile.cxx | 73 +++
+ xmloff/source/draw/ximpshap.cxx | 21 +
+ 47 files changed, 1468 insertions(+), 142 deletions(-)
+ create mode 100644 svx/inc/svx/sdr/media/medialink.hxx
+ create mode 100644 svx/inc/svx/sdr/media/mediamanager.hxx
+ create mode 100644 svx/source/sdr/media/makefile.mk
+ create mode 100644 svx/source/sdr/media/mediamanager.cxx
+
+
+diff --git avmedia/inc/avmedia/mediawindow.hxx avmedia/inc/avmedia/mediawindow.hxx
+index 1169876..3411821 100644
+--- avmedia/inc/avmedia/mediawindow.hxx
++++ avmedia/inc/avmedia/mediawindow.hxx
+@@ -64,7 +64,20 @@ namespace rtl { class OUString; }
+
+ 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;
+
+@@ -149,7 +162,12 @@ namespace avmedia
+ public:
+
+ static void getMediaFilters( FilterNameVector& rFilterNameVector );
+- static bool executeMediaURLDialog( Window* pParent, ::rtl::OUString& rURL, bool bInsertDialog = true );
++ static bool getMediaFilterForURL( const ::rtl::OUString& rURL, FilterInfo& rFilterInfo );
++
++ 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 );
+
+@@ -160,6 +178,7 @@ namespace avmedia
+ 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&);
+diff --git avmedia/source/framework/mediacontrol.cxx avmedia/source/framework/mediacontrol.cxx
+index 4675da3..156b345 100644
+--- avmedia/source/framework/mediacontrol.cxx
++++ avmedia/source/framework/mediacontrol.cxx
+@@ -524,7 +524,7 @@ IMPL_LINK( MediaControl, implSelectHdl, ToolBox*, p )
+ {
+ ::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 );
+diff --git avmedia/source/viewer/mediawindow.cxx avmedia/source/viewer/mediawindow.cxx
+index d345bb8..eae7afc 100644
+--- avmedia/source/viewer/mediawindow.cxx
++++ avmedia/source/viewer/mediawindow.cxx
+@@ -42,6 +42,8 @@
+ #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
+
+@@ -365,35 +367,95 @@ Window* MediaWindow::getWindow() const
+
+ // -------------------------------------------------------------------------
+
++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",
++ "FLAC Audio", "flac", "audio/x-flac",
++ "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",
+- "FLAC Audio", "flac",
+- "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" };
++ const char** pFilters = GetFiltersImpl();
+
+- 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 ] ) ) );
++ 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 )
++{
++ 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 )
+ {
+- ::sfx2::FileDialogHelper aDlg( com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
++ 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( ";" ) );
+@@ -411,7 +473,7 @@ bool MediaWindow::executeMediaURLDialog( Window* /* pParent */, ::rtl::OUString&
+ if( aAllTypes.getLength() )
+ aAllTypes += aSeparator;
+
+- ( aAllTypes += aWildcard ) += aFilters[ i ].second.getToken( 0, ';', nIndex );
++ ( aAllTypes += aWildcard ) += aFilters[ i ].msExtensions.getToken( 0, ';', nIndex );
+ }
+ }
+
+@@ -427,20 +489,30 @@ bool MediaWindow::executeMediaURLDialog( Window* /* pParent */, ::rtl::OUString&
+ 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();
+@@ -515,7 +587,7 @@ bool MediaWindow::isMediaURL( const ::rtl::OUString& rURL, bool bDeep, Size* pPr
+ {
+ 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;
+ }
+ }
+diff --git avmedia/source/viewer/mediawindow.hrc avmedia/source/viewer/mediawindow.hrc
+index 988088e..8e26f1b 100644
+--- avmedia/source/viewer/mediawindow.hrc
++++ avmedia/source/viewer/mediawindow.hrc
+@@ -7,3 +7,4 @@
+ #define AVMEDIA_BMP_EMPTYLOGO 20001
+
+ #define AVMEDIA_ERR_URL 21000
++
+diff --git fpicker/source/aqua/ControlHelper.cxx fpicker/source/aqua/ControlHelper.cxx
+index d289608..6c96513 100644
+--- fpicker/source/aqua/ControlHelper.cxx
++++ fpicker/source/aqua/ControlHelper.cxx
+@@ -155,6 +155,9 @@ void ControlHelper::initialize( sal_Int16 nTemplateId )
+ case FILESAVE_AUTOEXTENSION:
+ m_bToggleVisibility[AUTOEXTENSION] = true;
+ break;
++ case FILEOPEN_LINK:
++ m_bToggleVisibility[LINK] = true;
++ break;
+ }
+
+ createControls();
+diff --git fpicker/source/aqua/SalAquaFilePicker.cxx fpicker/source/aqua/SalAquaFilePicker.cxx
+index 9e99200..6372b64 100644
+--- fpicker/source/aqua/SalAquaFilePicker.cxx
++++ fpicker/source/aqua/SalAquaFilePicker.cxx
+@@ -555,6 +555,10 @@ throw( uno::Exception, uno::RuntimeException )
+ 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" );
+diff --git fpicker/source/office/OfficeFilePicker.cxx fpicker/source/office/OfficeFilePicker.cxx
+index 916b7bc..c1152e6 100644
+--- fpicker/source/office/OfficeFilePicker.cxx
++++ fpicker/source/office/OfficeFilePicker.cxx
+@@ -314,6 +314,11 @@ WinBits SvtFilePicker::getWinBits( WinBits& rExtraBits )
+ 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;
+diff --git fpicker/source/unx/gnome/SalGtkFilePicker.cxx fpicker/source/unx/gnome/SalGtkFilePicker.cxx
+index bccee17..5c9f39c 100644
+--- fpicker/source/unx/gnome/SalGtkFilePicker.cxx
++++ fpicker/source/unx/gnome/SalGtkFilePicker.cxx
+@@ -1711,6 +1711,12 @@ void SAL_CALL SalGtkFilePicker::initialize( const uno::Sequence<uno::Any>& aArgu
+ 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;
+diff --git fpicker/source/unx/kde4/KDE4FilePicker.cxx fpicker/source/unx/kde4/KDE4FilePicker.cxx
+index d7dfbc1..f9ec1f4 100644
+--- fpicker/source/unx/kde4/KDE4FilePicker.cxx
++++ fpicker/source/unx/kde4/KDE4FilePicker.cxx
+@@ -690,6 +690,10 @@ void SAL_CALL KDE4FilePicker::initialize( const uno::Sequence<uno::Any> &args )
+ addCustomControl( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE );
+ break;
+
++ case FILEOPEN_LINK:
++ addCustomControl( ExtendedFilePickerElementIds::CHECKBOX_LINK );
++ break;
++
+ case FILEOPEN_PLAY:
+ addCustomControl( ExtendedFilePickerElementIds::PUSHBUTTON_PLAY );
+ break;
+diff --git fpicker/source/win32/filepicker/FPServiceInfo.hxx fpicker/source/win32/filepicker/FPServiceInfo.hxx
+index 6b7f6ef..85e82d6 100644
+--- fpicker/source/win32/filepicker/FPServiceInfo.hxx
++++ fpicker/source/win32/filepicker/FPServiceInfo.hxx
+@@ -66,6 +66,9 @@
+ #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"
+
+diff --git fpicker/source/win32/filepicker/FilePicker.cxx fpicker/source/win32/filepicker/FilePicker.cxx
+index 2342c88..c7d5fe6 100644
+--- fpicker/source/win32/filepicker/FilePicker.cxx
++++ fpicker/source/win32/filepicker/FilePicker.cxx
+@@ -701,7 +701,14 @@ void SAL_CALL CFilePicker::initialize(const uno::Sequence<uno::Any>& aArguments)
+ 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
+diff --git fpicker/source/win32/filepicker/Fps.rc fpicker/source/win32/filepicker/Fps.rc
+index ad08ad0..e43d061 100644
+--- fpicker/source/win32/filepicker/Fps.rc
++++ fpicker/source/win32/filepicker/Fps.rc
+@@ -250,6 +250,23 @@ BEGIN
+ 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
+
+ /////////////////////////////////////////////////////////////////////////////
+ //
+diff --git fpicker/source/win32/filepicker/VistaFilePicker.cxx fpicker/source/win32/filepicker/VistaFilePicker.cxx
+index a80604c..7c664d3 100644
+--- fpicker/source/win32/filepicker/VistaFilePicker.cxx
++++ fpicker/source/win32/filepicker/VistaFilePicker.cxx
+@@ -629,6 +629,13 @@ void SAL_CALL VistaFilePicker::initialize(const css::uno::Sequence< css::uno::An
+ 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 :
+ {
+diff --git fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx
+index 6814f79..0ca0514 100644
+--- fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx
++++ fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx
+@@ -128,14 +128,14 @@ STDMETHODIMP VistaFilePickerEventHandler::OnFileOk(IFileDialog* /*pDialog*/)
+ }
+
+ //-----------------------------------------------------------------------------------------
+-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;
+@@ -253,7 +253,7 @@ void lcl_updateVersionListDirectly(IFileDialog* pDialog)
+ }
+
+ //-----------------------------------------------------------------------------------------
+-STDMETHODIMP VistaFilePickerEventHandler::OnSelectionChange(IFileDialog* pDialog)
++STDMETHODIMP VistaFilePickerEventHandler::OnSelectionChange(IFileDialog* /*pDialog*/)
+ {
+ impl_sendEvent(E_FILE_SELECTION_CHANGED, 0);
+ //lcl_updateVersionListDirectly(pDialog);
+@@ -261,16 +261,16 @@ STDMETHODIMP VistaFilePickerEventHandler::OnSelectionChange(IFileDialog* 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;
+@@ -302,32 +302,32 @@ STDMETHODIMP VistaFilePickerEventHandler::OnTypeChange(IFileDialog* pDialog)
+ }
+
+ //-----------------------------------------------------------------------------------------
+-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 )
+ {
+@@ -356,15 +356,15 @@ STDMETHODIMP VistaFilePickerEventHandler::OnCheckButtonToggled(IFileDialogCustom
+ 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;
+ }
+
+diff --git fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
+index 31784e4..a3c4e64 100644
+--- fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
++++ fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
+@@ -507,6 +507,10 @@ void VistaFilePickerImpl::impl_sta_enableFeatures(::sal_Int32 nFeatures, ::sal_I
+ 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;
+diff --git offapi/com/sun/star/ui/dialogs/TemplateDescription.idl offapi/com/sun/star/ui/dialogs/TemplateDescription.idl
+index dac89c4..5e867d8 100644
+--- offapi/com/sun/star/ui/dialogs/TemplateDescription.idl
++++ offapi/com/sun/star/ui/dialogs/TemplateDescription.idl
+@@ -137,6 +137,14 @@ published constants TemplateDescription
+ */
+ const short FILESAVE_AUTOEXTENSION = 10;
+
++ //---------------------------------------------------------------------
++ /** A FileOpen dialog with additional controls.
++ <ul>
++ <li>A checkbox "Insert as link"
++ </ul>
++ */
++ const short FILEOPEN_LINK = 11;
++
+ };
+
+ //=============================================================================
+diff --git sc/source/ui/drawfunc/fuins1.cxx sc/source/ui/drawfunc/fuins1.cxx
+index 6b2e3eb..c3592f5 100644
+--- sc/source/ui/drawfunc/fuins1.cxx
++++ sc/source/ui/drawfunc/fuins1.cxx
+@@ -213,7 +213,7 @@ void lcl_InsertGraphic( const Graphic& rGraphic,
+
+ void lcl_InsertMedia( const ::rtl::OUString& rMediaURL, bool bApi,
+ ScTabViewShell* pViewSh, Window* pWindow, SdrView* pView,
+- const Size& rPrefSize )
++ const Size& rPrefSize, bool bLinked )
+ {
+ SdrPageView* pPV = pView->GetSdrPageView();
+ SdrPage* pPage = pPV->GetPage();
+@@ -240,6 +240,9 @@ void lcl_InsertMedia( const ::rtl::OUString& rMediaURL, bool bApi,
+
+ pObj->setURL( rMediaURL );
+ pView->InsertObjectAtView( pObj, *pPV, bApi ? SDRINSERT_DONTMARK : 0 );
++
++ if( !bLinked )
++ pObj->breakLink();
+ }
+
+ /*************************************************************************
+@@ -389,6 +392,7 @@ FuInsertMedia::FuInsertMedia( ScTabViewShell* pViewSh,
+ FuPoor(pViewSh, pWin, pViewP, pDoc, rReq)
+ {
+ ::rtl::OUString aURL;
++ sal_Bool bLinked = sal_True;
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ bool bAPI = false;
+
+@@ -401,9 +405,15 @@ FuInsertMedia::FuInsertMedia( ScTabViewShell* pViewSh,
+ 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( pWindow, aURL ) )
++ if( bAPI || ::avmedia::MediaWindow::executeInsertMediaURLDialog( pWindow, aURL, bLinked ) )
+ {
+ Size aPrefSize;
+
+@@ -420,7 +430,7 @@ FuInsertMedia::FuInsertMedia( ScTabViewShell* pViewSh,
+ }
+ else
+ {
+- lcl_InsertMedia( aURL, bAPI, pViewSh, pWindow, pView, aPrefSize );
++ lcl_InsertMedia( aURL, bAPI, pViewSh, pWindow, pView, aPrefSize, bLinked );
+
+ if( pWin )
+ pWin->LeaveWait();
+diff --git sd/source/core/drawdoc.cxx sd/source/core/drawdoc.cxx
+index 624fa6f..8ab3f86 100644
+--- sd/source/core/drawdoc.cxx
++++ sd/source/core/drawdoc.cxx
+@@ -81,6 +81,7 @@
+ #endif
+ #include <svtools/lingucfg.hxx>
+ #include <svtools/linguprops.hxx>
++#include <svx/sdr/media/mediamanager.hxx>
+
+ #include "eetext.hxx"
+ #include "drawdoc.hxx"
+@@ -195,6 +196,9 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh)
+ 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
+diff --git sd/source/ui/func/fuinsert.cxx sd/source/ui/func/fuinsert.cxx
+index 3bd11fa..d622507 100644
+--- sd/source/ui/func/fuinsert.cxx
++++ sd/source/ui/func/fuinsert.cxx
+@@ -709,6 +709,7 @@ FunctionReference FuInsertAVMedia::Create( ViewShell* pViewSh, ::sd::Window* pWi
+ void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
+ {
+ ::rtl::OUString aURL;
++ sal_Bool bLinked = sal_True;
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ bool bAPI = false;
+
+@@ -721,9 +722,15 @@ void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
+ 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;
+
+@@ -742,7 +749,7 @@ void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
+ {
+ 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() )
+ {
+diff --git sd/source/ui/view/sdview4.cxx sd/source/ui/view/sdview4.cxx
+index 0596d55..c90886b 100644
+--- sd/source/ui/view/sdview4.cxx
++++ sd/source/ui/view/sdview4.cxx
+@@ -49,6 +49,7 @@
+ #ifndef _IMPGRF_HXX
+ #include <svx/impgrf.hxx>
+ #endif
++
+ #include <sot/storage.hxx>
+ #include <sfx2/app.hxx>
+ #include <avmedia/mediawindow.hxx>
+@@ -309,27 +310,37 @@ SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAc
+ pPV = 0L;
+ }
+
+- if( !pPickObj && pPV )
+- {
+- 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 );
+-
+- BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
+- ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
+- EndUndo();
+- }
+- else if( pPV )
++ if( pPV )
+ {
+- pNewMediaObj = new SdrMediaObj( Rectangle( rPos, rSize ) );
+-
+- if( pPV && InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER ) )
+- pNewMediaObj->setURL( rMediaURL );
++
++ if( !pPickObj )
++ {
++ SdrPageView* pPageView = pPV;
++ PickObj(rPos, getHitTolLog(), pPickObj, pPageView);
++ }
++
++ 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
++ {
++ 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;
+diff --git sfx2/inc/sfx2/lnkbase.hxx sfx2/inc/sfx2/lnkbase.hxx
+index 65ec501..9f9e659 100644
+--- sfx2/inc/sfx2/lnkbase.hxx
++++ sfx2/inc/sfx2/lnkbase.hxx
+@@ -68,6 +68,7 @@ class FileDialogHelper;
+ #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
+diff --git sfx2/sdi/sfx.sdi sfx2/sdi/sfx.sdi
+index 4c34e2a..26263b4 100644
+--- sfx2/sdi/sfx.sdi
++++ sfx2/sdi/sfx.sdi
+@@ -5924,31 +5924,31 @@ SfxVoidItem ExportDialog SID_EXPORT_DIALOG
+ ]
+
+ //--------------------------------------------------------------------------
+-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)
+ [
+@@ -8488,7 +8488,7 @@ SfxVoidItem AVMediaPlayer SID_AVMEDIA_PLAYER
+ ]
+
+ SfxStringItem InsertAVMedia SID_INSERT_AVMEDIA
+-()
++(SfxStringItem URL SID_INSERT_AVMEDIA,SfxBoolItem AsLink FN_PARAM_1)
+ [
+ /* flags: */
+ AutoUpdate = FALSE,
+diff --git sfx2/source/dialog/filedlghelper.cxx sfx2/source/dialog/filedlghelper.cxx
+index add3f37..fd3738b 100644
+--- sfx2/source/dialog/filedlghelper.cxx
++++ sfx2/source/dialog/filedlghelper.cxx
+@@ -957,7 +957,9 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
+ 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 ) )
+@@ -1044,6 +1046,7 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
+ nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE;
+ mbHasPreview = sal_True;
+ mbHasLink = sal_True;
++ bAddGraphicFilter = true;
+
+ // aPreviewTimer
+ maPreViewTimer.SetTimeout( 500 );
+@@ -1063,10 +1066,11 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
+ 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;
+@@ -1074,6 +1078,11 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
+ mbIsSaveDlg = sal_True;
+ break;
+
++ case FILEOPEN_LINK:
++ nTemplateDescription = TemplateDescription::FILEOPEN_LINK;
++ mbHasLink = sal_True;
++ break;
++
+ default:
+ DBG_ERRORFILE( "FileDialogHelper::ctor with unknown type" );
+ break;
+@@ -1137,7 +1146,7 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
+ 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
+diff --git sot/inc/sot/formats.hxx sot/inc/sot/formats.hxx
+index 2435f3b..a5904ea 100644
+--- sot/inc/sot/formats.hxx
++++ sot/inc/sot/formats.hxx
+@@ -188,7 +188,8 @@
+ #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
+
+diff --git sot/source/base/exchange.cxx sot/source/base/exchange.cxx
+index dc60f76..5ef0e78 100644
+--- sot/source/base/exchange.cxx
++++ sot/source/base/exchange.cxx
+@@ -214,6 +214,7 @@ namespace
+ /*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];
+ }
+diff --git svx/inc/svx/dialogs.hrc svx/inc/svx/dialogs.hrc
+index d36e0fc..e3f6940 100644
+--- svx/inc/svx/dialogs.hrc
++++ svx/inc/svx/dialogs.hrc
+@@ -1390,9 +1390,12 @@
+ #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
+diff --git svx/inc/svx/sdr/media/medialink.hxx svx/inc/svx/sdr/media/medialink.hxx
+new file mode 100644
+index 0000000..bc9259e
+--- /dev/null
++++ svx/inc/svx/sdr/media/medialink.hxx
+@@ -0,0 +1,81 @@
++/*************************************************************************
++ *
++ * 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
+diff --git svx/inc/svx/sdr/media/mediamanager.hxx svx/inc/svx/sdr/media/mediamanager.hxx
+new file mode 100644
+index 0000000..1beee5d
+--- /dev/null
++++ svx/inc/svx/sdr/media/mediamanager.hxx
+@@ -0,0 +1,90 @@
++/*************************************************************************
++ *
++ * 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
+diff --git svx/inc/svx/svdmodel.hxx svx/inc/svx/svdmodel.hxx
+index 56c0e85..59d76a8 100644
+--- svx/inc/svx/svdmodel.hxx
++++ svx/inc/svx/svdmodel.hxx
+@@ -57,6 +57,7 @@ class OutputDevice;
+ #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 */
+@@ -107,6 +108,11 @@ class SdrUndoFactory;
+ namespace comphelper{
+ class IEmbeddedHelper;
+ }
++
++namespace sdr { namespace media {
++ class MediaManager;
++} }
++
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ #define SDR_SWAPGRAPHICSMODE_NONE 0x00000000
+@@ -305,6 +311,8 @@ protected:
+
+ 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);
+@@ -740,6 +748,7 @@ public:
+ also during the runtime of the Undo() and Redo() methods. */
+ bool IsUndoEnabled() const;
+
++ rtl::Reference< sdr::media::MediaManager > GetMediaManager();
+ };
+
+ typedef tools::WeakReference< SdrModel > SdrModelWeakRef;
+diff --git svx/inc/svx/svdomedia.hxx svx/inc/svx/svdomedia.hxx
+index 14bbfac..cf82e82 100644
+--- svx/inc/svx/svdomedia.hxx
++++ svx/inc/svx/svdomedia.hxx
+@@ -34,8 +34,10 @@
+ #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; } }
+
+@@ -46,6 +48,7 @@ namespace sdr { namespace contact { class ViewContactOfSdrMediaObj; } }
+ class SVX_DLLPUBLIC SdrMediaObj : public SdrRectObj
+ {
+ friend class ::sdr::contact::ViewContactOfSdrMediaObj;
++ friend class SdrMediaLink;
+
+ public:
+
+@@ -66,8 +69,13 @@ 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;
+
+@@ -80,16 +88,26 @@ public:
+ 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
+diff --git svx/prj/build.lst svx/prj/build.lst
+index 5698070..2ef6f73 100644
+--- svx/prj/build.lst
++++ svx/prj/build.lst
+@@ -27,6 +27,7 @@ sx svx\source\sdr\properties nmake - all sx_properties sx_inc NULL
+ 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
+@@ -49,5 +50,5 @@ sx svx\source\accessibility nmake - all sx_accessibility 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
+diff --git svx/prj/d.lst svx/prj/d.lst
+index 276512a..59be923 100644
+--- svx/prj/d.lst
++++ svx/prj/d.lst
+@@ -622,6 +622,10 @@ mkdir: %_DEST%\inc%_EXT%\svx\sdr\animation
+ 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
+diff --git svx/source/cui/cuigaldlg.cxx svx/source/cui/cuigaldlg.cxx
+index 3c3bb13..4a07f2a 100644
+--- svx/source/cui/cuigaldlg.cxx
++++ svx/source/cui/cuigaldlg.cxx
+@@ -928,8 +928,8 @@ void TPGalleryThemeProperties::FillFilterList()
+ ::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 );
+ }
+@@ -965,7 +965,7 @@ void TPGalleryThemeProperties::FillFilterList()
+ {
+ 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 ) );
+ }
+ }
+
+diff --git svx/source/cui/linkdlg.cxx svx/source/cui/linkdlg.cxx
+index fe67a8d..6dee930 100644
+--- svx/source/cui/linkdlg.cxx
++++ svx/source/cui/linkdlg.cxx
+@@ -208,8 +208,11 @@ IMPL_LINK( SvBaseLinksDlg, LinksSelectHdl, SvTabListBox *, pSvTabListBox )
+ 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
+ {
+@@ -530,7 +533,7 @@ IMPL_LINK( SvBaseLinksDlg, EndEditHdl, sfx2::SvBaseLink*, _pLink )
+ 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!
+@@ -642,7 +645,7 @@ void SvBaseLinksDlg::InsertEntry( const SvBaseLink& rLink, USHORT nPos, sal_Bool
+ 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 )
+@@ -651,7 +654,7 @@ void SvBaseLinksDlg::InsertEntry( const SvBaseLink& rLink, USHORT nPos, sal_Bool
+
+ 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;
+diff --git svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx
+index b9cf4e0..7ade360 100644
+--- svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx
++++ svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx
+@@ -57,7 +57,14 @@ ViewContactOfSdrMediaObj::~ViewContactOfSdrMediaObj()
+
+ 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 ) );
+ }
+
+ // ------------------------------------------------------------------------------
+@@ -120,6 +127,10 @@ void ViewContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) co
+ static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->updateMediaItem(rItem);
+ }
+ }
++
++ SdrMediaObj& rObj = static_cast< SdrMediaObj& >( GetSdrObject() );
++ if( rObj.getMediaLink().is() && !rObj.getMediaLink()->isLinked() )
++ rItem.setURL( rObj.getMediaLink()->getOrCreateTempFileURL() );
+ }
+
+ // ------------------------------------------------------------------------------
+@@ -128,13 +139,18 @@ void ViewContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rIt
+ {
+ 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);
+ }
+ }
+ }
+diff --git svx/source/sdr/media/makefile.mk svx/source/sdr/media/makefile.mk
+new file mode 100644
+index 0000000..c5e1c6f
+--- /dev/null
++++ svx/source/sdr/media/makefile.mk
+@@ -0,0 +1,48 @@
++#*************************************************************************
++#
++# 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
+diff --git svx/source/sdr/media/mediamanager.cxx svx/source/sdr/media/mediamanager.cxx
+new file mode 100644
+index 0000000..98dff8b
+--- /dev/null
++++ svx/source/sdr/media/mediamanager.cxx
+@@ -0,0 +1,445 @@
++/*************************************************************************
++ *
++ * 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
+diff --git svx/source/svdraw/svdmodel.cxx svx/source/svdraw/svdmodel.cxx
+index 991582d..3339e5e 100644
+--- svx/source/svdraw/svdmodel.cxx
++++ svx/source/svdraw/svdmodel.cxx
+@@ -41,6 +41,8 @@
+ #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>
+@@ -107,6 +109,7 @@ struct SdrModelImpl
+ SfxUndoManager* mpUndoManager;
+ SdrUndoFactory* mpUndoFactory;
+ bool mbAllowShapePropertyChangeListener;
++ rtl::Reference< sdr::media::MediaManager > mxMediaManager;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+@@ -297,6 +300,12 @@ SdrModel::~SdrModel()
+
+ DBG_DTOR(SdrModel,NULL);
+
++ if( mpImpl && mpImpl->mxMediaManager.is() )
++ {
++ mpImpl->mxMediaManager->Dispose();
++ mpImpl->mxMediaManager.clear();
++ }
++
+ mbInDestruction = true;
+
+ Broadcast(SdrHint(HINT_MODELCLEARED));
+@@ -2162,6 +2171,27 @@ const ::com::sun::star::uno::Sequence< sal_Int8 >& SdrModel::getUnoTunnelImpleme
+ 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);
+diff --git svx/source/svdraw/svdomedia.cxx svx/source/svdraw/svdomedia.cxx
+index ee8352b..884d71f 100644
+--- svx/source/svdraw/svdomedia.cxx
++++ svx/source/svdraw/svdomedia.cxx
+@@ -31,11 +31,81 @@
+ // 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 -
+@@ -46,13 +116,15 @@ TYPEINIT1( SdrMediaObj, SdrRectObj );
+ // ------------------------------------------------------------------------------
+
+ SdrMediaObj::SdrMediaObj()
++: mpSdrMediaLink( 0 )
+ {
+ }
+
+ // ------------------------------------------------------------------------------
+
+-SdrMediaObj::SdrMediaObj( const Rectangle& rRect ) :
+- SdrRectObj( rRect )
++SdrMediaObj::SdrMediaObj( const Rectangle& rRect )
++: SdrRectObj( rRect )
++, mpSdrMediaLink( 0 )
+ {
+ }
+
+@@ -60,6 +132,7 @@ SdrMediaObj::SdrMediaObj( const Rectangle& rRect ) :
+
+ SdrMediaObj::~SdrMediaObj()
+ {
++ disconnect();
+ }
+
+ // ------------------------------------------------------------------------------
+@@ -150,6 +223,21 @@ void SdrMediaObj::operator=(const SdrObject& rObj)
+
+ // ------------------------------------------------------------------------------
+
++void SdrMediaObj::setMediaLink( const ::rtl::Reference< sdr::media::MediaLink >& xMediaLink )
++{
++ setGraphic();
++ disconnect();
++ mxMediaLink = xMediaLink;
++ rtl::OUString sURL;
++ if( mxMediaLink.is() )
++ sURL = mxMediaLink->getMediaURL();
++ maMediaProperties.setURL( sURL );
++ connect();
++ static_cast< ::sdr::contact::ViewContactOfSdrMediaObj& >( GetViewContact() ).executeMediaItem( getMediaProperties() );
++}
++
++// ------------------------------------------------------------------------------
++
+ void SdrMediaObj::setURL( const ::rtl::OUString& rURL )
+ {
+ ::avmedia::MediaItem aURLItem;
+@@ -159,6 +247,26 @@ void SdrMediaObj::setURL( const ::rtl::OUString& rURL )
+ }
+
+ // ------------------------------------------------------------------------------
++
++void SdrMediaObj::UpdateURL( const ::rtl::OUString& rURL )
++{
++ setGraphic();
++ maMediaProperties.setURL( rURL );
++
++ ::rtl::Reference< sdr::media::MediaManager > xMediaManager( GetModel()->GetMediaManager() );
++ if( xMediaManager.is() )
++ {
++ mxMediaLink = xMediaManager->getMediaLink( rURL );
++ }
++ else
++ {
++ mxMediaLink.set( new sdr::media::MediaLink( xMediaManager, rURL, !rURL.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.Package:" ) ) ) );
++ }
++ static_cast< ::sdr::contact::ViewContactOfSdrMediaObj& >( GetViewContact() ).executeMediaItem( getMediaProperties() );
++ ActionChanged();
++}
++
++// ------------------------------------------------------------------------------
+
+ const ::rtl::OUString& SdrMediaObj::getURL() const
+ {
+@@ -170,6 +278,28 @@ const ::rtl::OUString& SdrMediaObj::getURL() const
+ void SdrMediaObj::setMediaProperties( const ::avmedia::MediaItem& rState )
+ {
+ mediaPropertiesChanged( rState );
++
++ // use only a subset of MediaItem properties for own own properties
++ if( ( AVMEDIA_SETMASK_URL & rState.getMaskSet() ) && ( rState.getURL() != getURL() ) )
++ {
++ setGraphic();
++ disconnect();
++
++ const OUString sURL( rState.getURL() );
++ maMediaProperties.setURL( sURL );
++
++ ::rtl::Reference< sdr::media::MediaManager > xMediaManager( GetModel()->GetMediaManager() );
++ if( xMediaManager.is() )
++ {
++ mxMediaLink = xMediaManager->getMediaLink( sURL );
++ }
++ else
++ {
++ mxMediaLink.set( new sdr::media::MediaLink( xMediaManager, sURL, !sURL.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.Package:" ) ) ) );
++ }
++ connect();
++ }
++
+ static_cast< ::sdr::contact::ViewContactOfSdrMediaObj& >( GetViewContact() ).executeMediaItem( getMediaProperties() );
+ }
+
+@@ -216,15 +346,25 @@ void SdrMediaObj::setGraphic( const Graphic* pGraphic )
+ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProperties )
+ {
+ const sal_uInt32 nMaskSet = rNewProperties.getMaskSet();
+-
++/*
+ // use only a subset of MediaItem properties for own own properties
+ if( ( AVMEDIA_SETMASK_URL & nMaskSet ) &&
+ ( rNewProperties.getURL() != getURL() ) )
+ {
+ setGraphic();
+ maMediaProperties.setURL( rNewProperties.getURL() );
++
++ ::rtl::Reference< sdr::media::MediaManager > mxMediaManager( GetModel()->GetMediaManager() );
++ if( mxMediaManager.is() )
++ {
++ mxMediaLink = mxMediaManager->getMediaLink( rNewProperties.getURL() );
++ }
++ else
++ {
++ mxMediaLink.clear();
++ }
+ }
+-
++*/
+ if( AVMEDIA_SETMASK_LOOP & nMaskSet )
+ maMediaProperties.setLoop( rNewProperties.isLoop() );
+
+@@ -237,3 +377,107 @@ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProper
+ if( AVMEDIA_SETMASK_ZOOM & nMaskSet )
+ maMediaProperties.setZoom( rNewProperties.getZoom() );
+ }
++
++// -----------------------------------------------------------------------------
++
++void SdrMediaObj::SetPage( SdrPage* pNewPage )
++{
++ const bool bRemove = pNewPage == NULL && pPage != NULL;
++ const bool bInsert = pNewPage != NULL && pPage == NULL;
++
++ if( bRemove )
++ disconnect();
++ SdrRectObj::SetPage( pNewPage );
++ if( bInsert )
++ connect();
++}
++
++// -----------------------------------------------------------------------------
++
++void SdrMediaObj::SetModel( SdrModel* pNewModel )
++{
++ bool bChange = pNewModel != pModel;
++
++ if( bChange )
++ disconnect();
++
++ // Model umsetzen
++ SdrRectObj::SetModel(pNewModel);
++
++ if( bChange )
++ connect();
++}
++
++// -----------------------------------------------------------------------------
++
++// embeds the av link
++void SdrMediaObj::breakLink()
++{
++ if( !mxMediaLink.is() || !mxMediaLink->isLinked() )
++ return;
++
++ const OUString sURL( mxMediaLink->getMediaURL() );
++
++ sdr::media::MediaLinkRef xNewLink;
++
++ rtl::Reference< sdr::media::MediaManager > xMediaManager( mxMediaLink->getMediaManager() );
++ if( xMediaManager.is() )
++ {
++ xNewLink = xMediaManager->insertMediaStream( sURL );
++ }
++ else
++ {
++ // not yet connected to model, just remember link for now
++ xNewLink.set( new sdr::media::MediaLink( xMediaManager, sURL, false ) );
++ }
++
++ setMediaLink( xNewLink );
++}
++
++// -----------------------------------------------------------------------------
++
++void SdrMediaObj::connect()
++{
++ SvxLinkManager* pLinkManager = pModel != NULL ? pModel->GetLinkManager() : NULL;
++ if( pLinkManager )
++ {
++ if( mxMediaLink.is() && mxMediaLink->isLinked() && (mpSdrMediaLink == NULL) )
++ {
++ const String sFileName( mxMediaLink->getMediaURL() );
++ const String sFilterName( mxMediaLink->getFilterName() );
++ const String sMimeType( mxMediaLink->getMimeType() );
++ const ULONG nContentType = (sMimeType.Len() == 0) ? SOT_FORMATSTR_ID_AVMEDIA : SotExchange::RegisterFormatMimeType( sMimeType );
++ mpSdrMediaLink = new SdrMediaLink( this, nContentType );
++ pLinkManager->InsertFileLink( *mpSdrMediaLink, OBJECT_CLIENT_AVMEDIA, sFileName, &sFilterName, NULL );
++ mpSdrMediaLink->Connect();
++ }
++ }
++/*
++ if( mxGraphicLink.is() )
++ {
++ mxGraphicLink->connect( pLinkManager );
++ }
++ else if( getURL().getLength() != 0 )
++ {
++ mxGraphicLink = new
++ }
++ }
++*/
++}
++
++void SdrMediaObj::disconnect()
++{
++ SvxLinkManager* pLinkManager = pModel != NULL ? pModel->GetLinkManager() : NULL;
++
++ if( pLinkManager != NULL && mpSdrMediaLink!=NULL)
++ {
++ // Bei Remove wird *pGraphicLink implizit deleted
++ pLinkManager->Remove( mpSdrMediaLink );
++ mpSdrMediaLink=NULL;
++ }
++/*
++ if( mxGraphicLink.is() )
++ mxGraphicLink->disconnect();
++*/
++}
++
+diff --git svx/source/svxlink/fileobj.cxx svx/source/svxlink/fileobj.cxx
+index a77c885..c19c92c 100644
+--- svx/source/svxlink/fileobj.cxx
++++ svx/source/svxlink/fileobj.cxx
+@@ -30,6 +30,8 @@
+
+ // MARKER(update_precomp.py): autogen include statement, do not remove
+ #include "precompiled_svx.hxx"
++
++#include <avmedia/mediawindow.hxx>
+ #include <vcl/wrkwin.hxx>
+ #include <vcl/msgbox.hxx>
+ #include <tools/urlobj.hxx>
+@@ -268,6 +270,10 @@ BOOL SvFileObject::Connect( sfx2::SvBaseLink* pLink )
+ nType = FILETYPE_TEXT;
+ break;
+
++ case OBJECT_CLIENT_AVMEDIA:
++ nType = FILETYPE_OBJECT;
++ break;
++
+ case OBJECT_CLIENT_OLE:
+ nType = FILETYPE_OBJECT;
+ // TODO/LATER: introduce own type to be used for exchanging
+@@ -492,6 +498,23 @@ void SvFileObject::Edit( Window* pParent, sfx2::SvBaseLink* pLink, const Link& r
+ }
+ break;
+
++ case OBJECT_CLIENT_AVMEDIA:
++ {
++ nType = FILETYPE_OBJECT;
++
++ rtl::OUString aFileURL = sFile;
++ if( avmedia::MediaWindow::executeOpenMediaURLDialog( pParent, aFileURL ) )
++ {
++ sFile = aFileURL;
++ sFile += ::sfx2::cTokenSeperator;
++ sFile += ::sfx2::cTokenSeperator;
++
++ if( aEndEditLink.IsSet() )
++ aEndEditLink.Call( &sFile );
++ }
++ }
++ break;
++
+ case OBJECT_CLIENT_OLE:
+ {
+ nType = FILETYPE_OBJECT; // if not set already
+diff --git svx/source/svxlink/linkmgr.cxx svx/source/svxlink/linkmgr.cxx
+index 5d96e0c..32b2603 100644
+--- svx/source/svxlink/linkmgr.cxx
++++ svx/source/svxlink/linkmgr.cxx
+@@ -80,6 +80,7 @@ sfx2::SvLinkSourceRef SvxLinkManager::CreateObj( sfx2::SvBaseLink * pLink )
+ case OBJECT_CLIENT_FILE:
+ case OBJECT_CLIENT_GRF:
+ case OBJECT_CLIENT_OLE:
++ case OBJECT_CLIENT_AVMEDIA:
+ return new SvFileObject;
+
+ case OBJECT_INTERN:
+@@ -132,6 +133,7 @@ BOOL SvxLinkManager::GetDisplayNames( const sfx2::SvBaseLink* pBaseLink,
+ case OBJECT_CLIENT_FILE:
+ case OBJECT_CLIENT_GRF:
+ case OBJECT_CLIENT_OLE:
++ case OBJECT_CLIENT_AVMEDIA:
+ {
+ USHORT nPos = 0;
+ String sFile( sLNm.GetToken( 0, ::sfx2::cTokenSeperator, nPos ) );
+@@ -146,12 +148,15 @@ BOOL SvxLinkManager::GetDisplayNames( const sfx2::SvBaseLink* pBaseLink,
+
+ if( pType )
+ {
+- sal_uInt16 nObjType = pBaseLink->GetObjType();
+- *pType = String( ResId(
+- ( OBJECT_CLIENT_FILE == nObjType || OBJECT_CLIENT_OLE == nObjType )
+- ? RID_SVXSTR_FILELINK
+- : RID_SVXSTR_GRAFIKLINK
+- , DIALOG_MGR() ));
++ USHORT nId;
++ switch( pBaseLink->GetObjType() )
++ {
++ case OBJECT_CLIENT_GRF: nId = RID_SVXSTR_GRAFIKLINK; break;
++ case OBJECT_CLIENT_AVMEDIA: nId = RID_SVXSTR_AVMEDIALINK; break;
++ default: nId = RID_SVXSTR_FILELINK;
++ }
++
++ *pType = String( ResId(nId, DIALOG_MGR() ) );
+ }
+ bRet = TRUE;
+ }
+diff --git svx/source/svxlink/linkmgr.src svx/source/svxlink/linkmgr.src
+index aca244e..596bd9a 100644
+--- svx/source/svxlink/linkmgr.src
++++ svx/source/svxlink/linkmgr.src
+@@ -37,6 +37,11 @@ String RID_SVXSTR_GRAFIKLINK
+ {
+ Text [ en-US ] = "Graphic" ;
+ };
++String RID_SVXSTR_AVMEDIALINK
++{
++ Text [ en-US ]= "Audio/Video";
++};
++
+ String RID_SVXSTR_EDITGRFLINK
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Grafik Verknüpfen : Grafik Verkn³pfen */
+diff --git svx/util/makefile.mk svx/util/makefile.mk
+index 7165904..1658d13 100644
+--- svx/util/makefile.mk
++++ svx/util/makefile.mk
+@@ -118,7 +118,8 @@ LIB6FILES=\
+ $(SLB)$/unodraw-core.lib \
+ $(SLB)$/unoedit-core.lib \
+ $(SLB)$/xml.lib \
+- $(SLB)$/xout.lib
++ $(SLB)$/xout.lib \
++ $(SLB)$/media.lib
+
+ # Objects needed for the svxmsfilter library.
+ LIB7TARGET= $(SLB)$/$(TARGET)_7.lib
+diff --git sw/source/ui/shells/grfshex.cxx sw/source/ui/shells/grfshex.cxx
+index bb6d1be..a5722e8 100644
+--- sw/source/ui/shells/grfshex.cxx
++++ sw/source/ui/shells/grfshex.cxx
+@@ -99,6 +99,7 @@ using ::rtl::OUString;
+ bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
+ {
+ ::rtl::OUString aURL;
++ sal_Bool bLinked = sal_True;
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ Window* pWindow = &GetView().GetViewFrame()->GetWindow();
+ bool bAPI = false, bRet = false;
+@@ -112,9 +113,15 @@ bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
+ 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( pWindow, aURL ) )
++ if( bAPI || ::avmedia::MediaWindow::executeInsertMediaURLDialog( pWindow, aURL, bLinked ) )
+ {
+ Size aPrefSize;
+
+@@ -162,6 +169,9 @@ bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
+ pObj->setURL( aURL );
+ rSh.EnterStdMode();
+ rSh.SwFEShell::Insert( *pObj, 0, 0, &aPos );
++
++ if( !bLinked )
++ pObj->breakLink();
+ bRet = true;
+
+ if( pWindow )
+diff --git unotools/source/ucbhelper/XTempFile.hxx unotools/source/ucbhelper/XTempFile.hxx
+index 7d867a2..3eefe20 100644
+--- unotools/source/ucbhelper/XTempFile.hxx
++++ unotools/source/ucbhelper/XTempFile.hxx
+@@ -39,7 +39,8 @@
+ #include <com/sun/star/lang/XSingleComponentFactory.hpp>
+ #include <com/sun/star/lang/XMultiServiceFactory.hpp>
+ #include <com/sun/star/lang/XServiceInfo.hpp>
+-#include <cppuhelper/implbase5.hxx>
++#include <com/sun/star/lang/XInitialization.hpp>
++#include <cppuhelper/implbase6.hxx>
+ #ifndef _CPPUHELPER_PROPERTYSETMIXIN_HXX_
+ #include <cppuhelper/propertysetmixin.hxx>
+ #endif
+@@ -48,11 +49,12 @@
+ class SvStream;
+ namespace utl { class TempFile; }
+
+-typedef ::cppu::WeakImplHelper5< ::com::sun::star::io::XTempFile
++typedef ::cppu::WeakImplHelper6< ::com::sun::star::io::XTempFile
+ , ::com::sun::star::io::XInputStream
+ , ::com::sun::star::io::XOutputStream
+ , ::com::sun::star::io::XTruncate
+ , ::com::sun::star::lang::XServiceInfo
++ , ::com::sun::star::lang::XInitialization
+ >
+ OTempFileBase;
+
+@@ -85,6 +87,10 @@ public:
+ throw ();
+ virtual void SAL_CALL release( )
+ throw ();
++
++ // XInitialization
++ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
++
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( )
+ throw (::com::sun::star::uno::RuntimeException);
+diff --git unotools/source/ucbhelper/xtempfile.cxx unotools/source/ucbhelper/xtempfile.cxx
+index 9b9ba49..3fbaaec 100644
+--- unotools/source/ucbhelper/xtempfile.cxx
++++ unotools/source/ucbhelper/xtempfile.cxx
+@@ -31,12 +31,9 @@
+ #include <XTempFile.hxx>
+ #include <cppuhelper/factory.hxx>
+ #include <cppuhelper/typeprovider.hxx>
+-#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP
+ #include <com/sun/star/registry/XRegistryKey.hpp>
+-#endif
+-#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP
+ #include <com/sun/star/beans/PropertyAttribute.hpp>
+-#endif
++#include <com/sun/star/beans/NamedValue.hpp>
+ #include <unotools/tempfile.hxx>
+ #include <osl/file.hxx>
+ #include <unotools/configmgr.hxx>
+@@ -94,6 +91,74 @@ throw ()
+ OTempFileBase::release();
+ }
+
++// XInitialization
++void SAL_CALL OTempFileService::initialize( const ::css::uno::Sequence< ::css::uno::Any >& aArguments ) throw (::css::uno::Exception, ::css::uno::RuntimeException)
++{
++ String aLeadingChars;
++ String aExtension;
++ String aParent;
++
++ sal_Bool bKillingFileEnabled = mpTempFile ? mpTempFile->IsKillingFileEnabled() : sal_False;
++ rtl::OUString sTmp;
++ bool recreate = false;
++
++ String* pExtension=NULL;
++ String* pParent=NULL;
++
++ sal_Int32 nIndex = aArguments.getLength();
++ while( nIndex )
++ {
++ ::css::beans::NamedValue aValue;
++ if( aArguments[--nIndex] >>= aValue )
++ {
++ if( aValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "LeadingChars" ) ) )
++ {
++ if( !(aValue.Value >>= sTmp) )
++ throw ::css::lang::IllegalArgumentException();
++
++ aLeadingChars = sTmp;
++ recreate = true;
++ }
++ else if( aValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Extension" ) ) )
++ {
++ if( !(aValue.Value >>= sTmp) )
++ throw ::css::lang::IllegalArgumentException();
++
++ aExtension = sTmp;
++ pExtension = &aExtension;
++ recreate = true;
++ }
++ else if( aValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Parent" ) ) )
++ {
++ if( !(aValue.Value >>= sTmp) )
++ throw ::css::lang::IllegalArgumentException();
++
++ aParent = sTmp;
++ pParent = &aParent;
++ recreate = true;
++ }
++ else if( aValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "KillingFileEnabled" ) ) )
++ {
++ if( !(aValue.Value >>= bKillingFileEnabled) )
++ throw ::css::lang::IllegalArgumentException();
++ }
++ }
++ }
++
++ if( recreate )
++ {
++ if( mpTempFile )
++ {
++ mpTempFile->EnableKillingFile();
++ delete mpTempFile;
++ }
++ mpTempFile = new utl::TempFile( aLeadingChars, pExtension, pParent, /* no directory */ sal_False );
++ }
++
++ if( mpTempFile && (mpTempFile->IsKillingFileEnabled() != bKillingFileEnabled) )
... etc. - the rest is truncated
More information about the ooo-build-commit
mailing list