summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_editpage.cpp
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 /fpdfsdk/fpdf_editpage.cpp
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 'fpdfsdk/fpdf_editpage.cpp')
-rw-r--r--fpdfsdk/fpdf_editpage.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index 30049342ca..c71f7e27be 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -345,19 +345,21 @@ FPDFPageObj_RemoveMark(FPDF_PAGEOBJECT page_object, FPDF_PAGEOBJECTMARK mark) {
return result;
}
-FPDF_EXPORT unsigned long FPDF_CALLCONV
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObjMark_GetName(FPDF_PAGEOBJECTMARK mark,
void* buffer,
- unsigned long buflen) {
- if (!mark)
- return 0;
+ unsigned long buflen,
+ unsigned long* out_buflen) {
+ if (!mark || !out_buflen)
+ return false;
const CPDF_ContentMarkItem* pMarkItem =
CPDFContentMarkItemFromFPDFPageObjectMark(mark);
- return Utf16EncodeMaybeCopyAndReturnLength(
+ *out_buflen = Utf16EncodeMaybeCopyAndReturnLength(
WideString::FromUTF8(pMarkItem->GetName().AsStringView()), buffer,
buflen);
+ return true;
}
FPDF_EXPORT int FPDF_CALLCONV
@@ -372,24 +374,29 @@ FPDFPageObjMark_CountParams(FPDF_PAGEOBJECTMARK mark) {
return pParams ? pParams->GetCount() : 0;
}
-FPDF_EXPORT unsigned long FPDF_CALLCONV
+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) {
+ if (!out_buflen)
+ return false;
+
const CPDF_Dictionary* pParams = GetMarkParamDict(mark);
if (!pParams)
- return 0;
+ return false;
for (auto& it : *pParams) {
if (index == 0) {
- return Utf16EncodeMaybeCopyAndReturnLength(
+ *out_buflen = Utf16EncodeMaybeCopyAndReturnLength(
WideString::FromUTF8(it.first.AsStringView()), buffer, buflen);
+ return true;
}
--index;
}
- return 0;
+ return false;
}
FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV
@@ -407,6 +414,9 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObjMark_GetParamIntValue(FPDF_PAGEOBJECTMARK mark,
FPDF_BYTESTRING key,
int* out_value) {
+ if (!out_value)
+ return false;
+
const CPDF_Dictionary* pParams = GetMarkParamDict(mark);
if (!pParams)
return false;