diff options
author | Michael Stahl <mstahl@redhat.com> | 2011-12-02 23:43:23 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2011-12-03 00:48:15 +0100 |
commit | fd95f1ab6220c6a530fd2e4e727417f504a5db51 (patch) | |
tree | b378d6e72698a8329f41d7919016574a301016e2 /svx/source/svdraw/svdograf.cxx | |
parent | aa59ee85a8e902aa4dc956822e9169093de6c454 (diff) |
refactor SdrModel::GetDocumentStream
Remove 3 ~identical implementations of GetDocumentStream and the associated
struct SdrDocumentStreamInfo.
Diffstat (limited to 'svx/source/svdraw/svdograf.cxx')
-rw-r--r-- | svx/source/svdraw/svdograf.cxx | 38 |
1 files changed, 12 insertions, 26 deletions
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() ) { |