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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdftext/fpdf_text_int.h" 7 #include "core/fpdftext/fpdf_text_int.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cctype> 10 #include <cctype>
(...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 } 1795 }
1796 if (pTextObj2->GetFontSize() != pTextObj1->GetFontSize()) { 1796 if (pTextObj2->GetFontSize() != pTextObj1->GetFontSize()) {
1797 return FALSE; 1797 return FALSE;
1798 } 1798 }
1799 } 1799 }
1800 int nPreCount = pTextObj2->CountItems(); 1800 int nPreCount = pTextObj2->CountItems();
1801 int nCurCount = pTextObj1->CountItems(); 1801 int nCurCount = pTextObj1->CountItems();
1802 if (nPreCount != nCurCount) { 1802 if (nPreCount != nCurCount) {
1803 return FALSE; 1803 return FALSE;
1804 } 1804 }
1805 CPDF_TextObjectItem itemPer, itemCur; 1805
1806 CPDF_TextObjectItem itemPer;
1807 CPDF_TextObjectItem itemCur;
1806 for (int i = 0; i < nPreCount; i++) { 1808 for (int i = 0; i < nPreCount; i++) {
1807 pTextObj2->GetItemInfo(i, &itemPer); 1809 pTextObj2->GetItemInfo(i, &itemPer);
1808 pTextObj1->GetItemInfo(i, &itemCur); 1810 pTextObj1->GetItemInfo(i, &itemCur);
1809 if (itemCur.m_CharCode != itemPer.m_CharCode) { 1811 if (itemCur.m_CharCode != itemPer.m_CharCode) {
1810 return FALSE; 1812 return FALSE;
1811 } 1813 }
1812 } 1814 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
1813 if (FXSYS_fabs(pTextObj1->GetPosX() - pTextObj2->GetPosX()) > 1815 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
1814 GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()) * 1816 GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()) *
1815 pTextObj2->GetFontSize() / 1000 * 0.9 || 1817 pTextObj2->GetFontSize() / 1000 * 0.9 ||
1816 FXSYS_fabs(pTextObj1->GetPosY() - pTextObj2->GetPosY()) > 1818 FXSYS_fabs(pTextObj1->GetPosY() - pTextObj2->GetPosY()) >
1817 std::max(std::max(rcPreObj.Height(), rcPreObj.Width()), 1819 std::max(std::max(rcPreObj.Height(), rcPreObj.Width()),
1818 pTextObj2->GetFontSize()) / 1820 pTextObj2->GetFontSize()) /
1819 8) { 1821 8) {
1820 return FALSE; 1822 return FALSE;
1823 }
1824 }
1821 } 1825 }
1822 return TRUE; 1826 return TRUE;
1823 } 1827 }
1828
1824 FX_BOOL CPDF_TextPage::IsSameAsPreTextObject( 1829 FX_BOOL CPDF_TextPage::IsSameAsPreTextObject(
1825 CPDF_TextObject* pTextObj, 1830 CPDF_TextObject* pTextObj,
1826 const CPDF_PageObjectList* pObjList, 1831 const CPDF_PageObjectList* pObjList,
1827 CPDF_PageObjectList::const_iterator iter) { 1832 CPDF_PageObjectList::const_iterator iter) {
1828 int i = 0; 1833 int i = 0;
1829 while (i < 5 && iter != pObjList->begin()) { 1834 while (i < 5 && iter != pObjList->begin()) {
1830 --iter; 1835 --iter;
1831 CPDF_PageObject* pOtherObj = iter->get(); 1836 CPDF_PageObject* pOtherObj = iter->get();
1832 if (pOtherObj == pTextObj || !pOtherObj->IsText()) 1837 if (pOtherObj == pTextObj || !pOtherObj->IsText())
1833 continue; 1838 continue;
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { 2506 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) {
2502 return; 2507 return;
2503 } 2508 }
2504 CPDF_LinkExt* link = NULL; 2509 CPDF_LinkExt* link = NULL;
2505 link = m_LinkList.GetAt(index); 2510 link = m_LinkList.GetAt(index);
2506 if (!link) { 2511 if (!link) {
2507 return; 2512 return;
2508 } 2513 }
2509 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2514 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2510 } 2515 }
OLDNEW
« 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