Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: fpdfsdk/fpdfxfa/cpdfxfa_document.h

Issue 2414883006: Revert of Reland: Make the CPDFXFA_App non-global (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdfxfa/cpdfxfa_app.cpp ('k') | fpdfsdk/fpdfxfa/cpdfxfa_document.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
16 class CPDFSDK_FormFillEnvironment; 15 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);
33 ~CPDFXFA_Document(); 34 ~CPDFXFA_Document();
34 35
35 FX_BOOL LoadXFADoc(); 36 FX_BOOL LoadXFADoc();
36 CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); } 37 CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); }
37 CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } 38 CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); }
38 CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } 39 CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; }
39 int GetDocType() const { return m_iDocType; } 40 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);
45 m_pFormFillEnv = pFormFillEnv; 44 m_pFormFillEnv = pFormFillEnv;
46 } 45 }
47 46
48 void DeletePage(int page_index); 47 void DeletePage(int page_index);
49 int GetPageCount() const; 48 int GetPageCount() const;
50 49
51 CPDFXFA_Page* GetXFAPage(int page_index); 50 CPDFXFA_Page* GetXFAPage(int page_index);
52 CPDFXFA_Page* GetXFAPage(CXFA_FFPageView* pPage) const; 51 CPDFXFA_Page* GetXFAPage(CXFA_FFPageView* pPage) const;
53 52
54 void RemovePage(CPDFXFA_Page* page); 53 void RemovePage(CPDFXFA_Page* page);
55 54
56 void ClearChangeMark(); 55 void ClearChangeMark();
57 56
58 protected: 57 protected:
59 friend class CPDFXFA_DocEnvironment; 58 friend class CPDFXFA_DocEnvironment;
60 59
61 int GetOriginalPageCount() const { return m_nPageCount; } 60 int GetOriginalPageCount() const { return m_nPageCount; }
62 void SetOriginalPageCount(int count) { 61 void SetOriginalPageCount(int count) {
63 m_nPageCount = count; 62 m_nPageCount = count;
64 m_XFAPageList.SetSize(count); 63 m_XFAPageList.SetSize(count);
65 } 64 }
66 65
67 LoadStatus GetLoadStatus() const { return m_nLoadStatus; } 66 LoadStatus GetLoadStatus() const { return m_nLoadStatus; }
68 67
69 CFX_ArrayTemplate<CPDFXFA_Page*>* GetXFAPageList() { return &m_XFAPageList; } 68 CFX_ArrayTemplate<CPDFXFA_Page*>* GetXFAPageList() { return &m_XFAPageList; }
70 69
71 private: 70 private:
72 void CloseXFADoc(CXFA_FFDocHandler* pDoc); 71 void CloseXFADoc(CXFA_FFDocHandler* pDoc) {
72 if (pDoc) {
73 m_pXFADoc->CloseDoc();
74 m_pXFADoc.reset();
75 m_pXFADocView = nullptr;
76 }
77 }
73 78
74 int m_iDocType; 79 int m_iDocType;
75 80
76 std::unique_ptr<CPDF_Document> m_pPDFDoc; 81 std::unique_ptr<CPDF_Document> m_pPDFDoc;
77 std::unique_ptr<CXFA_FFDoc> m_pXFADoc; 82 std::unique_ptr<CXFA_FFDoc> m_pXFADoc;
78 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; // not owned. 83 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; // not owned.
79 CXFA_FFDocView* m_pXFADocView; // not owned. 84 CXFA_FFDocView* m_pXFADocView; // not owned.
80 std::unique_ptr<CPDFXFA_App> m_pApp; 85 CPDFXFA_App* const m_pApp;
81 CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList; 86 CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList;
82 LoadStatus m_nLoadStatus; 87 LoadStatus m_nLoadStatus;
83 int m_nPageCount; 88 int m_nPageCount;
84 89
85 // Must be destroyed before |m_pFormFillEnv|. 90 // Must be destroyed before |m_pFormFillEnv|.
86 CPDFXFA_DocEnvironment m_DocEnv; 91 CPDFXFA_DocEnvironment m_DocEnv;
87 }; 92 };
88 93
89 #endif // FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_ 94 #endif // FPDFSDK_FPDFXFA_CPDFXFA_DOCUMENT_H_
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfxfa/cpdfxfa_app.cpp ('k') | fpdfsdk/fpdfxfa/cpdfxfa_document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698