diff options
Diffstat (limited to 'fpdfsdk')
-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 |
5 files changed, 74 insertions, 237 deletions
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()); |