[Libreoffice-commits] .: 20 commits - automation/source avmedia/Library_avmedia.mk avmedia/inc avmedia/source comphelper/inc comphelper/source cui/source dbaccess/source extensions/source framework/source sc/inc sc/source sd/inc sd/source sfx2/inc sfx2/source starmath/source svtools/inc svtools/source svx/inc svx/source svx/workben sw/inc sw/source xmloff/source

Michael Stahl mst at kemper.freedesktop.org
Fri Dec 2 15:55:23 PST 2011


 automation/source/miniapp/testapp.cxx                |    2 
 avmedia/Library_avmedia.mk                           |    1 
 avmedia/inc/avmedia/mediaitem.hxx                    |   33 +
 avmedia/inc/avmedia/mediawindow.hxx                  |    5 
 avmedia/source/framework/mediacontrol.cxx            |    5 
 avmedia/source/framework/mediaitem.cxx               |  347 ++++++++++++++-----
 avmedia/source/viewer/mediawindow.cxx                |   40 +-
 avmedia/source/viewer/mediawindowbase_impl.cxx       |  127 ++++++
 avmedia/source/viewer/mediawindowbase_impl.hxx       |   20 -
 comphelper/inc/comphelper/storagehelper.hxx          |   35 +
 comphelper/source/misc/storagehelper.cxx             |   35 +
 cui/source/customize/acccfg.cxx                      |    4 
 cui/source/dialogs/insdlg.cxx                        |    3 
 cui/source/options/doclinkdialog.cxx                 |    7 
 cui/source/options/optinet2.cxx                      |    2 
 cui/source/options/optmemory.cxx                     |    1 
 cui/source/tabpages/tpgradnt.cxx                     |    2 
 cui/source/tabpages/tphatch.cxx                      |    2 
 cui/source/tabpages/tplnedef.cxx                     |    2 
 cui/source/tabpages/tplneend.cxx                     |    2 
 dbaccess/source/ext/adabas/AdabasNewDb.cxx           |    9 
 dbaccess/source/ui/app/AppController.cxx             |    5 
 dbaccess/source/ui/app/AppControllerDnD.cxx          |    1 
 dbaccess/source/ui/dlg/ConnectionHelper.cxx          |   18 
 dbaccess/source/ui/dlg/ConnectionPage.cxx            |    1 
 dbaccess/source/ui/dlg/ConnectionPageSetup.cxx       |    1 
 dbaccess/source/ui/dlg/dbwizsetup.cxx                |    5 
 dbaccess/source/ui/dlg/generalpage.cxx               |    6 
 extensions/source/abpilot/abpfinalpage.cxx           |    1 
 extensions/source/dbpilots/commonpagesdbp.cxx        |    5 
 extensions/source/propctrlr/formcomponenthandler.cxx |   12 
 framework/source/uielement/toolbarmanager.cxx        |    8 
 sc/inc/drwlayer.hxx                                  |    1 
 sc/source/core/data/drwlayer.cxx                     |   53 --
 sc/source/ui/docshell/docsh4.cxx                     |    2 
 sc/source/ui/drawfunc/fuins1.cxx                     |   27 +
 sc/source/ui/miscdlgs/instbdlg.cxx                   |    2 
 sc/source/ui/miscdlgs/linkarea.cxx                   |    2 
 sd/inc/drawdoc.hxx                                   |    1 
 sd/source/core/drawdoc3.cxx                          |   82 ----
 sd/source/ui/dlg/dlgass.cxx                          |    5 
 sd/source/ui/dlg/tpaction.cxx                        |    4 
 sd/source/ui/func/fuinsert.cxx                       |    6 
 sd/source/ui/func/fuinsfil.cxx                       |    5 
 sd/source/ui/inc/DrawDocShell.hxx                    |    1 
 sd/source/ui/inc/View.hxx                            |    3 
 sd/source/ui/view/sdview4.cxx                        |   22 -
 sfx2/inc/sfx2/docinsert.hxx                          |    6 
 sfx2/inc/sfx2/filedlghelper.hxx                      |   52 --
 sfx2/inc/sfx2/lnkbase.hxx                            |    2 
 sfx2/source/appl/appopen.cxx                         |    5 
 sfx2/source/appl/fileobj.cxx                         |   14 
 sfx2/source/appl/lnkbase2.cxx                        |   10 
 sfx2/source/appl/opengrf.cxx                         |    5 
 sfx2/source/appl/shutdownicon.cxx                    |    6 
 sfx2/source/dialog/dinfdlg.cxx                       |    4 
 sfx2/source/dialog/filedlghelper.cxx                 |  118 ++----
 sfx2/source/dialog/filedlgimpl.hxx                   |    5 
 sfx2/source/doc/docinsert.cxx                        |   16 
 sfx2/source/doc/docvor.cxx                           |    4 
 sfx2/source/doc/objserv.cxx                          |    1 
 sfx2/source/doc/objstor.cxx                          |    1 
 starmath/source/view.cxx                             |    4 
 svtools/inc/svtools/toolboxcontroller.hxx            |    6 
 svtools/source/filter/filter.cxx                     |    9 
 svtools/source/uno/toolboxcontroller.cxx             |   30 -
 svx/inc/svx/svdmodel.hxx                             |   27 -
 svx/inc/svx/svdomedia.hxx                            |    4 
 svx/source/dialog/imapdlg.cxx                        |    4 
 svx/source/dialog/pfiledlg.cxx                       |    5 
 svx/source/form/databaselocationinput.cxx            |    2 
 svx/source/svdraw/svdmodel.cxx                       |   49 ++
 svx/source/svdraw/svdograf.cxx                       |   38 --
 svx/source/svdraw/svdomedia.cxx                      |   11 
 svx/source/unodraw/unoshap4.cxx                      |    4 
 svx/source/xml/xmlxtimp.cxx                          |    2 
 svx/workben/msview/msview.cxx                        |    3 
 sw/inc/drawdoc.hxx                                   |    5 
 sw/source/core/draw/drawdoc.cxx                      |   40 --
 sw/source/ui/dialog/uiregionsw.cxx                   |    6 
 sw/source/ui/fldui/javaedit.cxx                      |    7 
 sw/source/ui/frmdlg/frmpage.cxx                      |    4 
 sw/source/ui/shells/grfshex.cxx                      |   21 +
 sw/source/ui/uiview/srcview.cxx                      |    3 
 sw/source/ui/uiview/uivwimp.cxx                      |    2 
 sw/source/ui/uiview/view2.cxx                        |    5 
 sw/source/ui/utlui/glbltree.cxx                      |    3 
 xmloff/source/draw/shapeexport2.cxx                  |   94 +++++
 xmloff/source/draw/ximpshap.cxx                      |   31 -
 89 files changed, 999 insertions(+), 632 deletions(-)

New commits:
commit b93aad95120df2c40756f4ba06344eac2297d0ee
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sat Dec 3 00:41:05 2011 +0100

    svt::ToolboxController: valgrind complained...

diff --git a/svtools/source/uno/toolboxcontroller.cxx b/svtools/source/uno/toolboxcontroller.cxx
index 63318d4..4e4970b 100644
--- a/svtools/source/uno/toolboxcontroller.cxx
+++ b/svtools/source/uno/toolboxcontroller.cxx
@@ -89,6 +89,7 @@ ToolboxController::ToolboxController(
     const ::rtl::OUString& aCommandURL ) :
     OPropertyContainer(GetBroadcastHelper())
     ,   OWeakObject()
+    ,   m_bSupportVisible(sal_False)
     ,   m_bInitialized( sal_False )
     ,   m_bDisposed( sal_False )
     ,   m_xFrame(xFrame)
@@ -116,6 +117,7 @@ ToolboxController::ToolboxController(
 ToolboxController::ToolboxController() :
     OPropertyContainer(GetBroadcastHelper())
     ,   OWeakObject()
+    ,   m_bSupportVisible(sal_False)
     ,   m_bInitialized( sal_False )
     ,   m_bDisposed( sal_False )
     ,   m_aListenerContainer( m_aMutex )
commit 4f01d343cd6c4e8558cd4331277f02d7089ff476
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sat Dec 3 00:34:56 2011 +0100

    property name spelling s/Visiable/Visible/

diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 8caf66b..01adbe5 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -1122,10 +1122,10 @@ void ToolBarManager::CreateControllers()
         {
             try
             {
-                sal_Bool bSupportVisiable = sal_True;
-                Any a( xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SupportsVisiable" ))) );
-                a >>= bSupportVisiable;
-                if ( bSupportVisiable )
+                sal_Bool bSupportVisible = sal_True;
+                Any a( xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SupportsVisible" ))) );
+                a >>= bSupportVisible;
+                if (bSupportVisible)
                 {
                     Reference< XToolbarController > xTbxController( xController, UNO_QUERY );
                     UpdateController(xTbxController);
diff --git a/svtools/inc/svtools/toolboxcontroller.hxx b/svtools/inc/svtools/toolboxcontroller.hxx
index af451e5..294fd8f 100644
--- a/svtools/inc/svtools/toolboxcontroller.hxx
+++ b/svtools/inc/svtools/toolboxcontroller.hxx
@@ -43,13 +43,11 @@
 #include <cppuhelper/interfacecontainer.hxx>
 #include <comphelper/broadcasthelper.hxx>
 #include <com/sun/star/util/XURLTransformer.hpp>
-//shizhoubo for ToolbarController Visiable
 #include <comphelper/proparrhlp.hxx>
 #include <comphelper/property.hxx>
 #include <comphelper/propertycontainer.hxx>
 #include <cppuhelper/propshlp.hxx>
 #include <cppuhelper/interfacecontainer.hxx>
-//end
 
 #include <boost/unordered_map.hpp>
 
@@ -70,7 +68,7 @@ class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusL
                           public ::cppu::OWeakObject
 {
     private:
-        sal_Bool  m_bSupportVisiable; //shizhoubo
+        sal_Bool  m_bSupportVisible; //shizhoubo
     public:
         ToolboxController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
                            const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
@@ -133,7 +131,7 @@ class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusL
 
     protected:
         bool getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox );
-        void setSupportVisiableProperty(sal_Bool bValue); //shizhoubo
+        void setSupportVisibleProperty(sal_Bool bValue); //shizhoubo
         struct Listener
         {
             Listener( const ::com::sun::star::util::URL& rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDispatch ) :
diff --git a/svtools/source/uno/toolboxcontroller.cxx b/svtools/source/uno/toolboxcontroller.cxx
index 115b095..63318d4 100644
--- a/svtools/source/uno/toolboxcontroller.cxx
+++ b/svtools/source/uno/toolboxcontroller.cxx
@@ -40,8 +40,8 @@
 #include <vcl/toolbox.hxx>
 //shizhobo
 #include <com/sun/star/beans/PropertyAttribute.hpp>
-const int TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIABLE  = 1;
-const rtl::OUString TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIABLE( RTL_CONSTASCII_USTRINGPARAM( "SupportsVisiable" ));
+const int TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE  = 1;
+const rtl::OUString TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIBLE( RTL_CONSTASCII_USTRINGPARAM( "SupportsVisible" ));
 //end
 
 using ::rtl::OUString;
@@ -97,8 +97,8 @@ ToolboxController::ToolboxController(
     ,   m_aListenerContainer( m_aMutex )
 {
     //registger Propertyh by shizhoubo
-    registerProperty(TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIABLE, TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIABLE, com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY,
-        &m_bSupportVisiable, getCppuType(&m_bSupportVisiable));
+    registerProperty(TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIBLE, TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE, com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY,
+        &m_bSupportVisible, getCppuType(&m_bSupportVisible));
 
     m_pImpl = new ToolboxController_Impl;
 
@@ -121,8 +121,8 @@ ToolboxController::ToolboxController() :
     ,   m_aListenerContainer( m_aMutex )
 {
     //registger Propertyh by shizhoubo
-    registerProperty(TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIABLE, TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIABLE, com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY,
-        &m_bSupportVisiable, getCppuType(&m_bSupportVisiable));
+    registerProperty(TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIBLE, TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE, com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY,
+        &m_bSupportVisible, getCppuType(&m_bSupportVisible));
 
     m_pImpl = new ToolboxController_Impl;
 }
@@ -220,7 +220,7 @@ throw ( Exception, RuntimeException )
         SolarMutexGuard aSolarMutexGuard;
         m_bInitialized = sal_True;
         //shizhoubo add
-        m_bSupportVisiable = sal_False;
+        m_bSupportVisible = sal_False;
         PropertyValue aPropValue;
         for ( int i = 0; i < aArguments.getLength(); i++ )
         {
@@ -771,9 +771,9 @@ com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >  SAL_C
         return new ::cppu::OPropertyArrayHelper(aProps);
 }
 //shizhoubo for supportsvisiable
-void ToolboxController::setSupportVisiableProperty(sal_Bool bValue)
+void ToolboxController::setSupportVisibleProperty(sal_Bool bValue)
 {
-    m_bSupportVisiable = bValue;
+    m_bSupportVisible = bValue;
 }
 //OPropertySetHelper by shizhoubo
 sal_Bool SAL_CALL ToolboxController::convertFastPropertyValue( com::sun::star::uno::Any&    aConvertedValue ,
@@ -783,14 +783,14 @@ sal_Bool SAL_CALL ToolboxController::convertFastPropertyValue( com::sun::star::u
 {
     switch (nHandle)
     {
-        case TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIABLE:
+        case TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE:
         {
             sal_Bool aNewValue(sal_False);
             aValue >>= aNewValue;
-            if (aNewValue != m_bSupportVisiable)
+            if (aNewValue != m_bSupportVisible)
             {
                 aConvertedValue <<= aNewValue;
-                aOldValue <<= m_bSupportVisiable;
+                aOldValue <<= m_bSupportVisible;
                 return sal_True;
             }
             return sal_False;
@@ -805,11 +805,11 @@ void SAL_CALL ToolboxController::setFastPropertyValue_NoBroadcast(
 throw( com::sun::star::uno::Exception)
 {
     OPropertyContainer::setFastPropertyValue_NoBroadcast(nHandle, aValue);
-    if (TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIABLE == nHandle)
+    if (TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE == nHandle)
     {
         sal_Bool rValue(sal_False);
         if (( aValue >>= rValue ) && m_bInitialized)
-            this->setSupportVisiableProperty( rValue );
+            this->setSupportVisibleProperty( rValue );
     }
 }
 
commit 59307a7164e35396f34bf621ad7e9d2f265b1c7f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sat Dec 3 00:10:10 2011 +0100

    actually play embedded media:
    
    In order to do this, the media is written to a temp file by
    avmedia::MediaWindowBaseImpl.  This requires some rather ugly hacks to
    transport the Storage that contains the media to the avmedia stuff,
    including adding a XModel reference to avmedia::MediaItem.

diff --git a/avmedia/inc/avmedia/mediaitem.hxx b/avmedia/inc/avmedia/mediaitem.hxx
index a190810..0e4af5c 100644
--- a/avmedia/inc/avmedia/mediaitem.hxx
+++ b/avmedia/inc/avmedia/mediaitem.hxx
@@ -114,8 +114,12 @@ public:
     void                    setZoom( ::com::sun::star::media::ZoomLevel eZoom );
     ::com::sun::star::media::ZoomLevel  getZoom() const;
 
-    void                    setURL( const ::rtl::OUString& rURL );
+    void                    setURL( const ::rtl::OUString& rURL,
+        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>
+            const& xModel);
     const ::rtl::OUString&  getURL() const;
+    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>
+            getModel() const;
 
 private:
 
diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx
index 2919069..ceb375e 100644
--- a/avmedia/source/framework/mediacontrol.cxx
+++ b/avmedia/source/framework/mediacontrol.cxx
@@ -506,7 +506,7 @@ IMPL_LINK( MediaControl, implSelectHdl, ToolBox*, p )
                         ::avmedia::MediaWindow::executeFormatErrorBox( this );
                     else
                     {
-                        aExecItem.setURL( aURL );
+                        aExecItem.setURL( aURL, 0 );
                         aExecItem.setState( MEDIASTATE_PLAY );
                     }
                 }
diff --git a/avmedia/source/framework/mediaitem.cxx b/avmedia/source/framework/mediaitem.cxx
index afda0ab..d38548a 100644
--- a/avmedia/source/framework/mediaitem.cxx
+++ b/avmedia/source/framework/mediaitem.cxx
@@ -27,6 +27,8 @@
  ************************************************************************/
 
 #include <avmedia/mediaitem.hxx>
+
+#include <cppuhelper/weakref.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
 
 #include <com/sun/star/beans/XPropertySet.hpp>
@@ -59,6 +61,8 @@ TYPEINIT1_AUTOFACTORY( MediaItem, ::SfxPoolItem );
 struct MediaItem::Impl
 {
     ::rtl::OUString         m_URL;
+    // store a weak ref to the model so we can get at embedded media
+    uno::WeakReference<frame::XModel> m_wModel;
     sal_uInt32              m_nMaskSet;
     MediaState              m_eState;
     double                  m_fTime;
@@ -81,6 +85,7 @@ struct MediaItem::Impl
     }
     Impl(Impl const& rOther)
         : m_URL( rOther.m_URL )
+        , m_wModel( rOther.m_wModel )
         , m_nMaskSet( rOther.m_nMaskSet )
         , m_eState( rOther.m_eState )
         , m_fTime( rOther.m_fTime )
@@ -207,7 +212,7 @@ void MediaItem::merge( const MediaItem& rMediaItem )
     const sal_uInt32 nMaskSet = rMediaItem.getMaskSet();
 
     if( AVMEDIA_SETMASK_URL & nMaskSet )
-        setURL( rMediaItem.getURL() );
+        setURL( rMediaItem.getURL(), rMediaItem.getModel() );
 
     if( AVMEDIA_SETMASK_STATE & nMaskSet )
         setState( rMediaItem.getState() );
@@ -240,10 +245,15 @@ sal_uInt32 MediaItem::getMaskSet() const
 
 //------------------------------------------------------------------------
 
-void MediaItem::setURL( const ::rtl::OUString& rURL )
+void MediaItem::setURL( const ::rtl::OUString& rURL,
+        uno::Reference<frame::XModel> const & xModel)
 {
     m_pImpl->m_URL = rURL;
     m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_URL;
+    if (xModel.is())
+    {
+        m_pImpl->m_wModel = xModel;
+    }
 }
 
 //------------------------------------------------------------------------
@@ -253,6 +263,11 @@ const ::rtl::OUString& MediaItem::getURL() const
     return m_pImpl->m_URL;
 }
 
+uno::Reference<frame::XModel> MediaItem::getModel() const
+{
+    return m_pImpl->m_wModel;
+}
+
 //------------------------------------------------------------------------
 
 void MediaItem::setState( MediaState eState )
diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx
index f063526..9a3cab2 100644
--- a/avmedia/source/viewer/mediawindow.cxx
+++ b/avmedia/source/viewer/mediawindow.cxx
@@ -73,7 +73,7 @@ MediaWindow::~MediaWindow()
 void MediaWindow::setURL( const ::rtl::OUString& rURL )
 {
     if( mpImpl )
-        mpImpl->setURL( rURL );
+        mpImpl->setURL( rURL, uno::Reference<frame::XModel>() );
 }
 
 // -------------------------------------------------------------------------
diff --git a/avmedia/source/viewer/mediawindowbase_impl.cxx b/avmedia/source/viewer/mediawindowbase_impl.cxx
index c6b46af..d9e8fa6 100644
--- a/avmedia/source/viewer/mediawindowbase_impl.cxx
+++ b/avmedia/source/viewer/mediawindowbase_impl.cxx
@@ -32,11 +32,16 @@
 #include "mediawindow.hrc"
 #include <rtl/oustringostreaminserter.hxx>
 #include <sal/log.hxx>
+#include <osl/file.hxx>
 #include <tools/urlobj.hxx>
+#include <ucbhelper/content.hxx>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/storagehelper.hxx>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/media/XManager.hpp>
 #include <com/sun/star/lang/XComponent.hdl>
+#include <com/sun/star/media/XManager.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
 
 #define MEDIA_TIMER_TIMEOUT 100
 
@@ -49,8 +54,9 @@ namespace avmedia { namespace priv {
 // -----------------------
 
 
-MediaWindowBaseImpl::MediaWindowBaseImpl( MediaWindow* pMediaWindow ) :
-    mpMediaWindow( pMediaWindow )
+MediaWindowBaseImpl::MediaWindowBaseImpl( MediaWindow* pMediaWindow )
+    : mpTempFileURL(0)
+    , mpMediaWindow( pMediaWindow )
 {
 }
 
@@ -101,13 +107,90 @@ uno::Reference< media::XPlayer > MediaWindowBaseImpl::createPlayer( const ::rtl:
 }
 
 // ---------------------------------------------------------------------
+void MediaWindowBaseImpl::cleanupTempFile()
+{
+    if (mpTempFileURL)
+    {
+        ::osl::File::remove(*mpTempFileURL);
+        delete mpTempFileURL;
+        mpTempFileURL = 0;
+    }
+}
 
-void MediaWindowBaseImpl::setURL( const ::rtl::OUString& rURL )
+bool
+MediaWindowBaseImpl::initPackageURL(::rtl::OUString const & rURL,
+        uno::Reference<frame::XModel> const& xModel)
 {
-    if( rURL != getURL() )
+    uno::Reference<document::XStorageBasedDocument> const xSBD(
+            xModel, uno::UNO_QUERY);
+    if (!xSBD.is())
+    {
+        SAL_WARN("avmedia", "cannot get model");
+        return false;
+    }
+    uno::Reference<embed::XStorage> const xStorage(
+        xSBD->getDocumentStorage());
+    if (!xStorage.is())
+    {
+        SAL_WARN("avmedia", "cannot get storage");
+        return false;
+    }
+    ::comphelper::LifecycleProxy proxy;
+    uno::Reference<io::XInputStream> xInStream;
+    try {
+        uno::Reference<io::XStream> const xStream(
+            ::comphelper::OStorageHelper::GetStreamAtPackageURL(
+                xStorage, rURL, embed::ElementModes::READ, proxy));
+        xInStream = (xStream.is()) ? xStream->getInputStream() : 0;
+    }
+    catch (container::NoSuchElementException const&)
+    {
+        SAL_INFO("avmedia", "not found: '" << ::rtl::OUString(rURL) << "'");
+        return false;
+    }
+    catch (uno::Exception const& e)
+    {
+        SAL_WARN("avmedia", "exception: '" << e.Message << "'");
+        return false;
+    }
+    if (!xInStream.is())
     {
-        INetURLObject aURL( maFileURL = rURL );
+        SAL_WARN("avmedia", "no stream?");
+        return false;
+    }
+
+    mpTempFileURL = new ::rtl::OUString;
+    ::osl::FileBase::RC const err =
+        ::osl::FileBase::createTempFile(0, 0, mpTempFileURL);
+    if (::osl::FileBase::E_None != err)
+    {
+        SAL_INFO("avmedia", "cannot create temp file");
+        delete mpTempFileURL;
+        mpTempFileURL = 0;
+        return false;
+    }
 
+    try
+    {
+        ::ucbhelper::Content tempContent(*mpTempFileURL,
+                uno::Reference<ucb::XCommandEnvironment>());
+        tempContent.writeStream(xInStream, true); // copy stream to file
+    }
+    catch (uno::Exception const& e)
+    {
+        SAL_WARN("avmedia", "exception: '" << e.Message << "'");
+        return false;
+    }
+    return true;
+}
+
+static char const s_PkgScheme[] = "vnd.sun.star.Package:";
+
+void MediaWindowBaseImpl::setURL( const ::rtl::OUString& rURL,
+        uno::Reference<frame::XModel> const& xModel )
+{
+    if( rURL != getURL() )
+    {
         if( mxPlayer.is() )
             mxPlayer->stop();
 
@@ -118,11 +201,32 @@ void MediaWindowBaseImpl::setURL( const ::rtl::OUString& rURL )
         }
 
         mxPlayer.clear();
+        cleanupTempFile();
 
-        if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
-            maFileURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+        bool bSuccess(true);
+        if (0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
+                rURL.getStr(), rURL.getLength(),
+                s_PkgScheme, SAL_N_ELEMENTS(s_PkgScheme) - 1))
+        {
+            bSuccess = initPackageURL(rURL, xModel);
 
-        mxPlayer = createPlayer( maFileURL );
+            maFileURL = (bSuccess) ? rURL : ::rtl::OUString();
+        }
+        else
+        {
+            INetURLObject aURL( rURL );
+
+            if (aURL.GetProtocol() != INET_PROT_NOT_VALID)
+                maFileURL = aURL.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS);
+            else
+                maFileURL = rURL;
+        }
+
+        if (bSuccess)
+        {
+            mxPlayer = createPlayer(
+                    (mpTempFileURL) ? *mpTempFileURL : maFileURL );
+        }
         onURLChanged();
     }
 }
@@ -200,6 +304,7 @@ void MediaWindowBaseImpl::cleanUp()
 
         mxPlayer.clear();
     }
+    cleanupTempFile();
 
     mpMediaWindow = NULL;
 }
@@ -376,7 +481,7 @@ void MediaWindowBaseImpl::updateMediaItem( MediaItem& rItem ) const
     rItem.setMute( isMute() );
     rItem.setVolumeDB( getVolumeDB() );
     rItem.setZoom( getZoom() );
-    rItem.setURL( getURL() );
+    rItem.setURL( getURL(), 0 );
 }
 
 // -------------------------------------------------------------------------
@@ -387,7 +492,7 @@ void MediaWindowBaseImpl::executeMediaItem( const MediaItem& rItem )
 
     // set URL first
     if( nMaskSet & AVMEDIA_SETMASK_URL )
-        setURL( rItem.getURL() );
+        setURL( rItem.getURL(), rItem.getModel() );
 
     // set different states next
     if( nMaskSet & AVMEDIA_SETMASK_TIME )
diff --git a/avmedia/source/viewer/mediawindowbase_impl.hxx b/avmedia/source/viewer/mediawindowbase_impl.hxx
index 1aa615a..935b88a 100644
--- a/avmedia/source/viewer/mediawindowbase_impl.hxx
+++ b/avmedia/source/viewer/mediawindowbase_impl.hxx
@@ -26,13 +26,19 @@
  *
  ************************************************************************/
 
-#ifndef _AVMEDIA_MEDIAWINDOWBASE_IMPL_HXX
-#define _AVMEDIA_MEDIAWINDOWBASE_IMPL_HXX
+#ifndef AVMEDIA_MEDIAWINDOWBASE_IMPL_HXX
+#define AVMEDIA_MEDIAWINDOWBASE_IMPL_HXX
 
 #include <avmedia/mediawindow.hxx>
+
 #include <com/sun/star/media/XPlayer.hpp>
 #include <com/sun/star/media/XPlayerWindow.hpp>
 
+
+namespace com { namespace sun { namespace star {
+    namespace frame { class XModel; }
+}}} // namespace com::sun::star
+
 namespace avmedia
 {
     namespace priv
@@ -64,9 +70,10 @@ namespace avmedia
 
             static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const ::rtl::OUString& rURL);
 
-        public:
+            void    setURL( const ::rtl::OUString& rURL,
+                            ::com::sun::star::uno::Reference<
+                                ::com::sun::star::frame::XModel> const& wModel);
 
-            void    setURL( const ::rtl::OUString& rURL );
             const ::rtl::OUString&  getURL() const;
 
             bool    isValid() const;
@@ -121,8 +128,13 @@ namespace avmedia
             ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > getPlayerWindow() const;
 
         private:
+            void    cleanupTempFile();
+            bool    initPackageURL( const ::rtl::OUString& rPath,
+                            ::com::sun::star::uno::Reference<
+                                ::com::sun::star::frame::XModel> const& wModel);
 
             ::rtl::OUString                                                             maFileURL;
+            ::rtl::OUString * mpTempFileURL;
             ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer >        mxPlayer;
             ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow >  mxPlayerWindow;
             MediaWindow*                                                                mpMediaWindow;
diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
index 7b29e9a..3d5ea7d 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -186,6 +186,8 @@ void lcl_InsertMedia( const ::rtl::OUString& rMediaURL, bool bApi,
     if( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) )
         aInsertPos.X() -= aSize.Width();
 
+    uno::Reference<frame::XModel> const xModel(
+            pData->GetDocument()->GetDocumentShell()->GetModel());
     ::rtl::OUString realURL;
     if (bLink)
     {
@@ -193,15 +195,13 @@ void lcl_InsertMedia( const ::rtl::OUString& rMediaURL, bool bApi,
     }
     else
     {
-        uno::Reference<frame::XModel> const xModel(
-                pData->GetDocument()->GetDocumentShell()->GetModel());
         bool const bRet = ::avmedia::EmbedMedia(xModel, rMediaURL, realURL);
         if (!bRet) { return; }
     }
 
     SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aInsertPos, aSize ) );
 
-    pObj->setURL( realURL );
+    pObj->setURL( realURL, (bLink) ? 0 : xModel );
     pView->InsertObjectAtView( pObj, *pPV, bApi ? SDRINSERT_DONTMARK : 0 );
 }
 
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
index f42ad34..4e6218d 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -287,6 +287,8 @@ SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAc
                                    const Point& rPos, const Size& rSize,
                                    bool const bLink )
 {
+    uno::Reference<frame::XModel> const xModel(
+            GetDoc()->GetObjectShell()->GetModel());
     ::rtl::OUString realURL;
     if (bLink)
     {
@@ -294,8 +296,6 @@ SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAc
     }
     else
     {
-        uno::Reference<frame::XModel> const xModel(
-                GetDoc()->GetObjectShell()->GetModel());
         bool const bRet = ::avmedia::EmbedMedia(xModel, rMediaURL, realURL);
         if (!bRet) { return 0; }
     }
@@ -322,7 +322,7 @@ SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAc
     if( mnAction == DND_ACTION_LINK && pPickObj && pPV && pPickObj->ISA( SdrMediaObj ) )
     {
         pNewMediaObj = static_cast< SdrMediaObj* >( pPickObj->Clone() );
-        pNewMediaObj->setURL( realURL );
+        pNewMediaObj->setURL( realURL, (bLink) ? 0 : xModel );
 
         BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
         ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
@@ -353,7 +353,7 @@ SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAc
         else
             InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER );
 
-        pNewMediaObj->setURL( realURL );
+        pNewMediaObj->setURL( realURL, (bLink) ? 0 : xModel );
 
         if( pPickObj )
         {
diff --git a/svx/inc/svx/svdomedia.hxx b/svx/inc/svx/svdomedia.hxx
index c2a3e53..ffb2d9b 100644
--- a/svx/inc/svx/svdomedia.hxx
+++ b/svx/inc/svx/svdomedia.hxx
@@ -69,7 +69,9 @@ public:
 
 public:
 
-        void                        setURL( const ::rtl::OUString& rURL );
+        void                        setURL( const ::rtl::OUString& rURL,
+                ::com::sun::star::uno::Reference<
+                    ::com::sun::star::frame::XModel> const& xModel = 0);
         const ::rtl::OUString&      getURL() const;
 
         void                        setMediaProperties( const ::avmedia::MediaItem& rState );
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index f290032..526d30f 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -35,6 +35,9 @@
 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
 #include <avmedia/mediawindow.hxx>
 
+
+using namespace ::com::sun::star;
+
 // ---------------
 // - SdrMediaObj -
 // ---------------
@@ -198,11 +201,12 @@ void SdrMediaObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly /
 
 // ------------------------------------------------------------------------------
 
-void SdrMediaObj::setURL( const ::rtl::OUString& rURL )
+void SdrMediaObj::setURL( const ::rtl::OUString& rURL,
+        uno::Reference<frame::XModel> const& xModel )
 {
     ::avmedia::MediaItem aURLItem;
 
-    aURLItem.setURL( rURL );
+    aURLItem.setURL( rURL, xModel );
     setMediaProperties( aURLItem );
 }
 
@@ -253,7 +257,8 @@ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProper
         ( rNewProperties.getURL() != getURL() ) )
     {
         setGraphic();
-        maMediaProperties.setURL( rNewProperties.getURL() );
+        maMediaProperties.setURL(rNewProperties.getURL(),
+                rNewProperties.getModel());
     }
 
     if( AVMEDIA_SETMASK_LOOP & nMaskSet )
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
index 0f3aee9..ebbbe38 100644
--- a/svx/source/unodraw/unoshap4.cxx
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -878,7 +878,9 @@ bool SvxMediaShape::setPropertyValueImpl( const ::rtl::OUString& rName, const Sf
             if( rValue >>= aURL )
             {
                 bOk = true;
-                aItem.setURL( aURL );
+                uno::Reference<frame::XModel> const xModel(
+                        mpModel->getUnoModel(), uno::UNO_QUERY_THROW);
+                aItem.setURL( aURL, xModel);
             }
         }
         break;
diff --git a/sw/source/ui/shells/grfshex.cxx b/sw/source/ui/shells/grfshex.cxx
index 4b98002..e3807cb 100644
--- a/sw/source/ui/shells/grfshex.cxx
+++ b/sw/source/ui/shells/grfshex.cxx
@@ -136,6 +136,8 @@ bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
             else
                 aSize = Size( 2835, 2835 );
 
+            uno::Reference<frame::XModel> const xModel(
+                    rSh.GetDoc()->GetDocShell()->GetModel());
             ::rtl::OUString realURL;
             if (bLink)
             {
@@ -143,15 +145,13 @@ bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
             }
             else
             {
-                uno::Reference<frame::XModel> const xModel(
-                        rSh.GetDoc()->GetDocShell()->GetModel());
                 bRet = ::avmedia::EmbedMedia(xModel, aURL, realURL);
                 if (!bRet) { return bRet; }
             }
 
             SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aPos, aSize ) );
 
-            pObj->setURL( realURL );
+            pObj->setURL( realURL, (bLink) ? 0 : xModel );
             rSh.EnterStdMode();
             rSh.SwFEShell::InsertDrawObj( *pObj, aPos );
             bRet = true;
commit 116ad02ae89a0036a223ef943352587119a47f65
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sat Dec 3 00:00:08 2011 +0100

    xmloff: load and store embedded media

diff --git a/xmloff/source/draw/shapeexport2.cxx b/xmloff/source/draw/shapeexport2.cxx
index 297bff3..5ae3223 100644
--- a/xmloff/source/draw/shapeexport2.cxx
+++ b/xmloff/source/draw/shapeexport2.cxx
@@ -35,7 +35,10 @@
 #include <com/sun/star/drawing/XControlShape.hpp>
 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
 #include <com/sun/star/document/XEventsSupplier.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
 #include <com/sun/star/media/ZoomLevel.hpp>
 
 #include <sax/tools/converter.hxx>
@@ -1944,6 +1947,93 @@ void XMLShapeExport::ImpExportPluginShape(
 
 //////////////////////////////////////////////////////////////////////////////
 
+/** split a uri hierarchy into first segment and rest */
+static bool
+splitPath(::rtl::OUString const & i_rPath,
+    ::rtl::OUString & o_rDir, ::rtl::OUString& o_rRest)
+{
+    const sal_Int32 idx(i_rPath.indexOf(static_cast<sal_Unicode>('/')));
+    if (idx < 0 || idx >= i_rPath.getLength()) {
+        o_rDir = ::rtl::OUString();
+        o_rRest = i_rPath;
+        return true;
+    } else if (idx == 0 || idx == i_rPath.getLength() - 1) {
+        // input must not start or end with '/'
+        return false;
+    } else {
+        o_rDir  = (i_rPath.copy(0, idx));
+        o_rRest = (i_rPath.copy(idx+1));
+        return true;
+    }
+}
+
+static void lcl_CopyStream(
+        uno::Reference<embed::XStorage> const& xSource,
+        uno::Reference<embed::XStorage> const& xTarget,
+         ::rtl::OUString const& rPath)
+{
+    ::rtl::OUString dir;
+    ::rtl::OUString rest;
+    if (!splitPath(rPath, dir, rest)) throw uno::RuntimeException();
+    if (0 == dir.getLength())
+    {
+        xSource->copyElementTo(rPath, xTarget, rPath);
+    }
+    else
+    {
+        uno::Reference<embed::XStorage> const xSubSource(
+            xSource->openStorageElement(dir, embed::ElementModes::READ));
+        uno::Reference<embed::XStorage> const xSubTarget(
+            xTarget->openStorageElement(dir, embed::ElementModes::WRITE));
+        lcl_CopyStream(xSubSource, xSubTarget, rest);
+    }
+    uno::Reference<embed::XTransactedObject> const xTransaction(xTarget,
+            uno::UNO_QUERY);
+    if (xTransaction.is())
+    {
+        xTransaction->commit();
+    }
+}
+
+static char const s_PkgScheme[] = "vnd.sun.star.Package:";
+
+static ::rtl::OUString
+lcl_StoreMediaAndGetURL(SvXMLExport & rExport, ::rtl::OUString const& rURL)
+{
+    if (0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
+                rURL.getStr(), rURL.getLength(),
+                s_PkgScheme, SAL_N_ELEMENTS(s_PkgScheme) - 1))
+    {
+        try // video is embedded
+        {
+            // copy the media stream from document storage to target storage
+            // (not sure if this is the best way to store these?)
+            uno::Reference<document::XStorageBasedDocument> const xSBD(
+                    rExport.GetModel(), uno::UNO_QUERY_THROW);
+            uno::Reference<embed::XStorage> const xSource(
+                    xSBD->getDocumentStorage(), uno::UNO_QUERY_THROW);
+            uno::Reference<embed::XStorage> const xTarget(
+                    rExport.GetTargetStorage(), uno::UNO_QUERY_THROW);
+
+            ::rtl::OUString const urlPath(
+                    rURL.copy(SAL_N_ELEMENTS(s_PkgScheme)-1));
+
+            lcl_CopyStream(xSource, xTarget, urlPath);
+
+            return urlPath;
+        }
+        catch (uno::Exception const& e)
+        {
+            SAL_INFO("xmloff", "exception while storing embedded media");
+        }
+        return ::rtl::OUString();
+    }
+    else
+    {
+        return rExport.GetRelativeReference(rURL); // linked
+    }
+}
+
 void XMLShapeExport::ImpExportMediaShape(
     const uno::Reference< drawing::XShape >& xShape,
     XmlShapeType eShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
@@ -1964,7 +2054,9 @@ void XMLShapeExport::ImpExportMediaShape(
         // export media url
         OUString aMediaURL;
         xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaURL" ) ) ) >>= aMediaURL;
-        mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference( aMediaURL ) );
+        OUString const persistentURL =
+            lcl_StoreMediaAndGetURL(GetExport(), aMediaURL);
+        mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, persistentURL );
         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
         mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index fec93a9..24824d9 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -3047,6 +3047,20 @@ void SdXMLPluginShapeContext::StartElement( const ::com::sun::star::uno::Referen
     }
 }
 
+static ::rtl::OUString
+lcl_GetMediaReference(SvXMLImport const& rImport, ::rtl::OUString const& rURL)
+{
+    if (rImport.IsPackageURL(rURL))
+    {
+        return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+                    "vnd.sun.star.Package:")) + rURL;
+    }
+    else
+    {
+        return rImport.GetAbsoluteReference(rURL);
+    }
+}
+
 // this is called from the parent group for each unparsed attribute in the attribute list
 void SdXMLPluginShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
 {
@@ -3062,7 +3076,7 @@ void SdXMLPluginShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl:
     case XML_NAMESPACE_XLINK:
         if( IsXMLToken( rLocalName, XML_HREF ) )
         {
-            maHref = GetImport().GetAbsoluteReference(rValue);
+            maHref = lcl_GetMediaReference(GetImport(), rValue);
             return;
         }
         break;
@@ -3116,18 +3130,9 @@ void SdXMLPluginShapeContext::EndElement()
         else
         {
             // in case we have a media object
-
-            OUString sTempRef;
-
-            // check for package URL
-            if( GetImport().IsPackageURL( maHref ) )
-            {
-                sTempRef = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
-            }
-
-            sTempRef += maHref;
-
-            xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaURL" ) ), uno::makeAny( sTempRef ) );
+            xProps->setPropertyValue(
+                    OUString(RTL_CONSTASCII_USTRINGPARAM("MediaURL")),
+                    uno::makeAny(maHref));
 
             for( sal_Int32 nParam = 0; nParam < maParams.getLength(); ++nParam )
             {
commit e8a54ef88dacccb9759dd394473d52b53ff1cbd7
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Dec 2 23:54:33 2011 +0100

    add avmedia::EmbedMedia
    
    This new function is used by sc,sd,sw to embed media in the document storage.

diff --git a/avmedia/Library_avmedia.mk b/avmedia/Library_avmedia.mk
index 9f6bd52..2c1c42f 100644
--- a/avmedia/Library_avmedia.mk
+++ b/avmedia/Library_avmedia.mk
@@ -49,6 +49,7 @@ $(eval $(call gb_Library_add_defs,avmedia,\
 
 $(eval $(call gb_Library_add_linked_libs,avmedia,\
 	comphelper \
+	ucbhelper \
 	cppu \
 	cppuhelper \
 	sal \
diff --git a/avmedia/inc/avmedia/mediaitem.hxx b/avmedia/inc/avmedia/mediaitem.hxx
index cf9f09b..a190810 100644
--- a/avmedia/inc/avmedia/mediaitem.hxx
+++ b/avmedia/inc/avmedia/mediaitem.hxx
@@ -34,6 +34,7 @@
 #include <tools/rtti.hxx>
 #include <svl/poolitem.hxx>
 #include <com/sun/star/media/ZoomLevel.hpp>
+#include <com/sun/star/frame/XModel.hpp>
 #include <avmedia/avmediadllapi.h>
 
 #define AVMEDIA_SETMASK_NONE        ((sal_uInt32)(0x00000000))
@@ -124,6 +125,12 @@ private:
 
 typedef ::avmedia::MediaItem avmedia_MediaItem;
 
+bool AVMEDIA_DLLPUBLIC EmbedMedia(
+        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>
+            const& xModel,
+        ::rtl::OUString const& rSourceURL,
+        ::rtl::OUString & o_rEmbeddedURL);
+
 }
 
 #endif
diff --git a/avmedia/source/framework/mediaitem.cxx b/avmedia/source/framework/mediaitem.cxx
index 756c869..afda0ab 100644
--- a/avmedia/source/framework/mediaitem.cxx
+++ b/avmedia/source/framework/mediaitem.cxx
@@ -29,6 +29,22 @@
 #include <avmedia/mediaitem.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
 
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <com/sun/star/uri/XUriReference.hpp>
+#include <com/sun/star/uri/XUriReferenceFactory.hpp>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <ucbhelper/content.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/storagehelper.hxx>
+
 using namespace ::com::sun::star;
 
 namespace avmedia
@@ -342,6 +358,137 @@ void MediaItem::setZoom( ::com::sun::star::media::ZoomLevel eZoom )
     return m_pImpl->m_eZoom;
 }
 
+//------------------------------------------------------------------------
+
+static ::rtl::OUString lcl_GetFilename(::rtl::OUString const& rSourceURL)
+{
+    uno::Reference<uri::XUriReferenceFactory> const xUriFactory(
+        ::comphelper::createProcessComponent(
+            ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+                "com.sun.star.uri.UriReferenceFactory"))),
+        uno::UNO_QUERY_THROW);
+
+    uno::Reference<uri::XUriReference> const xSourceURI(
+        xUriFactory->parse(rSourceURL), uno::UNO_SET_THROW);
+
+    ::rtl::OUString filename;
+    {
+        sal_Int32 const nSegments(xSourceURI->getPathSegmentCount());
+        if (0 < nSegments)
+        {
+            filename = xSourceURI->getPathSegment(nSegments - 1);
+        }
+    }
+    if (!::comphelper::OStorageHelper::IsValidZipEntryFileName(
+                filename, false) || !filename.getLength())
+    {
+        filename = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("media"));
+    }
+    return filename;
+}
+
+static uno::Reference<io::XStream>
+lcl_CreateStream(uno::Reference<embed::XStorage> const& xStorage,
+        ::rtl::OUString const& rFilename)
+{
+    ::rtl::OUString filename(rFilename);
+
+    if (xStorage->hasByName(filename))
+    {
+        ::rtl::OUString basename;
+        ::rtl::OUString suffix;
+        sal_Int32 const nIndex(rFilename.lastIndexOf(sal_Unicode('.')));
+        if (0 < nIndex)
+        {
+            basename = rFilename.copy(0, nIndex);
+            suffix = rFilename.copy(nIndex);
+        }
+        int count(0); // sigh... try to generate non-existent name
+        do
+        {
+            ++count;
+            filename = basename + ::rtl::OUString::valueOf(count) + suffix;
+        }
+        while (xStorage->hasByName(filename));
+    }
+
+    uno::Reference<io::XStream> const xStream(
+        xStorage->openStreamElement(filename,
+            embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE),
+        uno::UNO_SET_THROW);
+    uno::Reference< beans::XPropertySet > const xStreamProps(xStream,
+        uno::UNO_QUERY);
+    if (xStreamProps.is()) { // this is NOT supported in FileSystemStorage
+        xStreamProps->setPropertyValue(
+            ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MediaType")),
+            uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+            //FIXME how to detect real media type?
+            //but currently xmloff has this one hardcoded anyway...
+                    "application/vnd.sun.star.media"))));
+        xStreamProps->setPropertyValue( // turn off compression
+            ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Compressed")),
+            uno::makeAny(sal_False));
+    }
+    return xStream;
+}
+
+bool EmbedMedia(uno::Reference<frame::XModel> const& xModel,
+        ::rtl::OUString const& rSourceURL, ::rtl::OUString & o_rEmbeddedURL)
+{
+    try
+    {
+        ::ucbhelper::Content sourceContent(rSourceURL,
+                uno::Reference<ucb::XCommandEnvironment>());
+
+        uno::Reference<document::XStorageBasedDocument> const xSBD(xModel,
+                uno::UNO_QUERY_THROW);
+        uno::Reference<embed::XStorage> const xStorage(
+                xSBD->getDocumentStorage(), uno::UNO_QUERY_THROW);
+
+        ::rtl::OUString const media(RTL_CONSTASCII_USTRINGPARAM("Media"));
+        uno::Reference<embed::XStorage> const xSubStorage(
+            xStorage->openStorageElement(media, embed::ElementModes::WRITE));
+
+        ::rtl::OUString filename(lcl_GetFilename(rSourceURL));
+
+        uno::Reference<io::XStream> const xStream(
+            lcl_CreateStream(xSubStorage, filename), uno::UNO_SET_THROW);
+        uno::Reference<io::XOutputStream> const xOutStream(
+            xStream->getOutputStream(), uno::UNO_SET_THROW);
+
+        if (!sourceContent.openStream(xOutStream)) // copy file to storage
+        {
+            SAL_INFO("avmedia", "openStream to storage failed");
+            return false;
+        }
+
+        uno::Reference<embed::XTransactedObject> const xSubTransaction(
+            xSubStorage, uno::UNO_QUERY);
+        if (xSubTransaction.is()) {
+            xSubTransaction->commit();
+        }
+        uno::Reference<embed::XTransactedObject> const xTransaction(
+            xStorage, uno::UNO_QUERY);
+        if (xTransaction.is()) {
+            xTransaction->commit();
+        }
+
+        ::rtl::OUStringBuffer buf(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+                        "vnd.sun.star.Package:")));
+        buf.append(media);
+        buf.append(sal_Unicode('/'));
+        buf.append(filename);
+        o_rEmbeddedURL = buf.makeStringAndClear();
+        return true;
+    }
+    catch (uno::Exception const& e)
+    {
+        SAL_WARN("avmedia",
+                "Exception while trying to embed media");
+    }
+    return false;
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
index dca4491..7b29e9a 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -51,6 +51,9 @@
 #include "progress.hxx"
 #include "sc.hrc"
 
+
+using namespace ::com::sun::star;
+
 //------------------------------------------------------------------------
 
 void SC_DLLPUBLIC ScLimitSizeOnDrawPage( Size& rSize, Point& rPos, const Size& rPage )
@@ -160,7 +163,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 const bLink )
 {
     SdrPageView*    pPV  = pView->GetSdrPageView();
     SdrPage*        pPage = pPV->GetPage();
@@ -183,9 +186,22 @@ void lcl_InsertMedia( const ::rtl::OUString& rMediaURL, bool bApi,
     if( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) )
         aInsertPos.X() -= aSize.Width();
 
+    ::rtl::OUString realURL;
+    if (bLink)
+    {
+        realURL = rMediaURL;
+    }
+    else
+    {
+        uno::Reference<frame::XModel> const xModel(
+                pData->GetDocument()->GetDocumentShell()->GetModel());
+        bool const bRet = ::avmedia::EmbedMedia(xModel, rMediaURL, realURL);
+        if (!bRet) { return; }
+    }
+
     SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aInsertPos, aSize ) );
 
-    pObj->setURL( rMediaURL );
+    pObj->setURL( realURL );
     pView->InsertObjectAtView( pObj, *pPV, bApi ? SDRINSERT_DONTMARK : 0 );
 }
 
@@ -345,7 +361,8 @@ FuInsertMedia::FuInsertMedia( ScTabViewShell*   pViewSh,
         }
         else
         {
-            lcl_InsertMedia( aURL, bAPI, pViewSh, pWindow, pView, aPrefSize );
+            lcl_InsertMedia( aURL, bAPI, pViewSh, pWindow, pView, aPrefSize,
+                    bLink );
 
             if( pWin )
                 pWin->LeaveWait();
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 184248d..0ca60db 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -768,7 +768,7 @@ void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
                 aPos.Y() -= aSize.Height() >> 1;
             }
 
-            mpView->InsertMediaURL( aURL, nAction, aPos, aSize ) ;
+            mpView->InsertMediaURL( aURL, nAction, aPos, aSize, bLink ) ;
 
             if( mpWindow )
                 mpWindow->LeaveWait();
diff --git a/sd/source/ui/inc/View.hxx b/sd/source/ui/inc/View.hxx
index 1387f46..6816ef6 100644
--- a/sd/source/ui/inc/View.hxx
+++ b/sd/source/ui/inc/View.hxx
@@ -152,7 +152,8 @@ public:
                                            sal_Int8& rAction, const Point& rPos,
                                            SdrObject* pSelectedObj, ImageMap* pImageMap );
     SdrMediaObj*            InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAction,
-                                            const Point& rPos, const Size& rSize );
+                                            const Point& rPos, const Size& rSize,
+                                            bool const bLink );
 
     bool PasteRTFTable( SotStorageStreamRef xStm, SdrPage* pPage, sal_uLong nPasteOptions );
 
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
index 2e8663f..f42ad34 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -284,8 +284,22 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
 // -----------------------------------------------------------------------------
 
 SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAction,
-                                   const Point& rPos, const Size& rSize )
+                                   const Point& rPos, const Size& rSize,
+                                   bool const bLink )
 {
+    ::rtl::OUString realURL;
+    if (bLink)
+    {
+        realURL = rMediaURL;
+    }
+    else
+    {
+        uno::Reference<frame::XModel> const xModel(
+                GetDoc()->GetObjectShell()->GetModel());
+        bool const bRet = ::avmedia::EmbedMedia(xModel, rMediaURL, realURL);
+        if (!bRet) { return 0; }
+    }
+
     SdrEndTextEdit();
     mnAction = rAction;
 
@@ -308,7 +322,7 @@ SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAc
     if( mnAction == DND_ACTION_LINK && pPickObj && pPV && pPickObj->ISA( SdrMediaObj ) )
     {
         pNewMediaObj = static_cast< SdrMediaObj* >( pPickObj->Clone() );
-        pNewMediaObj->setURL( rMediaURL );
+        pNewMediaObj->setURL( realURL );
 
         BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
         ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
@@ -339,7 +353,7 @@ SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAc
         else
             InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER );
 
-        pNewMediaObj->setURL( rMediaURL );
+        pNewMediaObj->setURL( realURL );
 
         if( pPickObj )
         {
@@ -461,7 +475,7 @@ IMPL_LINK( View, DropInsertFileHdl, Timer*, EMPTYARG )
                 else
                     aPrefSize  = Size( 5000, 5000 );
 
-                InsertMediaURL( aCurrentDropFile, mnAction, maDropPos, aPrefSize ) ;
+                InsertMediaURL( aCurrentDropFile, mnAction, maDropPos, aPrefSize, true ) ;
             }
             else if( mnAction & DND_ACTION_LINK )
                 static_cast< DrawViewShell* >( mpViewSh )->InsertURLButton( aCurrentDropFile, aCurrentDropFile, String(), &maDropPos );
diff --git a/sw/source/ui/shells/grfshex.cxx b/sw/source/ui/shells/grfshex.cxx
index 8340579..4b98002 100644
--- a/sw/source/ui/shells/grfshex.cxx
+++ b/sw/source/ui/shells/grfshex.cxx
@@ -41,6 +41,7 @@
 #include <svl/svstdarr.hxx>
 #include <svtools/filter.hxx>
 #include <svx/htmlmode.hxx>
+#include <doc.hxx>
 #include <docsh.hxx>
 #include <frmfmt.hxx>
 #include <frmmgr.hxx>
@@ -66,6 +67,7 @@
 #include <comcore.hrc>
 // <- #111827#
 
+using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::ui::dialogs;
 using namespace ::sfx2;
@@ -134,9 +136,22 @@ bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
             else
                 aSize = Size( 2835, 2835 );
 
+            ::rtl::OUString realURL;
+            if (bLink)
+            {
+                realURL = aURL;
+            }
+            else
+            {
+                uno::Reference<frame::XModel> const xModel(
+                        rSh.GetDoc()->GetDocShell()->GetModel());
+                bRet = ::avmedia::EmbedMedia(xModel, aURL, realURL);
+                if (!bRet) { return bRet; }
+            }
+
             SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aPos, aSize ) );
 
-            pObj->setURL( aURL );
+            pObj->setURL( realURL );
             rSh.EnterStdMode();
             rSh.SwFEShell::InsertDrawObj( *pObj, aPos );
             bRet = true;
commit 51ea69880ca32220fa1c6b3e95c8916e3409184c
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Dec 2 23:53:42 2011 +0100

    avmedia::MediaItem: add pImpl

diff --git a/avmedia/inc/avmedia/mediaitem.hxx b/avmedia/inc/avmedia/mediaitem.hxx
index a535040..cf9f09b 100644
--- a/avmedia/inc/avmedia/mediaitem.hxx
+++ b/avmedia/inc/avmedia/mediaitem.hxx
@@ -26,8 +26,10 @@
  *
  ************************************************************************/
 
-#ifndef _AVMEDIA_MEDIAITEM_HXX
-#define _AVMEDIA_MEDIAITEM_HXX
+#ifndef AVMEDIA_MEDIAITEM_HXX
+#define AVMEDIA_MEDIAITEM_HXX
+
+#include <boost/scoped_ptr.hpp>
 
 #include <tools/rtti.hxx>
 #include <svl/poolitem.hxx>
@@ -71,7 +73,8 @@ class AVMEDIA_DLLPUBLIC MediaItem : public SfxPoolItem
 public:
                             TYPEINFO();
 
-                            MediaItem( sal_uInt16 nWhich = 0, sal_uInt32 nMaskSet = AVMEDIA_SETMASK_NONE );
+                            MediaItem( sal_uInt16 const i_nWhich = 0,
+                            sal_uInt32 const nMaskSet = AVMEDIA_SETMASK_NONE );
                             MediaItem( const MediaItem& rMediaItem );
     virtual                 ~MediaItem();
 
@@ -115,15 +118,8 @@ public:
 
 private:
 
-    ::rtl::OUString         maURL;
-    sal_uInt32              mnMaskSet;
-    MediaState              meState;
-    double                  mfTime;
-    double                  mfDuration;
-    sal_Int16               mnVolumeDB;
-    sal_Bool                mbLoop;
-    sal_Bool                mbMute;
-    ::com::sun::star::media::ZoomLevel meZoom;
+    struct Impl;
+    ::boost::scoped_ptr<Impl> m_pImpl;
 };
 
 typedef ::avmedia::MediaItem avmedia_MediaItem;
diff --git a/avmedia/source/framework/mediaitem.cxx b/avmedia/source/framework/mediaitem.cxx
index babaa39..756c869 100644
--- a/avmedia/source/framework/mediaitem.cxx
+++ b/avmedia/source/framework/mediaitem.cxx
@@ -39,44 +39,57 @@ namespace avmedia
 // -------------
 
 TYPEINIT1_AUTOFACTORY( MediaItem, ::SfxPoolItem );
-    ::rtl::OUString         maURL;
-    sal_uInt32              mnMaskSet;
-    MediaState              meState;
-    double                  mfTime;
-    double                  mfDuration;
-    sal_Int16               mnVolumeDB;
-    sal_Bool                mbLoop;
-    sal_Bool                mbMute;
-    ::com::sun::star::media::ZoomLevel meZoom;
+
+struct MediaItem::Impl
+{
+    ::rtl::OUString         m_URL;
+    sal_uInt32              m_nMaskSet;
+    MediaState              m_eState;
+    double                  m_fTime;
+    double                  m_fDuration;
+    sal_Int16               m_nVolumeDB;
+    sal_Bool                m_bLoop;
+    sal_Bool                m_bMute;
+    ::com::sun::star::media::ZoomLevel m_eZoom;
+
+    Impl(sal_uInt32 const nMaskSet)
+        : m_nMaskSet( nMaskSet )
+        , m_eState( MEDIASTATE_STOP )
+        , m_fTime( 0.0 )
+        , m_fDuration( 0.0 )
+        , m_nVolumeDB( 0 )
+        , m_bLoop( false )
+        , m_bMute( false )
+        , m_eZoom( ::com::sun::star::media::ZoomLevel_NOT_AVAILABLE )
+    {
+    }
+    Impl(Impl const& rOther)
+        : m_URL( rOther.m_URL )
+        , m_nMaskSet( rOther.m_nMaskSet )
+        , m_eState( rOther.m_eState )
+        , m_fTime( rOther.m_fTime )
+        , m_fDuration( rOther.m_fDuration )
+        , m_nVolumeDB( rOther.m_nVolumeDB )
+        , m_bLoop( rOther.m_bLoop )
+        , m_bMute( rOther.m_bMute )
+        , m_eZoom( rOther.m_eZoom )
+    {
+    }
+};
 
 // ------------------------------------------------------------------------------
 
-MediaItem::MediaItem( sal_uInt16 _nWhich, sal_uInt32 nMaskSet ) :
-    SfxPoolItem( _nWhich ),
-    mnMaskSet( nMaskSet ),
-    meState( MEDIASTATE_STOP ),
-    mfTime( 0.0 ),
-    mfDuration( 0.0 ),
-    mnVolumeDB( 0 ),
-    mbLoop( false ),
-    mbMute( false ),
-    meZoom( ::com::sun::star::media::ZoomLevel_NOT_AVAILABLE )
+MediaItem::MediaItem( sal_uInt16 const i_nWhich, sal_uInt32 const nMaskSet )
+    : SfxPoolItem( i_nWhich )
+    , m_pImpl( new Impl(nMaskSet) )
 {
 }
 
 // ------------------------------------------------------------------------------
 
-MediaItem::MediaItem( const MediaItem& rItem ) :
-    SfxPoolItem( rItem ),
-    maURL( rItem.maURL ),
-    mnMaskSet( rItem.mnMaskSet ),
-    meState( rItem.meState ),
-    mfTime( rItem.mfTime ),
-    mfDuration( rItem.mfDuration ),
-    mnVolumeDB( rItem.mnVolumeDB ),
-    mbLoop( rItem.mbLoop ),
-    mbMute( rItem.mbMute ),
-    meZoom( rItem.meZoom )
+MediaItem::MediaItem( const MediaItem& rItem )
+    : SfxPoolItem( rItem )
+    , m_pImpl( new Impl(*rItem.m_pImpl) )
 {
 }
 
@@ -90,16 +103,17 @@ MediaItem::~MediaItem()
 
 int MediaItem::operator==( const SfxPoolItem& rItem ) const
 {
-    DBG_ASSERT( SfxPoolItem::operator==(rItem), "unequal types" );
-    return( mnMaskSet == static_cast< const MediaItem& >( rItem ).mnMaskSet &&
-            maURL == static_cast< const MediaItem& >( rItem ).maURL &&
-            meState == static_cast< const MediaItem& >( rItem ).meState &&
-            mfDuration == static_cast< const MediaItem& >( rItem ).mfDuration &&
-            mfTime == static_cast< const MediaItem& >( rItem ).mfTime &&
-            mnVolumeDB == static_cast< const MediaItem& >( rItem ).mnVolumeDB &&
-            mbLoop == static_cast< const MediaItem& >( rItem ).mbLoop &&
-            mbMute == static_cast< const MediaItem& >( rItem ).mbMute &&
-            meZoom == static_cast< const MediaItem& >( rItem ).meZoom );
+    assert( SfxPoolItem::operator==(rItem));
+    MediaItem const& rOther(static_cast< const MediaItem& >(rItem));
+    return m_pImpl->m_nMaskSet == rOther.m_pImpl->m_nMaskSet
+        && m_pImpl->m_URL == rOther.m_pImpl->m_URL
+        && m_pImpl->m_eState == rOther.m_pImpl->m_eState
+        && m_pImpl->m_fDuration == rOther.m_pImpl->m_fDuration
+        && m_pImpl->m_fTime == rOther.m_pImpl->m_fTime
+        && m_pImpl->m_nVolumeDB == rOther.m_pImpl->m_nVolumeDB
+        && m_pImpl->m_bLoop == rOther.m_pImpl->m_bLoop
+        && m_pImpl->m_bMute == rOther.m_pImpl->m_bMute
+        && m_pImpl->m_eZoom == rOther.m_pImpl->m_eZoom;
 }
 
 // ------------------------------------------------------------------------------
@@ -127,15 +141,15 @@ bool MediaItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 ) const
 {
     uno::Sequence< uno::Any > aSeq( 9 );
 
-    aSeq[ 0 ] <<= maURL;
-    aSeq[ 1 ] <<= mnMaskSet;
-    aSeq[ 2 ] <<= static_cast< sal_Int32 >( meState );
-    aSeq[ 3 ] <<= mfTime;
-    aSeq[ 4 ] <<= mfDuration;
-    aSeq[ 5 ] <<= mnVolumeDB;
-    aSeq[ 6 ] <<= mbLoop;
-    aSeq[ 7 ] <<= mbMute;
-    aSeq[ 8 ] <<= meZoom;
+    aSeq[ 0 ] <<= m_pImpl->m_URL;
+    aSeq[ 1 ] <<= m_pImpl->m_nMaskSet;
+    aSeq[ 2 ] <<= static_cast< sal_Int32 >( m_pImpl->m_eState );
+    aSeq[ 3 ] <<= m_pImpl->m_fTime;
+    aSeq[ 4 ] <<= m_pImpl->m_fDuration;
+    aSeq[ 5 ] <<= m_pImpl->m_nVolumeDB;
+    aSeq[ 6 ] <<= m_pImpl->m_bLoop;
+    aSeq[ 7 ] <<= m_pImpl->m_bMute;
+    aSeq[ 8 ] <<= m_pImpl->m_eZoom;
 
     rVal <<= aSeq;
 
@@ -153,15 +167,16 @@ bool MediaItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 )
     {
         sal_Int32 nInt32 = 0;
 
-        aSeq[ 0 ] >>= maURL;
-        aSeq[ 1 ] >>= mnMaskSet;
-        aSeq[ 2 ] >>= nInt32; meState = static_cast< MediaState >( nInt32 );
-        aSeq[ 3 ] >>= mfTime;
-        aSeq[ 4 ] >>= mfDuration;
-        aSeq[ 5 ] >>= mnVolumeDB;
-        aSeq[ 6 ] >>= mbLoop;
-        aSeq[ 7 ] >>= mbMute;
-        aSeq[ 8 ] >>= meZoom;
+        aSeq[ 0 ] >>= m_pImpl->m_URL;
+        aSeq[ 1 ] >>= m_pImpl->m_nMaskSet;
+        aSeq[ 2 ] >>= nInt32;
+        m_pImpl->m_eState = static_cast< MediaState >( nInt32 );
+        aSeq[ 3 ] >>= m_pImpl->m_fTime;
+        aSeq[ 4 ] >>= m_pImpl->m_fDuration;
+        aSeq[ 5 ] >>= m_pImpl->m_nVolumeDB;
+        aSeq[ 6 ] >>= m_pImpl->m_bLoop;
+        aSeq[ 7 ] >>= m_pImpl->m_bMute;
+        aSeq[ 8 ] >>= m_pImpl->m_eZoom;
 
         bRet = true;
     }
@@ -204,127 +219,127 @@ void MediaItem::merge( const MediaItem& rMediaItem )
 
 sal_uInt32 MediaItem::getMaskSet() const
 {
-    return mnMaskSet;
+    return m_pImpl->m_nMaskSet;
 }
 
 //------------------------------------------------------------------------
 
 void MediaItem::setURL( const ::rtl::OUString& rURL )
 {
-    maURL = rURL;
-    mnMaskSet |= AVMEDIA_SETMASK_URL;
+    m_pImpl->m_URL = rURL;
+    m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_URL;
 }
 
 //------------------------------------------------------------------------
 
 const ::rtl::OUString& MediaItem::getURL() const
 {
-    return maURL;
+    return m_pImpl->m_URL;
 }
 
 //------------------------------------------------------------------------
 
 void MediaItem::setState( MediaState eState )
 {
-    meState = eState;
-    mnMaskSet |= AVMEDIA_SETMASK_STATE;
+    m_pImpl->m_eState = eState;
+    m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_STATE;
 }
 
 //------------------------------------------------------------------------
 
 MediaState MediaItem::getState() const
 {
-    return meState;
+    return m_pImpl->m_eState;
 }
 
 //------------------------------------------------------------------------
 
 void MediaItem::setDuration( double fDuration )
 {
-    mfDuration = fDuration;
-    mnMaskSet |= AVMEDIA_SETMASK_DURATION;
+    m_pImpl->m_fDuration = fDuration;
+    m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_DURATION;
 }
 
 //------------------------------------------------------------------------
 
 double MediaItem::getDuration() const
 {
-    return mfDuration;
+    return m_pImpl->m_fDuration;
 }
 
 //------------------------------------------------------------------------
 
 void MediaItem::setTime( double fTime )
 {
-    mfTime = fTime;
-    mnMaskSet |= AVMEDIA_SETMASK_TIME;
+    m_pImpl->m_fTime = fTime;
+    m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_TIME;
 }
 
 //------------------------------------------------------------------------
 
 double MediaItem::getTime() const
 {
-    return mfTime;
+    return m_pImpl->m_fTime;
 }
 
 //------------------------------------------------------------------------
 
 void MediaItem::setLoop( sal_Bool bLoop )
 {
-    mbLoop = bLoop;
-    mnMaskSet |= AVMEDIA_SETMASK_LOOP;
+    m_pImpl->m_bLoop = bLoop;
+    m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_LOOP;
 }
 
 //------------------------------------------------------------------------
 
 sal_Bool MediaItem::isLoop() const
 {
-    return mbLoop;
+    return m_pImpl->m_bLoop;
 }
 
 //------------------------------------------------------------------------
 
 void MediaItem::setMute( sal_Bool bMute )
 {
-    mbMute = bMute;
-    mnMaskSet |= AVMEDIA_SETMASK_MUTE;
+    m_pImpl->m_bMute = bMute;
+    m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_MUTE;
 }
 
 //------------------------------------------------------------------------
 
 sal_Bool MediaItem::isMute() const
 {
-    return mbMute;
+    return m_pImpl->m_bMute;
 }
 
 //------------------------------------------------------------------------
 
 void MediaItem::setVolumeDB( sal_Int16 nDB )
 {
-    mnVolumeDB = nDB;
-    mnMaskSet |= AVMEDIA_SETMASK_VOLUMEDB;
+    m_pImpl->m_nVolumeDB = nDB;
+    m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_VOLUMEDB;
 }
 
 //------------------------------------------------------------------------
 
 sal_Int16 MediaItem::getVolumeDB() const
 {
-    return mnVolumeDB;
+    return m_pImpl->m_nVolumeDB;
 }
 
 //------------------------------------------------------------------------
 
 void MediaItem::setZoom( ::com::sun::star::media::ZoomLevel eZoom )
 {
-    meZoom = eZoom;
-    mnMaskSet |= AVMEDIA_SETMASK_ZOOM;
+    m_pImpl->m_eZoom = eZoom;
+    m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_ZOOM;
 }
 
 //------------------------------------------------------------------------
 
 ::com::sun::star::media::ZoomLevel MediaItem::getZoom() const
 {
-    return meZoom;
+    return m_pImpl->m_eZoom;
 }
 
 }
commit fd95f1ab6220c6a530fd2e4e727417f504a5db51
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Dec 2 23:43:23 2011 +0100

    refactor SdrModel::GetDocumentStream
    
    Remove 3 ~identical implementations of GetDocumentStream and the associated
    struct SdrDocumentStreamInfo.

diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx
index 35e1843..6f4f71d 100644
--- a/sc/inc/drwlayer.hxx
+++ b/sc/inc/drwlayer.hxx
@@ -115,7 +115,6 @@ public:
     virtual void    SetChanged( sal_Bool bFlg = sal_True );
 
     virtual Window* GetCurDocViewWin();
-    virtual SvStream* GetDocumentStream(SdrDocumentStreamInfo& rStreamInfo) const;
 
     virtual SdrLayerID GetControlExportLayerId( const SdrObject & ) const;
 
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 58b591c..327f65a 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1904,59 +1904,6 @@ void ScDrawLayer::SetChanged( sal_Bool bFlg /* = sal_True */ )
     FmFormModel::SetChanged( bFlg );
 }
 
-SvStream* ScDrawLayer::GetDocumentStream(SdrDocumentStreamInfo& rStreamInfo) const
-{
-    OSL_ENSURE( pDoc, "ScDrawLayer::GetDocumentStream without document" );
-    if ( !pDoc )
-        return NULL;
-
-    uno::Reference< embed::XStorage > xStorage = pDoc->GetDocumentShell() ?
-                                                        pDoc->GetDocumentShell()->GetStorage() :
-                                                        NULL;
-    SvStream*   pRet = NULL;
-
-    if( xStorage.is() )
-    {
-        if( rStreamInfo.maUserData.Len() &&
-            ( rStreamInfo.maUserData.GetToken( 0, ':' ) ==
-              String( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package" ) ) ) )
-        {
-            const String aPicturePath( rStreamInfo.maUserData.GetToken( 1, ':' ) );
-
-            // graphic from picture stream in picture storage in XML package
-            if( aPicturePath.GetTokenCount( '/' ) == 2 )
-            {
-                const String aPictureStreamName( aPicturePath.GetToken( 1, '/' ) );
-                const String aPictureStorageName( aPicturePath.GetToken( 0, '/' ) );
-
-                try {
-                    if ( xStorage->isStorageElement( aPictureStorageName ) )
-                    {
-                        uno::Reference< embed::XStorage > xPictureStorage =
-                                    xStorage->openStorageElement( aPictureStorageName, embed::ElementModes::READ );
-
-                        if( xPictureStorage.is() &&
-                            xPictureStorage->isStreamElement( aPictureStreamName ) )
-                        {
-                            uno::Reference< io::XStream > xStream =
-                                xPictureStorage->openStreamElement( aPictureStreamName, embed::ElementModes::READ );
-                            if ( xStream.is() )
-                                pRet = ::utl::UcbStreamHelper::CreateStream( xStream );
-                        }
-                    }
-                }
-                catch( uno::Exception& )
-                {
-                    // TODO: error handling
-                }
-            }
-        }
-        rStreamInfo.mbDeleteAfterUse = ( pRet != NULL );
-    }
-
-    return pRet;
-}
-
 SdrLayerID ScDrawLayer::GetControlExportLayerId( const SdrObject & ) const
 {
     //  Layer fuer Export von Form-Controls in Versionen vor 5.0 - immer SC_LAYER_FRONT
diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index 86b2ef8..7e087f5 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -229,7 +229,6 @@ public:
     virtual void        DisposeLoadedModels();
     virtual bool    IsReadOnly() const;
     virtual void        SetChanged(sal_Bool bFlag = sal_True);
-    virtual SvStream*   GetDocumentStream(SdrDocumentStreamInfo& rStreamInfo) const;
 
     SfxItemPool&        GetPool() { return( *pItemPool ); }
 
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index b400015..c05af48 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -1242,88 +1242,6 @@ List* SdDrawDocument::GetCustomShowList(sal_Bool bCreate)
 
 /*************************************************************************
 |*
-|* Document-Stream herausgeben (fuer load-on-demand Graphiken)
-|*
-\************************************************************************/
-
-SvStream* SdDrawDocument::GetDocumentStream(SdrDocumentStreamInfo& rStreamInfo) const
-{
-    uno::Reference < embed::XStorage > xStor;
-    if (mpDocSh)
-        xStor = mpDocSh->GetStorage();
-    SvStream*   pRet = NULL;
-
-    if( xStor.is() )
-    {
-        //TODO/MBA: binary format removed, needs testing
-        if( rStreamInfo.maUserData.Len() &&
-            ( rStreamInfo.maUserData.GetToken( 0, ':' ) ==
-              String( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package" ) ) ) )
-        {
-            const String aPicturePath( rStreamInfo.maUserData.GetToken( 1, ':' ) );
-
-            // graphic from picture stream in picture storage in XML package
-            if( aPicturePath.GetTokenCount( '/' ) == 2 ) try
-            {
-                const String aPictureStreamName( aPicturePath.GetToken( 1, '/' ) );
-                const String aPictureStorageName( aPicturePath.GetToken( 0, '/' ) );
-                if( xStor->isStorageElement( aPictureStorageName )  )
-                {
-                    uno::Reference < embed::XStorage > xPictureStorage =
-                            xStor->openStorageElement( aPictureStorageName, embed::ElementModes::READ );
-                    try
-                    {
-                        if( xPictureStorage.is() && xPictureStorage->isStreamElement( aPictureStreamName ) )
-                        {
-                            uno::Reference < io::XStream > xStream = xPictureStorage->openStreamElement( aPictureStreamName, embed::ElementModes::READ );
-                            if( xStream.is() )
-                                pRet = ::utl::UcbStreamHelper::CreateStream( xStream );
-                        }
-                    }
-                    catch( container::NoSuchElementException& )
-                    {
-                    }
-                }
-            }
-            catch( uno::Exception& e )
-            {
-                (void)e;
-                OSL_FAIL(
-                    (rtl::OString("sd::SdDrawDocument::GetDocumentStream(), "
-                            "exception caught: ") +
-                    rtl::OUStringToOString(
-                        comphelper::anyToString( cppu::getCaughtException() ),
-                        RTL_TEXTENCODING_UTF8 ) +
-                        rtl::OString("\r\nATTENTION: Graphics may get lost now, please inform CL or KA!") ).getStr() );
-            }
-
-            rStreamInfo.mbDeleteAfterUse = ( pRet != NULL );
-        }
-    }
-
-#if OSL_DEBUG_LEVEL > 1
-    if( pRet )
-    {
-        // try to get some information from stream
-        const sal_uLong nStartPos = pRet->Tell();
-        const sal_uLong nEndPos = pRet->Seek( STREAM_SEEK_TO_END );
-        const sal_uLong nStmLen = nEndPos - nStartPos;
-        sal_uChar   aTestByte;
-
-        // try to read one byte
-        if( nStmLen )
-            *pRet >> aTestByte;
-
-        pRet->Seek( nStartPos );
-    }
-#endif
-
-    return pRet;
-}
-
-
-/*************************************************************************
-|*
 |* Nicht benutzte MasterPages und Layouts entfernen
 |*
 \************************************************************************/
diff --git a/sd/source/ui/inc/DrawDocShell.hxx b/sd/source/ui/inc/DrawDocShell.hxx
index 02f225d..0083f53 100644
--- a/sd/source/ui/inc/DrawDocShell.hxx
+++ b/sd/source/ui/inc/DrawDocShell.hxx
@@ -47,7 +47,6 @@ class SdDrawDocument;
 class SvxItemFactory;
 class SdPage;
 class SfxPrinter;
-struct SdrDocumentStreamInfo;
 struct SpellCallbackInfo;
 class AbstractSvxNameDialog;
 class SfxUndoManager;
diff --git a/svx/inc/svx/svdmodel.hxx b/svx/inc/svx/svdmodel.hxx
index 3cf998f..567c821 100644
--- a/svx/inc/svx/svdmodel.hxx
+++ b/svx/inc/svx/svdmodel.hxx
@@ -91,10 +91,13 @@ class SotStorage;
 class SdrOutlinerCache;
 class SotStorageRef;
 class SdrUndoFactory;
-namespace comphelper{
+namespace comphelper
+{
     class IEmbeddedHelper;
+    class LifecycleProxy;
 }
-namespace sfx2{
+namespace sfx2
+{
     class LinkManager;
 }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -156,13 +159,6 @@ public:
 // neu zu bestimmen und unbenutztes wegzuwerfen). sal_False == aktiv
 #define LOADREFCOUNTS (false)
 
-struct SdrDocumentStreamInfo
-{
-    bool            mbDeleteAfterUse;
-    String          maUserData;
-    com::sun::star::uno::Reference < com::sun::star::embed::XStorage > mxStorageRef;
-};
-
 struct SdrModelImpl;
 
 class SVX_DLLPUBLIC SdrModel : public SfxBroadcaster, public tools::WeakBase< SdrModel >
@@ -330,7 +326,12 @@ public:
     // Datei angelegt.
     // Geliefert werden muss der Stream, aus dem das Model geladen wurde
     // bzw. in den es zuletzt gespeichert wurde.
-    virtual SvStream* GetDocumentStream( SdrDocumentStreamInfo& rStreamInfo ) const;
+    virtual ::com::sun::star::uno::Reference<
+                ::com::sun::star::embed::XStorage> GetDocumentStorage() const;
+    ::com::sun::star::uno::Reference<
+            ::com::sun::star::io::XInputStream >
+        GetDocumentStream(::rtl::OUString const& rURL,
+                ::comphelper::LifecycleProxy & rProxy) const;
     // Die Vorlagenattribute der Zeichenobjekte in harte Attribute verwandeln.
     void BurnInStyleSheetAttributes();
     // Wer sich von SdrPage ableitet muss sich auch von SdrModel ableiten
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index cb24ca2..df94366 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -29,11 +29,16 @@
 
 #include <svx/svdmodel.hxx>
 
-#include <com/sun/star/lang/XComponent.hpp>
+#include <math.h>
+
 #include <osl/endian.h>
 #include <rtl/logfile.hxx>
 #include <rtl/strbuf.hxx>
-#include <math.h>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+
 #include <tools/urlobj.hxx>
 #include <unotools/ucbstreamhelper.hxx>
 
@@ -82,6 +87,7 @@
 #include <svl/zforlist.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/servicehelper.hxx>
+#include <comphelper/storagehelper.hxx>
 
 #include <tools/tenccvt.hxx>
 #include <unotools/syslocale.hxx>
@@ -886,9 +892,43 @@ void SdrModel::ImpReformatAllEdgeObjects()
     }
 }
 
-SvStream* SdrModel::GetDocumentStream(SdrDocumentStreamInfo& /*rStreamInfo*/) const
+uno::Reference<embed::XStorage> SdrModel::GetDocumentStorage() const
 {
-    return NULL;
+    uno::Reference<document::XStorageBasedDocument> const xSBD(
+            const_cast<SdrModel*>(this)->getUnoModel(), uno::UNO_QUERY);
+    if (!xSBD.is())
+    {
+        SAL_WARN("svx", "no UNO model");
+        return 0;
+    }
+    return xSBD->getDocumentStorage();
+}
+
+uno::Reference<io::XInputStream>
+SdrModel::GetDocumentStream( ::rtl::OUString const& rURL,
+                ::comphelper::LifecycleProxy & rProxy) const
+{
+    uno::Reference<embed::XStorage> const xStorage(GetDocumentStorage());
+    if (!xStorage.is())
+    {
+        SAL_WARN("svx", "no storage?");
+        return 0;
+    }
+    try {
+        uno::Reference<io::XStream> const xStream(
+            ::comphelper::OStorageHelper::GetStreamAtPackageURL(
+                xStorage, rURL, embed::ElementModes::READ, rProxy));
+        return (xStream.is()) ? xStream->getInputStream() : 0;
+    }
+    catch (container::NoSuchElementException const&)
+    {
+        SAL_INFO("svx", "not found");
+    }
+    catch (uno::Exception const&)
+    {
+        SAL_WARN("svx", "exception");
+    }
+    return 0;
 }
 
 // convert template attributes from the string into "hard" attributes
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index a587ab0..151878a 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -35,6 +35,7 @@
 #include <vcl/salbtype.hxx>
 #include <sot/formats.hxx>
 #include <sot/storage.hxx>
+#include <comphelper/storagehelper.hxx>
 #include <unotools/ucbstreamhelper.hxx>
 #include <unotools/localfilehelper.hxx>
 #include <svl/style.hxx>
@@ -71,6 +72,7 @@
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <osl/thread.hxx>
 
+using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::io;
 
@@ -1220,12 +1222,13 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
         {
             if( pGraphic->HasUserData() )
             {
-                SdrDocumentStreamInfo aStreamInfo;
+                ::comphelper::LifecycleProxy proxy;
+                uno::Reference<io::XInputStream> const xStream(
+                    pModel->GetDocumentStream(pGraphic->GetUserData(), proxy));
 
-                aStreamInfo.mbDeleteAfterUse = sal_False;
-                aStreamInfo.maUserData = pGraphic->GetUserData();
-
-                SvStream* pStream = pModel->GetDocumentStream( aStreamInfo );
+                ::boost::scoped_ptr<SvStream> const pStream( (xStream.is())
+                        ? ::utl::UcbStreamHelper::CreateStream(xStream)
+                        : 0 );
 
                 if( pStream != NULL )
                 {
@@ -1251,7 +1254,7 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
                     }
 
                     if( !GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic,
-                                                                          aStreamInfo.maUserData,
+                                                                          pGraphic->GetUserData(),
                                                                           *pStream,
                                                                           GRFILTER_FORMAT_DONTKNOW,
                                                                           NULL, 0, pFilterData ) )
@@ -1267,17 +1270,6 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
                     delete pFilterData;
 
                     pStream->ResetError();
-
-                    if( aStreamInfo.mbDeleteAfterUse || aStreamInfo.mxStorageRef.is() )
-                    {
-                        if ( aStreamInfo.mxStorageRef.is() )
-                        {
-                            aStreamInfo.mxStorageRef->dispose();
-                            aStreamInfo.mxStorageRef = 0;
-                        }
-
-                        delete pStream;
-                    }
                 }
             }
             else if( !ImpUpdateGraphicLink( sal_False ) )
@@ -1316,15 +1308,9 @@ Reference< XInputStream > SdrGrafObj::getInputStream()
         // kann aus dem original Doc-Stream nachgeladen werden...
         if( pGraphic->HasUserData() )
         {
-            SdrDocumentStreamInfo aStreamInfo;
-
-            aStreamInfo.mbDeleteAfterUse = sal_False;
-            aStreamInfo.maUserData = pGraphic->GetUserData();
-
-            SvStream* pStream = pModel->GetDocumentStream( aStreamInfo );
-
-            if( pStream )
-                xStream.set( new utl::OInputStreamWrapper( pStream, sal_True ) );
+            ::comphelper::LifecycleProxy proxy;
+            xStream.set(
+                pModel->GetDocumentStream(pGraphic->GetUserData(), proxy));
         }
         else if( pGraphic && GetGraphic().IsLink() )
         {
diff --git a/sw/inc/drawdoc.hxx b/sw/inc/drawdoc.hxx
index 4c699c3..cdc2c3b 100644
--- a/sw/inc/drawdoc.hxx
+++ b/sw/inc/drawdoc.hxx
@@ -47,9 +47,8 @@ public:
 
     virtual SdrPage* AllocPage(bool bMasterPage);
 
-
-    // For "load on demand" of graphics in DrawingLayer.
-    virtual SvStream* GetDocumentStream( SdrDocumentStreamInfo& rInfo ) const;
+    virtual ::com::sun::star::uno::Reference<
+                ::com::sun::star::embed::XStorage> GetDocumentStorage() const;
 
     // For saving of rectangles as control-replacement for versions < 5.0.
     virtual SdrLayerID GetControlExportLayerId( const SdrObject & ) const;
diff --git a/sw/source/core/draw/drawdoc.cxx b/sw/source/core/draw/drawdoc.cxx
index 92684dc..00ea9c7 100644
--- a/sw/source/core/draw/drawdoc.cxx
+++ b/sw/source/core/draw/drawdoc.cxx
@@ -161,45 +161,9 @@ SdrPage* SwDrawDocument::AllocPage(bool bMasterPage)
     return pPage;
 }
 
-
-SvStream* SwDrawDocument::GetDocumentStream( SdrDocumentStreamInfo& rInfo ) const
+uno::Reference<embed::XStorage> SwDrawDocument::GetDocumentStorage() const
 {
-    SvStream* pRet = NULL;
-    uno::Reference < embed::XStorage > xRoot( pDoc->GetDocStorage() );
-    if( xRoot.is() )
-    {
-        if( rInfo.maUserData.Len() &&
-            ( rInfo.maUserData.GetToken( 0, ':' ) ==
-              String( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package" ) ) ) )
-        {
-            const String aPicturePath( rInfo.maUserData.GetToken( 1, ':' ) );
-
-            // graphic from picture stream in picture storage in XML package
-            if( aPicturePath.GetTokenCount( '/' ) == 2 )
-            {
-                const String    aPictureStorageName( aPicturePath.GetToken( 0, '/' ) );
-                const String    aPictureStreamName( aPicturePath.GetToken( 1, '/' ) );
-
-                try
-                {
-                    uno::Reference < embed::XStorage > xPictureStorage = xRoot->openStorageElement(
-                            aPictureStorageName, embed::ElementModes::READ );
-                    uno::Reference < io::XStream > xStream = xPictureStorage->openStreamElement(
-                            aPictureStreamName, embed::ElementModes::READ );
-                    pRet = utl::UcbStreamHelper::CreateStream( xStream );
-                    if( pRet )
-                    {
-                        rInfo.mbDeleteAfterUse = sal_True;
-                        rInfo.mxStorageRef = xPictureStorage;
-                    }
-                }
-                catch ( uno::Exception& )
-                {
-                }
-            }
-        }
-    }
-    return pRet;
+    return pDoc->GetDocStorage();
 }
 
 SdrLayerID SwDrawDocument::GetControlExportLayerId( const SdrObject & ) const
commit aa59ee85a8e902aa4dc956822e9169093de6c454
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Dec 2 23:35:00 2011 +0100

    SdrModel: remove unused pModelStorage

diff --git a/svx/inc/svx/svdmodel.hxx b/svx/inc/svx/svdmodel.hxx
index 3eec2cf..3cf998f 100644
--- a/svx/inc/svx/svdmodel.hxx
+++ b/svx/inc/svx/svdmodel.hxx
@@ -161,7 +161,6 @@ struct SdrDocumentStreamInfo
     bool            mbDeleteAfterUse;
     String          maUserData;
     com::sun::star::uno::Reference < com::sun::star::embed::XStorage > mxStorageRef;
-    sal_Bool            mbDummy1 : 1;
 };
 
 struct SdrModelImpl;
@@ -253,8 +252,6 @@ public:
     void SetAllowShapePropertyChangeListener( bool bAllow );
 
     sal_uInt16          nStarDrawPreviewMasterPageNum;
-    // Reserven fuer kompatible Erweiterungen
-    SotStorage*     pModelStorage;
     SvxForbiddenCharactersTable* mpForbiddenCharactersTable;
     sal_uIntPtr         nSwapGraphicsMode;
 
@@ -645,9 +642,6 @@ public:
     void    SetStarDrawPreviewMode(sal_Bool bPreview);
     sal_Bool    IsStarDrawPreviewMode() { return bStarDrawPreviewMode; }
 
-    SotStorage* GetModelStorage() const { return pModelStorage; }
-    void        SetModelStorage( SotStorage* pStor ) { pModelStorage = pStor; }
-
     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoModel();
     void setUnoModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xModel );
 
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 3e8daa2..cb24ca2 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -164,7 +164,6 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe
     bTransparentTextFrames=sal_False;
     bStarDrawPreviewMode = sal_False;
     nStarDrawPreviewMasterPageNum = SDRPAGE_NOTFOUND;
-    pModelStorage = NULL;
     mpForbiddenCharactersTable = NULL;
     mbModelLocked = false;
     mpOutlinerCache = NULL;
commit c2d3f170fbe6ab553c50a0b9ba63a0496e1b24e0
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Dec 2 23:35:00 2011 +0100

    move LifecycleProxy out of comphelper::OStorageHelper
    
    ... so it can be forward declared

diff --git a/comphelper/inc/comphelper/storagehelper.hxx b/comphelper/inc/comphelper/storagehelper.hxx
index c0aa735..36ff795 100644
--- a/comphelper/inc/comphelper/storagehelper.hxx
+++ b/comphelper/inc/comphelper/storagehelper.hxx
@@ -25,8 +25,10 @@
  * for a copy of the LGPLv3 License.
  *
  ************************************************************************/
-#ifndef _COMPHELPER_STORAGEHELPER_HXX
-#define _COMPHELPER_STORAGEHELPER_HXX
+#ifndef COMPHELPER_STORAGEHELPER_HXX
+#define COMPHELPER_STORAGEHELPER_HXX
+
+#include <boost/scoped_ptr.hpp>
 
 #include <com/sun/star/uno/Sequence.hxx>
 #include <com/sun/star/uno/Reference.hxx>
@@ -51,6 +53,20 @@
 
 namespace comphelper {
 
+// Unfortunately - the impl.s of XStorage like to invalidate all
+// their sub streams and storages when you release references, so
+// it is necessary to keep references to all storages down the
+// path - this is 'beautiful' (TM). So we need this ugly hack:
+class COMPHELPER_DLLPUBLIC LifecycleProxy
+{
+private:
+    class Impl;
+public:
+    ::boost::scoped_ptr<Impl> m_pBadness;
+    LifecycleProxy();
+    ~LifecycleProxy();
+};
+
 class COMPHELPER_DLLPUBLIC OStorageHelper
 {
 public:
@@ -170,17 +186,6 @@ public:
 
     // Methods to allow easy use of hierachical names inside storages
 
-    // Unfortunately - the impl.s of XStorage like to invalidate all
-    // their sub streams and storages when you release references, so
-    // it is necessary to keep references to all storages down the
-    // path - this is 'beautiful' (TM). So we need this ugly hack:
-    class LifecycleProxyImpl;
-    class COMPHELPER_DLLPUBLIC LifecycleProxy {
-    public:
-        LifecycleProxyImpl *pBadness;
-        LifecycleProxy();
-        ~LifecycleProxy();
-    };
     static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetStorageAtPath(
         const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > &xStorage,
         const ::rtl::OUString& aPath, sal_uInt32 nOpenMode, LifecycleProxy &rNastiness );
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index 6fb41c9..e429f22 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -545,10 +545,11 @@ sal_Bool OStorageHelper::PathHasSegment( const ::rtl::OUString& aPath, const ::r
     return bResult;
 }
 
-class OStorageHelper::LifecycleProxyImpl : public std::vector< uno::Reference< embed::XStorage > > {};
-OStorageHelper::LifecycleProxy::LifecycleProxy() :
-        pBadness( new OStorageHelper::LifecycleProxyImpl() ) { }
-OStorageHelper::LifecycleProxy::~LifecycleProxy() { delete pBadness; }
+class LifecycleProxy::Impl
+    : public std::vector< uno::Reference< embed::XStorage > > {};
+LifecycleProxy::LifecycleProxy()
+    : m_pBadness( new Impl() ) { }
+LifecycleProxy::~LifecycleProxy() { }
 
 static void splitPath( std::vector<rtl::OUString> &rElems,
                        const ::rtl::OUString& rPath )
@@ -560,14 +561,14 @@ static void splitPath( std::vector<rtl::OUString> &rElems,
 static uno::Reference< embed::XStorage > LookupStorageAtPath(
         const uno::Reference< embed::XStorage > &xParentStorage,
         std::vector<rtl::OUString> &rElems, sal_uInt32 nOpenMode,
-        OStorageHelper::LifecycleProxy &rNastiness )
+        LifecycleProxy &rNastiness )
 {
     uno::Reference< embed::XStorage > xStorage( xParentStorage );
-    rNastiness.pBadness->push_back( xStorage );
+    rNastiness.m_pBadness->push_back( xStorage );
     for( size_t i = 0; i < rElems.size() && xStorage.is(); i++ )
     {
         xStorage = xStorage->openStorageElement( rElems[i], nOpenMode );
-        rNastiness.pBadness->push_back( xStorage );
+        rNastiness.m_pBadness->push_back( xStorage );
     }
     return xStorage;
 }
@@ -575,7 +576,7 @@ static uno::Reference< embed::XStorage > LookupStorageAtPath(
 uno::Reference< embed::XStorage > OStorageHelper::GetStorageAtPath(
         const uno::Reference< embed::XStorage > &xStorage,
         const ::rtl::OUString& rPath, sal_uInt32 nOpenMode,
-        OStorageHelper::LifecycleProxy &rNastiness )
+        LifecycleProxy &rNastiness )
 {
     std::vector<rtl::OUString> aElems;
     splitPath( aElems, rPath );
@@ -585,7 +586,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageAtPath(
 uno::Reference< io::XStream > OStorageHelper::GetStreamAtPath(
         const uno::Reference< embed::XStorage > &xParentStorage,
         const ::rtl::OUString& rPath, sal_uInt32 nOpenMode,
-        OStorageHelper::LifecycleProxy &rNastiness )
+        LifecycleProxy &rNastiness )
 {
     std::vector<rtl::OUString> aElems;
     splitPath( aElems, rPath );
@@ -601,7 +602,7 @@ uno::Reference< io::XStream > OStorageHelper::GetStreamAtPath(
 uno::Reference< io::XStream > OStorageHelper::GetStreamAtPackageURL(
         uno::Reference< embed::XStorage > const& xParentStorage,
         const ::rtl::OUString& rURL, sal_uInt32 const nOpenMode,
-        OStorageHelper::LifecycleProxy & rNastiness)
+        LifecycleProxy & rNastiness)
 {
     static char const s_PkgScheme[] = "vnd.sun.star.Package:";
     if (0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx
index 604c6fb..50106c1 100644
--- a/svx/source/xml/xmlxtimp.cxx
+++ b/svx/source/xml/xmlxtimp.cxx
@@ -403,7 +403,7 @@ bool SvxXMLXTableImport::load( const rtl::OUString &rPath,
         uno::Reference< xml::sax::XParser > xParser( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Parser" ) ) ), uno::UNO_QUERY_THROW );
 
         xml::sax::InputSource aParserInput;
-        comphelper::OStorageHelper::LifecycleProxy aNasty;
+        comphelper::LifecycleProxy aNasty;
 
         if( !bUseStorage || !xStorage.is() )
         {
commit c9a1a2acd51224f525f6ed246e52511192215dc0
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Dec 2 23:34:41 2011 +0100

    new comphelper::OStorageHelper::GetStreamAtPackageURL

diff --git a/comphelper/inc/comphelper/storagehelper.hxx b/comphelper/inc/comphelper/storagehelper.hxx
index 90685bf..c0aa735 100644
--- a/comphelper/inc/comphelper/storagehelper.hxx
+++ b/comphelper/inc/comphelper/storagehelper.hxx
@@ -187,6 +187,10 @@ public:
     static ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > GetStreamAtPath(
         const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > &xStorage,
         const ::rtl::OUString& aPath, sal_uInt32 nOpenMode, LifecycleProxy &rNastiness );
+    static ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > GetStreamAtPackageURL(
+        const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > &xStorage,
+        const ::rtl::OUString& rURL, sal_uInt32 const nOpenMode,
+        LifecycleProxy & rNastiness );
 };
 
 }
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index 0aee11e..6fb41c9 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -598,6 +598,22 @@ uno::Reference< io::XStream > OStorageHelper::GetStreamAtPath(
     return xStorage->openStreamElement( aName, nOpenMode );
 }
 
+uno::Reference< io::XStream > OStorageHelper::GetStreamAtPackageURL(
+        uno::Reference< embed::XStorage > const& xParentStorage,
+        const ::rtl::OUString& rURL, sal_uInt32 const nOpenMode,
+        OStorageHelper::LifecycleProxy & rNastiness)
+{
+    static char const s_PkgScheme[] = "vnd.sun.star.Package:";
+    if (0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
+                rURL.getStr(), rURL.getLength(),
+                s_PkgScheme, SAL_N_ELEMENTS(s_PkgScheme) - 1))
+    {
+        ::rtl::OUString const path(rURL.copy(SAL_N_ELEMENTS(s_PkgScheme)-1));
+        return GetStreamAtPath(xParentStorage, path, nOpenMode, rNastiness);
+    }
+    return 0;
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 18ab7abaa9426cd27092125637fdf5fb849b4a04
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Nov 30 16:08:24 2011 +0100

    MediaWindow::executeMediaURLDialog: add link button

diff --git a/avmedia/inc/avmedia/mediawindow.hxx b/avmedia/inc/avmedia/mediawindow.hxx
index 9de4ab6..696eab6 100644
--- a/avmedia/inc/avmedia/mediawindow.hxx
+++ b/avmedia/inc/avmedia/mediawindow.hxx
@@ -119,7 +119,10 @@ namespace avmedia
     public:
 
         static void         getMediaFilters( FilterNameVector& rFilterNameVector );
-        static bool         executeMediaURLDialog( Window* pParent, ::rtl::OUString& rURL, bool bInsertDialog = true );
+        /// @param o_pbLink if not 0, this is an "insert" dialog: display link
+        ///                 checkbox and store its state in *o_pbLink
+        static bool         executeMediaURLDialog( Window* pParent,
+                ::rtl::OUString& rURL, bool *const o_pbLink );
         static void         executeFormatErrorBox( Window* pParent );
         static bool         isMediaURL( const ::rtl::OUString& rURL, bool bDeep = false, Size* pPreferredSizePixel = NULL );
 
diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx
index e565505..2919069 100644
--- a/avmedia/source/framework/mediacontrol.cxx
+++ b/avmedia/source/framework/mediacontrol.cxx
@@ -499,7 +499,8 @@ IMPL_LINK( MediaControl, implSelectHdl, ToolBox*, p )
             {
                 ::rtl::OUString aURL;
 
-                 if( ::avmedia::MediaWindow::executeMediaURLDialog( GetParent(), aURL, false ) )
+                 if (::avmedia::MediaWindow::executeMediaURLDialog(
+                             GetParent(), aURL, 0))
                  {
                      if( !::avmedia::MediaWindow::isMediaURL( aURL, true ) )
                         ::avmedia::MediaWindow::executeFormatErrorBox( this );
diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx
index b910a0c..f063526 100644
--- a/avmedia/source/viewer/mediawindow.cxx
+++ b/avmedia/source/viewer/mediawindow.cxx
@@ -39,7 +39,9 @@
 #include <comphelper/processfactory.hxx>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/media/XManager.hpp>
+#include "com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp"
 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include "com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp"
 
 #define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME_MEDIATIME 3.0
 
@@ -251,15 +253,19 @@ void MediaWindow::getMediaFilters( FilterNameVector& rFilterNameVector )
 
 // -------------------------------------------------------------------------
 
-bool MediaWindow::executeMediaURLDialog( Window* /* pParent */, ::rtl::OUString& rURL, bool bInsertDialog )
+bool MediaWindow::executeMediaURLDialog(Window* /* pParent */,
+        ::rtl::OUString& rURL, bool *const o_pbLink)
 {
-    ::sfx2::FileDialogHelper        aDlg( com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
+    ::sfx2::FileDialogHelper        aDlg( (o_pbLink)
+            ? ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW
+            : ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
     static const ::rtl::OUString    aWildcard( RTL_CONSTASCII_USTRINGPARAM( "*." ) );
     FilterNameVector                aFilters;
     const ::rtl::OUString           aSeparator( RTL_CONSTASCII_USTRINGPARAM( ";" ) );
     ::rtl::OUString                 aAllTypes;
 
-    aDlg.SetTitle( AVMEDIA_RESID( bInsertDialog ? AVMEDIA_STR_INSERTMEDIA_DLG : AVMEDIA_STR_OPENMEDIA_DLG ) );
+    aDlg.SetTitle( AVMEDIA_RESID( (o_pbLink)
+                ? AVMEDIA_STR_INSERTMEDIA_DLG : AVMEDIA_STR_OPENMEDIA_DLG ) );
 
     getMediaFilters( aFilters );
 
@@ -297,10 +303,36 @@ bool MediaWindow::executeMediaURLDialog( Window* /* pParent */, ::rtl::OUString&
     // add filter for all types
     aDlg.AddFilter( AVMEDIA_RESID( AVMEDIA_STR_ALL_FILES ), String( RTL_CONSTASCII_USTRINGPARAM( "*.*" ) ) );
 
+    uno::Reference<ui::dialogs::XFilePicker> const xFP(aDlg.GetFilePicker());
+    uno::Reference<ui::dialogs::XFilePickerControlAccess> const xCtrlAcc(xFP,
+            uno::UNO_QUERY_THROW);
+    if (o_pbLink)
+    {
+        // for video link should be the default
+        xCtrlAcc->setValue(
+                ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0,
+                uno::makeAny(sal_True) );
+        // disabled for now: TODO: preview?
+        xCtrlAcc->enableControl(
+                ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_PREVIEW,
+                sal_False);
+    }
+
     if( aDlg.Execute() == ERRCODE_NONE )
     {
         const INetURLObject aURL( aDlg.GetPath() );
         rURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+
+        if (o_pbLink)
+        {
+            uno::Any const any = xCtrlAcc->getValue(
+                ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
+            if (!(any >>= *o_pbLink))
+            {
+                SAL_WARN("avmedia", "invalid link property");
+                *o_pbLink = true;
+            }
+        }
     }
     else if( rURL.getLength() )
         rURL = ::rtl::OUString();
diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
index 15385b3..dca4491 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -326,7 +326,9 @@ FuInsertMedia::FuInsertMedia( ScTabViewShell*   pViewSh,
         }
     }
 
-    if( bAPI || ::avmedia::MediaWindow::executeMediaURLDialog( pWindow, aURL ) )
+    bool bLink(true);
+    if (bAPI ||
+        ::avmedia::MediaWindow::executeMediaURLDialog(pWindow, aURL, & bLink))
     {
         Size aPrefSize;
 
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 417948e..184248d 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -728,7 +728,9 @@ void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
         }
     }
 
-    if( bAPI || ::avmedia::MediaWindow::executeMediaURLDialog( mpWindow, aURL ) )
+    bool bLink(true);
+    if (bAPI ||
+        ::avmedia::MediaWindow::executeMediaURLDialog(mpWindow, aURL, & bLink))
     {
         Size aPrefSize;
 
diff --git a/sw/source/ui/shells/grfshex.cxx b/sw/source/ui/shells/grfshex.cxx
index 4dbda31..8340579 100644
--- a/sw/source/ui/shells/grfshex.cxx
+++ b/sw/source/ui/shells/grfshex.cxx
@@ -89,7 +89,9 @@ bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
         }
     }
 
-    if( bAPI || ::avmedia::MediaWindow::executeMediaURLDialog( pWindow, aURL ) )
+    bool bLink(true);
+    if (bAPI ||
+        ::avmedia::MediaWindow::executeMediaURLDialog(pWindow, aURL, & bLink))
     {
         Size aPrefSize;
 
commit c6fdc42e87d3474d89d33486a23885a2921160af
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Nov 30 16:08:23 2011 +0100

    sfx2::FileDialogHelper: the punchline:
    
    Now that we have removed all the pointless clutter, we can finally make it
    possible to create a file dialog that has a link checkbox but not dozens of
    graphic filters pre-registered: only add them if SFXWB_GRAPHIC is given.

diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 1ab73ed..96cb966 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -919,7 +919,7 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
     mbHasVersions           = sal_False;
     mbHasPreview            = sal_False;
     mbShowPreview           = sal_False;
-    mbHasLink               = sal_False;
+    mbAddGraphicFilter      = SFXWB_GRAPHIC == (nFlags & SFXWB_GRAPHIC);
     mbDeleteMatcher         = sal_False;
     mbInsert                = SFXWB_INSERT == ( nFlags & SFXWB_INSERT );
     mbExport                = SFXWB_EXPORT == ( nFlags & SFXWB_EXPORT );
@@ -1016,7 +1016,6 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
             case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE:
                 nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE;
                 mbHasPreview = sal_True;
-                mbHasLink = sal_True;
 
                 // aPreviewTimer
                 maPreViewTimer.SetTimeout( 500 );
@@ -1035,7 +1034,6 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
             case FILEOPEN_LINK_PREVIEW:
                 nTemplateDescription = TemplateDescription::FILEOPEN_LINK_PREVIEW;
                 mbHasPreview = sal_True;
-                mbHasLink = sal_True;
                 // aPreviewTimer
                 maPreViewTimer.SetTimeout( 500 );
                 maPreViewTimer.SetTimeoutHdl( LINK( this, FileDialogHelper_Impl, TimeOutHdl_Impl ) );
@@ -1105,8 +1103,10 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
     if ( nFlags & SFXWB_MULTISELECTION )
         mxFileDlg->setMultiSelectionMode( sal_True );
 
-    if ( mbHasLink )        // generate graphic filter only on demand
+    if (mbAddGraphicFilter) // generate graphic filter only on demand
+    {
         addGraphicFilter();
+    }
 
     // Export dialog
     if ( mbExport )
diff --git a/sfx2/source/dialog/filedlgimpl.hxx b/sfx2/source/dialog/filedlgimpl.hxx
index 8d0ddcb..6770bb7 100644
--- a/sfx2/source/dialog/filedlgimpl.hxx
+++ b/sfx2/source/dialog/filedlgimpl.hxx
@@ -96,7 +96,7 @@ namespace sfx2
         sal_Bool                    m_bHaveFilterOptions    : 1;
         sal_Bool                    mbHasVersions           : 1;
         sal_Bool                    mbHasAutoExt            : 1;
-        sal_Bool                    mbHasLink               : 1;
+        sal_Bool                    mbAddGraphicFilter      : 1;
         sal_Bool                    mbHasPreview            : 1;
         sal_Bool                    mbShowPreview           : 1;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list