summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_docjsactions.cpp
blob: 91db2b0484745a525a4b2fc21c9e2f30e2391bf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#include "core/fpdfdoc/cpdf_docjsactions.h"

#include "core/fpdfdoc/cpdf_nametree.h"

CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) : m_pDocument(pDoc) {}

CPDF_DocJSActions::~CPDF_DocJSActions() {}

int CPDF_DocJSActions::CountJSActions() const {
  ASSERT(m_pDocument);
  CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript");
  return name_tree.GetCount();
}

CPDF_Action CPDF_DocJSActions::GetJSActionAndName(int index,
                                                  WideString* csName) const {
  ASSERT(m_pDocument);
  CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript");
  return CPDF_Action(ToDictionary(name_tree.LookupValueAndName(index, csName)));
}

CPDF_Action CPDF_DocJSActions::GetJSAction(const WideString& csName) const {
  ASSERT(m_pDocument);
  CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript");
  return CPDF_Action(ToDictionary(name_tree.LookupValue(csName)));
}

int CPDF_DocJSActions::FindJSAction(const WideString& csName) const {
  ASSERT(m_pDocument);
  CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript");
  return name_tree.GetIndex(csName);
}