summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2009-09-08 08:54:47 +0000
committerOliver Bolte <obo@openoffice.org>2009-09-08 08:54:47 +0000
commit98ae365df0a0c32d75649053dea7dfaace68159a (patch)
treef4f9e8f6306174b38c6c637d2ed90a6c2e7e198e /package
parent26aa928bf97652c8df13798f6ff3ce1df058f626 (diff)
CWS-TOOLING: integrate CWS dba32f
2009-08-31 10:43:51 +0200 msc r275590 : #no issuezilla available# make the testcase more error proof 2009-08-31 10:43:28 +0200 msc r275589 : #no issuezilla available# make the testcase more error proof 2009-08-31 10:40:33 +0200 msc r275588 : i85993 remove bugid 2009-08-31 10:38:28 +0200 msc r275587 : i100000 2009-08-27 13:27:32 +0200 fs r275476 : #i103882# 2009-08-27 12:47:54 +0200 fs r275474 : #i104544# do not allow re-entrance for impl_ensureControl_nothrow Actually, this is part of the fix only. I also removed the code which triggered this re-entrance (from the grid control implementation), but to ensure it won't happen, again, I added some safety herein. 2009-08-27 12:47:16 +0200 fs r275473 : #i104544# SetState: Do not call Update at the window which we just set text for. It should (sic\!) not be needed, but causes trouble 2009-08-27 10:18:05 +0200 mav r275461 : #i103266# do not allow any stream operation on package streams while commiting the package 2009-08-20 15:25:48 +0200 fs r275184 : #i104362# fall back to a ViewObjectContactOfSdrObj in case we don't have a page view 2009-08-20 15:25:06 +0200 fs r275183 : AUGMENT_LIBRARY_PATH 2009-08-20 15:10:34 +0200 fs r275182 : AUGMENT_LIBRARY_PATH 2009-08-20 09:50:36 +0200 oj r275167 : #i104266# notify propertyforward when new dest was created 2009-08-19 08:01:28 +0200 mav r275133 : #i103266# fix the typo 2009-08-18 22:45:34 +0200 fs r275131 : #i10000# 2009-08-18 13:53:07 +0200 oj r275105 : #i104266# set column settings after alter columns 2009-08-18 13:41:49 +0200 fs r275103 : #i102550# do not interpret names of existing data sources as system path 2009-08-18 13:13:05 +0200 oj r275097 : #i103882# use correct number Format 2009-08-18 12:59:13 +0200 fs r275094 : #i104181# 2009-08-18 09:07:48 +0200 fs r275079 : updated readme to refer to proper 1.1.14 2009-08-18 08:32:31 +0200 oj r275077 : #i104187# wrong default for FirstCellAsLabel corrected 2009-08-18 08:10:00 +0200 oj r275076 : #i104187# dispose status controller to avoid access of dead statusBar in sfx 2009-08-17 21:56:19 +0200 fs r275074 : merge fix for issue #102564# from dba32e 2009-08-17 15:34:40 +0200 fs r275058 : don't set MaxFieldSize to 0 unconditionally 2009-08-17 14:33:57 +0200 oj r275054 : #i103528# patch for bitxtor 2009-08-17 14:12:26 +0200 oj r275051 : #i104160# fix VerticalAlignment 2009-08-17 14:11:47 +0200 oj r275050 : #i104160# fix VerticalAlignment 2009-08-14 15:54:04 +0200 mav r274989 : #i103266# avoid possibility for race condition 2009-08-13 13:52:43 +0200 fs r274939 : improved diagnostics 2009-08-13 13:52:28 +0200 fs r274938 : typo 2009-08-13 12:51:03 +0200 fs r274934 : #i103763# provided by cloph: correct libIDL check when compiling Mozilla 2009-08-13 12:43:23 +0200 fs r274933 : #i103763# provided by cloph: allow to cross-compile prebuilt zips on Mac 2009-08-13 12:41:15 +0200 fs r274932 : #i103371# fire PREPARECLOSEDOC even for embedded objects (why not?) 2009-08-13 12:24:49 +0200 fs r274930 : #i99890# remove 'Insert Control' from the popup menu 2009-08-13 12:23:38 +0200 fs r274929 : #i99890# DoToolboxAction: assert unknown/unimplemented actions 2009-08-13 09:32:07 +0200 fs r274923 : #i103721# 2009-08-13 09:26:32 +0200 fs r274922 : #i99894# provided by dtardon: xforms_nowFunction: use proper memory allocation function 2009-08-13 09:20:21 +0200 fs r274921 : #i103938# provided by cmc: pass proper arguments to OUString::intern 2009-08-12 22:34:28 +0200 fs r274916 : #i104139# when executing a PopupMenu, pass the POPUPMENU_NOMOUSEUPCLOSE flag
Diffstat (limited to 'package')
-rw-r--r--package/inc/ZipFile.hxx14
-rw-r--r--package/inc/ZipPackage.hxx17
-rw-r--r--package/inc/ZipPackageBuffer.hxx2
-rw-r--r--package/inc/zipfileaccess.hxx6
-rw-r--r--package/source/zipapi/XUnbufferedStream.cxx13
-rw-r--r--package/source/zipapi/XUnbufferedStream.hxx13
-rw-r--r--package/source/zipapi/ZipFile.cxx25
-rw-r--r--package/source/zippackage/ZipPackage.cxx317
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx32
-rw-r--r--package/source/zippackage/ZipPackageStream.hxx2
-rw-r--r--package/source/zippackage/zipfileaccess.cxx33
11 files changed, 277 insertions, 197 deletions
diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx
index 287b899f7ab0..aaabda3181f0 100644
--- a/package/inc/ZipFile.hxx
+++ b/package/inc/ZipFile.hxx
@@ -40,6 +40,7 @@
#include <Inflater.hxx>
#endif
+#include <mutexholder.hxx>
namespace com { namespace sun { namespace star {
namespace lang { class XMultiServiceFactory; }
@@ -90,6 +91,7 @@ protected:
// aMediaType parameter is used only for raw stream header creation
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > createUnbufferedStream(
+ SotMutexHolderRef aMutexHolder,
ZipEntry & rEntry,
const vos::ORef < EncryptionData > &rData,
sal_Int8 nStreamMode,
@@ -128,7 +130,8 @@ public:
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawData(
ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bDecrypt)
+ sal_Bool bDecrypt,
+ SotMutexHolderRef aMutexHolder )
throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException);
static sal_Bool StaticGetCipher ( const vos::ORef < EncryptionData > & xEncryptionData, rtlCipher &rCipher, sal_Bool bDecode );
@@ -157,13 +160,15 @@ public:
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(
ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bDecrypt )
+ sal_Bool bDecrypt,
+ SotMutexHolderRef aMutexHolder )
throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getDataStream(
ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bDecrypt )
+ sal_Bool bDecrypt,
+ SotMutexHolderRef aMutexHolder )
throw ( ::com::sun::star::packages::WrongPasswordException,
::com::sun::star::io::IOException,
::com::sun::star::packages::zip::ZipException,
@@ -172,7 +177,8 @@ public:
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getWrappedRawStream(
ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- const ::rtl::OUString& aMediaType )
+ const ::rtl::OUString& aMediaType,
+ SotMutexHolderRef aMutexHolder )
throw ( ::com::sun::star::packages::NoEncryptionException,
::com::sun::star::io::IOException,
::com::sun::star::packages::zip::ZipException,
diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx
index 93d7b83c95ff..b733171edc4b 100644
--- a/package/inc/ZipPackage.hxx
+++ b/package/inc/ZipPackage.hxx
@@ -37,12 +37,15 @@
#include <com/sun/star/util/XChangesBatch.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
#ifndef _COM_SUN_STAR_LANG_XPSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#include <HashMaps.hxx>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <osl/file.h>
+#include <mutexholder.hxx>
+
class ZipOutputStream;
class ZipPackageFolder;
class ZipFile;
@@ -81,6 +84,8 @@ class ZipPackage : public cppu::WeakImplHelper7
>
{
protected:
+ SotMutexHolderRef m_aMutexHolder;
+
::com::sun::star::uno::Sequence < sal_Int8 > aEncryptionKey;
FolderHash aRecent;
::rtl::OUString sURL;
@@ -106,9 +111,13 @@ protected:
void parseManifest();
void parseContentType();
void getZipFileContents();
- sal_Bool writeFileIsTemp();
- ::com::sun::star::uno::Reference < ::com::sun::star::io::XActiveDataStreamer > openOriginalForOutput();
+
void WriteMimetypeMagicFile( ZipOutputStream& aZipOut );
+ void WriteManifest( ZipOutputStream& aZipOut, const ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aManList );
+ void WriteContentTypes( ZipOutputStream& aZipOut, const ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aManList );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > writeTempFile();
+ ::com::sun::star::uno::Reference < ::com::sun::star::io::XActiveDataStreamer > openOriginalForOutput();
void DisconnectFromTargetAndThrowException_Impl(
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xTempStream );
@@ -119,6 +128,10 @@ public:
const com::sun::star::uno::Sequence < sal_Int8 > & getEncryptionKey ( ) {return aEncryptionKey;}
sal_Int16 getFormat() const { return m_nFormat; }
+ SotMutexHolderRef GetSharedMutexRef() { return m_aMutexHolder; }
+
+ void ConnectTo( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInStream );
+
// XInitialization
virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
diff --git a/package/inc/ZipPackageBuffer.hxx b/package/inc/ZipPackageBuffer.hxx
index 222422fe6409..81f461bb2e77 100644
--- a/package/inc/ZipPackageBuffer.hxx
+++ b/package/inc/ZipPackageBuffer.hxx
@@ -56,7 +56,7 @@ public:
inline void realloc ( sal_Int32 nSize ) { m_aBuffer.realloc ( nSize ); }
inline const sal_Int8 * getConstArray () const { return m_aBuffer.getConstArray(); }
- inline const com::sun::star::uno::Sequence < sal_Int8> & getSequence () const { return m_aBuffer; }
+ inline const com::sun::star::uno::Sequence < sal_Int8> getSequence () const { return m_aBuffer; }
// XInputStream
virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
diff --git a/package/inc/zipfileaccess.hxx b/package/inc/zipfileaccess.hxx
index 434ddefb61c2..fbee9799930e 100644
--- a/package/inc/zipfileaccess.hxx
+++ b/package/inc/zipfileaccess.hxx
@@ -40,7 +40,8 @@
#include <cppuhelper/interfacecontainer.h>
#include <cppuhelper/implbase5.hxx>
-#include <osl/mutex.hxx>
+
+#include <mutexholder.hxx>
#include <ZipFile.hxx>
#include <HashMaps.hxx>
@@ -52,7 +53,8 @@ class OZipFileAccess : public ::cppu::WeakImplHelper5<
::com::sun::star::lang::XComponent,
::com::sun::star::lang::XServiceInfo >
{
- ::osl::Mutex m_aMutex;
+ SotMutexHolderRef m_aMutexHolder;
+
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > m_xContentStream;
diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx
index 1eba064a2165..53e4301844c9 100644
--- a/package/source/zipapi/XUnbufferedStream.cxx
+++ b/package/source/zipapi/XUnbufferedStream.cxx
@@ -41,6 +41,8 @@
#include <algorithm>
#include <string.h>
+#include <osl/mutex.hxx>
+
#if 0
// for debugging purposes here
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
@@ -55,14 +57,16 @@ using com::sun::star::lang::IllegalArgumentException;
using com::sun::star::packages::zip::ZipIOException;
using ::rtl::OUString;
-XUnbufferedStream::XUnbufferedStream( ZipEntry & rEntry,
+XUnbufferedStream::XUnbufferedStream( SotMutexHolderRef aMutexHolder,
+ ZipEntry & rEntry,
Reference < XInputStream > xNewZipStream,
const vos::ORef < EncryptionData > &rData,
sal_Int8 nStreamMode,
sal_Bool bIsEncrypted,
const ::rtl::OUString& aMediaType,
sal_Bool bRecoveryMode )
-: mxZipStream ( xNewZipStream )
+: maMutexHolder( aMutexHolder.Is() ? aMutexHolder : SotMutexHolderRef( new SotMutexHolder ) )
+, mxZipStream ( xNewZipStream )
, mxZipSeek ( xNewZipStream, UNO_QUERY )
, maEntry ( rEntry )
, mxData ( rData )
@@ -115,7 +119,8 @@ XUnbufferedStream::XUnbufferedStream( ZipEntry & rEntry,
// allows to read package raw stream
XUnbufferedStream::XUnbufferedStream( const Reference < XInputStream >& xRawStream,
const vos::ORef < EncryptionData > &rData )
-: mxZipStream ( xRawStream )
+: maMutexHolder( new SotMutexHolder )
+, mxZipStream ( xRawStream )
, mxZipSeek ( xRawStream, UNO_QUERY )
, mxData ( rData )
, maCipher ( NULL )
@@ -159,6 +164,8 @@ XUnbufferedStream::~XUnbufferedStream()
sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
{
+ ::osl::MutexGuard aGuard( maMutexHolder->GetMutex() );
+
sal_Int32 nRequestedBytes = nBytesToRead;
OSL_ENSURE( !mnHeaderToRead || mbWrappedRaw, "Only encrypted raw stream can be provided with header!" );
if ( mnMyCurrent + nRequestedBytes > mnZipSize + maHeader.getLength() )
diff --git a/package/source/zipapi/XUnbufferedStream.hxx b/package/source/zipapi/XUnbufferedStream.hxx
index 09be39fa85a3..db688761726e 100644
--- a/package/source/zipapi/XUnbufferedStream.hxx
+++ b/package/source/zipapi/XUnbufferedStream.hxx
@@ -36,16 +36,11 @@
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <cppuhelper/implbase1.hxx>
-#ifndef _VOS_REF_H_
#include <vos/ref.hxx>
-#endif
-#ifndef _INFLATER_HXX
#include <Inflater.hxx>
-#endif
#include <ZipEntry.hxx>
-#ifndef _CRC32_HXX_
#include <CRC32.hxx>
-#endif
+#include <mutexholder.hxx>
#define UNBUFF_STREAM_DATA 0
#define UNBUFF_STREAM_RAW 1
@@ -59,6 +54,8 @@ class XUnbufferedStream : public cppu::WeakImplHelper1
>
{
protected:
+ SotMutexHolderRef maMutexHolder;
+
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > mxZipStream;
com::sun::star::uno::Reference < com::sun::star::io::XSeekable > mxZipSeek;
com::sun::star::uno::Sequence < sal_Int8 > maCompBuffer, maHeader;
@@ -73,7 +70,9 @@ protected:
sal_Bool mbCheckCRC;
public:
- XUnbufferedStream( ZipEntry & rEntry,
+ XUnbufferedStream(
+ SotMutexHolderRef aMutexHolder,
+ ZipEntry & rEntry,
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewZipStream,
const vos::ORef < EncryptionData > &rData,
sal_Int8 nStreamMode,
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 1ddf31a66c5f..936ab2acd1bc 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -492,13 +492,14 @@ Reference < XInputStream > ZipFile::createMemoryStream(
}
#endif
Reference < XInputStream > ZipFile::createUnbufferedStream(
+ SotMutexHolderRef aMutexHolder,
ZipEntry & rEntry,
const ORef < EncryptionData > &rData,
sal_Int8 nStreamMode,
sal_Bool bIsEncrypted,
::rtl::OUString aMediaType )
{
- return new XUnbufferedStream ( rEntry, xStream, rData, nStreamMode, bIsEncrypted, aMediaType, bRecoveryMode );
+ return new XUnbufferedStream ( aMutexHolder, rEntry, xStream, rData, nStreamMode, bIsEncrypted, aMediaType, bRecoveryMode );
}
@@ -509,7 +510,8 @@ ZipEnumeration * SAL_CALL ZipFile::entries( )
Reference< XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bIsEncrypted )
+ sal_Bool bIsEncrypted,
+ SotMutexHolderRef aMutexHolder )
throw(IOException, ZipException, RuntimeException)
{
if ( rEntry.nOffset <= 0 )
@@ -525,7 +527,8 @@ Reference< XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry,
if ( bIsEncrypted && !rData.isEmpty() && rData->aDigest.getLength() )
bNeedRawStream = !hasValidPassword ( rEntry, rData );
- return createUnbufferedStream ( rEntry,
+ return createUnbufferedStream ( aMutexHolder,
+ rEntry,
rData,
bNeedRawStream ? UNBUFF_STREAM_RAW : UNBUFF_STREAM_DATA,
bIsEncrypted );
@@ -533,7 +536,8 @@ Reference< XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry,
Reference< XInputStream > SAL_CALL ZipFile::getDataStream( ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bIsEncrypted )
+ sal_Bool bIsEncrypted,
+ SotMutexHolderRef aMutexHolder )
throw ( packages::WrongPasswordException,
IOException,
ZipException,
@@ -562,7 +566,8 @@ Reference< XInputStream > SAL_CALL ZipFile::getDataStream( ZipEntry& rEntry,
else
bNeedRawStream = ( rEntry.nMethod == STORED );
- return createUnbufferedStream ( rEntry,
+ return createUnbufferedStream ( aMutexHolder,
+ rEntry,
rData,
bNeedRawStream ? UNBUFF_STREAM_RAW : UNBUFF_STREAM_DATA,
bIsEncrypted );
@@ -570,19 +575,21 @@ Reference< XInputStream > SAL_CALL ZipFile::getDataStream( ZipEntry& rEntry,
Reference< XInputStream > SAL_CALL ZipFile::getRawData( ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bIsEncrypted )
+ sal_Bool bIsEncrypted,
+ SotMutexHolderRef aMutexHolder )
throw(IOException, ZipException, RuntimeException)
{
if ( rEntry.nOffset <= 0 )
readLOC( rEntry );
- return createUnbufferedStream ( rEntry, rData, UNBUFF_STREAM_RAW, bIsEncrypted );
+ return createUnbufferedStream ( aMutexHolder, rEntry, rData, UNBUFF_STREAM_RAW, bIsEncrypted );
}
Reference< XInputStream > SAL_CALL ZipFile::getWrappedRawStream(
ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- const ::rtl::OUString& aMediaType )
+ const ::rtl::OUString& aMediaType,
+ SotMutexHolderRef aMutexHolder )
throw ( packages::NoEncryptionException,
IOException,
ZipException,
@@ -594,7 +601,7 @@ Reference< XInputStream > SAL_CALL ZipFile::getWrappedRawStream(
if ( rEntry.nOffset <= 0 )
readLOC( rEntry );
- return createUnbufferedStream ( rEntry, rData, UNBUFF_STREAM_WRAPPEDRAW, sal_True, aMediaType );
+ return createUnbufferedStream ( aMutexHolder, rEntry, rData, UNBUFF_STREAM_WRAPPEDRAW, sal_True, aMediaType );
}
sal_Bool ZipFile::readLOC( ZipEntry &rEntry )
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index caf64748afaa..a8c3d20be274 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -83,6 +83,7 @@
#include <comphelper/seekableinput.hxx>
#include <comphelper/storagehelper.hxx>
#include <comphelper/ofopxmlhelper.hxx>
+#include <comphelper/documentconstants.hxx>
using namespace rtl;
using namespace std;
@@ -106,6 +107,8 @@ using namespace com::sun::star::packages::zip::ZipConstants;
#define LOGFILE_AUTHOR "mg115289"
+namespace {
+
sal_Bool isLocalFile_Impl( ::rtl::OUString aURL )
{
::rtl::OUString aSystemPath;
@@ -132,6 +135,27 @@ sal_Bool isLocalFile_Impl( ::rtl::OUString aURL )
return ( aSystemPath.getLength() != 0 );
}
+class PostinitializationGuard
+{
+ uno::Reference< io::XInputStream > m_xTempStream;
+
+ ZipPackage& m_rZipPackage;
+
+public:
+ PostinitializationGuard( const uno::Reference< io::XInputStream >& xTempStream,
+ ZipPackage& rZipPackage )
+ : m_xTempStream( xTempStream )
+ , m_rZipPackage( rZipPackage )
+ {}
+
+ virtual ~PostinitializationGuard()
+ {
+ m_rZipPackage.ConnectTo( m_xTempStream );
+ }
+};
+
+}
+
//===========================================================================
class ActiveDataStreamer : public ::cppu::WeakImplHelper1< XActiveDataStreamer >
@@ -174,7 +198,8 @@ class DummyInputStream : public ::cppu::WeakImplHelper1< XInputStream >
//===========================================================================
ZipPackage::ZipPackage (const uno::Reference < XMultiServiceFactory > &xNewFactory)
-: bHasEncryptedEntries ( sal_False )
+: m_aMutexHolder( new SotMutexHolder )
+, bHasEncryptedEntries ( sal_False )
, bUseManifest ( sal_True )
, bForceRecovery ( sal_False )
, m_bMediaTypeFallbackUsed ( sal_False )
@@ -928,21 +953,138 @@ void ZipPackage::WriteMimetypeMagicFile( ZipOutputStream& aZipOut )
}
}
-sal_Bool ZipPackage::writeFileIsTemp()
+void ZipPackage::WriteManifest( ZipOutputStream& aZipOut, const vector< Sequence < PropertyValue > >& aManList )
+{
+ // Write the manifest
+ uno::Reference < XOutputStream > xManOutStream;
+ OUString sManifestWriter( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.packages.manifest.ManifestWriter" ) );
+ uno::Reference < XManifestWriter > xWriter ( xFactory->createInstance( sManifestWriter ), UNO_QUERY );
+ if ( xWriter.is() )
+ {
+ ZipEntry * pEntry = new ZipEntry;
+ ZipPackageBuffer *pBuffer = new ZipPackageBuffer( n_ConstBufferSize );
+ xManOutStream = uno::Reference < XOutputStream > (*pBuffer, UNO_QUERY);
+
+ pEntry->sName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "META-INF/manifest.xml") );
+ pEntry->nMethod = DEFLATED;
+ pEntry->nCrc = pEntry->nSize = pEntry->nCompressedSize = -1;
+ pEntry->nTime = ZipOutputStream::getCurrentDosTime();
+
+ // Convert vector into a Sequence
+ Sequence < Sequence < PropertyValue > > aManifestSequence ( aManList.size() );
+ Sequence < PropertyValue > * pSequence = aManifestSequence.getArray();
+ for (vector < Sequence < PropertyValue > >::const_iterator aIter = aManList.begin(), aEnd = aManList.end();
+ aIter != aEnd;
+ aIter++, pSequence++)
+ *pSequence= (*aIter);
+ xWriter->writeManifestSequence ( xManOutStream, aManifestSequence );
+
+ sal_Int32 nBufferLength = static_cast < sal_Int32 > ( pBuffer->getPosition() );
+ pBuffer->realloc( nBufferLength );
+
+ // the manifest.xml is never encrypted - so pass an empty reference
+ vos::ORef < EncryptionData > xEmpty;
+ aZipOut.putNextEntry( *pEntry, xEmpty );
+ aZipOut.write( pBuffer->getSequence(), 0, nBufferLength );
+ aZipOut.closeEntry();
+ }
+ else
+ {
+ VOS_ENSURE ( 0, "Couldn't get a ManifestWriter!" );
+ IOException aException;
+ throw WrappedTargetException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM ( OSL_LOG_PREFIX "Couldn't get a ManifestWriter!" ) ),
+ static_cast < OWeakObject * > ( this ),
+ makeAny( aException ) );
+ }
+}
+
+void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const vector< Sequence < PropertyValue > >& aManList )
+{
+ const OUString sFullPath ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
+ const OUString sMediaType ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
+
+ ZipEntry* pEntry = new ZipEntry;
+ ZipPackageBuffer *pBuffer = new ZipPackageBuffer( n_ConstBufferSize );
+ uno::Reference< io::XOutputStream > xConTypeOutStream( *pBuffer, UNO_QUERY );
+
+ pEntry->sName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "[Content_Types].xml") );
+ pEntry->nMethod = DEFLATED;
+ pEntry->nCrc = pEntry->nSize = pEntry->nCompressedSize = -1;
+ pEntry->nTime = ZipOutputStream::getCurrentDosTime();
+
+ // Convert vector into a Sequence
+ // TODO/LATER: use Defaulst entries in future
+ uno::Sequence< beans::StringPair > aDefaultsSequence;
+ uno::Sequence< beans::StringPair > aOverridesSequence( aManList.size() );
+ sal_Int32 nSeqLength = 0;
+ for ( vector< uno::Sequence< beans::PropertyValue > >::const_iterator aIter = aManList.begin(),
+ aEnd = aManList.end();
+ aIter != aEnd;
+ aIter++)
+ {
+ ::rtl::OUString aPath;
+ ::rtl::OUString aType;
+ OSL_ENSURE( (*aIter)[PKG_MNFST_MEDIATYPE].Name.equals( sMediaType ) && (*aIter)[PKG_MNFST_FULLPATH].Name.equals( sFullPath ),
+ "The mediatype sequence format is wrong!\n" );
+ (*aIter)[PKG_MNFST_MEDIATYPE].Value >>= aType;
+ if ( aType.getLength() )
+ {
+ // only nonempty type makes sence here
+ nSeqLength++;
+ (*aIter)[PKG_MNFST_FULLPATH].Value >>= aPath;
+ aOverridesSequence[nSeqLength-1].First = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) + aPath;
+ aOverridesSequence[nSeqLength-1].Second = aType;
+ }
+ }
+ aOverridesSequence.realloc( nSeqLength );
+
+ ::comphelper::OFOPXMLHelper::WriteContentSequence(
+ xConTypeOutStream, aDefaultsSequence, aOverridesSequence, xFactory );
+
+ sal_Int32 nBufferLength = static_cast < sal_Int32 > ( pBuffer->getPosition() );
+ pBuffer->realloc( nBufferLength );
+
+ // there is no encryption in this format currently
+ vos::ORef < EncryptionData > xEmpty;
+ aZipOut.putNextEntry( *pEntry, xEmpty );
+ aZipOut.write( pBuffer->getSequence(), 0, nBufferLength );
+ aZipOut.closeEntry();
+}
+
+void ZipPackage::ConnectTo( const uno::Reference< io::XInputStream >& xInStream )
+{
+ xContentSeek.set( xInStream, uno::UNO_QUERY_THROW );
+ xContentStream = xInStream;
+
+ // seek back to the beginning of the temp file so we can read segments from it
+ xContentSeek->seek( 0 );
+ if ( pZipFile )
+ pZipFile->setInputStream( xContentStream );
+ else
+ pZipFile = new ZipFile ( xContentStream, xFactory, sal_False );
+}
+
+uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
{
// In case the target local file does not exist or empty
- // write directly to it otherwize create a temporary file to write to
+ // write directly to it otherwize create a temporary file to write to.
+ // If a temporary file is created it is returned back by the method.
+ // If the data written directly, xComponentStream will be switched here
sal_Bool bUseTemp = sal_True;
- uno::Reference < XOutputStream > xTempOut;
- uno::Reference< XActiveDataStreamer > xSink;
+ uno::Reference < io::XInputStream > xResult;
+ uno::Reference < io::XInputStream > xTempIn;
+
+ uno::Reference < io::XOutputStream > xTempOut;
+ uno::Reference< io::XActiveDataStreamer > xSink;
if ( eMode == e_IMode_URL && !pZipFile && isLocalFile_Impl( sURL ) )
{
xSink = openOriginalForOutput();
if( xSink.is() )
{
- uno::Reference< XStream > xStr = xSink->getStream();
+ uno::Reference< io::XStream > xStr = xSink->getStream();
if( xStr.is() )
{
xTempOut = xStr->getOutputStream();
@@ -963,7 +1105,9 @@ sal_Bool ZipPackage::writeFileIsTemp()
{
// create temporary file
const OUString sServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.io.TempFile" ) );
- xTempOut = uno::Reference < XOutputStream > ( xFactory->createInstance ( sServiceName ), UNO_QUERY );
+ uno::Reference < io::XStream > xTempFile( xFactory->createInstance ( sServiceName ), UNO_QUERY_THROW );
+ xTempOut.set( xTempFile->getOutputStream(), UNO_SET_THROW );
+ xTempIn.set( xTempFile->getInputStream(), UNO_SET_THROW );
}
// Hand it to the ZipOutputStream:
@@ -995,7 +1139,7 @@ sal_Bool ZipPackage::writeFileIsTemp()
// Write a magic file with mimetype
WriteMimetypeMagicFile( aZipOut );
}
- if ( m_nFormat == OFOPXML_FORMAT )
+ else if ( m_nFormat == OFOPXML_FORMAT )
{
// Remove the old [Content_Types].xml file as the
// file will be re-generated
@@ -1009,9 +1153,6 @@ sal_Bool ZipPackage::writeFileIsTemp()
// Create a vector to store data for the manifest.xml file
vector < Sequence < PropertyValue > > aManList;
- // Make a reference to the manifest output stream so it persists
- // until the call to ZipOutputStream->finish()
- uno::Reference < XOutputStream > xManOutStream;
const OUString sMediaType ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
const OUString sVersion ( RTL_CONSTASCII_USTRINGPARAM ( "Version" ) );
const OUString sFullPath ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
@@ -1047,107 +1188,20 @@ sal_Bool ZipPackage::writeFileIsTemp()
if( bUseManifest && m_nFormat == PACKAGE_FORMAT )
{
- // Write the manifest
- OUString sManifestWriter( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.packages.manifest.ManifestWriter" ) );
- uno::Reference < XManifestWriter > xWriter ( xFactory->createInstance( sManifestWriter ), UNO_QUERY );
- if ( xWriter.is() )
- {
- ZipEntry * pEntry = new ZipEntry;
- ZipPackageBuffer *pBuffer = new ZipPackageBuffer( n_ConstBufferSize );
- xManOutStream = uno::Reference < XOutputStream > (*pBuffer, UNO_QUERY);
-
- pEntry->sName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "META-INF/manifest.xml") );
- pEntry->nMethod = DEFLATED;
- pEntry->nCrc = pEntry->nSize = pEntry->nCompressedSize = -1;
- pEntry->nTime = ZipOutputStream::getCurrentDosTime();
-
- // Convert vector into a Sequence
- Sequence < Sequence < PropertyValue > > aManifestSequence ( aManList.size() );
- Sequence < PropertyValue > * pSequence = aManifestSequence.getArray();
- for (vector < Sequence < PropertyValue > >::const_iterator aIter = aManList.begin(), aEnd = aManList.end();
- aIter != aEnd;
- aIter++, pSequence++)
- *pSequence= (*aIter);
- xWriter->writeManifestSequence ( xManOutStream, aManifestSequence );
-
- sal_Int32 nBufferLength = static_cast < sal_Int32 > ( pBuffer->getPosition() );
- pBuffer->realloc( nBufferLength );
-
- // the manifest.xml is never encrypted - so pass an empty reference
- vos::ORef < EncryptionData > xEmpty;
- aZipOut.putNextEntry( *pEntry, xEmpty );
- aZipOut.write( pBuffer->getSequence(), 0, nBufferLength );
- aZipOut.closeEntry();
- }
- else
- {
- VOS_ENSURE ( 0, "Couldn't get a ManifestWriter!" );
- IOException aException;
- throw WrappedTargetException(
- OUString( RTL_CONSTASCII_USTRINGPARAM ( OSL_LOG_PREFIX "Couldn't get a ManifestWriter!" ) ),
- static_cast < OWeakObject * > ( this ),
- makeAny( aException ) );
- }
+ WriteManifest( aZipOut, aManList );
}
else if( m_nFormat == OFOPXML_FORMAT )
{
- ZipEntry* pEntry = new ZipEntry;
- ZipPackageBuffer *pBuffer = new ZipPackageBuffer( n_ConstBufferSize );
- uno::Reference< io::XOutputStream > xConTypeOutStream( *pBuffer, UNO_QUERY );
-
- pEntry->sName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "[Content_Types].xml") );
- pEntry->nMethod = DEFLATED;
- pEntry->nCrc = pEntry->nSize = pEntry->nCompressedSize = -1;
- pEntry->nTime = ZipOutputStream::getCurrentDosTime();
-
- // Convert vector into a Sequence
- // TODO/LATER: use Defaulst entries in future
- uno::Sequence< beans::StringPair > aDefaultsSequence;
- uno::Sequence< beans::StringPair > aOverridesSequence( aManList.size() );
- sal_Int32 nSeqLength = 0;
- for ( vector< uno::Sequence< beans::PropertyValue > >::const_iterator aIter = aManList.begin(),
- aEnd = aManList.end();
- aIter != aEnd;
- aIter++)
- {
- ::rtl::OUString aPath;
- ::rtl::OUString aType;
- OSL_ENSURE( (*aIter)[PKG_MNFST_MEDIATYPE].Name.equals( sMediaType ) && (*aIter)[PKG_MNFST_FULLPATH].Name.equals( sFullPath ),
- "The mediatype sequence format is wrong!\n" );
- (*aIter)[PKG_MNFST_MEDIATYPE].Value >>= aType;
- if ( aType.getLength() )
- {
- // only nonempty type makes sence here
- nSeqLength++;
- (*aIter)[PKG_MNFST_FULLPATH].Value >>= aPath;
- aOverridesSequence[nSeqLength-1].First = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) + aPath;
- aOverridesSequence[nSeqLength-1].Second = aType;
- }
- }
- aOverridesSequence.realloc( nSeqLength );
-
- ::comphelper::OFOPXMLHelper::WriteContentSequence(
- xConTypeOutStream, aDefaultsSequence, aOverridesSequence, xFactory );
-
- sal_Int32 nBufferLength = static_cast < sal_Int32 > ( pBuffer->getPosition() );
- pBuffer->realloc( nBufferLength );
-
- // there is no encryption in this format currently
- vos::ORef < EncryptionData > xEmpty;
- aZipOut.putNextEntry( *pEntry, xEmpty );
- aZipOut.write( pBuffer->getSequence(), 0, nBufferLength );
- aZipOut.closeEntry();
+ WriteContentTypes( aZipOut, aManList );
}
aZipOut.finish();
- // Update our References to point to the new temp file
if( bUseTemp )
- {
- xContentStream = uno::Reference < XInputStream > ( xTempOut, UNO_QUERY_THROW );
- xContentSeek = uno::Reference < XSeekable > ( xTempOut, UNO_QUERY_THROW );
- }
- else
+ xResult = xTempIn;
+
+ // Update our References to point to the new temp file
+ if( !bUseTemp )
{
// the case when the original contents were written directly
xTempOut->flush();
@@ -1158,14 +1212,15 @@ sal_Bool ZipPackage::writeFileIsTemp()
if ( asyncOutputMonitor.is() )
asyncOutputMonitor->waitForCompletion();
+ // no need to postpone switching to the new stream since the target was written directly
+ uno::Reference< io::XInputStream > xNewStream;
if ( eMode == e_IMode_URL )
- xContentStream = xSink->getStream()->getInputStream();
- else if ( eMode == e_IMode_XStream )
- xContentStream = xStream->getInputStream();
-
- xContentSeek = uno::Reference < XSeekable > ( xContentStream, UNO_QUERY_THROW );
+ xNewStream = xSink->getStream()->getInputStream();
+ else if ( eMode == e_IMode_XStream && xStream.is() )
+ xNewStream = xStream->getInputStream();
- OSL_ENSURE( xContentStream.is() && xContentSeek.is(), "XSeekable interface is required!" );
+ if ( xNewStream.is() )
+ ConnectTo( xNewStream );
}
}
catch ( uno::Exception& )
@@ -1197,14 +1252,7 @@ sal_Bool ZipPackage::writeFileIsTemp()
}
}
- // seek back to the beginning of the temp file so we can read segments from it
- xContentSeek->seek ( 0 );
- if ( pZipFile )
- pZipFile->setInputStream ( xContentStream );
- else
- pZipFile = new ZipFile ( xContentStream, xFactory, sal_False );
-
- return bUseTemp;
+ return xResult;
}
uno::Reference< XActiveDataStreamer > ZipPackage::openOriginalForOutput()
@@ -1259,9 +1307,12 @@ uno::Reference< XActiveDataStreamer > ZipPackage::openOriginalForOutput()
}
// XChangesBatch
-void SAL_CALL ZipPackage::commitChanges( )
+void SAL_CALL ZipPackage::commitChanges()
throw(WrappedTargetException, RuntimeException)
{
+ // lock the component for the time of commiting
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
+
if ( eMode == e_IMode_XInputStream )
{
IOException aException;
@@ -1270,12 +1321,18 @@ void SAL_CALL ZipPackage::commitChanges( )
}
RTL_LOGFILE_TRACE_AUTHOR ( "package", LOGFILE_AUTHOR, "{ ZipPackage::commitChanges" );
- // First we write the entire package to a temporary file. After writeTempFile,
- // xContentSeek and xContentStream will reference the new temporary file.
- // Exception - empty or nonexistent local file that is written directly
- if ( writeFileIsTemp() )
+ // first the writeTempFile is called, if it returns a stream the stream should be written to the target
+ // if no stream was returned, the file was written directly, nothing should be done
+
+ uno::Reference< io::XInputStream > xTempInStream = writeTempFile();
+ if ( xTempInStream.is() )
{
+ uno::Reference< io::XSeekable > xTempSeek( xTempInStream, uno::UNO_QUERY_THROW );
+
+ // switch to the new temporary stream only after the transfer
+ PostinitializationGuard( xTempInStream, *this );
+
if ( eMode == e_IMode_XStream )
{
// First truncate our output stream
@@ -1284,7 +1341,7 @@ void SAL_CALL ZipPackage::commitChanges( )
// preparation for copy step
try
{
- xContentSeek->seek( 0 );
+ xTempSeek->seek( 0 );
xOutputStream = xStream->getOutputStream();
uno::Reference < XTruncate > xTruncate ( xOutputStream, UNO_QUERY );
@@ -1303,7 +1360,7 @@ void SAL_CALL ZipPackage::commitChanges( )
try
{
// then copy the contents of the tempfile to our output stream
- ::comphelper::OStorageHelper::CopyInputToOutput( xContentStream, xOutputStream );
+ ::comphelper::OStorageHelper::CopyInputToOutput( xTempInStream, xOutputStream );
xOutputStream->flush();
uno::Reference< io::XAsyncOutputMonitor > asyncOutputMonitor(
xOutputStream, uno::UNO_QUERY);
@@ -1316,7 +1373,7 @@ void SAL_CALL ZipPackage::commitChanges( )
// if anything goes wrong in this block the target file becomes corrupted
// so an exception should be thrown as a notification about it
// and the package must disconnect from the stream
- DisconnectFromTargetAndThrowException_Impl( xContentStream );
+ DisconnectFromTargetAndThrowException_Impl( xTempInStream );
}
}
else if ( eMode == e_IMode_URL )
@@ -1349,7 +1406,7 @@ void SAL_CALL ZipPackage::commitChanges( )
{
try
{
- ::comphelper::OStorageHelper::CopyInputToOutput( xContentStream, aOrigFileStream );
+ ::comphelper::OStorageHelper::CopyInputToOutput( xTempInStream, aOrigFileStream );
aOrigFileStream->closeOutput();
}
catch( uno::Exception& )
@@ -1369,7 +1426,7 @@ void SAL_CALL ZipPackage::commitChanges( )
{
try
{
- uno::Reference < XPropertySet > xPropSet ( xContentStream, UNO_QUERY );
+ uno::Reference < XPropertySet > xPropSet ( xTempInStream, UNO_QUERY );
OSL_ENSURE( xPropSet.is(), "This is a temporary file that must implement XPropertySet!\n" );
if ( !xPropSet.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -1396,7 +1453,7 @@ void SAL_CALL ZipPackage::commitChanges( )
catch (::com::sun::star::uno::Exception& r)
{
if ( bCanBeCorrupted )
- DisconnectFromTargetAndThrowException_Impl( xContentStream );
+ DisconnectFromTargetAndThrowException_Impl( xTempInStream );
throw WrappedTargetException(
OUString( RTL_CONSTASCII_USTRINGPARAM ( OSL_LOG_PREFIX "This package may be read only!" ) ),
@@ -1423,7 +1480,7 @@ void ZipPackage::DisconnectFromTargetAndThrowException_Impl( const uno::Referenc
::rtl::OUString aTempURL;
try {
- uno::Reference< beans::XPropertySet > xTempFile( xContentStream, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xTempFile( xTempStream, uno::UNO_QUERY_THROW );
uno::Any aUrl = xTempFile->getPropertyValue( ::rtl::OUString::createFromAscii( "Uri" ) );
aUrl >>= aTempURL;
xTempFile->setPropertyValue( ::rtl::OUString::createFromAscii( "RemoveFile" ),
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index ad68f34fd71c..b42a0e8ecde6 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -229,10 +229,8 @@ Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream( sal_B
if ( !xNewPackStream.is() )
throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- if ( !m_aSharedMutexRef.Is() )
- m_aSharedMutexRef = new SotMutexHolder();
xNewPackStream->setDataStream( static_cast< io::XInputStream* >(
- new WrapStreamForShare( GetOwnSeekStream(), m_aSharedMutexRef ) ) );
+ new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() ) ) );
Reference< XPropertySet > xNewPSProps( xNewPackStream, UNO_QUERY );
if ( !xNewPSProps.is() )
@@ -385,7 +383,6 @@ void SAL_CALL ZipPackageStream::setInputStream( const Reference< io::XInputStrea
throw(RuntimeException)
{
// if seekable access is required the wrapping will be done on demand
- m_aSharedMutexRef = new SotMutexHolder();
xStream = aStream;
m_bHasSeekable = sal_False;
SetPackageMember ( sal_False );
@@ -403,13 +400,11 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawData()
{
if ( !xEncryptionData.isEmpty() && !bHaveOwnKey )
xEncryptionData->aKey = rZipPackage.getEncryptionKey();
- return rZipPackage.getZipFile().getRawData( aEntry, xEncryptionData, bIsEncrypted );
+ return rZipPackage.getZipFile().getRawData( aEntry, xEncryptionData, bIsEncrypted, rZipPackage.GetSharedMutexRef() );
}
else if ( GetOwnSeekStream().is() )
{
- if ( !m_aSharedMutexRef.Is() )
- m_aSharedMutexRef = new SotMutexHolder();
- return new WrapStreamForShare( GetOwnSeekStream(), m_aSharedMutexRef );
+ return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() );
}
else
return Reference < io::XInputStream > ();
@@ -436,13 +431,11 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getInputStream( )
{
if ( !xEncryptionData.isEmpty() && !bHaveOwnKey )
xEncryptionData->aKey = rZipPackage.getEncryptionKey();
- return rZipPackage.getZipFile().getInputStream( aEntry, xEncryptionData, bIsEncrypted );
+ return rZipPackage.getZipFile().getInputStream( aEntry, xEncryptionData, bIsEncrypted, rZipPackage.GetSharedMutexRef() );
}
else if ( GetOwnSeekStream().is() )
{
- if ( !m_aSharedMutexRef.Is() )
- m_aSharedMutexRef = new SotMutexHolder();
- return new WrapStreamForShare( GetOwnSeekStream(), m_aSharedMutexRef );
+ return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() );
}
else
return Reference < io::XInputStream > ();
@@ -482,15 +475,13 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getDataStream()
if ( !xEncryptionData.isEmpty() && !bHaveOwnKey )
xEncryptionData->aKey = rZipPackage.getEncryptionKey();
- return rZipPackage.getZipFile().getDataStream( aEntry, xEncryptionData, bIsEncrypted );
+ return rZipPackage.getZipFile().getDataStream( aEntry, xEncryptionData, bIsEncrypted, rZipPackage.GetSharedMutexRef() );
}
else if ( m_nStreamMode == PACKAGE_STREAM_RAW )
return ZipFile::StaticGetDataFromRawStream( GetOwnSeekStream(), xEncryptionData );
else if ( GetOwnSeekStream().is() )
{
- if ( !m_aSharedMutexRef.Is() )
- m_aSharedMutexRef = new SotMutexHolder();
- return new WrapStreamForShare( GetOwnSeekStream(), m_aSharedMutexRef );
+ return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() );
}
else
return uno::Reference< io::XInputStream >();
@@ -515,15 +506,13 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawStream()
if ( !bIsEncrypted || xEncryptionData.isEmpty() )
throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- return rZipPackage.getZipFile().getWrappedRawStream( aEntry, xEncryptionData, sMediaType );
+ return rZipPackage.getZipFile().getWrappedRawStream( aEntry, xEncryptionData, sMediaType, rZipPackage.GetSharedMutexRef() );
}
else if ( GetOwnSeekStream().is() )
{
if ( m_nStreamMode == PACKAGE_STREAM_RAW )
{
- if ( !m_aSharedMutexRef.Is() )
- m_aSharedMutexRef = new SotMutexHolder();
- return new WrapStreamForShare( GetOwnSeekStream(), m_aSharedMutexRef );
+ return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() );
}
else if ( m_nStreamMode == PACKAGE_STREAM_DATA && bToBeEncrypted )
return TryToGetRawFromDataStream( sal_True );
@@ -568,7 +557,6 @@ void SAL_CALL ZipPackageStream::setRawStream( const Reference< io::XInputStream
// the raw stream MUST have seekable access
m_bHasSeekable = sal_True;
- m_aSharedMutexRef = new SotMutexHolder();
SetPackageMember ( sal_False );
aEntry.nTime = -1;
m_nStreamMode = PACKAGE_STREAM_RAW;
@@ -589,7 +577,7 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getPlainRawStream(
if (IsPackageMember())
{
- return rZipPackage.getZipFile().getRawData( aEntry, xEncryptionData, bIsEncrypted );
+ return rZipPackage.getZipFile().getRawData( aEntry, xEncryptionData, bIsEncrypted, rZipPackage.GetSharedMutexRef() );
}
else if ( GetOwnSeekStream().is() )
{
diff --git a/package/source/zippackage/ZipPackageStream.hxx b/package/source/zippackage/ZipPackageStream.hxx
index e0a2129c6519..dd4cc7edb81b 100644
--- a/package/source/zippackage/ZipPackageStream.hxx
+++ b/package/source/zippackage/ZipPackageStream.hxx
@@ -70,8 +70,6 @@ protected:
sal_uInt32 m_nMagicalHackPos;
sal_uInt32 m_nMagicalHackSize;
- SotMutexHolderRef m_aSharedMutexRef;
-
sal_Bool m_bHasSeekable;
sal_Bool m_bCompressedIsSetFromOutside;
diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx
index c284956f117e..0a70c8d32b88 100644
--- a/package/source/zippackage/zipfileaccess.cxx
+++ b/package/source/zippackage/zipfileaccess.cxx
@@ -53,7 +53,8 @@ using namespace ::com::sun::star;
// ----------------------------------------------------------------
OZipFileAccess::OZipFileAccess( const uno::Reference< lang::XMultiServiceFactory >& xFactory )
-: m_xFactory( xFactory )
+: m_aMutexHolder( new SotMutexHolder )
+, m_xFactory( xFactory )
, m_pZipFile( NULL )
, m_pListenersContainer( NULL )
, m_bDisposed( sal_False )
@@ -66,7 +67,7 @@ OZipFileAccess::OZipFileAccess( const uno::Reference< lang::XMultiServiceFactory
OZipFileAccess::~OZipFileAccess()
{
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( !m_bDisposed )
{
try {
@@ -179,7 +180,7 @@ void SAL_CALL OZipFileAccess::initialize( const uno::Sequence< uno::Any >& aArgu
throw ( uno::Exception,
uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -242,7 +243,7 @@ uno::Any SAL_CALL OZipFileAccess::getByName( const ::rtl::OUString& aName )
lang::WrappedTargetException,
uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -256,7 +257,8 @@ uno::Any SAL_CALL OZipFileAccess::getByName( const ::rtl::OUString& aName )
uno::Reference< io::XInputStream > xEntryStream( m_pZipFile->getDataStream( (*aIter).second,
new EncryptionData(),
- sal_False ) );
+ sal_False,
+ m_aMutexHolder ) );
if ( !xEntryStream.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -268,7 +270,7 @@ uno::Any SAL_CALL OZipFileAccess::getByName( const ::rtl::OUString& aName )
uno::Sequence< ::rtl::OUString > SAL_CALL OZipFileAccess::getElementNames()
throw ( uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -303,7 +305,7 @@ uno::Sequence< ::rtl::OUString > SAL_CALL OZipFileAccess::getElementNames()
sal_Bool SAL_CALL OZipFileAccess::hasByName( const ::rtl::OUString& aName )
throw (uno::RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -320,7 +322,7 @@ sal_Bool SAL_CALL OZipFileAccess::hasByName( const ::rtl::OUString& aName )
uno::Type SAL_CALL OZipFileAccess::getElementType()
throw ( uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -335,7 +337,7 @@ uno::Type SAL_CALL OZipFileAccess::getElementType()
sal_Bool SAL_CALL OZipFileAccess::hasElements()
throw ( uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -353,7 +355,7 @@ uno::Reference< io::XInputStream > SAL_CALL OZipFileAccess::getStreamByPattern(
io::IOException,
uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -370,7 +372,8 @@ uno::Reference< io::XInputStream > SAL_CALL OZipFileAccess::getStreamByPattern(
{
uno::Reference< io::XInputStream > xEntryStream( m_pZipFile->getDataStream( (*aIter).second,
new EncryptionData(),
- sal_False ) );
+ sal_False,
+ m_aMutexHolder ) );
if ( !xEntryStream.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -386,7 +389,7 @@ uno::Reference< io::XInputStream > SAL_CALL OZipFileAccess::getStreamByPattern(
void SAL_CALL OZipFileAccess::dispose()
throw ( uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -418,13 +421,13 @@ void SAL_CALL OZipFileAccess::dispose()
void SAL_CALL OZipFileAccess::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
throw ( uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
if ( !m_pListenersContainer )
- m_pListenersContainer = new ::cppu::OInterfaceContainerHelper( m_aMutex );
+ m_pListenersContainer = new ::cppu::OInterfaceContainerHelper( m_aMutexHolder->GetMutex() );
m_pListenersContainer->addInterface( xListener );
}
@@ -432,7 +435,7 @@ void SAL_CALL OZipFileAccess::addEventListener( const uno::Reference< lang::XEve
void SAL_CALL OZipFileAccess::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
throw ( uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );