From b3c76dee6d44d07eae404b8d7341e6c88e6c4429 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 26 May 2012 13:53:19 +0200 Subject: fdo#46808, Adapt UNO services to new style, Part 7, updating ::create Update calls to factories to use new ::create methods Change-Id: I01d4417820f52718836c92faf3c2fae0dc96b30d Signed-off-by: Stephan Bergmann , added some tweaks. --- embeddedobj/source/msole/graphconvert.cxx | 36 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'embeddedobj') diff --git a/embeddedobj/source/msole/graphconvert.cxx b/embeddedobj/source/msole/graphconvert.cxx index ca83da870135..77caf58c7910 100644 --- a/embeddedobj/source/msole/graphconvert.cxx +++ b/embeddedobj/source/msole/graphconvert.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -60,27 +61,24 @@ sal_Bool ConvertBufferToFormat( void* pBuf, uno::Reference < io::XInputStream > xIn = new comphelper::SequenceInputStream( aData ); try { - uno::Reference < graphic::XGraphicProvider > xGraphicProvider( comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.GraphicProvider")) ), uno::UNO_QUERY ); - if( xGraphicProvider.is() ) + uno::Reference < graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(comphelper::getProcessComponentContext())); + uno::Sequence< beans::PropertyValue > aMediaProperties( 1 ); + aMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "InputStream" )); + aMediaProperties[0].Value <<= xIn; + uno::Reference< graphic::XGraphic > xGraphic( xGraphicProvider->queryGraphic( aMediaProperties ) ); + if( xGraphic.is() ) { - uno::Sequence< beans::PropertyValue > aMediaProperties( 1 ); - aMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "InputStream" )); - aMediaProperties[0].Value <<= xIn; - uno::Reference< graphic::XGraphic > xGraphic( xGraphicProvider->queryGraphic( aMediaProperties ) ); - if( xGraphic.is() ) - { - SvMemoryStream aNewStream( 65535, 65535 ); - uno::Reference < io::XStream > xOut = new utl::OStreamWrapper( aNewStream ); - uno::Sequence< beans::PropertyValue > aOutMediaProperties( 2 ); - aOutMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "OutputStream" )); - aOutMediaProperties[0].Value <<= xOut; - aOutMediaProperties[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MimeType" )); - aOutMediaProperties[1].Value <<= aMimeType; + SvMemoryStream aNewStream( 65535, 65535 ); + uno::Reference < io::XStream > xOut = new utl::OStreamWrapper( aNewStream ); + uno::Sequence< beans::PropertyValue > aOutMediaProperties( 2 ); + aOutMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "OutputStream" )); + aOutMediaProperties[0].Value <<= xOut; + aOutMediaProperties[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MimeType" )); + aOutMediaProperties[1].Value <<= aMimeType; - xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); - aResult <<= uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aNewStream.GetData() ), aNewStream.Seek( STREAM_SEEK_TO_END ) ); - return sal_True; - } + xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); + aResult <<= uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aNewStream.GetData() ), aNewStream.Seek( STREAM_SEEK_TO_END ) ); + return sal_True; } } catch (const uno::Exception&) -- cgit