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

Side by Side Diff: core/src/fpdfdoc/doc_action.cpp

Issue 1529553003: Merge to XFA: Get rid of most instance of 'foo != NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years 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
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 "core/include/fpdfdoc/fpdf_doc.h" 7 #include "core/include/fpdfdoc/fpdf_doc.h"
8 8
9 CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const { 9 CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const {
10 if (!m_pDict) { 10 if (!m_pDict) {
(...skipping 16 matching lines...) Expand all
27 return CPDF_Dest(pArray); 27 return CPDF_Dest(pArray);
28 return CPDF_Dest(); 28 return CPDF_Dest();
29 } 29 }
30 const FX_CHAR* g_sATypes[] = { 30 const FX_CHAR* g_sATypes[] = {
31 "Unknown", "GoTo", "GoToR", "GoToE", "Launch", 31 "Unknown", "GoTo", "GoToR", "GoToE", "Launch",
32 "Thread", "URI", "Sound", "Movie", "Hide", 32 "Thread", "URI", "Sound", "Movie", "Hide",
33 "Named", "SubmitForm", "ResetForm", "ImportData", "JavaScript", 33 "Named", "SubmitForm", "ResetForm", "ImportData", "JavaScript",
34 "SetOCGState", "Rendition", "Trans", "GoTo3DView", ""}; 34 "SetOCGState", "Rendition", "Trans", "GoTo3DView", ""};
35 CPDF_Action::ActionType CPDF_Action::GetType() const { 35 CPDF_Action::ActionType CPDF_Action::GetType() const {
36 ActionType eType = Unknown; 36 ActionType eType = Unknown;
37 if (m_pDict != NULL) { 37 if (m_pDict) {
38 CFX_ByteString csType = m_pDict->GetString("S"); 38 CFX_ByteString csType = m_pDict->GetString("S");
39 if (!csType.IsEmpty()) { 39 if (!csType.IsEmpty()) {
40 int i = 0; 40 int i = 0;
41 while (g_sATypes[i][0] != '\0') { 41 while (g_sATypes[i][0] != '\0') {
42 if (csType == g_sATypes[i]) { 42 if (csType == g_sATypes[i]) {
43 return (ActionType)i; 43 return (ActionType)i;
44 } 44 }
45 i++; 45 i++;
46 } 46 }
47 } 47 }
(...skipping 25 matching lines...) Expand all
73 CFX_ByteString csURI; 73 CFX_ByteString csURI;
74 if (m_pDict == NULL) { 74 if (m_pDict == NULL) {
75 return csURI; 75 return csURI;
76 } 76 }
77 if (m_pDict->GetString("S") != "URI") { 77 if (m_pDict->GetString("S") != "URI") {
78 return csURI; 78 return csURI;
79 } 79 }
80 csURI = m_pDict->GetString("URI"); 80 csURI = m_pDict->GetString("URI");
81 CPDF_Dictionary* pRoot = pDoc->GetRoot(); 81 CPDF_Dictionary* pRoot = pDoc->GetRoot();
82 CPDF_Dictionary* pURI = pRoot->GetDict("URI"); 82 CPDF_Dictionary* pURI = pRoot->GetDict("URI");
83 if (pURI != NULL) { 83 if (pURI) {
84 if (csURI.Find(":", 0) < 1) { 84 if (csURI.Find(":", 0) < 1) {
85 csURI = pURI->GetString("Base") + csURI; 85 csURI = pURI->GetString("Base") + csURI;
86 } 86 }
87 } 87 }
88 return csURI; 88 return csURI;
89 } 89 }
90 FX_DWORD CPDF_ActionFields::GetFieldsCount() const { 90 FX_DWORD CPDF_ActionFields::GetFieldsCount() const {
91 if (m_pAction == NULL) { 91 if (m_pAction == NULL) {
92 return 0; 92 return 0;
93 } 93 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 return pFindObj; 173 return pFindObj;
174 } 174 }
175 175
176 CFX_WideString CPDF_Action::GetJavaScript() const { 176 CFX_WideString CPDF_Action::GetJavaScript() const {
177 CFX_WideString csJS; 177 CFX_WideString csJS;
178 if (m_pDict == NULL) { 178 if (m_pDict == NULL) {
179 return csJS; 179 return csJS;
180 } 180 }
181 CPDF_Object* pJS = m_pDict->GetElementValue("JS"); 181 CPDF_Object* pJS = m_pDict->GetElementValue("JS");
182 if (pJS != NULL) { 182 return pJS ? pJS->GetUnicodeText() : csJS;
183 return pJS->GetUnicodeText();
184 }
185 return csJS;
186 } 183 }
187 CPDF_Dictionary* CPDF_Action::GetAnnot() const { 184 CPDF_Dictionary* CPDF_Action::GetAnnot() const {
188 if (!m_pDict) { 185 if (!m_pDict) {
189 return nullptr; 186 return nullptr;
190 } 187 }
191 CFX_ByteString csType = m_pDict->GetString("S"); 188 CFX_ByteString csType = m_pDict->GetString("S");
192 if (csType == "Rendition") { 189 if (csType == "Rendition") {
193 return m_pDict->GetDict("AN"); 190 return m_pDict->GetDict("AN");
194 } 191 }
195 if (csType == "Movie") { 192 if (csType == "Movie") {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 288 }
292 i++; 289 i++;
293 } 290 }
294 eType = (AActionType)i; 291 eType = (AActionType)i;
295 return CPDF_Action(pDict); 292 return CPDF_Action(pDict);
296 } 293 }
297 294
298 CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) : m_pDocument(pDoc) {} 295 CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) : m_pDocument(pDoc) {}
299 296
300 int CPDF_DocJSActions::CountJSActions() const { 297 int CPDF_DocJSActions::CountJSActions() const {
301 ASSERT(m_pDocument != NULL); 298 ASSERT(m_pDocument);
302 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); 299 CPDF_NameTree name_tree(m_pDocument, "JavaScript");
303 return name_tree.GetCount(); 300 return name_tree.GetCount();
304 } 301 }
305 CPDF_Action CPDF_DocJSActions::GetJSAction(int index, 302 CPDF_Action CPDF_DocJSActions::GetJSAction(int index,
306 CFX_ByteString& csName) const { 303 CFX_ByteString& csName) const {
307 ASSERT(m_pDocument != NULL); 304 ASSERT(m_pDocument);
308 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); 305 CPDF_NameTree name_tree(m_pDocument, "JavaScript");
309 CPDF_Object* pAction = name_tree.LookupValue(index, csName); 306 CPDF_Object* pAction = name_tree.LookupValue(index, csName);
310 if (!ToDictionary(pAction)) { 307 if (!ToDictionary(pAction)) {
311 return CPDF_Action(); 308 return CPDF_Action();
312 } 309 }
313 return CPDF_Action(pAction->GetDict()); 310 return CPDF_Action(pAction->GetDict());
314 } 311 }
315 CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const { 312 CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const {
316 ASSERT(m_pDocument != NULL); 313 ASSERT(m_pDocument);
317 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); 314 CPDF_NameTree name_tree(m_pDocument, "JavaScript");
318 CPDF_Object* pAction = name_tree.LookupValue(csName); 315 CPDF_Object* pAction = name_tree.LookupValue(csName);
319 if (!ToDictionary(pAction)) { 316 if (!ToDictionary(pAction)) {
320 return CPDF_Action(); 317 return CPDF_Action();
321 } 318 }
322 return CPDF_Action(pAction->GetDict()); 319 return CPDF_Action(pAction->GetDict());
323 } 320 }
324 int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const { 321 int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const {
325 ASSERT(m_pDocument != NULL); 322 ASSERT(m_pDocument);
326 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); 323 CPDF_NameTree name_tree(m_pDocument, "JavaScript");
327 return name_tree.GetIndex(csName); 324 return name_tree.GetIndex(csName);
328 } 325 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698