blob: 2e6560b949b46ba81b433f5e4ed6985be89740d5 [file] [log] [blame]
dsinclair02e6f592016-08-02 11:25:48 -07001// 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
dsinclair1727aee2016-09-29 13:12:56 -07007#include "core/fpdfdoc/cpdf_docjsactions.h"
dsinclair02e6f592016-08-02 11:25:48 -07008
Lei Zhang81535612018-10-09 21:15:17 +00009#include "core/fpdfapi/parser/cpdf_dictionary.h"
dsinclair1727aee2016-09-29 13:12:56 -070010#include "core/fpdfdoc/cpdf_nametree.h"
dsinclair02e6f592016-08-02 11:25:48 -070011
Tom Sepez61d8d022018-10-03 21:02:42 +000012CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) : m_pDocument(pDoc) {
13 ASSERT(m_pDocument);
14}
dsinclair02e6f592016-08-02 11:25:48 -070015
Tom Sepez61d8d022018-10-03 21:02:42 +000016CPDF_DocJSActions::~CPDF_DocJSActions() = default;
Tom Sepezedc1e4e2017-05-24 13:21:45 -070017
dsinclair02e6f592016-08-02 11:25:48 -070018int CPDF_DocJSActions::CountJSActions() const {
Tom Sepezedc1e4e2017-05-24 13:21:45 -070019 CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript");
dsinclair02e6f592016-08-02 11:25:48 -070020 return name_tree.GetCount();
21}
22
Ryan Harrison275e2602017-09-18 14:23:18 -040023CPDF_Action CPDF_DocJSActions::GetJSActionAndName(int index,
24 WideString* csName) const {
Tom Sepezedc1e4e2017-05-24 13:21:45 -070025 CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript");
Lei Zhang4ecf9a82017-12-11 14:34:58 +000026 return CPDF_Action(ToDictionary(name_tree.LookupValueAndName(index, csName)));
dsinclair02e6f592016-08-02 11:25:48 -070027}