OLD | NEW |
| (Empty) |
1 // Copyright 2016 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_INCLUDE_CPDFSDK_ENVIRONMENT_H_ | |
8 #define FPDFSDK_INCLUDE_CPDFSDK_ENVIRONMENT_H_ | |
9 | |
10 #include <memory> | |
11 | |
12 #include "core/fpdfapi/fpdf_page/cpdf_page.h" | |
13 #include "core/fpdfapi/fpdf_parser/cpdf_document.h" | |
14 #include "core/fpdfdoc/cpdf_occontext.h" | |
15 #include "core/fxcrt/cfx_observable.h" | |
16 #include "fpdfsdk/cfx_systemhandler.h" | |
17 #include "fpdfsdk/include/fsdk_define.h" | |
18 #include "public/fpdf_formfill.h" | |
19 #include "public/fpdf_fwlevent.h" | |
20 | |
21 class CFFL_InteractiveFormFiller; | |
22 class CFX_SystemHandler; | |
23 class CPDFSDK_ActionHandler; | |
24 class CPDFSDK_AnnotHandlerMgr; | |
25 class CPDFSDK_Document; | |
26 class IJS_Runtime; | |
27 | |
28 class CPDFSDK_Environment final { | |
29 public: | |
30 CPDFSDK_Environment(UnderlyingDocumentType* pDoc, FPDF_FORMFILLINFO* pFFinfo); | |
31 ~CPDFSDK_Environment(); | |
32 | |
33 void Invalidate(FPDF_PAGE page, | |
34 double left, | |
35 double top, | |
36 double right, | |
37 double bottom); | |
38 void OutputSelectedRect(FPDF_PAGE page, | |
39 double left, | |
40 double top, | |
41 double right, | |
42 double bottom); | |
43 | |
44 void SetCursor(int nCursorType); | |
45 int SetTimer(int uElapse, TimerCallback lpTimerFunc); | |
46 void KillTimer(int nTimerID); | |
47 FX_SYSTEMTIME GetLocalTime() const; | |
48 | |
49 void OnChange(); | |
50 FX_BOOL IsSHIFTKeyDown(uint32_t nFlag) const; | |
51 FX_BOOL IsCTRLKeyDown(uint32_t nFlag) const; | |
52 FX_BOOL IsALTKeyDown(uint32_t nFlag) const; | |
53 | |
54 FPDF_PAGE GetPage(FPDF_DOCUMENT document, int nPageIndex); | |
55 FPDF_PAGE GetCurrentPage(FPDF_DOCUMENT document); | |
56 | |
57 void ExecuteNamedAction(const FX_CHAR* namedAction); | |
58 void OnSetFieldInputFocus(FPDF_WIDESTRING focusText, | |
59 FPDF_DWORD nTextLen, | |
60 FX_BOOL bFocus); | |
61 void DoURIAction(const FX_CHAR* bsURI); | |
62 void DoGoToAction(int nPageIndex, | |
63 int zoomMode, | |
64 float* fPosArray, | |
65 int sizeOfArray); | |
66 | |
67 #ifdef PDF_ENABLE_XFA | |
68 void DisplayCaret(FPDF_PAGE page, | |
69 FPDF_BOOL bVisible, | |
70 double left, | |
71 double top, | |
72 double right, | |
73 double bottom); | |
74 int GetCurrentPageIndex(FPDF_DOCUMENT document); | |
75 void SetCurrentPage(FPDF_DOCUMENT document, int iCurPage); | |
76 | |
77 // TODO(dsinclair): This should probably change to PDFium? | |
78 CFX_WideString FFI_GetAppName() const { return CFX_WideString(L"Acrobat"); } | |
79 | |
80 CFX_WideString GetPlatform(); | |
81 void GotoURL(FPDF_DOCUMENT document, const CFX_WideStringC& wsURL); | |
82 void GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect); | |
83 FX_BOOL PopupMenu(FPDF_PAGE page, | |
84 FPDF_WIDGET hWidget, | |
85 int menuFlag, | |
86 CFX_PointF pt); | |
87 | |
88 void Alert(FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, int Type, int Icon); | |
89 void EmailTo(FPDF_FILEHANDLER* fileHandler, | |
90 FPDF_WIDESTRING pTo, | |
91 FPDF_WIDESTRING pSubject, | |
92 FPDF_WIDESTRING pCC, | |
93 FPDF_WIDESTRING pBcc, | |
94 FPDF_WIDESTRING pMsg); | |
95 void UploadTo(FPDF_FILEHANDLER* fileHandler, | |
96 int fileFlag, | |
97 FPDF_WIDESTRING uploadTo); | |
98 FPDF_FILEHANDLER* OpenFile(int fileType, | |
99 FPDF_WIDESTRING wsURL, | |
100 const char* mode); | |
101 IFX_FileRead* DownloadFromURL(const FX_WCHAR* url); | |
102 CFX_WideString PostRequestURL(const FX_WCHAR* wsURL, | |
103 const FX_WCHAR* wsData, | |
104 const FX_WCHAR* wsContentType, | |
105 const FX_WCHAR* wsEncode, | |
106 const FX_WCHAR* wsHeader); | |
107 FPDF_BOOL PutRequestURL(const FX_WCHAR* wsURL, | |
108 const FX_WCHAR* wsData, | |
109 const FX_WCHAR* wsEncode); | |
110 CFX_WideString GetLanguage(); | |
111 | |
112 void PageEvent(int iPageCount, uint32_t dwEventType) const; | |
113 #endif // PDF_ENABLE_XFA | |
114 | |
115 int JS_appAlert(const FX_WCHAR* Msg, | |
116 const FX_WCHAR* Title, | |
117 uint32_t Type, | |
118 uint32_t Icon); | |
119 int JS_appResponse(const FX_WCHAR* Question, | |
120 const FX_WCHAR* Title, | |
121 const FX_WCHAR* Default, | |
122 const FX_WCHAR* cLabel, | |
123 FPDF_BOOL bPassword, | |
124 void* response, | |
125 int length); | |
126 void JS_appBeep(int nType); | |
127 CFX_WideString JS_fieldBrowse(); | |
128 CFX_WideString JS_docGetFilePath(); | |
129 void JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL); | |
130 void JS_docmailForm(void* mailData, | |
131 int length, | |
132 FPDF_BOOL bUI, | |
133 const FX_WCHAR* To, | |
134 const FX_WCHAR* Subject, | |
135 const FX_WCHAR* CC, | |
136 const FX_WCHAR* BCC, | |
137 const FX_WCHAR* Msg); | |
138 void JS_docprint(FPDF_BOOL bUI, | |
139 int nStart, | |
140 int nEnd, | |
141 FPDF_BOOL bSilent, | |
142 FPDF_BOOL bShrinkToFit, | |
143 FPDF_BOOL bPrintAsImage, | |
144 FPDF_BOOL bReverse, | |
145 FPDF_BOOL bAnnotations); | |
146 void JS_docgotoPage(int nPageNum); | |
147 | |
148 FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; } | |
149 void SetSDKDocument(CPDFSDK_Document* pFXDoc) { m_pSDKDoc = pFXDoc; } | |
150 CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc; } | |
151 UnderlyingDocumentType* GetUnderlyingDocument() const { | |
152 return m_pUnderlyingDoc; | |
153 } | |
154 CFX_ByteString GetAppName() const { return ""; } | |
155 CFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); } | |
156 FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; } | |
157 | |
158 // Creates if not present. | |
159 CFFL_InteractiveFormFiller* GetInteractiveFormFiller(); | |
160 CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present. | |
161 IJS_Runtime* GetJSRuntime(); // Creates if not present. | |
162 CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present. | |
163 | |
164 private: | |
165 std::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr; | |
166 std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler; | |
167 std::unique_ptr<IJS_Runtime> m_pJSRuntime; | |
168 FPDF_FORMFILLINFO* const m_pInfo; | |
169 // Ownership of |m_pSDKDoc| depends on if this is XFA. If we're in XFA then | |
170 // the object is owned by the CPDFXFA_Document. In non-xfa then we own | |
171 // the pointer. | |
172 CPDFSDK_Document* m_pSDKDoc; | |
173 UnderlyingDocumentType* const m_pUnderlyingDoc; | |
174 std::unique_ptr<CFFL_InteractiveFormFiller> m_pFormFiller; | |
175 std::unique_ptr<CFX_SystemHandler> m_pSysHandler; | |
176 }; | |
177 | |
178 #endif // FPDFSDK_INCLUDE_CPDFSDK_ENVIRONMENT_H_ | |
OLD | NEW |