LibreOffice Module tools (master) 1
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ZCodec Class Reference

#include <zcodec.hxx>

Collaboration diagram for ZCodec:
[legend]

Public Member Functions

 ZCodec (size_t nInBufSize=32768, size_t nOutBufSize=32768)
 
 ~ZCodec ()
 
void BeginCompression (int nCompressLevel=ZCODEC_DEFAULT_COMPRESSION, bool gzLib=false)
 
tools::Long EndCompression ()
 
void SetCompressionMetadata (const OString &sFilename, sal_uInt32 nLastModifiedTime, sal_uInt32 nInBufCRC32)
 Set metadata for gzlib compression. More...
 
void Compress (SvStream &rIStm, SvStream &rOStm)
 
tools::Long Decompress (SvStream &rIStm, SvStream &rOStm)
 
bool AttemptDecompression (SvStream &rIStm, SvStream &rOStm)
 
void Write (SvStream &rOStm, const sal_uInt8 *pData, sal_uInt32 nSize)
 
tools::Long Read (SvStream &rIStm, sal_uInt8 *pData, sal_uInt32 nSize)
 

Static Public Member Functions

static bool IsZCompressed (SvStream &rIStm)
 Checks whether a stream is Z compressed. More...
 

Private Types

enum  State {
  STATE_INIT ,
  STATE_DECOMPRESS ,
  STATE_COMPRESS
}
 

Private Member Functions

void InitCompress ()
 
void InitDecompress (SvStream &inStream)
 
void ImplWriteBack ()
 

Private Attributes

State meState
 
bool mbStatus
 
bool mbFinish
 
std::unique_ptr< sal_uInt8[]> mpInBuf
 
size_t mnInBufSize
 
size_t mnInToRead
 
SvStreammpOStm
 
std::unique_ptr< sal_uInt8[]> mpOutBuf
 
size_t mnOutBufSize
 
sal_uInt32 mnUncompressedSize
 
sal_uInt32 mnInBufCRC32
 
sal_uInt32 mnLastModifiedTime
 
OString msFilename
 
int mnCompressLevel
 
bool mbGzLib
 
void * mpsC_Stream
 

Detailed Description

Definition at line 40 of file zcodec.hxx.

Member Enumeration Documentation

◆ State

enum ZCodec::State
private
Enumerator
STATE_INIT 
STATE_DECOMPRESS 
STATE_COMPRESS 

Definition at line 42 of file zcodec.hxx.

Constructor & Destructor Documentation

◆ ZCodec()

ZCodec::ZCodec ( size_t  nInBufSize = 32768,
size_t  nOutBufSize = 32768 
)

Definition at line 42 of file zcodec.cxx.

References mpsC_Stream.

◆ ~ZCodec()

ZCodec::~ZCodec ( )

Definition at line 59 of file zcodec.cxx.

References mpsC_Stream.

Member Function Documentation

◆ AttemptDecompression()

bool ZCodec::AttemptDecompression ( SvStream rIStm,
SvStream rOStm 
)

◆ BeginCompression()

void ZCodec::BeginCompression ( int  nCompressLevel = ZCODEC_DEFAULT_COMPRESSION,
bool  gzLib = false 
)

◆ Compress()

void ZCodec::Compress ( SvStream rIStm,
SvStream rOStm 
)

◆ Decompress()

tools::Long ZCodec::Decompress ( SvStream rIStm,
SvStream rOStm 
)

◆ EndCompression()

tools::Long ZCodec::EndCompression ( )

◆ ImplWriteBack()

void ZCodec::ImplWriteBack ( )
private

Definition at line 285 of file zcodec.cxx.

References mnOutBufSize, mpOStm, mpOutBuf, mpsC_Stream, and SvStream::WriteBytes().

Referenced by Compress(), Decompress(), EndCompression(), and Write().

◆ InitCompress()

void ZCodec::InitCompress ( )
private

◆ InitDecompress()

void ZCodec::InitDecompress ( SvStream inStream)
private

◆ IsZCompressed()

bool ZCodec::IsZCompressed ( SvStream rIStm)
static

Checks whether a stream is Z compressed.

Parameters
rIStmthe stream to check

Definition at line 65 of file zcodec.cxx.

References GZ_MAGIC_BYTES_LE, SvStream::ReadUInt16(), SvStream::Seek(), and SvStream::Tell().

◆ Read()

tools::Long ZCodec::Read ( SvStream rIStm,
sal_uInt8 pData,
sal_uInt32  nSize 
)

◆ SetCompressionMetadata()

void ZCodec::SetCompressionMetadata ( const OString &  sFilename,
sal_uInt32  nLastModifiedTime,
sal_uInt32  nInBufCRC32 
)

Set metadata for gzlib compression.

Parameters
sFilenamethe uncompressed file filename
nLastModifiedTimethe files last modified time in unix format

Definition at line 148 of file zcodec.cxx.

References mbGzLib, mnInBufCRC32, mnLastModifiedTime, and msFilename.

◆ Write()

void ZCodec::Write ( SvStream rOStm,
const sal_uInt8 pData,
sal_uInt32  nSize 
)

Definition at line 218 of file zcodec.cxx.

References ImplWriteBack(), InitCompress(), mbStatus, meState, mpOStm, mpsC_Stream, pData, and STATE_INIT.

Member Data Documentation

◆ mbFinish

bool ZCodec::mbFinish
private

Definition at line 45 of file zcodec.hxx.

Referenced by BeginCompression(), and Read().

◆ mbGzLib

bool ZCodec::mbGzLib
private

◆ mbStatus

bool ZCodec::mbStatus
private

◆ meState

State ZCodec::meState
private

◆ mnCompressLevel

int ZCodec::mnCompressLevel
private

Definition at line 57 of file zcodec.hxx.

Referenced by BeginCompression(), and InitCompress().

◆ mnInBufCRC32

sal_uInt32 ZCodec::mnInBufCRC32
private

Definition at line 53 of file zcodec.hxx.

Referenced by EndCompression(), and SetCompressionMetadata().

◆ mnInBufSize

size_t ZCodec::mnInBufSize
private

Definition at line 47 of file zcodec.hxx.

Referenced by Compress(), Decompress(), InitDecompress(), and Read().

◆ mnInToRead

size_t ZCodec::mnInToRead
private

Definition at line 48 of file zcodec.hxx.

Referenced by BeginCompression(), Decompress(), and Read().

◆ mnLastModifiedTime

sal_uInt32 ZCodec::mnLastModifiedTime
private

Definition at line 54 of file zcodec.hxx.

Referenced by EndCompression(), and SetCompressionMetadata().

◆ mnOutBufSize

size_t ZCodec::mnOutBufSize
private

Definition at line 51 of file zcodec.hxx.

Referenced by Decompress(), ImplWriteBack(), and InitCompress().

◆ mnUncompressedSize

sal_uInt32 ZCodec::mnUncompressedSize
private

Definition at line 52 of file zcodec.hxx.

Referenced by Compress(), and EndCompression().

◆ mpInBuf

std::unique_ptr<sal_uInt8[]> ZCodec::mpInBuf
private

Definition at line 46 of file zcodec.hxx.

Referenced by BeginCompression(), Compress(), Decompress(), EndCompression(), InitDecompress(), and Read().

◆ mpOStm

SvStream* ZCodec::mpOStm
private

◆ mpOutBuf

std::unique_ptr<sal_uInt8[]> ZCodec::mpOutBuf
private

Definition at line 50 of file zcodec.hxx.

Referenced by BeginCompression(), Decompress(), EndCompression(), ImplWriteBack(), and InitCompress().

◆ mpsC_Stream

void* ZCodec::mpsC_Stream
private

◆ msFilename

OString ZCodec::msFilename
private

Definition at line 55 of file zcodec.hxx.

Referenced by EndCompression(), InitCompress(), and SetCompressionMetadata().


The documentation for this class was generated from the following files: