| 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_INCLUDE_CPDFSDK_ENVIRONMENT_H_ | 7 #ifndef FPDFSDK_INCLUDE_CPDFSDK_ENVIRONMENT_H_ |
| 8 #define FPDFSDK_INCLUDE_CPDFSDK_ENVIRONMENT_H_ | 8 #define FPDFSDK_INCLUDE_CPDFSDK_ENVIRONMENT_H_ |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 class CPDFSDK_ActionHandler; | 23 class CPDFSDK_ActionHandler; |
| 24 class CPDFSDK_AnnotHandlerMgr; | 24 class CPDFSDK_AnnotHandlerMgr; |
| 25 class CPDFSDK_Document; | 25 class CPDFSDK_Document; |
| 26 class IJS_Runtime; | 26 class IJS_Runtime; |
| 27 | 27 |
| 28 class CPDFSDK_Environment final { | 28 class CPDFSDK_Environment final { |
| 29 public: | 29 public: |
| 30 CPDFSDK_Environment(UnderlyingDocumentType* pDoc, FPDF_FORMFILLINFO* pFFinfo); | 30 CPDFSDK_Environment(UnderlyingDocumentType* pDoc, FPDF_FORMFILLINFO* pFFinfo); |
| 31 ~CPDFSDK_Environment(); | 31 ~CPDFSDK_Environment(); |
| 32 | 32 |
| 33 void FFI_Invalidate(FPDF_PAGE page, | 33 void Invalidate(FPDF_PAGE page, |
| 34 double left, | 34 double left, |
| 35 double top, | 35 double top, |
| 36 double right, | 36 double right, |
| 37 double bottom) { | 37 double bottom) { |
| 38 if (m_pInfo && m_pInfo->FFI_Invalidate) | 38 if (m_pInfo && m_pInfo->FFI_Invalidate) |
| 39 m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); | 39 m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void FFI_OutputSelectedRect(FPDF_PAGE page, | 42 void OutputSelectedRect(FPDF_PAGE page, |
| 43 double left, | 43 double left, |
| 44 double top, | 44 double top, |
| 45 double right, | 45 double right, |
| 46 double bottom) { | 46 double bottom) { |
| 47 if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) | 47 if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) |
| 48 m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); | 48 m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void FFI_SetCursor(int nCursorType) { | 51 void SetCursor(int nCursorType) { |
| 52 if (m_pInfo && m_pInfo->FFI_SetCursor) | 52 if (m_pInfo && m_pInfo->FFI_SetCursor) |
| 53 m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); | 53 m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); |
| 54 } | 54 } |
| 55 | 55 |
| 56 int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc) { | 56 int SetTimer(int uElapse, TimerCallback lpTimerFunc) { |
| 57 if (m_pInfo && m_pInfo->FFI_SetTimer) | 57 if (m_pInfo && m_pInfo->FFI_SetTimer) |
| 58 return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); | 58 return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); |
| 59 return -1; | 59 return -1; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void FFI_KillTimer(int nTimerID) { | 62 void KillTimer(int nTimerID) { |
| 63 if (m_pInfo && m_pInfo->FFI_KillTimer) | 63 if (m_pInfo && m_pInfo->FFI_KillTimer) |
| 64 m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); | 64 m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); |
| 65 } | 65 } |
| 66 | 66 |
| 67 FX_SYSTEMTIME FFI_GetLocalTime() const { | 67 FX_SYSTEMTIME GetLocalTime() const { |
| 68 FX_SYSTEMTIME fxtime; | 68 FX_SYSTEMTIME fxtime; |
| 69 if (m_pInfo && m_pInfo->FFI_GetLocalTime) { | 69 if (m_pInfo && m_pInfo->FFI_GetLocalTime) { |
| 70 FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); | 70 FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); |
| 71 fxtime.wDay = systime.wDay; | 71 fxtime.wDay = systime.wDay; |
| 72 fxtime.wDayOfWeek = systime.wDayOfWeek; | 72 fxtime.wDayOfWeek = systime.wDayOfWeek; |
| 73 fxtime.wHour = systime.wHour; | 73 fxtime.wHour = systime.wHour; |
| 74 fxtime.wMilliseconds = systime.wMilliseconds; | 74 fxtime.wMilliseconds = systime.wMilliseconds; |
| 75 fxtime.wMinute = systime.wMinute; | 75 fxtime.wMinute = systime.wMinute; |
| 76 fxtime.wMonth = systime.wMonth; | 76 fxtime.wMonth = systime.wMonth; |
| 77 fxtime.wSecond = systime.wSecond; | 77 fxtime.wSecond = systime.wSecond; |
| 78 fxtime.wYear = systime.wYear; | 78 fxtime.wYear = systime.wYear; |
| 79 } | 79 } |
| 80 return fxtime; | 80 return fxtime; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void FFI_OnChange() { | 83 void OnChange() { |
| 84 if (m_pInfo && m_pInfo->FFI_OnChange) | 84 if (m_pInfo && m_pInfo->FFI_OnChange) |
| 85 m_pInfo->FFI_OnChange(m_pInfo); | 85 m_pInfo->FFI_OnChange(m_pInfo); |
| 86 } | 86 } |
| 87 | 87 |
| 88 FX_BOOL FFI_IsSHIFTKeyDown(uint32_t nFlag) const { | 88 FX_BOOL IsSHIFTKeyDown(uint32_t nFlag) const { |
| 89 return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; | 89 return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; |
| 90 } | 90 } |
| 91 | 91 |
| 92 FX_BOOL FFI_IsCTRLKeyDown(uint32_t nFlag) const { | 92 FX_BOOL IsCTRLKeyDown(uint32_t nFlag) const { |
| 93 return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; | 93 return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; |
| 94 } | 94 } |
| 95 | 95 |
| 96 FX_BOOL FFI_IsALTKeyDown(uint32_t nFlag) const { | 96 FX_BOOL IsALTKeyDown(uint32_t nFlag) const { |
| 97 return (nFlag & FWL_EVENTFLAG_AltKey) != 0; | 97 return (nFlag & FWL_EVENTFLAG_AltKey) != 0; |
| 98 } | 98 } |
| 99 | 99 |
| 100 FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document, int nPageIndex) { | 100 FPDF_PAGE GetPage(FPDF_DOCUMENT document, int nPageIndex) { |
| 101 if (m_pInfo && m_pInfo->FFI_GetPage) | 101 if (m_pInfo && m_pInfo->FFI_GetPage) |
| 102 return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); | 102 return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); |
| 103 return nullptr; | 103 return nullptr; |
| 104 } | 104 } |
| 105 | 105 |
| 106 FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document) { | 106 FPDF_PAGE GetCurrentPage(FPDF_DOCUMENT document) { |
| 107 if (m_pInfo && m_pInfo->FFI_GetCurrentPage) | 107 if (m_pInfo && m_pInfo->FFI_GetCurrentPage) |
| 108 return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); | 108 return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); |
| 109 return nullptr; | 109 return nullptr; |
| 110 } | 110 } |
| 111 | 111 |
| 112 int FFI_GetRotation(FPDF_PAGE page) { | 112 void ExecuteNamedAction(const FX_CHAR* namedAction) { |
| 113 if (m_pInfo && m_pInfo->FFI_GetRotation) | |
| 114 return m_pInfo->FFI_GetRotation(m_pInfo, page); | |
| 115 return 0; | |
| 116 } | |
| 117 | |
| 118 void FFI_ExecuteNamedAction(const FX_CHAR* namedAction) { | |
| 119 if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction) | 113 if (m_pInfo && m_pInfo->FFI_ExecuteNamedAction) |
| 120 m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); | 114 m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); |
| 121 } | 115 } |
| 122 | 116 |
| 123 void FFI_OnSetFieldInputFocus(void* field, | 117 void OnSetFieldInputFocus(void* field, |
| 124 FPDF_WIDESTRING focusText, | 118 FPDF_WIDESTRING focusText, |
| 125 FPDF_DWORD nTextLen, | 119 FPDF_DWORD nTextLen, |
| 126 FX_BOOL bFocus) { | 120 FX_BOOL bFocus) { |
| 127 if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus) | 121 if (m_pInfo && m_pInfo->FFI_SetTextFieldFocus) |
| 128 m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); | 122 m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); |
| 129 } | 123 } |
| 130 | 124 |
| 131 void FFI_DoURIAction(const FX_CHAR* bsURI) { | 125 void DoURIAction(const FX_CHAR* bsURI) { |
| 132 if (m_pInfo && m_pInfo->FFI_DoURIAction) | 126 if (m_pInfo && m_pInfo->FFI_DoURIAction) |
| 133 m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); | 127 m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); |
| 134 } | 128 } |
| 135 | 129 |
| 136 void FFI_DoGoToAction(int nPageIndex, | 130 void DoGoToAction(int nPageIndex, |
| 137 int zoomMode, | 131 int zoomMode, |
| 138 float* fPosArray, | 132 float* fPosArray, |
| 139 int sizeOfArray) { | 133 int sizeOfArray) { |
| 140 if (m_pInfo && m_pInfo->FFI_DoGoToAction) | 134 if (m_pInfo && m_pInfo->FFI_DoGoToAction) |
| 141 m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, | 135 m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, |
| 142 sizeOfArray); | 136 sizeOfArray); |
| 143 } | 137 } |
| 144 | 138 |
| 145 #ifdef PDF_ENABLE_XFA | 139 #ifdef PDF_ENABLE_XFA |
| 146 void FFI_DisplayCaret(FPDF_PAGE page, | 140 void DisplayCaret(FPDF_PAGE page, |
| 147 FPDF_BOOL bVisible, | 141 FPDF_BOOL bVisible, |
| 148 double left, | 142 double left, |
| 149 double top, | 143 double top, |
| 150 double right, | 144 double right, |
| 151 double bottom) { | 145 double bottom) { |
| 152 if (m_pInfo && m_pInfo->FFI_DisplayCaret) | 146 if (m_pInfo && m_pInfo->FFI_DisplayCaret) |
| 153 m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right, | 147 m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right, |
| 154 bottom); | 148 bottom); |
| 155 } | 149 } |
| 156 | 150 |
| 157 int FFI_GetCurrentPageIndex(FPDF_DOCUMENT document) { | 151 int GetCurrentPageIndex(FPDF_DOCUMENT document) { |
| 158 if (!m_pInfo || !m_pInfo->FFI_GetCurrentPageIndex) { | 152 if (!m_pInfo || !m_pInfo->FFI_GetCurrentPageIndex) |
| 159 return -1; | 153 return -1; |
| 160 } | |
| 161 return m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document); | 154 return m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document); |
| 162 } | 155 } |
| 163 | 156 |
| 164 void FFI_SetCurrentPage(FPDF_DOCUMENT document, int iCurPage) { | 157 void SetCurrentPage(FPDF_DOCUMENT document, int iCurPage) { |
| 165 if (m_pInfo && m_pInfo->FFI_SetCurrentPage) | 158 if (m_pInfo && m_pInfo->FFI_SetCurrentPage) |
| 166 m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage); | 159 m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage); |
| 167 } | 160 } |
| 168 | 161 |
| 162 // TODO(dsinclair): This should probably change to PDFium? |
| 169 CFX_WideString FFI_GetAppName() const { return CFX_WideString(L"Acrobat"); } | 163 CFX_WideString FFI_GetAppName() const { return CFX_WideString(L"Acrobat"); } |
| 170 | 164 |
| 171 CFX_WideString FFI_GetPlatform() { | 165 CFX_WideString GetPlatform() { |
| 172 if (m_pInfo && m_pInfo->FFI_GetPlatform) { | 166 if (!m_pInfo || !m_pInfo->FFI_GetPlatform) |
| 173 int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, nullptr, 0); | 167 return L""; |
| 174 if (nRequiredLen <= 0) | |
| 175 return L""; | |
| 176 | 168 |
| 177 char* pbuff = new char[nRequiredLen]; | 169 int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, nullptr, 0); |
| 178 memset(pbuff, 0, nRequiredLen); | 170 if (nRequiredLen <= 0) |
| 179 int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff, nRequiredLen); | 171 return L""; |
| 180 if (nActualLen <= 0 || nActualLen > nRequiredLen) { | 172 |
| 181 delete[] pbuff; | 173 char* pbuff = new char[nRequiredLen]; |
| 182 return L""; | 174 memset(pbuff, 0, nRequiredLen); |
| 183 } | 175 int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff, nRequiredLen); |
| 184 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); | 176 if (nActualLen <= 0 || nActualLen > nRequiredLen) { |
| 185 CFX_WideString wsRet = CFX_WideString::FromUTF16LE( | |
| 186 (unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), | |
| 187 bsRet.GetLength() / sizeof(unsigned short)); | |
| 188 delete[] pbuff; | 177 delete[] pbuff; |
| 189 return wsRet; | 178 return L""; |
| 190 } | 179 } |
| 191 return L""; | 180 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
| 181 CFX_WideString wsRet = CFX_WideString::FromUTF16LE( |
| 182 (unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), |
| 183 bsRet.GetLength() / sizeof(unsigned short)); |
| 184 delete[] pbuff; |
| 185 return wsRet; |
| 192 } | 186 } |
| 193 | 187 |
| 194 void FFI_GotoURL(FPDF_DOCUMENT document, | 188 void GotoURL(FPDF_DOCUMENT document, |
| 195 const CFX_WideStringC& wsURL, | 189 const CFX_WideStringC& wsURL, |
| 196 FX_BOOL bAppend) { | 190 FX_BOOL bAppend) { |
| 197 if (m_pInfo && m_pInfo->FFI_GotoURL) { | 191 if (m_pInfo && m_pInfo->FFI_GotoURL) { |
| 198 CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode(); | 192 CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode(); |
| 199 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLength()); | 193 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLength()); |
| 200 m_pInfo->FFI_GotoURL(m_pInfo, document, pTo); | 194 m_pInfo->FFI_GotoURL(m_pInfo, document, pTo); |
| 201 bsTo.ReleaseBuffer(); | 195 bsTo.ReleaseBuffer(); |
| 202 } | 196 } |
| 203 } | 197 } |
| 204 | 198 |
| 205 void FFI_GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect) { | 199 void GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect) { |
| 206 if (m_pInfo && m_pInfo->FFI_GetPageViewRect) { | 200 if (m_pInfo && m_pInfo->FFI_GetPageViewRect) { |
| 207 double left; | 201 double left; |
| 208 double top; | 202 double top; |
| 209 double right; | 203 double right; |
| 210 double bottom; | 204 double bottom; |
| 211 m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom); | 205 m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom); |
| 212 | 206 |
| 213 dstRect.left = static_cast<float>(left); | 207 dstRect.left = static_cast<float>(left); |
| 214 dstRect.top = static_cast<float>(top < bottom ? bottom : top); | 208 dstRect.top = static_cast<float>(top < bottom ? bottom : top); |
| 215 dstRect.bottom = static_cast<float>(top < bottom ? top : bottom); | 209 dstRect.bottom = static_cast<float>(top < bottom ? top : bottom); |
| 216 dstRect.right = static_cast<float>(right); | 210 dstRect.right = static_cast<float>(right); |
| 217 } | 211 } |
| 218 } | 212 } |
| 219 | 213 |
| 220 FX_BOOL FFI_PopupMenu(FPDF_PAGE page, | 214 FX_BOOL PopupMenu(FPDF_PAGE page, |
| 221 FPDF_WIDGET hWidget, | 215 FPDF_WIDGET hWidget, |
| 222 int menuFlag, | 216 int menuFlag, |
| 223 CFX_PointF ptPopup, | 217 CFX_PointF ptPopup, |
| 224 const CFX_PointF* pRectExclude) { | 218 const CFX_PointF* pRectExclude) { |
| 225 if (m_pInfo && m_pInfo->FFI_PopupMenu) | 219 if (m_pInfo && m_pInfo->FFI_PopupMenu) |
| 226 return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, ptPopup.x, | 220 return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, ptPopup.x, |
| 227 ptPopup.y); | 221 ptPopup.y); |
| 228 return FALSE; | 222 return FALSE; |
| 229 } | 223 } |
| 230 | 224 |
| 231 void FFI_Alert(FPDF_WIDESTRING Msg, | 225 void Alert(FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, int Type, int Icon) { |
| 232 FPDF_WIDESTRING Title, | |
| 233 int Type, | |
| 234 int Icon) { | |
| 235 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) | 226 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) |
| 236 m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title, | 227 m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title, |
| 237 Type, Icon); | 228 Type, Icon); |
| 238 } | 229 } |
| 239 | 230 |
| 240 void FFI_EmailTo(FPDF_FILEHANDLER* fileHandler, | 231 void EmailTo(FPDF_FILEHANDLER* fileHandler, |
| 241 FPDF_WIDESTRING pTo, | 232 FPDF_WIDESTRING pTo, |
| 242 FPDF_WIDESTRING pSubject, | 233 FPDF_WIDESTRING pSubject, |
| 243 FPDF_WIDESTRING pCC, | 234 FPDF_WIDESTRING pCC, |
| 244 FPDF_WIDESTRING pBcc, | 235 FPDF_WIDESTRING pBcc, |
| 245 FPDF_WIDESTRING pMsg) { | 236 FPDF_WIDESTRING pMsg) { |
| 246 if (m_pInfo && m_pInfo->FFI_EmailTo) | 237 if (m_pInfo && m_pInfo->FFI_EmailTo) |
| 247 m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, | 238 m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, |
| 248 pMsg); | 239 pMsg); |
| 249 } | 240 } |
| 250 | 241 |
| 251 void FFI_UploadTo(FPDF_FILEHANDLER* fileHandler, | 242 void UploadTo(FPDF_FILEHANDLER* fileHandler, |
| 252 int fileFlag, | 243 int fileFlag, |
| 253 FPDF_WIDESTRING uploadTo) { | 244 FPDF_WIDESTRING uploadTo) { |
| 254 if (m_pInfo && m_pInfo->FFI_UploadTo) | 245 if (m_pInfo && m_pInfo->FFI_UploadTo) |
| 255 m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo); | 246 m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo); |
| 256 } | 247 } |
| 257 | 248 |
| 258 FPDF_FILEHANDLER* FFI_OpenFile(int fileType, | 249 FPDF_FILEHANDLER* OpenFile(int fileType, |
| 259 FPDF_WIDESTRING wsURL, | 250 FPDF_WIDESTRING wsURL, |
| 260 const char* mode) { | 251 const char* mode) { |
| 261 if (m_pInfo && m_pInfo->FFI_OpenFile) | 252 if (m_pInfo && m_pInfo->FFI_OpenFile) |
| 262 return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode); | 253 return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode); |
| 263 return nullptr; | 254 return nullptr; |
| 264 } | 255 } |
| 265 | 256 |
| 266 CFX_WideString FFI_GetFilePath(FPDF_FILEHANDLER* pFileHandler) const { | 257 IFX_FileRead* DownloadFromURL(const FX_WCHAR* url) { |
| 267 return L""; | 258 if (!m_pInfo || !m_pInfo->FFI_DownloadFromURL) |
| 259 return nullptr; |
| 260 |
| 261 CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode(); |
| 262 FPDF_WIDESTRING wsURL = |
| 263 (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.GetLength()); |
| 264 |
| 265 FPDF_LPFILEHANDLER fileHandler = |
| 266 m_pInfo->FFI_DownloadFromURL(m_pInfo, wsURL); |
| 267 |
| 268 return new CFPDF_FileStream(fileHandler); |
| 268 } | 269 } |
| 269 | 270 |
| 270 int FFI_GetDocumentCount() const { return 0; } | 271 CFX_WideString PostRequestURL(const FX_WCHAR* wsURL, |
| 271 int FFI_GetCurDocument() const { return 0; } | 272 const FX_WCHAR* wsData, |
| 273 const FX_WCHAR* wsContentType, |
| 274 const FX_WCHAR* wsEncode, |
| 275 const FX_WCHAR* wsHeader) { |
| 276 if (!m_pInfo || !m_pInfo->FFI_PostRequestURL) |
| 277 return L""; |
| 272 | 278 |
| 273 IFX_FileRead* FFI_DownloadFromURL(const FX_WCHAR* url) { | 279 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); |
| 274 if (m_pInfo && m_pInfo->FFI_DownloadFromURL) { | 280 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); |
| 275 CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode(); | |
| 276 FPDF_WIDESTRING wsURL = | |
| 277 (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.GetLength()); | |
| 278 | 281 |
| 279 FPDF_LPFILEHANDLER fileHandler = | 282 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); |
| 280 m_pInfo->FFI_DownloadFromURL(m_pInfo, wsURL); | 283 FPDF_WIDESTRING data = |
| 284 (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); |
| 281 | 285 |
| 282 return new CFPDF_FileStream(fileHandler); | 286 CFX_ByteString bsContentType = |
| 283 } | 287 CFX_WideString(wsContentType).UTF16LE_Encode(); |
| 284 return nullptr; | 288 FPDF_WIDESTRING contentType = |
| 289 (FPDF_WIDESTRING)bsContentType.GetBuffer(bsContentType.GetLength()); |
| 290 |
| 291 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); |
| 292 FPDF_WIDESTRING encode = |
| 293 (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); |
| 294 |
| 295 CFX_ByteString bsHeader = CFX_WideString(wsHeader).UTF16LE_Encode(); |
| 296 FPDF_WIDESTRING header = |
| 297 (FPDF_WIDESTRING)bsHeader.GetBuffer(bsHeader.GetLength()); |
| 298 |
| 299 FPDF_BSTR response; |
| 300 FPDF_BStr_Init(&response); |
| 301 m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, header, |
| 302 &response); |
| 303 |
| 304 CFX_WideString wsRet = CFX_WideString::FromUTF16LE( |
| 305 (unsigned short*)response.str, response.len / sizeof(unsigned short)); |
| 306 FPDF_BStr_Clear(&response); |
| 307 |
| 308 return wsRet; |
| 285 } | 309 } |
| 286 | 310 |
| 287 CFX_WideString FFI_PostRequestURL(const FX_WCHAR* wsURL, | 311 FPDF_BOOL PutRequestURL(const FX_WCHAR* wsURL, |
| 288 const FX_WCHAR* wsData, | 312 const FX_WCHAR* wsData, |
| 289 const FX_WCHAR* wsContentType, | 313 const FX_WCHAR* wsEncode) { |
| 290 const FX_WCHAR* wsEncode, | 314 if (!m_pInfo || !m_pInfo->FFI_PutRequestURL) |
| 291 const FX_WCHAR* wsHeader) { | 315 return FALSE; |
| 292 if (m_pInfo && m_pInfo->FFI_PostRequestURL) { | |
| 293 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); | |
| 294 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); | |
| 295 | 316 |
| 296 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); | 317 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); |
| 297 FPDF_WIDESTRING data = | 318 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); |
| 298 (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); | |
| 299 | 319 |
| 300 CFX_ByteString bsContentType = | 320 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); |
| 301 CFX_WideString(wsContentType).UTF16LE_Encode(); | 321 FPDF_WIDESTRING data = |
| 302 FPDF_WIDESTRING contentType = | 322 (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); |
| 303 (FPDF_WIDESTRING)bsContentType.GetBuffer(bsContentType.GetLength()); | |
| 304 | 323 |
| 305 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); | 324 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); |
| 306 FPDF_WIDESTRING encode = | 325 FPDF_WIDESTRING encode = |
| 307 (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); | 326 (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); |
| 308 | 327 |
| 309 CFX_ByteString bsHeader = CFX_WideString(wsHeader).UTF16LE_Encode(); | 328 return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode); |
| 310 FPDF_WIDESTRING header = | |
| 311 (FPDF_WIDESTRING)bsHeader.GetBuffer(bsHeader.GetLength()); | |
| 312 | |
| 313 FPDF_BSTR response; | |
| 314 FPDF_BStr_Init(&response); | |
| 315 m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, | |
| 316 header, &response); | |
| 317 | |
| 318 CFX_WideString wsRet = CFX_WideString::FromUTF16LE( | |
| 319 (unsigned short*)response.str, response.len / sizeof(unsigned short)); | |
| 320 FPDF_BStr_Clear(&response); | |
| 321 | |
| 322 return wsRet; | |
| 323 } | |
| 324 return L""; | |
| 325 } | 329 } |
| 326 | 330 |
| 327 FPDF_BOOL FFI_PutRequestURL(const FX_WCHAR* wsURL, | 331 CFX_WideString GetLanguage() { |
| 328 const FX_WCHAR* wsData, | 332 if (!m_pInfo || !m_pInfo->FFI_GetLanguage) |
| 329 const FX_WCHAR* wsEncode) { | 333 return L""; |
| 330 if (m_pInfo && m_pInfo->FFI_PutRequestURL) { | |
| 331 CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); | |
| 332 FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); | |
| 333 | 334 |
| 334 CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); | 335 int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, nullptr, 0); |
| 335 FPDF_WIDESTRING data = | 336 if (nRequiredLen <= 0) |
| 336 (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); | 337 return L""; |
| 337 | 338 |
| 338 CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); | 339 char* pbuff = new char[nRequiredLen]; |
| 339 FPDF_WIDESTRING encode = | 340 memset(pbuff, 0, nRequiredLen); |
| 340 (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); | 341 int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff, nRequiredLen); |
| 341 | 342 if (nActualLen <= 0 || nActualLen > nRequiredLen) { |
| 342 return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode); | 343 delete[] pbuff; |
| 344 return L""; |
| 343 } | 345 } |
| 344 return FALSE; | 346 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
| 347 CFX_WideString wsRet = CFX_WideString::FromUTF16LE( |
| 348 (unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), |
| 349 bsRet.GetLength() / sizeof(unsigned short)); |
| 350 delete[] pbuff; |
| 351 return wsRet; |
| 345 } | 352 } |
| 346 | 353 |
| 347 CFX_WideString FFI_GetLanguage() { | 354 void PageEvent(int iPageCount, uint32_t dwEventType) const { |
| 348 if (m_pInfo && m_pInfo->FFI_GetLanguage) { | |
| 349 int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, nullptr, 0); | |
| 350 if (nRequiredLen <= 0) | |
| 351 return L""; | |
| 352 | |
| 353 char* pbuff = new char[nRequiredLen]; | |
| 354 memset(pbuff, 0, nRequiredLen); | |
| 355 int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff, nRequiredLen); | |
| 356 if (nActualLen <= 0 || nActualLen > nRequiredLen) { | |
| 357 delete[] pbuff; | |
| 358 return L""; | |
| 359 } | |
| 360 CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); | |
| 361 CFX_WideString wsRet = CFX_WideString::FromUTF16LE( | |
| 362 (unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), | |
| 363 bsRet.GetLength() / sizeof(unsigned short)); | |
| 364 delete[] pbuff; | |
| 365 return wsRet; | |
| 366 } | |
| 367 return L""; | |
| 368 } | |
| 369 | |
| 370 void FFI_PageEvent(int iPageCount, uint32_t dwEventType) const { | |
| 371 if (m_pInfo && m_pInfo->FFI_PageEvent) | 355 if (m_pInfo && m_pInfo->FFI_PageEvent) |
| 372 m_pInfo->FFI_PageEvent(m_pInfo, iPageCount, dwEventType); | 356 m_pInfo->FFI_PageEvent(m_pInfo, iPageCount, dwEventType); |
| 373 } | 357 } |
| 374 #endif // PDF_ENABLE_XFA | 358 #endif // PDF_ENABLE_XFA |
| 375 | 359 |
| 376 int JS_appAlert(const FX_WCHAR* Msg, | 360 int JS_appAlert(const FX_WCHAR* Msg, |
| 377 const FX_WCHAR* Title, | 361 const FX_WCHAR* Title, |
| 378 FX_UINT Type, | 362 FX_UINT Type, |
| 379 FX_UINT Icon); | 363 FX_UINT Icon); |
| 380 int JS_appResponse(const FX_WCHAR* Question, | 364 int JS_appResponse(const FX_WCHAR* Question, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler; | 410 std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler; |
| 427 std::unique_ptr<IJS_Runtime> m_pJSRuntime; | 411 std::unique_ptr<IJS_Runtime> m_pJSRuntime; |
| 428 FPDF_FORMFILLINFO* const m_pInfo; | 412 FPDF_FORMFILLINFO* const m_pInfo; |
| 429 CPDFSDK_Document* m_pSDKDoc; | 413 CPDFSDK_Document* m_pSDKDoc; |
| 430 UnderlyingDocumentType* const m_pUnderlyingDoc; | 414 UnderlyingDocumentType* const m_pUnderlyingDoc; |
| 431 std::unique_ptr<CFFL_IFormFiller> m_pIFormFiller; | 415 std::unique_ptr<CFFL_IFormFiller> m_pIFormFiller; |
| 432 std::unique_ptr<CFX_SystemHandler> m_pSysHandler; | 416 std::unique_ptr<CFX_SystemHandler> m_pSysHandler; |
| 433 }; | 417 }; |
| 434 | 418 |
| 435 #endif // FPDFSDK_INCLUDE_CPDFSDK_ENVIRONMENT_H_ | 419 #endif // FPDFSDK_INCLUDE_CPDFSDK_ENVIRONMENT_H_ |
| OLD | NEW |