From c08dc39850188d96ad81f5800c7a51d2663eeb44 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 24 Jul 2017 08:57:35 -0400 Subject: Remove fx_edit.h This CL moves GetPDFWordString to be a method on CFX_Edit. The FX_EDIT_ISLATINWORD define is moved into fx_edit.h. CFWL_Edit::FX_EDIT_ISLATINWORD is renamed to FxEditIsLatinWord to make less confusing with the define. Change-Id: I47d12d41447b268894a1d0376ac4b2bdb409e2df Reviewed-on: https://pdfium-review.googlesource.com/8531 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- fpdfsdk/fxedit/fxet_edit.cpp | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'fpdfsdk/fxedit/fxet_edit.cpp') diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp index 96868d03c1..6c4595408f 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp @@ -27,7 +27,6 @@ #include "core/fxge/cfx_pathdata.h" #include "core/fxge/cfx_renderdevice.h" #include "fpdfsdk/cfx_systemhandler.h" -#include "fpdfsdk/fxedit/fx_edit.h" #include "fpdfsdk/pdfwindow/cpwl_edit.h" #include "fpdfsdk/pdfwindow/cpwl_edit_ctrl.h" #include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h" @@ -586,14 +585,15 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, crOldFill = crCurFill; } - sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, - SubWord); + sTextBuf << pEdit->GetPDFWordString(word.nFontIndex, word.Word, + SubWord); } else { DrawTextString( - pDevice, CFX_PointF(word.ptWord.x + ptOffset.x, - word.ptWord.y + ptOffset.y), + pDevice, + CFX_PointF(word.ptWord.x + ptOffset.x, + word.ptWord.y + ptOffset.y), pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device, - GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord), + pEdit->GetPDFWordString(word.nFontIndex, word.Word, SubWord), crCurFill, nHorzScale); } oldplace = place; @@ -1937,6 +1937,30 @@ void CFX_Edit::AddEditUndoItem( m_Undo.AddItem(std::move(pEditUndoItem)); } +CFX_ByteString CFX_Edit::GetPDFWordString(int32_t nFontIndex, + uint16_t Word, + uint16_t SubWord) { + IPVT_FontMap* pFontMap = GetFontMap(); + CPDF_Font* pPDFFont = pFontMap->GetPDFFont(nFontIndex); + if (!pPDFFont) + return CFX_ByteString(); + + CFX_ByteString sWord; + if (SubWord > 0) { + Word = SubWord; + } else { + uint32_t dwCharCode = pPDFFont->IsUnicodeCompatible() + ? pPDFFont->CharCodeFromUnicode(Word) + : pFontMap->CharCodeFromUnicode(nFontIndex, Word); + if (dwCharCode > 0) { + pPDFFont->AppendChar(&sWord, dwCharCode); + return sWord; + } + } + pPDFFont->AppendChar(&sWord, Word); + return sWord; +} + CFX_Edit_LineRectArray::CFX_Edit_LineRectArray() {} CFX_Edit_LineRectArray::~CFX_Edit_LineRectArray() {} -- cgit v1.2.3