summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gallwey <mtg@openoffice.org>2001-07-04 13:56:37 +0000
committerMartin Gallwey <mtg@openoffice.org>2001-07-04 13:56:37 +0000
commit1157563ae83b41998a4982c06299780aba7830d4 (patch)
tree91fa8c017f3e78f7291dc4628d5e49c434ee0b77
parentf424dd7645c4aed5ecad0e9437f552fa934c6ba2 (diff)
#86708# changes for pack'n'go feature (incomplete)
-rw-r--r--package/inc/ByteChucker.hxx17
-rw-r--r--package/inc/CRC32.hxx6
-rw-r--r--package/inc/HashMaps.hxx15
-rw-r--r--package/inc/ImplValidCharacters.hxx93
-rw-r--r--package/inc/Inflater.hxx9
-rw-r--r--package/inc/PackageConstants.hxx6
-rw-r--r--package/inc/ZipEnumeration.hxx6
-rw-r--r--package/inc/ZipFile.hxx51
-rw-r--r--package/inc/ZipOutputStream.hxx34
-rw-r--r--package/inc/ZipPackage.hxx34
-rw-r--r--package/inc/ZipPackageBuffer.hxx5
-rw-r--r--package/inc/ZipPackageFolder.hxx6
-rw-r--r--package/source/manifest/ManifestExport.cxx5
-rw-r--r--package/source/zipapi/ByteChucker.cxx103
-rw-r--r--package/source/zipapi/Deflater.cxx10
-rw-r--r--package/source/zipapi/EntryInputStream.cxx13
-rw-r--r--package/source/zipapi/EntryInputStream.hxx12
-rw-r--r--package/source/zipapi/Inflater.cxx58
-rw-r--r--package/source/zipapi/XFileStream.cxx194
-rw-r--r--package/source/zipapi/XFileStream.hxx118
-rw-r--r--package/source/zipapi/XMemoryStream.cxx85
-rw-r--r--package/source/zipapi/XMemoryStream.hxx79
-rw-r--r--package/source/zipapi/ZipEnumeration.cxx5
-rw-r--r--package/source/zipapi/ZipFile.cxx402
-rw-r--r--package/source/zipapi/ZipOutputStream.cxx92
-rw-r--r--package/source/zipapi/makefile.mk33
-rw-r--r--package/source/zippackage/ZipPackage.cxx455
-rw-r--r--package/source/zippackage/ZipPackageBuffer.cxx18
-rw-r--r--package/source/zippackage/ZipPackageEntry.cxx20
-rw-r--r--package/source/zippackage/ZipPackageEntry.hxx10
-rw-r--r--package/source/zippackage/ZipPackageFolder.cxx102
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx17
-rw-r--r--package/source/zippackage/ZipPackageStream.hxx10
-rw-r--r--package/source/zippackage/makefile.mk18
34 files changed, 1797 insertions, 344 deletions
diff --git a/package/inc/ByteChucker.hxx b/package/inc/ByteChucker.hxx
index 2ba8a6c569f2..4b9cbf0b2ae0 100644
--- a/package/inc/ByteChucker.hxx
+++ b/package/inc/ByteChucker.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ByteChucker.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: mtg $ $Date: 2001-05-31 09:36:05 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,20 +68,25 @@
#include <com/sun/star/io/XSeekable.hpp>
#endif
+class ThreadedBuffer;
+
class ByteChucker
{
+ friend class ThreadedBuffer;
protected:
com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > xStream;
com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
- com::sun::star::uno::Sequence < sal_Int8 > a1Sequence, a2Sequence, a4Sequence;
- sal_Int8 *p1Sequence, *p2Sequence, *p4Sequence;
+ com::sun::star::uno::Sequence < sal_Int8 > aBuffer, a1Sequence, a2Sequence, a4Sequence;
+ sal_Bool bSpannable, bNextWriteIsAtomic;
+ sal_Int8 * const p1Sequence, * const p2Sequence, * const p4Sequence, * pBuffer;
+ sal_Int32 nBufferSize, nCurrentBufferPos;
public:
ByteChucker (com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> xOstream);
~ByteChucker();
// XOutputStream
- void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData )
+ void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nLength = -1, const sal_Int8 * const pData = NULL)
throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
void SAL_CALL flush( )
throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
@@ -101,6 +106,8 @@ public:
ByteChucker& operator << (sal_uInt8 nuInt8);
ByteChucker& operator << (sal_uInt16 nuInt16);
ByteChucker& operator << (sal_uInt32 nuInt32);
+ void setSpannable ( sal_Bool bNewSpannable );
+ inline sal_Bool isSpannable () { return bSpannable; }
};
#endif
diff --git a/package/inc/CRC32.hxx b/package/inc/CRC32.hxx
index 9a765d1c4090..4587175ae9a0 100644
--- a/package/inc/CRC32.hxx
+++ b/package/inc/CRC32.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: CRC32.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: mtg $ $Date: 2001-05-31 09:37:33 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,7 +73,7 @@
class CRC32
{
-private:
+protected:
sal_uInt32 nCRC;
public:
CRC32();
diff --git a/package/inc/HashMaps.hxx b/package/inc/HashMaps.hxx
index e58f3607c52c..125a2dbecea9 100644
--- a/package/inc/HashMaps.hxx
+++ b/package/inc/HashMaps.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: HashMaps.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:11:06 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -78,20 +78,13 @@ struct eqFunc
}
};
-struct hashFunc
-{
- sal_Int32 operator()(const rtl::OUString &r1) const
- {
- return r1.hashCode();
- }
-};
typedef std::hash_map < rtl::OUString,
com::sun::star::uno::Reference < com::sun::star::lang::XUnoTunnel >,
- hashFunc,
+ ::rtl::OUStringHash,
eqFunc > TunnelHash;
typedef std::hash_map < rtl::OUString,
com::sun::star::uno::Reference < com::sun::star::container::XNameContainer >,
- hashFunc,
+ ::rtl::OUStringHash,
eqFunc > NameHash;
#endif
diff --git a/package/inc/ImplValidCharacters.hxx b/package/inc/ImplValidCharacters.hxx
new file mode 100644
index 000000000000..7520de7fc34c
--- /dev/null
+++ b/package/inc/ImplValidCharacters.hxx
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * $RCSfile: ImplValidCharacters.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:13 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): Martin Gallwey (gallwey@sun.com)
+ *
+ *
+ ************************************************************************/
+#ifndef _IMPL_VALID_CHARACTERS_HXX_
+#define _IMPL_VALID_CHARACTERS_HXX_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+static sal_Bool Impl_IsValidChar ( sal_Unicode aChar, sal_Bool bSlashAllowed )
+{
+ sal_Bool bReturn = sal_True;
+
+ switch ( aChar )
+ {
+ case '\\':
+ case '?':
+ case '<':
+ case '>':
+ case '\"':
+ case '|':
+ case ':':
+ bReturn = sal_False;
+ break;
+ case '/':
+ bReturn = bSlashAllowed;
+ break;
+ default:
+ if ( aChar < 32 || aChar > 127 )
+ bReturn = sal_False;
+ break;
+ }
+ return bReturn;
+}
+#endif
diff --git a/package/inc/Inflater.hxx b/package/inc/Inflater.hxx
index 92d24dad83c5..341a77ae4345 100644
--- a/package/inc/Inflater.hxx
+++ b/package/inc/Inflater.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Inflater.hxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,10 +75,7 @@ extern "C"
class Inflater
{
protected:
- sal_Bool bFinish;
- sal_Bool bFinished;
- sal_Bool bSetParams;
- sal_Bool bNeedDict;
+ sal_Bool bFinish, bFinished, bSetParams, bNeedDict;
sal_Int32 nOffset, nLength;
z_stream* pStream;
com::sun::star::uno::Sequence < sal_Int8 > sInBuffer;
diff --git a/package/inc/PackageConstants.hxx b/package/inc/PackageConstants.hxx
index 3914bb87ebc5..92cd8653f93b 100644
--- a/package/inc/PackageConstants.hxx
+++ b/package/inc/PackageConstants.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: PackageConstants.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2001-05-31 09:35:05 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -66,5 +66,7 @@
#endif
const sal_Int32 n_ConstBufferSize = 32768;
+const sal_Int32 n_ConstNonSpannableBufferSize = 128;
+const sal_Int32 n_ConstMaxMemoryStreamSize = 20480;
#endif
diff --git a/package/inc/ZipEnumeration.hxx b/package/inc/ZipEnumeration.hxx
index f2333f585fcc..b625535bcb21 100644
--- a/package/inc/ZipEnumeration.hxx
+++ b/package/inc/ZipEnumeration.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipEnumeration.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: mtg $ $Date: 2001-04-27 14:56:52 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -72,7 +72,7 @@ protected:
EntryHash::const_iterator aIterator;
public:
sal_Bool SAL_CALL hasMoreElements();
- const com::sun::star::packages::ZipEntry * SAL_CALL nextElement();
+ const com::sun::star::packages::zip::ZipEntry * SAL_CALL nextElement();
ZipEnumeration( EntryHash &rNewEntryHash);
~ZipEnumeration(void);
};
diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx
index b09f683a1910..4b55f476bb57 100644
--- a/package/inc/ZipFile.hxx
+++ b/package/inc/ZipFile.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipFile.hxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,8 +70,8 @@
#ifndef _INFLATER_HXX
#include <Inflater.hxx>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPEXCEPTION_HPP_
-#include <com/sun/star/packages/ZipException.hpp>
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPEXCEPTION_HPP_
+#include <com/sun/star/packages/zip/ZipException.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_NOSUCHELEMENTEXCEPTION_HPP_
#include <com/sun/star/container/NoSuchElementException.hpp>
@@ -98,21 +98,40 @@ class ZipFile
protected:
::rtl::OUString sName; /* zip file name */
::rtl::OUString sComment; /* zip file comment */
+ ::rtl::OUString sURL;
EntryHash aEntries;
ByteGrabber aGrabber;
Inflater aInflater;
+ sal_Bool bSpanned;
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
+ com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
+
+ com::sun::star::uno::Reference < com::sun::star::io::XInputStream > createMemoryStream(
+ com::sun::star::packages::zip::ZipEntry & rEntry,
+ const vos::ORef < EncryptionData > &rData,
+ sal_Bool bRawStream,
+ sal_Int32 nUncompressedSize,
+ sal_Int32 nEnd);
+
+ com::sun::star::uno::Reference < com::sun::star::io::XInputStream > createFileStream(
+ com::sun::star::packages::zip::ZipEntry & rEntry,
+ const vos::ORef < EncryptionData > &rData,
+ sal_Bool bRawStream,
+ sal_Int32 nUncompressedSize,
+ sal_Int32 nEnd);
public:
ZipFile( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &xInput, sal_Bool bInitialise)
- throw(::com::sun::star::io::IOException, com::sun::star::packages::ZipException, com::sun::star::uno::RuntimeException);
+ throw(::com::sun::star::io::IOException, com::sun::star::packages::zip::ZipException, com::sun::star::uno::RuntimeException);
+ ZipFile( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &xInput, ::rtl::OUString &rURL )
+ throw(::com::sun::star::io::IOException, com::sun::star::packages::zip::ZipException, com::sun::star::uno::RuntimeException);
void setInputStream ( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewStream );
- sal_uInt32 SAL_CALL getHeader(const ::com::sun::star::packages::ZipEntry& rEntry)
- throw(::com::sun::star::io::IOException, ::com::sun::star::packages::ZipException, ::com::sun::star::uno::RuntimeException);
+ sal_uInt32 SAL_CALL getHeader(const ::com::sun::star::packages::zip::ZipEntry& rEntry)
+ throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException);
~ZipFile();
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawStream(
- ::com::sun::star::packages::ZipEntry& rEntry,
+ ::com::sun::star::packages::zip::ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData)
- throw(::com::sun::star::io::IOException, ::com::sun::star::packages::ZipException, ::com::sun::star::uno::RuntimeException);
+ throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException);
// XElementAccess
::com::sun::star::uno::Type SAL_CALL getElementType( )
@@ -121,9 +140,9 @@ public:
throw(::com::sun::star::uno::RuntimeException);
// XZipFile
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(
- ::com::sun::star::packages::ZipEntry& rEntry,
+ ::com::sun::star::packages::zip::ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData)
- throw(::com::sun::star::io::IOException, ::com::sun::star::packages::ZipException, ::com::sun::star::uno::RuntimeException);
+ throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException);
::rtl::OUString SAL_CALL getName( )
throw(::com::sun::star::uno::RuntimeException);
sal_Int32 SAL_CALL getSize( )
@@ -140,13 +159,13 @@ public:
throw(::com::sun::star::uno::RuntimeException);
ZipEnumeration * SAL_CALL entries( );
-private:
- sal_Bool readLOC (com::sun::star::packages::ZipEntry &rEntry)
- throw(::com::sun::star::io::IOException, com::sun::star::packages::ZipException, com::sun::star::uno::RuntimeException);
+protected:
+ sal_Bool readLOC (com::sun::star::packages::zip::ZipEntry &rEntry)
+ throw(::com::sun::star::io::IOException, com::sun::star::packages::zip::ZipException, com::sun::star::uno::RuntimeException);
sal_Int32 readCEN()
- throw(::com::sun::star::io::IOException, com::sun::star::packages::ZipException, com::sun::star::uno::RuntimeException);
+ throw(::com::sun::star::io::IOException, com::sun::star::packages::zip::ZipException, com::sun::star::uno::RuntimeException);
sal_Int32 findEND()
- throw(::com::sun::star::io::IOException, com::sun::star::packages::ZipException, com::sun::star::uno::RuntimeException);
+ throw(::com::sun::star::io::IOException, com::sun::star::packages::zip::ZipException, com::sun::star::uno::RuntimeException);
};
#endif
diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx
index 11fcb8a50f21..cc44b50829f7 100644
--- a/package/inc/ZipOutputStream.hxx
+++ b/package/inc/ZipOutputStream.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipOutputStream.hxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: mtg $ $Date: 2001-05-31 09:38:31 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -76,19 +76,22 @@
#ifndef _RTL_CIPHER_H_
#include <rtl/cipher.h>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPENTRY_HPP_
-#include <com/sun/star/packages/ZipEntry.hpp>
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPENTRY_HPP_
+#include <com/sun/star/packages/zip/ZipEntry.hpp>
#endif
#ifndef _VOS_REF_H_
#include <vos/ref.hxx>
#endif
class EncryptionData;
+class ThreadedBuffer;
+
class ZipOutputStream
{
+ friend class ThreadedBuffer;
protected:
com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > xStream;
- ::std::vector < ::com::sun::star::packages::ZipEntry *> aZipList;
+ ::std::vector < ::com::sun::star::packages::zip::ZipEntry *> aZipList;
com::sun::star::uno::Sequence < sal_Int8 > aBuffer;
com::sun::star::uno::Sequence < sal_Int8 > aEncryptionBuffer;
::rtl::OUString sComment;
@@ -96,15 +99,15 @@ protected:
rtlCipher aCipher;
CRC32 aCRC;
ByteChucker aChucker;
- com::sun::star::packages::ZipEntry *pCurrentEntry;
- sal_Int16 nMethod;
- sal_Int16 nLevel;
- sal_Bool bFinished;
- sal_Bool bEncryptCurrentEntry;
+ com::sun::star::packages::zip::ZipEntry *pCurrentEntry;
+ sal_Int16 nMethod, nLevel;
+ sal_Bool bFinished, bEncryptCurrentEntry, bSpanning;
+ sal_Int16 nCurrentDiskNumber;
public:
- ZipOutputStream( com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > &xOStream, sal_Int32 nNewBufferSize);
+ ZipOutputStream( com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > &xOStream, sal_Bool bNewSpanning );
~ZipOutputStream(void);
+ void setDiskNumber ( sal_Int16 nNewDiskNumber ) { nCurrentDiskNumber = nNewDiskNumber; }
// rawWrite to support a direct write to the output stream
void SAL_CALL rawWrite( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
@@ -119,7 +122,7 @@ public:
throw(::com::sun::star::uno::RuntimeException);
void SAL_CALL setLevel( sal_Int32 nNewLevel )
throw(::com::sun::star::uno::RuntimeException);
- void SAL_CALL putNextEntry( ::com::sun::star::packages::ZipEntry& rEntry,
+ void SAL_CALL putNextEntry( ::com::sun::star::packages::zip::ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
sal_Bool bEncrypt = sal_False )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
@@ -136,13 +139,12 @@ protected:
void doDeflate();
void writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- void writeCEN( const com::sun::star::packages::ZipEntry &rEntry )
+ void writeCEN( const com::sun::star::packages::zip::ZipEntry &rEntry )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- void writeEXT( const com::sun::star::packages::ZipEntry &rEntry )
+ void writeEXT( const com::sun::star::packages::zip::ZipEntry &rEntry )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- void writeLOC( const com::sun::star::packages::ZipEntry &rEntry )
+ sal_Int32 writeLOC( const com::sun::star::packages::zip::ZipEntry &rEntry )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
-
};
#endif
diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx
index 1f9f718d4f9a..e44b89f45428 100644
--- a/package/inc/ZipPackage.hxx
+++ b/package/inc/ZipPackage.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackage.hxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: mtg $ $Date: 2001-05-31 09:39:40 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -88,6 +88,9 @@
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
+#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#endif
#ifndef _ZIP_PACKAGE_BUFFER_HXX
#include <ZipPackageBuffer.hxx>
#endif
@@ -97,15 +100,23 @@
#ifndef _HASHMAPS_HXX
#include <HashMaps.hxx>
#endif
-
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
#include <vector>
class ZipPackageFolder;
class ZipFile;
class OutputThread;
+enum SegmentEnum
+{
+ e_Aborted = -1000,
+ e_Retry,
+ e_Success = 0
+};
class ZipPackage :
- public ::cppu::OWeakObject,
+ public cppu::OWeakObject,
public com::sun::star::lang::XInitialization,
public com::sun::star::lang::XSingleServiceFactory,
public com::sun::star::lang::XUnoTunnel,
@@ -119,11 +130,12 @@ protected:
NameHash aRecent;
::rtl::OUString sURL;
sal_Int32 nSegmentSize;
- sal_Bool bHasEncryptedEntries;
+ sal_Bool bHasEncryptedEntries, bSpanned;
::com::sun::star::uno::Reference < com::sun::star::container::XNameContainer > xRootFolder;
::com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xContentStream;
::com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xContentSeek;
+ ::com::sun::star::uno::Reference < com::sun::star::task::XInteractionHandler > xInteractionHandler;
const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xFactory;
ZipPackageFolder *pRootFolder;
@@ -131,6 +143,17 @@ protected:
::ucb::Content *pContent;
void getZipFileContents();
+ SegmentEnum writeSegment(
+ const ::rtl::OUString & rFileName,
+ ::rtl::OUString & rMountPath,
+ ::com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &xStream,
+ ::com::sun::star::uno::Sequence < sal_Int8 > &rBuffer,
+ sal_Bool bRetry,
+ const sal_Int16 nDiskNum);
+ void getInteractionHandler();
+ sal_Bool HandleError ( com::sun::star::uno::Any &rAny, sal_uInt16 eContinuations );
+ sal_Bool HandleError ( oslFileError, sal_uInt16 eContinuations, ::rtl::OUString &rFileName );
+ sal_Int32 RequestDisk ( ::rtl::OUString &rMountPath, sal_Int16 nDiskNum);
public:
ZipPackage (const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory);
@@ -186,6 +209,7 @@ public:
throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
// Uno componentiseralation
static ::rtl::OUString getImplementationName();
static ::com::sun::star::uno::Sequence < ::rtl::OUString > getSupportedServiceNames();
diff --git a/package/inc/ZipPackageBuffer.hxx b/package/inc/ZipPackageBuffer.hxx
index a6b57f9b004c..71f3b6608b9e 100644
--- a/package/inc/ZipPackageBuffer.hxx
+++ b/package/inc/ZipPackageBuffer.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageBuffer.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: hr $ $Date: 2001-06-11 09:32:41 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -93,6 +93,7 @@ protected:
sal_Bool m_bMustInitBuffer;
public:
ZipPackageBuffer(sal_Int64 nNewBufferSize);
+ ZipPackageBuffer( com::sun::star::uno::Sequence < sal_Int8 > &nNewBuffer );
virtual ~ZipPackageBuffer(void);
virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type& rType )
throw(com::sun::star::uno::RuntimeException);
diff --git a/package/inc/ZipPackageFolder.hxx b/package/inc/ZipPackageFolder.hxx
index e62ef7446191..45936f3568ce 100644
--- a/package/inc/ZipPackageFolder.hxx
+++ b/package/inc/ZipPackageFolder.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageFolder.hxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: mtg $ $Date: 2001-05-08 13:51:29 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -98,7 +98,7 @@ public:
ZipPackageFolder ();
virtual ~ZipPackageFolder();
- static void copyZipEntry( com::sun::star::packages::ZipEntry &rDest, const com::sun::star::packages::ZipEntry &rSource);
+ static void copyZipEntry( com::sun::star::packages::zip::ZipEntry &rDest, const com::sun::star::packages::zip::ZipEntry &rSource);
// Recursive functions
void saveContents(rtl::OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, com::sun::star::uno::Sequence < sal_Int8 > &rEncryptionKey)
throw(::com::sun::star::uno::RuntimeException);
diff --git a/package/source/manifest/ManifestExport.cxx b/package/source/manifest/ManifestExport.cxx
index 199d5d950d38..fab54b31a830 100644
--- a/package/source/manifest/ManifestExport.cxx
+++ b/package/source/manifest/ManifestExport.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ManifestExport.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: mtg $ $Date: 2001-05-08 13:54:33 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,7 +79,6 @@
#endif
using namespace rtl;
-using namespace std;
using namespace com::sun::star::beans;
using namespace com::sun::star::uno;
using namespace com::sun::star::xml::sax;
diff --git a/package/source/zipapi/ByteChucker.cxx b/package/source/zipapi/ByteChucker.cxx
index a6305bb7b263..c0d9663d4f8c 100644
--- a/package/source/zipapi/ByteChucker.cxx
+++ b/package/source/zipapi/ByteChucker.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ByteChucker.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: mtg $ $Date: 2001-05-31 09:46:05 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,51 +59,75 @@
*
************************************************************************/
#ifndef _BYTE_CHUCKER_HXX_
-#include "ByteChucker.hxx"
+#include <ByteChucker.hxx>
+#endif
+#ifndef _PACKAGE_CONSTANTS_HXX_
+#include <PackageConstants.hxx>
#endif
#include <memory.h> //for memcpy
-using namespace ::com::sun::star;
-
-/** ByteChucker implements the << operators on an XOutputStream. This is
- * potentially quite slow and may need to be optimised
- */
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
-ByteChucker::ByteChucker(uno::Reference<io::XOutputStream> xOstream)
+ByteChucker::ByteChucker(Reference<XOutputStream> xOstream)
: xStream(xOstream)
-, xSeek (xOstream, uno::UNO_QUERY )
+, xSeek (xOstream, UNO_QUERY )
, a1Sequence ( 1 )
, a2Sequence ( 2 )
, a4Sequence ( 4 )
+, aBuffer ( n_ConstNonSpannableBufferSize )
+, p1Sequence ( a1Sequence.getArray() )
+, p2Sequence ( a2Sequence.getArray() )
+, p4Sequence ( a4Sequence.getArray() )
+, pBuffer ( aBuffer.getArray() )
+, nBufferSize ( n_ConstNonSpannableBufferSize )
+, nCurrentBufferPos ( 0 )
+, bSpannable ( sal_True )
+, bNextWriteIsAtomic ( sal_False )
{
- p1Sequence = a1Sequence.getArray();
- p2Sequence = a2Sequence.getArray();
- p4Sequence = a4Sequence.getArray();
}
+
ByteChucker::~ByteChucker()
{
}
// XOutputStream chained...
-void SAL_CALL ByteChucker::writeBytes( const uno::Sequence< sal_Int8 >& aData )
- throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
+void SAL_CALL ByteChucker::writeBytes( const Sequence< sal_Int8 >& aData, sal_Int32 nLength, const sal_Int8 * const pData )
+ throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
{
- xStream->writeBytes(aData);
+ if ( !bSpannable )
+ {
+ if ( nLength < 0 )
+ nLength = aData.getLength();
+ if (nLength > nBufferSize )
+ {
+ do
+ nBufferSize *= 2;
+ while ( nLength > nBufferSize );
+
+ aBuffer.realloc ( nBufferSize );
+ }
+ memcpy ( pBuffer + nCurrentBufferPos, pData ? pData : aData.getConstArray(), nLength);
+ nCurrentBufferPos += nLength;
+ }
+ else
+ xStream->writeBytes(aData);
}
void SAL_CALL ByteChucker::flush( )
- throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
+ throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
{
xStream->flush();
}
void SAL_CALL ByteChucker::closeOutput( )
- throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
+ throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
{
xStream->closeOutput();
}
// XSeekable chained...
sal_Int64 SAL_CALL ByteChucker::seek( sal_Int64 location )
- throw(lang::IllegalArgumentException, io::IOException, uno::RuntimeException)
+ throw(IllegalArgumentException, IOException, RuntimeException)
{
if (xSeek.is() )
{
@@ -114,29 +138,48 @@ sal_Int64 SAL_CALL ByteChucker::seek( sal_Int64 location )
return location;
}
else
- throw io::IOException();
+ throw IOException();
}
sal_Int64 SAL_CALL ByteChucker::getPosition( )
- throw(io::IOException, uno::RuntimeException)
+ throw(IOException, RuntimeException)
{
if (xSeek.is() )
return xSeek->getPosition();
else
- throw io::IOException();
+ throw IOException();
}
sal_Int64 SAL_CALL ByteChucker::getLength( )
- throw(io::IOException, uno::RuntimeException)
+ throw(IOException, RuntimeException)
{
if (xSeek.is() )
return xSeek->getLength();
else
- throw io::IOException();
+ throw IOException();
+}
+
+void ByteChucker::setSpannable ( sal_Bool bNewSpannable )
+{
+ // if current data isn't spannable, then it's been stored in the Buffer
+ // until we know how much of it there is. Once we start recieving
+ // spannable data again, we'll pass it on
+ if (!isSpannable() && bNewSpannable)
+ {
+ bNextWriteIsAtomic = sal_True;
+ sal_Int32 nOldLength = aBuffer.getLength();
+ aBuffer.realloc ( nCurrentBufferPos );
+ xStream->writeBytes( aBuffer );
+ aBuffer.realloc ( nOldLength );
+ pBuffer = aBuffer.getArray();
+ bNextWriteIsAtomic = sal_False;
+ nCurrentBufferPos = 0;
+ }
+ bSpannable = bNewSpannable;
}
ByteChucker& ByteChucker::operator << (sal_Int8 nInt8)
{
p1Sequence[0] = nInt8 & 0xFF;
- xStream->writeBytes( a1Sequence );
+ writeBytes( a1Sequence, 1, p1Sequence );
return *this;
}
@@ -144,7 +187,7 @@ ByteChucker& ByteChucker::operator << (sal_Int16 nInt16)
{
p2Sequence[0] = (nInt16 >> 0 ) & 0xFF;
p2Sequence[1] = (nInt16 >> 8 ) & 0xFF;
- xStream->writeBytes( a2Sequence );
+ writeBytes( a2Sequence, 2, p2Sequence );
return *this;
}
ByteChucker& ByteChucker::operator << (sal_Int32 nInt32)
@@ -153,21 +196,21 @@ ByteChucker& ByteChucker::operator << (sal_Int32 nInt32)
p4Sequence[1] = (nInt32 >> 8 ) & 0xFF;
p4Sequence[2] = (nInt32 >> 16 ) & 0xFF;
p4Sequence[3] = (nInt32 >> 24 ) & 0xFF;
- xStream->writeBytes( a4Sequence);
+ writeBytes( a4Sequence, 4, p4Sequence );
return *this;
}
ByteChucker& ByteChucker::operator << (sal_uInt8 nuInt8)
{
p1Sequence[0] = nuInt8 & 0xFF;
- xStream->writeBytes( a1Sequence );
+ writeBytes( a1Sequence, 1, p1Sequence );
return *this;
}
ByteChucker& ByteChucker::operator << (sal_uInt16 nuInt16)
{
p2Sequence[0] = (nuInt16 >> 0 ) & 0xFF;
p2Sequence[1] = (nuInt16 >> 8 ) & 0xFF;
- xStream->writeBytes( a2Sequence );
+ writeBytes( a2Sequence, 2, p2Sequence );
return *this;
}
ByteChucker& ByteChucker::operator << (sal_uInt32 nuInt32)
@@ -176,6 +219,6 @@ ByteChucker& ByteChucker::operator << (sal_uInt32 nuInt32)
p4Sequence[1] = static_cast < sal_Int8 > ((nuInt32 >> 8 ) & 0xFF);
p4Sequence[2] = static_cast < sal_Int8 > ((nuInt32 >> 16 ) & 0xFF);
p4Sequence[3] = static_cast < sal_Int8 > ((nuInt32 >> 24 ) & 0xFF);
- xStream->writeBytes( a4Sequence);
+ writeBytes( a4Sequence, 4, p4Sequence );
return *this;
}
diff --git a/package/source/zipapi/Deflater.cxx b/package/source/zipapi/Deflater.cxx
index 0bc472fee918..6eca84055806 100644
--- a/package/source/zipapi/Deflater.cxx
+++ b/package/source/zipapi/Deflater.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Deflater.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,12 +67,12 @@
#ifndef _VOS_DIAGNOSE_H_
#include <vos/diagnose.hxx>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
-#include <com/sun/star/packages/ZipConstants.hpp>
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPCONSTANTS_HPP_
+#include <com/sun/star/packages/zip/ZipConstants.hpp>
#endif
#include <string.h> // for memset
-using namespace com::sun::star::packages::ZipConstants;
+using namespace com::sun::star::packages::zip::ZipConstants;
using namespace com::sun::star;
/** Provides general purpose compression using the ZLIB compression
diff --git a/package/source/zipapi/EntryInputStream.cxx b/package/source/zipapi/EntryInputStream.cxx
index f3ee578cb622..99c3df1253eb 100644
--- a/package/source/zipapi/EntryInputStream.cxx
+++ b/package/source/zipapi/EntryInputStream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: EntryInputStream.cxx,v $
*
- * $Revision: 1.16 $
+ * $Revision: 1.17 $
*
- * last change: $Author: mtg $ $Date: 2001-05-29 11:57:06 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,8 +61,8 @@
#ifndef _ENTRY_INPUT_STREAM_HXX
#include <EntryInputStream.hxx>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
-#include <com/sun/star/packages/ZipConstants.hpp>
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPCONSTANTS_HPP_
+#include <com/sun/star/packages/zip/ZipConstants.hpp>
#endif
#ifndef _RTL_CIPHER_H_
#include <rtl/cipher.h>
@@ -75,7 +75,8 @@
using namespace rtl;
using namespace com::sun::star;
using namespace com::sun::star::uno;
-using namespace com::sun::star::packages::ZipConstants;
+using namespace com::sun::star::packages::zip;
+using namespace com::sun::star::packages::zip::ZipConstants;
/** Provides access to the compressed data in a zipfile.
*
@@ -89,7 +90,7 @@ using namespace com::sun::star::packages::ZipConstants;
*/
EntryInputStream::EntryInputStream( Reference < io::XInputStream > xNewInput,
- const packages::ZipEntry & rNewEntry,
+ const ZipEntry & rNewEntry,
const vos::ORef < EncryptionData > &xEncryptData,
sal_Bool bGetRawStream)
: xStream( xNewInput )
diff --git a/package/source/zipapi/EntryInputStream.hxx b/package/source/zipapi/EntryInputStream.hxx
index 956ed6bc16bf..bcfb1ffba689 100644
--- a/package/source/zipapi/EntryInputStream.hxx
+++ b/package/source/zipapi/EntryInputStream.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: EntryInputStream.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: mtg $ $Date: 2001-05-29 11:57:06 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,8 +73,8 @@
#ifndef _INFLATER_HXX_
#include <Inflater.hxx>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPENTRY_HPP_
-#include <com/sun/star/packages/ZipEntry.hpp>
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPENTRY_HPP_
+#include <com/sun/star/packages/zip/ZipEntry.hpp>
#endif
#ifndef _VOS_REF_H_
#include <vos/ref.hxx>
@@ -92,13 +92,13 @@ protected:
sal_Bool bRawStream, bHaveInMemory, bEncrypted;
com::sun::star::uno::Sequence < sal_Int8 > aBuffer;
const vos::ORef < EncryptionData > xEncryptionData;
- const com::sun::star::packages::ZipEntry aEntry;
+ const com::sun::star::packages::zip::ZipEntry aEntry;
Inflater aInflater;
void readIntoMemory()
throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
public:
EntryInputStream( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xInput,
- const com::sun::star::packages::ZipEntry &rNewEntry,
+ const com::sun::star::packages::zip::ZipEntry &rNewEntry,
const vos::ORef < EncryptionData > &xEncryptData,
sal_Bool bGetRawStream = sal_False);
virtual ~EntryInputStream();
diff --git a/package/source/zipapi/Inflater.cxx b/package/source/zipapi/Inflater.cxx
index bcc6f64c43ec..b35525615ec7 100644
--- a/package/source/zipapi/Inflater.cxx
+++ b/package/source/zipapi/Inflater.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Inflater.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: mtg $ $Date: 2001-04-27 14:56:06 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,11 +67,9 @@
#ifndef _VOS_DIAGNOSE_H_
#include <vos/diagnose.hxx>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
-#include <com/sun/star/packages/ZipConstants.hpp>
-#endif
#include <string.h> // for memset
+using namespace com::sun::star::uno;
/** Provides general purpose decompression using the ZLIB library */
@@ -111,24 +109,24 @@ Inflater::~Inflater()
{
end();
}
-void SAL_CALL Inflater::setInputSegment( const com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
- throw(com::sun::star::uno::RuntimeException)
+void SAL_CALL Inflater::setInputSegment( const Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+ throw(RuntimeException)
{
sInBuffer = rBuffer;
nOffset = nNewOffset;
nLength = nNewLength;
}
-void SAL_CALL Inflater::setInput( const com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
- throw(com::sun::star::uno::RuntimeException)
+void SAL_CALL Inflater::setInput( const Sequence< sal_Int8 >& rBuffer )
+ throw(RuntimeException)
{
sInBuffer = rBuffer;
nOffset = 0;
nLength = rBuffer.getLength();
}
-void SAL_CALL Inflater::setDictionarySegment( const com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
- throw(com::sun::star::uno::RuntimeException)
+void SAL_CALL Inflater::setDictionarySegment( const Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+ throw(RuntimeException)
{
if (pStream == NULL)
{
@@ -142,8 +140,8 @@ void SAL_CALL Inflater::setDictionarySegment( const com::sun::star::uno::Sequenc
nNewLength);
}
-void SAL_CALL Inflater::setDictionary( const com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
- throw(com::sun::star::uno::RuntimeException)
+void SAL_CALL Inflater::setDictionary( const Sequence< sal_Int8 >& rBuffer )
+ throw(RuntimeException)
{
if (pStream == NULL)
{
@@ -154,36 +152,36 @@ void SAL_CALL Inflater::setDictionary( const com::sun::star::uno::Sequence< sal_
}
sal_Int32 SAL_CALL Inflater::getRemaining( )
- throw(com::sun::star::uno::RuntimeException)
+ throw(RuntimeException)
{
return nLength;
}
sal_Bool SAL_CALL Inflater::needsInput( )
- throw(com::sun::star::uno::RuntimeException)
+ throw(RuntimeException)
{
return nLength <=0;
}
sal_Bool SAL_CALL Inflater::needsDictionary( )
- throw(com::sun::star::uno::RuntimeException)
+ throw(RuntimeException)
{
return bNeedDict;
}
void SAL_CALL Inflater::finish( )
- throw(com::sun::star::uno::RuntimeException)
+ throw(RuntimeException)
{
bFinish = sal_True;
}
sal_Bool SAL_CALL Inflater::finished( )
- throw(com::sun::star::uno::RuntimeException)
+ throw(RuntimeException)
{
return bFinished;
}
-sal_Int32 SAL_CALL Inflater::doInflateSegment( com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
- throw(com::sun::star::uno::RuntimeException)
+sal_Int32 SAL_CALL Inflater::doInflateSegment( Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+ throw(RuntimeException)
{
if (nNewOffset < 0 || nNewLength < 0 || nNewOffset + nNewLength > rBuffer.getLength())
{
@@ -192,32 +190,32 @@ sal_Int32 SAL_CALL Inflater::doInflateSegment( com::sun::star::uno::Sequence< sa
return doInflateBytes(rBuffer, nNewOffset, nNewLength);
}
-sal_Int32 SAL_CALL Inflater::doInflate( com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
- throw(com::sun::star::uno::RuntimeException)
+sal_Int32 SAL_CALL Inflater::doInflate( Sequence< sal_Int8 >& rBuffer )
+ throw(RuntimeException)
{
return doInflateBytes(rBuffer, 0, rBuffer.getLength());
}
sal_Int32 SAL_CALL Inflater::getAdler( )
- throw(com::sun::star::uno::RuntimeException)
+ throw(RuntimeException)
{
return pStream->adler;
}
sal_Int32 SAL_CALL Inflater::getTotalIn( )
- throw(com::sun::star::uno::RuntimeException)
+ throw(RuntimeException)
{
return pStream->total_in;
}
sal_Int32 SAL_CALL Inflater::getTotalOut( )
- throw(com::sun::star::uno::RuntimeException)
+ throw(RuntimeException)
{
return pStream->total_out;
}
void SAL_CALL Inflater::reset( )
- throw(com::sun::star::uno::RuntimeException)
+ throw(RuntimeException)
{
z_inflateReset(pStream);
bFinish = bNeedDict = bFinished = sal_False;
@@ -225,7 +223,7 @@ void SAL_CALL Inflater::reset( )
}
void SAL_CALL Inflater::end( )
- throw(com::sun::star::uno::RuntimeException)
+ throw(RuntimeException)
{
if (pStream != NULL)
{
@@ -235,12 +233,12 @@ void SAL_CALL Inflater::end( )
pStream = NULL;
}
-sal_Int32 Inflater::doInflateBytes (com::sun::star::uno::Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength)
+sal_Int32 Inflater::doInflateBytes (Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength)
{
sal_Int32 nResult;
- pStream->next_in = (unsigned char*) sInBuffer.getConstArray()+ nOffset;
+ pStream->next_in = ( unsigned char* ) ( sInBuffer.getConstArray() + nOffset );
pStream->avail_in = nLength;
- pStream->next_out = (unsigned char*) rBuffer.getArray() + nNewOffset;
+ pStream->next_out = reinterpret_cast < unsigned char* > ( rBuffer.getArray() + nNewOffset );
pStream->avail_out = nNewLength;
nResult = ::z_inflate(pStream, bFinish ? Z_SYNC_FLUSH : Z_PARTIAL_FLUSH);
diff --git a/package/source/zipapi/XFileStream.cxx b/package/source/zipapi/XFileStream.cxx
new file mode 100644
index 000000000000..34d0941b6f51
--- /dev/null
+++ b/package/source/zipapi/XFileStream.cxx
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * $RCSfile: XFileStream.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): Martin Gallwey (gallwey@sun.com)
+ *
+ *
+ ************************************************************************/
+#ifndef _XFILE_STREAM_HXX
+#include <XFileStream.hxx>
+#endif
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+#include <memory.h> // for memcpy
+
+using namespace osl;
+using namespace com::sun::star::io;
+using namespace com::sun::star::uno;
+
+XFileStream::XFileStream( File * pNewFile )
+: pFile (pNewFile )
+{
+}
+XFileStream::~XFileStream(void)
+{
+ delete pFile;
+}
+Any SAL_CALL XFileStream::queryInterface( const Type& rType )
+ throw(RuntimeException)
+{
+ return ::cppu::queryInterface ( rType ,
+ // OWeakObject interfaces
+ reinterpret_cast< XInterface* > ( this ) ,
+ static_cast< XWeak* > ( this ) ,
+ // my interfaces
+ static_cast< XInputStream* > ( this ) ,
+ static_cast< XSeekable* > ( this ) );
+
+}
+void SAL_CALL XFileStream::acquire(void)
+ throw()
+{
+ OWeakObject::acquire();
+}
+void SAL_CALL XFileStream::release(void)
+ throw()
+{
+ OWeakObject::release();
+}
+sal_Int32 SAL_CALL XFileStream::readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
+ throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
+{
+ if (nBytesToRead < 0)
+ throw BufferSizeExceededException(::rtl::OUString(),*this);
+
+ sal_uInt64 nBytesRead = 0;
+ aData.realloc ( nBytesToRead );
+ FileBase::RC nError = pFile->read ( aData.getArray(), nBytesToRead, nBytesRead );
+
+ if ( nError != FileBase::E_None )
+ throw IOException ();
+
+ return static_cast < sal_Int32 > (nBytesRead);
+}
+
+sal_Int32 SAL_CALL XFileStream::readSomeBytes( Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
+ throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
+{
+ return readBytes(aData, nMaxBytesToRead);
+}
+void SAL_CALL XFileStream::skipBytes( sal_Int32 nBytesToSkip )
+ throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
+{
+ if (nBytesToSkip < 0)
+ throw BufferSizeExceededException(::rtl::OUString(),*this);
+
+ FileBase::RC nError = pFile->setPos ( osl_Pos_Current, nBytesToSkip );
+ if ( nError != FileBase::E_None )
+ throw IOException ();
+}
+
+sal_Int32 SAL_CALL XFileStream::available( )
+ throw(NotConnectedException, IOException, RuntimeException)
+{
+ sal_uInt64 nPos, nEndPos;
+ sal_Int32 nResult = 0;
+ FileBase::RC nError = pFile->getPos ( nPos );
+ if ( nError != FileBase::E_None )
+ throw IOException ();
+ nError = pFile->setPos ( osl_Pos_End, 0 );
+ if ( nError != FileBase::E_None )
+ throw IOException ();
+ nError = pFile->getPos ( nEndPos );
+ if ( nError != FileBase::E_None )
+ throw IOException ();
+ nResult = static_cast < sal_Int32 > ( nEndPos - nPos );
+ nError = pFile->setPos ( osl_Pos_Absolut, nPos );
+ if ( nError != FileBase::E_None )
+ throw IOException ();
+ return nResult;
+}
+
+void SAL_CALL XFileStream::closeInput( )
+ throw(NotConnectedException, IOException, RuntimeException)
+{
+ pFile->close();
+}
+void SAL_CALL XFileStream::seek( sal_Int64 location )
+ throw(::com::sun::star::lang::IllegalArgumentException, IOException, RuntimeException)
+{
+ FileBase::RC nError = pFile->setPos ( osl_Pos_Absolut, location );
+ if ( nError != FileBase::E_None )
+ throw IOException ();
+}
+sal_Int64 SAL_CALL XFileStream::getPosition( )
+ throw(IOException, RuntimeException)
+{
+ sal_uInt64 nPos;
+ FileBase::RC nError = pFile->getPos ( nPos );
+ if ( nError != FileBase::E_None )
+ throw IOException ();
+ return nPos;
+}
+sal_Int64 SAL_CALL XFileStream::getLength( )
+ throw(IOException, RuntimeException)
+{
+ sal_uInt64 nPos, nEndPos;
+ FileBase::RC nError = pFile->getPos ( nPos );
+ if ( nError != FileBase::E_None )
+ throw IOException ();
+ nError = pFile->setPos ( osl_Pos_End, 0 );
+ if ( nError != FileBase::E_None )
+ throw IOException ();
+ nError = pFile->getPos ( nEndPos );
+ if ( nError != FileBase::E_None )
+ throw IOException ();
+ nError = pFile->setPos ( osl_Pos_Absolut, nPos );
+ if ( nError != FileBase::E_None )
+ throw IOException ();
+ return nEndPos;
+}
diff --git a/package/source/zipapi/XFileStream.hxx b/package/source/zipapi/XFileStream.hxx
new file mode 100644
index 000000000000..c6751a1477e4
--- /dev/null
+++ b/package/source/zipapi/XFileStream.hxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * $RCSfile: XFileStream.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): Martin Gallwey (gallwey@sun.com)
+ *
+ *
+ ************************************************************************/
+#ifndef _XFILE_STREAM_HXX
+#define _XFILE_STREAM_HXX
+
+#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
+#include <com/sun/star/io/XOutputStream.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
+#include <com/sun/star/io/XSeekable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
+#include <com/sun/star/io/XInputStream.hpp>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+namespace osl { class File; }
+
+class XFileStream : public com::sun::star::io::XInputStream,
+ public com::sun::star::io::XSeekable,
+ public cppu::OWeakObject
+{
+protected:
+ osl::File *pFile;
+public:
+ XFileStream( osl::File * pNewFile );
+ virtual ~XFileStream(void);
+
+ // XInterface
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type& rType )
+ throw(com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire(void)
+ throw();
+ virtual void SAL_CALL release(void)
+ throw();
+ // XInputStream
+ virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL available( )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL closeInput( )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ // XSeekable
+ virtual void SAL_CALL seek( sal_Int64 location )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getPosition( )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getLength( )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+};
+#endif
diff --git a/package/source/zipapi/XMemoryStream.cxx b/package/source/zipapi/XMemoryStream.cxx
new file mode 100644
index 000000000000..7b31a013d726
--- /dev/null
+++ b/package/source/zipapi/XMemoryStream.cxx
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * $RCSfile: XMemoryStream.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): Martin Gallwey (gallwey@sun.com)
+ *
+ *
+ ************************************************************************/
+#ifndef _XMEMORY_STREAM_HXX
+#include <XMemoryStream.hxx>
+#endif
+
+using namespace com::sun::star::io;
+using namespace com::sun::star::uno;
+
+XMemoryStream::XMemoryStream ( com::sun::star::uno::Sequence < sal_Int8 > & rNewBuffer )
+: ZipPackageBuffer ( rNewBuffer )
+{
+}
+XMemoryStream::~XMemoryStream(void)
+{
+}
+::com::sun::star::uno::Any SAL_CALL XMemoryStream::queryInterface( const com::sun::star::uno::Type& rType )
+ throw(com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::queryInterface ( rType ,
+ // OWeakObject interfaces
+ reinterpret_cast< XInterface* > ( this ) ,
+ static_cast< XWeak* > ( this ) ,
+ // my interfaces
+ static_cast< XInputStream* > ( this ) ,
+ static_cast< XSeekable* > ( this ) );
+}
diff --git a/package/source/zipapi/XMemoryStream.hxx b/package/source/zipapi/XMemoryStream.hxx
new file mode 100644
index 000000000000..da749986584b
--- /dev/null
+++ b/package/source/zipapi/XMemoryStream.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * $RCSfile: XMemoryStream.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): Martin Gallwey (gallwey@sun.com)
+ *
+ *
+ ************************************************************************/
+#ifndef _XMEMORY_STREAM_HXX
+#define _XMEMORY_STREAM_HXX
+
+#ifndef _ZIP_PACKAGE_BUFFER_HXX
+#include <ZipPackageBuffer.hxx>
+#endif
+
+class ZipPackage;
+class OutputThread;
+
+class XMemoryStream: public ZipPackageBuffer
+{
+public:
+ XMemoryStream ( com::sun::star::uno::Sequence < sal_Int8 > & rNewBuffer );
+ virtual ~XMemoryStream(void);
+ virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type& rType )
+ throw(com::sun::star::uno::RuntimeException);
+};
+#endif
diff --git a/package/source/zipapi/ZipEnumeration.cxx b/package/source/zipapi/ZipEnumeration.cxx
index dedd320b1d3a..5d7318333895 100644
--- a/package/source/zipapi/ZipEnumeration.cxx
+++ b/package/source/zipapi/ZipEnumeration.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipEnumeration.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: mtg $ $Date: 2001-04-27 14:56:06 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,7 @@
using namespace rtl;
using namespace com::sun::star;
using namespace com::sun::star::packages;
+using namespace com::sun::star::packages::zip;
/** Provides an Enumeration over the contents of a Zip file */
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 66d223cc3b50..897db4ddd72b 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipFile.cxx,v $
*
- * $Revision: 1.24 $
+ * $Revision: 1.25 $
*
- * last change: $Author: mtg $ $Date: 2001-06-15 15:25:10 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,26 +70,346 @@
#ifndef _VOS_DIAGNOSE_H_
#include <vos/diagnose.hxx>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
-#include <com/sun/star/packages/ZipConstants.hpp>
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPCONSTANTS_HPP_
+#include <com/sun/star/packages/zip/ZipConstants.hpp>
#endif
+#ifndef _RTL_CIPHER_H_
+#include <rtl/cipher.h>
+#endif
+#ifndef _RTL_DIGEST_H_
+#include <rtl/digest.h>
+#endif
+#ifndef _XMEMORY_STREAM_HXX
+#include <XMemoryStream.hxx>
+#endif
+#ifndef _XFILE_STREAM_HXX
+#include <XFileStream.hxx>
+#endif
+#ifndef _PACKAGE_CONSTANTS_HXX_
+#include <PackageConstants.hxx>
+#endif
+#ifndef _UCBHELPER_CONTENTBROKER_HXX
+#include <ucbhelper/contentbroker.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef UCBHELPER_FILEIDENTIFIERCONVERTER_HXX_
+#include <ucbhelper/fileidentifierconverter.hxx>
+#endif
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+#include <memory.h> // for memcpy
#include <vector>
-
+using namespace vos;
+using namespace ucb;
+using namespace osl;
using namespace rtl;
using namespace com::sun::star;
+using namespace com::sun::star::io;
using namespace com::sun::star::uno;
+using namespace com::sun::star::ucb;
using namespace com::sun::star::lang;
using namespace com::sun::star::packages;
-using namespace com::sun::star::packages::ZipConstants;
+using namespace com::sun::star::packages::zip;
+using namespace com::sun::star::packages::zip::ZipConstants;
+
+static OUString aTempNameBase_Impl;
+
+void Impl_GetCipher ( const ORef < EncryptionData > & xEncryptionData, rtlCipher &rCipher )
+{
+ Sequence < sal_uInt8 > aDerivedKey (16);
+ rtlCipherError aResult;
+ Sequence < sal_Int8 > aDecryptBuffer;
+
+ // Get the key
+ rtl_digest_PBKDF2 ( aDerivedKey.getArray(), 16,
+ reinterpret_cast < const sal_uInt8 * > (xEncryptionData->aKey.getConstArray()),
+ xEncryptionData->aKey.getLength(),
+ xEncryptionData->aSalt.getConstArray(),
+ xEncryptionData->aSalt.getLength(),
+ xEncryptionData->nIterationCount );
+
+ rCipher = rtl_cipher_create (rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeStream);
+ aResult = rtl_cipher_init( rCipher, rtl_Cipher_DirectionDecode,
+ aDerivedKey.getConstArray(),
+ aDerivedKey.getLength(),
+ xEncryptionData->aInitVector.getConstArray(),
+ xEncryptionData->aInitVector.getLength());
+ OSL_ASSERT (aResult == rtl_Cipher_E_None);
+}
+
+OUString Impl_GetTempNameBaseDirectory()
+{
+ if (!aTempNameBase_Impl.getLength() )
+ return OUString ();
+ OUString aTmp;
+ #ifdef TF_FILEURL
+ FileBase::getSystemPathFromFileURL( aTempNameBase_Impl, aTmp );
+#else
+ FileBase::getSystemPathFromNormalizedPath( aTempNameBase_Impl, aTmp );
+#endif
+ return aTmp;
+}
+
+#define TMPNAME_SIZE ( 1 + 5 + 5 + 4 + 1 )
+OUString Impl_ConstructTempDir( const OUString* pParent )
+{
+ OUString aName;
+ if ( pParent && pParent->getLength() )
+ {
+ ContentBroker* pBroker = ContentBroker::get();
+ if ( pBroker )
+ {
+ Reference< XContentProviderManager > xManager =
+ pBroker->getContentProviderManagerInterface();
+
+ // if parent given try to use it
+ OUString aTmp( *pParent );
+
+ // test for valid filename
+ OUString aRet;
+#ifdef TF_FILEURL
+ FileBase::getFileURLFromSystemPath( getSystemPathFromFileURL( xManager, aTmp ), aRet );
+#else
+ FileBase::normalizePath( getSystemPathFromFileURL( xManager, aTmp ), aRet );
+#endif
+ if ( aRet.getLength() )
+ {
+ DirectoryItem aItem;
+ sal_Int32 i = aRet.getLength();
+ if ( aRet[i-1] == '/' )
+ i--;
+
+ if ( DirectoryItem::get( OUString( aRet, i ), aItem ) == FileBase::E_None )
+ aName = aRet;
+ }
+ }
+ else
+ {
+ VOS_ENSURE( sal_False, "::unotools::TempFile : UCB not present or not initialized!" );
+ }
+ }
+
+#if 1
+ if ( !aName.getLength() )
+ {
+ // if no parent or invalid parent : use system directory
+ if ( !aTempNameBase_Impl.getLength() )
+ aTempNameBase_Impl = Impl_GetTempNameBaseDirectory();
+ aName = aTempNameBase_Impl;
+ }
+#else
+ if ( !aName.getLength() )
+ {
+ // if no parent or invalid parent : use default directory
+ VOS_ENSURE( aTempNameBase_Impl.getLength(), "No TempDir!" );
+ aName = aTempNameBase_Impl;
+ }
+#endif
+
+ // Make sure that directory ends with a separator
+ sal_Int32 i = aName.getLength();
+ if( aName.lastIndexOf ('/' != i ) )
+ aName += OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
+
+ return aName;
+}
+
+void Impl_CreateTempName ( OUString& rName, sal_Bool bKeep, sal_Bool bDir = sal_True )
+{
+ // add a suitable tempname
+ // Prefix can have 5 chars, leaving 3 for numbers. 26 ** 3 == 17576
+ // ER 13.07.00 why not radix 36 [0-9A-Z] ?!?
+ const sal_uInt32 nRadix = 26;
+ OUString aName( rName );
+ TimeValue aTimeValue;
+ osl_getSystemTime ( &aTimeValue );
+
+ aName += OUString::createFromAscii( "sv" );
+ rName = OUString();
+
+ sal_uInt32 nSeed = aTimeValue.Nanosec;
+ for ( unsigned long nOld = nSeed; ++nSeed != nOld; )
+ {
+ nSeed %= (nRadix*nRadix*nRadix);
+ OUStringBuffer aBuffer;
+ aBuffer.append ( aName );
+ aBuffer.append ( static_cast < sal_Int32 > (nSeed), nRadix );
+ aBuffer.appendAscii ( ".tmp" );
+
+ OUString aTmp( aBuffer.makeStringAndClear() );
+
+ if ( bDir )
+ {
+ FileBase::RC err = Directory::create( aTmp );
+ if ( err == FileBase::E_None )
+ {
+ // !bKeep: only for creating a name, not a file or directory
+ if ( bKeep || Directory::remove( aTmp ) == FileBase::E_None )
+ rName = aTmp;
+ break;
+ }
+ else if ( err != FileBase::E_EXIST )
+ {
+ // if f.e. name contains invalid chars stop trying to create dirs
+ break;
+ }
+ }
+ else
+ {
+ VOS_ENSURE ( bKeep, "Too expensive, use directory for creating name!" );
+ File aFile( aTmp );
+ FileBase::RC err = aFile.open(osl_File_OpenFlag_Create);
+ if ( err == FileBase::E_None )
+ {
+ rName = aTmp;
+ aFile.close();
+ break;
+ }
+ else if ( err != FileBase::E_EXIST )
+ {
+ // if f.e. name contains invalid chars stop trying to create files
+ break;
+ }
+ }
+ }
+}
+Reference < XInputStream > ZipFile::createFileStream(
+ ZipEntry & rEntry,
+ const ORef < EncryptionData > &rData,
+ sal_Bool bRawStream,
+ sal_Int32 nUncompressedSize,
+ sal_Int32 nEnd)
+{
+ Sequence < sal_Int8 > aDecryptBuffer, aReadBuffer ( n_ConstBufferSize ), aWriteBuffer ( n_ConstBufferSize );
+ xSeek->seek(rEntry.nOffset);
+
+ sal_Int32 nRead = 0, nSize = rEntry.nMethod == DEFLATED ? rEntry.nCompressedSize : rEntry.nSize;
+ sal_uInt64 nWritten = 0;
+ rtlCipher aCipher;
+ sal_Bool bMustDecrypt = rData->aSalt.getLength() ? sal_True : sal_False;
+
+ if (nSize <0)
+ throw IOException();
+
+ OUString sTempFileName = Impl_ConstructTempDir( NULL );
+ Impl_CreateTempName ( sTempFileName, sal_False );
+ // Convert to File URL
+ OUString sFileName;
+ if ( sTempFileName.getLength() )
+ {
+#ifdef TF_FILEURL
+ FileBase::getSystemPathFromFileURL( sTempFileName, sFileName );
+#else
+ FileBase::getSystemPathFromNormalizedPath( sTempFileName, sFileName );
+#endif
+ }
+
+ if ( bMustDecrypt )
+ {
+ Impl_GetCipher ( rData, aCipher );
+ aDecryptBuffer.realloc ( n_ConstBufferSize );
+ }
+ File *pFile = new File ( sFileName );
+ pFile->open( osl_File_OpenFlag_Write );
+
+ do
+ {
+ nRead = xStream->readBytes( aReadBuffer, n_ConstBufferSize ); // Now it holds the raw stuff from disk
+
+ if ( bMustDecrypt )
+ {
+ rtlCipherError aResult = rtl_cipher_decode ( aCipher,
+ aReadBuffer.getConstArray(),
+ nRead,
+ reinterpret_cast < sal_uInt8 * > (aDecryptBuffer.getArray()),
+ nRead);
+ OSL_ASSERT (aResult == rtl_Cipher_E_None);
+ }
+
+ if (!bRawStream && rEntry.nMethod != STORED)
+ {
+ aInflater.setInputSegment( bMustDecrypt ? aDecryptBuffer : aReadBuffer, 0, nRead );
+ sal_Int32 nNewBytes = aInflater.doInflate( aWriteBuffer );
+ pFile->write ( aWriteBuffer.getConstArray(), nNewBytes, nWritten );
+ }
+ else
+ pFile->write ( aReadBuffer.getConstArray(), nRead, nWritten );
+ }
+ while (nRead == n_ConstBufferSize );
+
+ if (!bRawStream && rEntry.nMethod != STORED )
+ {
+ sal_Int32 nNewBytes;
+ while (!aInflater.finished())
+ {
+ nNewBytes = aInflater.doInflate ( aWriteBuffer );
+ pFile->write ( aWriteBuffer.getConstArray(), nNewBytes, nWritten );
+ }
+ aInflater.reset();
+ }
+ pFile->close();
+ return Reference < XInputStream > ( new XFileStream ( pFile ) );
+}
+
+Reference < XInputStream > ZipFile::createMemoryStream(
+ ZipEntry & rEntry,
+ const ORef < EncryptionData > &rData,
+ sal_Bool bRawStream,
+ sal_Int32 nUncompressedSize,
+ sal_Int32 nEnd)
+{
+ xSeek->seek(rEntry.nOffset);
+ sal_Int32 nSize = rEntry.nMethod == DEFLATED ? rEntry.nCompressedSize : rEntry.nSize;
+ Sequence < sal_Int8 > aReadBuffer ( nSize ), aDecryptBuffer, aWriteBuffer;
+ rtlCipher aCipher;
+ sal_Bool bMustDecrypt = rData->aSalt.getLength() ? sal_True : sal_False;
+
+ if ( bMustDecrypt )
+ {
+ Impl_GetCipher ( rData, aCipher );
+ aDecryptBuffer.realloc ( nSize );
+ }
+
+ if (nSize <0)
+ throw IOException ( );
+
+ xStream->readBytes( aReadBuffer, nSize ); // Now it holds the raw stuff from disk
+
+ if ( bMustDecrypt )
+ {
+ rtlCipherError aResult = rtl_cipher_decode ( aCipher,
+ aReadBuffer.getConstArray(),
+ nSize,
+ reinterpret_cast < sal_uInt8 * > (aDecryptBuffer.getArray()),
+ nSize);
+ OSL_ASSERT (aResult == rtl_Cipher_E_None);
+ aReadBuffer = aDecryptBuffer; // Now it holds the decrypted data
+ }
+ if (bRawStream || rEntry.nMethod == STORED)
+ aWriteBuffer = aReadBuffer; // bRawStream means the caller doesn't want it decompressed
+ else
+ {
+ aInflater.setInputSegment(aReadBuffer, 0, nSize );
+ aWriteBuffer.realloc( nUncompressedSize );
+ aInflater.doInflate( aWriteBuffer );
+ aInflater.reset();
+ }
+ return Reference < XInputStream > ( new XMemoryStream ( aWriteBuffer ) );
+}
/** This class is used to read entries from a zip file
*/
-ZipFile::ZipFile( Reference < io::XInputStream > &xInput, sal_Bool bInitialise)
- throw(io::IOException, ZipException, RuntimeException)
+ZipFile::ZipFile( Reference < XInputStream > &xInput, sal_Bool bInitialise)
+ throw(IOException, ZipException, RuntimeException)
: xStream(xInput)
+, xSeek(xInput, UNO_QUERY)
, aGrabber(xInput)
, aInflater (sal_True)
+, bSpanned ( sal_False )
{
if (bInitialise)
{
@@ -97,9 +417,24 @@ ZipFile::ZipFile( Reference < io::XInputStream > &xInput, sal_Bool bInitialise)
aEntries.clear();
}
}
-void ZipFile::setInputStream ( Reference < io::XInputStream > xNewStream )
+
+ZipFile::ZipFile( Reference < XInputStream > &xInput, OUString &rURL)
+ throw(IOException, ZipException, RuntimeException)
+: xStream(xInput)
+, xSeek(xInput, UNO_QUERY)
+, aGrabber(xInput)
+, aInflater (sal_True)
+, sURL ( rURL )
+, bSpanned ( sal_True )
+{
+ if ( readCEN() == -1 )
+ aEntries.clear();
+}
+
+void ZipFile::setInputStream ( Reference < XInputStream > xNewStream )
{
xStream = xNewStream;
+ xSeek = Reference < XSeekable > ( xStream, UNO_QUERY );
aGrabber.setInputStream ( xStream );
}
@@ -109,7 +444,7 @@ ZipFile::~ZipFile()
}
void SAL_CALL ZipFile::close( )
- throw(io::IOException, RuntimeException)
+ throw(IOException, RuntimeException)
{
}
@@ -158,7 +493,9 @@ Sequence< ::rtl::OUString > SAL_CALL ZipFile::getElementNames( )
{
sal_uInt32 i=0, nSize = aEntries.size();
OUString *pNames = new OUString[aEntries.size()];
- for (EntryHash::const_iterator aIterator = aEntries.begin(); aIterator != aEntries.end(); aIterator++,i++)
+ for ( EntryHash::const_iterator aIterator = aEntries.begin(), aEnd = aEntries.end();
+ aIterator != aEnd;
+ aIterator++,i++)
pNames[i] = (*aIterator).first;
return Sequence<OUString> (pNames, nSize);
}
@@ -169,28 +506,46 @@ sal_Bool SAL_CALL ZipFile::hasByName( const ::rtl::OUString& aName )
return aEntries.find(aName) != aEntries.end();
}
-Reference< io::XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry,
+Reference< XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData)
- throw(io::IOException, ZipException, RuntimeException)
+ throw(IOException, ZipException, RuntimeException)
{
if (rEntry.nOffset <= 0)
readLOC(rEntry);
- Reference< io::XInputStream > xStreamRef = new EntryInputStream(xStream, rEntry, rData, sal_False );
- return xStreamRef;
+ //Reference< XInputStream > xStreamRef = new EntryInputStream(xStream, rEntry, rData, sal_False );
+
+ sal_Int32 nUncompressedSize = rEntry.nSize;
+ sal_Int32 nEnd = rEntry.nMethod == DEFLATED ? rEntry.nOffset + rEntry.nCompressedSize : rEntry.nOffset + rEntry.nSize;
+
+/*
+ return nUncompressedSize > n_ConstMaxMemoryStreamSize ?
+ createFileStream(rEntry, rData, sal_False, nUncompressedSize, nEnd) :
+ createMemoryStream(rEntry, rData, sal_False, nUncompressedSize, nEnd);
+*/
+ return createMemoryStream(rEntry, rData, sal_False, nUncompressedSize, nEnd);
+
}
-Reference< io::XInputStream > SAL_CALL ZipFile::getRawStream( ZipEntry& rEntry,
+Reference< XInputStream > SAL_CALL ZipFile::getRawStream( ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData)
- throw(io::IOException, ZipException, RuntimeException)
+ throw(IOException, ZipException, RuntimeException)
{
if (rEntry.nOffset <= 0)
readLOC(rEntry);
- Reference< io::XInputStream > xStreamRef = new EntryInputStream(xStream, rEntry, rData, sal_True );
- return xStreamRef;
+
+ sal_Int32 nUncompressedSize = rEntry.nMethod == DEFLATED ? rEntry.nCompressedSize : rEntry.nSize;
+ sal_Int32 nEnd = rEntry.nOffset + nUncompressedSize;
+
+/*
+ return nUncompressedSize > n_ConstMaxMemoryStreamSize ?
+ createFileStream(rEntry, rData, sal_False, nUncompressedSize, nEnd) :
+ createMemoryStream(rEntry, rData, sal_False, nUncompressedSize, nEnd);
+*/
+ return createMemoryStream(rEntry, rData, sal_False, nUncompressedSize, nEnd);
}
sal_Bool ZipFile::readLOC( ZipEntry &rEntry )
- throw(io::IOException, ZipException, RuntimeException)
+ throw(IOException, ZipException, RuntimeException)
{
sal_uInt32 nTestSig, nTime, nCRC, nSize, nCompressedSize;
sal_uInt16 nVersion, nFlag, nHow, nNameLen, nExtraLen;
@@ -215,14 +570,13 @@ sal_Bool ZipFile::readLOC( ZipEntry &rEntry )
}
sal_Int32 ZipFile::findEND( )
- throw(io::IOException, ZipException, RuntimeException)
+ throw(IOException, ZipException, RuntimeException)
{
sal_Int32 nLength=0, nPos=0;
Sequence < sal_Int8 > aByteSeq;
try
{
nLength = nPos = static_cast <sal_Int32 > (aGrabber.getLength());
-
if (nLength == 0)
return -1;
//throw (ZipException( OUString::createFromAscii("Trying to find Zip END signature in a zero length file!"), Reference < XInterface> () ));
@@ -238,7 +592,7 @@ sal_Int32 ZipFile::findEND( )
for (sal_uInt16 i=0; i <nCount;i++)
{
- sal_uInt32 nTest;
+ sal_uInt32 nTest=0, nFoo=ENDSIG;
aGrabber.seek (nPos+i);
aGrabber >> nTest;
if (nTest == ENDSIG)
@@ -279,7 +633,7 @@ sal_Int32 ZipFile::findEND( )
}
sal_Int32 ZipFile::readCEN()
- throw(io::IOException, ZipException, RuntimeException)
+ throw(IOException, ZipException, RuntimeException)
{
sal_Int32 nEndPos, nLocPos;
sal_Int16 nCount, nTotal;
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx
index 22d6692271c1..08c5cbedf5af 100644
--- a/package/source/zipapi/ZipOutputStream.cxx
+++ b/package/source/zipapi/ZipOutputStream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipOutputStream.cxx,v $
*
- * $Revision: 1.27 $
+ * $Revision: 1.28 $
*
- * last change: $Author: mtg $ $Date: 2001-05-31 10:23:43 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,8 +67,8 @@
#ifndef _VOS_REF_H_
#include <vos/ref.hxx>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
-#include <com/sun/star/packages/ZipConstants.hpp>
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPCONSTANTS_HPP_
+#include <com/sun/star/packages/zip/ZipConstants.hpp>
#endif
#ifndef _OSL_TIME_H_
#include <osl/time.h>
@@ -76,24 +76,33 @@
#ifndef _ENCRYPTION_DATA_HXX_
#include <EncryptionData.hxx>
#endif
+#ifndef _IMPL_VALID_CHARACTERS_HXX_
+#include <ImplValidCharacters.hxx>
+#endif
+#ifndef _PACKAGE_CONSTANTS_HXX_
+#include <PackageConstants.hxx>
+#endif
using namespace rtl;
using namespace com::sun::star::io;
-using namespace com::sun::star::packages;
using namespace com::sun::star::uno;
-using namespace com::sun::star::packages::ZipConstants;
+using namespace com::sun::star::packages;
+using namespace com::sun::star::packages::zip;
+using namespace com::sun::star::packages::zip::ZipConstants;
/** This class is used to write Zip files
*/
-ZipOutputStream::ZipOutputStream( Reference < XOutputStream > &xOStream, sal_Int32 nNewBufferSize)
+ZipOutputStream::ZipOutputStream( Reference < XOutputStream > &xOStream, sal_Bool bNewSpanning )
: xStream(xOStream)
, aChucker(xOStream)
, nMethod(DEFLATED)
, pCurrentEntry(NULL)
, bFinished(sal_False)
, bEncryptCurrentEntry(sal_False)
-, aBuffer(nNewBufferSize)
+, aBuffer(n_ConstBufferSize)
, aDeflater(DEFAULT_COMPRESSION, sal_True)
+, nCurrentDiskNumber ( 0 )
+, bSpanning ( bNewSpanning )
{
}
@@ -124,6 +133,16 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
sal_Bool bEncrypt)
throw(IOException, RuntimeException)
{
+ if ( bSpanning && ! aZipList.size() )
+ {
+ Sequence < sal_Int8 > aSequence ( 4 );
+ sal_Int8 *pNum = aSequence.getArray();
+ pNum[0] = 'P';
+ pNum[1] = 'K';
+ pNum[2] = 7;
+ pNum[3] = 8;
+ aChucker.writeBytes( aSequence, 4, pNum );
+ }
if (pCurrentEntry != NULL)
closeEntry();
if (rEntry.nTime == -1)
@@ -138,7 +157,6 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
rEntry.nCrc != -1)
rEntry.nFlag = 0;
- rEntry.nOffset = static_cast < sal_Int32 > (aChucker.getPosition());
if (bEncrypt)
{
bEncryptCurrentEntry = sal_True;
@@ -153,10 +171,12 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
OSL_ASSERT( aResult == rtl_Cipher_E_None );
rEntry.nFlag |= 1 << 4;
}
- writeLOC(rEntry);
+ sal_Int32 nLOCLength = writeLOC(rEntry);
+ // After writeLOC we know which disk we're stored on and also the offset
+ rEntry.nDiskNumber = nCurrentDiskNumber;
+ rEntry.nOffset = static_cast < sal_Int32 > (aChucker.getPosition()) - nLOCLength;
aZipList.push_back( &rEntry );
pCurrentEntry = &rEntry;
-
}
void SAL_CALL ZipOutputStream::close( )
throw(IOException, RuntimeException)
@@ -312,6 +332,7 @@ void ZipOutputStream::doDeflate()
void ZipOutputStream::writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
throw(IOException, RuntimeException)
{
+ aChucker.setSpannable ( sal_False );
sal_Int16 nCommentLength = static_cast < sal_Int16 > (sComment.getLength());
Sequence < sal_Int8 > aSequence (nCommentLength);
sal_Int8 *pArray = aSequence.getArray();
@@ -319,8 +340,8 @@ void ZipOutputStream::writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
const sal_Unicode *pChar = sComment.getStr();
for ( sal_Int16 i = 0; i < nCommentLength; i++)
{
- VOS_ENSURE (pChar[i] <127, "Non US ASCII character in zipfile comment!");
- *(pArray+i) = static_cast < const sal_Int8 > (pChar[i]);
+ VOS_ENSURE ( Impl_IsValidChar ( pChar[i], sal_True), "Non US ASCII character in zipfile comment!");
+ pArray[i] = static_cast < const sal_Int8 > (pChar[i]);
}
aChucker << ENDSIG;
aChucker << static_cast < sal_Int16 > ( 0 );
@@ -331,11 +352,13 @@ void ZipOutputStream::writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
aChucker << nOffset;
aChucker << nCommentLength;
if (nCommentLength)
- aChucker.writeBytes(aSequence);
+ aChucker.writeBytes( aSequence, nCommentLength, pArray );
+ aChucker.setSpannable ( sal_True );
}
void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
throw(IOException, RuntimeException)
{
+ aChucker.setSpannable ( sal_False );
sal_Int16 nNameLength = static_cast < sal_Int16 > ( rEntry.sName.getLength() ) ,
nCommentLength = static_cast < sal_Int16 > ( rEntry.sComment.getLength() ) ,
nExtraLength = static_cast < sal_Int16 > ( rEntry.extra.getLength() );
@@ -356,14 +379,14 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
aChucker << rEntry.nFlag;
aChucker << rEntry.nMethod;
}
- aChucker << static_cast < sal_uInt32> (rEntry.nTime);
- aChucker << static_cast < sal_uInt32> (rEntry.nCrc);
+ aChucker << static_cast < sal_uInt32> ( rEntry.nTime );
+ aChucker << static_cast < sal_uInt32> ( rEntry.nCrc );
aChucker << rEntry.nCompressedSize;
aChucker << rEntry.nSize;
aChucker << nNameLength;
aChucker << nExtraLength;
aChucker << nCommentLength;
- aChucker << static_cast < sal_Int16> (0);
+ aChucker << static_cast < sal_Int16> ( rEntry.nDiskNumber );
aChucker << static_cast < sal_Int16> (0);
aChucker << static_cast < sal_Int32> (0);
aChucker << rEntry.nOffset;
@@ -374,13 +397,13 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
for ( sal_Int16 i = 0; i < nNameLength; i++)
{
- VOS_ENSURE (pChar[i] <127, "Non US ASCII character in zipentry name!");
- *(pArray+i) = static_cast < const sal_Int8 > (pChar[i]);
+ VOS_ENSURE ( Impl_IsValidChar ( pChar[i], sal_True ), "Non US ASCII character in zipentry name!");
+ pArray[i] = static_cast < const sal_Int8 > (pChar[i]);
}
- aChucker.writeBytes( aSequence );
+ aChucker.writeBytes( aSequence, nNameLength, pArray );
if (nExtraLength)
- aChucker.writeBytes( rEntry.extra);
+ aChucker.writeBytes( rEntry.extra );
if (nCommentLength)
{
if (nNameLength != nCommentLength)
@@ -390,25 +413,30 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
}
for (i=0, pChar = rEntry.sComment.getStr(); i < nCommentLength; i++)
{
- VOS_ENSURE (pChar[i] <127, "Non US ASCII character in zipentry comment!");
- *(pArray+i) = static_cast < const sal_Int8 > (pChar[i]);
+ VOS_ENSURE ( Impl_IsValidChar ( pChar[i], sal_True ), "Non US ASCII character in zipentry comment!");
+ pArray[i] = static_cast < const sal_Int8 > (pChar[i]);
}
- aChucker.writeBytes( aSequence );
+ aChucker.writeBytes( aSequence, nCommentLength, pArray );
}
+ aChucker.setSpannable ( sal_True );
}
void ZipOutputStream::writeEXT( const ZipEntry &rEntry )
throw(IOException, RuntimeException)
{
+ aChucker.setSpannable ( sal_False );
aChucker << EXTSIG;
aChucker << static_cast < sal_uInt32> ( rEntry.nCrc );
aChucker << rEntry.nCompressedSize;
aChucker << rEntry.nSize;
+ aChucker.setSpannable ( sal_True );
}
-void ZipOutputStream::writeLOC( const ZipEntry &rEntry )
+sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry )
throw(IOException, RuntimeException)
{
- sal_Int16 nNameLength = static_cast < sal_Int16 > (rEntry.sName.getLength());
+ aChucker.setSpannable ( sal_False );
+ sal_Int16 nNameLength = static_cast < sal_Int16 > (rEntry.sName.getLength()),
+ nExtraLength = static_cast < sal_Int16 > (rEntry.extra.getLength());
Sequence < sal_Int8 > aSequence(nNameLength);
sal_Int8 *pArray = aSequence.getArray();
@@ -443,17 +471,19 @@ void ZipOutputStream::writeLOC( const ZipEntry &rEntry )
aChucker << rEntry.nSize;
}
aChucker << nNameLength;
- aChucker << static_cast <sal_Int16 > ( rEntry.extra.getLength());
+ aChucker << nExtraLength;
const sal_Unicode *pChar = rEntry.sName.getStr();
for ( sal_Int16 i = 0; i < nNameLength; i++)
{
- VOS_ENSURE (pChar[i] <127, "Non US ASCII character in zipentry name!");
- *(pArray+i) = static_cast < const sal_Int8 > (pChar[i]);
+ VOS_ENSURE ( Impl_IsValidChar ( pChar[i], sal_True ), "Non US ASCII character in zipentry name!");
+ pArray[i] = static_cast < const sal_Int8 > (pChar[i]);
}
- aChucker.writeBytes( aSequence );
- if (rEntry.extra.getLength() != 0)
+ aChucker.writeBytes( aSequence, nNameLength, pArray );
+ if ( nExtraLength )
aChucker.writeBytes( rEntry.extra );
+ aChucker.setSpannable ( sal_True );
+ return LOCHDR + nNameLength + nExtraLength;
}
sal_uInt32 ZipOutputStream::getCurrentDosTime( )
{
diff --git a/package/source/zipapi/makefile.mk b/package/source/zipapi/makefile.mk
index a3fc7273ebe9..30c51c968b46 100644
--- a/package/source/zipapi/makefile.mk
+++ b/package/source/zipapi/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.9 $
+# $Revision: 1.10 $
#
-# last change: $Author: mtg $ $Date: 2001-05-31 10:21:44 $
+# last change: $Author: mtg $ $Date: 2001-07-04 14:56:24 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -76,16 +76,17 @@ ENABLE_EXCEPTIONS=TRUE
# --- Files --------------------------------------------------------
SLOFILES= \
- $(SLO)$/Adler32.obj \
- $(SLO)$/CRC32.obj \
- $(SLO)$/ByteChucker.obj \
- $(SLO)$/ByteGrabber.obj \
- $(SLO)$/Inflater.obj \
- $(SLO)$/Deflater.obj \
+ $(SLO)$/Adler32.obj \
+ $(SLO)$/CRC32.obj \
+ $(SLO)$/ByteChucker.obj \
+ $(SLO)$/ByteGrabber.obj \
+ $(SLO)$/Inflater.obj \
+ $(SLO)$/Deflater.obj \
$(SLO)$/ZipEnumeration.obj \
- $(SLO)$/ZipFile.obj \
+ $(SLO)$/ZipFile.obj \
$(SLO)$/ZipOutputStream.obj \
- $(SLO)$/EntryInputStream.obj
+ $(SLO)$/XMemoryStream.obj \
+ $(SLO)$/XFileStream.obj
# --- UNO stuff ---------------------------------------------------
@@ -97,15 +98,9 @@ UNOUCRDEP= $(SOLARBINDIR)$/offapi.rdb
UNOUCRRDB= $(SOLARBINDIR)$/offapi.rdb
UNOTYPES=\
- com.sun.star.packages.ZipEntry \
- com.sun.star.packages.ZipConstants \
- com.sun.star.packages.ZipException
-# com.sun.star.packages.XChecksum \
-# com.sun.star.packages.XInflater \
-# com.sun.star.packages.XDeflater \
-# com.sun.star.packages.XZipFile \
-# com.sun.star.packages.XZipInputStream \
-# com.sun.star.packages.XZipOutputStream \
+ com.sun.star.packages.zip.ZipEntry \
+ com.sun.star.packages.zip.ZipConstants \
+ com.sun.star.packages.zip.ZipException
# --- Targets ------------------------------------------------------
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 9cd48f4ee31a..98a734d1fe4c 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackage.cxx,v $
*
- * $Revision: 1.48 $
+ * $Revision: 1.49 $
*
- * last change: $Author: mtg $ $Date: 2001-06-15 15:26:10 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,38 +85,52 @@
#ifndef _PACKAGE_CONSTANTS_HXX_
#include <PackageConstants.hxx>
#endif
-#ifndef _COM_SUN_STAR_UCB_COMMANDABORTEDEXCEPTION_HPP_
-#include <com/sun/star/ucb/CommandAbortedException.hpp>
-#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
#include <com/sun/star/beans/PropertyValue.hpp>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
-#include <com/sun/star/packages/ZipConstants.hpp>
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPCONSTANTS_HPP_
+#include <com/sun/star/packages/zip/ZipConstants.hpp>
#endif
#ifndef _COM_SUN_STAR_PACKAGES_MANIFEST_XMANIFESTREADER_HPP_
#include <com/sun/star/packages/manifest/XManifestReader.hpp>
#endif
-/*
-ifndef _COM_SUN_STAR_UCB_COMMANDFAILEDEXCEPTION_HPP_
-#include <com/sun/star/ucb/CommandFailedException.hpp>
+#ifndef _COM_SUN_STAR_UCB_INTERACTIVEFILEIOEXCEPTION_HPP_
+#include <com/sun/star/ucb/InteractiveFileIOException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_INTERACTIVEWRONGMEDIUMEXCEPTION_HPP_
+#include <com/sun/star/ucb/InteractiveWrongMediumException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_IOERRORCODE_HPP
+#include <com/sun/star/ucb/IOErrorCode.hpp>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef _INTERACTION_REQUEST_HXX_
+#include <InteractionRequest.hxx>
#endif
-*/
using namespace rtl;
+using namespace ucb;
using namespace std;
+using namespace osl;
using namespace cppu;
using namespace com::sun::star::io;
+using namespace com::sun::star::util;
using namespace com::sun::star::uno;
using namespace com::sun::star::ucb;
using namespace com::sun::star::util;
using namespace com::sun::star::lang;
+using namespace com::sun::star::task;
using namespace com::sun::star::beans;
using namespace com::sun::star::packages;
using namespace com::sun::star::registry;
using namespace com::sun::star::container;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::container;
+using namespace com::sun::star::packages::zip;
using namespace com::sun::star::packages::manifest;
-using namespace com::sun::star::packages::ZipConstants;
+using namespace com::sun::star::packages::zip::ZipConstants;
ZipPackage::ZipPackage (const Reference < XMultiServiceFactory > &xNewFactory)
: pContent(NULL)
@@ -127,6 +141,8 @@ ZipPackage::ZipPackage (const Reference < XMultiServiceFactory > &xNewFactory)
, xRootFolder (NULL)
, xFactory(xNewFactory)
, bHasEncryptedEntries ( sal_False )
+, bSpanned( sal_False )
+, nSegmentSize ( 0 )
{
pRootFolder = new ZipPackageFolder();
xRootFolder = Reference < XNameContainer > (pRootFolder );
@@ -332,14 +348,25 @@ void SAL_CALL ZipPackage::initialize( const Sequence< Any >& aArguments )
throw(Exception, RuntimeException)
{
aArguments[0] >>= sURL;
+ pContent = new Content(sURL, Reference < XCommandEnvironment >() );
sal_Bool bBadZipFile = sal_False;
pContent = new ::ucb::Content(sURL, Reference < com::sun::star::ucb::XCommandEnvironment >() );
+
Reference < XActiveDataSink > xSink = new ZipPackageSink;
try
{
if (pContent->openStream ( xSink ) )
xContentStream = xSink->getInputStream();
xContentSeek = Reference < XSeekable > (xContentStream, UNO_QUERY);
+ Sequence < sal_Int8 > aSequence ( 4 );
+ xContentStream->readBytes( aSequence, 4 );
+ xContentSeek->seek ( 0 );
+ const sal_Int8 *pSeq = aSequence.getConstArray();
+ if (pSeq[0] == 'P' &&
+ pSeq[1] == 'K' &&
+ pSeq[2] == '7' &&
+ pSeq[3] == '8' )
+ bSpanned= sal_True;
}
catch (com::sun::star::uno::Exception&)
{
@@ -349,7 +376,10 @@ void SAL_CALL ZipPackage::initialize( const Sequence< Any >& aArguments )
}
try
{
- pZipFile = new ZipFile(xContentStream, sal_True);
+ if ( bSpanned)
+ pZipFile = new ZipFile ( xContentStream, sURL );
+ else
+ pZipFile = new ZipFile( xContentStream, sal_True);
getZipFileContents();
}
catch ( IOException & )
@@ -559,13 +589,28 @@ Reference< XInterface > SAL_CALL ZipPackage::createInstanceWithArguments( const
return xRef;
}
+char * ImplGetChars( const OUString & rString )
+{
+ // Memory leak ? oh yeah! Who cares, this function lives until this feature works
+ // and no longer
+ sal_Int32 nLength = rString.getLength();
+ const sal_Unicode *pString = rString.getStr();
+ char * pChar = new char [nLength];
+ for ( sal_Int16 i = 0; i < nLength; i++ )
+ {
+ pChar[i] = static_cast < char > (pString[i]);
+ }
+ pChar[nLength] = '\0';
+ return pChar;
+}
// XChangesBatch
void SAL_CALL ZipPackage::commitChanges( )
throw(WrappedTargetException, RuntimeException)
{
ThreadedBuffer *pBuffer;
- Reference < XOutputStream > xBuffer = (pBuffer = new ThreadedBuffer ( n_ConstBufferSize, sURL, *this ));
- ZipOutputStream aZipOut ( xBuffer, n_ConstBufferSize); //, nSegmentSize );
+ Reference < XOutputStream > xOutBuffer = (pBuffer = new ThreadedBuffer ( n_ConstBufferSize, nSegmentSize, *this ));
+ Reference < XInputStream > xInBuffer ( pBuffer );
+ ZipOutputStream aZipOut ( xOutBuffer, nSegmentSize != 0);
pBuffer->setZipOutputStream ( aZipOut );
aZipOut.setMethod(DEFLATED);
@@ -579,29 +624,269 @@ void SAL_CALL ZipPackage::commitChanges( )
if (xRootFolder->hasByName( sMeta ) )
xRootFolder->removeByName( sMeta );
- try
+
+ if (!nSegmentSize )
{
- pContent->writeStream( Reference < XInputStream > (pBuffer), sal_True );
+ try
+ {
+ pContent->writeStream ( xInBuffer, sal_True );
+ }
+ catch (::com::sun::star::uno::Exception& r)
+ {
+ throw WrappedTargetException( OUString::createFromAscii( "Unable to write Zip File to disk!" ),
+ static_cast < OWeakObject * > ( this ), makeAny( r ) );
+ }
+ Reference < XActiveDataSink > xSink = new ZipPackageSink;
+ try
+ {
+ // Update our references to point to the new file
+ if (pContent->openStream ( xSink ) )
+ xContentStream = xSink->getInputStream();
+ xContentSeek = Reference < XSeekable > (xContentStream, UNO_QUERY);
+ pZipFile->setInputStream ( xContentStream );
+ }
+ catch (com::sun::star::uno::Exception& r)
+ {
+ throw WrappedTargetException( OUString::createFromAscii( "Unable to read Zip File content!" ),
+ static_cast < OWeakObject * > ( this ), makeAny( r ) );
+ }
+ }
+ else
+ {
+ // We want to span...first, make sure we have an interaction handler...
+ getInteractionHandler();
+ sal_Int16 nDiskNum = 0;
+ sal_Int32 nDot = sURL.lastIndexOf ( '.' );
+ OUStringBuffer aStringBuf;
+
+ Sequence < sal_Int8 > aBuffer;
+
+ // If we don't have a specified segment size, don't span
+#ifdef UNX
+ sal_Int32 nPrefixLength = sURL.lastIndexOf ( '/' );
+#else
+ sal_Int32 nPrefixLength = 2 + sURL.lastIndexOf ( ':' );
+#endif
+ OUString sMountPath ( sURL.copy ( 0, nPrefixLength ) );
+ VolumeInfo aInfo ( osl_VolumeInfo_Mask_FreeSpace | osl_VolumeInfo_Mask_DeviceHandle | osl_VolumeInfo_Mask_Attributes );
+ FileBase::RC aRC = Directory::getVolumeInfo ( sMountPath, aInfo );
+ fprintf(stderr, "MTG: url is %s first getVolumeInfo on %s returned %d\n", ImplGetChars ( sURL), ImplGetChars ( sMountPath), aRC);
+ sal_Bool bIsRemovable = aInfo.getRemoveableFlag();
+ fprintf(stderr, "MTG: Removable flag is %d\n", bIsRemovable);
+ do
+ {
+ pBuffer->nextSegment( ++nDiskNum);
+ sal_Int32 nLastSlash = sURL.lastIndexOf ( '/' );
+ if (nDiskNum == 1 )
+ {
+ // Everything after the last slash is file name
+ aStringBuf.append ( sURL.copy ( 1 + nLastSlash ) );
+ }
+ else
+ {
+ // same file prefix, different extension
+ aStringBuf.append ( sURL.copy ( 1 + nLastSlash, sURL.lastIndexOf ( '.' ) - nLastSlash ) );
+ aStringBuf.appendAscii ( nDiskNum -1 < 10 ? "s0" : "s" );
+ aStringBuf.append ( static_cast < sal_Int32 > ( nDiskNum -1 ) );
+
+ }
+ OUString sFileName ( aStringBuf.makeStringAndClear() );
+ if ( bIsRemovable )
+ {
+ if ( nDiskNum > 1 && RequestDisk( sMountPath, nDiskNum ) < 0 )
+ return;
+ sal_Bool bRetry;
+ do
+ {
+ bRetry = sal_False;
+ SegmentEnum eRet = writeSegment ( sFileName, sMountPath, xInBuffer, aBuffer, bRetry, nDiskNum );
+ if (eRet == e_Aborted)
+ return;
+ }
+ while ( bRetry );
+ }
+ else
+ {
+ OUString sFullPath = sURL.copy ( 0, nLastSlash + 1 ) + sFileName;
+ Content aContent (sFullPath, Reference < XCommandEnvironment >() );
+ aContent.writeStream ( xInBuffer, sal_True );
+ }
+ }
+ while ( !pBuffer->isOutputFinished() );
}
- catch (::com::sun::star::uno::Exception& r)
+ fprintf ( stderr, "MTG: ZipPackage Commit finished\n");
+}
+
+sal_Int32 ZipPackage::RequestDisk ( OUString &rMountPath, sal_Int16 nDiskNum)
+{
+ VolumeInfo aInfo ( osl_VolumeInfo_Mask_FreeSpace | osl_VolumeInfo_Mask_DeviceHandle | osl_VolumeInfo_Mask_Attributes );
+ VolumeDevice aDevice;
+ FileBase::RC aRC;
+
+ do
{
- throw WrappedTargetException( OUString::createFromAscii( "Unable to write Zip File to disk!" ),
- static_cast < OWeakObject * > ( this ), makeAny( r ) );
+ aRC = Directory::getVolumeInfo ( rMountPath, aInfo );
+ if ( aRC == FileBase::E_None )
+ aDevice = aInfo.getDeviceHandle();
+ else
+ {
+ if ( ! HandleError ( osl_File_E_INVAL, EC_RETRY|EC_ABORT, rMountPath) )
+ return -1;
+ }
}
- Reference < XActiveDataSink > xSink = new ZipPackageSink;
- try
+ while ( aRC != FileBase::E_None );
+#ifdef UNX
+ do
{
- // Update our references to point to the new file
- if (pContent->openStream ( xSink ) )
- xContentStream = xSink->getInputStream();
- xContentSeek = Reference < XSeekable > (xContentStream, UNO_QUERY);
- pZipFile->setInputStream ( xContentStream );
+ aRC = aDevice.unmount();
+ if ( aRC != FileBase::E_None )
+ {
+ if ( ! HandleError ( osl_File_E_ACCES, EC_RETRY|EC_ABORT, rMountPath) )
+ return -1;
+ }
+ }
+ while ( aRC != FileBase::E_None );
+#endif
+
+ Any aExceptionAny, aMediumException;
+ InteractiveWrongMediumException aException;
+ aMediumException <<= nDiskNum;
+ aException.Medium = aMediumException;
+ aExceptionAny <<= aException;
+ if ( !HandleError ( aExceptionAny, EC_YES|EC_ABORT ) )
+ return -1;
+#ifdef UNX
+ do
+ {
+ aRC = aDevice.automount();
+
+ if ( aRC != FileBase::E_None )
+ {
+ if ( ! HandleError ( osl_File_E_ACCES, EC_RETRY|EC_ABORT, rURL ) )
+ return -1;
+ }
+ }
+ while ( aRC != FileBase::E_None );
+ OUString aNewMountPath ( aDevice.getMountPath() );
+
+ if (aNewMountPath != rMountPath)
+ rMountPath = aNewMountPath;
+#endif
+ return FileBase::E_None;
+}
+SegmentEnum ZipPackage::writeSegment ( const OUString &rFileName, OUString &rMountPath, Reference < XInputStream > &xInBuffer, Sequence < sal_Int8 > &rBuffer, sal_Bool bRetry, const sal_Int16 nDiskNum )
+{
+ File *pFile = NULL;
+ FileBase::RC aRC;
+ sal_Bool bDynamicSpan = nSegmentSize < 0;
+
+ sal_Int32 nRead = n_ConstBufferSize;
+ sal_uInt64 nLeft, nWritten;
+ VolumeInfo aInfo ( osl_VolumeInfo_Mask_FreeSpace | osl_VolumeInfo_Mask_DeviceHandle | osl_VolumeInfo_Mask_Attributes );
+
+ fprintf (stderr, "MTG: In writeSegment, disk num is %d, file is %s, dir is %s\n",
+ nDiskNum, ImplGetChars(rFileName), ImplGetChars(rMountPath));
+ do
+ {
+ aRC = Directory::getVolumeInfo ( rMountPath, aInfo );
+ fprintf(stderr, "MTG: getVolumeInfo returned %d\n", aRC );
+ if (aRC == FileBase::E_None )
+ {
+ sal_Bool bReCheck;
+ OUStringBuffer aBuffer;
+ aBuffer.append ( rMountPath );
+ if ( rMountPath.lastIndexOf ( '/' ) != rMountPath.getLength()-1 )
+ aBuffer.appendAscii ( "/" );
+ aBuffer.append ( rFileName );
+ OUString sFullPath ( aBuffer.makeStringAndClear() );
+ do
+ {
+ bReCheck = sal_False;
+ sal_uInt64 nFree = aInfo.getFreeSpace();
+ fprintf(stderr, "MTG: free is %d\n", nFree );
+ if (( bDynamicSpan && nFree < 1000) ||
+ !bDynamicSpan && nFree < nSegmentSize )
+ {
+ if ( !HandleError ( osl_File_E_NOSPC, EC_RETRY|EC_ABORT, sFullPath )
+ || RequestDisk ( rMountPath, nDiskNum ) < 0 )
+ {
+ if ( pFile )
+ delete pFile;
+ return e_Aborted;
+ }
+ else
+ {
+ aRC = Directory::getVolumeInfo ( rMountPath, aInfo );
+ bReCheck = sal_True;
+ }
+ }
+ else
+ {
+ nLeft = bDynamicSpan ? nFree : nSegmentSize;
+ fprintf(stderr, "MTG: left is %d\n", nLeft );
+ }
+ }
+ while ( bReCheck );
+
+ fprintf( stderr, "MTG: sDirectoryName is %s sFileName is %s FullPath is %s\n",
+ ImplGetChars ( rMountPath ), ImplGetChars ( rFileName ), ImplGetChars ( sFullPath ) );
+ pFile = new File ( sFullPath );
+ aRC = pFile->open ( osl_File_OpenFlag_Create | osl_File_OpenFlag_Write );
+ if ( aRC == FileBase::E_EXIST )
+ aRC = pFile->open ( osl_File_OpenFlag_Write );
+ if ( aRC != FileBase::E_None )
+ {
+ if ( ! HandleError ( (oslFileError) aRC, EC_RETRY|EC_ABORT, sFullPath ) )
+ {
+ delete pFile;
+ return e_Aborted;
+ }
+ }
+ }
+ fprintf(stderr, "MTG: file open returned %d\n", aRC );
}
- catch (com::sun::star::uno::Exception& r)
+ while (aRC != FileBase::E_None );
+
+ // Now! We should have an open file on a disk which has at least nSegmentSize if not
+ // dynamic spanning and 1000 bytes if dynamic spanning.
+
+
+ /*
+ if ( rOffset )
+ {
+ sal_uInt64 nLeft = rBuffer.getLength() - rOffset;
+ sal_uInt64 nToWrite = (nSegmentSize - nTotalWritten ) > nLeft ? nLeft : nSegmentSize - nTotalWritten;
+ aRC = aFile.write ( rBuffer.getConstArray() + rOffset, nToWrite, nWritten );
+ VOS_ENSURE ( aRC == FileBase::E_None, "Unable to write to file!");
+ nTotalWritten += nWritten;
+ if ( nWritten != nToWrite )
+ {
+ rOffset += nWritten;
+ // Need an interaction handler!
+ }
+ }
+ */
+
+ // Let's read it all into the buffer in case something goes wrong and also
+ // so that the spannable checks in ByteChucker and ZipOutputStream work
+
+ if (!bRetry)
+ nRead = xInBuffer->readBytes ( rBuffer, static_cast < sal_Int32 > ( nLeft ) );
+
+ aRC = pFile->write ( rBuffer.getConstArray(), nRead, nWritten );
+ fprintf ( stderr, "MTG: write returned %d\n", aRC );
+
+ if ( nWritten != nRead || aRC != FileBase::E_None )
+ bRetry = sal_True;
+ else
{
- throw WrappedTargetException( OUString::createFromAscii( "Unable to read Zip File content!" ),
- static_cast < OWeakObject * > ( this ), makeAny( r ) );
+ aRC = pFile->close ();
+ fprintf ( stderr, "MTG: close returned %d\n", aRC );
+ if ( aRC != FileBase::E_None )
+ bRetry = sal_True;
}
+ delete pFile;
+ return bRetry ? e_Retry : e_Success;
}
sal_Bool SAL_CALL ZipPackage::hasPendingChanges( )
@@ -729,9 +1014,9 @@ void SAL_CALL ZipPackage::setPropertyValue( const OUString& aPropertyName, const
{
if (!( aValue >>= nSegmentSize ) )
throw IllegalArgumentException();
+ // always force the value back to 0 as this feature is not complete
+ nSegmentSize = 0;
}
- else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("HasEncryptedEntries") ) )
- throw IllegalArgumentException (); // This property is read-only
else
throw UnknownPropertyException();
}
@@ -772,3 +1057,109 @@ void SAL_CALL ZipPackage::removeVetoableChangeListener( const OUString& Property
throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
{
}
+void ZipPackage::getInteractionHandler()
+{
+ if ( ! xInteractionHandler.is() )
+ {
+ OUString sServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.InteractionHandler" ) );
+ xInteractionHandler = Reference < XInteractionHandler > ( xFactory->createInstance ( sServiceName ), UNO_QUERY );
+ }
+}
+
+IOErrorCode Impl_OSLFileErrorToUCBIoErrorCode ( oslFileError aRC )
+{
+ IOErrorCode eReturn = IOErrorCode_UNKNOWN;
+ switch ( aRC )
+ {
+ // open
+ case osl_File_E_NOMEM:// not enough memory for allocating structures <br>
+ eReturn = IOErrorCode_OUT_OF_MEMORY;
+ break;
+ case osl_File_E_NAMETOOLONG:// pathname was too long<br>
+ eReturn = IOErrorCode_NAME_TOO_LONG;
+ break;
+ case osl_File_E_NOENT:// No such file or directory<br>
+ eReturn = IOErrorCode_NOT_EXISTING;
+ break;
+ case osl_File_E_ACCES:// permission denied<P>
+ eReturn = IOErrorCode_ACCESS_DENIED;
+ break;
+ case osl_File_E_ISDIR:// Is a directory<p>
+ eReturn = IOErrorCode_INVALID_ACCESS;
+ break;
+ case osl_File_E_NOTDIR:// Not a directory<br>
+ eReturn = IOErrorCode_NO_DIRECTORY;
+ break;
+ case osl_File_E_NXIO:// No such device or address<br>
+ eReturn = IOErrorCode_INVALID_DEVICE;
+ break;
+ case osl_File_E_NODEV:// No such device<br>
+ eReturn = IOErrorCode_INVALID_DEVICE;
+ break;
+ case osl_File_E_ROFS:// Read-only file system<br>
+ eReturn = IOErrorCode_ACCESS_DENIED;
+ break;
+ case osl_File_E_FAULT:// Bad address<br>
+ eReturn = IOErrorCode_INVALID_DEVICE;
+ break;
+ case osl_File_E_LOOP:// Too many symbolic links encountered<br>
+ break;
+ case osl_File_E_MFILE:// too many open files used by the process<br>
+ break;
+ case osl_File_E_NFILE:// too many open files in the system<br>
+ break;
+ case osl_File_E_EXIST:// File exists<br>
+ eReturn = IOErrorCode_CANT_CREATE;
+ break;
+ case osl_File_E_MULTIHOP:// Multihop attempted<br>
+ break;
+ case osl_File_E_FBIG:// File too large<br>
+ eReturn = IOErrorCode_INVALID_LENGTH;
+ break;
+
+ // write
+ case osl_File_E_AGAIN:// Operation would block<br>
+ break;
+ case osl_File_E_NOLCK:// No record locks available<br>
+ break;
+ case osl_File_E_NOSPC:// No space left on device<br>
+ eReturn = IOErrorCode_OUT_OF_DISK_SPACE;
+ break;
+ case osl_File_E_INVAL:// the format of the parameters was not valid<p>
+ eReturn = IOErrorCode_INVALID_PARAMETER;
+ break;
+
+ // close
+ case osl_File_E_BADF:// Bad file<br>
+ eReturn = IOErrorCode_NO_FILE;
+ break;
+ case osl_File_E_INTR:// function call was interrupted<br>
+ eReturn = IOErrorCode_ABORT;
+ break;
+ case osl_File_E_NOLINK:// Link has been severed<br>
+ break;
+ case osl_File_E_IO:// I/O error<p>
+ eReturn = IOErrorCode_GENERAL;
+ break;
+ }
+ return eReturn;
+}
+
+sal_Bool ZipPackage::HandleError ( Any &rAny, sal_uInt16 eContinuations )
+{
+ InteractionRequest* pRequest;
+ Reference < XInteractionRequest > xRequest ( pRequest = new InteractionRequest ( rAny, eContinuations ));
+ xInteractionHandler->handle ( xRequest );
+ const sal_uInt16 nSelection = pRequest->getSelection();
+ return nSelection == EC_YES || nSelection == EC_RETRY;
+}
+
+sal_Bool ZipPackage::HandleError ( oslFileError aRC, sal_uInt16 eContinuations, OUString &rFileName )
+{
+ Any aAny;
+ InteractiveFileIOException aException;
+ aException.Code = Impl_OSLFileErrorToUCBIoErrorCode ( aRC );
+ aException.FileName = rFileName;
+ aAny <<= aException;
+ return HandleError (aAny, eContinuations );
+}
diff --git a/package/source/zippackage/ZipPackageBuffer.cxx b/package/source/zippackage/ZipPackageBuffer.cxx
index 743da4de0734..9742ec10f4f5 100644
--- a/package/source/zippackage/ZipPackageBuffer.cxx
+++ b/package/source/zippackage/ZipPackageBuffer.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageBuffer.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: mtg $ $Date: 2001-05-31 10:25:58 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -72,6 +72,13 @@ ZipPackageBuffer::ZipPackageBuffer(sal_Int64 nNewBufferSize )
, m_nEnd(0)
{
}
+ZipPackageBuffer::ZipPackageBuffer(Sequence < sal_Int8 > &nNewBuffer )
+: m_aBuffer ( nNewBuffer )
+, m_bMustInitBuffer ( sal_False )
+, m_nCurrent( 0 )
+, m_nEnd ( nNewBuffer.getLength() )
+{
+}
ZipPackageBuffer::~ZipPackageBuffer(void)
{
}
@@ -141,13 +148,14 @@ void SAL_CALL ZipPackageBuffer::closeInput( )
void SAL_CALL ZipPackageBuffer::writeBytes( const Sequence< sal_Int8 >& aData )
throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
{
- sal_Int64 nDataLen = aData.getLength();
+ sal_Int64 nDataLen = aData.getLength(), nCombined = m_nEnd + nDataLen;
const sal_Int8 *pData = aData.getConstArray();
- if (m_nEnd + nDataLen > m_nBufferSize)
+ if ( nCombined > m_nBufferSize)
{
- while (m_nEnd + nDataLen > m_nBufferSize)
+ do
m_nBufferSize *=2;
+ while (nCombined > m_nBufferSize);
m_aBuffer.realloc(static_cast < sal_Int32 > (m_nBufferSize));
m_bMustInitBuffer = sal_False;
}
diff --git a/package/source/zippackage/ZipPackageEntry.cxx b/package/source/zippackage/ZipPackageEntry.cxx
index ac7cdc09741c..964f51008131 100644
--- a/package/source/zippackage/ZipPackageEntry.cxx
+++ b/package/source/zippackage/ZipPackageEntry.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageEntry.cxx,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: mtg $ $Date: 2001-05-02 18:11:27 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,8 +61,8 @@
#ifndef _ZIP_PACKAGE_ENTRY_HXX
#include <ZipPackageEntry.hxx>
#endif
-#ifndef _COM_SUN_STAR_PACKAGE_ZIPCONSTANTS_HPP_
-#include <com/sun/star/packages/ZipConstants.hpp>
+#ifndef _COM_SUN_STAR_PACKAGE_ZIP_ZIPCONSTANTS_HPP_
+#include <com/sun/star/packages/zip/ZipConstants.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
#include <com/sun/star/container/XNameContainer.hpp>
@@ -70,13 +70,17 @@
#ifndef _VOS_DIAGNOSE_H_
#include <vos/diagnose.hxx>
#endif
+#ifndef _IMPL_VALID_CHARACTERS_HXX_
+#include <ImplValidCharacters.hxx>
+#endif
+using namespace rtl;
using namespace com::sun::star;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::container;
-using namespace com::sun::star::packages::ZipConstants;
-using namespace rtl;
+using namespace com::sun::star::packages::zip;
+using namespace com::sun::star::packages::zip::ZipConstants;
ZipPackageEntry::ZipPackageEntry (void)
{
@@ -124,6 +128,10 @@ void SAL_CALL ZipPackageEntry::setName( const OUString& aName )
if (xCont.is() && xCont->hasByName ( aEntry.sName ) )
xCont->removeByName ( aEntry.sName );
+ const sal_Unicode *pChar = aName.getStr();
+ for ( sal_Int32 i = 0, nEnd = aName.getLength(); i < nEnd; i++)
+ VOS_ENSURE ( Impl_IsValidChar (pChar[i], sal_False), "Invalid character in new zip package entry name!");
+
aEntry.sName = aName;
if (xCont.is())
diff --git a/package/source/zippackage/ZipPackageEntry.hxx b/package/source/zippackage/ZipPackageEntry.hxx
index ef2e41bec7d5..929ce71c088a 100644
--- a/package/source/zippackage/ZipPackageEntry.hxx
+++ b/package/source/zippackage/ZipPackageEntry.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageEntry.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: mtg $ $Date: 2001-04-27 14:56:07 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,8 +67,8 @@
#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
#include <com/sun/star/container/XChild.hpp>
#endif
-#ifndef _COM_SUN_STAR_PACKAGE_ZIPENTRY_HPP_
-#include <com/sun/star/packages/ZipEntry.hpp>
+#ifndef _COM_SUN_STAR_PACKAGE_ZIP_ZIPENTRY_HPP_
+#include <com/sun/star/packages/zip/ZipEntry.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
#include <com/sun/star/container/XNamed.hpp>
@@ -89,7 +89,7 @@ protected:
com::sun::star::uno::Reference < com::sun::star::uno::XInterface > xParent;
::rtl::OUString sMediaType;
public:
- com::sun::star::packages::ZipEntry aEntry;
+ com::sun::star::packages::zip::ZipEntry aEntry;
::rtl::OUString & GetMediaType () { return sMediaType; }
void SetMediaType ( ::rtl::OUString & sNewType) { sMediaType = sNewType; }
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index fe61ee917fc4..b826772386ef 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageFolder.cxx,v $
*
- * $Revision: 1.44 $
+ * $Revision: 1.45 $
*
- * last change: $Author: mtg $ $Date: 2001-06-22 11:48:03 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -76,8 +76,8 @@
#ifndef _ZIP_PACKAGE_FOLDER_ENUMERATION_HXX
#include <ZipPackageFolderEnumeration.hxx>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
-#include <com/sun/star/packages/ZipConstants.hpp>
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPCONSTANTS_HPP_
+#include <com/sun/star/packages/zip/ZipConstants.hpp>
#endif
#ifndef _VOS_DIAGNOSE_H_
#include <vos/diagnose.hxx>
@@ -92,7 +92,8 @@
#include <rtl/digest.h>
#endif
-using namespace com::sun::star::packages::ZipConstants;
+using namespace com::sun::star::packages::zip::ZipConstants;
+using namespace com::sun::star::packages::zip;
using namespace com::sun::star::container;
using namespace com::sun::star::packages;
using namespace com::sun::star::beans;
@@ -207,7 +208,7 @@ void SAL_CALL ZipPackageFolder::removeByName( const OUString& Name )
sName = Name.copy(1, Name.getLength());
else
sName = Name;
- if (!aContents.count(sName))
+ if (aContents.find(sName) == aContents.end())
throw NoSuchElementException();
aContents.erase(sName);
}
@@ -251,7 +252,9 @@ Sequence< OUString > SAL_CALL ZipPackageFolder::getElementNames( )
{
sal_uInt32 i=0, nSize = aContents.size();
OUString *pNames = new OUString[nSize];
- for (TunnelHash::const_iterator aIterator = aContents.begin() ; aIterator != aContents.end(); i++,aIterator++)
+ for ( TunnelHash::const_iterator aIterator = aContents.begin(), aEnd = aContents.end();
+ aIterator != aEnd;
+ i++,aIterator++)
pNames[i] = (*aIterator).first;
return Sequence < OUString > (pNames, nSize);
}
@@ -263,7 +266,7 @@ sal_Bool SAL_CALL ZipPackageFolder::hasByName( const OUString& aName )
sName = aName.copy(1, aName.getLength());
else
sName = aName;
- return aContents.count(sName);
+ return aContents.find(sName) != aContents.end();
}
// XNameReplace
void SAL_CALL ZipPackageFolder::replaceByName( const OUString& aName, const Any& aElement )
@@ -286,7 +289,6 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
Reference < XUnoTunnel > xTunnel;
ZipPackageFolder *pFolder = NULL;
ZipPackageStream *pStream = NULL;
- TunnelHash::const_iterator aCI = aContents.begin(), aEnd = aContents.end();
const OUString sMediaTypeProperty ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
const OUString sFullPathProperty ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
const OUString sInitialisationVectorProperty ( RTL_CONSTASCII_USTRINGPARAM ( "InitialisationVector" ) );
@@ -302,15 +304,18 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
rtlRandomPool aRandomPool = rtl_random_createPool ();
rtl_random_addBytes ( aRandomPool, &aTime, 8 );
- for (; aCI!=aEnd ; aCI++)
+ for ( TunnelHash::const_iterator aCI = aContents.begin(), aEnd = aContents.end();
+ aCI != aEnd;
+ aCI++)
{
// pTempEntry is stored in a vector by ZipOutputStream and will
// be deleted by the ZipOutputStream destructor
ZipEntry * pTempEntry = new ZipEntry;
-
+ const OUString &rShortName = (*aCI).first;
xTunnel = Reference < XUnoTunnel> ((*aCI).second, UNO_QUERY);
sal_Int64 nTest = 0;
Sequence < PropertyValue > aPropSet (2);
+ PropertyValue *pValue = aPropSet.getArray();
pFolder = NULL;
pStream = NULL;
sal_Bool bIsFolder = sal_True;
@@ -335,11 +340,9 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
// store the ZipEntry data in pTempEntry
ZipPackageFolder::copyZipEntry ( *pTempEntry, pFolder->aEntry );
pTempEntry->nTime = ZipOutputStream::getCurrentDosTime();
- pTempEntry->nCrc = 0;
- pTempEntry->nSize = 0;
- pTempEntry->nCompressedSize = 0;
+ pTempEntry->nCrc = pTempEntry->nSize = pTempEntry->nCompressedSize = 0;
pTempEntry->nMethod = STORED;
- pTempEntry->sName = rPath + (*aCI).first + OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
+ pTempEntry->sName = rPath + rShortName + OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
try
{
vos::ORef < EncryptionData > xEmpty;
@@ -351,17 +354,17 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
}
- aPropSet[0].Name = sMediaTypeProperty;
- aPropSet[0].Value <<= pFolder->GetMediaType();
- aPropSet[1].Name = sFullPathProperty;
- aPropSet[1].Value <<= pTempEntry->sName;
+ pValue[0].Name = sMediaTypeProperty;
+ pValue[0].Value <<= pFolder->GetMediaType();
+ pValue[1].Name = sFullPathProperty;
+ pValue[1].Value <<= pTempEntry->sName;
// Copy back the zip entry and make the offset negative so that we
// know it's point at the beginning of the LOC
ZipPackageFolder::copyZipEntry ( pFolder->aEntry, *pTempEntry );
pFolder->aEntry.nOffset *= -1;
pFolder->saveContents(pTempEntry->sName, rManList, rZipOut, rEncryptionKey);
- pFolder->aEntry.sName = (*aCI).first;
+ pFolder->aEntry.sName = rShortName;
}
else
{
@@ -369,15 +372,15 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
// store the ZipEntry data in pTempEntry
ZipPackageFolder::copyZipEntry ( *pTempEntry, pStream->aEntry );
- pTempEntry->sName = rPath + (*aCI).first;
+ pTempEntry->sName = rPath + rShortName;
sal_Bool bToBeEncrypted = pStream->IsToBeEncrypted() && bHaveEncryptionKey;
sal_Bool bToBeCompressed = bToBeEncrypted ? sal_True : pStream->IsToBeCompressed();
- aPropSet[0].Name = sMediaTypeProperty;
- aPropSet[0].Value <<= pStream->GetMediaType( );
- aPropSet[1].Name = sFullPathProperty;
- aPropSet[1].Value <<= pTempEntry->sName;
+ pValue[0].Name = sMediaTypeProperty;
+ pValue[0].Value <<= pStream->GetMediaType( );
+ pValue[1].Name = sFullPathProperty;
+ pValue[1].Value <<= pTempEntry->sName;
if ( bToBeEncrypted )
{
@@ -397,12 +400,13 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
pStream->setKey ( aKey );
aPropSet.realloc(6); // 6th property is size, below
- aPropSet[2].Name = sInitialisationVectorProperty;
- aPropSet[2].Value <<= aVector;
- aPropSet[3].Name = sSaltProperty;
- aPropSet[3].Value <<= aSalt;
- aPropSet[4].Name = sIterationCountProperty;
- aPropSet[4].Value <<= nIterationCount;
+ pValue = aPropSet.getArray();
+ pValue[2].Name = sInitialisationVectorProperty;
+ pValue[2].Value <<= aVector;
+ pValue[3].Name = sSaltProperty;
+ pValue[3].Value <<= aSalt;
+ pValue[4].Name = sIterationCountProperty;
+ pValue[4].Value <<= nIterationCount;
}
// If the entry is already stored in the zip file in the format we
@@ -414,22 +418,19 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
try
{
Reference < XInputStream > xStream = pStream->getRawStream();
- try
- {
- rZipOut.putNextEntry ( *pTempEntry, pStream->getEncryptionData(), bToBeEncrypted);
- Sequence < sal_Int8 > aSeq (n_ConstBufferSize);
- sal_Int32 nLength = n_ConstBufferSize;
- while ( nLength >= n_ConstBufferSize )
- {
- nLength = xStream->readBytes(aSeq, n_ConstBufferSize);
- rZipOut.rawWrite(aSeq, 0, nLength);
- }
- rZipOut.rawCloseEntry();
- }
- catch (ZipException&)
+ rZipOut.putNextEntry ( *pTempEntry, pStream->getEncryptionData(), bToBeEncrypted);
+ Sequence < sal_Int8 > aSeq (n_ConstBufferSize);
+ sal_Int32 nLength = n_ConstBufferSize;
+ while ( nLength >= n_ConstBufferSize )
{
- VOS_ENSURE( 0, "Error writing ZipOutputStream" );
+ nLength = xStream->readBytes(aSeq, n_ConstBufferSize);
+ rZipOut.rawWrite(aSeq, 0, nLength);
}
+ rZipOut.rawCloseEntry();
+ }
+ catch (ZipException&)
+ {
+ VOS_ENSURE( 0, "Error writing ZipOutputStream" );
}
catch (IOException & )
{
@@ -444,7 +445,6 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
VOS_ENSURE ( 0, "Bad juju! We can only package streams which support XSeekable!");
sal_Int32 nStreamLength = static_cast < sal_Int32 > ( xSeek->getLength() );
-
if ( bToBeCompressed )
{
pTempEntry->nMethod = DEFLATED;
@@ -462,8 +462,8 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
if (bToBeEncrypted)
{
// Need to store the uncompressed size in the manifest
- aPropSet[5].Name = sSizeProperty;
- aPropSet[5].Value <<= nStreamLength;
+ pValue[5].Name = sSizeProperty;
+ pValue[5].Value <<= nStreamLength;
}
try
@@ -479,6 +479,10 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
pStream->SetPackageMember ( sal_True );
rZipOut.closeEntry();
}
+ catch (ZipException&)
+ {
+ VOS_ENSURE( 0, "Error writing ZipOutputStream" );
+ }
catch (IOException & )
{
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
@@ -487,7 +491,7 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
// Then copy it back afterwards...
ZipPackageFolder::copyZipEntry ( pStream->aEntry, *pTempEntry );
- pStream->aEntry.sName = (*aCI).first;
+ pStream->aEntry.sName = rShortName;
pStream->aEntry.nOffset *= -1;
}
rManList.push_back (aPropSet);
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 4e5986977830..4a06b8f820c5 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageStream.cxx,v $
*
- * $Revision: 1.22 $
+ * $Revision: 1.23 $
*
- * last change: $Author: mtg $ $Date: 2001-06-22 11:46:49 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,11 +71,12 @@
#ifndef _VOS_DIAGNOSE_H_
#include <vos/diagnose.hxx>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
-#include <com/sun/star/packages/ZipConstants.hpp>
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPCONSTANTS_HPP_
+#include <com/sun/star/packages/zip/ZipConstants.hpp>
#endif
-using namespace com::sun::star::packages::ZipConstants;
+using namespace com::sun::star::packages::zip::ZipConstants;
+using namespace com::sun::star::packages::zip;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star;
@@ -103,7 +104,7 @@ ZipPackageStream::~ZipPackageStream( void )
{
}
-void ZipPackageStream::setZipEntry( const packages::ZipEntry &rInEntry)
+void ZipPackageStream::setZipEntry( const ZipEntry &rInEntry)
{
aEntry.nVersion = rInEntry.nVersion;
aEntry.nFlag = rInEntry.nFlag;
@@ -165,7 +166,7 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawStream( )
xEncryptionData->aKey = rZipPackage.getEncryptionKey();
return rZipPackage.getZipFile().getRawStream(aEntry, xEncryptionData);
}
- catch (packages::ZipException &)//rException)
+ catch (ZipException &)//rException)
{
VOS_ENSURE( 0, "ZipException thrown");//rException.Message);
return Reference < io::XInputStream > ();
@@ -185,7 +186,7 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getInputStream( )
xEncryptionData->aKey = rZipPackage.getEncryptionKey();
return rZipPackage.getZipFile().getInputStream( aEntry, xEncryptionData);
}
- catch (packages::ZipException &)//rException)
+ catch (ZipException &)//rException)
{
VOS_ENSURE( 0,"ZipException thrown");//rException.Message);
return Reference < io::XInputStream > ();
diff --git a/package/source/zippackage/ZipPackageStream.hxx b/package/source/zippackage/ZipPackageStream.hxx
index cea64b30fc06..50a3e8652f98 100644
--- a/package/source/zippackage/ZipPackageStream.hxx
+++ b/package/source/zippackage/ZipPackageStream.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageStream.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: mtg $ $Date: 2001-05-17 16:17:06 $
+ * last change: $Author: mtg $ $Date: 2001-07-04 14:56:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,8 +64,8 @@
#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
#include <com/sun/star/io/XActiveDataSink.hpp>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPENTRY_HPP_
-#include <com/sun/star/packages/ZipEntry.hpp>
+#ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPENTRY_HPP_
+#include <com/sun/star/packages/zip/ZipEntry.hpp>
#endif
#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
#include <cppuhelper/typeprovider.hxx>
@@ -123,7 +123,7 @@ public:
ZipPackageStream (ZipPackage & rNewPackage);
virtual ~ZipPackageStream( void );
- void setZipEntry( const com::sun::star::packages::ZipEntry &rInEntry);
+ void setZipEntry( const com::sun::star::packages::zip::ZipEntry &rInEntry);
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawStream( )
throw(::com::sun::star::uno::RuntimeException);
diff --git a/package/source/zippackage/makefile.mk b/package/source/zippackage/makefile.mk
index a748b93c95e2..b04c3ba5c7fb 100644
--- a/package/source/zippackage/makefile.mk
+++ b/package/source/zippackage/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.14 $
+# $Revision: 1.15 $
#
-# last change: $Author: mtg $ $Date: 2001-05-31 10:28:09 $
+# last change: $Author: mtg $ $Date: 2001-07-04 14:56:37 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -84,20 +84,26 @@ SLOFILES= \
$(SLO)$/ZipPackageSink.obj \
$(SLO)$/ZipPackageStream.obj \
$(SLO)$/OutputThread.obj \
- $(SLO)$/ThreadedBuffer.obj
+ $(SLO)$/ThreadedBuffer.obj \
+ $(SLO)$/InteractionRequest.obj \
+ $(SLO)$/InteractionContinuation.obj
+
# --- UNO stuff ---------------------------------------------------
CPPUMAKERFLAGS=
-#UNOUCROUT=$(OUT)$/inc
-#INCPRE+=$(UNOUCROUT)
+UNOUCROUT=$(OUT)$/inc
+INCPRE+=$(UNOUCROUT)
UNOUCRDEP= $(SOLARBINDIR)$/offapi.rdb
UNOUCRRDB= $(SOLARBINDIR)$/offapi.rdb
UNOTYPES=\
com.sun.star.packages.manifest.XManifestReader \
- com.sun.star.packages.manifest.XManifestWriter
+ com.sun.star.packages.manifest.XManifestWriter \
+ com.sun.star.packages.zip.ZipEntry \
+ com.sun.star.packages.zip.ZipConstants \
+ com.sun.star.packages.zip.ZipException
# --- Targets ------------------------------------------------------