summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/cpdf_action.cpp70
1 files changed, 33 insertions, 37 deletions
diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp
index 6238b05299..6e9e9f7b68 100644
--- a/core/fpdfdoc/cpdf_action.cpp
+++ b/core/fpdfdoc/cpdf_action.cpp
@@ -27,14 +27,26 @@ CPDF_Action::CPDF_Action(const CPDF_Dictionary* pDict) : m_pDict(pDict) {}
CPDF_Action::CPDF_Action(const CPDF_Action& that) = default;
-CPDF_Action::~CPDF_Action() {}
+CPDF_Action::~CPDF_Action() = default;
-CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const {
+CPDF_Action::ActionType CPDF_Action::GetType() const {
if (!m_pDict)
- return CPDF_Dest();
+ return Unknown;
+
+ ByteString csType = m_pDict->GetStringFor("S");
+ if (csType.IsEmpty())
+ return Unknown;
- ByteString type = m_pDict->GetStringFor("S");
- if (type != "GoTo" && type != "GoToR")
+ for (int i = 0; g_sATypes[i]; ++i) {
+ if (csType == g_sATypes[i])
+ return static_cast<ActionType>(i);
+ }
+ return Unknown;
+}
+
+CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const {
+ ActionType type = GetType();
+ if (type != GoTo && type != GoToR)
return CPDF_Dest();
const CPDF_Object* pDest = m_pDict->GetDirectObjectFor("D");
@@ -50,25 +62,10 @@ CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const {
return CPDF_Dest();
}
-CPDF_Action::ActionType CPDF_Action::GetType() const {
- if (!m_pDict)
- return Unknown;
-
- ByteString csType = m_pDict->GetStringFor("S");
- if (csType.IsEmpty())
- return Unknown;
-
- for (int i = 0; g_sATypes[i]; ++i) {
- if (csType == g_sATypes[i])
- return static_cast<ActionType>(i);
- }
- return Unknown;
-}
-
WideString CPDF_Action::GetFilePath() const {
- ByteString type = m_pDict->GetStringFor("S");
- if (type != "GoToR" && type != "Launch" && type != "SubmitForm" &&
- type != "ImportData") {
+ ActionType type = GetType();
+ if (type != GoToR && type != Launch && type != SubmitForm &&
+ type != ImportData) {
return WideString();
}
@@ -76,24 +73,23 @@ WideString CPDF_Action::GetFilePath() const {
if (pFile)
return CPDF_FileSpec(pFile).GetFileName();
- if (type == "Launch") {
- const CPDF_Dictionary* pWinDict = m_pDict->GetDictFor("Win");
- if (pWinDict) {
- return WideString::FromLocal(
- pWinDict->GetStringFor(pdfium::stream::kF).AsStringView());
- }
- }
- return WideString();
+ if (type != Launch)
+ return WideString();
+
+ const CPDF_Dictionary* pWinDict = m_pDict->GetDictFor("Win");
+ if (!pWinDict)
+ return WideString();
+
+ return WideString::FromLocal(
+ pWinDict->GetStringFor(pdfium::stream::kF).AsStringView());
}
ByteString CPDF_Action::GetURI(const CPDF_Document* pDoc) const {
- ByteString csURI;
- if (!m_pDict)
- return csURI;
- if (m_pDict->GetStringFor("S") != "URI")
- return csURI;
+ ActionType type = GetType();
+ if (type != URI)
+ return ByteString();
- csURI = m_pDict->GetStringFor("URI");
+ ByteString csURI = m_pDict->GetStringFor("URI");
const CPDF_Dictionary* pRoot = pDoc->GetRoot();
const CPDF_Dictionary* pURI = pRoot->GetDictFor("URI");
if (pURI) {