summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_variabletext.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-21 13:42:38 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-21 22:34:49 +0000
commit52f69b39403b1ac0df0fdf45698e80e60c0f2def (patch)
tree75c62cdb179bc287f283794600f252783603ad9f /core/fpdfdoc/cpdf_variabletext.cpp
parent7dd72a3f39c09a7fdc34558061831620bc149420 (diff)
downloadpdfium-52f69b39403b1ac0df0fdf45698e80e60c0f2def.tar.xz
Make CPVT_WordPlace more conformant with the prevailing idioms.
Add relational operators to replace CmpWord(). Leave CmpLine() for the moment as it saves some work. Remove CmpSec() and just inline comparison of the one member. Invert IsExist() as IsEmpty(). There is a big philosophical discussion as to whether things that are empty exist. I say they do, but they're just empty. Rename Default() to Reset(). Default sounds like a noun. Add AdvanceSection() method and call as appropriate. Change-Id: I01d9479f63a4860e0fd228255540d6d94dc24a9f Reviewed-on: https://pdfium-review.googlesource.com/3139 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_variabletext.cpp')
-rw-r--r--core/fpdfdoc/cpdf_variabletext.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp
index 24dd9b065d..4e46969dc4 100644
--- a/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -432,9 +432,7 @@ void CPDF_VariableText::SetText(const CFX_WideString& swText) {
if (swText.GetAt(i + 1) == 0x0A)
i += 1;
- wp.nSecIndex++;
- wp.nLineIndex = 0;
- wp.nWordIndex = -1;
+ wp.AdvanceSection();
AddSection(wp, secinfo);
}
break;
@@ -443,9 +441,7 @@ void CPDF_VariableText::SetText(const CFX_WideString& swText) {
if (swText.GetAt(i + 1) == 0x0D)
i += 1;
- wp.nSecIndex++;
- wp.nLineIndex = 0;
- wp.nWordIndex = -1;
+ wp.AdvanceSection();
AddSection(wp, secinfo);
}
break;
@@ -537,7 +533,7 @@ CPVT_WordPlace CPDF_VariableText::GetPrevWordPlace(
return GetEndWordPlace();
CSection* pSection = m_SectionArray[place.nSecIndex].get();
- if (place.WordCmp(pSection->GetBeginWordPlace()) > 0)
+ if (place > pSection->GetBeginWordPlace())
return pSection->GetPrevWordPlace(place);
if (!pdfium::IndexInBounds(m_SectionArray, place.nSecIndex - 1))
return GetBeginWordPlace();
@@ -552,7 +548,7 @@ CPVT_WordPlace CPDF_VariableText::GetNextWordPlace(
return GetEndWordPlace();
CSection* pSection = m_SectionArray[place.nSecIndex].get();
- if (place.WordCmp(pSection->GetEndWordPlace()) < 0)
+ if (place < pSection->GetEndWordPlace())
return pSection->GetNextWordPlace(place);
if (!pdfium::IndexInBounds(m_SectionArray, place.nSecIndex + 1))
return GetEndWordPlace();
@@ -638,8 +634,7 @@ CPVT_WordPlace CPDF_VariableText::GetDownWordPlace(
return pSection->SearchWordPlace(pt.x - pSection->m_SecInfo.rcSection.left,
temp);
}
- ++temp.nSecIndex;
- temp.nLineIndex = 0;
+ temp.AdvanceSection();
if (!pdfium::IndexInBounds(m_SectionArray, temp.nSecIndex))
return place;