diff options
Diffstat (limited to 'fpdfsdk/include')
-rw-r--r-- | fpdfsdk/include/formfiller/FFL_ComboBox.h | 5 | ||||
-rw-r--r-- | fpdfsdk/include/formfiller/FFL_FormFiller.h | 4 | ||||
-rw-r--r-- | fpdfsdk/include/formfiller/FFL_IFormFiller.h | 34 | ||||
-rw-r--r-- | fpdfsdk/include/formfiller/FFL_TextField.h | 5 | ||||
-rw-r--r-- | fpdfsdk/include/fpdfxfa/fpdfxfa_app.h | 98 | ||||
-rw-r--r-- | fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h | 228 | ||||
-rw-r--r-- | fpdfsdk/include/fpdfxfa/fpdfxfa_page.h | 66 | ||||
-rw-r--r-- | fpdfsdk/include/fpdfxfa/fpdfxfa_util.h | 47 | ||||
-rw-r--r-- | fpdfsdk/include/fsdk_annothandler.h | 147 | ||||
-rw-r--r-- | fpdfsdk/include/fsdk_baseannot.h | 17 | ||||
-rw-r--r-- | fpdfsdk/include/fsdk_baseform.h | 100 | ||||
-rw-r--r-- | fpdfsdk/include/fsdk_define.h | 51 | ||||
-rw-r--r-- | fpdfsdk/include/fsdk_mgr.h | 307 | ||||
-rw-r--r-- | fpdfsdk/include/javascript/IJavaScript.h | 11 | ||||
-rw-r--r-- | fpdfsdk/include/jsapi/fxjs_v8.h | 81 | ||||
-rw-r--r-- | fpdfsdk/include/pdfwindow/PWL_Edit.h | 8 |
16 files changed, 1203 insertions, 6 deletions
diff --git a/fpdfsdk/include/formfiller/FFL_ComboBox.h b/fpdfsdk/include/formfiller/FFL_ComboBox.h index d26aa7b9c8..5c36779df7 100644 --- a/fpdfsdk/include/formfiller/FFL_ComboBox.h +++ b/fpdfsdk/include/formfiller/FFL_ComboBox.h @@ -55,6 +55,11 @@ class CFFL_ComboBox : public CFFL_FormFiller, // IPWL_Edit_Notify: void OnAddUndo(CPWL_Edit* pEdit) override; +#ifdef PDF_ENABLE_XFA + // CFFL_FormFiller: + FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView) override; +#endif // PDF_ENABLE_XFA + private: CFX_WideString GetSelectExportText(); diff --git a/fpdfsdk/include/formfiller/FFL_FormFiller.h b/fpdfsdk/include/formfiller/FFL_FormFiller.h index ff7d0ab28c..cb14397be5 100644 --- a/fpdfsdk/include/formfiller/FFL_FormFiller.h +++ b/fpdfsdk/include/formfiller/FFL_FormFiller.h @@ -121,6 +121,10 @@ class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler { virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); virtual void SaveData(CPDFSDK_PageView* pPageView); +#ifdef PDF_ENABLE_XFA + virtual FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView); +#endif // PDF_ENABLE_XFA + CPWL_Wnd* GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNew); void DestroyPDFWindow(CPDFSDK_PageView* pPageView); void EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroyPDFWindow); diff --git a/fpdfsdk/include/formfiller/FFL_IFormFiller.h b/fpdfsdk/include/formfiller/FFL_IFormFiller.h index 95e2f8df83..93e7505f9c 100644 --- a/fpdfsdk/include/formfiller/FFL_IFormFiller.h +++ b/fpdfsdk/include/formfiller/FFL_IFormFiller.h @@ -117,6 +117,28 @@ class CFFL_IFormFiller : public IPWL_Filler_Notify { FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag); +#ifdef PDF_ENABLE_XFA + void OnClick(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bReset, + FX_BOOL& bExit, + FX_UINT nFlag); + void OnFull(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bReset, + FX_BOOL& bExit, + FX_UINT nFlag); + void OnPreOpen(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bReset, + FX_BOOL& bExit, + FX_UINT nFlag); + void OnPostOpen(CPDFSDK_Widget* pWidget, + CPDFSDK_PageView* pPageView, + FX_BOOL& bReset, + FX_BOOL& bExit, + FX_UINT nFlag); +#endif // PDF_ENABLE_XFA private: using CFFL_Widget2Filler = std::map<CPDFSDK_Annot*, CFFL_FormFiller*>; @@ -136,7 +158,17 @@ class CFFL_IFormFiller : public IPWL_Filler_Notify { FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag) override; - +#ifdef PDF_ENABLE_XFA + void OnPopupPreOpen(void* pPrivateData, + FX_BOOL& bExit, + FX_DWORD nFlag) override; + void OnPopupPostOpen(void* pPrivateData, + FX_BOOL& bExit, + FX_DWORD nFlag) override; + void SetFocusAnnotTab(CPDFSDK_Annot* pWidget, + FX_BOOL bSameField, + FX_BOOL bNext); +#endif // PDF_ENABLE_XFA void UnRegisterFormFiller(CPDFSDK_Annot* pAnnot); CPDFDoc_Environment* m_pApp; diff --git a/fpdfsdk/include/formfiller/FFL_TextField.h b/fpdfsdk/include/formfiller/FFL_TextField.h index 057825a4e1..12ac15abb8 100644 --- a/fpdfsdk/include/formfiller/FFL_TextField.h +++ b/fpdfsdk/include/formfiller/FFL_TextField.h @@ -56,6 +56,11 @@ class CFFL_TextField : public CFFL_FormFiller, // IPWL_Edit_Notify: void OnAddUndo(CPWL_Edit* pEdit) override; +#ifdef PDF_ENABLE_XFA + // CFFL_FormFiller: + FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView) override; +#endif // PDF_ENABLE_XFA + private: CBA_FontMap* m_pFontMap; FFL_TextFieldState m_State; diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h new file mode 100644 index 0000000000..5ec6de5644 --- /dev/null +++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h @@ -0,0 +1,98 @@ +// Copyright 2014 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 FPDFXFA_APP_H_ +#define FPDFXFA_APP_H_ + +#include "xfa/include/fxfa/fxfa.h" + +class IFXJS_Runtime; + +class CPDFXFA_App : public IXFA_AppProvider { + public: + static CPDFXFA_App* GetInstance(); + static void ReleaseInstance(); + + CPDFXFA_App(); + ~CPDFXFA_App() override; + + FX_BOOL Initialize(FXJSE_HRUNTIME hRuntime); + IXFA_App* GetXFAApp() { return m_pXFAApp; } + + FX_BOOL AddFormFillEnv(CPDFDoc_Environment* pEnv); + FX_BOOL RemoveFormFillEnv(CPDFDoc_Environment* pEnv); + + FX_BOOL IsJavaScriptInitialized() const { return m_bJavaScriptInitialized; } + void SetJavaScriptInitialized(FX_BOOL bInitialized) { + m_bJavaScriptInitialized = bInitialized; + } + + FXJSE_HRUNTIME GetJSERuntime() const { return m_hJSERuntime; } + + // IFXA_AppProvider: + void GetAppType(CFX_WideString& wsAppType) override; + void SetAppType(const CFX_WideStringC& wsAppType) override; + + void GetLanguage(CFX_WideString& wsLanguage) override; + void GetPlatform(CFX_WideString& wsPlatform) override; + void GetVariation(CFX_WideString& wsVariation) override; + void GetVersion(CFX_WideString& wsVersion) override; + void GetFoxitVersion(CFX_WideString& wsFoxitVersion) override { + wsFoxitVersion = L"7.0"; + } + + void GetAppName(CFX_WideString& wsName) override; + void GetFoxitAppName(CFX_WideString& wsFoxitName) override { + wsFoxitName = L"Foxit"; + } + + void Beep(FX_DWORD dwType) override; + int32_t MsgBox(const CFX_WideStringC& wsMessage, + const CFX_WideStringC& wsTitle, + FX_DWORD dwIconType, + FX_DWORD dwButtonType) override; + void Response(CFX_WideString& wsAnswer, + const CFX_WideStringC& wsQuestion, + const CFX_WideStringC& wsTitle, + const CFX_WideStringC& wsDefaultAnswer, + FX_BOOL bMark) override; + + int32_t GetDocumentCountInBatch() override; + int32_t GetCurDocumentInBatch() override; + + IFX_FileRead* DownloadURL(const CFX_WideStringC& wsURL) override; + FX_BOOL PostRequestURL(const CFX_WideStringC& wsURL, + const CFX_WideStringC& wsData, + const CFX_WideStringC& wsContentType, + const CFX_WideStringC& wsEncode, + const CFX_WideStringC& wsHeader, + CFX_WideString& wsResponse) override; + FX_BOOL PutRequestURL(const CFX_WideStringC& wsURL, + const CFX_WideStringC& wsData, + const CFX_WideStringC& wsEncode) override; + + void LoadString(int32_t iStringID, CFX_WideString& wsString) override; + FX_BOOL ShowFileDialog(const CFX_WideStringC& wsTitle, + const CFX_WideStringC& wsFilter, + CFX_WideStringArray& wsPathArr, + FX_BOOL bOpen) override; + IFWL_AdapterTimerMgr* GetTimerMgr() override; + + CFX_ArrayTemplate<CPDFDoc_Environment*> m_pEnvList; + + protected: + static CPDFXFA_App* g_pApp; + + FX_BOOL m_bJavaScriptInitialized; + IXFA_App* m_pXFAApp; + IXFA_FontMgr* m_pFontMgr; + FXJSE_HRUNTIME m_hJSERuntime; + IFXJS_Runtime* m_pJSRuntime; + CFX_WideString m_csAppType; + bool m_bOwnedRuntime; +}; + +#endif // FPDFXFA_APP_H_ diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h new file mode 100644 index 0000000000..64b3875629 --- /dev/null +++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h @@ -0,0 +1,228 @@ +// Copyright 2014 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 FPDFXFA_DOC_H_ +#define FPDFXFA_DOC_H_ + +#include "public/fpdfview.h" +#include "xfa/include/fxfa/fxfa.h" + +class CPDFXFA_App; +class CPDFXFA_Document; +class CPDFXFA_Page; +class CPDFSDK_Document; +class CPDFDoc_Environment; +class IJS_Runtime; +class IJS_Context; +class IXFA_DocHandler; + +class CPDFXFA_Document : public IXFA_DocProvider { + public: + CPDFXFA_Document(CPDF_Document* pPDFDoc, CPDFXFA_App* pProvider); + ~CPDFXFA_Document(); + + FX_BOOL LoadXFADoc(); + CPDFXFA_App* GetApp() { return m_pApp; } + CPDF_Document* GetPDFDoc() { return m_pPDFDoc; } + IXFA_Doc* GetXFADoc() { return m_pXFADoc; } + IXFA_DocView* GetXFADocView() { return m_pXFADocView; } + + int GetPageCount(); + CPDFXFA_Page* GetPage(int page_index); + CPDFXFA_Page* GetPage(IXFA_PageView* pPage); + void RemovePage(CPDFXFA_Page* page); + int GetDocType() { return m_iDocType; } + + CPDFSDK_Document* GetSDKDocument(CPDFDoc_Environment* pFormFillEnv); + + void FXRect2PDFRect(const CFX_RectF& fxRectF, CPDF_Rect& pdfRect); + + virtual void SetChangeMark(IXFA_Doc* hDoc); + virtual FX_BOOL GetChangeMark(IXFA_Doc* hDoc); + // used in dynamic xfa, dwFlags refer to XFA_INVALIDATE_XXX macros. + virtual void InvalidateRect(IXFA_PageView* pPageView, + const CFX_RectF& rt, + FX_DWORD dwFlags = 0); + // used in static xfa, dwFlags refer to XFA_INVALIDATE_XXX macros. + virtual void InvalidateRect(IXFA_Widget* hWidget, FX_DWORD dwFlags = 0); + // show or hide caret + virtual void DisplayCaret(IXFA_Widget* hWidget, + FX_BOOL bVisible, + const CFX_RectF* pRtAnchor); + // dwPos: (0:bottom 1:top) + virtual FX_BOOL GetPopupPos(IXFA_Widget* hWidget, + FX_FLOAT fMinPopup, + FX_FLOAT fMaxPopup, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup); + virtual FX_BOOL PopupMenu(IXFA_Widget* hWidget, + CFX_PointF ptPopup, + const CFX_RectF* pRectExclude = NULL); + + // dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing + virtual void PageViewEvent(IXFA_PageView* pPageView, FX_DWORD dwFlags); + // dwEvent refer to XFA_WIDGETEVENT_XXX + virtual void WidgetEvent(IXFA_Widget* hWidget, + CXFA_WidgetAcc* pWidgetData, + FX_DWORD dwEvent, + void* pParam = NULL, + void* pAdditional = NULL); + + // return true if render it. + virtual FX_BOOL RenderCustomWidget(IXFA_Widget* hWidget, + CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + const CFX_RectF& rtUI) { + return FALSE; + } + + // host method + virtual int32_t CountPages(IXFA_Doc* hDoc); + virtual int32_t GetCurrentPage(IXFA_Doc* hDoc); + virtual void SetCurrentPage(IXFA_Doc* hDoc, int32_t iCurPage); + virtual FX_BOOL IsCalculationsEnabled(IXFA_Doc* hDoc); + virtual void SetCalculationsEnabled(IXFA_Doc* hDoc, FX_BOOL bEnabled); + virtual void GetTitle(IXFA_Doc* hDoc, CFX_WideString& wsTitle); + virtual void SetTitle(IXFA_Doc* hDoc, const CFX_WideStringC& wsTitle); + virtual void ExportData(IXFA_Doc* hDoc, + const CFX_WideStringC& wsFilePath, + FX_BOOL bXDP = TRUE); + virtual void ImportData(IXFA_Doc* hDoc, const CFX_WideStringC& wsFilePath); + virtual void GotoURL(IXFA_Doc* hDoc, + const CFX_WideStringC& bsURL, + FX_BOOL bAppend = TRUE); + virtual FX_BOOL IsValidationsEnabled(IXFA_Doc* hDoc); + virtual void SetValidationsEnabled(IXFA_Doc* hDoc, FX_BOOL bEnabled); + virtual void SetFocusWidget(IXFA_Doc* hDoc, IXFA_Widget* hWidget); + virtual void Print(IXFA_Doc* hDoc, + int32_t nStartPage, + int32_t nEndPage, + FX_DWORD dwOptions); + + // LayoutPseudo method + virtual int32_t AbsPageCountInBatch(IXFA_Doc* hDoc) { return 0; } + virtual int32_t AbsPageInBatch(IXFA_Doc* hDoc, IXFA_Widget* hWidget) { + return 0; + } + virtual int32_t SheetCountInBatch(IXFA_Doc* hDoc) { return 0; } + virtual int32_t SheetInBatch(IXFA_Doc* hDoc, IXFA_Widget* hWidget) { + return 0; + } + + // SignaturePseudoModel method + // TODO: + virtual int32_t Verify( + IXFA_Doc* hDoc, + CXFA_Node* pSigNode, + FX_BOOL + bUsed = TRUE /*, SecurityHandler* pHandler, SignatureInfo &info*/) { + return 0; + } + virtual FX_BOOL Sign( + IXFA_Doc* hDoc, + CXFA_NodeList* pNodeList, + const CFX_WideStringC& wsExpression, + const CFX_WideStringC& wsXMLIdent, + const CFX_WideStringC& wsValue = FX_WSTRC(L"open"), + FX_BOOL + bUsed = TRUE /*, SecurityHandler* pHandler = NULL, SignatureInfo &info*/) { + return 0; + } + virtual CXFA_NodeList* Enumerate(IXFA_Doc* hDoc) { return 0; } + virtual FX_BOOL Clear(IXFA_Doc* hDoc, + CXFA_Node* pSigNode, + FX_BOOL bCleared = TRUE) { + return 0; + } + + // Get document path + virtual void GetURL(IXFA_Doc* hDoc, CFX_WideString& wsDocURL); + virtual FX_ARGB GetHighlightColor(IXFA_Doc* hDoc); + + /** + *Submit data to email, http, ftp. + * @param[in] hDoc The document handler. + * @param[in] eFormat Determines the format in which the data will be + *submitted. XFA_ATTRIBUTEENUM_Xdp, XFA_ATTRIBUTEENUM_Xml... + * @param[in] wsTarget The URL to which the data will be submitted. + * @param[in] eEncoding The encoding of text content. + * @param[in] pXDPContent Controls what subset of the data is submitted, used + *only when the format property is xdp. + * @param[in] bEmbedPDF, specifies whether PDF is embedded in the submitted + *content or not. + */ + virtual FX_BOOL SubmitData(IXFA_Doc* hDoc, CXFA_Submit submit); + + virtual FX_BOOL CheckWord(IXFA_Doc* hDoc, const CFX_ByteStringC& sWord) { + return FALSE; + } + virtual FX_BOOL GetSuggestWords(IXFA_Doc* hDoc, + const CFX_ByteStringC& sWord, + CFX_ByteStringArray& sSuggest) { + return FALSE; + } + + // Get PDF javascript object, set the object to hValue. + virtual FX_BOOL GetPDFScriptObject(IXFA_Doc* hDoc, + const CFX_ByteStringC& utf8Name, + FXJSE_HVALUE hValue); + + virtual FX_BOOL GetGlobalProperty(IXFA_Doc* hDoc, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue); + virtual FX_BOOL SetGlobalProperty(IXFA_Doc* hDoc, + const CFX_ByteStringC& szPropName, + FXJSE_HVALUE hValue); + virtual CPDF_Document* OpenPDF(IXFA_Doc* hDoc, + IFX_FileRead* pFile, + FX_BOOL bTakeOverFile) { + return NULL; + } + + virtual IFX_FileRead* OpenLinkedFile(IXFA_Doc* hDoc, + const CFX_WideString& wsLink); + + FX_BOOL _GetHValueByName(const CFX_ByteStringC& utf8Name, + FXJSE_HVALUE hValue, + IJS_Runtime* runTime); + FX_BOOL _OnBeforeNotifySumbit(); + void _OnAfterNotifySumbit(); + FX_BOOL _NotifySubmit(FX_BOOL bPrevOrPost); + FX_BOOL _SubmitData(IXFA_Doc* hDoc, CXFA_Submit submit); + FX_BOOL _MailToInfo(CFX_WideString& csURL, + CFX_WideString& csToAddress, + CFX_WideString& csCCAddress, + CFX_WideString& csBCCAddress, + CFX_WideString& csSubject, + CFX_WideString& csMsg); + FX_BOOL _ExportSubmitFile(FPDF_FILEHANDLER* ppFileHandler, + int fileType, + FPDF_DWORD encodeType, + FPDF_DWORD flag = 0x01111111); + void _ToXFAContentFlags(CFX_WideString csSrcContent, FPDF_DWORD& flag); + void _ClearChangeMark(); + + private: + void CloseXFADoc(IXFA_DocHandler* pDoc) { + if (pDoc) { + pDoc->CloseDoc(m_pXFADoc); + pDoc->ReleaseDoc(m_pXFADoc); + m_pXFADoc = NULL; + m_pXFADocView = NULL; + } + } + + int m_iDocType; + CPDF_Document* m_pPDFDoc; + CPDFSDK_Document* m_pSDKDoc; + IXFA_Doc* m_pXFADoc; + IXFA_DocView* m_pXFADocView; + CPDFXFA_App* m_pApp; + IJS_Context* m_pJSContext; + CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; +}; + +#endif // FPDFXFA_DOC_H_ diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_page.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_page.h new file mode 100644 index 0000000000..814599cc7e --- /dev/null +++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_page.h @@ -0,0 +1,66 @@ +// Copyright 2014 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 _FPDFXFA_PAGEVIEW_H_ +#define _FPDFXFA_PAGEVIEW_H_ + +class CPDFXFA_Page { + public: + CPDFXFA_Page(CPDFXFA_Document* pDoc, int page_index); + ~CPDFXFA_Page(); + + void Release(); + void AddRef() { m_iRef++; } + FX_BOOL LoadPage(); + FX_BOOL LoadPDFPage(CPDF_Dictionary* pageDict); + CPDFXFA_Document* GetDocument() { return m_pDocument; } + int GetPageIndex() { return m_iPageIndex; } + CPDF_Page* GetPDFPage() { return m_pPDFPage; } + IXFA_PageView* GetXFAPageView() { return m_pXFAPageView; } + void SetXFAPageView(IXFA_PageView* pPageView) { m_pXFAPageView = pPageView; } + + FX_FLOAT GetPageWidth(); + FX_FLOAT GetPageHeight(); + + void DeviceToPage(int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int device_x, + int device_y, + double* page_x, + double* page_y); + void PageToDevice(int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + double page_x, + double page_y, + int* device_x, + int* device_y); + + void GetDisplayMatrix(CFX_Matrix& matrix, + int xPos, + int yPos, + int xSize, + int ySize, + int iRotate) const; + + protected: + FX_BOOL LoadPDFPage(); + FX_BOOL LoadXFAPageView(); + + private: + CPDF_Page* m_pPDFPage; + IXFA_PageView* m_pXFAPageView; + int m_iPageIndex; + CPDFXFA_Document* m_pDocument; + int m_iRef; +}; + +#endif diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h new file mode 100644 index 0000000000..6cb07915ed --- /dev/null +++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h @@ -0,0 +1,47 @@ +// Copyright 2014 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_FPDFXFA_FPDFXFA_UTIL_H_ +#define FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_UTIL_H_ + +#include <vector> + +#include "xfa/include/fwl/adapter/fwl_adaptertimermgr.h" + +#define JS_STR_VIEWERTYPE_STANDARD L"Exchange" +#define JS_STR_LANGUANGE L"ENU" +#define JS_STR_VIEWERVARIATION L"Full" +#define JS_STR_VIEWERVERSION_XFA L"11" + +class CFWL_TimerInfo; + +class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr { + public: + CXFA_FWLAdapterTimerMgr(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv) {} + virtual FWL_ERR Start(IFWL_Timer* pTimer, + FX_DWORD dwElapse, + FWL_HTIMER& hTimer, + FX_BOOL bImmediately = TRUE); + virtual FWL_ERR Stop(FWL_HTIMER hTimer); + + protected: + static void TimerProc(int32_t idEvent); + + static std::vector<CFWL_TimerInfo*> s_TimerArray; + CPDFDoc_Environment* const m_pEnv; +}; + +class CFWL_TimerInfo { + public: + CFWL_TimerInfo() : pTimer(nullptr) {} + CFWL_TimerInfo(uint32_t event, IFWL_Timer* timer) + : uIDEvent(event), pTimer(timer) {} + + uint32_t uIDEvent; + IFWL_Timer* pTimer; +}; + +#endif // FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_UTIL_H_ diff --git a/fpdfsdk/include/fsdk_annothandler.h b/fpdfsdk/include/fsdk_annothandler.h index b45f4ef181..95b11d1823 100644 --- a/fpdfsdk/include/fsdk_annothandler.h +++ b/fpdfsdk/include/fsdk_annothandler.h @@ -12,6 +12,10 @@ #include "core/include/fxcrt/fx_basic.h" +#ifdef PDF_ENABLE_XFA +#define FSDK_XFAWIDGET_TYPENAME "XFAWidget" +#endif // PDF_ENABLE_XFA + class CFFL_IFormFiller; class CFX_RenderDevice; class CPDFDoc_Environment; @@ -34,6 +38,11 @@ class IPDFSDK_AnnotHandler { virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) = 0; +#ifdef PDF_ENABLE_XFA + virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget, + CPDFSDK_PageView* pPage) = 0; +#endif // PDF_ENABLE_XFA + virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) = 0; virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) = 0; @@ -118,6 +127,10 @@ class IPDFSDK_AnnotHandler { virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; +#ifdef PDF_ENABLE_XFA + virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, + CPDFSDK_Annot* pNewAnnot) = 0; +#endif // PDF_ENABLE_XFA }; class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { @@ -131,6 +144,10 @@ class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { CFX_ByteString GetName() override { return CFX_ByteString("WidgetHandler"); } FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override; CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override; +#ifdef PDF_ENABLE_XFA + CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget, + CPDFSDK_PageView* pPage) override; +#endif // PDF_ENABLE_XFA void ReleaseAnnot(CPDFSDK_Annot* pAnnot) override; void DeleteAnnot(CPDFSDK_Annot* pAnnot) override {} CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, @@ -203,6 +220,12 @@ class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { void OnSelected(CPDFSDK_Annot* pAnnot) override {} FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) override; FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) override; +#ifdef PDF_ENABLE_XFA + FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, + CPDFSDK_Annot* pNewAnnot) override { + return TRUE; + } +#endif // PDF_ENABLE_XFA void SetFormFiller(CFFL_IFormFiller* pFiller) { m_pFormFiller = pFiller; } CFFL_IFormFiller* GetFormFiller() { return m_pFormFiller; } @@ -212,6 +235,121 @@ class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { CFFL_IFormFiller* m_pFormFiller; }; +#ifdef PDF_ENABLE_XFA +class CPDFSDK_XFAAnnotHandler : public IPDFSDK_AnnotHandler { + public: + explicit CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp); + ~CPDFSDK_XFAAnnotHandler() {} + + public: + virtual CFX_ByteString GetType() { return FSDK_XFAWIDGET_TYPENAME; } + + virtual CFX_ByteString GetName() { return "XFAWidgetHandler"; } + + virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot); + + virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) { + return NULL; + } + + virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* pAnnot, CPDFSDK_PageView* pPage); + + virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot); + + virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) {} + + virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot); + + virtual FX_BOOL HitTest(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + const CPDF_Point& point); + + virtual void OnDraw(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + FX_DWORD dwFlags); + + virtual void OnDrawSleep(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + CFX_RenderDevice* pDevice, + CFX_Matrix* pUser2Device, + const CPDF_Rect& rcWindow, + FX_DWORD dwFlags) {} + + virtual void OnCreate(CPDFSDK_Annot* pAnnot) {} + + virtual void OnLoad(CPDFSDK_Annot* pAnnot) {} + + virtual void OnDelete(CPDFSDK_Annot* pAnnot) {} + + virtual void OnRelease(CPDFSDK_Annot* pAnnot) {} + + virtual void OnMouseEnter(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlag); + virtual void OnMouseExit(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlag); + + virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + short zDelta, + const CPDF_Point& point); + virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + FX_DWORD nFlags, + const CPDF_Point& point); + // by wjm. + virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, + FX_DWORD nChar, + FX_DWORD nFlags); + virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); + virtual FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); + + virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) {} + virtual void OnSelected(CPDFSDK_Annot* pAnnot) {} + + virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); + virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); + virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, + CPDFSDK_Annot* pNewAnnot); + + private: + IXFA_WidgetHandler* GetXFAWidgetHandler(CPDFSDK_Annot* pAnnot); + FX_DWORD GetFWLFlags(FX_DWORD dwFlag); + + private: + CPDFDoc_Environment* m_pApp; +}; +#endif // PDF_ENABLE_XFA + #define CBA_AnnotHandlerArray CFX_ArrayTemplate<IPDFSDK_AnnotHandler*> class CPDFSDK_AnnotHandlerMgr { public: @@ -225,6 +363,10 @@ class CPDFSDK_AnnotHandlerMgr { virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView); +#ifdef PDF_ENABLE_XFA + virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* pAnnot, + CPDFSDK_PageView* pPageView); +#endif // PDF_ENABLE_XFA virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot); virtual void Annot_OnCreate(CPDFSDK_Annot* pAnnot); @@ -287,6 +429,11 @@ class CPDFSDK_AnnotHandlerMgr { virtual FX_BOOL Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); virtual FX_BOOL Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); +#ifdef PDF_ENABLE_XFA + virtual FX_BOOL Annot_OnChangeFocus(CPDFSDK_Annot* pSetAnnot, + CPDFSDK_Annot* pKillAnnot); +#endif // PDF_ENABLE_XFA + virtual CPDF_Rect Annot_OnGetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); virtual FX_BOOL Annot_OnHitTest(CPDFSDK_PageView* pPageView, diff --git a/fpdfsdk/include/fsdk_baseannot.h b/fpdfsdk/include/fsdk_baseannot.h index 667ea1ec0e..49c25de284 100644 --- a/fpdfsdk/include/fsdk_baseannot.h +++ b/fpdfsdk/include/fsdk_baseannot.h @@ -16,7 +16,7 @@ #include "core/include/fpdfdoc/fpdf_doc.h" #include "core/include/fxcrt/fx_basic.h" #include "fpdfsdk/include/fsdk_define.h" -#include "fx_systemhandler.h" +#include "fpdfsdk/include/fx_systemhandler.h" class CPDFSDK_PageView; class CPDF_Annot; @@ -71,6 +71,10 @@ class CPDFSDK_Annot { explicit CPDFSDK_Annot(CPDFSDK_PageView* pPageView); virtual ~CPDFSDK_Annot() {} +#ifdef PDF_ENABLE_XFA + virtual FX_BOOL IsXFAField() { return FALSE; } +#endif // PDF_ENABLE_XFA + virtual FX_FLOAT GetMinWidth() const; virtual FX_FLOAT GetMinHeight() const; // define layout order to 5. @@ -78,6 +82,10 @@ class CPDFSDK_Annot { virtual CPDF_Annot* GetPDFAnnot() const { return nullptr; } +#ifdef PDF_ENABLE_XFA + virtual IXFA_Widget* GetXFAWidget() const { return nullptr; } +#endif // PDF_ENABLE_XFA + virtual CFX_ByteString GetType() const { return ""; } virtual CFX_ByteString GetSubType() const { return ""; } @@ -90,6 +98,9 @@ class CPDFSDK_Annot { UnderlyingPageType* GetUnderlyingPage(); CPDF_Page* GetPDFPage(); +#ifdef PDF_ENABLE_XFA + CPDFXFA_Page* GetPDFXFAPage(); +#endif // PDF_ENABLE_XFA void SetPage(CPDFSDK_PageView* pPageView) { m_pPageView = pPageView; } CPDFSDK_PageView* GetPageView() const { return m_pPageView; } @@ -113,6 +124,10 @@ class CPDFSDK_BAAnnot : public CPDFSDK_Annot { CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView); ~CPDFSDK_BAAnnot() override {} +#ifdef PDF_ENABLE_XFA + FX_BOOL IsXFAField() override; +#endif // PDF_ENABLE_XFA + CFX_ByteString GetType() const override; CFX_ByteString GetSubType() const override; void SetRect(const CPDF_Rect& rect) override; diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h index cd4b311e2e..28caa7b7b8 100644 --- a/fpdfsdk/include/fsdk_baseform.h +++ b/fpdfsdk/include/fsdk_baseform.h @@ -32,6 +32,15 @@ class CPDF_Action; class CPDF_FormField; struct CPWL_Color; +#ifdef PDF_ENABLE_XFA +typedef enum _PDFSDK_XFAAActionType { + PDFSDK_XFA_Click = 0, + PDFSDK_XFA_Full, + PDFSDK_XFA_PreOpen, + PDFSDK_XFA_PostOpen +} PDFSDK_XFAAActionType; +#endif // PDF_ENABLE_XFA + typedef struct _PDFSDK_FieldAction { _PDFSDK_FieldAction() { bModifier = FALSE; @@ -60,6 +69,30 @@ typedef struct _PDFSDK_FieldAction { class CPDFSDK_Widget : public CPDFSDK_BAAnnot { public: +#ifdef PDF_ENABLE_XFA + IXFA_Widget* GetMixXFAWidget() const; + IXFA_Widget* GetGroupMixXFAWidget(); + IXFA_WidgetHandler* GetXFAWidgetHandler() const; + + FX_BOOL HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT); + FX_BOOL OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, + PDFSDK_FieldAction& data, + CPDFSDK_PageView* pPageView); + + void Synchronize(FX_BOOL bSynchronizeElse); + void SynchronizeXFAValue(); + void SynchronizeXFAItems(); + + static void SynchronizeXFAValue(IXFA_DocView* pXFADocView, + IXFA_Widget* hWidget, + CPDF_FormField* pFormField, + CPDF_FormControl* pFormControl); + static void SynchronizeXFAItems(IXFA_DocView* pXFADocView, + IXFA_Widget* hWidget, + CPDF_FormField* pFormField, + CPDF_FormControl* pFormControl); +#endif // PDF_ENABLE_XFA + CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm); @@ -87,7 +120,11 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { FX_FLOAT GetFontSize() const; int GetSelectedIndex(int nIndex) const; +#ifndef PDF_ENABLE_XFA CFX_WideString GetValue() const; +#else + CFX_WideString GetValue(FX_BOOL bDisplay = TRUE) const; +#endif // PDF_ENABLE_XFA CFX_WideString GetDefaultValue() const; CFX_WideString GetOptionLabel(int nIndex) const; int CountOptions() const; @@ -101,6 +138,9 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { */ int GetAlignment() const; int GetMaxLen() const; +#ifdef PDF_ENABLE_XFA + CFX_WideString GetName() const; +#endif // PDF_ENABLE_XFA CFX_WideString GetAlternateName() const; // Set Properties. @@ -111,6 +151,9 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { void ClearSelection(FX_BOOL bNotify); void SetTopVisibleIndex(int index); +#ifdef PDF_ENABLE_XFA + void ResetAppearance(FX_BOOL bValueChanged); +#endif // PDF_ENABLE_XFA void ResetAppearance(const FX_WCHAR* sValue, FX_BOOL bValueChanged); void ResetFieldAppearance(FX_BOOL bValueChanged); void UpdateField(); @@ -167,13 +210,45 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { FX_BOOL HitTest(FX_FLOAT pageX, FX_FLOAT pageY); +#ifndef PDF_ENABLE_XFA private: +#endif // PDF_ENABLE_XFA CPDFSDK_InterForm* m_pInterForm; FX_BOOL m_bAppModified; int32_t m_nAppAge; int32_t m_nValueAge; + +#ifdef PDF_ENABLE_XFA + mutable IXFA_Widget* m_hMixXFAWidget; + mutable IXFA_WidgetHandler* m_pWidgetHandler; +#endif // PDF_ENABLE_XFA }; +#ifdef PDF_ENABLE_XFA +class CPDFSDK_XFAWidget : public CPDFSDK_Annot { + public: + CPDFSDK_XFAWidget(IXFA_Widget* pAnnot, + CPDFSDK_PageView* pPageView, + CPDFSDK_InterForm* pInterForm); + ~CPDFSDK_XFAWidget() override {} + + FX_BOOL IsXFAField() override; + IXFA_Widget* GetXFAWidget() const override { return m_hXFAWidget; } + CFX_ByteString GetType() const override; + CFX_ByteString GetSubType() const override { return ""; } + CFX_FloatRect GetRect() const override; + + CPDFSDK_InterForm* GetInterForm() { return m_pInterForm; } + + private: + CPDFSDK_InterForm* m_pInterForm; + IXFA_Widget* m_hXFAWidget; +}; +#define CPDFSDK_XFAWidgetMap \ + CFX_MapPtrTemplate<IXFA_Widget*, CPDFSDK_XFAWidget*> +#define CPDFSDK_FieldSynchronizeMap CFX_MapPtrTemplate<CPDF_FormField*, int> +#endif // PDF_ENABLE_XFA + class CPDFSDK_InterForm : public CPDF_FormNotify { public: explicit CPDFSDK_InterForm(CPDFSDK_Document* pDocument); @@ -197,6 +272,16 @@ class CPDFSDK_InterForm : public CPDF_FormNotify { void EnableCalculate(FX_BOOL bEnabled); FX_BOOL IsCalculateEnabled() const; +#ifdef PDF_ENABLE_XFA + void AddXFAMap(IXFA_Widget* hWidget, CPDFSDK_XFAWidget* pWidget); + void RemoveXFAMap(IXFA_Widget* hWidget); + CPDFSDK_XFAWidget* GetXFAWidget(IXFA_Widget* hWidget); + void XfaEnableCalculate(FX_BOOL bEnabled); + FX_BOOL IsXfaCalculateEnabled() const; + FX_BOOL IsXfaValidationsEnabled(); + void XfaSetValidationsEnabled(FX_BOOL bEnabled); +#endif // PDF_ENABLE_XFA + FX_BOOL OnKeyStrokeCommit(CPDF_FormField* pFormField, const CFX_WideString& csValue); FX_BOOL OnValidate(CPDF_FormField* pFormField, const CFX_WideString& csValue); @@ -227,6 +312,10 @@ class CPDFSDK_InterForm : public CPDF_FormNotify { CFX_ByteTextBuf& textBuf); CFX_WideString GetTemporaryFileName(const CFX_WideString& sFileExt); +#ifdef PDF_ENABLE_XFA + void SynchronizeField(CPDF_FormField* pFormField, FX_BOOL bSynchronizeElse); +#endif // PDF_ENABLE_XFA + private: // CPDF_FormNotify: int BeforeValueChange(CPDF_FormField* pField, @@ -252,6 +341,12 @@ class CPDFSDK_InterForm : public CPDF_FormNotify { CPDFSDK_Document* m_pDocument; CPDF_InterForm* m_pInterForm; CPDFSDK_WidgetMap m_Map; +#ifdef PDF_ENABLE_XFA + CPDFSDK_XFAWidgetMap m_XFAMap; + CPDFSDK_FieldSynchronizeMap m_FieldSynchronizeMap; + FX_BOOL m_bXfaCalculate; + FX_BOOL m_bXfaValidationsEnabled; +#endif // PDF_ENABLE_XFA FX_BOOL m_bCalculate; FX_BOOL m_bBusy; @@ -264,7 +359,12 @@ class CPDFSDK_InterForm : public CPDF_FormNotify { FX_COLORREF GetHighlightColor(int nFieldType); private: +#ifndef PDF_ENABLE_XFA static const int kNumFieldTypes = 6; +#else // PDF_ENABLE_XFA + static const int kNumFieldTypes = 7; +#endif // PDF_ENABLE_XFA + FX_COLORREF m_aHighlightColor[kNumFieldTypes]; uint8_t m_iHighlightAlpha; FX_BOOL m_bNeedHightlight[kNumFieldTypes]; diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h index 6242696f9a..7f9c38791e 100644 --- a/fpdfsdk/include/fsdk_define.h +++ b/fpdfsdk/include/fsdk_define.h @@ -17,6 +17,16 @@ #include "core/include/fxge/fx_ge_win32.h" #include "public/fpdfview.h" +#ifdef PDF_ENABLE_XFA +#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" +#include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" +#include "xfa/include/fwl/adapter/fwl_adaptertimermgr.h" +#include "xfa/include/fxbarcode/BC_BarCode.h" +#include "xfa/include/fxfa/fxfa.h" +#include "xfa/include/fxgraphics/fx_graphics.h" +#include "xfa/include/fxjse/fxjse.h" +#endif // PDF_ENABLE_XFA + #ifdef _WIN32 #include <tchar.h> #include <math.h> @@ -46,15 +56,56 @@ class CPDF_CustomAccess final : public IFX_FileRead { void Release() override { delete this; } FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; +#ifdef PDF_ENABLE_XFA + virtual CFX_ByteString GetFullPath() { return ""; } + virtual FX_BOOL GetByte(FX_DWORD pos, uint8_t& ch); + virtual FX_BOOL GetBlock(FX_DWORD pos, uint8_t* pBuf, FX_DWORD size); +#endif // PDF_ENABLE_XFA + private: FPDF_FILEACCESS m_FileAccess; +#ifdef PDF_ENABLE_XFA + uint8_t m_Buffer[512]; + FX_DWORD m_BufferOffset; +#endif // PDF_ENABLE_XFA +}; + +#ifdef PDF_ENABLE_XFA +class CFPDF_FileStream : public IFX_FileStream { + public: + CFPDF_FileStream(FPDF_FILEHANDLER* pFS); + virtual ~CFPDF_FileStream() {} + + virtual IFX_FileStream* Retain(); + virtual void Release(); + + virtual FX_FILESIZE GetSize(); + virtual FX_BOOL IsEOF(); + virtual FX_FILESIZE GetPosition() { return m_nCurPos; } + virtual void SetPosition(FX_FILESIZE pos) { m_nCurPos = pos; } + virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); + virtual size_t ReadBlock(void* buffer, size_t size); + virtual FX_BOOL WriteBlock(const void* buffer, + FX_FILESIZE offset, + size_t size); + virtual FX_BOOL Flush(); + + protected: + FPDF_FILEHANDLER* m_pFS; + FX_FILESIZE m_nCurPos; }; +#endif // PDF_ENABLE_XFA // Object types for public FPDF_ types; these correspond to next layer down // from fpdfsdk. For master, these are CPDF_ types, but for XFA, these are // CPDFXFA_ types. +#ifndef PDF_ENABLE_XFA using UnderlyingDocumentType = CPDF_Document; using UnderlyingPageType = CPDF_Page; +#else // PDF_ENABLE_XFA +using UnderlyingDocumentType = CPDFXFA_Document; +using UnderlyingPageType = CPDFXFA_Page; +#endif // PDF_ENABLE_XFA // Conversions to/from underlying types. UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc); diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h index 130abc8436..2df44c7ca1 100644 --- a/fpdfsdk/include/fsdk_mgr.h +++ b/fpdfsdk/include/fsdk_mgr.h @@ -22,6 +22,11 @@ #include "public/fpdf_formfill.h" #include "public/fpdf_fwlevent.h" // cross platform keycode and events define. +#ifdef PDF_ENABLE_XFA +#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" +#include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" +#endif // PDF_ENABLE_XFA + class CFFL_IFormFiller; class CPDFSDK_ActionHandler; class CPDFSDK_Annot; @@ -40,6 +45,14 @@ class CPDFDoc_Environment final { CPDFDoc_Environment(UnderlyingDocumentType* pDoc, FPDF_FORMFILLINFO* pFFinfo); ~CPDFDoc_Environment(); +#ifdef PDF_ENABLE_XFA + void Release() { + if (m_pInfo && m_pInfo->Release) + m_pInfo->Release(m_pInfo); + delete this; + } +#endif // PDF_ENABLE_XFA + void FFI_Invalidate(FPDF_PAGE page, double left, double top, @@ -154,6 +167,249 @@ class CPDFDoc_Environment final { sizeOfArray); } +#ifdef PDF_ENABLE_XFA + void FFI_DisplayCaret(FPDF_PAGE page, + FPDF_BOOL bVisible, + double left, + double top, + double right, + double bottom) { + if (m_pInfo && m_pInfo->FFI_DisplayCaret) + m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right, + bottom); + } + + int FFI_GetCurrentPageIndex(FPDF_DOCUMENT document) { + if (!m_pInfo || !m_pInfo->FFI_GetCurrentPageIndex) { + return -1; + } + return m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document); + } + + void FFI_SetCurrentPage(FPDF_DOCUMENT document, int iCurPage) { + if (m_pInfo && m_pInfo->FFI_SetCurrentPage) + m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage); + } + + CFX_WideString FFI_GetAppName() const { return CFX_WideString(L"Acrobat"); } + + CFX_WideString FFI_GetPlatform() { + if (m_pInfo && m_pInfo->FFI_GetPlatform) { + int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, NULL, 0); + if (nRequiredLen <= 0) + return L""; + + char* pbuff = new char[nRequiredLen]; + memset(pbuff, 0, nRequiredLen); + int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff, nRequiredLen); + if (nActualLen <= 0 || nActualLen > nRequiredLen) { + delete[] pbuff; + return L""; + } + CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); + CFX_WideString wsRet = CFX_WideString::FromUTF16LE( + (unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), + bsRet.GetLength() / sizeof(unsigned short)); + delete[] pbuff; + return wsRet; + } + return L""; + } + + void FFI_GotoURL(FPDF_DOCUMENT document, + const CFX_WideStringC& wsURL, + FX_BOOL bAppend) { + if (m_pInfo && m_pInfo->FFI_GotoURL) { + CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode(); + FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLength()); + m_pInfo->FFI_GotoURL(m_pInfo, document, pTo); + bsTo.ReleaseBuffer(); + } + } + + void FFI_GetURL(FPDF_DOCUMENT document, CFX_WideString& wsURL) { + wsURL = CFX_WideString(); + } + + void FFI_PageEvent(FPDF_PAGE page, FPDF_DWORD flag) {} + + void FFI_GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect) { + if (m_pInfo && m_pInfo->FFI_GetPageViewRect) { + double left; + double top; + double right; + double bottom; + m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom); + + dstRect.left = static_cast<float>(left); + dstRect.top = static_cast<float>(top < bottom ? bottom : top); + dstRect.bottom = static_cast<float>(top < bottom ? top : bottom); + dstRect.right = static_cast<float>(right); + } + } + + FX_BOOL FFI_PopupMenu(FPDF_PAGE page, + FPDF_WIDGET hWidget, + int menuFlag, + CFX_PointF ptPopup, + const CFX_PointF* pRectExclude) { + if (m_pInfo && m_pInfo->FFI_PopupMenu) + return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, ptPopup.x, + ptPopup.y); + return FALSE; + } + + void FFI_Alert(FPDF_WIDESTRING Msg, + FPDF_WIDESTRING Title, + int Type, + int Icon) { + if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) + m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title, + Type, Icon); + } + + void FFI_EmailTo(FPDF_FILEHANDLER* fileHandler, + FPDF_WIDESTRING pTo, + FPDF_WIDESTRING pSubject, + FPDF_WIDESTRING pCC, + FPDF_WIDESTRING pBcc, + FPDF_WIDESTRING pMsg) { + if (m_pInfo && m_pInfo->FFI_EmailTo) + m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, + pMsg); + } + + void FFI_UploadTo(FPDF_FILEHANDLER* fileHandler, + int fileFlag, + FPDF_WIDESTRING uploadTo) { + if (m_pInfo && m_pInfo->FFI_UploadTo) + m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo); + } + + FPDF_FILEHANDLER* FFI_OpenFile(int fileType, + FPDF_WIDESTRING wsURL, + const char* mode) { + if (m_pInfo && m_pInfo->FFI_OpenFile) + return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode); + return NULL; + } + + CFX_WideString FFI_GetFilePath(FPDF_FILEHANDLER* pFileHandler) const { + return L""; + } + + int FFI_GetDocumentCount() const { return 0; } + int FFI_GetCurDocument() const { return 0; } + + IFX_FileRead* FFI_DownloadFromURL(const FX_WCHAR* url) { + if (m_pInfo && m_pInfo->FFI_DownloadFromURL) { + CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode(); + FPDF_WIDESTRING wsURL = + (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.GetLength()); + + FPDF_LPFILEHANDLER fileHandler = + m_pInfo->FFI_DownloadFromURL(m_pInfo, wsURL); + + return new CFPDF_FileStream(fileHandler); + } + return NULL; + } + + CFX_WideString FFI_PostRequestURL(const FX_WCHAR* wsURL, + const FX_WCHAR* wsData, + const FX_WCHAR* wsContentType, + const FX_WCHAR* wsEncode, + const FX_WCHAR* wsHeader) { + if (m_pInfo && m_pInfo->FFI_PostRequestURL) { + CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); + FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); + + CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); + FPDF_WIDESTRING data = + (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); + + CFX_ByteString bsContentType = + CFX_WideString(wsContentType).UTF16LE_Encode(); + FPDF_WIDESTRING contentType = + (FPDF_WIDESTRING)bsContentType.GetBuffer(bsContentType.GetLength()); + + CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); + FPDF_WIDESTRING encode = + (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); + + CFX_ByteString bsHeader = CFX_WideString(wsHeader).UTF16LE_Encode(); + FPDF_WIDESTRING header = + (FPDF_WIDESTRING)bsHeader.GetBuffer(bsHeader.GetLength()); + + FPDF_BSTR respone; + FPDF_BStr_Init(&respone); + m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, + header, &respone); + + CFX_WideString wsRet = CFX_WideString::FromUTF16LE( + (unsigned short*)respone.str, respone.len / sizeof(unsigned short)); + FPDF_BStr_Clear(&respone); + + return wsRet; + } + return L""; + } + + FPDF_BOOL FFI_PutRequestURL(const FX_WCHAR* wsURL, + const FX_WCHAR* wsData, + const FX_WCHAR* wsEncode) { + if (m_pInfo && m_pInfo->FFI_PutRequestURL) { + CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); + FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); + + CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); + FPDF_WIDESTRING data = + (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); + + CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); + FPDF_WIDESTRING encode = + (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); + + return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode); + } + return FALSE; + } + + FPDF_BOOL FFI_ShowFileDialog(const FX_WCHAR* wsTitle, + const FX_WCHAR* wsFilter, + CFX_WideStringArray& wsPathArr, + FX_BOOL bOpen) { + return FALSE; + } + + CFX_WideString FFI_GetLanguage() { + if (m_pInfo && m_pInfo->FFI_GetLanguage) { + int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, NULL, 0); + if (nRequiredLen <= 0) + return L""; + + char* pbuff = new char[nRequiredLen]; + memset(pbuff, 0, nRequiredLen); + int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff, nRequiredLen); + if (nActualLen <= 0 || nActualLen > nRequiredLen) { + delete[] pbuff; + return L""; + } + CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); + CFX_WideString wsRet = CFX_WideString::FromUTF16LE( + (unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), + bsRet.GetLength() / sizeof(unsigned short)); + delete[] pbuff; + return wsRet; + } + return L""; + } + void FFI_PageEvent(int iPageIndex, int iEventType) const { + // Todo: call a call-back function when it's implemented + // in applicaiton's side. + } +#endif // PDF_ENABLE_XFA + int JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type, @@ -225,12 +481,29 @@ class CPDFSDK_Document { // 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 { return m_pDoc; } + 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, FX_BOOL ReNew = TRUE); @@ -284,9 +557,18 @@ class CPDFSDK_PageView final { 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); @@ -304,15 +586,29 @@ class CPDFSDK_PageView final { 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(IXFA_Widget* pPDFAnnot); + CPDFSDK_Annot* GetAnnotByXFAWidget(IXFA_Widget* hWidget); + CPDFXFA_Page* GetPDFXFAPage() { return m_page; } + CPDF_Page* GetPDFPage(); +#else CPDF_Page* GetPDFPage() { return m_page; } +#endif // PDF_ENABLE_XFA + CPDF_Document* GetPDFDocument(); CPDFSDK_Document* GetSDKDocument() { return m_pSDKDoc; } FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_UINT nFlag); FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag); +#ifdef PDF_ENABLE_XFA + FX_BOOL OnRButtonDown(const CPDF_Point& point, FX_UINT nFlag); + FX_BOOL OnRButtonUp(const CPDF_Point& 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); @@ -332,11 +628,14 @@ class CPDFSDK_PageView final { int GetPageIndex(); 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 void TakeOverPage() { m_bTakeOverPage = TRUE; } +#endif // PDF_ENABLE_XFA private: void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, @@ -347,13 +646,17 @@ class CPDFSDK_PageView final { std::unique_ptr<CPDF_AnnotList> m_pAnnotList; std::vector<CPDFSDK_Annot*> m_fxAnnotArray; CPDFSDK_Document* m_pSDKDoc; +#ifdef PDF_ENABLE_XFA + CPDFSDK_Annot* m_CaptureWidget; +#else // PDF_ENABLE_XFA CPDFSDK_Widget* m_CaptureWidget; + FX_BOOL m_bTakeOverPage; +#endif // PDF_ENABLE_XFA FX_BOOL m_bEnterWidget; FX_BOOL m_bExitWidget; FX_BOOL m_bOnWidget; FX_BOOL m_bValid; FX_BOOL m_bLocked; - FX_BOOL m_bTakeOverPage; }; #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_ diff --git a/fpdfsdk/include/javascript/IJavaScript.h b/fpdfsdk/include/javascript/IJavaScript.h index 79247c868a..6b154676da 100644 --- a/fpdfsdk/include/javascript/IJavaScript.h +++ b/fpdfsdk/include/javascript/IJavaScript.h @@ -10,6 +10,10 @@ #include "core/include/fxcrt/fx_string.h" #include "core/include/fxcrt/fx_system.h" +#ifdef PDF_ENABLE_XFA +#include "xfa/include/fxjse/fxjse.h" +#endif // PDF_ENABLE_XFA + class CPDFDoc_Environment; class CPDFSDK_Annot; class CPDFSDK_Document; @@ -148,6 +152,13 @@ class IJS_Runtime { const wchar_t* script, CFX_WideString* info) = 0; +#ifdef PDF_ENABLE_XFA + virtual FX_BOOL GetHValueByName(const CFX_ByteStringC& utf8Name, + FXJSE_HVALUE hValue) = 0; + virtual FX_BOOL SetHValueByName(const CFX_ByteStringC& utf8Name, + FXJSE_HVALUE hValue) = 0; +#endif // PDF_ENABLE_XFA + protected: IJS_Runtime() {} }; diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h index b8a63c6c7b..50b2656e91 100644 --- a/fpdfsdk/include/jsapi/fxjs_v8.h +++ b/fpdfsdk/include/jsapi/fxjs_v8.h @@ -15,6 +15,7 @@ #define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ #include <v8.h> +#include <v8-util.h> #include <vector> @@ -27,6 +28,12 @@ class CFXJS_ObjDefinition; class IJS_Context; // A description of the event that caused JS execution. class IJS_Runtime; // A native runtime, typically owns the v8::Context. +#ifdef PDF_ENABLE_XFA +// FXJS_V8 places no interpreation on this calass; it merely passes it +// along to XFA. +class CFXJSE_RuntimeData; +#endif // PDF_ENABLE_XFA + enum FXJSOBJTYPE { FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS. FXJSOBJTYPE_STATIC, // Created by init and hung off of global object. @@ -39,15 +46,77 @@ struct FXJSErr { unsigned linnum; }; +// Global weak map to save dynamic objects. +class V8TemplateMapTraits : public v8::StdMapTraits<void*, v8::Object> { + public: + typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; + typedef void WeakCallbackDataType; + + static WeakCallbackDataType* WeakCallbackParameter( + MapType* map, + void* key, + const v8::Local<v8::Object>& value) { + return key; + } + static MapType* MapFromWeakCallbackInfo( + const v8::WeakCallbackInfo<WeakCallbackDataType>&); + + static void* KeyFromWeakCallbackInfo( + const v8::WeakCallbackInfo<WeakCallbackDataType>& data) { + return data.GetParameter(); + } + static const v8::PersistentContainerCallbackType kCallbackType = + v8::kWeakWithInternalFields; + static void DisposeWeak( + const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {} + static void OnWeakCallback( + const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {} + static void Dispose(v8::Isolate* isolate, + v8::Global<v8::Object> value, + void* key); + static void DisposeCallbackData(WeakCallbackDataType* callbackData) {} +}; + +class V8TemplateMap { + public: + typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; + + void set(void* key, v8::Local<v8::Object> handle) { + ASSERT(!m_map.Contains(key)); + m_map.Set(key, handle); + } + explicit V8TemplateMap(v8::Isolate* isolate) : m_map(isolate) {} + friend class V8TemplateMapTraits; + + private: + MapType m_map; +}; + class FXJS_PerIsolateData { public: static void SetUp(v8::Isolate* pIsolate); static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); + void CreateDynamicObjsMap(v8::Isolate* pIsolate) { + m_pDynamicObjsMap = new V8TemplateMap(pIsolate); + } + void ReleaseDynamicObjsMap() { + delete m_pDynamicObjsMap; + m_pDynamicObjsMap = nullptr; + } std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray; +#ifdef PDF_ENABLE_XFA + CFXJSE_RuntimeData* m_pFXJSERuntimeData; +#endif // PDF_ENABLE_XFA + V8TemplateMap* m_pDynamicObjsMap; protected: - FXJS_PerIsolateData() {} +#ifndef PDF_ENABLE_XFA + FXJS_PerIsolateData() : m_pDynamicObjsMap(nullptr) {} +#else // PDF_ENABLE_XFA + FXJS_PerIsolateData() + : m_pFXJSERuntimeData(nullptr), m_pDynamicObjsMap(nullptr) {} +#endif // PDF_ENABLE_XFA }; extern const wchar_t kFXJSValueNameString[]; @@ -132,6 +201,13 @@ void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, std::vector<v8::Global<v8::Object>*>* pStaticObjects); IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate); +#ifdef PDF_ENABLE_XFA +// Called as part of FXJS_InitializeRuntime, exposed so PDF can make its +// own contexts compatible with XFA or vice versa. +void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, + IJS_Runtime* pIRuntime); +#endif // PDF_ENABLE_XFA + // Called after FXJS_InitializeRuntime call made. int FXJS_Execute(v8::Isolate* pIsolate, IJS_Context* pJSContext, @@ -140,7 +216,8 @@ int FXJS_Execute(v8::Isolate* pIsolate, v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, IJS_Runtime* pJSContext, - int nObjDefnID); + int nObjDefnID, + bool bStatic = false); v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate); int FXJS_GetObjDefnID(v8::Local<v8::Object> pObj); const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj); diff --git a/fpdfsdk/include/pdfwindow/PWL_Edit.h b/fpdfsdk/include/pdfwindow/PWL_Edit.h index f46f12ebf2..7885331bc7 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Edit.h +++ b/fpdfsdk/include/pdfwindow/PWL_Edit.h @@ -32,6 +32,14 @@ class IPWL_Filler_Notify { FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag) = 0; +#ifdef PDF_ENABLE_XFA + virtual void OnPopupPreOpen(void* pPrivateData, + FX_BOOL& bExit, + FX_DWORD nFlag) = 0; + virtual void OnPopupPostOpen(void* pPrivateData, + FX_BOOL& bExit, + FX_DWORD nFlag) = 0; +#endif // PDF_ENABLE_XFA }; class CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify { |