1 // Copyright 2016 The PDFium Authors 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/abseil-cpp/absl/types/optional.h" 16 17 class CPDF_Dictionary; 18 class CPDF_Document; 19 class CPDF_Object; 20 21 class CPDF_Action { 22 public: 23 enum class Type { 24 kUnknown = 0, 25 kGoTo, 26 kGoToR, 27 kGoToE, 28 kLaunch, 29 kThread, 30 kURI, 31 kSound, 32 kMovie, 33 kHide, 34 kNamed, 35 kSubmitForm, 36 kResetForm, 37 kImportData, 38 kJavaScript, 39 kSetOCGState, 40 kRendition, 41 kTrans, 42 kGoTo3DView, 43 kLast = kGoTo3DView 44 }; 45 46 explicit CPDF_Action(RetainPtr<const CPDF_Dictionary> pDict); 47 CPDF_Action(const CPDF_Action& that); 48 ~CPDF_Action(); 49 HasDict()50 bool HasDict() const { return !!m_pDict; } GetDict()51 const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } 52 53 Type GetType() const; 54 CPDF_Dest GetDest(CPDF_Document* pDoc) const; 55 WideString GetFilePath() const; 56 ByteString GetURI(const CPDF_Document* pDoc) const; 57 bool GetHideStatus() const; 58 ByteString GetNamedAction() const; 59 uint32_t GetFlags() const; 60 bool HasFields() const; 61 62 std::vector<RetainPtr<const CPDF_Object>> GetAllFields() const; 63 64 // Differentiates between empty JS entry and no JS entry. 65 absl::optional<WideString> MaybeGetJavaScript() const; 66 67 // Returns empty string for empty JS entry and no JS entry. 68 WideString GetJavaScript() const; 69 70 size_t GetSubActionsCount() const; 71 CPDF_Action GetSubAction(size_t iIndex) const; 72 73 private: 74 RetainPtr<const CPDF_Object> GetJavaScriptObject() const; 75 76 RetainPtr<const CPDF_Dictionary> const m_pDict; 77 }; 78 79 #endif // CORE_FPDFDOC_CPDF_ACTION_H_ 80