summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfxfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-23 09:17:10 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-23 13:50:52 +0000
commitcdba747a53082a7f36534dffa6a3ad01628e53c3 (patch)
tree4df0b15de7600592588a263deb9a3adee617f417 /fpdfsdk/fpdfxfa
parent1bbedec89cc59df3e305dc25082d9699237d70ab (diff)
downloadpdfium-cdba747a53082a7f36534dffa6a3ad01628e53c3.tar.xz
Cleanup DocType defines
This Cl synchronizes the DocType's defined in XFA with the DOCTYPE flag used in public/. The internal XFA version is converted to an enum class. Change-Id: I1f7be71a200c1ec0f09f9b08099791da1f4fa2e4 Reviewed-on: https://pdfium-review.googlesource.com/3152 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfxfa')
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.cpp16
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.h4
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp26
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.cpp38
4 files changed, 39 insertions, 45 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index 653e086e16..8d2996f1de 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -34,7 +34,7 @@ extern int GetLastError();
#endif
CPDFXFA_Context::CPDFXFA_Context(std::unique_ptr<CPDF_Document> pPDFDoc)
- : m_iDocType(DOCTYPE_PDF),
+ : m_iDocType(XFA_DocType::PDF),
m_pPDFDoc(std::move(pPDFDoc)),
m_pFormFillEnv(nullptr),
m_pXFADocView(nullptr),
@@ -114,10 +114,10 @@ bool CPDFXFA_Context::LoadXFADoc() {
m_pXFADoc->StopLoad();
m_pXFADoc->GetXFADoc()->InitScriptContext(GetJSERuntime());
- if (m_pXFADoc->GetDocType() == XFA_DOCTYPE_Dynamic)
- m_iDocType = DOCTYPE_DYNAMIC_XFA;
+ if (m_pXFADoc->GetDocType() == XFA_DocType::Dynamic)
+ m_iDocType = XFA_DocType::Dynamic;
else
- m_iDocType = DOCTYPE_STATIC_XFA;
+ m_iDocType = XFA_DocType::Static;
m_pXFADocView = m_pXFADoc->CreateDocView();
if (m_pXFADocView->StartLayout() < 0) {
@@ -138,11 +138,11 @@ int CPDFXFA_Context::GetPageCount() const {
return 0;
switch (m_iDocType) {
- case DOCTYPE_PDF:
- case DOCTYPE_STATIC_XFA:
+ case XFA_DocType::PDF:
+ case XFA_DocType::Static:
if (m_pPDFDoc)
return m_pPDFDoc->GetPageCount();
- case DOCTYPE_DYNAMIC_XFA:
+ case XFA_DocType::Dynamic:
if (m_pXFADoc)
return m_pXFADocView->CountPageViews();
default:
@@ -184,7 +184,7 @@ CPDFXFA_Page* CPDFXFA_Context::GetXFAPage(CXFA_FFPageView* pPage) const {
if (!m_pXFADoc)
return nullptr;
- if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
+ if (m_iDocType != XFA_DocType::Dynamic)
return nullptr;
for (CPDFXFA_Page* pTempPage : m_XFAPageList) {
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h
index 9a2a517fb5..65e54566e8 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h
@@ -37,7 +37,7 @@ class CPDFXFA_Context : public IXFA_AppProvider {
CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); }
CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); }
CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; }
- int GetDocType() const { return m_iDocType; }
+ XFA_DocType GetDocType() const { return m_iDocType; }
v8::Isolate* GetJSERuntime() const;
CXFA_FFApp* GetXFAApp() { return m_pXFAApp.get(); }
@@ -98,7 +98,7 @@ class CPDFXFA_Context : public IXFA_AppProvider {
private:
void CloseXFADoc();
- int m_iDocType;
+ XFA_DocType m_iDocType;
std::unique_ptr<CPDF_Document> m_pPDFDoc;
std::unique_ptr<CXFA_FFDoc> m_pXFADoc;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index e54ca85fd9..44d59c69df 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -59,7 +59,7 @@ void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView,
if (!m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv())
return;
- if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA)
+ if (m_pContext->GetDocType() != XFA_DocType::Dynamic)
return;
CPDFXFA_Page* pPage = m_pContext->GetXFAPage(pPageView);
@@ -81,7 +81,7 @@ void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget,
!m_pContext->GetFormFillEnv() || !m_pContext->GetXFADocView())
return;
- if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA)
+ if (m_pContext->GetDocType() != XFA_DocType::Dynamic)
return;
CXFA_FFWidgetHandler* pWidgetHandler =
@@ -295,7 +295,7 @@ void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView,
void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget,
CXFA_WidgetAcc* pWidgetData) {
- if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget)
+ if (m_pContext->GetDocType() != XFA_DocType::Dynamic || !hWidget)
return;
CXFA_FFPageView* pPageView = hWidget->GetPageView();
@@ -311,7 +311,7 @@ void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget,
void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget,
CXFA_WidgetAcc* pWidgetData) {
- if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA || !hWidget)
+ if (m_pContext->GetDocType() != XFA_DocType::Dynamic || !hWidget)
return;
CXFA_FFPageView* pPageView = hWidget->GetPageView();
@@ -337,7 +337,7 @@ int32_t CPDFXFA_DocEnvironment::CountPages(CXFA_FFDoc* hDoc) {
int32_t CPDFXFA_DocEnvironment::GetCurrentPage(CXFA_FFDoc* hDoc) {
if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv())
return -1;
- if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA)
+ if (m_pContext->GetDocType() != XFA_DocType::Dynamic)
return -1;
CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
@@ -350,7 +350,7 @@ int32_t CPDFXFA_DocEnvironment::GetCurrentPage(CXFA_FFDoc* hDoc) {
void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc,
int32_t iCurPage) {
if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv() ||
- m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 ||
+ m_pContext->GetDocType() != XFA_DocType::Dynamic || iCurPage < 0 ||
iCurPage >= m_pContext->GetFormFillEnv()->GetPageCount()) {
return;
}
@@ -410,8 +410,8 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc,
if (hDoc != m_pContext->GetXFADoc())
return;
- if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
- m_pContext->GetDocType() != DOCTYPE_STATIC_XFA) {
+ if (m_pContext->GetDocType() != XFA_DocType::Dynamic &&
+ m_pContext->GetDocType() != XFA_DocType::Static) {
return;
}
@@ -510,7 +510,7 @@ void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc,
if (hDoc != m_pContext->GetXFADoc())
return;
- if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA)
+ if (m_pContext->GetDocType() != XFA_DocType::Dynamic)
return;
CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
@@ -610,8 +610,8 @@ bool CPDFXFA_DocEnvironment::NotifySubmit(bool bPrevOrPost) {
}
bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() {
- if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
- m_pContext->GetDocType() != DOCTYPE_STATIC_XFA) {
+ if (m_pContext->GetDocType() != XFA_DocType::Dynamic &&
+ m_pContext->GetDocType() != XFA_DocType::Static) {
return true;
}
@@ -663,8 +663,8 @@ bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() {
}
void CPDFXFA_DocEnvironment::OnAfterNotifySubmit() {
- if (m_pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
- m_pContext->GetDocType() != DOCTYPE_STATIC_XFA)
+ if (m_pContext->GetDocType() != XFA_DocType::Dynamic &&
+ m_pContext->GetDocType() != XFA_DocType::Static)
return;
if (!m_pContext->GetXFADocView())
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
index d3910ae263..508cf7a15f 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
@@ -70,15 +70,12 @@ bool CPDFXFA_Page::LoadPage() {
if (!m_pContext || m_iPageIndex < 0)
return false;
- int iDocType = m_pContext->GetDocType();
- switch (iDocType) {
- case DOCTYPE_PDF:
- case DOCTYPE_STATIC_XFA: {
+ switch (m_pContext->GetDocType()) {
+ case XFA_DocType::PDF:
+ case XFA_DocType::Static:
return LoadPDFPage();
- }
- case DOCTYPE_DYNAMIC_XFA: {
+ case XFA_DocType::Dynamic:
return LoadXFAPageView();
- }
default:
return false;
}
@@ -98,15 +95,14 @@ float CPDFXFA_Page::GetPageWidth() const {
if (!m_pPDFPage && !m_pXFAPageView)
return 0.0f;
- int nDocType = m_pContext->GetDocType();
- switch (nDocType) {
- case DOCTYPE_DYNAMIC_XFA: {
+ switch (m_pContext->GetDocType()) {
+ case XFA_DocType::Dynamic: {
if (m_pXFAPageView)
return m_pXFAPageView->GetPageViewRect().width;
break;
}
- case DOCTYPE_STATIC_XFA:
- case DOCTYPE_PDF: {
+ case XFA_DocType::Static:
+ case XFA_DocType::PDF: {
if (m_pPDFPage)
return m_pPDFPage->GetPageWidth();
break;
@@ -122,15 +118,14 @@ float CPDFXFA_Page::GetPageHeight() const {
if (!m_pPDFPage && !m_pXFAPageView)
return 0.0f;
- int nDocType = m_pContext->GetDocType();
- switch (nDocType) {
- case DOCTYPE_PDF:
- case DOCTYPE_STATIC_XFA: {
+ switch (m_pContext->GetDocType()) {
+ case XFA_DocType::PDF:
+ case XFA_DocType::Static: {
if (m_pPDFPage)
return m_pPDFPage->GetPageHeight();
break;
}
- case DOCTYPE_DYNAMIC_XFA: {
+ case XFA_DocType::Dynamic: {
if (m_pXFAPageView)
return m_pXFAPageView->GetPageViewRect().height;
break;
@@ -195,17 +190,16 @@ CFX_Matrix CPDFXFA_Page::GetDisplayMatrix(int xPos,
if (!m_pPDFPage && !m_pXFAPageView)
return CFX_Matrix();
- int nDocType = m_pContext->GetDocType();
- switch (nDocType) {
- case DOCTYPE_DYNAMIC_XFA: {
+ switch (m_pContext->GetDocType()) {
+ case XFA_DocType::Dynamic: {
if (m_pXFAPageView) {
return m_pXFAPageView->GetDisplayMatrix(
CFX_Rect(xPos, yPos, xSize, ySize), iRotate);
}
break;
}
- case DOCTYPE_PDF:
- case DOCTYPE_STATIC_XFA: {
+ case XFA_DocType::PDF:
+ case XFA_DocType::Static: {
if (m_pPDFPage)
return m_pPDFPage->GetDisplayMatrix(xPos, yPos, xSize, ySize, iRotate);
break;