summaryrefslogtreecommitdiff
path: root/package/inc
diff options
context:
space:
mode:
Diffstat (limited to 'package/inc')
-rw-r--r--package/inc/ByteChucker.hxx67
-rw-r--r--package/inc/ByteGrabber.hxx77
-rw-r--r--package/inc/CRC32.hxx56
-rw-r--r--package/inc/Deflater.hxx66
-rw-r--r--package/inc/EncryptedDataHeader.hxx51
-rw-r--r--package/inc/EncryptionData.hxx43
-rw-r--r--package/inc/HashMaps.hxx63
-rw-r--r--package/inc/Inflater.hxx57
-rw-r--r--package/inc/PackageConstants.hxx52
-rw-r--r--package/inc/ZipEntry.hxx46
-rw-r--r--package/inc/ZipEnumeration.hxx43
-rw-r--r--package/inc/ZipFile.hxx198
-rw-r--r--package/inc/ZipOutputStream.hxx103
-rw-r--r--package/inc/ZipPackage.hxx189
-rw-r--r--package/inc/ZipPackageBuffer.hxx84
-rw-r--r--package/inc/ZipPackageFolder.hxx144
-rw-r--r--package/inc/makefile.mk47
-rw-r--r--package/inc/mutexholder.hxx131
-rw-r--r--package/inc/pch/precompiled_package.cxx29
-rw-r--r--package/inc/pch/precompiled_package.hxx32
-rw-r--r--package/inc/zipfileaccess.hxx109
21 files changed, 1687 insertions, 0 deletions
diff --git a/package/inc/ByteChucker.hxx b/package/inc/ByteChucker.hxx
new file mode 100644
index 000000000000..d0a07cdfadaf
--- /dev/null
+++ b/package/inc/ByteChucker.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BYTE_CHUCKER_HXX_
+#define _BYTE_CHUCKER_HXX_
+
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/io/BufferSizeExceededException.hpp>
+#include <com/sun/star/io/IOException.hpp>
+#include <com/sun/star/io/NotConnectedException.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+
+namespace com { namespace sun { namespace star {
+ namespace io { class XSeekable; class XOutputStream; }
+} } }
+class ByteChucker
+{
+protected:
+ com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > xStream;
+ com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
+ com::sun::star::uno::Sequence < sal_Int8 > a1Sequence, a2Sequence, a4Sequence;
+ sal_Int8 * const p1Sequence, * const p2Sequence, * const p4Sequence;
+
+public:
+ ByteChucker (com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> xOstream);
+ ~ByteChucker();
+
+ void 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);
+
+ sal_Int64 GetPosition()
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ ByteChucker& operator << (sal_Int8 nInt8);
+ ByteChucker& operator << (sal_Int16 nInt16);
+ ByteChucker& operator << (sal_Int32 nInt32);
+ ByteChucker& operator << (sal_uInt8 nuInt8);
+ ByteChucker& operator << (sal_uInt16 nuInt16);
+ ByteChucker& operator << (sal_uInt32 nuInt32);
+};
+
+#endif
diff --git a/package/inc/ByteGrabber.hxx b/package/inc/ByteGrabber.hxx
new file mode 100644
index 000000000000..8ef127900655
--- /dev/null
+++ b/package/inc/ByteGrabber.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BYTE_GRABBER_HXX_
+#define _BYTE_GRABBER_HXX_
+
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/io/BufferSizeExceededException.hpp>
+#include <com/sun/star/io/IOException.hpp>
+#include <com/sun/star/io/NotConnectedException.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+
+#include <osl/mutex.hxx>
+
+namespace com { namespace sun { namespace star {
+ namespace io { class XSeekable; class XInputStream; }
+} } }
+class ByteGrabber
+{
+protected:
+ ::osl::Mutex m_aMutex;
+
+ com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
+ com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
+ com::sun::star::uno::Sequence < sal_Int8 > aSequence;
+ const sal_Int8 *pSequence;
+
+public:
+ ByteGrabber (com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xIstream);
+ ~ByteGrabber();
+
+ void setInputStream (com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewStream);
+ // XInputStream
+ 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);
+ // XSeekable
+ sal_Int64 SAL_CALL seek( sal_Int64 location )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ sal_Int64 SAL_CALL getPosition( )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ sal_Int64 SAL_CALL getLength( )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ ByteGrabber& operator >> (sal_Int8& rInt8);
+ ByteGrabber& operator >> (sal_Int16& rInt16);
+ ByteGrabber& operator >> (sal_Int32& rInt32);
+ ByteGrabber& operator >> (sal_uInt8& ruInt8);
+ ByteGrabber& operator >> (sal_uInt16& ruInt16);
+ ByteGrabber& operator >> (sal_uInt32& ruInt32);
+};
+
+#endif
diff --git a/package/inc/CRC32.hxx b/package/inc/CRC32.hxx
new file mode 100644
index 000000000000..b8de389c8721
--- /dev/null
+++ b/package/inc/CRC32.hxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _CRC32_HXX
+#define _CRC32_HXX
+
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/uno/RuntimeException.hpp>
+
+namespace com { namespace sun { namespace star {
+ namespace io { class XInputStream; }
+} } }
+class CRC32
+{
+protected:
+ sal_uInt32 nCRC;
+public:
+ CRC32();
+ ~CRC32();
+
+ sal_Int32 SAL_CALL updateStream (::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > & xStream)
+ throw(::com::sun::star::uno::RuntimeException);
+ 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);
+ void SAL_CALL update(const ::com::sun::star::uno::Sequence< sal_Int8 > &b)
+ throw(::com::sun::star::uno::RuntimeException);
+ sal_Int32 SAL_CALL getValue()
+ throw(::com::sun::star::uno::RuntimeException);
+ void SAL_CALL reset()
+ throw(::com::sun::star::uno::RuntimeException);
+};
+
+#endif
diff --git a/package/inc/Deflater.hxx b/package/inc/Deflater.hxx
new file mode 100644
index 000000000000..f39b8e2b9547
--- /dev/null
+++ b/package/inc/Deflater.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _DEFLATER_HXX_
+#define _DEFLATER_HXX_
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+extern "C"
+{
+ typedef struct z_stream_s z_stream;
+}
+
+class Deflater
+{
+protected:
+ com::sun::star::uno::Sequence< sal_Int8 > sInBuffer;
+ sal_Bool bFinish;
+ sal_Bool bFinished;
+ sal_Bool bSetParams;
+ sal_Int32 nLevel, nStrategy;
+ sal_Int32 nOffset, nLength;
+ z_stream* pStream;
+
+ void init (sal_Int32 nLevel, sal_Int32 nStrategy, sal_Bool bNowrap);
+ sal_Int32 doDeflateBytes (com::sun::star::uno::Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength);
+
+public:
+ ~Deflater();
+ Deflater(sal_Int32 nSetLevel, sal_Bool bNowrap);
+ void SAL_CALL setInputSegment( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength );
+ void SAL_CALL setLevel( sal_Int32 nNewLevel );
+ sal_Bool SAL_CALL needsInput( );
+ void SAL_CALL finish( );
+ sal_Bool SAL_CALL finished( );
+ sal_Int32 SAL_CALL doDeflateSegment( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength );
+ sal_Int32 SAL_CALL getTotalIn( );
+ sal_Int32 SAL_CALL getTotalOut( );
+ void SAL_CALL reset( );
+ void SAL_CALL end( );
+};
+
+#endif
diff --git a/package/inc/EncryptedDataHeader.hxx b/package/inc/EncryptedDataHeader.hxx
new file mode 100644
index 000000000000..a166397cce34
--- /dev/null
+++ b/package/inc/EncryptedDataHeader.hxx
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _ENCRYPTED_DATA_HEADER_HXX_
+#define _ENCRYPTED_DATA_HEADER_HXX_
+
+#include <sal/types.h>
+
+/* The structure of this header is as follows:
+
+ Header signature 4 bytes
+ Version number 2 bytes
+ Iteraction count 4 bytes
+ Size 4 bytes
+ Salt length 2 bytes
+ IV length 2 bytes
+ Digest length 2 bytes
+ MediaType length 2 bytes
+ Salt content X bytes
+ IV content X bytes
+ digest content X bytes
+ MediaType X bytes
+
+*/
+const sal_uInt32 n_ConstHeader = 0x0502474dL; // "MG\002\005"
+const sal_Int32 n_ConstHeaderSize = 22; // + salt length + iv length + digest length + mediatype length
+const sal_Int16 n_ConstCurrentVersion = 1;
+#endif
diff --git a/package/inc/EncryptionData.hxx b/package/inc/EncryptionData.hxx
new file mode 100644
index 000000000000..66d74f739b9c
--- /dev/null
+++ b/package/inc/EncryptionData.hxx
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _ENCRYPTION_DATA_HXX_
+#define _ENCRYPTION_DATA_HXX_
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <cppuhelper/weak.hxx>
+
+class EncryptionData : public cppu::OWeakObject
+{
+public:
+ // On export aKey holds the derived key
+ // On import aKey holds the hash of the user enterred key
+ com::sun::star::uno::Sequence < sal_Int8 > aKey;
+ com::sun::star::uno::Sequence < sal_uInt8 > aSalt, aInitVector, aDigest;
+ sal_Int32 nIterationCount;
+ EncryptionData(): nIterationCount ( 0 ){}
+};
+#endif
diff --git a/package/inc/HashMaps.hxx b/package/inc/HashMaps.hxx
new file mode 100644
index 000000000000..b10f42aa7020
--- /dev/null
+++ b/package/inc/HashMaps.hxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _HASHMAPS_HXX
+#define _HASHMAPS_HXX
+
+#include <ZipEntry.hxx>
+#include <vos/ref.hxx>
+#include <hash_map>
+
+struct eqFunc
+{
+ sal_Bool operator()( const rtl::OUString &r1,
+ const rtl::OUString &r2) const
+ {
+ return r1 == r2;
+ }
+};
+
+class ZipPackageFolder;
+namespace com { namespace sun { namespace star { namespace packages {
+class ContentInfo;
+} } } }
+
+typedef std::hash_map < rtl::OUString,
+ ZipPackageFolder *,
+ ::rtl::OUStringHash,
+ eqFunc > FolderHash;
+
+typedef std::hash_map < rtl::OUString,
+ vos::ORef < com::sun::star::packages::ContentInfo >,
+ ::rtl::OUStringHash,
+ eqFunc > ContentHash;
+
+typedef std::hash_map < rtl::OUString,
+ ZipEntry,
+ rtl::OUStringHash,
+ eqFunc > EntryHash;
+
+#endif
diff --git a/package/inc/Inflater.hxx b/package/inc/Inflater.hxx
new file mode 100644
index 000000000000..26c903ae5c47
--- /dev/null
+++ b/package/inc/Inflater.hxx
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _INFLATER_HXX_
+#define _INFLATER_HXX_
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+extern "C"
+{
+ typedef struct z_stream_s z_stream;
+}
+class Inflater
+{
+protected:
+ sal_Bool bFinish, bFinished, bSetParams, bNeedDict;
+ sal_Int32 nOffset, nLength, nLastInflateError;
+ z_stream* pStream;
+ com::sun::star::uno::Sequence < sal_Int8 > sInBuffer;
+ sal_Int32 doInflateBytes (com::sun::star::uno::Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength);
+
+public:
+ Inflater(sal_Bool bNoWrap = sal_False);
+ ~Inflater();
+ void SAL_CALL setInput( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer );
+ sal_Bool SAL_CALL needsDictionary( );
+ sal_Bool SAL_CALL finished( );
+ sal_Int32 SAL_CALL doInflateSegment( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength );
+ void SAL_CALL end( );
+
+ sal_Int32 getLastInflateError() { return nLastInflateError; }
+};
+
+#endif
diff --git a/package/inc/PackageConstants.hxx b/package/inc/PackageConstants.hxx
new file mode 100644
index 000000000000..a23a22fcb888
--- /dev/null
+++ b/package/inc/PackageConstants.hxx
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _PACKAGE_CONSTANTS_HXX_
+#define _PACKAGE_CONSTANTS_HXX_
+
+#include <sal/types.h>
+
+const sal_Int32 n_ConstBufferSize = 32768;
+const sal_Int32 n_ConstMaxMemoryStreamSize = 20480;
+const sal_Int32 n_ConstDigestLength = 1024;
+
+// the constants related to the manifest.xml entries
+#define PKG_MNFST_MEDIATYPE 0
+#define PKG_MNFST_VERSION 1
+#define PKG_MNFST_FULLPATH 2
+
+#define PKG_MNFST_INIVECTOR 3
+#define PKG_MNFST_SALT 4
+#define PKG_MNFST_ITERATION 5
+#define PKG_MNFST_UCOMPSIZE 6
+#define PKG_MNFST_DIGEST 7
+
+#define PKG_SIZE_NOENCR_MNFST 3
+#define PKG_SIZE_ENCR_MNFST 8
+
+
+#endif
+
diff --git a/package/inc/ZipEntry.hxx b/package/inc/ZipEntry.hxx
new file mode 100644
index 000000000000..4f47f25a1329
--- /dev/null
+++ b/package/inc/ZipEntry.hxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _ZIP_ENTRY_HXX_
+#define _ZIP_ENTRY_HXX_
+
+#include <rtl/ustring.hxx>
+
+struct ZipEntry
+{
+ sal_Int16 nVersion;
+ sal_Int16 nFlag;
+ sal_Int16 nMethod;
+ sal_Int32 nTime;
+ sal_Int32 nCrc;
+ sal_Int32 nCompressedSize;
+ sal_Int32 nSize;
+ sal_Int32 nOffset;
+ sal_Int16 nPathLen;
+ sal_Int16 nExtraLen;
+ ::rtl::OUString sPath;
+};
+#endif
diff --git a/package/inc/ZipEnumeration.hxx b/package/inc/ZipEnumeration.hxx
new file mode 100644
index 000000000000..967007ade78d
--- /dev/null
+++ b/package/inc/ZipEnumeration.hxx
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _ZIP_ENUMERATION_HXX
+#define _ZIP_ENUMERATION_HXX
+
+#include <HashMaps.hxx>
+
+class ZipEnumeration
+{
+protected:
+ EntryHash &rEntryHash;
+ EntryHash::const_iterator aIterator;
+public:
+ sal_Bool SAL_CALL hasMoreElements();
+ const ZipEntry * SAL_CALL nextElement();
+ ZipEnumeration( EntryHash &rNewEntryHash );
+ ~ZipEnumeration();
+};
+#endif
diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx
new file mode 100644
index 000000000000..be8158c0ba4e
--- /dev/null
+++ b/package/inc/ZipFile.hxx
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _ZIP_FILE_HXX
+#define _ZIP_FILE_HXX
+
+#include <com/sun/star/packages/zip/ZipException.hpp>
+#include <com/sun/star/packages/zip/ZipIOException.hpp>
+#include <com/sun/star/packages/NoEncryptionException.hpp>
+#include <com/sun/star/packages/WrongPasswordException.hpp>
+#include <ByteGrabber.hxx>
+#include <HashMaps.hxx>
+#ifndef _INFLATER_HXX
+#include <Inflater.hxx>
+#endif
+
+#include <mutexholder.hxx>
+
+namespace com { namespace sun { namespace star {
+ namespace lang { class XMultiServiceFactory; }
+ namespace ucb { class XProgressHandler; }
+} } }
+namespace vos
+{
+ template < class T > class ORef;
+}
+/*
+ * We impose arbitrary but reasonable limit on ZIP files.
+ */
+
+#define ZIP_MAXNAMELEN 512
+#define ZIP_MAXEXTRA 256
+#define ZIP_MAXENTRIES (0x10000 - 2)
+
+typedef void* rtlCipher;
+class ZipEnumeration;
+class EncryptionData;
+
+class ZipFile
+{
+protected:
+ ::osl::Mutex m_aMutex;
+
+ ::rtl::OUString sComment; /* zip file comment */
+ EntryHash aEntries;
+ ByteGrabber aGrabber;
+ Inflater aInflater;
+ com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
+ com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
+ const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xFactory;
+ ::com::sun::star::uno::Reference < ::com::sun::star::ucb::XProgressHandler > xProgressHandler;
+
+ sal_Bool bRecoveryMode;
+
+ com::sun::star::uno::Reference < com::sun::star::io::XInputStream > createMemoryStream(
+ ZipEntry & rEntry,
+ const vos::ORef < EncryptionData > &rData,
+ sal_Bool bRawStream,
+ sal_Bool bDecrypt );
+
+ com::sun::star::uno::Reference < com::sun::star::io::XInputStream > createFileStream(
+ ZipEntry & rEntry,
+ const vos::ORef < EncryptionData > &rData,
+ sal_Bool bRawStream,
+ sal_Bool bDecrypt );
+
+ // aMediaType parameter is used only for raw stream header creation
+ com::sun::star::uno::Reference < com::sun::star::io::XInputStream > createUnbufferedStream(
+ SotMutexHolderRef aMutexHolder,
+ ZipEntry & rEntry,
+ const vos::ORef < EncryptionData > &rData,
+ sal_Int8 nStreamMode,
+ sal_Bool bDecrypt,
+ ::rtl::OUString aMediaType = ::rtl::OUString() );
+
+ sal_Bool hasValidPassword ( ZipEntry & rEntry, const vos::ORef < EncryptionData > &rData );
+
+ sal_Bool checkSizeAndCRC( const ZipEntry& aEntry );
+
+ sal_Int32 getCRC( sal_Int32 nOffset, sal_Int32 nSize );
+
+ void getSizeAndCRC( sal_Int32 nOffset, sal_Int32 nCompressedSize, sal_Int32 *nSize, sal_Int32 *nCRC );
+
+public:
+
+ ZipFile( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &xInput,
+ const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory,
+ sal_Bool bInitialise
+ )
+ throw(::com::sun::star::io::IOException, com::sun::star::packages::zip::ZipException, com::sun::star::uno::RuntimeException);
+
+ ZipFile( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &xInput,
+ const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory,
+ sal_Bool bInitialise,
+ sal_Bool bForceRecover,
+ ::com::sun::star::uno::Reference < ::com::sun::star::ucb::XProgressHandler > xProgress
+ )
+ throw(::com::sun::star::io::IOException, com::sun::star::packages::zip::ZipException, com::sun::star::uno::RuntimeException);
+
+ ~ZipFile();
+
+ EntryHash& GetEntryHash() { return aEntries; }
+
+ void setInputStream ( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewStream );
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawData(
+ ZipEntry& rEntry,
+ const vos::ORef < EncryptionData > &rData,
+ sal_Bool bDecrypt,
+ SotMutexHolderRef aMutexHolder )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException);
+
+ static sal_Bool StaticGetCipher ( const vos::ORef < EncryptionData > & xEncryptionData, rtlCipher &rCipher, sal_Bool bDecode );
+
+ static void StaticFillHeader ( const vos::ORef < EncryptionData > & rData,
+ sal_Int32 nSize,
+ const ::rtl::OUString& aMediaType,
+ sal_Int8 * & pHeader );
+
+ static sal_Bool StaticFillData ( vos::ORef < EncryptionData > & rData,
+ sal_Int32 &rSize,
+ ::rtl::OUString& aMediaType,
+ ::com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &rStream );
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > StaticGetDataFromRawStream(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xStream,
+ const vos::ORef < EncryptionData > &rData )
+ throw ( ::com::sun::star::packages::WrongPasswordException,
+ ::com::sun::star::packages::zip::ZipIOException,
+ ::com::sun::star::uno::RuntimeException );
+
+ static sal_Bool StaticHasValidPassword ( const ::com::sun::star::uno::Sequence< sal_Int8 > &aReadBuffer,
+ const vos::ORef < EncryptionData > &rData );
+
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(
+ ZipEntry& rEntry,
+ const vos::ORef < EncryptionData > &rData,
+ sal_Bool bDecrypt,
+ SotMutexHolderRef aMutexHolder )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getDataStream(
+ ZipEntry& rEntry,
+ const vos::ORef < EncryptionData > &rData,
+ sal_Bool bDecrypt,
+ SotMutexHolderRef aMutexHolder )
+ throw ( ::com::sun::star::packages::WrongPasswordException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::packages::zip::ZipException,
+ ::com::sun::star::uno::RuntimeException );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getWrappedRawStream(
+ ZipEntry& rEntry,
+ const vos::ORef < EncryptionData > &rData,
+ const ::rtl::OUString& aMediaType,
+ SotMutexHolderRef aMutexHolder )
+ throw ( ::com::sun::star::packages::NoEncryptionException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::packages::zip::ZipException,
+ ::com::sun::star::uno::RuntimeException );
+
+ ZipEnumeration * SAL_CALL entries( );
+protected:
+ sal_Bool readLOC ( ZipEntry &rEntry)
+ throw(::com::sun::star::io::IOException, com::sun::star::packages::zip::ZipException, com::sun::star::uno::RuntimeException);
+ sal_Int32 readCEN()
+ throw(::com::sun::star::io::IOException, com::sun::star::packages::zip::ZipException, com::sun::star::uno::RuntimeException);
+ sal_Int32 findEND()
+ throw(::com::sun::star::io::IOException, com::sun::star::packages::zip::ZipException, com::sun::star::uno::RuntimeException);
+ sal_Int32 recover()
+ throw(::com::sun::star::io::IOException, com::sun::star::packages::zip::ZipException, com::sun::star::uno::RuntimeException);
+
+};
+
+#endif
diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx
new file mode 100644
index 000000000000..345fe332b8cc
--- /dev/null
+++ b/package/inc/ZipOutputStream.hxx
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _ZIP_OUTPUT_STREAM_HXX
+#define _ZIP_OUTPUT_STREAM_HXX
+
+#include <ByteChucker.hxx>
+#ifndef _DEFLATER_HXX
+#include <Deflater.hxx>
+#endif
+#include <CRC32.hxx>
+#include <rtl/cipher.h>
+#ifndef RTL_DIGEST_H_
+#include <rtl/digest.h>
+#endif
+
+#include <vector>
+
+struct ZipEntry;
+class EncryptionData;
+namespace vos
+{
+ template < class T > class ORef;
+}
+class ZipOutputStream
+{
+protected:
+ com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > xStream;
+ ::std::vector < ZipEntry * > aZipList;
+ com::sun::star::uno::Sequence < sal_Int8 > aBuffer, aEncryptionBuffer;
+ ::rtl::OUString sComment;
+ Deflater aDeflater;
+ rtlCipher aCipher;
+ rtlDigest aDigest;
+ CRC32 aCRC;
+ ByteChucker aChucker;
+ ZipEntry *pCurrentEntry;
+ sal_Int16 nMethod, nLevel, mnDigested;
+ sal_Bool bFinished, bEncryptCurrentEntry;
+ EncryptionData *pCurrentEncryptData;
+
+public:
+ ZipOutputStream( com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > &xOStream );
+ ~ZipOutputStream();
+
+ // rawWrite to support a direct write to the output stream
+ void SAL_CALL rawWrite( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
+ 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);
+
+ // XZipOutputStream interfaces
+ void SAL_CALL setMethod( sal_Int32 nNewMethod )
+ throw(::com::sun::star::uno::RuntimeException);
+ void SAL_CALL setLevel( sal_Int32 nNewLevel )
+ throw(::com::sun::star::uno::RuntimeException);
+ void SAL_CALL putNextEntry( ZipEntry& rEntry,
+ vos::ORef < EncryptionData > &rData,
+ sal_Bool bEncrypt = sal_False )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ void SAL_CALL closeEntry( )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ 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);
+ void SAL_CALL finish( )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ static sal_uInt32 getCurrentDosTime ( );
+protected:
+ void doDeflate();
+ void writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ void writeCEN( const ZipEntry &rEntry )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ void writeEXT( const ZipEntry &rEntry )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 writeLOC( const ZipEntry &rEntry )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+};
+
+#endif
diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx
new file mode 100644
index 000000000000..e3b8d44be183
--- /dev/null
+++ b/package/inc/ZipPackage.hxx
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _ZIP_PACKAGE_HXX
+#define _ZIP_PACKAGE_HXX
+
+#include <cppuhelper/implbase7.hxx>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#ifndef _COM_SUN_STAR_LANG_XPSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#include <HashMaps.hxx>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <osl/file.h>
+#include <mutexholder.hxx>
+
+class ZipOutputStream;
+class ZipPackageFolder;
+class ZipFile;
+class ByteGrabber;
+namespace com { namespace sun { namespace star {
+ namespace container { class XNameContainer; }
+ namespace io { class XStream; class XOutputStream; class XInputStream; class XSeekable; class XActiveDataStreamer; }
+ namespace lang { class XMultiServiceFactory; }
+ namespace task { class XInteractionHandler; }
+} } }
+enum SegmentEnum
+{
+ e_Aborted = -1000,
+ e_Retry,
+ e_Finished,
+ e_Success = 0
+};
+
+enum InitialisationMode
+{
+ e_IMode_None,
+ e_IMode_URL,
+ e_IMode_XInputStream,
+ e_IMode_XStream
+};
+
+class ZipPackage : public cppu::WeakImplHelper7
+ <
+ com::sun::star::lang::XInitialization,
+ com::sun::star::lang::XSingleServiceFactory,
+ com::sun::star::lang::XUnoTunnel,
+ com::sun::star::lang::XServiceInfo,
+ com::sun::star::container::XHierarchicalNameAccess,
+ com::sun::star::util::XChangesBatch,
+ com::sun::star::beans::XPropertySet
+ >
+{
+protected:
+ SotMutexHolderRef m_aMutexHolder;
+
+ ::com::sun::star::uno::Sequence < sal_Int8 > m_aEncryptionKey;
+ FolderHash m_aRecent;
+ ::rtl::OUString m_aURL;
+ sal_Bool m_bHasEncryptedEntries;
+ sal_Bool m_bHasNonEncryptedEntries;
+ sal_Bool m_bInconsistent;
+ sal_Bool m_bUseManifest;
+ sal_Bool m_bForceRecovery;
+
+ sal_Bool m_bMediaTypeFallbackUsed;
+ sal_Int32 m_nFormat;
+ sal_Bool m_bAllowRemoveOnInsert;
+
+ InitialisationMode m_eMode;
+
+ ::com::sun::star::uno::Reference < com::sun::star::container::XNameContainer > m_xRootFolder;
+ ::com::sun::star::uno::Reference < com::sun::star::io::XStream > m_xStream;
+ ::com::sun::star::uno::Reference < com::sun::star::io::XInputStream > m_xContentStream;
+ ::com::sun::star::uno::Reference < com::sun::star::io::XSeekable > m_xContentSeek;
+ const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+
+ ZipPackageFolder *m_pRootFolder;
+ ZipFile *m_pZipFile;
+
+ void parseManifest();
+ void parseContentType();
+ void getZipFileContents();
+
+ void WriteMimetypeMagicFile( ZipOutputStream& aZipOut );
+ void WriteManifest( ZipOutputStream& aZipOut, const ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aManList );
+ void WriteContentTypes( ZipOutputStream& aZipOut, const ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aManList );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > writeTempFile();
+ ::com::sun::star::uno::Reference < ::com::sun::star::io::XActiveDataStreamer > openOriginalForOutput();
+ void DisconnectFromTargetAndThrowException_Impl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xTempStream );
+
+public:
+ ZipPackage (const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory);
+ virtual ~ZipPackage( void );
+ ZipFile& getZipFile() { return *m_pZipFile;}
+ const com::sun::star::uno::Sequence < sal_Int8 > & getEncryptionKey ( ) {return m_aEncryptionKey;}
+ sal_Int32 getFormat() const { return m_nFormat; }
+
+ SotMutexHolderRef GetSharedMutexRef() { return m_aMutexHolder; }
+
+ void ConnectTo( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInStream );
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ // XHierarchicalNameAccess
+ virtual ::com::sun::star::uno::Any SAL_CALL getByHierarchicalName( const ::rtl::OUString& aName )
+ throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByHierarchicalName( const ::rtl::OUString& aName )
+ throw(::com::sun::star::uno::RuntimeException);
+ // XSingleServiceFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( )
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ // XChangesBatch
+ virtual void SAL_CALL commitChanges( )
+ throw(::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasPendingChanges( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::util::ElementChange > SAL_CALL getPendingChanges( )
+ throw(::com::sun::star::uno::RuntimeException);
+ // XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
+ 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);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // Uno componentiseralation
+ static ::rtl::OUString static_getImplementationName();
+ static ::com::sun::star::uno::Sequence < ::rtl::OUString > static_getSupportedServiceNames();
+ static ::com::sun::star::uno::Reference < com::sun::star::lang::XSingleServiceFactory > createServiceFactory( com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory );
+ sal_Bool SAL_CALL static_supportsService(rtl::OUString const & rServiceName);
+};
+#endif
diff --git a/package/inc/ZipPackageBuffer.hxx b/package/inc/ZipPackageBuffer.hxx
new file mode 100644
index 000000000000..54876d97bde1
--- /dev/null
+++ b/package/inc/ZipPackageBuffer.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _ZIP_PACKAGE_BUFFER_HXX
+#define _ZIP_PACKAGE_BUFFER_HXX
+
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#ifndef _CPPUHELPER_IMPLBASE3_HXX
+#include <cppuhelper/implbase3.hxx>
+#endif
+
+class ZipPackage;
+
+class ZipPackageBuffer : public ::cppu::WeakImplHelper3
+<
+ com::sun::star::io::XInputStream,
+ com::sun::star::io::XOutputStream,
+ com::sun::star::io::XSeekable
+>
+{
+protected:
+ com::sun::star::uno::Sequence < sal_Int8 > m_aBuffer;
+ sal_Int64 m_nBufferSize, m_nEnd, m_nCurrent;
+ sal_Bool m_bMustInitBuffer;
+public:
+ ZipPackageBuffer(sal_Int64 nNewBufferSize);
+ virtual ~ZipPackageBuffer(void);
+
+ inline void realloc ( sal_Int32 nSize ) { m_aBuffer.realloc ( nSize ); }
+ inline const sal_Int8 * getConstArray () const { return m_aBuffer.getConstArray(); }
+ inline const com::sun::star::uno::Sequence < sal_Int8> getSequence () const { return m_aBuffer; }
+
+ // XInputStream
+ virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL available( )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL closeInput( )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ // XOutputStream
+ virtual 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( )
+ 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( )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ // XSeekable
+ virtual void SAL_CALL seek( sal_Int64 location )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getPosition( )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getLength( )
+ throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+};
+#endif
diff --git a/package/inc/ZipPackageFolder.hxx b/package/inc/ZipPackageFolder.hxx
new file mode 100644
index 000000000000..89414f18ce65
--- /dev/null
+++ b/package/inc/ZipPackageFolder.hxx
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _ZIP_PACKAGE_FOLDER_HXX
+#define _ZIP_PACKAGE_FOLDER_HXX
+
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/beans/StringPair.hpp>
+#include <HashMaps.hxx>
+#include <ZipPackageEntry.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+namespace com { namespace sun { namespace star {
+namespace beans
+{
+ struct PropertyValue;
+}
+} } }
+class ZipFile;
+class ZipPackage;
+class ZipOutputStream;
+struct ZipEntry;
+typedef void* rtlRandomPool;
+
+class ZipPackageFolder : public cppu::ImplInheritanceHelper2
+<
+ ZipPackageEntry,
+ ::com::sun::star::container::XNameContainer,
+ ::com::sun::star::container::XEnumerationAccess
+>
+{
+ static com::sun::star::uno::Sequence < sal_Int8 > aImplementationId;
+
+protected:
+ ContentHash maContents;
+ const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+ sal_Int32 m_nFormat;
+ ::rtl::OUString m_sVersion;
+
+public:
+
+ ZipPackageFolder( const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& xFactory,
+ sal_Int32 nFormat,
+ sal_Bool bAllowRemoveOnInsert );
+ virtual ~ZipPackageFolder();
+
+ ::rtl::OUString& GetVersion() { return m_sVersion; }
+ void SetVersion( const ::rtl::OUString& aVersion ) { m_sVersion = aVersion; }
+
+ sal_Bool LookForUnexpectedODF12Streams( const ::rtl::OUString& aPath );
+
+ void setChildStreamsTypeByExtension( const ::com::sun::star::beans::StringPair& aPair );
+
+ void doInsertByName ( ZipPackageEntry *pEntry, sal_Bool bSetParent )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ com::sun::star::packages::ContentInfo & doGetByName( const ::rtl::OUString& aName )
+ throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ static void copyZipEntry( ZipEntry &rDest, const ZipEntry &rSource);
+ static ::com::sun::star::uno::Sequence < sal_Int8 > static_getImplementationId()
+ {
+ return aImplementationId;
+ }
+
+ void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
+ void setRemoveOnInsertMode_Impl( sal_Bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; }
+
+ // Recursive functions
+ void saveContents(rtl::OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, com::sun::star::uno::Sequence < sal_Int8 > &rEncryptionKey, rtlRandomPool & rRandomPool)
+ throw(::com::sun::star::uno::RuntimeException);
+ void releaseUpwardRef();
+
+ // XNameContainer
+ virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeByName( const ::rtl::OUString& Name )
+ throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XEnumerationAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // XNameAccess
+ virtual ::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( )
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // XNameReplace
+ 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
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+};
+#endif
diff --git a/package/inc/makefile.mk b/package/inc/makefile.mk
new file mode 100644
index 000000000000..19d89678b0ae
--- /dev/null
+++ b/package/inc/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=package
+TARGET=inc
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.IF "$(ENABLE_PCH)"!=""
+ALLTAR : \
+ $(SLO)$/precompiled.pch \
+ $(SLO)$/precompiled_ex.pch
+
+.ENDIF # "$(ENABLE_PCH)"!=""
+
diff --git a/package/inc/mutexholder.hxx b/package/inc/mutexholder.hxx
new file mode 100644
index 000000000000..97b410ad549b
--- /dev/null
+++ b/package/inc/mutexholder.hxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __MUTEXHOLDER_HXX_
+#define __MUTEXHOLDER_HXX_
+
+#include <osl/mutex.hxx>
+
+class SotMutexHolder
+{
+ ::osl::Mutex m_aMutex;
+ sal_Int32 m_nRefCount;
+
+ public:
+ SotMutexHolder() : m_nRefCount( 0 ) {}
+
+ void AddRef()
+ {
+ m_nRefCount++;
+ }
+
+ void ReleaseRef()
+ {
+ if ( !--m_nRefCount )
+ delete this;
+ }
+
+ ::osl::Mutex& GetMutex() { return m_aMutex; }
+};
+
+class SotMutexHolderRef
+{
+ SotMutexHolder* m_pHolder;
+
+public:
+ SotMutexHolderRef()
+ : m_pHolder( NULL )
+ {}
+
+ SotMutexHolderRef( SotMutexHolder* pHolder )
+ : m_pHolder( pHolder )
+ {
+ if ( m_pHolder )
+ m_pHolder->AddRef();
+ }
+
+ SotMutexHolderRef( const SotMutexHolderRef& rRef )
+ : m_pHolder( rRef.m_pHolder )
+ {
+ if ( m_pHolder )
+ m_pHolder->AddRef();
+ }
+
+ ~SotMutexHolderRef()
+ {
+ if ( m_pHolder )
+ m_pHolder->ReleaseRef();
+ }
+
+ SotMutexHolderRef& operator =( const SotMutexHolderRef& rRef )
+ {
+ if ( m_pHolder )
+ m_pHolder->ReleaseRef();
+
+ m_pHolder = rRef.m_pHolder;
+
+ if ( m_pHolder )
+ m_pHolder->AddRef();
+
+ return *this;
+ }
+
+ SotMutexHolderRef& operator =( SotMutexHolder* pHolder )
+ {
+ if ( m_pHolder )
+ m_pHolder->ReleaseRef();
+
+ m_pHolder = pHolder;
+
+ if ( m_pHolder )
+ m_pHolder->AddRef();
+ return *this;
+ }
+
+ SotMutexHolder* operator ->() const
+ {
+ return m_pHolder;
+ }
+
+ SotMutexHolder& operator *() const
+ {
+ return *m_pHolder;
+ }
+
+ operator SotMutexHolder*() const
+ {
+ return m_pHolder;
+ }
+
+ sal_Bool Is() const
+ {
+ return m_pHolder != NULL;
+ }
+};
+
+#endif
+
diff --git a/package/inc/pch/precompiled_package.cxx b/package/inc/pch/precompiled_package.cxx
new file mode 100644
index 000000000000..da7eca4d4557
--- /dev/null
+++ b/package/inc/pch/precompiled_package.cxx
@@ -0,0 +1,29 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_package.hxx"
+
diff --git a/package/inc/pch/precompiled_package.hxx b/package/inc/pch/precompiled_package.hxx
new file mode 100644
index 000000000000..3fc91f789528
--- /dev/null
+++ b/package/inc/pch/precompiled_package.hxx
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): Generated on 2006-09-01 17:49:53.889391
+
+#ifdef PRECOMPILED_HEADERS
+#endif
+
diff --git a/package/inc/zipfileaccess.hxx b/package/inc/zipfileaccess.hxx
new file mode 100644
index 000000000000..61297aed6da6
--- /dev/null
+++ b/package/inc/zipfileaccess.hxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _ZIPFILEACCESS_HXX_
+#define _ZIPFILEACCESS_HXX_
+
+#include <com/sun/star/packages/zip/XZipFileAccess.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include <cppuhelper/interfacecontainer.h>
+#include <cppuhelper/implbase5.hxx>
+
+#include <mutexholder.hxx>
+
+#include <ZipFile.hxx>
+#include <HashMaps.hxx>
+
+class OZipFileAccess : public ::cppu::WeakImplHelper5<
+ ::com::sun::star::packages::zip::XZipFileAccess,
+ ::com::sun::star::container::XNameAccess,
+ ::com::sun::star::lang::XInitialization,
+ ::com::sun::star::lang::XComponent,
+ ::com::sun::star::lang::XServiceInfo >
+{
+ SotMutexHolderRef m_aMutexHolder;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > m_xContentStream;
+ ZipFile* m_pZipFile;
+
+ ::cppu::OInterfaceContainerHelper* m_pListenersContainer;
+
+ sal_Bool m_bDisposed;
+
+public:
+ OZipFileAccess( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory );
+
+ virtual ~OZipFileAccess();
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > GetPatternsFromString_Impl( const ::rtl::OUString& aString );
+
+ sal_Bool StringGoodForPattern_Impl( const ::rtl::OUString& aString,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPattern );
+
+
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL impl_staticGetSupportedServiceNames();
+
+ static ::rtl::OUString SAL_CALL impl_staticGetImplementationName();
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_staticCreateSelfInstance(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
+
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XNameAccess
+ virtual ::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( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XZipFileAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getStreamByPattern( const ::rtl::OUString& aPattern ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+};
+
+#endif
+