summaryrefslogtreecommitdiff
path: root/package/source/zippackage
diff options
context:
space:
mode:
Diffstat (limited to 'package/source/zippackage')
-rw-r--r--package/source/zippackage/ZipPackage.cxx18
-rw-r--r--package/source/zippackage/ZipPackageFolder.cxx76
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx15
-rw-r--r--package/source/zippackage/ZipPackageStream.hxx6
4 files changed, 59 insertions, 56 deletions
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 9ba26e0100c5..fca0e09f63bd 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 )
@@ -1650,7 +1644,7 @@ void SAL_CALL ZipPackage::setPropertyValue( const OUString& aPropertyName, const
throw PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("EncryptionKey") ) )
{
- if (!( aValue >>= m_aEncryptionKey ) )
+ if (!( aValue >>= m_aEncryptionKey ) || m_aEncryptionKey.getLength() == 0 )
throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
}
else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UseManifest") ) )
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index f0c4a11d22f4..ba83b34910ed 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)
@@ -266,11 +271,10 @@ Sequence< OUString > SAL_CALL ZipPackageFolder::getElementNames( )
{
sal_uInt32 i=0, nSize = maContents.size();
Sequence < OUString > aSequence ( nSize );
- OUString *pNames = aSequence.getArray();
for ( ContentHash::const_iterator aIterator = maContents.begin(), aEnd = maContents.end();
aIterator != aEnd;
++i, ++aIterator)
- pNames[i] = (*aIterator).first;
+ aSequence[i] = (*aIterator).first;
return aSequence;
}
sal_Bool SAL_CALL ZipPackageFolder::hasByName( const OUString& aName )
@@ -353,7 +357,6 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
const ContentInfo &rInfo = *(*aCI).second;
Sequence < PropertyValue > aPropSet (PKG_SIZE_NOENCR_MNFST);
- PropertyValue *pValue = aPropSet.getArray();
if ( rInfo.bFolder )
pFolder = rInfo.pFolder;
@@ -364,12 +367,17 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
{
OUString sTempName = rPath + rShortName + OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
- pValue[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
- pValue[PKG_MNFST_MEDIATYPE].Value <<= pFolder->GetMediaType();
- pValue[PKG_MNFST_VERSION].Name = sVersionProperty;
- pValue[PKG_MNFST_VERSION].Value <<= pFolder->GetVersion();
- pValue[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
- pValue[PKG_MNFST_FULLPATH].Value <<= sTempName;
+ if ( pFolder->GetMediaType().getLength() )
+ {
+ aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
+ aPropSet[PKG_MNFST_MEDIATYPE].Value <<= pFolder->GetMediaType();
+ aPropSet[PKG_MNFST_VERSION].Name = sVersionProperty;
+ aPropSet[PKG_MNFST_VERSION].Value <<= pFolder->GetVersion();
+ aPropSet[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
+ aPropSet[PKG_MNFST_FULLPATH].Value <<= sTempName;
+ }
+ else
+ aPropSet.realloc( 0 );
pFolder->saveContents( sTempName, rManList, rZipOut, rEncryptionKey, rRandomPool);
}
@@ -390,12 +398,12 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
sal_Bool bToBeEncrypted = pStream->IsToBeEncrypted() && (bHaveEncryptionKey || pStream->HasOwnKey());
sal_Bool bToBeCompressed = bToBeEncrypted ? sal_True : pStream->IsToBeCompressed();
- pValue[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
- pValue[PKG_MNFST_MEDIATYPE].Value <<= pStream->GetMediaType( );
- pValue[PKG_MNFST_VERSION].Name = sVersionProperty;
- pValue[PKG_MNFST_VERSION].Value <<= ::rtl::OUString(); // no version is stored for streams currently
- pValue[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
- pValue[PKG_MNFST_FULLPATH].Value <<= pTempEntry->sPath;
+ aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
+ aPropSet[PKG_MNFST_MEDIATYPE].Value <<= pStream->GetMediaType( );
+ aPropSet[PKG_MNFST_VERSION].Name = sVersionProperty;
+ aPropSet[PKG_MNFST_VERSION].Value <<= ::rtl::OUString(); // no version is stored for streams currently
+ aPropSet[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
+ aPropSet[PKG_MNFST_FULLPATH].Value <<= pTempEntry->sPath;
OSL_ENSURE( pStream->GetStreamMode() != PACKAGE_STREAM_NOTSET, "Unacceptable ZipPackageStream mode!" );
@@ -517,23 +525,22 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
// a magic header
aPropSet.realloc(PKG_SIZE_ENCR_MNFST);
- pValue = aPropSet.getArray();
- pValue[PKG_MNFST_INIVECTOR].Name = sInitialisationVectorProperty;
- pValue[PKG_MNFST_INIVECTOR].Value <<= pStream->getInitialisationVector();
- pValue[PKG_MNFST_SALT].Name = sSaltProperty;
- pValue[PKG_MNFST_SALT].Value <<= pStream->getSalt();
- pValue[PKG_MNFST_ITERATION].Name = sIterationCountProperty;
- pValue[PKG_MNFST_ITERATION].Value <<= pStream->getIterationCount ();
+ aPropSet[PKG_MNFST_INIVECTOR].Name = sInitialisationVectorProperty;
+ aPropSet[PKG_MNFST_INIVECTOR].Value <<= pStream->getInitialisationVector();
+ aPropSet[PKG_MNFST_SALT].Name = sSaltProperty;
+ aPropSet[PKG_MNFST_SALT].Value <<= pStream->getSalt();
+ aPropSet[PKG_MNFST_ITERATION].Name = sIterationCountProperty;
+ aPropSet[PKG_MNFST_ITERATION].Value <<= pStream->getIterationCount ();
// Need to store the uncompressed size in the manifest
OSL_ENSURE( nOwnStreamOrigSize >= 0, "The stream size was not correctly initialized!\n" );
- pValue[PKG_MNFST_UCOMPSIZE].Name = sSizeProperty;
- pValue[PKG_MNFST_UCOMPSIZE].Value <<= nOwnStreamOrigSize;
+ aPropSet[PKG_MNFST_UCOMPSIZE].Name = sSizeProperty;
+ aPropSet[PKG_MNFST_UCOMPSIZE].Value <<= nOwnStreamOrigSize;
if ( bRawStream || bTransportOwnEncrStreamAsRaw )
{
- pValue[PKG_MNFST_DIGEST].Name = sDigestProperty;
- pValue[PKG_MNFST_DIGEST].Value <<= pStream->getDigest();
+ aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty;
+ aPropSet[PKG_MNFST_DIGEST].Value <<= pStream->getDigest();
}
}
}
@@ -650,8 +657,8 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
if ( bToBeEncrypted )
{
- pValue[PKG_MNFST_DIGEST].Name = sDigestProperty;
- pValue[PKG_MNFST_DIGEST].Value <<= pStream->getDigest();
+ aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty;
+ aPropSet[PKG_MNFST_DIGEST].Value <<= pStream->getDigest();
pStream->SetIsEncrypted ( sal_True );
}
}
@@ -690,7 +697,8 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
}
// folder can have a mediatype only in package format
- if ( m_nFormat == embed::StorageFormats::PACKAGE || ( m_nFormat == embed::StorageFormats::OFOPXML && !rInfo.bFolder ) )
+ if ( aPropSet.getLength()
+ && ( m_nFormat == embed::StorageFormats::PACKAGE || ( m_nFormat == embed::StorageFormats::OFOPXML && !rInfo.bFolder ) ) )
rManList.push_back( aPropSet );
}
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 )