diff options
author | Michael Meeks <michael.meeks@suse.com> | 2012-11-12 17:09:32 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-11-15 16:06:06 +0000 |
commit | 1099f6d52b1b8319c0eb9364ead75540318cfdc3 (patch) | |
tree | aaa3b45a388da7ad0ffbfa60838fd337bc4f064a /xmloff | |
parent | ced21f28931e749a16a676420c31c1e880fb8854 (diff) |
Revert "sb140: #i117310# remove unnecessary dependency
on XTypeProvider::getImplementationId"
This reverts commit 27b9f9f348b720e08f37db829533372dc4b73248.
Conflicts:
xmloff/inc/xmloff/txtparae.hxx
xmloff/source/style/SinglePropertySetInfoCache.cxx
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/Package_inc.mk | 1 | ||||
-rw-r--r-- | xmloff/inc/xmloff/PropertySetInfoHash.hxx | 47 | ||||
-rw-r--r-- | xmloff/inc/xmloff/SinglePropertySetInfoCache.hxx | 3 | ||||
-rw-r--r-- | xmloff/inc/xmloff/txtparae.hxx | 1 | ||||
-rw-r--r-- | xmloff/source/style/SinglePropertySetInfoCache.cxx | 53 | ||||
-rw-r--r-- | xmloff/source/style/xmlexppr.cxx | 58 |
6 files changed, 103 insertions, 60 deletions
diff --git a/xmloff/Package_inc.mk b/xmloff/Package_inc.mk index 0041f4c980d8..9b3628b691db 100644 --- a/xmloff/Package_inc.mk +++ b/xmloff/Package_inc.mk @@ -29,6 +29,7 @@ $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/NamedBoolPropertyHdl.hxx $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/PageMasterStyleMap.hxx,xmloff/PageMasterStyleMap.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/ProgressBarHelper.hxx,xmloff/ProgressBarHelper.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/PropertySetInfoHash.hxx,xmloff/PropertySetInfoHash.hxx)) +$(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/PropertySetInfoKey.hxx,xmloff/PropertySetInfoKey.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/SchXMLExportHelper.hxx,xmloff/SchXMLExportHelper.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/SchXMLImportHelper.hxx,xmloff/SchXMLImportHelper.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/SettingsExportHelper.hxx,xmloff/SettingsExportHelper.hxx)) diff --git a/xmloff/inc/xmloff/PropertySetInfoHash.hxx b/xmloff/inc/xmloff/PropertySetInfoHash.hxx index 300efae90310..802f2445c770 100644 --- a/xmloff/inc/xmloff/PropertySetInfoHash.hxx +++ b/xmloff/inc/xmloff/PropertySetInfoHash.hxx @@ -28,41 +28,40 @@ #ifndef _XMLOFF_PROPERTYSETINFOHASH_HXX #define _XMLOFF_PROPERTYSETINFOHASH_HXX -#include "sal/config.h" +#include <xmloff/PropertySetInfoKey.hxx> -#include <cstddef> - -#include "com/sun/star/beans/XPropertySetInfo.hpp" -#include "com/sun/star/uno/Reference.hxx" -#include "com/sun/star/uno/XInterface.hpp" -#include "osl/diagnose.h" -#include "sal/types.h" +#include <string.h> +#include <memory> struct PropertySetInfoHash { - inline std::size_t operator()( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >& r ) const; - inline bool operator()( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >& r1, - const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >& r2 ) const; + inline size_t operator()( const PropertySetInfoKey& r ) const; + inline bool operator()( const PropertySetInfoKey& r1, + const PropertySetInfoKey& r2 ) const; }; -inline std::size_t PropertySetInfoHash::operator()( - const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >& r ) const +inline size_t PropertySetInfoHash::operator()( + const PropertySetInfoKey& r ) const { - OSL_ASSERT(r.is()); - return static_cast< std::size_t >( - reinterpret_cast< sal_uIntPtr >( - com::sun::star::uno::Reference< com::sun::star::uno::XInterface >( - r, com::sun::star::uno::UNO_QUERY) - .get())); - // should be UNO_QUERY_THROW, but some clients are compiled with - // EXCEPTIONS_OFF + const sal_Int32* pBytesAsInt32Array = + (const sal_Int32*)r.aImplementationId.getConstArray(); + sal_Int32 nId32 = pBytesAsInt32Array[0] ^ + pBytesAsInt32Array[1] ^ + pBytesAsInt32Array[2] ^ + pBytesAsInt32Array[3]; + return (size_t)nId32 ^ (size_t)r.xPropInfo.get(); } inline bool PropertySetInfoHash::operator()( - const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >& r1, - const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >& r2 ) const + const PropertySetInfoKey& r1, + const PropertySetInfoKey& r2 ) const { - return r1 == r2; + if( r1.xPropInfo != r2.xPropInfo ) + return sal_False; + + const sal_Int8* pId1 = r1.aImplementationId.getConstArray(); + const sal_Int8* pId2 = r2.aImplementationId.getConstArray(); + return memcmp( pId1, pId2, 16 * sizeof( sal_Int8 ) ) == 0; } #endif diff --git a/xmloff/inc/xmloff/SinglePropertySetInfoCache.hxx b/xmloff/inc/xmloff/SinglePropertySetInfoCache.hxx index a0d4e9ac162d..4458417a125b 100644 --- a/xmloff/inc/xmloff/SinglePropertySetInfoCache.hxx +++ b/xmloff/inc/xmloff/SinglePropertySetInfoCache.hxx @@ -36,8 +36,7 @@ typedef boost::unordered_map < - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySetInfo >, + PropertySetInfoKey, sal_Bool, PropertySetInfoHash, PropertySetInfoHash diff --git a/xmloff/inc/xmloff/txtparae.hxx b/xmloff/inc/xmloff/txtparae.hxx index 179a3883ffbe..b46b78e001c6 100644 --- a/xmloff/inc/xmloff/txtparae.hxx +++ b/xmloff/inc/xmloff/txtparae.hxx @@ -21,7 +21,6 @@ #define _XMLOFF_TEXTPARAE_HXX_ #include "sal/config.h" - #include "xmloff/dllapi.h" #include <rtl/ustring.hxx> #include <com/sun/star/uno/Reference.h> 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 <com/sun/star/lang/XTypeProvider.hpp> #include <cppuhelper/weakref.hxx> - #include <xmloff/SinglePropertySetInfoCache.hxx> 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 <com/sun/star/xml/AttributeData.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp> #include <com/sun/star/beans/TolerantPropertySetResultType.hpp> @@ -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() ) |