summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-04-23 18:04:26 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-23 18:04:26 +0000
commitb557bdcbd1584a7e37f8883b0fc491e0641cfc9c (patch)
tree447c0360d9f2f2555c1c2d19e6f8d7e007e58503
parent0784c7317e3aaa2c65d098cf2593b6b49986307d (diff)
downloadpdfium-b557bdcbd1584a7e37f8883b0fc491e0641cfc9c.tar.xz
Create FPDFPageObjMark_GetParamStringValue().
Bug: pdfium:1037 Change-Id: I05f992d2a4ee5a11b5c57ec51107c4b00011809c Reviewed-on: https://pdfium-review.googlesource.com/31190 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
-rw-r--r--fpdfsdk/fpdf_edit_embeddertest.cpp14
-rw-r--r--fpdfsdk/fpdf_editpage.cpp14
-rw-r--r--fpdfsdk/fpdf_view_c_api_test.c1
-rw-r--r--public/fpdf_edit.h22
-rw-r--r--testing/resources/text_in_page_marked.in2
-rw-r--r--testing/resources/text_in_page_marked.pdf6
6 files changed, 54 insertions, 5 deletions
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index ec6b893530..3da57ab737 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -484,6 +484,20 @@ TEST_F(FPDFEditEmbeddertest, RemoveMarkedObjectsPrime) {
} else if (name == L"GreaterThanTen") {
greater_than_ten_count++;
EXPECT_EQ(0, FPDFPageObjMark_CountParams(mark));
+ } else if (name == L"Bounds") {
+ EXPECT_EQ(1, FPDFPageObjMark_CountParams(mark));
+ ASSERT_GT(FPDFPageObjMark_GetParamKey(mark, 0, buffer, 256), 0u);
+ std::wstring key =
+ GetPlatformWString(reinterpret_cast<unsigned short*>(buffer));
+ EXPECT_EQ(L"Position", key);
+ EXPECT_EQ(FPDF_OBJECT_STRING,
+ FPDFPageObjMark_GetParamValueType(mark, 0));
+ ASSERT_GT(FPDFPageObjMark_GetParamStringValue(mark, 0, buffer, 256),
+ 0u);
+ std::wstring value =
+ GetPlatformWString(reinterpret_cast<unsigned short*>(buffer));
+ EXPECT_EQ(L"Last", value);
+ EXPECT_EQ(18, i);
} else {
FAIL();
}
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index 241025f3a6..fc6b21f24c 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -339,6 +339,20 @@ FPDFPageObjMark_GetParamIntValue(FPDF_PAGEOBJECTMARK mark,
return param_pair->second->GetInteger();
}
+FPDF_EXPORT unsigned long FPDF_CALLCONV
+FPDFPageObjMark_GetParamStringValue(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->second->GetString().AsStringView()),
+ buffer, buflen);
+}
+
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) {
if (!pageObject)
diff --git a/fpdfsdk/fpdf_view_c_api_test.c b/fpdfsdk/fpdf_view_c_api_test.c
index dd93095550..792acbe439 100644
--- a/fpdfsdk/fpdf_view_c_api_test.c
+++ b/fpdfsdk/fpdf_view_c_api_test.c
@@ -152,6 +152,7 @@ int CheckPDFiumCApi() {
CHK(FPDFPageObjMark_GetParamKey);
CHK(FPDFPageObjMark_GetParamValueType);
CHK(FPDFPageObjMark_GetParamIntValue);
+ CHK(FPDFPageObjMark_GetParamStringValue);
CHK(FPDFImageObj_LoadJpegFile);
CHK(FPDFImageObj_LoadJpegFileInline);
CHK(FPDFImageObj_SetMatrix);
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index 8228bb759a..023d955d00 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -319,7 +319,7 @@ FPDFPageObjMark_GetName(FPDF_PAGEOBJECTMARK mark,
unsigned long buflen);
// Experimental API.
-// Get number of key/value pair parameters in |mark|.
+// Get the number of key/value pair parameters in |mark|.
//
// mark - handle to a content mark.
//
@@ -345,7 +345,7 @@ FPDFPageObjMark_GetParamKey(FPDF_PAGEOBJECTMARK mark,
unsigned long buflen);
// Experimental API.
-// Get type of the value of a property in a content mark.
+// Get the type of the value of a property in a content mark.
//
// mark - handle to a content mark.
// index - index of the property.
@@ -356,7 +356,7 @@ FPDFPageObjMark_GetParamValueType(FPDF_PAGEOBJECTMARK mark,
unsigned long index);
// Experimental API.
-// Get value of an int property in a content mark.
+// Get the value of an int property in a content mark.
// FPDFPageObjMark_GetParamValueType() should have returned FPDF_OBJECT_NUMBER
// for this property.
//
@@ -367,6 +367,22 @@ FPDFPageObjMark_GetParamValueType(FPDF_PAGEOBJECTMARK mark,
FPDF_EXPORT int FPDF_CALLCONV
FPDFPageObjMark_GetParamIntValue(FPDF_PAGEOBJECTMARK mark, unsigned long index);
+// Experimental API.
+// Get the value of a string property in a content mark.
+// |buffer| is only modified if |buflen| is longer than the length of the key.
+//
+// mark - handle to a content mark.
+// index - index of the property.
+// buffer - buffer for holding the returned key in UTF16-LE.
+// buflen - length of the buffer.
+//
+// Returns the length of the value.
+FPDF_EXPORT unsigned long FPDF_CALLCONV
+FPDFPageObjMark_GetParamStringValue(FPDF_PAGEOBJECTMARK mark,
+ unsigned long index,
+ void* buffer,
+ unsigned long buflen);
+
// Load an image from a JPEG image file and then set it into |image_object|.
//
// pages - pointer to the start of all loaded pages, may be NULL.
diff --git a/testing/resources/text_in_page_marked.in b/testing/resources/text_in_page_marked.in
index 982fc7be7c..e33847909b 100644
--- a/testing/resources/text_in_page_marked.in
+++ b/testing/resources/text_in_page_marked.in
@@ -116,12 +116,14 @@ EMC
q 0 0 0.894118 rg /FXE2 gs
BT 1.49521 1.16377 -1.16377 1.49521 129.904 123.275
Tm /FXF2 9 Tf (Test 18) Tj ET Q
+/Bounds <</Position (Last)>> BDC
/Prime BMC
q 0 0 0.945098 rg /FXE2 gs
BT 1.84185 0.632309 -0.632309 1.84185 136.837 112.646
Tm /FXF1 9 Tf (Test 19) Tj ET Q
EMC
EMC
+EMC
Q
endstream
endobj
diff --git a/testing/resources/text_in_page_marked.pdf b/testing/resources/text_in_page_marked.pdf
index 1f9e54f575..a30ab9d4a5 100644
--- a/testing/resources/text_in_page_marked.pdf
+++ b/testing/resources/text_in_page_marked.pdf
@@ -39,7 +39,7 @@ endobj
<< /BaseFont /Times-Bold /Subtype /Type1 /Type /Font >>
endobj
12 0 obj
-<< /Length 2396 >>
+<< /Length 2433 >>
stream
q
0 0 0 RG 0 0 0 rg 1 w 0 J 0 j
@@ -117,12 +117,14 @@ EMC
q 0 0 0.894118 rg /FXE2 gs
BT 1.49521 1.16377 -1.16377 1.49521 129.904 123.275
Tm /FXF2 9 Tf (Test 18) Tj ET Q
+/Bounds <</Position (Last)>> BDC
/Prime BMC
q 0 0 0.945098 rg /FXE2 gs
BT 1.84185 0.632309 -0.632309 1.84185 136.837 112.646
Tm /FXF1 9 Tf (Test 19) Tj ET Q
EMC
EMC
+EMC
Q
endstream
endobj
@@ -148,5 +150,5 @@ trailer <<
/ID [<f341ae654a77acd5065a7645e596e6e6><bc37298a3f87f479229bce997ca791f7>]
>>
startxref
-3186
+3223
%%EOF