From f9068a5c08e55c1c16b14863abd8a089a327bc4d Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Mon, 16 Oct 2017 14:16:18 -0400 Subject: 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 Commit-Queue: Ryan Harrison --- fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 16 ++++++++-------- fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 26 +++++++++++++------------- fpdfsdk/fpdfxfa/cpdfxfa_page.cpp | 24 ++++++++++++------------ 3 files changed, 33 insertions(+), 33 deletions(-) (limited to 'fpdfsdk/fpdfxfa') 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 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_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 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; -- cgit v1.2.3