diff options
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_jpx_opj.cpp | 268 | ||||
-rw-r--r-- | fpdfsdk/include/javascript/JS_Define.h | 124 | ||||
-rw-r--r-- | fpdfsdk/src/fpdf_progressive.cpp | 9 | ||||
-rw-r--r-- | fpdfsdk/src/fpdftext.cpp | 43 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfview.cpp | 92 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Context.cpp | 43 |
6 files changed, 203 insertions, 376 deletions
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp index 8e77cdaece..4494244410 100644 --- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -582,83 +582,79 @@ CJPX_Decoder::~CJPX_Decoder() FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size) { opj_dparameters_t parameters; - try { + image = NULL; + m_SrcData = src_data; + m_SrcSize = src_size; + decodeData srcData; + srcData.offset = 0; + srcData.src_size = src_size; + srcData.src_data = src_data; + l_stream = fx_opj_stream_create_memory_stream(&srcData, OPJ_J2K_STREAM_CHUNK_SIZE, 1); + if (l_stream == NULL) { + return FALSE; + } + opj_set_default_decoder_parameters(¶meters); + parameters.decod_format = 0; + parameters.cod_format = 3; + if(FXSYS_memcmp32(m_SrcData, "\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a", 12) == 0) { + l_codec = opj_create_decompress(OPJ_CODEC_JP2); + parameters.decod_format = 1; + } else { + l_codec = opj_create_decompress(OPJ_CODEC_J2K); + } + if(!l_codec) { + return FALSE; + } + opj_set_info_handler(l_codec, fx_info_callback, 00); + opj_set_warning_handler(l_codec, fx_warning_callback, 00); + opj_set_error_handler(l_codec, fx_error_callback, 00); + if ( !opj_setup_decoder(l_codec, ¶meters) ) { + return FALSE; + } + if(! opj_read_header(l_stream, l_codec, &image)) { image = NULL; - m_SrcData = src_data; - m_SrcSize = src_size; - decodeData srcData; - srcData.offset = 0; - srcData.src_size = src_size; - srcData.src_data = src_data; - l_stream = fx_opj_stream_create_memory_stream(&srcData, OPJ_J2K_STREAM_CHUNK_SIZE, 1); - if (l_stream == NULL) { - return FALSE; - } - opj_set_default_decoder_parameters(¶meters); - parameters.decod_format = 0; - parameters.cod_format = 3; - if(FXSYS_memcmp32(m_SrcData, "\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a", 12) == 0) { - l_codec = opj_create_decompress(OPJ_CODEC_JP2); - parameters.decod_format = 1; - } else { - l_codec = opj_create_decompress(OPJ_CODEC_J2K); - } - if(!l_codec) { - return FALSE; - } - opj_set_info_handler(l_codec, fx_info_callback, 00); - opj_set_warning_handler(l_codec, fx_warning_callback, 00); - opj_set_error_handler(l_codec, fx_error_callback, 00); - if ( !opj_setup_decoder(l_codec, ¶meters) ) { + return FALSE; + } + if(this->m_useColorSpace) { + image->useColorSpace = 1; + } else { + image->useColorSpace = 0; + } + if (!parameters.nb_tile_to_decode) { + if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, + parameters.DA_y0, parameters.DA_x1, parameters.DA_y1)) { + opj_image_destroy(image); + image = NULL; return FALSE; } - if(! opj_read_header(l_stream, l_codec, &image)) { + if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) { + opj_image_destroy(image); image = NULL; return FALSE; } - if(this->m_useColorSpace) { - image->useColorSpace = 1; - } else { - image->useColorSpace = 0; - } - if (!parameters.nb_tile_to_decode) { - if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, - parameters.DA_y0, parameters.DA_x1, parameters.DA_y1)) { - opj_image_destroy(image); - image = NULL; - return FALSE; - } - if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) { - opj_image_destroy(image); - image = NULL; - return FALSE; - } - } else { - if (!opj_get_decoded_tile(l_codec, l_stream, image, parameters.tile_index)) { - return FALSE; - } - } - opj_stream_destroy(l_stream); - l_stream = NULL; - if( image->color_space != OPJ_CLRSPC_SYCC - && image->numcomps == 3 && image->comps[0].dx == image->comps[0].dy - && image->comps[1].dx != 1 ) { - image->color_space = OPJ_CLRSPC_SYCC; - } else if (image->numcomps <= 2) { - image->color_space = OPJ_CLRSPC_GRAY; - } - if(image->color_space == OPJ_CLRSPC_SYCC) { - color_sycc_to_rgb(image); - } - if(image->icc_profile_buf && !image->useColorSpace) { - FX_Free(image->icc_profile_buf); - image->icc_profile_buf = NULL; - image->icc_profile_len = 0; - } - if(!image) { + } else { + if (!opj_get_decoded_tile(l_codec, l_stream, image, parameters.tile_index)) { return FALSE; } - } catch (...) { + } + opj_stream_destroy(l_stream); + l_stream = NULL; + if( image->color_space != OPJ_CLRSPC_SYCC + && image->numcomps == 3 && image->comps[0].dx == image->comps[0].dy + && image->comps[1].dx != 1 ) { + image->color_space = OPJ_CLRSPC_SYCC; + } else if (image->numcomps <= 2) { + image->color_space = OPJ_CLRSPC_GRAY; + } + if(image->color_space == OPJ_CLRSPC_SYCC) { + color_sycc_to_rgb(image); + } + if(image->icc_profile_buf && !image->useColorSpace) { + FX_Free(image->icc_profile_buf); + image->icc_profile_buf = NULL; + image->icc_profile_len = 0; + } + if(!image) { return FALSE; } return TRUE; @@ -676,86 +672,80 @@ FX_BOOL CJPX_Decoder::Decode(FX_LPBYTE dest_buf, int pitch, FX_BOOL bTranslateCo int i, wid, hei, row, col, channel, src; FX_BOOL flag; FX_LPBYTE pChannel, pScanline, pPixel; - try { - if(image->comps[0].w != image->x1 || image->comps[0].h != image->y1) { - return FALSE; - } - if(pitch < (int)(image->comps[0].w * 8 * image->numcomps + 31) >> 5 << 2) { - return FALSE; - } - FXSYS_memset8(dest_buf, 0xff, image->y1 * pitch); - channel_bufs = FX_Alloc(FX_BYTE*, image->numcomps); - if (channel_bufs == NULL) { - return FALSE; - } - adjust_comps = FX_Alloc(int, image->numcomps); - if (adjust_comps == NULL) { - FX_Free(channel_bufs); - return FALSE; - } - flag = TRUE; - for (i = 0; i < (int)image->numcomps; i ++) { - channel_bufs[i] = dest_buf + offsets[i]; - adjust_comps[i] = image->comps[i].prec - 8; - if(i > 0) { - if(image->comps[i].dx != image->comps[i - 1].dx - || image->comps[i].dy != image->comps[i - 1].dy - || image->comps[i].prec != image->comps[i - 1].prec) { - flag = FALSE; - goto failed; - } + + if(image->comps[0].w != image->x1 || image->comps[0].h != image->y1) { + return FALSE; + } + if(pitch < (int)(image->comps[0].w * 8 * image->numcomps + 31) >> 5 << 2) { + return FALSE; + } + FXSYS_memset8(dest_buf, 0xff, image->y1 * pitch); + channel_bufs = FX_Alloc(FX_BYTE*, image->numcomps); + if (channel_bufs == NULL) { + return FALSE; + } + adjust_comps = FX_Alloc(int, image->numcomps); + if (adjust_comps == NULL) { + FX_Free(channel_bufs); + return FALSE; + } + flag = TRUE; + for (i = 0; i < (int)image->numcomps; i ++) { + channel_bufs[i] = dest_buf + offsets[i]; + adjust_comps[i] = image->comps[i].prec - 8; + if(i > 0) { + if(image->comps[i].dx != image->comps[i - 1].dx + || image->comps[i].dy != image->comps[i - 1].dy + || image->comps[i].prec != image->comps[i - 1].prec) { + flag = FALSE; + goto failed; } } - wid = image->comps[0].w; - hei = image->comps[0].h; - for (channel = 0; channel < (int)image->numcomps; channel++) { - pChannel = channel_bufs[channel]; - if(adjust_comps[channel] < 0) { - for(row = 0; row < hei; row++) { - pScanline = pChannel + row * pitch; - for (col = 0; col < wid; col++) { - pPixel = pScanline + col * image->numcomps; - src = image->comps[channel].data[row * wid + col]; - src += image->comps[channel].sgnd ? 1 << (image->comps[channel].prec - 1) : 0; - if (adjust_comps[channel] > 0) { - *pPixel = 0; - } else { - *pPixel = (FX_BYTE)(src << -adjust_comps[channel]); - } + } + wid = image->comps[0].w; + hei = image->comps[0].h; + for (channel = 0; channel < (int)image->numcomps; channel++) { + pChannel = channel_bufs[channel]; + if(adjust_comps[channel] < 0) { + for(row = 0; row < hei; row++) { + pScanline = pChannel + row * pitch; + for (col = 0; col < wid; col++) { + pPixel = pScanline + col * image->numcomps; + src = image->comps[channel].data[row * wid + col]; + src += image->comps[channel].sgnd ? 1 << (image->comps[channel].prec - 1) : 0; + if (adjust_comps[channel] > 0) { + *pPixel = 0; + } else { + *pPixel = (FX_BYTE)(src << -adjust_comps[channel]); } } - } else { - for(row = 0; row < hei; row++) { - pScanline = pChannel + row * pitch; - for (col = 0; col < wid; col++) { - pPixel = pScanline + col * image->numcomps; - if (!image->comps[channel].data) { - continue; - } - src = image->comps[channel].data[row * wid + col]; - src += image->comps[channel].sgnd ? 1 << (image->comps[channel].prec - 1) : 0; - if (adjust_comps[channel] - 1 < 0) { - *pPixel = (FX_BYTE)((src >> adjust_comps[channel])); - } else { - int tmpPixel = (src >> adjust_comps[channel]) + ((src >> (adjust_comps[channel] - 1)) % 2); - if (tmpPixel > 255) { - tmpPixel = 255; - } else if (tmpPixel < 0) { - tmpPixel = 0; - } - *pPixel = (FX_BYTE)tmpPixel; + } + } else { + for(row = 0; row < hei; row++) { + pScanline = pChannel + row * pitch; + for (col = 0; col < wid; col++) { + pPixel = pScanline + col * image->numcomps; + if (!image->comps[channel].data) { + continue; + } + src = image->comps[channel].data[row * wid + col]; + src += image->comps[channel].sgnd ? 1 << (image->comps[channel].prec - 1) : 0; + if (adjust_comps[channel] - 1 < 0) { + *pPixel = (FX_BYTE)((src >> adjust_comps[channel])); + } else { + int tmpPixel = (src >> adjust_comps[channel]) + ((src >> (adjust_comps[channel] - 1)) % 2); + if (tmpPixel > 255) { + tmpPixel = 255; + } else if (tmpPixel < 0) { + tmpPixel = 0; } + *pPixel = (FX_BYTE)tmpPixel; } } } } - } catch (...) { - if (channel_bufs) { - FX_Free(channel_bufs); - } - FX_Free(adjust_comps); - return FALSE; } + FX_Free(channel_bufs); FX_Free(adjust_comps); return TRUE; diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h index ba978e9e2d..108c1e23ee 100644 --- a/fpdfsdk/include/javascript/JS_Define.h +++ b/fpdfsdk/include/javascript/JS_Define.h @@ -107,19 +107,9 @@ typedef CFX_WideString JS_ErrorString; ASSERT(pObj != NULL);\ JS_ErrorString sError;\ FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->prop_name(cc, value, sError);\ - MEMLEAKCHECK_2(class_name, prop_name);\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, #prop_name);\ - JS_Error(NULL,CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\ - return ;\ - }\ + MEMLEAKCHECK_1();\ + bRet = pObj->prop_name(cc, value, sError);\ + MEMLEAKCHECK_2(class_name, prop_name);\ if (bRet)\ {\ info.GetReturnValue().Set((v8::Handle<v8::Value>)value);\ @@ -153,19 +143,9 @@ typedef CFX_WideString JS_ErrorString; ASSERT(pObj != NULL);\ JS_ErrorString sError;\ FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->prop_name(cc, propValue, sError);\ - MEMLEAKCHECK_2(class_name, prop_name);\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, #prop_name);\ - JS_Error(NULL,CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\ - return ;\ - }\ + MEMLEAKCHECK_1();\ + bRet = pObj->prop_name(cc, propValue, sError);\ + MEMLEAKCHECK_2(class_name, prop_name);\ if (bRet)\ {\ return ;\ @@ -208,19 +188,9 @@ JS_STATIC_PROP_SET(prop_name, class_name) ASSERT(pObj != NULL);\ JS_ErrorString sError;\ FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->method_name(cc, parameters, valueRes, sError);\ - MEMLEAKCHECK_2(class_name, method_name);\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, #method_name);\ - JS_Error(NULL, CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\ - return ;\ - }\ + MEMLEAKCHECK_1();\ + bRet = pObj->method_name(cc, parameters, valueRes, sError);\ + MEMLEAKCHECK_2(class_name, method_name);\ if (bRet)\ {\ info.GetReturnValue().Set(valueRes.ToJSValue());\ @@ -370,16 +340,9 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ ASSERT(pObj != NULL);\ FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->QueryProperty((FX_LPCWSTR)propname);\ - MEMLEAKCHECK_2(class_name, (FX_LPCWSTR)prop_name);\ - }\ - catch (...)\ - {\ - return ;\ - }\ + MEMLEAKCHECK_1();\ + bRet = pObj->QueryProperty((FX_LPCWSTR)propname);\ + MEMLEAKCHECK_2(class_name, (FX_LPCWSTR)prop_name);\ if (bRet)\ {\ info.GetReturnValue().Set(0x004);\ @@ -412,19 +375,9 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ ASSERT(pObj != NULL);\ JS_ErrorString sError;\ FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->DoProperty(cc, (FX_LPCWSTR)propname, value, sError);\ - MEMLEAKCHECK_2(class_name, L"GetProperty");\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, L"GetProperty");\ - JS_Error(NULL,CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\ - return ;\ - }\ + MEMLEAKCHECK_1();\ + bRet = pObj->DoProperty(cc, (FX_LPCWSTR)propname, value, sError);\ + MEMLEAKCHECK_2(class_name, L"GetProperty");\ if (bRet)\ {\ info.GetReturnValue().Set((v8::Handle<v8::Value>)value);\ @@ -460,19 +413,9 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ ASSERT(pObj != NULL);\ JS_ErrorString sError;\ FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->DoProperty(cc, (FX_LPCWSTR)propname, PropValue, sError);\ - MEMLEAKCHECK_2(class_name,L"PutProperty");\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, "PutProperty");\ - JS_Error(NULL,CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\ - return ;\ - }\ + MEMLEAKCHECK_1();\ + bRet = pObj->DoProperty(cc, (FX_LPCWSTR)propname, PropValue, sError);\ + MEMLEAKCHECK_2(class_name,L"PutProperty");\ if (bRet)\ {\ return ;\ @@ -505,18 +448,9 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ ASSERT(pObj != NULL);\ JS_ErrorString sError;\ FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->DelProperty(cc, (FX_LPCWSTR)propname, sError);\ - MEMLEAKCHECK_2(class_name,L"DelProperty");\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, "DelProperty");\ - return ;\ - }\ + MEMLEAKCHECK_1();\ + bRet = pObj->DelProperty(cc, (FX_LPCWSTR)propname, sError);\ + MEMLEAKCHECK_2(class_name,L"DelProperty");\ if (bRet)\ {\ return ;\ @@ -609,19 +543,9 @@ void js_class_name::GetMethods(JSMethodSpec*& pMethods, int& nSize)\ ASSERT(pObj != NULL);\ JS_ErrorString sError;\ FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->method_name(cc, parameters, valueRes, sError);\ - MEMLEAKCHECK_2(class_name, method_name);\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, #method_name);\ - JS_Error(NULL, CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\ - return ;\ - }\ + MEMLEAKCHECK_1();\ + bRet = pObj->method_name(cc, parameters, valueRes, sError);\ + MEMLEAKCHECK_2(class_name, method_name);\ if (bRet)\ {\ info.GetReturnValue().Set(valueRes.ToJSValue());\ diff --git a/fpdfsdk/src/fpdf_progressive.cpp b/fpdfsdk/src/fpdf_progressive.cpp index b6691af82d..2490df8c2f 100644 --- a/fpdfsdk/src/fpdf_progressive.cpp +++ b/fpdfsdk/src/fpdf_progressive.cpp @@ -49,14 +49,7 @@ DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start( FPDF_BITMAP bitmap, FPDF_PAGE #endif IFSDK_PAUSE_Adapter IPauseAdapter(pause); - if (flags & FPDF_NO_CATCH) - Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate, flags,FALSE, &IPauseAdapter); - else { - try { - Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate, flags,FALSE, &IPauseAdapter); - } - catch (...){} - } + Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate, flags,FALSE, &IPauseAdapter); if ( pContext->m_pRenderer ) { diff --git a/fpdfsdk/src/fpdftext.cpp b/fpdfsdk/src/fpdftext.cpp index 869ec48ba6..264631b630 100644 --- a/fpdfsdk/src/fpdftext.cpp +++ b/fpdfsdk/src/fpdftext.cpp @@ -18,18 +18,9 @@ DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) { if (!page) return NULL; IPDF_TextPage* textpage=NULL; - try - { - CPDF_ViewerPreferences viewRef(((CPDF_Page*)page)->m_pDocument); - textpage=IPDF_TextPage::CreateTextPage((CPDF_Page*)page,viewRef.IsDirectionR2L()); - textpage->ParseTextPage(); - } - catch (...) - { - if (textpage) - delete textpage; - return NULL; - } + CPDF_ViewerPreferences viewRef(((CPDF_Page*)page)->m_pDocument); + textpage=IPDF_TextPage::CreateTextPage((CPDF_Page*)page,viewRef.IsDirectionR2L()); + textpage->ParseTextPage(); return textpage; } DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page) @@ -159,18 +150,9 @@ DLLEXPORT FPDF_SCHHANDLE STDCALL FPDFText_FindStart(FPDF_TEXTPAGE text_page,FPDF { if (!text_page) return NULL; IPDF_TextPageFind* textpageFind=NULL; - try - { - textpageFind=IPDF_TextPageFind::CreatePageFind((IPDF_TextPage*)text_page); - FX_STRSIZE len = CFX_WideString::WStringLength(findwhat); - textpageFind->FindFirst(CFX_WideString::FromUTF16LE(findwhat, len),flags,start_index); - } - catch (...) - { - if (textpageFind) - delete textpageFind; - return NULL; - } + textpageFind=IPDF_TextPageFind::CreatePageFind((IPDF_TextPage*)text_page); + FX_STRSIZE len = CFX_WideString::WStringLength(findwhat); + textpageFind->FindFirst(CFX_WideString::FromUTF16LE(findwhat, len),flags,start_index); return textpageFind; } DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindNext(FPDF_SCHHANDLE handle) @@ -210,17 +192,8 @@ DLLEXPORT FPDF_PAGELINK STDCALL FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page) { if (!text_page) return NULL; IPDF_LinkExtract* pageLink=NULL; - try - { - pageLink=IPDF_LinkExtract::CreateLinkExtract(); - pageLink->ExtractLinks((IPDF_TextPage*)text_page); - } - catch (...) - { - if (pageLink) - delete pageLink; - return NULL; - } + pageLink=IPDF_LinkExtract::CreateLinkExtract(); + pageLink->ExtractLinks((IPDF_TextPage*)text_page); return pageLink; } DLLEXPORT int STDCALL FPDFLink_CountWebLinks(FPDF_PAGELINK link_page) diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp index 23d44935b5..2e1bca3a66 100644 --- a/fpdfsdk/src/fpdfview.cpp +++ b/fpdfsdk/src/fpdfview.cpp @@ -272,17 +272,11 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BY { CPDF_Parser* pParser = FX_NEW CPDF_Parser; pParser->SetPassword(password); - try { - FX_DWORD err_code = pParser->StartParse((FX_LPCSTR)file_path); - if (err_code) { - delete pParser; - ProcessParseError(err_code); - return NULL; - } - } - catch (...) { + + FX_DWORD err_code = pParser->StartParse((FX_LPCSTR)file_path); + if (err_code) { delete pParser; - SetLastError(FPDF_ERR_UNKNOWN); + ProcessParseError(err_code); return NULL; } return pParser->GetDocument(); @@ -318,23 +312,16 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, int s { CPDF_Parser* pParser = FX_NEW CPDF_Parser; pParser->SetPassword(password); - try { - CMemFile* pMemFile = FX_NEW CMemFile((FX_BYTE*)data_buf, size); - FX_DWORD err_code = pParser->StartParse(pMemFile); - if (err_code) { - delete pParser; - ProcessParseError(err_code); - return NULL; - } - CPDF_Document * pDoc = NULL; - pDoc = pParser?pParser->GetDocument():NULL; - CheckUnSupportError(pDoc, err_code); - } - catch (...) { + CMemFile* pMemFile = FX_NEW CMemFile((FX_BYTE*)data_buf, size); + FX_DWORD err_code = pParser->StartParse(pMemFile); + if (err_code) { delete pParser; - SetLastError(FPDF_ERR_UNKNOWN); + ProcessParseError(err_code); return NULL; } + CPDF_Document * pDoc = NULL; + pDoc = pParser?pParser->GetDocument():NULL; + CheckUnSupportError(pDoc, err_code); return pParser->GetDocument(); } @@ -343,22 +330,15 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAc CPDF_Parser* pParser = FX_NEW CPDF_Parser; pParser->SetPassword(password); CPDF_CustomAccess* pFile = FX_NEW CPDF_CustomAccess(pFileAccess); - try { - FX_DWORD err_code = pParser->StartParse(pFile); - if (err_code) { - delete pParser; - ProcessParseError(err_code); - return NULL; - } - CPDF_Document * pDoc = NULL; - pDoc = pParser?pParser->GetDocument():NULL; - CheckUnSupportError(pDoc, err_code); - } - catch (...) { + FX_DWORD err_code = pParser->StartParse(pFile); + if (err_code) { delete pParser; - SetLastError(FPDF_ERR_UNKNOWN); + ProcessParseError(err_code); return NULL; } + CPDF_Document * pDoc = NULL; + pDoc = pParser?pParser->GetDocument():NULL; + CheckUnSupportError(pDoc, err_code); return pParser->GetDocument(); } @@ -403,13 +383,7 @@ DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, int page_index if (pDict == NULL) return NULL; CPDF_Page* pPage = FX_NEW CPDF_Page; pPage->Load(pDoc, pDict); - try { - pPage->ParseContent(); - } - catch (...) { - delete pPage; - return NULL; - } + pPage->ParseContent(); // CheckUnSupportError(pDoc, 0); @@ -473,14 +447,9 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int } else pContext->m_pDevice = FX_NEW CFX_WindowsDevice(dc); - if (flags & FPDF_NO_CATCH) - Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate, flags,TRUE,NULL); - else { - try { - Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate, flags,TRUE,NULL); - } catch (...) { - } - } + + Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate, flags,TRUE,NULL); + if (bBackgroundAlphaNeeded) { if (pBitmap) @@ -559,14 +528,7 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int #endif // output to bitmap device - if (flags & FPDF_NO_CATCH) - Func_RenderPage(pContext, page, start_x - rect.left, start_y - rect.top, size_x, size_y, rotate, flags); - else { - try { - Func_RenderPage(pContext, page, start_x - rect.left, start_y - rect.top, size_x, size_y, rotate, flags); - } catch (...) { - } - } + Func_RenderPage(pContext, page, start_x - rect.left, start_y - rect.top, size_x, size_y, rotate, flags); #ifdef DEBUG_TRACE CPDF_ModuleMgr::Get()->ReportError(999, "Finished PDF rendering"); @@ -634,14 +596,8 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, else ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); #endif - if (flags & FPDF_NO_CATCH) - Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate, flags,TRUE,NULL); - else { - try { - Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate, flags,TRUE,NULL); - } catch (...) { - } - } + + Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate, flags,TRUE,NULL); delete pContext; pPage->RemovePrivateData((void*)1); diff --git a/fpdfsdk/src/javascript/JS_Context.cpp b/fpdfsdk/src/javascript/JS_Context.cpp index e34ffb51ba..a83e1e057d 100644 --- a/fpdfsdk/src/javascript/JS_Context.cpp +++ b/fpdfsdk/src/javascript/JS_Context.cpp @@ -68,41 +68,32 @@ FX_BOOL CJS_Context::DoJob(int nMode, const CFX_WideString& script, CFX_WideStri FXJSErr error ={NULL,NULL, 0}; int nRet = 0; - try - { - if (script.GetLength() > 0) + if (script.GetLength() > 0) + { + if (nMode == 0) { - if (nMode == 0) - { - nRet = JS_Execute(*m_pRuntime, this, script, script.GetLength(), &error); - } - else - { - nRet = JS_Parse(*m_pRuntime, this, script, script.GetLength(), &error); - } + nRet = JS_Execute(*m_pRuntime, this, script, script.GetLength(), &error); } - - if (nRet < 0) + else { - CFX_WideString sLine; - sLine.Format((FX_LPCWSTR)L"[ Line: %05d { %s } ] : %s",error.linnum-1,error.srcline,error.message); + nRet = JS_Parse(*m_pRuntime, this, script, script.GetLength(), &error); + } + } + + if (nRet < 0) + { + CFX_WideString sLine; + sLine.Format((FX_LPCWSTR)L"[ Line: %05d { %s } ] : %s",error.linnum-1,error.srcline,error.message); // TRACE(L"/* -------------- JS Error -------------- */\n"); // TRACE(sLine); // TRACE(L"\n"); - //CFX_ByteString sTemp = CFX_ByteString::FromUnicode(error.message); - info += sLine; - } - else - { - info = JSGetStringFromID(this, IDS_STRING_RUN); - } - + //CFX_ByteString sTemp = CFX_ByteString::FromUnicode(error.message); + info += sLine; } - catch (...) + else { - info = JSGetStringFromID(this, IDS_STRING_UNHANDLED); - nRet = -1; + info = JSGetStringFromID(this, IDS_STRING_RUN); } m_pRuntime->RemoveEventInLoop(m_pEventHandler->TargetName(), m_pEventHandler->EventType()); |