diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-05-31 22:55:31 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-06-01 15:21:18 +0100 |
commit | 6ae5667c07ae7047ce47e8f9fba5ea3e5f569286 (patch) | |
tree | 6498d230b3a8ea49b6e92e10bd2ddb20d1b74846 | |
parent | d322f8701aa8eb9ba69385d1cbcd4435a2d2b297 (diff) |
use this pattern throughout
-rw-r--r-- | xmloff/source/core/attrlist.cxx | 20 | ||||
-rw-r--r-- | xmloff/source/core/unoatrcn.cxx | 20 | ||||
-rw-r--r-- | xmloff/source/core/xmlexp.cxx | 20 | ||||
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 20 | ||||
-rw-r--r-- | xmloff/source/style/StyleMap.cxx | 20 | ||||
-rw-r--r-- | xmloff/source/transform/MutableAttrList.cxx | 19 | ||||
-rw-r--r-- | xmloff/source/transform/OOo2Oasis.cxx | 14 | ||||
-rw-r--r-- | xmloff/source/transform/Oasis2OOo.cxx | 13 |
8 files changed, 48 insertions, 98 deletions
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 <vector> #include <osl/mutex.hxx> #include <xmloff/xmltoken.hxx> -#include <rtl/uuid.h> #include <rtl/memory.h> +#include <comphelper/servicehelper.hxx> #include <xmloff/attrlist.hxx> @@ -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 <tools/debug.hxx> #include <com/sun/star/xml/AttributeData.hpp> #include <rtl/ustrbuf.hxx> -#include <rtl/uuid.h> #include <rtl/memory.h> +#include <comphelper/servicehelper.hxx> #include <xmloff/xmlcnimp.hxx> @@ -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 <osl/mutex.hxx> -#include <rtl/uuid.h> #include <tools/debug.hxx> #include <tools/urlobj.hxx> #include <comphelper/genericpropertyset.hxx> @@ -83,6 +82,7 @@ #include <rtl/logfile.hxx> #include <cppuhelper/implbase1.hxx> #include <comphelper/extract.hxx> +#include <comphelper/servicehelper.hxx> #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 <tools/debug.hxx> #include <tools/urlobj.hxx> #include <osl/mutex.hxx> -#include <rtl/uuid.h> #include <rtl/memory.h> #include <svl/svarray.hxx> #include "unointerfacetouniqueidentifiermapper.hxx" @@ -59,6 +58,7 @@ #include <com/sun/star/xml/sax/XLocator.hpp> #include <com/sun/star/packages/zip/ZipIOException.hpp> #include <comphelper/namecontainer.hxx> +#include <comphelper/servicehelper.hxx> #include <rtl/logfile.hxx> #include <tools/string.hxx> // used in StartElement for logging #include <cppuhelper/implbase1.hxx> @@ -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 <osl/mutex.hxx> -#include <rtl/uuid.h> #include <rtl/memory.h> +#include <comphelper/servicehelper.hxx> #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<sal_uInt8*>( 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 <osl/mutex.hxx> #include <xmloff/xmltoken.hxx> -#include <rtl/uuid.h> #include <rtl/memory.h> #include <xmloff/attrlist.hxx> +#include <comphelper/servicehelper.hxx> #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 <rtl/uuid.h> #include <rtl/ustrbuf.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/servicehelper.hxx> #include <xmloff/nmspmap.hxx> #include "xmloff/xmlnmspe.hxx" #include <xmloff/xmltoken.hxx> @@ -1996,20 +1996,14 @@ void SAL_CALL OOo2OasisTransformer::Initialize( } } - -Sequence< sal_Int8 > static CreateUnoTunnelId() +namespace { - static osl::Mutex aCreateMutex; - ::osl::Guard<osl::Mutex> 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 <com/sun/star/beans/XPropertySetInfo.hpp> -#include <rtl/uuid.h> #include <rtl/ustrbuf.hxx> #include <xmloff/nmspmap.hxx> #include "xmloff/xmlnmspe.hxx" @@ -52,6 +51,7 @@ #include "TransformerActions.hxx" #include "FamilyType.hxx" #include <xmloff/xmluconv.hxx> +#include <comphelper/servicehelper.hxx> #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<osl::Mutex> 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 |