summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfdoc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src/fpdfdoc.cpp')
-rw-r--r--fpdfsdk/src/fpdfdoc.cpp49
1 files changed, 30 insertions, 19 deletions
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index 47225dd2b1..34caf95b52 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -128,7 +128,8 @@ DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) {
DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) {
if (!pDict)
- return 0;
+ return PDFACTION_UNSUPPORTED;
+
CPDF_Action action((CPDF_Dictionary*)pDict);
CPDF_Action::ActionType type = action.GetType();
switch (type) {
@@ -143,43 +144,53 @@ DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) {
default:
return PDFACTION_UNSUPPORTED;
}
- return PDFACTION_UNSUPPORTED;
}
DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document,
FPDF_ACTION pDict) {
- if (!document)
- return NULL;
- if (!pDict)
- return NULL;
+ if (!document || !pDict)
+ return nullptr;
+
CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
CPDF_Action action((CPDF_Dictionary*)pDict);
return action.GetDest(pDoc).GetObject();
}
+DLLEXPORT unsigned long STDCALL
+FPDFAction_GetFilePath(FPDF_ACTION pDict, void* buffer, unsigned long buflen) {
+ unsigned long type = FPDFAction_GetType(pDict);
+ if (type != PDFACTION_REMOTEGOTO && type != PDFACTION_LAUNCH)
+ return 0;
+
+ CPDF_Action action((CPDF_Dictionary*)pDict);
+ CFX_ByteString path = action.GetFilePath().UTF8Encode();
+ unsigned long len = path.GetLength() + 1;
+ if (buffer && buflen >= len)
+ FXSYS_memcpy(buffer, path.c_str(), len);
+ return len;
+}
+
DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document,
FPDF_ACTION pDict,
void* buffer,
unsigned long buflen) {
- if (!document)
- return 0;
- if (!pDict)
+ if (!document || !pDict)
return 0;
+
CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
CPDF_Action action((CPDF_Dictionary*)pDict);
CFX_ByteString path = action.GetURI(pDoc);
unsigned long len = path.GetLength() + 1;
- if (buffer != NULL && buflen >= len)
+ if (buffer && buflen >= len)
FXSYS_memcpy(buffer, path.c_str(), len);
return len;
}
DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document,
FPDF_DEST pDict) {
- if (!document)
- return 0;
- if (!pDict)
+ if (!document || !pDict)
return 0;
+
CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
CPDF_Dest dest((CPDF_Array*)pDict);
return dest.GetPageIndex(pDoc);
@@ -218,10 +229,9 @@ FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y) {
DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,
FPDF_LINK pDict) {
- if (!document)
- return NULL;
- if (!pDict)
- return NULL;
+ if (!document || !pDict)
+ return nullptr;
+
CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
CPDF_Link link((CPDF_Dictionary*)pDict);
FPDF_DEST dest = link.GetDest(pDoc).GetObject();
@@ -230,13 +240,14 @@ DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,
// 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 nullptr;
return action.GetDest(pDoc).GetObject();
}
DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) {
if (!pDict)
- return NULL;
+ return nullptr;
+
CPDF_Link link((CPDF_Dictionary*)pDict);
return link.GetAction().GetDict();
}