Rename |CPDF_TextPage::m_CharIndex| to |m_CharIndices|.
Since it is a vector of values and not a single value.
Change-Id: I0a28a348b3db35e18f17529c911c9daa1eb6100e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/65490
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 260b101..38d1a3f 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -258,32 +258,32 @@
m_bIsParsed = true;
const int nCount = CountChars();
if (nCount)
- m_CharIndex.push_back(0);
+ m_CharIndices.push_back(0);
for (int i = 0; i < nCount; ++i) {
const PAGECHAR_INFO& charinfo = m_CharList[i];
if (charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED ||
(charinfo.m_Unicode != 0 && !IsControlChar(charinfo)) ||
(charinfo.m_Unicode == 0 && charinfo.m_CharCode != 0)) {
- if (m_CharIndex.size() % 2) {
- m_CharIndex.push_back(1);
+ if (m_CharIndices.size() % 2) {
+ m_CharIndices.push_back(1);
} else {
- if (m_CharIndex.empty())
+ if (m_CharIndices.empty())
continue;
- m_CharIndex.back() += 1;
+ m_CharIndices.back() += 1;
}
} else {
- if (m_CharIndex.size() % 2) {
- if (m_CharIndex.empty())
+ if (m_CharIndices.size() % 2) {
+ if (m_CharIndices.empty())
continue;
- m_CharIndex.back() = i + 1;
+ m_CharIndices.back() = i + 1;
} else {
- m_CharIndex.push_back(i + 1);
+ m_CharIndices.push_back(i + 1);
}
}
}
- if (m_CharIndex.size() % 2)
- m_CharIndex.pop_back();
+ if (m_CharIndices.size() % 2)
+ m_CharIndices.pop_back();
}
int CPDF_TextPage::CountChars() const {
@@ -292,22 +292,22 @@
int CPDF_TextPage::CharIndexFromTextIndex(int text_index) const {
int count = 0;
- for (size_t i = 0; i < m_CharIndex.size(); i += 2) {
- count += m_CharIndex[i + 1];
+ for (size_t i = 0; i < m_CharIndices.size(); i += 2) {
+ count += m_CharIndices[i + 1];
if (count > text_index)
- return text_index - count + m_CharIndex[i + 1] + m_CharIndex[i];
+ return text_index - count + m_CharIndices[i + 1] + m_CharIndices[i];
}
return -1;
}
int CPDF_TextPage::TextIndexFromCharIndex(int char_index) const {
int count = 0;
- for (size_t i = 0; i < m_CharIndex.size(); i += 2) {
- int text_index = char_index - m_CharIndex[i];
- if (text_index < m_CharIndex[i + 1])
+ for (size_t i = 0; i < m_CharIndices.size(); i += 2) {
+ int text_index = char_index - m_CharIndices[i];
+ if (text_index < m_CharIndices[i + 1])
return text_index >= 0 ? text_index + count : -1;
- count += m_CharIndex[i + 1];
+ count += m_CharIndices[i + 1];
}
return -1;
}
diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h
index cd5c13d..2bb8a18 100644
--- a/core/fpdftext/cpdf_textpage.h
+++ b/core/fpdftext/cpdf_textpage.h
@@ -93,8 +93,8 @@
WideString GetTextByObject(const CPDF_TextObject* pTextObj) const;
// Returns string with the text from |m_TextBuf| that are covered by the input
- // range. |start| and |count| are in terms of the |m_CharIndex|, so the range
- // will be converted into appropriate indices.
+ // range. |start| and |count| are in terms of the |m_CharIndices|, so the
+ // range will be converted into appropriate indices.
WideString GetPageText(int start, int count) const;
WideString GetAllPageText() const { return GetPageText(0, CountChars()); }
@@ -151,7 +151,7 @@
const std::function<bool(const PAGECHAR_INFO&)>& predicate) const;
UnownedPtr<const CPDF_Page> const m_pPage;
- std::vector<uint16_t> m_CharIndex;
+ std::vector<uint16_t> m_CharIndices;
std::deque<PAGECHAR_INFO> m_CharList;
std::deque<PAGECHAR_INFO> m_TempCharList;
CFX_WideTextBuf m_TextBuf;