summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_editpage.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-07-05 18:04:19 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-05 18:04:19 +0000
commit7007fd56221cb2c19444051ad34afb758c89706b (patch)
tree1fab21c7a5df5e78a55598245a94bde9913fdedd /fpdfsdk/fpdf_editpage.cpp
parent6f0d8ea78adbb7f5d93e2470a6888b5417a01bca (diff)
downloadpdfium-7007fd56221cb2c19444051ad34afb758c89706b.tar.xz
Create content mark APIs to get values by key.
Bug: pdfium:1037 Change-Id: Ie887c0bbf3e543676adec6d8411b0b3254677d3c Reviewed-on: https://pdfium-review.googlesource.com/37170 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_editpage.cpp')
-rw-r--r--fpdfsdk/fpdf_editpage.cpp59
1 files changed, 56 insertions, 3 deletions
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index d21b215d09..d275559107 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -99,15 +99,19 @@ void CalcBoundingBox(CPDF_PageObject* pPageObj) {
}
}
-const std::pair<const ByteString, std::unique_ptr<CPDF_Object>>*
-GetMarkParamPairAtIndex(FPDF_PAGEOBJECTMARK mark, unsigned long index) {
+const CPDF_Dictionary* GetMarkParamDict(FPDF_PAGEOBJECTMARK mark) {
if (!mark)
return nullptr;
const CPDF_ContentMarkItem* pMarkItem =
CPDFContentMarkItemFromFPDFPageObjectMark(mark);
- const CPDF_Dictionary* pParams = pMarkItem->GetParam();
+ return pMarkItem->GetParam();
+}
+
+const std::pair<const ByteString, std::unique_ptr<CPDF_Object>>*
+GetMarkParamPairAtIndex(FPDF_PAGEOBJECTMARK mark, unsigned long index) {
+ const CPDF_Dictionary* pParams = GetMarkParamDict(mark);
if (!pParams)
return nullptr;
@@ -345,6 +349,20 @@ FPDFPageObjMark_GetParamValueType(FPDF_PAGEOBJECTMARK mark,
return param_pair->second->GetType();
}
+FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV
+FPDFPageObjMark_GetParamValueTypeByKey(FPDF_PAGEOBJECTMARK mark,
+ FPDF_BYTESTRING key) {
+ const CPDF_Dictionary* pParams = GetMarkParamDict(mark);
+ if (!pParams)
+ return FPDF_OBJECT_UNKNOWN;
+
+ const CPDF_Object* pObject = pParams->GetObjectFor(key);
+ if (!pObject)
+ return FPDF_OBJECT_UNKNOWN;
+
+ return pObject->GetType();
+}
+
FPDF_EXPORT int FPDF_CALLCONV
FPDFPageObjMark_GetParamIntValue(FPDF_PAGEOBJECTMARK mark,
unsigned long index) {
@@ -355,6 +373,22 @@ FPDFPageObjMark_GetParamIntValue(FPDF_PAGEOBJECTMARK mark,
return param_pair->second->GetInteger();
}
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
+FPDFPageObjMark_GetParamIntValueByKey(FPDF_PAGEOBJECTMARK mark,
+ FPDF_BYTESTRING key,
+ int* out_value) {
+ const CPDF_Dictionary* pParams = GetMarkParamDict(mark);
+ if (!pParams)
+ return false;
+
+ const CPDF_Object* pObj = pParams->GetObjectFor(key);
+ if (!pObj || !pObj->IsNumber())
+ return false;
+
+ *out_value = pObj->GetInteger();
+ return true;
+}
+
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFPageObjMark_GetParamStringValue(FPDF_PAGEOBJECTMARK mark,
unsigned long index,
@@ -370,6 +404,25 @@ FPDFPageObjMark_GetParamStringValue(FPDF_PAGEOBJECTMARK mark,
}
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
+FPDFPageObjMark_GetParamStringValueByKey(FPDF_PAGEOBJECTMARK mark,
+ FPDF_BYTESTRING key,
+ void* buffer,
+ unsigned long buflen,
+ unsigned long* out_buflen) {
+ const CPDF_Dictionary* pParams = GetMarkParamDict(mark);
+ if (!pParams)
+ return false;
+
+ const CPDF_Object* pObj = pParams->GetObjectFor(key);
+ if (!pObj || !pObj->IsString())
+ return false;
+
+ *out_buflen = Utf16EncodeMaybeCopyAndReturnLength(
+ WideString::FromUTF8(pObj->GetString().AsStringView()), buffer, buflen);
+ return true;
+}
+
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) {
if (!pageObject)
return false;