summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-26 14:19:52 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-26 14:19:52 -0800
commitf10ae634e7b198b18942baaf9f111f07cc8ce818 (patch)
treea753a70bdac1d2775895a30922d6e58e62e00360 /fpdfsdk/src
parentbef1eb99263b80d013d9a2c2618446dec99551c1 (diff)
downloadpdfium-f10ae634e7b198b18942baaf9f111f07cc8ce818.tar.xz
War on #defines - part 2
Introduce CPDF_Parser::Error. Introduce CPDF_Color::Type. Unused XFA_DATASETS and XFA_FORMS defines. Move FPDF_CreateStandardSecurityHandler() prototype to header. Delete prototype for nonexistent FPDF_CreatePubKeyHandler(). Make PBS_* defines local to .cpp file. Tidy whitespace. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1634123004 .
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/fpdf_dataavail.cpp15
-rw-r--r--fpdfsdk/src/fpdfsave.cpp3
-rw-r--r--fpdfsdk/src/fpdfview.cpp38
3 files changed, 29 insertions, 27 deletions
diff --git a/fpdfsdk/src/fpdf_dataavail.cpp b/fpdfsdk/src/fpdf_dataavail.cpp
index f4e235ccf5..baf8f9c924 100644
--- a/fpdfsdk/src/fpdf_dataavail.cpp
+++ b/fpdfsdk/src/fpdf_dataavail.cpp
@@ -122,19 +122,20 @@ FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints) {
DLLEXPORT FPDF_DOCUMENT STDCALL
FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) {
- if (!avail)
+ CFPDF_DataAvail* pDataAvail = static_cast<CFPDF_DataAvail*>(avail);
+ if (!pDataAvail)
return NULL;
+
CPDF_Parser* pParser = new CPDF_Parser;
pParser->SetPassword(password);
-
- FX_DWORD err_code = pParser->StartAsynParse(
- ((CFPDF_DataAvail*)avail)->m_pDataAvail->GetFileRead());
- if (err_code) {
+ CPDF_Parser::Error error =
+ pParser->StartAsynParse(pDataAvail->m_pDataAvail->GetFileRead());
+ if (error != CPDF_Parser::SUCCESS) {
delete pParser;
- ProcessParseError(err_code);
+ ProcessParseError(error);
return NULL;
}
- ((CFPDF_DataAvail*)avail)->m_pDataAvail->SetDocument(pParser->GetDocument());
+ pDataAvail->m_pDataAvail->SetDocument(pParser->GetDocument());
CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS);
return FPDFDocumentFromCPDFDocument(pParser->GetDocument());
}
diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp
index c8bf5e767d..598d93676c 100644
--- a/fpdfsdk/src/fpdfsave.cpp
+++ b/fpdfsdk/src/fpdfsave.cpp
@@ -61,9 +61,6 @@ void CFX_IFileWrite::Release() {
}
#ifdef PDF_ENABLE_XFA
-#define XFA_DATASETS 0
-#define XFA_FORMS 1
-
FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument,
CFX_PtrArray& fileList) {
if (!pDocument)
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index ccd127c559..6e9ee05ea0 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -274,19 +274,23 @@ int GetLastError() {
}
#endif // _WIN32
-void ProcessParseError(FX_DWORD err_code) {
+void ProcessParseError(CPDF_Parser::Error err) {
+ FX_DWORD err_code;
// Translate FPDFAPI error code to FPDFVIEW error code
- switch (err_code) {
- case PDFPARSE_ERROR_FILE:
+ switch (err) {
+ case CPDF_Parser::SUCCESS:
+ err_code = FPDF_ERR_SUCCESS;
+ break;
+ case CPDF_Parser::FILE_ERROR:
err_code = FPDF_ERR_FILE;
break;
- case PDFPARSE_ERROR_FORMAT:
+ case CPDF_Parser::FORMAT_ERROR:
err_code = FPDF_ERR_FORMAT;
break;
- case PDFPARSE_ERROR_PASSWORD:
+ case CPDF_Parser::PASSWORD_ERROR:
err_code = FPDF_ERR_PASSWORD;
break;
- case PDFPARSE_ERROR_HANDLER:
+ case CPDF_Parser::HANDLER_ERROR:
err_code = FPDF_ERR_SECURITY;
break;
}
@@ -310,10 +314,10 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
CPDF_Parser* pParser = new CPDF_Parser;
pParser->SetPassword(password);
- FX_DWORD err_code = pParser->StartParse(pFileAccess);
- if (err_code) {
+ CPDF_Parser::Error error = pParser->StartParse(pFileAccess);
+ if (error != CPDF_Parser::SUCCESS) {
delete pParser;
- ProcessParseError(err_code);
+ ProcessParseError(error);
return NULL;
}
#ifdef PDF_ENABLE_XFA
@@ -399,15 +403,15 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
CPDF_Parser* pParser = new CPDF_Parser;
pParser->SetPassword(password);
CMemFile* pMemFile = new CMemFile((uint8_t*)data_buf, size);
- FX_DWORD err_code = pParser->StartParse(pMemFile);
- if (err_code) {
+ CPDF_Parser::Error error = pParser->StartParse(pMemFile);
+ if (error != CPDF_Parser::SUCCESS) {
delete pParser;
- ProcessParseError(err_code);
+ ProcessParseError(error);
return NULL;
}
CPDF_Document* pDoc = NULL;
pDoc = pParser ? pParser->GetDocument() : NULL;
- CheckUnSupportError(pDoc, err_code);
+ CheckUnSupportError(pDoc, error);
return FPDFDocumentFromCPDFDocument(pParser->GetDocument());
}
@@ -417,15 +421,15 @@ FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess,
CPDF_Parser* pParser = new CPDF_Parser;
pParser->SetPassword(password);
CPDF_CustomAccess* pFile = new CPDF_CustomAccess(pFileAccess);
- FX_DWORD err_code = pParser->StartParse(pFile);
- if (err_code) {
+ CPDF_Parser::Error error = pParser->StartParse(pFile);
+ if (error != CPDF_Parser::SUCCESS) {
delete pParser;
- ProcessParseError(err_code);
+ ProcessParseError(error);
return NULL;
}
CPDF_Document* pDoc = NULL;
pDoc = pParser ? pParser->GetDocument() : NULL;
- CheckUnSupportError(pDoc, err_code);
+ CheckUnSupportError(pDoc, error);
return FPDFDocumentFromCPDFDocument(pParser->GetDocument());
}