summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_edit_embeddertest.cpp15
-rw-r--r--fpdfsdk/fpdf_editpage.cpp59
-rw-r--r--fpdfsdk/fpdf_view_c_api_test.c3
3 files changed, 74 insertions, 3 deletions
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index 445b0cc6b9..a490162e15 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -573,6 +573,12 @@ TEST_F(FPDFEditEmbeddertest, RemoveMarkedObjectsPrime) {
FPDFPageObjMark_GetParamValueType(mark, 0));
int square_root = FPDFPageObjMark_GetParamIntValue(mark, 0);
EXPECT_EQ(i + 1, square_root * square_root);
+
+ EXPECT_EQ(FPDF_OBJECT_NUMBER,
+ FPDFPageObjMark_GetParamValueTypeByKey(mark, "Factor"));
+ EXPECT_TRUE(FPDFPageObjMark_GetParamIntValueByKey(mark, "Factor",
+ &square_root));
+ EXPECT_EQ(i + 1, square_root * square_root);
} else if (name == L"GreaterThanTen") {
greater_than_ten_count++;
EXPECT_EQ(0, FPDFPageObjMark_CountParams(mark));
@@ -590,6 +596,15 @@ TEST_F(FPDFEditEmbeddertest, RemoveMarkedObjectsPrime) {
GetPlatformWString(reinterpret_cast<unsigned short*>(buffer));
EXPECT_EQ(L"Last", value);
EXPECT_EQ(18, i);
+
+ EXPECT_EQ(FPDF_OBJECT_STRING,
+ FPDFPageObjMark_GetParamValueTypeByKey(mark, "Position"));
+ unsigned long length;
+ EXPECT_TRUE(FPDFPageObjMark_GetParamStringValueByKey(
+ mark, "Position", buffer, 256, &length));
+ ASSERT_GT(length, 0u);
+ value = GetPlatformWString(reinterpret_cast<unsigned short*>(buffer));
+ EXPECT_EQ(L"Last", value);
} else {
FAIL();
}
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;
diff --git a/fpdfsdk/fpdf_view_c_api_test.c b/fpdfsdk/fpdf_view_c_api_test.c
index 1837b58e2a..51b5884e80 100644
--- a/fpdfsdk/fpdf_view_c_api_test.c
+++ b/fpdfsdk/fpdf_view_c_api_test.c
@@ -139,9 +139,12 @@ int CheckPDFiumCApi() {
CHK(FPDFPageObjMark_CountParams);
CHK(FPDFPageObjMark_GetName);
CHK(FPDFPageObjMark_GetParamIntValue);
+ CHK(FPDFPageObjMark_GetParamIntValueByKey);
CHK(FPDFPageObjMark_GetParamKey);
CHK(FPDFPageObjMark_GetParamStringValue);
+ CHK(FPDFPageObjMark_GetParamStringValueByKey);
CHK(FPDFPageObjMark_GetParamValueType);
+ CHK(FPDFPageObjMark_GetParamValueTypeByKey);
CHK(FPDFPageObj_CountMarks);
CHK(FPDFPageObj_CreateNewPath);
CHK(FPDFPageObj_CreateNewRect);