diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-11-25 15:15:31 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-11-25 15:15:31 -0800 |
commit | 1b2462846b5deee5b142251cbe2bb7d7c07df41b (patch) | |
tree | 4338992c2fe5d005c0cbbd5d1a68b54eb3fe1709 /fpdfsdk | |
parent | 5c4c193fd4b6dd0657abf5e74125f9887f91d720 (diff) | |
download | pdfium-1b2462846b5deee5b142251cbe2bb7d7c07df41b.tar.xz |
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 .
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/include/jsapi/fxjs_v8.h | 1 | ||||
-rw-r--r-- | fpdfsdk/src/formfiller/FFL_FormFiller.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/src/formfiller/FFL_TextField.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfformfill.cpp | 10 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfsave.cpp | 14 | ||||
-rw-r--r-- | fpdfsdk/src/fpdftext.cpp | 13 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfview.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_mgr.cpp | 7 |
8 files changed, 30 insertions, 31 deletions
diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h index 8263cd4eeb..97f96f6c5f 100644 --- a/fpdfsdk/include/jsapi/fxjs_v8.h +++ b/fpdfsdk/include/jsapi/fxjs_v8.h @@ -135,7 +135,6 @@ void FXJS_InitializeRuntime( 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 048ebafa12..9817f05db3 100644 --- a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp +++ b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp @@ -243,7 +243,7 @@ FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, 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 @@ CPDF_Rect CFFL_FormFiller::GetPDFWindowRect() const { } 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 @@ void CFFL_FormFiller::InvalidateRect(double left, 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 253671d554..3c0cdeb1f2 100644 --- a/fpdfsdk/src/formfiller/FFL_TextField.cpp +++ b/fpdfsdk/src/formfiller/FFL_TextField.cpp @@ -119,7 +119,7 @@ FX_BOOL CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot, 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 5dcfb47890..0798c4e190 100644 --- a/fpdfsdk/src/fpdfformfill.cpp +++ b/fpdfsdk/src/fpdfformfill.cpp @@ -269,13 +269,17 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, int size_y, int rotate, int flags) { - if (!hHandle || !page) + if (!hHandle) + return; + + UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); + if (!pPage) return; - CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; CPDFXFA_Document* pDocument = pPage->GetDocument(); if (!pDocument) return; + CPDF_Document* pPDFDoc = pDocument->GetPDFDoc(); if (!pPDFDoc) return; @@ -321,7 +325,7 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, 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 882161c8fe..f643f704d7 100644 --- a/fpdfsdk/src/fpdfsave.cpp +++ b/fpdfsdk/src/fpdfsave.cpp @@ -284,16 +284,14 @@ FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document, FPDF_DWORD flags, FPDF_BOOL bSetVersion, int fileVerion) { - CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document; + CPDF_Document* pPDFDoc = CPDFDocumentFromFPDFDocument(document); + if (!pPDFDoc) + return 0; + CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document; CFX_PtrArray fileList; - _SendPreSaveToXFADoc(pDoc, fileList); - CPDF_Document* pPDFDoc = pDoc->GetPDFDoc(); - if (!pPDFDoc) - return 0; - if (flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY) { flags = 0; } @@ -305,20 +303,18 @@ FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document, 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 7675dada61..ac4e01e2bc 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 adb14cd3b9..2066631e3c 100644 --- a/fpdfsdk/src/fpdfview.cpp +++ b/fpdfsdk/src/fpdfview.cpp @@ -214,9 +214,10 @@ DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig( 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 @@ DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, 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 27cfe514c8..ed2ac1a971 100644 --- a/fpdfsdk/src/fsdk_mgr.cpp +++ b/fpdfsdk/src/fsdk_mgr.cpp @@ -638,7 +638,6 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, m_curMatrix = *pUser2Device; CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); CPDFXFA_Page* pPage = GetPDFXFAPage(); - if (pPage == NULL) return; @@ -718,8 +717,9 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, 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 @@ CPDF_Page* CPDFSDK_PageView::GetPDFPage() { if (m_page) { return m_page->GetPDFPage(); } - return NULL; } |