2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-11 09:51:50 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2007-04-11 19:21:48 +00:00
|
|
|
|
2013-10-23 19:15:52 +02:00
|
|
|
#ifndef INCLUDED_TOOLS_ZCODEC_HXX
|
|
|
|
#define INCLUDED_TOOLS_ZCODEC_HXX
|
2007-04-11 19:21:48 +00:00
|
|
|
|
2013-11-09 15:37:43 -06:00
|
|
|
#include <tools/toolsdllapi.h>
|
2007-04-11 19:21:48 +00:00
|
|
|
|
2014-05-21 12:20:59 +02:00
|
|
|
#define ZCODEC_NO_COMPRESSION 0
|
|
|
|
#define ZCODEC_DEFAULT_COMPRESSION 6
|
2007-04-11 19:21:48 +00:00
|
|
|
|
|
|
|
class SvStream;
|
|
|
|
|
2014-05-21 17:03:41 +02:00
|
|
|
// The overall client call protocol is one of:
|
|
|
|
// * BeginCompression, Compress, EndCompression
|
|
|
|
// * BeginCompression, Decompress, EndCompression
|
|
|
|
// * BeginCompression, Write*, EndCompression
|
|
|
|
// * BeginCompression, Read*, EndCompression
|
|
|
|
// * BeginCompression, ReadAsynchron*, EndCompression
|
2007-04-11 19:21:48 +00:00
|
|
|
class TOOLS_DLLPUBLIC ZCodec
|
|
|
|
{
|
2014-05-21 17:03:41 +02:00
|
|
|
enum State { STATE_INIT, STATE_DECOMPRESS, STATE_COMPRESS };
|
|
|
|
State meState;
|
2013-06-29 23:57:38 -05:00
|
|
|
bool mbStatus;
|
|
|
|
bool mbFinish;
|
2012-08-13 23:42:18 +02:00
|
|
|
sal_uInt8* mpInBuf;
|
|
|
|
sal_uIntPtr mnInBufSize;
|
|
|
|
sal_uIntPtr mnInToRead;
|
2007-04-11 19:21:48 +00:00
|
|
|
SvStream* mpOStm;
|
2012-08-13 23:42:18 +02:00
|
|
|
sal_uInt8* mpOutBuf;
|
|
|
|
sal_uIntPtr mnOutBufSize;
|
2007-04-11 19:21:48 +00:00
|
|
|
|
2012-08-13 23:42:18 +02:00
|
|
|
sal_uIntPtr mnCRC;
|
2014-05-21 12:20:59 +02:00
|
|
|
int mnCompressLevel;
|
|
|
|
bool mbUpdateCrc;
|
|
|
|
bool mbGzLib;
|
2007-04-11 19:21:48 +00:00
|
|
|
void* mpsC_Stream;
|
|
|
|
|
2014-05-21 17:35:27 +02:00
|
|
|
void InitCompress();
|
2014-05-21 18:07:14 +02:00
|
|
|
void InitDecompress(SvStream & inStream);
|
2014-05-21 09:48:06 +02:00
|
|
|
void ImplWriteBack();
|
2007-04-11 19:21:48 +00:00
|
|
|
|
2014-05-21 14:33:20 +02:00
|
|
|
void UpdateCRC( sal_uInt8* pSource, long nDatSize );
|
|
|
|
|
2007-04-11 19:21:48 +00:00
|
|
|
public:
|
2014-05-21 11:02:36 +02:00
|
|
|
ZCodec( sal_uIntPtr nInBuf = 0x8000UL, sal_uIntPtr nOutBuf = 0x8000UL );
|
2014-05-21 12:44:53 +02:00
|
|
|
~ZCodec();
|
2007-04-11 19:21:48 +00:00
|
|
|
|
2014-05-21 12:44:53 +02:00
|
|
|
void BeginCompression( int nCompressLevel = ZCODEC_DEFAULT_COMPRESSION, bool updateCrc = false, bool gzLib = false );
|
|
|
|
long EndCompression();
|
2007-04-11 19:21:48 +00:00
|
|
|
|
|
|
|
long Compress( SvStream& rIStm, SvStream& rOStm );
|
|
|
|
long Decompress( SvStream& rIStm, SvStream& rOStm );
|
|
|
|
|
2010-07-29 10:56:19 +08:00
|
|
|
long Write( SvStream& rOStm, const sal_uInt8* pData, sal_uIntPtr nSize );
|
|
|
|
long Read( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize );
|
|
|
|
long ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize );
|
2007-04-11 19:21:48 +00:00
|
|
|
|
2010-07-29 10:56:19 +08:00
|
|
|
void SetBreak( sal_uIntPtr );
|
2014-05-21 09:48:06 +02:00
|
|
|
sal_uIntPtr GetBreak();
|
2010-07-29 10:56:19 +08:00
|
|
|
void SetCRC( sal_uIntPtr nCurrentCRC );
|
2014-06-09 10:09:42 +02:00
|
|
|
sal_uIntPtr GetCRC() { return mnCRC;}
|
2007-04-11 19:21:48 +00:00
|
|
|
};
|
|
|
|
|
2012-08-13 23:14:08 +02:00
|
|
|
#endif
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|