diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2018-04-23 16:35:56 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-23 16:35:56 +0000 |
commit | 132c38e7bdd0bdd1aa526b35c7bcb79c286fb061 (patch) | |
tree | 20801fa3c9ce77a72d2195dcd6e2daba8298d853 /fpdfsdk/fpdf_editpage.cpp | |
parent | fd016f4e9b0df99ed4670b50b30e5c6f18028f9a (diff) | |
download | pdfium-132c38e7bdd0bdd1aa526b35c7bcb79c286fb061.tar.xz |
Create API to get PageObject mark parameters.
New calls added in this cl:
- FPDFPageObjMark_GetParamKey
- FPDFPageObjMark_GetParamValueType
- FPDFPageObjMark_GetParamIntValue
Bug: pdfium:1037
Change-Id: Iedb74ddbf8a5483de62094ec295dadd6367d5175
Reviewed-on: https://pdfium-review.googlesource.com/30912
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_editpage.cpp')
-rw-r--r-- | fpdfsdk/fpdf_editpage.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp index 7a8bbabf2d..241025f3a6 100644 --- a/fpdfsdk/fpdf_editpage.cpp +++ b/fpdfsdk/fpdf_editpage.cpp @@ -99,6 +99,28 @@ void CalcBoundingBox(CPDF_PageObject* pPageObj) { } } +const std::pair<const ByteString, std::unique_ptr<CPDF_Object>>* +GetMarkParamPairAtIndex(FPDF_PAGEOBJECTMARK mark, unsigned long index) { + if (!mark) + return nullptr; + + const CPDF_ContentMarkItem* pMarkItem = + CPDFContentMarkItemFromFPDFPageObjectMark(mark); + + const CPDF_Dictionary* pParams = pMarkItem->GetParam(); + if (!pParams) + return nullptr; + + for (auto& it : *pParams) { + if (index == 0) + return ⁢ + + --index; + } + + return nullptr; +} + } // namespace FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument() { @@ -284,6 +306,39 @@ FPDFPageObjMark_CountParams(FPDF_PAGEOBJECTMARK mark) { return pParams->GetCount(); } +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFPageObjMark_GetParamKey(FPDF_PAGEOBJECTMARK mark, + unsigned long index, + void* buffer, + unsigned long buflen) { + auto* param_pair = GetMarkParamPairAtIndex(mark, index); + if (!param_pair) + return 0; + + return Utf16EncodeMaybeCopyAndReturnLength( + WideString::FromUTF8(param_pair->first.AsStringView()), buffer, buflen); +} + +FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV +FPDFPageObjMark_GetParamValueType(FPDF_PAGEOBJECTMARK mark, + unsigned long index) { + auto* param_pair = GetMarkParamPairAtIndex(mark, index); + if (!param_pair) + return FPDF_OBJECT_UNKNOWN; + + return param_pair->second->GetType(); +} + +FPDF_EXPORT int FPDF_CALLCONV +FPDFPageObjMark_GetParamIntValue(FPDF_PAGEOBJECTMARK mark, + unsigned long index) { + auto* param_pair = GetMarkParamPairAtIndex(mark, index); + if (!param_pair) + return 0; + + return param_pair->second->GetInteger(); +} + FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) { if (!pageObject) |