diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2018-07-12 19:45:29 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-12 19:45:29 +0000 |
commit | 07520f6e9cfd1c1f304d18af614d83938e382adb (patch) | |
tree | 19616c41d1a7540f0bc334164ab76aa44e0f2020 /fpdfsdk/fpdf_editpage.cpp | |
parent | 83f2d7060194a146ffcb9cbac993178d92a166bc (diff) | |
download | pdfium-07520f6e9cfd1c1f304d18af614d83938e382adb.tar.xz |
Create API to set and get blob values from a mark dict.
The new functions are:
- FPDFPageObjMark_GetParamBlobValue
- FPDFPageObjMark_SetBlobParam
Bug: pdfium:1037
Change-Id: Ie04df04c64c6cf517a8cde182d7e9a38c3c78d1b
Reviewed-on: https://pdfium-review.googlesource.com/37570
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.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp index 4df5505cca..02c07d1724 100644 --- a/fpdfsdk/fpdf_editpage.cpp +++ b/fpdfsdk/fpdf_editpage.cpp @@ -402,6 +402,9 @@ FPDFPageObjMark_GetParamStringValue(FPDF_PAGEOBJECTMARK mark, void* buffer, unsigned long buflen, unsigned long* out_buflen) { + if (!out_buflen) + return false; + const CPDF_Dictionary* pParams = GetMarkParamDict(mark); if (!pParams) return false; @@ -416,6 +419,33 @@ FPDFPageObjMark_GetParamStringValue(FPDF_PAGEOBJECTMARK mark, } FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObjMark_GetParamBlobValue(FPDF_PAGEOBJECTMARK mark, + FPDF_BYTESTRING key, + void* buffer, + unsigned long buflen, + unsigned long* out_buflen) { + if (!out_buflen) + return false; + + const CPDF_Dictionary* pParams = GetMarkParamDict(mark); + if (!pParams) + return false; + + const CPDF_Object* pObj = pParams->GetObjectFor(key); + if (!pObj || !pObj->IsString()) + return false; + + ByteString result = pObj->GetString(); + unsigned long len = result.GetLength(); + + if (buffer && len <= buflen) + memcpy(buffer, result.c_str(), len); + + *out_buflen = len; + return true; +} + +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) { if (!pageObject) return false; @@ -475,6 +505,24 @@ FPDFPageObjMark_SetStringParam(FPDF_DOCUMENT document, return true; } +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObjMark_SetBlobParam(FPDF_DOCUMENT document, + FPDF_PAGEOBJECTMARK mark, + FPDF_BYTESTRING key, + void* value, + unsigned long value_len) { + CPDF_Dictionary* pParams = GetOrCreateMarkParamsDict(document, mark); + if (!pParams) + return false; + + if (!value && value_len > 0) + return false; + + pParams->SetNewFor<CPDF_String>( + key, ByteString(static_cast<const char*>(value), value_len), true); + return true; +} + FPDF_EXPORT int FPDF_CALLCONV FPDFPageObj_GetType(FPDF_PAGEOBJECT pageObject) { if (!pageObject) return FPDF_PAGEOBJ_UNKNOWN; |