From 73abef117eda826b17f85971de271a01589348f5 Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Tue, 10 Apr 2018 07:45:06 -0400 Subject: svx: support PDF text color Change-Id: I7fa675c6560504e4fc7917e19cac3cceb2700d8e (cherry picked from commit 3c02b52fdad9c5a34d4bfb7623e04c4e85875a89) --- .../pdfium/0004-svx-support-PDF-text-color.patch.2 | 130 +++++++++++++++++++++ external/pdfium/UnpackedTarball_pdfium.mk | 1 + 2 files changed, 131 insertions(+) create mode 100644 external/pdfium/0004-svx-support-PDF-text-color.patch.2 (limited to 'external/pdfium') 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 +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(handle); + } + ++inline CPDF_TextObject* CPDFTextObjectFromFPDFPageObject( ++ FPDF_PAGEOBJECT page_object) { ++ return reinterpret_cast(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(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(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(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(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(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( ++ (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)) -- cgit