| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "fpdfsdk/fsdk_actionhandler.h" | 7 #include "fpdfsdk/fsdk_actionhandler.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "core/fpdfapi/parser/cpdf_array.h" | 11 #include "core/fpdfapi/parser/cpdf_array.h" |
| 12 #include "core/fpdfdoc/cpdf_formfield.h" | 12 #include "core/fpdfdoc/cpdf_formfield.h" |
| 13 #include "core/fpdfdoc/cpdf_interform.h" | 13 #include "core/fpdfdoc/cpdf_interform.h" |
| 14 #include "fpdfsdk/cpdfsdk_document.h" | 14 #include "fpdfsdk/cpdfsdk_document.h" |
| 15 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" | 15 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
| 16 #include "fpdfsdk/cpdfsdk_interform.h" | 16 #include "fpdfsdk/cpdfsdk_interform.h" |
| 17 #include "fpdfsdk/fsdk_define.h" | 17 #include "fpdfsdk/fsdk_define.h" |
| 18 #include "fpdfsdk/javascript/ijs_context.h" | 18 #include "fpdfsdk/javascript/ijs_context.h" |
| 19 #include "fpdfsdk/javascript/ijs_runtime.h" | 19 #include "fpdfsdk/javascript/ijs_runtime.h" |
| 20 #include "third_party/base/stl_util.h" | 20 #include "third_party/base/stl_util.h" |
| 21 | 21 |
| 22 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, | 22 FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen( |
| 23 CPDFSDK_Document* pDocument) { | 23 const CPDF_Action& action, |
| 24 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 24 std::set<CPDF_Dictionary*> visited; | 25 std::set<CPDF_Dictionary*> visited; |
| 25 return ExecuteDocumentOpenAction(action, pDocument, &visited); | 26 return ExecuteDocumentOpenAction(action, pFormFillEnv, &visited); |
| 26 } | 27 } |
| 27 | 28 |
| 28 FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript( | 29 FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript( |
| 29 const CPDF_Action& JsAction, | 30 const CPDF_Action& JsAction, |
| 30 CFX_WideString csJSName, | 31 CFX_WideString csJSName, |
| 31 CPDFSDK_Document* pDocument) { | 32 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 32 if (JsAction.GetType() == CPDF_Action::JavaScript) { | 33 if (JsAction.GetType() == CPDF_Action::JavaScript) { |
| 33 CFX_WideString swJS = JsAction.GetJavaScript(); | 34 CFX_WideString swJS = JsAction.GetJavaScript(); |
| 34 if (!swJS.IsEmpty()) { | 35 if (!swJS.IsEmpty()) { |
| 35 RunDocumentOpenJavaScript(pDocument, csJSName, swJS); | 36 RunDocumentOpenJavaScript(pFormFillEnv, csJSName, swJS); |
| 36 return TRUE; | 37 return TRUE; |
| 37 } | 38 } |
| 38 } | 39 } |
| 39 | 40 |
| 40 return FALSE; | 41 return FALSE; |
| 41 } | 42 } |
| 42 | 43 |
| 43 FX_BOOL CPDFSDK_ActionHandler::DoAction_FieldJavaScript( | 44 FX_BOOL CPDFSDK_ActionHandler::DoAction_FieldJavaScript( |
| 44 const CPDF_Action& JsAction, | 45 const CPDF_Action& JsAction, |
| 45 CPDF_AAction::AActionType type, | 46 CPDF_AAction::AActionType type, |
| 46 CPDFSDK_Document* pDocument, | 47 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 47 CPDF_FormField* pFormField, | 48 CPDF_FormField* pFormField, |
| 48 PDFSDK_FieldAction& data) { | 49 PDFSDK_FieldAction& data) { |
| 49 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv(); | 50 ASSERT(pFormFillEnv); |
| 50 ASSERT(pEnv); | 51 if (pFormFillEnv->IsJSInitiated() && |
| 51 if (pEnv->IsJSInitiated() && JsAction.GetType() == CPDF_Action::JavaScript) { | 52 JsAction.GetType() == CPDF_Action::JavaScript) { |
| 52 CFX_WideString swJS = JsAction.GetJavaScript(); | 53 CFX_WideString swJS = JsAction.GetJavaScript(); |
| 53 if (!swJS.IsEmpty()) { | 54 if (!swJS.IsEmpty()) { |
| 54 RunFieldJavaScript(pDocument, pFormField, type, data, swJS); | 55 RunFieldJavaScript(pFormFillEnv, pFormField, type, data, swJS); |
| 55 return TRUE; | 56 return TRUE; |
| 56 } | 57 } |
| 57 } | 58 } |
| 58 return FALSE; | 59 return FALSE; |
| 59 } | 60 } |
| 60 | 61 |
| 61 FX_BOOL CPDFSDK_ActionHandler::DoAction_Page( | 62 FX_BOOL CPDFSDK_ActionHandler::DoAction_Page( |
| 62 const CPDF_Action& action, | 63 const CPDF_Action& action, |
| 63 enum CPDF_AAction::AActionType eType, | 64 enum CPDF_AAction::AActionType eType, |
| 64 CPDFSDK_Document* pDocument) { | 65 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 65 std::set<CPDF_Dictionary*> visited; | 66 std::set<CPDF_Dictionary*> visited; |
| 66 return ExecuteDocumentPageAction(action, eType, pDocument, &visited); | 67 return ExecuteDocumentPageAction(action, eType, pFormFillEnv, &visited); |
| 67 } | 68 } |
| 68 | 69 |
| 69 FX_BOOL CPDFSDK_ActionHandler::DoAction_Document( | 70 FX_BOOL CPDFSDK_ActionHandler::DoAction_Document( |
| 70 const CPDF_Action& action, | 71 const CPDF_Action& action, |
| 71 enum CPDF_AAction::AActionType eType, | 72 enum CPDF_AAction::AActionType eType, |
| 72 CPDFSDK_Document* pDocument) { | 73 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 73 std::set<CPDF_Dictionary*> visited; | 74 std::set<CPDF_Dictionary*> visited; |
| 74 return ExecuteDocumentPageAction(action, eType, pDocument, &visited); | 75 return ExecuteDocumentPageAction(action, eType, pFormFillEnv, &visited); |
| 75 } | 76 } |
| 76 | 77 |
| 77 FX_BOOL CPDFSDK_ActionHandler::DoAction_BookMark(CPDF_Bookmark* pBookMark, | 78 FX_BOOL CPDFSDK_ActionHandler::DoAction_BookMark( |
| 78 const CPDF_Action& action, | 79 CPDF_Bookmark* pBookMark, |
| 79 CPDF_AAction::AActionType type, | 80 const CPDF_Action& action, |
| 80 CPDFSDK_Document* pDocument) { | 81 CPDF_AAction::AActionType type, |
| 82 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 81 std::set<CPDF_Dictionary*> visited; | 83 std::set<CPDF_Dictionary*> visited; |
| 82 return ExecuteBookMark(action, pDocument, pBookMark, &visited); | 84 return ExecuteBookMark(action, pFormFillEnv, pBookMark, &visited); |
| 83 } | 85 } |
| 84 | 86 |
| 85 FX_BOOL CPDFSDK_ActionHandler::DoAction_Screen(const CPDF_Action& action, | 87 FX_BOOL CPDFSDK_ActionHandler::DoAction_Screen( |
| 86 CPDF_AAction::AActionType type, | 88 const CPDF_Action& action, |
| 87 CPDFSDK_Document* pDocument, | 89 CPDF_AAction::AActionType type, |
| 88 CPDFSDK_Annot* pScreen) { | 90 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 91 CPDFSDK_Annot* pScreen) { |
| 89 std::set<CPDF_Dictionary*> visited; | 92 std::set<CPDF_Dictionary*> visited; |
| 90 return ExecuteScreenAction(action, type, pDocument, pScreen, &visited); | 93 return ExecuteScreenAction(action, type, pFormFillEnv, pScreen, &visited); |
| 91 } | 94 } |
| 92 | 95 |
| 93 FX_BOOL CPDFSDK_ActionHandler::DoAction_Link(const CPDF_Action& action, | 96 FX_BOOL CPDFSDK_ActionHandler::DoAction_Link( |
| 94 CPDFSDK_Document* pDocument) { | 97 const CPDF_Action& action, |
| 98 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 95 std::set<CPDF_Dictionary*> visited; | 99 std::set<CPDF_Dictionary*> visited; |
| 96 return ExecuteLinkAction(action, pDocument, &visited); | 100 return ExecuteLinkAction(action, pFormFillEnv, &visited); |
| 97 } | 101 } |
| 98 | 102 |
| 99 FX_BOOL CPDFSDK_ActionHandler::DoAction_Field(const CPDF_Action& action, | 103 FX_BOOL CPDFSDK_ActionHandler::DoAction_Field( |
| 100 CPDF_AAction::AActionType type, | 104 const CPDF_Action& action, |
| 101 CPDFSDK_Document* pDocument, | 105 CPDF_AAction::AActionType type, |
| 102 CPDF_FormField* pFormField, | 106 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 103 PDFSDK_FieldAction& data) { | 107 CPDF_FormField* pFormField, |
| 108 PDFSDK_FieldAction& data) { |
| 104 std::set<CPDF_Dictionary*> visited; | 109 std::set<CPDF_Dictionary*> visited; |
| 105 return ExecuteFieldAction(action, type, pDocument, pFormField, data, | 110 return ExecuteFieldAction(action, type, pFormFillEnv, pFormField, data, |
| 106 &visited); | 111 &visited); |
| 107 } | 112 } |
| 108 | 113 |
| 109 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction( | 114 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction( |
| 110 const CPDF_Action& action, | 115 const CPDF_Action& action, |
| 111 CPDFSDK_Document* pDocument, | 116 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 112 std::set<CPDF_Dictionary*>* visited) { | 117 std::set<CPDF_Dictionary*>* visited) { |
| 113 CPDF_Dictionary* pDict = action.GetDict(); | 118 CPDF_Dictionary* pDict = action.GetDict(); |
| 114 if (pdfium::ContainsKey(*visited, pDict)) | 119 if (pdfium::ContainsKey(*visited, pDict)) |
| 115 return FALSE; | 120 return FALSE; |
| 116 | 121 |
| 117 visited->insert(pDict); | 122 visited->insert(pDict); |
| 118 | 123 |
| 119 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv(); | 124 ASSERT(pFormFillEnv); |
| 120 ASSERT(pEnv); | |
| 121 if (action.GetType() == CPDF_Action::JavaScript) { | 125 if (action.GetType() == CPDF_Action::JavaScript) { |
| 122 if (pEnv->IsJSInitiated()) { | 126 if (pFormFillEnv->IsJSInitiated()) { |
| 123 CFX_WideString swJS = action.GetJavaScript(); | 127 CFX_WideString swJS = action.GetJavaScript(); |
| 124 if (!swJS.IsEmpty()) { | 128 if (!swJS.IsEmpty()) { |
| 125 RunDocumentOpenJavaScript(pDocument, L"", swJS); | 129 RunDocumentOpenJavaScript(pFormFillEnv, L"", swJS); |
| 126 } | 130 } |
| 127 } | 131 } |
| 128 } else { | 132 } else { |
| 129 DoAction_NoJs(action, pDocument); | 133 DoAction_NoJs(action, pFormFillEnv); |
| 130 } | 134 } |
| 131 | 135 |
| 132 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 136 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 133 CPDF_Action subaction = action.GetSubAction(i); | 137 CPDF_Action subaction = action.GetSubAction(i); |
| 134 if (!ExecuteDocumentOpenAction(subaction, pDocument, visited)) | 138 if (!ExecuteDocumentOpenAction(subaction, pFormFillEnv, visited)) |
| 135 return FALSE; | 139 return FALSE; |
| 136 } | 140 } |
| 137 | 141 |
| 138 return TRUE; | 142 return TRUE; |
| 139 } | 143 } |
| 140 | 144 |
| 141 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction( | 145 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction( |
| 142 const CPDF_Action& action, | 146 const CPDF_Action& action, |
| 143 CPDFSDK_Document* pDocument, | 147 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 144 std::set<CPDF_Dictionary*>* visited) { | 148 std::set<CPDF_Dictionary*>* visited) { |
| 145 CPDF_Dictionary* pDict = action.GetDict(); | 149 CPDF_Dictionary* pDict = action.GetDict(); |
| 146 if (pdfium::ContainsKey(*visited, pDict)) | 150 if (pdfium::ContainsKey(*visited, pDict)) |
| 147 return FALSE; | 151 return FALSE; |
| 148 | 152 |
| 149 visited->insert(pDict); | 153 visited->insert(pDict); |
| 150 | 154 |
| 151 CPDFSDK_FormFillEnvironment* pFormFillEnv = pDocument->GetEnv(); | |
| 152 ASSERT(pFormFillEnv); | 155 ASSERT(pFormFillEnv); |
| 153 if (action.GetType() == CPDF_Action::JavaScript) { | 156 if (action.GetType() == CPDF_Action::JavaScript) { |
| 154 if (pFormFillEnv->IsJSInitiated()) { | 157 if (pFormFillEnv->IsJSInitiated()) { |
| 155 CFX_WideString swJS = action.GetJavaScript(); | 158 CFX_WideString swJS = action.GetJavaScript(); |
| 156 if (!swJS.IsEmpty()) { | 159 if (!swJS.IsEmpty()) { |
| 157 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime(); | 160 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime(); |
| 158 IJS_Context* pContext = pRuntime->NewContext(); | 161 IJS_Context* pContext = pRuntime->NewContext(); |
| 159 pContext->OnLink_MouseUp(pFormFillEnv); | 162 pContext->OnLink_MouseUp(pFormFillEnv); |
| 160 | 163 |
| 161 CFX_WideString csInfo; | 164 CFX_WideString csInfo; |
| 162 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); | 165 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); |
| 163 if (!bRet) { | 166 if (!bRet) { |
| 164 // FIXME: return error. | 167 // FIXME: return error. |
| 165 } | 168 } |
| 166 | 169 |
| 167 pRuntime->ReleaseContext(pContext); | 170 pRuntime->ReleaseContext(pContext); |
| 168 } | 171 } |
| 169 } | 172 } |
| 170 } else { | 173 } else { |
| 171 DoAction_NoJs(action, pDocument); | 174 DoAction_NoJs(action, pFormFillEnv); |
| 172 } | 175 } |
| 173 | 176 |
| 174 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 177 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 175 CPDF_Action subaction = action.GetSubAction(i); | 178 CPDF_Action subaction = action.GetSubAction(i); |
| 176 if (!ExecuteLinkAction(subaction, pDocument, visited)) | 179 if (!ExecuteLinkAction(subaction, pFormFillEnv, visited)) |
| 177 return FALSE; | 180 return FALSE; |
| 178 } | 181 } |
| 179 | 182 |
| 180 return TRUE; | 183 return TRUE; |
| 181 } | 184 } |
| 182 | 185 |
| 183 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction( | 186 FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction( |
| 184 const CPDF_Action& action, | 187 const CPDF_Action& action, |
| 185 CPDF_AAction::AActionType type, | 188 CPDF_AAction::AActionType type, |
| 186 CPDFSDK_Document* pDocument, | 189 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 187 std::set<CPDF_Dictionary*>* visited) { | 190 std::set<CPDF_Dictionary*>* visited) { |
| 188 CPDF_Dictionary* pDict = action.GetDict(); | 191 CPDF_Dictionary* pDict = action.GetDict(); |
| 189 if (pdfium::ContainsKey(*visited, pDict)) | 192 if (pdfium::ContainsKey(*visited, pDict)) |
| 190 return FALSE; | 193 return FALSE; |
| 191 | 194 |
| 192 visited->insert(pDict); | 195 visited->insert(pDict); |
| 193 | 196 |
| 194 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv(); | 197 ASSERT(pFormFillEnv); |
| 195 ASSERT(pEnv); | |
| 196 if (action.GetType() == CPDF_Action::JavaScript) { | 198 if (action.GetType() == CPDF_Action::JavaScript) { |
| 197 if (pEnv->IsJSInitiated()) { | 199 if (pFormFillEnv->IsJSInitiated()) { |
| 198 CFX_WideString swJS = action.GetJavaScript(); | 200 CFX_WideString swJS = action.GetJavaScript(); |
| 199 if (!swJS.IsEmpty()) { | 201 if (!swJS.IsEmpty()) { |
| 200 RunDocumentPageJavaScript(pDocument, type, swJS); | 202 RunDocumentPageJavaScript(pFormFillEnv, type, swJS); |
| 201 } | 203 } |
| 202 } | 204 } |
| 203 } else { | 205 } else { |
| 204 DoAction_NoJs(action, pDocument); | 206 DoAction_NoJs(action, pFormFillEnv); |
| 205 } | 207 } |
| 206 | 208 |
| 207 if (!IsValidDocView(pDocument)) | 209 if (!IsValidDocView(pFormFillEnv)) |
| 208 return FALSE; | 210 return FALSE; |
| 209 | 211 |
| 210 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 212 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 211 CPDF_Action subaction = action.GetSubAction(i); | 213 CPDF_Action subaction = action.GetSubAction(i); |
| 212 if (!ExecuteDocumentPageAction(subaction, type, pDocument, visited)) | 214 if (!ExecuteDocumentPageAction(subaction, type, pFormFillEnv, visited)) |
| 213 return FALSE; | 215 return FALSE; |
| 214 } | 216 } |
| 215 | 217 |
| 216 return TRUE; | 218 return TRUE; |
| 217 } | 219 } |
| 218 | 220 |
| 219 FX_BOOL CPDFSDK_ActionHandler::IsValidField(CPDFSDK_Document* pDocument, | 221 FX_BOOL CPDFSDK_ActionHandler::IsValidField( |
| 220 CPDF_Dictionary* pFieldDict) { | 222 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 223 CPDF_Dictionary* pFieldDict) { |
| 221 ASSERT(pFieldDict); | 224 ASSERT(pFieldDict); |
| 222 | 225 |
| 223 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 226 CPDFSDK_InterForm* pInterForm = |
| 227 pFormFillEnv->GetSDKDocument()->GetInterForm(); |
| 224 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 228 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 225 return !!pPDFInterForm->GetFieldByDict(pFieldDict); | 229 return !!pPDFInterForm->GetFieldByDict(pFieldDict); |
| 226 } | 230 } |
| 227 | 231 |
| 228 FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction( | 232 FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction( |
| 229 const CPDF_Action& action, | 233 const CPDF_Action& action, |
| 230 CPDF_AAction::AActionType type, | 234 CPDF_AAction::AActionType type, |
| 231 CPDFSDK_Document* pDocument, | 235 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 232 CPDF_FormField* pFormField, | 236 CPDF_FormField* pFormField, |
| 233 PDFSDK_FieldAction& data, | 237 PDFSDK_FieldAction& data, |
| 234 std::set<CPDF_Dictionary*>* visited) { | 238 std::set<CPDF_Dictionary*>* visited) { |
| 235 CPDF_Dictionary* pDict = action.GetDict(); | 239 CPDF_Dictionary* pDict = action.GetDict(); |
| 236 if (pdfium::ContainsKey(*visited, pDict)) | 240 if (pdfium::ContainsKey(*visited, pDict)) |
| 237 return FALSE; | 241 return FALSE; |
| 238 | 242 |
| 239 visited->insert(pDict); | 243 visited->insert(pDict); |
| 240 | 244 |
| 241 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv(); | 245 ASSERT(pFormFillEnv); |
| 242 ASSERT(pEnv); | |
| 243 if (action.GetType() == CPDF_Action::JavaScript) { | 246 if (action.GetType() == CPDF_Action::JavaScript) { |
| 244 if (pEnv->IsJSInitiated()) { | 247 if (pFormFillEnv->IsJSInitiated()) { |
| 245 CFX_WideString swJS = action.GetJavaScript(); | 248 CFX_WideString swJS = action.GetJavaScript(); |
| 246 if (!swJS.IsEmpty()) { | 249 if (!swJS.IsEmpty()) { |
| 247 RunFieldJavaScript(pDocument, pFormField, type, data, swJS); | 250 RunFieldJavaScript(pFormFillEnv, pFormField, type, data, swJS); |
| 248 if (!IsValidField(pDocument, pFormField->GetFieldDict())) | 251 if (!IsValidField(pFormFillEnv, pFormField->GetFieldDict())) |
| 249 return FALSE; | 252 return FALSE; |
| 250 } | 253 } |
| 251 } | 254 } |
| 252 } else { | 255 } else { |
| 253 DoAction_NoJs(action, pDocument); | 256 DoAction_NoJs(action, pFormFillEnv); |
| 254 } | 257 } |
| 255 | 258 |
| 256 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 259 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 257 CPDF_Action subaction = action.GetSubAction(i); | 260 CPDF_Action subaction = action.GetSubAction(i); |
| 258 if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data, | 261 if (!ExecuteFieldAction(subaction, type, pFormFillEnv, pFormField, data, |
| 259 visited)) | 262 visited)) |
| 260 return FALSE; | 263 return FALSE; |
| 261 } | 264 } |
| 262 | 265 |
| 263 return TRUE; | 266 return TRUE; |
| 264 } | 267 } |
| 265 | 268 |
| 266 FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction( | 269 FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction( |
| 267 const CPDF_Action& action, | 270 const CPDF_Action& action, |
| 268 CPDF_AAction::AActionType type, | 271 CPDF_AAction::AActionType type, |
| 269 CPDFSDK_Document* pDocument, | 272 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 270 CPDFSDK_Annot* pScreen, | 273 CPDFSDK_Annot* pScreen, |
| 271 std::set<CPDF_Dictionary*>* visited) { | 274 std::set<CPDF_Dictionary*>* visited) { |
| 272 CPDF_Dictionary* pDict = action.GetDict(); | 275 CPDF_Dictionary* pDict = action.GetDict(); |
| 273 if (pdfium::ContainsKey(*visited, pDict)) | 276 if (pdfium::ContainsKey(*visited, pDict)) |
| 274 return FALSE; | 277 return FALSE; |
| 275 | 278 |
| 276 visited->insert(pDict); | 279 visited->insert(pDict); |
| 277 | 280 |
| 278 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv(); | 281 ASSERT(pFormFillEnv); |
| 279 ASSERT(pEnv); | |
| 280 if (action.GetType() == CPDF_Action::JavaScript) { | 282 if (action.GetType() == CPDF_Action::JavaScript) { |
| 281 if (pEnv->IsJSInitiated()) { | 283 if (pFormFillEnv->IsJSInitiated()) { |
| 282 CFX_WideString swJS = action.GetJavaScript(); | 284 CFX_WideString swJS = action.GetJavaScript(); |
| 283 if (!swJS.IsEmpty()) { | 285 if (!swJS.IsEmpty()) { |
| 284 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 286 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime(); |
| 285 IJS_Context* pContext = pRuntime->NewContext(); | 287 IJS_Context* pContext = pRuntime->NewContext(); |
| 286 CFX_WideString csInfo; | 288 CFX_WideString csInfo; |
| 287 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); | 289 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); |
| 288 if (!bRet) { | 290 if (!bRet) { |
| 289 // FIXME: return error. | 291 // FIXME: return error. |
| 290 } | 292 } |
| 291 | 293 |
| 292 pRuntime->ReleaseContext(pContext); | 294 pRuntime->ReleaseContext(pContext); |
| 293 } | 295 } |
| 294 } | 296 } |
| 295 } else { | 297 } else { |
| 296 DoAction_NoJs(action, pDocument); | 298 DoAction_NoJs(action, pFormFillEnv); |
| 297 } | 299 } |
| 298 | 300 |
| 299 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 301 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 300 CPDF_Action subaction = action.GetSubAction(i); | 302 CPDF_Action subaction = action.GetSubAction(i); |
| 301 if (!ExecuteScreenAction(subaction, type, pDocument, pScreen, visited)) | 303 if (!ExecuteScreenAction(subaction, type, pFormFillEnv, pScreen, visited)) |
| 302 return FALSE; | 304 return FALSE; |
| 303 } | 305 } |
| 304 | 306 |
| 305 return TRUE; | 307 return TRUE; |
| 306 } | 308 } |
| 307 | 309 |
| 308 FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark( | 310 FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark( |
| 309 const CPDF_Action& action, | 311 const CPDF_Action& action, |
| 310 CPDFSDK_Document* pDocument, | 312 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 311 CPDF_Bookmark* pBookmark, | 313 CPDF_Bookmark* pBookmark, |
| 312 std::set<CPDF_Dictionary*>* visited) { | 314 std::set<CPDF_Dictionary*>* visited) { |
| 313 CPDF_Dictionary* pDict = action.GetDict(); | 315 CPDF_Dictionary* pDict = action.GetDict(); |
| 314 if (pdfium::ContainsKey(*visited, pDict)) | 316 if (pdfium::ContainsKey(*visited, pDict)) |
| 315 return FALSE; | 317 return FALSE; |
| 316 | 318 |
| 317 visited->insert(pDict); | 319 visited->insert(pDict); |
| 318 | 320 |
| 319 CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv(); | 321 ASSERT(pFormFillEnv); |
| 320 ASSERT(pEnv); | |
| 321 if (action.GetType() == CPDF_Action::JavaScript) { | 322 if (action.GetType() == CPDF_Action::JavaScript) { |
| 322 if (pEnv->IsJSInitiated()) { | 323 if (pFormFillEnv->IsJSInitiated()) { |
| 323 CFX_WideString swJS = action.GetJavaScript(); | 324 CFX_WideString swJS = action.GetJavaScript(); |
| 324 if (!swJS.IsEmpty()) { | 325 if (!swJS.IsEmpty()) { |
| 325 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 326 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime(); |
| 326 IJS_Context* pContext = pRuntime->NewContext(); | 327 IJS_Context* pContext = pRuntime->NewContext(); |
| 327 pContext->OnBookmark_MouseUp(pBookmark); | 328 pContext->OnBookmark_MouseUp(pBookmark); |
| 328 | 329 |
| 329 CFX_WideString csInfo; | 330 CFX_WideString csInfo; |
| 330 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); | 331 FX_BOOL bRet = pContext->RunScript(swJS, &csInfo); |
| 331 if (!bRet) { | 332 if (!bRet) { |
| 332 // FIXME: return error. | 333 // FIXME: return error. |
| 333 } | 334 } |
| 334 | 335 |
| 335 pRuntime->ReleaseContext(pContext); | 336 pRuntime->ReleaseContext(pContext); |
| 336 } | 337 } |
| 337 } | 338 } |
| 338 } else { | 339 } else { |
| 339 DoAction_NoJs(action, pDocument); | 340 DoAction_NoJs(action, pFormFillEnv); |
| 340 } | 341 } |
| 341 | 342 |
| 342 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { | 343 for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) { |
| 343 CPDF_Action subaction = action.GetSubAction(i); | 344 CPDF_Action subaction = action.GetSubAction(i); |
| 344 if (!ExecuteBookMark(subaction, pDocument, pBookmark, visited)) | 345 if (!ExecuteBookMark(subaction, pFormFillEnv, pBookmark, visited)) |
| 345 return FALSE; | 346 return FALSE; |
| 346 } | 347 } |
| 347 | 348 |
| 348 return TRUE; | 349 return TRUE; |
| 349 } | 350 } |
| 350 | 351 |
| 351 void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action, | 352 void CPDFSDK_ActionHandler::DoAction_NoJs( |
| 352 CPDFSDK_Document* pDocument) { | 353 const CPDF_Action& action, |
| 353 ASSERT(pDocument); | 354 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 355 ASSERT(pFormFillEnv); |
| 354 | 356 |
| 355 switch (action.GetType()) { | 357 switch (action.GetType()) { |
| 356 case CPDF_Action::GoTo: | 358 case CPDF_Action::GoTo: |
| 357 DoAction_GoTo(pDocument, action); | 359 DoAction_GoTo(pFormFillEnv, action); |
| 358 break; | 360 break; |
| 359 case CPDF_Action::GoToR: | 361 case CPDF_Action::GoToR: |
| 360 DoAction_GoToR(pDocument, action); | 362 DoAction_GoToR(pFormFillEnv, action); |
| 361 break; | 363 break; |
| 362 case CPDF_Action::GoToE: | 364 case CPDF_Action::GoToE: |
| 363 break; | 365 break; |
| 364 case CPDF_Action::Launch: | 366 case CPDF_Action::Launch: |
| 365 DoAction_Launch(pDocument, action); | 367 DoAction_Launch(pFormFillEnv, action); |
| 366 break; | 368 break; |
| 367 case CPDF_Action::Thread: | 369 case CPDF_Action::Thread: |
| 368 break; | 370 break; |
| 369 case CPDF_Action::URI: | 371 case CPDF_Action::URI: |
| 370 DoAction_URI(pDocument, action); | 372 DoAction_URI(pFormFillEnv, action); |
| 371 break; | 373 break; |
| 372 case CPDF_Action::Sound: | 374 case CPDF_Action::Sound: |
| 373 break; | 375 break; |
| 374 case CPDF_Action::Movie: | 376 case CPDF_Action::Movie: |
| 375 break; | 377 break; |
| 376 case CPDF_Action::Hide: | 378 case CPDF_Action::Hide: |
| 377 DoAction_Hide(action, pDocument); | 379 DoAction_Hide(action, pFormFillEnv); |
| 378 break; | 380 break; |
| 379 case CPDF_Action::Named: | 381 case CPDF_Action::Named: |
| 380 DoAction_Named(pDocument, action); | 382 DoAction_Named(pFormFillEnv, action); |
| 381 break; | 383 break; |
| 382 case CPDF_Action::SubmitForm: | 384 case CPDF_Action::SubmitForm: |
| 383 DoAction_SubmitForm(action, pDocument); | 385 DoAction_SubmitForm(action, pFormFillEnv); |
| 384 break; | 386 break; |
| 385 case CPDF_Action::ResetForm: | 387 case CPDF_Action::ResetForm: |
| 386 DoAction_ResetForm(action, pDocument); | 388 DoAction_ResetForm(action, pFormFillEnv); |
| 387 break; | 389 break; |
| 388 case CPDF_Action::ImportData: | 390 case CPDF_Action::ImportData: |
| 389 DoAction_ImportData(action, pDocument); | 391 DoAction_ImportData(action, pFormFillEnv); |
| 390 break; | 392 break; |
| 391 case CPDF_Action::JavaScript: | 393 case CPDF_Action::JavaScript: |
| 392 ASSERT(FALSE); | 394 ASSERT(FALSE); |
| 393 break; | 395 break; |
| 394 case CPDF_Action::SetOCGState: | 396 case CPDF_Action::SetOCGState: |
| 395 DoAction_SetOCGState(pDocument, action); | 397 DoAction_SetOCGState(pFormFillEnv, action); |
| 396 break; | 398 break; |
| 397 case CPDF_Action::Rendition: | 399 case CPDF_Action::Rendition: |
| 398 break; | 400 break; |
| 399 case CPDF_Action::Trans: | 401 case CPDF_Action::Trans: |
| 400 break; | 402 break; |
| 401 case CPDF_Action::GoTo3DView: | 403 case CPDF_Action::GoTo3DView: |
| 402 break; | 404 break; |
| 403 default: | 405 default: |
| 404 break; | 406 break; |
| 405 } | 407 } |
| 406 } | 408 } |
| 407 | 409 |
| 408 FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument) { | 410 FX_BOOL CPDFSDK_ActionHandler::IsValidDocView( |
| 409 ASSERT(pDocument); | 411 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 412 ASSERT(pFormFillEnv); |
| 410 return TRUE; | 413 return TRUE; |
| 411 } | 414 } |
| 412 | 415 |
| 413 void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument, | 416 void CPDFSDK_ActionHandler::DoAction_GoTo( |
| 414 const CPDF_Action& action) { | 417 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 418 const CPDF_Action& action) { |
| 415 ASSERT(action.GetDict()); | 419 ASSERT(action.GetDict()); |
| 416 | 420 |
| 417 CPDF_Document* pPDFDocument = pDocument->GetPDFDocument(); | 421 CPDF_Document* pPDFDocument = |
| 422 pFormFillEnv->GetSDKDocument()->GetPDFDocument(); |
| 418 ASSERT(pPDFDocument); | 423 ASSERT(pPDFDocument); |
| 419 | 424 |
| 420 CPDF_Dest MyDest = action.GetDest(pPDFDocument); | 425 CPDF_Dest MyDest = action.GetDest(pPDFDocument); |
| 421 int nPageIndex = MyDest.GetPageIndex(pPDFDocument); | 426 int nPageIndex = MyDest.GetPageIndex(pPDFDocument); |
| 422 int nFitType = MyDest.GetZoomMode(); | 427 int nFitType = MyDest.GetZoomMode(); |
| 423 const CPDF_Array* pMyArray = ToArray(MyDest.GetObject()); | 428 const CPDF_Array* pMyArray = ToArray(MyDest.GetObject()); |
| 424 float* pPosAry = nullptr; | 429 float* pPosAry = nullptr; |
| 425 int sizeOfAry = 0; | 430 int sizeOfAry = 0; |
| 426 if (pMyArray) { | 431 if (pMyArray) { |
| 427 pPosAry = new float[pMyArray->GetCount()]; | 432 pPosAry = new float[pMyArray->GetCount()]; |
| 428 int j = 0; | 433 int j = 0; |
| 429 for (size_t i = 2; i < pMyArray->GetCount(); i++) { | 434 for (size_t i = 2; i < pMyArray->GetCount(); i++) { |
| 430 pPosAry[j++] = pMyArray->GetFloatAt(i); | 435 pPosAry[j++] = pMyArray->GetFloatAt(i); |
| 431 } | 436 } |
| 432 sizeOfAry = j; | 437 sizeOfAry = j; |
| 433 } | 438 } |
| 434 | 439 |
| 435 CPDFSDK_FormFillEnvironment* pApp = pDocument->GetEnv(); | 440 pFormFillEnv->DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry); |
| 436 pApp->DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry); | |
| 437 delete[] pPosAry; | 441 delete[] pPosAry; |
| 438 } | 442 } |
| 439 | 443 |
| 440 void CPDFSDK_ActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument, | 444 void CPDFSDK_ActionHandler::DoAction_GoToR( |
| 441 const CPDF_Action& action) {} | 445 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 446 const CPDF_Action& action) {} |
| 442 | 447 |
| 443 void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument, | 448 void CPDFSDK_ActionHandler::DoAction_Launch( |
| 444 const CPDF_Action& action) {} | 449 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 450 const CPDF_Action& action) {} |
| 445 | 451 |
| 446 void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument, | 452 void CPDFSDK_ActionHandler::DoAction_URI( |
| 447 const CPDF_Action& action) { | 453 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 454 const CPDF_Action& action) { |
| 448 ASSERT(action.GetDict()); | 455 ASSERT(action.GetDict()); |
| 449 | 456 |
| 450 CPDFSDK_FormFillEnvironment* pApp = pDocument->GetEnv(); | 457 CFX_ByteString sURI = |
| 451 CFX_ByteString sURI = action.GetURI(pDocument->GetPDFDocument()); | 458 action.GetURI(pFormFillEnv->GetSDKDocument()->GetPDFDocument()); |
| 452 pApp->DoURIAction(sURI.c_str()); | 459 pFormFillEnv->DoURIAction(sURI.c_str()); |
| 453 } | 460 } |
| 454 | 461 |
| 455 void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument, | 462 void CPDFSDK_ActionHandler::DoAction_Named( |
| 456 const CPDF_Action& action) { | 463 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 464 const CPDF_Action& action) { |
| 457 ASSERT(action.GetDict()); | 465 ASSERT(action.GetDict()); |
| 458 | 466 |
| 459 CFX_ByteString csName = action.GetNamedAction(); | 467 CFX_ByteString csName = action.GetNamedAction(); |
| 460 pDocument->GetEnv()->ExecuteNamedAction(csName.c_str()); | 468 pFormFillEnv->ExecuteNamedAction(csName.c_str()); |
| 461 } | 469 } |
| 462 | 470 |
| 463 void CPDFSDK_ActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument, | 471 void CPDFSDK_ActionHandler::DoAction_SetOCGState( |
| 464 const CPDF_Action& action) {} | 472 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 473 const CPDF_Action& action) {} |
| 465 | 474 |
| 466 void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument, | 475 void CPDFSDK_ActionHandler::RunFieldJavaScript( |
| 467 CPDF_FormField* pFormField, | 476 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 468 CPDF_AAction::AActionType type, | 477 CPDF_FormField* pFormField, |
| 469 PDFSDK_FieldAction& data, | 478 CPDF_AAction::AActionType type, |
| 470 const CFX_WideString& script) { | 479 PDFSDK_FieldAction& data, |
| 480 const CFX_WideString& script) { |
| 471 ASSERT(type != CPDF_AAction::Calculate); | 481 ASSERT(type != CPDF_AAction::Calculate); |
| 472 ASSERT(type != CPDF_AAction::Format); | 482 ASSERT(type != CPDF_AAction::Format); |
| 473 | 483 |
| 474 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 484 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime(); |
| 475 IJS_Context* pContext = pRuntime->NewContext(); | 485 IJS_Context* pContext = pRuntime->NewContext(); |
| 476 switch (type) { | 486 switch (type) { |
| 477 case CPDF_AAction::CursorEnter: | 487 case CPDF_AAction::CursorEnter: |
| 478 pContext->OnField_MouseEnter(data.bModifier, data.bShift, pFormField); | 488 pContext->OnField_MouseEnter(data.bModifier, data.bShift, pFormField); |
| 479 break; | 489 break; |
| 480 case CPDF_AAction::CursorExit: | 490 case CPDF_AAction::CursorExit: |
| 481 pContext->OnField_MouseExit(data.bModifier, data.bShift, pFormField); | 491 pContext->OnField_MouseExit(data.bModifier, data.bShift, pFormField); |
| 482 break; | 492 break; |
| 483 case CPDF_AAction::ButtonDown: | 493 case CPDF_AAction::ButtonDown: |
| 484 pContext->OnField_MouseDown(data.bModifier, data.bShift, pFormField); | 494 pContext->OnField_MouseDown(data.bModifier, data.bShift, pFormField); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 513 CFX_WideString csInfo; | 523 CFX_WideString csInfo; |
| 514 FX_BOOL bRet = pContext->RunScript(script, &csInfo); | 524 FX_BOOL bRet = pContext->RunScript(script, &csInfo); |
| 515 if (!bRet) { | 525 if (!bRet) { |
| 516 // FIXME: return error. | 526 // FIXME: return error. |
| 517 } | 527 } |
| 518 | 528 |
| 519 pRuntime->ReleaseContext(pContext); | 529 pRuntime->ReleaseContext(pContext); |
| 520 } | 530 } |
| 521 | 531 |
| 522 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( | 532 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript( |
| 523 CPDFSDK_Document* pDocument, | 533 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 524 const CFX_WideString& sScriptName, | 534 const CFX_WideString& sScriptName, |
| 525 const CFX_WideString& script) { | 535 const CFX_WideString& script) { |
| 526 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 536 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime(); |
| 527 IJS_Context* pContext = pRuntime->NewContext(); | 537 IJS_Context* pContext = pRuntime->NewContext(); |
| 528 pContext->OnDoc_Open(pDocument->GetEnv(), sScriptName); | 538 pContext->OnDoc_Open(pFormFillEnv, sScriptName); |
| 529 | 539 |
| 530 CFX_WideString csInfo; | 540 CFX_WideString csInfo; |
| 531 FX_BOOL bRet = pContext->RunScript(script, &csInfo); | 541 FX_BOOL bRet = pContext->RunScript(script, &csInfo); |
| 532 if (!bRet) { | 542 if (!bRet) { |
| 533 // FIXME: return error. | 543 // FIXME: return error. |
| 534 } | 544 } |
| 535 | 545 |
| 536 pRuntime->ReleaseContext(pContext); | 546 pRuntime->ReleaseContext(pContext); |
| 537 } | 547 } |
| 538 | 548 |
| 539 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( | 549 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( |
| 540 CPDFSDK_Document* pDocument, | 550 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 541 CPDF_AAction::AActionType type, | 551 CPDF_AAction::AActionType type, |
| 542 const CFX_WideString& script) { | 552 const CFX_WideString& script) { |
| 543 IJS_Runtime* pRuntime = pDocument->GetJsRuntime(); | 553 IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime(); |
| 544 IJS_Context* pContext = pRuntime->NewContext(); | 554 IJS_Context* pContext = pRuntime->NewContext(); |
| 545 switch (type) { | 555 switch (type) { |
| 546 case CPDF_AAction::OpenPage: | 556 case CPDF_AAction::OpenPage: |
| 547 pContext->OnPage_Open(pDocument->GetEnv()); | 557 pContext->OnPage_Open(pFormFillEnv); |
| 548 break; | 558 break; |
| 549 case CPDF_AAction::ClosePage: | 559 case CPDF_AAction::ClosePage: |
| 550 pContext->OnPage_Close(pDocument->GetEnv()); | 560 pContext->OnPage_Close(pFormFillEnv); |
| 551 break; | 561 break; |
| 552 case CPDF_AAction::CloseDocument: | 562 case CPDF_AAction::CloseDocument: |
| 553 pContext->OnDoc_WillClose(pDocument->GetEnv()); | 563 pContext->OnDoc_WillClose(pFormFillEnv); |
| 554 break; | 564 break; |
| 555 case CPDF_AAction::SaveDocument: | 565 case CPDF_AAction::SaveDocument: |
| 556 pContext->OnDoc_WillSave(pDocument->GetEnv()); | 566 pContext->OnDoc_WillSave(pFormFillEnv); |
| 557 break; | 567 break; |
| 558 case CPDF_AAction::DocumentSaved: | 568 case CPDF_AAction::DocumentSaved: |
| 559 pContext->OnDoc_DidSave(pDocument->GetEnv()); | 569 pContext->OnDoc_DidSave(pFormFillEnv); |
| 560 break; | 570 break; |
| 561 case CPDF_AAction::PrintDocument: | 571 case CPDF_AAction::PrintDocument: |
| 562 pContext->OnDoc_WillPrint(pDocument->GetEnv()); | 572 pContext->OnDoc_WillPrint(pFormFillEnv); |
| 563 break; | 573 break; |
| 564 case CPDF_AAction::DocumentPrinted: | 574 case CPDF_AAction::DocumentPrinted: |
| 565 pContext->OnDoc_DidPrint(pDocument->GetEnv()); | 575 pContext->OnDoc_DidPrint(pFormFillEnv); |
| 566 break; | 576 break; |
| 567 case CPDF_AAction::PageVisible: | 577 case CPDF_AAction::PageVisible: |
| 568 pContext->OnPage_InView(pDocument->GetEnv()); | 578 pContext->OnPage_InView(pFormFillEnv); |
| 569 break; | 579 break; |
| 570 case CPDF_AAction::PageInvisible: | 580 case CPDF_AAction::PageInvisible: |
| 571 pContext->OnPage_OutView(pDocument->GetEnv()); | 581 pContext->OnPage_OutView(pFormFillEnv); |
| 572 break; | 582 break; |
| 573 default: | 583 default: |
| 574 ASSERT(FALSE); | 584 ASSERT(FALSE); |
| 575 break; | 585 break; |
| 576 } | 586 } |
| 577 | 587 |
| 578 CFX_WideString csInfo; | 588 CFX_WideString csInfo; |
| 579 FX_BOOL bRet = pContext->RunScript(script, &csInfo); | 589 FX_BOOL bRet = pContext->RunScript(script, &csInfo); |
| 580 if (!bRet) { | 590 if (!bRet) { |
| 581 // FIXME: return error. | 591 // FIXME: return error. |
| 582 } | 592 } |
| 583 | 593 |
| 584 pRuntime->ReleaseContext(pContext); | 594 pRuntime->ReleaseContext(pContext); |
| 585 } | 595 } |
| 586 | 596 |
| 587 FX_BOOL CPDFSDK_ActionHandler::DoAction_Hide(const CPDF_Action& action, | 597 FX_BOOL CPDFSDK_ActionHandler::DoAction_Hide( |
| 588 CPDFSDK_Document* pDocument) { | 598 const CPDF_Action& action, |
| 589 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 599 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 600 CPDFSDK_InterForm* pInterForm = |
| 601 pFormFillEnv->GetSDKDocument()->GetInterForm(); |
| 590 if (pInterForm->DoAction_Hide(action)) { | 602 if (pInterForm->DoAction_Hide(action)) { |
| 591 pDocument->SetChangeMark(); | 603 pFormFillEnv->GetSDKDocument()->SetChangeMark(); |
| 592 return TRUE; | 604 return TRUE; |
| 593 } | 605 } |
| 594 | 606 |
| 595 return FALSE; | 607 return FALSE; |
| 596 } | 608 } |
| 597 | 609 |
| 598 FX_BOOL CPDFSDK_ActionHandler::DoAction_SubmitForm( | 610 FX_BOOL CPDFSDK_ActionHandler::DoAction_SubmitForm( |
| 599 const CPDF_Action& action, | 611 const CPDF_Action& action, |
| 600 CPDFSDK_Document* pDocument) { | 612 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 601 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 613 CPDFSDK_InterForm* pInterForm = |
| 614 pFormFillEnv->GetSDKDocument()->GetInterForm(); |
| 602 return pInterForm->DoAction_SubmitForm(action); | 615 return pInterForm->DoAction_SubmitForm(action); |
| 603 } | 616 } |
| 604 | 617 |
| 605 FX_BOOL CPDFSDK_ActionHandler::DoAction_ResetForm(const CPDF_Action& action, | 618 FX_BOOL CPDFSDK_ActionHandler::DoAction_ResetForm( |
| 606 CPDFSDK_Document* pDocument) { | 619 const CPDF_Action& action, |
| 607 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 620 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 621 CPDFSDK_InterForm* pInterForm = |
| 622 pFormFillEnv->GetSDKDocument()->GetInterForm(); |
| 608 return pInterForm->DoAction_ResetForm(action); | 623 return pInterForm->DoAction_ResetForm(action); |
| 609 } | 624 } |
| 610 | 625 |
| 611 FX_BOOL CPDFSDK_ActionHandler::DoAction_ImportData( | 626 FX_BOOL CPDFSDK_ActionHandler::DoAction_ImportData( |
| 612 const CPDF_Action& action, | 627 const CPDF_Action& action, |
| 613 CPDFSDK_Document* pDocument) { | 628 CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
| 614 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); | 629 CPDFSDK_InterForm* pInterForm = |
| 630 pFormFillEnv->GetSDKDocument()->GetInterForm(); |
| 615 if (pInterForm->DoAction_ImportData(action)) { | 631 if (pInterForm->DoAction_ImportData(action)) { |
| 616 pDocument->SetChangeMark(); | 632 pFormFillEnv->GetSDKDocument()->SetChangeMark(); |
| 617 return TRUE; | 633 return TRUE; |
| 618 } | 634 } |
| 619 | 635 |
| 620 return FALSE; | 636 return FALSE; |
| 621 } | 637 } |
| OLD | NEW |