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

x->getSomething(x->getImplementationId()) doesn't make any sense

...the point of the aIdentifier parameter to css.lang.XUnoTunnel.getSomething is
so that caller and callee can verify they know each other and the value passed
back (pointer in local address space, in this case) will actually make sense for
the caller.

Change-Id: Id79c419307992b30ea6ef7997b74a015631ad21c
üst 4ba89680
...@@ -198,6 +198,8 @@ public: ...@@ -198,6 +198,8 @@ public:
virtual void Assign( const SvDataCopyStream& ); virtual void Assign( const SvDataCopyStream& );
const SvgDataPtr& getSvgData() const; const SvgDataPtr& getSvgData() const;
static css::uno::Sequence<sal_Int8> getUnoTunnelId();
}; };
#endif // INCLUDED_VCL_GRAPH_HXX #endif // INCLUDED_VCL_GRAPH_HXX
......
...@@ -251,14 +251,14 @@ const ::Graphic* Graphic::getImplementation( const uno::Reference< uno::XInterfa ...@@ -251,14 +251,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, std::exception ) throw( uno::RuntimeException, std::exception )
{ {
return( ( rId.getLength() == 16 && 0 == memcmp( getImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) ? return( ( rId.getLength() == 16 && 0 == memcmp( ::Graphic::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) ?
reinterpret_cast< sal_Int64 >( mpGraphic ) : reinterpret_cast< sal_Int64 >( mpGraphic ) :
0 ); 0 );
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#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>
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -224,9 +225,8 @@ Graphic::Graphic( const GDIMetaFile& rMtf ) ...@@ -224,9 +225,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 )
...@@ -587,4 +587,14 @@ const SvgDataPtr& Graphic::getSvgData() const ...@@ -587,4 +587,14 @@ const SvgDataPtr& Graphic::getSvgData() const
return mpImpGraphic->getSvgData(); return mpImpGraphic->getSvgData();
} }
namespace {
struct Id: public rtl::Static<cppu::OImplementationId, Id> {};
}
css::uno::Sequence<sal_Int8> Graphic::getUnoTunnelId() {
return Id::get().getImplementationId();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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