From f701ff3ce04a4e7e757a9f3ee62b4967749455dd Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Tue, 5 Jun 2018 14:27:55 +0200 Subject: [PATCH 14/14] svx: update PDFium patch and code --- pdfium/fpdfsdk/cpdfsdk_helpers.h | 2 ++ pdfium/fpdfsdk/fpdf_editimg.cpp | 2 +- pdfium/fpdfsdk/fpdf_editpage.cpp | 19 ++++++++++++------- pdfium/public/fpdf_edit.h | 16 ++++++++-------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/pdfium/fpdfsdk/cpdfsdk_helpers.h b/pdfium/fpdfsdk/cpdfsdk_helpers.h index 477bb74..c907ad8 100644 --- a/pdfium/fpdfsdk/cpdfsdk_helpers.h +++ b/pdfium/fpdfsdk/cpdfsdk_helpers.h @@ -40,6 +40,8 @@ class CPDF_TextPage; class CPDF_TextPageFind; class IPDFSDK_PauseAdapter; class FX_PATHPOINT; +class CPDF_TextObject; +class CPDF_FormObject; #ifdef PDF_ENABLE_XFA class CPDFXFA_Context; diff --git a/pdfium/fpdfsdk/fpdf_editimg.cpp b/pdfium/fpdfsdk/fpdf_editimg.cpp index 3f400c7..968b84a 100644 --- a/pdfium/fpdfsdk/fpdf_editimg.cpp +++ b/pdfium/fpdfsdk/fpdf_editimg.cpp @@ -203,7 +203,7 @@ FPDFImageObj_GetBitmapBgra(FPDF_PAGEOBJECT image_object) { RetainPtr pBitmap; pBitmap = pSource->CloneConvert(FXDIB_Argb); - return pBitmap.Leak(); + return FPDFBitmapFromCFXDIBitmap(pBitmap.Leak()); } FPDF_EXPORT unsigned long FPDF_CALLCONV diff --git a/pdfium/fpdfsdk/fpdf_editpage.cpp b/pdfium/fpdfsdk/fpdf_editpage.cpp index 29c8b01..a52e1a9 100644 --- a/pdfium/fpdfsdk/fpdf_editpage.cpp +++ b/pdfium/fpdfsdk/fpdf_editpage.cpp @@ -718,7 +718,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFTextObj_GetText(FPDF_PAGEOBJECT text_object, int ret_count = byte_str_len / sizeof(unsigned short); ASSERT(ret_count <= char_count + 1); // +1 to account for the NUL terminator. - memcpy(result, byte_str.GetBuffer(byte_str_len), byte_str_len); + memcpy(result, byte_str.GetBuffer(byte_str_len).data(), byte_str_len); return ret_count; } @@ -758,7 +758,7 @@ FPDFTextObj_GetTextProcessed(FPDF_PAGEOBJECT text_object, int ret_count = byte_str_len / kBytesPerCharacter; ASSERT(ret_count <= char_count + 1); // +1 to account for the NUL terminator. - memcpy(result, byte_str.GetBuffer(byte_str_len), byte_str_len); + memcpy(result, byte_str.GetBuffer(byte_str_len).data(), byte_str_len); return ret_count; } @@ -801,10 +801,15 @@ FPDFTextObj_GetColor(FPDF_PAGEOBJECT text_object, 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); + const CPDF_Color* pColor = bStroke ? pTxtObj->m_ColorState.GetStrokeColor() : pTxtObj->m_ColorState.GetFillColor(); + if (pColor == nullptr) + return false; + + int r, g, b; + pColor->GetRGB(&r, &g, &b); + *R = r; + *G = g; + *B = b; *A = static_cast( (pTxtObj->m_GeneralState.GetStrokeAlpha() * 255.f) + 0.5f); @@ -834,7 +839,7 @@ FPDFFormObj_GetSubObject(FPDF_PAGEOBJECT form_object, int index) const CFX_Matrix& matrix = pFrmObj->form_matrix(); const CPDF_PageObjectList* pObjectList = pFrmObj->form()->GetPageObjectList(); if (pObjectList) - return pObjectList->GetPageObjectByIndex(index); + return FPDFPageObjectFromCPDFPageObject(pObjectList->GetPageObjectByIndex(index)); } return nullptr; diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h index e14b2a5..4351649 100644 --- a/pdfium/public/fpdf_edit.h +++ b/pdfium/public/fpdf_edit.h @@ -660,32 +660,32 @@ FPDFPageObj_GetStrokeColor(FPDF_PAGEOBJECT page_object, unsigned int* B, unsigned int* A); -// Set the stroke width of a path. +// Get the stroke width of a path. // // path - the handle to the path object. // width - the width of the stroke. // // Returns TRUE on success FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV -FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width); +FPDFPath_GetStrokeWidth(FPDF_PAGEOBJECT path, float* width); -// Set the stroke width of a page object. +// Set the stroke width of a path. // -// path - the handle to the page object. +// path - the handle to the path object. // width - the width of the stroke. // // Returns TRUE on success FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV -FPDFPageObj_SetStrokeWidth(FPDF_PAGEOBJECT page_object, float width); +FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width); -// Get the stroke width of a path. +// Set the stroke width of a page object. // -// path - the handle to the path object. +// path - the handle to the page object. // width - the width of the stroke. // // Returns TRUE on success FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV -FPDFPath_GetStrokeWidth(FPDF_PAGEOBJECT path, float* width); +FPDFPageObj_SetStrokeWidth(FPDF_PAGEOBJECT page_object, float width); // Set the line join of |page_object|. // -- 2.16.3