diff options
author | thestig <thestig@chromium.org> | 2016-05-11 12:59:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-11 12:59:22 -0700 |
commit | 821d59e1d66b67af970c59b7681828b1b82858b6 (patch) | |
tree | 60e71c3c317f5843d0488e827c6932a956df7866 /core/fpdfdoc/cpvt_generateap.cpp | |
parent | a244dfe2ba2cc82ee264475253cc16222e022524 (diff) | |
download | pdfium-821d59e1d66b67af970c59b7681828b1b82858b6.tar.xz |
CPDF_VariableText::GetIterator() never returns NULL.
Same goes for CFX_Edit::GetIterator().
Review-Url: https://codereview.chromium.org/1967963002
Diffstat (limited to 'core/fpdfdoc/cpvt_generateap.cpp')
-rw-r--r-- | core/fpdfdoc/cpvt_generateap.cpp | 119 |
1 files changed, 58 insertions, 61 deletions
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index 5ec9513e84..7fcd90969e 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(); } |