summaryrefslogtreecommitdiff
path: root/fpdfsdk/fxedit/fxet_edit.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2017-01-04 10:09:45 -0800
committerCommit bot <commit-bot@chromium.org>2017-01-04 10:09:45 -0800
commit6745f96fab41e2b46f57a3717b034a4064c0de02 (patch)
treead3d8df2b200d99c6c32ea0ddd7e0ce53118c641 /fpdfsdk/fxedit/fxet_edit.cpp
parentfff400a5df032c2203eef9f76a5dbb164672df3d (diff)
downloadpdfium-6745f96fab41e2b46f57a3717b034a4064c0de02.tar.xz
Remove CFX_ArrayTemplate, use unique_ptr in fpdfsdk/pdfwindow
Review-Url: https://codereview.chromium.org/2594153003
Diffstat (limited to 'fpdfsdk/fxedit/fxet_edit.cpp')
-rw-r--r--fpdfsdk/fxedit/fxet_edit.cpp95
1 files changed, 45 insertions, 50 deletions
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<CPDF_TextObject*>& 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<CPDF_TextObject*>* 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()));
}
}