Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 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 | |
dsinclair | 4d29e78 | 2016-10-04 14:02:47 -0700 | [diff] [blame^] | 7 | #ifndef FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ |
| 8 | #define FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 9 | |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 10 | #include <memory> |
| 11 | |
dsinclair | bec7692 | 2016-09-29 16:52:30 -0700 | [diff] [blame] | 12 | #include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h" |
dsinclair | 5b49309 | 2016-09-29 20:20:24 -0700 | [diff] [blame] | 13 | #include "xfa/fxfa/xfa_ffdoc.h" |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 14 | |
dsinclair | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 15 | class CPDFSDK_Document; |
| 16 | class CPDFSDK_Environment; |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 17 | class CPDFXFA_App; |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 18 | class CPDFXFA_Page; |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 19 | class CXFA_FFDocHandler; |
dsinclair | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 20 | class IJS_Runtime; |
| 21 | class IJS_Context; |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 22 | |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 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 { |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 32 | public: |
dsinclair | cedaa55 | 2016-08-24 11:12:19 -0700 | [diff] [blame] | 33 | CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc, |
| 34 | CPDFXFA_App* pProvider); |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 35 | ~CPDFXFA_Document(); |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 36 | |
| 37 | FX_BOOL LoadXFADoc(); |
dsinclair | cedaa55 | 2016-08-24 11:12:19 -0700 | [diff] [blame] | 38 | CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); } |
weili | 2d5b020 | 2016-08-03 11:06:49 -0700 | [diff] [blame] | 39 | CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 40 | CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } |
dsinclair | 9f206f0 | 2016-09-20 12:17:42 -0700 | [diff] [blame] | 41 | int GetDocType() const { return m_iDocType; } |
Tom Sepez | 744da70 | 2016-03-15 12:43:09 -0700 | [diff] [blame] | 42 | |
dsinclair | a939bfe | 2016-09-22 13:18:45 -0700 | [diff] [blame] | 43 | CPDFSDK_Document* GetSDKDoc() const { return m_pSDKDoc.get(); } |
| 44 | void SetSDKDoc(std::unique_ptr<CPDFSDK_Document> pSDKDoc); |
| 45 | |
Tom Sepez | 744da70 | 2016-03-15 12:43:09 -0700 | [diff] [blame] | 46 | void DeletePage(int page_index); |
dsinclair | 9f206f0 | 2016-09-20 12:17:42 -0700 | [diff] [blame] | 47 | int GetPageCount() const; |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 48 | |
dsinclair | 9f206f0 | 2016-09-20 12:17:42 -0700 | [diff] [blame] | 49 | CPDFXFA_Page* GetXFAPage(int page_index); |
| 50 | CPDFXFA_Page* GetXFAPage(CXFA_FFPageView* pPage) const; |
| 51 | |
| 52 | void RemovePage(CPDFXFA_Page* page); |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 53 | |
dsinclair | 89f8fa8 | 2016-09-14 06:11:08 -0700 | [diff] [blame] | 54 | void ClearChangeMark(); |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 55 | |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 56 | protected: |
| 57 | friend class CPDFXFA_DocEnvironment; |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 58 | |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 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: |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 70 | void CloseXFADoc(CXFA_FFDocHandler* pDoc) { |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 71 | if (pDoc) { |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 72 | m_pXFADoc->CloseDoc(); |
weili | 2d5b020 | 2016-08-03 11:06:49 -0700 | [diff] [blame] | 73 | m_pXFADoc.reset(); |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 74 | m_pXFADocView = nullptr; |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 75 | } |
| 76 | } |
| 77 | |
| 78 | int m_iDocType; |
dsinclair | cedaa55 | 2016-08-24 11:12:19 -0700 | [diff] [blame] | 79 | |
dsinclair | cedaa55 | 2016-08-24 11:12:19 -0700 | [diff] [blame] | 80 | std::unique_ptr<CPDF_Document> m_pPDFDoc; |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 81 | // |m_pSDKDoc| must be destroyed before |m_pPDFDoc| since it needs to access |
| 82 | // it to kill focused annotations. |
weili | 2d5b020 | 2016-08-03 11:06:49 -0700 | [diff] [blame] | 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; |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 87 | CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; |
jinming_wang | a1cef70 | 2016-03-18 16:35:40 +0800 | [diff] [blame] | 88 | LoadStatus m_nLoadStatus; |
| 89 | int m_nPageCount; |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 90 | |
| 91 | // Must be destroy before |m_pSDKDoc|. |
| 92 | CPDFXFA_DocEnvironment m_DocEnv; |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 93 | }; |
| 94 | |
dsinclair | 4d29e78 | 2016-10-04 14:02:47 -0700 | [diff] [blame^] | 95 | #endif // FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ |