Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2531)

Unified Diff: core/fpdftext/fpdf_text_int.cpp

Issue 1815453002: Handle empty objects in IsSameTextObject() and free from warning (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdftext/fpdf_text_int.cpp
diff --git a/core/fpdftext/fpdf_text_int.cpp b/core/fpdftext/fpdf_text_int.cpp
index be01648d4574d8eee30d702f8bf238d61e860730..85740fe73f67e8d441b0bc473a491734eb521a3a 100644
--- a/core/fpdftext/fpdf_text_int.cpp
+++ b/core/fpdftext/fpdf_text_int.cpp
@@ -1802,25 +1802,30 @@ FX_BOOL CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1,
if (nPreCount != nCurCount) {
return FALSE;
}
- CPDF_TextObjectItem itemPer, itemCur;
+
+ CPDF_TextObjectItem itemPer;
+ CPDF_TextObjectItem itemCur;
for (int i = 0; i < nPreCount; i++) {
pTextObj2->GetItemInfo(i, &itemPer);
pTextObj1->GetItemInfo(i, &itemCur);
if (itemCur.m_CharCode != itemPer.m_CharCode) {
return FALSE;
}
- }
- if (FXSYS_fabs(pTextObj1->GetPosX() - pTextObj2->GetPosX()) >
jun_fang 2016/03/18 05:31:48 Code here is used to check whether the distance of
- GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()) *
- pTextObj2->GetFontSize() / 1000 * 0.9 ||
- FXSYS_fabs(pTextObj1->GetPosY() - pTextObj2->GetPosY()) >
- std::max(std::max(rcPreObj.Height(), rcPreObj.Width()),
- pTextObj2->GetFontSize()) /
- 8) {
- return FALSE;
+ if (i == nPreCount - 1) {
jun_fang 2016/03/18 05:31:48 If I work on this issue, I may do code change like
Tom Sepez 2016/03/18 16:13:43 Ok, this is close to what Wei originally suggested
Wei Li 2016/03/18 16:59:44 Thank you for the clarification and suggestion. I
+ if (FXSYS_fabs(pTextObj1->GetPosX() - pTextObj2->GetPosX()) >
+ GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()) *
+ pTextObj2->GetFontSize() / 1000 * 0.9 ||
+ FXSYS_fabs(pTextObj1->GetPosY() - pTextObj2->GetPosY()) >
+ std::max(std::max(rcPreObj.Height(), rcPreObj.Width()),
+ pTextObj2->GetFontSize()) /
+ 8) {
+ return FALSE;
+ }
+ }
}
return TRUE;
}
+
FX_BOOL CPDF_TextPage::IsSameAsPreTextObject(
CPDF_TextObject* pTextObj,
const CPDF_PageObjectList* pObjList,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698