OLD | NEW |
---|---|
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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_CPDFSDK_FORMFILLENVIRONMENT_H_ | 7 #ifndef FPDFSDK_CPDFSDK_FORMFILLENVIRONMENT_H_ |
8 #define FPDFSDK_CPDFSDK_FORMFILLENVIRONMENT_H_ | 8 #define FPDFSDK_CPDFSDK_FORMFILLENVIRONMENT_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "core/fpdfapi/page/cpdf_page.h" | 12 #include "core/fpdfapi/page/cpdf_page.h" |
13 #include "core/fpdfapi/parser/cpdf_document.h" | 13 #include "core/fpdfapi/parser/cpdf_document.h" |
14 #include "core/fpdfdoc/cpdf_occontext.h" | 14 #include "core/fpdfdoc/cpdf_occontext.h" |
15 #include "core/fxcrt/cfx_observable.h" | 15 #include "core/fxcrt/cfx_observable.h" |
16 #include "fpdfsdk/cfx_systemhandler.h" | 16 #include "fpdfsdk/cfx_systemhandler.h" |
17 #include "fpdfsdk/cpdfsdk_annot.h" | |
17 #include "fpdfsdk/fsdk_define.h" | 18 #include "fpdfsdk/fsdk_define.h" |
18 #include "public/fpdf_formfill.h" | 19 #include "public/fpdf_formfill.h" |
19 #include "public/fpdf_fwlevent.h" | 20 #include "public/fpdf_fwlevent.h" |
20 | 21 |
21 class CFFL_InteractiveFormFiller; | 22 class CFFL_InteractiveFormFiller; |
22 class CFX_SystemHandler; | 23 class CFX_SystemHandler; |
23 class CPDFSDK_ActionHandler; | 24 class CPDFSDK_ActionHandler; |
24 class CPDFSDK_AnnotHandlerMgr; | 25 class CPDFSDK_AnnotHandlerMgr; |
25 class CPDFSDK_Document; | 26 class CPDFSDK_InterForm; |
27 class CPDFSDK_PageView; | |
26 class IJS_Runtime; | 28 class IJS_Runtime; |
27 | 29 |
28 class CPDFSDK_FormFillEnvironment | 30 class CPDFSDK_FormFillEnvironment |
29 : public CFX_Observable<CPDFSDK_FormFillEnvironment> { | 31 : public CFX_Observable<CPDFSDK_FormFillEnvironment> { |
30 public: | 32 public: |
31 CPDFSDK_FormFillEnvironment(UnderlyingDocumentType* pDoc, | 33 CPDFSDK_FormFillEnvironment(UnderlyingDocumentType* pDoc, |
32 FPDF_FORMFILLINFO* pFFinfo); | 34 FPDF_FORMFILLINFO* pFFinfo); |
33 ~CPDFSDK_FormFillEnvironment(); | 35 ~CPDFSDK_FormFillEnvironment(); |
34 | 36 |
37 CPDFSDK_InterForm* GetInterForm(); | |
Tom Sepez
2016/10/12 18:52:59
nit: const method?
dsinclair
2016/10/12 19:44:29
Can't, creates if doesn't exist. Moved down with o
| |
38 | |
39 // Gets the document object for the next layer down; for master this is | |
40 // a CPDF_Document, but for XFA it is a CPDFXFA_Document. | |
41 UnderlyingDocumentType* GetUnderlyingDocument() const { | |
42 #ifdef PDF_ENABLE_XFA | |
43 return GetXFADocument(); | |
44 #else // PDF_ENABLE_XFA | |
45 return GetPDFDocument(); | |
46 #endif // PDF_ENABLE_XFA | |
47 } | |
48 | |
49 // Gets the CPDF_Document, either directly in master, or from the | |
50 // CPDFXFA_Document for XFA. | |
51 CPDF_Document* GetPDFDocument() const { | |
52 #ifdef PDF_ENABLE_XFA | |
53 return m_pUnderlyingDoc ? m_pUnderlyingDoc->GetPDFDoc() : nullptr; | |
54 #else // PDF_ENABLE_XFA | |
55 return m_pUnderlyingDoc; | |
56 #endif // PDF_ENABLE_XFA | |
57 } | |
58 | |
59 #ifdef PDF_ENABLE_XFA | |
60 // Gets the XFA document directly (XFA-only). | |
61 CPDFXFA_Document* GetXFADocument() const { return m_pUnderlyingDoc; } | |
62 void ResetXFADocument() { m_pUnderlyingDoc = nullptr; } | |
63 | |
64 int GetPageViewCount() const { return m_pageMap.size(); } | |
65 #endif // PDF_ENABLE_XFA | |
66 | |
67 CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPage, bool ReNew); | |
68 CPDFSDK_PageView* GetPageView(int nIndex); | |
69 CPDFSDK_PageView* GetCurrentView(); | |
70 void RemovePageView(UnderlyingPageType* pPage); | |
71 void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); | |
72 | |
73 CPDFSDK_Annot* GetFocusAnnot() { return m_pFocusAnnot.Get(); } | |
74 FX_BOOL SetFocusAnnot(CPDFSDK_Annot::ObservedPtr* pAnnot); | |
75 FX_BOOL KillFocusAnnot(uint32_t nFlag); | |
76 void ClearAllFocusedAnnots(); | |
77 | |
78 FX_BOOL ExtractPages(const std::vector<uint16_t>& arrExtraPages, | |
79 CPDF_Document* pDstDoc); | |
80 FX_BOOL InsertPages(int nInsertAt, | |
81 const CPDF_Document* pSrcDoc, | |
82 const std::vector<uint16_t>& arrSrcPages); | |
83 FX_BOOL ReplacePages(int nPage, | |
84 const CPDF_Document* pSrcDoc, | |
85 const std::vector<uint16_t>& arrSrcPages); | |
86 | |
87 int GetPageCount() { return m_pUnderlyingDoc->GetPageCount(); } | |
88 FX_BOOL GetPermissions(int nFlag); | |
89 | |
90 FX_BOOL GetChangeMark() { return m_bChangeMask; } | |
Tom Sepez
2016/10/12 18:52:59
nit: const method.
dsinclair
2016/10/12 19:44:29
Done.
| |
91 void SetChangeMark() { m_bChangeMask = TRUE; } | |
92 void ClearChangeMark() { m_bChangeMask = FALSE; } | |
93 | |
94 UnderlyingPageType* GetPage(int nIndex); | |
95 | |
96 void ProcJavascriptFun(); | |
97 FX_BOOL ProcOpenAction(); | |
98 | |
35 void Invalidate(FPDF_PAGE page, | 99 void Invalidate(FPDF_PAGE page, |
36 double left, | 100 double left, |
37 double top, | 101 double top, |
38 double right, | 102 double right, |
39 double bottom); | 103 double bottom); |
40 void OutputSelectedRect(FPDF_PAGE page, | 104 void OutputSelectedRect(FPDF_PAGE page, |
41 double left, | 105 double left, |
42 double top, | 106 double top, |
43 double right, | 107 double right, |
44 double bottom); | 108 double bottom); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 int nStart, | 205 int nStart, |
142 int nEnd, | 206 int nEnd, |
143 FPDF_BOOL bSilent, | 207 FPDF_BOOL bSilent, |
144 FPDF_BOOL bShrinkToFit, | 208 FPDF_BOOL bShrinkToFit, |
145 FPDF_BOOL bPrintAsImage, | 209 FPDF_BOOL bPrintAsImage, |
146 FPDF_BOOL bReverse, | 210 FPDF_BOOL bReverse, |
147 FPDF_BOOL bAnnotations); | 211 FPDF_BOOL bAnnotations); |
148 void JS_docgotoPage(int nPageNum); | 212 void JS_docgotoPage(int nPageNum); |
149 | 213 |
150 FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; } | 214 FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; } |
151 CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc.get(); } | |
152 UnderlyingDocumentType* GetUnderlyingDocument() const { | |
153 return m_pUnderlyingDoc; | |
154 } | |
155 CFX_ByteString GetAppName() const { return ""; } | 215 CFX_ByteString GetAppName() const { return ""; } |
156 CFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); } | 216 CFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); } |
157 FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; } | 217 FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; } |
158 | 218 |
159 // Creates if not present. | 219 // Creates if not present. |
160 CFFL_InteractiveFormFiller* GetInteractiveFormFiller(); | 220 CFFL_InteractiveFormFiller* GetInteractiveFormFiller(); |
161 CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present. | 221 CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present. |
162 IJS_Runtime* GetJSRuntime(); // Creates if not present. | 222 IJS_Runtime* GetJSRuntime(); // Creates if not present. |
163 CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present. | 223 CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present. |
164 | 224 |
165 private: | 225 private: |
166 std::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr; | 226 std::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr; |
167 std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler; | 227 std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler; |
168 std::unique_ptr<IJS_Runtime> m_pJSRuntime; | 228 std::unique_ptr<IJS_Runtime> m_pJSRuntime; |
169 FPDF_FORMFILLINFO* const m_pInfo; | 229 FPDF_FORMFILLINFO* const m_pInfo; |
170 std::unique_ptr<CPDFSDK_Document> m_pSDKDoc; | 230 std::map<UnderlyingPageType*, CPDFSDK_PageView*> m_pageMap; |
171 UnderlyingDocumentType* const m_pUnderlyingDoc; | 231 std::unique_ptr<CPDFSDK_InterForm> m_pInterForm; |
232 CPDFSDK_Annot::ObservedPtr m_pFocusAnnot; | |
233 UnderlyingDocumentType* m_pUnderlyingDoc; | |
172 std::unique_ptr<CFFL_InteractiveFormFiller> m_pFormFiller; | 234 std::unique_ptr<CFFL_InteractiveFormFiller> m_pFormFiller; |
173 std::unique_ptr<CFX_SystemHandler> m_pSysHandler; | 235 std::unique_ptr<CFX_SystemHandler> m_pSysHandler; |
236 FX_BOOL m_bChangeMask; | |
Tom Sepez
2016/10/12 18:53:00
nit: bool (next line too)
dsinclair
2016/10/12 19:44:29
Done.
| |
237 FX_BOOL m_bBeingDestroyed; | |
174 }; | 238 }; |
175 | 239 |
176 #endif // FPDFSDK_CPDFSDK_FORMFILLENVIRONMENT_H_ | 240 #endif // FPDFSDK_CPDFSDK_FORMFILLENVIRONMENT_H_ |
OLD | NEW |