[ooo-build-commit] .: 2 commits - patches/dev300
Thorsten Behrens
thorsten at kemper.freedesktop.org
Mon Aug 16 05:31:19 PDT 2010
patches/dev300/apply | 17
patches/dev300/cws-impressmedia01-backport.diff | 2469 ---------------
patches/dev300/cws-impressmedia01-crash-fix.diff | 44
patches/dev300/cws-impressmedia01-pptin.diff | 364 --
patches/dev300/cws-impressmedia01-slotparams-fix.diff | 85
patches/dev300/impressmedia-features.diff | 2905 ++++++++++++++++++
patches/dev300/svx-sound.diff | 28
7 files changed, 2922 insertions(+), 2990 deletions(-)
New commits:
commit e718f1ebc065c0fac4d59067ffaf0e499b4b66b0
Author: Thorsten Behrens <thb at openoffice.org>
Date: Mon Aug 16 14:24:26 2010 +0200
Folded more stuff into impressmedia patch
* patches/dev300/apply: folded svx/sd-sound patches into
impressmedia patch, which is heavily interrelated. moved
slideshow-sound patch into that section, too (you'll otherwise
get Invalid args exceptions in slideshow)
* patches/dev300/cws-impressmedia01-backport.diff: renamed
* patches/dev300/impressmedia-features.diff: now called this
diff --git a/patches/dev300/apply b/patches/dev300/apply
index d8a0d15..70cb5ae 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -3544,14 +3544,12 @@ SectionOwner => thorsten
transogl-crossplatform.diff, ericb
[ Features ]
-# embed generic media files inside odf docs, 1st part
-# FIXME: svx-sound.diff depends on this diff
-cws-impressmedia01-backport.diff, i#83753, thorsten
+# embed generic media files inside odf docs, plus various related
+# sound fixes from rodo
+impressmedia-features.diff, i#83753, n#515553, thorsten
+slideshow-sound.diff, n#515553, rodo
[ Fixes ]
-svx-sound.diff, n#515553, rodo
-# sd-sound.diff, n#515553, rodo #depends on svx-sound.diff
-slideshow-sound.diff, n#515553, rodo
vcl-gtk-process-events-on-exit.diff, rodo
sfx2-add-to-recently-used-after-save.diff, rodo
diff --git a/patches/dev300/cws-impressmedia01-backport.diff b/patches/dev300/cws-impressmedia01-backport.diff
deleted file mode 100644
index 33b2ade..0000000
--- a/patches/dev300/cws-impressmedia01-backport.diff
+++ /dev/null
@@ -1,2905 +0,0 @@
-Impress media embedding CWS backport
-
-From: Thorsten Behrens <thb at openoffice.org>
-
-
----
-
- avmedia/inc/avmedia/mediawindow.hxx | 23 +
- avmedia/source/framework/mediacontrol.cxx | 2
- avmedia/source/framework/mediaplayer.cxx | 8
- avmedia/source/viewer/mediawindow.cxx | 118 ++++
- cui/source/dialogs/cuigaldlg.cxx | 6
- cui/source/dialogs/linkdlg.cxx | 11
- 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
- .../win32/filepicker/VistaFilePickerImpl.cxx | 4
- .../sun/star/ui/dialogs/TemplateDescription.idl | 8
- sc/source/ui/drawfunc/fuins1.cxx | 18 +
- sc/source/ui/view/tabvwsh9.cxx | 4
- sd/source/core/drawdoc.cxx | 8
- sd/source/filter/ppt/pptin.cxx | 102 +---
- sd/source/filter/ppt/pptin.hxx | 5
- sd/source/filter/ppt/pptinanimations.cxx | 6
- sd/source/ui/func/fuinsert.cxx | 11
- sd/source/ui/view/drviews9.cxx | 4
- sd/source/ui/view/sdview4.cxx | 82 ++-
- sfx2/inc/sfx2/lnkbase.hxx | 1
- sfx2/inc/sfx2/sfx.hrc | 1
- sfx2/sdi/sfx.sdi | 2
- sfx2/source/appl/fileobj.cxx | 22 +
- sfx2/source/appl/linkmgr2.cxx | 15 -
- sfx2/source/appl/sfx.src | 6
- sfx2/source/dialog/filedlghelper.cxx | 11
- sot/inc/sot/formats.hxx | 3
- sot/source/base/exchange.cxx | 1
- svx/inc/svx/sdr/media/medialink.hxx | 81 +++
- svx/inc/svx/sdr/media/mediamanager.hxx | 92 +++
- svx/inc/svx/svdmodel.hxx | 9
- svx/inc/svx/svdomedia.hxx | 16 +
- svx/prj/build.lst | 3
- svx/prj/d.lst | 4
- .../sdr/contact/viewcontactofsdrmediaobj.cxx | 20 +
- svx/source/sdr/media/makefile.mk | 48 ++
- svx/source/sdr/media/mediamanager.cxx | 527 ++++++++++++++++++++
- svx/source/svdraw/svdmodel.cxx | 30 +
- svx/source/svdraw/svdomedia.cxx | 257 +++++++++-
- svx/util/makefile.mk | 3
- sw/source/ui/shells/basesh.cxx | 4
- sw/source/ui/shells/grfshex.cxx | 12
- unotools/source/ucbhelper/XTempFile.hxx | 10
- unotools/source/ucbhelper/xtempfile.cxx | 73 +++
- xmloff/source/draw/shapeexport2.cxx | 14 -
- xmloff/source/draw/ximpshap.cxx | 8
- 53 files changed, 1563 insertions(+), 188 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 8643318..c4516aa 100644
---- avmedia/inc/avmedia/mediawindow.hxx
-+++ avmedia/inc/avmedia/mediawindow.hxx
-@@ -61,7 +61,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;
-
-@@ -146,7 +159,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 );
-
-@@ -157,6 +175,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 178ee23..1b959a0 100644
---- avmedia/source/framework/mediacontrol.cxx
-+++ avmedia/source/framework/mediacontrol.cxx
-@@ -521,7 +521,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/framework/mediaplayer.cxx avmedia/source/framework/mediaplayer.cxx
-index 669f861..7af7034 100644
---- avmedia/source/framework/mediaplayer.cxx
-+++ avmedia/source/framework/mediaplayer.cxx
-@@ -33,6 +33,7 @@
- #include "helpids.hrc"
-
- #include <svl/stritem.hxx>
-+#include <svl/eitem.hxx>
- #include <sfx2/app.hxx>
- #include <sfx2/sfxsids.hrc>
- #include <sfx2/bindings.hxx>
-@@ -159,7 +160,12 @@ void MediaFloater::dispatchCurrentURL()
- if( pDispatcher )
- {
- const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, getURL() );
-- pDispatcher->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_RECORD, &aMediaURLItem, 0L );
-+ const SfxBoolItem aLinkFlagItem( FN_PARAM_1, FALSE );
-+ pDispatcher->Execute( SID_INSERT_AVMEDIA,
-+ SFX_CALLMODE_RECORD,
-+ &aMediaURLItem,
-+ &aLinkFlagItem,
-+ 0L );
- }
- }
-
-diff --git avmedia/source/viewer/mediawindow.cxx avmedia/source/viewer/mediawindow.cxx
-index e9ade6d..0db22b7 100644
---- avmedia/source/viewer/mediawindow.cxx
-+++ avmedia/source/viewer/mediawindow.cxx
-@@ -39,6 +39,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
-
-@@ -362,35 +364,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 )
-+ while( *pFilters )
- {
-- rFilterNameVector.push_back( ::std::make_pair< ::rtl::OUString, ::rtl::OUString >(
-- ::rtl::OUString::createFromAscii( pFilters[ i ] ),
-- ::rtl::OUString::createFromAscii( pFilters[ i + 1 ] ) ) );
-+ rFilterNameVector.push_back( FilterInfo( ::rtl::OUString::createFromAscii( pFilters[0] ),
-+ ::rtl::OUString::createFromAscii( pFilters[1] ),
-+ ::rtl::OUString::createFromAscii( pFilters[2] ) ) );
-+ pFilters += 3;
-+ }
-+}
-+
-+// -------------------------------------------------------------------------
-+
-+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 )
-+{
-+ return executeMediaURLDialogImpl( pParent, rURL, rLink, true );
- }
-
- // -------------------------------------------------------------------------
-
--bool MediaWindow::executeMediaURLDialog( Window* /* pParent */, ::rtl::OUString& rURL, bool bInsertDialog )
-+bool MediaWindow::executeOpenMediaURLDialog( Window* pParent, ::rtl::OUString& rURL )
- {
-- ::sfx2::FileDialogHelper aDlg( com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
-+ 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( ";" ) );
-@@ -408,7 +470,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 );
- }
- }
-
-@@ -424,11 +486,11 @@ 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
-@@ -438,6 +500,16 @@ bool MediaWindow::executeMediaURLDialog( Window* /* pParent */, ::rtl::OUString&
- {
- const INetURLObject aURL( aDlg.GetPath() );
- 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();
-@@ -512,7 +584,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 cui/source/dialogs/cuigaldlg.cxx cui/source/dialogs/cuigaldlg.cxx
-index 9e07923..46d4202 100644
---- cui/source/dialogs/cuigaldlg.cxx
-+++ cui/source/dialogs/cuigaldlg.cxx
-@@ -918,8 +918,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 );
- }
-@@ -955,7 +955,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 cui/source/dialogs/linkdlg.cxx cui/source/dialogs/linkdlg.cxx
-index 965aefe..c72f3ff 100644
---- cui/source/dialogs/linkdlg.cxx
-+++ cui/source/dialogs/linkdlg.cxx
-@@ -202,8 +202,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
- {
-@@ -632,7 +635,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);
- aFileName = INetURLObject::decode(aFileName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS);
-
- if( aFileName.Len() > aTxt.Len() )
-@@ -643,7 +646,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 fpicker/source/aqua/ControlHelper.cxx fpicker/source/aqua/ControlHelper.cxx
-index 2909675..20409d5 100644
---- fpicker/source/aqua/ControlHelper.cxx
-+++ fpicker/source/aqua/ControlHelper.cxx
-@@ -152,6 +152,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 f48275c..5976af3 100644
---- fpicker/source/aqua/SalAquaFilePicker.cxx
-+++ fpicker/source/aqua/SalAquaFilePicker.cxx
-@@ -552,6 +552,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 980a197..0e18cf5 100644
---- fpicker/source/office/OfficeFilePicker.cxx
-+++ fpicker/source/office/OfficeFilePicker.cxx
-@@ -311,6 +311,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 c92df17..462c491 100644
---- fpicker/source/unx/gnome/SalGtkFilePicker.cxx
-+++ fpicker/source/unx/gnome/SalGtkFilePicker.cxx
-@@ -1721,6 +1721,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 744e19f..e7ab9b0 100644
---- fpicker/source/unx/kde4/KDE4FilePicker.cxx
-+++ fpicker/source/unx/kde4/KDE4FilePicker.cxx
-@@ -671,6 +671,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 3661771..fca2a8c 100644
---- fpicker/source/win32/filepicker/FPServiceInfo.hxx
-+++ fpicker/source/win32/filepicker/FPServiceInfo.hxx
-@@ -63,6 +63,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 67b2124..eca066c 100644
---- fpicker/source/win32/filepicker/FilePicker.cxx
-+++ fpicker/source/win32/filepicker/FilePicker.cxx
-@@ -698,7 +698,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..f914084 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 b6cff99..ca67a93 100644
---- fpicker/source/win32/filepicker/VistaFilePicker.cxx
-+++ fpicker/source/win32/filepicker/VistaFilePicker.cxx
-@@ -626,6 +626,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/VistaFilePickerImpl.cxx fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
-index 85ed779..35afa41 100644
---- fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
-+++ fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
-@@ -505,6 +505,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 6990845..9d231bb 100644
---- offapi/com/sun/star/ui/dialogs/TemplateDescription.idl
-+++ offapi/com/sun/star/ui/dialogs/TemplateDescription.idl
-@@ -134,6 +134,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 70243ac..6229107 100644
---- sc/source/ui/drawfunc/fuins1.cxx
-+++ sc/source/ui/drawfunc/fuins1.cxx
-@@ -209,7 +209,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();
-@@ -234,8 +234,11 @@ void lcl_InsertMedia( const ::rtl::OUString& rMediaURL, bool bApi,
-
- SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aInsertPos, aSize ) );
-
-- pObj->setURL( rMediaURL );
- pView->InsertObjectAtView( pObj, *pPV, bApi ? SDRINSERT_DONTMARK : 0 );
-+
-+ pObj->setURL( rMediaURL );
-+ if( !bLinked )
-+ pObj->breakLink();
- }
-
- /*************************************************************************
-@@ -385,6 +388,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;
-
-@@ -397,9 +401,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;
-
-@@ -416,7 +426,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 sc/source/ui/view/tabvwsh9.cxx sc/source/ui/view/tabvwsh9.cxx
-index d1beb28..8195790 100644
---- sc/source/ui/view/tabvwsh9.cxx
-+++ sc/source/ui/view/tabvwsh9.cxx
-@@ -151,7 +151,9 @@ void ScTabViewShell::ExecGallery( SfxRequest& rReq )
- if ( pGal )
- {
- const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
-- GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
-+ const SfxBoolItem aLinkFlagItem( FN_PARAM_1, FALSE );
-+ GetViewFrame()->GetDispatcher()->Execute(
-+ SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, &aLinkFlagItem, 0L );
- }
- }
- }
-diff --git sd/source/core/drawdoc.cxx sd/source/core/drawdoc.cxx
-index c8e61c4..fa61e1b 100644
---- sd/source/core/drawdoc.cxx
-+++ sd/source/core/drawdoc.cxx
-@@ -53,6 +53,7 @@
- #include <svl/flagitem.hxx>
- #include <svx/svdoattr.hxx>
- #include <svx/svdotext.hxx>
-+#include <svx/sdr/media/mediamanager.hxx>
- #include <editeng/bulitem.hxx>
- #include <editeng/numitem.hxx>
- #include <svx/svditer.hxx>
-@@ -188,6 +189,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
-@@ -348,7 +352,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh)
- *
- * Es werden auf Pages und MasterPages folgende Default-Layer angelegt:
- *
-- * Layer STR_LAYOUT : Standardlayer fr alle Zeichenobjekte
-+ * Layer STR_LAYOUT : Standardlayer fÂr alle Zeichenobjekte
- *
- * Layer STR_BCKGRND : Hintergrund der MasterPage
- * (auf normalen Pages z.Z. keine Verwendung)
-@@ -356,7 +360,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh)
- * Layer STR_BCKGRNDOBJ: Objekte auf dem Hintergrund der MasterPage
- * (auf normalen Pages z.Z. keine Verwendung)
- *
-- * Layer STR_CONTROLS : Standardlayer fr Controls
-+ * Layer STR_CONTROLS : Standardlayer fÂr Controls
- *
- **************************************************************************/
- {
-diff --git sd/source/filter/ppt/pptin.cxx sd/source/filter/ppt/pptin.cxx
-index 723fcbd..3d47afd 100755
---- sd/source/filter/ppt/pptin.cxx
-+++ sd/source/filter/ppt/pptin.cxx
-@@ -56,6 +56,7 @@
- #include <editeng/lrspitem.hxx>
- #include <editeng/lspcitem.hxx>
- #include <editeng/tstpitem.hxx>
-+#include <svx/sdr/media/mediamanager.hxx>
-
- #include <sfx2/docinf.hxx>
-
-@@ -1819,8 +1820,9 @@ void ImplSdPPTImport::ImportPageEffect( SdPage* pPage, const sal_Bool bNewAnimat
- if ( nBuildFlags & 16 )
- { // Dia mit Soundeffekt
- pPage->SetSound( TRUE );
-- String aSoundFile( ReadSound( nSoundRef ) );
-- pPage->SetSoundFile( aSoundFile );
-+ sdr::media::MediaLinkRef aSoundFile( ReadSound( nSoundRef ) );
-+ if ( aSoundFile.is() )
-+ pPage->SetSoundFile( aSoundFile->getMediaURL() );
- }
- if ( nBuildFlags & ( 1 << 6 ) ) // Loop until next sound
- pPage->SetLoopSound( sal_True );
-@@ -1903,9 +1905,13 @@ void ImplSdPPTImport::ImportPageEffect( SdPage* pPage, const sal_Bool bNewAnimat
- //
- ///////////////////////////////////////////////////////////////////////////
-
--String ImplSdPPTImport::ReadSound(UINT32 nSoundRef) const
-+sdr::media::MediaLinkRef ImplSdPPTImport::ReadSound(UINT32 nSoundRef) const
- {
-- String aRetval;
-+ ::rtl::Reference< sdr::media::MediaManager > xMediaManager(
-+ GetModel()->GetMediaManager() );
-+
-+ String aURL;
-+ sdr::media::MediaLinkRef aRetval;
- UINT32 nPosMerk = rStCtrl.Tell();
- DffRecordHeader aDocHd;
- if ( SeekToDocument( &aDocHd ) )
-@@ -1936,70 +1942,19 @@ String ImplSdPPTImport::ReadSound(UINT32 nSoundRef) const
- rStCtrl.Seek( nPosMerk2 );
- if ( SeekToRec( rStCtrl, PPT_PST_CString, nStrLen, NULL, 0 ) )
- {
-- ReadString( aRetval );
-+ ReadString( aURL );
- bDone = TRUE;
- }
- }
- }
- if ( bDone )
- {
-- // ueberpruefen, ob diese Sound-Datei schon
-- // existiert. Wenn nicht, exportiere diese
-- // in unser lokales Sound-Verzeichnis.
-- BOOL bSoundExists = FALSE;
-- List* pSoundList = new List();
--
-- GalleryExplorer::FillObjList( GALLERY_THEME_SOUNDS, *pSoundList );
-- GalleryExplorer::FillObjList( GALLERY_THEME_USERSOUNDS, *pSoundList );
--
-- for( ULONG n = 0; ( n < pSoundList->Count() ) && !bSoundExists; n++ )
-+ rStCtrl.Seek( nPosMerk2 );
-+ DffRecordHeader aSoundDataRecHd;
-+ if ( SeekToRec( rStCtrl, PPT_PST_SoundData, nStrLen, &aSoundDataRecHd, 0 ) )
- {
-- INetURLObject aURL( *(String*)pSoundList->GetObject( n ) );
-- String aSoundName( aURL.GetName() );
--
-- if( aSoundName == aRetval )
-- {
-- aRetval = *(String*)pSoundList->GetObject( n );
-- bSoundExists = TRUE;
-- }
-- }
--
-- for ( void* pPtr = pSoundList->First(); pPtr; pPtr = pSoundList->Next() )
-- delete (String*)pPtr;
--
-- delete pSoundList;
--
-- if ( !bSoundExists )
-- {
-- rStCtrl.Seek( nPosMerk2 );
-- DffRecordHeader aSoundDataRecHd;
-- if ( SeekToRec( rStCtrl, PPT_PST_SoundData, nStrLen, &aSoundDataRecHd, 0 ) )
-- {
-- String aGalleryDir( SvtPathOptions().GetGalleryPath() );
-- INetURLObject aGalleryUserSound( aGalleryDir.GetToken( aGalleryDir.GetTokenCount( ';' ) - 1 ) );
--
-- aGalleryUserSound.Append( aRetval );
-- UINT32 nSoundDataLen = aSoundDataRecHd.nRecLen;
-- UINT8* pBuf = new UINT8[ nSoundDataLen ];
--
-- rStCtrl.Read( pBuf, nSoundDataLen );
-- SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aGalleryUserSound.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC );
--
-- if( pOStm )
-- {
-- pOStm->Write( pBuf, nSoundDataLen );
--
-- if( pOStm->GetError() == ERRCODE_NONE )
-- {
-- GalleryExplorer::InsertURL( GALLERY_THEME_USERSOUNDS, aGalleryUserSound.GetMainURL( INetURLObject::NO_DECODE ) );
-- aRetval = aGalleryUserSound.GetMainURL( INetURLObject::NO_DECODE );
-- }
--
-- delete pOStm;
-- }
--
-- delete[] pBuf;
-- }
-+ // shove bytes over to media manager
-+ aRetval = xMediaManager->insertMediaStream(aURL, rStCtrl, aSoundDataRecHd.nRecLen);
- }
- }
- if ( !bDone )
-@@ -2017,9 +1972,12 @@ String ImplSdPPTImport::ReadSound(UINT32 nSoundRef) const
- //
- //////////////////////////////////////////////////////////////////////////
-
--String ImplSdPPTImport::ReadMedia( sal_uInt32 nMediaRef ) const
-+sdr::media::MediaLinkRef ImplSdPPTImport::ReadMedia( sal_uInt32 nMediaRef, bool& o_bLoop ) const
- {
- String aRetVal;
-+ ::rtl::Reference< sdr::media::MediaManager > xMediaManager(
-+ GetModel()->GetMediaManager() );
-+
- DffRecordHeader* pHd( const_cast<ImplSdPPTImport*>(this)->aDocRecManager.GetRecordHeader( PPT_PST_ExObjList, SEEK_FROM_BEGINNING ) );
- if ( pHd )
- {
-@@ -2076,7 +2034,7 @@ String ImplSdPPTImport::ReadMedia( sal_uInt32 nMediaRef ) const
- aHdMovie.SeekToEndOfRecord( rStCtrl );
- }
- }
-- return aRetVal;
-+ return xMediaManager->insertMediaStream(aRetVal);
- }
-
- //////////////////////////////////////////////////////////////////////////
-@@ -2090,7 +2048,8 @@ void ImplSdPPTImport::FillSdAnimationInfo( SdAnimationInfo* pInfo, PptInteractiv
- // Lokale Informationen in pInfo eintragen
- if( pIAtom->nSoundRef )
- {
-- pInfo->SetBookmark( ReadSound( pIAtom->nSoundRef ) ); // Pfad zum Soundfile in MSDOS-Notation
-+ sdr::media::MediaLinkRef aSoundFile( ReadSound( pIAtom->nSoundRef ) );
-+ pInfo->SetBookmark( aSoundFile->getMediaURL() ); // Pfad zum Soundfile in MSDOS-Notation
- pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_SOUND; // RunProgramAction
- }
- // if ( nFlags & 0x01 ) // koennen wir nicht ( beim Anklicken markieren )
-@@ -2634,7 +2593,10 @@ SdrObject* ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
- pAnimation->SetDimColor( MSO_CLR_ToColor(pAnimation->GetDimColor()).GetColor() );
- // translate sound bits to file url
- if( pAnimation->HasSoundEffect() )
-- pAnimation->SetSoundFileUrl( ReadSound( pAnimation->GetSoundRef() ) );
-+ {
-+ sdr::media::MediaLinkRef aSoundFile( ReadSound( pAnimation->GetSoundRef() ) );
-+ pAnimation->SetSoundFileUrl( aSoundFile->getMediaURL() );
-+ }
-
- bool bDontAnimateInvisibleShape = false;
- {
-@@ -2693,10 +2655,10 @@ SdrObject* ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
- {
- sal_uInt32 nRef;
- rSt >> nRef;
-- String aMediaURL( ReadMedia( nRef ) );
-- if ( !aMediaURL.Len() )
-- aMediaURL = ReadSound( nRef );
-- if ( aMediaURL.Len() )
-+ sdr::media::MediaLinkRef aMediaLink( ReadMedia( nRef, bLoop ) );
-+ if ( !aMediaLink.is() )
-+ aMediaLink = ReadSound( nRef );
-+ if ( aMediaLink.is() )
- {
- SdrMediaObj* pMediaObj = new SdrMediaObj( pObj->GetSnapRect() );
- pMediaObj->SetModel( pObj->GetModel() );
-@@ -2716,7 +2678,7 @@ SdrObject* ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
- //--
-
- SdrObject::Free( pObj ), pObj = pMediaObj; // SJ: hoping that pObj is not inserted in any list
-- pMediaObj->setURL( aMediaURL );
-+ pMediaObj->setMediaLink( aMediaLink );
- }
- }
- }
-diff --git sd/source/filter/ppt/pptin.hxx sd/source/filter/ppt/pptin.hxx
-index 6eae4d8..81cbc2e 100644
---- sd/source/filter/ppt/pptin.hxx
-+++ sd/source/filter/ppt/pptin.hxx
-@@ -30,6 +30,7 @@
-
- #include <filter/msfilter/svdfppt.hxx>
- #include <svx/msdffdef.hxx>
-+#include <svx/sdr/media/medialink.hxx>
- #include <diadef.h>
- #include <svx/svdtypes.hxx>
- #include <filter/msfilter/msfiltertracer.hxx>
-@@ -81,8 +82,8 @@ class ImplSdPPTImport : public SdrPowerPointImport
-
- public:
-
-- String ReadSound( sal_uInt32 nSoundRef ) const;
-- String ReadMedia( sal_uInt32 nMediaRef ) const;
-+ sdr::media::MediaLinkRef ReadSound( sal_uInt32 nSoundRef ) const;
-+ sdr::media::MediaLinkRef ReadMedia( sal_uInt32 nMediaRef, bool& o_bLoop ) const;
-
- ImplSdPPTImport( SdDrawDocument* pDoc, SvStorage& rStorage, SfxMedium& rMed, PowerPointImportParam& );
- ~ImplSdPPTImport();
-diff --git sd/source/filter/ppt/pptinanimations.cxx sd/source/filter/ppt/pptinanimations.cxx
-index 43184fe..892415f 100755
---- sd/source/filter/ppt/pptinanimations.cxx
-+++ sd/source/filter/ppt/pptinanimations.cxx
-@@ -3112,9 +3112,9 @@ sal_Int32 AnimationImporter::importTargetElementContainer( const Atom* pAtom, An
-
- case 2: // sound
- {
-- OUString aSoundURL( ((ImplSdPPTImport*)mpPPTImport)->ReadSound( nRefId ) );
-- rTarget <<= aSoundURL;
-- dump( " srcRef=\"%s\"", aSoundURL );
-+ sdr::media::MediaLinkRef aSound( ((ImplSdPPTImport*)mpPPTImport)->ReadSound( nRefId ) );
-+ rTarget <<= aSound->getMediaURL();
-+ dump( " srcRef=\"%s\"", aSound->getMediaURL() );
- }
- break;
- case 3: // audio object
-diff --git sd/source/ui/func/fuinsert.cxx sd/source/ui/func/fuinsert.cxx
-index 916a512..06bef6c 100755
---- sd/source/ui/func/fuinsert.cxx
-+++ sd/source/ui/func/fuinsert.cxx
-@@ -727,6 +727,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;
-
-@@ -739,9 +740,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;
-
-@@ -760,7 +767,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/drviews9.cxx sd/source/ui/view/drviews9.cxx
-index 31fd7fb..c4b5a91 100644
---- sd/source/ui/view/drviews9.cxx
-+++ sd/source/ui/view/drviews9.cxx
-@@ -217,7 +217,9 @@ void DrawViewShell::ExecGallery(SfxRequest& rReq)
- else if( nFormats & SGA_FORMAT_SOUND )
- {
- const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
-- GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
-+ const SfxBoolItem aLinkFlagItem( FN_PARAM_1, FALSE );
-+ GetViewFrame()->GetDispatcher()->Execute(
-+ SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, &aLinkFlagItem, 0L );
- }
-
- GetDocSh()->SetWaitCursor( FALSE );
-diff --git sd/source/ui/view/sdview4.cxx sd/source/ui/view/sdview4.cxx
-index 9ec90c5..ff0b0d5 100755
---- sd/source/ui/view/sdview4.cxx
-+++ sd/source/ui/view/sdview4.cxx
-@@ -300,53 +300,61 @@ SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAc
- pPV = 0L;
- }
-
-- if( !pPickObj && pPV )
-+ if( 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 );
-+ if( !pPickObj )
-+ {
-+ SdrPageView* pPageView = pPV;
-+ PickObj(rPos, getHitTolLog(), pPickObj, pPageView);
-+ }
-
-- BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
-- ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
-- EndUndo();
-- }
-- else if( pPV )
-- {
-- Rectangle aRect( rPos, rSize );
-- if( pPickObj )
-- aRect = pPickObj->GetLogicRect();
-+ 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
-+ {
-+ Rectangle aRect( rPos, rSize );
-+ if( pPickObj )
-+ aRect = pPickObj->GetLogicRect();
-
-- pNewMediaObj = new SdrMediaObj( aRect );
-+ pNewMediaObj = new SdrMediaObj( aRect );
-
-- bool bIsPres = false;
-- if( pPickObj )
-- {
-- SdPage* pPage = static_cast< SdPage* >(pPickObj->GetPage());
-- bIsPres = pPage && pPage->IsPresObj(pPickObj);
-- if( bIsPres )
-+ bool bIsPres = false;
-+ if( pPickObj )
- {
-- pPage->InsertPresObj( pNewMediaObj, PRESOBJ_MEDIA );
-+ SdPage* pPage = static_cast< SdPage* >(pPickObj->GetPage());
-+ bIsPres = pPage && pPage->IsPresObj(pPickObj);
-+ if( bIsPres )
-+ {
-+ pPage->InsertPresObj( pNewMediaObj, PRESOBJ_MEDIA );
-+ }
- }
-- }
-
-- if( pPickObj )
-- ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
-- else
-- InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER );
-+ if( pPickObj )
-+ ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
-+ else
-+ InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER );
-
-- pNewMediaObj->setURL( rMediaURL );
-+ pNewMediaObj->setURL( rMediaURL );
-
-- if( pPickObj )
-- {
-- pNewMediaObj->AdjustToMaxRect( pPickObj->GetLogicRect() );
-- if( bIsPres )
-- pNewMediaObj->SetUserCall(pPickObj->GetUserCall());
-+ if( pPickObj )
-+ {
-+ pNewMediaObj->AdjustToMaxRect( pPickObj->GetLogicRect() );
-+ if( bIsPres )
-+ pNewMediaObj->SetUserCall(pPickObj->GetUserCall());
-+ }
-+
-+ if( pNewMediaObj && (mnAction != DND_ACTION_LINK) )
-+ {
-+ // embed av target
-+ pNewMediaObj->breakLink();
-+ }
- }
- }
-
-diff --git sfx2/inc/sfx2/lnkbase.hxx sfx2/inc/sfx2/lnkbase.hxx
-index a719411..67c894d 100644
---- sfx2/inc/sfx2/lnkbase.hxx
-+++ sfx2/inc/sfx2/lnkbase.hxx
-@@ -65,6 +65,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/inc/sfx2/sfx.hrc sfx2/inc/sfx2/sfx.hrc
-index 8c58159..6071c16 100755
---- sfx2/inc/sfx2/sfx.hrc
-+++ sfx2/inc/sfx2/sfx.hrc
-@@ -362,6 +362,7 @@
- #define RID_SFXQB_SET_LANGUAGE (RID_OPTIONS_START + 10)
- #define RID_ITEMLIST_LINGU (RID_OPTIONS_START + 11)
- #define RID_SFXPAGE_PRINTOPTIONS (RID_OPTIONS_START + 12)
-+#define RID_SFXSTR_AVMEDIALINK (RID_OPTIONS_START + 13)
-
- #define STR_UNDO (RID_SFX_VIEW_START+11)
- #define STR_REDO (RID_SFX_VIEW_START+12)
-diff --git sfx2/sdi/sfx.sdi sfx2/sdi/sfx.sdi
-index 30a7398..92a839b 100755
---- sfx2/sdi/sfx.sdi
-+++ sfx2/sdi/sfx.sdi
-@@ -7960,7 +7960,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/appl/fileobj.cxx sfx2/source/appl/fileobj.cxx
-index 158fbb3..ee0ea79 100644
---- sfx2/source/appl/fileobj.cxx
-+++ sfx2/source/appl/fileobj.cxx
-@@ -28,6 +28,7 @@
- // MARKER(update_precomp.py): autogen include statement, do not remove
- #include "precompiled_sfx2.hxx"
-
-+#include <avmedia/mediawindow.hxx>
- #include <vcl/wrkwin.hxx>
- #include <vcl/msgbox.hxx>
- #include <tools/urlobj.hxx>
-@@ -260,6 +261,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
-@@ -481,6 +486,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 sfx2/source/appl/linkmgr2.cxx sfx2/source/appl/linkmgr2.cxx
-index 758f5e0..b9619d2 100644
---- sfx2/source/appl/linkmgr2.cxx
-+++ sfx2/source/appl/linkmgr2.cxx
-@@ -273,6 +273,7 @@ BOOL LinkManager::GetDisplayNames( const SvBaseLink * pLink,
- 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 ) );
-@@ -287,11 +288,14 @@ BOOL LinkManager::GetDisplayNames( const SvBaseLink * pLink,
-
- if( pType )
- {
-- sal_uInt16 nObjType = pLink->GetObjType();
-- *pType = String( SfxResId(
-- ( OBJECT_CLIENT_FILE == nObjType || OBJECT_CLIENT_OLE == nObjType )
-- ? RID_SVXSTR_FILELINK
-- : RID_SVXSTR_GRAFIKLINK ));
-+ USHORT nId;
-+ switch( pLink->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( SfxResId(nId) );
- }
- bRet = TRUE;
- }
-@@ -391,6 +395,7 @@ SvLinkSourceRef LinkManager::CreateObj( SvBaseLink * pLink )
- case OBJECT_CLIENT_FILE:
- case OBJECT_CLIENT_GRF:
- case OBJECT_CLIENT_OLE:
-+ case OBJECT_CLIENT_AVMEDIA:
- return new SvFileObject;
- case OBJECT_INTERN:
- return new SvxInternalLink;
-diff --git sfx2/source/appl/sfx.src sfx2/source/appl/sfx.src
-index 6802197..63ccc6f 100644
---- sfx2/source/appl/sfx.src
-+++ sfx2/source/appl/sfx.src
-@@ -1,4 +1,4 @@
--/*************************************************************************
-+/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
-@@ -131,3 +131,7 @@ String STR_ERRUNOEVENTBINDUNG
- Text [ en-US ] = "An appropriate component method %1\ncould not be found.\n\nCheck spelling of method name.";
- };
-
-+String RID_SFXSTR_AVMEDIALINK
-+{
-+ Text [ en-US ]= "Audio/Video";
-+};
-diff --git sfx2/source/dialog/filedlghelper.cxx sfx2/source/dialog/filedlghelper.cxx
-index 3bab58f..7a38eae 100644
---- sfx2/source/dialog/filedlghelper.cxx
-+++ sfx2/source/dialog/filedlghelper.cxx
-@@ -938,6 +938,8 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
- mbHasSelectionBox = sal_False;
- mbSelectionFltrEnabled = sal_False;
-
-+ bool bAddGraphicFilter = false;
-+
- // default settings
- m_nDontFlags = SFX_FILTER_INTERNAL | SFX_FILTER_NOTINFILEDLG | SFX_FILTER_NOTINSTALLED;
- if( WB_OPEN == ( nFlags & WB_OPEN ) )
-@@ -1025,6 +1027,7 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
- nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE;
- mbHasPreview = sal_True;
- mbHasLink = sal_True;
-+ bAddGraphicFilter = true;
-
- // aPreviewTimer
- maPreViewTimer.SetTimeout( 500 );
-@@ -1044,6 +1047,7 @@ 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 ) );
-@@ -1055,6 +1059,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;
-@@ -1118,7 +1127,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 c50d2cc..cc6fd0f 100644
---- sot/inc/sot/formats.hxx
-+++ sot/inc/sot/formats.hxx
-@@ -185,7 +185,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 c633676..754f64f 100644
---- sot/source/base/exchange.cxx
-+++ sot/source/base/exchange.cxx
-@@ -211,6 +211,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/sdr/media/medialink.hxx svx/inc/svx/sdr/media/medialink.hxx
-new file mode 100644
-index 0000000..736de64
---- /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..9a543ac
---- /dev/null
-+++ svx/inc/svx/sdr/media/mediamanager.hxx
-@@ -0,0 +1,92 @@
-+/*************************************************************************
-+ *
-+ * 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;
-+class SvStream;
-+
-+//////////////////////////////////////////////////////////////////////////////
-+// 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 insertMediaStream( const rtl::OUString& rURL, SvStream& rSrcStream, sal_uInt32 nBytes );
-+
-+ 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 39411ea..6d96d08 100644
---- svx/inc/svx/svdmodel.hxx
-+++ svx/inc/svx/svdmodel.hxx
-@@ -52,6 +52,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 */
-@@ -104,6 +105,11 @@ namespace comphelper{
- namespace sfx2{
- class LinkManager;
- }
-+
-+namespace sdr { namespace media {
-+ class MediaManager;
-+} }
-+
- ////////////////////////////////////////////////////////////////////////////////////////////////////
-
- #define SDR_SWAPGRAPHICSMODE_NONE 0x00000000
-@@ -306,6 +312,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);
-@@ -741,6 +749,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 914100f..6deabc0 100644
---- svx/inc/svx/svdomedia.hxx
-+++ svx/inc/svx/svdomedia.hxx
-@@ -31,8 +31,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; } }
-
-@@ -43,6 +45,7 @@ namespace sdr { namespace contact { class ViewContactOfSdrMediaObj; } }
- class SVX_DLLPUBLIC SdrMediaObj : public SdrRectObj
- {
- friend class ::sdr::contact::ViewContactOfSdrMediaObj;
-+ friend class SdrMediaLink;
-
- public:
-
-@@ -65,8 +68,13 @@ public:
-
- virtual void AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly = false );
-
-+ // 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;
-
-@@ -79,15 +87,23 @@ 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 ::sdr::contact::ViewContact* CreateObjectSpecificViewContact();
-
-+ virtual void connect();
-+ virtual void disconnect();
-+
- private:
-
- ::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 9f75974..c1207d3 100644
---- svx/prj/build.lst
-+++ svx/prj/build.lst
-@@ -17,6 +17,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
-@@ -34,6 +35,6 @@ sx svx\source\core nmake - all sx_core sx_inc NULL
- 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\util nmake - all sx_util sx_3deng sx_dlg sx_draw sx_attribute sx_properties sx_contact sx_event sx_animation sx_primitive2d sx_primitive3d sx_overlay sx_fmcmp sx_form sx_gall sx_items sx_mnuc sx_sdi sx_stbc sx_tbxc sx_undrw sx_ungal sx_xml sx_core sx_xout sx_accessibility sx_intro sx_customshapes sx_toolbars sx_table sx_smarttags NULL
-+sx svx\util nmake - all sx_util sx_3deng sx_dlg sx_draw sx_attribute sx_properties sx_contact sx_event sx_animation sx_primitive2d sx_primitive3d sx_overlay sx_fmcmp sx_form sx_gall sx_items sx_mnuc sx_sdi sx_stbc sx_tbxc sx_undrw sx_ungal sx_xml sx_core 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
- sx svx\qa\unoapi nmake - all sx_qa_unoapi NULL
-diff --git svx/prj/d.lst svx/prj/d.lst
-index d79e421..17e087b 100644
---- svx/prj/d.lst
-+++ svx/prj/d.lst
-@@ -523,6 +523,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/sdr/contact/viewcontactofsdrmediaobj.cxx svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx
-index 5a38d50..6dcb7c0 100644
---- svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx
-+++ svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx
-@@ -54,7 +54,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 ) );
- }
-
- // ------------------------------------------------------------------------------
-@@ -117,6 +124,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() );
- }
-
- // ------------------------------------------------------------------------------
-@@ -125,13 +136,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..5991627
---- /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..85661ac
---- /dev/null
-+++ svx/source/sdr/media/mediamanager.cxx
-@@ -0,0 +1,527 @@
-+/*************************************************************************
-+ *
-+ * 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::insertMediaStream( const rtl::OUString& rURL, SvStream& rSrcStream, sal_uInt32 nBytes )
-+{
-+ // TODO(Q3): duplicate code
-+ 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 ) );
-+ if( pDstStream.get() )
-+ {
-+ // TODO(P3): SRSLY
-+ char aBuf;
-+ while( nBytes-- )
-+ {
-+ rSrcStream.Read(&aBuf,1);
-+ pDstStream->Write(&aBuf,1);
-+ }
-+ }
-+ }
-+
-+ 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 1699622..1541eeb 100644
---- svx/source/svdraw/svdmodel.cxx
-+++ svx/source/svdraw/svdmodel.cxx
-@@ -38,6 +38,8 @@
- #include <tools/urlobj.hxx>
- #include <unotools/ucbstreamhelper.hxx>
-
-+#include <svx/sdr/media/mediamanager.hxx>
-+
- #include <tools/string.hxx>
- #include <svl/whiter.hxx>
- #include <svx/xit.hxx>
-@@ -104,6 +106,7 @@ struct SdrModelImpl
- SfxUndoManager* mpUndoManager;
- SdrUndoFactory* mpUndoFactory;
- bool mbAllowShapePropertyChangeListener;
-+ rtl::Reference< sdr::media::MediaManager > mxMediaManager;
- };
-
- ////////////////////////////////////////////////////////////////////////////////////////////////////
-@@ -295,6 +298,12 @@ SdrModel::~SdrModel()
-
- DBG_DTOR(SdrModel,NULL);
-
-+ if( mpImpl && mpImpl->mxMediaManager.is() )
-+ {
-+ mpImpl->mxMediaManager->Dispose();
-+ mpImpl->mxMediaManager.clear();
-+ }
-+
- mbInDestruction = true;
-
- Broadcast(SdrHint(HINT_MODELCLEARED));
-@@ -2160,6 +2169,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 88651ed..1ae905e 100644
---- svx/source/svdraw/svdomedia.cxx
-+++ svx/source/svdraw/svdomedia.cxx
-@@ -30,11 +30,81 @@
-
- #include <vcl/svapp.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 "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 )
... etc. - the rest is truncated
More information about the ooo-build-commit
mailing list