summaryrefslogtreecommitdiff
path: root/external/pdfium
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-04-15 10:51:39 -0400
committerJan Holesovsky <kendy@collabora.com>2018-06-07 10:45:26 +0200
commit4a65225b304b30f6e7cbfe777067f231cac1eebc (patch)
tree4df41dbfd81d215b463ef83c0fec5247baf2a8bd /external/pdfium
parent95b0ac87567bb80d80be9904e1fc4e5f0da08a10 (diff)
svx: support color text for imported PDFs
Change-Id: I01cba9456b37bd7a63c823bbe332d686f7ede389 (cherry picked from commit 26e37f98b08ce59a0feb93a8d2a8fbc982cfc103)
Diffstat (limited to 'external/pdfium')
-rw-r--r--external/pdfium/0009-svx-support-color-text-for-imported-PDFs.patch.2135
-rw-r--r--external/pdfium/UnpackedTarball_pdfium.mk1
2 files changed, 136 insertions, 0 deletions
diff --git a/external/pdfium/0009-svx-support-color-text-for-imported-PDFs.patch.2 b/external/pdfium/0009-svx-support-color-text-for-imported-PDFs.patch.2
new file mode 100644
index 000000000000..25bba8d52cbb
--- /dev/null
+++ b/external/pdfium/0009-svx-support-color-text-for-imported-PDFs.patch.2
@@ -0,0 +1,135 @@
+From 32ec9efddb8e1706085478fd8434dd2860840345 Mon Sep 17 00:00:00 2001
+From: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
+Date: Tue, 5 Jun 2018 11:33:56 +0200
+Subject: [PATCH 09/14] svx: support color text for imported PDFs
+
+---
+ pdfium/core/fpdfapi/page/cpdf_imageobject.cpp | 2 +-
+ pdfium/core/fxge/cfx_pathdata.cpp | 4 +--
+ pdfium/fpdfsdk/fpdf_editpage.cpp | 47 ++++++++++++++++++++++-----
+ pdfium/public/fpdf_edit.h | 10 +++---
+ 4 files changed, 46 insertions(+), 17 deletions(-)
+
+diff --git a/pdfium/core/fpdfapi/page/cpdf_imageobject.cpp b/pdfium/core/fpdfapi/page/cpdf_imageobject.cpp
+index 58ef90a..416d82d 100644
+--- a/pdfium/core/fpdfapi/page/cpdf_imageobject.cpp
++++ b/pdfium/core/fpdfapi/page/cpdf_imageobject.cpp
+@@ -43,7 +43,7 @@ const CPDF_ImageObject* CPDF_ImageObject::AsImage() const {
+ void CPDF_ImageObject::CalcBoundingBox() {
+ std::tie(m_Left, m_Right, m_Top, m_Bottom) =
+ m_Matrix.TransformRect(0.f, 1.f, 1.f, 0.f);
+- fprintf(stderr, "Image BB: %f, %f, %f, %f\n", m_Left, m_Right, m_Top, m_Bottom);
++ // fprintf(stderr, "Image BB: %f, %f, %f, %f\n", m_Left, m_Right, m_Top, m_Bottom);
+ }
+
+ void CPDF_ImageObject::SetImage(const RetainPtr<CPDF_Image>& pImage) {
+diff --git a/pdfium/core/fxge/cfx_pathdata.cpp b/pdfium/core/fxge/cfx_pathdata.cpp
+index a483edf..13e2cdb 100644
+--- a/pdfium/core/fxge/cfx_pathdata.cpp
++++ b/pdfium/core/fxge/cfx_pathdata.cpp
+@@ -199,7 +199,7 @@ void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) {
+ void CFX_PathData::AppendPoint(const CFX_PointF& point,
+ FXPT_TYPE type,
+ bool closeFigure) {
+- fprintf(stderr, "Append: %f, %f (%s)\n", point.x, point.y, closeFigure ? "CLOSE" : "OPEN");
++// fprintf(stderr, "Append: %f, %f (%s)\n", point.x, point.y, closeFigure ? "CLOSE" : "OPEN");
+ m_Points.push_back(FX_PATHPOINT(point, type, closeFigure));
+ }
+
+@@ -295,7 +295,7 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(float line_width,
+ void CFX_PathData::Transform(const CFX_Matrix* pMatrix) {
+ if (!pMatrix)
+ return;
+- fprintf(stderr, "XForm: %f, %f %f, %f, %f, %f\n", pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, pMatrix->e, pMatrix->f);
++// fprintf(stderr, "XForm: %f, %f %f, %f, %f, %f\n", pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, pMatrix->e, pMatrix->f);
+ for (auto& point : m_Points)
+ point.m_Point = pMatrix->Transform(point.m_Point);
+ }
+diff --git a/pdfium/fpdfsdk/fpdf_editpage.cpp b/pdfium/fpdfsdk/fpdf_editpage.cpp
+index 2249e8e..9c353a4 100644
+--- a/pdfium/fpdfsdk/fpdf_editpage.cpp
++++ b/pdfium/fpdfsdk/fpdf_editpage.cpp
+@@ -733,21 +733,50 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFTextObj_GetText(FPDF_PAGEOBJECT text_object,
+ }
+
+ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
+-FPDFTextObj_GetStrokeColor(FPDF_PAGEOBJECT text_object,
+- unsigned int* R,
+- unsigned int* G,
+- unsigned int* B,
+- unsigned int* A)
++FPDFTextObj_GetColor(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);
++ bool bFill = false;
++ bool bStroke = false;
++ CPDF_Font* pFont = pTxtObj->m_TextState.GetFont();
++ const TextRenderingMode text_render_mode = pTxtObj->m_TextState.GetTextMode();
++ switch (text_render_mode)
++ {
++ case TextRenderingMode::MODE_FILL:
++ case TextRenderingMode::MODE_FILL_CLIP:
++ bFill = true;
++ break;
++ case TextRenderingMode::MODE_STROKE:
++ case TextRenderingMode::MODE_STROKE_CLIP:
++ if (pFont->GetFace())
++ bStroke = true;
++ else
++ bFill = true;
++ break;
++ case TextRenderingMode::MODE_FILL_STROKE:
++ case TextRenderingMode::MODE_FILL_STROKE_CLIP:
++ bFill = true;
++ if (pFont->GetFace())
++ bStroke = true;
++ break;
++ case TextRenderingMode::MODE_INVISIBLE:
++ case TextRenderingMode::MODE_CLIP:
++ return false;
++ }
++
++ const uint32_t RGB = bStroke ? pTxtObj->m_ColorState.GetStrokeRGB() : pTxtObj->m_ColorState.GetFillRGB();
++ *R = FXSYS_GetRValue(RGB);
++ *G = FXSYS_GetGValue(RGB);
++ *B = FXSYS_GetBValue(RGB);
+ *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 fc906f4..4264ccd 100644
+--- a/pdfium/public/fpdf_edit.h
++++ b/pdfium/public/fpdf_edit.h
+@@ -1075,11 +1075,11 @@ FPDFTextObj_GetText(FPDF_PAGEOBJECT text_object,
+ //
+ // 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);
++FPDFTextObj_GetColor(FPDF_PAGEOBJECT text_object,
++ unsigned int* R,
++ unsigned int* G,
++ unsigned int* B,
++ unsigned int* A);
+
+ #ifdef __cplusplus
+ } // extern "C"
+--
+2.16.3
+
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk
index 979df64d03c4..04a2f70d3204 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -22,6 +22,7 @@ pdfium_patches += 0005-svx-support-Paths-in-PDFs-while-importing.patch.2
pdfium_patches += 0006-svx-improve-path-importing-from-PDF.patch.2
pdfium_patches += 0007-svx-improved-text-importing-from-PDF.patch.2
pdfium_patches += 0008-svx-correct-the-positioning-of-PDF-Paths-and-the-str.patch.2
+pdfium_patches += 0009-svx-support-color-text-for-imported-PDFs.patch.2
$(eval $(call gb_UnpackedTarball_UnpackedTarball,pdfium))