summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/cpdf_variabletext.cpp4
-rw-r--r--core/fpdfdoc/csection.cpp13
2 files changed, 7 insertions, 10 deletions
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp
index d5333192f5..dcd3a0785a 100644
--- a/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -699,7 +699,7 @@ CPVT_WordPlace CPDF_VariableText::AddSection(const CPVT_WordPlace& place,
return place;
int32_t nSecIndex =
- std::max(std::min(place.nSecIndex, m_SectionArray.GetSize()), 0);
+ pdfium::clamp(place.nSecIndex, 0, m_SectionArray.GetSize());
CSection* pSection = new CSection(this);
pSection->m_SecInfo = secinfo;
pSection->SecPlace.nSecIndex = nSecIndex;
@@ -727,7 +727,7 @@ CPVT_WordPlace CPDF_VariableText::AddWord(const CPVT_WordPlace& place,
}
CPVT_WordPlace newplace = place;
newplace.nSecIndex =
- std::max(std::min(newplace.nSecIndex, m_SectionArray.GetSize() - 1), 0);
+ pdfium::clamp(newplace.nSecIndex, 0, m_SectionArray.GetSize() - 1);
if (CSection* pSection = m_SectionArray.GetAt(newplace.nSecIndex))
return pSection->AddWord(newplace, wordinfo);
return place;
diff --git a/core/fpdfdoc/csection.cpp b/core/fpdfdoc/csection.cpp
index 981f6d0b54..0c7825585c 100644
--- a/core/fpdfdoc/csection.cpp
+++ b/core/fpdfdoc/csection.cpp
@@ -29,9 +29,8 @@ void CSection::ResetLineArray() {
}
void CSection::ResetWordArray() {
- for (int32_t i = 0, sz = m_WordArray.GetSize(); i < sz; i++) {
+ for (int32_t i = 0, sz = m_WordArray.GetSize(); i < sz; i++)
delete m_WordArray.GetAt(i);
- }
m_WordArray.RemoveAll();
}
@@ -47,12 +46,11 @@ CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace& place,
const CPVT_WordInfo& wordinfo) {
CPVT_WordInfo* pWord = new CPVT_WordInfo(wordinfo);
int32_t nWordIndex =
- std::max(std::min(place.nWordIndex, m_WordArray.GetSize()), 0);
- if (nWordIndex == m_WordArray.GetSize()) {
+ pdfium::clamp(place.nWordIndex, 0, m_WordArray.GetSize());
+ if (nWordIndex == m_WordArray.GetSize())
m_WordArray.Add(pWord);
- } else {
+ else
m_WordArray.InsertAt(nWordIndex, pWord);
- }
return place;
}
@@ -62,9 +60,8 @@ CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo& lineinfo) {
}
CPVT_FloatRect CSection::Rearrange() {
- if (m_pVT->m_nCharArray > 0) {
+ if (m_pVT->m_nCharArray > 0)
return CTypeset(this).CharArray();
- }
return CTypeset(this).Typeset();
}