summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfeditpage.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-03-27 16:26:44 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-03-27 16:26:44 +0000
commitc90adc58b97200d20b0532bde95b79dcba00637f (patch)
tree002895239afa554f84a0fb76e6cb85265fef19b3 /fpdfsdk/fpdfeditpage.cpp
parentc526e38a47a7fc7d83cc87aaf521d14bb7b7304d (diff)
downloadpdfium-c90adc58b97200d20b0532bde95b79dcba00637f.tar.xz
Open FPDF_PAGEOBJECTMARK API.
Initially it contains: - FPDFPageObj_CountMarks - FPDFPageObj_GetMark - FPDFPageObjMark_GetName This allows reading the content marks from a page object. Bug: pdfium:1037 Change-Id: I3d7554b71f938778890fdb44088e0d45dd2718d9 Reviewed-on: https://pdfium-review.googlesource.com/28710 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfeditpage.cpp')
-rw-r--r--fpdfsdk/fpdfeditpage.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
index 902aab4dd1..d0724d5359 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -222,6 +222,47 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPageObj_Destroy(FPDF_PAGEOBJECT page_obj) {
delete CPDFPageObjectFromFPDFPageObject(page_obj);
}
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFPageObj_CountMarks(FPDF_PAGEOBJECT page_object) {
+ if (!page_object)
+ return -1;
+
+ const auto& mark =
+ CPDFPageObjectFromFPDFPageObject(page_object)->m_ContentMark;
+ return mark.HasRef() ? mark.CountItems() : 0;
+}
+
+FPDF_EXPORT FPDF_PAGEOBJECTMARK FPDF_CALLCONV
+FPDFPageObj_GetMark(FPDF_PAGEOBJECT page_object, unsigned long index) {
+ if (!page_object)
+ return nullptr;
+
+ const auto& mark =
+ CPDFPageObjectFromFPDFPageObject(page_object)->m_ContentMark;
+ if (!mark.HasRef())
+ return nullptr;
+
+ if (index >= mark.CountItems())
+ return nullptr;
+
+ return static_cast<FPDF_PAGEOBJECTMARK>(&mark.GetItem(index));
+}
+
+FPDF_EXPORT unsigned long FPDF_CALLCONV
+FPDFPageObjMark_GetName(FPDF_PAGEOBJECTMARK mark,
+ void* buffer,
+ unsigned long buflen) {
+ if (!mark)
+ return 0;
+
+ const CPDF_ContentMarkItem* pMarkItem =
+ CPDFContentMarkItemFromFPDFPageObjectMark(mark);
+
+ return Utf16EncodeMaybeCopyAndReturnLength(
+ WideString::FromUTF8(pMarkItem->GetName().AsStringView()), buffer,
+ buflen);
+}
+
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) {
if (!pageObject)