John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 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. |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Tom Sepez | 19922bb | 2015-05-28 13:23:12 -0700 | [diff] [blame] | 7 | #ifndef FPDFSDK_INCLUDE_FSDK_MGR_H_ |
| 8 | #define FPDFSDK_INCLUDE_FSDK_MGR_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
Lei Zhang | 606346f | 2015-06-19 18:11:07 -0700 | [diff] [blame] | 10 | #include <map> |
| 11 | |
Lei Zhang | e5b0bd1 | 2015-06-19 17:15:41 -0700 | [diff] [blame] | 12 | #include "../../core/include/fpdftext/fpdf_text.h" |
Tom Sepez | 1ed8a21 | 2015-05-11 15:25:39 -0700 | [diff] [blame] | 13 | #include "../../public/fpdf_formfill.h" |
| 14 | #include "../../public/fpdf_fwlevent.h" // cross platform keycode and events define. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 15 | #include "fsdk_common.h" |
| 16 | #include "fsdk_define.h" |
| 17 | #include "fx_systemhandler.h" |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 18 | #include "fpdfxfa/fpdfxfa_doc.h" |
| 19 | #include "fpdfxfa/fpdfxfa_page.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 20 | #include "fsdk_baseannot.h" |
| 21 | #include "fsdk_baseform.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 22 | #include "fsdk_annothandler.h" |
| 23 | #include "fsdk_actionhandler.h" |
Lei Zhang | e5b0bd1 | 2015-06-19 17:15:41 -0700 | [diff] [blame] | 24 | #include "javascript/IJavaScript.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 25 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 26 | class CPDFSDK_Document; |
| 27 | class CPDFSDK_PageView; |
| 28 | class CPDFSDK_Annot; |
| 29 | class CFFL_IFormFiller; |
| 30 | class CPDFSDK_Widget; |
| 31 | class IFX_SystemHandler; |
| 32 | class CPDFSDK_ActionHandler; |
| 33 | class CJS_RuntimeFactory; |
| 34 | |
Tom Sepez | b116136 | 2015-06-09 11:29:12 -0700 | [diff] [blame] | 35 | class CPDFDoc_Environment final |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 36 | { |
| 37 | public: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 38 | CPDFDoc_Environment(CPDFXFA_Document * pDoc); |
Lei Zhang | 568aff5 | 2015-06-19 14:58:28 -0700 | [diff] [blame] | 39 | virtual ~CPDFDoc_Environment(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 40 | |
Tom Sepez | 2f3dfef | 2015-03-02 15:35:26 -0800 | [diff] [blame] | 41 | int RegAppHandle(FPDF_FORMFILLINFO* pFFinfo); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 42 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 43 | virtual void Release() |
| 44 | { |
| 45 | if (m_pInfo && m_pInfo->Release) |
| 46 | m_pInfo->Release(m_pInfo); |
| 47 | delete this; |
| 48 | } |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 49 | void FFI_Invalidate(FPDF_PAGE page, double left, double top, double right, double bottom) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 50 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 51 | if (m_pInfo && m_pInfo->FFI_Invalidate) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 52 | { |
| 53 | m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); |
| 54 | } |
| 55 | } |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 56 | void FFI_OutputSelectedRect(FPDF_PAGE page, double left, double top, double right, double bottom) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 57 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 58 | if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 59 | { |
| 60 | m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); |
| 61 | } |
| 62 | } |
| 63 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 64 | void FFI_SetCursor(int nCursorType) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 65 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 66 | if (m_pInfo && m_pInfo->FFI_SetCursor) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 67 | { |
| 68 | m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); |
| 69 | } |
| 70 | } |
| 71 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 72 | int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 73 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 74 | if (m_pInfo && m_pInfo->FFI_SetTimer) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 75 | { |
| 76 | return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); |
| 77 | } |
| 78 | return -1; |
| 79 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 80 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 81 | void FFI_KillTimer(int nTimerID) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 82 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 83 | if (m_pInfo && m_pInfo->FFI_KillTimer) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 84 | { |
| 85 | m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); |
| 86 | } |
| 87 | } |
| 88 | FX_SYSTEMTIME FFI_GetLocalTime() |
| 89 | { |
| 90 | FX_SYSTEMTIME fxtime; |
| 91 | if(m_pInfo && m_pInfo->FFI_GetLocalTime) |
| 92 | { |
| 93 | FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); |
| 94 | fxtime.wDay = systime.wDay; |
| 95 | fxtime.wDayOfWeek = systime.wDayOfWeek; |
| 96 | fxtime.wHour = systime.wHour; |
| 97 | fxtime.wMilliseconds = systime.wMilliseconds; |
| 98 | fxtime.wMinute = systime.wMinute; |
| 99 | fxtime.wMonth = systime.wMonth; |
| 100 | fxtime.wSecond = systime.wSecond; |
| 101 | fxtime.wYear = systime.wYear; |
| 102 | } |
| 103 | return fxtime; |
| 104 | } |
| 105 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 106 | void FFI_OnChange() |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 107 | { |
| 108 | if(m_pInfo && m_pInfo->FFI_OnChange) |
| 109 | { |
| 110 | m_pInfo->FFI_OnChange(m_pInfo); |
| 111 | } |
| 112 | } |
| 113 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 114 | FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 115 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 116 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 117 | return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; |
| 118 | } |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 119 | FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 120 | { |
| 121 | |
| 122 | return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; |
| 123 | } |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 124 | FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 125 | { |
| 126 | |
| 127 | return (nFlag & FWL_EVENTFLAG_AltKey) != 0; |
| 128 | } |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 129 | FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 130 | { |
| 131 | return FALSE; |
| 132 | } |
| 133 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 134 | int JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type, FX_UINT Icon) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 135 | { |
| 136 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) |
| 137 | { |
| 138 | CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); |
| 139 | CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); |
| 140 | FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); |
| 141 | FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); |
| 142 | int ret = m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, pMsg, pTitle, Type, Icon); |
| 143 | bsMsg.ReleaseBuffer(); |
| 144 | bsTitle.ReleaseBuffer(); |
| 145 | return ret; |
| 146 | } |
| 147 | return -1; |
| 148 | } |
| 149 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 150 | int JS_appResponse(const FX_WCHAR* Question, const FX_WCHAR* Title, const FX_WCHAR* Default, const FX_WCHAR* cLabel, FPDF_BOOL bPassword, void* response, int length) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 151 | { |
| 152 | if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_response) |
| 153 | { |
| 154 | CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode(); |
| 155 | CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); |
| 156 | CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode(); |
| 157 | CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode(); |
| 158 | FPDF_WIDESTRING pQuestion = (FPDF_WIDESTRING)bsQuestion.GetBuffer(bsQuestion.GetLength()); |
| 159 | FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); |
| 160 | FPDF_WIDESTRING pDefault = (FPDF_WIDESTRING)bsDefault.GetBuffer(bsDefault.GetLength()); |
| 161 | FPDF_WIDESTRING pLabel = (FPDF_WIDESTRING)bsLabel.GetBuffer(bsLabel.GetLength()); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 162 | int ret = m_pInfo->m_pJsPlatform->app_response(m_pInfo->m_pJsPlatform, pQuestion, pTitle, |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 163 | pDefault, pLabel, bPassword, response, length); |
| 164 | bsQuestion.ReleaseBuffer(); |
| 165 | bsTitle.ReleaseBuffer(); |
| 166 | bsDefault.ReleaseBuffer(); |
| 167 | bsLabel.ReleaseBuffer(); |
| 168 | return ret; |
| 169 | } |
| 170 | return -1; |
| 171 | } |
| 172 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 173 | void JS_appBeep(int nType) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 174 | { |
| 175 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_beep) |
| 176 | { |
| 177 | m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType); |
| 178 | } |
| 179 | } |
| 180 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 181 | CFX_WideString JS_fieldBrowse() |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 182 | { |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 183 | if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Field_browse) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 184 | { |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 185 | int nRequiredLen = m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, NULL, 0); |
| 186 | if (nRequiredLen <= 0) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 187 | return L""; |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 188 | |
| 189 | char* pbuff = new char[nRequiredLen]; |
| 190 | if (!pbuff) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 191 | return L""; |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 192 | |
| 193 | memset(pbuff, 0, nRequiredLen); |
| 194 | int nActualLen = m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, pbuff, nRequiredLen); |
| 195 | if (nActualLen <= 0 || nActualLen > nRequiredLen) |
| 196 | { |
| 197 | delete[] pbuff; |
| 198 | return L""; |
| 199 | } |
| 200 | CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 201 | CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); |
| 202 | delete[] pbuff; |
| 203 | return wsRet; |
| 204 | } |
| 205 | return L""; |
| 206 | } |
| 207 | |
| 208 | CFX_WideString JS_docGetFilePath() |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 209 | { |
| 210 | if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_getFilePath) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 211 | { |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 212 | int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(m_pInfo->m_pJsPlatform, NULL, 0); |
| 213 | if (nRequiredLen <= 0) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 214 | return L""; |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 215 | |
| 216 | char* pbuff = new char[nRequiredLen]; |
| 217 | if (!pbuff) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 218 | return L""; |
Tom Sepez | 0d3b5cc | 2014-07-30 13:03:52 -0700 | [diff] [blame] | 219 | |
| 220 | memset(pbuff, 0, nRequiredLen); |
| 221 | int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(m_pInfo->m_pJsPlatform, pbuff, nRequiredLen); |
| 222 | if (nActualLen <= 0 || nActualLen > nRequiredLen) |
| 223 | { |
| 224 | delete[] pbuff; |
| 225 | return L""; |
| 226 | } |
| 227 | CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 228 | CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); |
| 229 | delete[] pbuff; |
| 230 | return wsRet; |
| 231 | } |
| 232 | return L""; |
| 233 | } |
| 234 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 235 | void JS_docSubmitForm(void* formData, int length, const FX_WCHAR* URL) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 236 | { |
| 237 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_submitForm) |
| 238 | { |
| 239 | CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode(); |
| 240 | FPDF_WIDESTRING pDestination = (FPDF_WIDESTRING)bsDestination.GetBuffer(bsDestination.GetLength()); |
| 241 | m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, length, pDestination); |
| 242 | bsDestination.ReleaseBuffer(); |
| 243 | } |
| 244 | } |
| 245 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 246 | void JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI,const FX_WCHAR* To, const FX_WCHAR* Subject, const FX_WCHAR* CC, const FX_WCHAR* BCC, const FX_WCHAR* Msg) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 247 | { |
| 248 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_mail) |
| 249 | { |
| 250 | CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode(); |
| 251 | CFX_ByteString bsCC = CFX_WideString(Subject).UTF16LE_Encode(); |
| 252 | CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode(); |
| 253 | CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode(); |
| 254 | CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); |
| 255 | FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); |
| 256 | FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); |
| 257 | FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); |
| 258 | FPDF_WIDESTRING pSubject = (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); |
| 259 | FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); |
| 260 | m_pInfo->m_pJsPlatform->Doc_mail(m_pInfo->m_pJsPlatform, mailData, length, bUI, pTo, pSubject, |
| 261 | pCC, pBcc, pMsg); |
| 262 | bsTo.ReleaseBuffer(); |
| 263 | bsCC.ReleaseBuffer(); |
| 264 | bsBcc.ReleaseBuffer(); |
| 265 | bsSubject.ReleaseBuffer(); |
| 266 | bsMsg.ReleaseBuffer(); |
| 267 | } |
| 268 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 269 | |
| 270 | void JS_docprint(FPDF_BOOL bUI , int nStart, int nEnd, FPDF_BOOL bSilent ,FPDF_BOOL bShrinkToFit,FPDF_BOOL bPrintAsImage ,FPDF_BOOL bReverse ,FPDF_BOOL bAnnotations) |
| 271 | { |
| 272 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_print) |
| 273 | { |
| 274 | m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations); |
| 275 | } |
| 276 | } |
| 277 | void JS_docgotoPage(int nPageNum) |
| 278 | { |
| 279 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_gotoPage) |
| 280 | { |
| 281 | m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum); |
| 282 | } |
| 283 | } |
| 284 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 285 | FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document,int nPageIndex) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 286 | { |
| 287 | if(m_pInfo && m_pInfo->FFI_GetPage) |
| 288 | { |
| 289 | return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); |
| 290 | } |
| 291 | return NULL; |
| 292 | } |
| 293 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 294 | FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 295 | { |
| 296 | if(m_pInfo && m_pInfo->FFI_GetCurrentPage) |
| 297 | { |
| 298 | return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); |
| 299 | } |
| 300 | return NULL; |
| 301 | } |
| 302 | |
| 303 | int FFI_GetRotation(FPDF_PAGE page) |
| 304 | { |
| 305 | if(m_pInfo && m_pInfo->FFI_GetRotation) |
| 306 | { |
| 307 | return m_pInfo->FFI_GetRotation(m_pInfo, page); |
| 308 | } |
| 309 | return 0; |
| 310 | } |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 311 | void FFI_ExecuteNamedAction(const FX_CHAR* namedAction) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 312 | { |
| 313 | if(m_pInfo && m_pInfo->FFI_ExecuteNamedAction) |
| 314 | { |
| 315 | m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); |
| 316 | } |
| 317 | } |
| 318 | void FFI_OnSetFieldInputFocus(void* field,FPDF_WIDESTRING focusText, FPDF_DWORD nTextLen, FX_BOOL bFocus) |
| 319 | { |
| 320 | if(m_pInfo && m_pInfo->FFI_SetTextFieldFocus) |
| 321 | { |
| 322 | m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); |
| 323 | } |
| 324 | } |
| 325 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 326 | void FFI_DoURIAction(const FX_CHAR* bsURI) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 327 | { |
| 328 | if(m_pInfo && m_pInfo->FFI_DoURIAction) |
| 329 | { |
| 330 | m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | void FFI_DoGoToAction(int nPageIndex, int zoomMode, float* fPosArray, int sizeOfArray) |
| 335 | { |
| 336 | if(m_pInfo && m_pInfo->FFI_DoGoToAction) |
| 337 | { |
| 338 | m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, sizeOfArray); |
| 339 | } |
| 340 | } |
| 341 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 342 | void FFI_DisplayCaret(FPDF_PAGE page, FPDF_BOOL bVisible, double left, double top, double right, double bottom) |
| 343 | { |
| 344 | if (m_pInfo && m_pInfo->FFI_DisplayCaret) |
| 345 | { |
| 346 | m_pInfo->FFI_DisplayCaret(m_pInfo, page, bVisible, left, top, right, bottom); |
| 347 | } |
| 348 | } |
| 349 | int FFI_GetCurrentPageIndex(FPDF_DOCUMENT document) |
| 350 | { |
| 351 | if (m_pInfo && m_pInfo->FFI_GetCurrentPageIndex) |
| 352 | { |
| 353 | m_pInfo->FFI_GetCurrentPageIndex(m_pInfo, document); |
| 354 | } |
| 355 | return -1; |
| 356 | } |
| 357 | int FFI_SetCurrentPage(FPDF_DOCUMENT document, int iCurPage) |
| 358 | { |
| 359 | if (m_pInfo && m_pInfo->FFI_SetCurrentPage) |
| 360 | { |
| 361 | m_pInfo->FFI_SetCurrentPage(m_pInfo, document, iCurPage); |
| 362 | } |
| 363 | return -1; |
| 364 | } |
| 365 | |
| 366 | CFX_WideString FFI_GetAppName() |
| 367 | { |
| 368 | return CFX_WideString(L"Acrobat"); |
| 369 | |
| 370 | //if (m_pInfo && m_pInfo->FFI_GetAppName) |
| 371 | //{ |
| 372 | // int nLen = m_pInfo->FFI_GetAppName(m_pInfo, NULL, 0); |
| 373 | // if(nLen <= 0) |
| 374 | // return L""; |
| 375 | // char* pbuff = new char[nLen]; |
| 376 | // if(pbuff) |
| 377 | // memset(pbuff, 0, nLen); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 378 | // else |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 379 | // return L""; |
| 380 | // nLen = m_pInfo->FFI_GetAppName(m_pInfo, pbuff, nLen); |
| 381 | // CFX_ByteString bsRet = CFX_ByteString(pbuff, nLen); |
| 382 | // CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); |
| 383 | // delete[] pbuff; |
| 384 | // return wsRet; |
| 385 | //} |
| 386 | |
| 387 | //return L""; |
| 388 | } |
| 389 | |
| 390 | CFX_WideString FFI_GetPlatform() |
| 391 | { |
| 392 | if (m_pInfo && m_pInfo->FFI_GetPlatform) |
| 393 | { |
| 394 | int nRequiredLen = m_pInfo->FFI_GetPlatform(m_pInfo, NULL, 0); |
| 395 | if (nRequiredLen <= 0) |
| 396 | return L""; |
| 397 | |
| 398 | char* pbuff = new char[nRequiredLen]; |
| 399 | if (!pbuff) |
| 400 | return L""; |
| 401 | |
| 402 | memset(pbuff, 0, nRequiredLen); |
| 403 | int nActualLen = m_pInfo->FFI_GetPlatform(m_pInfo, pbuff, nRequiredLen); |
| 404 | if (nActualLen <= 0 || nActualLen > nRequiredLen) |
| 405 | { |
| 406 | delete[] pbuff; |
| 407 | return L""; |
| 408 | } |
| 409 | CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
| 410 | CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short)); |
| 411 | delete[] pbuff; |
| 412 | return wsRet; |
| 413 | } |
| 414 | return L""; |
| 415 | } |
| 416 | |
Tom Sepez | ca3ac5e | 2015-06-10 17:38:11 -0700 | [diff] [blame] | 417 | void FFI_GotoURL(FPDF_DOCUMENT document, const CFX_WideStringC& wsURL, FX_BOOL bAppend) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 418 | { |
| 419 | if (m_pInfo && m_pInfo->FFI_GotoURL) |
| 420 | { |
| 421 | CFX_ByteString bsTo = CFX_WideString(wsURL).UTF16LE_Encode(); |
| 422 | FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(wsURL.GetLength()); |
| 423 | m_pInfo->FFI_GotoURL(m_pInfo, document, pTo); |
| 424 | bsTo.ReleaseBuffer(); |
| 425 | } |
| 426 | } |
| 427 | void FFI_GetURL(FPDF_DOCUMENT document, CFX_WideString& wsURL) |
| 428 | { |
| 429 | wsURL = CFX_WideString(); |
| 430 | return; |
| 431 | //if (m_pInfo && m_pInfo->FFI_GetURL) |
| 432 | //{ |
| 433 | // FPDF_WIDESTRING url = m_pInfo->FFI_GetURL(m_pInfo, document); |
| 434 | // CFX_WideString tmp; |
| 435 | // tmp.FromUTF16LE(url); |
| 436 | // wsURL = tmp; |
| 437 | //} |
| 438 | } |
| 439 | |
| 440 | void FFI_AddDoRecord(FPDF_DOCUMENT document, FPDF_WIDGET hWidget) |
| 441 | { |
| 442 | //if (m_pInfo && m_pInfo->FFI_AddDoRecord) |
| 443 | //{ |
| 444 | // m_pInfo->FFI_AddDoRecord(m_pInfo, document, hWidget); |
| 445 | //} |
| 446 | } |
| 447 | void FFI_PageEvent(FPDF_PAGE page, FPDF_DWORD flag) |
| 448 | { |
| 449 | //if (m_pInfo && m_pInfo->FFI_PageEvent) |
| 450 | //{ |
| 451 | // m_pInfo->FFI_PageEvent(m_pInfo, page, flag); |
| 452 | //} |
| 453 | } |
| 454 | |
| 455 | void FFI_GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect) |
| 456 | { |
| 457 | if (m_pInfo && m_pInfo->FFI_GetPageViewRect) |
| 458 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 459 | double left; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 460 | double top; |
| 461 | double right; |
| 462 | double bottom; |
| 463 | m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom); |
| 464 | |
Bruce Dawson | 3f49aa3 | 2015-01-08 11:47:49 -0800 | [diff] [blame] | 465 | dstRect.left = static_cast<float>(left); |
| 466 | dstRect.top = static_cast<float>(top < bottom ? bottom : top); |
| 467 | dstRect.bottom = static_cast<float>(top < bottom ? top : bottom); |
| 468 | dstRect.right = static_cast<float>(right); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 469 | } |
| 470 | } |
| 471 | |
| 472 | |
| 473 | FX_BOOL FFI_PopupMenu(FPDF_PAGE page, FPDF_WIDGET hWidget, int menuFlag, CFX_PointF ptPopup, const CFX_PointF* pRectExclude) |
| 474 | { |
| 475 | if (m_pInfo && m_pInfo->FFI_PopupMenu) |
| 476 | { |
| 477 | return m_pInfo->FFI_PopupMenu(m_pInfo, page, hWidget, menuFlag, ptPopup.x, ptPopup.y); |
| 478 | } |
| 479 | return FALSE; |
| 480 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 481 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 482 | void FFI_Alert(FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, int Type, int Icon) |
| 483 | { |
| 484 | if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) |
| 485 | { |
| 486 | m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, Msg, Title, Type, Icon); |
| 487 | } |
| 488 | } |
| 489 | void FFI_EmailTo(FPDF_FILEHANDLER* fileHandler, FPDF_WIDESTRING pTo, FPDF_WIDESTRING pSubject, FPDF_WIDESTRING pCC, FPDF_WIDESTRING pBcc, FPDF_WIDESTRING pMsg) |
| 490 | { |
| 491 | if(m_pInfo && m_pInfo->FFI_EmailTo) |
| 492 | { |
| 493 | m_pInfo->FFI_EmailTo(m_pInfo, fileHandler, pTo, pSubject, pCC, pBcc, pMsg); |
| 494 | } |
| 495 | } |
| 496 | void FFI_UploadTo(FPDF_FILEHANDLER* fileHandler, int fileFlag, FPDF_WIDESTRING uploadTo) |
| 497 | { |
| 498 | if(m_pInfo && m_pInfo->FFI_UploadTo) |
| 499 | { |
| 500 | m_pInfo->FFI_UploadTo(m_pInfo, fileHandler, fileFlag, uploadTo); |
| 501 | } |
| 502 | } |
| 503 | FPDF_FILEHANDLER* FFI_OpenFile(int fileType, FPDF_WIDESTRING wsURL, const char* mode) |
| 504 | { |
| 505 | if(m_pInfo && m_pInfo->FFI_OpenFile) |
| 506 | { |
| 507 | return m_pInfo->FFI_OpenFile(m_pInfo, fileType, wsURL, mode); |
| 508 | } |
| 509 | return NULL; |
| 510 | } |
| 511 | CFX_WideString FFI_GetFilePath(FPDF_FILEHANDLER* pFileHandler) |
| 512 | { |
| 513 | #if 0 |
| 514 | if (m_pInfo && m_pInfo->FFI_GetFilePath) |
| 515 | { |
| 516 | int nRequiredLen = m_pInfo->FFI_GetFilePath(m_pInfo, pFileHandler, NULL, 0); |
| 517 | if (nRequiredLen <= 0) |
| 518 | return L""; |
| 519 | |
| 520 | char* pbuff = new char[nRequiredLen]; |
| 521 | if (!pbuff) |
| 522 | return L""; |
| 523 | |
| 524 | memset(pbuff, 0, nRequiredLen); |
| 525 | int nActualLen = m_pInfo->FFI_GetFilePath(m_pInfo, pFileHandler, pbuff, nRequiredLen); |
| 526 | if (nActualLen <= 0 || nActualLen > nRequiredLen) |
| 527 | { |
| 528 | delete[] pbuff; |
| 529 | return L""; |
| 530 | } |
| 531 | CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
| 532 | CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short)); |
| 533 | delete[] pbuff; |
| 534 | return wsRet; |
| 535 | } |
| 536 | return L""; |
| 537 | #else |
| 538 | return L""; |
| 539 | #endif |
| 540 | } |
| 541 | int FFI_GetDocumentCount() |
| 542 | { |
| 543 | //if (m_pInfo && m_pInfo->FFI_GetDocumentCount) |
| 544 | //{ |
| 545 | //return m_pInfo->FFI_GetDocumentCount(m_pInfo); |
| 546 | //} |
| 547 | return 0; |
| 548 | } |
| 549 | |
| 550 | int FFI_GetCurDocument() |
| 551 | { |
| 552 | //if (m_pInfo && m_pInfo->FFI_GetCurDocumentIndex) |
| 553 | //{ |
| 554 | // return m_pInfo->FFI_GetCurDocumentIndex(m_pInfo); |
| 555 | //} |
| 556 | return 0; |
| 557 | } |
| 558 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 559 | IFX_FileRead* FFI_DownloadFromURL(const FX_WCHAR* url) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 560 | { |
| 561 | if (m_pInfo && m_pInfo->FFI_DownloadFromURL) |
| 562 | { |
| 563 | CFX_ByteString bstrURL = CFX_WideString(url).UTF16LE_Encode(); |
| 564 | FPDF_WIDESTRING wsURL = (FPDF_WIDESTRING)bstrURL.GetBuffer(bstrURL.GetLength()); |
| 565 | |
| 566 | FPDF_LPFILEHANDLER fileHandler = m_pInfo->FFI_DownloadFromURL(m_pInfo, wsURL); |
| 567 | |
| 568 | CFPDF_FileStream* fileStream = FX_NEW CFPDF_FileStream(fileHandler); |
| 569 | return fileStream; |
| 570 | } |
| 571 | return NULL; |
| 572 | } |
| 573 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 574 | CFX_WideString FFI_PostRequestURL(const FX_WCHAR* wsURL, const FX_WCHAR* wsData, const FX_WCHAR* wsContentType, const FX_WCHAR* wsEncode, const FX_WCHAR* wsHeader) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 575 | { |
| 576 | if (m_pInfo && m_pInfo->FFI_PostRequestURL) |
| 577 | { |
| 578 | CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); |
| 579 | FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); |
| 580 | |
| 581 | CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); |
| 582 | FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); |
| 583 | |
| 584 | CFX_ByteString bsContentType = CFX_WideString(wsContentType).UTF16LE_Encode(); |
| 585 | FPDF_WIDESTRING contentType = (FPDF_WIDESTRING)bsContentType.GetBuffer(bsContentType.GetLength()); |
| 586 | |
| 587 | CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); |
| 588 | FPDF_WIDESTRING encode = (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); |
| 589 | |
| 590 | CFX_ByteString bsHeader = CFX_WideString(wsHeader).UTF16LE_Encode(); |
| 591 | FPDF_WIDESTRING header = (FPDF_WIDESTRING)bsHeader.GetBuffer(bsHeader.GetLength()); |
| 592 | |
| 593 | FPDF_BSTR respone; |
| 594 | FPDF_BStr_Init(&respone); |
| 595 | FPDF_BOOL bRet = m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode, header, &respone); |
| 596 | |
| 597 | CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)respone.str, respone.len/sizeof(unsigned short)); |
| 598 | FPDF_BStr_Clear(&respone); |
| 599 | |
| 600 | return wsRet; |
| 601 | } |
| 602 | return L""; |
| 603 | } |
| 604 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 605 | FPDF_BOOL FFI_PutRequestURL(const FX_WCHAR* wsURL, const FX_WCHAR* wsData, const FX_WCHAR* wsEncode) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 606 | { |
| 607 | if (m_pInfo && m_pInfo->FFI_PutRequestURL) |
| 608 | { |
| 609 | CFX_ByteString bsURL = CFX_WideString(wsURL).UTF16LE_Encode(); |
| 610 | FPDF_WIDESTRING URL = (FPDF_WIDESTRING)bsURL.GetBuffer(bsURL.GetLength()); |
| 611 | |
| 612 | CFX_ByteString bsData = CFX_WideString(wsData).UTF16LE_Encode(); |
| 613 | FPDF_WIDESTRING data = (FPDF_WIDESTRING)bsData.GetBuffer(bsData.GetLength()); |
| 614 | |
| 615 | CFX_ByteString bsEncode = CFX_WideString(wsEncode).UTF16LE_Encode(); |
| 616 | FPDF_WIDESTRING encode = (FPDF_WIDESTRING)bsEncode.GetBuffer(bsEncode.GetLength()); |
| 617 | |
| 618 | return m_pInfo->FFI_PutRequestURL(m_pInfo, URL, data, encode); |
| 619 | } |
| 620 | return FALSE; |
| 621 | } |
| 622 | |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 623 | FPDF_BOOL FFI_ShowFileDialog(const FX_WCHAR* wsTitle, const FX_WCHAR* wsFilter, CFX_WideStringArray &wsPathArr, FX_BOOL bOpen) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 624 | { |
| 625 | /*CFX_ByteString bsTitle = CFX_WideString(wsTitle).UTF16LE_Encode(); |
| 626 | FPDF_WIDESTRING title = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); |
| 627 | |
| 628 | CFX_ByteString bsFilter = CFX_WideString(wsFilter).UTF16LE_Encode(); |
| 629 | FPDF_WIDESTRING filter = (FPDF_WIDESTRING)bsFilter.GetBuffer(bsFilter.GetLength()); |
| 630 | |
| 631 | CFX_ByteStringArray* strPathArr = FX_NEW CFX_ByteStringArray(); |
| 632 | if (m_pInfo && m_pInfo->FFI_ShowFileDialog) |
| 633 | { |
| 634 | FPDF_BOOL bRet = m_pInfo->FFI_ShowFileDialog(m_pInfo, title, filter, bOpen, (FPDF_STRINGHANDLE)strPathArr); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 635 | if (bRet) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 636 | { |
| 637 | int count = strPathArr->GetSize(); |
| 638 | for (int i=0; i<count; i++) |
| 639 | { |
| 640 | CFX_ByteString bsPath = *strPathArr->GetDataPtr(i); |
| 641 | CFX_WideString wsPath = CFX_WideString::FromUTF16LE((unsigned short*)bsPath.GetBuffer(bsPath.GetLength()), bsPath.GetLength()/sizeof(unsigned short)); |
| 642 | if (!wsPath.IsEmpty()) |
| 643 | wsPathArr.Add(wsPath); |
| 644 | wsPath = L""; |
| 645 | } |
| 646 | return TRUE; |
| 647 | } |
| 648 | |
| 649 | return FALSE; |
| 650 | } |
| 651 | */ |
| 652 | |
| 653 | return FALSE; |
| 654 | } |
| 655 | CFX_WideString FFI_GetLanguage() |
| 656 | { |
| 657 | if (m_pInfo && m_pInfo->FFI_GetLanguage) |
| 658 | { |
| 659 | int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, NULL, 0); |
| 660 | if (nRequiredLen <= 0) |
| 661 | return L""; |
| 662 | |
| 663 | char* pbuff = new char[nRequiredLen]; |
| 664 | if (!pbuff) |
| 665 | return L""; |
| 666 | |
| 667 | memset(pbuff, 0, nRequiredLen); |
| 668 | int nActualLen = m_pInfo->FFI_GetLanguage(m_pInfo, pbuff, nRequiredLen); |
| 669 | if (nActualLen <= 0 || nActualLen > nRequiredLen) |
| 670 | { |
| 671 | delete[] pbuff; |
| 672 | return L""; |
| 673 | } |
| 674 | CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen); |
| 675 | CFX_WideString wsRet = CFX_WideString::FromUTF16LE((unsigned short*)bsRet.GetBuffer(bsRet.GetLength()), bsRet.GetLength()/sizeof(unsigned short)); |
| 676 | delete[] pbuff; |
| 677 | return wsRet; |
| 678 | } |
| 679 | return L""; |
| 680 | } |
| 681 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 682 | FX_BOOL IsJSInitiated(); |
| 683 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 684 | void SetCurrentDoc(CPDFSDK_Document* pFXDoc) {m_pSDKDoc = pFXDoc;} |
| 685 | CPDFSDK_Document* GetCurrentDoc(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 686 | CPDFXFA_Document* GetPDFXFADocument() {return m_pDoc;} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 687 | |
| 688 | CFX_ByteString GetAppName() {return "";} |
| 689 | |
| 690 | CFFL_IFormFiller* GetIFormFiller(); |
| 691 | IFX_SystemHandler* GetSysHandler() {return m_pSysHandler;} |
| 692 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 693 | CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); |
| 694 | IFXJS_Runtime* GetJSRuntime(); |
| 695 | CPDFSDK_ActionHandler* GetActionHander(); |
Tom Sepez | 2f3dfef | 2015-03-02 15:35:26 -0800 | [diff] [blame] | 696 | FPDF_FORMFILLINFO* GetFormFillInfo() {return m_pInfo;} |
| 697 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 698 | private: |
| 699 | CPDFSDK_AnnotHandlerMgr* m_pAnnotHandlerMgr; |
| 700 | CPDFSDK_ActionHandler* m_pActionHandler; |
| 701 | IFXJS_Runtime* m_pJSRuntime; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 702 | FPDF_FORMFILLINFO* m_pInfo; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 703 | CPDFSDK_Document* m_pSDKDoc; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 704 | CPDFXFA_Document* m_pDoc; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 705 | |
| 706 | CFFL_IFormFiller* m_pIFormFiller; |
| 707 | IFX_SystemHandler* m_pSysHandler; |
| 708 | |
| 709 | public: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 710 | //CJS_RuntimeFactory* m_pJSRuntimeFactory; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 711 | }; |
| 712 | |
| 713 | |
| 714 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 715 | class CPDFSDK_InterForm; |
| 716 | class CPDFSDK_Document |
| 717 | { |
| 718 | public: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 719 | CPDFSDK_Document(CPDFXFA_Document* pDoc, CPDFDoc_Environment* pEnv); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 720 | ~CPDFSDK_Document(); |
Tom Sepez | 2f3dfef | 2015-03-02 15:35:26 -0800 | [diff] [blame] | 721 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 722 | CPDFSDK_InterForm* GetInterForm() ; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 723 | CPDFXFA_Document* GetDocument() {return m_pDoc;} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 724 | |
Lei Zhang | 606346f | 2015-06-19 18:11:07 -0700 | [diff] [blame] | 725 | int GetPageViewCount() const { return m_pageMap.size(); } |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 726 | CPDFSDK_PageView* GetPageView(CPDFXFA_Page* pPDFXFAPage, FX_BOOL ReNew = TRUE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 727 | CPDFSDK_PageView* GetPageView(int nIndex); |
| 728 | CPDFSDK_PageView* GetCurrentView(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 729 | void ReMovePageView(CPDFXFA_Page* pPDFPage); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 730 | void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); |
| 731 | |
Tom Sepez | 2f3dfef | 2015-03-02 15:35:26 -0800 | [diff] [blame] | 732 | CPDFSDK_Annot* GetFocusAnnot(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 733 | |
| 734 | IFXJS_Runtime * GetJsRuntime(); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 735 | |
Tom Sepez | 2f3dfef | 2015-03-02 15:35:26 -0800 | [diff] [blame] | 736 | FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 737 | FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0); |
| 738 | |
| 739 | FX_BOOL ExtractPages(const CFX_WordArray &arrExtraPages, CPDF_Document* pDstDoc); |
| 740 | FX_BOOL InsertPages(int nInsertAt, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages); |
| 741 | FX_BOOL DeletePages(int nStart, int nCount); |
| 742 | FX_BOOL ReplacePages(int nPage, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages); |
| 743 | |
| 744 | void OnCloseDocument(); |
| 745 | |
| 746 | int GetPageCount() {return m_pDoc->GetPageCount();} |
| 747 | FX_BOOL GetPermissions(int nFlag); |
| 748 | FX_BOOL GetChangeMark() {return m_bChangeMask;} |
| 749 | void SetChangeMark() {m_bChangeMask = TRUE;} |
| 750 | void ClearChangeMark() {m_bChangeMask= FALSE;} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 751 | CFX_WideString GetPath() ; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 752 | CPDFXFA_Page* GetPage(int nIndex); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 753 | CPDFDoc_Environment * GetEnv() {return m_pEnv; } |
| 754 | void ProcJavascriptFun(); |
| 755 | FX_BOOL ProcOpenAction(); |
| 756 | CPDF_OCContext* GetOCContext(); |
| 757 | private: |
Lei Zhang | 606346f | 2015-06-19 18:11:07 -0700 | [diff] [blame] | 758 | std::map<CPDFXFA_Page*, CPDFSDK_PageView*> m_pageMap; |
| 759 | CPDFXFA_Document* m_pDoc; |
| 760 | CPDFSDK_InterForm* m_pInterForm; |
| 761 | CPDFSDK_Annot* m_pFocusAnnot; |
| 762 | CPDFDoc_Environment* m_pEnv; |
| 763 | CPDF_OCContext* m_pOccontent; |
| 764 | FX_BOOL m_bChangeMask; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 765 | }; |
Tom Sepez | b116136 | 2015-06-09 11:29:12 -0700 | [diff] [blame] | 766 | class CPDFSDK_PageView final |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 767 | { |
| 768 | public: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 769 | CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDFXFA_Page* page); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 770 | ~CPDFSDK_PageView(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 771 | void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions, FX_RECT* pClip = NULL) ; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 772 | CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 773 | CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 774 | CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 775 | CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 776 | CPDFSDK_Annot* GetFocusAnnot() ; |
| 777 | void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot,FX_UINT nFlag = 0) {m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag);} |
| 778 | FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) {return m_pSDKDoc->KillFocusAnnot(nFlag);} |
| 779 | FX_BOOL Annot_HasAppearance(CPDF_Annot* pAnnot); |
| 780 | |
| 781 | CPDFSDK_Annot* AddAnnot(CPDF_Dictionary * pDict); |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 782 | CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictionary * pDict); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 783 | CPDFSDK_Annot* AddAnnot(CPDF_Annot * pPDFAnnot); |
Tom Sepez | eed467d | 2015-06-02 10:35:27 -0700 | [diff] [blame] | 784 | CPDFSDK_Annot* AddAnnot(IXFA_Widget* pPDFAnnot); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 785 | FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); |
| 786 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 787 | int CountAnnots(); |
| 788 | CPDFSDK_Annot* GetAnnot(int nIndex); |
| 789 | CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary * pDict); |
Tom Sepez | eed467d | 2015-06-02 10:35:27 -0700 | [diff] [blame] | 790 | CPDFSDK_Annot* GetAnnotByXFAWidget(IXFA_Widget* hWidget); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 791 | CPDFXFA_Page* GetPDFXFAPage(){return m_page;} |
| 792 | CPDF_Page* GetPDFPage(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 793 | CPDF_Document* GetPDFDocument(); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 794 | CPDFSDK_Document* GetSDKDocument() {return m_pSDKDoc;} |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 795 | FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag); |
| 796 | FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 797 | FX_BOOL OnRButtonDown(const CPDF_Point & point, FX_UINT nFlag); |
| 798 | FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_UINT nFlag); |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 799 | FX_BOOL OnChar(int nChar, FX_UINT nFlag); |
| 800 | FX_BOOL OnKeyDown(int nKeyCode, int nFlag); |
| 801 | FX_BOOL OnKeyUp(int nKeyCode, int nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 802 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 803 | FX_BOOL OnMouseMove(const CPDF_Point & point, int nFlag); |
| 804 | FX_BOOL OnMouseWheel(double deltaX, double deltaY,const CPDF_Point& point, int nFlag); |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 805 | FX_BOOL IsValidAnnot(void* p); |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 806 | void GetCurrentMatrix(CPDF_Matrix& matrix) {matrix = m_curMatrix;} |
| 807 | void UpdateRects(CFX_RectArray& rects); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 808 | void UpdateView(CPDFSDK_Annot* pAnnot); |
| 809 | CFX_PtrArray* GetAnnotList(){ return &m_fxAnnotArray; } |
| 810 | |
Nico Weber | 5eb9f7b | 2014-07-18 09:14:35 -0700 | [diff] [blame] | 811 | int GetPageIndex(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 812 | void LoadFXAnnots(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 813 | void SetValid(FX_BOOL bValid) {m_bValid = bValid;} |
| 814 | FX_BOOL IsValid() {return m_bValid;} |
| 815 | void SetLock(FX_BOOL bLocked) {m_bLocked= bLocked;} |
| 816 | FX_BOOL IsLocked() {return m_bLocked;} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 817 | private: |
| 818 | void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, CPDFSDK_Widget* pWidget); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 819 | CPDF_Matrix m_curMatrix; |
| 820 | CPDFXFA_Page* m_page; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 821 | CPDF_AnnotList* m_pAnnotList; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 822 | //CPDFSDK_Annot* m_pFocusAnnot; |
| 823 | CFX_PtrArray m_fxAnnotArray; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 824 | CPDFSDK_Document* m_pSDKDoc; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 825 | CPDFSDK_Annot* m_CaptureWidget; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 826 | FX_BOOL m_bEnterWidget; |
| 827 | FX_BOOL m_bExitWidget; |
| 828 | FX_BOOL m_bOnWidget; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 829 | FX_BOOL m_bValid; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 830 | FX_BOOL m_bLocked; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 831 | }; |
| 832 | |
| 833 | |
| 834 | template<class TYPE> |
| 835 | class CGW_ArrayTemplate : public CFX_ArrayTemplate<TYPE> |
| 836 | { |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 837 | public: |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 838 | CGW_ArrayTemplate(){} |
| 839 | virtual ~CGW_ArrayTemplate(){} |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 840 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 841 | typedef int (*LP_COMPARE)(TYPE p1, TYPE p2); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 842 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 843 | void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE) |
| 844 | { |
| 845 | int nSize = this->GetSize(); |
| 846 | QuickSort(0, nSize -1, bAscent, pCompare); |
| 847 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 848 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 849 | private: |
| 850 | void QuickSort(FX_UINT nStartPos, FX_UINT nStopPos, FX_BOOL bAscend, LP_COMPARE pCompare) |
| 851 | { |
| 852 | if (nStartPos >= nStopPos) return; |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 853 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 854 | if ((nStopPos - nStartPos) == 1) |
| 855 | { |
| 856 | TYPE Value1 = this->GetAt(nStartPos); |
| 857 | TYPE Value2 = this->GetAt(nStopPos); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 858 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 859 | int iGreate = (*pCompare)(Value1, Value2); |
| 860 | if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) |
| 861 | { |
| 862 | this->SetAt(nStartPos, Value2); |
| 863 | this->SetAt(nStopPos, Value1); |
| 864 | } |
| 865 | return; |
| 866 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 867 | |
Bo Xu | 9a52eb0 | 2014-06-24 11:37:49 -0700 | [diff] [blame] | 868 | FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 869 | FX_UINT i = nStartPos; |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 870 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 871 | TYPE Value = this->GetAt(m); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 872 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 873 | while (i < m) |
| 874 | { |
| 875 | TYPE temp = this->GetAt(i); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 876 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 877 | int iGreate = (*pCompare)(temp, Value); |
| 878 | if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) |
| 879 | { |
| 880 | this->InsertAt(m+1, temp); |
| 881 | this->RemoveAt(i); |
| 882 | m--; |
| 883 | } |
| 884 | else |
| 885 | { |
| 886 | i++; |
| 887 | } |
| 888 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 889 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 890 | FX_UINT j = nStopPos; |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 891 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 892 | while (j > m) |
| 893 | { |
| 894 | TYPE temp = this->GetAt(j); |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 895 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 896 | int iGreate = (*pCompare)(temp, Value); |
| 897 | if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0)) |
| 898 | { |
| 899 | this->RemoveAt(j); |
| 900 | this->InsertAt(m, temp); |
| 901 | m++; |
| 902 | } |
| 903 | else |
| 904 | { |
| 905 | j--; |
| 906 | } |
| 907 | } |
Tom Sepez | c6ab172 | 2015-02-05 15:27:25 -0800 | [diff] [blame] | 908 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 909 | if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare); |
| 910 | if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare); |
| 911 | } |
| 912 | }; |
| 913 | |
Tom Sepez | 19922bb | 2015-05-28 13:23:12 -0700 | [diff] [blame] | 914 | #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_ |