diff options
-rw-r--r-- | fpdfsdk/cpdfsdk_pageview.cpp | 18 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.cpp | 37 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widgethandler.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/fpdfformfill.cpp | 40 | ||||
-rw-r--r-- | fpdfsdk/fpdfsave.cpp | 13 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 16 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_context.h | 4 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 26 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_page.cpp | 38 | ||||
-rw-r--r-- | fpdfsdk/javascript/app.cpp | 3 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffdoc.cpp | 33 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffdocview.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/fxfa.h | 6 | ||||
-rw-r--r-- | xfa/fxfa/xfa_ffdoc.h | 5 |
14 files changed, 121 insertions, 124 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; } diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index 22450a74fe..ba1f5d8124 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -156,16 +156,12 @@ 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::Static) {} CXFA_FFDoc::~CXFA_FFDoc() { CloseDoc(); } -uint32_t CXFA_FFDoc::GetDocType() { - return m_dwDocType; -} - int32_t CXFA_FFDoc::StartLoad() { m_pNotify = pdfium::MakeUnique<CXFA_FFNotify>(this); m_pDocumentParser = pdfium::MakeUnique<CXFA_DocumentParser>(m_pNotify.get()); @@ -245,29 +241,28 @@ int32_t CXFA_FFDoc::DoLoad(IFX_Pause* pPause) { void CXFA_FFDoc::StopLoad() { m_pApp->GetXFAFontMgr()->LoadDocFonts(this); - m_dwDocType = XFA_DOCTYPE_Static; + m_dwDocType = XFA_DocType::Static; CXFA_Node* pConfig = ToNode( m_pDocumentParser->GetDocument()->GetXFAObject(XFA_HASHCODE_Config)); - if (!pConfig) { + if (!pConfig) return; - } + CXFA_Node* pAcrobat = pConfig->GetFirstChildByClass(XFA_Element::Acrobat); - if (!pAcrobat) { + if (!pAcrobat) return; - } + CXFA_Node* pAcrobat7 = pAcrobat->GetFirstChildByClass(XFA_Element::Acrobat7); - if (!pAcrobat7) { + if (!pAcrobat7) return; - } + CXFA_Node* pDynamicRender = pAcrobat7->GetFirstChildByClass(XFA_Element::DynamicRender); - if (!pDynamicRender) { + if (!pDynamicRender) return; - } + CFX_WideString wsType; - if (pDynamicRender->TryContent(wsType) && wsType == L"required") { - m_dwDocType = XFA_DOCTYPE_Dynamic; - } + if (pDynamicRender->TryContent(wsType) && wsType == L"required") + m_dwDocType = XFA_DocType::Dynamic; } CXFA_FFDocView* CXFA_FFDoc::CreateDocView() { @@ -345,9 +340,7 @@ bool CXFA_FFDoc::CloseDoc() { m_pApp->ClearEventTargets(); return true; } -void CXFA_FFDoc::SetDocType(uint32_t dwType) { - m_dwDocType = dwType; -} + CPDF_Document* CXFA_FFDoc::GetPDFDoc() { return m_pPDFDoc; } diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp index b2ed1e907c..f4ea3afdd8 100644 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -598,6 +598,7 @@ void CXFA_FFDocView::RunDocClose() { ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose, false, true, nullptr); } + void CXFA_FFDocView::DestroyDocView() { ClearInvalidateList(); m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_None; @@ -606,8 +607,9 @@ void CXFA_FFDocView::DestroyDocView() { m_BindItems.clear(); m_CalculateAccs.clear(); } + bool CXFA_FFDocView::IsStaticNotify() { - return m_pDoc->GetDocType() == XFA_DOCTYPE_Static; + return m_pDoc->GetDocType() == XFA_DocType::Static; } void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h index 0820a79d22..cc75524624 100644 --- a/xfa/fxfa/fxfa.h +++ b/xfa/fxfa/fxfa.h @@ -39,9 +39,9 @@ class IXFA_WidgetIterator; #define XFA_IDNo 3 #define XFA_IDYes 4 -#define XFA_DOCTYPE_Dynamic 0 -#define XFA_DOCTYPE_Static 1 -#define XFA_DOCTYPE_XDP 2 +// Note, values match fpdf_formfill.h DOCTYPE_* flags. +enum class XFA_DocType { PDF = 0, Dynamic = 1, Static = 2 }; + #define XFA_PARSESTATUS_StatusErr -3 #define XFA_PARSESTATUS_StreamErr -2 #define XFA_PARSESTATUS_SyntaxErr -1 diff --git a/xfa/fxfa/xfa_ffdoc.h b/xfa/fxfa/xfa_ffdoc.h index af2bf2c796..ee7695b15a 100644 --- a/xfa/fxfa/xfa_ffdoc.h +++ b/xfa/fxfa/xfa_ffdoc.h @@ -31,8 +31,7 @@ class CXFA_FFDoc { ~CXFA_FFDoc(); IXFA_DocEnvironment* GetDocEnvironment() const { return m_pDocEnvironment; } - uint32_t GetDocType(); - void SetDocType(uint32_t dwType); + XFA_DocType GetDocType() const { return m_dwDocType; } int32_t StartLoad(); int32_t DoLoad(IFX_Pause* pPause = nullptr); @@ -68,7 +67,7 @@ class CXFA_FFDoc { CPDF_Document* m_pPDFDoc; std::map<uint32_t, FX_IMAGEDIB_AND_DPI> m_HashToDibDpiMap; std::unique_ptr<CXFA_FFDocView> m_DocView; - uint32_t m_dwDocType; + XFA_DocType m_dwDocType; }; #endif // XFA_FXFA_XFA_FFDOC_H_ |