diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-04-15 10:51:39 -0400 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-06-01 08:59:19 +0200 |
commit | af65cce147b549e9eb5a0451d0f7e81998721ac8 (patch) | |
tree | 7f7e04d8ae247fe42505d389e021c959196acf4c /external | |
parent | 8a5a1bc29e141af9febaedbf301d01e611b03d59 (diff) |
svx: support color text for imported PDFs
Change-Id: I01cba9456b37bd7a63c823bbe332d686f7ede389
Diffstat (limited to 'external')
-rw-r--r-- | external/pdfium/edit.patch.1 | 134 |
1 files changed, 112 insertions, 22 deletions
diff --git a/external/pdfium/edit.patch.1 b/external/pdfium/edit.patch.1 index 96e0fa4f9725..02e0b44c3e87 100644 --- a/external/pdfium/edit.patch.1 +++ b/external/pdfium/edit.patch.1 @@ -1,12 +1,73 @@ +diff --git a/core/fpdfapi/page/cpdf_colorstate.cpp b/core/fpdfapi/page/cpdf_colorstate.cpp +index 693fcf1..d3e1202 100644 +--- a/core/fpdfapi/page/cpdf_colorstate.cpp ++++ b/core/fpdfapi/page/cpdf_colorstate.cpp +@@ -74,6 +74,8 @@ void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS, + uint32_t nValues) { + ColorData* pData = m_Ref.GetPrivateCopy(); + SetColor(pData->m_FillColor, pData->m_FillRGB, pCS, pValue, nValues); ++ if (pData->m_FillRGB != 0 && pData->m_FillRGB != 0xFFFFFFFF) ++ fprintf(stderr, "COLOR FILL!!!!> %x\n", pData->m_FillRGB); + } + + void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS, +@@ -81,6 +83,8 @@ void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS, + uint32_t nValues) { + ColorData* pData = m_Ref.GetPrivateCopy(); + SetColor(pData->m_StrokeColor, pData->m_StrokeRGB, pCS, pValue, nValues); ++ if (pData->m_StrokeRGB != 0 && pData->m_StrokeRGB != 0xFFFFFFFF) ++ fprintf(stderr, "COLOR STROkE!!!!> %x\n", pData->m_StrokeRGB); + } + + void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern, +@@ -99,6 +103,8 @@ void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern, + } + } + pData->m_FillRGB = ret ? FXSYS_RGB(R, G, B) : 0xFFFFFFFF; ++ if (pData->m_FillRGB != 0 && pData->m_FillRGB != 0xFFFFFFFF) ++ fprintf(stderr, "COLOR FILL!!!!> %x\n", pData->m_FillRGB); + } + + void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern, +@@ -118,13 +124,15 @@ void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern, + } + pData->m_StrokeRGB = + pData->m_StrokeColor.GetRGB(&R, &G, &B) ? FXSYS_RGB(R, G, B) : 0xFFFFFFFF; ++ if (pData->m_StrokeRGB != 0 && pData->m_StrokeRGB != 0xFFFFFFFF) ++ fprintf(stderr, "COLOR STROkE!!!!> %x\n", pData->m_StrokeRGB); + } + + void CPDF_ColorState::SetColor(CPDF_Color& color, + uint32_t& rgb, + CPDF_ColorSpace* pCS, + float* pValue, +- uint32_t nValues) { ++ uint32_t nValues) const { + if (pCS) + color.SetColorSpace(pCS); + else if (color.IsNull()) +diff --git a/core/fpdfapi/page/cpdf_colorstate.h b/core/fpdfapi/page/cpdf_colorstate.h +index 9619051..dbe9c47 100644 +--- a/core/fpdfapi/page/cpdf_colorstate.h ++++ b/core/fpdfapi/page/cpdf_colorstate.h +@@ -64,7 +64,7 @@ class CPDF_ColorState { + uint32_t& rgb, + CPDF_ColorSpace* pCS, + float* pValue, +- uint32_t nValues); ++ uint32_t nValues) const; + + SharedCopyOnWrite<ColorData> m_Ref; + }; diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp -index 3b5a740..58ef90a 100644 +index 3b5a740..416d82d 100644 --- a/core/fpdfapi/page/cpdf_imageobject.cpp +++ b/core/fpdfapi/page/cpdf_imageobject.cpp @@ -43,6 +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) { @@ -62,14 +123,14 @@ index 0a01ae0..6947e3a 100644 DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size, &text_matrix, bFill, bStroke); diff --git a/core/fxge/cfx_pathdata.cpp b/core/fxge/cfx_pathdata.cpp -index 4ac5cf6..28ea81f 100644 +index 4ac5cf6..4286de4 100644 --- a/core/fxge/cfx_pathdata.cpp +++ b/core/fxge/cfx_pathdata.cpp @@ -199,6 +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)); } @@ -77,7 +138,7 @@ index 4ac5cf6..28ea81f 100644 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); } @@ -113,7 +174,7 @@ index 0d7ba56..37bdf99 100644 FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object, void* buffer, diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp -index ca2cf3f..e7d633f 100644 +index ca2cf3f..f86201d 100644 --- a/fpdfsdk/fpdfeditpage.cpp +++ b/fpdfsdk/fpdfeditpage.cpp @@ -11,12 +11,14 @@ @@ -131,7 +192,7 @@ index ca2cf3f..e7d633f 100644 #include "core/fpdfapi/page/cpdf_shadingobject.h" #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_document.h" -@@ -363,3 +365,128 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject, +@@ -363,3 +365,157 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject, *top = bbox.top; return true; } @@ -242,22 +303,51 @@ index ca2cf3f..e7d633f 100644 +} + +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/fpdfsdk/fpdfeditpath.cpp b/fpdfsdk/fpdfeditpath.cpp @@ -409,7 +499,7 @@ index 77c2315..db3e734 100644 CPDF_PageObject* CPDFPageObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object); diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h -index 54735a3..c86b638 100644 +index 54735a3..c0231c2 100644 --- a/public/fpdf_edit.h +++ b/public/fpdf_edit.h @@ -520,6 +520,15 @@ FPDFPath_GetStrokeColor(FPDF_PAGEOBJECT path, @@ -534,11 +624,11 @@ index 54735a3..c86b638 100644 +// +// 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" |