summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/svdraw/svdmodel.cxx48
-rw-r--r--svx/source/svdraw/svdograf.cxx38
2 files changed, 56 insertions, 30 deletions
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index cb24ca2c3768..df94366e8b31 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 a587ab0b512a..151878a1bb27 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() )
{