diff options
author | Noel Grandin <noel@peralex.com> | 2012-05-26 13:53:19 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-06-04 16:57:55 +0200 |
commit | b3c76dee6d44d07eae404b8d7341e6c88e6c4429 (patch) | |
tree | c747dd5bddf94c3b4312c7b1861a5087e76e71d6 /vcl | |
parent | eb68bf18f2d859486c4a737abb2536a6afe45411 (diff) |
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 <sbergman@redhat.com>, added some tweaks.
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/control/throbber.cxx | 6 | ||||
-rw-r--r-- | vcl/source/gdi/graph.cxx | 24 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl2.cxx | 67 |
3 files changed, 44 insertions, 53 deletions
diff --git a/vcl/source/control/throbber.cxx b/vcl/source/control/throbber.cxx index a6a6d00a0197..c4167b5c88de 100644 --- a/vcl/source/control/throbber.cxx +++ b/vcl/source/control/throbber.cxx @@ -30,6 +30,8 @@ #include "vcl/throbber.hxx" #include "vcl/svapp.hxx" +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/awt/ImageScaleMode.hpp> @@ -119,8 +121,8 @@ namespace ::std::vector< Image > aImages; ENSURE_OR_RETURN( i_imageSet != Throbber::IMAGES_NONE, "lcl_loadImageSet: illegal image set", aImages ); - const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - const Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW ); + const Reference< com::sun::star::uno::XComponentContext > aContext( ::comphelper::getProcessComponentContext() ); + const Reference< XGraphicProvider > xGraphicProvider( com::sun::star::graphic::GraphicProvider::create(aContext) ); ::std::vector< ::rtl::OUString > aImageURLs( Throbber::getDefaultImageURLs( i_imageSet ) ); aImages.reserve( aImageURLs.size() ); diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx index 35ac193a1e38..07c9d4f75f86 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -36,6 +36,7 @@ #include <comphelper/processfactory.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/lang/XTypeProvider.hpp> @@ -492,25 +493,16 @@ uno::Reference< graphic::XGraphic > Graphic::GetXGraphic() const if( GetType() != GRAPHIC_NONE ) { - uno::Reference < lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); + uno::Reference < uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + uno::Reference< graphic::XGraphicProvider > xProv( graphic::GraphicProvider::create( xContext ) ); - if( xMSF.is() ) - { - uno::Reference< graphic::XGraphicProvider > xProv( xMSF->createInstance( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) ) ), - uno::UNO_QUERY ); - - if( xProv.is() ) - { - uno::Sequence< beans::PropertyValue > aLoadProps( 1 ); - ::rtl::OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "private:memorygraphic/" ) ); + uno::Sequence< beans::PropertyValue > aLoadProps( 1 ); + ::rtl::OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "private:memorygraphic/" ) ); - aLoadProps[ 0 ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); - aLoadProps[ 0 ].Value <<= ( aURL += ::rtl::OUString::valueOf( reinterpret_cast< sal_Int64 >( this ) ) ); + aLoadProps[ 0 ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); + aLoadProps[ 0 ].Value <<= ( aURL += ::rtl::OUString::valueOf( reinterpret_cast< sal_Int64 >( this ) ) ); - xRet = xProv->queryGraphic( aLoadProps ); - } - } + xRet = xProv->queryGraphic( aLoadProps ); } return xRet; diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index b86e758667bb..d94281bdc784 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -42,9 +42,11 @@ #include "unotools/streamwrap.hxx" #include "comphelper/processfactory.hxx" +#include "comphelper/componentcontext.hxx" #include "com/sun/star/beans/PropertyValue.hpp" #include "com/sun/star/io/XSeekable.hpp" +#include "com/sun/star/graphic/GraphicProvider.hpp" #include "com/sun/star/graphic/XGraphicProvider.hpp" #include "cppuhelper/implbase1.hxx" @@ -194,47 +196,42 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz { uno::Reference < io::XStream > xStream = new utl::OStreamWrapper( aStrm ); uno::Reference< io::XSeekable > xSeekable( xStream, UNO_QUERY_THROW ); - uno::Reference< graphic::XGraphicProvider > xGraphicProvider( ImplGetSVData()->maAppData.mxMSF->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.GraphicProvider")) ), UNO_QUERY ); - if ( xGraphicProvider.is() ) + uno::Reference< uno::XComponentContext > xContext( comphelper::ComponentContext(ImplGetSVData()->maAppData.mxMSF).getUNOContext() ); + uno::Reference< graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(xContext) ); + uno::Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() ); + uno::Reference < io::XOutputStream > xOut( xStream->getOutputStream() ); + rtl::OUString aMimeType(RTL_CONSTASCII_USTRINGPARAM("image/jpeg")); + uno::Sequence< beans::PropertyValue > aOutMediaProperties( 3 ); + 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; + aOutMediaProperties[2].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FilterData")); + aOutMediaProperties[2].Value <<= aFilterData; + xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); + xOut->flush(); + if ( xSeekable->getLength() > nZippedFileSize ) { - uno::Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() ); - uno::Reference < io::XOutputStream > xOut( xStream->getOutputStream() ); - rtl::OUString aMimeType(RTL_CONSTASCII_USTRINGPARAM("image/jpeg")); - uno::Sequence< beans::PropertyValue > aOutMediaProperties( 3 ); - 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; - aOutMediaProperties[2].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FilterData")); - aOutMediaProperties[2].Value <<= aFilterData; - xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); - xOut->flush(); - if ( xSeekable->getLength() > nZippedFileSize ) - { - bUseJPGCompression = sal_False; - } - else + bUseJPGCompression = sal_False; + } + else + { + aStrm.Seek( STREAM_SEEK_TO_END ); + + xSeekable->seek( 0 ); + Sequence< PropertyValue > aArgs( 1 ); + aArgs[ 0 ].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream")); + aArgs[ 0 ].Value <<= xStream; + uno::Reference< XPropertySet > xPropSet( xGraphicProvider->queryGraphicDescriptor( aArgs ) ); + if ( xPropSet.is() ) { - aStrm.Seek( STREAM_SEEK_TO_END ); - - xSeekable->seek( 0 ); - Sequence< PropertyValue > aArgs( 1 ); - aArgs[ 0 ].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream")); - aArgs[ 0 ].Value <<= xStream; - uno::Reference< XPropertySet > xPropSet( xGraphicProvider->queryGraphicDescriptor( aArgs ) ); - if ( xPropSet.is() ) + sal_Int16 nBitsPerPixel = 24; + if ( xPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BitsPerPixel")) ) >>= nBitsPerPixel ) { - sal_Int16 nBitsPerPixel = 24; - if ( xPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BitsPerPixel")) ) >>= nBitsPerPixel ) - { - bTrueColorJPG = nBitsPerPixel != 8; - } + bTrueColorJPG = nBitsPerPixel != 8; } } } - else - bUseJPGCompression = sal_False; } catch( uno::Exception& ) { |