diff options
author | Noel Power <noel.power@novell.com> | 2012-02-13 14:19:22 +0000 |
---|---|---|
committer | Petr Mladek <pmladek@suse.cz> | 2012-02-14 20:04:36 +0100 |
commit | 4ea4f80121eedc7f87d950ea8e15336fb691e52f (patch) | |
tree | 1cfc4cb87d9b5188478ddeb1355f187540e2e3d6 /toolkit/source/controls/unocontrols.cxx | |
parent | 3809a64ee66afd1be3988b1161390f9b49f1de61 (diff) |
fix support for embedded images for basic Dialogs ( fdo#45992 )
Signed-off-by: Petr Mladek <pmladek@suse.cz>
Diffstat (limited to 'toolkit/source/controls/unocontrols.cxx')
-rw-r--r-- | toolkit/source/controls/unocontrols.cxx | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index 2fae9e6fa4d8..1ea47596e5cc 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -87,7 +87,49 @@ using namespace ::toolkit; } \ +uno::Reference< graphic::XGraphic > +ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( uno::Reference< graphic::XGraphicObject >& xOutGraphicObj, const ::rtl::OUString& _rURL ) +{ + if( ( _rURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 ) ) + { + // graphic manager uniqueid + rtl::OUString sID = _rURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 ); + // get the DefaultContext + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + xOutGraphicObj = graphic::GraphicObject::createWithId( aContext.getUNOContext(), sID ); + } + else // linked + xOutGraphicObj = NULL; // release the GraphicObject + + return ImageHelper::getGraphicFromURL_nothrow( _rURL ); +} +::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > +ImageHelper::getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL ) +{ + uno::Reference< graphic::XGraphic > xGraphic; + if ( _rURL.isEmpty() ) + return xGraphic; + + try + { + uno::Reference< graphic::XGraphicProvider > xProvider; + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) + { + uno::Sequence< beans::PropertyValue > aMediaProperties(1); + aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); + aMediaProperties[0].Value <<= _rURL; + xGraphic = xProvider->queryGraphic( aMediaProperties ); + } + } + catch (const Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return xGraphic; +} // ---------------------------------------------------- // class UnoControlEditModel // ---------------------------------------------------- @@ -591,7 +633,7 @@ void SAL_CALL GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 n mbAdjustingGraphic = true; ::rtl::OUString sImageURL; OSL_VERIFY( rValue >>= sImageURL ); - setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC, uno::makeAny( getGraphicFromURL_nothrow( sImageURL ) ) ); + setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC, uno::makeAny( ImageHelper::getGraphicFromURL_nothrow( sImageURL ) ) ); mbAdjustingGraphic = false; } break; |