Kaydet (Commit) 56ac8214 authored tarafından Miklos Vajna's avatar Miklos Vajna

pdfium: update to 3550

Allows dropping all the backports, so only one custom API patch remains.

Change-Id: I13dc4f62be86d0859862cbd95bb14e07bbcf53d6
Reviewed-on: https://gerrit.libreoffice.org/60697
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 47a173ed
......@@ -200,8 +200,8 @@ export OWNCLOUD_ANDROID_LIB_SHA256SUM := b18b3e3ef7fae6a79b62f2bb43cc47a5346b633
export OWNCLOUD_ANDROID_LIB_TARBALL := owncloud-android-library-0.9.4-no-binary-deps.tar.gz
export PAGEMAKER_SHA256SUM := 66adacd705a7d19895e08eac46d1e851332adf2e736c566bef1164e7a442519d
export PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
export PDFIUM_SHA256SUM := 4acbc905fee1743e96169ca155347a81fb2b0f381281109c1860aa4408ec6c4f
export PDFIUM_TARBALL := pdfium-3471.tar.bz2
export PDFIUM_SHA256SUM := 572460f7f9e2f86d022a9c6a82f1e2ded6c3c29ba352d4b9fac60b87e2159679
export PDFIUM_TARBALL := pdfium-3550.tar.bz2
export PIXMAN_SHA256SUM := 21b6b249b51c6800dc9553b65106e1e37d0e25df942c90531d4c3997aa20a88e
export PIXMAN_TARBALL := e80ebae4da01e77f68744319f01d52a3-pixman-0.34.0.tar.gz
export LIBPNG_SHA256SUM := 2f1e960d92ce3b3abd03d06dfec9637dfbd22febf107a536b44f7a47c60659f6
......
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
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
From 1d273f1cf00676725da6f0cd17e107f114030e87 Mon Sep 17 00:00:00 2001
Date: Mon, 16 Jul 2018 19:20:36 +0000
Subject: [PATCH] Add FPDFFormObj_GetObject() API
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
To be used together with the existing FPDFFormObj_CountObjects()
function.
Change-Id: I8ed69624e967708c8db7e8f135e28fbe6a52752f
Reviewed-on: https://pdfium-review.googlesource.com/37890
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
---
fpdfsdk/fpdf_edit_embeddertest.cpp | 20 +++++++++++++++++++
fpdfsdk/fpdf_editpage.cpp | 41 +++++++++++++++++++++++++++-----------
fpdfsdk/fpdf_view_c_api_test.c | 1 +
public/fpdf_edit.h | 10 ++++++++++
4 files changed, 60 insertions(+), 12 deletions(-)
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index ded55b9be..f1dbf7019 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -140,6 +140,23 @@ unsigned int GetUnsignedAlpha(float alpha) {
return static_cast<unsigned int>(alpha * 255.f + 0.5f);
}
+const CPDF_PageObjectList* CPDFPageObjListFromFPDFFormObject(
+ FPDF_PAGEOBJECT page_object) {
+ auto* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object);
+ if (!pPageObj)
+ return nullptr;
+
+ CPDF_FormObject* pFormObject = pPageObj->AsForm();
+ if (!pFormObject)
+ return nullptr;
+
+ const CPDF_Form* pForm = pFormObject->form();
+ if (!pForm)
+ return nullptr;
+
+ return pForm->GetPageObjectList();
+}
+
} // namespace
FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument() {
@@ -812,21 +829,21 @@ FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) {
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)
+ const CPDF_PageObjectList* pObjectList =
+ CPDFPageObjListFromFPDFFormObject(page_object);
+ if (!pObjectList)
return -1;
- const CPDF_Form* pForm = pFormObject->form();
- if (!pForm)
- return -1;
+ return pObjectList->size();
+}
- const CPDF_PageObjectList* pObjectList = pForm->GetPageObjectList();
+FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
+FPDFFormObj_GetObject(FPDF_PAGEOBJECT form_object, unsigned long index) {
+ const CPDF_PageObjectList* pObjectList =
+ CPDFPageObjListFromFPDFFormObject(form_object);
if (!pObjectList)
- return -1;
+ return nullptr;
- return pObjectList->size();
+ return FPDFPageObjectFromCPDFPageObject(
+ pObjectList->GetPageObjectByIndex(index));
}
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index fdd8c97d0..b97a7adbd 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -1265,6 +1265,16 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text);
FPDF_EXPORT int FPDF_CALLCONV
FPDFFormObj_CountObjects(FPDF_PAGEOBJECT form_object);
+// Experimental API.
+// Get page object in |form_object| at |index|.
+//
+// form_object - handle to a form object.
+// index - the 0-based index of a page object.
+//
+// Returns the handle to the page object, or NULL on error.
+FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
+FPDFFormObj_GetObject(FPDF_PAGEOBJECT form_object, unsigned long index);
+
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
--
2.16.4
From b9d88e52f8c1a4a27daab5739e6c777f2dbb655a Mon Sep 17 00:00:00 2001
Date: Tue, 26 Jun 2018 15:12:48 +0000
Subject: [PATCH] Add FPDFTextObj_GetFontSize() API
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In contrast with FPDFText_GetFontSize(), this exposes the font size of
the text object according to the text state, rather than the font size
of a particular character.
Change-Id: Iac88d1aea8fb6bb5522bdaf01363aa6d32025b8f
Reviewed-on: https://pdfium-review.googlesource.com/35931
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
---
fpdfsdk/fpdf_edit_embeddertest.cpp | 3 +++
fpdfsdk/fpdf_edittext.cpp | 11 +++++++++++
fpdfsdk/fpdf_view_c_api_test.c | 1 +
public/fpdf_edit.h | 9 +++++++++
4 files changed, 24 insertions(+)
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index a927e16e1..e339c2412 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -511,6 +511,17 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetMatrix(FPDF_PAGEOBJECT text,
return true;
}
+FPDF_EXPORT double FPDF_CALLCONV FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text) {
+ if (!text)
+ return 0;
+
+ CPDF_TextObject* pTextObj = CPDFTextObjectFromFPDFPageObject(text);
+ if (!pTextObj)
+ return 0;
+
+ return pTextObj->GetFontSize();
+}
+
FPDF_EXPORT void FPDF_CALLCONV FPDFFont_Close(FPDF_FONT font) {
CPDF_Font* pFont = CPDFFontFromFPDFFont(font);
if (!pFont)
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index 6df5e3237..6e613bca0 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -1090,6 +1090,15 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetMatrix(FPDF_PAGEOBJECT text,
double* e,
double* f);
+// Experimental API.
+// Get the font size of a text object.
+//
+// text - handle to a text.
+//
+// Returns the font size of the text object, measured in points (about 1/72
+// inch) on success; 0 on failure.
+FPDF_EXPORT double FPDF_CALLCONV FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text);
+
// Close a loaded PDF font.
//
// font - Handle to the loaded font.
--
2.16.4
From 3bee9c60f013b8b7e99c39ee35699d132b330334 Mon Sep 17 00:00:00 2001
Date: Tue, 7 Aug 2018 21:45:34 +0000
Subject: [PATCH] Add FPDFTextObj_GetText() API
Generalize CPDF_TextPage::GetTextByRect(), so that it's possible to get
the text from a text page using a predicate, that way we can easily
get the text that belongs to single text object as well.
Change-Id: Ia457af0f41184694dc1481709be72b35685bce7f
Reviewed-on: https://pdfium-review.googlesource.com/39530
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
---
core/fpdftext/cpdf_textpage.cpp | 18 +++++++++++++--
core/fpdftext/cpdf_textpage.h | 4 ++++
fpdfsdk/fpdf_edittext.cpp | 18 +++++++++++++++
fpdfsdk/fpdf_text_embeddertest.cpp | 45 ++++++++++++++++++++++++++++++++++++++
fpdfsdk/fpdf_view_c_api_test.c | 1 +
public/fpdf_edit.h | 20 +++++++++++++++++
6 files changed, 104 insertions(+), 2 deletions(-)
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 289416043..ed7f36fb6 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -426,7 +426,8 @@ int CPDF_TextPage::GetIndexAtPos(const CFX_PointF& point,
return pos < nCount ? pos : NearPos;
}
-WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const {
+WideString CPDF_TextPage::GetTextByPredicate(
+ const std::function<bool(const PAGECHAR_INFO&)>& predicate) const {
if (!m_bIsParsed)
return WideString();
@@ -435,7 +436,7 @@ WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const {
bool IsAddLineFeed = false;
WideString strText;
for (const auto& charinfo : m_CharList) {
- if (IsRectIntersect(rect, charinfo.m_CharBox)) {
+ if (predicate(charinfo)) {
if (fabs(posy - charinfo.m_Origin.y) > 0 && !IsContainPreChar &&
IsAddLineFeed) {
posy = charinfo.m_Origin.y;
@@ -460,6 +461,19 @@ WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const {
return strText;
}
+WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const {
+ return GetTextByPredicate([&rect](const PAGECHAR_INFO& charinfo) {
+ return IsRectIntersect(rect, charinfo.m_CharBox);
+ });
+}
+
+WideString CPDF_TextPage::GetTextByObject(
+ const CPDF_TextObject* pTextObj) const {
+ return GetTextByPredicate([pTextObj](const PAGECHAR_INFO& charinfo) {
+ return charinfo.m_pTextObj == pTextObj;
+ });
+}
+
void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO* info) const {
if (!m_bIsParsed || !pdfium::IndexInBounds(m_CharList, index))
return;
diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h
index 36d01854f..90b45bd96 100644
--- a/core/fpdftext/cpdf_textpage.h
+++ b/core/fpdftext/cpdf_textpage.h
@@ -8,6 +8,7 @@
#define CORE_FPDFTEXT_CPDF_TEXTPAGE_H_
#include <deque>
+#include <functional>
#include <vector>
#include "core/fpdfapi/page/cpdf_pageobjectlist.h"
@@ -97,6 +98,7 @@ class CPDF_TextPage {
std::vector<CFX_FloatRect> GetRectArray(int start, int nCount) const;
int GetIndexAtPos(const CFX_PointF& point, const CFX_SizeF& tolerance) const;
WideString GetTextByRect(const CFX_FloatRect& rect) const;
+ WideString GetTextByObject(const CPDF_TextObject* pTextObj) const;
// Returns string with the text from |m_TextBuf| that are covered by the input
// range. |start| and |count| are in terms of the |m_CharIndex|, so the range
@@ -151,6 +153,8 @@ class CPDF_TextPage {
TextOrientation FindTextlineFlowOrientation() const;
void AppendGeneratedCharacter(wchar_t unicode, const CFX_Matrix& formMatrix);
void SwapTempTextBuf(int32_t iCharListStartAppend, int32_t iBufStartAppend);
+ WideString GetTextByPredicate(
+ const std::function<bool(const PAGECHAR_INFO&)>& predicate) const;
UnownedPtr<const CPDF_Page> const m_pPage;
std::vector<uint16_t> m_CharIndex;
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index 6aa44b3b2..2773763b9 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -22,6 +22,7 @@
#include "core/fpdfapi/parser/cpdf_number.h"
#include "core/fpdfapi/parser/cpdf_reference.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
+#include "core/fpdftext/cpdf_textpage.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxge/cfx_fontmgr.h"
#include "core/fxge/fx_font.h"
@@ -564,6 +565,23 @@ FPDFTextObj_GetFontName(FPDF_PAGEOBJECT text,
return dwStringLen;
}
+FPDF_EXPORT unsigned long FPDF_CALLCONV
+FPDFTextObj_GetText(FPDF_PAGEOBJECT text_object,
+ FPDF_TEXTPAGE text_page,
+ void* buffer,
+ unsigned long length) {
+ CPDF_TextObject* pTextObj = CPDFTextObjectFromFPDFPageObject(text_object);
+ if (!pTextObj)
+ return 0;
+
+ CPDF_TextPage* pTextPage = CPDFTextPageFromFPDFTextPage(text_page);
+ if (!pTextPage)
+ return 0;
+
+ WideString text = pTextPage->GetTextByObject(pTextObj);
+ return Utf16EncodeMaybeCopyAndReturnLength(text, buffer, length);
+}
+
FPDF_EXPORT void FPDF_CALLCONV FPDFFont_Close(FPDF_FONT font) {
CPDF_Font* pFont = CPDFFontFromFPDFFont(font);
if (!pFont)
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index 4d5aa9c48..83fedba90 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -1274,6 +1274,26 @@ FPDFTextObj_GetFontName(FPDF_PAGEOBJECT text,
void* buffer,
unsigned long length);
+// Experimental API.
+// Get the text of a text object.
+//
+// text_object - the handle to the text object.
+// text_page - the handle to the text page.
+// buffer - the address of a buffer that receives the text.
+// length - the size, in bytes, of |buffer|.
+//
+// Returns the number of bytes in the text (including the trailing NUL
+// character) on success, 0 on error.
+//
+// Regardless of the platform, the |buffer| is always in UTF16-LE encoding.
+// If |length| is less than the returned length, or |buffer| is NULL, |buffer|
+// will not be modified.
+FPDF_EXPORT unsigned long FPDF_CALLCONV
+FPDFTextObj_GetText(FPDF_PAGEOBJECT text_object,
+ FPDF_TEXTPAGE text_page,
+ void* buffer,
+ unsigned long length);
+
// Experimental API.
// Get number of page objects inside |form_object|.
//
--
2.16.4
From 53d4f0a4526ef996caf5005ae84406a9467423f2 Mon Sep 17 00:00:00 2001
Date: Wed, 1 Aug 2018 01:28:49 +0000
Subject: [PATCH] Add FPDFText_GetFontName() API
This follows the same pattern as DefaultGetFaceName(), so the client has
to call this function twice, but allocation of the string buffer happens
outside pdfium.
Change-Id: I06b7dcd00aca9b9b94799dad3f139617d7f5451e
Reviewed-on: https://pdfium-review.googlesource.com/38870
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 | 28 ++++++++++++++++++++++++++++
fpdfsdk/fpdf_edittext.cpp | 22 ++++++++++++++++++++++
fpdfsdk/fpdf_view_c_api_test.c | 1 +
public/fpdf_edit.h | 18 ++++++++++++++++++
testing/resources/text_font.pdf | Bin 0 -> 10576 bytes
5 files changed, 69 insertions(+)
create mode 100644 testing/resources/text_font.pdf
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index c552d615e..6aa44b3b2 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -548,6 +548,28 @@ FPDF_EXPORT double FPDF_CALLCONV FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text) {
return pTextObj->GetFontSize();
}
+FPDF_EXPORT unsigned long FPDF_CALLCONV
+FPDFTextObj_GetFontName(FPDF_PAGEOBJECT text,
+ void* buffer,
+ unsigned long length) {
+ CPDF_TextObject* pTextObj = CPDFTextObjectFromFPDFPageObject(text);
+ if (!pTextObj)
+ return 0;
+
+ CPDF_Font* pPdfFont = pTextObj->GetFont();
+ if (!pPdfFont)
+ return 0;
+
+ CFX_Font* pFont = pPdfFont->GetFont();
+ ASSERT(pFont);
+
+ ByteString name = pFont->GetFamilyName();
+ unsigned long dwStringLen = name.GetLength() + 1;
+ if (buffer && length >= dwStringLen)
+ memcpy(buffer, name.c_str(), dwStringLen);
+ return dwStringLen;
+}
+
FPDF_EXPORT void FPDF_CALLCONV FPDFFont_Close(FPDF_FONT font) {
CPDF_Font* pFont = CPDFFontFromFPDFFont(font);
if (!pFont)
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index b97a7adbd..4d5aa9c48 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -1256,6 +1256,24 @@ 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 the font name of a text object.
+//
+// text - the handle to the text object.
+// buffer - the address of a buffer that receives the font name.
+// length - the size, in bytes, of |buffer|.
+//
+// Returns the number of bytes in the font name (including the trailing NUL
+// character) on success, 0 on error.
+//
+// Regardless of the platform, the |buffer| is always in UTF-8 encoding.
+// If |length| is less than the returned length, or |buffer| is NULL, |buffer|
+// will not be modified.
+FPDF_EXPORT unsigned long FPDF_CALLCONV
+FPDFTextObj_GetFontName(FPDF_PAGEOBJECT text,
+ void* buffer,
+ unsigned long length);
+
// Experimental API.
// Get number of page objects inside |form_object|.
//
--
2.16.4
From 1448cc11b9be67d2d1fcd3f2f833cc6f79ad8d42 Mon Sep 17 00:00:00 2001
Date: Tue, 3 Jul 2018 13:52:33 +0000
Subject: [PATCH] Add FPDFText_GetTextRenderMode() API
This allows deciding if FPDFPageObj_GetFillColor() or
FPDFPageObj_GetStrokeColor() should be used to get the effective color
of a text object.
Change-Id: Ic6e99a9eb8512b164756da8b5fcd8cd7771271ae
Reviewed-on: https://pdfium-review.googlesource.com/36750
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
---
fpdfsdk/fpdf_edit_embeddertest.cpp | 17 ++++++++
fpdfsdk/fpdf_edittext.cpp | 37 +++++++++++++++++
fpdfsdk/fpdf_view_c_api_test.c | 1 +
public/fpdf_edit.h | 17 ++++++++
testing/resources/text_render_mode.pdf | 75 ++++++++++++++++++++++++++++++++++
5 files changed, 147 insertions(+)
create mode 100644 testing/resources/text_render_mode.pdf
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index 3115e2a16..c552d615e 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -14,6 +14,7 @@
#include "core/fpdfapi/font/cpdf_type1font.h"
#include "core/fpdfapi/page/cpdf_docpagedata.h"
#include "core/fpdfapi/page/cpdf_textobject.h"
+#include "core/fpdfapi/page/cpdf_textstate.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
@@ -27,6 +28,31 @@
#include "fpdfsdk/cpdfsdk_helpers.h"
#include "public/fpdf_edit.h"
+// These checks are here because core/ and public/ cannot depend on each other.
+static_assert(static_cast<int>(TextRenderingMode::MODE_FILL) ==
+ FPDF_TEXTRENDERMODE_FILL,
+ "TextRenderingMode::MODE_FILL value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_STROKE) ==
+ FPDF_TEXTRENDERMODE_STROKE,
+ "TextRenderingMode::MODE_STROKE value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_FILL_STROKE) ==
+ FPDF_TEXTRENDERMODE_FILL_STROKE,
+ "TextRenderingMode::MODE_FILL_STROKE value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_INVISIBLE) ==
+ FPDF_TEXTRENDERMODE_INVISIBLE,
+ "TextRenderingMode::MODE_INVISIBLE value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_FILL_CLIP) ==
+ FPDF_TEXTRENDERMODE_FILL_CLIP,
+ "TextRenderingMode::MODE_FILL_CLIP value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_STROKE_CLIP) ==
+ FPDF_TEXTRENDERMODE_STROKE_CLIP,
+ "TextRenderingMode::MODE_STROKE_CLIP value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_FILL_STROKE_CLIP) ==
+ FPDF_TEXTRENDERMODE_FILL_STROKE_CLIP,
+ "TextRenderingMode::MODE_FILL_STROKE_CLIP value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_CLIP) ==
+ FPDF_TEXTRENDERMODE_CLIP,
+ "TextRenderingMode::MODE_CLIP value mismatch");
namespace {
CPDF_Dictionary* LoadFontDesc(CPDF_Document* pDoc,
@@ -545,3 +571,14 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
pTextObj->DefaultStates();
return FPDFPageObjectFromCPDFPageObject(pTextObj.release());
}
+
+FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text) {
+ if (!text)
+ return -1;
+
+ CPDF_TextObject* pTextObj = CPDFTextObjectFromFPDFPageObject(text);
+ if (!pTextObj)
+ return -1;
+
+ return static_cast<int>(pTextObj->m_TextState.GetTextMode());
+}
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index 6e613bca0..6490c18c6 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -70,6 +70,15 @@
#define FPDF_PRINTMODE_POSTSCRIPT2_PASSTHROUGH 4
#define FPDF_PRINTMODE_POSTSCRIPT3_PASSTHROUGH 5
+#define FPDF_TEXTRENDERMODE_FILL 0
+#define FPDF_TEXTRENDERMODE_STROKE 1
+#define FPDF_TEXTRENDERMODE_FILL_STROKE 2
+#define FPDF_TEXTRENDERMODE_INVISIBLE 3
+#define FPDF_TEXTRENDERMODE_FILL_CLIP 4
+#define FPDF_TEXTRENDERMODE_STROKE_CLIP 5
+#define FPDF_TEXTRENDERMODE_FILL_STROKE_CLIP 6
+#define FPDF_TEXTRENDERMODE_CLIP 7
+
typedef struct FPDF_IMAGEOBJ_METADATA {
// The image width in pixels.
unsigned int width;
@@ -1116,6 +1125,14 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
FPDF_FONT font,
float font_size);
+// Experimental API.
+// Get the text rendering mode of a text object.
+//
+// text - the handle to the text object.
+//
+// Returns one of the FPDF_TEXTRENDERMODE_* flags on success, -1 on error.
+FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text);
+
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
--
2.16.4
......@@ -26,7 +26,7 @@ index fed1581..3f400c7 100644
+ if (!pImg)
+ return nullptr;
+
+ RetainPtr<CFX_DIBSource> pSource = pImg->LoadDIBSource();
+ RetainPtr<CFX_DIBBase> pSource = pImg->LoadDIBBase();
+ if (!pSource)
+ return nullptr;
+
......
......@@ -67,7 +67,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_fieldaction \
UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_filewriteadapter \
UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_helpers \
UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_memoryaccess \
UnpackedTarball/pdfium/fpdfsdk/fpdf_annot \
UnpackedTarball/pdfium/fpdfsdk/fpdf_attachment \
UnpackedTarball/pdfium/fpdfsdk/fpdf_catalog \
......@@ -240,7 +239,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fpdfapi/parser/cpdf_read_validator \
UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_charposlist \
UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_devicebuffer \
UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_dibsource \
UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_dibtransferfunc \
UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_docrenderdata \
UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_imagecacheentry \
......@@ -281,6 +279,10 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fpdfapi/parser/cpdf_cross_ref_avail \
UnpackedTarball/pdfium/core/fpdfapi/edit/cpdf_pagecontentmanager \
UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_transparency \
UnpackedTarball/pdfium/core/fpdfapi/render/cpdf_dibbase \
UnpackedTarball/pdfium/core/fpdfapi/parser/cpdf_object_stream \
UnpackedTarball/pdfium/core/fpdfapi/parser/cpdf_cross_ref_table \
UnpackedTarball/pdfium/core/fpdfapi/edit/cpdf_stringarchivestream \
))
# fpdfdoc
......@@ -331,12 +333,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
# fxcodec
$(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxcodec/codec/fx_codec \
UnpackedTarball/pdfium/core/fxcodec/codec/fx_codec_fax \
UnpackedTarball/pdfium/core/fxcodec/codec/fx_codec_flate \
UnpackedTarball/pdfium/core/fxcodec/codec/fx_codec_icc \
UnpackedTarball/pdfium/core/fxcodec/codec/fx_codec_jbig \
UnpackedTarball/pdfium/core/fxcodec/codec/fx_codec_jpeg \
UnpackedTarball/pdfium/core/fxcodec/codec/fx_codec_jpx_opj \
UnpackedTarball/pdfium/core/fxcodec/jbig2/JBig2_ArithDecoder \
UnpackedTarball/pdfium/core/fxcodec/jbig2/JBig2_ArithIntDecoder \
UnpackedTarball/pdfium/core/fxcodec/jbig2/JBig2_BitStream \
......@@ -358,6 +354,13 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxcodec/gif/cfx_gif \
UnpackedTarball/pdfium/core/fxcodec/gif/cfx_gifcontext \
UnpackedTarball/pdfium/core/fxcodec/gif/cfx_lzwdecompressor \
UnpackedTarball/pdfium/core/fxcodec/codec/cfx_codec_memory \
UnpackedTarball/pdfium/core/fxcodec/codec/ccodec_faxmodule \
UnpackedTarball/pdfium/core/fxcodec/codec/ccodec_iccmodule \
UnpackedTarball/pdfium/core/fxcodec/codec/ccodec_jbig2module \
UnpackedTarball/pdfium/core/fxcodec/codec/ccodec_jpxmodule \
UnpackedTarball/pdfium/core/fxcodec/codec/ccodec_jpegmodule \
UnpackedTarball/pdfium/core/fxcodec/codec/ccodec_flatemodule \
))
# fxcrt
......@@ -402,8 +405,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxcrt/bytestring \
UnpackedTarball/pdfium/core/fxcrt/cfx_binarybuf \
UnpackedTarball/pdfium/core/fxcrt/cfx_bitstream \
UnpackedTarball/pdfium/core/fxcrt/cfx_fileaccess_posix \
UnpackedTarball/pdfium/core/fxcrt/cfx_fileaccess_windows \
UnpackedTarball/pdfium/core/fxcrt/cfx_utf8decoder \
UnpackedTarball/pdfium/core/fxcrt/cfx_widetextbuf \
UnpackedTarball/pdfium/core/fxcrt/fx_random \
......@@ -412,6 +413,8 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxcrt/cfx_seekablemultistream \
UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssdata \
UnpackedTarball/pdfium/core/fxcrt/fx_codepage \
UnpackedTarball/pdfium/core/fxcrt/cfx_utf8encoder \
UnpackedTarball/pdfium/core/fxcrt/cfx_readonlymemorystream \
))
# fxge
......@@ -420,7 +423,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxge/dib/cfx_bitmapstorer \
UnpackedTarball/pdfium/core/fxge/dib/cfx_dibextractor \
UnpackedTarball/pdfium/core/fxge/dib/cfx_dibitmap \
UnpackedTarball/pdfium/core/fxge/dib/cfx_dibsource \
UnpackedTarball/pdfium/core/fxge/dib/cfx_filtereddib \
UnpackedTarball/pdfium/core/fxge/dib/cfx_imagerenderer \
UnpackedTarball/pdfium/core/fxge/dib/cfx_imagestretcher \
......@@ -466,6 +468,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxge/fx_ge_fontmap \
UnpackedTarball/pdfium/core/fxge/fx_ge_linux \
UnpackedTarball/pdfium/core/fxge/fx_ge_text \
UnpackedTarball/pdfium/core/fxge/dib/cfx_dibbase \
))
# javascript, build with pdf_enable_v8 disabled.
......@@ -542,6 +545,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/page_allocator \
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/spin_lock \
UnpackedTarball/pdfium/third_party/base/allocator/partition_allocator/partition_alloc \
UnpackedTarball/pdfium/third_party/base/debug/alias \
))
# skia_shared
......@@ -600,6 +604,13 @@ $(eval $(call gb_Library_add_generated_cobjects,pdfium,\
UnpackedTarball/pdfium/third_party/freetype/src/src/smooth/smooth \
UnpackedTarball/pdfium/third_party/freetype/src/src/truetype/truetype \
UnpackedTarball/pdfium/third_party/freetype/src/src/type1/type1 \
UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftdebug \
))
endif
ifneq ($(OS),WNT)
$(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxcrt/cfx_fileaccess_posix \
))
endif
......@@ -612,6 +623,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxge/win32/fx_win32_dib \
UnpackedTarball/pdfium/core/fxge/win32/fx_win32_gdipext \
UnpackedTarball/pdfium/core/fxge/win32/fx_win32_print \
UnpackedTarball/pdfium/core/fxcrt/cfx_fileaccess_windows \
))
$(eval $(call gb_Library_use_system_win32_libs,pdfium,\
......@@ -641,9 +653,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxge/android/cfpf_skiafontmgr \
UnpackedTarball/pdfium/core/fxge/android/cfx_androidfontinfo \
UnpackedTarball/pdfium/core/fxge/android/fx_android_imp \
UnpackedTarball/pdfium/core/fxge/android/cfpf_skiabufferfont \
UnpackedTarball/pdfium/core/fxge/android/cfpf_skiafilefont \
UnpackedTarball/pdfium/core/fxge/android/cfpf_skiafontdescriptor \
UnpackedTarball/pdfium/core/fxge/android/cfpf_skiapathfont \
))
endif
......
......@@ -13,20 +13,6 @@ pdfium_patches += ubsan.patch
# Fixes build on our baseline.
pdfium_patches += build.patch.1
# Adds missing editing API
# Backport of <https://pdfium-review.googlesource.com/35931>.
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
# Backport of <https://pdfium-review.googlesource.com/37890>.
pdfium_patches += 0001-Add-FPDFFormObj_GetObject-API.patch.1
# Backport of <https://pdfium-review.googlesource.com/38870>.
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
$(eval $(call gb_UnpackedTarball_UnpackedTarball,pdfium))
......@@ -51,7 +37,8 @@ $(eval $(call gb_UnpackedTarball_set_post_action,pdfium,\
mv third_party/base/allocator/partition_allocator/address_space_randomization.cc third_party/base/allocator/partition_allocator/address_space_randomization.cpp && \
mv third_party/base/allocator/partition_allocator/page_allocator.cc third_party/base/allocator/partition_allocator/page_allocator.cpp && \
mv third_party/base/allocator/partition_allocator/partition_alloc.cc third_party/base/allocator/partition_allocator/partition_alloc.cpp && \
mv third_party/base/allocator/partition_allocator/spin_lock.cc third_party/base/allocator/partition_allocator/spin_lock.cpp \
mv third_party/base/allocator/partition_allocator/spin_lock.cc third_party/base/allocator/partition_allocator/spin_lock.cpp && \
mv third_party/base/debug/alias.cc third_party/base/debug/alias.cpp \
))
# vim: set noet sw=4 ts=4:
......@@ -125,12 +125,12 @@ diff --git a/core/fpdfdoc/cpdf_dest.h b/core/fpdfdoc/cpdf_dest.h
index 7f4eb86c0..5e227f86e 100644
--- a/core/fpdfdoc/cpdf_dest.h
+++ b/core/fpdfdoc/cpdf_dest.h
@@ -46,7 +46,7 @@ class CPDF_Dest {
@@ -41,7 +41,7 @@
float* pZoom) const;
private:
- UnownedPtr<const CPDF_Array> const m_pObj;
+ UnownedPtr<const CPDF_Array> m_pObj;
- UnownedPtr<const CPDF_Array> const m_pArray;
+ UnownedPtr<const CPDF_Array> m_pArray;
};
#endif // CORE_FPDFDOC_CPDF_DEST_H_
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment