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 /fpdfsdk/fxedit/fxet_ap.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 'fpdfsdk/fxedit/fxet_ap.cpp')
-rw-r--r-- | fpdfsdk/fxedit/fxet_ap.cpp | 158 |
1 files changed, 78 insertions, 80 deletions
diff --git a/fpdfsdk/fxedit/fxet_ap.cpp b/fpdfsdk/fxedit/fxet_ap.cpp index 1a36c803da..262f1e70cd 100644 --- a/fpdfsdk/fxedit/fxet_ap.cpp +++ b/fpdfsdk/fxedit/fxet_ap.cpp @@ -70,91 +70,90 @@ CFX_ByteString IFX_Edit::GetEditAppearanceStream( CFX_FloatPoint ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f); int32_t nCurFontIndex = -1; - if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { - if (pRange) - pIterator->SetAt(pRange->BeginPos); - else - pIterator->SetAt(0); + IFX_Edit_Iterator* pIterator = pEdit->GetIterator(); + if (pRange) + pIterator->SetAt(pRange->BeginPos); + else + pIterator->SetAt(0); - CPVT_WordPlace oldplace; + CPVT_WordPlace oldplace; - while (pIterator->NextWord()) { - CPVT_WordPlace place = pIterator->GetAt(); - - if (pRange && place.WordCmp(pRange->EndPos) > 0) - break; + while (pIterator->NextWord()) { + CPVT_WordPlace place = pIterator->GetAt(); - if (bContinuous) { - if (place.LineCmp(oldplace) != 0) { - if (sWords.GetSize() > 0) { - sEditStream << GetWordRenderString(sWords.AsStringC()); - 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 (pRange && place.WordCmp(pRange->EndPos) > 0) + break; - if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) { - sEditStream << 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) { - sEditStream << GetWordRenderString(sWords.AsStringC()); - sWords.Clear(); - } - sEditStream << GetFontSetString(pEdit->GetFontMap(), - word.nFontIndex, word.fFontSize); - nCurFontIndex = word.nFontIndex; - } - - sWords << GetPDFWordString(pEdit->GetFontMap(), nCurFontIndex, - word.Word, SubWord); + if (bContinuous) { + if (place.LineCmp(oldplace) != 0) { + if (sWords.GetSize() > 0) { + sEditStream << GetWordRenderString(sWords.AsStringC()); + sWords.Clear(); } - oldplace = place; - } else { 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) { - sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y - << " Td\n"; - ptOld = ptNew; - } + if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) { + sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y + << " Td\n"; - if (word.nFontIndex != nCurFontIndex) { - sEditStream << GetFontSetString(pEdit->GetFontMap(), - word.nFontIndex, word.fFontSize); - nCurFontIndex = word.nFontIndex; + ptOld = ptNew; + } + } + + CPVT_Word word; + if (pIterator->GetWord(word)) { + if (word.nFontIndex != nCurFontIndex) { + if (sWords.GetSize() > 0) { + sEditStream << GetWordRenderString(sWords.AsStringC()); + sWords.Clear(); } + sEditStream << GetFontSetString(pEdit->GetFontMap(), word.nFontIndex, + word.fFontSize); + nCurFontIndex = word.nFontIndex; + } + + sWords << GetPDFWordString(pEdit->GetFontMap(), nCurFontIndex, + word.Word, SubWord); + } - sEditStream << GetWordRenderString(GetPDFWordString( - pEdit->GetFontMap(), 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(pEdit->GetFontMap(), word.nFontIndex, + word.fFontSize); + nCurFontIndex = word.nFontIndex; + } + + sEditStream << GetWordRenderString(GetPDFWordString( + pEdit->GetFontMap(), nCurFontIndex, word.Word, SubWord)); } } + } - if (sWords.GetSize() > 0) { - sEditStream << GetWordRenderString(sWords.AsStringC()); - sWords.Clear(); - } + if (sWords.GetSize() > 0) { + sEditStream << GetWordRenderString(sWords.AsStringC()); + sWords.Clear(); } CFX_ByteTextBuf sAppStream; @@ -182,22 +181,21 @@ CFX_ByteString IFX_Edit::GetSelectAppearanceStream( CFX_ByteTextBuf sRet; if (pRange && pRange->IsExist()) { - if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) { - pIterator->SetAt(pRange->BeginPos); + IFX_Edit_Iterator* pIterator = pEdit->GetIterator(); + pIterator->SetAt(pRange->BeginPos); - while (pIterator->NextWord()) { - CPVT_WordPlace place = pIterator->GetAt(); + while (pIterator->NextWord()) { + CPVT_WordPlace place = pIterator->GetAt(); - if (pRange && place.WordCmp(pRange->EndPos) > 0) - break; + if (pRange && place.WordCmp(pRange->EndPos) > 0) + break; - CPVT_Word word; - CPVT_Line line; - if (pIterator->GetWord(word) && pIterator->GetLine(line)) { - sRet << word.ptWord.x + ptOffset.x << " " - << line.ptLine.y + line.fLineDescent << " " << word.fWidth << " " - << line.fLineAscent - line.fLineDescent << " re\nf\n"; - } + CPVT_Word word; + CPVT_Line line; + if (pIterator->GetWord(word) && pIterator->GetLine(line)) { + sRet << word.ptWord.x + ptOffset.x << " " + << line.ptLine.y + line.fLineDescent << " " << word.fWidth << " " + << line.fLineAscent - line.fLineDescent << " re\nf\n"; } } } |