summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-11-24 13:33:57 -0800
committerTom Sepez <tsepez@chromium.org>2015-11-24 13:33:57 -0800
commit540c436dc8e7d7b700b448acc8536f5cf68d4b74 (patch)
treebff6a2297a280b39753d93b64ec61d6c9459b50a /fpdfsdk/src
parented19d211f96f47e06dc1b597c5a054e17d7e160d (diff)
downloadpdfium-540c436dc8e7d7b700b448acc8536f5cf68d4b74.tar.xz
XFA: more underlying type changes to match master
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1474663004 .
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/fpdfformfill.cpp27
-rw-r--r--fpdfsdk/src/fpdfview.cpp14
-rw-r--r--fpdfsdk/src/fsdk_annothandler.cpp8
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp21
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp18
5 files changed, 46 insertions, 42 deletions
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),