pdfium: replace FPDFFormObj_GetMatrix patch with backport

Change-Id: Ic819fb1097986437cae99f4769bd93f20b6db44a
Reviewed-on: https://gerrit.libreoffice.org/60358
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
This commit is contained in:
Miklos Vajna
2018-09-12 09:06:57 +02:00
parent 5fe2c43a94
commit 1b267db43b
6 changed files with 99 additions and 182 deletions
@@ -0,0 +1,96 @@
From 46b437333e53295869afde696ed31043c1f6c717 Mon Sep 17 00:00:00 2001
Date: Tue, 14 Aug 2018 19:15:43 +0000
Subject: [PATCH] Add FPDFFormObj_GetMatrix() API
This is similar to FPDFText_GetMatrix() (wrapping
CPDF_TextObject::GetTextMatrix()) and FPDFPath_GetMatrix() (wrapping
CPDF_PathObject::m_Matrix), but wraps the matrix of form objects:
CPDF_FormObject::form_matrix().
Change-Id: Ic4ce7ad8050012f54de356bb936263d3e4f097ca
Reviewed-on: https://pdfium-review.googlesource.com/39930
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
---
fpdfsdk/fpdf_edit_embeddertest.cpp | 34 ++++++++++++++++++++++++++++++++++
fpdfsdk/fpdf_editpage.cpp | 27 +++++++++++++++++++++++++++
fpdfsdk/fpdf_view_c_api_test.c | 1 +
public/fpdf_edit.h | 26 ++++++++++++++++++++++++++
4 files changed, 88 insertions(+)
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index 438a0624f..0ff7a119a 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -842,3 +842,30 @@ FPDFFormObj_GetObject(FPDF_PAGEOBJECT form_object, unsigned long index) {
return FPDFPageObjectFromCPDFPageObject(
pObjectList->GetPageObjectByIndex(index));
}
+
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
+FPDFFormObj_GetMatrix(FPDF_PAGEOBJECT form_object,
+ double* a,
+ double* b,
+ double* c,
+ double* d,
+ double* e,
+ double* f) {
+ if (!form_object || !a || !b || !c || !d || !e || !f)
+ return false;
+
+ auto* pPageObj = CPDFPageObjectFromFPDFPageObject(form_object);
+ CPDF_FormObject* pFormObj = pPageObj->AsForm();
+ if (!pFormObj)
+ return false;
+
+ const CFX_Matrix& matrix = pFormObj->form_matrix();
+ *a = matrix.a;
+ *b = matrix.b;
+ *c = matrix.c;
+ *d = matrix.d;
+ *e = matrix.e;
+ *f = matrix.f;
+
+ return true;
+}
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index 83fedba90..577ae7fac 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -1313,6 +1313,32 @@ FPDFFormObj_CountObjects(FPDF_PAGEOBJECT form_object);
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
FPDFFormObj_GetObject(FPDF_PAGEOBJECT form_object, unsigned long index);
+// Experimental API.
+// Get the transform matrix of a form object.
+//
+// form_object - handle to a form.
+// a - pointer to out variable to receive matrix value.
+// b - pointer to out variable to receive matrix value.
+// c - pointer to out variable to receive matrix value.
+// d - pointer to out variable to receive matrix value.
+// e - pointer to out variable to receive matrix value.
+// f - pointer to out variable to receive matrix value.
+//
+// The matrix is composed as:
+// |a c e|
+// |b d f|
+// and used to scale, rotate, shear and translate the form object.
+//
+// Returns TRUE on success.
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
+FPDFFormObj_GetMatrix(FPDF_PAGEOBJECT form_object,
+ double* a,
+ double* b,
+ double* c,
+ double* d,
+ double* e,
+ double* f);
+
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
--
2.16.4
+1 -1
View File
@@ -33,7 +33,7 @@ index fed1581..3f400c7 100644
+ RetainPtr<CFX_DIBitmap> pBitmap;
+ pBitmap = pSource->CloneConvert(FXDIB_Argb);
+
+ return pBitmap.Leak();
+ return FPDFBitmapFromCFXDIBitmap(pBitmap.Leak());
+}
+
FPDF_EXPORT unsigned long FPDF_CALLCONV
-46
View File
@@ -1,46 +0,0 @@
From 914467a56b9c4cd6a27cfa9b7ed61ebfb5a122d3 Mon Sep 17 00:00:00 2001
From: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Date: Tue, 5 Jun 2018 11:29:49 +0200
Subject: [PATCH 04/14] svx: support PDF text color
---
pdfium/fpdfsdk/cpdfsdk_helpers.h | 5 +++++
pdfium/fpdfsdk/fpdf_editpage.cpp | 30 +++++++++++++++++++++++++-----
pdfium/public/fpdf_edit.h | 16 ++++++++++++++++
3 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/pdfium/fpdfsdk/cpdfsdk_helpers.h b/pdfium/fpdfsdk/cpdfsdk_helpers.h
index d93ecfc..13362cf 100644
--- a/pdfium/fpdfsdk/cpdfsdk_helpers.h
+++ b/pdfium/fpdfsdk/cpdfsdk_helpers.h
@@ -204,6 +204,11 @@ inline CPDF_TextPageFind* CPDFTextPageFindFromFPDFSchHandle(
return reinterpret_cast<CPDF_TextPageFind*>(handle);
}
+inline CPDF_TextObject* CPDFTextObjectFromFPDFPageObject(
+ FPDF_PAGEOBJECT page_object) {
+ return reinterpret_cast<CPDF_TextObject*>(page_object);
+}
+
ByteString CFXByteStringFromFPDFWideString(FPDF_WIDESTRING wide_string);
#ifdef PDF_ENABLE_XFA
diff --git a/pdfium/fpdfsdk/fpdf_edittext.cpp b/pdfium/fpdfsdk/fpdf_edittext.cpp
index c38873faa..aa3287ef4 100644
--- a/pdfium/fpdfsdk/fpdf_edittext.cpp
+++ b/pdfium/fpdfsdk/fpdf_edittext.cpp
@@ -398,11 +398,6 @@ CPDF_Font* LoadCompositeFont(CPDF_Document* pDoc,
return pDoc->LoadFont(fontDict);
}
-CPDF_TextObject* CPDFTextObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object) {
- auto* obj = CPDFPageObjectFromFPDFPageObject(page_object);
- return obj ? obj->AsText() : nullptr;
-}
-
} // namespace
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
--
2.16.3
@@ -1,91 +0,0 @@
From c82f6e80d94f8598221009035c8f336f5f656333 Mon Sep 17 00:00:00 2001
From: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Date: Tue, 5 Jun 2018 11:35:14 +0200
Subject: [PATCH 11/14] svx: correctly possition form objects from PDF
---
pdfium/fpdfsdk/fpdf_editpage.cpp | 25 +++++++++++++++++++++++++
pdfium/public/fpdf_edit.h | 18 ++++++++++++++++++
2 files changed, 43 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 bf68250..f4a1688 100644
--- a/pdfium/fpdfsdk/fpdf_editpage.cpp
+++ b/pdfium/fpdfsdk/fpdf_editpage.cpp
@@ -688,3 +688,28 @@ FPDFFormObj_GetObject(FPDF_PAGEOBJECT form_object, unsigned long index) {
return FPDFPageObjectFromCPDFPageObject(
pObjectList->GetPageObjectByIndex(index));
}
+
+FPDF_EXPORT void FPDF_CALLCONV
+FPDFFormObj_GetMatrix(FPDF_PAGEOBJECT form_object,
+ double* a,
+ double* b,
+ double* c,
+ double* d,
+ double* e,
+ double* f)
+{
+ if (!form_object || !a || !b || !c || !d || !e || !f)
+ return;
+
+ CPDF_FormObject* pFrmObj = CPDFFormObjectFromFPDFPageObject(form_object);
+ if (pFrmObj)
+ {
+ const CFX_Matrix& matrix = pFrmObj->form_matrix();
+ *a = matrix.a;
+ *b = matrix.b;
+ *c = matrix.c;
+ *d = matrix.d;
+ *e = matrix.e;
+ *f = matrix.f;
+ }
+}
diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h
index ca76954..f249e64 100644
--- a/pdfium/public/fpdf_edit.h
+++ b/pdfium/public/fpdf_edit.h
@@ -1190,6 +1190,24 @@ FPDFFormObj_CountObjects(FPDF_PAGEOBJECT form_object);
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
FPDFFormObj_GetObject(FPDF_PAGEOBJECT form_object, unsigned long index);
+// Get the matrix of a particular form object.
+//
+// form_object - Handle of form object
+// a - Pointer to a double value receiving coefficient "a" of the matrix.
+// b - Pointer to a double value receiving coefficient "b" of the matrix.
+// c - Pointer to a double value receiving coefficient "c" of the matrix.
+// d - Pointer to a double value receiving coefficient "d" of the matrix.
+// e - Pointer to a double value receiving coefficient "e" of the matrix.
+// f - Pointer to a double value receiving coefficient "f" of the matrix.
+FPDF_EXPORT void FPDF_CALLCONV
+FPDFFormObj_GetMatrix(FPDF_PAGEOBJECT form_object,
+ double* a,
+ double* b,
+ double* c,
+ double* d,
+ double* e,
+ double* f);
+
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
--
2.16.3
@@ -1,41 +0,0 @@
From f701ff3ce04a4e7e757a9f3ee62b4967749455dd Mon Sep 17 00:00:00 2001
From: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Date: Tue, 5 Jun 2018 14:27:55 +0200
Subject: [PATCH 14/14] svx: update PDFium patch and code
---
pdfium/fpdfsdk/cpdfsdk_helpers.h | 2 ++
pdfium/fpdfsdk/fpdf_editimg.cpp | 2 +-
pdfium/fpdfsdk/fpdf_editpage.cpp | 19 ++++++++++++-------
pdfium/public/fpdf_edit.h | 16 ++++++++--------
4 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/pdfium/fpdfsdk/cpdfsdk_helpers.h b/pdfium/fpdfsdk/cpdfsdk_helpers.h
index 477bb74..c907ad8 100644
--- a/pdfium/fpdfsdk/cpdfsdk_helpers.h
+++ b/pdfium/fpdfsdk/cpdfsdk_helpers.h
@@ -40,6 +40,8 @@ class CPDF_TextPage;
class CPDF_TextPageFind;
class IPDFSDK_PauseAdapter;
class FX_PATHPOINT;
+class CPDF_TextObject;
+class CPDF_FormObject;
#ifdef PDF_ENABLE_XFA
class CPDFXFA_Context;
diff --git a/pdfium/fpdfsdk/fpdf_editimg.cpp b/pdfium/fpdfsdk/fpdf_editimg.cpp
index 3f400c7..968b84a 100644
--- a/pdfium/fpdfsdk/fpdf_editimg.cpp
+++ b/pdfium/fpdfsdk/fpdf_editimg.cpp
@@ -203,7 +203,7 @@ FPDFImageObj_GetBitmapBgra(FPDF_PAGEOBJECT image_object) {
RetainPtr<CFX_DIBitmap> pBitmap;
pBitmap = pSource->CloneConvert(FXDIB_Argb);
- return pBitmap.Leak();
+ return FPDFBitmapFromCFXDIBitmap(pBitmap.Leak());
}
FPDF_EXPORT unsigned long FPDF_CALLCONV
--
2.16.3
+2 -3
View File
@@ -25,10 +25,9 @@ pdfium_patches += 0001-Add-FPDFFormObj_GetObject-API.patch.1
pdfium_patches += 0001-Add-FPDFText_GetFontName-API.patch.1
# Backport of <https://pdfium-review.googlesource.com/39530>.
pdfium_patches += 0001-Add-FPDFTextObj_GetText-API.patch.1
# Backport of <https://pdfium-review.googlesource.com/39930>.
pdfium_patches += 0001-Add-FPDFFormObj_GetMatrix-API.patch.1
pdfium_patches += 0003-svx-import-PDF-images-as-BGRA.patch.2
pdfium_patches += 0004-svx-support-PDF-text-color.patch.2
pdfium_patches += 0011-svx-correctly-possition-form-objects-from-PDF.patch.2
pdfium_patches += 0014-svx-update-PDFium-patch-and-code.patch.2
$(eval $(call gb_UnpackedTarball_UnpackedTarball,pdfium))