From 6ae5667c07ae7047ce47e8f9fba5ea3e5f569286 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 31 May 2011 22:55:31 +0100 Subject: use this pattern throughout --- xmloff/source/core/attrlist.cxx | 20 +++++++------------- xmloff/source/core/unoatrcn.cxx | 20 +++++++------------- xmloff/source/core/xmlexp.cxx | 20 +++++++------------- xmloff/source/core/xmlimp.cxx | 20 +++++++------------- xmloff/source/style/StyleMap.cxx | 20 ++++++-------------- xmloff/source/transform/MutableAttrList.cxx | 19 ++++++------------- xmloff/source/transform/OOo2Oasis.cxx | 14 ++++---------- xmloff/source/transform/Oasis2OOo.cxx | 13 ++++--------- 8 files changed, 48 insertions(+), 98 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/core/attrlist.cxx b/xmloff/source/core/attrlist.cxx index 3da996ee5220..9216f694bc6b 100644 --- a/xmloff/source/core/attrlist.cxx +++ b/xmloff/source/core/attrlist.cxx @@ -32,8 +32,8 @@ #include #include #include -#include #include +#include #include @@ -256,21 +256,15 @@ sal_Int16 SvXMLAttributeList::GetIndexByName( const OUString& rName ) const return -1; } +namespace +{ + class theSvXMLAttributeListUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSvXMLAttributeListUnoTunnelId> {}; +} + // XUnoTunnel & co const uno::Sequence< sal_Int8 > & SvXMLAttributeList::getUnoTunnelId() throw() { - static uno::Sequence< sal_Int8 > * pSeq = 0; - if( !pSeq ) - { - Guard< Mutex > aGuard( Mutex::getGlobalMutex() ); - if( !pSeq ) - { - static uno::Sequence< sal_Int8 > aSeq( 16 ); - rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); - pSeq = &aSeq; - } - } - return *pSeq; + return theSvXMLAttributeListUnoTunnelId::get().getSeq(); } SvXMLAttributeList* SvXMLAttributeList::getImplementation( uno::Reference< uno::XInterface > xInt ) throw() diff --git a/xmloff/source/core/unoatrcn.cxx b/xmloff/source/core/unoatrcn.cxx index 7889d3d62f7d..38e0d4c53fd3 100644 --- a/xmloff/source/core/unoatrcn.cxx +++ b/xmloff/source/core/unoatrcn.cxx @@ -31,8 +31,8 @@ #include #include #include -#include #include +#include #include @@ -109,20 +109,14 @@ sal_uInt16 SvUnoAttributeContainer::getIndexByName(const OUString& aName ) const return USHRT_MAX; } +namespace +{ + class theSvUnoAttributeContainerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSvUnoAttributeContainerUnoTunnelId> {}; +} + const ::com::sun::star::uno::Sequence< sal_Int8 > & SvUnoAttributeContainer::getUnoTunnelId() throw() { - static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0; - if( !pSeq ) - { - ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !pSeq ) - { - static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 ); - rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); - pSeq = &aSeq; - } - } - return *pSeq; + return theSvUnoAttributeContainerUnoTunnelId::get().getSeq(); } SvUnoAttributeContainer* SvUnoAttributeContainer::getImplementation( uno::Reference< uno::XInterface > xInt ) throw() diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index 860c566ffd1a..2d407f41bfc3 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -34,7 +34,6 @@ #endif #include "unointerfacetouniqueidentifiermapper.hxx" #include -#include #include #include #include @@ -83,6 +82,7 @@ #include #include #include +#include #include "PropertySetMerger.hxx" #include "svl/urihelper.hxx" @@ -2089,21 +2089,15 @@ XMLImageMapExport& SvXMLExport::GetImageMapExport() return *mpImageMapExport; } +namespace +{ + class theSvXMLExportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSvXMLExportUnoTunnelId> {}; +} + // XUnoTunnel & co const uno::Sequence< sal_Int8 > & SvXMLExport::getUnoTunnelId() throw() { - static uno::Sequence< sal_Int8 > * pSeq = 0; - if( !pSeq ) - { - Guard< Mutex > aGuard( Mutex::getGlobalMutex() ); - if( !pSeq ) - { - static uno::Sequence< sal_Int8 > aSeq( 16 ); - rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); - pSeq = &aSeq; - } - } - return *pSeq; + return theSvXMLExportUnoTunnelId::get().getSeq(); } SvXMLExport* SvXMLExport::getImplementation( uno::Reference< uno::XInterface > xInt ) throw() diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 44a8adc7c824..816be91c48b9 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include "unointerfacetouniqueidentifiermapper.hxx" @@ -59,6 +58,7 @@ #include #include #include +#include #include #include // used in StartElement for logging #include @@ -464,21 +464,15 @@ SvXMLImport::~SvXMLImport() throw () mxModel->removeEventListener(mxEventListener); } +namespace +{ + class theSvXMLImportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSvXMLImportUnoTunnelId> {}; +} + // XUnoTunnel & co const uno::Sequence< sal_Int8 > & SvXMLImport::getUnoTunnelId() throw() { - static uno::Sequence< sal_Int8 > * pSeq = 0; - if( !pSeq ) - { - Guard< Mutex > aGuard( Mutex::getGlobalMutex() ); - if( !pSeq ) - { - static uno::Sequence< sal_Int8 > aSeq( 16 ); - rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); - pSeq = &aSeq; - } - } - return *pSeq; + return theSvXMLImportUnoTunnelId::get().getSeq(); } SvXMLImport* SvXMLImport::getImplementation( uno::Reference< uno::XInterface > xInt ) throw() diff --git a/xmloff/source/style/StyleMap.cxx b/xmloff/source/style/StyleMap.cxx index 66b9453f4bb8..1fc3863ee551 100644 --- a/xmloff/source/style/StyleMap.cxx +++ b/xmloff/source/style/StyleMap.cxx @@ -29,8 +29,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" #include -#include #include +#include #include "StyleMap.hxx" @@ -49,23 +49,15 @@ StyleMap::~StyleMap() { } +namespace +{ + class theStyleMapUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theStyleMapUnoTunnelId> {}; +} // XUnoTunnel & co const Sequence< sal_Int8 > & StyleMap::getUnoTunnelId() throw() { - static Sequence< sal_Int8 > * pSeq = 0; - if( !pSeq ) - { - Guard< Mutex > aGuard( Mutex::getGlobalMutex() ); - if( !pSeq ) - { - static Sequence< sal_Int8 > aSeq( 16 ); - rtl_createUuid( reinterpret_cast( aSeq.getArray() ), - 0, sal_True ); - pSeq = &aSeq; - } - } - return *pSeq; + return theStyleMapUnoTunnelId::get().getSeq(); } StyleMap* StyleMap::getImplementation( Reference< XInterface > xInt ) throw() diff --git a/xmloff/source/transform/MutableAttrList.cxx b/xmloff/source/transform/MutableAttrList.cxx index 94606585fdd9..202b9cf84304 100644 --- a/xmloff/source/transform/MutableAttrList.cxx +++ b/xmloff/source/transform/MutableAttrList.cxx @@ -30,9 +30,9 @@ #include "precompiled_xmloff.hxx" #include #include -#include #include #include +#include #include "MutableAttrList.hxx" using ::rtl::OUString; @@ -74,22 +74,15 @@ XMLMutableAttributeList::~XMLMutableAttributeList() m_xAttrList = 0; } +namespace +{ + class theXMLMutableAttributeListUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theXMLMutableAttributeListUnoTunnelId> {}; +} // XUnoTunnel & co const Sequence< sal_Int8 > & XMLMutableAttributeList::getUnoTunnelId() throw() { - static Sequence< sal_Int8 > * pSeq = 0; - if( !pSeq ) - { - Guard< Mutex > aGuard( Mutex::getGlobalMutex() ); - if( !pSeq ) - { - static Sequence< sal_Int8 > aSeq( 16 ); - rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); - pSeq = &aSeq; - } - } - return *pSeq; + return theXMLMutableAttributeListUnoTunnelId::get().getSeq(); } // XUnoTunnel diff --git a/xmloff/source/transform/OOo2Oasis.cxx b/xmloff/source/transform/OOo2Oasis.cxx index 2df52defcf0c..f94794ef4831 100644 --- a/xmloff/source/transform/OOo2Oasis.cxx +++ b/xmloff/source/transform/OOo2Oasis.cxx @@ -28,9 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#include #include #include +#include #include #include "xmloff/xmlnmspe.hxx" #include @@ -1996,20 +1996,14 @@ void SAL_CALL OOo2OasisTransformer::Initialize( } } - -Sequence< sal_Int8 > static CreateUnoTunnelId() +namespace { - static osl::Mutex aCreateMutex; - ::osl::Guard aGuard( aCreateMutex ); - Sequence< sal_Int8 > aSeq( 16 ); - rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); - return aSeq; + class theOOo2OasisTransformerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theOOo2OasisTransformerUnoTunnelId> {}; } const Sequence< sal_Int8 > & OOo2OasisTransformer::getUnoTunnelId() throw() { - static Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; + return theOOo2OasisTransformerUnoTunnelId::get().getSeq(); } // XUnoTunnel diff --git a/xmloff/source/transform/Oasis2OOo.cxx b/xmloff/source/transform/Oasis2OOo.cxx index e4788a7ecaf2..90765e472ca5 100644 --- a/xmloff/source/transform/Oasis2OOo.cxx +++ b/xmloff/source/transform/Oasis2OOo.cxx @@ -29,7 +29,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" #include -#include #include #include #include "xmloff/xmlnmspe.hxx" @@ -52,6 +51,7 @@ #include "TransformerActions.hxx" #include "FamilyType.hxx" #include +#include #include "Oasis2OOo.hxx" using ::rtl::OUString; @@ -2005,19 +2005,14 @@ Oasis2OOoTransformer::~Oasis2OOoTransformer() throw() XMLEventOASISTransformerContext::FlushEventMap( m_pFormEventMap ); } -::com::sun::star::uno::Sequence< sal_Int8 > static CreateUnoTunnelId() +namespace { - static osl::Mutex aCreateMutex; - Guard aGuard( aCreateMutex ); - Sequence< sal_Int8 > aSeq( 16 ); - rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); - return aSeq; + class theOasis2OOoTransformerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theOasis2OOoTransformerUnoTunnelId> {}; } const Sequence< sal_Int8 > & Oasis2OOoTransformer::getUnoTunnelId() throw() { - static Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; + return theOasis2OOoTransformerUnoTunnelId::get().getSeq(); } // XUnoTunnel -- cgit