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

sb140: #i117310# remove unnecessary dependency on XTypeProvider::getImplementationId

plus
sb140: #i117310# missing include
sb140: #i117310# support EXCEPTIONS_OFF (no UNO_QUERY_THROW)
üst 63fd3f18
...@@ -38,7 +38,6 @@ $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/NamedBoolPropertyHdl.hxx ...@@ -38,7 +38,6 @@ $(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/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/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/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/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/SchXMLImportHelper.hxx,xmloff/SchXMLImportHelper.hxx))
$(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/SettingsExportHelper.hxx,xmloff/SettingsExportHelper.hxx)) $(eval $(call gb_Package_add_file,xmloff_inc,inc/xmloff/SettingsExportHelper.hxx,xmloff/SettingsExportHelper.hxx))
......
...@@ -28,40 +28,41 @@ ...@@ -28,40 +28,41 @@
#ifndef _XMLOFF_PROPERTYSETINFOHASH_HXX #ifndef _XMLOFF_PROPERTYSETINFOHASH_HXX
#define _XMLOFF_PROPERTYSETINFOHASH_HXX #define _XMLOFF_PROPERTYSETINFOHASH_HXX
#include <xmloff/PropertySetInfoKey.hxx> #include "sal/config.h"
#include <string.h> #include <cstddef>
#include <memory>
#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"
struct PropertySetInfoHash struct PropertySetInfoHash
{ {
inline size_t operator()( const PropertySetInfoKey& r ) const; inline std::size_t operator()( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >& r ) const;
inline bool operator()( const PropertySetInfoKey& r1, inline bool operator()( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >& r1,
const PropertySetInfoKey& r2 ) const; const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >& r2 ) const;
}; };
inline size_t PropertySetInfoHash::operator()( inline std::size_t PropertySetInfoHash::operator()(
const PropertySetInfoKey& r ) const const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >& r ) const
{ {
const sal_Int32* pBytesAsInt32Array = OSL_ASSERT(r.is());
(const sal_Int32*)r.aImplementationId.getConstArray(); return static_cast< std::size_t >(
sal_Int32 nId32 = pBytesAsInt32Array[0] ^ reinterpret_cast< sal_uIntPtr >(
pBytesAsInt32Array[1] ^ com::sun::star::uno::Reference< com::sun::star::uno::XInterface >(
pBytesAsInt32Array[2] ^ r, com::sun::star::uno::UNO_QUERY)
pBytesAsInt32Array[3]; .get()));
return (size_t)nId32 ^ (size_t)r.xPropInfo.get(); // should be UNO_QUERY_THROW, but some clients are compiled with
// EXCEPTIONS_OFF
} }
inline bool PropertySetInfoHash::operator()( inline bool PropertySetInfoHash::operator()(
const PropertySetInfoKey& r1, const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >& r1,
const PropertySetInfoKey& r2 ) const const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >& r2 ) const
{ {
if( r1.xPropInfo != r2.xPropInfo ) return r1 == r2;
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 #endif
......
...@@ -36,7 +36,8 @@ ...@@ -36,7 +36,8 @@
typedef boost::unordered_map typedef boost::unordered_map
< <
PropertySetInfoKey, ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySetInfo >,
sal_Bool, sal_Bool,
PropertySetInfoHash, PropertySetInfoHash,
PropertySetInfoHash PropertySetInfoHash
......
...@@ -29,6 +29,9 @@ ...@@ -29,6 +29,9 @@
#define _XMLOFF_TEXTPARAE_HXX_ #define _XMLOFF_TEXTPARAE_HXX_
#include "sal/config.h" #include "sal/config.h"
#include <memory>
#include "xmloff/dllapi.h" #include "xmloff/dllapi.h"
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <com/sun/star/uno/Reference.h> #include <com/sun/star/uno/Reference.h>
......
...@@ -28,13 +28,11 @@ ...@@ -28,13 +28,11 @@
// MARKER(update_precomp.py): autogen include statement, do not remove // MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_xmloff.hxx" #include "precompiled_xmloff.hxx"
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <cppuhelper/weakref.hxx> #include <cppuhelper/weakref.hxx>
#include <xmloff/SinglePropertySetInfoCache.hxx> #include <xmloff/SinglePropertySetInfoCache.hxx>
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using ::com::sun::star::lang::XTypeProvider;
using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::beans::XPropertySetInfo; using ::com::sun::star::beans::XPropertySetInfo;
...@@ -44,46 +42,24 @@ sal_Bool SinglePropertySetInfoCache::hasProperty( ...@@ -44,46 +42,24 @@ sal_Bool SinglePropertySetInfoCache::hasProperty(
{ {
if( !rPropSetInfo.is() ) if( !rPropSetInfo.is() )
rPropSetInfo = rPropSet->getPropertySetInfo(); rPropSetInfo = rPropSet->getPropertySetInfo();
sal_Bool bRet = sal_False, bValid = sal_False; iterator aIter = find( rPropSetInfo );
Reference < XTypeProvider > xTypeProv( rPropSet, UNO_QUERY ); if( aIter != end() )
Sequence< sal_Int8 > aImplId;
if( xTypeProv.is() )
{ {
aImplId = xTypeProv->getImplementationId(); return aIter->second;
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;
}
}
} }
if( !bValid ) 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() )
{ {
bRet = rPropSetInfo->hasPropertyByName( sName ); value_type aValue( rPropSetInfo, bRet );
if( xTypeProv.is() && aImplId.getLength() == 16 ) insert( aValue );
{
// 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; return bRet;
} }
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <com/sun/star/xml/AttributeData.hpp> #include <com/sun/star/xml/AttributeData.hpp>
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertyState.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/XMultiPropertySet.hpp>
#include <com/sun/star/beans/XTolerantMultiPropertySet.hpp> #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
#include <com/sun/star/beans/TolerantPropertySetResultType.hpp> #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
...@@ -236,7 +235,7 @@ public: ...@@ -236,7 +235,7 @@ public:
typedef boost::unordered_map typedef boost::unordered_map
< <
PropertySetInfoKey, Reference< XPropertySetInfo >,
FilterPropertiesInfo_Impl *, FilterPropertiesInfo_Impl *,
PropertySetInfoHash, PropertySetInfoHash,
PropertySetInfoHash PropertySetInfoHash
...@@ -636,24 +635,12 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter( ...@@ -636,24 +635,12 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter(
FilterPropertiesInfo_Impl *pFilterInfo = 0; FilterPropertiesInfo_Impl *pFilterInfo = 0;
Reference < XTypeProvider > xTypeProv( xPropSet, UNO_QUERY ); if( pCache )
Sequence< sal_Int8 > aImplId;
if( xTypeProv.is() )
{ {
aImplId = xTypeProv->getImplementationId(); FilterPropertiesInfos_Impl::iterator aIter =
if( aImplId.getLength() == 16 ) pCache->find( xInfo );
{ if( aIter != pCache->end() )
if( pCache ) pFilterInfo = (*aIter).second;
{
// 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; sal_Bool bDelInfo = sal_False;
...@@ -680,31 +667,22 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter( ...@@ -680,31 +667,22 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter(
} }
} }
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( xInfo );
xInfo = 0;
xInfo = xWeakInfo;
if( xInfo.is() )
{ {
// Check whether the property set info is destroyed if it is if( !pCache )
// assigned to a weak reference only. If it is destroyed, then ((SvXMLExportPropertyMapper *)this)->pCache =
// every instance of getPropertySetInfo returns a new object. new FilterPropertiesInfos_Impl;
// Such property set infos must not be cached. (*pCache)[xInfo] = pFilterInfo;
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 else
{
OSL_FAIL("here is no TypeProvider or the ImplId is wrong");
bDelInfo = sal_True; bDelInfo = sal_True;
}
} }
if( pFilterInfo->GetPropertyCount() ) if( pFilterInfo->GetPropertyCount() )
......
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