Clean up CPDF_TextObject::GetCharInfo().
There are actually two methods with this name. Disambiguate them by
renaming the first one to CPDF_TextObject::GetCharCode(). Then simplify
GetCharCode() to remove some dead code.
Change-Id: I0420e655c4df5cb8f77769356a488e5a92ffbbb3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/71930
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp
index beb3ce9..dc302ed 100644
--- a/core/fpdfapi/page/cpdf_textobject.cpp
+++ b/core/fpdfapi/page/cpdf_textobject.cpp
@@ -66,24 +66,16 @@
return count;
}
-void CPDF_TextObject::GetCharInfo(size_t index,
- uint32_t* charcode,
- float* kerning) const {
+uint32_t CPDF_TextObject::GetCharCode(size_t index) const {
size_t count = 0;
- for (size_t i = 0; i < m_CharCodes.size(); ++i) {
- if (m_CharCodes[i] == CPDF_Font::kInvalidCharCode)
+ for (uint32_t code : m_CharCodes) {
+ if (code == CPDF_Font::kInvalidCharCode)
continue;
if (count++ != index)
continue;
- *charcode = m_CharCodes[i];
- if (i == m_CharCodes.size() - 1 ||
- m_CharCodes[i + 1] != CPDF_Font::kInvalidCharCode) {
- *kerning = 0;
- } else {
- *kerning = m_CharPos[i];
- }
- return;
+ return code;
}
+ return CPDF_Font::kInvalidCharCode;
}
void CPDF_TextObject::GetCharInfo(size_t index,
@@ -105,9 +97,7 @@
bool bInLatinWord = false;
int nWords = 0;
for (size_t i = 0, sz = CountChars(); i < sz; ++i) {
- uint32_t charcode = CPDF_Font::kInvalidCharCode;
- float unused_kerning;
- GetCharInfo(i, &charcode, &unused_kerning);
+ uint32_t charcode = GetCharCode(i);
WideString swUnicode = pFont->UnicodeFromCharCode(charcode);
uint16_t unicode = 0;
@@ -132,9 +122,7 @@
int nWords = 0;
bool bInLatinWord = false;
for (size_t i = 0, sz = CountChars(); i < sz; ++i) {
- uint32_t charcode = CPDF_Font::kInvalidCharCode;
- float unused_kerning;
- GetCharInfo(i, &charcode, &unused_kerning);
+ uint32_t charcode = GetCharCode(i);
WideString swUnicode = pFont->UnicodeFromCharCode(charcode);
uint16_t unicode = 0;
diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h
index 935fb83..cc8f64a 100644
--- a/core/fpdfapi/page/cpdf_textobject.h
+++ b/core/fpdfapi/page/cpdf_textobject.h
@@ -43,7 +43,7 @@
void GetItemInfo(size_t index, CPDF_TextObjectItem* pInfo) const;
size_t CountChars() const;
- void GetCharInfo(size_t index, uint32_t* charcode, float* kerning) const;
+ uint32_t GetCharCode(size_t index) const;
void GetCharInfo(size_t index, CPDF_TextObjectItem* pInfo) const;
float GetCharWidth(uint32_t charcode) const;
int CountWords() const;