Chromium Code Reviews| 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 "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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 if (pJS) { |
|
Tom Sepez
2015/12/14 19:14:08
nit: use ? oper.
Lei Zhang
2015/12/15 01:38:32
Done.
| |
| 183 return pJS->GetUnicodeText(); | 183 return pJS->GetUnicodeText(); |
| 184 } | 184 } |
| 185 return csJS; | 185 return csJS; |
| 186 } | 186 } |
| 187 CPDF_Dictionary* CPDF_Action::GetAnnot() const { | 187 CPDF_Dictionary* CPDF_Action::GetAnnot() const { |
| 188 if (!m_pDict) { | 188 if (!m_pDict) { |
| 189 return nullptr; | 189 return nullptr; |
| 190 } | 190 } |
| 191 CFX_ByteString csType = m_pDict->GetString("S"); | 191 CFX_ByteString csType = m_pDict->GetString("S"); |
| 192 if (csType == "Rendition") { | 192 if (csType == "Rendition") { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 } | 291 } |
| 292 i++; | 292 i++; |
| 293 } | 293 } |
| 294 eType = (AActionType)i; | 294 eType = (AActionType)i; |
| 295 return CPDF_Action(pDict); | 295 return CPDF_Action(pDict); |
| 296 } | 296 } |
| 297 | 297 |
| 298 CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) : m_pDocument(pDoc) {} | 298 CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) : m_pDocument(pDoc) {} |
| 299 | 299 |
| 300 int CPDF_DocJSActions::CountJSActions() const { | 300 int CPDF_DocJSActions::CountJSActions() const { |
| 301 ASSERT(m_pDocument != NULL); | 301 ASSERT(m_pDocument); |
| 302 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); | 302 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); |
| 303 return name_tree.GetCount(); | 303 return name_tree.GetCount(); |
| 304 } | 304 } |
| 305 CPDF_Action CPDF_DocJSActions::GetJSAction(int index, | 305 CPDF_Action CPDF_DocJSActions::GetJSAction(int index, |
| 306 CFX_ByteString& csName) const { | 306 CFX_ByteString& csName) const { |
| 307 ASSERT(m_pDocument != NULL); | 307 ASSERT(m_pDocument); |
| 308 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); | 308 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); |
| 309 CPDF_Object* pAction = name_tree.LookupValue(index, csName); | 309 CPDF_Object* pAction = name_tree.LookupValue(index, csName); |
| 310 if (!ToDictionary(pAction)) { | 310 if (!ToDictionary(pAction)) { |
| 311 return CPDF_Action(); | 311 return CPDF_Action(); |
| 312 } | 312 } |
| 313 return CPDF_Action(pAction->GetDict()); | 313 return CPDF_Action(pAction->GetDict()); |
| 314 } | 314 } |
| 315 CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const { | 315 CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const { |
| 316 ASSERT(m_pDocument != NULL); | 316 ASSERT(m_pDocument); |
| 317 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); | 317 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); |
| 318 CPDF_Object* pAction = name_tree.LookupValue(csName); | 318 CPDF_Object* pAction = name_tree.LookupValue(csName); |
| 319 if (!ToDictionary(pAction)) { | 319 if (!ToDictionary(pAction)) { |
| 320 return CPDF_Action(); | 320 return CPDF_Action(); |
| 321 } | 321 } |
| 322 return CPDF_Action(pAction->GetDict()); | 322 return CPDF_Action(pAction->GetDict()); |
| 323 } | 323 } |
| 324 int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const { | 324 int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const { |
| 325 ASSERT(m_pDocument != NULL); | 325 ASSERT(m_pDocument); |
| 326 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); | 326 CPDF_NameTree name_tree(m_pDocument, "JavaScript"); |
| 327 return name_tree.GetIndex(csName); | 327 return name_tree.GetIndex(csName); |
| 328 } | 328 } |
| OLD | NEW |