diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-08-07 22:52:39 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-08-08 09:03:34 +0200 |
commit | 3820aff0a577f72d63446a62f0e614a1408ab114 (patch) | |
tree | 60e62495ad18e577c4f882e623d8d68f7b7fc2f1 /external/pdfium | |
parent | b9a739e0d3909e0fa4b76d5c0087d92a505e95fa (diff) |
pdfium: replace FPDFFormObj_CountSubObjects() with backport
Change-Id: Ie7aaf6790c29818236f38b90409860dedecb3cb3
Reviewed-on: https://gerrit.libreoffice.org/58711
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'external/pdfium')
6 files changed, 93 insertions, 36 deletions
diff --git a/external/pdfium/0001-Add-FPDFFormObj_CountObjects-API.patch.1 b/external/pdfium/0001-Add-FPDFFormObj_CountObjects-API.patch.1 new file mode 100644 index 000000000000..190fc6b2c9b6 --- /dev/null +++ b/external/pdfium/0001-Add-FPDFFormObj_CountObjects-API.patch.1 @@ -0,0 +1,77 @@ +From b66077d3ef7ba594f2a831840783549f4dd70d86 Mon Sep 17 00:00:00 2001 +Date: Wed, 11 Jul 2018 13:25:02 +0000 +Subject: [PATCH] Add FPDFFormObj_CountObjects() API +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +To find out the number of sub-objects a form object has, similar to how +FPDFPage_CountObjects() does it for page objects. + +Change-Id: I7e5775dece42b74fd5b71b1d9622a1aa37bf64ac +Reviewed-on: https://pdfium-review.googlesource.com/37316 +Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> +Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> +--- + fpdfsdk/fpdf_edit_embeddertest.cpp | 14 ++++++ + fpdfsdk/fpdf_editpage.cpp | 21 +++++++++ + fpdfsdk/fpdf_view_c_api_test.c | 1 + + public/fpdf_edit.h | 9 ++++ + testing/resources/form_object.in | 80 +++++++++++++++++++++++++++++++++ + testing/resources/form_object.pdf | 91 ++++++++++++++++++++++++++++++++++++++ + 6 files changed, 216 insertions(+) + create mode 100644 testing/resources/form_object.in + create mode 100644 testing/resources/form_object.pdf + +diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp +index 8a1200885..4151de5df 100644 +--- a/fpdfsdk/fpdf_editpage.cpp ++++ b/fpdfsdk/fpdf_editpage.cpp +@@ -751,3 +751,24 @@ FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) { + pPageObj->SetDirty(true); + return true; + } ++ ++FPDF_EXPORT int FPDF_CALLCONV ++FPDFFormObj_CountObjects(FPDF_PAGEOBJECT page_object) { ++ auto* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object); ++ if (!pPageObj) ++ return -1; ++ ++ CPDF_FormObject* pFormObject = pPageObj->AsForm(); ++ if (!pFormObject) ++ return -1; ++ ++ const CPDF_Form* pForm = pFormObject->form(); ++ if (!pForm) ++ return -1; ++ ++ const CPDF_PageObjectList* pObjectList = pForm->GetPageObjectList(); ++ if (!pObjectList) ++ return -1; ++ ++ return pObjectList->size(); ++} +diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h +index b85537d0b..e6f193a37 100644 +--- a/public/fpdf_edit.h ++++ b/public/fpdf_edit.h +@@ -1226,6 +1226,15 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document, + // Returns one of the FPDF_TEXTRENDERMODE_* flags on success, -1 on error. + FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text); + ++// Experimental API. ++// Get number of page objects inside |form_object|. ++// ++// form_object - handle to a form object. ++// ++// Returns the number of objects in |form_object| on success, -1 on error. ++FPDF_EXPORT int FPDF_CALLCONV ++FPDFFormObj_CountObjects(FPDF_PAGEOBJECT form_object); ++ + #ifdef __cplusplus + } // extern "C" + #endif // __cplusplus +-- +2.16.4 + diff --git a/external/pdfium/0002-svx-more-accurate-PDF-text-importing.patch.2 b/external/pdfium/0002-svx-more-accurate-PDF-text-importing.patch.2 index d4f8de52b3ec..896e676bf287 100644 --- a/external/pdfium/0002-svx-more-accurate-PDF-text-importing.patch.2 +++ b/external/pdfium/0002-svx-more-accurate-PDF-text-importing.patch.2 @@ -40,9 +40,9 @@ index 912df63..3244943 100644 diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h --- a/pdfium/public/fpdf_edit.h +++ b/pdfium/public/fpdf_edit.h -@@ -1133,6 +1133,15 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document, - // Returns one of the FPDF_TEXTRENDERMODE_* flags on success, -1 on error. - FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text); +@@ -1142,6 +1142,15 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text); + FPDF_EXPORT int FPDF_CALLCONV + FPDFFormObj_CountObjects(FPDF_PAGEOBJECT form_object); +// Get the number of characters from a text object. +// diff --git a/external/pdfium/0010-svx-support-importing-forms-from-PDFs.patch.2 b/external/pdfium/0010-svx-support-importing-forms-from-PDFs.patch.2 index 21d0511bf1b6..346ce2c2848c 100644 --- a/external/pdfium/0010-svx-support-importing-forms-from-PDFs.patch.2 +++ b/external/pdfium/0010-svx-support-importing-forms-from-PDFs.patch.2 @@ -29,25 +29,11 @@ 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; +@@ -671,3 +671,17 @@ FPDFFormObj_CountObjects(FPDF_PAGEOBJECT page_object) { + + return pObjectList->size(); } + -+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) +{ @@ -65,18 +51,10 @@ 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); +@@ -1151,6 +1151,15 @@ FPDFFormObj_CountObjects(FPDF_PAGEOBJECT form_object); 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. diff --git a/external/pdfium/0012-svx-import-processed-PDF-text.patch.2 b/external/pdfium/0012-svx-import-processed-PDF-text.patch.2 index 85e7662a8314..7996e7cd87e1 100644 --- a/external/pdfium/0012-svx-import-processed-PDF-text.patch.2 +++ b/external/pdfium/0012-svx-import-processed-PDF-text.patch.2 @@ -117,13 +117,13 @@ index f4a1688..f34d3b5 100644 +} + FPDF_EXPORT int FPDF_CALLCONV - FPDFFormObj_CountSubObjects(FPDF_PAGEOBJECT form_object) - { + FPDFFormObj_CountObjects(FPDF_PAGEOBJECT page_object) { + auto* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object); diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h index f249e64..e14b2a5 100644 --- a/pdfium/public/fpdf_edit.h +++ b/pdfium/public/fpdf_edit.h -@@ -1142,6 +1142,19 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text); +@@ -1151,6 +1151,19 @@ FPDFFormObj_CountObjects(FPDF_PAGEOBJECT form_object); FPDF_EXPORT int FPDF_CALLCONV FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object); @@ -140,7 +140,7 @@ index f249e64..e14b2a5 100644 + int char_count, + unsigned short* result); + - // Get number of page objects inside the form object. + // Get the page object from a form object. // // form_object - Handle to a form object. Returned by FPDFPage_GetObject. -- diff --git a/external/pdfium/0015-svx-set-the-font-name-of-imported-PDF-text.patch.2 b/external/pdfium/0015-svx-set-the-font-name-of-imported-PDF-text.patch.2 index 8943af795919..9ce208578d0b 100644 --- a/external/pdfium/0015-svx-set-the-font-name-of-imported-PDF-text.patch.2 +++ b/external/pdfium/0015-svx-set-the-font-name-of-imported-PDF-text.patch.2 @@ -54,9 +54,9 @@ diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h index 4351649..f858ab2 100644 --- a/pdfium/public/fpdf_edit.h +++ b/pdfium/public/fpdf_edit.h -@@ -1133,6 +1133,17 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document, - // Returns one of the FPDF_TEXTRENDERMODE_* flags on success, -1 on error. - FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text); +@@ -1142,6 +1142,17 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text); + FPDF_EXPORT int FPDF_CALLCONV + FPDFFormObj_CountObjects(FPDF_PAGEOBJECT form_object); +// Get the font name of a text object. +// diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk index 6c5eef772da3..957a859625f4 100644 --- a/external/pdfium/UnpackedTarball_pdfium.mk +++ b/external/pdfium/UnpackedTarball_pdfium.mk @@ -17,6 +17,8 @@ pdfium_patches += build.patch.1 pdfium_patches += 0001-Add-FPDFTextObj_GetFontSize-API.patch.patch.1 # Backport of <https://pdfium-review.googlesource.com/36750>. pdfium_patches += 0001-Add-FPDFText_GetTextRenderMode-API.patch.1 +# Backport of <https://pdfium-review.googlesource.com/37316>. +pdfium_patches += 0001-Add-FPDFFormObj_CountObjects-API.patch.1 pdfium_patches += 0002-svx-more-accurate-PDF-text-importing.patch.2 pdfium_patches += 0003-svx-import-PDF-images-as-BGRA.patch.2 pdfium_patches += 0004-svx-support-PDF-text-color.patch.2 |