diff options
author | dsinclair <dsinclair@chromium.org> | 2016-08-02 11:25:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-02 11:25:49 -0700 |
commit | 02e6f5957a56ea492961aef71b3c16cf42ea5998 (patch) | |
tree | 065375d976a97f6b127368f665f24fca1fe994fe /core/fpdfdoc/cpdf_docjsactions.cpp | |
parent | 0690c35fec9c320bdc69b4a8678677fe143cee54 (diff) | |
download | pdfium-02e6f5957a56ea492961aef71b3c16cf42ea5998.tar.xz |
Splitting fpdfdoc/doc_* part I
The first of several CLs to split the core/fpdfdoc/doc_* files up to individual
class files.
Review-Url: https://codereview.chromium.org/2192823002
Diffstat (limited to 'core/fpdfdoc/cpdf_docjsactions.cpp')
-rw-r--r-- | core/fpdfdoc/cpdf_docjsactions.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/core/fpdfdoc/cpdf_docjsactions.cpp b/core/fpdfdoc/cpdf_docjsactions.cpp new file mode 100644 index 0000000000..897cdac610 --- /dev/null +++ b/core/fpdfdoc/cpdf_docjsactions.cpp @@ -0,0 +1,40 @@ +// 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/include/cpdf_docjsactions.h" + +#include "core/fpdfdoc/include/cpdf_nametree.h" + +CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) : m_pDocument(pDoc) {} + +int CPDF_DocJSActions::CountJSActions() const { + ASSERT(m_pDocument); + CPDF_NameTree name_tree(m_pDocument, "JavaScript"); + return name_tree.GetCount(); +} + +CPDF_Action CPDF_DocJSActions::GetJSAction(int index, + CFX_ByteString& csName) const { + ASSERT(m_pDocument); + CPDF_NameTree name_tree(m_pDocument, "JavaScript"); + CPDF_Object* pAction = name_tree.LookupValue(index, csName); + return ToDictionary(pAction) ? CPDF_Action(pAction->GetDict()) + : CPDF_Action(); +} + +CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const { + ASSERT(m_pDocument); + CPDF_NameTree name_tree(m_pDocument, "JavaScript"); + CPDF_Object* pAction = name_tree.LookupValue(csName); + return ToDictionary(pAction) ? CPDF_Action(pAction->GetDict()) + : CPDF_Action(); +} + +int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const { + ASSERT(m_pDocument); + CPDF_NameTree name_tree(m_pDocument, "JavaScript"); + return name_tree.GetIndex(csName); +} |