diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/include/fsdk_mgr.h | 12 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfformfill.cpp | 27 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfview.cpp | 14 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_annothandler.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_baseform.cpp | 21 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_mgr.cpp | 18 |
6 files changed, 52 insertions, 48 deletions
diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h index 3e65a17ad6..a3a97984df 100644 --- a/fpdfsdk/include/fsdk_mgr.h +++ b/fpdfsdk/include/fsdk_mgr.h @@ -495,11 +495,11 @@ class CPDFSDK_Document { CPDFXFA_Document* GetXFADocument() const { return m_pDoc; } int GetPageViewCount() const { return m_pageMap.size(); } - CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPDFXFAPage, + CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPage, FX_BOOL ReNew = TRUE); CPDFSDK_PageView* GetPageView(int nIndex); CPDFSDK_PageView* GetCurrentView(); - void RemovePageView(UnderlyingPageType* pPDFPage); + void RemovePageView(UnderlyingPageType* pPage); void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); CPDFSDK_Annot* GetFocusAnnot(); @@ -526,14 +526,14 @@ class CPDFSDK_Document { void SetChangeMark() { m_bChangeMask = TRUE; } void ClearChangeMark() { m_bChangeMask = FALSE; } CFX_WideString GetPath(); - CPDFXFA_Page* GetPage(int nIndex); + UnderlyingPageType* GetPage(int nIndex); CPDFDoc_Environment* GetEnv() { return m_pEnv; } void ProcJavascriptFun(); FX_BOOL ProcOpenAction(); CPDF_OCContext* GetOCContext(); private: - std::map<CPDFXFA_Page*, CPDFSDK_PageView*> m_pageMap; + std::map<UnderlyingPageType*, CPDFSDK_PageView*> m_pageMap; UnderlyingDocumentType* m_pDoc; nonstd::unique_ptr<CPDFSDK_InterForm> m_pInterForm; CPDFSDK_Annot* m_pFocusAnnot; @@ -544,7 +544,7 @@ class CPDFSDK_Document { }; class CPDFSDK_PageView final { public: - CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, CPDFXFA_Page* page); + CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page); ~CPDFSDK_PageView(); void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, @@ -610,7 +610,7 @@ class CPDFSDK_PageView final { CPDFSDK_Widget* pWidget); CPDF_Matrix m_curMatrix; - CPDFXFA_Page* m_page; + UnderlyingPageType* m_page; nonstd::unique_ptr<CPDF_AnnotList> m_pAnnotList; std::vector<CPDFSDK_Annot*> m_fxAnnotArray; CPDFSDK_Document* m_pSDKDoc; diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp index a1e807224d..5dcfb47890 100644 --- a/fpdfsdk/src/fpdfformfill.cpp +++ b/fpdfsdk/src/fpdfformfill.cpp @@ -28,11 +28,12 @@ CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) { CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, FPDF_PAGE page) { - if (!page) + UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); + if (!pPage) return nullptr; CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); - return pSDKDoc ? pSDKDoc->GetPageView((CPDFXFA_Page*)page, TRUE) : nullptr; + return pSDKDoc ? pSDKDoc->GetPageView(pPage, TRUE) : nullptr; } } // namespace @@ -128,16 +129,19 @@ DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo) { - if (!document || !formInfo || formInfo->version != 2) + const int kRequiredVersion = 2; + if (!formInfo || formInfo->version != kRequiredVersion) + return nullptr; + + UnderlyingDocumentType* pDocument = UnderlyingFromFPDFDocument(document); + if (!pDocument) return nullptr; - CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo); pEnv->SetSDKDocument(pDocument->GetSDKDocument(pEnv)); CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); pApp->AddFormFillEnv(pEnv); - return pEnv; } @@ -600,14 +604,17 @@ DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hHandle) { - if (!hHandle || !page) + if (!hHandle) return; CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument(); if (!pSDKDoc) return; - CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; + UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); + if (!pPage) + return; + CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); if (pPageView) { pPageView->SetValid(FALSE); @@ -653,11 +660,11 @@ DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandle, int aaType) { - if (!hHandle || !page) + if (!hHandle) return; CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument(); - CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; - CPDF_Page* pPDFPage = pPage->GetPDFPage(); + UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); + CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page); if (!pPDFPage) return; if (pSDKDoc->GetPageView(pPage, FALSE)) { diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp index 7e568062f0..1ff1004880 100644 --- a/fpdfsdk/src/fpdfview.cpp +++ b/fpdfsdk/src/fpdfview.cpp @@ -873,8 +873,8 @@ DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_index, double* width, double* height) { - CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document; - if (pDoc == NULL) + UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document); + if (!pDoc) return FALSE; int count = pDoc->GetPageCount(); @@ -1021,13 +1021,17 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, long* buflen) { if (!buffer) *buflen = 0; - if (!document || index < 0) - return NULL; + + if (index < 0) + return nullptr; CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); + if (!pDoc) + return nullptr; + CPDF_Dictionary* pRoot = pDoc->GetRoot(); if (!pRoot) - return NULL; + return nullptr; CPDF_Object* pDestObj = NULL; CFX_ByteString bsName; diff --git a/fpdfsdk/src/fsdk_annothandler.cpp b/fpdfsdk/src/fsdk_annothandler.cpp index 2965d3290f..5edd88a8e2 100644 --- a/fpdfsdk/src/fsdk_annothandler.cpp +++ b/fpdfsdk/src/fsdk_annothandler.cpp @@ -142,10 +142,10 @@ void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); } else { - if (!pAnnot->IsXFAField()) { - static_cast<CPDFSDK_BAAnnot*>(pAnnot) - ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); - } + if (pAnnot->IsXFAField()) + return; + static_cast<CPDFSDK_BAAnnot*>(pAnnot) + ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); } } diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp index aac27316ea..af6a8e549a 100644 --- a/fpdfsdk/src/fsdk_baseform.cpp +++ b/fpdfsdk/src/fsdk_baseform.cpp @@ -505,10 +505,10 @@ FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); int nDocType = pDoc->GetDocType(); - if (nDocType == DOCTYPE_PDF || nDocType == DOCTYPE_STATIC_XFA) - return CPDFSDK_BAAnnot::IsAppearanceValid(); + if (nDocType != DOCTYPE_PDF && nDocType != DOCTYPE_STATIC_XFA) + return TRUE; - return TRUE; + return CPDFSDK_BAAnnot::IsAppearanceValid(); } int CPDFSDK_Widget::GetFieldFlags() const { @@ -1955,14 +1955,14 @@ FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, PDFSDK_FieldAction& data, CPDFSDK_PageView* pPageView) { CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); - CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); CPDFDoc_Environment* pEnv = pDocument->GetEnv(); - if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { + CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); + if (IXFA_Widget* hWidget = GetMixXFAWidget()) { XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); if (eEventType != XFA_EVENT_Unknown) { - if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { + if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { CXFA_EventParam param; param.m_eType = eEventType; param.m_wsChange = data.sChange; @@ -2067,7 +2067,6 @@ FX_BOOL CPDFSDK_Widget::HitTest(FX_FLOAT pageX, FX_FLOAT pageY) { return FALSE; } -// CPDFSDK_XFAWidget CPDFSDK_XFAWidget::CPDFSDK_XFAWidget(IXFA_Widget* pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm) @@ -2096,7 +2095,6 @@ CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const { rcBBox.top + rcBBox.height); } -// CPDFSDK_InterForm CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) : m_pDocument(pDocument), m_pInterForm(NULL), @@ -2104,7 +2102,6 @@ CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) m_bXfaCalculate(TRUE), m_bXfaValidationsEnabled(TRUE), m_bBusy(FALSE) { - ASSERT(m_pDocument != NULL); m_pInterForm = new CPDF_InterForm(m_pDocument->GetPDFDocument(), FALSE); m_pInterForm->SetFormNotify(this); @@ -2452,8 +2449,6 @@ void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, } void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { - ASSERT(pFormField != NULL); - for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); ASSERT(pFormCtrl != NULL); @@ -2461,10 +2456,8 @@ void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); - - CPDFXFA_Page* pPage = pWidget->GetPDFXFAPage(); + UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, FALSE); - FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); pEnv->FFI_Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp index 69432a4af1..b05fd128a1 100644 --- a/fpdfsdk/src/fsdk_mgr.cpp +++ b/fpdfsdk/src/fsdk_mgr.cpp @@ -530,16 +530,17 @@ FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { if (m_pFocusAnnot == pAnnot) return TRUE; - CPDFSDK_Annot* pLastFocusAnnot = m_pFocusAnnot; - if (m_pFocusAnnot) { if (!KillFocusAnnot(nFlag)) return FALSE; } - CPDFSDK_PageView* pPageView = NULL; - if (pAnnot) - pPageView = pAnnot->GetPageView(); - if (pAnnot && pPageView->IsValid()) { + + if (!pAnnot) + return FALSE; + + CPDFSDK_Annot* pLastFocusAnnot = m_pFocusAnnot; + CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); + if (pPageView && pPageView->IsValid()) { CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); if (!m_pFocusAnnot) { if (!pAnnotHandler->Annot_OnChangeFocus(pAnnot, pLastFocusAnnot)) @@ -589,8 +590,7 @@ void CPDFSDK_Document::OnCloseDocument() { } FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag) { - FX_DWORD dwPermissions = m_pDoc->GetPDFDoc()->GetUserPermissions(); - return dwPermissions & nFlag; + return GetPDFDocument()->GetUserPermissions() & nFlag; } IJS_Runtime* CPDFSDK_Document::GetJsRuntime() { @@ -604,7 +604,7 @@ CFX_WideString CPDFSDK_Document::GetPath() { } CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, - CPDFXFA_Page* page) + UnderlyingPageType* page) : m_page(page), m_pSDKDoc(pSDKDoc), m_CaptureWidget(nullptr), |