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/pdfwindow/PWL_Edit.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/pdfwindow/PWL_Edit.cpp')
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Edit.cpp | 87 |
1 files changed, 42 insertions, 45 deletions
diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp index dffc62a02f..80aa629a06 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp @@ -524,18 +524,17 @@ CFX_FloatPoint CPWL_Edit::GetWordRightBottomPoint( const CPVT_WordPlace& wpWord) { CFX_FloatPoint pt(0.0f, 0.0f); - if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { - CPVT_WordPlace wpOld = pIterator->GetAt(); - pIterator->SetAt(wpWord); - CPVT_Word word; - if (pIterator->GetWord(word)) { - pt = CFX_FloatPoint(word.ptWord.x + word.fWidth, - word.ptWord.y + word.fDescent); - } - - pIterator->SetAt(wpOld); + IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); + CPVT_WordPlace wpOld = pIterator->GetAt(); + pIterator->SetAt(wpWord); + CPVT_Word word; + if (pIterator->GetWord(word)) { + pt = CFX_FloatPoint(word.ptWord.x + word.fWidth, + word.ptWord.y + word.fDescent); } + pIterator->SetAt(wpOld); + return pt; } @@ -879,52 +878,50 @@ CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace& place, FX_BOOL bArabic) const { CPVT_WordRange range; - if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { - CPVT_Word wordinfo; - CPVT_WordPlace wpStart(place), wpEnd(place); - pIterator->SetAt(place); - - if (bLatin) { - while (pIterator->NextWord()) { - if (!pIterator->GetWord(wordinfo) || - !FX_EDIT_ISLATINWORD(wordinfo.Word)) { - break; - } + IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); + CPVT_Word wordinfo; + CPVT_WordPlace wpStart(place), wpEnd(place); + pIterator->SetAt(place); - wpEnd = pIterator->GetAt(); + if (bLatin) { + while (pIterator->NextWord()) { + if (!pIterator->GetWord(wordinfo) || + !FX_EDIT_ISLATINWORD(wordinfo.Word)) { + break; } - } else if (bArabic) { - while (pIterator->NextWord()) { - if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) - break; - wpEnd = pIterator->GetAt(); - } + wpEnd = pIterator->GetAt(); } + } else if (bArabic) { + while (pIterator->NextWord()) { + if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) + break; - pIterator->SetAt(place); + wpEnd = pIterator->GetAt(); + } + } - if (bLatin) { - do { - if (!pIterator->GetWord(wordinfo) || - !FX_EDIT_ISLATINWORD(wordinfo.Word)) { - break; - } + pIterator->SetAt(place); - wpStart = pIterator->GetAt(); - } while (pIterator->PrevWord()); - } else if (bArabic) { - do { - if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) - break; + if (bLatin) { + do { + if (!pIterator->GetWord(wordinfo) || + !FX_EDIT_ISLATINWORD(wordinfo.Word)) { + break; + } - wpStart = pIterator->GetAt(); - } while (pIterator->PrevWord()); - } + wpStart = pIterator->GetAt(); + } while (pIterator->PrevWord()); + } else if (bArabic) { + do { + if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) + break; - range.Set(wpStart, wpEnd); + wpStart = pIterator->GetAt(); + } while (pIterator->PrevWord()); } + range.Set(wpStart, wpEnd); return range; } |