diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-10-16 14:16:18 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-17 13:57:00 +0000 |
commit | f9068a5c08e55c1c16b14863abd8a089a327bc4d (patch) | |
tree | f8dc58642256506eb9051add027d06696836b811 | |
parent | 90fffb31e2ec6cf66fe1b85b466cd2f12ee9c87f (diff) | |
download | pdfium-f9068a5c08e55c1c16b14863abd8a089a327bc4d.tar.xz |
Convert XFA Doc Types to be more precise
The existing types are PDF, Dynamic & Static, which are poorly named
since they don't really convey the fundamental differences between the
types. "PDF" is confusing because PDFium only handles PDFs, and
"Dynamic" & "Static" describe what a form may do, not how it is
specified or some other fundamental difference. The terms "Dynamic"
and "Static" were especially confusing, since XFAF documents must be
static by definition, whereas full XFA documents can be either
dynamic or static, depending on whether or not they change their
layout.
The types have been renamed to be clear that they are talking about
the type of PDF document being described. "PDF" becomes "None", since
this is used to indicate that there are no XFA forms in the
document. "Dynamic" becomes "Full", since this indicates that the
entire XFA spec is being used for the forms, specifically display
layout is in the XML. "Static" has become "ForegroundOnly", since the
form is specified using the XFAF (XFA Foreground) subset of the spec.
The terms Full & Foreground come from the XFA spec. I would have
preferred XFAF to have a different name, since it is the
display/foreground layer that isn't XFA when using it.
BUG=pdfium:917
Change-Id: I4335958c4a11d77d3bbe63b93602dd5bc14acb57
Reviewed-on: https://pdfium-review.googlesource.com/16010
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
-rw-r--r-- | fpdfsdk/cpdfsdk_pageview.cpp | 15 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.cpp | 9 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widgethandler.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/fpdfformfill.cpp | 39 | ||||
-rw-r--r-- | fpdfsdk/fpdfsave.cpp | 12 | ||||
-rw-r--r-- | fpdfsdk/fpdfview.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 16 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 26 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_page.cpp | 24 | ||||
-rw-r--r-- | fpdfsdk/javascript/app.cpp | 4 | ||||
-rw-r--r-- | public/fpdf_formfill.h | 9 | ||||
-rw-r--r-- | samples/pdfium_test.cc | 4 | ||||
-rw-r--r-- | testing/embedder_test.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdoc.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdocview.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/fxfa.h | 4 |
16 files changed, 91 insertions, 87 deletions
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp index f46c74f79a..516b0eb499 100644 --- a/fpdfsdk/cpdfsdk_pageview.cpp +++ b/fpdfsdk/cpdfsdk_pageview.cpp @@ -88,7 +88,7 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, if (!pPage) return; - if (pPage->GetContext()->GetDocType() == XFA_DocType::Dynamic) { + if (pPage->GetContext()->GetDocType() == XFA_DocType::kFull) { CFX_RectF rectClip( static_cast<float>(pClip.left), static_cast<float>(pClip.top), static_cast<float>(pClip.Width()), static_cast<float>(pClip.Height())); @@ -176,8 +176,9 @@ bool CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { return false; CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); - if (!pPage || (pPage->GetContext()->GetDocType() != XFA_DocType::Static && - pPage->GetContext()->GetDocType() != XFA_DocType::Dynamic)) { + if (!pPage || + (pPage->GetContext()->GetDocType() != XFA_DocType::kForegroundOnly && + pPage->GetContext()->GetDocType() != XFA_DocType::kFull)) { return false; } @@ -428,7 +429,7 @@ void CPDFSDK_PageView::LoadFXAnnots() { #ifdef PDF_ENABLE_XFA RetainPtr<CPDFXFA_Page> protector(m_page); - if (m_pFormFillEnv->GetXFAContext()->GetDocType() == XFA_DocType::Dynamic) { + if (m_pFormFillEnv->GetXFAContext()->GetDocType() == XFA_DocType::kFull) { CXFA_FFPageView* pageView = m_page->GetXFAPageView(); std::unique_ptr<IXFA_WidgetIterator> pWidgetHandler( pageView->CreateWidgetIterator( @@ -486,12 +487,12 @@ int CPDFSDK_PageView::GetPageIndex() const { #ifdef PDF_ENABLE_XFA switch (m_page->GetContext()->GetDocType()) { - case XFA_DocType::Dynamic: { + case XFA_DocType::kFull: { CXFA_FFPageView* pPageView = m_page->GetXFAPageView(); return pPageView ? pPageView->GetPageIndex() : -1; } - case XFA_DocType::Static: - case XFA_DocType::PDF: + case XFA_DocType::kForegroundOnly: + case XFA_DocType::kNone: return GetPageIndexForStaticPDF(); default: return -1; diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index c8bd4eaf08..0e121e8596 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() == XFA_DocType::Static) { + if (pContext->GetDocType() == XFA_DocType::kForegroundOnly) { if (!m_hMixXFAWidget) { if (CXFA_FFDocView* pDocView = pContext->GetXFADocView()) { WideString sName; @@ -95,7 +95,7 @@ CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const { CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() { CPDFXFA_Context* pContext = m_pPageView->GetFormFillEnv()->GetXFAContext(); - if (pContext->GetDocType() != XFA_DocType::Static) + if (pContext->GetDocType() != XFA_DocType::kForegroundOnly) return nullptr; CXFA_FFDocView* pDocView = pContext->GetXFADocView(); @@ -108,7 +108,7 @@ CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() { CXFA_FFWidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const { CPDFXFA_Context* pContext = m_pPageView->GetFormFillEnv()->GetXFAContext(); - if (pContext->GetDocType() != XFA_DocType::Static) + if (pContext->GetDocType() != XFA_DocType::kForegroundOnly) return nullptr; if (!m_pWidgetHandler) { @@ -507,7 +507,8 @@ bool CPDFSDK_Widget::IsAppearanceValid() { #ifdef PDF_ENABLE_XFA CPDFXFA_Context* pContext = m_pPageView->GetFormFillEnv()->GetXFAContext(); XFA_DocType nDocType = pContext->GetDocType(); - if (nDocType != XFA_DocType::PDF && nDocType != XFA_DocType::Static) + if (nDocType != XFA_DocType::kNone && + nDocType != XFA_DocType::kForegroundOnly) return true; #endif // PDF_ENABLE_XFA return CPDFSDK_BAAnnot::IsAppearanceValid(); diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp index ab37141ba2..44c1c66b1c 100644 --- a/fpdfsdk/cpdfsdk_widgethandler.cpp +++ b/fpdfsdk/cpdfsdk_widgethandler.cpp @@ -242,7 +242,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() == XFA_DocType::Static) { + if (pContext->GetDocType() == XFA_DocType::kForegroundOnly) { if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) pWidget->ResetAppearance(false); } diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index e789df461e..9e8b69e29e 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -33,11 +33,12 @@ #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" -static_assert(static_cast<int>(XFA_DocType::PDF) == DOCTYPE_PDF, +static_assert(static_cast<int>(XFA_DocType::kNone) == XFADOCTYPE_NONE, "PDF doctype must match"); -static_assert(static_cast<int>(XFA_DocType::Dynamic) == DOCTYPE_DYNAMIC_XFA, +static_assert(static_cast<int>(XFA_DocType::kFull) == XFADOCTYPE_FULL, "Dynamic XFA doctype must match"); -static_assert(static_cast<int>(XFA_DocType::Static) == DOCTYPE_STATIC_XFA, +static_assert(static_cast<int>(XFA_DocType::kForegroundOnly) == + XFADOCTYPE_FOREGROUNDONLY, "Static XFA doctype must match"); #endif // PDF_ENABLE_XFA @@ -456,8 +457,8 @@ FPDF_EXPORT void FPDF_CALLCONV 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::kFull && + pContext->GetDocType() != XFA_DocType::kForegroundOnly) { return; } @@ -470,8 +471,8 @@ FPDF_EXPORT void FPDF_CALLCONV 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::kFull && + pContext->GetDocType() != XFA_DocType::kForegroundOnly) return; static_cast<CXFA_FFWidget*>(hWidget)->Redo(); @@ -483,8 +484,8 @@ FPDF_EXPORT void FPDF_CALLCONV 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::kFull && + pContext->GetDocType() != XFA_DocType::kForegroundOnly) return; static_cast<CXFA_FFWidget*>(hWidget)->SelectAll(); @@ -498,8 +499,8 @@ FPDF_EXPORT void FPDF_CALLCONV 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::kFull && + pContext->GetDocType() != XFA_DocType::kForegroundOnly) return; WideString wsCpText; @@ -530,8 +531,8 @@ FPDF_EXPORT void FPDF_CALLCONV 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::kFull && + pContext->GetDocType() != XFA_DocType::kForegroundOnly) return; WideString wsCpText; @@ -562,8 +563,8 @@ FPDF_EXPORT void FPDF_CALLCONV 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::kFull && + pContext->GetDocType() != XFA_DocType::kForegroundOnly) return; WideString wstr = WideString::FromUTF16LE(wsText, size); @@ -580,8 +581,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::kFull && + pContext->GetDocType() != XFA_DocType::kForegroundOnly) return; CFX_PointF ptPopup; @@ -601,8 +602,8 @@ FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, return; auto* pContext = static_cast<CPDFXFA_Context*>(document); - if (pContext->GetDocType() != XFA_DocType::Dynamic && - pContext->GetDocType() != XFA_DocType::Static) + if (pContext->GetDocType() != XFA_DocType::kFull && + pContext->GetDocType() != XFA_DocType::kForegroundOnly) return; CFX_PointF ptPopup; diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp index 13475f690e..783a913022 100644 --- a/fpdfsdk/fpdfsave.cpp +++ b/fpdfsdk/fpdfsave.cpp @@ -48,8 +48,8 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext, if (!pContext) return false; - if (pContext->GetDocType() != XFA_DocType::Dynamic && - pContext->GetDocType() != XFA_DocType::Static) { + if (pContext->GetDocType() != XFA_DocType::kFull && + pContext->GetDocType() != XFA_DocType::kForegroundOnly) { return true; } @@ -192,8 +192,8 @@ bool SendPostSaveToXFADoc(CPDFXFA_Context* pContext) { if (!pContext) return false; - if (pContext->GetDocType() != XFA_DocType::Dynamic && - pContext->GetDocType() != XFA_DocType::Static) + if (pContext->GetDocType() != XFA_DocType::kFull && + pContext->GetDocType() != XFA_DocType::kForegroundOnly) return true; CXFA_FFDocView* pXFADocView = pContext->GetXFADocView(); @@ -215,8 +215,8 @@ bool SendPostSaveToXFADoc(CPDFXFA_Context* pContext) { bool SendPreSaveToXFADoc(CPDFXFA_Context* pContext, std::vector<RetainPtr<IFX_SeekableStream>>* fileList) { - if (pContext->GetDocType() != XFA_DocType::Dynamic && - pContext->GetDocType() != XFA_DocType::Static) + if (pContext->GetDocType() != XFA_DocType::kFull && + pContext->GetDocType() != XFA_DocType::kForegroundOnly) return true; CXFA_FFDocView* pXFADocView = pContext->GetXFADocView(); diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 47a92f1bca..9a8e8eb0b5 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -587,7 +587,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_HasXFAField(FPDF_DOCUMENT document, return false; bool bDynamicXFA = pRoot->GetBooleanFor("NeedsRendering", false); - *docType = bDynamicXFA ? DOCTYPE_DYNAMIC_XFA : DOCTYPE_STATIC_XFA; + *docType = bDynamicXFA ? XFADOCTYPE_FULL : XFADOCTYPE_FOREGROUNDONLY; return true; } diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp index a67ac0178b..692306aebf 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp @@ -36,7 +36,7 @@ extern int GetLastError(); #endif CPDFXFA_Context::CPDFXFA_Context(std::unique_ptr<CPDF_Document> pPDFDoc) - : m_iDocType(XFA_DocType::PDF), + : m_iDocType(XFA_DocType::kNone), m_pPDFDoc(std::move(pPDFDoc)), m_pFormFillEnv(nullptr), m_pXFADocView(nullptr), @@ -117,10 +117,10 @@ bool CPDFXFA_Context::LoadXFADoc() { m_pXFADoc->StopLoad(); m_pXFADoc->GetXFADoc()->InitScriptContext(GetJSERuntime()); - if (m_pXFADoc->GetDocType() == XFA_DocType::Dynamic) - m_iDocType = XFA_DocType::Dynamic; + if (m_pXFADoc->GetDocType() == XFA_DocType::kFull) + m_iDocType = XFA_DocType::kFull; else - m_iDocType = XFA_DocType::Static; + m_iDocType = XFA_DocType::kForegroundOnly; m_pXFADocView = m_pXFADoc->CreateDocView(); if (m_pXFADocView->StartLayout() < 0) { @@ -141,11 +141,11 @@ int CPDFXFA_Context::GetPageCount() const { return 0; switch (m_iDocType) { - case XFA_DocType::PDF: - case XFA_DocType::Static: + case XFA_DocType::kNone: + case XFA_DocType::kForegroundOnly: if (m_pPDFDoc) return m_pPDFDoc->GetPageCount(); - case XFA_DocType::Dynamic: + case XFA_DocType::kFull: if (m_pXFADoc) return m_pXFADocView->CountPageViews(); default: @@ -183,7 +183,7 @@ RetainPtr<CPDFXFA_Page> CPDFXFA_Context::GetXFAPage( if (!m_pXFADoc) return nullptr; - if (m_iDocType != XFA_DocType::Dynamic) + if (m_iDocType != XFA_DocType::kFull) return nullptr; for (auto& pTempPage : m_XFAPageList) { diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index 4dcdcac0f6..91322ee103 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -55,7 +55,7 @@ void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView, if (!m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv()) return; - if (m_pContext->GetDocType() != XFA_DocType::Dynamic) + if (m_pContext->GetDocType() != XFA_DocType::kFull) return; RetainPtr<CPDFXFA_Page> pPage = m_pContext->GetXFAPage(pPageView); @@ -76,7 +76,7 @@ void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget, !m_pContext->GetFormFillEnv() || !m_pContext->GetXFADocView()) return; - if (m_pContext->GetDocType() != XFA_DocType::Dynamic) + if (m_pContext->GetDocType() != XFA_DocType::kFull) return; CXFA_FFWidgetHandler* pWidgetHandler = @@ -289,7 +289,7 @@ void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView, void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget, CXFA_WidgetAcc* pWidgetData) { - if (m_pContext->GetDocType() != XFA_DocType::Dynamic || !hWidget) + if (m_pContext->GetDocType() != XFA_DocType::kFull || !hWidget) return; CXFA_FFPageView* pPageView = hWidget->GetPageView(); @@ -307,7 +307,7 @@ void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget, void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget, CXFA_WidgetAcc* pWidgetData) { - if (m_pContext->GetDocType() != XFA_DocType::Dynamic || !hWidget) + if (m_pContext->GetDocType() != XFA_DocType::kFull || !hWidget) return; CXFA_FFPageView* pPageView = hWidget->GetPageView(); @@ -334,7 +334,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() != XFA_DocType::Dynamic) + if (m_pContext->GetDocType() != XFA_DocType::kFull) return -1; CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); @@ -347,7 +347,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() != XFA_DocType::Dynamic || iCurPage < 0 || + m_pContext->GetDocType() != XFA_DocType::kFull || iCurPage < 0 || iCurPage >= m_pContext->GetFormFillEnv()->GetPageCount()) { return; } @@ -407,8 +407,8 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc, if (hDoc != m_pContext->GetXFADoc()) return; - if (m_pContext->GetDocType() != XFA_DocType::Dynamic && - m_pContext->GetDocType() != XFA_DocType::Static) { + if (m_pContext->GetDocType() != XFA_DocType::kFull && + m_pContext->GetDocType() != XFA_DocType::kForegroundOnly) { return; } @@ -506,7 +506,7 @@ void CPDFXFA_DocEnvironment::GotoURL(CXFA_FFDoc* hDoc, if (hDoc != m_pContext->GetXFADoc()) return; - if (m_pContext->GetDocType() != XFA_DocType::Dynamic) + if (m_pContext->GetDocType() != XFA_DocType::kFull) return; CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); @@ -606,8 +606,8 @@ bool CPDFXFA_DocEnvironment::NotifySubmit(bool bPrevOrPost) { } bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() { - if (m_pContext->GetDocType() != XFA_DocType::Dynamic && - m_pContext->GetDocType() != XFA_DocType::Static) { + if (m_pContext->GetDocType() != XFA_DocType::kFull && + m_pContext->GetDocType() != XFA_DocType::kForegroundOnly) { return true; } @@ -658,8 +658,8 @@ bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() { } void CPDFXFA_DocEnvironment::OnAfterNotifySubmit() { - if (m_pContext->GetDocType() != XFA_DocType::Dynamic && - m_pContext->GetDocType() != XFA_DocType::Static) + if (m_pContext->GetDocType() != XFA_DocType::kFull && + m_pContext->GetDocType() != XFA_DocType::kForegroundOnly) return; if (!m_pContext->GetXFADocView()) diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp index 87e003e147..fa10a925cd 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp @@ -65,10 +65,10 @@ bool CPDFXFA_Page::LoadPage() { return false; switch (m_pContext->GetDocType()) { - case XFA_DocType::PDF: - case XFA_DocType::Static: + case XFA_DocType::kNone: + case XFA_DocType::kForegroundOnly: return LoadPDFPage(); - case XFA_DocType::Dynamic: + case XFA_DocType::kFull: return LoadXFAPageView(); default: return false; @@ -90,13 +90,13 @@ float CPDFXFA_Page::GetPageWidth() const { return 0.0f; switch (m_pContext->GetDocType()) { - case XFA_DocType::Dynamic: { + case XFA_DocType::kFull: { if (m_pXFAPageView) return m_pXFAPageView->GetPageViewRect().width; break; } - case XFA_DocType::Static: - case XFA_DocType::PDF: { + case XFA_DocType::kForegroundOnly: + case XFA_DocType::kNone: { if (m_pPDFPage) return m_pPDFPage->GetPageWidth(); break; @@ -113,13 +113,13 @@ float CPDFXFA_Page::GetPageHeight() const { return 0.0f; switch (m_pContext->GetDocType()) { - case XFA_DocType::PDF: - case XFA_DocType::Static: { + case XFA_DocType::kNone: + case XFA_DocType::kForegroundOnly: { if (m_pPDFPage) return m_pPDFPage->GetPageHeight(); break; } - case XFA_DocType::Dynamic: { + case XFA_DocType::kFull: { if (m_pXFAPageView) return m_pXFAPageView->GetPageViewRect().height; break; @@ -183,15 +183,15 @@ CFX_Matrix CPDFXFA_Page::GetDisplayMatrix(int xPos, return CFX_Matrix(); switch (m_pContext->GetDocType()) { - case XFA_DocType::Dynamic: { + case XFA_DocType::kFull: { if (m_pXFAPageView) { return m_pXFAPageView->GetDisplayMatrix( CFX_Rect(xPos, yPos, xSize, ySize), iRotate); } break; } - case XFA_DocType::PDF: - case XFA_DocType::Static: { + case XFA_DocType::kNone: + case XFA_DocType::kForegroundOnly: { 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 3c0f9af286..f29a098fde 100644 --- a/fpdfsdk/javascript/app.cpp +++ b/fpdfsdk/javascript/app.cpp @@ -282,8 +282,8 @@ bool app::viewerVersion(CJS_Runtime* pRuntime, return false; #ifdef PDF_ENABLE_XFA CPDFXFA_Context* pXFAContext = pRuntime->GetFormFillEnv()->GetXFAContext(); - if (pXFAContext->GetDocType() == XFA_DocType::Dynamic || - pXFAContext->GetDocType() == XFA_DocType::Static) { + if (pXFAContext->GetDocType() == XFA_DocType::kFull || + pXFAContext->GetDocType() == XFA_DocType::kForegroundOnly) { vp << JS_NUM_VIEWERVERSION_XFA; return true; } diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h index e4194fed8e..1e0d305a6f 100644 --- a/public/fpdf_formfill.h +++ b/public/fpdf_formfill.h @@ -12,9 +12,10 @@ typedef void* FPDF_FORMHANDLE; -#define DOCTYPE_PDF 0 // Normal pdf Document -#define DOCTYPE_DYNAMIC_XFA 1 // Dynamic XFA Document Type -#define DOCTYPE_STATIC_XFA 2 // Static XFA Document Type +#define XFADOCTYPE_NONE 0 // Document contains no XFA forms +#define XFADOCTYPE_FULL 1 // XFA forms are specified using the entire XFA spec +#define XFADOCTYPE_FOREGROUNDONLY \ + 2 // XFA forms are specified using the XFAF subset // Exported Functions #ifdef __cplusplus @@ -1613,7 +1614,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_FFLRecord(FPDF_FORMHANDLE hHandle, * document - Handle to document. *Returned by FPDF_LoadDocument function. * docType - Document type defined as - *DOCTYPE_xxx. + *XFADOCTYPE_xxx. * Return Value: * TRUE indicates that the input document has XFA fields, *otherwise FALSE. diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index 0c002a8c63..a638fd0822 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -1430,8 +1430,8 @@ void RenderPdf(const std::string& name, form_callbacks.form_handle = form.get(); #ifdef PDF_ENABLE_XFA - int doc_type = DOCTYPE_PDF; - if (FPDF_HasXFAField(doc.get(), &doc_type) && doc_type != DOCTYPE_PDF && + int doc_type = XFADOCTYPE_NONE; + if (FPDF_HasXFAField(doc.get(), &doc_type) && doc_type != XFADOCTYPE_NONE && !FPDF_LoadXFA(doc.get())) { fprintf(stderr, "LoadXFA unsuccessful, continuing anyway.\n"); } diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp index dab06af50d..41be0c0298 100644 --- a/testing/embedder_test.cpp +++ b/testing/embedder_test.cpp @@ -205,9 +205,9 @@ bool EmbedderTest::OpenDocumentHelper(const char* password, } *form_handle = SetupFormFillEnvironment(*document); #ifdef PDF_ENABLE_XFA - int docType = DOCTYPE_PDF; + int docType = XFADOCTYPE_NONE; if (FPDF_HasXFAField(*document, &docType)) { - if (docType != DOCTYPE_PDF) + if (docType != XFADOCTYPE_NONE) (void)FPDF_LoadXFA(*document); } #endif // PDF_ENABLE_XFA diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index ee31a46f50..23b3df638e 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -160,7 +160,7 @@ CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment) m_pApp(pApp), m_pNotify(nullptr), m_pPDFDoc(nullptr), - m_dwDocType(XFA_DocType::Static) {} + m_dwDocType(XFA_DocType::kForegroundOnly) {} CXFA_FFDoc::~CXFA_FFDoc() { CloseDoc(); @@ -244,7 +244,7 @@ void CXFA_FFDoc::StopLoad() { m_pPDFFontMgr = pdfium::MakeUnique<CFGAS_PDFFontMgr>( GetPDFDoc(), GetApp()->GetFDEFontMgr()); - m_dwDocType = XFA_DocType::Static; + m_dwDocType = XFA_DocType::kForegroundOnly; CXFA_Node* pConfig = ToNode( m_pDocumentParser->GetDocument()->GetXFAObject(XFA_HASHCODE_Config)); if (!pConfig) @@ -265,7 +265,7 @@ void CXFA_FFDoc::StopLoad() { WideString wsType; if (pDynamicRender->TryContent(wsType) && wsType == L"required") - m_dwDocType = XFA_DocType::Dynamic; + m_dwDocType = XFA_DocType::kFull; } CXFA_FFDocView* CXFA_FFDoc::CreateDocView() { diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index 56dfeed3ca..0e895b676e 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -622,7 +622,7 @@ void CXFA_FFDocView::DestroyDocView() { } bool CXFA_FFDocView::IsStaticNotify() { - return m_pDoc->GetDocType() == XFA_DocType::Static; + return m_pDoc->GetDocType() == XFA_DocType::kForegroundOnly; } void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h index 929594ff38..9f5432e3ad 100644 --- a/xfa/fxfa/fxfa.h +++ b/xfa/fxfa/fxfa.h @@ -40,8 +40,8 @@ class IXFA_WidgetIterator; #define XFA_IDNo 3 #define XFA_IDYes 4 -// Note, values match fpdf_formfill.h DOCTYPE_* flags. -enum class XFA_DocType { PDF = 0, Dynamic = 1, Static = 2 }; +// Note, values match fpdf_formfill.h XFADOCTYPE_* flags. +enum class XFA_DocType { kNone = 0, kFull = 1, kForegroundOnly = 2 }; #define XFA_PARSESTATUS_StatusErr -3 #define XFA_PARSESTATUS_StreamErr -2 |