OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ | 7 #ifndef FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ |
8 #define FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ | 8 #define FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "fpdfsdk/fpdfxfa/cpdfxfa_app.h" | |
13 #include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h" | 12 #include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h" |
14 #include "xfa/fxfa/xfa_ffdoc.h" | 13 #include "xfa/fxfa/xfa_ffdoc.h" |
15 | 14 |
| 15 class CJS_Runtime; |
16 class CPDFSDK_FormFillEnvironment; | 16 class CPDFSDK_FormFillEnvironment; |
17 class CPDFXFA_Page; | 17 class CPDFXFA_Page; |
18 class CXFA_FFDocHandler; | 18 class CXFA_FFDocHandler; |
19 class IJS_Runtime; | 19 class IJS_Runtime; |
20 class IJS_Context; | 20 class IJS_Context; |
21 | 21 |
22 enum LoadStatus { | 22 enum LoadStatus { |
23 FXFA_LOADSTATUS_PRELOAD = 0, | 23 FXFA_LOADSTATUS_PRELOAD = 0, |
24 FXFA_LOADSTATUS_LOADING, | 24 FXFA_LOADSTATUS_LOADING, |
25 FXFA_LOADSTATUS_LOADED, | 25 FXFA_LOADSTATUS_LOADED, |
26 FXFA_LOADSTATUS_CLOSING, | 26 FXFA_LOADSTATUS_CLOSING, |
27 FXFA_LOADSTATUS_CLOSED | 27 FXFA_LOADSTATUS_CLOSED |
28 }; | 28 }; |
29 | 29 |
30 class CPDFXFA_Document { | 30 class CPDFXFA_Document : public IXFA_AppProvider { |
31 public: | 31 public: |
32 CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc); | 32 CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc); |
33 ~CPDFXFA_Document(); | 33 ~CPDFXFA_Document() override; |
34 | 34 |
35 FX_BOOL LoadXFADoc(); | 35 FX_BOOL LoadXFADoc(); |
36 CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); } | 36 CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); } |
37 CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } | 37 CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } |
38 CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } | 38 CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } |
39 int GetDocType() const { return m_iDocType; } | 39 int GetDocType() const { return m_iDocType; } |
40 CPDFXFA_App* GetApp(); // Creates if needed. | 40 v8::Isolate* GetJSERuntime() const; |
| 41 CXFA_FFApp* GetXFAApp() { return m_pXFAApp.get(); } |
41 | 42 |
42 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; } | 43 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; } |
43 void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv); | 44 void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv); |
44 | 45 |
45 void DeletePage(int page_index); | 46 void DeletePage(int page_index); |
46 int GetPageCount() const; | 47 int GetPageCount() const; |
47 | 48 |
48 CPDFXFA_Page* GetXFAPage(int page_index); | 49 CPDFXFA_Page* GetXFAPage(int page_index); |
49 CPDFXFA_Page* GetXFAPage(CXFA_FFPageView* pPage) const; | 50 CPDFXFA_Page* GetXFAPage(CXFA_FFPageView* pPage) const; |
50 | 51 |
51 void RemovePage(CPDFXFA_Page* page); | 52 void RemovePage(CPDFXFA_Page* page); |
52 | 53 |
53 void ClearChangeMark(); | 54 void ClearChangeMark(); |
54 | 55 |
| 56 // IFXA_AppProvider: |
| 57 void GetLanguage(CFX_WideString& wsLanguage) override; |
| 58 void GetPlatform(CFX_WideString& wsPlatform) override; |
| 59 void GetAppName(CFX_WideString& wsName) override; |
| 60 |
| 61 void Beep(uint32_t dwType) override; |
| 62 int32_t MsgBox(const CFX_WideString& wsMessage, |
| 63 const CFX_WideString& wsTitle, |
| 64 uint32_t dwIconType, |
| 65 uint32_t dwButtonType) override; |
| 66 CFX_WideString Response(const CFX_WideString& wsQuestion, |
| 67 const CFX_WideString& wsTitle, |
| 68 const CFX_WideString& wsDefaultAnswer, |
| 69 FX_BOOL bMark) override; |
| 70 IFX_SeekableReadStream* DownloadURL(const CFX_WideString& wsURL) override; |
| 71 FX_BOOL PostRequestURL(const CFX_WideString& wsURL, |
| 72 const CFX_WideString& wsData, |
| 73 const CFX_WideString& wsContentType, |
| 74 const CFX_WideString& wsEncode, |
| 75 const CFX_WideString& wsHeader, |
| 76 CFX_WideString& wsResponse) override; |
| 77 FX_BOOL PutRequestURL(const CFX_WideString& wsURL, |
| 78 const CFX_WideString& wsData, |
| 79 const CFX_WideString& wsEncode) override; |
| 80 |
| 81 void LoadString(int32_t iStringID, CFX_WideString& wsString) override; |
| 82 IFWL_AdapterTimerMgr* GetTimerMgr() override; |
| 83 |
55 protected: | 84 protected: |
56 friend class CPDFXFA_DocEnvironment; | 85 friend class CPDFXFA_DocEnvironment; |
57 | 86 |
58 int GetOriginalPageCount() const { return m_nPageCount; } | 87 int GetOriginalPageCount() const { return m_nPageCount; } |
59 void SetOriginalPageCount(int count) { | 88 void SetOriginalPageCount(int count) { |
60 m_nPageCount = count; | 89 m_nPageCount = count; |
61 m_XFAPageList.SetSize(count); | 90 m_XFAPageList.SetSize(count); |
62 } | 91 } |
63 | 92 |
64 LoadStatus GetLoadStatus() const { return m_nLoadStatus; } | 93 LoadStatus GetLoadStatus() const { return m_nLoadStatus; } |
65 | 94 |
66 CFX_ArrayTemplate<CPDFXFA_Page*>* GetXFAPageList() { return &m_XFAPageList; } | 95 CFX_ArrayTemplate<CPDFXFA_Page*>* GetXFAPageList() { return &m_XFAPageList; } |
67 | 96 |
68 private: | 97 private: |
69 void CloseXFADoc(CXFA_FFDocHandler* pDoc); | 98 void CloseXFADoc(); |
70 | 99 |
71 int m_iDocType; | 100 int m_iDocType; |
72 | 101 |
73 std::unique_ptr<CPDF_Document> m_pPDFDoc; | 102 std::unique_ptr<CPDF_Document> m_pPDFDoc; |
74 std::unique_ptr<CXFA_FFDoc> m_pXFADoc; | 103 std::unique_ptr<CXFA_FFDoc> m_pXFADoc; |
75 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; // not owned. | 104 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; // not owned. |
76 CXFA_FFDocView* m_pXFADocView; // not owned. | 105 CXFA_FFDocView* m_pXFADocView; // not owned. |
77 std::unique_ptr<CPDFXFA_App> m_pApp; | 106 std::unique_ptr<CXFA_FFApp> m_pXFAApp; |
| 107 std::unique_ptr<CJS_Runtime> m_pRuntime; |
78 CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; | 108 CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; |
79 LoadStatus m_nLoadStatus; | 109 LoadStatus m_nLoadStatus; |
80 int m_nPageCount; | 110 int m_nPageCount; |
81 | 111 |
82 // Must be destroyed before |m_pFormFillEnv|. | 112 // Must be destroyed before |m_pFormFillEnv|. |
83 CPDFXFA_DocEnvironment m_DocEnv; | 113 CPDFXFA_DocEnvironment m_DocEnv; |
84 }; | 114 }; |
85 | 115 |
86 #endif // FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ | 116 #endif // FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ |
OLD | NEW |