From 1423319f52c5e80253d337ad02b19187c6d66ff1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 3 Apr 2017 16:02:39 +0200 Subject: Add public method FPDFPageObj_GetType to get type of a page object. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The possible return values were already part of the public header in the form of a set of defines. Change-Id: I040e0f330fdd7a3cd29f74fc6ee06d122afd2dd0 Reviewed-on: https://pdfium-review.googlesource.com/3570 Reviewed-by: Nicolás Peña Reviewed-by: dsinclair Commit-Queue: dsinclair --- fpdfsdk/fpdfeditpage.cpp | 8 ++++++++ fpdfsdk/fpdfview_c_api_test.c | 1 + public/fpdf_edit.h | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp index 7b55e4d99d..511b7f5b4b 100644 --- a/fpdfsdk/fpdfeditpage.cpp +++ b/fpdfsdk/fpdfeditpage.cpp @@ -246,6 +246,14 @@ FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) { return false; } +DLLEXPORT int STDCALL FPDFPageObj_GetType(FPDF_PAGEOBJECT pageObject) { + if (!pageObject) + return FPDF_PAGEOBJ_UNKNOWN; + + CPDF_PageObject* pPageObj = reinterpret_cast(pageObject); + return pPageObj->GetType(); +} + DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page) { CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (!IsPageObject(pPage)) diff --git a/fpdfsdk/fpdfview_c_api_test.c b/fpdfsdk/fpdfview_c_api_test.c index b090319d86..fec91efeca 100644 --- a/fpdfsdk/fpdfview_c_api_test.c +++ b/fpdfsdk/fpdfview_c_api_test.c @@ -79,6 +79,7 @@ int CheckPDFiumCApi() { CHK(FPDFPage_HasTransparency); CHK(FPDFPage_GenerateContent); CHK(FPDFPageObj_HasTransparency); + CHK(FPDFPageObj_GetType); CHK(FPDFPageObj_Transform); CHK(FPDFPage_TransformAnnots); CHK(FPDFPageObj_NewImageObj); diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h index 34a47a7c83..ce02a6406d 100644 --- a/public/fpdf_edit.h +++ b/public/fpdf_edit.h @@ -21,6 +21,7 @@ #define FPDF_GetAValue(argb) ((uint8_t)((argb) >> 24)) // The page object constants. +#define FPDF_PAGEOBJ_UNKNOWN 0 #define FPDF_PAGEOBJ_TEXT 1 #define FPDF_PAGEOBJ_PATH 2 #define FPDF_PAGEOBJ_IMAGE 3 @@ -135,6 +136,14 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page); DLLEXPORT FPDF_BOOL STDCALL FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject); +// Get type of |pageObject|. +// +// pageObject - handle to a page object. +// +// Returns one of the FPDF_PAGEOBJ_* values on success, FPDF_PAGEOBJ_UNKNOWN on +// error. +DLLEXPORT int STDCALL FPDFPageObj_GetType(FPDF_PAGEOBJECT pageObject); + // Transform |pageObject| by the given matrix. // // page_object - handle to a page object. -- cgit v1.2.3