| OLD | NEW |
| 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 "../../include/fpdfapi/fpdf_resource.h" | 7 #include "../../include/fpdfapi/fpdf_resource.h" |
| 8 #include "../../include/fpdfapi/fpdf_pageobj.h" | 8 #include "../../include/fpdfapi/fpdf_pageobj.h" |
| 9 #include "../../include/fpdftext/fpdf_text.h" | 9 #include "../../include/fpdftext/fpdf_text.h" |
| 10 #include "../../include/fpdfapi/fpdf_page.h" | 10 #include "../../include/fpdfapi/fpdf_page.h" |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 return; | 311 return; |
| 312 } | 312 } |
| 313 int CPDF_TextPage::GetIndexAtPos(CPDF_Point point , FX_FLOAT xTorelance, FX_FLOA
T yTorelance) const | 313 int CPDF_TextPage::GetIndexAtPos(CPDF_Point point , FX_FLOAT xTorelance, FX_FLOA
T yTorelance) const |
| 314 { | 314 { |
| 315 if(m_ParseOptions.m_bGetCharCodeOnly) { | 315 if(m_ParseOptions.m_bGetCharCodeOnly) { |
| 316 return -3; | 316 return -3; |
| 317 } | 317 } |
| 318 if (!m_IsParsered) { | 318 if (!m_IsParsered) { |
| 319 return -3; | 319 return -3; |
| 320 } | 320 } |
| 321 FX_FLOAT distance = 0; | |
| 322 int pos = 0; | 321 int pos = 0; |
| 323 int NearPos = -1; | 322 int NearPos = -1; |
| 324 double xdif = 5000, ydif = 5000; | 323 double xdif = 5000, ydif = 5000; |
| 325 while(pos < m_charList.GetSize()) { | 324 while(pos < m_charList.GetSize()) { |
| 326 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)(m_charList.GetAt(pos)); | 325 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)(m_charList.GetAt(pos)); |
| 327 CFX_FloatRect charrect = charinfo.m_CharBox; | 326 CFX_FloatRect charrect = charinfo.m_CharBox; |
| 328 if (charrect.Contains(point.x, point.y)) { | 327 if (charrect.Contains(point.x, point.y)) { |
| 329 break; | 328 break; |
| 330 } | 329 } |
| 331 if (xTorelance > 0 || yTorelance > 0) { | 330 if (xTorelance > 0 || yTorelance > 0) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 CFX_FloatRect curRect; | 401 CFX_FloatRect curRect; |
| 403 FX_BOOL flagNewRect = TRUE; | 402 FX_BOOL flagNewRect = TRUE; |
| 404 CPDF_TextObject* pCurObj = NULL; | 403 CPDF_TextObject* pCurObj = NULL; |
| 405 int nCount = m_charList.GetSize(); | 404 int nCount = m_charList.GetSize(); |
| 406 int pos = 0; | 405 int pos = 0; |
| 407 while (pos < nCount) { | 406 while (pos < nCount) { |
| 408 PAGECHAR_INFO info_curchar = *(PAGECHAR_INFO*)m_charList.GetAt(pos++); | 407 PAGECHAR_INFO info_curchar = *(PAGECHAR_INFO*)m_charList.GetAt(pos++); |
| 409 if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) { | 408 if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) { |
| 410 continue; | 409 continue; |
| 411 } | 410 } |
| 412 if(pos == 494) { | |
| 413 int a = 0; | |
| 414 } | |
| 415 if (IsRectIntersect(rect, info_curchar.m_CharBox)) { | 411 if (IsRectIntersect(rect, info_curchar.m_CharBox)) { |
| 416 if(!pCurObj) { | 412 if(!pCurObj) { |
| 417 pCurObj = info_curchar.m_pTextObj; | 413 pCurObj = info_curchar.m_pTextObj; |
| 418 } | 414 } |
| 419 if (pCurObj != info_curchar.m_pTextObj) { | 415 if (pCurObj != info_curchar.m_pTextObj) { |
| 420 resRectArray.Add(curRect); | 416 resRectArray.Add(curRect); |
| 421 pCurObj = info_curchar.m_pTextObj; | 417 pCurObj = info_curchar.m_pTextObj; |
| 422 flagNewRect = TRUE; | 418 flagNewRect = TRUE; |
| 423 } | 419 } |
| 424 if (flagNewRect) { | 420 if (flagNewRect) { |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 CFX_FloatRect rect(left, bottom, right, top); | 805 CFX_FloatRect rect(left, bottom, right, top); |
| 810 rect.Normalize(); | 806 rect.Normalize(); |
| 811 int nCount = m_charList.GetSize(); | 807 int nCount = m_charList.GetSize(); |
| 812 int pos = 0; | 808 int pos = 0; |
| 813 FPDF_SEGMENT segment; | 809 FPDF_SEGMENT segment; |
| 814 segment.m_Start = 0; | 810 segment.m_Start = 0; |
| 815 segment.m_nCount = 0; | 811 segment.m_nCount = 0; |
| 816 FX_BOOL segmentStatus = 0; | 812 FX_BOOL segmentStatus = 0; |
| 817 FX_BOOL IsContainPreChar = FALSE; | 813 FX_BOOL IsContainPreChar = FALSE; |
| 818 while (pos < nCount) { | 814 while (pos < nCount) { |
| 819 if(pos == 493) { | |
| 820 int a = 0; | |
| 821 } | |
| 822 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(pos); | 815 PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(pos); |
| 823 if(bContains && rect.Contains(charinfo.m_CharBox)) { | 816 if(bContains && rect.Contains(charinfo.m_CharBox)) { |
| 824 if (segmentStatus == 0 || segmentStatus == 2) { | 817 if (segmentStatus == 0 || segmentStatus == 2) { |
| 825 segment.m_Start = pos; | 818 segment.m_Start = pos; |
| 826 segment.m_nCount = 1; | 819 segment.m_nCount = 1; |
| 827 segmentStatus = 1; | 820 segmentStatus = 1; |
| 828 } else if (segmentStatus == 1) { | 821 } else if (segmentStatus == 1) { |
| 829 segment.m_nCount++; | 822 segment.m_nCount++; |
| 830 } | 823 } |
| 831 IsContainPreChar = TRUE; | 824 IsContainPreChar = TRUE; |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 n = i + 3; | 1279 n = i + 3; |
| 1287 } | 1280 } |
| 1288 if(n >= j) { | 1281 if(n >= j) { |
| 1289 for(int m = start; m < end; m++) { | 1282 for(int m = start; m < end; m++) { |
| 1290 AddCharInfoByLRDirection(str, m); | 1283 AddCharInfoByLRDirection(str, m); |
| 1291 } | 1284 } |
| 1292 } else { | 1285 } else { |
| 1293 i = j; | 1286 i = j; |
| 1294 j = n; | 1287 j = n; |
| 1295 for(; n <= i; n += 3) { | 1288 for(; n <= i; n += 3) { |
| 1296 int ret = order.GetAt(n); | |
| 1297 int start = order.GetAt(n - 2); | 1289 int start = order.GetAt(n - 2); |
| 1298 int count1 = order.GetAt(n - 1); | 1290 int count1 = order.GetAt(n - 1); |
| 1299 int end = start + count1 ; | 1291 int end = start + count1 ; |
| 1300 for(int m = start; m < end; m++) { | 1292 for(int m = start; m < end; m++) { |
| 1301 AddCharInfoByLRDirection(str, m); | 1293 AddCharInfoByLRDirection(str, m); |
| 1302 } | 1294 } |
| 1303 } | 1295 } |
| 1304 } | 1296 } |
| 1305 } | 1297 } |
| 1306 } | 1298 } |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2176 } | 2168 } |
| 2177 return TRUE; | 2169 return TRUE; |
| 2178 } | 2170 } |
| 2179 CPDF_TextPageFind::CPDF_TextPageFind(const IPDF_TextPage* pTextPage) | 2171 CPDF_TextPageFind::CPDF_TextPageFind(const IPDF_TextPage* pTextPage) |
| 2180 : m_IsFind(FALSE), | 2172 : m_IsFind(FALSE), |
| 2181 m_pTextPage(NULL) | 2173 m_pTextPage(NULL) |
| 2182 { | 2174 { |
| 2183 if (!pTextPage) { | 2175 if (!pTextPage) { |
| 2184 return; | 2176 return; |
| 2185 } | 2177 } |
| 2186 CPDF_ModuleMgr* pPDFModule = CPDF_ModuleMgr::Get(); | |
| 2187 m_pTextPage = pTextPage; | 2178 m_pTextPage = pTextPage; |
| 2188 m_strText = m_pTextPage->GetPageText(); | 2179 m_strText = m_pTextPage->GetPageText(); |
| 2189 int nCount = pTextPage->CountChars(); | 2180 int nCount = pTextPage->CountChars(); |
| 2190 if(nCount) { | 2181 if(nCount) { |
| 2191 m_CharIndex.Add(0); | 2182 m_CharIndex.Add(0); |
| 2192 } | 2183 } |
| 2193 for(int i = 0; i < nCount; i++) { | 2184 for(int i = 0; i < nCount; i++) { |
| 2194 FPDF_CHAR_INFO info; | 2185 FPDF_CHAR_INFO info; |
| 2195 pTextPage->GetCharInfo(i, info); | 2186 pTextPage->GetCharInfo(i, info); |
| 2196 int indexSize = m_CharIndex.GetSize(); | 2187 int indexSize = m_CharIndex.GetSize(); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2493 } | 2484 } |
| 2494 if (char_count == 1 && csPageText.GetAt(startPos) > 255) { | 2485 if (char_count == 1 && csPageText.GetAt(startPos) > 255) { |
| 2495 return TRUE; | 2486 return TRUE; |
| 2496 } | 2487 } |
| 2497 if(startPos - 1 >= 0 ) { | 2488 if(startPos - 1 >= 0 ) { |
| 2498 char_left = csPageText.GetAt(startPos - 1); | 2489 char_left = csPageText.GetAt(startPos - 1); |
| 2499 } | 2490 } |
| 2500 if(startPos + char_count < csPageText.GetLength()) { | 2491 if(startPos + char_count < csPageText.GetLength()) { |
| 2501 char_right = csPageText.GetAt(startPos + char_count); | 2492 char_right = csPageText.GetAt(startPos + char_count); |
| 2502 } | 2493 } |
| 2503 if(char_left == 0x61) { | |
| 2504 int a = 0; | |
| 2505 } | |
| 2506 if ((char_left > 'A' && char_left < 'a') || (char_left > 'a' && char_left <
'z') || (char_left > 0xfb00 && char_left < 0xfb06) || (char_left >= '0' && char_
left <= '9') || | 2494 if ((char_left > 'A' && char_left < 'a') || (char_left > 'a' && char_left <
'z') || (char_left > 0xfb00 && char_left < 0xfb06) || (char_left >= '0' && char_
left <= '9') || |
| 2507 (char_right > 'A' && char_right < 'a') || (char_right > 'a' && char_
right < 'z') || (char_right > 0xfb00 && char_right < 0xfb06) || (char_right >= '
0' && char_right <= '9')) { | 2495 (char_right > 'A' && char_right < 'a') || (char_right > 'a' && char_
right < 'z') || (char_right > 0xfb00 && char_right < 0xfb06) || (char_right >= '
0' && char_right <= '9')) { |
| 2508 return FALSE; | 2496 return FALSE; |
| 2509 } | 2497 } |
| 2510 if(!(('A' > char_left || char_left > 'Z') && ('a' > char_left || char_left
> 'z') | 2498 if(!(('A' > char_left || char_left > 'Z') && ('a' > char_left || char_left
> 'z') |
| 2511 && ('A' > char_right || char_right > 'Z') && ('a' > char_right || c
har_right > 'z'))) { | 2499 && ('A' > char_right || char_right > 'Z') && ('a' > char_right || c
har_right > 'z'))) { |
| 2512 return FALSE; | 2500 return FALSE; |
| 2513 } | 2501 } |
| 2514 if (char_count > 0) { | 2502 if (char_count > 0) { |
| 2515 if (csPageText.GetAt(startPos) >= L'0' && csPageText.GetAt(startPos) <=
L'9' && char_left >= L'0' && char_left <= L'9') { | 2503 if (csPageText.GetAt(startPos) >= L'0' && csPageText.GetAt(startPos) <=
L'9' && char_left >= L'0' && char_left <= L'9') { |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2792 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { | 2780 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { |
| 2793 return; | 2781 return; |
| 2794 } | 2782 } |
| 2795 CPDF_LinkExt* link = NULL; | 2783 CPDF_LinkExt* link = NULL; |
| 2796 link = m_LinkList.GetAt(index); | 2784 link = m_LinkList.GetAt(index); |
| 2797 if (!link) { | 2785 if (!link) { |
| 2798 return ; | 2786 return ; |
| 2799 } | 2787 } |
| 2800 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2788 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
| 2801 } | 2789 } |
| OLD | NEW |