summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package/dtd/Manifest.dtd11
-rw-r--r--package/inc/ByteChucker.hxx20
-rw-r--r--package/inc/ByteGrabber.hxx22
-rw-r--r--package/inc/CRC32.hxx26
-rw-r--r--package/inc/Deflater.hxx50
-rw-r--r--package/inc/Inflater.hxx52
-rw-r--r--package/inc/ZipFile.hxx65
-rw-r--r--package/inc/ZipOutputStream.hxx65
-rw-r--r--package/inc/ZipPackage.hxx33
-rw-r--r--package/inc/ZipPackageBuffer.hxx6
-rw-r--r--package/inc/ZipPackageFolder.hxx21
-rw-r--r--package/source/manifest/ManifestDefines.hxx9
-rw-r--r--package/source/manifest/ManifestExport.cxx83
-rw-r--r--package/source/manifest/ManifestImport.cxx71
-rw-r--r--package/source/manifest/ManifestImport.hxx15
-rw-r--r--package/source/manifest/ManifestReader.cxx5
-rw-r--r--package/source/manifest/makefile.mk5
-rw-r--r--package/source/zipapi/EntryInputStream.cxx96
-rw-r--r--package/source/zipapi/EntryInputStream.hxx30
-rw-r--r--package/source/zipapi/Inflater.cxx39
-rw-r--r--package/source/zipapi/ZipEnumeration.cxx22
-rw-r--r--package/source/zipapi/ZipFile.cxx175
-rw-r--r--package/source/zipapi/ZipOutputStream.cxx135
-rw-r--r--package/source/zipapi/makefile.mk18
-rw-r--r--package/source/zippackage/ZipPackage.cxx158
-rw-r--r--package/source/zippackage/ZipPackageEntry.cxx58
-rw-r--r--package/source/zippackage/ZipPackageEntry.hxx14
-rw-r--r--package/source/zippackage/ZipPackageFolder.cxx194
-rw-r--r--package/source/zippackage/ZipPackageFolderEnumeration.hxx6
-rw-r--r--package/source/zippackage/ZipPackageSink.hxx6
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx130
-rw-r--r--package/source/zippackage/ZipPackageStream.hxx49
-rw-r--r--package/util/makefile.mk6
33 files changed, 1009 insertions, 686 deletions
diff --git a/package/dtd/Manifest.dtd b/package/dtd/Manifest.dtd
index 087c8441b61a..a55dd7169ed9 100644
--- a/package/dtd/Manifest.dtd
+++ b/package/dtd/Manifest.dtd
@@ -1,5 +1,5 @@
<!--
- $Id: Manifest.dtd,v 1.5 2001-03-19 12:27:07 mtg Exp $
+ $Id: Manifest.dtd,v 1.6 2001-04-27 14:56:04 mtg Exp $
The Contents of this file are made available subject to the terms of
either of the following licenses
@@ -54,8 +54,15 @@
-->
<!ELEMENT manifest:manifest (manifest:file-entry+)>
<!ATTLIST manifest:manifest xmlns:manifest CDATA #FIXED "http://openoffice.org/2001/manifest">
-<!ELEMENT manifest:file-entry EMPTY>
+<!ELEMENT manifest:file-entry (manifest:encryption-data?)>
<!ATTLIST manifest:file-entry
manifest:full-path CDATA #REQUIRED
manifest:media-type CDATA #REQUIRED
>
+<!ELEMENT manifest:encryption-data (manifest:initialisation-vector?)>
+<!ATTLIST manifest:encryption-data
+ manifest:algorithm CDATA #REQUIRED
+ manifest:salt CDATA #REQUIRED
+ manifest:iteration-count CDATA #REQUIRED>
+<!-- the initialisation-vector should be base-64 encoded -->
+<!ELEMENT manifest:initialisation-vector (#PCDATA)>
diff --git a/package/inc/ByteChucker.hxx b/package/inc/ByteChucker.hxx
index 8e1a0699fba5..895317d5b0e4 100644
--- a/package/inc/ByteChucker.hxx
+++ b/package/inc/ByteChucker.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ByteChucker.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:11:06 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,27 +70,27 @@
class ByteChucker
{
-private:
+protected:
com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > xStream;
com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
public:
ByteChucker (com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> xOstream);
- virtual ~ByteChucker();
+ ~ByteChucker();
// XOutputStream
- virtual 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 )
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 flush( )
+ 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);
- virtual void SAL_CALL closeOutput( )
+ void SAL_CALL closeOutput( )
throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
// XSeekable
- virtual sal_Int64 SAL_CALL seek( sal_Int64 location )
+ sal_Int64 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( )
+ sal_Int64 SAL_CALL getPosition( )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Int64 SAL_CALL getLength( )
+ sal_Int64 SAL_CALL getLength( )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
ByteChucker& operator << (sal_Int8 nInt8);
diff --git a/package/inc/ByteGrabber.hxx b/package/inc/ByteGrabber.hxx
index 3496cb7210a6..1c2f15ca5664 100644
--- a/package/inc/ByteGrabber.hxx
+++ b/package/inc/ByteGrabber.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ByteGrabber.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:11:06 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,7 +70,7 @@
class ByteGrabber
{
-private:
+protected:
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
public:
@@ -79,22 +79,22 @@ public:
void setInputStream (com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewStream);
// XInputStream
- virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
+ 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 )
+ 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 )
+ 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( )
+ 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( )
+ void SAL_CALL closeInput( )
throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
// XSeekable
- virtual sal_Int64 SAL_CALL seek( sal_Int64 location )
+ sal_Int64 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( )
+ sal_Int64 SAL_CALL getPosition( )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Int64 SAL_CALL getLength( )
+ sal_Int64 SAL_CALL getLength( )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
ByteGrabber& operator >> (sal_Int8& rInt8);
diff --git a/package/inc/CRC32.hxx b/package/inc/CRC32.hxx
index 8ca85ffe6189..f92a16a3cc45 100644
--- a/package/inc/CRC32.hxx
+++ b/package/inc/CRC32.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: CRC32.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:11:06 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,29 +61,29 @@
#ifndef _CRC32_HXX
#define _CRC32_HXX
-#ifndef _CPPUHELPER_IMPLBASE1_HXX_
-#include <cppuhelper/implbase1.hxx>
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
+#include <com/sun/star/uno/Sequence.h>
#endif
-#ifndef _COM_SUN_STAR_PACKAGE_XCHECKSUM_HPP_
-#include <com/sun/star/packages/XChecksum.hpp>
+#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HDL_
+#include <com/sun/star/uno/RuntimeException.hdl>
#endif
-class CRC32 : public cppu::WeakImplHelper1<com::sun::star::packages::XChecksum>
+class CRC32
{
private:
sal_uInt32 nCRC;
public:
CRC32();
- virtual ~CRC32();
- virtual void SAL_CALL updateByte (sal_Int8 nByte)
+ ~CRC32();
+ void SAL_CALL updateByte (sal_Int8 nByte)
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL updateSegment(const ::com::sun::star::uno::Sequence< sal_Int8 > &b, sal_Int32 off, sal_Int32 len)
+ void SAL_CALL updateSegment(const ::com::sun::star::uno::Sequence< sal_Int8 > &b, sal_Int32 off, sal_Int32 len)
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL update(const ::com::sun::star::uno::Sequence< sal_Int8 > &b)
+ void SAL_CALL update(const ::com::sun::star::uno::Sequence< sal_Int8 > &b)
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getValue()
+ sal_Int32 SAL_CALL getValue()
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL reset()
+ void SAL_CALL reset()
throw(::com::sun::star::uno::RuntimeException);
};
diff --git a/package/inc/Deflater.hxx b/package/inc/Deflater.hxx
index 5a0259056e31..7d787478ca53 100644
--- a/package/inc/Deflater.hxx
+++ b/package/inc/Deflater.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Deflater.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:11:06 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,21 +61,21 @@
#ifndef _DEFLATER_HXX_
#define _DEFLATER_HXX_
-#ifndef _COM_SUN_STAR_PACKAGE_XDEFLATER_HDL_
-#include <com/sun/star/packages/XDeflater.hpp>
+
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
#endif
-#ifndef _CPPUHELPER_IMPLBASE1_HXX_
-#include <cppuhelper/implbase1.hxx>
+#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HDL_
+#include <com/sun/star/uno/RuntimeException.hdl>
#endif
-
extern "C"
{
typedef struct z_stream_s z_stream;;
};
-class Deflater : public cppu::WeakImplHelper1 < com::sun::star::packages::XDeflater>
+class Deflater
{
-private:
+protected:
com::sun::star::uno::Sequence< sal_Int8 > sInBuffer;
sal_Bool bFinish;
sal_Bool bFinished;
@@ -92,37 +92,37 @@ public:
~Deflater();
Deflater(sal_Int32 nSetLevel);
Deflater(sal_Int32 nSetLevel, sal_Bool bNowrap);
- virtual void SAL_CALL setInputSegment( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+ void SAL_CALL setInputSegment( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setInput( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
+ void SAL_CALL setInput( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setDictionarySegment( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+ void SAL_CALL setDictionarySegment( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setDictionary( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
+ void SAL_CALL setDictionary( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setStrategy( sal_Int32 nNewStrategy )
+ void SAL_CALL setStrategy( sal_Int32 nNewStrategy )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setLevel( sal_Int32 nNewLevel )
+ void SAL_CALL setLevel( sal_Int32 nNewLevel )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL needsInput( )
+ sal_Bool SAL_CALL needsInput( )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL finish( )
+ void SAL_CALL finish( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL finished( )
+ sal_Bool SAL_CALL finished( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL doDeflateSegment( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+ sal_Int32 SAL_CALL doDeflateSegment( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL doDeflate( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
+ sal_Int32 SAL_CALL doDeflate( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getAdler( )
+ sal_Int32 SAL_CALL getAdler( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getTotalIn( )
+ sal_Int32 SAL_CALL getTotalIn( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getTotalOut( )
+ sal_Int32 SAL_CALL getTotalOut( )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL reset( )
+ void SAL_CALL reset( )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL end( )
+ void SAL_CALL end( )
throw(::com::sun::star::uno::RuntimeException);
};
diff --git a/package/inc/Inflater.hxx b/package/inc/Inflater.hxx
index b9b21eeb71e5..92d24dad83c5 100644
--- a/package/inc/Inflater.hxx
+++ b/package/inc/Inflater.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Inflater.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:11:06 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,20 +61,20 @@
#ifndef _INFLATER_HXX_
#define _INFLATER_HXX_
-#ifndef _COM_SUN_STAR_PACKAGE_XINFLATER_HDL_
-#include <com/sun/star/packages/XInflater.hpp>
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
#endif
-#ifndef _CPPUHELPER_IMPLBASE1_HXX_
-#include <cppuhelper/implbase1.hxx>
+#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HDL_
+#include <com/sun/star/uno/RuntimeException.hdl>
#endif
extern "C"
{
typedef struct z_stream_s z_stream;
}
-class Inflater : public cppu::WeakImplHelper1 < com::sun::star::packages::XInflater>
+class Inflater
{
-private:
+protected:
sal_Bool bFinish;
sal_Bool bFinished;
sal_Bool bSetParams;
@@ -82,44 +82,42 @@ private:
sal_Int32 nOffset, nLength;
z_stream* pStream;
com::sun::star::uno::Sequence < sal_Int8 > sInBuffer;
- void init (sal_Bool bNowrap);
sal_Int32 doInflateBytes (com::sun::star::uno::Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength);
public:
- Inflater(sal_Bool bNoWrap);
- Inflater();
+ Inflater(sal_Bool bNoWrap = sal_False);
~Inflater();
- virtual void SAL_CALL setInputSegment( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+ void SAL_CALL setInputSegment( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setInput( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
+ void SAL_CALL setInput( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setDictionarySegment( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+ void SAL_CALL setDictionarySegment( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setDictionary( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
+ void SAL_CALL setDictionary( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getRemaining( )
+ sal_Int32 SAL_CALL getRemaining( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL needsInput( )
+ sal_Bool SAL_CALL needsInput( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL needsDictionary( )
+ sal_Bool SAL_CALL needsDictionary( )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL finish( )
+ void SAL_CALL finish( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL finished( )
+ sal_Bool SAL_CALL finished( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL doInflateSegment( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+ sal_Int32 SAL_CALL doInflateSegment( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL doInflate( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
+ sal_Int32 SAL_CALL doInflate( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getAdler( )
+ sal_Int32 SAL_CALL getAdler( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getTotalIn( )
+ sal_Int32 SAL_CALL getTotalIn( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getTotalOut( )
+ sal_Int32 SAL_CALL getTotalOut( )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL reset( )
+ void SAL_CALL reset( )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL end( )
+ void SAL_CALL end( )
throw(::com::sun::star::uno::RuntimeException);
};
diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx
index 2db761a41edb..b09f683a1910 100644
--- a/package/inc/ZipFile.hxx
+++ b/package/inc/ZipFile.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipFile.hxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:11:06 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,12 +61,6 @@
#ifndef _ZIP_FILE_HXX
#define _ZIP_FILE_HXX
-#ifndef _COM_SUN_STAR_PACKAGE_XZIPFILE_HPP_
-#include <com/sun/star/packages/XZipFile.hpp>
-#endif
-#ifndef _CPPUHELPER_IMPLBASE1_HXX_
-#include <cppuhelper/implbase1.hxx> // helper for implementations
-#endif
#ifndef _BYTE_GRABBER_HXX_
#include <ByteGrabber.hxx>
#endif
@@ -76,18 +70,32 @@
#ifndef _INFLATER_HXX
#include <Inflater.hxx>
#endif
-
+#ifndef _COM_SUN_STAR_PACKAGES_ZIPEXCEPTION_HPP_
+#include <com/sun/star/packages/ZipException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_NOSUCHELEMENTEXCEPTION_HPP_
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_WRAPPEDTARGETEXCEPTION_HPP_
+#include <com/sun/star/lang/WrappedTargetException.hpp>
+#endif
+#ifndef _VOS_REF_H_
+#include <vos/ref.hxx>
+#endif
/*
* We impose arbitrary but reasonable limit on ZIP files.
*/
+
#define ZIP_MAXNAMELEN 512
#define ZIP_MAXEXTRA 256
#define ZIP_MAXENTRIES (0x10000 - 2)
-class ZipFile : public cppu::WeakImplHelper1<
- com::sun::star::packages::XZipFile>
+class ZipEnumeration;
+class EncryptionData;
+
+class ZipFile
{
-private:
+protected:
::rtl::OUString sName; /* zip file name */
::rtl::OUString sComment; /* zip file comment */
EntryHash aEntries;
@@ -100,39 +108,40 @@ public:
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);
- virtual ~ZipFile();
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawStream( const ::com::sun::star::packages::ZipEntry& rEntry )
+ ~ZipFile();
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawStream(
+ ::com::sun::star::packages::ZipEntry& rEntry,
+ const vos::ORef < EncryptionData > &rData)
throw(::com::sun::star::io::IOException, ::com::sun::star::packages::ZipException, ::com::sun::star::uno::RuntimeException);
// XElementAccess
- virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
+ ::com::sun::star::uno::Type SAL_CALL getElementType( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL hasElements( )
+ sal_Bool SAL_CALL hasElements( )
throw(::com::sun::star::uno::RuntimeException);
// XZipFile
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( const ::com::sun::star::packages::ZipEntry& rEntry )
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(
+ ::com::sun::star::packages::ZipEntry& rEntry,
+ const vos::ORef < EncryptionData > &rData)
throw(::com::sun::star::io::IOException, ::com::sun::star::packages::ZipException, ::com::sun::star::uno::RuntimeException);
- virtual ::rtl::OUString SAL_CALL getName( )
+ ::rtl::OUString SAL_CALL getName( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getSize( )
+ sal_Int32 SAL_CALL getSize( )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL close( )
+ void SAL_CALL close( )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
// XNameAccess
- virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
+ ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( )
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( )
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
+ sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
throw(::com::sun::star::uno::RuntimeException);
- // XEnumerationAccess (except called with entries instead of
- // createEnumeration
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL entries( )
- throw(::com::sun::star::uno::RuntimeException);
+ ZipEnumeration * SAL_CALL entries( );
private:
- sal_Bool readLOC(const com::sun::star::packages::ZipEntry &rEntry)
+ 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);
sal_Int32 readCEN()
throw(::com::sun::star::io::IOException, com::sun::star::packages::ZipException, com::sun::star::uno::RuntimeException);
diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx
index f95299d791c7..75029ebdcd0e 100644
--- a/package/inc/ZipOutputStream.hxx
+++ b/package/inc/ZipOutputStream.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipOutputStream.hxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:11:06 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,64 +70,71 @@
#ifndef _CRC32_HXX
#include <CRC32.hxx>
#endif
-#ifndef _COM_SUN_STAR_PACKAGE_XZIPOUTPUTSTREAM_HPP_
-#include <com/sun/star/packages/XZipOutputStream.hpp>
-#endif
-#ifndef _CPPUHELPER_IMPLBASE1_HXX_
-#include <cppuhelper/implbase1.hxx> // helper for implementations
-#endif
#ifndef __SGI_STL_VECTOR
#include <vector>
#endif
+#ifndef _RTL_CIPHER_H_
+#include <rtl/cipher.h>
+#endif
+#ifndef _COM_SUN_STAR_PACKAGES_ZIPENTRY_HPP_
+#include <com/sun/star/packages/ZipEntry.hpp>
+#endif
+#ifndef _VOS_REF_H_
+#include <vos/ref.hxx>
+#endif
-
-class ZipOutputStream : public cppu::WeakImplHelper1< com::sun::star::packages::XZipOutputStream >
+class EncryptionData;
+class ZipOutputStream
{
private:
com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > xStream;
- Deflater aDeflater;
+ ::std::vector < ::com::sun::star::packages::ZipEntry *> aZipList;
com::sun::star::uno::Sequence < sal_Int8 > aBuffer;
+ com::sun::star::uno::Sequence < sal_Int8 > aEncryptionBuffer;
::rtl::OUString sComment;
+ Deflater aDeflater;
+ rtlCipher aCipher;
+ CRC32 aCRC;
+ ByteChucker aChucker;
+ com::sun::star::packages::ZipEntry *pCurrentEntry;
sal_Int16 nMethod;
sal_Int16 nLevel;
- com::sun::star::packages::ZipEntry *pCurrentEntry;
- CRC32 aCRC;
sal_Bool bFinished;
- ByteChucker aChucker;
- ::std::vector < ::com::sun::star::packages::ZipEntry *> aZipList;
+ sal_Bool bEncryptCurrentEntry;
public:
ZipOutputStream( com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > &xOStream, sal_Int32 nNewBufferSize);
- virtual ~ZipOutputStream(void);
+ ~ZipOutputStream(void);
+ void SAL_CALL setEncryptionKey ( com::sun::star::uno::Sequence < sal_Int8 > &rKey, com::sun::star::packages::ZipEntry & rEntry );
+ static com::sun::star::uno::Sequence < sal_Int8 > getInitialisationVector();
// rawWrite to support a direct write to the output stream
void SAL_CALL rawWrite( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer)
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
void SAL_CALL rawCloseEntry( )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setComment( const ::rtl::OUString& rComment )
+ // XZipOutputStream interfaces
+ void SAL_CALL setComment( const ::rtl::OUString& rComment )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setMethod( sal_Int32 nNewMethod )
+ void SAL_CALL setMethod( sal_Int32 nNewMethod )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setLevel( sal_Int32 nNewLevel )
+ void SAL_CALL setLevel( sal_Int32 nNewLevel )
throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL putNextEntry( const ::com::sun::star::packages::ZipEntry& rEntry )
+ void SAL_CALL putNextEntry( ::com::sun::star::packages::ZipEntry& rEntry,
+ const vos::ORef < EncryptionData > &rData,
+ sal_Bool bEncrypt = sal_False )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL closeEntry( )
+ void SAL_CALL closeEntry( )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL write( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+ void SAL_CALL write( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL finish( )
+ void SAL_CALL finish( )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL close( )
+ void SAL_CALL close( )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
static sal_uInt32 getCurrentDosTime ( );
- /*
- static sal_uInt32 tmDateToDosDate ( tm *pTime);
- static void dosDateToTMDate ( tm &rTime, sal_uInt32 nDosDate);
- */
-private:
+protected:
void doDeflate();
void writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx
index 2bc794d1d0ef..f03bc6913a0d 100644
--- a/package/inc/ZipPackage.hxx
+++ b/package/inc/ZipPackage.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackage.hxx,v $
*
- * $Revision: 1.17 $
+ * $Revision: 1.18 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:11:06 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,8 +85,8 @@
#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
#include <com/sun/star/lang/XUnoTunnel.hpp>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_XZIPFILE_HPP_
-#include <com/sun/star/packages/XZipFile.hpp>
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _ZIP_PACKAGE_BUFFER_HXX
#include <ZipPackageBuffer.hxx>
@@ -109,13 +109,14 @@ class ZipPackage :
public com::sun::star::lang::XSingleServiceFactory,
public com::sun::star::lang::XUnoTunnel,
public com::sun::star::container::XHierarchicalNameAccess,
- public com::sun::star::util::XChangesBatch
+ public com::sun::star::util::XChangesBatch,
+ public com::sun::star::beans::XPropertySet
{
-private:
+protected:
ZipPackageFolder *pRootFolder;
ZipFile *pZipFile;
::ucb::Content *pContent;
- ::com::sun::star::uno::Reference < com::sun::star::packages::XZipFile > xZipFile;
+ ::com::sun::star::uno::Sequence < sal_Int8 > aEncryptionKey;
::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;
@@ -126,6 +127,9 @@ private:
public:
ZipPackage (const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory);
virtual ~ZipPackage( void );
+ ZipFile& getZipFile() { return *pZipFile;}
+ const com::sun::star::uno::Sequence < sal_Int8 > & getEncryptionKey ( ) {return aEncryptionKey;}
+
// XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
throw(::com::sun::star::uno::RuntimeException);
@@ -160,6 +164,21 @@ public:
throw(::com::sun::star::uno::RuntimeException);
com::sun::star::uno::Sequence < sal_Int8 > getUnoTunnelImplementationId( void )
throw(::com::sun::star::uno::RuntimeException);
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addVetoableChangeListener( 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);
+ 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 40ee3a117282..62e9ef8ecf92 100644
--- a/package/inc/ZipPackageBuffer.hxx
+++ b/package/inc/ZipPackageBuffer.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageBuffer.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:11:06 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -84,7 +84,7 @@ class ZipPackageBuffer :
public com::sun::star::io::XSeekable,
public cppu::OWeakObject
{
-private:
+protected:
sal_Int64 nBufferSize;
sal_Int64 nEnd;
sal_Int64 nCurrent;
diff --git a/package/inc/ZipPackageFolder.hxx b/package/inc/ZipPackageFolder.hxx
index 1a86c14a7053..7f62abec70a7 100644
--- a/package/inc/ZipPackageFolder.hxx
+++ b/package/inc/ZipPackageFolder.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageFolder.hxx,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:28:02 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -91,21 +91,18 @@ class ZipPackageFolder : public ZipPackageEntry,
public ::com::sun::star::container::XNameContainer,
public ::com::sun::star::container::XEnumerationAccess
{
-private:
+protected:
TunnelHash aContents;
public:
- ZipPackage *pPackage;
- com::sun::star::uno::Reference < com::sun::star::lang::XSingleServiceFactory > xPackage;
- ZipPackageFolder ( void );
- virtual ~ZipPackageFolder( void );
+ ZipPackageFolder ();
+ virtual ~ZipPackageFolder();
static void copyZipEntry( com::sun::star::packages::ZipEntry &rDest, const com::sun::star::packages::ZipEntry &rSource);
// Recursive functions
void saveContents(rtl::OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut)
throw(::com::sun::star::uno::RuntimeException);
- void updateReferences( ZipFile * pNewZipFile);
- void releaseUpwardRef( void );
+ void releaseUpwardRef();
// XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
@@ -143,6 +140,12 @@ public:
virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement )
throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ // XPropertySet
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
// XUnoTunnel
static ::com::sun::star::uno::Sequence < sal_Int8 > getUnoTunnelImplementationId( void )
throw(::com::sun::star::uno::RuntimeException);
diff --git a/package/source/manifest/ManifestDefines.hxx b/package/source/manifest/ManifestDefines.hxx
index b3c1c7af6dd8..3fcf3e4d3ce2 100644
--- a/package/source/manifest/ManifestDefines.hxx
+++ b/package/source/manifest/ManifestDefines.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ManifestDefines.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:09:35 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,8 +63,13 @@
#define ELEMENT_MANIFEST "manifest:manifest"
#define ELEMENT_FILE_ENTRY "manifest:file-entry"
+#define ELEMENT_ENCRYPTION_DATA "manifest:encryption-data"
+#define ELEMENT_INITIALISATION_VECTOR "manifest:initialisation-vector"
#define ATTRIBUTE_FULL_PATH "manifest:full-path"
#define ATTRIBUTE_MEDIA_TYPE "manifest:media-type"
+#define ATTRIBUTE_ALGORITHM "manifest:algorithm"
+#define ATTRIBUTE_SALT "manifest:salt"
+#define ATTRIBUTE_ITERATION_COUNT "manifest:iteration-count"
#define ATTRIBUTE_CDATA "CDATA"
#define ATTRIBUTE_XMLNS "xmlns:manifest"
#define MANIFEST_NAMESPACE "http://openoffice.org/2001/manifest"
diff --git a/package/source/manifest/ManifestExport.cxx b/package/source/manifest/ManifestExport.cxx
index be4fe22ffacf..6685b5ba1ca1 100644
--- a/package/source/manifest/ManifestExport.cxx
+++ b/package/source/manifest/ManifestExport.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ManifestExport.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:09:35 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,6 +71,12 @@
#ifndef _COM_SUN_STAR_XML_SAX_XATTRIBUTELIST_HXX
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef _BASE64_CODEC_HXX_
+#include <Base64Codec.hxx>
+#endif
using namespace rtl;
using namespace std;
@@ -80,14 +86,23 @@ using namespace com::sun::star::xml::sax;
ManifestExport::ManifestExport(Reference < XDocumentHandler > xHandler, const Sequence < Sequence < PropertyValue > > &rManList)
{
- const OUString sFileEntryElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_FILE_ENTRY ) );
- const OUString sManifestElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_MANIFEST ) );
- const OUString sCdataAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_CDATA ) );
- const OUString sMediaTypeAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_MEDIA_TYPE ) );
- const OUString sFullPathAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_FULL_PATH ) );
+ const OUString sFileEntryElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_FILE_ENTRY ) );
+ const OUString sManifestElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_MANIFEST ) );
+ const OUString sInitialisationVectorElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_INITIALISATION_VECTOR ) );
+ const OUString sEncryptionDataElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_ENCRYPTION_DATA ) );
+ const OUString sCdataAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_CDATA ) );
+ const OUString sMediaTypeAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_MEDIA_TYPE ) );
+ const OUString sFullPathAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_FULL_PATH ) );
+ const OUString sAlgorithmAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ALGORITHM ) );
+ const OUString sSaltAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_SALT ) );
+ const OUString sIterationCountAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITERATION_COUNT ) );
- const OUString sFullPath ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
- const OUString sMediaType ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
+ const OUString sFullPath ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
+ const OUString sMediaType ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
+ const OUString sBlowfish ( RTL_CONSTASCII_USTRINGPARAM ( "Blowfish" ) );
+ const OUString sIterationCount ( RTL_CONSTASCII_USTRINGPARAM ( "IterationCount" ) );
+ const OUString sSalt ( RTL_CONSTASCII_USTRINGPARAM ( "Salt" ) );
+ const OUString sInitialisationVector( RTL_CONSTASCII_USTRINGPARAM ( "InitialisationVector" ) );
AttributeList * pRootAttrList = new AttributeList;
pRootAttrList->AddAttribute ( OUString( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_XMLNS ) ),
@@ -104,16 +119,64 @@ ManifestExport::ManifestExport(Reference < XDocumentHandler > xHandler, const S
AttributeList *pAttrList = new AttributeList;
const PropertyValue *pValue = pSequence->getConstArray();
OUString aString;
+ const PropertyValue *pVector = NULL, *pSalt = NULL, *pIterationCount = NULL;
for (sal_uInt32 j = 0, nNum = pSequence->getLength(); j < nNum; j++, pValue++)
{
- pValue->Value >>= aString;
if (pValue->Name.equals (sMediaType) )
+ {
+ pValue->Value >>= aString;
pAttrList->AddAttribute ( sMediaTypeAttribute, sCdataAttribute, aString );
+ }
else if (pValue->Name.equals (sFullPath) )
+ {
+ pValue->Value >>= aString;
pAttrList->AddAttribute ( sFullPathAttribute, sCdataAttribute, aString );
+ }
+ else if (pValue->Name.equals (sInitialisationVector) )
+ pVector = pValue;
+ else if (pValue->Name.equals (sSalt) )
+ pSalt = pValue;
+ else if (pValue->Name.equals (sIterationCount) )
+ pIterationCount = pValue;
}
Reference < XAttributeList > xAttrList = pAttrList;
xHandler->startElement( sFileEntryElement , xAttrList);
+ if ( pVector )
+ {
+ AttributeList * pAttrList = new AttributeList;
+ pAttrList->AddAttribute ( sAlgorithmAttribute, sCdataAttribute, sBlowfish );
+ if ( pIterationCount )
+ {
+ sal_Int64 nValue;
+ pIterationCount->Value >>= nValue;
+ OUStringBuffer aBuffer;
+ aBuffer.append (nValue);
+ pAttrList->AddAttribute ( sIterationCountAttribute, sCdataAttribute, aBuffer.makeStringAndClear() );
+ }
+ if ( pSalt )
+ {
+ OUStringBuffer aBuffer;
+ Sequence < sal_Int8 > aSequence;
+ pSalt->Value >>= aSequence;
+ Base64Codec::encodeBase64 ( aBuffer, aSequence );
+ pAttrList->AddAttribute ( sSaltAttribute, sCdataAttribute, aBuffer.makeStringAndClear() );
+ }
+ Reference < XAttributeList > xAttrList (pAttrList);
+ xHandler->startElement( sEncryptionDataElement , xAttrList);
+ if ( pVector )
+ {
+ AttributeList * pAttrList = new AttributeList;
+ Reference < XAttributeList > xAttrList (pAttrList);
+ OUStringBuffer aBuffer;
+ Sequence < sal_Int8 > aSequence;
+ pVector->Value >>= aSequence;
+ Base64Codec::encodeBase64 ( aBuffer, aSequence );
+ xHandler->startElement ( sInitialisationVectorElement, xAttrList);
+ xHandler->characters ( aBuffer.makeStringAndClear() );
+ xHandler->endElement ( sInitialisationVectorElement );
+ }
+ xHandler->endElement( sEncryptionDataElement );
+ }
xHandler->endElement( sFileEntryElement );
pSequence++;
}
diff --git a/package/source/manifest/ManifestImport.cxx b/package/source/manifest/ManifestImport.cxx
index b77265c52956..b163ba09eff8 100644
--- a/package/source/manifest/ManifestImport.cxx
+++ b/package/source/manifest/ManifestImport.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ManifestImport.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:09:35 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,9 @@
#ifndef _MANIFEST_DEFINES_HXX
#include <ManifestDefines.hxx>
#endif
+#ifndef _BASE64_CODEC_HXX_
+#include <Base64Codec.hxx>
+#endif
using namespace com::sun::star::uno;
using namespace com::sun::star::beans;
using namespace com::sun::star;
@@ -73,6 +76,7 @@ using namespace std;
ManifestImport::ManifestImport( vector < Sequence < PropertyValue > > & rNewManVector )
: rManVector ( rNewManVector )
+, nNumProperty (0)
{
}
ManifestImport::~ManifestImport (void )
@@ -89,31 +93,78 @@ void SAL_CALL ManifestImport::endDocument( )
void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs )
throw(xml::sax::SAXException, uno::RuntimeException)
{
- static const OUString sFileEntryElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_FILE_ENTRY ) );
+ static const OUString sEncryptionDataElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_ENCRYPTION_DATA ) );
+ static const OUString sInitialisationVectorElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_INITIALISATION_VECTOR ) );
+ static const OUString sAlgorithmAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_INITIALISATION_VECTOR ) );
+ static const OUString sSaltAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_SALT ) );
+ static const OUString sIterationCountAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITERATION_COUNT ) );
static const OUString sManifestElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_MANIFEST ) );
+ static const OUString sFileEntryElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_FILE_ENTRY ) );
static const OUString sCdataAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_CDATA ) );
static const OUString sMediaTypeAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_MEDIA_TYPE ) );
static const OUString sFullPathAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_FULL_PATH ) );
static const OUString sMediaTypeProperty ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
static const OUString sFullPathProperty ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
+ static const OUString sSaltProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Salt" ) );
+ static const OUString sAlgorithmProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Algorithm" ) );
+ static const OUString sIterationCountProperty ( RTL_CONSTASCII_USTRINGPARAM ( "IterationCount" ) );
if (aName == sFileEntryElement)
{
- Sequence < PropertyValue > aPropSeq ( 2 );
- aPropSeq[0].Name = sMediaTypeProperty;
- aPropSeq[0].Value <<= xAttribs->getValueByName( sMediaTypeAttribute );
- aPropSeq[1].Name = sFullPathProperty;
- aPropSeq[1].Value <<= xAttribs->getValueByName( sFullPathAttribute );
- rManVector.push_back ( aPropSeq );
+ aStack.push( e_FileEntry );
+ aSequence.realloc ( 2 );
+ aSequence[0].Name = sMediaTypeProperty;
+ aSequence[0].Value <<= xAttribs->getValueByName( sMediaTypeAttribute );
+ aSequence[1].Name = sFullPathProperty;
+ aSequence[1].Value <<= xAttribs->getValueByName( sFullPathAttribute );
+ nNumProperty=2;
+ }
+ else if (!aStack.empty())
+ {
+ if (aStack.top() == e_FileEntry && aName == sEncryptionDataElement)
+ {
+ aSequence.realloc (nNumProperty+3);
+ aStack.push (e_EncryptionData );
+ aSequence[nNumProperty].Name = sAlgorithmProperty;
+ aSequence[nNumProperty].Value <<= xAttribs->getValueByName( sAlgorithmAttribute );
+ aSequence[nNumProperty+1].Name = sSaltProperty;
+ OUString aString;
+ aString = xAttribs->getValueByName ( sSaltAttribute );
+ Sequence < sal_Int8 > aDecodeBuffer;
+ Base64Codec::decodeBase64 (aDecodeBuffer, aString);
+ aSequence[nNumProperty+1].Value <<= aDecodeBuffer;
+ aSequence[nNumProperty+2].Name = sIterationCountProperty;
+ aSequence[nNumProperty+2].Value <<= xAttribs->getValueByName( sIterationCountAttribute );
+ nNumProperty+=3;
+ }
+ else if (aStack.top() == e_EncryptionData && aName == sInitialisationVectorElement)
+ {
+ aStack.push (e_InitialisationVector);
+ aSequence.realloc (++nNumProperty);
+ }
}
}
void SAL_CALL ManifestImport::endElement( const OUString& aName )
- throw(xml::sax::SAXException, uno::RuntimeException)
+ throw(xml::sax::SAXException, uno::RuntimeException)
{
+ if ( !aStack.empty() )
+ {
+ if (aStack.top() == e_FileEntry)
+ rManVector.push_back ( aSequence );
+ aStack.pop();
+ }
}
void SAL_CALL ManifestImport::characters( const OUString& aChars )
throw(xml::sax::SAXException, uno::RuntimeException)
{
+ if (!aStack.empty() && aStack.top() == e_InitialisationVector)
+ {
+ const OUString sAlgorithmProperty ( RTL_CONSTASCII_USTRINGPARAM ( "Algorithm" ) );
+ Sequence < sal_Int8 > aDecodeBuffer;
+ Base64Codec::decodeBase64 (aDecodeBuffer, aChars);
+ aSequence[nNumProperty-1].Name = sAlgorithmProperty;
+ aSequence[nNumProperty-1].Value <<= aDecodeBuffer;
+ }
}
void SAL_CALL ManifestImport::ignorableWhitespace( const OUString& aWhitespaces )
throw(xml::sax::SAXException, uno::RuntimeException)
diff --git a/package/source/manifest/ManifestImport.hxx b/package/source/manifest/ManifestImport.hxx
index 91bc91647fdf..51968e482838 100644
--- a/package/source/manifest/ManifestImport.hxx
+++ b/package/source/manifest/ManifestImport.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ManifestImport.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:09:35 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,10 +75,21 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#endif
#include <vector>
+#include <stack>
+enum ElementNames
+{
+ e_Manifest,
+ e_FileEntry,
+ e_EncryptionData,
+ e_InitialisationVector
+};
class ManifestImport : public cppu::WeakImplHelper1 < com::sun::star::xml::sax::XDocumentHandler >
{
private:
+ com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aSequence;
+ sal_Int16 nNumProperty;
+ ::std::stack < ElementNames > aStack;
std::vector < ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > > & rManVector;
public:
ManifestImport( std::vector < ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > > & rNewVector );
diff --git a/package/source/manifest/ManifestReader.cxx b/package/source/manifest/ManifestReader.cxx
index 4dce8a1129ef..cd02600a8661 100644
--- a/package/source/manifest/ManifestReader.cxx
+++ b/package/source/manifest/ManifestReader.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ManifestReader.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: vg $ $Date: 2001-04-23 15:52:53 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -159,6 +159,7 @@ Sequence< Sequence< PropertyValue > > SAL_CALL ManifestReader::readManifestSeque
{
}
}
+ xParser->setDocumentHandler ( Reference < XDocumentHandler > () );
return aManifestSequence;
}
// Component functions
diff --git a/package/source/manifest/makefile.mk b/package/source/manifest/makefile.mk
index fed7d3947a12..a8ff5d916402 100644
--- a/package/source/manifest/makefile.mk
+++ b/package/source/manifest/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.1 $
+# $Revision: 1.2 $
#
-# last change: $Author: mtg $ $Date: 2001-04-19 14:09:35 $
+# last change: $Author: mtg $ $Date: 2001-04-27 14:56:05 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -81,6 +81,7 @@ SLOFILES= \
$(SLO)$/ManifestImport.obj \
$(SLO)$/ManifestExport.obj \
$(SLO)$/AttributeList.obj \
+ $(SLO)$/Base64Codec.obj \
$(SLO)$/UnoRegister.obj
# --- UNO stuff ---------------------------------------------------
diff --git a/package/source/zipapi/EntryInputStream.cxx b/package/source/zipapi/EntryInputStream.cxx
index efb893439bb6..023dd53f6989 100644
--- a/package/source/zipapi/EntryInputStream.cxx
+++ b/package/source/zipapi/EntryInputStream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: EntryInputStream.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,55 +59,59 @@
*
************************************************************************/
#ifndef _ENTRY_INPUT_STREAM_HXX
-#include "EntryInputStream.hxx"
+#include <EntryInputStream.hxx>
#endif
#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
#include <com/sun/star/packages/ZipConstants.hpp>
#endif
+#ifndef _RTL_CIPHER_H_
+#include <rtl/cipher.h>
+#endif
#include <memory.h> // for memcpy
using namespace rtl;
using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::packages::ZipConstants;
/** Provides access to the compressed data in a zipfile.
*
* 04/12/00 - uncompresses the stream into memory and seeks on it 'in memory'
- * This is a "temporary" fix which will be changed ASAP (read 2001)
+ * This and the ZipPackageBuffer used in the ZipOutputStream are memory hogs
+ * and will hopefully be replaced eventually
*
* Acts on the same underlying XInputStream as both the full Zip File and other
* EntryInputStreams, and thus must maintain its current position in the stream and
* seek to it before performing any reads.
*/
-EntryInputStream::EntryInputStream( uno::Reference < io::XInputStream > xNewInput,
- sal_Int64 nNewBegin,
- sal_Int64 nNewEnd,
- sal_Int64 nNewUncompressedSize,
+EntryInputStream::EntryInputStream( Reference < io::XInputStream > xNewInput,
+ const packages::ZipEntry & rNewEntry,
+ const vos::ORef < EncryptionData > &xEncryptData,
sal_Bool bIsDeflated)
: xStream( xNewInput )
-, xSeek( xNewInput, uno::UNO_QUERY )
-, nBegin( nNewBegin )
-, nEnd ( nNewEnd )
+, xSeek( xNewInput, UNO_QUERY )
+, rEntry (rNewEntry )
, nCurrent( 0 )
-, nUncompressedSize (nNewUncompressedSize)
, aSequence ( 0 )
-, bReachEOF ( sal_False )
, bHaveInMemory ( sal_False )
, aInflater( sal_True )
, aBuffer( 0 )
, bDeflated ( bIsDeflated )
+, xEncryptionData (xEncryptData)
{
+ nEnd = rEntry.nMethod == DEFLATED ? rEntry.nOffset + rEntry.nCompressedSize : rEntry.nOffset + rEntry.nSize;
}
void EntryInputStream::readIntoMemory()
{
if (!bHaveInMemory)
{
- aBuffer.realloc ( static_cast < sal_Int32 > ( nUncompressedSize ) );
+ aBuffer.realloc ( static_cast < sal_Int32 > ( rEntry.nSize ) );
if (bDeflated)
{
- sal_Int32 nSize = static_cast < sal_Int32 > (nEnd - nBegin );
+ sal_Int32 nSize = static_cast < sal_Int32 > (nEnd - rEntry.nOffset );
aSequence.realloc( nSize );
- xSeek->seek(nBegin);
+ xSeek->seek(rEntry.nOffset);
xStream->readBytes(aSequence, nSize );
aInflater.setInputSegment(aSequence, 0, nSize );
aInflater.doInflate(aBuffer);
@@ -116,26 +120,46 @@ void EntryInputStream::readIntoMemory()
}
else
{
- xSeek->seek(nBegin);
- xStream->readBytes(aBuffer, static_cast < sal_Int32 > (nUncompressedSize));
+ xSeek->seek(rEntry.nOffset);
+ xStream->readBytes(aBuffer, static_cast < sal_Int32 > (rEntry.nSize));
}
bHaveInMemory = sal_True;
+
+ /*
+ * Don't have the decryption code yet...
+ if (rEncryptionKey.getLength())
+ {
+ // An encrypted entry!
+ rtlCipherError aResult;
+ aSequence.realloc ( rEntry.nSize );
+ rtlCipher aCipher = rtl_cipher_create (rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeStream);
+ aResult = rtl_cipher_init( aCipher, rtl_Cipher_DirectionDecode,
+ reinterpret_cast < const sal_uInt8 * > ( rEncryptionKey.getConstArray()),
+ rEncryptionKey.getLength(),
+ reinterpret_cast < const sal_uInt8 * > ( rVector.getConstArray()),
+ rVector.getLength() );
+ OSL_ASSERT (aResult == rtl_Cipher_E_None);
+ aBuffer.realloc ( 0 );
+ aBuffer = aSequence;
+ aSequence.realloc ( 0 );
+ }
+ */
}
}
EntryInputStream::~EntryInputStream( void )
{
}
-sal_Int32 SAL_CALL EntryInputStream::readBytes( uno::Sequence< sal_Int8 >& aData,
+sal_Int32 SAL_CALL EntryInputStream::readBytes( Sequence< sal_Int8 >& aData,
sal_Int32 nBytesToRead )
- throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
+ throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException)
{
if (nBytesToRead <0)
throw io::BufferSizeExceededException(::rtl::OUString(), *this);
if (!bHaveInMemory)
readIntoMemory();
- if (nBytesToRead + nCurrent > nUncompressedSize)
- nBytesToRead = static_cast < sal_Int32> (nUncompressedSize - nCurrent);
+ if (nBytesToRead + nCurrent > rEntry.nSize)
+ nBytesToRead = static_cast < sal_Int32> (rEntry.nSize - nCurrent);
aData.realloc( nBytesToRead );
memcpy(aData.getArray(), aBuffer.getConstArray() + nCurrent, nBytesToRead);
@@ -143,49 +167,49 @@ sal_Int32 SAL_CALL EntryInputStream::readBytes( uno::Sequence< sal_Int8 >& aData
return nBytesToRead;
}
-sal_Int32 SAL_CALL EntryInputStream::readSomeBytes( uno::Sequence< sal_Int8 >& aData,
+sal_Int32 SAL_CALL EntryInputStream::readSomeBytes( Sequence< sal_Int8 >& aData,
sal_Int32 nMaxBytesToRead )
- throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
+ throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException)
{
return readBytes( aData, nMaxBytesToRead );
}
void SAL_CALL EntryInputStream::skipBytes( sal_Int32 nBytesToSkip )
- throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
+ throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException)
{
if (nBytesToSkip < 0)
throw io::BufferSizeExceededException(::rtl::OUString(), *this);
- if (nBytesToSkip + nCurrent > nUncompressedSize )
- nBytesToSkip = static_cast < sal_Int32 > (nUncompressedSize - nCurrent);
+ if (nBytesToSkip + nCurrent > rEntry.nSize )
+ nBytesToSkip = static_cast < sal_Int32 > (rEntry.nSize - nCurrent);
nCurrent+=nBytesToSkip;
}
sal_Int32 SAL_CALL EntryInputStream::available( )
- throw(io::NotConnectedException, io::IOException, uno::RuntimeException)
+ throw(io::NotConnectedException, io::IOException, RuntimeException)
{
- return static_cast < sal_Int32 > (nUncompressedSize - nCurrent);
+ return static_cast < sal_Int32 > (rEntry.nSize - nCurrent);
}
void SAL_CALL EntryInputStream::closeInput( )
- throw(io::NotConnectedException, io::IOException, uno::RuntimeException)
+ throw(io::NotConnectedException, io::IOException, RuntimeException)
{
}
void SAL_CALL EntryInputStream::seek( sal_Int64 location )
- throw(lang::IllegalArgumentException, io::IOException, uno::RuntimeException)
+ throw(lang::IllegalArgumentException, io::IOException, RuntimeException)
{
- if (location > nUncompressedSize)
- location = nUncompressedSize;
+ if (location > rEntry.nSize)
+ location = rEntry.nSize;
if (location <0)
location = 0;
nCurrent = location;
}
sal_Int64 SAL_CALL EntryInputStream::getPosition( )
- throw(io::IOException, uno::RuntimeException)
+ throw(io::IOException, RuntimeException)
{
return nCurrent;
}
sal_Int64 SAL_CALL EntryInputStream::getLength( )
- throw(io::IOException, uno::RuntimeException)
+ throw(io::IOException, RuntimeException)
{
- return nUncompressedSize;
+ return rEntry.nSize;
}
diff --git a/package/source/zipapi/EntryInputStream.hxx b/package/source/zipapi/EntryInputStream.hxx
index d1a7fd128917..82463f4158f9 100644
--- a/package/source/zipapi/EntryInputStream.hxx
+++ b/package/source/zipapi/EntryInputStream.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: EntryInputStream.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:12:53 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,23 +73,33 @@
#ifndef _INFLATER_HXX_
#include <Inflater.hxx>
#endif
-
+#ifndef _COM_SUN_STAR_PACKAGES_ZIPENTRY_HPP_
+#include <com/sun/star/packages/ZipEntry.hpp>
+#endif
+#ifndef _VOS_REF_H_
+#include <vos/ref.hxx>
+#endif
+#ifndef _ENCRYPTION_DATA_HXX
+#include <EncryptionData.hxx>
+#endif
class EntryInputStream : public cppu::WeakImplHelper2< com::sun::star::io::XInputStream,
com::sun::star::io::XSeekable >
{
private:
com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xStream;
com::sun::star::uno::Reference< com::sun::star::io::XSeekable > xSeek;
- sal_Int64 nBegin, nEnd, nCurrent, nUncompressedSize;
- sal_Bool bReachEOF;
- sal_Bool bDeflated;
- sal_Bool bHaveInMemory;
- com::sun::star::uno::Sequence < sal_Int8 > aSequence;
- com::sun::star::uno::Sequence < sal_Int8 > aBuffer;
+ sal_Int64 nEnd, nCurrent;
+ sal_Bool bDeflated, bHaveInMemory, bEncrypted;
+ com::sun::star::uno::Sequence < sal_Int8 > aSequence, aBuffer;
+ const vos::ORef < EncryptionData > xEncryptionData;
+ const com::sun::star::packages::ZipEntry & rEntry;
Inflater aInflater;
void readIntoMemory();
public:
- EntryInputStream( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xInput, sal_Int64 nBegin, sal_Int64 nEnd, sal_Int64 nNewUncompressedSize, sal_Bool bIsDeflated);
+ EntryInputStream( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xInput,
+ const com::sun::star::packages::ZipEntry &rNewEntry,
+ const vos::ORef < EncryptionData > &xEncryptData,
+ sal_Bool bIsDeflated );
virtual ~EntryInputStream();
// XInputStream
diff --git a/package/source/zipapi/Inflater.cxx b/package/source/zipapi/Inflater.cxx
index e58067a6ee38..bcc6f64c43ec 100644
--- a/package/source/zipapi/Inflater.cxx
+++ b/package/source/zipapi/Inflater.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Inflater.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -74,13 +74,21 @@
/** Provides general purpose decompression using the ZLIB library */
-void Inflater::init (sal_Bool bNowrap)
+
+Inflater::Inflater(sal_Bool bNoWrap)
+: bFinish(sal_False),
+ bFinished(sal_False),
+ bSetParams(sal_False),
+ bNeedDict(sal_False),
+ nOffset(0),
+ nLength(0),
+ pStream(NULL)
{
pStream = new z_stream;
/* memset to 0 to set zalloc/opaque etc */
memset (pStream, 0, sizeof(*pStream));
sal_Int32 nRes;
- nRes = inflateInit2(pStream, bNowrap ? -MAX_WBITS : MAX_WBITS);
+ nRes = inflateInit2(pStream, bNoWrap ? -MAX_WBITS : MAX_WBITS);
switch (nRes)
{
case Z_OK:
@@ -99,29 +107,6 @@ void Inflater::init (sal_Bool bNowrap)
}
}
-Inflater::Inflater(sal_Bool bNoWrap)
-: bFinish(sal_False),
- bFinished(sal_False),
- bSetParams(sal_False),
- bNeedDict(sal_False),
- nOffset(0),
- nLength(0),
- pStream(NULL)
-{
- init(bNoWrap);
-}
-
-Inflater::Inflater()
-: bFinish(sal_False),
- bFinished(sal_False),
- bSetParams(sal_False),
- bNeedDict(sal_False),
- nOffset(0),
- nLength(0),
- pStream(NULL)
-{
- init(sal_False);
-}
Inflater::~Inflater()
{
end();
diff --git a/package/source/zipapi/ZipEnumeration.cxx b/package/source/zipapi/ZipEnumeration.cxx
index e5c373d4a6c4..dedd320b1d3a 100644
--- a/package/source/zipapi/ZipEnumeration.cxx
+++ b/package/source/zipapi/ZipEnumeration.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipEnumeration.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-04-27 14:56:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,12 +61,10 @@
#ifndef _ZIP_ENUMERATION_HXX
#include <ZipEnumeration.hxx>
#endif
-#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
-#include <com/sun/star/packages/ZipConstants.hpp>
-#endif
using namespace rtl;
using namespace com::sun::star;
+using namespace com::sun::star::packages;
/** Provides an Enumeration over the contents of a Zip file */
@@ -78,17 +76,15 @@ ZipEnumeration::ZipEnumeration( EntryHash & rNewEntryHash)
ZipEnumeration::~ZipEnumeration( void )
{
}
-sal_Bool SAL_CALL ZipEnumeration::hasMoreElements() throw (uno::RuntimeException)
+sal_Bool SAL_CALL ZipEnumeration::hasMoreElements()
{
return (aIterator != rEntryHash.end());
}
-uno::Any SAL_CALL ZipEnumeration::nextElement() throw (uno::RuntimeException)
+const ZipEntry* SAL_CALL ZipEnumeration::nextElement()
{
- uno::Any aAny;
- if (aIterator == rEntryHash.end())
- throw container::NoSuchElementException();
- aAny <<= (*aIterator).second;
- aIterator++;
- return aAny;
+ if (aIterator != rEntryHash.end())
+ return &((*aIterator++).second);
+ else
+ return NULL;
}
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 23c45905011a..87a6081653eb 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipFile.cxx,v $
*
- * $Revision: 1.19 $
+ * $Revision: 1.20 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -78,12 +78,14 @@
using namespace rtl;
using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::packages;
using namespace com::sun::star::packages::ZipConstants;
/** This class is used to read entries from a zip file
*/
-ZipFile::ZipFile( uno::Reference < io::XInputStream > &xInput, sal_Bool bInitialise)
- throw(io::IOException, packages::ZipException, uno::RuntimeException)
+ZipFile::ZipFile( Reference < io::XInputStream > &xInput, sal_Bool bInitialise)
+ throw(io::IOException, ZipException, RuntimeException)
: xStream(xInput)
, aGrabber(xInput)
, aInflater (sal_True)
@@ -91,7 +93,7 @@ ZipFile::ZipFile( uno::Reference < io::XInputStream > &xInput, sal_Bool bInitial
if (bInitialise)
readCEN();
}
-void ZipFile::setInputStream ( uno::Reference < io::XInputStream > xNewStream )
+void ZipFile::setInputStream ( Reference < io::XInputStream > xNewStream )
{
xStream = xNewStream;
aGrabber.setInputStream ( xStream );
@@ -107,7 +109,7 @@ void ZipFile::updateFromManList(std::vector < ManifestEntry * > &rManList)
// I'm not sure how evil this is in this case...
for (;i < nSize ; i++)
{
- packages::ZipEntry * pEntry = &rManList[i]->aEntry;
+ ZipEntry * pEntry = &rManList[i]->aEntry;
aEntries[pEntry->sName] = *pEntry;
}
}
@@ -118,145 +120,91 @@ ZipFile::~ZipFile()
}
void SAL_CALL ZipFile::close( )
- throw(io::IOException, uno::RuntimeException)
+ throw(io::IOException, RuntimeException)
{
}
-uno::Reference< container::XEnumeration > SAL_CALL ZipFile::entries( )
- throw(uno::RuntimeException)
+ZipEnumeration * SAL_CALL ZipFile::entries( )
{
- uno::Reference< container::XEnumeration> xEnumRef = new ZipEnumeration( aEntries );
- return xEnumRef;
+ return new ZipEnumeration ( aEntries );
}
::rtl::OUString SAL_CALL ZipFile::getName( )
- throw(uno::RuntimeException)
+ throw(RuntimeException)
{
return sName;
}
sal_Int32 SAL_CALL ZipFile::getSize( )
- throw(uno::RuntimeException)
+ throw(RuntimeException)
{
return aEntries.size();
}
-uno::Type SAL_CALL ZipFile::getElementType( )
- throw(uno::RuntimeException)
+Type SAL_CALL ZipFile::getElementType( )
+ throw(RuntimeException)
{
- return ::getCppuType((packages::ZipEntry *) 0);
+ return ::getCppuType((ZipEntry *) 0);
}
sal_Bool SAL_CALL ZipFile::hasElements( )
- throw(uno::RuntimeException)
+ throw(RuntimeException)
{
return (aEntries.size()>0);
}
-uno::Any SAL_CALL ZipFile::getByName( const ::rtl::OUString& aName )
- throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+Any SAL_CALL ZipFile::getByName( const ::rtl::OUString& aName )
+ throw(container::NoSuchElementException, lang::WrappedTargetException, RuntimeException)
{
- uno::Any aAny;
- if (!aEntries.count(sName))
- throw container::NoSuchElementException();
+ Any aAny;
EntryHash::const_iterator aCI = aEntries.find(sName);
+ if (aCI == aEntries.end())
+ throw container::NoSuchElementException();
aAny <<= (*aCI).second;
return aAny;
}
-uno::Sequence< ::rtl::OUString > SAL_CALL ZipFile::getElementNames( )
- throw(uno::RuntimeException)
+Sequence< ::rtl::OUString > SAL_CALL ZipFile::getElementNames( )
+ throw(RuntimeException)
{
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++)
pNames[i] = (*aIterator).first;
- return uno::Sequence<OUString> (pNames, nSize);
+ return Sequence<OUString> (pNames, nSize);
}
sal_Bool SAL_CALL ZipFile::hasByName( const ::rtl::OUString& aName )
- throw(uno::RuntimeException)
+ throw(RuntimeException)
{
- return aEntries.count(aName);
+ return aEntries.find(aName) != aEntries.end();
}
-uno::Reference< io::XInputStream > SAL_CALL ZipFile::getInputStream( const packages::ZipEntry& rEntry )
- throw(io::IOException, packages::ZipException, uno::RuntimeException)
+Reference< io::XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry,
+ const vos::ORef < EncryptionData > &rData)
+ throw(io::IOException, ZipException, RuntimeException)
{
sal_Int64 nSize = rEntry.nMethod == DEFLATED ? rEntry.nCompressedSize : rEntry.nSize;
if (rEntry.nOffset <= 0)
readLOC(rEntry);
- uno::Reference< io::XInputStream > xStreamRef =
- new EntryInputStream(xStream,
- rEntry.nOffset,
- rEntry.nOffset + nSize,
- rEntry.nSize,
- rEntry.nMethod == DEFLATED );
+ Reference< io::XInputStream > xStreamRef = new EntryInputStream(xStream, rEntry, rData, rEntry.nMethod == DEFLATED );
return xStreamRef;
}
-sal_uInt32 SAL_CALL ZipFile::getHeader(const packages::ZipEntry& rEntry)
- throw(io::IOException, packages::ZipException, uno::RuntimeException)
-{
- uno::Sequence < sal_Int8 > aSequence (4);
-
- try
- {
- if (rEntry.nOffset <= 0)
- readLOC(rEntry);
- }
- catch (packages::ZipException&)
- {
- VOS_ENSURE(0, "Zip file bug!");
- return 0;
- }
-
- aGrabber.seek(rEntry.nOffset);
- if (rEntry.nMethod == STORED)
- {
- if (xStream->readBytes(aSequence, 4) < 4)
- return 0;
- }
- else if (rEntry.nMethod == DEFLATED)
- {
- /*
- uno::Reference < io::XInputStream > xEntryStream = getInputStream (rEntry);
- if (xEntryStream->readBytes(aSequence, 4) < 4)
- return 0;
- */
- sal_Int32 nSize = rEntry.nCompressedSize < 32768 ? rEntry.nCompressedSize : 32768;
- uno::Sequence < sal_Int8 > aCompSeq (nSize );
- if (xStream->readBytes(aCompSeq, nSize) < nSize)
- return 0;
- aInflater.finish();
- aInflater.setInput(aCompSeq);
- aInflater.doInflate(aSequence);
- aInflater.reset();
- }
- return (static_cast < sal_uInt32 >
- (static_cast < sal_uInt8> (aSequence[0]& 0xFF)
- | static_cast < sal_uInt8> (aSequence[1]& 0xFF) << 8
- | static_cast < sal_uInt8> (aSequence[2]& 0xFF) << 16
- | static_cast < sal_uInt8> (aSequence[3]& 0xFF) << 24));
-}
-
-uno::Reference< io::XInputStream > SAL_CALL ZipFile::getRawStream( const packages::ZipEntry& rEntry )
- throw(io::IOException, packages::ZipException, uno::RuntimeException)
+Reference< io::XInputStream > SAL_CALL ZipFile::getRawStream( ZipEntry& rEntry,
+ const vos::ORef < EncryptionData > &rData)
+ throw(io::IOException, ZipException, RuntimeException)
{
sal_Int64 nSize = rEntry.nMethod == DEFLATED ? rEntry.nCompressedSize : rEntry.nSize;
if (rEntry.nOffset <= 0)
readLOC(rEntry);
- uno::Reference< io::XInputStream > xStreamRef =
- new EntryInputStream(xStream,
- rEntry.nOffset,
- rEntry.nOffset + nSize,
- nSize,
- sal_False );
+ Reference< io::XInputStream > xStreamRef =
+ new EntryInputStream(xStream, rEntry, rData, sal_False );
return xStreamRef;
}
-sal_Bool ZipFile::readLOC(const packages::ZipEntry &rEntry)
- throw(io::IOException, packages::ZipException, uno::RuntimeException)
+sal_Bool ZipFile::readLOC( ZipEntry &rEntry )
+ throw(io::IOException, ZipException, RuntimeException)
{
sal_uInt32 nTestSig, nTime, nCRC, nSize, nCompressedSize;
sal_uInt16 nVersion, nFlag, nHow, nNameLen, nExtraLen;
@@ -266,7 +214,7 @@ sal_Bool ZipFile::readLOC(const packages::ZipEntry &rEntry)
aGrabber >> nTestSig;
if (nTestSig != LOCSIG)
- throw packages::ZipException( OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid LOC header (bad signature") ), uno::Reference < uno::XInterface > () );
+ throw ZipException( OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid LOC header (bad signature") ), Reference < XInterface > () );
aGrabber >> nVersion;
aGrabber >> nFlag;
aGrabber >> nHow;
@@ -276,21 +224,20 @@ sal_Bool ZipFile::readLOC(const packages::ZipEntry &rEntry)
aGrabber >> nSize;
aGrabber >> nNameLen;
aGrabber >> nExtraLen;
- packages::ZipEntry *pNonConstEntry = const_cast < packages::ZipEntry* > (&rEntry);
- pNonConstEntry->nOffset = static_cast < sal_Int32 > (aGrabber.getPosition()) + nNameLen + nExtraLen;
+ rEntry.nOffset = static_cast < sal_Int32 > (aGrabber.getPosition()) + nNameLen + nExtraLen;
return sal_True;
}
sal_Int32 ZipFile::findEND( )
- throw(io::IOException, packages::ZipException, uno::RuntimeException)
+ throw(io::IOException, ZipException, RuntimeException)
{
sal_Int32 nLength=0, nPos=0;
- uno::Sequence < sal_Int8 > aByteSeq;
+ Sequence < sal_Int8 > aByteSeq;
nLength = nPos = static_cast <sal_Int32 > (aGrabber.getLength());
if (nLength == 0)
return -1;
- //throw (packages::ZipException( OUString::createFromAscii("Trying to find Zip END signature in a zero length file!"), uno::Reference < uno::XInterface> () ));
+ //throw (ZipException( OUString::createFromAscii("Trying to find Zip END signature in a zero length file!"), Reference < XInterface> () ));
aGrabber.seek( nLength );
@@ -317,7 +264,7 @@ sal_Int32 ZipFile::findEND( )
if (nCommentLength>0)
{
aByteSeq.realloc(nCommentLength+1);
- aGrabber.readBytes(uno::Sequence< sal_Int8>(aByteSeq.getArray(), nCommentLength), nCommentLength);
+ aGrabber.readBytes(Sequence< sal_Int8>(aByteSeq.getArray(), nCommentLength), nCommentLength);
aByteSeq[nCommentLength]='\0';
sComment = OUString((sal_Char*)aByteSeq.getConstArray(), nCommentLength+1, RTL_TEXTENCODING_ASCII_US);
@@ -327,11 +274,11 @@ sal_Int32 ZipFile::findEND( )
}
}
}
- throw packages::ZipException( OUString( RTL_CONSTASCII_USTRINGPARAM ( "Zip END signature not found!") ), uno::Reference < uno::XInterface> () );
+ throw ZipException( OUString( RTL_CONSTASCII_USTRINGPARAM ( "Zip END signature not found!") ), Reference < XInterface> () );
}
sal_Int32 ZipFile::readCEN()
- throw(io::IOException, packages::ZipException, uno::RuntimeException)
+ throw(io::IOException, ZipException, RuntimeException)
{
sal_Int32 nEndPos, nLocPos;
sal_Int16 nCount, nTotal;
@@ -346,23 +293,23 @@ sal_Int32 ZipFile::readCEN()
aGrabber >> nCenOff;
if (nTotal<0 || nTotal * CENHDR > nCenLen)
- throw packages::ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "invalid END header (bad entry count)") ), uno::Reference < uno::XInterface > ());
+ throw ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "invalid END header (bad entry count)") ), Reference < XInterface > ());
if (nTotal > ZIP_MAXENTRIES)
- throw packages::ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "too many entries in ZIP File") ), uno::Reference < uno::XInterface > ());
+ throw ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "too many entries in ZIP File") ), Reference < XInterface > ());
if (nCenLen < 0 || nCenLen > nEndPos)
- throw packages::ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid END header (bad central directory size)") ), uno::Reference < uno::XInterface > ());
+ throw ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid END header (bad central directory size)") ), Reference < XInterface > ());
nCenPos = nEndPos - nCenLen;
if (nCenOff < 0 || nCenOff > nCenPos)
- throw packages::ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid END header (bad central directory size)") ), uno::Reference < uno::XInterface > ());
+ throw ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid END header (bad central directory size)") ), Reference < XInterface > ());
nLocPos = nCenPos - nCenOff;
aGrabber.seek(nCenPos);
- packages::ZipEntry *pEntry = new packages::ZipEntry;
+ ZipEntry *pEntry = new ZipEntry;
for (nCount = 0 ; nCount < nTotal; nCount++)
{
sal_Int32 nTestSig, nCRC, nCompressedSize, nTime, nSize, nExtAttr, nOffset;
@@ -370,21 +317,21 @@ sal_Int32 ZipFile::readCEN()
sal_Int16 nDisk, nIntAttr;
if (aGrabber.getPosition() - nCenPos + CENHDR > nCenLen)
- throw packages::ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid CEN header (bad header size check 1)") ), uno::Reference < uno::XInterface > ());
+ throw ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid CEN header (bad header size check 1)") ), Reference < XInterface > ());
aGrabber >> nTestSig;
if (nTestSig != CENSIG)
- throw packages::ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid CEN header (bad signature)") ), uno::Reference < uno::XInterface > ());
+ throw ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid CEN header (bad signature)") ), Reference < XInterface > ());
aGrabber >> nVerMade;
aGrabber >> nVersion;
if ((nVersion & 1) == 1)
- throw packages::ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid CEN header (encrypted entry)") ), uno::Reference < uno::XInterface > ());
+ throw ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid CEN header (encrypted entry)") ), Reference < XInterface > ());
aGrabber >> nFlag;
aGrabber >> nHow;
if (nHow != STORED && nHow != DEFLATED)
- throw packages::ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid CEN header (bad compression method)") ), uno::Reference < uno::XInterface > ());
+ throw ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid CEN header (bad compression method)") ), Reference < XInterface > ());
aGrabber >> nTime;
aGrabber >> nCRC;
@@ -399,13 +346,13 @@ sal_Int32 ZipFile::readCEN()
aGrabber >> nOffset;
if (aGrabber.getPosition() - nCenPos + nNameLen + nExtraLen + nCommentLen > nCenLen)
- throw packages::ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid CEN header (bad header size check 2)") ), uno::Reference < uno::XInterface > ());
+ throw ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Invalid CEN header (bad header size check 2)") ), Reference < XInterface > ());
if (nNameLen > ZIP_MAXNAMELEN)
- throw packages::ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "name length exceeds 512 bytes" ) ), uno::Reference < uno::XInterface > ());
+ throw ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "name length exceeds 512 bytes" ) ), Reference < XInterface > ());
if (nExtraLen > ZIP_MAXEXTRA)
- throw packages::ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "extra header info exceeds 256 bytes") ), uno::Reference < uno::XInterface > ());
+ throw ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "extra header info exceeds 256 bytes") ), Reference < XInterface > ());
pEntry->nTime = nTime;
pEntry->nCrc = nCRC;
@@ -421,14 +368,14 @@ sal_Int32 ZipFile::readCEN()
if (nHow == STORED)
pEntry->nCompressedSize = 0;
*/
- uno::Sequence < sal_Int8> aSequence (nNameLen);
+ Sequence < sal_Int8> aSequence (nNameLen);
aGrabber.readBytes(aSequence, nNameLen);
pEntry->sName = OUString((sal_Char*)aSequence.getConstArray(), nNameLen, RTL_TEXTENCODING_ASCII_US);
aGrabber.seek(aGrabber.getPosition() + nExtraLen);
if (nCommentLen>0)
{
- uno::Sequence < sal_Int8 > aCommentSeq( nCommentLen );
+ Sequence < sal_Int8 > aCommentSeq( nCommentLen );
aGrabber.readBytes(aCommentSeq, nCommentLen);
pEntry->sComment = OUString((sal_Char*)aCommentSeq.getConstArray(), nNameLen, RTL_TEXTENCODING_ASCII_US);
}
@@ -437,7 +384,7 @@ sal_Int32 ZipFile::readCEN()
delete pEntry;
if (nCount != nTotal)
- throw packages::ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Count != Total") ), uno::Reference < uno::XInterface > ());
+ throw ZipException(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Count != Total") ), Reference < XInterface > ());
return nCenPos;
}
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx
index d8078ca0dcbf..ee0ef68f6660 100644
--- a/package/source/zipapi/ZipOutputStream.cxx
+++ b/package/source/zipapi/ZipOutputStream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipOutputStream.cxx,v $
*
- * $Revision: 1.24 $
+ * $Revision: 1.25 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,14 +64,19 @@
#ifndef _VOS_DIAGNOSE_H_
#include <vos/diagnose.hxx>
#endif
+#ifndef _VOS_REF_H_
+#include <vos/ref.hxx>
+#endif
#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
#include <com/sun/star/packages/ZipConstants.hpp>
#endif
-#include <time.h>
-#include <utime.h>
+#ifndef _OSL_TIME_H_
+#include <osl/time.h>
+#endif
using namespace rtl;
using namespace com::sun::star;
+using namespace com::sun::star::uno;
using namespace com::sun::star::packages::ZipConstants;
/** This class is used to write Zip files
@@ -82,6 +87,7 @@ ZipOutputStream::ZipOutputStream( uno::Reference < io::XOutputStream > &xOStream
, nMethod(DEFLATED)
, pCurrentEntry(NULL)
, bFinished(sal_False)
+, bEncryptCurrentEntry(sal_False)
, aBuffer(nNewBufferSize)
, aDeflater(DEFAULT_COMPRESSION, sal_True)
{
@@ -108,30 +114,64 @@ void SAL_CALL ZipOutputStream::setLevel( sal_Int32 nNewLevel )
{
aDeflater.setLevel( nNewLevel);
}
-void SAL_CALL ZipOutputStream::putNextEntry( const packages::ZipEntry& rEntry )
+
+Sequence < sal_Int8 > ZipOutputStream::getInitialisationVector()
+{
+ Sequence < sal_Int8 > aSequence( 8 );
+ TimeValue aTimeVal;
+ sal_Int8 * pVector = aSequence.getArray();
+ osl_getSystemTime( &aTimeVal );
+
+ pVector[0] = static_cast < sal_Int8 > ( (aTimeVal.Seconds >> 0 ) & 0xFF );
+ pVector[1] = static_cast < sal_Int8 > ( (aTimeVal.Seconds >> 8 ) & 0xFF );
+ pVector[2] = static_cast < sal_Int8 > ( (aTimeVal.Seconds >> 16 ) & 0xFF );
+ pVector[3] = static_cast < sal_Int8 > ( (aTimeVal.Seconds >> 24 ) & 0xFF );
+ pVector[4] = static_cast < sal_Int8 > ( (aTimeVal.Nanosec >> 0 ) & 0xFF );
+ pVector[5] = static_cast < sal_Int8 > ( (aTimeVal.Nanosec >> 8 ) & 0xFF );
+ pVector[6] = static_cast < sal_Int8 > ( (aTimeVal.Nanosec >> 16 ) & 0xFF );
+ pVector[7] = static_cast < sal_Int8 > ( (aTimeVal.Nanosec >> 24 ) & 0xFF );
+ return aSequence;
+}
+
+void SAL_CALL ZipOutputStream::putNextEntry( packages::ZipEntry& rEntry,
+ const vos::ORef < EncryptionData > &xEncryptData,
+ sal_Bool bEncrypt)
throw(io::IOException, uno::RuntimeException)
{
- packages::ZipEntry *pNonConstEntry = const_cast < packages::ZipEntry* >(&rEntry);
if (pCurrentEntry != NULL)
closeEntry();
- if (pNonConstEntry->nTime == -1)
- pNonConstEntry->nTime = getCurrentDosTime();
- if (pNonConstEntry->nMethod == -1)
- {
- pNonConstEntry->nMethod = nMethod;
- }
- pNonConstEntry->nVersion = 20;
- if (pNonConstEntry->nSize == -1 || pNonConstEntry->nCompressedSize == -1 ||
- pNonConstEntry->nCrc == -1)
- pNonConstEntry->nFlag = 8;
- else if (pNonConstEntry->nSize != -1 && pNonConstEntry->nCompressedSize != -1 &&
- pNonConstEntry->nCrc != -1)
- pNonConstEntry->nFlag = 0;
+ if (rEntry.nTime == -1)
+ rEntry.nTime = getCurrentDosTime();
+ if (rEntry.nMethod == -1)
+ rEntry.nMethod = nMethod;
+ rEntry.nVersion = 20;
+ if (rEntry.nSize == -1 || rEntry.nCompressedSize == -1 ||
+ rEntry.nCrc == -1)
+ rEntry.nFlag = 8;
+ else if (rEntry.nSize != -1 && rEntry.nCompressedSize != -1 &&
+ rEntry.nCrc != -1)
+ rEntry.nFlag = 0;
- pNonConstEntry->nOffset = static_cast < sal_Int32 > (aChucker.getPosition());
+ rEntry.nOffset = static_cast < sal_Int32 > (aChucker.getPosition());
writeLOC(rEntry);
- aZipList.push_back( pNonConstEntry );
- pCurrentEntry=pNonConstEntry;
+ aZipList.push_back( &rEntry );
+ pCurrentEntry = &rEntry;
+ /* Don't have encryption code yet...
+ if (bEncrypt)
+ {
+
+ bEncryptCurrentEntry = sal_True;
+ rtlCipherError aResult;
+
+ aCipher = rtl_cipher_create ( rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeStream);
+ aResult = rtl_cipher_init( aCipher, rtl_Cipher_DirectionEncode,
+ reinterpret_cast < const sal_uInt8 *> (rKey.getConstArray()),
+ rKey.getLength(),
+ reinterpret_cast < const sal_uInt8 *> (rVector.getConstArray()),
+ rVector.getLength());
+ OSL_ASSERT( aResult == rtl_Cipher_E_None );
+ }
+ */
}
void SAL_CALL ZipOutputStream::close( )
throw(io::IOException, uno::RuntimeException)
@@ -220,6 +260,11 @@ void SAL_CALL ZipOutputStream::closeEntry( )
break;
}
aCRC.reset();
+ if (bEncryptCurrentEntry)
+ {
+ aEncryptionBuffer.realloc ( 0 );
+ bEncryptCurrentEntry = sal_False;
+ }
pCurrentEntry = NULL;
}
}
@@ -241,7 +286,17 @@ void SAL_CALL ZipOutputStream::write( const uno::Sequence< sal_Int8 >& rBuffer,
sal_Int32 nOldLength = rBuffer.getLength();
uno::Sequence < sal_Int8 > *pBuffer = const_cast < uno::Sequence < sal_Int8 > *> (&rBuffer);
pBuffer->realloc(nNewLength);
- aChucker.writeBytes(*pBuffer);
+ if (bEncryptCurrentEntry)
+ {
+ rtlCipherError aResult;
+ aEncryptionBuffer.realloc ( nNewLength );
+ aResult = rtl_cipher_encode ( aCipher, static_cast < const void * > (pBuffer->getConstArray()),
+ nNewLength, reinterpret_cast < sal_uInt8 * > (aEncryptionBuffer.getArray()), nNewLength );
+ aChucker.writeBytes ( aEncryptionBuffer );
+ aEncryptionBuffer.realloc ( nOldLength );
+ }
+ else
+ aChucker.writeBytes( *pBuffer );
pBuffer->realloc(nOldLength);
break;
}
@@ -286,7 +341,17 @@ void ZipOutputStream::doDeflate()
if (nLength> 0 )
{
aBuffer.realloc(nLength);
- aChucker.writeBytes(aBuffer);
+ if (bEncryptCurrentEntry)
+ {
+ rtlCipherError aResult;
+ aEncryptionBuffer.realloc ( nLength );
+ aResult = rtl_cipher_encode ( aCipher, static_cast < const void * > (aBuffer.getConstArray()),
+ nLength, reinterpret_cast < sal_uInt8 * > (aEncryptionBuffer.getArray()), nLength );
+ aChucker.writeBytes ( aEncryptionBuffer );
+ aEncryptionBuffer.realloc ( nOldLength );
+ }
+ else
+ aChucker.writeBytes(aBuffer);
aBuffer.realloc(nOldLength);
}
}
@@ -421,22 +486,23 @@ void ZipOutputStream::writeLOC( const packages::ZipEntry &rEntry )
}
sal_uInt32 ZipOutputStream::getCurrentDosTime( )
{
- time_t nTime = time (NULL);
- // pTime is a static internal to the time library and shouldn't be deleted
- struct tm *pTime = localtime ( &nTime);
+ oslDateTime aDateTime;
+ TimeValue aTimeValue;
+ osl_getSystemTime ( &aTimeValue );
+ osl_getDateTimeFromTimeValue( &aTimeValue, &aDateTime);
- sal_uInt32 nYear = static_cast <sal_uInt32> (pTime->tm_year);
+ sal_uInt32 nYear = static_cast <sal_uInt32> (aDateTime.Year);
if (nYear>1980)
nYear-=1980;
else if (nYear>80)
nYear-=80;
- sal_uInt32 nResult = static_cast < sal_uInt32>( ( ( ( pTime->tm_mday) +
- ( 32 * (pTime->tm_mon+1)) +
+ sal_uInt32 nResult = static_cast < sal_uInt32>( ( ( ( aDateTime.Day) +
+ ( 32 * (aDateTime.Month)) +
( 512 * nYear ) ) << 16) |
- ( ( pTime->tm_sec/2) +
- ( 32 * pTime->tm_min) +
- ( 2048 * static_cast <sal_uInt32 > (pTime->tm_hour) ) ) );
+ ( ( aDateTime.Seconds/2) +
+ ( 32 * aDateTime.Minutes) +
+ ( 2048 * static_cast <sal_uInt32 > (aDateTime.Hours) ) ) );
return nResult;
}
/*
@@ -444,6 +510,9 @@ sal_uInt32 ZipOutputStream::getCurrentDosTime( )
This is actually never used, so I removed it, but thought that the
implementation details may be useful in the future...mtg 20010307
+ I stopped using the time library and used the OSL version instead, but
+ it might still be useful to have this code here..
+
void ZipOutputStream::dosDateToTMDate ( tm &rTime, sal_uInt32 nDosDate)
{
sal_uInt32 nDate = static_cast < sal_uInt32 > (nDosDate >> 16);
diff --git a/package/source/zipapi/makefile.mk b/package/source/zipapi/makefile.mk
index 5bda73ee2225..389c46e7dd95 100644
--- a/package/source/zipapi/makefile.mk
+++ b/package/source/zipapi/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.7 $
+# $Revision: 1.8 $
#
-# last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
+# last change: $Author: mtg $ $Date: 2001-04-27 14:56:06 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -97,15 +97,15 @@ UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb
UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb
UNOTYPES=\
- 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.ZipConstants \
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 \
# --- Targets ------------------------------------------------------
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index f1ec914f77a7..e3a775fb4b1b 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackage.cxx,v $
*
- * $Revision: 1.39 $
+ * $Revision: 1.40 $
*
- * last change: $Author: mtg $ $Date: 2001-04-23 15:34:21 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,6 +64,9 @@
#ifndef _ZIP_PACKAGE_SINK_HXX
#include <ZipPackageSink.hxx>
#endif
+#ifndef _ZIP_ENUMERATION_HXX
+#include <ZipEnumeration.hxx>
+#endif
#ifndef _ZIP_PACKAGE_STREAM_HXX
#include <ZipPackageStream.hxx>
#endif
@@ -112,7 +115,6 @@ ZipPackage::ZipPackage (const Reference < XMultiServiceFactory > &xNewFactory)
, xContentStream (NULL)
, xContentSeek (NULL)
, xRootFolder (NULL)
-, xZipFile (NULL)
, xFactory(xNewFactory)
{
pRootFolder = new ZipPackageFolder();
@@ -121,8 +123,8 @@ ZipPackage::ZipPackage (const Reference < XMultiServiceFactory > &xNewFactory)
ZipPackage::~ZipPackage( void )
{
- if (pContent)
- delete pContent;
+ delete pContent;
+ delete pZipFile;
// As all folders and streams contain references to their parents,
// we must remove these references so that they will be deleted when
// the hash_map of the root folder is cleared, releasing all subfolders
@@ -135,19 +137,18 @@ ZipPackage::~ZipPackage( void )
void ZipPackage::getZipFileContents()
{
- Reference< XEnumeration > xEnum = pZipFile->entries();
+ ZipEnumeration *pEnum = pZipFile->entries();
Reference< XNameContainer > xCurrent;
ZipPackageStream *pPkgStream;
ZipPackageFolder *pPkgFolder;
- ZipEntry aEntry;
Any aAny;
- while (xEnum->hasMoreElements())
+
+ while (pEnum->hasMoreElements())
{
xCurrent = xRootFolder;
- sal_Int32 nOldIndex =0,nIndex = 0;
- aAny = xEnum->nextElement();
- aAny >>= aEntry;
- OUString &rName = aEntry.sName;
+ sal_Int32 nOldIndex = 0,nIndex = 0;
+ const ZipEntry & rEntry = *pEnum->nextElement();
+ const OUString &rName = rEntry.sName;
if (rName.lastIndexOf('/') == rName.getLength()-1)
{
@@ -212,9 +213,9 @@ void ZipPackage::getZipFileContents()
nOldIndex = nIndex+1;
}
OUString sStreamName = rName.copy( nOldIndex, rName.getLength() - nOldIndex);
- pPkgStream = new ZipPackageStream( pZipFile );
- pPkgStream->bPackageMember = sal_True;
- pPkgStream->setZipEntry( aEntry );
+ pPkgStream = new ZipPackageStream( *this );
+ pPkgStream->SetPackageMember( sal_True );
+ pPkgStream->setZipEntry( rEntry );
pPkgStream->setName( sStreamName );
try
{
@@ -241,32 +242,69 @@ void ZipPackage::getZipFileContents()
{
const OUString sFullPath ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
const OUString sMediaType ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
+ const OUString sInitialisationVector ( RTL_CONSTASCII_USTRINGPARAM ( "InitialisationVector" ) );
+ const OUString sSalt ( RTL_CONSTASCII_USTRINGPARAM ( "Salt" ) );
+ const OUString sIterationCount ( RTL_CONSTASCII_USTRINGPARAM ( "IterationCount" ) );
Sequence < Sequence < PropertyValue > > aManifestSequence = xReader->readManifestSequence ( xSink->getInputStream() );
sal_Int32 nLength = aManifestSequence.getLength();
const Sequence < PropertyValue > *pSequence = aManifestSequence.getConstArray();
+ ZipPackageStream *pStream = NULL;
+ ZipPackageFolder *pFolder = NULL;
for (sal_Int32 i = 0; i < nLength ; i++, pSequence++)
{
- OUString sPath;
- Any aValueAny;
+ OUString sPath, sMediaType;
const PropertyValue *pValue = pSequence->getConstArray();
for (sal_Int32 j = 0, nNum = pSequence->getLength(); j < nNum; j++ )
{
if (pValue[j].Name.equals( sFullPath ) )
pValue[j].Value >>= sPath;
else if (pValue[j].Name.equals( sMediaType ) )
- aValueAny = pValue[j].Value;
+ pValue[j].Value >>= sMediaType;
}
- if (sPath.getLength() && aValueAny.getValueTypeClass() == TypeClass_STRING)
+ if (sPath.getLength() && hasByHierarchicalName ( sPath ) )
{
- if ( hasByHierarchicalName ( sPath ) )
+ Any aAny = getByHierarchicalName( sPath );
+ Reference < XUnoTunnel > xTunnel;
+ aAny >>= xTunnel;
+ sal_Int64 nTest=0;
+ if ((nTest = xTunnel->getSomething(ZipPackageFolder::getUnoTunnelImplementationId())) != 0)
+ {
+ pFolder = reinterpret_cast < ZipPackageFolder* > ( nTest );
+ pFolder->SetMediaType ( sMediaType );
+ }
+ else
{
- Any aAny = getByHierarchicalName( sPath );
- Reference < XUnoTunnel > xTunnel;
- aAny >>= xTunnel;
- Reference < XPropertySet > xProps ( xTunnel, UNO_QUERY );
- xProps->setPropertyValue ( sMediaType, aValueAny );
+ pStream = reinterpret_cast < ZipPackageStream* > ( xTunnel->getSomething(ZipPackageStream::getUnoTunnelImplementationId()));
+ pStream->SetMediaType ( sMediaType );
+ pValue = pSequence->getConstArray();
+ sal_Bool bSetEncrypted = sal_False;
+ for (sal_Int32 j = 0, nNum = pSequence->getLength(); j < nNum; j++ )
+ {
+ Sequence < sal_Int8 > aSequence;
+ if (pValue[j].Name.equals( sSalt ) )
+ {
+ pValue[j].Value >>= aSequence;
+ pStream->setSalt ( aSequence );
+ bSetEncrypted = sal_True;
+ }
+ else if (pValue[j].Name.equals( sInitialisationVector ) )
+ {
+ pValue[j].Value >>= aSequence;
+ pStream->setInitialisationVector ( aSequence );
+ bSetEncrypted = sal_True;
+ }
+ else if (pValue[j].Name.equals( sIterationCount ) )
+ {
+ sal_Int64 nCount;
+ pValue[j].Value >>= nCount;
+ pStream->setIterationCount ( nCount );
+ bSetEncrypted = sal_True;
+ }
+ }
+ if (bSetEncrypted)
+ pStream->SetToBeEncrypted ( sal_True );
}
}
}
@@ -290,7 +328,6 @@ void SAL_CALL ZipPackage::initialize( const Sequence< Any >& aArguments )
try
{
pZipFile = new ZipFile(xContentStream, sal_True);
- xZipFile = Reference < XZipFile > ( pZipFile );
getZipFileContents();
}
catch (ZipException&)// rException)
@@ -479,7 +516,7 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName )
Reference< XInterface > SAL_CALL ZipPackage::createInstance( )
throw(Exception, RuntimeException)
{
- Reference < XInterface > xRef = *(new ZipPackageStream ( pZipFile ));
+ Reference < XInterface > xRef = *(new ZipPackageStream ( *this ));
return xRef;
}
Reference< XInterface > SAL_CALL ZipPackage::createInstanceWithArguments( const Sequence< Any >& aArguments )
@@ -491,7 +528,7 @@ Reference< XInterface > SAL_CALL ZipPackage::createInstanceWithArguments( const
if (bArg)
xRef = *new ZipPackageFolder ( );
else
- xRef = *new ZipPackageStream ( pZipFile );
+ xRef = *new ZipPackageStream ( *this );
return xRef;
}
@@ -508,17 +545,14 @@ void SAL_CALL ZipPackage::commitChanges( )
ZipPackageBuffer *pZipBuffer = new ZipPackageBuffer( 65535 );
Reference < XOutputStream > xOutStream (pZipBuffer);
- ZipOutputStream *pZipOut = new ZipOutputStream( xOutStream, 65535 );
+ ZipOutputStream aZipOut ( xOutStream, 65535 );
// Make a reference to the manifest output stream so it persists
// until the call to ZipOutputStream->finish()
Reference < XOutputStream > xManOutStream;
- ZipPackageStream *pManifestStream = NULL;
-
- Reference < XZipOutputStream > xZipOut (pZipOut);
- pZipOut->setMethod(DEFLATED);
- pZipOut->setLevel(DEFAULT_COMPRESSION);
+ aZipOut.setMethod(DEFLATED);
+ aZipOut.setLevel(DEFAULT_COMPRESSION);
// Remove the old META-INF directory as this will be re-generated below.
// Pass save-contents a vector which will be used to store the entries which
@@ -533,12 +567,12 @@ void SAL_CALL ZipPackage::commitChanges( )
Sequence < PropertyValue > aPropSeq ( 2 );
aPropSeq [0].Name = sMediaType;
- aPropSeq [0].Value <<= pRootFolder->getPropertyValue( sMediaType ) ;
+ aPropSeq [0].Value <<= pRootFolder->GetMediaType( );
aPropSeq [1].Name = sFullPath;
aPropSeq [1].Value <<= OUString ( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
aManList.push_back( aPropSeq );
- pRootFolder->saveContents(OUString(), aManList, *pZipOut);
+ pRootFolder->saveContents(OUString(), aManList, aZipOut);
OUString sManifestWriter( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.packages.manifest.ManifestWriter" ) );
Reference < XManifestWriter > xWriter (xFactory->createInstance( sManifestWriter ), UNO_QUERY );
@@ -567,9 +601,10 @@ void SAL_CALL ZipPackage::commitChanges( )
try
{
- pZipOut->putNextEntry(*pEntry);
- pZipOut->write(pBuffer->aBuffer, 0, pEntry->nSize);
- pZipOut->closeEntry();
+ vos::ORef < EncryptionData > xEmpty;
+ aZipOut.putNextEntry(*pEntry, xEmpty);
+ aZipOut.write(pBuffer->aBuffer, 0, pEntry->nSize);
+ aZipOut.closeEntry();
}
catch (::com::sun::star::io::IOException & )
{
@@ -578,7 +613,7 @@ void SAL_CALL ZipPackage::commitChanges( )
}
try
{
- pZipOut->finish();
+ aZipOut.finish();
}
catch (::com::sun::star::io::IOException & )
{
@@ -666,6 +701,7 @@ Any SAL_CALL ZipPackage::queryInterface( const Type& rType )
static_cast< XSingleServiceFactory* > ( this ) ,
static_cast< XUnoTunnel* > ( this ) ,
static_cast< XHierarchicalNameAccess* > ( this ) ,
+ static_cast< XPropertySet* > ( this ) ,
static_cast< XChangesBatch* > ( this ) );
}
@@ -705,3 +741,45 @@ sal_Int64 SAL_CALL ZipPackage::getSomething( const Sequence< sal_Int8 >& aIdenti
return 0;
}
+Reference< XPropertySetInfo > SAL_CALL ZipPackage::getPropertySetInfo( )
+ throw(RuntimeException)
+{
+ return Reference < XPropertySetInfo > (NULL);
+}
+void SAL_CALL ZipPackage::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("EncryptionKey") ) )
+ if (!( aValue >>= aEncryptionKey ) )
+ throw IllegalArgumentException();
+ else
+ throw UnknownPropertyException();
+}
+Any SAL_CALL ZipPackage::getPropertyValue( const OUString& PropertyName )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ Any aAny;
+ if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "EncryptionKey" ) ) )
+ {
+ aAny <<= aEncryptionKey;
+ return aAny;
+ }
+ else
+ throw UnknownPropertyException();
+}
+void SAL_CALL ZipPackage::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+void SAL_CALL ZipPackage::removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& aListener )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+void SAL_CALL ZipPackage::addVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+void SAL_CALL ZipPackage::removeVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
diff --git a/package/source/zippackage/ZipPackageEntry.cxx b/package/source/zippackage/ZipPackageEntry.cxx
index 4276d4b80318..6559464d7db8 100644
--- a/package/source/zippackage/ZipPackageEntry.cxx
+++ b/package/source/zippackage/ZipPackageEntry.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageEntry.cxx,v $
*
- * $Revision: 1.16 $
+ * $Revision: 1.17 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:16:31 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,8 +73,6 @@ using namespace com::sun::star::packages::ZipConstants;
using namespace rtl;
ZipPackageEntry::ZipPackageEntry (void)
-: bPackageMember ( sal_False )
-, bToBeCompressed ( sal_True )
{
}
@@ -147,58 +145,6 @@ uno::Reference< beans::XPropertySetInfo > SAL_CALL ZipPackageEntry::getPropertyS
{
return uno::Reference < beans::XPropertySetInfo > (NULL);
}
-void SAL_CALL ZipPackageEntry::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue )
- throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
-{
- if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("MediaType")))
- {
- aValue >>= sMediaType;
-
- if (sMediaType.getLength() > 0)
- {
- if ( sMediaType.indexOf (OUString( RTL_CONSTASCII_USTRINGPARAM ( "text" ) ) ) != -1)
- bToBeCompressed = sal_True;
- else
- bToBeCompressed = sal_False;
- }
- }
- else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Size") ) )
- aValue >>= aEntry.nSize;
-#if SUPD>617
- else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Compressed") ) )
-#else
- else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Compress") ) )
-#endif
- aValue >>= bToBeCompressed;
- else
- throw beans::UnknownPropertyException();
-}
-uno::Any SAL_CALL ZipPackageEntry::getPropertyValue( const ::rtl::OUString& PropertyName )
- throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
-{
- uno::Any aAny;
- if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) )
- {
- aAny <<= sMediaType;
- return aAny;
- }
- else if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Size" ) ) )
- {
- aAny <<= aEntry.nSize;
- return aAny;
- }
-#if SUPD>617
- else if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Compressed" ) ) )
-#else
- else if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Compress" ) ) )
-#endif
- {
- aAny <<= bToBeCompressed;
- return aAny;
- }
- else
- throw beans::UnknownPropertyException();
-}
void SAL_CALL ZipPackageEntry::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
diff --git a/package/source/zippackage/ZipPackageEntry.hxx b/package/source/zippackage/ZipPackageEntry.hxx
index a89e75d250c1..ef2e41bec7d5 100644
--- a/package/source/zippackage/ZipPackageEntry.hxx
+++ b/package/source/zippackage/ZipPackageEntry.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageEntry.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:15:42 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,13 +85,13 @@ class ZipPackageEntry : public com::sun::star::container::XNamed,
public com::sun::star::lang::XUnoTunnel,
public com::sun::star::beans::XPropertySet
{
-private:
+protected:
com::sun::star::uno::Reference < com::sun::star::uno::XInterface > xParent;
::rtl::OUString sMediaType;
- sal_Bool bToBeCompressed;
public:
com::sun::star::packages::ZipEntry aEntry;
- sal_Bool bPackageMember;
+ ::rtl::OUString & GetMediaType () { return sMediaType; }
+ void SetMediaType ( ::rtl::OUString & sNewType) { sMediaType = sNewType; }
ZipPackageEntry (void);
virtual ~ZipPackageEntry( void );
@@ -124,9 +124,9 @@ public:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
- throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) = 0;
virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
- throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) = 0;
virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index cf25ae64fa19..1ec2cf5f097d 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageFolder.cxx,v $
*
- * $Revision: 1.35 $
+ * $Revision: 1.36 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:16:31 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,6 +79,12 @@
#ifndef _VOS_DIAGNOSE_H_
#include <vos/diagnose.hxx>
#endif
+#ifndef _RTL_RANDOM_H_
+#include <rtl/random.h>
+#endif
+#ifndef _OSL_TIME_H_
+#include <osl/time.h>
+#endif
using namespace com::sun::star::packages::ZipConstants;
using namespace com::sun::star::container;
@@ -92,7 +98,6 @@ using namespace rtl;
using namespace std;
ZipPackageFolder::ZipPackageFolder (void)
-: pPackage( NULL )
{
aEntry.nVersion = -1;
aEntry.nFlag = 0;
@@ -225,10 +230,11 @@ Any SAL_CALL ZipPackageFolder::getByName( const OUString& aName )
sName = aName.copy(1, aName.getLength());
else
sName = aName;
- if (!aContents.count(sName))
+ TunnelHash::const_iterator aCI = aContents.find(sName);
+
+ if (aCI == aContents.end())
throw NoSuchElementException();
- TunnelHash::const_iterator aCI = aContents.find(sName);
aAny <<= (*aCI).second;
return aAny;
}
@@ -275,6 +281,15 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
TunnelHash::const_iterator aCI = aContents.begin(), aEnd = aContents.end();
const OUString sMediaType ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
const OUString sFullPath ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
+ const OUString sInitialisationVector ( RTL_CONSTASCII_USTRINGPARAM ( "InitialisationVector" ) );
+ const OUString sSalt ( RTL_CONSTASCII_USTRINGPARAM ( "Salt" ) );
+ const OUString sIterationCount ( RTL_CONSTASCII_USTRINGPARAM ( "IterationCount" ) );
+
+ // Get a random number generator and seed it with current timestamp
+ TimeValue aTime;
+ osl_getSystemTime( &aTime );
+ rtlRandomPool aRandomPool = rtl_random_createPool ();
+ rtl_random_addBytes ( aRandomPool, &aTime, 8 );
for (; aCI!=aEnd ; aCI++)
{
@@ -314,35 +329,24 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
try
{
- rZipOut.putNextEntry(*pTempEntry);
+ vos::ORef < EncryptionData > xEmpty;
+ rZipOut.putNextEntry(*pTempEntry, xEmpty);
rZipOut.closeEntry();
}
catch (IOException & )
{
VOS_ENSURE( 0, "Error writing ZipOutputStream" );
}
- try
- {
- aPropSet[1].Name = sMediaType;
- aPropSet[1].Value <<= pFolder->getPropertyValue(OUString( RTL_CONSTASCII_USTRINGPARAM ( "MediaType") ) );
- }
- catch (UnknownPropertyException & )
- {
- VOS_ENSURE( 0, "MediaType is an unknown property!!" );
- }
- // Then copy it back
+ aPropSet[0].Name = sMediaType;
+ aPropSet[0].Value <<= pFolder->GetMediaType();
+ aPropSet[1].Name = sFullPath;
+ aPropSet[1].Value <<= pFolder->aEntry.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;
- try
- {
- aPropSet[0].Name = sFullPath;
- aPropSet[0].Value <<= pFolder->aEntry.sName;
- }
- catch (UnknownPropertyException & )
- {
- VOS_ENSURE( 0, "MediaType is an unknown property!!" );
- }
pFolder->saveContents(pFolder->aEntry.sName, rManList, rZipOut);
pFolder->aEntry.sName = (*aCI).first;
}
@@ -351,20 +355,39 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
// In case the entry we are reading is also the entry we are writing, we will
// store the ZipEntry data in pTempEntry
-#if SUPD>617
- Any aAny = pStream->getPropertyValue(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Compressed") ) );
-#else
- Any aAny = pStream->getPropertyValue(OUString( RTL_CONSTASCII_USTRINGPARAM ( "Compress") ) );
-#endif
- sal_Bool bToBeCompressed;
- aAny >>= bToBeCompressed;
-
ZipPackageFolder::copyZipEntry ( *pTempEntry, pStream->aEntry );
pTempEntry->sName = rPath + (*aCI).first;
+ sal_Bool bToBeCompressed = pStream->IsToBeCompressed();
+ sal_Bool bToBeEncrypted = pStream->IsToBeEncrypted();
+
+ aPropSet[0].Name = sMediaType;
+ aPropSet[0].Value <<= pStream->GetMediaType( );
+ aPropSet[1].Name = sFullPath;
+ aPropSet[1].Value <<= pStream->aEntry.sName;
+
+ if ( bToBeEncrypted)
+ {
+ Sequence < sal_Int8 > aSalt ( 16 ), aVector ( 8 );
+ rtl_random_getBytes ( aRandomPool, aSalt.getArray(), 16 );
+ rtl_random_getBytes ( aRandomPool, aVector.getArray(), 8 );
+ sal_Int64 nIterationCount = 1024;
+
+ pStream->setInitialisationVector ( aVector );
+ pStream->setSalt ( aSalt );
+ pStream->setIterationCount ( nIterationCount );
+
+ aPropSet.realloc(5);
+ aPropSet[2].Name = sInitialisationVector;
+ aPropSet[2].Value <<= aVector;
+ aPropSet[3].Name = sSalt;
+ aPropSet[3].Value <<= aSalt;
+ aPropSet[4].Name = sIterationCount;
+ aPropSet[4].Value <<= nIterationCount;
+ }
// If the entry is already stored in the zip file in the format we
// want for this write...copy it raw
- if (pStream->bPackageMember &&
+ if (pStream->IsPackageMember() &&
( (pTempEntry->nMethod == DEFLATED && bToBeCompressed) ||
(pTempEntry->nMethod == STORED && !bToBeCompressed) ) )
{
@@ -373,7 +396,7 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
Reference < XInputStream > xStream = pStream->getRawStream( *pTempEntry );
try
{
- rZipOut.putNextEntry ( *pTempEntry );
+ rZipOut.putNextEntry ( *pTempEntry, pStream->getEncryptionData(), bToBeEncrypted );
while (1)
{
Sequence < sal_Int8 > aSeq (65535);
@@ -405,11 +428,7 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
pTempEntry->nCrc = -1;
pTempEntry->nSize = -1;
pTempEntry->nCompressedSize = -1;
-
- if (bToBeCompressed)
- pTempEntry->nMethod = DEFLATED;
- else
- pTempEntry->nMethod = STORED;
+ pTempEntry->nMethod = bToBeCompressed ? DEFLATED : STORED;
if (xSeek.is())
{
@@ -426,7 +445,7 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
try
{
- rZipOut.putNextEntry ( *pTempEntry );
+ rZipOut.putNextEntry ( *pTempEntry, pStream->getEncryptionData(), bToBeEncrypted );
while (1)
{
Sequence < sal_Int8 > aSeq (65535);
@@ -442,7 +461,7 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
}
if (bTrackLength)
pTempEntry->nCompressedSize = pStream->aEntry.nSize;
- pStream->bPackageMember = sal_True;
+ pStream->SetPackageMember ( sal_True );
rZipOut.closeEntry();
}
catch (IOException & )
@@ -451,32 +470,12 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
}
}
- try
- {
- aPropSet[0].Name = sFullPath;
- aPropSet[0].Value <<= pStream->aEntry.sName;
- }
- catch (UnknownPropertyException & )
- {
- VOS_ENSURE( 0, "MediaType is an unknown property!!" );
- }
- try
- {
- aPropSet[1].Name = sMediaType;
- aPropSet[1].Value <<= pStream->getPropertyValue( sMediaType );
- }
- catch (UnknownPropertyException & )
- {
- VOS_ENSURE( 0, "MediaType is an unknown property!!" );
- }
+
// Then copy it back afterwards...
ZipPackageFolder::copyZipEntry ( pStream->aEntry, *pTempEntry );
pStream->aEntry.sName = (*aCI).first;
pStream->aEntry.nOffset *= -1;
}
- OUString aString, bString;
- aPropSet[0].Value >>= aString;
- aPropSet[1].Value >>= bString;
rManList.push_back (aPropSet);
}
}
@@ -514,48 +513,6 @@ void ZipPackageFolder::releaseUpwardRef( void )
pStream->clearParent();
}
}
-void ZipPackageFolder::updateReferences( ZipFile * pNewZipFile)
-{
- Reference < XUnoTunnel > xTunnel;
- ZipPackageFolder *pFolder = NULL;
- ZipPackageStream *pStream = NULL;
- sal_Bool bIsFolder;
- TunnelHash::const_iterator aCI = aContents.begin();
-
- for (;aCI!=aContents.end();aCI++)
- {
- xTunnel = Reference < XUnoTunnel> ((*aCI).second, UNO_QUERY);
- sal_Int64 nTest=0;
- if ((nTest = xTunnel->getSomething(ZipPackageFolder::getUnoTunnelImplementationId())) != 0)
- {
- pFolder = reinterpret_cast < ZipPackageFolder* > ( nTest );
- bIsFolder = sal_True;
- }
- else
- {
- // If this getSomething call returns 0, it means that
- // something evil has crept into the contents hash_map, which
- // should mean that something has gone very wrong somewhere, and someone
- // else should deal with it
-
- nTest = xTunnel->getSomething(ZipPackageStream::getUnoTunnelImplementationId());
- if (nTest == 0)
- throw RuntimeException();
- pStream = reinterpret_cast < ZipPackageStream* > ( nTest );
- bIsFolder = sal_False;
- }
-
- if (bIsFolder)
- {
- //if pPackage is set,then this is the root folder of a different ZipPackage and
- // should not be changed
- if (!pFolder->pPackage)
- pFolder->updateReferences(pNewZipFile);
- }
- else
- pStream->pZipFile = pNewZipFile;
- }
-}
Sequence< sal_Int8 > ZipPackageFolder::getUnoTunnelImplementationId( void )
throw (RuntimeException)
@@ -581,3 +538,30 @@ sal_Int64 SAL_CALL ZipPackageFolder::getSomething( const Sequence< sal_Int8 >& a
return 0;
}
+void SAL_CALL ZipPackageFolder::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("MediaType")))
+ aValue >>= sMediaType;
+ else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Size") ) )
+ aValue >>= aEntry.nSize;
+ else
+ throw UnknownPropertyException();
+}
+Any SAL_CALL ZipPackageFolder::getPropertyValue( const OUString& PropertyName )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ Any aAny;
+ if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) )
+ {
+ aAny <<= sMediaType;
+ return aAny;
+ }
+ else if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Size" ) ) )
+ {
+ aAny <<= aEntry.nSize;
+ return aAny;
+ }
+ else
+ throw UnknownPropertyException();
+}
diff --git a/package/source/zippackage/ZipPackageFolderEnumeration.hxx b/package/source/zippackage/ZipPackageFolderEnumeration.hxx
index dcffd3d51c8e..49b8fa09a22e 100644
--- a/package/source/zippackage/ZipPackageFolderEnumeration.hxx
+++ b/package/source/zippackage/ZipPackageFolderEnumeration.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageFolderEnumeration.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:15:53 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,7 +75,7 @@ class ZipPackageFolderEnumeration : public cppu::WeakImplHelper1<
com::sun::star::container::XEnumeration
>
{
-private:
+protected:
TunnelHash &rContents;
TunnelHash::const_iterator aIterator;
public:
diff --git a/package/source/zippackage/ZipPackageSink.hxx b/package/source/zippackage/ZipPackageSink.hxx
index 3e1cf1802b00..80bfde7a3c0c 100644
--- a/package/source/zippackage/ZipPackageSink.hxx
+++ b/package/source/zippackage/ZipPackageSink.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageSink.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:15:31 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,7 +71,7 @@
class ZipPackageSink : public com::sun::star::io::XActiveDataSink,
public cppu::OWeakObject
{
-private:
+protected:
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
public:
ZipPackageSink(void);
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index b68e3f217c87..ea82be5a0212 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageStream.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:16:31 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,6 +62,9 @@
#ifndef _ZIP_PACKAGE_STREAM_HXX
#include <ZipPackageStream.hxx>
#endif
+#ifndef _ZIP_PACKAGE_HXX
+#include <ZipPackage.hxx>
+#endif
#ifndef _ZIP_FILE_HXX
#include <ZipFile.hxx>
#endif
@@ -69,13 +72,18 @@
#include <vos/diagnose.hxx>
#endif
-
-
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
using namespace com::sun::star;
using namespace cppu;
+using namespace rtl;
-ZipPackageStream::ZipPackageStream (ZipFile *pInFile)
-: pZipFile(pInFile)
+ZipPackageStream::ZipPackageStream (ZipPackage & rNewPackage )
+: rZipPackage(rNewPackage)
+, bToBeCompressed ( sal_False )
+, bToBeEncrypted ( sal_False )
+, bPackageMember ( sal_False )
+, xEncryptionData ( new EncryptionData )
{
aEntry.nVersion = -1;
aEntry.nFlag = 0;
@@ -106,17 +114,17 @@ void ZipPackageStream::setZipEntry( const packages::ZipEntry &rInEntry)
aEntry.sComment = rInEntry.sComment;
}
//XInterface
-uno::Any SAL_CALL ZipPackageStream::queryInterface( const uno::Type& rType )
- throw(uno::RuntimeException)
+Any SAL_CALL ZipPackageStream::queryInterface( const Type& rType )
+ throw(RuntimeException)
{
return ( ::cppu::queryInterface ( rType ,
// OWeakObject interfaces
- reinterpret_cast< uno::XInterface* > ( this ) ,
- static_cast< uno::XWeak* > ( this ) ,
+ reinterpret_cast< XInterface* > ( this ) ,
+ static_cast< XWeak* > ( this ) ,
// ZipPackageEntry interfaces
static_cast< container::XNamed* > ( this ) ,
static_cast< container::XChild* > ( this ) ,
- static_cast< lang::XUnoTunnel* > ( this ) ,
+ static_cast< XUnoTunnel* > ( this ) ,
// My own interfaces
static_cast< io::XActiveDataSink* > ( this ) ,
static_cast< beans::XPropertySet* > ( this ) ) );
@@ -135,53 +143,55 @@ void SAL_CALL ZipPackageStream::release( )
}
// XActiveDataSink
-void SAL_CALL ZipPackageStream::setInputStream( const uno::Reference< io::XInputStream >& aStream )
- throw(uno::RuntimeException)
+void SAL_CALL ZipPackageStream::setInputStream( const Reference< io::XInputStream >& aStream )
+ throw(RuntimeException)
{
xStream = aStream;
- bPackageMember = sal_False;
+ SetPackageMember ( sal_False );
aEntry.nTime = -1;
}
-uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawStream( com::sun::star::packages::ZipEntry &rEntry )
- throw(uno::RuntimeException)
+Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawStream( com::sun::star::packages::ZipEntry &rEntry )
+ throw(RuntimeException)
{
- if (bPackageMember)
+ if (IsPackageMember())
{
try
{
- return pZipFile->getRawStream(rEntry);
+ return rZipPackage.getZipFile().getRawStream(rEntry, xEncryptionData);
}
catch (packages::ZipException &)//rException)
{
VOS_ENSURE( 0, "ZipException thrown");//rException.Message);
- return uno::Reference < io::XInputStream > ();
+ return Reference < io::XInputStream > ();
}
}
else
return xStream;
}
-uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getInputStream( )
- throw(uno::RuntimeException)
+Reference< io::XInputStream > SAL_CALL ZipPackageStream::getInputStream( )
+ throw(RuntimeException)
{
- if (bPackageMember)
+ if (IsPackageMember())
{
try
{
- return pZipFile->getInputStream(aEntry);
+ return rZipPackage.getZipFile().getInputStream( aEntry, xEncryptionData);
}
catch (packages::ZipException &)//rException)
{
VOS_ENSURE( 0,"ZipException thrown");//rException.Message);
- return uno::Reference < io::XInputStream > ();
+ return Reference < io::XInputStream > ();
}
}
else
return xStream;
}
-uno::Sequence< sal_Int8 > ZipPackageStream::getUnoTunnelImplementationId( void )
- throw (uno::RuntimeException)
+
+// XPropertySet
+Sequence< sal_Int8 > ZipPackageStream::getUnoTunnelImplementationId( void )
+ throw (RuntimeException)
{
static ::cppu::OImplementationId * pId = 0;
if (! pId)
@@ -196,8 +206,8 @@ uno::Sequence< sal_Int8 > ZipPackageStream::getUnoTunnelImplementationId( void )
return pId->getImplementationId();
}
-sal_Int64 SAL_CALL ZipPackageStream::getSomething( const uno::Sequence< sal_Int8 >& aIdentifier )
- throw(uno::RuntimeException)
+sal_Int64 SAL_CALL ZipPackageStream::getSomething( const Sequence< sal_Int8 >& aIdentifier )
+ throw(RuntimeException)
{
if (aIdentifier.getLength() == 16 &&
0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(),
@@ -206,3 +216,67 @@ sal_Int64 SAL_CALL ZipPackageStream::getSomething( const uno::Sequence< sal_Int8
return 0;
}
+void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("MediaType")))
+ {
+ aValue >>= sMediaType;
+
+ if (sMediaType.getLength() > 0)
+ {
+ if ( sMediaType.indexOf (OUString( RTL_CONSTASCII_USTRINGPARAM ( "text" ) ) ) != -1)
+ bToBeCompressed = sal_True;
+ else
+ bToBeCompressed = sal_False;
+ }
+ }
+ else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Size") ) )
+ aValue >>= aEntry.nSize;
+ else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Encrypted") ) )
+ aValue >>= bToBeEncrypted;
+#if SUPD>617
+ else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Compressed") ) )
+#else
+ else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Compress") ) )
+#endif
+ aValue >>= bToBeCompressed;
+ else
+ throw beans::UnknownPropertyException();
+}
+Any SAL_CALL ZipPackageStream::getPropertyValue( const OUString& PropertyName )
+ throw(beans::UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ Any aAny;
+ if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) )
+ {
+ aAny <<= sMediaType;
+ return aAny;
+ }
+ else if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Size" ) ) )
+ {
+ aAny <<= aEntry.nSize;
+ return aAny;
+ }
+ else if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Encrypted" ) ) )
+ {
+ aAny <<= bToBeEncrypted;
+ return aAny;
+ }
+#if SUPD>617
+ else if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Compressed" ) ) )
+#else
+ else if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Compress" ) ) )
+#endif
+ {
+ aAny <<= bToBeCompressed;
+ return aAny;
+ }
+ else
+ throw beans::UnknownPropertyException();
+}
+
+const com::sun::star::uno::Sequence < sal_Int8 >& ZipPackageStream::getEncryptionKey ()
+{
+ return rZipPackage.getEncryptionKey();
+}
diff --git a/package/source/zippackage/ZipPackageStream.hxx b/package/source/zippackage/ZipPackageStream.hxx
index 5cf456905cb5..75524abfee30 100644
--- a/package/source/zippackage/ZipPackageStream.hxx
+++ b/package/source/zippackage/ZipPackageStream.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageStream.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2001-04-19 14:15:10 $
+ * last change: $Author: mtg $ $Date: 2001-04-27 14:56:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,17 +73,48 @@
#ifndef _ZIP_PACKAGE_ENTRY_HXX
#include <ZipPackageEntry.hxx>
#endif
+#ifndef _VOS_REF_H_
+#include <vos/ref.hxx>
+#endif
+#ifndef _ENCRYPTION_DATA_HXX_
+#include <EncryptionData.hxx>
+#endif
-class ZipFile;
+class ZipPackage;
class ZipPackageStream : public ZipPackageEntry,
public ::cppu::OWeakObject,
public ::com::sun::star::io::XActiveDataSink
{
-private:
+protected:
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
+ ZipPackage &rZipPackage;
+ sal_Bool bToBeCompressed, bToBeEncrypted, bPackageMember;
+ vos::ORef < EncryptionData > xEncryptionData;
public:
- ZipFile *pZipFile;
- ZipPackageStream (ZipFile *pInFile);
+ inline sal_Bool IsToBeCompressed () { return bToBeCompressed;}
+ inline sal_Bool IsToBeEncrypted () { return bToBeEncrypted;}
+ inline sal_Bool IsPackageMember () { return bPackageMember;}
+ const com::sun::star::uno::Sequence < sal_Int8 >& getEncryptionKey ();
+ const vos::ORef < EncryptionData > & getEncryptionData ()
+ { return xEncryptionData;}
+ const com::sun::star::uno::Sequence < sal_Int8 >& getInitialisationVector ()
+ { return xEncryptionData->aInitVector;}
+ const com::sun::star::uno::Sequence < sal_Int8 >& getSalt ()
+ { return xEncryptionData->aSalt;}
+ const sal_Int64 getIterationCount ()
+ { return xEncryptionData->nIterationCount;}
+
+ inline void SetToBeCompressed (sal_Bool bNewValue) { bToBeCompressed = bNewValue;}
+ inline void SetToBeEncrypted (sal_Bool bNewValue) { bToBeEncrypted = bNewValue;}
+ inline void SetPackageMember (sal_Bool bNewValue) { bPackageMember = bNewValue;}
+ inline void setInitialisationVector (const com::sun::star::uno::Sequence < sal_Int8 >& rNewVector )
+ { xEncryptionData->aInitVector = rNewVector;}
+ inline void setSalt (const com::sun::star::uno::Sequence < sal_Int8 >& rNewSalt )
+ { xEncryptionData->aSalt = rNewSalt;}
+ inline void setIterationCount (const sal_Int64 nNewCount)
+ { xEncryptionData->nIterationCount = nNewCount;}
+
+ ZipPackageStream (ZipPackage & rNewPackage);
virtual ~ZipPackageStream( void );
void setZipEntry( const com::sun::star::packages::ZipEntry &rInEntry);
@@ -109,5 +140,11 @@ public:
throw(::com::sun::star::uno::RuntimeException);
virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
};
#endif
diff --git a/package/util/makefile.mk b/package/util/makefile.mk
index fed922fc0ca3..ff55409fc79d 100644
--- a/package/util/makefile.mk
+++ b/package/util/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.6 $
+# $Revision: 1.7 $
#
-# last change: $Author: mtg $ $Date: 2001-04-19 14:12:12 $
+# last change: $Author: mtg $ $Date: 2001-04-27 14:56:07 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -91,11 +91,9 @@ SHL1IMPLIB=i$(TARGET)
SHL1VERSIONMAP=exports.map
SHL1STDLIBS=\
- $(VOSLIB) \
$(CPPULIB) \
$(UCBHELPERLIB) \
$(CPPUHELPERLIB) \
- $(COMPHELPERLIB) \
$(SALLIB) \
$(ZLIB3RDLIB)