summaryrefslogtreecommitdiffstats
path: root/external/pdfium
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-04-10 07:45:06 -0400
committerJan Holesovsky <kendy@collabora.com>2018-06-07 10:45:23 +0200
commit73abef117eda826b17f85971de271a01589348f5 (patch)
tree8651c3988b515469da68bb4401b288c7233f6de2 /external/pdfium
parentsvx: more informative logging (diff)
downloadcore-73abef117eda826b17f85971de271a01589348f5.tar.gz
core-73abef117eda826b17f85971de271a01589348f5.zip
svx: support PDF text color
Change-Id: I7fa675c6560504e4fc7917e19cac3cceb2700d8e (cherry picked from commit 3c02b52fdad9c5a34d4bfb7623e04c4e85875a89)
Diffstat (limited to 'external/pdfium')
-rw-r--r--external/pdfium/0004-svx-support-PDF-text-color.patch.2130
-rw-r--r--external/pdfium/UnpackedTarball_pdfium.mk1
2 files changed, 131 insertions, 0 deletions
diff --git a/external/pdfium/0004-svx-support-PDF-text-color.patch.2 b/external/pdfium/0004-svx-support-PDF-text-color.patch.2
new file mode 100644
index 000000000000..5bf196cdfefa
--- /dev/null
+++ b/external/pdfium/0004-svx-support-PDF-text-color.patch.2
@@ -0,0 +1,130 @@
+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_editpage.cpp b/pdfium/fpdfsdk/fpdf_editpage.cpp
+index 3244943..f8e2418 100644
+--- a/pdfium/fpdfsdk/fpdf_editpage.cpp
++++ b/pdfium/fpdfsdk/fpdf_editpage.cpp
+@@ -633,7 +633,7 @@ FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object)
+ if (!text_object)
+ return 0;
+
+- CPDF_TextObject* pTxtObj = static_cast<CPDF_TextObject*>(text_object);
++ CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
+ return pTxtObj->CountChars();
+ }
+
+@@ -643,7 +643,7 @@ FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object)
+ if (!text_object)
+ return 0;
+
+- CPDF_TextObject* pTxtObj = static_cast<CPDF_TextObject*>(text_object);
++ CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
+ return pTxtObj->GetFontSize();
+ }
+
+@@ -656,7 +656,7 @@ FPDFTextObj_GetMatrix(FPDF_PAGEOBJECT text_object,
+ if (!text_object)
+ return;
+
+- CPDF_TextObject* pTxtObj = static_cast<CPDF_TextObject*>(text_object);
++ CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
+ const CFX_Matrix& matrix = pTxtObj->GetTextMatrix();
+ *a = matrix.a;
+ *b = matrix.b;
+@@ -670,7 +670,7 @@ FPDFTextObj_GetUnicode(FPDF_PAGEOBJECT text_object, int index)
+ if (!text_object || index < 0)
+ return 0;
+
+- CPDF_TextObject* pTxtObj = static_cast<CPDF_TextObject*>(text_object);
++ CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
+ if (index > pTxtObj->CountChars())
+ return 0;
+
+@@ -686,7 +686,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFTextObj_GetText(FPDF_PAGEOBJECT text_object,
+ if (!text_object || char_start < 0 || char_count < 0 || !result)
+ return 0;
+
+- CPDF_TextObject* pTxtObj = static_cast<CPDF_TextObject*>(text_object);
++ CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
+ int char_available = pTxtObj->CountChars() - char_start;
+ if (char_available <= 0)
+ return 0;
+@@ -726,3 +726,23 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFTextObj_GetText(FPDF_PAGEOBJECT text_object,
+ memcpy(result, byte_str.GetBuffer(byte_str_len), byte_str_len);
+ return ret_count;
+ }
++
++FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
++FPDFTextObj_GetStrokeColor(FPDF_PAGEOBJECT text_object,
++ unsigned int* R,
++ unsigned int* G,
++ unsigned int* B,
++ unsigned int* A)
++{
++ CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
++ if (!pTxtObj || !R || !G || !B || !A)
++ return false;
++
++ const uint32_t strokeRGB = pTxtObj->m_ColorState.GetStrokeRGB();
++ *R = FXSYS_GetRValue(strokeRGB);
++ *G = FXSYS_GetGValue(strokeRGB);
++ *B = FXSYS_GetBValue(strokeRGB);
++ *A = static_cast<unsigned int>(
++ (pTxtObj->m_GeneralState.GetStrokeAlpha() * 255.f) + 0.5f);
++ return true;
++}
+diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h
+index 602849f..fa9902e 100644
+--- a/pdfium/public/fpdf_edit.h
++++ b/pdfium/public/fpdf_edit.h
+@@ -1022,6 +1022,22 @@ FPDFTextObj_GetText(FPDF_PAGEOBJECT text_object,
+ int char_count,
+ unsigned short* result);
+
++// Get the stroke RGBA of a text. Range of values: 0 - 255.
++//
++// path - the handle to the path object.
++// R - the red component of the path stroke color.
++// G - the green component of the path stroke color.
++// B - the blue component of the path stroke color.
++// A - the stroke alpha of the path.
++//
++// Returns TRUE on success.
++FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
++FPDFTextObj_GetStrokeColor(FPDF_PAGEOBJECT text_object,
++ unsigned int* R,
++ unsigned int* G,
++ unsigned int* B,
++ unsigned int* A);
++
+ #ifdef __cplusplus
+ } // extern "C"
+ #endif // __cplusplus
+--
+2.16.3
+
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk
index 7da652c4532c..b7dc4d2fa5e3 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -17,6 +17,7 @@ pdfium_patches += build.patch.1
pdfium_patches += 0001-svx-import-PDF-text-using-PDFium.patch.2
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
$(eval $(call gb_UnpackedTarball_UnpackedTarball,pdfium))