Commit 18adb421 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

PdfWriter with JBig2 linux build

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62538 954022d7-b5bf-4e40-9824-e11837661b57
parent c790d7af
......@@ -808,7 +808,7 @@ CString RtfCharProperty::RenderToOOX(RenderParameter oRenderParameter)
sResult.Append( m_poShading.RenderToOOX( oRenderParameter ));
return sResult;
}
#include <langinfo.h>
CString RtfListLevelProperty::RenderToRtf(RenderParameter oRenderParameter)
{
RtfDocument* poRtfDocument = static_cast<RtfDocument*>( oRenderParameter.poDocument);
......
......@@ -432,8 +432,7 @@ SOURCES += \
../../../cximage/CxImage/ximawmf.cpp \
../../../cximage/CxImage/ximawnd.cpp \
../../../cximage/CxImage/xmemfile.cpp \
../../../raster/BgraFrame.cpp \
../../../raster/ImageFileFormatChecker.cpp
../../../raster/BgraFrame.cpp
HEADERS += \
../../../graphics/AggPlusEnums.h \
......
......@@ -114,7 +114,7 @@ jbig2enc_init(struct jbig2enc_ctx *ctx) {
ctx->bp = -1;
ctx->b = 0;
ctx->outbuf_used = 0;
ctx->outbuf = (u8 *) malloc(JBIG2_OUTPUTBUFFER_SIZE);
ctx->outbuf = (u8 *) new u8 [JBIG2_OUTPUTBUFFER_SIZE];
ctx->output_chunks = new std::vector<uint8_t *>;
ctx->iaidctx = NULL;
}
......@@ -127,7 +127,7 @@ jbig2enc_reset(struct jbig2enc_ctx *ctx) {
ctx->ct = 12;
ctx->bp = -1;
ctx->b = 0;
free(ctx->iaidctx);
delete []ctx->iaidctx;
ctx->iaidctx = NULL;
memset(ctx->context, 0, JBIG2_MAX_CTX);
memset(ctx->intctx, 0, 13 * 512);
......@@ -139,8 +139,9 @@ jbig2enc_flush(struct jbig2enc_ctx *ctx) {
ctx->outbuf_used = 0;
for (std::vector<uint8_t *>::iterator i = ctx->output_chunks->begin();
i != ctx->output_chunks->end(); ++i) {
free(*i);
i != ctx->output_chunks->end(); ++i)
{
delete [](*i);
}
ctx->output_chunks->clear();
ctx->bp = -1;
......@@ -150,12 +151,14 @@ jbig2enc_flush(struct jbig2enc_ctx *ctx) {
void
jbig2enc_dealloc(struct jbig2enc_ctx *ctx) {
for (std::vector<uint8_t *>::iterator i = ctx->output_chunks->begin();
i != ctx->output_chunks->end(); ++i) {
free(*i);
i != ctx->output_chunks->end(); ++i)
{
delete [](*i);
}
delete ctx->output_chunks;
free(ctx->outbuf);
free(ctx->iaidctx);
delete []ctx->outbuf;
delete []ctx->iaidctx;
}
// -----------------------------------------------------------------------------
......@@ -166,7 +169,7 @@ static void inline
emit(struct jbig2enc_ctx *restrict ctx) {
if (unlikely(ctx->outbuf_used == JBIG2_OUTPUTBUFFER_SIZE)) {
ctx->output_chunks->push_back(ctx->outbuf);
ctx->outbuf = (u8 *) malloc(JBIG2_OUTPUTBUFFER_SIZE);
ctx->outbuf = new u8[JBIG2_OUTPUTBUFFER_SIZE];
ctx->outbuf_used = 0;
}
......@@ -359,11 +362,12 @@ jbig2enc_oob(struct jbig2enc_ctx *restrict ctx, int proc) {
// see comments in .h file
void
jbig2enc_int(struct jbig2enc_ctx *restrict ctx, int proc, int value) {
jbig2enc_int(struct jbig2enc_ctx *restrict ctx, int proc, int value)
{
u8 *const context = ctx->intctx[proc];
int i;
if (value > 2000000000 || value < -2000000000) abort();
// if (value > 2000000000 || value < -2000000000) assert();
u32 prev = 1;
......@@ -404,10 +408,12 @@ jbig2enc_int(struct jbig2enc_ctx *restrict ctx, int proc, int value) {
// see comments in .h file
void
jbig2enc_iaid(struct jbig2enc_ctx *restrict ctx, int symcodelen, int value) {
if (!ctx->iaidctx) {
jbig2enc_iaid(struct jbig2enc_ctx *restrict ctx, int symcodelen, int value)
{
if (!ctx->iaidctx)
{
// we've not yet allocated the context index buffer for this
ctx->iaidctx = (u8 *) malloc(1 << symcodelen);
ctx->iaidctx = (u8 *) new u8[1 << symcodelen];
memset(ctx->iaidctx, 0, 1 << symcodelen);
}
const u32 mask = (1 << (symcodelen + 1)) - 1;
......
......@@ -286,7 +286,8 @@ jbig2_pages_complete(struct jbig2ctx *ctx, int *const length) {
jbig2enc_init(&ectx);
struct jbig2_file_header header;
if (ctx->full_headers) {
if (ctx->full_headers)
{
memset(&header, 0, sizeof(header));
header.n_pages = htonl(ctx->classer->npages);
header.organisation_type = 1;
......
......@@ -11,7 +11,8 @@
#include "../LeptonLib/allheaders.h"
#include "../LeptonLib/pix.h"
#include "jbig2enc.h"
#include "io.h"
#include "../../../Common/DocxFormat/Source/SystemUtility/File.h"
#if defined(_WIN32) || defined (_WIN64)
// -----------------------------------------------------------------------------
......
......@@ -11,6 +11,8 @@
#include <netinet/in.h>
#endif
#include <string.h>
// -----------------------------------------------------------------------------
// See comments in jbig2structs.h about the bit packing in this structure.
// -----------------------------------------------------------------------------
......
......@@ -130,11 +130,11 @@ bool CJBig2File::MemoryToJBig2(unsigned char* pBufferBGRA ,int BufferSize, int n
uint8_t *pBuffer = jbig2_encode_generic( pPixT, !m_bPDFMode, 0, 0, m_bDuplicateLineRemoval, &nLength );
bool bRes = true;
FILE *pFile = _wfopen( sDstFileName.c_str(), _T("wb") );
if ( pFile && pBuffer )
CFile file;
if (file.CreateFile(sDstFileName.c_str() ) == S_OK )
{
::fwrite( pBuffer, nLength, 1, pFile );
::fclose( pFile );
file.WriteFile(pBuffer, nLength);
file.CloseFile();
bRes = true;
}
else
......@@ -162,16 +162,16 @@ bool CJBig2File::MemoryToJBig2(unsigned char* pBufferBGRA ,int BufferSize, int n
if ( m_bPDFMode )
{
std::wstring sFileName = sDstFileName;//m_sBaseName + _T(".sym");
const int nFileD = _wopen( sFileName.c_str(), O_WRONLY | O_TRUNC | O_CREAT /*| WINBINARY*/, 0600 );
if ( nFileD < 0 )
CFile file;
if ( file.CreateFile(sFileName.c_str()) != S_OK)
{
free( pBuffer );
jbig2_destroy( pContext );
return false;
}
write( nFileD, pBuffer, nLength );
close( nFileD );
file.WriteFile( pBuffer, nLength );
file.CloseFile();
}
free( pBuffer );
......@@ -181,16 +181,16 @@ bool CJBig2File::MemoryToJBig2(unsigned char* pBufferBGRA ,int BufferSize, int n
if ( m_bPDFMode )
{
std::wstring sFileName = m_sBaseName + _T(".0000");
const int nFileD = _wopen( sFileName.c_str(), O_WRONLY | O_TRUNC | O_CREAT /*| WINBINARY*/, 0600 );
CFile file;
if ( nFileD < 0 )
if ( file.CreateFile(sFileName.c_str()) != S_OK)
{
free( pBuffer );
jbig2_destroy( pContext );
return false;
}
write( nFileD, pBuffer, nLength );
close( nFileD );
file.WriteFile( pBuffer, nLength );
file.CloseFile();
}
free( pBuffer );
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment