Kaydet (Commit) 7275be15 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

sb140: #i117291# do not mis-use XTypeProvider.getImplementationId in XUnoTunnel.getSomething

üst 4209a612
...@@ -114,19 +114,6 @@ void SAL_CALL Graphic::release() throw() ...@@ -114,19 +114,6 @@ void SAL_CALL Graphic::release() throw()
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
namespace
{
class theGraphicUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theGraphicUnoTunnelId > {};
}
uno::Sequence< sal_Int8 > SAL_CALL Graphic::getImplementationId_Static()
throw(uno::RuntimeException)
{
return theGraphicUnoTunnelId::get().getSeq();
}
// ------------------------------------------------------------------------------
::rtl::OUString Graphic::getImplementationName_Static() ::rtl::OUString Graphic::getImplementationName_Static()
throw() throw()
{ {
...@@ -210,7 +197,7 @@ uno::Sequence< uno::Type > SAL_CALL Graphic::getTypes() ...@@ -210,7 +197,7 @@ uno::Sequence< uno::Type > SAL_CALL Graphic::getTypes()
uno::Sequence< sal_Int8 > SAL_CALL Graphic::getImplementationId() uno::Sequence< sal_Int8 > SAL_CALL Graphic::getImplementationId()
throw(uno::RuntimeException) throw(uno::RuntimeException)
{ {
return getImplementationId_Static(); return uno::Sequence< sal_Int8 >();
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
...@@ -282,14 +269,14 @@ const ::Graphic* Graphic::getImplementation( const uno::Reference< uno::XInterfa ...@@ -282,14 +269,14 @@ const ::Graphic* Graphic::getImplementation( const uno::Reference< uno::XInterfa
throw() throw()
{ {
uno::Reference< lang::XUnoTunnel > xTunnel( rxIFace, uno::UNO_QUERY ); uno::Reference< lang::XUnoTunnel > xTunnel( rxIFace, uno::UNO_QUERY );
return( xTunnel.is() ? reinterpret_cast< ::Graphic* >( xTunnel->getSomething( getImplementationId_Static() ) ) : NULL ); return( xTunnel.is() ? reinterpret_cast< ::Graphic* >( xTunnel->getSomething( ::Graphic::getUnoTunnelId() ) ) : NULL );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
sal_Int64 SAL_CALL Graphic::getSomething( const uno::Sequence< sal_Int8 >& rId ) sal_Int64 SAL_CALL Graphic::getSomething( const uno::Sequence< sal_Int8 >& rId )
throw( uno::RuntimeException ) throw( uno::RuntimeException )
{ {
return( ( rId.getLength() == 16 && 0 == rtl_compareMemory( getImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) ? return( ( rId.getLength() == 16 && 0 == rtl_compareMemory( ::Graphic::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) ?
reinterpret_cast< sal_Int64 >( mpGraphic ) : reinterpret_cast< sal_Int64 >( mpGraphic ) :
0 ); 0 );
} }
......
...@@ -62,7 +62,6 @@ public: ...@@ -62,7 +62,6 @@ public:
void init( const ::Graphic& rGraphic ) throw(); void init( const ::Graphic& rGraphic ) throw();
static const ::Graphic* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxIFace ) throw(); static const ::Graphic* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxIFace ) throw();
static ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId_Static( ) throw(::com::sun::star::uno::RuntimeException);
static ::rtl::OUString getImplementationName_Static() throw(); static ::rtl::OUString getImplementationName_Static() throw();
static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw(); static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <vcl/graph.h> #include <vcl/graph.h>
#include <vcl/gfxlink.hxx> #include <vcl/gfxlink.hxx>
#include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
namespace com { namespace sun { namespace star { namespace graphic { class XGraphic;} } } } namespace com { namespace sun { namespace star { namespace graphic { class XGraphic;} } } }
...@@ -94,6 +95,7 @@ public: ...@@ -94,6 +95,7 @@ public:
SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return mpImpGraphic; } SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return mpImpGraphic; }
public: public:
static com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelId();
TYPEINFO(); TYPEINFO();
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp> #include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/graphic/XGraphic.hpp>
#include <cppuhelper/typeprovider.hxx>
#include <rtl/instance.hxx>
// ----------------------- // -----------------------
// - Compression defines - // - Compression defines -
...@@ -210,6 +212,16 @@ static void ImplDrawDefault( OutputDevice* pOutDev, const UniString* pText, ...@@ -210,6 +212,16 @@ static void ImplDrawDefault( OutputDevice* pOutDev, const UniString* pText,
// - Graphic - // - Graphic -
// ----------- // -----------
namespace {
struct Id: public rtl::Static< cppu::OImplementationId, Id > {};
}
uno::Sequence< sal_Int8 > Graphic::getUnoTunnelId() {
return Id::get().getImplementationId();
}
TYPEINIT1_AUTOFACTORY( Graphic, SvDataCopyStream ); TYPEINIT1_AUTOFACTORY( Graphic, SvDataCopyStream );
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
...@@ -266,9 +278,8 @@ Graphic::Graphic( const GDIMetaFile& rMtf ) ...@@ -266,9 +278,8 @@ Graphic::Graphic( const GDIMetaFile& rMtf )
Graphic::Graphic( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ) Graphic::Graphic( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic )
{ {
uno::Reference< lang::XUnoTunnel > xTunnel( rxGraphic, uno::UNO_QUERY ); uno::Reference< lang::XUnoTunnel > xTunnel( rxGraphic, uno::UNO_QUERY );
uno::Reference< lang::XTypeProvider > xProv( rxGraphic, uno::UNO_QUERY ); const ::Graphic* pGraphic = ( xTunnel.is() ?
const ::Graphic* pGraphic = ( ( xTunnel.is() && xProv.is() ) ? reinterpret_cast< ::Graphic* >( xTunnel->getSomething( getUnoTunnelId() ) ) :
reinterpret_cast< ::Graphic* >( xTunnel->getSomething( xProv->getImplementationId() ) ) :
NULL ); NULL );
if( pGraphic ) if( pGraphic )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment