Initial Revision :D

This commit is contained in:
Martin Gallwey
2000-11-13 12:38:03 +00:00
parent e1f02829a3
commit db4e8a77ce
19 changed files with 3629 additions and 0 deletions

112
package/inc/ByteChucker.hxx Normal file
View File

@@ -0,0 +1,112 @@
/*************************************************************************
*
* $RCSfile: ByteChucker.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:37:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _BYTE_CHUCKER_HXX_
#define _BYTE_CHUCKER_HXX_
#ifndef _SAL_TYPES_H_
#include <sal/types.h>
#endif
#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
#include <com/sun/star/io/XOutputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
#include <com/sun/star/io/XSeekable.hpp>
#endif
class ByteChucker
{
private:
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();
// 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 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( )
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);
void putInt8 ( sal_Int8 nInt8 );
void putInt16( sal_Int16 nInt16 );
void putInt32( sal_Int32 nInt32 );
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

115
package/inc/ByteGrabber.hxx Normal file
View File

@@ -0,0 +1,115 @@
/*************************************************************************
*
* $RCSfile: ByteGrabber.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:37:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _BYTE_GRABBER_HXX_
#define _BYTE_GRABBER_HXX_
#ifndef _SAL_TYPES_H_
#include <sal/types.h>
#endif
#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
#include <com/sun/star/io/XInputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
#include <com/sun/star/io/XSeekable.hpp>
#endif
class ByteGrabber
{
private:
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xSeek;
public:
ByteGrabber (com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xIstream);
~ByteGrabber();
// XInputStream
virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL available( )
throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL closeInput( )
throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
// XSeekable
virtual 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( )
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);
sal_Int8 getInt8();
sal_Int16 getInt16();
sal_Int32 getInt32();
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

99
package/inc/CRC32.hxx Normal file
View File

@@ -0,0 +1,99 @@
/*************************************************************************
*
* $RCSfile: CRC32.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:37:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _CRC32_HXX
#define _CRC32_HXX
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif
#ifndef _ZLIB_H
#include <external/zlib/zlib.h>
#endif
#ifndef _COM_SUN_STAR_PACKAGE_XCHECKSUM_HPP_
#include <com/sun/star/package/XChecksum.hpp>
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
class CRC32 : public cppu::WeakImplHelper1<com::sun::star::package::XChecksum>
{
private:
sal_uInt32 nCRC;
public:
CRC32();
virtual ~CRC32();
virtual 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)
throw(::com::sun::star::uno::RuntimeException);
virtual 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()
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL reset()
throw(::com::sun::star::uno::RuntimeException);
};
#endif

134
package/inc/Deflater.hxx Normal file
View File

@@ -0,0 +1,134 @@
/*************************************************************************
*
* $RCSfile: Deflater.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:37:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _DEFLATER_HXX_
#define _DEFLATER_HXX_
#ifndef _COM_SUN_STAR_PACKAGE_XDEFLATER_HDL_
#include <com/sun/star/package/XDeflater.hpp>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif
#ifndef _ZLIB_H
#include <external/zlib/zlib.h>
#endif
#ifndef _COM_SUN_STAR_PACKAGE_ZIPCONSTANTS_HPP_
#include <com/sun/star/package/ZipConstants.hpp>
#endif
class Deflater : public cppu::WeakImplHelper1 < com::sun::star::package::XDeflater>
{
private:
com::sun::star::uno::Sequence< sal_Int8 > sInBuffer;
sal_Bool bFinish;
sal_Bool bFinished;
sal_Bool bSetParams;
sal_Int16 nLevel, nStrategy;
sal_Int16 nOffset, nLength;
z_stream* pStream;
void init (sal_Int16 nLevel, sal_Int16 nStrategy, sal_Bool bNowrap);
sal_Int16 doDeflateBytes (com::sun::star::uno::Sequence < sal_Int8 > &rBuffer, sal_Int16 nNewOffset, sal_Int16 nNewLength);
public:
Deflater();
~Deflater();
Deflater(sal_Int16 nSetLevel);
Deflater(sal_Int16 nSetLevel, sal_Bool bNowrap);
virtual 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 )
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 )
throw(::com::sun::star::uno::RuntimeException);
virtual 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 )
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setLevel( sal_Int32 nNewLevel )
throw(::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL needsInput( )
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL finish( )
throw(::com::sun::star::uno::RuntimeException);
virtual 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 )
throw(::com::sun::star::uno::RuntimeException);
virtual 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( )
throw(::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getTotalIn( )
throw(::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getTotalOut( )
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL reset( )
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL end( )
throw(::com::sun::star::uno::RuntimeException);
};
#endif

134
package/inc/Inflater.hxx Normal file
View File

@@ -0,0 +1,134 @@
/*************************************************************************
*
* $RCSfile: Inflater.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:37:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _INFLATER_HXX_
#define _INFLATER_HXX_
#ifndef _ZLIB_H
#include <external/zlib/zlib.h>
#endif
#ifndef _COM_SUN_STAR_PACKAGE_XINFLATER_HDL_
#include <com/sun/star/package/XInflater.hpp>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _COM_SUN_STAR_PACKAGE_ZIPCONSTANTS_HPP_
#include <com/sun/star/package/ZipConstants.hpp>
#endif
class Inflater : public cppu::WeakImplHelper1 < com::sun::star::package::XInflater>
{
private:
sal_Bool bFinish;
sal_Bool bFinished;
sal_Bool bSetParams;
sal_Bool bNeedDict;
sal_Int16 nOffset, nLength;
z_stream* pStream;
com::sun::star::uno::Sequence < sal_Int8 > sInBuffer;
void init (sal_Bool bNowrap);
sal_Int16 doInflateBytes (com::sun::star::uno::Sequence < sal_Int8 > &rBuffer, sal_Int16 nNewOffset, sal_Int16 nNewLength);
public:
Inflater(sal_Bool bNoWrap);
Inflater();
~Inflater();
virtual 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 )
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 )
throw(::com::sun::star::uno::RuntimeException);
virtual 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( )
throw(::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL needsInput( )
throw(::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL needsDictionary( )
throw(::com::sun::star::uno::RuntimeException);
virtual 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 )
throw(::com::sun::star::uno::RuntimeException);
virtual 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( )
throw(::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getTotalIn( )
throw(::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getTotalOut( )
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL reset( )
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL end( )
throw(::com::sun::star::uno::RuntimeException);
};
#endif

View File

@@ -0,0 +1,185 @@
/*************************************************************************
*
* $RCSfile: ZipEnumeration.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:37:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _ZIP_ENUMERATION_HXX
#define _ZIP_ENUMERATION_HXX
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx> // helper for implementations
#endif
#ifndef COM_SUN_STAR_CONTAINER_XENUMERATION_HPP
#include <com/sun/star/container/XEnumeration.hpp>
#endif
#ifndef _ZIP_ENTRY_IMPL_HXX_
#include "ZipEntryImpl.hxx"
#endif
class ZipEnumeration : public cppu::WeakImplHelper1 < com::sun::star::container::XEnumeration>
{
private:
com::sun::star::uno::Sequence< com::sun::star::package::ZipEntry > xZipList;
sal_uInt16 nCurrent;
public:
virtual sal_Bool SAL_CALL hasMoreElements() throw (::com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Any SAL_CALL nextElement() throw (::com::sun::star::uno::RuntimeException);
virtual ~ZipEnumeration(void);
ZipEnumeration(void);
ZipEnumeration( com::sun::star::uno::Sequence< com::sun::star::package::ZipEntry > &xList);
//ZipEnumeration( com::sun::star::uno::Reference < com::sun::star::uno::Sequence< com::sun::star::package::ZipEntry > >&xList);
/*
ZipEnumeration(const com::sun::star::uno::Sequence<
com::sun::star::uno::Reference<
com::sun::star::package::ZipEntry> > & seqEntries);
// XInterface
virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type & aType )
throw( ::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL acquire() throw( ::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL release() throw( ::com::sun::star::uno::RuntimeException );
*/
};
#if 0
/**
* Function to create a new component instance; is needed by factory helper implementation.
* @param xMgr service manager to if the components needs other component instances
*/
com::sun::star::uno::Reference< com::sun::star::uno::XInterface > ZipEnum_create
( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & xMgr )
{
return com::sun::star::uno::Reference< com::sun::star::uno::XInterface >( *new ZipEnum( xMgr ) );
}
/**
* This function returns the name of the used environment.
* @param ppEnvTypeName name of the environment
* @param ppEnv could be point to a special environment, this parameter is normally set to null
*/
extern "C" void SAL_CALL component_getImplementationEnvironment(
const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
/**
* This function creates an implementation section in the registry and another subkey
* for each supported service.
* @param pServiceManager generic uno interface providing a service manager
* @param pRegistryKey generic uno interface providing registry key to write
*/
extern "C" sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey )
{
if (pRegistryKey)
{
try
{
com::sun::star::uno::Reference< com::sun::star::registry::XRegistryKey > xNewKey(
reinterpret_cast< com::sun::star::registry::XRegistryKey * >( pRegistryKey )->createKey(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/package.ZipEnum/UNO/SERVICES") ) ) );
xNewKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("package.ZipEnum") ) );
return sal_True;
}
catch ( com::sun::star::registry::InvalidRegistryException& )
{
DBG_ERROR( "InvalidRegistryException detected\n");
return sal_False;
}
}
return sal_False;
}
/**
* This function is called to get service factories for an implementation.
* @param pImplName name of implementation
* @param pServiceManager generic uno interface providing a service manager to instantiate components
* @param pRegistryKey registry data key to read and write component persistent data
* @return a component factory (generic uno interface)
*/
extern "C" void * SAL_CALL component_getFactory(
const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
{
void * pRet = 0;
// which implementation is demanded?
if (pServiceManager && rtl_str_compare( pImplName, "package.ZipEnumeration" ))
{
rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("package.ZipEnumeration") );
com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > xFactory(
cppu::createSingleFactory( // helper function from cppuhelper lib
reinterpret_cast< com::sun::star::lang::XMultiServiceFactory * >( pServiceManager ),
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("package.ZipEnumeration") ),
ZipEnum_create,
com::sun::star::uno::Sequence< rtl::OUString >( &aServiceName, 1 ) ) );
if (xFactory.is())
{
xFactory->acquire();
pRet = xFactory.get();
}
}
return pRet;
}
#endif
#endif

230
package/inc/ZipFile.hxx Normal file
View File

@@ -0,0 +1,230 @@
/*************************************************************************
*
* $RCSfile: ZipFile.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:37:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _ZIP_FILE_HXX
#define _ZIP_FILE_HXX
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx> // helper for implementations
#endif
#ifndef _COM_SUN_STAR_PACKAGE_XZIPFILE_HPP_
#include <com/sun/star/package/XZipFile.hpp>
#endif
#ifndef _ENTRY_INPUT_STREAM_HXX
#include "EntryInputStream.hxx"
#endif
#ifndef _ZIP_ENUMERATION_HXX
#include "ZipEnumeration.hxx"
#endif
#ifndef _ZIP_ENTRY_IMPL_HXX
#include "ZipEntryImpl.hxx"
#endif
#ifndef _BYTE_GRABBER_HXX_
#include "ByteGrabber.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::package::XZipFile>
{
private:
::rtl::OUString sName; /* zip file name */
::rtl::OUString sComment; /* zip file comment */
sal_uInt16 nTotal; /* total number of entries */
com::sun::star::package::ZipEntry *pEntries; /* array of zip entries */
ZipEntryImpl **pTable; /* Hash chain heads: indexes into entries */
sal_Int32 nTableLen; /* number of hash eads */
ByteGrabber aGrabber;
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xStream;
public:
//ZipFile( void );
ZipFile( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &xInput);
virtual ~ZipFile();
// 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);
// XZipFile
virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( const ::com::sun::star::package::ZipEntry& rEntry )
throw(::com::sun::star::io::IOException, ::com::sun::star::package::ZipException, ::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getName( )
throw(::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getSize( )
throw(::com::sun::star::uno::RuntimeException);
virtual 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 )
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);
// 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);
private:
sal_Bool readLOC(const com::sun::star::package::ZipEntry &rEntry);
ZipEntryImpl* getNthEntry(sal_Int32 nIndex);
sal_Int32 readCEN();
sal_Int32 findEND();
};
#if 0
/**
* Function to create a new component instance; is needed by factory helper implementation.
* @param xMgr service manager to if the components needs other component instances
*/
com::sun::star::uno::Reference< com::sun::star::uno::XInterface > ZipFile_create
( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & xMgr )
{
return com::sun::star::uno::Reference< com::sun::star::uno::XInterface >( *new ZipFile( xMgr ) );
}
/**
* This function returns the name of the used environment.
* @param ppEnvTypeName name of the environment
* @param ppEnv could be point to a special environment, this parameter is normally set to null
*/
extern "C" void SAL_CALL component_getImplementationEnvironment(
const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
/**
* This function creates an implementation section in the registry and another subkey
* for each supported service.
* @param pServiceManager generic uno interface providing a service manager
* @param pRegistryKey generic uno interface providing registry key to write
*/
extern "C" sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey )
{
if (pRegistryKey)
{
try
{
com::sun::star::uno::Reference< com::sun::star::registry::XRegistryKey > xNewKey(
reinterpret_cast< com::sun::star::registry::XRegistryKey * >( pRegistryKey )->createKey(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/package.ZipFile/UNO/SERVICES") ) ) );
xNewKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("package.XZipFile") ) );
return sal_True;
}
catch ( com::sun::star::registry::InvalidRegistryException& )
{
DBG_ERROR( "InvalidRegistryException detected\n");
return sal_False;
}
}
return sal_False;
}
/**
* This function is called to get service factories for an implementation.
* @param pImplName name of implementation
* @param pServiceManager generic uno interface providing a service manager to instantiate components
* @param pRegistryKey registry data key to read and write component persistent data
* @return a component factory (generic uno interface)
*/
extern "C" void * SAL_CALL component_getFactory(
const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
{
void * pRet = 0;
// which implementation is demanded?
if (pServiceManager && rtl_str_compare( pImplName, "package.ZipFile" ))
{
rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("package.XZipFile") );
com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > xFactory(
cppu::createSingleFactory( // helper function from cppuhelper lib
reinterpret_cast< com::sun::star::lang::XMultiServiceFactory * >( pServiceManager ),
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("package.ZipFile") ),
ZipFile_create,
com::sun::star::uno::Sequence< rtl::OUString >( &aServiceName, 1 ) ) );
if (xFactory.is())
{
xFactory->acquire();
pRet = xFactory.get();
}
}
return pRet;
}
#endif
#endif

View File

@@ -0,0 +1,157 @@
/*************************************************************************
*
* $RCSfile: ZipOutputStream.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:37:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _ZIP_OUTPUT_STREAM_HXX
#define _ZIP_OUTPUT_STREAM_HXX
#ifndef _BYTE_CHUCKER_HXX_
#include "ByteChucker.hxx"
#endif
#ifndef _ZIP_ENTRY_IMPL_HXX
#include "ZipEntryImpl.hxx"
#endif
#ifndef _ZIP_FILE_HXX
#include "ZipFile.hxx"
#endif
#ifndef _DEFLATER_HXX
#include "Deflater.hxx"
#endif
#ifndef _CRC32_HXX
#include "CRC32.hxx"
#endif
#ifndef _TOOLS_TIME_HXX
#include <tools/time.hxx>
#endif
#ifndef _COM_SUN_STAR_PACKAGE_XZIPOUTPUTSTREAM_HPP_
#include <com/sun/star/package/XZipOutputStream.hpp>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx> // helper for implementations
#endif
#ifndef __SGI_STL_VECTOR
#include <stl/vector>
#endif
class ZipOutputStream : public cppu::WeakImplHelper1< com::sun::star::package::XZipOutputStream >
{
private:
com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > xStream;
Deflater aDeflater;
com::sun::star::uno::Sequence < sal_Int8 > aBuffer;
::rtl::OUString sComment;
sal_Int16 nMethod;
sal_Int16 nLevel;
com::sun::star::package::ZipEntry *pCurrentEntry;
CRC32 aCRC;
sal_Bool bFinished;
ByteChucker aChucker;
::std::vector <::com::sun::star::package::ZipEntry*> aZipList;
public:
ZipOutputStream( com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > &xOStream, sal_Int32 nNewBufferSize);
virtual ~ZipOutputStream(void);
virtual void SAL_CALL setComment( const ::rtl::OUString& rComment )
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setMethod( sal_Int32 nNewMethod )
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setLevel( sal_Int32 nNewLevel )
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL putNextEntry( const ::com::sun::star::package::ZipEntry& rEntry )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual 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 )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL finish( )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL close( )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
#if 0
ZipOutputStream (SvStream& aOStream);
void close();
void closeEntry();
void finish();
void putNextEntry(ZipEntry &rEntry);
void setComment(::rtl::ByteSequence &nComment);
void setLevel(sal_Int16 nNewLevel);
void setMethod(sal_Int16 nNewMethod);
void write (::rtl::ByteSequence &rBuffer, sal_uInt16 nOff, sal_uInt16 nLen);
static const sal_Int16 STORED = ZipEntry::STORED;
static const sal_Int16 DEFLATED = ZipEntry::DEFLATED;
#endif
private:
void doDeflate();
void writeEND(sal_uInt32 nOffset, sal_uInt32 nLength);
void writeCEN( const com::sun::star::package::ZipEntry &rEntry );
void writeEXT( const com::sun::star::package::ZipEntry &rEntry );
void writeLOC( const com::sun::star::package::ZipEntry &rEntry );
};
#endif

View File

@@ -0,0 +1,202 @@
/*************************************************************************
*
* $RCSfile: ByteChucker.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _BYTE_CHUCKER_HXX_
#include "ByteChucker.hxx"
#endif
using namespace ::com::sun::star;
/** ByteChucker implements the << operators on an XOutputStream. This is
* potentially quite slow and may need to be optimised
*/
ByteChucker::ByteChucker(uno::Reference<io::XOutputStream> xOstream)
: xStream(xOstream)
, xSeek (xOstream, uno::UNO_QUERY )
{
}
ByteChucker::~ByteChucker()
{
if ( xStream.is() )
xStream->closeOutput();
}
// XOutputStream chained...
void SAL_CALL ByteChucker::writeBytes( const uno::Sequence< sal_Int8 >& aData )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
{
xStream->writeBytes(aData);
}
void SAL_CALL ByteChucker::flush( )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
{
xStream->flush();
}
void SAL_CALL ByteChucker::closeOutput( )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
{
xStream->closeOutput();
}
// XSeekable chained...
sal_Int64 SAL_CALL ByteChucker::seek( sal_Int64 location )
throw(lang::IllegalArgumentException, io::IOException, uno::RuntimeException)
{
if (xSeek.is() )
{
sal_Int32 nLen = xSeek->getLength();
if (location > nLen )
location = nLen;
xSeek->seek( location );
return location;
}
else
throw (io::IOException());
}
sal_Int64 SAL_CALL ByteChucker::getPosition( )
throw(io::IOException, uno::RuntimeException)
{
if (xSeek.is() )
return xSeek->getPosition();
else
throw (io::IOException());
}
sal_Int64 SAL_CALL ByteChucker::getLength( )
throw(io::IOException, uno::RuntimeException)
{
if (xSeek.is() )
return xSeek->getLength();
else
throw (io::IOException());
}
void ByteChucker::putInt8( sal_Int8 nInt8)
{
uno::Sequence< sal_Int8 > aSequence (1);
aSequence[0]=nInt8 & 0xFF;
xStream->writeBytes(aSequence);
}
void ByteChucker::putInt16(sal_Int16 nInt16)
{
uno::Sequence< sal_Int8 > aSequence (2);
aSequence[0] = (nInt16 >>0 ) & 0xFF;
aSequence[1] = (nInt16 >>8 ) & 0xFF;
xStream->writeBytes(aSequence);
}
void ByteChucker::putInt32(sal_Int32 nInt32)
{
uno::Sequence< sal_Int8 > aSequence (4);
aSequence[0] = (nInt32 >> 0 ) & 0xFF;
aSequence[1] = (nInt32 >> 8 ) & 0xFF;
aSequence[2] = (nInt32 >> 16 ) & 0xFF;
aSequence[3] = (nInt32 >> 24 ) & 0xFF;
xStream->writeBytes(aSequence);
}
ByteChucker& ByteChucker::operator << (sal_Int8 nInt8)
{
uno::Sequence< sal_Int8 > aSequence (1);
aSequence[0]=nInt8 & 0xFF;
xStream->writeBytes(aSequence);
return *this;
}
ByteChucker& ByteChucker::operator << (sal_Int16 nInt16)
{
uno::Sequence< sal_Int8 > aSequence (2);
aSequence[0] = (nInt16 >>0 ) & 0xFF;
aSequence[1] = (nInt16 >>8 ) & 0xFF;
xStream->writeBytes(aSequence);
return *this;
}
ByteChucker& ByteChucker::operator << (sal_Int32 nInt32)
{
uno::Sequence< sal_Int8 > aSequence (4);
aSequence[0] = (nInt32 >> 0 ) & 0xFF;
aSequence[1] = (nInt32 >> 8 ) & 0xFF;
aSequence[2] = (nInt32 >> 16 ) & 0xFF;
aSequence[3] = (nInt32 >> 24 ) & 0xFF;
xStream->writeBytes(aSequence);
return *this;
}
ByteChucker& ByteChucker::operator << (sal_uInt8 nuInt8)
{
uno::Sequence< sal_Int8 > aSequence (1);
aSequence[0]=nuInt8 & 0xFF;
xStream->writeBytes(aSequence);
return *this;
}
ByteChucker& ByteChucker::operator << (sal_uInt16 nuInt16)
{
uno::Sequence< sal_Int8 > aSequence (2);
aSequence[0] = (nuInt16 >>0 ) & 0xFF;
aSequence[1] = (nuInt16 >>8 ) & 0xFF;
xStream->writeBytes(aSequence);
return *this;
}
ByteChucker& ByteChucker::operator << (sal_uInt32 nuInt32)
{
uno::Sequence< sal_Int8 > aSequence (4);
aSequence[0] = (nuInt32 >> 0 ) & 0xFF;
aSequence[1] = (nuInt32 >> 8 ) & 0xFF;
aSequence[2] = (nuInt32 >> 16 ) & 0xFF;
aSequence[3] = (nuInt32 >> 24 ) & 0xFF;
xStream->writeBytes(aSequence);
return *this;
}

View File

@@ -0,0 +1,215 @@
/*************************************************************************
*
* $RCSfile: ByteGrabber.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _BYTE_GRABBER_HXX_
#include "ByteGrabber.hxx"
#endif
using namespace ::com::sun::star;
/** ByteGrabber implements the >> operators on an XOutputStream. This is
* potentially quite slow and may need to be optimised
*/
ByteGrabber::ByteGrabber(uno::Reference < io::XInputStream > xIstream)
: xStream(xIstream)
, xSeek (xIstream, uno::UNO_QUERY )
{
}
ByteGrabber::~ByteGrabber()
{
if ( xStream.is() )
xStream->closeInput();
}
// XInputStream chained
sal_Int32 SAL_CALL ByteGrabber::readBytes( uno::Sequence< sal_Int8 >& aData,
sal_Int32 nBytesToRead )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
{
return xStream->readBytes(aData, nBytesToRead );
}
sal_Int32 SAL_CALL ByteGrabber::readSomeBytes( uno::Sequence< sal_Int8 >& aData,
sal_Int32 nMaxBytesToRead )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
{
return xStream->readSomeBytes( aData, nMaxBytesToRead );
}
void SAL_CALL ByteGrabber::skipBytes( sal_Int32 nBytesToSkip )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
{
xStream->skipBytes( nBytesToSkip );
}
sal_Int32 SAL_CALL ByteGrabber::available( )
throw(io::NotConnectedException, io::IOException, uno::RuntimeException)
{
return xStream->available();
}
void SAL_CALL ByteGrabber::closeInput( )
throw(io::NotConnectedException, io::IOException, uno::RuntimeException)
{
xStream->closeInput();
}
// XSeekable chained...
sal_Int64 SAL_CALL ByteGrabber::seek( sal_Int64 location )
throw(lang::IllegalArgumentException, io::IOException, uno::RuntimeException)
{
if (xSeek.is() )
{
sal_Int32 nLen = xSeek->getLength();
if (location > nLen )
location = nLen;
xSeek->seek( location );
return location;
}
else
throw (io::IOException());
}
sal_Int64 SAL_CALL ByteGrabber::getPosition( )
throw(io::IOException, uno::RuntimeException)
{
if (xSeek.is() )
return xSeek->getPosition();
else
throw (io::IOException());
}
sal_Int64 SAL_CALL ByteGrabber::getLength( )
throw(io::IOException, uno::RuntimeException)
{
if (xSeek.is() )
return xSeek->getLength();
else
throw (io::IOException());
}
sal_Int8 ByteGrabber::getInt8()
{
uno::Sequence< sal_Int8 > aSequence (1);
xStream->readBytes(aSequence,1);
return aSequence[0];
}
sal_Int16 ByteGrabber::getInt16()
{
uno::Sequence< sal_Int8 > aSequence (2);
xStream->readBytes(aSequence, 2);
return (aSequence[0] | aSequence[1] << 8);
}
sal_Int32 ByteGrabber::getInt32()
{
uno::Sequence< sal_Int8 > aSequence (4);
xStream->readBytes(aSequence, 4);
return (aSequence [0]| aSequence[1] << 8 | (sal_Int32) (aSequence[2] | aSequence[3] <<8) << 16);
}
ByteGrabber& ByteGrabber::operator >> (sal_Int8& rInt8)
{
uno::Sequence< sal_Int8 > aSequence (1);
xStream->readBytes(aSequence,1);
rInt8 = aSequence[0]& 0xFF;
return *this;
}
ByteGrabber& ByteGrabber::operator >> (sal_Int16& rInt16)
{
uno::Sequence< sal_Int8 > aSequence (2);
xStream->readBytes(aSequence, 2);
rInt16 = static_cast <sal_Int16>
(static_cast <sal_uInt8> (aSequence[0]& 0xFF)
| static_cast <sal_uInt8> (aSequence[1]& 0xFF) << 8);
return *this;
}
ByteGrabber& ByteGrabber::operator >> (sal_Int32& rInt32)
{
uno::Sequence< sal_Int8 > aSequence (4);
xStream->readBytes(aSequence, 4);
rInt32 = static_cast < sal_Int32 >
(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 );
return *this;
}
ByteGrabber& ByteGrabber::operator >> (sal_uInt8& ruInt8)
{
uno::Sequence< sal_Int8 > aSequence (1);
xStream->readBytes(aSequence,1);
ruInt8 = static_cast <sal_uInt8> (aSequence[0]& 0xFF);
return *this;
}
ByteGrabber& ByteGrabber::operator >> (sal_uInt16& ruInt16)
{
uno::Sequence< sal_Int8 > aSequence (2);
xStream->readBytes(aSequence, 2);
ruInt16 = static_cast <sal_uInt16>
(static_cast < sal_uInt8 > (aSequence[0]& 0xFF)
| static_cast < sal_uInt8 > (aSequence[1]& 0xFF) << 8);
return *this;
}
ByteGrabber& ByteGrabber::operator >> (sal_uInt32& ruInt32)
{
uno::Sequence< sal_Int8 > aSequence (4);
xStream->readBytes(aSequence, 4);
ruInt32 = 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);
return *this;
}

View File

@@ -0,0 +1,110 @@
/*************************************************************************
*
* $RCSfile: CRC32.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _CRC32_HXX
#include "CRC32.hxx"
#endif
using namespace rtl;
using namespace com::sun::star;
/** A class to compute the CRC32 value of a data stream
*/
CRC32::CRC32()
: nCRC(0)
{
}
CRC32::~CRC32()
{
}
void CRC32::reset()
{
nCRC=0;
}
sal_Int32 CRC32::getValue()
{
return (sal_Int32) nCRC & 0xFFFFFFFFL;
}
/** Update CRC32 with specified byte
*/
void SAL_CALL CRC32::updateByte (sal_Int8 nByte)
throw(uno::RuntimeException)
{
sal_uInt8 pBuf[1];
pBuf[0] = (sal_uInt8)nByte;
nCRC = crc32(nCRC, pBuf, 1);
}
/** Update CRC32 with specified sequence of bytes
*/
void SAL_CALL CRC32::updateSegment(const uno::Sequence< sal_Int8 > &b,
sal_Int32 off,
sal_Int32 len)
throw(uno::RuntimeException)
{
nCRC = crc32(nCRC, (const unsigned char*)b.getConstArray()+off, len );
}
/** Update CRC32 with specified sequence of bytes
*/
void SAL_CALL CRC32::update(const uno::Sequence< sal_Int8 > &b)
throw(uno::RuntimeException)
{
nCRC = crc32(nCRC, (const unsigned char*)b.getConstArray(),b.getLength());
}

View File

@@ -0,0 +1,303 @@
/*************************************************************************
*
* $RCSfile: Deflater.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _DEFLATER_HXX_
#include "Deflater.hxx"
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#include <iostream.h>
#include <string.h>
using namespace com::sun::star::package::ZipConstants;
using namespace com::sun::star;
/** Provides general purpose compression using the ZLIB compression
* library.
*/
Deflater::~Deflater(void)
{
if (pStream)
delete pStream;
}
void Deflater::init (sal_Int16 nLevel, sal_Int16 nStrategy, sal_Bool bNowrap)
{
pStream = new z_stream;
/* Memset it to 0...sets zalloc/zfree/opaque to NULL */
memset (pStream, 0, sizeof(*pStream));
switch (deflateInit2(pStream, nLevel, Z_DEFLATED, bNowrap? -MAX_WBITS : MAX_WBITS,
DEF_MEM_LEVEL, nStrategy))
{
case Z_OK:
break;
case Z_MEM_ERROR:
delete pStream;
break;
case Z_STREAM_ERROR:
delete pStream;
break;
default:
break;
}
}
Deflater::Deflater()
: nLevel(DEFAULT_COMPRESSION)
, nStrategy(DEFAULT_STRATEGY)
, bFinish(sal_False)
, bFinished(sal_False)
, bSetParams(sal_False)
, nOffset(0)
, nLength(0)
{
init(DEFAULT_COMPRESSION, DEFAULT_STRATEGY, sal_False);
}
Deflater::Deflater(sal_Int16 nSetLevel)
: nLevel(nSetLevel)
, nStrategy(DEFAULT_STRATEGY)
, bFinish(sal_False)
, bFinished(sal_False)
, bSetParams(sal_False)
, nOffset(0)
, nLength(0)
{
init(nSetLevel, DEFAULT_STRATEGY, sal_False);
}
Deflater::Deflater(sal_Int16 nSetLevel, sal_Bool bNowrap)
: nLevel(nSetLevel)
, nStrategy(DEFAULT_STRATEGY)
, bFinish(sal_False)
, bFinished(sal_False)
, bSetParams(sal_False)
, nOffset(0)
, nLength(0)
{
init(nSetLevel, DEFAULT_STRATEGY, bNowrap);
}
sal_Int16 Deflater::doDeflateBytes (uno::Sequence < sal_Int8 > &rBuffer, sal_Int16 nNewOffset, sal_Int16 nNewLength)
{
sal_Int16 nResult;
if (bSetParams)
{
nResult = z_deflateParams(pStream, nLevel, nStrategy);
bSetParams = sal_False;
}
pStream->next_in = (unsigned char*) sInBuffer.getConstArray();
pStream->next_out = (unsigned char*) rBuffer.getArray()+nNewOffset;
pStream->avail_in = nLength;
pStream->avail_out = nNewLength;
nResult = z_deflate(pStream, Z_FINISH);
switch (nResult)
{
case Z_STREAM_END:
bFinished = sal_True;
case Z_OK:
nOffset += nLength - pStream->avail_in;
nLength = pStream->avail_in;
return nNewLength - pStream->avail_out;
case Z_BUF_ERROR:
bSetParams = sal_False;
DBG_ERROR( pStream->msg );
return 0;
default:
DBG_ERROR( pStream->msg );
return 0;
}
return 0;
}
void SAL_CALL Deflater::setInputSegment( const uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(uno::RuntimeException)
{
if (nNewOffset < 0 || nNewLength < 0 || nNewOffset + nNewLength > rBuffer.getLength())
DBG_ERROR("Invalid parameters to Deflater::setInputSegment!");
sInBuffer = rBuffer;
nOffset = nNewOffset;
nLength = nNewLength;
}
void SAL_CALL Deflater::setInput( const uno::Sequence< sal_Int8 >& rBuffer )
throw(uno::RuntimeException)
{
sInBuffer = rBuffer;
nOffset = 0;
nLength = rBuffer.getLength();
}
void SAL_CALL Deflater::setDictionarySegment( const uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(uno::RuntimeException)
{
if (pStream == NULL)
{
// do error handling
DBG_ERROR("No stream!");
}
if (nNewOffset < 0 || nNewLength < 0 || nNewOffset + nNewLength > rBuffer.getLength())
{
// do error handling
}
sal_Int16 nResult = z_deflateSetDictionary(pStream, (const unsigned char*)rBuffer.getConstArray()+nOffset, nLength);
}
void SAL_CALL Deflater::setDictionary( const uno::Sequence< sal_Int8 >& rBuffer )
throw(uno::RuntimeException)
{
if (pStream == NULL)
{
// do error handling
DBG_ERROR("No stream!");
}
sal_Int16 nResult = z_deflateSetDictionary(pStream, (const unsigned char*)rBuffer.getConstArray(), rBuffer.getLength());
}
void SAL_CALL Deflater::setStrategy( sal_Int32 nNewStrategy )
throw(uno::RuntimeException)
{
if (nNewStrategy != DEFAULT_STRATEGY &&
nNewStrategy != FILTERED &&
nNewStrategy != HUFFMAN_ONLY)
{
// do error handling
}
if (nStrategy != nNewStrategy)
{
nStrategy = nNewStrategy;
bSetParams = sal_True;
}
}
void SAL_CALL Deflater::setLevel( sal_Int32 nNewLevel )
throw(uno::RuntimeException)
{
if ((nNewLevel < 0 || nNewLevel > 9) && nNewLevel != DEFAULT_COMPRESSION)
{
// do error handling
}
if (nNewLevel != nLevel)
{
nLevel = nNewLevel;
bSetParams = sal_True;
}
}
sal_Bool SAL_CALL Deflater::needsInput( )
throw(uno::RuntimeException)
{
return nLength <=0;
}
void SAL_CALL Deflater::finish( )
throw(uno::RuntimeException)
{
bFinish = sal_True;
}
sal_Bool SAL_CALL Deflater::finished( )
throw(uno::RuntimeException)
{
return bFinished;
}
sal_Int32 SAL_CALL Deflater::doDeflateSegment( uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(uno::RuntimeException)
{
if (nNewOffset < 0 || nNewLength < 0 || nNewOffset + nNewLength > rBuffer.getLength())
{
// do error handling
}
return doDeflateBytes(rBuffer, nNewOffset, nNewLength);
}
sal_Int32 SAL_CALL Deflater::doDeflate( uno::Sequence< sal_Int8 >& rBuffer )
throw(uno::RuntimeException)
{
return doDeflateBytes(rBuffer, 0, rBuffer.getLength());
}
sal_Int32 SAL_CALL Deflater::getAdler( )
throw(uno::RuntimeException)
{
return pStream->adler;
}
sal_Int32 SAL_CALL Deflater::getTotalIn( )
throw(uno::RuntimeException)
{
return pStream->total_in;
}
sal_Int32 SAL_CALL Deflater::getTotalOut( )
throw(uno::RuntimeException)
{
return pStream->total_out;
}
void SAL_CALL Deflater::reset( )
throw(uno::RuntimeException)
{
z_deflateReset(pStream);
bFinish = sal_False;
bFinished = sal_False;
nOffset = nLength = 0;
}
void SAL_CALL Deflater::end( )
throw(uno::RuntimeException)
{
z_deflateEnd(pStream);
pStream = NULL;
}

View File

@@ -0,0 +1,188 @@
/*************************************************************************
*
* $RCSfile: EntryInputStream.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _ENTRY_INPUT_STREAM_HXX
#include "EntryInputStream.hxx"
#endif
#ifndef _COM_SUN_STAR_PACKAGE_ZIPCONSTANTS_HPP_
#include <com/sun/star/package/ZipConstants.hpp>
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
using namespace rtl;
using namespace com::sun::star;
/** Provides access to the compressed data in a zipfile. Decompresses on the fly, but
* does not currently support XSeekable into the compressed data stream.
* 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_Int32 nNewBufferSize)
: xStream(xNewInput)
, xSeek(xNewInput, uno::UNO_QUERY)
, nBegin(nNewBegin)
, nCurrent(nNewBegin)
, nEnd(nNewEnd)
, aSequence ( nNewBufferSize )
, aInflater( sal_True )
, nLength(0)
{
}
EntryInputStream::~EntryInputStream( void )
{
}
void EntryInputStream::fill(void)
{
sal_Int32 nBytesToRead = aSequence.getLength();
if (nBytesToRead + nCurrent> nEnd)
nBytesToRead = nEnd - nCurrent;
if (xSeek.is())
xSeek->seek( nCurrent );
else
throw (io::IOException());
nLength = xStream->readBytes(aSequence, nBytesToRead);
aInflater.setInputSegment(aSequence, 0, nLength);
}
sal_Int32 SAL_CALL EntryInputStream::readBytes( uno::Sequence< sal_Int8 >& aData,
sal_Int32 nBytesToRead )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
{
sal_Int32 n;
if (nBytesToRead <=0)
return 0;
while ( (n = aInflater.doInflate(aData)) == 0)
{
if (aInflater.finished() || aInflater.needsDictionary())
{
bReachEOF = sal_True;
return -1;
}
if (aInflater.needsInput())
fill();
}
return n;
//return xStream->readBytes(aData, nBytesToRead );
}
sal_Int32 SAL_CALL EntryInputStream::readSomeBytes( uno::Sequence< sal_Int8 >& aData,
sal_Int32 nMaxBytesToRead )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
{
if (nMaxBytesToRead + nCurrent > nEnd)
{
if (nCurrent > nEnd)
return 0;
nMaxBytesToRead = nEnd - nCurrent;
}
if (xSeek.is())
xSeek->seek( nCurrent );
else
throw (io::IOException());
return xStream->readSomeBytes( aData, nMaxBytesToRead );
}
void SAL_CALL EntryInputStream::skipBytes( sal_Int32 nBytesToSkip )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
{
if (nBytesToSkip + nCurrent> nEnd)
{
if (nCurrent> nEnd)
return;
nBytesToSkip = nEnd - nCurrent;
}
nCurrent+=nBytesToSkip;
}
sal_Int32 SAL_CALL EntryInputStream::available( )
throw(io::NotConnectedException, io::IOException, uno::RuntimeException)
{
return nEnd - nCurrent;
}
void SAL_CALL EntryInputStream::closeInput( )
throw(io::NotConnectedException, io::IOException, uno::RuntimeException)
{
}
sal_Int64 SAL_CALL EntryInputStream::seek( sal_Int64 location )
throw(lang::IllegalArgumentException, io::IOException, uno::RuntimeException)
{
if (location < nBegin)
location = nBegin;
if (location > nEnd)
location = nEnd;
nCurrent = location;
return nCurrent;
}
sal_Int64 SAL_CALL EntryInputStream::getPosition( )
throw(io::IOException, uno::RuntimeException)
{
return nCurrent;
}
sal_Int64 SAL_CALL EntryInputStream::getLength( )
throw(io::IOException, uno::RuntimeException)
{
return nEnd - nBegin;
}

View File

@@ -0,0 +1,268 @@
/*************************************************************************
*
* $RCSfile: Inflater.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _INFLATER_HXX_
#include "Inflater.hxx"
#endif
#include <iostream.h>
#include <string.h>
/** Provides general purpose decompression using the ZLIB library */
void Inflater::init (sal_Bool bNowrap)
{
pStream = new z_stream;
/* memset to 0 to set zalloc/opaque etc */
memset (pStream, 0, sizeof(*pStream));
sal_Int16 nRes;
nRes = inflateInit2(pStream, bNowrap ? -MAX_WBITS : MAX_WBITS);
switch (nRes)
{
case Z_OK:
break;
case Z_MEM_ERROR:
DBG_ERROR ( pStream->msg);
delete pStream;
break;
case Z_STREAM_ERROR:
DBG_ERROR ( pStream->msg);
delete pStream;
break;
default:
DBG_ERROR ( pStream->msg);
break;
}
}
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()
{
if (pStream)
delete pStream;
}
void SAL_CALL Inflater::setInputSegment( const com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(com::sun::star::uno::RuntimeException)
{
sInBuffer = rBuffer;
nOffset = nNewOffset;
nLength = nNewLength;
}
void SAL_CALL Inflater::setInput( const com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
throw(com::sun::star::uno::RuntimeException)
{
sInBuffer = rBuffer;
nOffset = 0;
nLength = rBuffer.getLength();
}
void SAL_CALL Inflater::setDictionarySegment( const com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(com::sun::star::uno::RuntimeException)
{
if (pStream == NULL)
{
// do error handling
}
if (nNewOffset < 0 || nNewLength < 0 || nNewOffset + nNewLength > rBuffer.getLength())
{
// do error handling
}
z_inflateSetDictionary(pStream, (const unsigned char*)rBuffer.getConstArray() + nNewOffset,
nNewLength);
}
void SAL_CALL Inflater::setDictionary( const com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
throw(com::sun::star::uno::RuntimeException)
{
if (pStream == NULL)
{
// do error handling
}
z_inflateSetDictionary(pStream, (const unsigned char*)rBuffer.getConstArray(),
rBuffer.getLength());
}
sal_Int32 SAL_CALL Inflater::getRemaining( )
throw(com::sun::star::uno::RuntimeException)
{
return nLength;
}
sal_Bool SAL_CALL Inflater::needsInput( )
throw(com::sun::star::uno::RuntimeException)
{
return nLength <=0;
}
sal_Bool SAL_CALL Inflater::needsDictionary( )
throw(com::sun::star::uno::RuntimeException)
{
return bNeedDict;
}
sal_Bool SAL_CALL Inflater::finished( )
throw(com::sun::star::uno::RuntimeException)
{
return bFinished;
}
sal_Int32 SAL_CALL Inflater::doInflateSegment( com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(com::sun::star::uno::RuntimeException)
{
if (nNewOffset < 0 || nNewLength < 0 || nNewOffset + nNewLength > rBuffer.getLength())
{
// do error handling
}
return doInflateBytes(rBuffer, nNewOffset, nNewLength);
}
sal_Int32 SAL_CALL Inflater::doInflate( com::sun::star::uno::Sequence< sal_Int8 >& rBuffer )
throw(com::sun::star::uno::RuntimeException)
{
return doInflateBytes(rBuffer, 0, rBuffer.getLength());
}
sal_Int32 SAL_CALL Inflater::getAdler( )
throw(com::sun::star::uno::RuntimeException)
{
return pStream->adler;
}
sal_Int32 SAL_CALL Inflater::getTotalIn( )
throw(com::sun::star::uno::RuntimeException)
{
return pStream->total_in;
}
sal_Int32 SAL_CALL Inflater::getTotalOut( )
throw(com::sun::star::uno::RuntimeException)
{
return pStream->total_out;
}
void SAL_CALL Inflater::reset( )
throw(com::sun::star::uno::RuntimeException)
{
z_inflateReset(pStream);
bNeedDict = sal_False;
bFinished = sal_False;
nOffset = nLength = 0;
}
void SAL_CALL Inflater::end( )
throw(com::sun::star::uno::RuntimeException)
{
z_inflateEnd(pStream);
pStream = NULL;
}
sal_Int16 Inflater::doInflateBytes (com::sun::star::uno::Sequence < sal_Int8 > &rBuffer, sal_Int16 nNewOffset, sal_Int16 nNewLength)
{
sal_Int16 nResult;
pStream->next_in = (unsigned char*) sInBuffer.getConstArray()+ nOffset;
pStream->avail_in = nLength;
pStream->next_out = (unsigned char*) rBuffer.getArray() + nNewOffset;
pStream->avail_out = nNewLength;
nResult = ::z_inflate(pStream, Z_PARTIAL_FLUSH);
switch (nResult)
{
case Z_STREAM_END:
bFinished = sal_True;
case Z_OK:
nOffset += nLength - pStream->avail_in;
nLength = pStream->avail_in;
return nLength - pStream->avail_out;
case Z_NEED_DICT:
bNeedDict = sal_True;
nOffset += nLength - pStream->avail_in;
nLength = pStream->avail_in;
case Z_BUF_ERROR:
return 0;
case Z_DATA_ERROR:
DBG_ERROR(pStream->msg);
return 0;
}
return 0;
}

View File

@@ -0,0 +1,105 @@
/*************************************************************************
*
* $RCSfile: ZipEnumeration.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _ZIP_ENUMERATION_HXX
#include "ZipEnumeration.hxx"
#endif
#ifndef _COM_SUN_STAR_PACKAGE_ZIPCONSTANTS_HPP_
#include <com/sun/star/package/ZipConstants.hpp>
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#include <iostream.h>
using namespace rtl;
using namespace com::sun::star;
/** Provides an Enumeration over the contents of a Zip file */
ZipEnumeration::ZipEnumeration( uno::Sequence< package::ZipEntry > &xList)
: nCurrent(0)
{
xZipList = xList;
}
ZipEnumeration::ZipEnumeration( )
: nCurrent(0)
{
}
ZipEnumeration::~ZipEnumeration( void )
{
}
sal_Bool SAL_CALL ZipEnumeration::hasMoreElements() throw (uno::RuntimeException)
{
return (nCurrent < xZipList.getLength());
}
uno::Any SAL_CALL ZipEnumeration::nextElement() throw (uno::RuntimeException)
{
if (hasMoreElements() == sal_False)
throw (container::NoSuchElementException() );
uno::Any aElement;
//aElement <<= uno::Reference < package::ZipEntry > (static_cast <package::ZipEntry > (xZipList[nCurrent++]));
aElement <<= xZipList[nCurrent++];
return aElement;
}

View File

@@ -0,0 +1,483 @@
/*************************************************************************
*
* $RCSfile: ZipFile.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _ZIP_FILE_HXX
#include "ZipFile.hxx"
#endif
#ifndef _ZIP_ENUMERATION_HXX
#include "ZipEnumeration.hxx"
#endif
#ifndef _COM_SUN_STAR_PACKAGE_ZIPCONSTANTS_HPP_
#include <com/sun/star/package/ZipConstants.hpp>
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _RTL_BYTESEQ_HXX_
#include <rtl/byteseq.hxx>
#endif
#include <string.h>
using namespace rtl;
using namespace com::sun::star;
using namespace com::sun::star::package::ZipConstants;
/** This class is used to read entries from a zip file
*/
ZipFile::ZipFile (uno::Reference < io::XInputStream > &xInput)
: xStream(xInput)
, aGrabber(xInput)
, pEntries(NULL)
, pTable(NULL)
, nTotal(0)
, nTableLen(0)
{
readCEN();
}
/*
ZipFile::ZipFile( void )
:pEntries(NULL)
, pTable(NULL)
, nTotal(0)
, nTableLen(0)
{
}
void SAL_CALL ZipFile::setInputStream( const uno::Reference< io::XInputStream >& xInput )
throw(io::IOException, package::ZipException, uno::RuntimeException)
{
xStream = uno::Reference <io::XInputStream> (xInput);
aGrabber.setInputStream ( xInput );
readCEN();
}
*/
//ZipFile::ZipFile (const uno::Reference < lang::XMultiServiceFactory > &xFactory)
//{
//}
ZipFile::~ZipFile()
{
if (pEntries != NULL)
delete []pEntries;
if (pTable != NULL)
{
ZipEntryImpl* pTmp = NULL;
for (int i =0; i < nTableLen; i++)
{
while ((pTmp = pTable[i]) != NULL)
{
pTable[i] = pTmp->pNext;
delete pTmp;
}
}
delete []pTable;
}
}
void ZipFile::close()
{
}
uno::Reference<container::XEnumeration> ZipFile::entries()
{
uno::Reference< container::XEnumeration> xEnumRef;
xEnumRef= new ZipEnumeration( uno::Sequence < package::ZipEntry > (pEntries, nTotal) );
//xEnumRef = uno::Reference < container::XEnumeration>( (OWeakObject*) pEnum, uno::UNO_QUERY );
// xEnumRef = uno::Reference < container::XEnumeration>( static_cast < container::XEnumeration *> (pEnum), uno::UNO_QUERY );
return xEnumRef;
}
::rtl::OUString ZipFile::getName()
{
return sName;
}
sal_Int32 ZipFile::getSize()
{
return nTotal;
}
uno::Type ZipFile::getElementType()
{
return ::getCppuType((package::ZipEntry *) 0);
}
sal_Bool ZipFile::hasElements()
{
return (nTotal>0);
}
uno::Any ZipFile::getByName(const ::rtl::OUString& rName)
{
uno::Any aAny;
sal_Int32 nHash = abs(rName.hashCode() % nTableLen);
ZipEntryImpl * pEntry = pTable[nHash];
while (pEntry != NULL)
{
if (rName == pEntry->getName())
{
//uno::Reference < package::ZepEntry > xEntry = pEntry;
aAny <<= *(pEntry->pEntry);
return aAny;
}
pEntry = pEntry->pNext;
}
throw container::NoSuchElementException();
return aAny;
}
uno::Sequence<rtl::OUString> ZipFile::getElementNames()
{
OUString *pNames = new OUString[nTotal];
for (int i = 0; i < nTotal; i++)
pNames[i] = pEntries[i].sName;
return uno::Sequence<OUString> (pNames, nTotal);
}
sal_Bool ZipFile::hasByName(const ::rtl::OUString& rName)
{
sal_Int32 nHash = abs(rName.hashCode() % nTableLen);
ZipEntryImpl * pEntry = pTable[nHash];
while (pEntry != NULL)
{
if (rName == pEntry->getName())
return sal_True;
pEntry = pEntry->pNext;
}
return sal_False;
}
uno::Reference< io::XInputStream> ZipFile::getInputStream(const package::ZipEntry& rEntry)
{
sal_Int64 nEnd = rEntry.nCompressedSize == 0 ? rEntry.nSize : rEntry.nCompressedSize;
if (rEntry.nOffset <= 0)
readLOC(rEntry);
sal_Int64 nBegin = rEntry.nOffset;
nEnd +=nBegin;
uno::Reference< io::XInputStream > xStreamRef = new EntryInputStream(xStream, nBegin, nEnd, 1024);
return xStreamRef;
}
sal_Bool ZipFile::readLOC(const package::ZipEntry &rEntry)
{
sal_uInt32 nTestSig, nTime, nCRC, nSize, nCompressedSize;
sal_uInt16 nVersion, nFlag, nHow, nNameLen, nExtraLen;
sal_Int32 nPos = -rEntry.nOffset;
aGrabber.seek(nPos);
aGrabber >> nTestSig;
if (nTestSig != LOCSIG)
{
DBG_ERROR ("Invalid LOC header (bad signature)");
return sal_False;
}
aGrabber >> nVersion;
aGrabber >> nFlag;
aGrabber >> nHow;
aGrabber >> nTime;
aGrabber >> nCRC;
aGrabber >> nCompressedSize;
aGrabber >> nSize;
aGrabber >> nNameLen;
aGrabber >> nExtraLen;
package::ZipEntry *pNonConstEntry = const_cast < package::ZipEntry* > (&rEntry);
pNonConstEntry->nOffset = aGrabber.getPosition() + nNameLen + nExtraLen;
return sal_True;
/*
ZipEntryImpl *pEntry = new ZipEntryImpl();
sal_Char * pTmpName = new sal_Char[nNameLen];
xStream.Read(pTmpName, nNameLen);
pEntry->sName = ByteSequence( pTmpName, nNameLen, RTL_TEXTENCODING_ASCII_US);
delete [] pTmpName;
sal_Char * pTmpExtra = new sal_Char[nExtraLen];
xStream.Read(pTmpExtra, nExtraLen);
pEntry->sExtra = ByteSequence(pTmpExtra, nExtraLen);
delete [] pTmpExtra;
pEntry->sComment = pComments[pCell->nIndex];
pEntry->nSize = pCell->nSize;
pEntry->nCompressedSize = pCell->nCompressedSize;
pEntry->nCRC = pCell->nCRC;
pEntry->nTime = nTime;
pEntry->nMethod = nHow;
pEntry->nPos = pCell->nPos + LOCHDR + nNameLen + nExtraLen;
return pEntry;
*/
}
sal_Int32 ZipFile::findEND( )
{
ULONG nLength=0, nPos=0;
ByteSequence aByteSeq;
nLength = nPos = aGrabber.getLength();
aGrabber.seek( nLength );
while (nLength - nPos < 0xFFFF)
{
ULONG nCount = 0xFFFF - ( nLength - nPos);
if (nCount > ENDHDR)
nCount = ENDHDR;
nPos -= nCount;
for (sal_uInt16 i=0; i <nCount;i++)
{
sal_uInt32 nTest=0, nFoo=ENDSIG;
aGrabber.seek (nPos+i);
aGrabber >> nTest;
if (nTest == ENDSIG)
{
sal_uInt16 nCommentLength;
sal_uInt32 nEndPos = nPos + i;
aGrabber.seek(nEndPos+ENDCOM);
aGrabber >> nCommentLength;
if (nEndPos + ENDHDR + nCommentLength == nLength)
{
if (nCommentLength>0)
{
aByteSeq.realloc(nCommentLength+1);
aGrabber.readBytes(uno::Sequence< sal_Int8>(aByteSeq.getArray(), nCommentLength), nCommentLength);
aByteSeq[nCommentLength]='\0';
sComment = OUString((sal_Char*)aByteSeq.getConstArray(), nCommentLength+1, RTL_TEXTENCODING_ASCII_US);
}
return nPos + i;
}
}
}
}
return -1;
}
#if 0
sal_Bool ZipFile::isMetaName( ByteSequence &rName)
{
ByteSequence sTemp = rName.toUpperCase();
if (sTemp.compareToAscii( "META_INF/", 9) == 0)
return sal_True;
return sal_False;
}
void ZipFile::addMetaName( ByteSequence &rName )
{
aMetaNames.Insert (new String(rName));
}
void ZipFile::addEntryComment( int nIndex, ByteSequence &rComment)
{
if (pComments == NULL)
pComments = new ByteSequence[nTotal];
pComments[nIndex]=rComment;
}
#endif
sal_Int32 ZipFile::readCEN()
{
sal_uInt32 nEndPos, nLocPos;
sal_Int16 nCount;
sal_uInt32 nCenLen, nCenPos, nCenOff;
nEndPos = findEND();
aGrabber.seek(nEndPos + ENDTOT);
aGrabber >> nTotal;
aGrabber >> nCenLen;
aGrabber >> nCenOff;
if (nTotal<0 || nTotal * CENHDR > nCenLen)
{
DBG_ERROR("invalid END header (bad entry count)");
return -1;
}
if (nTotal > ZIP_MAXENTRIES)
{
DBG_ERROR("too many entries in ZIP File");
return -1;
}
//aGrabber.seek(nEndPos+ENDSIZ);
if (nCenLen < 0 || nCenLen > nEndPos)
{
DBG_ERROR ("invalid END header (bad central directory size)");
return -1;
}
nCenPos = nEndPos - nCenLen;
if (nCenOff < 0 || nCenOff > nCenPos)
{
DBG_ERROR("invalid END header (bad central directory size)");
return -1;
}
nLocPos = nCenPos - nCenOff;
aGrabber.seek(nCenPos);
pEntries = new package::ZipEntry[nTotal];
nTableLen = nTotal * 2;
pTable = new ZipEntryImpl*[nTableLen];
memset(pTable, 0, sizeof (ZipEntryImpl*) * nTableLen);
for (nCount = 0 ; nCount < nTotal; nCount++)
{
package::ZipEntry *pEntry = &pEntries[nCount];
sal_Int32 nTestSig, nCRC, nCompressedSize, nTime, nSize, nExtAttr, nOffset;
sal_Int16 nVerMade, nVersion, nFlag, nHow, nNameLen, nExtraLen, nCommentLen;
sal_Int16 nDisk, nIntAttr;
if (aGrabber.getPosition() - nCenPos + CENHDR > nCenLen)
{
DBG_ERROR("invalid CEN header (bad header size check 1");
break;
}
aGrabber >> nTestSig;
if (nTestSig != CENSIG)
{
DBG_ERROR ("invalid CEN header (bad signature)");
break;
}
aGrabber >> nVerMade;
aGrabber >> nVersion;
if ((nVersion & 1) == 1)
{
DBG_ERROR ( "invalid CEN header (encrypted entry)");
break;
}
aGrabber >> nFlag;
aGrabber >> nHow;
if (nHow != STORED && nHow != DEFLATED)
{
DBG_ERROR ( "invalid CEN header (bad compression method)");
break;
}
aGrabber >> nTime;
aGrabber >> nCRC;
aGrabber >> nCompressedSize;
aGrabber >> nSize;
aGrabber >> nNameLen;
aGrabber >> nExtraLen;
aGrabber >> nCommentLen;
aGrabber >> nDisk;
aGrabber >> nIntAttr;
aGrabber >> nExtAttr;
aGrabber >> nOffset;
if (aGrabber.getPosition() - nCenPos + nNameLen + nExtraLen + nCommentLen > nCenLen)
{
DBG_ERROR ( "invalid CEN header (bad header size check 2)");
break;
}
if (nNameLen > ZIP_MAXNAMELEN)
{
DBG_ERROR ( "name length exceeds 512 bytes");
break;
}
if (nExtraLen > ZIP_MAXEXTRA)
{
DBG_ERROR ( "extra header info exceeds 256 bytes");
break;
}
pEntry->nTime = nTime;
pEntry->nCrc = nCRC;
pEntry->nSize = nSize;
pEntry->nCompressedSize = nCompressedSize;
pEntry->nMethod = nHow;
pEntry->nFlag = nFlag;
pEntry->nVersion= nVersion;
pEntry->nOffset = nOffset + nLocPos;
pEntry->nOffset *= -1;
if (nHow == STORED)
pEntry->nCompressedSize = 0;
uno::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 );
aGrabber.readBytes(aCommentSeq, nCommentLen);
pEntry->sComment = OUString((sal_Char*)aCommentSeq.getConstArray(), nNameLen, RTL_TEXTENCODING_ASCII_US);
}
sal_Int32 nHash = abs(pEntry->sName.hashCode() % nTableLen);
ZipEntryImpl* pTmp = new ZipEntryImpl();
pTmp->pEntry = pEntry;
pTmp->pNext = pTable[nHash];
pTable[nHash] = pTmp;
/*pEntry->pNext = pTable[nHash];
pTable[nHash] = pEntry;*/
}
if (nCount != nTotal)
{
DBG_ERROR("Count != total!");
return -1;
}
return nCenPos;
}

View File

@@ -0,0 +1,356 @@
/*************************************************************************
*
* $RCSfile: ZipOutputStream.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _ZIP_OUTPUT_STREAM_HXX
#include "ZipOutputStream.hxx"
#endif
using namespace rtl;
using namespace com::sun::star;
using namespace com::sun::star::package::ZipConstants;
/** This class is used to write Zip files
*/
ZipOutputStream::ZipOutputStream( uno::Reference < io::XOutputStream > &xOStream, sal_Int32 nNewBufferSize)
: xStream(xOStream)
, aChucker(xOStream)
, nMethod(DEFLATED)
, pCurrentEntry(NULL)
, bFinished(sal_False)
, aBuffer(nNewBufferSize)
, aDeflater(DEFAULT_COMPRESSION, sal_True)
{
}
ZipOutputStream::~ZipOutputStream( void )
{
}
void SAL_CALL ZipOutputStream::setComment( const ::rtl::OUString& rComment )
throw(uno::RuntimeException)
{
sComment = rComment;
}
void SAL_CALL ZipOutputStream::setMethod( sal_Int32 nNewMethod )
throw(uno::RuntimeException)
{
nMethod = nNewMethod;
}
void SAL_CALL ZipOutputStream::setLevel( sal_Int32 nNewLevel )
throw(uno::RuntimeException)
{
aDeflater.setLevel( nNewLevel);
}
void SAL_CALL ZipOutputStream::putNextEntry( const package::ZipEntry& rEntry )
throw(io::IOException, uno::RuntimeException)
{
package::ZipEntry *pNonConstEntry = const_cast < package::ZipEntry* >(&rEntry);
if (pCurrentEntry != NULL)
closeEntry();
if (pNonConstEntry->nTime == -1)
{
Time aTime;
aTime = Time();
pNonConstEntry->nTime = aTime.GetTime();
}
if (pNonConstEntry->nMethod == -1)
{
pNonConstEntry->nMethod = nMethod;
}
switch (pNonConstEntry->nMethod)
{
case DEFLATED:
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;
pNonConstEntry->nVersion = 20;
break;
case STORED:
if (pNonConstEntry->nSize == -1)
pNonConstEntry->nSize = pNonConstEntry->nCompressedSize;
else if (pNonConstEntry->nCompressedSize == -1)
pNonConstEntry->nCompressedSize = pNonConstEntry->nSize;
pNonConstEntry->nVersion = 10;
pNonConstEntry->nFlag = 0;
break;
}
pNonConstEntry->nOffset = aChucker.getPosition();
writeLOC(rEntry);
aZipList.push_back(pNonConstEntry);
pCurrentEntry=pNonConstEntry;
}
void SAL_CALL ZipOutputStream::close( )
throw(io::IOException, uno::RuntimeException)
{
finish();
}
void SAL_CALL ZipOutputStream::closeEntry( )
throw(io::IOException, uno::RuntimeException)
{
package::ZipEntry *pEntry = pCurrentEntry;
if (pEntry)
{
switch (pEntry->nMethod)
{
case DEFLATED:
aDeflater.finish();
while (!aDeflater.finished())
doDeflate();
if ((pEntry->nFlag & 8) == 0)
{
if (pEntry->nSize != aDeflater.getTotalIn())
{
// boom
DBG_ERROR("Invalid entry size");
}
if (pEntry->nCompressedSize != aDeflater.getTotalOut())
{
// boom
DBG_ERROR("Invalid entry compressed size");
}
if (pEntry->nCrc != aCRC.getValue())
{
// boom
DBG_ERROR("Invalid entry CRC-32");
}
}
else
{
pEntry->nSize = aDeflater.getTotalIn();
pEntry->nCompressedSize = aDeflater.getTotalOut();
pEntry->nCrc = aCRC.getValue();
writeEXT(*pEntry);
}
aDeflater.reset();
break;
case STORED:
if (pEntry->nCrc != aCRC.getValue())
{
// boom
DBG_ERROR("Invalid entry crc32");
}
break;
default:
// boom;
DBG_ERROR("Invalid compression method");
break;
}
aCRC.reset();
pCurrentEntry = NULL;
}
}
void SAL_CALL ZipOutputStream::write( const uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(io::IOException, uno::RuntimeException)
{
switch (pCurrentEntry->nMethod)
{
case DEFLATED:
if (!aDeflater.finished())
{
aDeflater.setInputSegment(rBuffer, nNewOffset, nNewLength);
while (!aDeflater.needsInput())
doDeflate();
}
break;
case STORED:
aChucker.writeBytes(rBuffer);
break;
}
aCRC.updateSegment(rBuffer, nNewOffset, nNewLength);
}
void SAL_CALL ZipOutputStream::finish( )
throw(io::IOException, uno::RuntimeException)
{
if (bFinished)
return;
if (pCurrentEntry != NULL)
closeEntry();
if (aZipList.size() < 1)
{
// boom
DBG_ERROR("Zip file must have at least one entry!\n");
}
sal_Int32 nOffset= aChucker.getPosition();
for (int i =0, nEnd = aZipList.size(); i < nEnd; i++)
writeCEN(*aZipList[i]);
writeEND( nOffset, aChucker.getPosition() - nOffset);
bFinished = sal_True;
}
void ZipOutputStream::doDeflate()
{
sal_Int16 nLength = aDeflater.doDeflateSegment(aBuffer, 0, aBuffer.getLength());
if (nLength > 0 )
{
aChucker.writeBytes(aBuffer);
}
}
void ZipOutputStream::writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
{
sal_Int16 i=0, nCommentLength = sComment.getLength();
const sal_Unicode *pChar = sComment.getStr();
uno::Sequence < sal_Int8 > aSequence (nCommentLength);
for ( ; i < nCommentLength; i++)
{
DBG_ASSERT (pChar[i] <127, "Non US ASCII character in zipfile comment!");
aSequence[i] = static_cast < const sal_Int8 > (pChar[i]);
}
aChucker << ENDSIG;
aChucker << static_cast < sal_Int16 > ( 0 );
aChucker << static_cast < sal_Int16 > ( 0 );
aChucker << static_cast < sal_Int16 > ( aZipList.size() );
aChucker << static_cast < sal_Int16 > ( aZipList.size() );
aChucker << nLength;
aChucker << nOffset;
aChucker << nCommentLength;
if (nCommentLength)
aChucker.writeBytes(aSequence);
}
void ZipOutputStream::writeCEN( const package::ZipEntry &rEntry )
{
sal_Int16 nNameLength = rEntry.sName.getLength(),
nCommentLength = rEntry.sName.getLength(),
nExtraLength = rEntry.extra.getLength(), i = 0;
aChucker << CENSIG;
aChucker << rEntry.nVersion;
aChucker << rEntry.nVersion;
aChucker << rEntry.nFlag;
aChucker << rEntry.nMethod;
aChucker << rEntry.nTime;
aChucker << static_cast < sal_uInt32> (rEntry.nCrc);
aChucker << rEntry.nCompressedSize;
aChucker << rEntry.nSize;
aChucker << nNameLength;
aChucker << nExtraLength;
aChucker << nCommentLength;
aChucker << static_cast < sal_Int16> (0);
aChucker << static_cast < sal_Int16> (0);
aChucker << static_cast < sal_Int32> (0);
aChucker << rEntry.nOffset;
const sal_Unicode *pChar = rEntry.sName.getStr();
uno::Sequence < sal_Int8 > aSequence (nNameLength);
for ( ; i < nNameLength; i++)
{
DBG_ASSERT (pChar[i] <127, "Non US ASCII character in zipentry name!");
aSequence[i] = static_cast < const sal_Int8 > (pChar[i]);
}
aChucker.writeBytes( aSequence );
if (nExtraLength)
aChucker.writeBytes( rEntry.extra);
if (nCommentLength)
{
aSequence.realloc (nCommentLength);
for (i=0, pChar = rEntry.sName.getStr(); i < nCommentLength; i++)
{
DBG_ASSERT (pChar[i] <127, "Non US ASCII character in zipentry comment!");
aSequence[i] = static_cast < const sal_Int8 > (pChar[i]);
}
aChucker.writeBytes( aSequence );
}
}
void ZipOutputStream::writeEXT( const package::ZipEntry &rEntry )
{
aChucker << EXTSIG;
aChucker << rEntry.nCrc;
aChucker << rEntry.nCompressedSize;
aChucker << rEntry.nSize;
}
void ZipOutputStream::writeLOC( const package::ZipEntry &rEntry )
{
sal_Int16 nNameLength = rEntry.sName.getLength(), i=0;
aChucker << LOCSIG;
aChucker << rEntry.nVersion;
aChucker << rEntry.nFlag;
aChucker << rEntry.nMethod;
aChucker << rEntry.nTime;
if ((rEntry.nFlag & 8) == 8 )
{
aChucker << static_cast < sal_Int32 > (0);
aChucker << static_cast < sal_Int32 > (0);
aChucker << static_cast < sal_Int32 > (0);
}
else
{
aChucker << static_cast < sal_uInt32 > (rEntry.nCrc);
aChucker << rEntry.nCompressedSize;
aChucker << rEntry.nSize;
}
aChucker << nNameLength;
aChucker << static_cast <sal_Int16 > ( rEntry.extra.getLength());
const sal_Unicode *pChar = rEntry.sName.getStr();
uno::Sequence < sal_Int8 > aSequence (nNameLength);
for ( ; i < nNameLength; i++)
{
DBG_ASSERT (pChar[i] <127, "Non US ASCII character in zipentry name!");
aSequence[i] = static_cast < const sal_Int8 > (pChar[i]);
}
aChucker.writeBytes( aSequence );
if (rEntry.extra.getLength() != 0)
aChucker.writeBytes( rEntry.extra );
}

View File

@@ -0,0 +1,115 @@
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..
PRJNAME=package
TARGET=zipapi
AUTOSEG=true
ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
# --- Files --------------------------------------------------------
SLOFILES= \
$(SLO)$/Adler32.obj \
$(SLO)$/CRC32.obj \
$(SLO)$/ByteChucker.obj \
$(SLO)$/ByteGrabber.obj \
$(SLO)$/Inflater.obj \
$(SLO)$/Deflater.obj \
$(SLO)$/ZipEnumeration.obj \
$(SLO)$/ZipFile.obj \
$(SLO)$/ZipOutputStream.obj \
$(SLO)$/EntryInputStream.obj \
# --- UNO stuff ---------------------------------------------------
CPPUMAKERFLAGS=
#UNOUCROUT=$(OUT)$/inc
#INCPRE+=$(UNOUCROUT)
UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb
UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb
UNOTYPES=\
com.sun.star.package.* \
com.sun.star.io.XSeekable \
com.sun.star.io.XOutputStream \
com.sun.star.lang.XInitialization \
com.sun.star.container.XHierarchicalNameAccess \
com.sun.star.lang.XSingleServiceFactory \
com.sun.star.util.XChangesBatch \
com.sun.star.container.XEnumeration \
com.sun.star.container.XNamed \
com.sun.star.container.XNameContainer \
com.sun.star.container.XEnumerationAccess \
com.sun.star.io.XActiveDataSink \
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk

118
package/util/makefile.mk Normal file
View File

@@ -0,0 +1,118 @@
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: mtg $ $Date: 2000-11-13 13:38:03 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..
PRJNAME=package
TARGET=package
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
# --- General ----------------------------------------------------
LIB1TARGET= $(SLB)$/package.lib
LIB1FILES= \
$(SLB)$/zipapi.lib \
# --- Shared-Library -----------------------------------------------
SHL1TARGET= package$(UPD)$(DLLPOSTFIX)
SHL1IMPLIB= _ipackage
SHL1STDLIBS= \
$(TOOLSLIB) \
$(VOSLIB) \
$(CPPULIB) \
$(CPPUHELPERLIB)\
$(COMPHELPERLIB)\
$(RTLLIB) \
$(SALLIB) \
$(UNOTOOLSLIB) \
$(ZLIB3RDLIB)
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
SHL1LIBS= $(LIB1TARGET)
# --- Def-File ---------------------------------------------------------
DEF1NAME =$(SHL1TARGET)
DEF1DEPN =$(MISC)$/$(SHL1TARGET).flt
DEFLIB1NAME =package
DEF1DES =Package Lib
# --- Targets ----------------------------------------------------------
.INCLUDE : target.mk
# --- Filter ----------------------------------------------------------
$(MISC)$/$(SHL1TARGET).flt: makefile.mk
.IF "$(GUI)"=="WNT"
+echo _CT? > $@
.ENDIF
+echo _CTA >> $@
+echo sXML_ >> $@