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" |
12 #include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h" | 13 #include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h" |
13 #include "xfa/fxfa/xfa_ffdoc.h" | 14 #include "xfa/fxfa/xfa_ffdoc.h" |
14 | 15 |
15 class CPDFSDK_FormFillEnvironment; | 16 class CPDFSDK_FormFillEnvironment; |
16 class CPDFXFA_App; | |
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 { |
31 public: | 31 public: |
32 CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc, | 32 CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc); |
33 CPDFXFA_App* pProvider); | |
34 ~CPDFXFA_Document(); | 33 ~CPDFXFA_Document(); |
35 | 34 |
36 FX_BOOL LoadXFADoc(); | 35 FX_BOOL LoadXFADoc(); |
37 CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); } | 36 CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); } |
38 CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } | 37 CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } |
39 CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } | 38 CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } |
40 int GetDocType() const { return m_iDocType; } | 39 int GetDocType() const { return m_iDocType; } |
| 40 CPDFXFA_App* GetApp(); // Creates if needed. |
41 | 41 |
42 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; } | 42 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; } |
43 void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) { | 43 void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 44 GetApp()->SetFormFillEnv(pFormFillEnv); |
44 m_pFormFillEnv = pFormFillEnv; | 45 m_pFormFillEnv = pFormFillEnv; |
45 } | 46 } |
46 | 47 |
47 void DeletePage(int page_index); | 48 void DeletePage(int page_index); |
48 int GetPageCount() const; | 49 int GetPageCount() const; |
49 | 50 |
50 CPDFXFA_Page* GetXFAPage(int page_index); | 51 CPDFXFA_Page* GetXFAPage(int page_index); |
51 CPDFXFA_Page* GetXFAPage(CXFA_FFPageView* pPage) const; | 52 CPDFXFA_Page* GetXFAPage(CXFA_FFPageView* pPage) const; |
52 | 53 |
53 void RemovePage(CPDFXFA_Page* page); | 54 void RemovePage(CPDFXFA_Page* page); |
54 | 55 |
55 void ClearChangeMark(); | 56 void ClearChangeMark(); |
56 | 57 |
57 protected: | 58 protected: |
58 friend class CPDFXFA_DocEnvironment; | 59 friend class CPDFXFA_DocEnvironment; |
59 | 60 |
60 int GetOriginalPageCount() const { return m_nPageCount; } | 61 int GetOriginalPageCount() const { return m_nPageCount; } |
61 void SetOriginalPageCount(int count) { | 62 void SetOriginalPageCount(int count) { |
62 m_nPageCount = count; | 63 m_nPageCount = count; |
63 m_XFAPageList.SetSize(count); | 64 m_XFAPageList.SetSize(count); |
64 } | 65 } |
65 | 66 |
66 LoadStatus GetLoadStatus() const { return m_nLoadStatus; } | 67 LoadStatus GetLoadStatus() const { return m_nLoadStatus; } |
67 | 68 |
68 CFX_ArrayTemplate<CPDFXFA_Page*>* GetXFAPageList() { return &m_XFAPageList; } | 69 CFX_ArrayTemplate<CPDFXFA_Page*>* GetXFAPageList() { return &m_XFAPageList; } |
69 | 70 |
70 private: | 71 private: |
71 void CloseXFADoc(CXFA_FFDocHandler* pDoc) { | 72 void CloseXFADoc(CXFA_FFDocHandler* pDoc); |
72 if (pDoc) { | |
73 m_pXFADoc->CloseDoc(); | |
74 m_pXFADoc.reset(); | |
75 m_pXFADocView = nullptr; | |
76 } | |
77 } | |
78 | 73 |
79 int m_iDocType; | 74 int m_iDocType; |
80 | 75 |
81 std::unique_ptr<CPDF_Document> m_pPDFDoc; | 76 std::unique_ptr<CPDF_Document> m_pPDFDoc; |
82 std::unique_ptr<CXFA_FFDoc> m_pXFADoc; | 77 std::unique_ptr<CXFA_FFDoc> m_pXFADoc; |
83 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; // not owned. | 78 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; // not owned. |
84 CXFA_FFDocView* m_pXFADocView; // not owned. | 79 CXFA_FFDocView* m_pXFADocView; // not owned. |
85 CPDFXFA_App* const m_pApp; | 80 std::unique_ptr<CPDFXFA_App> m_pApp; |
86 CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; | 81 CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; |
87 LoadStatus m_nLoadStatus; | 82 LoadStatus m_nLoadStatus; |
88 int m_nPageCount; | 83 int m_nPageCount; |
89 | 84 |
90 // Must be destroyed before |m_pFormFillEnv|. | 85 // Must be destroyed before |m_pFormFillEnv|. |
91 CPDFXFA_DocEnvironment m_DocEnv; | 86 CPDFXFA_DocEnvironment m_DocEnv; |
92 }; | 87 }; |
93 | 88 |
94 #endif // FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ | 89 #endif // FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ |
OLD | NEW |