summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-09-25 12:59:29 +0200
committerChromium commit bot <commit-bot@chromium.org>2017-09-25 12:44:35 +0000
commit92627618a93720c6153828b8a8d1c6ed17c6e91f (patch)
tree9a9eb6b76ff402da02bd68ffc5e321967b3da4c5
parentf5777a117a7557507616eaf585de5eb266531e16 (diff)
downloadpdfium-92627618a93720c6153828b8a8d1c6ed17c6e91f.tar.xz
API: rename FPDFPage_CountObject() to FPDFPage_CountObjects()
Keep the old name, but mark it as deprecated and don't use it in own code. Change-Id: I17b88dccacf494a03562c0d003cfcb2bc03bf430 Reviewed-on: https://pdfium-review.googlesource.com/14750 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--fpdfsdk/fpdfedit_embeddertest.cpp4
-rw-r--r--fpdfsdk/fpdfeditimg_unittest.cpp16
-rw-r--r--fpdfsdk/fpdfeditpage.cpp4
-rw-r--r--fpdfsdk/fpdfview_c_api_test.c1
-rw-r--r--public/fpdf_edit.h9
-rw-r--r--samples/pdfium_test.cc2
6 files changed, 25 insertions, 11 deletions
diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp
index f8c053a6ad..44d5aaf438 100644
--- a/fpdfsdk/fpdfedit_embeddertest.cpp
+++ b/fpdfsdk/fpdfedit_embeddertest.cpp
@@ -1021,7 +1021,7 @@ TEST_F(FPDFEditEmbeddertest, ExtractImageBitmap) {
ASSERT_TRUE(OpenDocument("embedded_images.pdf"));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- ASSERT_EQ(39, FPDFPage_CountObject(page));
+ ASSERT_EQ(39, FPDFPage_CountObjects(page));
FPDF_PAGEOBJECT obj = FPDFPage_GetObject(page, 32);
EXPECT_NE(FPDF_PAGEOBJ_IMAGE, FPDFPageObj_GetType(obj));
@@ -1075,7 +1075,7 @@ TEST_F(FPDFEditEmbeddertest, GetImageData) {
EXPECT_TRUE(OpenDocument("embedded_images.pdf"));
FPDF_PAGE page = LoadPage(0);
ASSERT_TRUE(page);
- ASSERT_EQ(39, FPDFPage_CountObject(page));
+ ASSERT_EQ(39, FPDFPage_CountObjects(page));
// Retrieve an image object with flate-encoded data stream.
FPDF_PAGEOBJECT obj = FPDFPage_GetObject(page, 33);
diff --git a/fpdfsdk/fpdfeditimg_unittest.cpp b/fpdfsdk/fpdfeditimg_unittest.cpp
index 0ff3db8e2d..fcc081ab76 100644
--- a/fpdfsdk/fpdfeditimg_unittest.cpp
+++ b/fpdfsdk/fpdfeditimg_unittest.cpp
@@ -16,17 +16,17 @@ class PDFEditTest : public testing::Test {
TEST_F(PDFEditTest, InsertObjectWithInvalidPage) {
FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
- EXPECT_EQ(0, FPDFPage_CountObject(page));
+ EXPECT_EQ(0, FPDFPage_CountObjects(page));
FPDFPage_InsertObject(nullptr, nullptr);
- EXPECT_EQ(0, FPDFPage_CountObject(page));
+ EXPECT_EQ(0, FPDFPage_CountObjects(page));
FPDFPage_InsertObject(page, nullptr);
- EXPECT_EQ(0, FPDFPage_CountObject(page));
+ EXPECT_EQ(0, FPDFPage_CountObjects(page));
FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImageObj(doc);
FPDFPage_InsertObject(nullptr, page_image);
- EXPECT_EQ(0, FPDFPage_CountObject(page));
+ EXPECT_EQ(0, FPDFPage_CountObjects(page));
FPDF_ClosePage(page);
FPDF_CloseDocument(doc);
@@ -35,11 +35,11 @@ TEST_F(PDFEditTest, InsertObjectWithInvalidPage) {
TEST_F(PDFEditTest, NewImageObj) {
FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
- EXPECT_EQ(0, FPDFPage_CountObject(page));
+ EXPECT_EQ(0, FPDFPage_CountObjects(page));
FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImageObj(doc);
FPDFPage_InsertObject(page, page_image);
- EXPECT_EQ(1, FPDFPage_CountObject(page));
+ EXPECT_EQ(1, FPDFPage_CountObjects(page));
EXPECT_TRUE(FPDFPage_GenerateContent(page));
FPDF_ClosePage(page);
@@ -49,7 +49,7 @@ TEST_F(PDFEditTest, NewImageObj) {
TEST_F(PDFEditTest, NewImageObjGenerateContent) {
FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
- EXPECT_EQ(0, FPDFPage_CountObject(page));
+ EXPECT_EQ(0, FPDFPage_CountObjects(page));
constexpr int kBitmapSize = 50;
FPDF_BITMAP bitmap = FPDFBitmap_Create(kBitmapSize, kBitmapSize, 0);
@@ -62,7 +62,7 @@ TEST_F(PDFEditTest, NewImageObjGenerateContent) {
ASSERT_TRUE(
FPDFImageObj_SetMatrix(page_image, kBitmapSize, 0, 0, kBitmapSize, 0, 0));
FPDFPage_InsertObject(page, page_image);
- EXPECT_EQ(1, FPDFPage_CountObject(page));
+ EXPECT_EQ(1, FPDFPage_CountObjects(page));
EXPECT_TRUE(FPDFPage_GenerateContent(page));
FPDFBitmap_Destroy(bitmap);
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
index 26f4424d10..b4e71bf254 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -183,6 +183,10 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertObject(FPDF_PAGE page,
}
FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObject(FPDF_PAGE page) {
+ return FPDFPage_CountObjects(page);
+}
+
+FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObjects(FPDF_PAGE page) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!IsPageObject(pPage))
return -1;
diff --git a/fpdfsdk/fpdfview_c_api_test.c b/fpdfsdk/fpdfview_c_api_test.c
index cc5d6c995d..996f48af16 100644
--- a/fpdfsdk/fpdfview_c_api_test.c
+++ b/fpdfsdk/fpdfview_c_api_test.c
@@ -120,6 +120,7 @@ int CheckPDFiumCApi() {
CHK(FPDFPage_SetRotation);
CHK(FPDFPage_InsertObject);
CHK(FPDFPage_CountObject);
+ CHK(FPDFPage_CountObjects);
CHK(FPDFPage_GetObject);
CHK(FPDFPage_HasTransparency);
CHK(FPDFPage_GenerateContent);
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index 6e4f9a4ae8..f2dad739ca 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -150,8 +150,17 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertObject(FPDF_PAGE page,
// page - handle to a page.
//
// Returns the number of objects in |page|.
+//
+// DEPRECATED. Please use FPDFPage_CountObjects.
FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObject(FPDF_PAGE page);
+// Get number of page objects inside |page|.
+//
+// page - handle to a page.
+//
+// Returns the number of objects in |page|.
+FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObjects(FPDF_PAGE page);
+
// Get object in |page| at |index|.
//
// page - handle to a page.
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 40f12a318b..0c002a8c63 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -1136,7 +1136,7 @@ void SaveAttachments(FPDF_DOCUMENT doc, const std::string& name) {
}
void SaveImages(FPDF_PAGE page, const char* pdf_name, int page_num) {
- for (int i = 0; i < FPDFPage_CountObject(page); ++i) {
+ for (int i = 0; i < FPDFPage_CountObjects(page); ++i) {
FPDF_PAGEOBJECT obj = FPDFPage_GetObject(page, i);
if (FPDFPageObj_GetType(obj) != FPDF_PAGEOBJ_IMAGE)
continue;