diff options
author | Mikhail Voytenko <mav@openoffice.org> | 2010-09-28 14:51:09 +0200 |
---|---|---|
committer | Mikhail Voytenko <mav@openoffice.org> | 2010-09-28 14:51:09 +0200 |
commit | 1724393d0044cdc535f635cc15d957176554c6ea (patch) | |
tree | 25809256f955938410e9612c6deb40cf1256d94e /package | |
parent | 5762777d4910b51df2f76f6e442564170c83cad9 (diff) |
fwk149: #i112602# integrate the patch
Diffstat (limited to 'package')
-rw-r--r-- | package/inc/ZipPackageFolder.hxx | 7 | ||||
-rw-r--r-- | package/source/xstor/owriteablestream.cxx | 20 | ||||
-rw-r--r-- | package/source/xstor/xstorage.cxx | 20 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 16 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageFolder.cxx | 15 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageStream.cxx | 15 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageStream.hxx | 6 |
7 files changed, 37 insertions, 62 deletions
diff --git a/package/inc/ZipPackageFolder.hxx b/package/inc/ZipPackageFolder.hxx index 89414f18ce65..037c27f1fdd7 100644 --- a/package/inc/ZipPackageFolder.hxx +++ b/package/inc/ZipPackageFolder.hxx @@ -53,8 +53,6 @@ class ZipPackageFolder : public cppu::ImplInheritanceHelper2 ::com::sun::star::container::XEnumerationAccess > { - static com::sun::star::uno::Sequence < sal_Int8 > aImplementationId; - protected: ContentHash maContents; const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory; @@ -82,10 +80,7 @@ public: throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); static void copyZipEntry( ZipEntry &rDest, const ZipEntry &rSource); - static ::com::sun::star::uno::Sequence < sal_Int8 > static_getImplementationId() - { - return aImplementationId; - } + static const ::com::sun::star::uno::Sequence < sal_Int8 >& static_getImplementationId(); void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; } void setRemoveOnInsertMode_Impl( sal_Bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; } diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index be11586bc4fb..2f58595ab4a3 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -54,6 +54,7 @@ #include <rtl/digest.h> #include <rtl/logfile.hxx> +#include <rtl/instance.hxx> // since the copying uses 32000 blocks usually, it makes sense to have a smaller size #define MAX_STORCACHE_SIZE 30000 @@ -2173,25 +2174,14 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() return m_pData->m_pTypeCollection->getTypes() ; } +namespace { struct lcl_ImplId : public rtl::Static< ::cppu::OImplementationId, lcl_ImplId > {}; } + //----------------------------------------------- uno::Sequence< sal_Int8 > SAL_CALL OWriteStream::getImplementationId() throw( uno::RuntimeException ) { - static ::cppu::OImplementationId* pID = NULL ; - - if ( pID == NULL ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ; - - if ( pID == NULL ) - { - static ::cppu::OImplementationId aID( sal_False ) ; - pID = &aID ; - } - } - - return pID->getImplementationId() ; - + ::cppu::OImplementationId &rId = lcl_ImplId::get(); + return rId.getImplementationId(); } //----------------------------------------------- diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index 9c90c4ce35dd..01489c5b4f5d 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -49,6 +49,7 @@ #include <cppuhelper/typeprovider.hxx> #include <cppuhelper/exc_hlp.hxx> #include <rtl/logfile.hxx> +#include <rtl/instance.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/componentcontext.hxx> @@ -2368,25 +2369,14 @@ uno::Sequence< uno::Type > SAL_CALL OStorage::getTypes() return m_pData->m_pTypeCollection->getTypes() ; } +namespace { struct lcl_ImplId : public rtl::Static< ::cppu::OImplementationId, lcl_ImplId > {}; } + //----------------------------------------------- uno::Sequence< sal_Int8 > SAL_CALL OStorage::getImplementationId() throw( uno::RuntimeException ) { - static ::cppu::OImplementationId* pID = NULL ; - - if ( pID == NULL ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ; - - if ( pID == NULL ) - { - static ::cppu::OImplementationId aID( sal_False ) ; - pID = &aID ; - } - } - - return pID->getImplementationId() ; - + ::cppu::OImplementationId &rID = lcl_ImplId::get(); + return rID.getImplementationId(); } //____________________________________________________________________________________________________ diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 9ba26e0100c5..c99cd22d3b4c 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -69,6 +69,7 @@ #include <rtl/uri.hxx> #include <rtl/random.h> #include <rtl/logfile.hxx> +#include <rtl/instance.hxx> #include <osl/time.h> #include <osl/file.hxx> #include "com/sun/star/io/XAsyncOutputMonitor.hpp" @@ -1607,21 +1608,14 @@ uno::Reference < XSingleServiceFactory > ZipPackage::createServiceFactory( uno:: static_getSupportedServiceNames()); } +namespace { struct lcl_ImplId : public rtl::Static< ::cppu::OImplementationId, lcl_ImplId > {}; } + // XUnoTunnel Sequence< sal_Int8 > ZipPackage::getUnoTunnelImplementationId( void ) throw (RuntimeException) { - static ::cppu::OImplementationId * pId = 0; - if (! pId) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if (! pId) - { - static ::cppu::OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); + ::cppu::OImplementationId &rId = lcl_ImplId::get(); + return rId.getImplementationId(); } sal_Int64 SAL_CALL ZipPackage::getSomething( const Sequence< sal_Int8 >& aIdentifier ) diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx index f0c4a11d22f4..903191deb6be 100644 --- a/package/source/zippackage/ZipPackageFolder.cxx +++ b/package/source/zippackage/ZipPackageFolder.cxx @@ -43,6 +43,7 @@ #include <com/sun/star/io/XSeekable.hpp> #include <EncryptedDataHeader.hxx> #include <rtl/random.h> +#include <rtl/instance.hxx> #include <memory> using namespace com::sun::star::packages::zip::ZipConstants; @@ -59,7 +60,7 @@ using namespace std; using namespace ::com::sun::star; using vos::ORef; -Sequence < sal_Int8 > ZipPackageFolder::aImplementationId = Sequence < sal_Int8 > (); +namespace { struct lcl_CachedImplId : public rtl::Static< Sequence < sal_Int8 >, lcl_CachedImplId > {}; } ZipPackageFolder::ZipPackageFolder ( const Reference< XMultiServiceFactory >& xFactory, sal_Int32 nFormat, @@ -80,10 +81,9 @@ ZipPackageFolder::ZipPackageFolder ( const Reference< XMultiServiceFactory >& xF aEntry.nCompressedSize = 0; aEntry.nSize = 0; aEntry.nOffset = -1; - if ( !aImplementationId.getLength() ) - { - aImplementationId = getImplementationId(); - } + Sequence < sal_Int8 > &rCachedImplId = lcl_CachedImplId::get(); + if ( !rCachedImplId.getLength() ) + rCachedImplId = getImplementationId(); } @@ -187,6 +187,11 @@ void ZipPackageFolder::copyZipEntry( ZipEntry &rDest, const ZipEntry &rSource) rDest.nExtraLen = rSource.nExtraLen; } +const ::com::sun::star::uno::Sequence < sal_Int8 >& ZipPackageFolder::static_getImplementationId() +{ + return lcl_CachedImplId::get(); +} + // XNameContainer void SAL_CALL ZipPackageFolder::insertByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException) diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 6343607c8711..da44dafa000b 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -46,6 +46,8 @@ #include <comphelper/seekableinput.hxx> #include <comphelper/storagehelper.hxx> +#include <rtl/instance.hxx> + #include <PackageConstants.hxx> using namespace com::sun::star::packages::zip::ZipConstants; @@ -56,8 +58,12 @@ using namespace com::sun::star; using namespace cppu; using namespace rtl; -Sequence < sal_Int8 > ZipPackageStream::aImplementationId = Sequence < sal_Int8 > (); +namespace { struct lcl_CachedImplId : public rtl::Static< Sequence < sal_Int8 >, lcl_CachedImplId > {}; } +const ::com::sun::star::uno::Sequence < sal_Int8 >& ZipPackageStream::static_getImplementationId() +{ + return lcl_CachedImplId::get(); +} ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage, const Reference< XMultiServiceFactory >& xFactory, @@ -92,10 +98,9 @@ ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage, aEntry.nPathLen = -1; aEntry.nExtraLen = -1; - if ( !aImplementationId.getLength() ) - { - aImplementationId = getImplementationId(); - } + Sequence < sal_Int8 > &rCachedImplId = lcl_CachedImplId::get(); + if ( !rCachedImplId.getLength() ) + rCachedImplId = getImplementationId(); } ZipPackageStream::~ZipPackageStream( void ) diff --git a/package/source/zippackage/ZipPackageStream.hxx b/package/source/zippackage/ZipPackageStream.hxx index a0d5fad6e4da..38301d5e7d12 100644 --- a/package/source/zippackage/ZipPackageStream.hxx +++ b/package/source/zippackage/ZipPackageStream.hxx @@ -55,7 +55,6 @@ class ZipPackageStream : public cppu::ImplInheritanceHelper2 ::com::sun::star::packages::XDataSinkEncrSupport > { - static com::sun::star::uno::Sequence < sal_Int8 > aImplementationId; protected: com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream; const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory; @@ -146,10 +145,7 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawData() throw(::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence < sal_Int8 >& static_getImplementationId() - { - return aImplementationId; - } + static const ::com::sun::star::uno::Sequence < sal_Int8 >& static_getImplementationId(); // XActiveDataSink virtual void SAL_CALL setInputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& aStream ) |