Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(775)

Unified Diff: core/fpdfdoc/cpvt_generateap.cpp

Issue 1967963002: CPDF_VariableText::GetIterator() never returns NULL. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Fix more nits in CFX_Edit Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfdoc/cpdf_variabletext.cpp ('k') | core/fpdfdoc/include/cpdf_variabletext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/cpvt_generateap.cpp
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index 5ec9513e849e184dc135e265f0af98d124632388..7fcd90969e85019f2a2590d7c81645a225f634d3 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -507,76 +507,73 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
CFX_ByteTextBuf sEditStream, sLineStream, sWords;
CFX_FloatPoint ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f);
int32_t nCurFontIndex = -1;
- if (pIterator) {
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (bContinuous) {
- if (place.LineCmp(oldplace) != 0) {
- if (sWords.GetSize() > 0) {
- sLineStream << GetWordRenderString(sWords.AsStringC());
- sEditStream << sLineStream;
- sLineStream.Clear();
- sWords.Clear();
- }
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
- word.ptWord.y + ptOffset.y);
- } else {
- CPVT_Line line;
- pIterator->GetLine(line);
- ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x,
- line.ptLine.y + ptOffset.y);
- }
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
- sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
- << " Td\n";
- ptOld = ptNew;
- }
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (bContinuous) {
+ if (place.LineCmp(oldplace) != 0) {
+ if (sWords.GetSize() > 0) {
+ sLineStream << GetWordRenderString(sWords.AsStringC());
+ sEditStream << sLineStream;
+ sLineStream.Clear();
+ sWords.Clear();
}
CPVT_Word word;
if (pIterator->GetWord(word)) {
- if (word.nFontIndex != nCurFontIndex) {
- if (sWords.GetSize() > 0) {
- sLineStream << GetWordRenderString(sWords.AsStringC());
- sWords.Clear();
- }
- sLineStream << GetFontSetString(pFontMap, word.nFontIndex,
- word.fFontSize);
- nCurFontIndex = word.nFontIndex;
- }
- sWords << GetPDFWordString(pFontMap, nCurFontIndex, word.Word,
- SubWord);
- }
- oldplace = place;
- } else {
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
word.ptWord.y + ptOffset.y);
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
- sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
- << " Td\n";
- ptOld = ptNew;
- }
- if (word.nFontIndex != nCurFontIndex) {
- sEditStream << GetFontSetString(pFontMap, word.nFontIndex,
- word.fFontSize);
- nCurFontIndex = word.nFontIndex;
+ } else {
+ CPVT_Line line;
+ pIterator->GetLine(line);
+ ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x,
+ line.ptLine.y + ptOffset.y);
+ }
+ if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
+ sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
+ << " Td\n";
+ ptOld = ptNew;
+ }
+ }
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ if (word.nFontIndex != nCurFontIndex) {
+ if (sWords.GetSize() > 0) {
+ sLineStream << GetWordRenderString(sWords.AsStringC());
+ sWords.Clear();
}
- sEditStream << GetWordRenderString(
- GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord));
+ sLineStream << GetFontSetString(pFontMap, word.nFontIndex,
+ word.fFontSize);
+ nCurFontIndex = word.nFontIndex;
}
+ sWords << GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord);
+ }
+ oldplace = place;
+ } else {
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
+ word.ptWord.y + ptOffset.y);
+ if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
+ sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
+ << " Td\n";
+ ptOld = ptNew;
+ }
+ if (word.nFontIndex != nCurFontIndex) {
+ sEditStream << GetFontSetString(pFontMap, word.nFontIndex,
+ word.fFontSize);
+ nCurFontIndex = word.nFontIndex;
+ }
+ sEditStream << GetWordRenderString(
+ GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord));
}
}
- if (sWords.GetSize() > 0) {
- sLineStream << GetWordRenderString(sWords.AsStringC());
- sEditStream << sLineStream;
- sWords.Clear();
- }
+ }
+ if (sWords.GetSize() > 0) {
+ sLineStream << GetWordRenderString(sWords.AsStringC());
+ sEditStream << sLineStream;
+ sWords.Clear();
}
return sEditStream.AsStringC();
}
« no previous file with comments | « core/fpdfdoc/cpdf_variabletext.cpp ('k') | core/fpdfdoc/include/cpdf_variabletext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698