1 // Copyright 2016 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. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "core/fpdfdoc/cpdf_docjsactions.h" 8 9 #include "core/fpdfdoc/cpdf_nametree.h" 10 CPDF_DocJSActions(CPDF_Document * pDoc)11CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) : m_pDocument(pDoc) {} 12 ~CPDF_DocJSActions()13CPDF_DocJSActions::~CPDF_DocJSActions() {} 14 CountJSActions() const15int CPDF_DocJSActions::CountJSActions() const { 16 ASSERT(m_pDocument); 17 CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript"); 18 return name_tree.GetCount(); 19 } 20 GetJSActionAndName(int index,WideString * csName) const21CPDF_Action CPDF_DocJSActions::GetJSActionAndName(int index, 22 WideString* csName) const { 23 ASSERT(m_pDocument); 24 CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript"); 25 return CPDF_Action(ToDictionary(name_tree.LookupValueAndName(index, csName))); 26 } 27 GetJSAction(const WideString & csName) const28CPDF_Action CPDF_DocJSActions::GetJSAction(const WideString& csName) const { 29 ASSERT(m_pDocument); 30 CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript"); 31 return CPDF_Action(ToDictionary(name_tree.LookupValue(csName))); 32 } 33 FindJSAction(const WideString & csName) const34int CPDF_DocJSActions::FindJSAction(const WideString& csName) const { 35 ASSERT(m_pDocument); 36 CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript"); 37 return name_tree.GetIndex(csName); 38 } 39