• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef CORE_FPDFDOC_CPDF_ACTION_H_
8 #define CORE_FPDFDOC_CPDF_ACTION_H_
9 
10 #include <vector>
11 
12 #include "core/fpdfdoc/cpdf_dest.h"
13 #include "core/fxcrt/fx_string.h"
14 #include "core/fxcrt/retain_ptr.h"
15 #include "third_party/base/optional.h"
16 
17 class CPDF_Dictionary;
18 class CPDF_Document;
19 class CPDF_Object;
20 
21 class CPDF_Action {
22  public:
23   enum ActionType {
24     Unknown = 0,
25     GoTo,
26     GoToR,
27     GoToE,
28     Launch,
29     Thread,
30     URI,
31     Sound,
32     Movie,
33     Hide,
34     Named,
35     SubmitForm,
36     ResetForm,
37     ImportData,
38     JavaScript,
39     SetOCGState,
40     Rendition,
41     Trans,
42     GoTo3DView
43   };
44 
45   explicit CPDF_Action(const CPDF_Dictionary* pDict);
46   CPDF_Action(const CPDF_Action& that);
47   ~CPDF_Action();
48 
GetDict()49   const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
50 
51   ActionType GetType() const;
52   CPDF_Dest GetDest(CPDF_Document* pDoc) const;
53   WideString GetFilePath() const;
54   ByteString GetURI(const CPDF_Document* pDoc) const;
55   bool GetHideStatus() const;
56   ByteString GetNamedAction() const;
57   uint32_t GetFlags() const;
58 
59   std::vector<const CPDF_Object*> GetAllFields() const;
60 
61   // Differentiates between empty JS entry and no JS entry.
62   Optional<WideString> MaybeGetJavaScript() const;
63 
64   // Returns empty string for empty JS entry and no JS entry.
65   WideString GetJavaScript() const;
66 
67   size_t GetSubActionsCount() const;
68   CPDF_Action GetSubAction(size_t iIndex) const;
69 
70  private:
71   const CPDF_Object* GetJavaScriptObject() const;
72 
73   RetainPtr<const CPDF_Dictionary> const m_pDict;
74 };
75 
76 #endif  // CORE_FPDFDOC_CPDF_ACTION_H_
77