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 | 7b5bc26 | 2015-03-05 16:44:22 -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 | |
| 7 | #include "../include/fsdk_define.h" |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 8 | #include "../include/fpdfxfa/fpdfxfa_doc.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | #include "../include/fsdk_mgr.h" |
| 10 | #include "../include/fsdk_actionhandler.h" |
| 11 | #include "../include/javascript/IJavaScript.h" |
| 12 | |
Tom Sepez | 3b5f124 | 2015-09-01 14:06:55 -0700 | [diff] [blame^] | 13 | CPDFSDK_ActionHandler::CPDFSDK_ActionHandler() |
| 14 | : m_pFormActionHandler(new CPDFSDK_FormActionHandler) { |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 15 | } |
| 16 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 17 | FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, |
| 18 | CPDFSDK_Document* pDocument) { |
| 19 | CFX_PtrList list; |
| 20 | return ExecuteDocumentOpenAction(action, pDocument, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 21 | } |
| 22 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 23 | FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript( |
| 24 | const CPDF_Action& JsAction, |
| 25 | CFX_WideString csJSName, |
| 26 | CPDFSDK_Document* pDocument) { |
| 27 | if (JsAction.GetType() == CPDF_Action::JavaScript) { |
| 28 | CFX_WideString swJS = JsAction.GetJavaScript(); |
| 29 | if (!swJS.IsEmpty()) { |
| 30 | RunDocumentOpenJavaScript(pDocument, csJSName, swJS); |
| 31 | return TRUE; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 38 | FX_BOOL CPDFSDK_ActionHandler::DoAction_FieldJavaScript( |
| 39 | const CPDF_Action& JsAction, |
| 40 | CPDF_AAction::AActionType type, |
| 41 | CPDFSDK_Document* pDocument, |
| 42 | CPDF_FormField* pFormField, |
| 43 | PDFSDK_FieldAction& data) { |
| 44 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 45 | ASSERT(pEnv); |
| 46 | if (pEnv->IsJSInitiated() && JsAction.GetType() == CPDF_Action::JavaScript) { |
| 47 | CFX_WideString swJS = JsAction.GetJavaScript(); |
| 48 | if (!swJS.IsEmpty()) { |
| 49 | RunFieldJavaScript(pDocument, pFormField, type, data, swJS); |
| 50 | return TRUE; |
| 51 | } |
| 52 | } |
| 53 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 56 | FX_BOOL CPDFSDK_ActionHandler::DoAction_Page( |
| 57 | const CPDF_Action& action, |
| 58 | enum CPDF_AAction::AActionType eType, |
| 59 | CPDFSDK_Document* pDocument) { |
| 60 | CFX_PtrList list; |
| 61 | return ExecuteDocumentPageAction(action, eType, pDocument, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 62 | } |
| 63 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 64 | FX_BOOL CPDFSDK_ActionHandler::DoAction_Document( |
| 65 | const CPDF_Action& action, |
| 66 | enum CPDF_AAction::AActionType eType, |
| 67 | CPDFSDK_Document* pDocument) { |
| 68 | CFX_PtrList list; |
| 69 | return ExecuteDocumentPageAction(action, eType, pDocument, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 72 | FX_BOOL CPDFSDK_ActionHandler::DoAction_BookMark(CPDF_Bookmark* pBookMark, |
| 73 | const CPDF_Action& action, |
| 74 | CPDF_AAction::AActionType type, |
| 75 | CPDFSDK_Document* pDocument) { |
| 76 | CFX_PtrList list; |
| 77 | return ExecuteBookMark(action, pDocument, pBookMark, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 80 | FX_BOOL CPDFSDK_ActionHandler::DoAction_Screen(const CPDF_Action& action, |
| 81 | CPDF_AAction::AActionType type, |
| 82 | CPDFSDK_Document* pDocument, |
| 83 | CPDFSDK_Annot* pScreen) { |
| 84 | CFX_PtrList list; |
| 85 | return ExecuteScreenAction(action, type, pDocument, pScreen, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 88 | FX_BOOL CPDFSDK_ActionHandler::DoAction_Link(const CPDF_Action& action, |
| 89 | CPDFSDK_Document* pDocument) { |
| 90 | CFX_PtrList list; |
| 91 | return ExecuteLinkAction(action, pDocument, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 92 | } |
| 93 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 94 | FX_BOOL CPDFSDK_ActionHandler::DoAction_Field(const CPDF_Action& action, |
| 95 | CPDF_AAction::AActionType type, |
| 96 | CPDFSDK_Document* pDocument, |
| 97 | CPDF_FormField* pFormField, |
| 98 | PDFSDK_FieldAction& data) { |
| 99 | CFX_PtrList list; |
| 100 | return ExecuteFieldAction(action, type, pDocument, pFormField, data, list); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 103 | FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction( |
| 104 | const CPDF_Action& action, |
| 105 | CPDFSDK_Document* pDocument, |
| 106 | CFX_PtrList& list) { |
| 107 | CPDF_Dictionary* pDict = action.GetDict(); |
| 108 | if (list.Find(pDict)) |
| 109 | return FALSE; |
| 110 | |
| 111 | list.AddTail(pDict); |
| 112 | |
| 113 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 114 | ASSERT(pEnv); |
| 115 | if (action.GetType() == CPDF_Action::JavaScript) { |
| 116 | if (pEnv->IsJSInitiated()) { |
| 117 | CFX_WideString swJS = action.GetJavaScript(); |
| 118 | if (!swJS.IsEmpty()) { |
| 119 | RunDocumentOpenJavaScript(pDocument, L"", swJS); |
| 120 | } |
| 121 | } |
| 122 | } else { |
| 123 | DoAction_NoJs(action, pDocument); |
| 124 | } |
| 125 | |
| 126 | for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 127 | CPDF_Action subaction = action.GetSubAction(i); |
| 128 | if (!ExecuteDocumentOpenAction(subaction, pDocument, list)) |
| 129 | return FALSE; |
| 130 | } |
| 131 | |
| 132 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 133 | } |
| 134 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 135 | FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(const CPDF_Action& action, |
| 136 | CPDFSDK_Document* pDocument, |
| 137 | CFX_PtrList& list) { |
| 138 | ASSERT(pDocument != NULL); |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 139 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 140 | CPDF_Dictionary* pDict = action.GetDict(); |
| 141 | if (list.Find(pDict)) |
| 142 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 143 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 144 | list.AddTail(pDict); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 145 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 146 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 147 | ASSERT(pEnv); |
| 148 | if (action.GetType() == CPDF_Action::JavaScript) { |
| 149 | if (pEnv->IsJSInitiated()) { |
| 150 | CFX_WideString swJS = action.GetJavaScript(); |
| 151 | if (!swJS.IsEmpty()) { |
| 152 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); //???? |
| 153 | ASSERT(pRuntime != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 154 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 155 | pRuntime->SetReaderDocument(pDocument); |
| 156 | |
| 157 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 158 | ASSERT(pContext != NULL); |
| 159 | |
| 160 | pContext->OnLink_MouseUp(pDocument); |
| 161 | |
| 162 | CFX_WideString csInfo; |
| 163 | FX_BOOL bRet = pContext->RunScript(swJS, csInfo); |
| 164 | if (!bRet) { |
| 165 | // FIXME: return error. |
| 166 | } |
| 167 | |
| 168 | pRuntime->ReleaseContext(pContext); |
| 169 | } |
| 170 | } |
| 171 | } else { |
| 172 | DoAction_NoJs(action, pDocument); |
| 173 | } |
| 174 | |
| 175 | for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 176 | CPDF_Action subaction = action.GetSubAction(i); |
| 177 | if (!ExecuteLinkAction(subaction, pDocument, list)) |
| 178 | return FALSE; |
| 179 | } |
| 180 | |
| 181 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 182 | } |
| 183 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 184 | FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction( |
| 185 | const CPDF_Action& action, |
| 186 | CPDF_AAction::AActionType type, |
| 187 | CPDFSDK_Document* pDocument, |
| 188 | CFX_PtrList& list) { |
| 189 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 190 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 191 | CPDF_Dictionary* pDict = action.GetDict(); |
| 192 | if (list.Find(pDict)) |
| 193 | return FALSE; |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 194 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 195 | list.AddTail(pDict); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 196 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 197 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 198 | ASSERT(pEnv); |
| 199 | if (action.GetType() == CPDF_Action::JavaScript) { |
| 200 | if (pEnv->IsJSInitiated()) { |
| 201 | CFX_WideString swJS = action.GetJavaScript(); |
| 202 | if (!swJS.IsEmpty()) { |
| 203 | RunDocumentPageJavaScript(pDocument, type, swJS); |
| 204 | } |
| 205 | } |
| 206 | } else { |
| 207 | DoAction_NoJs(action, pDocument); |
| 208 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 209 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 210 | if (!IsValidDocView(pDocument)) |
| 211 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 212 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 213 | for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 214 | CPDF_Action subaction = action.GetSubAction(i); |
| 215 | if (!ExecuteDocumentPageAction(subaction, type, pDocument, list)) |
| 216 | return FALSE; |
| 217 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 218 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 219 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 220 | } |
| 221 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 222 | FX_BOOL CPDFSDK_ActionHandler::IsValidField(CPDFSDK_Document* pDocument, |
| 223 | CPDF_Dictionary* pFieldDict) { |
Chris Palmer | 9047b8b | 2014-08-06 14:17:45 -0700 | [diff] [blame] | 224 | ASSERT(pDocument != NULL); |
| 225 | ASSERT(pFieldDict != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 226 | |
Chris Palmer | 9047b8b | 2014-08-06 14:17:45 -0700 | [diff] [blame] | 227 | CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); |
| 228 | ASSERT(pInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 229 | |
Chris Palmer | 9047b8b | 2014-08-06 14:17:45 -0700 | [diff] [blame] | 230 | CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 231 | ASSERT(pPDFInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 232 | |
Chris Palmer | 9047b8b | 2014-08-06 14:17:45 -0700 | [diff] [blame] | 233 | return pPDFInterForm->GetFieldByDict(pFieldDict) != NULL; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 234 | } |
| 235 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 236 | FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction( |
| 237 | const CPDF_Action& action, |
| 238 | CPDF_AAction::AActionType type, |
| 239 | CPDFSDK_Document* pDocument, |
| 240 | CPDF_FormField* pFormField, |
| 241 | PDFSDK_FieldAction& data, |
| 242 | CFX_PtrList& list) { |
| 243 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 244 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 245 | CPDF_Dictionary* pDict = action.GetDict(); |
| 246 | if (list.Find(pDict)) |
| 247 | return FALSE; |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 248 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 249 | list.AddTail(pDict); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 250 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 251 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 252 | ASSERT(pEnv); |
| 253 | if (action.GetType() == CPDF_Action::JavaScript) { |
| 254 | if (pEnv->IsJSInitiated()) { |
| 255 | CFX_WideString swJS = action.GetJavaScript(); |
| 256 | if (!swJS.IsEmpty()) { |
| 257 | RunFieldJavaScript(pDocument, pFormField, type, data, swJS); |
| 258 | if (!IsValidField(pDocument, pFormField->GetFieldDict())) |
| 259 | return FALSE; |
| 260 | } |
| 261 | } |
| 262 | } else { |
| 263 | DoAction_NoJs(action, pDocument); |
| 264 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 265 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 266 | for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 267 | CPDF_Action subaction = action.GetSubAction(i); |
| 268 | if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data, list)) |
| 269 | return FALSE; |
| 270 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 271 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 272 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 275 | FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction( |
| 276 | const CPDF_Action& action, |
| 277 | CPDF_AAction::AActionType type, |
| 278 | CPDFSDK_Document* pDocument, |
| 279 | CPDFSDK_Annot* pScreen, |
| 280 | CFX_PtrList& list) { |
| 281 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 282 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 283 | CPDF_Dictionary* pDict = action.GetDict(); |
| 284 | if (list.Find(pDict)) |
| 285 | return FALSE; |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 286 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 287 | list.AddTail(pDict); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 288 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 289 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 290 | ASSERT(pEnv); |
| 291 | if (action.GetType() == CPDF_Action::JavaScript) { |
| 292 | if (pEnv->IsJSInitiated()) { |
| 293 | CFX_WideString swJS = action.GetJavaScript(); |
| 294 | if (!swJS.IsEmpty()) { |
| 295 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 296 | ASSERT(pRuntime != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 297 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 298 | pRuntime->SetReaderDocument(pDocument); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 299 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 300 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 301 | ASSERT(pContext != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 302 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 303 | // switch (type) |
| 304 | // { |
| 305 | // case CPDF_AAction::CursorEnter: |
| 306 | // pContext->OnScreen_MouseEnter(IsCTRLpressed(), |
| 307 | // IsSHIFTpressed(), pScreen); |
| 308 | // break; |
| 309 | // case CPDF_AAction::CursorExit: |
| 310 | // pContext->OnScreen_MouseExit(IsCTRLpressed(), |
| 311 | // IsSHIFTpressed(), pScreen); |
| 312 | // break; |
| 313 | // case CPDF_AAction::ButtonDown: |
| 314 | // pContext->OnScreen_MouseDown(IsCTRLpressed(), |
| 315 | // IsSHIFTpressed(), pScreen); |
| 316 | // break; |
| 317 | // case CPDF_AAction::ButtonUp: |
| 318 | // pContext->OnScreen_MouseUp(IsCTRLpressed(), |
| 319 | // IsSHIFTpressed(), pScreen); |
| 320 | // break; |
| 321 | // case CPDF_AAction::GetFocus: |
| 322 | // pContext->OnScreen_Focus(IsCTRLpressed(), |
| 323 | // IsSHIFTpressed(), pScreen); |
| 324 | // break; |
| 325 | // case CPDF_AAction::LoseFocus: |
| 326 | // pContext->OnScreen_Blur(IsCTRLpressed(), |
| 327 | // IsSHIFTpressed(), pScreen); |
| 328 | // break; |
| 329 | // case CPDF_AAction::PageOpen: |
| 330 | // pContext->OnScreen_Open(IsCTRLpressed(), |
| 331 | // IsSHIFTpressed(), pScreen); |
| 332 | // break; |
| 333 | // case CPDF_AAction::PageClose: |
| 334 | // pContext->OnScreen_Close(IsCTRLpressed(), |
| 335 | // IsSHIFTpressed(), pScreen); |
| 336 | // break; |
| 337 | // case CPDF_AAction::PageVisible: |
| 338 | // pContext->OnScreen_InView(IsCTRLpressed(), |
| 339 | // IsSHIFTpressed(), pScreen); |
| 340 | // break; |
| 341 | // case CPDF_AAction::PageInvisible: |
| 342 | // pContext->OnScreen_OutView(IsCTRLpressed(), |
| 343 | // IsSHIFTpressed(), pScreen); |
| 344 | // break; |
| 345 | // default: |
| 346 | // ASSERT(FALSE); |
| 347 | // break; |
| 348 | // } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 349 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 350 | CFX_WideString csInfo; |
| 351 | FX_BOOL bRet = pContext->RunScript(swJS, csInfo); |
| 352 | if (!bRet) { |
| 353 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), |
| 354 | // csInfo); |
| 355 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 356 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 357 | pRuntime->ReleaseContext(pContext); |
| 358 | } |
| 359 | } |
| 360 | } else { |
| 361 | DoAction_NoJs(action, pDocument); |
| 362 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 363 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 364 | for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 365 | CPDF_Action subaction = action.GetSubAction(i); |
| 366 | if (!ExecuteScreenAction(subaction, type, pDocument, pScreen, list)) |
| 367 | return FALSE; |
| 368 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 369 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 370 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 371 | } |
| 372 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 373 | FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark(const CPDF_Action& action, |
| 374 | CPDFSDK_Document* pDocument, |
| 375 | CPDF_Bookmark* pBookmark, |
| 376 | CFX_PtrList& list) { |
| 377 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 378 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 379 | CPDF_Dictionary* pDict = action.GetDict(); |
| 380 | if (list.Find(pDict)) |
| 381 | return FALSE; |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 382 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 383 | list.AddTail(pDict); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 384 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 385 | CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
| 386 | ASSERT(pEnv); |
| 387 | if (action.GetType() == CPDF_Action::JavaScript) { |
| 388 | if (pEnv->IsJSInitiated()) { |
| 389 | CFX_WideString swJS = action.GetJavaScript(); |
| 390 | if (!swJS.IsEmpty()) { |
| 391 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 392 | ASSERT(pRuntime != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 393 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 394 | pRuntime->SetReaderDocument(pDocument); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 395 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 396 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 397 | ASSERT(pContext != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 398 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 399 | pContext->OnBookmark_MouseUp(pBookmark); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 400 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 401 | CFX_WideString csInfo; |
| 402 | FX_BOOL bRet = pContext->RunScript(swJS, csInfo); |
| 403 | if (!bRet) { |
| 404 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), |
| 405 | // csInfo); |
| 406 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 407 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 408 | pRuntime->ReleaseContext(pContext); |
| 409 | } |
| 410 | } |
| 411 | } else { |
| 412 | DoAction_NoJs(action, pDocument); |
| 413 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 414 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 415 | for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 416 | CPDF_Action subaction = action.GetSubAction(i); |
| 417 | if (!ExecuteBookMark(subaction, pDocument, pBookmark, list)) |
| 418 | return FALSE; |
| 419 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 420 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 421 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 422 | } |
| 423 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 424 | void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action, |
| 425 | CPDFSDK_Document* pDocument) { |
| 426 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 427 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 428 | switch (action.GetType()) { |
| 429 | case CPDF_Action::GoTo: |
| 430 | DoAction_GoTo(pDocument, action); |
| 431 | break; |
| 432 | case CPDF_Action::GoToR: |
| 433 | DoAction_GoToR(pDocument, action); |
| 434 | break; |
| 435 | case CPDF_Action::GoToE: |
| 436 | break; |
| 437 | case CPDF_Action::Launch: |
| 438 | DoAction_Launch(pDocument, action); |
| 439 | break; |
| 440 | case CPDF_Action::Thread: |
| 441 | break; |
| 442 | case CPDF_Action::URI: |
| 443 | DoAction_URI(pDocument, action); |
| 444 | break; |
| 445 | case CPDF_Action::Sound: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 446 | break; |
| 447 | case CPDF_Action::Movie: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 448 | break; |
| 449 | case CPDF_Action::Hide: |
| 450 | if (m_pFormActionHandler) { |
| 451 | m_pFormActionHandler->DoAction_Hide(action, pDocument); |
| 452 | } |
| 453 | break; |
| 454 | case CPDF_Action::Named: |
| 455 | DoAction_Named(pDocument, action); |
| 456 | break; |
| 457 | case CPDF_Action::SubmitForm: |
| 458 | if (m_pFormActionHandler) { |
| 459 | m_pFormActionHandler->DoAction_SubmitForm(action, pDocument); |
| 460 | } |
| 461 | break; |
| 462 | case CPDF_Action::ResetForm: |
| 463 | if (m_pFormActionHandler) { |
| 464 | m_pFormActionHandler->DoAction_ResetForm(action, pDocument); |
| 465 | } |
| 466 | break; |
| 467 | case CPDF_Action::ImportData: |
| 468 | if (m_pFormActionHandler) { |
| 469 | m_pFormActionHandler->DoAction_ImportData(action, pDocument); |
| 470 | } |
| 471 | break; |
| 472 | case CPDF_Action::JavaScript: |
| 473 | ASSERT(FALSE); |
| 474 | break; |
| 475 | case CPDF_Action::SetOCGState: |
| 476 | DoAction_SetOCGState(pDocument, action); |
| 477 | break; |
| 478 | case CPDF_Action::Rendition: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 479 | break; |
| 480 | case CPDF_Action::Trans: |
| 481 | break; |
| 482 | case CPDF_Action::GoTo3DView: |
| 483 | break; |
| 484 | default: |
| 485 | break; |
| 486 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 487 | } |
| 488 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 489 | FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument) { |
| 490 | ASSERT(pDocument != NULL); |
| 491 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 492 | } |
| 493 | |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 494 | void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 495 | const CPDF_Action& action) { |
| 496 | ASSERT(action); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 497 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 498 | CPDF_Document* pPDFDocument = pDocument->GetDocument()->GetPDFDoc(); |
| 499 | ASSERT(pPDFDocument != NULL); |
| 500 | CPDFDoc_Environment* pApp = pDocument->GetEnv(); |
| 501 | ASSERT(pApp != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 502 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 503 | CPDF_Dest MyDest = action.GetDest(pPDFDocument); |
| 504 | int nPageIndex = MyDest.GetPageIndex(pPDFDocument); |
| 505 | int nFitType = MyDest.GetZoomMode(); |
| 506 | const CPDF_Array* pMyArray = (CPDF_Array*)MyDest.GetObject(); |
| 507 | float* pPosAry = NULL; |
| 508 | int sizeOfAry = 0; |
| 509 | if (pMyArray != NULL) { |
| 510 | pPosAry = new float[pMyArray->GetCount()]; |
| 511 | int j = 0; |
| 512 | for (int i = 2; i < (int)pMyArray->GetCount(); i++) { |
| 513 | pPosAry[j++] = pMyArray->GetFloat(i); |
| 514 | } |
| 515 | sizeOfAry = j; |
| 516 | } |
| 517 | pApp->FFI_DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry); |
Lei Zhang | da180e9 | 2015-08-14 22:22:13 -0700 | [diff] [blame] | 518 | delete[] pPosAry; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 519 | } |
| 520 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 521 | void CPDFSDK_ActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument, |
| 522 | const CPDF_Action& action) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 523 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 524 | void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument, |
| 525 | const CPDF_Action& action) {} |
| 526 | |
| 527 | void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument, |
| 528 | const CPDF_Action& action) { |
| 529 | ASSERT(action); |
| 530 | |
| 531 | CPDFDoc_Environment* pApp = pDocument->GetEnv(); |
| 532 | ASSERT(pApp != NULL); |
| 533 | |
| 534 | CFX_ByteString sURI = action.GetURI(pDocument->GetDocument()->GetPDFDoc()); |
| 535 | pApp->FFI_DoURIAction(sURI.c_str()); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 536 | } |
| 537 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 538 | void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument, |
| 539 | const CPDF_Action& action) { |
| 540 | ASSERT(action); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 541 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 542 | CFX_ByteString csName = action.GetNamedAction(); |
| 543 | pDocument->GetEnv()->FFI_ExecuteNamedAction(csName); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 544 | } |
| 545 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 546 | void CPDFSDK_ActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument, |
| 547 | const CPDF_Action& action) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 548 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 549 | void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument, |
| 550 | CPDF_FormField* pFormField, |
| 551 | CPDF_AAction::AActionType type, |
| 552 | PDFSDK_FieldAction& data, |
| 553 | const CFX_WideString& script) { |
| 554 | ASSERT(type != CPDF_AAction::Calculate); |
| 555 | ASSERT(type != CPDF_AAction::Format); |
Tom Sepez | d7e5cc7 | 2015-06-10 14:33:37 -0700 | [diff] [blame] | 556 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 557 | ASSERT(pDocument != NULL); |
| 558 | |
| 559 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 560 | ASSERT(pRuntime != NULL); |
| 561 | |
| 562 | pRuntime->SetReaderDocument(pDocument); |
| 563 | |
| 564 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 565 | ASSERT(pContext != NULL); |
| 566 | |
| 567 | switch (type) { |
| 568 | case CPDF_AAction::CursorEnter: |
| 569 | pContext->OnField_MouseEnter(data.bModifier, data.bShift, pFormField); |
| 570 | break; |
| 571 | case CPDF_AAction::CursorExit: |
| 572 | pContext->OnField_MouseExit(data.bModifier, data.bShift, pFormField); |
| 573 | break; |
| 574 | case CPDF_AAction::ButtonDown: |
| 575 | pContext->OnField_MouseDown(data.bModifier, data.bShift, pFormField); |
| 576 | break; |
| 577 | case CPDF_AAction::ButtonUp: |
| 578 | pContext->OnField_MouseUp(data.bModifier, data.bShift, pFormField); |
| 579 | break; |
| 580 | case CPDF_AAction::GetFocus: |
| 581 | pContext->OnField_Focus(data.bModifier, data.bShift, pFormField, |
| 582 | data.sValue); |
| 583 | break; |
| 584 | case CPDF_AAction::LoseFocus: |
| 585 | pContext->OnField_Blur(data.bModifier, data.bShift, pFormField, |
| 586 | data.sValue); |
| 587 | break; |
| 588 | case CPDF_AAction::KeyStroke: |
| 589 | pContext->OnField_Keystroke(data.sChange, data.sChangeEx, data.bKeyDown, |
| 590 | data.bModifier, data.nSelEnd, data.nSelStart, |
| 591 | data.bShift, pFormField, data.sValue, |
| 592 | data.bWillCommit, data.bFieldFull, data.bRC); |
| 593 | break; |
| 594 | case CPDF_AAction::Validate: |
| 595 | pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bKeyDown, |
| 596 | data.bModifier, data.bShift, pFormField, |
| 597 | data.sValue, data.bRC); |
| 598 | break; |
| 599 | default: |
| 600 | ASSERT(FALSE); |
| 601 | break; |
| 602 | } |
| 603 | |
| 604 | CFX_WideString csInfo; |
| 605 | FX_BOOL bRet = pContext->RunScript(script, csInfo); |
| 606 | if (!bRet) { |
| 607 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); |
| 608 | } |
| 609 | |
| 610 | pRuntime->ReleaseContext(pContext); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 611 | } |
| 612 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 613 | void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( |
| 614 | CPDFSDK_Document* pDocument, |
| 615 | const CFX_WideString& sScriptName, |
| 616 | const CFX_WideString& script) { |
| 617 | ASSERT(pDocument != NULL); |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 618 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 619 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 620 | ASSERT(pRuntime != NULL); |
| 621 | |
| 622 | pRuntime->SetReaderDocument(pDocument); |
| 623 | |
| 624 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 625 | ASSERT(pContext != NULL); |
| 626 | |
| 627 | pContext->OnDoc_Open(pDocument, sScriptName); |
| 628 | |
| 629 | CFX_WideString csInfo; |
| 630 | FX_BOOL bRet = pContext->RunScript(script, csInfo); |
| 631 | if (!bRet) { |
| 632 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); |
| 633 | } |
| 634 | |
| 635 | pRuntime->ReleaseContext(pContext); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 636 | } |
| 637 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 638 | void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( |
| 639 | CPDFSDK_Document* pDocument, |
| 640 | CPDF_AAction::AActionType type, |
| 641 | const CFX_WideString& script) { |
| 642 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 643 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 644 | IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); |
| 645 | ASSERT(pRuntime != NULL); |
| 646 | |
| 647 | pRuntime->SetReaderDocument(pDocument); |
| 648 | |
| 649 | IFXJS_Context* pContext = pRuntime->NewContext(); |
| 650 | ASSERT(pContext != NULL); |
| 651 | |
| 652 | switch (type) { |
| 653 | case CPDF_AAction::OpenPage: |
| 654 | pContext->OnPage_Open(pDocument); |
| 655 | break; |
| 656 | case CPDF_AAction::ClosePage: |
| 657 | pContext->OnPage_Close(pDocument); |
| 658 | break; |
| 659 | case CPDF_AAction::CloseDocument: |
| 660 | pContext->OnDoc_WillClose(pDocument); |
| 661 | break; |
| 662 | case CPDF_AAction::SaveDocument: |
| 663 | pContext->OnDoc_WillSave(pDocument); |
| 664 | break; |
| 665 | case CPDF_AAction::DocumentSaved: |
| 666 | pContext->OnDoc_DidSave(pDocument); |
| 667 | break; |
| 668 | case CPDF_AAction::PrintDocument: |
| 669 | pContext->OnDoc_WillPrint(pDocument); |
| 670 | break; |
| 671 | case CPDF_AAction::DocumentPrinted: |
| 672 | pContext->OnDoc_DidPrint(pDocument); |
| 673 | break; |
| 674 | case CPDF_AAction::PageVisible: |
| 675 | pContext->OnPage_InView(pDocument); |
| 676 | break; |
| 677 | case CPDF_AAction::PageInvisible: |
| 678 | pContext->OnPage_OutView(pDocument); |
| 679 | break; |
| 680 | default: |
| 681 | ASSERT(FALSE); |
| 682 | break; |
| 683 | } |
| 684 | |
| 685 | CFX_WideString csInfo; |
| 686 | FX_BOOL bRet = pContext->RunScript(script, csInfo); |
| 687 | if (!bRet) { |
| 688 | // CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), csInfo); |
| 689 | } |
| 690 | |
| 691 | pRuntime->ReleaseContext(pContext); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 692 | } |
| 693 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 694 | FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, |
| 695 | CPDFSDK_Document* pDocument) { |
| 696 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 697 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 698 | CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 699 | ASSERT(pInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 700 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 701 | if (pInterForm->DoAction_Hide(action)) { |
| 702 | pDocument->SetChangeMark(); |
| 703 | return TRUE; |
| 704 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 705 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 706 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 707 | } |
| 708 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 709 | FX_BOOL CPDFSDK_FormActionHandler::DoAction_SubmitForm( |
| 710 | const CPDF_Action& action, |
| 711 | CPDFSDK_Document* pDocument) { |
| 712 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 713 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 714 | CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 715 | ASSERT(pInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 716 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 717 | return pInterForm->DoAction_SubmitForm(action); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 718 | } |
| 719 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 720 | FX_BOOL CPDFSDK_FormActionHandler::DoAction_ResetForm( |
| 721 | const CPDF_Action& action, |
| 722 | CPDFSDK_Document* pDocument) { |
| 723 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 724 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 725 | CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 726 | ASSERT(pInterForm != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 727 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 728 | if (pInterForm->DoAction_ResetForm(action)) { |
| 729 | return TRUE; |
| 730 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 731 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 732 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 733 | } |
| 734 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 735 | FX_BOOL CPDFSDK_FormActionHandler::DoAction_ImportData( |
| 736 | const CPDF_Action& action, |
| 737 | CPDFSDK_Document* pDocument) { |
| 738 | ASSERT(pDocument != NULL); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 739 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 740 | CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterForm(); |
| 741 | ASSERT(pInterForm != NULL); |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 742 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 743 | if (pInterForm->DoAction_ImportData(action)) { |
| 744 | pDocument->SetChangeMark(); |
| 745 | return TRUE; |
| 746 | } |
Tom Sepez | 7b5bc26 | 2015-03-05 16:44:22 -0800 | [diff] [blame] | 747 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 748 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 749 | } |