| 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_CPDFSDK_ENVIRONMENT_H_ | |
| 8 #define FPDFSDK_CPDFSDK_ENVIRONMENT_H_ | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "core/fpdfapi/page/cpdf_page.h" | |
| 13 #include "core/fpdfapi/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/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 CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc.get(); } | |
| 150 UnderlyingDocumentType* GetUnderlyingDocument() const { | |
| 151 return m_pUnderlyingDoc; | |
| 152 } | |
| 153 CFX_ByteString GetAppName() const { return ""; } | |
| 154 CFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); } | |
| 155 FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; } | |
| 156 | |
| 157 // Creates if not present. | |
| 158 CFFL_InteractiveFormFiller* GetInteractiveFormFiller(); | |
| 159 CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present. | |
| 160 IJS_Runtime* GetJSRuntime(); // Creates if not present. | |
| 161 CPDFSDK_ActionHandler* GetActionHander(); // Creates if not present. | |
| 162 | |
| 163 private: | |
| 164 std::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr; | |
| 165 std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler; | |
| 166 std::unique_ptr<IJS_Runtime> m_pJSRuntime; | |
| 167 FPDF_FORMFILLINFO* const m_pInfo; | |
| 168 std::unique_ptr<CPDFSDK_Document> m_pSDKDoc; | |
| 169 UnderlyingDocumentType* const m_pUnderlyingDoc; | |
| 170 std::unique_ptr<CFFL_InteractiveFormFiller> m_pFormFiller; | |
| 171 std::unique_ptr<CFX_SystemHandler> m_pSysHandler; | |
| 172 }; | |
| 173 | |
| 174 #endif // FPDFSDK_CPDFSDK_ENVIRONMENT_H_ | |
| OLD | NEW |