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