From 854d71c1420eb80ec79755a6cdf829f3f39aead7 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 18 Oct 2017 12:28:14 -0400 Subject: Refactor HasXFAField into HasFormInfo The existing API is too restrictive for collection the metrics information that we want. Specifically it only tells us if there are XFA forms in the document, but not AcroForms. This refactoring makes the method more general, so that non-XFA information is provided also. This change in semantics of the return value required some changes at the call sites of the API. BUG=chromium:775519 Change-Id: Id421c66c09b47196c252c64cdc2c711ca1911de0 Reviewed-on: https://pdfium-review.googlesource.com/16210 Commit-Queue: Ryan Harrison Reviewed-by: Henrique Nakashima Reviewed-by: dsinclair --- fpdfsdk/fpdfxfa/cpdfxfa_page.cpp | 69 ++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 42 deletions(-) (limited to 'fpdfsdk/fpdfxfa/cpdfxfa_page.cpp') diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp index fa10a925cd..fbea90d9a9 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp @@ -64,15 +64,15 @@ bool CPDFXFA_Page::LoadPage() { if (!m_pContext || m_iPageIndex < 0) return false; - switch (m_pContext->GetDocType()) { - case XFA_DocType::kNone: - case XFA_DocType::kForegroundOnly: + switch (m_pContext->GetFormType()) { + case FormType::kNone: + case FormType::kAcroForm: + case FormType::kXFAForeground: return LoadPDFPage(); - case XFA_DocType::kFull: + case FormType::kXFAFull: return LoadXFAPageView(); - default: - return false; } + return false; } bool CPDFXFA_Page::LoadPDFPage(CPDF_Dictionary* pageDict) { @@ -89,20 +89,15 @@ float CPDFXFA_Page::GetPageWidth() const { if (!m_pPDFPage && !m_pXFAPageView) return 0.0f; - switch (m_pContext->GetDocType()) { - case XFA_DocType::kFull: { - if (m_pXFAPageView) - return m_pXFAPageView->GetPageViewRect().width; - break; - } - case XFA_DocType::kForegroundOnly: - case XFA_DocType::kNone: { + switch (m_pContext->GetFormType()) { + case FormType::kNone: + case FormType::kAcroForm: + case FormType::kXFAForeground: if (m_pPDFPage) return m_pPDFPage->GetPageWidth(); - break; - } - default: - return 0.0f; + case FormType::kXFAFull: + if (m_pXFAPageView) + return m_pXFAPageView->GetPageViewRect().width; } return 0.0f; @@ -112,20 +107,15 @@ float CPDFXFA_Page::GetPageHeight() const { if (!m_pPDFPage && !m_pXFAPageView) return 0.0f; - switch (m_pContext->GetDocType()) { - case XFA_DocType::kNone: - case XFA_DocType::kForegroundOnly: { + switch (m_pContext->GetFormType()) { + case FormType::kNone: + case FormType::kAcroForm: + case FormType::kXFAForeground: if (m_pPDFPage) return m_pPDFPage->GetPageHeight(); - break; - } - case XFA_DocType::kFull: { + case FormType::kXFAFull: if (m_pXFAPageView) return m_pXFAPageView->GetPageViewRect().height; - break; - } - default: - return 0.0f; } return 0.0f; @@ -182,22 +172,17 @@ CFX_Matrix CPDFXFA_Page::GetDisplayMatrix(int xPos, if (!m_pPDFPage && !m_pXFAPageView) return CFX_Matrix(); - switch (m_pContext->GetDocType()) { - case XFA_DocType::kFull: { - if (m_pXFAPageView) { - return m_pXFAPageView->GetDisplayMatrix( - CFX_Rect(xPos, yPos, xSize, ySize), iRotate); - } - break; - } - case XFA_DocType::kNone: - case XFA_DocType::kForegroundOnly: { + switch (m_pContext->GetFormType()) { + case FormType::kNone: + case FormType::kAcroForm: + case FormType::kXFAForeground: if (m_pPDFPage) return m_pPDFPage->GetDisplayMatrix(xPos, yPos, xSize, ySize, iRotate); - break; - } - default: - return CFX_Matrix(); + case FormType::kXFAFull: + if (m_pXFAPageView) + return m_pXFAPageView->GetDisplayMatrix( + CFX_Rect(xPos, yPos, xSize, ySize), iRotate); } + return CFX_Matrix(); } -- cgit v1.2.3