Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(922)

Unified Diff: fpdfsdk/src/fpdfdoc.cpp

Issue 1335373002: Implement FPDFAction_GetFilePath(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: fpdfsdk/src/fpdfdoc.cpp
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index 5d2469c160759f4a6521e8bdb96c0b138affd31d..6a1991d4e1c816c4f87851e8ec15a72417169b16 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -126,7 +126,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) {
@@ -141,7 +142,6 @@ 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,
@@ -155,6 +155,20 @@ DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document,
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)
jun_fang 2015/09/14 12:10:43 it should return 0 in 'else' rather than len.
Lei Zhang 2015/09/15 08:24:50 Are you saying I should write the following? if (
jun_fang 2015/09/15 08:35:03 yes. For else cases, when buffer is null or buflen
Lei Zhang 2015/09/15 08:50:57 But returning 0 contradicts the comments section o
+ FXSYS_memcpy(buffer, path.c_str(), len);
+ return len;
+}
+
DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document,
FPDF_ACTION pDict,
void* buffer,

Powered by Google App Engine
This is Rietveld 408576698