diff options
author | dsinclair <dsinclair@chromium.org> | 2016-09-13 12:03:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-13 12:03:48 -0700 |
commit | f34518bd1379289659b4c050d140690ba8f8b8aa (patch) | |
tree | 97f2d8a32f7c061c378dca668d4e066283407e91 | |
parent | 067990ccf96ae962392a2dbacbfd8348dc4c7676 (diff) | |
download | pdfium-f34518bd1379289659b4c050d140690ba8f8b8aa.tar.xz |
Split fsdk_mgr files apart.
This CL separates the CPDFDoc_Environment, CPDFSDK_Document and CPDFSDK_PageView
classes into their own h and cpp files.
Review-Url: https://codereview.chromium.org/2335243002
42 files changed, 796 insertions, 699 deletions
@@ -65,13 +65,16 @@ static_library("pdfium") { "fpdfsdk/cba_annotiterator.cpp", "fpdfsdk/cfx_systemhandler.cpp", "fpdfsdk/cfx_systemhandler.h", + "fpdfsdk/cpdfdoc_environment.cpp", "fpdfsdk/cpdfsdk_annot.cpp", "fpdfsdk/cpdfsdk_annothandlermgr.cpp", "fpdfsdk/cpdfsdk_annotiterator.cpp", "fpdfsdk/cpdfsdk_baannot.cpp", "fpdfsdk/cpdfsdk_baannothandler.cpp", "fpdfsdk/cpdfsdk_datetime.cpp", + "fpdfsdk/cpdfsdk_document.cpp", "fpdfsdk/cpdfsdk_interform.cpp", + "fpdfsdk/cpdfsdk_pageview.cpp", "fpdfsdk/cpdfsdk_widget.cpp", "fpdfsdk/cpdfsdk_widgethandler.cpp", "fpdfsdk/fpdf_dataavail.cpp", @@ -90,16 +93,18 @@ static_library("pdfium") { "fpdfsdk/fpdftext.cpp", "fpdfsdk/fpdfview.cpp", "fpdfsdk/fsdk_actionhandler.cpp", - "fpdfsdk/fsdk_mgr.cpp", "fpdfsdk/fsdk_pauseadapter.cpp", "fpdfsdk/include/cba_annotiterator.h", + "fpdfsdk/include/cpdfdoc_environment.h", "fpdfsdk/include/cpdfsdk_annot.h", "fpdfsdk/include/cpdfsdk_annothandlermgr.h", "fpdfsdk/include/cpdfsdk_annotiterator.h", "fpdfsdk/include/cpdfsdk_baannot.h", "fpdfsdk/include/cpdfsdk_baannothandler.h", "fpdfsdk/include/cpdfsdk_datetime.h", + "fpdfsdk/include/cpdfsdk_document.h", "fpdfsdk/include/cpdfsdk_interform.h", + "fpdfsdk/include/cpdfsdk_pageview.h", "fpdfsdk/include/cpdfsdk_widget.h", "fpdfsdk/include/cpdfsdk_widgethandler.h", "fpdfsdk/include/fsdk_actionhandler.h", diff --git a/fpdfsdk/cba_annotiterator.cpp b/fpdfsdk/cba_annotiterator.cpp index b99fabfabe..51ee54beca 100644 --- a/fpdfsdk/cba_annotiterator.cpp +++ b/fpdfsdk/cba_annotiterator.cpp @@ -8,7 +8,7 @@ #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "fpdfsdk/include/cpdfsdk_annot.h" -#include "fpdfsdk/include/fsdk_mgr.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" // static bool CBA_AnnotIterator::CompareByLeftAscending(const CPDFSDK_Annot* p1, diff --git a/fpdfsdk/cfx_systemhandler.cpp b/fpdfsdk/cfx_systemhandler.cpp index 996a17a6b7..25895655f6 100644 --- a/fpdfsdk/cfx_systemhandler.cpp +++ b/fpdfsdk/cfx_systemhandler.cpp @@ -8,11 +8,15 @@ #include <memory> +#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fxge/include/cfx_fontmapper.h" #include "core/fxge/include/cfx_fontmgr.h" #include "core/fxge/include/cfx_gemodule.h" #include "fpdfsdk/formfiller/cffl_formfiller.h" -#include "fpdfsdk/include/fsdk_mgr.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" +#include "fpdfsdk/include/cpdfsdk_annot.h" +#include "fpdfsdk/include/cpdfsdk_document.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" namespace { diff --git a/fpdfsdk/cpdfdoc_environment.cpp b/fpdfsdk/cpdfdoc_environment.cpp new file mode 100644 index 0000000000..ddc9917361 --- /dev/null +++ b/fpdfsdk/cpdfdoc_environment.cpp @@ -0,0 +1,214 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "fpdfsdk/include/cpdfdoc_environment.h" + +#include "fpdfsdk/formfiller/cffl_iformfiller.h" +#include "fpdfsdk/include/cpdfsdk_annothandlermgr.h" +#include "fpdfsdk/include/fsdk_actionhandler.h" +#include "fpdfsdk/javascript/ijs_runtime.h" + +#ifdef PDF_ENABLE_XFA +#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" +#endif // PDF_ENABLE_XFA + +namespace { + +// NOTE: |bsUTF16LE| must outlive the use of the result. Care must be taken +// since modifying the result would impact |bsUTF16LE|. +FPDF_WIDESTRING AsFPDFWideString(CFX_ByteString* bsUTF16LE) { + return reinterpret_cast<FPDF_WIDESTRING>( + bsUTF16LE->GetBuffer(bsUTF16LE->GetLength())); +} + +} // namespace + +CPDFDoc_Environment::CPDFDoc_Environment(UnderlyingDocumentType* pDoc, + FPDF_FORMFILLINFO* pFFinfo) + : m_pInfo(pFFinfo), m_pSDKDoc(nullptr), m_pUnderlyingDoc(pDoc) { + m_pSysHandler.reset(new CFX_SystemHandler(this)); +} + +CPDFDoc_Environment::~CPDFDoc_Environment() { +#ifdef PDF_ENABLE_XFA + CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); + if (pProvider->m_pEnvList.GetSize() == 0) + pProvider->SetJavaScriptInitialized(FALSE); +#endif // PDF_ENABLE_XFA + if (m_pInfo && m_pInfo->Release) + m_pInfo->Release(m_pInfo); +} + +int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg, + const FX_WCHAR* Title, + FX_UINT Type, + FX_UINT Icon) { + if (!m_pInfo || !m_pInfo->m_pJsPlatform || + !m_pInfo->m_pJsPlatform->app_alert) { + return -1; + } + CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); + CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); + return m_pInfo->m_pJsPlatform->app_alert( + m_pInfo->m_pJsPlatform, AsFPDFWideString(&bsMsg), + AsFPDFWideString(&bsTitle), Type, Icon); +} + +int CPDFDoc_Environment::JS_appResponse(const FX_WCHAR* Question, + const FX_WCHAR* Title, + const FX_WCHAR* Default, + const FX_WCHAR* cLabel, + FPDF_BOOL bPassword, + void* response, + int length) { + if (!m_pInfo || !m_pInfo->m_pJsPlatform || + !m_pInfo->m_pJsPlatform->app_response) { + return -1; + } + CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode(); + CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); + CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode(); + CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode(); + return m_pInfo->m_pJsPlatform->app_response( + m_pInfo->m_pJsPlatform, AsFPDFWideString(&bsQuestion), + AsFPDFWideString(&bsTitle), AsFPDFWideString(&bsDefault), + AsFPDFWideString(&bsLabel), bPassword, response, length); +} + +void CPDFDoc_Environment::JS_appBeep(int nType) { + if (!m_pInfo || !m_pInfo->m_pJsPlatform || + !m_pInfo->m_pJsPlatform->app_beep) { + return; + } + m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType); +} + +CFX_WideString CPDFDoc_Environment::JS_fieldBrowse() { + if (!m_pInfo || !m_pInfo->m_pJsPlatform || + !m_pInfo->m_pJsPlatform->Field_browse) { + return CFX_WideString(); + } + const int nRequiredLen = + m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, nullptr, 0); + if (nRequiredLen <= 0) + return CFX_WideString(); + + std::unique_ptr<char[]> pBuff(new char[nRequiredLen]); + memset(pBuff.get(), 0, nRequiredLen); + const int nActualLen = m_pInfo->m_pJsPlatform->Field_browse( + m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); + if (nActualLen <= 0 || nActualLen > nRequiredLen) + return CFX_WideString(); + + return CFX_WideString::FromLocal(CFX_ByteStringC(pBuff.get(), nActualLen)); +} + +CFX_WideString CPDFDoc_Environment::JS_docGetFilePath() { + if (!m_pInfo || !m_pInfo->m_pJsPlatform || + !m_pInfo->m_pJsPlatform->Doc_getFilePath) { + return CFX_WideString(); + } + const int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( + m_pInfo->m_pJsPlatform, nullptr, 0); + if (nRequiredLen <= 0) + return CFX_WideString(); + + std::unique_ptr<char[]> pBuff(new char[nRequiredLen]); + memset(pBuff.get(), 0, nRequiredLen); + const int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( + m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); + if (nActualLen <= 0 || nActualLen > nRequiredLen) + return CFX_WideString(); + + return CFX_WideString::FromLocal(CFX_ByteStringC(pBuff.get(), nActualLen)); +} + +void CPDFDoc_Environment::JS_docSubmitForm(void* formData, + int length, + const FX_WCHAR* URL) { + if (!m_pInfo || !m_pInfo->m_pJsPlatform || + !m_pInfo->m_pJsPlatform->Doc_submitForm) { + return; + } + CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode(); + m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, + length, + AsFPDFWideString(&bsDestination)); +} + +void CPDFDoc_Environment::JS_docmailForm(void* mailData, + int length, + FPDF_BOOL bUI, + const FX_WCHAR* To, + const FX_WCHAR* Subject, + const FX_WCHAR* CC, + const FX_WCHAR* BCC, + const FX_WCHAR* Msg) { + if (!m_pInfo || !m_pInfo->m_pJsPlatform || + !m_pInfo->m_pJsPlatform->Doc_mail) { + return; + } + CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode(); + CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode(); + CFX_ByteString bsCC = CFX_WideString(CC).UTF16LE_Encode(); + CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode(); + CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); + m_pInfo->m_pJsPlatform->Doc_mail( + m_pInfo->m_pJsPlatform, mailData, length, bUI, AsFPDFWideString(&bsTo), + AsFPDFWideString(&bsSubject), AsFPDFWideString(&bsCC), + AsFPDFWideString(&bsBcc), AsFPDFWideString(&bsMsg)); +} + +void CPDFDoc_Environment::JS_docprint(FPDF_BOOL bUI, + int nStart, + int nEnd, + FPDF_BOOL bSilent, + FPDF_BOOL bShrinkToFit, + FPDF_BOOL bPrintAsImage, + FPDF_BOOL bReverse, + FPDF_BOOL bAnnotations) { + if (!m_pInfo || !m_pInfo->m_pJsPlatform || + !m_pInfo->m_pJsPlatform->Doc_print) { + return; + } + m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, + bSilent, bShrinkToFit, bPrintAsImage, + bReverse, bAnnotations); +} + +void CPDFDoc_Environment::JS_docgotoPage(int nPageNum) { + if (!m_pInfo || !m_pInfo->m_pJsPlatform || + !m_pInfo->m_pJsPlatform->Doc_gotoPage) { + return; + } + m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum); +} + +IJS_Runtime* CPDFDoc_Environment::GetJSRuntime() { + if (!IsJSInitiated()) + return nullptr; + if (!m_pJSRuntime) + m_pJSRuntime.reset(IJS_Runtime::Create(this)); + return m_pJSRuntime.get(); +} + +CPDFSDK_AnnotHandlerMgr* CPDFDoc_Environment::GetAnnotHandlerMgr() { + if (!m_pAnnotHandlerMgr) + m_pAnnotHandlerMgr.reset(new CPDFSDK_AnnotHandlerMgr(this)); + return m_pAnnotHandlerMgr.get(); +} + +CPDFSDK_ActionHandler* CPDFDoc_Environment::GetActionHander() { + if (!m_pActionHandler) + m_pActionHandler.reset(new CPDFSDK_ActionHandler()); + return m_pActionHandler.get(); +} + +CFFL_IFormFiller* CPDFDoc_Environment::GetIFormFiller() { + if (!m_pIFormFiller) + m_pIFormFiller.reset(new CFFL_IFormFiller(this)); + return m_pIFormFiller.get(); +} diff --git a/fpdfsdk/cpdfsdk_annot.cpp b/fpdfsdk/cpdfsdk_annot.cpp index 738508f984..7752cf120f 100644 --- a/fpdfsdk/cpdfsdk_annot.cpp +++ b/fpdfsdk/cpdfsdk_annot.cpp @@ -8,7 +8,7 @@ #include <algorithm> -#include "fpdfsdk/include/fsdk_mgr.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" #include "third_party/base/stl_util.h" #ifdef PDF_ENABLE_XFA diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp index 0fd48d2aa0..8fa1093818 100644 --- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp +++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp @@ -8,12 +8,14 @@ #include "core/fpdfdoc/include/cpdf_annot.h" #include "fpdfsdk/include/cba_annotiterator.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/include/cpdfsdk_annot.h" #include "fpdfsdk/include/cpdfsdk_baannot.h" #include "fpdfsdk/include/cpdfsdk_baannothandler.h" #include "fpdfsdk/include/cpdfsdk_datetime.h" +#include "fpdfsdk/include/cpdfsdk_document.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" #include "fpdfsdk/include/cpdfsdk_widgethandler.h" -#include "fpdfsdk/include/fsdk_mgr.h" #ifdef PDF_ENABLE_XFA #include "fpdfsdk/include/cpdfsdk_xfawidgethandler.h" diff --git a/fpdfsdk/cpdfsdk_annotiterator.cpp b/fpdfsdk/cpdfsdk_annotiterator.cpp index 01a4e15379..0505ce0b6e 100644 --- a/fpdfsdk/cpdfsdk_annotiterator.cpp +++ b/fpdfsdk/cpdfsdk_annotiterator.cpp @@ -9,7 +9,7 @@ #include <algorithm> #include "fpdfsdk/include/cpdfsdk_annot.h" -#include "fpdfsdk/include/fsdk_mgr.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, bool bReverse) diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp index a2fd7c79bb..48daaf9d08 100644 --- a/fpdfsdk/cpdfsdk_baannot.cpp +++ b/fpdfsdk/cpdfsdk_baannot.cpp @@ -7,11 +7,13 @@ #include "fpdfsdk/include/cpdfsdk_baannot.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "fpdfsdk/include/cpdfsdk_datetime.h" -#include "fpdfsdk/include/fsdk_mgr.h" +#include "fpdfsdk/include/cpdfsdk_document.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView) diff --git a/fpdfsdk/cpdfsdk_baannothandler.cpp b/fpdfsdk/cpdfsdk_baannothandler.cpp index f0d67f4617..1422c75f49 100644 --- a/fpdfsdk/cpdfsdk_baannothandler.cpp +++ b/fpdfsdk/cpdfsdk_baannothandler.cpp @@ -15,7 +15,7 @@ #include "fpdfsdk/formfiller/cffl_formfiller.h" #include "fpdfsdk/include/cpdfsdk_annot.h" #include "fpdfsdk/include/cpdfsdk_baannot.h" -#include "fpdfsdk/include/fsdk_mgr.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" #ifdef PDF_ENABLE_XFA #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" diff --git a/fpdfsdk/cpdfsdk_document.cpp b/fpdfsdk/cpdfsdk_document.cpp new file mode 100644 index 0000000000..232adbaba5 --- /dev/null +++ b/fpdfsdk/cpdfsdk_document.cpp @@ -0,0 +1,261 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "fpdfsdk/include/cpdfsdk_document.h" + +#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" +#include "core/fpdfdoc/include/cpdf_action.h" +#include "core/fpdfdoc/include/cpdf_docjsactions.h" +#include "core/fpdfdoc/include/cpdf_occontext.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" +#include "fpdfsdk/include/cpdfsdk_annot.h" +#include "fpdfsdk/include/cpdfsdk_annothandlermgr.h" +#include "fpdfsdk/include/cpdfsdk_interform.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" +#include "fpdfsdk/include/cpdfsdk_widget.h" +#include "fpdfsdk/include/fsdk_actionhandler.h" + +// static +CPDFSDK_Document* CPDFSDK_Document::FromFPDFFormHandle( + FPDF_FORMHANDLE hHandle) { + CPDFDoc_Environment* pEnv = static_cast<CPDFDoc_Environment*>(hHandle); + return pEnv ? pEnv->GetSDKDocument() : nullptr; +} + +CPDFSDK_Document::CPDFSDK_Document(UnderlyingDocumentType* pDoc, + CPDFDoc_Environment* pEnv) + : m_pDoc(pDoc), + m_pFocusAnnot(nullptr), + m_pEnv(pEnv), + m_bChangeMask(FALSE), + m_bBeingDestroyed(FALSE) {} + +CPDFSDK_Document::~CPDFSDK_Document() { + m_bBeingDestroyed = TRUE; + + for (auto& it : m_pageMap) + it.second->KillFocusAnnotIfNeeded(); + + for (auto& it : m_pageMap) + delete it.second; + m_pageMap.clear(); +} + +CPDFSDK_PageView* CPDFSDK_Document::GetPageView( + UnderlyingPageType* pUnderlyingPage, + bool ReNew) { + auto it = m_pageMap.find(pUnderlyingPage); + if (it != m_pageMap.end()) + return it->second; + + if (!ReNew) + return nullptr; + + CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pUnderlyingPage); + m_pageMap[pUnderlyingPage] = pPageView; + // Delay to load all the annotations, to avoid endless loop. + pPageView->LoadFXAnnots(); + return pPageView; +} + +CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView() { + UnderlyingPageType* pPage = + UnderlyingFromFPDFPage(m_pEnv->FFI_GetCurrentPage(m_pDoc)); + return pPage ? GetPageView(pPage, true) : nullptr; +} + +CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) { + UnderlyingPageType* pTempPage = + UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); + if (!pTempPage) + return nullptr; + + auto it = m_pageMap.find(pTempPage); + return it != m_pageMap.end() ? it->second : nullptr; +} + +void CPDFSDK_Document::ProcJavascriptFun() { + CPDF_Document* pPDFDoc = GetPDFDocument(); + CPDF_DocJSActions docJS(pPDFDoc); + int iCount = docJS.CountJSActions(); + if (iCount < 1) + return; + for (int i = 0; i < iCount; i++) { + CFX_ByteString csJSName; + CPDF_Action jsAction = docJS.GetJSAction(i, csJSName); + if (m_pEnv->GetActionHander()) + m_pEnv->GetActionHander()->DoAction_JavaScript( + jsAction, CFX_WideString::FromLocal(csJSName.AsStringC()), this); + } +} + +FX_BOOL CPDFSDK_Document::ProcOpenAction() { + if (!m_pDoc) + return FALSE; + + CPDF_Dictionary* pRoot = GetPDFDocument()->GetRoot(); + if (!pRoot) + return FALSE; + + CPDF_Object* pOpenAction = pRoot->GetDictBy("OpenAction"); + if (!pOpenAction) + pOpenAction = pRoot->GetArrayBy("OpenAction"); + + if (!pOpenAction) + return FALSE; + + if (pOpenAction->IsArray()) + return TRUE; + + if (CPDF_Dictionary* pDict = pOpenAction->AsDictionary()) { + CPDF_Action action(pDict); + if (m_pEnv->GetActionHander()) + m_pEnv->GetActionHander()->DoAction_DocOpen(action, this); + return TRUE; + } + return FALSE; +} + +CPDF_OCContext* CPDFSDK_Document::GetOCContext() { + if (!m_pOccontent) { + m_pOccontent.reset( + new CPDF_OCContext(GetPDFDocument(), CPDF_OCContext::View)); + } + return m_pOccontent.get(); +} + +void CPDFSDK_Document::RemovePageView(UnderlyingPageType* pUnderlyingPage) { + auto it = m_pageMap.find(pUnderlyingPage); + if (it == m_pageMap.end()) + return; + + CPDFSDK_PageView* pPageView = it->second; + if (pPageView->IsLocked()) + return; + + // This must happen before we remove |pPageView| from the map because + // |KillFocusAnnotIfNeeded| can call into the |GetPage| method which will + // look for this page view in the map, if it doesn't find it a new one will + // be created. We then have two page views pointing to the same page and + // bad things happen. + pPageView->KillFocusAnnotIfNeeded(); + + // Remove the page from the map to make sure we don't accidentally attempt + // to use the |pPageView| while we're cleaning it up. + m_pageMap.erase(it); + + delete pPageView; +} + +UnderlyingPageType* CPDFSDK_Document::GetPage(int nIndex) { + return UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); +} + +CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm() { + if (!m_pInterForm) + m_pInterForm.reset(new CPDFSDK_InterForm(this)); + return m_pInterForm.get(); +} + +void CPDFSDK_Document::UpdateAllViews(CPDFSDK_PageView* pSender, + CPDFSDK_Annot* pAnnot) { + for (const auto& it : m_pageMap) { + CPDFSDK_PageView* pPageView = it.second; + if (pPageView != pSender) { + pPageView->UpdateView(pAnnot); + } + } +} + +CPDFSDK_Annot* CPDFSDK_Document::GetFocusAnnot() { + return m_pFocusAnnot; +} + +FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { + if (m_bBeingDestroyed) + return FALSE; + + if (m_pFocusAnnot == pAnnot) + return TRUE; + + if (m_pFocusAnnot) { + if (!KillFocusAnnot(nFlag)) + return FALSE; + } + + if (!pAnnot) + return FALSE; + +#ifdef PDF_ENABLE_XFA + CPDFSDK_Annot* pLastFocusAnnot = m_pFocusAnnot; +#endif // PDF_ENABLE_XFA + CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); + if (pPageView && pPageView->IsValid()) { + CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); + if (!m_pFocusAnnot) { +#ifdef PDF_ENABLE_XFA + if (!pAnnotHandler->Annot_OnChangeFocus(pAnnot, pLastFocusAnnot)) + return FALSE; +#endif // PDF_ENABLE_XFA + if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, nFlag)) + return FALSE; + if (!m_pFocusAnnot) { + m_pFocusAnnot = pAnnot; + return TRUE; + } + } + } + return FALSE; +} + +FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) { + if (m_pFocusAnnot) { + CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); + CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; + m_pFocusAnnot = nullptr; + +#ifdef PDF_ENABLE_XFA + if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot)) + return FALSE; +#endif // PDF_ENABLE_XFA + + if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { + if (pFocusAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET) { + CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; + int nFieldType = pWidget->GetFieldType(); + if (FIELDTYPE_TEXTFIELD == nFieldType || + FIELDTYPE_COMBOBOX == nFieldType) { + m_pEnv->FFI_OnSetFieldInputFocus(nullptr, nullptr, 0, FALSE); + } + } + + if (!m_pFocusAnnot) + return TRUE; + } else { + m_pFocusAnnot = pFocusAnnot; + } + } + return FALSE; +} + +void CPDFSDK_Document::OnCloseDocument() { + KillFocusAnnot(); +} + +FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag) { + return GetPDFDocument()->GetUserPermissions() & nFlag; +} + +IJS_Runtime* CPDFSDK_Document::GetJsRuntime() { + return m_pEnv->GetJSRuntime(); +} + +CFX_WideString CPDFSDK_Document::GetPath() { + return m_pEnv->JS_docGetFilePath(); +} diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index 1f182d4a0c..f762b89d81 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -22,11 +22,13 @@ #include "fpdfsdk/formfiller/cffl_formfiller.h" #include "fpdfsdk/fxedit/include/fxet_edit.h" #include "fpdfsdk/include/cba_annotiterator.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/include/cpdfsdk_annot.h" +#include "fpdfsdk/include/cpdfsdk_document.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" #include "fpdfsdk/include/cpdfsdk_widget.h" #include "fpdfsdk/include/fsdk_actionhandler.h" #include "fpdfsdk/include/fsdk_define.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/include/ipdfsdk_annothandler.h" #include "fpdfsdk/javascript/ijs_context.h" #include "fpdfsdk/javascript/ijs_runtime.h" diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/cpdfsdk_pageview.cpp index c8f387e903..ae0d3fa7df 100644 --- a/fpdfsdk/fsdk_mgr.cpp +++ b/fpdfsdk/cpdfsdk_pageview.cpp @@ -1,38 +1,23 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2016 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/include/fsdk_mgr.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" -#include <algorithm> -#include <memory> - -#include "core/fpdfapi/fpdf_page/include/cpdf_page.h" -#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" -#include "core/fpdfdoc/include/cpdf_docjsactions.h" +#include "core/fpdfdoc/include/cpdf_annotlist.h" #include "core/fpdfdoc/include/cpdf_interform.h" -#include "core/fxcrt/include/cfx_retain_ptr.h" -#include "core/fxge/include/cfx_renderdevice.h" -#include "fpdfsdk/formfiller/cffl_formfiller.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" +#include "fpdfsdk/include/cpdfsdk_annot.h" #include "fpdfsdk/include/cpdfsdk_annothandlermgr.h" #include "fpdfsdk/include/cpdfsdk_annotiterator.h" #include "fpdfsdk/include/cpdfsdk_interform.h" -#include "fpdfsdk/include/cpdfsdk_widget.h" -#include "fpdfsdk/include/fsdk_define.h" -#include "fpdfsdk/include/ipdfsdk_annothandler.h" -#include "fpdfsdk/javascript/ijs_runtime.h" -#include "public/fpdf_ext.h" -#include "third_party/base/stl_util.h" #ifdef PDF_ENABLE_XFA -#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" -#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" -#include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" #include "xfa/fxfa/include/xfa_ffdocview.h" #include "xfa/fxfa/include/xfa_ffpageview.h" #include "xfa/fxfa/include/xfa_ffwidgethandler.h" @@ -40,449 +25,6 @@ #include "xfa/fxgraphics/include/cfx_graphics.h" #endif // PDF_ENABLE_XFA -#if _FX_OS_ == _FX_ANDROID_ -#include "time.h" -#else -#include <ctime> -#endif - -namespace { - -// NOTE: |bsUTF16LE| must outlive the use of the result. Care must be taken -// since modifying the result would impact |bsUTF16LE|. -FPDF_WIDESTRING AsFPDFWideString(CFX_ByteString* bsUTF16LE) { - return reinterpret_cast<FPDF_WIDESTRING>( - bsUTF16LE->GetBuffer(bsUTF16LE->GetLength())); -} - -} // namespace - -CPDFDoc_Environment::CPDFDoc_Environment(UnderlyingDocumentType* pDoc, - FPDF_FORMFILLINFO* pFFinfo) - : m_pInfo(pFFinfo), m_pSDKDoc(nullptr), m_pUnderlyingDoc(pDoc) { - m_pSysHandler.reset(new CFX_SystemHandler(this)); -} - -CPDFDoc_Environment::~CPDFDoc_Environment() { -#ifdef PDF_ENABLE_XFA - CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); - if (pProvider->m_pEnvList.GetSize() == 0) - pProvider->SetJavaScriptInitialized(FALSE); -#endif // PDF_ENABLE_XFA - if (m_pInfo && m_pInfo->Release) - m_pInfo->Release(m_pInfo); -} - -int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg, - const FX_WCHAR* Title, - FX_UINT Type, - FX_UINT Icon) { - if (!m_pInfo || !m_pInfo->m_pJsPlatform || - !m_pInfo->m_pJsPlatform->app_alert) { - return -1; - } - CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); - CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); - return m_pInfo->m_pJsPlatform->app_alert( - m_pInfo->m_pJsPlatform, AsFPDFWideString(&bsMsg), - AsFPDFWideString(&bsTitle), Type, Icon); -} - -int CPDFDoc_Environment::JS_appResponse(const FX_WCHAR* Question, - const FX_WCHAR* Title, - const FX_WCHAR* Default, - const FX_WCHAR* cLabel, - FPDF_BOOL bPassword, - void* response, - int length) { - if (!m_pInfo || !m_pInfo->m_pJsPlatform || - !m_pInfo->m_pJsPlatform->app_response) { - return -1; - } - CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode(); - CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); - CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode(); - CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode(); - return m_pInfo->m_pJsPlatform->app_response( - m_pInfo->m_pJsPlatform, AsFPDFWideString(&bsQuestion), - AsFPDFWideString(&bsTitle), AsFPDFWideString(&bsDefault), - AsFPDFWideString(&bsLabel), bPassword, response, length); -} - -void CPDFDoc_Environment::JS_appBeep(int nType) { - if (!m_pInfo || !m_pInfo->m_pJsPlatform || - !m_pInfo->m_pJsPlatform->app_beep) { - return; - } - m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType); -} - -CFX_WideString CPDFDoc_Environment::JS_fieldBrowse() { - if (!m_pInfo || !m_pInfo->m_pJsPlatform || - !m_pInfo->m_pJsPlatform->Field_browse) { - return CFX_WideString(); - } - const int nRequiredLen = - m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, nullptr, 0); - if (nRequiredLen <= 0) - return CFX_WideString(); - - std::unique_ptr<char[]> pBuff(new char[nRequiredLen]); - memset(pBuff.get(), 0, nRequiredLen); - const int nActualLen = m_pInfo->m_pJsPlatform->Field_browse( - m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); - if (nActualLen <= 0 || nActualLen > nRequiredLen) - return CFX_WideString(); - - return CFX_WideString::FromLocal(CFX_ByteStringC(pBuff.get(), nActualLen)); -} - -CFX_WideString CPDFDoc_Environment::JS_docGetFilePath() { - if (!m_pInfo || !m_pInfo->m_pJsPlatform || - !m_pInfo->m_pJsPlatform->Doc_getFilePath) { - return CFX_WideString(); - } - const int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( - m_pInfo->m_pJsPlatform, nullptr, 0); - if (nRequiredLen <= 0) - return CFX_WideString(); - - std::unique_ptr<char[]> pBuff(new char[nRequiredLen]); - memset(pBuff.get(), 0, nRequiredLen); - const int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( - m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); - if (nActualLen <= 0 || nActualLen > nRequiredLen) - return CFX_WideString(); - - return CFX_WideString::FromLocal(CFX_ByteStringC(pBuff.get(), nActualLen)); -} - -void CPDFDoc_Environment::JS_docSubmitForm(void* formData, - int length, - const FX_WCHAR* URL) { - if (!m_pInfo || !m_pInfo->m_pJsPlatform || - !m_pInfo->m_pJsPlatform->Doc_submitForm) { - return; - } - CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode(); - m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, - length, - AsFPDFWideString(&bsDestination)); -} - -void CPDFDoc_Environment::JS_docmailForm(void* mailData, - int length, - FPDF_BOOL bUI, - const FX_WCHAR* To, - const FX_WCHAR* Subject, - const FX_WCHAR* CC, - const FX_WCHAR* BCC, - const FX_WCHAR* Msg) { - if (!m_pInfo || !m_pInfo->m_pJsPlatform || - !m_pInfo->m_pJsPlatform->Doc_mail) { - return; - } - CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode(); - CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode(); - CFX_ByteString bsCC = CFX_WideString(CC).UTF16LE_Encode(); - CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode(); - CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); - m_pInfo->m_pJsPlatform->Doc_mail( - m_pInfo->m_pJsPlatform, mailData, length, bUI, AsFPDFWideString(&bsTo), - AsFPDFWideString(&bsSubject), AsFPDFWideString(&bsCC), - AsFPDFWideString(&bsBcc), AsFPDFWideString(&bsMsg)); -} - -void CPDFDoc_Environment::JS_docprint(FPDF_BOOL bUI, - int nStart, - int nEnd, - FPDF_BOOL bSilent, - FPDF_BOOL bShrinkToFit, - FPDF_BOOL bPrintAsImage, - FPDF_BOOL bReverse, - FPDF_BOOL bAnnotations) { - if (!m_pInfo || !m_pInfo->m_pJsPlatform || - !m_pInfo->m_pJsPlatform->Doc_print) { - return; - } - m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, - bSilent, bShrinkToFit, bPrintAsImage, - bReverse, bAnnotations); -} - -void CPDFDoc_Environment::JS_docgotoPage(int nPageNum) { - if (!m_pInfo || !m_pInfo->m_pJsPlatform || - !m_pInfo->m_pJsPlatform->Doc_gotoPage) { - return; - } - m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum); -} - -IJS_Runtime* CPDFDoc_Environment::GetJSRuntime() { - if (!IsJSInitiated()) - return nullptr; - if (!m_pJSRuntime) - m_pJSRuntime.reset(IJS_Runtime::Create(this)); - return m_pJSRuntime.get(); -} - -CPDFSDK_AnnotHandlerMgr* CPDFDoc_Environment::GetAnnotHandlerMgr() { - if (!m_pAnnotHandlerMgr) - m_pAnnotHandlerMgr.reset(new CPDFSDK_AnnotHandlerMgr(this)); - return m_pAnnotHandlerMgr.get(); -} - -CPDFSDK_ActionHandler* CPDFDoc_Environment::GetActionHander() { - if (!m_pActionHandler) - m_pActionHandler.reset(new CPDFSDK_ActionHandler()); - return m_pActionHandler.get(); -} - -CFFL_IFormFiller* CPDFDoc_Environment::GetIFormFiller() { - if (!m_pIFormFiller) - m_pIFormFiller.reset(new CFFL_IFormFiller(this)); - return m_pIFormFiller.get(); -} - -// static -CPDFSDK_Document* CPDFSDK_Document::FromFPDFFormHandle( - FPDF_FORMHANDLE hHandle) { - CPDFDoc_Environment* pEnv = static_cast<CPDFDoc_Environment*>(hHandle); - return pEnv ? pEnv->GetSDKDocument() : nullptr; -} - -CPDFSDK_Document::CPDFSDK_Document(UnderlyingDocumentType* pDoc, - CPDFDoc_Environment* pEnv) - : m_pDoc(pDoc), - m_pFocusAnnot(nullptr), - m_pEnv(pEnv), - m_bChangeMask(FALSE), - m_bBeingDestroyed(FALSE) {} - -CPDFSDK_Document::~CPDFSDK_Document() { - m_bBeingDestroyed = TRUE; - - for (auto& it : m_pageMap) - it.second->KillFocusAnnotIfNeeded(); - - for (auto& it : m_pageMap) - delete it.second; - m_pageMap.clear(); -} - -CPDFSDK_PageView* CPDFSDK_Document::GetPageView( - UnderlyingPageType* pUnderlyingPage, - bool ReNew) { - auto it = m_pageMap.find(pUnderlyingPage); - if (it != m_pageMap.end()) - return it->second; - - if (!ReNew) - return nullptr; - - CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pUnderlyingPage); - m_pageMap[pUnderlyingPage] = pPageView; - // Delay to load all the annotations, to avoid endless loop. - pPageView->LoadFXAnnots(); - return pPageView; -} - -CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView() { - UnderlyingPageType* pPage = - UnderlyingFromFPDFPage(m_pEnv->FFI_GetCurrentPage(m_pDoc)); - return pPage ? GetPageView(pPage, true) : nullptr; -} - -CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) { - UnderlyingPageType* pTempPage = - UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); - if (!pTempPage) - return nullptr; - - auto it = m_pageMap.find(pTempPage); - return it != m_pageMap.end() ? it->second : nullptr; -} - -void CPDFSDK_Document::ProcJavascriptFun() { - CPDF_Document* pPDFDoc = GetPDFDocument(); - CPDF_DocJSActions docJS(pPDFDoc); - int iCount = docJS.CountJSActions(); - if (iCount < 1) - return; - for (int i = 0; i < iCount; i++) { - CFX_ByteString csJSName; - CPDF_Action jsAction = docJS.GetJSAction(i, csJSName); - if (m_pEnv->GetActionHander()) - m_pEnv->GetActionHander()->DoAction_JavaScript( - jsAction, CFX_WideString::FromLocal(csJSName.AsStringC()), this); - } -} - -FX_BOOL CPDFSDK_Document::ProcOpenAction() { - if (!m_pDoc) - return FALSE; - - CPDF_Dictionary* pRoot = GetPDFDocument()->GetRoot(); - if (!pRoot) - return FALSE; - - CPDF_Object* pOpenAction = pRoot->GetDictBy("OpenAction"); - if (!pOpenAction) - pOpenAction = pRoot->GetArrayBy("OpenAction"); - - if (!pOpenAction) - return FALSE; - - if (pOpenAction->IsArray()) - return TRUE; - - if (CPDF_Dictionary* pDict = pOpenAction->AsDictionary()) { - CPDF_Action action(pDict); - if (m_pEnv->GetActionHander()) - m_pEnv->GetActionHander()->DoAction_DocOpen(action, this); - return TRUE; - } - return FALSE; -} - -CPDF_OCContext* CPDFSDK_Document::GetOCContext() { - if (!m_pOccontent) { - m_pOccontent.reset( - new CPDF_OCContext(GetPDFDocument(), CPDF_OCContext::View)); - } - return m_pOccontent.get(); -} - -void CPDFSDK_Document::RemovePageView(UnderlyingPageType* pUnderlyingPage) { - auto it = m_pageMap.find(pUnderlyingPage); - if (it == m_pageMap.end()) - return; - - CPDFSDK_PageView* pPageView = it->second; - if (pPageView->IsLocked()) - return; - - // This must happen before we remove |pPageView| from the map because - // |KillFocusAnnotIfNeeded| can call into the |GetPage| method which will - // look for this page view in the map, if it doesn't find it a new one will - // be created. We then have two page views pointing to the same page and - // bad things happen. - pPageView->KillFocusAnnotIfNeeded(); - - // Remove the page from the map to make sure we don't accidentally attempt - // to use the |pPageView| while we're cleaning it up. - m_pageMap.erase(it); - - delete pPageView; -} - -UnderlyingPageType* CPDFSDK_Document::GetPage(int nIndex) { - return UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); -} - -CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm() { - if (!m_pInterForm) - m_pInterForm.reset(new CPDFSDK_InterForm(this)); - return m_pInterForm.get(); -} - -void CPDFSDK_Document::UpdateAllViews(CPDFSDK_PageView* pSender, - CPDFSDK_Annot* pAnnot) { - for (const auto& it : m_pageMap) { - CPDFSDK_PageView* pPageView = it.second; - if (pPageView != pSender) { - pPageView->UpdateView(pAnnot); - } - } -} - -CPDFSDK_Annot* CPDFSDK_Document::GetFocusAnnot() { - return m_pFocusAnnot; -} - -FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { - if (m_bBeingDestroyed) - return FALSE; - - if (m_pFocusAnnot == pAnnot) - return TRUE; - - if (m_pFocusAnnot) { - if (!KillFocusAnnot(nFlag)) - return FALSE; - } - - if (!pAnnot) - return FALSE; - -#ifdef PDF_ENABLE_XFA - CPDFSDK_Annot* pLastFocusAnnot = m_pFocusAnnot; -#endif // PDF_ENABLE_XFA - CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); - if (pPageView && pPageView->IsValid()) { - CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); - if (!m_pFocusAnnot) { -#ifdef PDF_ENABLE_XFA - if (!pAnnotHandler->Annot_OnChangeFocus(pAnnot, pLastFocusAnnot)) - return FALSE; -#endif // PDF_ENABLE_XFA - if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, nFlag)) - return FALSE; - if (!m_pFocusAnnot) { - m_pFocusAnnot = pAnnot; - return TRUE; - } - } - } - return FALSE; -} - -FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) { - if (m_pFocusAnnot) { - CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); - CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; - m_pFocusAnnot = nullptr; - -#ifdef PDF_ENABLE_XFA - if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot)) - return FALSE; -#endif // PDF_ENABLE_XFA - - if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { - if (pFocusAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET) { - CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; - int nFieldType = pWidget->GetFieldType(); - if (FIELDTYPE_TEXTFIELD == nFieldType || - FIELDTYPE_COMBOBOX == nFieldType) { - m_pEnv->FFI_OnSetFieldInputFocus(nullptr, nullptr, 0, FALSE); - } - } - - if (!m_pFocusAnnot) - return TRUE; - } else { - m_pFocusAnnot = pFocusAnnot; - } - } - return FALSE; -} - -void CPDFSDK_Document::OnCloseDocument() { - KillFocusAnnot(); -} - -FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag) { - return GetPDFDocument()->GetUserPermissions() & nFlag; -} - -IJS_Runtime* CPDFSDK_Document::GetJsRuntime() { - return m_pEnv->GetJSRuntime(); -} - -CFX_WideString CPDFSDK_Document::GetPath() { - return m_pEnv->JS_docGetFilePath(); -} - CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page) : m_page(page), diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index 016e78a848..11e9883272 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -21,9 +21,12 @@ #include "core/fxge/include/cfx_renderdevice.h" #include "fpdfsdk/formfiller/cba_fontmap.h" #include "fpdfsdk/fxedit/include/fxet_edit.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/include/cpdfsdk_interform.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" +#include "fpdfsdk/include/fsdk_actionhandler.h" #include "fpdfsdk/include/fsdk_define.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/pdfwindow/PWL_Edit.h" #include "fpdfsdk/pdfwindow/PWL_Utils.h" diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp index 8a061e5541..965a26ceb0 100644 --- a/fpdfsdk/cpdfsdk_widgethandler.cpp +++ b/fpdfsdk/cpdfsdk_widgethandler.cpp @@ -13,10 +13,12 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfdoc/include/cpdf_interform.h" #include "fpdfsdk/formfiller/cffl_formfiller.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/include/cpdfsdk_annot.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/include/cpdfsdk_interform.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" #include "fpdfsdk/include/cpdfsdk_widget.h" -#include "fpdfsdk/include/fsdk_mgr.h" #ifdef PDF_ENABLE_XFA #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" diff --git a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp index 8621f77dbd..0765011c4d 100644 --- a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp +++ b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp @@ -8,10 +8,12 @@ #include "core/fpdfdoc/include/cpdf_interform.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/include/cpdfsdk_annot.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/include/cpdfsdk_interform.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" #include "fpdfsdk/include/cpdfsdk_xfawidget.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "xfa/fxfa/include/fxfa_basic.h" #include "xfa/fxfa/include/xfa_ffdocview.h" #include "xfa/fxfa/include/xfa_ffpageview.h" diff --git a/fpdfsdk/formfiller/cffl_checkbox.cpp b/fpdfsdk/formfiller/cffl_checkbox.cpp index ed81f37bb6..3455cded60 100644 --- a/fpdfsdk/formfiller/cffl_checkbox.cpp +++ b/fpdfsdk/formfiller/cffl_checkbox.cpp @@ -7,8 +7,8 @@ #include "fpdfsdk/formfiller/cffl_checkbox.h" #include "fpdfsdk/formfiller/cffl_formfiller.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/include/cpdfsdk_widget.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/pdfwindow/PWL_SpecialButton.h" #include "public/fpdf_fwlevent.h" diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp index fc590fd940..3eea1e4fcc 100644 --- a/fpdfsdk/formfiller/cffl_combobox.cpp +++ b/fpdfsdk/formfiller/cffl_combobox.cpp @@ -9,9 +9,9 @@ #include "fpdfsdk/formfiller/cba_fontmap.h" #include "fpdfsdk/formfiller/cffl_formfiller.h" #include "fpdfsdk/formfiller/cffl_iformfiller.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/include/cpdfsdk_widget.h" #include "fpdfsdk/include/fsdk_common.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/pdfwindow/PWL_ComboBox.h" CFFL_ComboBox::CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index f97df0a2b3..4b33c38b52 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -8,10 +8,12 @@ #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fxge/include/cfx_renderdevice.h" -#include "fpdfsdk/include/cpdfsdk_widget.h" #include "fpdfsdk/formfiller/cba_fontmap.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" +#include "fpdfsdk/include/cpdfsdk_document.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" +#include "fpdfsdk/include/cpdfsdk_widget.h" #include "fpdfsdk/include/fsdk_common.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/pdfwindow/PWL_Utils.h" #define GetRed(rgb) ((uint8_t)(rgb)) diff --git a/fpdfsdk/formfiller/cffl_iformfiller.cpp b/fpdfsdk/formfiller/cffl_iformfiller.cpp index 24a6122f62..d7ccaf217a 100644 --- a/fpdfsdk/formfiller/cffl_iformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_iformfiller.cpp @@ -18,9 +18,11 @@ #include "fpdfsdk/formfiller/cffl_pushbutton.h" #include "fpdfsdk/formfiller/cffl_radiobutton.h" #include "fpdfsdk/formfiller/cffl_textfield.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/include/cpdfsdk_interform.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" #include "fpdfsdk/include/cpdfsdk_widget.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/pdfwindow/PWL_Utils.h" #define FFL_MAXLISTBOXHEIGHT 140.0f diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp index 860fd07a75..39b766a62c 100644 --- a/fpdfsdk/formfiller/cffl_listbox.cpp +++ b/fpdfsdk/formfiller/cffl_listbox.cpp @@ -9,9 +9,9 @@ #include "fpdfsdk/formfiller/cba_fontmap.h" #include "fpdfsdk/formfiller/cffl_formfiller.h" #include "fpdfsdk/formfiller/cffl_iformfiller.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/include/cpdfsdk_widget.h" #include "fpdfsdk/include/fsdk_common.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/pdfwindow/PWL_ListBox.h" #define FFL_DEFAULTLISTBOXFONTSIZE 12.0f diff --git a/fpdfsdk/formfiller/cffl_radiobutton.cpp b/fpdfsdk/formfiller/cffl_radiobutton.cpp index d5474f99db..752baadf5e 100644 --- a/fpdfsdk/formfiller/cffl_radiobutton.cpp +++ b/fpdfsdk/formfiller/cffl_radiobutton.cpp @@ -7,9 +7,10 @@ #include "fpdfsdk/formfiller/cffl_radiobutton.h" #include "fpdfsdk/formfiller/cffl_formfiller.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/include/cpdfsdk_widget.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/pdfwindow/PWL_SpecialButton.h" +#include "public/fpdf_fwlevent.h" CFFL_RadioButton::CFFL_RadioButton(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp index 369bb4d209..15bfbc841c 100644 --- a/fpdfsdk/formfiller/cffl_textfield.cpp +++ b/fpdfsdk/formfiller/cffl_textfield.cpp @@ -7,9 +7,9 @@ #include "fpdfsdk/formfiller/cffl_textfield.h" #include "fpdfsdk/formfiller/cba_fontmap.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/include/cpdfsdk_widget.h" #include "fpdfsdk/include/fsdk_common.h" -#include "fpdfsdk/include/fsdk_mgr.h" CFFL_TextField::CFFL_TextField(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot) : CFFL_FormFiller(pApp, pAnnot) {} diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index 2ac6c60999..86585842e1 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -15,10 +15,14 @@ #include "core/fpdfdoc/include/cpdf_formcontrol.h" #include "core/fpdfdoc/include/cpdf_formfield.h" #include "core/fpdfdoc/include/cpdf_interform.h" +#include "core/fpdfdoc/include/cpdf_occontext.h" #include "core/fxge/include/cfx_fxgedevice.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/include/cpdfsdk_interform.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" +#include "fpdfsdk/include/fsdk_actionhandler.h" #include "fpdfsdk/include/fsdk_define.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "public/fpdfview.h" #include "third_party/base/stl_util.h" diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 4e20751f5d..76540fc283 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -18,14 +18,15 @@ #include "core/fpdfapi/include/cpdf_pagerendercontext.h" #include "core/fpdfdoc/include/cpdf_annotlist.h" #include "core/fpdfdoc/include/cpdf_nametree.h" +#include "core/fpdfdoc/include/cpdf_occontext.h" #include "core/fpdfdoc/include/cpdf_viewerpreferences.h" #include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_memory.h" #include "core/fxcrt/include/fx_safe_types.h" #include "core/fxge/include/cfx_fxgedevice.h" #include "core/fxge/include/cfx_gemodule.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" #include "fpdfsdk/include/fsdk_define.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/include/fsdk_pauseadapter.h" #include "fpdfsdk/javascript/ijs_runtime.h" #include "public/fpdf_ext.h" diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp index b829246908..9f89a144cf 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp @@ -7,8 +7,8 @@ #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/include/fsdk_define.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "xfa/fxbarcode/include/BC_Library.h" #include "xfa/fxfa/include/xfa_ffapp.h" #include "xfa/fxfa/include/xfa_fontmgr.h" diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp index d4c43c5706..63f4bb9faf 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp @@ -13,9 +13,11 @@ #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" -#include "fpdfsdk/include/fsdk_define.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/include/cpdfsdk_interform.h" -#include "fpdfsdk/include/fsdk_mgr.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" +#include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/javascript/ijs_runtime.h" #include "public/fpdf_formfill.h" #include "xfa/fxfa/include/cxfa_eventparam.h" diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp index 8c4301f248..451175a9a4 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp @@ -6,11 +6,12 @@ #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" +#include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" #include "fpdfsdk/include/fsdk_define.h" -#include "fpdfsdk/include/fsdk_mgr.h" +#include "public/fpdf_formfill.h" #include "xfa/fxfa/include/xfa_ffdocview.h" #include "xfa/fxfa/include/xfa_ffpageview.h" diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp index 9971f5d165..b3a77a842c 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp @@ -8,8 +8,8 @@ #include <vector> +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/include/fsdk_define.h" -#include "fpdfsdk/include/fsdk_mgr.h" std::vector<CFWL_TimerInfo*>* CXFA_FWLAdapterTimerMgr::s_TimerArray = nullptr; diff --git a/fpdfsdk/fsdk_actionhandler.cpp b/fpdfsdk/fsdk_actionhandler.cpp index c755d723f7..8168d4a1b5 100644 --- a/fpdfsdk/fsdk_actionhandler.cpp +++ b/fpdfsdk/fsdk_actionhandler.cpp @@ -11,9 +11,10 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfdoc/include/cpdf_formfield.h" #include "core/fpdfdoc/include/cpdf_interform.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/include/cpdfsdk_interform.h" #include "fpdfsdk/include/fsdk_define.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/javascript/ijs_context.h" #include "fpdfsdk/javascript/ijs_runtime.h" #include "third_party/base/stl_util.h" diff --git a/fpdfsdk/fsdk_baseform_embeddertest.cpp b/fpdfsdk/fsdk_baseform_embeddertest.cpp index 53611ae698..1bb081d9a0 100644 --- a/fpdfsdk/fsdk_baseform_embeddertest.cpp +++ b/fpdfsdk/fsdk_baseform_embeddertest.cpp @@ -3,8 +3,9 @@ // found in the LICENSE file. #include "fpdfsdk/include/cba_annotiterator.h" +#include "fpdfsdk/include/cpdfsdk_annot.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/include/fsdk_define.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "testing/embedder_test.h" #include "testing/embedder_test_mock_delegate.h" #include "testing/embedder_test_timer_handling_delegate.h" diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/cpdfdoc_environment.h index 38b06a9b5a..f6211d264c 100644 --- a/fpdfsdk/include/fsdk_mgr.h +++ b/fpdfsdk/include/cpdfdoc_environment.h @@ -1,37 +1,28 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2016 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef FPDFSDK_INCLUDE_FSDK_MGR_H_ -#define FPDFSDK_INCLUDE_FSDK_MGR_H_ +#ifndef FPDFSDK_INCLUDE_CPDFDOC_ENVIRONMENT_H_ +#define FPDFSDK_INCLUDE_CPDFDOC_ENVIRONMENT_H_ -#include <map> #include <memory> -#include <vector> #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfdoc/include/cpdf_occontext.h" #include "core/fxcrt/include/cfx_observable.h" #include "fpdfsdk/cfx_systemhandler.h" -#include "fpdfsdk/include/cpdfsdk_annot.h" -#include "fpdfsdk/include/fsdk_actionhandler.h" -#include "fpdfsdk/include/fsdk_common.h" #include "fpdfsdk/include/fsdk_define.h" #include "public/fpdf_formfill.h" #include "public/fpdf_fwlevent.h" class CFFL_IFormFiller; class CFX_SystemHandler; -class CPDF_AnnotList; class CPDFSDK_ActionHandler; -class CPDFSDK_Annot; class CPDFSDK_AnnotHandlerMgr; -class CPDFSDK_InterForm; -class CPDFSDK_PageView; -class CPDFSDK_Widget; +class CPDFSDK_Document; class IJS_Runtime; class CPDFDoc_Environment final { @@ -445,188 +436,4 @@ class CPDFDoc_Environment final { std::unique_ptr<CFX_SystemHandler> m_pSysHandler; }; -class CPDFSDK_Document : public CFX_Observable<CPDFSDK_Document> { - public: - static CPDFSDK_Document* FromFPDFFormHandle(FPDF_FORMHANDLE hHandle); - - CPDFSDK_Document(UnderlyingDocumentType* pDoc, CPDFDoc_Environment* pEnv); - ~CPDFSDK_Document(); - - CPDFSDK_InterForm* GetInterForm(); - - // Gets the document object for the next layer down; for master this is - // a CPDF_Document, but for XFA it is a CPDFXFA_Document. - UnderlyingDocumentType* GetUnderlyingDocument() const { -#ifdef PDF_ENABLE_XFA - return GetXFADocument(); -#else // PDF_ENABLE_XFA - return GetPDFDocument(); -#endif // PDF_ENABLE_XFA - } - - // Gets the CPDF_Document, either directly in master, or from the - // CPDFXFA_Document for XFA. - CPDF_Document* GetPDFDocument() const { -#ifdef PDF_ENABLE_XFA - return m_pDoc ? m_pDoc->GetPDFDoc() : nullptr; -#else // PDF_ENABLE_XFA - return m_pDoc; -#endif // PDF_ENABLE_XFA - } - -#ifdef PDF_ENABLE_XFA - // Gets the XFA document directly (XFA-only). - CPDFXFA_Document* GetXFADocument() const { return m_pDoc; } - - int GetPageViewCount() const { return m_pageMap.size(); } -#endif // PDF_ENABLE_XFA - - CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPage, bool ReNew); - CPDFSDK_PageView* GetPageView(int nIndex); - CPDFSDK_PageView* GetCurrentView(); - void RemovePageView(UnderlyingPageType* pPage); - void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); - - CPDFSDK_Annot* GetFocusAnnot(); - - IJS_Runtime* GetJsRuntime(); - - FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0); - FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0); - - FX_BOOL ExtractPages(const std::vector<uint16_t>& arrExtraPages, - CPDF_Document* pDstDoc); - FX_BOOL InsertPages(int nInsertAt, - const CPDF_Document* pSrcDoc, - const std::vector<uint16_t>& arrSrcPages); - FX_BOOL ReplacePages(int nPage, - const CPDF_Document* pSrcDoc, - const std::vector<uint16_t>& arrSrcPages); - - void OnCloseDocument(); - - int GetPageCount() { return m_pDoc->GetPageCount(); } - FX_BOOL GetPermissions(int nFlag); - FX_BOOL GetChangeMark() { return m_bChangeMask; } - void SetChangeMark() { m_bChangeMask = TRUE; } - void ClearChangeMark() { m_bChangeMask = FALSE; } - CFX_WideString GetPath(); - UnderlyingPageType* GetPage(int nIndex); - CPDFDoc_Environment* GetEnv() { return m_pEnv; } - void ProcJavascriptFun(); - FX_BOOL ProcOpenAction(); - CPDF_OCContext* GetOCContext(); - - private: - std::map<UnderlyingPageType*, CPDFSDK_PageView*> m_pageMap; - UnderlyingDocumentType* m_pDoc; - std::unique_ptr<CPDFSDK_InterForm> m_pInterForm; - CPDFSDK_Annot* m_pFocusAnnot; - CPDFDoc_Environment* m_pEnv; - std::unique_ptr<CPDF_OCContext> m_pOccontent; - FX_BOOL m_bChangeMask; - FX_BOOL m_bBeingDestroyed; -}; - -class CPDFSDK_PageView final : public CPDF_Page::View { - public: - CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page); - ~CPDFSDK_PageView(); - -#ifdef PDF_ENABLE_XFA - void PageView_OnDraw(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device, - CPDF_RenderOptions* pOptions, - const FX_RECT& pClip); -#else // PDF_ENABLE_XFA - void PageView_OnDraw(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device, - CPDF_RenderOptions* pOptions); -#endif // PDF_ENABLE_XFA - - const CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - const CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - CPDFSDK_Annot* GetFocusAnnot(); - void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot, FX_UINT nFlag = 0) { - m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag); - } - FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) { - return m_pSDKDoc->KillFocusAnnot(nFlag); - } - void KillFocusAnnotIfNeeded(); - - CPDFSDK_Annot* AddAnnot(CPDF_Dictionary* pDict); - CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType, CPDF_Dictionary* pDict); - CPDFSDK_Annot* AddAnnot(CPDF_Annot* pPDFAnnot); - - FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); - size_t CountAnnots() const; - CPDFSDK_Annot* GetAnnot(size_t nIndex); - CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict); - -#ifdef PDF_ENABLE_XFA - CPDFSDK_Annot* AddAnnot(CXFA_FFWidget* pPDFAnnot); - CPDFSDK_Annot* GetAnnotByXFAWidget(CXFA_FFWidget* hWidget); - CPDFXFA_Page* GetPDFXFAPage() { return m_page; } -#endif // PDF_ENABLE_XFA - - CPDF_Page* GetPDFPage() const; - CPDF_Document* GetPDFDocument(); - CPDFSDK_Document* GetSDKDocument() { return m_pSDKDoc; } - FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, FX_UINT nFlag); - FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, FX_UINT nFlag); -#ifdef PDF_ENABLE_XFA - FX_BOOL OnRButtonDown(const CFX_FloatPoint& point, FX_UINT nFlag); - FX_BOOL OnRButtonUp(const CFX_FloatPoint& point, FX_UINT nFlag); -#endif // PDF_ENABLE_XFA - FX_BOOL OnChar(int nChar, FX_UINT nFlag); - FX_BOOL OnKeyDown(int nKeyCode, int nFlag); - FX_BOOL OnKeyUp(int nKeyCode, int nFlag); - - FX_BOOL OnMouseMove(const CFX_FloatPoint& point, int nFlag); - FX_BOOL OnMouseWheel(double deltaX, - double deltaY, - const CFX_FloatPoint& point, - int nFlag); - bool IsValidAnnot(const CPDF_Annot* p) const; - void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; } - void UpdateRects(const std::vector<CFX_FloatRect>& rects); - void UpdateView(CPDFSDK_Annot* pAnnot); - const std::vector<CPDFSDK_Annot*>& GetAnnotList() const { - return m_fxAnnotArray; - } - - int GetPageIndex() const; - void LoadFXAnnots(); - void ClearFXAnnots(); - void SetValid(FX_BOOL bValid) { m_bValid = bValid; } - FX_BOOL IsValid() { return m_bValid; } - void SetLock(FX_BOOL bLocked) { m_bLocked = bLocked; } - FX_BOOL IsLocked() { return m_bLocked; } -#ifndef PDF_ENABLE_XFA - bool OwnsPage() const { return m_bOwnsPage; } - void TakePageOwnership() { m_bOwnsPage = true; } -#endif // PDF_ENABLE_XFA - - private: - int GetPageIndexForStaticPDF() const; - - CFX_Matrix m_curMatrix; - UnderlyingPageType* const m_page; - std::unique_ptr<CPDF_AnnotList> m_pAnnotList; - std::vector<CPDFSDK_Annot*> m_fxAnnotArray; - CPDFSDK_Document* const m_pSDKDoc; - CPDFSDK_Annot* m_CaptureWidget; -#ifndef PDF_ENABLE_XFA - bool m_bOwnsPage; -#endif // PDF_ENABLE_XFA - FX_BOOL m_bEnterWidget; - FX_BOOL m_bExitWidget; - FX_BOOL m_bOnWidget; - FX_BOOL m_bValid; - FX_BOOL m_bLocked; -}; - -#endif // FPDFSDK_INCLUDE_FSDK_MGR_H_ +#endif // FPDFSDK_INCLUDE_CPDFDOC_ENVIRONMENT_H_ diff --git a/fpdfsdk/include/cpdfsdk_document.h b/fpdfsdk/include/cpdfsdk_document.h new file mode 100644 index 0000000000..610fb1781d --- /dev/null +++ b/fpdfsdk/include/cpdfsdk_document.h @@ -0,0 +1,108 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_INCLUDE_CPDFSDK_DOCUMENT_H_ +#define FPDFSDK_INCLUDE_CPDFSDK_DOCUMENT_H_ + +#include <map> +#include <memory> + +#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" +#include "core/fxcrt/include/cfx_observable.h" +#include "fpdfsdk/include/fsdk_define.h" +#include "public/fpdf_formfill.h" + +class CPDF_OCContext; +class CPDFDoc_Environment; +class CPDFSDK_Annot; +class CPDFSDK_InterForm; +class CPDFSDK_PageView; +class IJS_Runtime; + +class CPDFSDK_Document : public CFX_Observable<CPDFSDK_Document> { + public: + static CPDFSDK_Document* FromFPDFFormHandle(FPDF_FORMHANDLE hHandle); + + CPDFSDK_Document(UnderlyingDocumentType* pDoc, CPDFDoc_Environment* pEnv); + ~CPDFSDK_Document(); + + CPDFSDK_InterForm* GetInterForm(); + + // Gets the document object for the next layer down; for master this is + // a CPDF_Document, but for XFA it is a CPDFXFA_Document. + UnderlyingDocumentType* GetUnderlyingDocument() const { +#ifdef PDF_ENABLE_XFA + return GetXFADocument(); +#else // PDF_ENABLE_XFA + return GetPDFDocument(); +#endif // PDF_ENABLE_XFA + } + + // Gets the CPDF_Document, either directly in master, or from the + // CPDFXFA_Document for XFA. + CPDF_Document* GetPDFDocument() const { +#ifdef PDF_ENABLE_XFA + return m_pDoc ? m_pDoc->GetPDFDoc() : nullptr; +#else // PDF_ENABLE_XFA + return m_pDoc; +#endif // PDF_ENABLE_XFA + } + +#ifdef PDF_ENABLE_XFA + // Gets the XFA document directly (XFA-only). + CPDFXFA_Document* GetXFADocument() const { return m_pDoc; } + + int GetPageViewCount() const { return m_pageMap.size(); } +#endif // PDF_ENABLE_XFA + + CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPage, bool ReNew); + CPDFSDK_PageView* GetPageView(int nIndex); + CPDFSDK_PageView* GetCurrentView(); + void RemovePageView(UnderlyingPageType* pPage); + void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); + + CPDFSDK_Annot* GetFocusAnnot(); + + IJS_Runtime* GetJsRuntime(); + + FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0); + FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0); + + FX_BOOL ExtractPages(const std::vector<uint16_t>& arrExtraPages, + CPDF_Document* pDstDoc); + FX_BOOL InsertPages(int nInsertAt, + const CPDF_Document* pSrcDoc, + const std::vector<uint16_t>& arrSrcPages); + FX_BOOL ReplacePages(int nPage, + const CPDF_Document* pSrcDoc, + const std::vector<uint16_t>& arrSrcPages); + + void OnCloseDocument(); + + int GetPageCount() { return m_pDoc->GetPageCount(); } + FX_BOOL GetPermissions(int nFlag); + FX_BOOL GetChangeMark() { return m_bChangeMask; } + void SetChangeMark() { m_bChangeMask = TRUE; } + void ClearChangeMark() { m_bChangeMask = FALSE; } + CFX_WideString GetPath(); + UnderlyingPageType* GetPage(int nIndex); + CPDFDoc_Environment* GetEnv() { return m_pEnv; } + void ProcJavascriptFun(); + FX_BOOL ProcOpenAction(); + CPDF_OCContext* GetOCContext(); + + private: + std::map<UnderlyingPageType*, CPDFSDK_PageView*> m_pageMap; + UnderlyingDocumentType* m_pDoc; + std::unique_ptr<CPDFSDK_InterForm> m_pInterForm; + CPDFSDK_Annot* m_pFocusAnnot; + CPDFDoc_Environment* m_pEnv; + std::unique_ptr<CPDF_OCContext> m_pOccontent; + FX_BOOL m_bChangeMask; + FX_BOOL m_bBeingDestroyed; +}; + +#endif // FPDFSDK_INCLUDE_CPDFSDK_DOCUMENT_H_ diff --git a/fpdfsdk/include/cpdfsdk_pageview.h b/fpdfsdk/include/cpdfsdk_pageview.h new file mode 100644 index 0000000000..a496334c2d --- /dev/null +++ b/fpdfsdk/include/cpdfsdk_pageview.h @@ -0,0 +1,122 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_INCLUDE_CPDFSDK_PAGEVIEW_H_ +#define FPDFSDK_INCLUDE_CPDFSDK_PAGEVIEW_H_ + +#include <memory> +#include <vector> + +#include "core/fpdfapi/fpdf_page/include/cpdf_page.h" +#include "core/fxcrt/include/fx_system.h" +#include "fpdfsdk/include/cpdfsdk_document.h" + +class CFX_RenderDevice; +class CPDF_AnnotList; +class CPDF_RenderOptions; + +class CPDFSDK_PageView final : public CPDF_Page::View { + public: + CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page); + ~CPDFSDK_PageView(); + +#ifdef PDF_ENABLE_XFA + void PageView_OnDraw(CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + CPDF_RenderOptions* pOptions, + const FX_RECT& pClip); +#else // PDF_ENABLE_XFA + void PageView_OnDraw(CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + CPDF_RenderOptions* pOptions); +#endif // PDF_ENABLE_XFA + + const CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); + CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); + const CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); + CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); + CPDFSDK_Annot* GetFocusAnnot(); + void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot, FX_UINT nFlag = 0) { + m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag); + } + FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) { + return m_pSDKDoc->KillFocusAnnot(nFlag); + } + void KillFocusAnnotIfNeeded(); + + CPDFSDK_Annot* AddAnnot(CPDF_Dictionary* pDict); + CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType, CPDF_Dictionary* pDict); + CPDFSDK_Annot* AddAnnot(CPDF_Annot* pPDFAnnot); + + FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); + size_t CountAnnots() const; + CPDFSDK_Annot* GetAnnot(size_t nIndex); + CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict); + +#ifdef PDF_ENABLE_XFA + CPDFSDK_Annot* AddAnnot(CXFA_FFWidget* pPDFAnnot); + CPDFSDK_Annot* GetAnnotByXFAWidget(CXFA_FFWidget* hWidget); + CPDFXFA_Page* GetPDFXFAPage() { return m_page; } +#endif // PDF_ENABLE_XFA + + CPDF_Page* GetPDFPage() const; + CPDF_Document* GetPDFDocument(); + CPDFSDK_Document* GetSDKDocument() { return m_pSDKDoc; } + FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, FX_UINT nFlag); + FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, FX_UINT nFlag); +#ifdef PDF_ENABLE_XFA + FX_BOOL OnRButtonDown(const CFX_FloatPoint& point, FX_UINT nFlag); + FX_BOOL OnRButtonUp(const CFX_FloatPoint& point, FX_UINT nFlag); +#endif // PDF_ENABLE_XFA + FX_BOOL OnChar(int nChar, FX_UINT nFlag); + FX_BOOL OnKeyDown(int nKeyCode, int nFlag); + FX_BOOL OnKeyUp(int nKeyCode, int nFlag); + + FX_BOOL OnMouseMove(const CFX_FloatPoint& point, int nFlag); + FX_BOOL OnMouseWheel(double deltaX, + double deltaY, + const CFX_FloatPoint& point, + int nFlag); + bool IsValidAnnot(const CPDF_Annot* p) const; + void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; } + void UpdateRects(const std::vector<CFX_FloatRect>& rects); + void UpdateView(CPDFSDK_Annot* pAnnot); + const std::vector<CPDFSDK_Annot*>& GetAnnotList() const { + return m_fxAnnotArray; + } + + int GetPageIndex() const; + void LoadFXAnnots(); + void ClearFXAnnots(); + void SetValid(FX_BOOL bValid) { m_bValid = bValid; } + FX_BOOL IsValid() { return m_bValid; } + void SetLock(FX_BOOL bLocked) { m_bLocked = bLocked; } + FX_BOOL IsLocked() { return m_bLocked; } +#ifndef PDF_ENABLE_XFA + bool OwnsPage() const { return m_bOwnsPage; } + void TakePageOwnership() { m_bOwnsPage = true; } +#endif // PDF_ENABLE_XFA + + private: + int GetPageIndexForStaticPDF() const; + + CFX_Matrix m_curMatrix; + UnderlyingPageType* const m_page; + std::unique_ptr<CPDF_AnnotList> m_pAnnotList; + std::vector<CPDFSDK_Annot*> m_fxAnnotArray; + CPDFSDK_Document* const m_pSDKDoc; + CPDFSDK_Annot* m_CaptureWidget; +#ifndef PDF_ENABLE_XFA + bool m_bOwnsPage; +#endif // PDF_ENABLE_XFA + FX_BOOL m_bEnterWidget; + FX_BOOL m_bExitWidget; + FX_BOOL m_bOnWidget; + FX_BOOL m_bValid; + FX_BOOL m_bLocked; +}; + +#endif // FPDFSDK_INCLUDE_CPDFSDK_PAGEVIEW_H_ diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index fe623e960f..cbf155abf1 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -15,10 +15,12 @@ #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/fpdfdoc/include/cpdf_interform.h" #include "core/fpdfdoc/include/cpdf_nametree.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/include/cpdfsdk_annotiterator.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/include/cpdfsdk_interform.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" #include "fpdfsdk/include/cpdfsdk_widget.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/javascript/Annot.h" #include "fpdfsdk/javascript/Field.h" #include "fpdfsdk/javascript/Icon.h" diff --git a/fpdfsdk/javascript/Document.h b/fpdfsdk/javascript/Document.h index a35358d4df..544a042eec 100644 --- a/fpdfsdk/javascript/Document.h +++ b/fpdfsdk/javascript/Document.h @@ -13,7 +13,7 @@ #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" #include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h" -#include "fpdfsdk/include/fsdk_mgr.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/javascript/JS_Define.h" class PrintParamsObj : public CJS_EmbedObj { diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp index 8b9e981b33..0803cfa138 100644 --- a/fpdfsdk/javascript/Field.cpp +++ b/fpdfsdk/javascript/Field.cpp @@ -13,10 +13,13 @@ #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" +#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfdoc/include/cpdf_interform.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/include/cpdfsdk_interform.h" +#include "fpdfsdk/include/cpdfsdk_pageview.h" #include "fpdfsdk/include/cpdfsdk_widget.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/javascript/Document.h" #include "fpdfsdk/javascript/Icon.h" #include "fpdfsdk/javascript/JS_Define.h" diff --git a/fpdfsdk/javascript/Field.h b/fpdfsdk/javascript/Field.h index 700302c724..56cfd20d83 100644 --- a/fpdfsdk/javascript/Field.h +++ b/fpdfsdk/javascript/Field.h @@ -11,7 +11,7 @@ #include <vector> #include "core/fxcrt/include/cfx_observable.h" -#include "fpdfsdk/include/fsdk_mgr.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/pdfwindow/PWL_Wnd.h" // For CPWL_Color. diff --git a/fpdfsdk/javascript/JS_Object.cpp b/fpdfsdk/javascript/JS_Object.cpp index 3de0eceba3..88dd288f1e 100644 --- a/fpdfsdk/javascript/JS_Object.cpp +++ b/fpdfsdk/javascript/JS_Object.cpp @@ -6,7 +6,6 @@ #include "fpdfsdk/javascript/JS_Object.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/cjs_context.h" diff --git a/fpdfsdk/javascript/JS_Runtime_Stub.cpp b/fpdfsdk/javascript/JS_Runtime_Stub.cpp index 98c641f750..2b4a624c0e 100644 --- a/fpdfsdk/javascript/JS_Runtime_Stub.cpp +++ b/fpdfsdk/javascript/JS_Runtime_Stub.cpp @@ -6,7 +6,6 @@ #include <memory> -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/javascript/ijs_context.h" #include "fpdfsdk/javascript/ijs_runtime.h" diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp index 749c8d7cc9..5a793f4270 100644 --- a/fpdfsdk/javascript/PublicMethods.cpp +++ b/fpdfsdk/javascript/PublicMethods.cpp @@ -11,8 +11,9 @@ #include "core/fpdfdoc/include/cpdf_interform.h" #include "core/fxcrt/include/fx_ext.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/include/cpdfsdk_interform.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/javascript/Field.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_EventHandler.h" diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp index 1e3ea2f04a..5e708de9ea 100644 --- a/fpdfsdk/javascript/app.cpp +++ b/fpdfsdk/javascript/app.cpp @@ -9,8 +9,9 @@ #include <memory> #include <vector> +#include "fpdfsdk/include/cpdfdoc_environment.h" +#include "fpdfsdk/include/cpdfsdk_document.h" #include "fpdfsdk/include/cpdfsdk_interform.h" -#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/javascript/Document.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_EventHandler.h" diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp index bfed82efe1..e35ee5bc54 100644 --- a/fpdfsdk/javascript/cjs_runtime.cpp +++ b/fpdfsdk/javascript/cjs_runtime.cpp @@ -8,7 +8,7 @@ #include <algorithm> -#include "fpdfsdk/include/fsdk_mgr.h" +#include "fpdfsdk/include/cpdfdoc_environment.h" #include "fpdfsdk/javascript/Annot.h" #include "fpdfsdk/javascript/Consts.h" #include "fpdfsdk/javascript/Document.h" @@ -28,6 +28,7 @@ #include "fpdfsdk/javascript/global.h" #include "fpdfsdk/javascript/report.h" #include "fpdfsdk/javascript/util.h" +#include "public/fpdf_formfill.h" #include "third_party/base/stl_util.h" #ifdef PDF_ENABLE_XFA |