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