summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/include/fpdfdoc/fpdf_doc.h19
-rw-r--r--core/src/fpdfdoc/doc_action.cpp19
-rw-r--r--core/src/fpdfdoc/doc_bookmark.cpp13
-rw-r--r--core/src/fpdfdoc/doc_link.cpp11
-rw-r--r--fpdfsdk/src/fpdfdoc.cpp12
-rw-r--r--fpdfsdk/src/fsdk_actionhandler.cpp2
6 files changed, 35 insertions, 41 deletions
diff --git a/core/include/fpdfdoc/fpdf_doc.h b/core/include/fpdfdoc/fpdf_doc.h
index a21063fedd..5e3e11acab 100644
--- a/core/include/fpdfdoc/fpdf_doc.h
+++ b/core/include/fpdfdoc/fpdf_doc.h
@@ -124,28 +124,19 @@ public:
class CPDF_Dest : public CFX_Object
{
public:
+ CPDF_Dest() : m_pObj(nullptr) { }
+ explicit CPDF_Dest(CPDF_Object* pObj) : m_pObj(pObj) { }
- CPDF_Dest(CPDF_Object* pObj = NULL)
- {
- m_pObj = pObj;
- }
-
- operator CPDF_Object* () const
- {
- return m_pObj;
- }
+ operator bool () const { return m_pObj != NULL; }
+ CPDF_Object* GetObject() const { return m_pObj; }
CFX_ByteString GetRemoteName();
-
int GetPageIndex(CPDF_Document* pDoc);
-
FX_DWORD GetPageObjNum();
-
int GetZoomMode();
-
FX_FLOAT GetParam(int index);
-
+protected:
CPDF_Object* m_pObj;
};
class CPDF_OCContext : public CFX_Object, public IPDF_OCContext
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp
index 324153563a..ac40335a4c 100644
--- a/core/src/fpdfdoc/doc_action.cpp
+++ b/core/src/fpdfdoc/doc_action.cpp
@@ -7,25 +7,26 @@
#include "../../include/fpdfdoc/fpdf_doc.h"
CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const
{
- if (m_pDict == NULL) {
- return NULL;
+ if (!m_pDict) {
+ return CPDF_Dest();
}
CFX_ByteString type = m_pDict->GetString("S");
if (type != "GoTo" && type != "GoToR") {
- return NULL;
+ return CPDF_Dest();
}
CPDF_Object* pDest = m_pDict->GetElementValue("D");
- if (pDest == NULL) {
- return NULL;
+ if (!pDest) {
+ return CPDF_Dest();
}
if (pDest->GetType() == PDFOBJ_STRING || pDest->GetType() == PDFOBJ_NAME) {
CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests"));
CFX_ByteStringC name = pDest->GetString();
- return name_tree.LookupNamedDest(pDoc, name);
- } else if (pDest->GetType() == PDFOBJ_ARRAY) {
- return (CPDF_Array*)pDest;
+ return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name));
}
- return NULL;
+ if (pDest->GetType() == PDFOBJ_ARRAY) {
+ return CPDF_Dest((CPDF_Array*)pDest);
+ }
+ return CPDF_Dest();
}
const FX_CHAR* g_sATypes[] = {"Unknown", "GoTo", "GoToR", "GoToE", "Launch", "Thread", "URI", "Sound", "Movie",
"Hide", "Named", "SubmitForm", "ResetForm", "ImportData", "JavaScript", "SetOCGState",
diff --git a/core/src/fpdfdoc/doc_bookmark.cpp b/core/src/fpdfdoc/doc_bookmark.cpp
index a3a194337e..9814de61bf 100644
--- a/core/src/fpdfdoc/doc_bookmark.cpp
+++ b/core/src/fpdfdoc/doc_bookmark.cpp
@@ -68,20 +68,21 @@ CFX_WideString CPDF_Bookmark::GetTitle() const
CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const
{
if (!m_pDict) {
- return NULL;
+ return CPDF_Dest();
}
CPDF_Object* pDest = m_pDict->GetElementValue("Dest");
if (!pDest) {
- return NULL;
+ return CPDF_Dest();
}
if (pDest->GetType() == PDFOBJ_STRING || pDest->GetType() == PDFOBJ_NAME) {
CPDF_NameTree name_tree(pDocument, FX_BSTRC("Dests"));
CFX_ByteStringC name = pDest->GetString();
- return name_tree.LookupNamedDest(pDocument, name);
- } else if (pDest->GetType() == PDFOBJ_ARRAY) {
- return (CPDF_Array*)pDest;
+ return CPDF_Dest(name_tree.LookupNamedDest(pDocument, name));
}
- return NULL;
+ if (pDest->GetType() == PDFOBJ_ARRAY) {
+ return CPDF_Dest((CPDF_Array*)pDest);
+ }
+ return CPDF_Dest();
}
CPDF_Action CPDF_Bookmark::GetAction() const
{
diff --git a/core/src/fpdfdoc/doc_link.cpp b/core/src/fpdfdoc/doc_link.cpp
index e7b6be5ca4..b7c640af5e 100644
--- a/core/src/fpdfdoc/doc_link.cpp
+++ b/core/src/fpdfdoc/doc_link.cpp
@@ -90,16 +90,17 @@ CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc)
{
CPDF_Object* pDest = m_pDict->GetElementValue("Dest");
if (pDest == NULL) {
- return NULL;
+ return CPDF_Dest();
}
if (pDest->GetType() == PDFOBJ_STRING || pDest->GetType() == PDFOBJ_NAME) {
CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests"));
CFX_ByteStringC name = pDest->GetString();
- return name_tree.LookupNamedDest(pDoc, name);
- } else if (pDest->GetType() == PDFOBJ_ARRAY) {
- return (CPDF_Array*)pDest;
+ return CPDF_Dest(name_tree.LookupNamedDest(pDoc, name));
}
- return NULL;
+ if (pDest->GetType() == PDFOBJ_ARRAY) {
+ return CPDF_Dest((CPDF_Array*)pDest);
+ }
+ return CPDF_Dest();
}
CPDF_Action CPDF_Link::GetAction()
{
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index 9e4267ffc7..e89a7aa294 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -86,12 +86,12 @@ DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BO
CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
CPDF_Dest dest = bookmark.GetDest(pDoc);
if (dest)
- return dest;
+ return dest.GetObject();
// If this bookmark is not directly associated with a dest, we try to get action
CPDF_Action action = bookmark.GetAction();
if (!action)
return NULL;
- return action.GetDest(pDoc);
+ return action.GetDest(pDoc).GetObject();
}
DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict)
@@ -131,7 +131,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTI
return NULL;
CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
CPDF_Action action((CPDF_Dictionary*)pDict);
- return action.GetDest(pDoc);
+ return action.GetDest(pDoc).GetObject();
}
DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, FPDF_ACTION pDict,
@@ -157,7 +157,7 @@ DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FP
if (!pDict)
return 0;
CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
- CPDF_Dest dest = (CPDF_Array*)pDict;
+ CPDF_Dest dest((CPDF_Array*)pDict);
return dest.GetPageIndex(pDoc);
}
@@ -192,14 +192,14 @@ DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, FPDF_LINK p
return NULL;
CPDF_Link link = (CPDF_Dictionary*)pDict;
- FPDF_DEST dest = link.GetDest(pDoc);
+ FPDF_DEST dest = link.GetDest(pDoc).GetObject();
if (dest)
return dest;
// If this link is not directly associated with a dest, we try to get action
CPDF_Action action = link.GetAction();
if (!action)
return NULL;
- return action.GetDest(pDoc);
+ return action.GetDest(pDoc).GetObject();
}
DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict)
diff --git a/fpdfsdk/src/fsdk_actionhandler.cpp b/fpdfsdk/src/fsdk_actionhandler.cpp
index 5fd6c54209..6f8ea0c60f 100644
--- a/fpdfsdk/src/fsdk_actionhandler.cpp
+++ b/fpdfsdk/src/fsdk_actionhandler.cpp
@@ -565,7 +565,7 @@ void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument,
CPDF_Dest MyDest = action.GetDest(pPDFDocument);
int nPageIndex = MyDest.GetPageIndex(pPDFDocument);
int nFitType = MyDest.GetZoomMode();
- const CPDF_Array * pMyArray = (CPDF_Array*)MyDest.m_pObj;
+ const CPDF_Array * pMyArray = (CPDF_Array*)MyDest.GetObject();
float* pPosAry = NULL;
int sizeOfAry = 0;
if (pMyArray != NULL)