OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #ifndef FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_ | |
8 #define FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_ | |
9 | |
10 #include <memory> | |
11 | |
12 #include "fpdfsdk/fpdfxfa/include/cpdfxfa_docenvironment.h" | |
13 #include "xfa/fxfa/include/xfa_ffdoc.h" | |
14 | |
15 class CPDFSDK_Document; | |
16 class CPDFSDK_Environment; | |
17 class CPDFXFA_App; | |
18 class CPDFXFA_Page; | |
19 class CXFA_FFDocHandler; | |
20 class IJS_Runtime; | |
21 class IJS_Context; | |
22 | |
23 enum LoadStatus { | |
24 FXFA_LOADSTATUS_PRELOAD = 0, | |
25 FXFA_LOADSTATUS_LOADING, | |
26 FXFA_LOADSTATUS_LOADED, | |
27 FXFA_LOADSTATUS_CLOSING, | |
28 FXFA_LOADSTATUS_CLOSED | |
29 }; | |
30 | |
31 class CPDFXFA_Document { | |
32 public: | |
33 CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc, | |
34 CPDFXFA_App* pProvider); | |
35 ~CPDFXFA_Document(); | |
36 | |
37 FX_BOOL LoadXFADoc(); | |
38 CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); } | |
39 CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } | |
40 CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } | |
41 int GetDocType() const { return m_iDocType; } | |
42 | |
43 CPDFSDK_Document* GetSDKDoc() const { return m_pSDKDoc.get(); } | |
44 void SetSDKDoc(std::unique_ptr<CPDFSDK_Document> pSDKDoc); | |
45 | |
46 void DeletePage(int page_index); | |
47 int GetPageCount() const; | |
48 | |
49 CPDFXFA_Page* GetXFAPage(int page_index); | |
50 CPDFXFA_Page* GetXFAPage(CXFA_FFPageView* pPage) const; | |
51 | |
52 void RemovePage(CPDFXFA_Page* page); | |
53 | |
54 void ClearChangeMark(); | |
55 | |
56 protected: | |
57 friend class CPDFXFA_DocEnvironment; | |
58 | |
59 int GetOriginalPageCount() const { return m_nPageCount; } | |
60 void SetOriginalPageCount(int count) { | |
61 m_nPageCount = count; | |
62 m_XFAPageList.SetSize(count); | |
63 } | |
64 | |
65 LoadStatus GetLoadStatus() const { return m_nLoadStatus; } | |
66 | |
67 CFX_ArrayTemplate<CPDFXFA_Page*>* GetXFAPageList() { return &m_XFAPageList; } | |
68 | |
69 private: | |
70 void CloseXFADoc(CXFA_FFDocHandler* pDoc) { | |
71 if (pDoc) { | |
72 m_pXFADoc->CloseDoc(); | |
73 m_pXFADoc.reset(); | |
74 m_pXFADocView = nullptr; | |
75 } | |
76 } | |
77 | |
78 int m_iDocType; | |
79 | |
80 std::unique_ptr<CPDF_Document> m_pPDFDoc; | |
81 // |m_pSDKDoc| must be destroyed before |m_pPDFDoc| since it needs to access | |
82 // it to kill focused annotations. | |
83 std::unique_ptr<CPDFSDK_Document> m_pSDKDoc; | |
84 std::unique_ptr<CXFA_FFDoc> m_pXFADoc; | |
85 CXFA_FFDocView* m_pXFADocView; // not owned. | |
86 CPDFXFA_App* const m_pApp; | |
87 CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; | |
88 LoadStatus m_nLoadStatus; | |
89 int m_nPageCount; | |
90 | |
91 // Must be destroy before |m_pSDKDoc|. | |
92 CPDFXFA_DocEnvironment m_DocEnv; | |
93 }; | |
94 | |
95 #endif // FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_ | |
OLD | NEW |