From 6745f96fab41e2b46f57a3717b034a4064c0de02 Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 4 Jan 2017 10:09:45 -0800 Subject: Remove CFX_ArrayTemplate, use unique_ptr in fpdfsdk/pdfwindow Review-Url: https://codereview.chromium.org/2594153003 --- fpdfsdk/fxedit/fxet_edit.cpp | 95 +++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 50 deletions(-) (limited to 'fpdfsdk/fxedit/fxet_edit.cpp') diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp index ececa0b9a3..aa77e9fa5b 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp @@ -936,65 +936,60 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, } // static -void CFX_Edit::GeneratePageObjects( - CPDF_PageObjectHolder* pObjectHolder, - CFX_Edit* pEdit, - const CFX_FloatPoint& ptOffset, - const CPVT_WordRange* pRange, - FX_COLORREF crText, - CFX_ArrayTemplate& ObjArray) { - FX_FLOAT fFontSize = pEdit->GetFontSize(); +void CFX_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, + CFX_Edit* pEdit, + const CFX_FloatPoint& ptOffset, + const CPVT_WordRange* pRange, + FX_COLORREF crText, + std::vector* ObjArray) { + ObjArray->clear(); + + IPVT_FontMap* pFontMap = pEdit->GetFontMap(); + if (!pFontMap) + return; + FX_FLOAT fFontSize = pEdit->GetFontSize(); int32_t nOldFontIndex = -1; - CFX_ByteTextBuf sTextBuf; + CPVT_WordPlace oldplace; CFX_FloatPoint ptBT(0.0f, 0.0f); - - ObjArray.RemoveAll(); - CFX_Edit_Iterator* pIterator = pEdit->GetIterator(); - if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) { - if (pRange) - pIterator->SetAt(pRange->BeginPos); - else - pIterator->SetAt(0); - - CPVT_WordPlace oldplace; - - while (pIterator->NextWord()) { - CPVT_WordPlace place = pIterator->GetAt(); - if (pRange && place.WordCmp(pRange->EndPos) > 0) - break; - - CPVT_Word word; - if (pIterator->GetWord(word)) { - if (place.LineCmp(oldplace) != 0 || nOldFontIndex != word.nFontIndex) { - if (sTextBuf.GetLength() > 0) { - ObjArray.Add(AddTextObjToPageObjects( - pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), - fFontSize, 0.0f, 100, - CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), - sTextBuf.MakeString())); - - sTextBuf.Clear(); - } + if (pRange) + pIterator->SetAt(pRange->BeginPos); + else + pIterator->SetAt(0); - ptBT = word.ptWord; - nOldFontIndex = word.nFontIndex; - } + while (pIterator->NextWord()) { + CPVT_WordPlace place = pIterator->GetAt(); + if (pRange && place.WordCmp(pRange->EndPos) > 0) + break; - sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0) - .AsStringC(); - oldplace = place; + CPVT_Word word; + if (!pIterator->GetWord(word)) + continue; + + if (place.LineCmp(oldplace) != 0 || nOldFontIndex != word.nFontIndex) { + if (sTextBuf.GetLength() > 0) { + ObjArray->push_back(AddTextObjToPageObjects( + pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), + fFontSize, 0.0f, 100, + CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), + sTextBuf.MakeString())); + + sTextBuf.Clear(); } + ptBT = word.ptWord; + nOldFontIndex = word.nFontIndex; } - - if (sTextBuf.GetLength() > 0) { - ObjArray.Add(AddTextObjToPageObjects( - pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, - 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), - sTextBuf.MakeString())); - } + sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0) + .AsStringC(); + oldplace = place; + } + if (sTextBuf.GetLength() > 0) { + ObjArray->push_back(AddTextObjToPageObjects( + pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, + 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y), + sTextBuf.MakeString())); } } -- cgit v1.2.3