XFA: More underlying types
Precursor to https://codereview.chromium.org/1477583002/
Also:
whitespace in fxjs_v8.h
Merge where possible.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1472363003 .
diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h
index 8263cd4..97f96f6 100644
--- a/fpdfsdk/include/jsapi/fxjs_v8.h
+++ b/fpdfsdk/include/jsapi/fxjs_v8.h
@@ -135,7 +135,6 @@
void FXJS_ReleaseRuntime(v8::Isolate* pIsolate,
v8::Global<v8::Context>* pV8PersistentContext,
std::vector<v8::Global<v8::Object>*>* pStaticObjects);
-
IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate);
// Called as part of FXJS_InitializeRuntime, exposed so PDF can make its
diff --git a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
index 048ebaf..9817f05 100644
--- a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
@@ -243,7 +243,7 @@
void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- CPDFXFA_Page* pPage = pWidget->GetPDFXFAPage();
+ UnderlyingPageType* pPage = pWidget->GetUnderlyingPage();
CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument();
CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage);
if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE))
@@ -461,7 +461,7 @@
}
CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView() {
- CPDFXFA_Page* pPage = m_pAnnot->GetPDFXFAPage();
+ UnderlyingPageType* pPage = m_pAnnot->GetUnderlyingPage();
CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument();
return pSDKDoc ? pSDKDoc->GetPageView(pPage) : nullptr;
}
@@ -616,7 +616,7 @@
double top,
double right,
double bottom) {
- CPDFXFA_Page* pPage = m_pWidget->GetPDFXFAPage();
+ UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage();
m_pApp->FFI_Invalidate(pPage, left, top, right, bottom);
}
diff --git a/fpdfsdk/src/formfiller/FFL_TextField.cpp b/fpdfsdk/src/formfiller/FFL_TextField.cpp
index 253671d..3c0cdeb 100644
--- a/fpdfsdk/src/formfiller/FFL_TextField.cpp
+++ b/fpdfsdk/src/formfiller/FFL_TextField.cpp
@@ -119,7 +119,7 @@
ASSERT(pPageView != NULL);
m_bValid = !m_bValid;
CPDF_Rect rcAnnot = pAnnot->GetRect();
- m_pApp->FFI_Invalidate(pAnnot->GetPDFXFAPage(), rcAnnot.left,
+ m_pApp->FFI_Invalidate(pAnnot->GetUnderlyingPage(), rcAnnot.left,
rcAnnot.top, rcAnnot.right, rcAnnot.bottom);
if (m_bValid) {
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp
index 5dcfb47..0798c4e 100644
--- a/fpdfsdk/src/fpdfformfill.cpp
+++ b/fpdfsdk/src/fpdfformfill.cpp
@@ -269,13 +269,17 @@
int size_y,
int rotate,
int flags) {
- if (!hHandle || !page)
+ if (!hHandle)
return;
- CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
+ UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+ if (!pPage)
+ return;
+
CPDFXFA_Document* pDocument = pPage->GetDocument();
if (!pDocument)
return;
+
CPDF_Document* pPDFDoc = pDocument->GetPDFDoc();
if (!pPDFDoc)
return;
@@ -321,7 +325,7 @@
options.m_AddFlags = flags >> 8;
options.m_pOCContext = new CPDF_OCContext(pPDFDoc);
- if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView((CPDFXFA_Page*)page))
+ if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage))
pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip);
pDevice->RestoreState();
diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp
index 882161c..f643f70 100644
--- a/fpdfsdk/src/fpdfsave.cpp
+++ b/fpdfsdk/src/fpdfsave.cpp
@@ -284,16 +284,14 @@
FPDF_DWORD flags,
FPDF_BOOL bSetVersion,
int fileVerion) {
- CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
-
- CFX_PtrArray fileList;
-
- _SendPreSaveToXFADoc(pDoc, fileList);
-
- CPDF_Document* pPDFDoc = pDoc->GetPDFDoc();
+ CPDF_Document* pPDFDoc = CPDFDocumentFromFPDFDocument(document);
if (!pPDFDoc)
return 0;
+ CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
+ CFX_PtrArray fileList;
+ _SendPreSaveToXFADoc(pDoc, fileList);
+
if (flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY) {
flags = 0;
}
@@ -305,20 +303,18 @@
flags = 0;
FileMaker.RemoveSecurity();
}
+
CFX_IFileWrite* pStreamWrite = NULL;
FX_BOOL bRet;
pStreamWrite = new CFX_IFileWrite;
pStreamWrite->Init(pFileWrite);
bRet = FileMaker.Create(pStreamWrite, flags);
-
_SendPostSaveToXFADoc(pDoc);
-
for (int i = 0; i < fileList.GetSize(); i++) {
IFX_FileStream* pFile = (IFX_FileStream*)fileList.GetAt(i);
pFile->Release();
}
fileList.RemoveAll();
-
pStreamWrite->Release();
return bRet;
}
diff --git a/fpdfsdk/src/fpdftext.cpp b/fpdfsdk/src/fpdftext.cpp
index 7675dad..ac4e01e 100644
--- a/fpdfsdk/src/fpdftext.cpp
+++ b/fpdfsdk/src/fpdftext.cpp
@@ -10,22 +10,21 @@
#include "../include/fpdfxfa/fpdfxfa_page.h"
#include "core/include/fpdfdoc/fpdf_doc.h"
#include "core/include/fpdftext/fpdf_text.h"
+#include "fpdfsdk/include/fsdk_define.h"
#ifdef _WIN32
#include <tchar.h>
#endif
DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) {
- if (!page)
- return NULL;
- IPDF_TextPage* textpage = NULL;
+ CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page);
+ if (!pPDFPage)
+ return nullptr;
CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
- if (!pPage->GetPDFPage())
- return NULL;
CPDFXFA_Document* pDoc = pPage->GetDocument();
CPDF_ViewerPreferences viewRef(pDoc->GetPDFDoc());
- textpage = IPDF_TextPage::CreateTextPage((CPDF_Page*)pPage->GetPDFPage(),
- viewRef.IsDirectionR2L());
+ IPDF_TextPage* textpage =
+ IPDF_TextPage::CreateTextPage(pPDFPage, viewRef.IsDirectionR2L());
textpage->ParseTextPage();
return textpage;
}
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index adb14cd..2066631 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -214,9 +214,10 @@
CFX_GEModule::Get()->SetCodecModule(g_pCodecModule);
CPDF_ModuleMgr::Create();
- CPDF_ModuleMgr::Get()->SetCodecModule(g_pCodecModule);
- CPDF_ModuleMgr::Get()->InitPageModule();
- CPDF_ModuleMgr::Get()->InitRenderModule();
+ CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get();
+ pModuleMgr->SetCodecModule(g_pCodecModule);
+ pModuleMgr->InitPageModule();
+ pModuleMgr->InitRenderModule();
CPDFXFA_App::GetInstance()->Initialize();
if (cfg && cfg->version >= 2)
IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate);
@@ -439,6 +440,7 @@
UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document);
if (!pDoc)
return nullptr;
+
if (page_index < 0 || page_index >= pDoc->GetPageCount())
return nullptr;
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index 27cfe51..ed2ac1a 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -638,7 +638,6 @@
m_curMatrix = *pUser2Device;
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
CPDFXFA_Page* pPage = GetPDFXFAPage();
-
if (pPage == NULL)
return;
@@ -718,8 +717,9 @@
CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
CPDFSDK_AnnotIterator annotIterator(this, false);
while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
- if (pSDKAnnot->GetType() == "Widget" ||
- pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME) {
+ bool bHitTest = pSDKAnnot->GetType() == "Widget";
+ bHitTest = bHitTest || pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME;
+ if (bHitTest) {
pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
CPDF_Point point(pageX, pageY);
if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point))
@@ -815,7 +815,6 @@
if (m_page) {
return m_page->GetPDFPage();
}
-
return NULL;
}