summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-08-13 11:03:19 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-08-13 11:03:19 -0700
commitd4e406e254b5a60e58ff2fcc12b59bef7e436e74 (patch)
tree4e00632c4ba0efc86d4adce4cb774f5fe4adb943 /fpdfsdk/src
parentd38a35ec7416a884de964014691777110093a931 (diff)
downloadpdfium-d4e406e254b5a60e58ff2fcc12b59bef7e436e74.tar.xz
Remove try/catch block
BUG=pdfium:28 R=thakis@chromium.org Review URL: https://codereview.chromium.org/472563002
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/fpdf_progressive.cpp9
-rw-r--r--fpdfsdk/src/fpdftext.cpp43
-rw-r--r--fpdfsdk/src/fpdfview.cpp92
-rw-r--r--fpdfsdk/src/javascript/JS_Context.cpp43
4 files changed, 50 insertions, 137 deletions
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());