Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: fpdfsdk/src/fsdk_actionhandler.cpp

Issue 1254703002: FX_BOOL considered harmful, part 2. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/fpdfview.cpp ('k') | fpdfsdk/src/fsdk_annothandler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fsdk_mgr.h" 8 #include "../include/fsdk_mgr.h"
9 #include "../include/fsdk_actionhandler.h" 9 #include "../include/fsdk_actionhandler.h"
10 #include "../include/javascript/IJavaScript.h" 10 #include "../include/javascript/IJavaScript.h"
11 11
12 /* -------------------------- CBA_ActionHandler -------------------------- */ 12 /* -------------------------- CBA_ActionHandler -------------------------- */
13 13
14 CPDFSDK_ActionHandler::CPDFSDK_ActionHandler(CPDFDoc_Environment* pEvi) 14 CPDFSDK_ActionHandler::CPDFSDK_ActionHandler(CPDFDoc_Environment* pEvi)
15 : m_pFormActionHandler(new CPDFSDK_FormActionHandler), 15 : m_pFormActionHandler(new CPDFSDK_FormActionHandler),
16 m_pMediaActionHandler(NULL) { 16 m_pMediaActionHandler(NULL) {
17 } 17 }
18 18
19 void CPDFSDK_ActionHandler::SetMediaActionHandler(CPDFSDK_MediaActionHandler* pH andler) 19 void CPDFSDK_ActionHandler::SetMediaActionHandler(CPDFSDK_MediaActionHandler* pH andler)
20 { 20 {
21 ASSERT(pHandler != NULL); 21 ASSERT(pHandler != NULL);
22 ASSERT(m_pMediaActionHandler == NULL); 22 ASSERT(m_pMediaActionHandler == NULL);
23 m_pMediaActionHandler = pHandler; 23 m_pMediaActionHandler = pHandler;
24 } 24 }
25 25
26 //document open 26 //document open
27 FX_BOOL»CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, CPDFS DK_Document* pDocument) 27 bool» CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, CPDFS DK_Document* pDocument)
28 { 28 {
29 CFX_PtrList list; 29 CFX_PtrList list;
30 return ExecuteDocumentOpenAction(action, pDocument, list); 30 return ExecuteDocumentOpenAction(action, pDocument, list);
31 } 31 }
32 32
33 //document open 33 //document open
34 FX_BOOL»CPDFSDK_ActionHandler::DoAction_JavaScript(const CPDF_Action& JsAction,C FX_WideString csJSName, 34 bool» CPDFSDK_ActionHandler::DoAction_JavaScript(const CPDF_Action& JsAction,C FX_WideString csJSName,
35 CPDFSDK_Document* pDocum ent) 35 CPDFSDK_Document* pDocum ent)
36 { 36 {
37 if (JsAction.GetType() == CPDF_Action::JavaScript) 37 if (JsAction.GetType() == CPDF_Action::JavaScript)
38 { 38 {
39 CFX_WideString swJS = JsAction.GetJavaScript(); 39 CFX_WideString swJS = JsAction.GetJavaScript();
40 if (!swJS.IsEmpty()) 40 if (!swJS.IsEmpty())
41 { 41 {
42 RunDocumentOpenJavaScript(pDocument, csJSName, swJS); 42 RunDocumentOpenJavaScript(pDocument, csJSName, swJS);
43 » » » return TRUE; 43 » » » return true;
44 } 44 }
45 } 45 }
46 46
47 » return FALSE; 47 » return false;
48 } 48 }
49 49
50 FX_BOOL»CPDFSDK_ActionHandler::DoAction_FieldJavaScript(const CPDF_Action& JsAct ion, CPDF_AAction::AActionType type, 50 bool» CPDFSDK_ActionHandler::DoAction_FieldJavaScript(const CPDF_Action& JsAct ion, CPDF_AAction::AActionType type,
51 CPDFSDK_ Document* pDocument, CPDF_FormField* pFormField, 51 CPDFSDK_ Document* pDocument, CPDF_FormField* pFormField,
52 PDFSDK_F ieldAction& data) 52 PDFSDK_F ieldAction& data)
53 { 53 {
54 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 54 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
55 ASSERT(pEnv); 55 ASSERT(pEnv);
56 if (pEnv->IsJSInitiated() && JsAction.GetType() == CPDF_Action::JavaScri pt) 56 if (pEnv->IsJSInitiated() && JsAction.GetType() == CPDF_Action::JavaScri pt)
57 { 57 {
58 CFX_WideString swJS = JsAction.GetJavaScript(); 58 CFX_WideString swJS = JsAction.GetJavaScript();
59 if (!swJS.IsEmpty()) 59 if (!swJS.IsEmpty())
60 { 60 {
61 RunFieldJavaScript(pDocument, pFormField, type, data, sw JS); 61 RunFieldJavaScript(pDocument, pFormField, type, data, sw JS);
62 » » » return TRUE; 62 » » » return true;
63 } 63 }
64 } 64 }
65 » return FALSE; 65 » return false;
66 } 66 }
67 67
68 FX_BOOL»CPDFSDK_ActionHandler::DoAction_Page(const CPDF_Action& action, enum CPD F_AAction::AActionType eType, 68 bool» CPDFSDK_ActionHandler::DoAction_Page(const CPDF_Action& action, enum CPD F_AAction::AActionType eType,
69 CPDFSDK_Document* pDocument) 69 CPDFSDK_Document* pDocument)
70 { 70 {
71 CFX_PtrList list; 71 CFX_PtrList list;
72 return ExecuteDocumentPageAction(action, eType, pDocument, list); 72 return ExecuteDocumentPageAction(action, eType, pDocument, list);
73 } 73 }
74 74
75 FX_BOOL»CPDFSDK_ActionHandler::DoAction_Document(const CPDF_Action& action, enum CPDF_AAction::AActionType eType, 75 bool» CPDFSDK_ActionHandler::DoAction_Document(const CPDF_Action& action, enum CPDF_AAction::AActionType eType,
76 CPDFSDK_Document* pDocument) 76 CPDFSDK_Document* pDocument)
77 { 77 {
78 CFX_PtrList list; 78 CFX_PtrList list;
79 return ExecuteDocumentPageAction(action, eType, pDocument, list); 79 return ExecuteDocumentPageAction(action, eType, pDocument, list);
80 } 80 }
81 81
82 FX_BOOL»CPDFSDK_ActionHandler::DoAction_BookMark(CPDF_Bookmark *pBookMark, const CPDF_Action& action, CPDF_AAction::AActionType type, 82 bool» CPDFSDK_ActionHandler::DoAction_BookMark(CPDF_Bookmark *pBookMark, const CPDF_Action& action, CPDF_AAction::AActionType type,
83 CPDFSDK_Document* pDocum ent) 83 CPDFSDK_Document* pDocum ent)
84 { 84 {
85 CFX_PtrList list; 85 CFX_PtrList list;
86 return ExecuteBookMark(action, pDocument, pBookMark, list); 86 return ExecuteBookMark(action, pDocument, pBookMark, list);
87 } 87 }
88 88
89 FX_BOOL»CPDFSDK_ActionHandler::DoAction_Screen(const CPDF_Action& action, CPDF_A Action::AActionType type, 89 bool» CPDFSDK_ActionHandler::DoAction_Screen(const CPDF_Action& action, CPDF_A Action::AActionType type,
90 CPDFSDK_Document* pDocument, CPDFSDK_Annot* pScreen) 90 CPDFSDK_Document* pDocument, CPDFSDK_Annot* pScreen)
91 { 91 {
92 CFX_PtrList list; 92 CFX_PtrList list;
93 return ExecuteScreenAction(action, type, pDocument, pScreen, list); 93 return ExecuteScreenAction(action, type, pDocument, pScreen, list);
94 } 94 }
95 95
96 FX_BOOL»CPDFSDK_ActionHandler::DoAction_Link(const CPDF_Action& action, 96 bool» CPDFSDK_ActionHandler::DoAction_Link(const CPDF_Action& action,
97 CPDFSDK_Document* pDocument) 97 CPDFSDK_Document* pDocument)
98 { 98 {
99 CFX_PtrList list; 99 CFX_PtrList list;
100 return ExecuteLinkAction(action, pDocument, list); 100 return ExecuteLinkAction(action, pDocument, list);
101 } 101 }
102 102
103 FX_BOOL»CPDFSDK_ActionHandler::DoAction_Field(const CPDF_Action& action, CPDF_AA ction::AActionType type, 103 bool» CPDFSDK_ActionHandler::DoAction_Field(const CPDF_Action& action, CPDF_AA ction::AActionType type,
104 CPDFSDK_Document* pDocument, 104 CPDFSDK_Document* pDocument,
105 CPDF_FormField* pFormField, PDFSDK_FieldAction& data) 105 CPDF_FormField* pFormField, PDFSDK_FieldAction& data)
106 { 106 {
107 CFX_PtrList list; 107 CFX_PtrList list;
108 return ExecuteFieldAction(action, type, pDocument, pFormField, data, lis t); 108 return ExecuteFieldAction(action, type, pDocument, pFormField, data, lis t);
109 } 109 }
110 110
111 FX_BOOL»CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(const CPDF_Action& acti on, CPDFSDK_Document* pDocument, 111 bool» CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(const CPDF_Action& acti on, CPDFSDK_Document* pDocument,
112 CFX_PtrList& list) 112 CFX_PtrList& list)
113 { 113 {
114 CPDF_Dictionary* pDict = action.GetDict(); 114 CPDF_Dictionary* pDict = action.GetDict();
115 if (list.Find(pDict)) 115 if (list.Find(pDict))
116 » » return FALSE; 116 » » return false;
117 117
118 list.AddTail(pDict); 118 list.AddTail(pDict);
119 119
120 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 120 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
121 ASSERT(pEnv); 121 ASSERT(pEnv);
122 if (action.GetType() == CPDF_Action::JavaScript) 122 if (action.GetType() == CPDF_Action::JavaScript)
123 { 123 {
124 if(pEnv->IsJSInitiated()) 124 if(pEnv->IsJSInitiated())
125 { 125 {
126 CFX_WideString swJS = action.GetJavaScript(); 126 CFX_WideString swJS = action.GetJavaScript();
127 if (!swJS.IsEmpty()) 127 if (!swJS.IsEmpty())
128 { 128 {
129 RunDocumentOpenJavaScript(pDocument, L"", swJS); 129 RunDocumentOpenJavaScript(pDocument, L"", swJS);
130 } 130 }
131 } 131 }
132 } 132 }
133 else 133 else
134 { 134 {
135 DoAction_NoJs(action, pDocument); 135 DoAction_NoJs(action, pDocument);
136 } 136 }
137 137
138 for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++) 138 for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++)
139 { 139 {
140 CPDF_Action subaction = action.GetSubAction(i); 140 CPDF_Action subaction = action.GetSubAction(i);
141 » » if (!ExecuteDocumentOpenAction(subaction, pDocument, list)) retu rn FALSE; 141 » » if (!ExecuteDocumentOpenAction(subaction, pDocument, list)) retu rn false;
142 } 142 }
143 143
144 » return TRUE; 144 » return true;
145 } 145 }
146 146
147 FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(const CPDF_Action& action,» CPDFSDK_Document* pDocument, 147 bool CPDFSDK_ActionHandler::ExecuteLinkAction(const CPDF_Action& action,» CPDFSDK_Document* pDocument,
148 CFX_PtrList& list) 148 CFX_PtrList& list)
149 { 149 {
150 ASSERT(pDocument != NULL); 150 ASSERT(pDocument != NULL);
151 151
152 CPDF_Dictionary* pDict = action.GetDict(); 152 CPDF_Dictionary* pDict = action.GetDict();
153 if (list.Find(pDict)) 153 if (list.Find(pDict))
154 » » return FALSE; 154 » » return false;
155 155
156 list.AddTail(pDict); 156 list.AddTail(pDict);
157 157
158 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 158 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
159 ASSERT(pEnv); 159 ASSERT(pEnv);
160 if (action.GetType() == CPDF_Action::JavaScript) 160 if (action.GetType() == CPDF_Action::JavaScript)
161 { 161 {
162 if(pEnv->IsJSInitiated()) 162 if(pEnv->IsJSInitiated())
163 { 163 {
164 CFX_WideString swJS = action.GetJavaScript(); 164 CFX_WideString swJS = action.GetJavaScript();
165 if (!swJS.IsEmpty()) 165 if (!swJS.IsEmpty())
166 { 166 {
167 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntim e(); //???? 167 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntim e(); //????
168 ASSERT(pRuntime != NULL); 168 ASSERT(pRuntime != NULL);
169 169
170 pRuntime->SetReaderDocument(pDocument); 170 pRuntime->SetReaderDocument(pDocument);
171 171
172 IFXJS_Context* pContext = pRuntime->NewContext() ; 172 IFXJS_Context* pContext = pRuntime->NewContext() ;
173 ASSERT(pContext != NULL); 173 ASSERT(pContext != NULL);
174 174
175 pContext->OnLink_MouseUp(pDocument); 175 pContext->OnLink_MouseUp(pDocument);
176 176
177 CFX_WideString csInfo; 177 CFX_WideString csInfo;
178 » » » » FX_BOOL bRet = pContext->RunScript(swJS, csInfo) ; 178 » » » » bool bRet = pContext->RunScript(swJS, csInfo);
179 if (!bRet) 179 if (!bRet)
180 { 180 {
181 // FIXME: return error. 181 // FIXME: return error.
182 } 182 }
183 183
184 pRuntime->ReleaseContext(pContext); 184 pRuntime->ReleaseContext(pContext);
185 } 185 }
186 } 186 }
187 } 187 }
188 else 188 else
189 { 189 {
190 DoAction_NoJs(action, pDocument); 190 DoAction_NoJs(action, pDocument);
191 } 191 }
192 192
193 for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++) 193 for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++)
194 { 194 {
195 CPDF_Action subaction = action.GetSubAction(i); 195 CPDF_Action subaction = action.GetSubAction(i);
196 » » if (!ExecuteLinkAction(subaction, pDocument, list)) return FALSE ; 196 » » if (!ExecuteLinkAction(subaction, pDocument, list)) return false ;
197 } 197 }
198 198
199 » return TRUE; 199 » return true;
200 } 200 }
201 201
202 FX_BOOL»CPDFSDK_ActionHandler::ExecuteDocumentPageAction(const CPDF_Action& acti on, CPDF_AAction::AActionType type, 202 bool» CPDFSDK_ActionHandler::ExecuteDocumentPageAction(const CPDF_Action& acti on, CPDF_AAction::AActionType type,
203 CPDFSDK_Document* pDocument, CFX_PtrList& list) 203 CPDFSDK_Document* pDocument, CFX_PtrList& list)
204 { 204 {
205 ASSERT(pDocument != NULL); 205 ASSERT(pDocument != NULL);
206 206
207 CPDF_Dictionary* pDict = action.GetDict(); 207 CPDF_Dictionary* pDict = action.GetDict();
208 if (list.Find(pDict)) 208 if (list.Find(pDict))
209 » » return FALSE; 209 » » return false;
210 210
211 list.AddTail(pDict); 211 list.AddTail(pDict);
212 212
213 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 213 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
214 ASSERT(pEnv); 214 ASSERT(pEnv);
215 if (action.GetType() == CPDF_Action::JavaScript) 215 if (action.GetType() == CPDF_Action::JavaScript)
216 { 216 {
217 if(pEnv->IsJSInitiated()) 217 if(pEnv->IsJSInitiated())
218 { 218 {
219 CFX_WideString swJS = action.GetJavaScript(); 219 CFX_WideString swJS = action.GetJavaScript();
220 if (!swJS.IsEmpty()) 220 if (!swJS.IsEmpty())
221 { 221 {
222 RunDocumentPageJavaScript(pDocument, type, swJS) ; 222 RunDocumentPageJavaScript(pDocument, type, swJS) ;
223 } 223 }
224 } 224 }
225 } 225 }
226 else 226 else
227 { 227 {
228 DoAction_NoJs(action, pDocument); 228 DoAction_NoJs(action, pDocument);
229 } 229 }
230 230
231 if (!IsValidDocView(pDocument)) 231 if (!IsValidDocView(pDocument))
232 » » return FALSE; 232 » » return false;
233 233
234 for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++) 234 for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++)
235 { 235 {
236 CPDF_Action subaction = action.GetSubAction(i); 236 CPDF_Action subaction = action.GetSubAction(i);
237 » » if (!ExecuteDocumentPageAction(subaction, type, pDocument, list) ) return FALSE; 237 » » if (!ExecuteDocumentPageAction(subaction, type, pDocument, list) ) return false;
238 } 238 }
239 239
240 » return TRUE; 240 » return true;
241 } 241 }
242 242
243 FX_BOOL»CPDFSDK_ActionHandler::IsValidField(CPDFSDK_Document* pDocument, CPDF_Di ctionary* pFieldDict) 243 bool» CPDFSDK_ActionHandler::IsValidField(CPDFSDK_Document* pDocument, CPDF_Di ctionary* pFieldDict)
244 { 244 {
245 ASSERT(pDocument != NULL); 245 ASSERT(pDocument != NULL);
246 ASSERT(pFieldDict != NULL); 246 ASSERT(pFieldDict != NULL);
247 247
248 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); 248 CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
249 ASSERT(pInterForm != NULL); 249 ASSERT(pInterForm != NULL);
250 250
251 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); 251 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
252 ASSERT(pPDFInterForm != NULL); 252 ASSERT(pPDFInterForm != NULL);
253 253
254 return pPDFInterForm->GetFieldByDict(pFieldDict) != NULL; 254 return pPDFInterForm->GetFieldByDict(pFieldDict) != NULL;
255 } 255 }
256 256
257 FX_BOOL»CPDFSDK_ActionHandler::ExecuteFieldAction(const CPDF_Action& action, CPD F_AAction::AActionType type, 257 bool» CPDFSDK_ActionHandler::ExecuteFieldAction(const CPDF_Action& action, CPD F_AAction::AActionType type,
258 CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, 258 CPDFSDK_Document* pDocument, CPDF_FormField* pFormField,
259 PDFSDK_FieldAction& data, CFX_PtrList& list) 259 PDFSDK_FieldAction& data, CFX_PtrList& list)
260 { 260 {
261 ASSERT(pDocument != NULL); 261 ASSERT(pDocument != NULL);
262 262
263 CPDF_Dictionary* pDict = action.GetDict(); 263 CPDF_Dictionary* pDict = action.GetDict();
264 if (list.Find(pDict)) 264 if (list.Find(pDict))
265 » » return FALSE; 265 » » return false;
266 266
267 list.AddTail(pDict); 267 list.AddTail(pDict);
268 268
269 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 269 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
270 ASSERT(pEnv); 270 ASSERT(pEnv);
271 if (action.GetType() == CPDF_Action::JavaScript) 271 if (action.GetType() == CPDF_Action::JavaScript)
272 { 272 {
273 if(pEnv->IsJSInitiated()) 273 if(pEnv->IsJSInitiated())
274 { 274 {
275 CFX_WideString swJS = action.GetJavaScript(); 275 CFX_WideString swJS = action.GetJavaScript();
276 if (!swJS.IsEmpty()) 276 if (!swJS.IsEmpty())
277 { 277 {
278 RunFieldJavaScript(pDocument, pFormField, type, data, swJS); 278 RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
279 if (!IsValidField(pDocument, pFormField->GetFiel dDict())) 279 if (!IsValidField(pDocument, pFormField->GetFiel dDict()))
280 » » » » » return FALSE; 280 » » » » » return false;
281 } 281 }
282 } 282 }
283 } 283 }
284 else 284 else
285 { 285 {
286 DoAction_NoJs(action, pDocument); 286 DoAction_NoJs(action, pDocument);
287 } 287 }
288 288
289 for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++) 289 for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++)
290 { 290 {
291 CPDF_Action subaction = action.GetSubAction(i); 291 CPDF_Action subaction = action.GetSubAction(i);
292 » » if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data, list)) return FALSE; 292 » » if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data, list)) return false;
293 } 293 }
294 294
295 » return TRUE; 295 » return true;
296 } 296 }
297 297
298 FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction(const CPDF_Action& action, CP DF_AAction::AActionType type, 298 bool CPDFSDK_ActionHandler::ExecuteScreenAction(const CPDF_Action& action, CPDF_ AAction::AActionType type,
299 CPDFSDK_Document* pDocument, CPDFSDK_Annot* pScreen, CFX_PtrList& list) 299 CPDFSDK_Document* pDocument, CPDFSDK_Annot* pScreen, CFX_PtrList& list)
300 { 300 {
301 ASSERT(pDocument != NULL); 301 ASSERT(pDocument != NULL);
302 302
303 CPDF_Dictionary* pDict = action.GetDict(); 303 CPDF_Dictionary* pDict = action.GetDict();
304 if (list.Find(pDict)) 304 if (list.Find(pDict))
305 » » return FALSE; 305 » » return false;
306 306
307 list.AddTail(pDict); 307 list.AddTail(pDict);
308 308
309 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 309 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
310 ASSERT(pEnv); 310 ASSERT(pEnv);
311 if (action.GetType() == CPDF_Action::JavaScript) 311 if (action.GetType() == CPDF_Action::JavaScript)
312 { 312 {
313 if(pEnv->IsJSInitiated()) 313 if(pEnv->IsJSInitiated())
314 { 314 {
315 CFX_WideString swJS = action.GetJavaScript(); 315 CFX_WideString swJS = action.GetJavaScript();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // case CPDF_AAction::PageClose: 349 // case CPDF_AAction::PageClose:
350 // pContext->OnScreen_Close(IsCTRLpressed() , IsSHIFTpressed(), pScreen); 350 // pContext->OnScreen_Close(IsCTRLpressed() , IsSHIFTpressed(), pScreen);
351 // break; 351 // break;
352 // case CPDF_AAction::PageVisible: 352 // case CPDF_AAction::PageVisible:
353 // pContext->OnScreen_InView(IsCTRLpressed( ), IsSHIFTpressed(), pScreen); 353 // pContext->OnScreen_InView(IsCTRLpressed( ), IsSHIFTpressed(), pScreen);
354 // break; 354 // break;
355 // case CPDF_AAction::PageInvisible: 355 // case CPDF_AAction::PageInvisible:
356 // pContext->OnScreen_OutView(IsCTRLpressed (), IsSHIFTpressed(), pScreen); 356 // pContext->OnScreen_OutView(IsCTRLpressed (), IsSHIFTpressed(), pScreen);
357 // break; 357 // break;
358 // default: 358 // default:
359 » // » » » » ASSERT(FALSE); 359 » // » » » » ASSERT(false);
360 // break; 360 // break;
361 // } 361 // }
362 362
363 CFX_WideString csInfo; 363 CFX_WideString csInfo;
364 » » » » FX_BOOL bRet = pContext->RunScript(swJS, csInfo) ; 364 » » » » bool bRet = pContext->RunScript(swJS, csInfo);
365 if (!bRet) 365 if (!bRet)
366 { 366 {
367 //CBCL_FormNotify::MsgBoxJSError(pPageVi ew->GetPageViewWnd(), csInfo); 367 //CBCL_FormNotify::MsgBoxJSError(pPageVi ew->GetPageViewWnd(), csInfo);
368 } 368 }
369 369
370 pRuntime->ReleaseContext(pContext); 370 pRuntime->ReleaseContext(pContext);
371 } 371 }
372 } 372 }
373 } 373 }
374 else 374 else
375 { 375 {
376 DoAction_NoJs(action, pDocument); 376 DoAction_NoJs(action, pDocument);
377 } 377 }
378 378
379 for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++) 379 for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++)
380 { 380 {
381 CPDF_Action subaction = action.GetSubAction(i); 381 CPDF_Action subaction = action.GetSubAction(i);
382 » » if (!ExecuteScreenAction(subaction, type, pDocument, pScreen, li st)) return FALSE; 382 » » if (!ExecuteScreenAction(subaction, type, pDocument, pScreen, li st)) return false;
383 } 383 }
384 384
385 » return TRUE; 385 » return true;
386 } 386 }
387 387
388 FX_BOOL»CPDFSDK_ActionHandler::ExecuteBookMark(const CPDF_Action& action, CPDFSD K_Document* pDocument, 388 bool» CPDFSDK_ActionHandler::ExecuteBookMark(const CPDF_Action& action, CPDFSD K_Document* pDocument,
389 CPDF_Bookmark* pBookmark, CFX_PtrList& list) 389 CPDF_Bookmark* pBookmark, CFX_PtrList& list)
390 { 390 {
391 ASSERT(pDocument != NULL); 391 ASSERT(pDocument != NULL);
392 392
393 CPDF_Dictionary* pDict = action.GetDict(); 393 CPDF_Dictionary* pDict = action.GetDict();
394 if (list.Find(pDict)) 394 if (list.Find(pDict))
395 » » return FALSE; 395 » » return false;
396 396
397 list.AddTail(pDict); 397 list.AddTail(pDict);
398 398
399 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 399 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
400 ASSERT(pEnv); 400 ASSERT(pEnv);
401 if (action.GetType() == CPDF_Action::JavaScript) 401 if (action.GetType() == CPDF_Action::JavaScript)
402 { 402 {
403 if(pEnv->IsJSInitiated()) 403 if(pEnv->IsJSInitiated())
404 { 404 {
405 CFX_WideString swJS = action.GetJavaScript(); 405 CFX_WideString swJS = action.GetJavaScript();
406 if (!swJS.IsEmpty()) 406 if (!swJS.IsEmpty())
407 { 407 {
408 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntim e(); 408 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntim e();
409 ASSERT(pRuntime != NULL); 409 ASSERT(pRuntime != NULL);
410 410
411 pRuntime->SetReaderDocument(pDocument); 411 pRuntime->SetReaderDocument(pDocument);
412 412
413 IFXJS_Context* pContext = pRuntime->NewContext() ; 413 IFXJS_Context* pContext = pRuntime->NewContext() ;
414 ASSERT(pContext != NULL); 414 ASSERT(pContext != NULL);
415 415
416 pContext->OnBookmark_MouseUp(pBookmark); 416 pContext->OnBookmark_MouseUp(pBookmark);
417 417
418 CFX_WideString csInfo; 418 CFX_WideString csInfo;
419 » » » » FX_BOOL bRet = pContext->RunScript(swJS, csInfo) ; 419 » » » » bool bRet = pContext->RunScript(swJS, csInfo);
420 if (!bRet) 420 if (!bRet)
421 { 421 {
422 //CBCL_FormNotify::MsgBoxJSError(pPageVi ew->GetPageViewWnd(), csInfo); 422 //CBCL_FormNotify::MsgBoxJSError(pPageVi ew->GetPageViewWnd(), csInfo);
423 } 423 }
424 424
425 pRuntime->ReleaseContext(pContext); 425 pRuntime->ReleaseContext(pContext);
426 } 426 }
427 } 427 }
428 } 428 }
429 else 429 else
430 { 430 {
431 DoAction_NoJs(action, pDocument); 431 DoAction_NoJs(action, pDocument);
432 } 432 }
433 433
434 for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++) 434 for (int32_t i=0,sz=action.GetSubActionsCount(); i<sz; i++)
435 { 435 {
436 CPDF_Action subaction = action.GetSubAction(i); 436 CPDF_Action subaction = action.GetSubAction(i);
437 » » if (!ExecuteBookMark(subaction, pDocument, pBookmark, list)) ret urn FALSE; 437 » » if (!ExecuteBookMark(subaction, pDocument, pBookmark, list)) ret urn false;
438 } 438 }
439 439
440 » return TRUE; 440 » return true;
441 } 441 }
442 442
443 void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Doc ument* pDocument) 443 void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Doc ument* pDocument)
444 { 444 {
445 ASSERT(pDocument != NULL); 445 ASSERT(pDocument != NULL);
446 446
447 switch (action.GetType()) 447 switch (action.GetType())
448 { 448 {
449 case CPDF_Action::GoTo: 449 case CPDF_Action::GoTo:
450 DoAction_GoTo(pDocument, action); 450 DoAction_GoTo(pDocument, action);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 m_pFormActionHandler->DoAction_ResetForm(action, pDocume nt); 495 m_pFormActionHandler->DoAction_ResetForm(action, pDocume nt);
496 } 496 }
497 break; 497 break;
498 case CPDF_Action::ImportData: 498 case CPDF_Action::ImportData:
499 if (m_pFormActionHandler) 499 if (m_pFormActionHandler)
500 { 500 {
501 m_pFormActionHandler->DoAction_ImportData(action, pDocum ent); 501 m_pFormActionHandler->DoAction_ImportData(action, pDocum ent);
502 } 502 }
503 break; 503 break;
504 case CPDF_Action::JavaScript: 504 case CPDF_Action::JavaScript:
505 » » ASSERT(FALSE); 505 » » ASSERT(false);
506 break; 506 break;
507 case CPDF_Action::SetOCGState: 507 case CPDF_Action::SetOCGState:
508 DoAction_SetOCGState(pDocument, action); 508 DoAction_SetOCGState(pDocument, action);
509 break; 509 break;
510 case CPDF_Action::Rendition: 510 case CPDF_Action::Rendition:
511 if (m_pMediaActionHandler) 511 if (m_pMediaActionHandler)
512 { 512 {
513 m_pMediaActionHandler->DoAction_Rendition(action, pDocum ent); 513 m_pMediaActionHandler->DoAction_Rendition(action, pDocum ent);
514 } 514 }
515 break; 515 break;
516 case CPDF_Action::Trans: 516 case CPDF_Action::Trans:
517 break; 517 break;
518 case CPDF_Action::GoTo3DView: 518 case CPDF_Action::GoTo3DView:
519 break; 519 break;
520 default: 520 default:
521 break; 521 break;
522 } 522 }
523 } 523 }
524 524
525 FX_BOOL»CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument) 525 bool» CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument)
526 { 526 {
527 ASSERT(pDocument != NULL); 527 ASSERT(pDocument != NULL);
528 » return TRUE; 528 » return true;
529 } 529 }
530 530
531 void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument, 531 void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument,
532 const CPDF_Act ion& action) 532 const CPDF_Act ion& action)
533 { 533 {
534 ASSERT(action); 534 ASSERT(action);
535 535
536 CPDF_Document* pPDFDocument = pDocument->GetDocument(); 536 CPDF_Document* pPDFDocument = pDocument->GetDocument();
537 ASSERT(pPDFDocument != NULL); 537 ASSERT(pPDFDocument != NULL);
538 CPDFDoc_Environment* pApp = pDocument->GetEnv(); 538 CPDFDoc_Environment* pApp = pDocument->GetEnv();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 case CPDF_AAction::KeyStroke: 632 case CPDF_AAction::KeyStroke:
633 pContext->OnField_Keystroke(data.sChange, data.sChangeEx, data.b KeyDown, 633 pContext->OnField_Keystroke(data.sChange, data.sChangeEx, data.b KeyDown,
634 data.bModifier, data.nSelEnd, data.nSelStart, data.bShif t, pFormField, data.sValue, 634 data.bModifier, data.nSelEnd, data.nSelStart, data.bShif t, pFormField, data.sValue,
635 data.bWillCommit, data.bFieldFull, data.bRC); 635 data.bWillCommit, data.bFieldFull, data.bRC);
636 break; 636 break;
637 case CPDF_AAction::Validate: 637 case CPDF_AAction::Validate:
638 pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bK eyDown, data.bModifier, 638 pContext->OnField_Validate(data.sChange, data.sChangeEx, data.bK eyDown, data.bModifier,
639 data.bShift, pFormField, data.sValue, data.bRC); 639 data.bShift, pFormField, data.sValue, data.bRC);
640 break; 640 break;
641 default: 641 default:
642 » » ASSERT(FALSE); 642 » » ASSERT(false);
643 break; 643 break;
644 } 644 }
645 645
646 CFX_WideString csInfo; 646 CFX_WideString csInfo;
647 » FX_BOOL bRet = pContext->RunScript(script, csInfo); 647 » bool bRet = pContext->RunScript(script, csInfo);
648 if (!bRet) 648 if (!bRet)
649 { 649 {
650 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), cs Info); 650 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), cs Info);
651 } 651 }
652 652
653 pRuntime->ReleaseContext(pContext); 653 pRuntime->ReleaseContext(pContext);
654 } 654 }
655 655
656 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(CPDFSDK_Document* pDocumen t, const CFX_WideString& sScriptName, const CFX_WideString& script) 656 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(CPDFSDK_Document* pDocumen t, const CFX_WideString& sScriptName, const CFX_WideString& script)
657 { 657 {
658 ASSERT(pDocument != NULL); 658 ASSERT(pDocument != NULL);
659 659
660 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime(); 660 IFXJS_Runtime* pRuntime = pDocument->GetJsRuntime();
661 ASSERT(pRuntime != NULL); 661 ASSERT(pRuntime != NULL);
662 662
663 pRuntime->SetReaderDocument(pDocument); 663 pRuntime->SetReaderDocument(pDocument);
664 664
665 IFXJS_Context* pContext = pRuntime->NewContext(); 665 IFXJS_Context* pContext = pRuntime->NewContext();
666 ASSERT(pContext != NULL); 666 ASSERT(pContext != NULL);
667 667
668 pContext->OnDoc_Open(pDocument, sScriptName); 668 pContext->OnDoc_Open(pDocument, sScriptName);
669 669
670 CFX_WideString csInfo; 670 CFX_WideString csInfo;
671 » FX_BOOL bRet = pContext->RunScript(script, csInfo); 671 » bool bRet = pContext->RunScript(script, csInfo);
672 if (!bRet) 672 if (!bRet)
673 { 673 {
674 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), cs Info); 674 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), cs Info);
675 } 675 }
676 676
677 pRuntime->ReleaseContext(pContext); 677 pRuntime->ReleaseContext(pContext);
678 } 678 }
679 679
680 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(CPDFSDK_Document* pDocumen t, CPDF_AAction::AActionType type, const CFX_WideString& script) 680 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(CPDFSDK_Document* pDocumen t, CPDF_AAction::AActionType type, const CFX_WideString& script)
681 { 681 {
(...skipping 30 matching lines...) Expand all
712 case CPDF_AAction::DocumentPrinted: 712 case CPDF_AAction::DocumentPrinted:
713 pContext->OnDoc_DidPrint(pDocument); 713 pContext->OnDoc_DidPrint(pDocument);
714 break; 714 break;
715 case CPDF_AAction::PageVisible: 715 case CPDF_AAction::PageVisible:
716 pContext->OnPage_InView(pDocument); 716 pContext->OnPage_InView(pDocument);
717 break; 717 break;
718 case CPDF_AAction::PageInvisible: 718 case CPDF_AAction::PageInvisible:
719 pContext->OnPage_OutView(pDocument); 719 pContext->OnPage_OutView(pDocument);
720 break; 720 break;
721 default: 721 default:
722 » » ASSERT(FALSE); 722 » » ASSERT(false);
723 break; 723 break;
724 } 724 }
725 725
726 CFX_WideString csInfo; 726 CFX_WideString csInfo;
727 » FX_BOOL bRet = pContext->RunScript(script, csInfo); 727 » bool bRet = pContext->RunScript(script, csInfo);
728 if (!bRet) 728 if (!bRet)
729 { 729 {
730 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), cs Info); 730 //CBCL_FormNotify::MsgBoxJSError(pPageView->GetPageViewWnd(), cs Info);
731 } 731 }
732 732
733 pRuntime->ReleaseContext(pContext); 733 pRuntime->ReleaseContext(pContext);
734 } 734 }
735 735
736 736
737 FX_BOOL»CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, CPDF SDK_Document* pDocument) 737 bool» CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, CPDF SDK_Document* pDocument)
738 { 738 {
739 ASSERT(pDocument != NULL); 739 ASSERT(pDocument != NULL);
740 740
741 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterF orm(); 741 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterF orm();
742 ASSERT(pInterForm != NULL); 742 ASSERT(pInterForm != NULL);
743 743
744 if (pInterForm->DoAction_Hide(action)) 744 if (pInterForm->DoAction_Hide(action))
745 { 745 {
746 pDocument->SetChangeMark(); 746 pDocument->SetChangeMark();
747 » » return TRUE; 747 » » return true;
748 } 748 }
749 749
750 » return FALSE; 750 » return false;
751 } 751 }
752 752
753 FX_BOOL»CPDFSDK_FormActionHandler::DoAction_SubmitForm(const CPDF_Action& action , CPDFSDK_Document* pDocument) 753 bool» CPDFSDK_FormActionHandler::DoAction_SubmitForm(const CPDF_Action& action , CPDFSDK_Document* pDocument)
754 { 754 {
755 ASSERT(pDocument != NULL); 755 ASSERT(pDocument != NULL);
756 756
757 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterF orm(); 757 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterF orm();
758 ASSERT(pInterForm != NULL); 758 ASSERT(pInterForm != NULL);
759 759
760 return pInterForm->DoAction_SubmitForm(action); 760 return pInterForm->DoAction_SubmitForm(action);
761 } 761 }
762 762
763 FX_BOOL»CPDFSDK_FormActionHandler::DoAction_ResetForm(const CPDF_Action& action, CPDFSDK_Document* pDocument) 763 bool» CPDFSDK_FormActionHandler::DoAction_ResetForm(const CPDF_Action& action, CPDFSDK_Document* pDocument)
764 { 764 {
765 ASSERT(pDocument != NULL); 765 ASSERT(pDocument != NULL);
766 766
767 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterF orm(); 767 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterF orm();
768 ASSERT(pInterForm != NULL); 768 ASSERT(pInterForm != NULL);
769 769
770 if (pInterForm->DoAction_ResetForm(action)) 770 if (pInterForm->DoAction_ResetForm(action))
771 { 771 {
772 » » return TRUE; 772 » » return true;
773 } 773 }
774 774
775 » return FALSE; 775 » return false;
776 } 776 }
777 777
778 FX_BOOL»CPDFSDK_FormActionHandler::DoAction_ImportData(const CPDF_Action& action , CPDFSDK_Document* pDocument) 778 bool» CPDFSDK_FormActionHandler::DoAction_ImportData(const CPDF_Action& action , CPDFSDK_Document* pDocument)
779 { 779 {
780 ASSERT(pDocument != NULL); 780 ASSERT(pDocument != NULL);
781 781
782 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterF orm(); 782 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pDocument->GetInterF orm();
783 ASSERT(pInterForm != NULL); 783 ASSERT(pInterForm != NULL);
784 784
785 if (pInterForm->DoAction_ImportData(action)) 785 if (pInterForm->DoAction_ImportData(action))
786 { 786 {
787 pDocument->SetChangeMark(); 787 pDocument->SetChangeMark();
788 » » return TRUE; 788 » » return true;
789 } 789 }
790 790
791 » return FALSE; 791 » return false;
792 } 792 }
793 793
794 FX_BOOL»CPDFSDK_MediaActionHandler::DoAction_Rendition(const CPDF_Action& action , CPDFSDK_Document* pDocument) 794 bool» CPDFSDK_MediaActionHandler::DoAction_Rendition(const CPDF_Action& action , CPDFSDK_Document* pDocument)
795 { 795 {
796 » return FALSE; 796 » return false;
797 } 797 }
798 798
799 FX_BOOL»CPDFSDK_MediaActionHandler::DoAction_Sound(const CPDF_Action& action, CP DFSDK_Document* pDocument) 799 bool» CPDFSDK_MediaActionHandler::DoAction_Sound(const CPDF_Action& action, CP DFSDK_Document* pDocument)
800 { 800 {
801 » return FALSE; 801 » return false;
802 } 802 }
803 803
804 FX_BOOL»CPDFSDK_MediaActionHandler::DoAction_Movie(const CPDF_Action& action, CP DFSDK_Document* pDocument) 804 bool» CPDFSDK_MediaActionHandler::DoAction_Movie(const CPDF_Action& action, CP DFSDK_Document* pDocument)
805 { 805 {
806 » return FALSE; 806 » return false;
807 } 807 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfview.cpp ('k') | fpdfsdk/src/fsdk_annothandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698