| 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 m_pFormFillEnv = pFormFillEnv; | |
| 45 } | |
| 46 | 44 |
| 47 void DeletePage(int page_index); | 45 void DeletePage(int page_index); |
| 48 int GetPageCount() const; | 46 int GetPageCount() const; |
| 49 | 47 |
| 50 CPDFXFA_Page* GetXFAPage(int page_index); | 48 CPDFXFA_Page* GetXFAPage(int page_index); |
| 51 CPDFXFA_Page* GetXFAPage(CXFA_FFPageView* pPage) const; | 49 CPDFXFA_Page* GetXFAPage(CXFA_FFPageView* pPage) const; |
| 52 | 50 |
| 53 void RemovePage(CPDFXFA_Page* page); | 51 void RemovePage(CPDFXFA_Page* page); |
| 54 | 52 |
| 55 void ClearChangeMark(); | 53 void ClearChangeMark(); |
| 56 | 54 |
| 57 protected: | 55 protected: |
| 58 friend class CPDFXFA_DocEnvironment; | 56 friend class CPDFXFA_DocEnvironment; |
| 59 | 57 |
| 60 int GetOriginalPageCount() const { return m_nPageCount; } | 58 int GetOriginalPageCount() const { return m_nPageCount; } |
| 61 void SetOriginalPageCount(int count) { | 59 void SetOriginalPageCount(int count) { |
| 62 m_nPageCount = count; | 60 m_nPageCount = count; |
| 63 m_XFAPageList.SetSize(count); | 61 m_XFAPageList.SetSize(count); |
| 64 } | 62 } |
| 65 | 63 |
| 66 LoadStatus GetLoadStatus() const { return m_nLoadStatus; } | 64 LoadStatus GetLoadStatus() const { return m_nLoadStatus; } |
| 67 | 65 |
| 68 CFX_ArrayTemplate<CPDFXFA_Page*>* GetXFAPageList() { return &m_XFAPageList; } | 66 CFX_ArrayTemplate<CPDFXFA_Page*>* GetXFAPageList() { return &m_XFAPageList; } |
| 69 | 67 |
| 70 private: | 68 private: |
| 71 void CloseXFADoc(CXFA_FFDocHandler* pDoc) { | 69 void CloseXFADoc(CXFA_FFDocHandler* pDoc); |
| 72 if (pDoc) { | |
| 73 m_pXFADoc->CloseDoc(); | |
| 74 m_pXFADoc.reset(); | |
| 75 m_pXFADocView = nullptr; | |
| 76 } | |
| 77 } | |
| 78 | 70 |
| 79 int m_iDocType; | 71 int m_iDocType; |
| 80 | 72 |
| 81 std::unique_ptr<CPDF_Document> m_pPDFDoc; | 73 std::unique_ptr<CPDF_Document> m_pPDFDoc; |
| 82 std::unique_ptr<CXFA_FFDoc> m_pXFADoc; | 74 std::unique_ptr<CXFA_FFDoc> m_pXFADoc; |
| 83 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; // not owned. | 75 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; // not owned. |
| 84 CXFA_FFDocView* m_pXFADocView; // not owned. | 76 CXFA_FFDocView* m_pXFADocView; // not owned. |
| 85 CPDFXFA_App* const m_pApp; | 77 std::unique_ptr<CPDFXFA_App> m_pApp; |
| 86 CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; | 78 CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; |
| 87 LoadStatus m_nLoadStatus; | 79 LoadStatus m_nLoadStatus; |
| 88 int m_nPageCount; | 80 int m_nPageCount; |
| 89 | 81 |
| 90 // Must be destroyed before |m_pFormFillEnv|. | 82 // Must be destroyed before |m_pFormFillEnv|. |
| 91 CPDFXFA_DocEnvironment m_DocEnv; | 83 CPDFXFA_DocEnvironment m_DocEnv; |
| 92 }; | 84 }; |
| 93 | 85 |
| 94 #endif // FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ | 86 #endif // FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ |
| OLD | NEW |