From 1099f6d52b1b8319c0eb9364ead75540318cfdc3 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Mon, 12 Nov 2012 17:09:32 +0000 Subject: Revert "sb140: #i117310# remove unnecessary dependency on XTypeProvider::getImplementationId" This reverts commit 27b9f9f348b720e08f37db829533372dc4b73248. Conflicts: xmloff/inc/xmloff/txtparae.hxx xmloff/source/style/SinglePropertySetInfoCache.cxx --- xmloff/source/style/SinglePropertySetInfoCache.cxx | 53 ++++++++++++++------ xmloff/source/style/xmlexppr.cxx | 58 +++++++++++++++------- 2 files changed, 78 insertions(+), 33 deletions(-) (limited to 'xmloff/source') diff --git a/xmloff/source/style/SinglePropertySetInfoCache.cxx b/xmloff/source/style/SinglePropertySetInfoCache.cxx index 7b70aabeba59..c1188fb51137 100644 --- a/xmloff/source/style/SinglePropertySetInfoCache.cxx +++ b/xmloff/source/style/SinglePropertySetInfoCache.cxx @@ -26,11 +26,12 @@ * ************************************************************************/ +#include #include - #include using namespace ::com::sun::star::uno; +using ::com::sun::star::lang::XTypeProvider; using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::beans::XPropertySetInfo; @@ -40,24 +41,46 @@ sal_Bool SinglePropertySetInfoCache::hasProperty( { if( !rPropSetInfo.is() ) rPropSetInfo = rPropSet->getPropertySetInfo(); - iterator aIter = find( rPropSetInfo ); - if( aIter != end() ) + sal_Bool bRet = sal_False, bValid = sal_False; + Reference < XTypeProvider > xTypeProv( rPropSet, UNO_QUERY ); + Sequence< sal_Int8 > aImplId; + if( xTypeProv.is() ) { - return aIter->second; + aImplId = xTypeProv->getImplementationId(); + if( aImplId.getLength() == 16 ) + { + // The key must not be created outside this block, because it + // keeps a reference to the property set info. + PropertySetInfoKey aKey( rPropSetInfo, aImplId ); + iterator aIter = find( aKey ); + if( aIter != end() ) + { + bRet = (*aIter).second; + bValid = sal_True; + } + } } - bool bRet = rPropSetInfo->hasPropertyByName( sName ); - // Check whether the property set info is destroyed if it is - // assigned to a weak reference only. If it is destroyed, then - // every instance of getPropertySetInfo returns a new object. - // Such property set infos must not be cached. - WeakReference < XPropertySetInfo > xWeakInfo( rPropSetInfo ); - rPropSetInfo = 0; - rPropSetInfo = xWeakInfo; - if( rPropSetInfo.is() ) + if( !bValid ) { - value_type aValue( rPropSetInfo, bRet ); - insert( aValue ); + bRet = rPropSetInfo->hasPropertyByName( sName ); + if( xTypeProv.is() && aImplId.getLength() == 16 ) + { + // Check whether the property set info is destroyed if it is + // assigned to a weak reference only. If it is destroyed, then + // every instance of getPropertySetInfo returns a new object. + // Such property set infos must not be cached. + WeakReference < XPropertySetInfo > xWeakInfo( rPropSetInfo ); + rPropSetInfo = 0; + rPropSetInfo = xWeakInfo; + if( rPropSetInfo.is() ) + { + PropertySetInfoKey aKey( rPropSetInfo, aImplId ); + value_type aValue( aKey, bRet ); + insert( aValue ); + } + } } + return bRet; } diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx index c1f143204bf5..7513d4b3dac4 100644 --- a/xmloff/source/style/xmlexppr.cxx +++ b/xmloff/source/style/xmlexppr.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -228,7 +229,7 @@ public: typedef boost::unordered_map < - Reference< XPropertySetInfo >, + PropertySetInfoKey, FilterPropertiesInfo_Impl *, PropertySetInfoHash, PropertySetInfoHash @@ -628,12 +629,24 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter( FilterPropertiesInfo_Impl *pFilterInfo = 0; - if( pCache ) + Reference < XTypeProvider > xTypeProv( xPropSet, UNO_QUERY ); + Sequence< sal_Int8 > aImplId; + if( xTypeProv.is() ) { - FilterPropertiesInfos_Impl::iterator aIter = - pCache->find( xInfo ); - if( aIter != pCache->end() ) - pFilterInfo = (*aIter).second; + aImplId = xTypeProv->getImplementationId(); + if( aImplId.getLength() == 16 ) + { + if( pCache ) + { + // The key must not be created outside this block, because it + // keeps a reference to the property set info. + PropertySetInfoKey aKey( xInfo, aImplId ); + FilterPropertiesInfos_Impl::iterator aIter = + pCache->find( aKey ); + if( aIter != pCache->end() ) + pFilterInfo = (*aIter).second; + } + } } sal_Bool bDelInfo = sal_False; @@ -660,22 +673,31 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter( } } - // Check whether the property set info is destroyed if it is - // assigned to a weak reference only. If it is destroyed, then - // every instance of getPropertySetInfo returns a new object. - // Such property set infos must not be cached. - WeakReference < XPropertySetInfo > xWeakInfo( xInfo ); - xInfo = 0; - xInfo = xWeakInfo; - if( xInfo.is() ) + if( xTypeProv.is() && aImplId.getLength() == 16 ) { - if( !pCache ) - ((SvXMLExportPropertyMapper *)this)->pCache = - new FilterPropertiesInfos_Impl; - (*pCache)[xInfo] = pFilterInfo; + // Check whether the property set info is destroyed if it is + // assigned to a weak reference only. If it is destroyed, then + // every instance of getPropertySetInfo returns a new object. + // Such property set infos must not be cached. + WeakReference < XPropertySetInfo > xWeakInfo( xInfo ); + xInfo = 0; + xInfo = xWeakInfo; + if( xInfo.is() ) + { + if( !pCache ) + ((SvXMLExportPropertyMapper *)this)->pCache = + new FilterPropertiesInfos_Impl; + PropertySetInfoKey aKey( xInfo, aImplId ); + (*pCache)[aKey] = pFilterInfo; + } + else + bDelInfo = sal_True; } else + { + OSL_FAIL("here is no TypeProvider or the ImplId is wrong"); bDelInfo = sal_True; + } } if( pFilterInfo->GetPropertyCount() ) -- cgit