blob: 21d0511bf1b658e081b2bea17f8e387e64baac58 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
From 636f92aac24f0accfbce910c9153d5479e097e5f Mon Sep 17 00:00:00 2001
From: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Date: Tue, 5 Jun 2018 11:34:38 +0200
Subject: [PATCH 10/14] svx: support importing forms from PDFs
---
pdfium/fpdfsdk/cpdfsdk_helpers.h | 5 +++++
pdfium/fpdfsdk/fpdf_editpage.cpp | 30 ++++++++++++++++++++++++++++++
pdfium/public/fpdf_edit.h | 17 +++++++++++++++++
3 files changed, 52 insertions(+)
diff --git a/pdfium/fpdfsdk/cpdfsdk_helpers.h b/pdfium/fpdfsdk/cpdfsdk_helpers.h
index 13362cf..477bb74 100644
--- a/pdfium/fpdfsdk/cpdfsdk_helpers.h
+++ b/pdfium/fpdfsdk/cpdfsdk_helpers.h
@@ -209,6 +209,11 @@ inline CPDF_TextObject* CPDFTextObjectFromFPDFPageObject(
return reinterpret_cast<CPDF_TextObject*>(page_object);
}
+inline CPDF_FormObject* CPDFFormObjectFromFPDFPageObject(
+ FPDF_PAGEOBJECT page_object) {
+ return reinterpret_cast<CPDF_FormObject*>(page_object);
+}
+
ByteString CFXByteStringFromFPDFWideString(FPDF_WIDESTRING wide_string);
#ifdef PDF_ENABLE_XFA
diff --git a/pdfium/fpdfsdk/fpdf_editpage.cpp b/pdfium/fpdfsdk/fpdf_editpage.cpp
index 9c353a4..bf68250 100644
--- a/pdfium/fpdfsdk/fpdf_editpage.cpp
+++ b/pdfium/fpdfsdk/fpdf_editpage.cpp
@@ -650,3 +650,31 @@ FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) {
pPageObj->SetDirty(true);
return true;
}
+
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFFormObj_CountSubObjects(FPDF_PAGEOBJECT form_object)
+{
+ CPDF_FormObject* pFrmObj = CPDFFormObjectFromFPDFPageObject(form_object);
+ if (pFrmObj)
+ {
+ const CPDF_PageObjectList* pObjectList = pFrmObj->form()->GetPageObjectList();
+ if (pObjectList)
+ return pObjectList->size();
+ }
+
+ return 0;
+}
+
+FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
+FPDFFormObj_GetSubObject(FPDF_PAGEOBJECT form_object, int index)
+{
+ CPDF_FormObject* pFrmObj = CPDFFormObjectFromFPDFPageObject(form_object);
+ if (pFrmObj)
+ {
+ const CPDF_PageObjectList* pObjectList = pFrmObj->form()->GetPageObjectList();
+ if (pObjectList)
+ return pObjectList->GetPageObjectByIndex(index);
+ }
+
+ return nullptr;
+}
diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h
index 4264ccd..ca76954 100644
--- a/pdfium/public/fpdf_edit.h
+++ b/pdfium/public/fpdf_edit.h
@@ -1142,6 +1142,23 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text);
FPDF_EXPORT int FPDF_CALLCONV
FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object);
+// Get number of page objects inside the form object.
+//
+// form_object - Handle to a form object. Returned by FPDFPage_GetObject.
+// Return value:
+// The number of the page objects.
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFFormObj_CountSubObjects(FPDF_PAGEOBJECT form_object);
+
+// Get the page object from a form object.
+//
+// form_object - Handle to a form object. Returned by FPDFPage_GetObject.
+// index - The index of a page object.
+// Return value:
+// The handle of the page object. Null for failed.
+FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
+FPDFFormObj_GetSubObject(FPDF_PAGEOBJECT form_object, int index);
+
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
--
2.16.3
|