summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-09-18 18:08:15 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-09-18 18:08:15 +0000
commitc3099d1c694251a654edc6cb72df8adb5e2268ab (patch)
tree527e4cfa4a2efdaeef4ed6d5f5d93ec953ef8e83 /public
parent7ea611fb82308b4b8f9dc150a9d79334435c53b6 (diff)
downloadpdfium-c3099d1c694251a654edc6cb72df8adb5e2268ab.tar.xz
Change signature of FPDFPageObjMark_Get(Name|ParamKey).chromium/3556
These methods used to return the size of the buffer to contain the value to be returned. Now they will return an FPDF_BOOL to make it consistent with the other mark APIs and more intuitive to differentiate a success from a failure. The size will be returned through an out param. This CL also adds more focused testing for these API methods and similar ones. Change-Id: I6f9837f99d955aaba2c49a259ed7805a286e091d Reviewed-on: https://pdfium-review.googlesource.com/42411 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'public')
-rw-r--r--public/fpdf_edit.h66
1 files changed, 40 insertions, 26 deletions
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index dcf6201fe8..180d50247e 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -332,18 +332,23 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObj_RemoveMark(FPDF_PAGEOBJECT page_object, FPDF_PAGEOBJECTMARK mark);
// Experimental API.
-// Get name of a content mark. |buffer| is only modified if |buflen| is longer
-// than the length of the name.
+// Get the name of a content mark.
//
-// mark - handle to a content mark.
-// buffer - buffer for holding the returned name in UTF16-LE.
-// buflen - length of the buffer.
+// mark - handle to a content mark.
+// buffer - buffer for holding the returned name in UTF16-LE. This is only
+// modified if |buflen| is longer than the length of the name.
+// Optional, pass null to just retrieve the size of the buffer
+// needed.
+// buflen - length of the buffer.
+// out_buflen - pointer to variable that will receive the minimum buffer size
+// to contain the name. Not filled if FALSE is returned.
//
-// Returns the length of the name.
-FPDF_EXPORT unsigned long FPDF_CALLCONV
+// Returns TRUE if the operation succeeded, FALSE if it failed.
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObjMark_GetName(FPDF_PAGEOBJECTMARK mark,
void* buffer,
- unsigned long buflen);
+ unsigned long buflen,
+ unsigned long* out_buflen);
// Experimental API.
// Get the number of key/value pair parameters in |mark|.
@@ -356,20 +361,25 @@ FPDF_EXPORT int FPDF_CALLCONV
FPDFPageObjMark_CountParams(FPDF_PAGEOBJECTMARK mark);
// Experimental API.
-// Get the key of a property in a content mark. |buffer| is only modified if
-// |buflen| is longer than the length of the key.
+// Get the key of a property in a content mark.
//
-// mark - handle to a content mark.
-// index - index of the property.
-// buffer - buffer for holding the returned key in UTF16-LE.
-// buflen - length of the buffer.
+// mark - handle to a content mark.
+// index - index of the property.
+// buffer - buffer for holding the returned key in UTF16-LE. This is only
+// modified if |buflen| is longer than the length of the key.
+// Optional, pass null to just retrieve the size of the buffer
+// needed.
+// buflen - length of the buffer.
+// out_buflen - pointer to variable that will receive the minimum buffer size
+// to contain the key. Not filled if FALSE is returned.
//
-// Returns the length of the key.
-FPDF_EXPORT unsigned long FPDF_CALLCONV
+// Returns TRUE if the operation was successful, FALSE otherwise.
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObjMark_GetParamKey(FPDF_PAGEOBJECTMARK mark,
unsigned long index,
void* buffer,
- unsigned long buflen);
+ unsigned long buflen,
+ unsigned long* out_buflen);
// Experimental API.
// Get the type of the value of a property in a content mark by key.
@@ -400,14 +410,17 @@ FPDFPageObjMark_GetParamIntValue(FPDF_PAGEOBJECTMARK mark,
// Experimental API.
// Get the value of a string property in a content mark by key.
-// |buffer| is only modified if |buflen| is longer than the length of the value.
//
// mark - handle to a content mark.
// key - string key of the property.
-// buffer - buffer for holding the returned value in UTF16-LE.
+// buffer - buffer for holding the returned value in UTF16-LE. This is
+// only modified if |buflen| is longer than the length of the
+// value.
+// Optional, pass null to just retrieve the size of the buffer
+// needed.
// buflen - length of the buffer.
-// out_buflen - pointer to variable that will receive the length of the value.
-// Not filled if false is returned.
+// out_buflen - pointer to variable that will receive the minimum buffer size
+// to contain the value. Not filled if FALSE is returned.
//
// Returns TRUE if the key maps to a string/blob value, FALSE otherwise.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
@@ -419,15 +432,16 @@ FPDFPageObjMark_GetParamStringValue(FPDF_PAGEOBJECTMARK mark,
// Experimental API.
// Get the value of a blob property in a content mark by key.
-// |buffer| is only modified if |buflen| is longer than or equal to the length
-// of the value.
//
// mark - handle to a content mark.
// key - string key of the property.
-// buffer - buffer for holding the returned value.
+// buffer - buffer for holding the returned value. This is only modified
+// if |buflen| is at least as long as the length of the value.
+// Optional, pass null to just retrieve the size of the buffer
+// needed.
// buflen - length of the buffer.
-// out_buflen - pointer to variable that will receive the length of the value.
-// Not filled if false is returned.
+// out_buflen - pointer to variable that will receive the minimum buffer size
+// to contain the value. Not filled if FALSE is returned.
//
// Returns TRUE if the key maps to a string/blob value, FALSE otherwise.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV