7#include "core/fpdfdoc/cpdf_action.h"
12#include "constants/stream_dict_common.h"
13#include "core/fpdfapi/parser/cpdf_array.h"
14#include "core/fpdfapi/parser/cpdf_dictionary.h"
15#include "core/fpdfapi/parser/cpdf_document.h"
16#include "core/fpdfapi/parser/cpdf_name.h"
17#include "core/fpdfapi/parser/fpdf_parser_utility.h"
18#include "core/fpdfdoc/cpdf_filespec.h"
22const char*
const kActionTypeStrings[] = {
23 "GoTo",
"GoToR",
"GoToE",
"Launch",
"Thread",
24 "URI",
"Sound",
"Movie",
"Hide",
"Named",
25 "SubmitForm",
"ResetForm",
"ImportData",
"JavaScript",
"SetOCGState",
26 "Rendition",
"Trans",
"GoTo3DView"};
39 if (!ValidateDictOptionalType(m_pDict.Get(),
"Action"))
42 ByteString csType = m_pDict->GetNameFor(
"S");
49 for (size_t i = 0; i <
std::size(kActionTypeStrings); ++i) {
50 if (csType == kActionTypeStrings[i])
51 return static_cast<
Type>(i + 1);
59 return CPDF_Dest(
nullptr);
61 return CPDF_Dest::Create(pDoc, m_pDict->GetDirectObjectFor(
"D"));
72 m_pDict->GetDirectObjectFor(pdfium::stream::kF);
79 RetainPtr<
const CPDF_Dictionary> pWinDict = m_pDict->GetDictFor(
"Win");
84 pWinDict->GetByteStringFor(pdfium
::stream::kF).AsStringView()
);
91 ByteString csURI = m_pDict->GetByteStringFor(
"URI");
92 RetainPtr<
const CPDF_Dictionary> pURI = pDoc->GetRoot()->GetDictFor(
"URI");
94 auto result = csURI.Find(
":");
95 if (!result.has_value() || result.value() == 0) {
97 if (pBase && (pBase->IsString() || pBase->IsStream()))
98 csURI = pBase->GetString() + csURI;
105 return m_pDict->GetBooleanFor(
"H",
true);
109 return m_pDict->GetByteStringFor(
"N");
113 return m_pDict->GetIntegerFor(
"Flags");
117 return m_pDict->KeyExist(
"Fields");
121 std::vector<RetainPtr<
const CPDF_Object>> result;
125 ByteString csType = m_pDict->GetByteStringFor(
"S");
127 ? m_pDict->GetDirectObjectFor(
"T")
128 : m_pDict->GetArrayFor(
"Fields");
132 if (pFields->IsDictionary() || pFields->IsString()) {
133 result.push_back(
std::move(pFields));
137 const CPDF_Array* pArray = pFields->AsArray();
141 for (size_t i = 0; i < pArray->size(); ++i) {
144 result.push_back(
std::move(pObj));
152 return absl::nullopt;
153 return pObject->GetUnicodeText();
158 return pObject ? pObject->GetUnicodeText() : WideString
();
162 if (!m_pDict || !m_pDict->KeyExist(
"Next"))
168 if (pNext->IsDictionary())
170 const CPDF_Array* pArray = pNext->AsArray();
171 return pArray ? pArray->size() : 0;
175 if (!m_pDict || !m_pDict->KeyExist(
"Next"))
176 return CPDF_Action(
nullptr);
180 return CPDF_Action(
nullptr);
182 if (
const CPDF_Array* pArray = pNext->AsArray())
185 if (
const CPDF_Dictionary* pDict = pNext->AsDictionary()) {
189 return CPDF_Action(
nullptr);
197 return (pJS && (pJS->IsString() || pJS->IsStream())) ? pJS :
nullptr;
CPDF_Action(RetainPtr< const CPDF_Dictionary > pDict)
size_t GetSubActionsCount() const
CPDF_Dest GetDest(CPDF_Document *pDoc) const
CPDF_Action GetSubAction(size_t iIndex) const
CPDF_Action(const CPDF_Action &that)
WideString GetFilePath() const
std::vector< RetainPtr< const CPDF_Object > > GetAllFields() const
ByteString GetURI(const CPDF_Document *pDoc) const
uint32_t GetFlags() const
bool GetHideStatus() const
WideString GetJavaScript() const
absl::optional< WideString > MaybeGetJavaScript() const
ByteString GetNamedAction() const
WideString GetFileName() const
static WideString FromDefANSI(ByteStringView str)