summaryrefslogtreecommitdiff
path: root/fpdfsdk
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
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')
-rw-r--r--fpdfsdk/cpdfsdk_pageview.cpp18
-rw-r--r--fpdfsdk/cpdfsdk_widget.cpp37
-rw-r--r--fpdfsdk/cpdfsdk_widgethandler.cpp2
-rw-r--r--fpdfsdk/fpdfformfill.cpp40
-rw-r--r--fpdfsdk/fpdfsave.cpp13
-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
-rw-r--r--fpdfsdk/javascript/app.cpp3
10 files changed, 100 insertions, 97 deletions
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp
index d5a04fef3e..a1a02ef185 100644
--- a/fpdfsdk/cpdfsdk_pageview.cpp
+++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -94,7 +94,7 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
if (!pPage)
return;
- if (pPage->GetContext()->GetDocType() == DOCTYPE_DYNAMIC_XFA) {
+ if (pPage->GetContext()->GetDocType() == XFA_DocType::Dynamic) {
CFX_Graphics gs(pDevice);
CFX_RectF rectClip(
static_cast<float>(pClip.left), static_cast<float>(pClip.top),
@@ -181,9 +181,10 @@ bool CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) {
if (!pAnnot)
return false;
CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage();
- if (!pPage || (pPage->GetContext()->GetDocType() != DOCTYPE_STATIC_XFA &&
- pPage->GetContext()->GetDocType() != DOCTYPE_DYNAMIC_XFA))
+ if (!pPage || (pPage->GetContext()->GetDocType() != XFA_DocType::Static &&
+ pPage->GetContext()->GetDocType() != XFA_DocType::Dynamic)) {
return false;
+ }
if (GetFocusAnnot() == pAnnot)
m_pFormFillEnv->KillFocusAnnot(0);
@@ -383,7 +384,7 @@ void CPDFSDK_PageView::LoadFXAnnots() {
#ifdef PDF_ENABLE_XFA
CFX_RetainPtr<CPDFXFA_Page> protector(m_page);
- if (m_pFormFillEnv->GetXFAContext()->GetDocType() == DOCTYPE_DYNAMIC_XFA) {
+ if (m_pFormFillEnv->GetXFAContext()->GetDocType() == XFA_DocType::Dynamic) {
CXFA_FFPageView* pageView = m_page->GetXFAPageView();
std::unique_ptr<IXFA_WidgetIterator> pWidgetHander(
pageView->CreateWidgetIterator(
@@ -444,14 +445,13 @@ int CPDFSDK_PageView::GetPageIndex() const {
return -1;
#ifdef PDF_ENABLE_XFA
- int nDocType = m_page->GetContext()->GetDocType();
- switch (nDocType) {
- case DOCTYPE_DYNAMIC_XFA: {
+ switch (m_page->GetContext()->GetDocType()) {
+ case XFA_DocType::Dynamic: {
CXFA_FFPageView* pPageView = m_page->GetXFAPageView();
return pPageView ? pPageView->GetPageIndex() : -1;
}
- case DOCTYPE_STATIC_XFA:
- case DOCTYPE_PDF:
+ case XFA_DocType::Static:
+ case XFA_DocType::PDF:
return GetPageIndexForStaticPDF();
default:
return -1;
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index 75c34b38b4..ccfee05575 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -72,7 +72,7 @@ CPDFSDK_Widget::~CPDFSDK_Widget() {}
#ifdef PDF_ENABLE_XFA
CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const {
CPDFXFA_Context* pContext = m_pPageView->GetFormFillEnv()->GetXFAContext();
- if (pContext->GetDocType() == DOCTYPE_STATIC_XFA) {
+ if (pContext->GetDocType() == XFA_DocType::Static) {
if (!m_hMixXFAWidget) {
if (CXFA_FFDocView* pDocView = pContext->GetXFADocView()) {
CFX_WideString sName;
@@ -96,28 +96,27 @@ CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const {
CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() {
CPDFXFA_Context* pContext = m_pPageView->GetFormFillEnv()->GetXFAContext();
- if (pContext->GetDocType() == DOCTYPE_STATIC_XFA) {
- if (CXFA_FFDocView* pDocView = pContext->GetXFADocView()) {
- CFX_WideString sName = GetName();
- if (!sName.IsEmpty())
- return pDocView->GetWidgetByName(sName, nullptr);
- }
- }
+ if (pContext->GetDocType() != XFA_DocType::Static)
+ return nullptr;
- return nullptr;
+ CXFA_FFDocView* pDocView = pContext->GetXFADocView();
+ if (!pDocView)
+ return nullptr;
+
+ CFX_WideString sName = GetName();
+ return !sName.IsEmpty() ? pDocView->GetWidgetByName(sName, nullptr) : nullptr;
}
CXFA_FFWidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const {
CPDFXFA_Context* pContext = m_pPageView->GetFormFillEnv()->GetXFAContext();
- if (pContext->GetDocType() == DOCTYPE_STATIC_XFA) {
- if (!m_pWidgetHandler) {
- if (CXFA_FFDocView* pDocView = pContext->GetXFADocView())
- m_pWidgetHandler = pDocView->GetWidgetHandler();
- }
- return m_pWidgetHandler;
- }
+ if (pContext->GetDocType() != XFA_DocType::Static)
+ return nullptr;
- return nullptr;
+ if (!m_pWidgetHandler) {
+ if (CXFA_FFDocView* pDocView = pContext->GetXFADocView())
+ m_pWidgetHandler = pDocView->GetWidgetHandler();
+ }
+ return m_pWidgetHandler;
}
static XFA_EVENTTYPE GetXFAEventType(PDFSDK_XFAAActionType eXFAAAT) {
@@ -505,8 +504,8 @@ int CPDFSDK_Widget::GetFieldType() const {
bool CPDFSDK_Widget::IsAppearanceValid() {
#ifdef PDF_ENABLE_XFA
CPDFXFA_Context* pContext = m_pPageView->GetFormFillEnv()->GetXFAContext();
- int nDocType = pContext->GetDocType();
- if (nDocType != DOCTYPE_PDF && nDocType != DOCTYPE_STATIC_XFA)
+ XFA_DocType nDocType = pContext->GetDocType();
+ if (nDocType != XFA_DocType::PDF && nDocType != XFA_DocType::Static)
return true;
#endif // PDF_ENABLE_XFA
return CPDFSDK_BAAnnot::IsAppearanceValid();
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index e85d24c4e0..cab210db42 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -238,7 +238,7 @@ void CPDFSDK_WidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) {
#ifdef PDF_ENABLE_XFA
CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
CPDFXFA_Context* pContext = pPageView->GetFormFillEnv()->GetXFAContext();
- if (pContext->GetDocType() == DOCTYPE_STATIC_XFA) {
+ if (pContext->GetDocType() == XFA_DocType::Static) {
if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty())
pWidget->ResetAppearance(false);
}
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index 3c866a91a3..c664d70c57 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -32,6 +32,13 @@
#include "xfa/fxfa/xfa_ffdocview.h"
#include "xfa/fxfa/xfa_ffpageview.h"
#include "xfa/fxfa/xfa_ffwidget.h"
+
+static_assert(static_cast<int>(XFA_DocType::PDF) == DOCTYPE_PDF,
+ "PDF doctype must match");
+static_assert(static_cast<int>(XFA_DocType::Dynamic) == DOCTYPE_DYNAMIC_XFA,
+ "Dynamic XFA doctype must match");
+static_assert(static_cast<int>(XFA_DocType::Static) == DOCTYPE_STATIC_XFA,
+ "Static XFA doctype must match");
#endif // PDF_ENABLE_XFA
namespace {
@@ -423,9 +430,10 @@ DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document,
return;
CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document);
- if (pContext->GetDocType() != XFA_DOCTYPE_Dynamic &&
- pContext->GetDocType() != XFA_DOCTYPE_Static)
+ if (pContext->GetDocType() != XFA_DocType::Dynamic &&
+ pContext->GetDocType() != XFA_DocType::Static) {
return;
+ }
static_cast<CXFA_FFWidget*>(hWidget)->Undo();
}
@@ -436,8 +444,8 @@ DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document,
return;
CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document);
- if (pContext->GetDocType() != XFA_DOCTYPE_Dynamic &&
- pContext->GetDocType() != XFA_DOCTYPE_Static)
+ if (pContext->GetDocType() != XFA_DocType::Dynamic &&
+ pContext->GetDocType() != XFA_DocType::Static)
return;
static_cast<CXFA_FFWidget*>(hWidget)->Redo();
@@ -449,8 +457,8 @@ DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document,
return;
CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document);
- if (pContext->GetDocType() != XFA_DOCTYPE_Dynamic &&
- pContext->GetDocType() != XFA_DOCTYPE_Static)
+ if (pContext->GetDocType() != XFA_DocType::Dynamic &&
+ pContext->GetDocType() != XFA_DocType::Static)
return;
static_cast<CXFA_FFWidget*>(hWidget)->SelectAll();
@@ -464,8 +472,8 @@ DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document,
return;
CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document);
- if (pContext->GetDocType() != XFA_DOCTYPE_Dynamic &&
- pContext->GetDocType() != XFA_DOCTYPE_Static)
+ if (pContext->GetDocType() != XFA_DocType::Dynamic &&
+ pContext->GetDocType() != XFA_DocType::Static)
return;
CFX_WideString wsCpText;
@@ -496,8 +504,8 @@ DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document,
return;
CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document);
- if (pContext->GetDocType() != XFA_DOCTYPE_Dynamic &&
- pContext->GetDocType() != XFA_DOCTYPE_Static)
+ if (pContext->GetDocType() != XFA_DocType::Dynamic &&
+ pContext->GetDocType() != XFA_DocType::Static)
return;
CFX_WideString wsCpText;
@@ -528,8 +536,8 @@ DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document,
return;
CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document);
- if (pContext->GetDocType() != XFA_DOCTYPE_Dynamic &&
- pContext->GetDocType() != XFA_DOCTYPE_Static)
+ if (pContext->GetDocType() != XFA_DocType::Dynamic &&
+ pContext->GetDocType() != XFA_DocType::Static)
return;
CFX_WideString wstr = CFX_WideString::FromUTF16LE(wsText, size);
@@ -546,8 +554,8 @@ FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document,
return;
CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document);
- if (pContext->GetDocType() != XFA_DOCTYPE_Dynamic &&
- pContext->GetDocType() != XFA_DOCTYPE_Static)
+ if (pContext->GetDocType() != XFA_DocType::Dynamic &&
+ pContext->GetDocType() != XFA_DocType::Static)
return;
CFX_PointF ptPopup;
@@ -567,8 +575,8 @@ FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document,
return;
CPDFXFA_Context* pContext = static_cast<CPDFXFA_Context*>(document);
- if (pContext->GetDocType() != XFA_DOCTYPE_Dynamic &&
- pContext->GetDocType() != XFA_DOCTYPE_Static)
+ if (pContext->GetDocType() != XFA_DocType::Dynamic &&
+ pContext->GetDocType() != XFA_DocType::Static)
return;
std::vector<CFX_ByteString>* sSuggestWords = new std::vector<CFX_ByteString>;
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp
index 0cfcd4af57..bc67cbba23 100644
--- a/fpdfsdk/fpdfsave.cpp
+++ b/fpdfsdk/fpdfsave.cpp
@@ -81,9 +81,10 @@ bool SaveXFADocumentData(
if (!pContext)
return false;
- if (pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
- pContext->GetDocType() != DOCTYPE_STATIC_XFA)
+ if (pContext->GetDocType() != XFA_DocType::Dynamic &&
+ pContext->GetDocType() != XFA_DocType::Static) {
return true;
+ }
CXFA_FFDocView* pXFADocView = pContext->GetXFADocView();
if (!pXFADocView)
@@ -223,8 +224,8 @@ bool SendPostSaveToXFADoc(CPDFXFA_Context* pContext) {
if (!pContext)
return false;
- if (pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
- pContext->GetDocType() != DOCTYPE_STATIC_XFA)
+ if (pContext->GetDocType() != XFA_DocType::Dynamic &&
+ pContext->GetDocType() != XFA_DocType::Static)
return true;
CXFA_FFDocView* pXFADocView = pContext->GetXFADocView();
@@ -247,8 +248,8 @@ bool SendPostSaveToXFADoc(CPDFXFA_Context* pContext) {
bool SendPreSaveToXFADoc(
CPDFXFA_Context* pContext,
std::vector<CFX_RetainPtr<IFX_SeekableStream>>* fileList) {
- if (pContext->GetDocType() != DOCTYPE_DYNAMIC_XFA &&
- pContext->GetDocType() != DOCTYPE_STATIC_XFA)
+ if (pContext->GetDocType() != XFA_DocType::Dynamic &&
+ pContext->GetDocType() != XFA_DocType::Static)
return true;
CXFA_FFDocView* pXFADocView = pContext->GetXFADocView();
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;
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index 3a8bf088f3..400340e38d 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -283,7 +283,8 @@ bool app::viewerVersion(CJS_Runtime* pRuntime,
return false;
#ifdef PDF_ENABLE_XFA
CPDFXFA_Context* pXFAContext = pRuntime->GetFormFillEnv()->GetXFAContext();
- if (pXFAContext->GetDocType() == 1 || pXFAContext->GetDocType() == 2) {
+ if (pXFAContext->GetDocType() == XFA_DocType::Dynamic ||
+ pXFAContext->GetDocType() == XFA_DocType::Static) {
vp << JS_NUM_VIEWERVERSION_XFA;
return true;
}