From 62a7c4b173ba686c5f941cd5677567ca4be2331e Mon Sep 17 00:00:00 2001 From: Oliver Specht Date: Wed, 4 Apr 2001 11:29:22 +0000 Subject: [PATCH] #84964# create type dependent implementation id --- sw/inc/unodraw.hxx | 6 ++-- sw/source/core/unocore/unodraw.cxx | 58 ++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/sw/inc/unodraw.hxx b/sw/inc/unodraw.hxx index 384d460a9727..ffa5f7a310e7 100644 --- a/sw/inc/unodraw.hxx +++ b/sw/inc/unodraw.hxx @@ -2,9 +2,9 @@ * * $RCSfile: unodraw.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: os $ $Date: 2000-11-02 09:41:18 $ + * last change: $Author: os $ $Date: 2001-04-04 12:29:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -196,6 +196,7 @@ class SwXShape : public SwXShapeBaseClass, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > xShapeAgg; SfxItemPropertySet aPropSet; const SfxItemPropertyMap* _pMap; + com::sun::star::uno::Sequence< sal_Int8 >* pImplementationId; SwShapeDescriptor_Impl* pImpl; @@ -212,6 +213,7 @@ public: static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); //XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 1e5212f1608d..9da4cb539c0f 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unodraw.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: os $ $Date: 2001-03-28 10:11:01 $ + * last change: $Author: os $ $Date: 2001-04-04 12:29:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -139,6 +139,9 @@ #ifndef _COMPHELPER_EXTRACT_HXX_ #include #endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include +#endif using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -147,6 +150,10 @@ using namespace ::com::sun::star::text; using namespace ::com::sun::star::drawing; using namespace ::rtl; +DECLARE_STL_USTRINGACCESS_MAP( Sequence< sal_Int8 > *, SwShapeImplementationIdMap ); + +static SwShapeImplementationIdMap aImplementationIdMap; + /* -----------------22.01.99 13:19------------------- * * --------------------------------------------------*/ @@ -790,6 +797,7 @@ SwXShape::SwXShape(uno::Reference< uno::XInterface > & xShape) : aPropSet(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_SHAPE)), _pMap(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_SHAPE)), pImpl(new SwShapeDescriptor_Impl), + pImplementationId(0), m_bDescriptor(sal_True) { if(xShape.is()) // default Ctor @@ -847,7 +855,7 @@ Any SwXShape::queryInterface( const uno::Type& aType ) throw(RuntimeException) /* -----------------------------16.06.00 12:21-------------------------------- ---------------------------------------------------------------------------*/ -Sequence< Type > SAL_CALL SwXShape::getTypes( ) throw(RuntimeException) +Sequence< Type > SwXShape::getTypes( ) throw(RuntimeException) { Sequence< uno::Type > aRet = SwXShapeBaseClass::getTypes(); if(xShapeAgg.is()) @@ -870,6 +878,50 @@ Sequence< Type > SAL_CALL SwXShape::getTypes( ) throw(RuntimeException) } return aRet; } +/* -----------------------------04.04.01 07:37-------------------------------- + + ---------------------------------------------------------------------------*/ +Sequence< sal_Int8 > SwXShape::getImplementationId( ) throw(RuntimeException) +{ + vos::OGuard aGuard( Application::GetSolarMutex() ); + // do we need to compute the implementation id for this instance? + if( !pImplementationId && xShapeAgg.is()) + { + Reference< XShape > xAggShape; + xShapeAgg->queryAggregation( ::getCppuType((Reference< XShape >*)0) ) >>= xAggShape; + + if( xAggShape.is() ) + { + const OUString aShapeType( xAggShape->getShapeType() ); + // did we already compute an implementation id for the agregated shape type? + SwShapeImplementationIdMap::iterator aIter( aImplementationIdMap.find(aShapeType ) ); + if( aIter == aImplementationIdMap.end() ) + { + // we need to create a new implementation id for this + // note: this memory is not free'd until application exists + // but since we have a fixed set of shapetypes and the + // memory will be reused this is ok. + pImplementationId = new uno::Sequence< sal_Int8 >( 16 ); + rtl_createUuid( (sal_uInt8 *) pImplementationId->getArray(), 0, sal_True ); + aImplementationIdMap[ aShapeType ] = pImplementationId; + } + else + { + // use the already computed implementation id + pImplementationId = (*aIter).second; + } + } + } + if( NULL == pImplementationId ) + { + DBG_ERROR( "Could not create an implementation id for a SwXShape!" ); + return Sequence< sal_Int8 > (); + } + else + { + return *pImplementationId; + } +} /*-- 22.01.99 11:42:26--------------------------------------------------- -----------------------------------------------------------------------*/