| 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 <ctype.h> | 7 #include <cctype> |
| 8 #include <cwctype> |
| 8 #include <algorithm> | 9 #include <algorithm> |
| 9 | 10 |
| 10 #include "core/include/fpdfapi/fpdf_module.h" | 11 #include "core/include/fpdfapi/fpdf_module.h" |
| 11 #include "core/include/fpdfapi/fpdf_page.h" | 12 #include "core/include/fpdfapi/fpdf_page.h" |
| 12 #include "core/include/fpdfapi/fpdf_pageobj.h" | 13 #include "core/include/fpdfapi/fpdf_pageobj.h" |
| 13 #include "core/include/fpdfapi/fpdf_resource.h" | 14 #include "core/include/fpdfapi/fpdf_resource.h" |
| 14 #include "core/include/fpdftext/fpdf_text.h" | 15 #include "core/include/fpdftext/fpdf_text.h" |
| 15 #include "core/include/fxcrt/fx_bidi.h" | 16 #include "core/include/fxcrt/fx_bidi.h" |
| 16 #include "core/include/fxcrt/fx_ucd.h" | 17 #include "core/include/fxcrt/fx_ucd.h" |
| 17 #include "text_int.h" | 18 #include "text_int.h" |
| (...skipping 2421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2439 } | 2440 } |
| 2440 if (!csWord.IsEmpty()) { | 2441 if (!csWord.IsEmpty()) { |
| 2441 m_csFindWhatArray.Add(csWord); | 2442 m_csFindWhatArray.Add(csWord); |
| 2442 } | 2443 } |
| 2443 index++; | 2444 index++; |
| 2444 } | 2445 } |
| 2445 } | 2446 } |
| 2446 FX_BOOL CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, | 2447 FX_BOOL CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, |
| 2447 int startPos, | 2448 int startPos, |
| 2448 int endPos) { | 2449 int endPos) { |
| 2449 int char_left = 0; | 2450 FX_WCHAR char_left = 0; |
| 2450 int char_right = 0; | 2451 FX_WCHAR char_right = 0; |
| 2451 int char_count = endPos - startPos + 1; | 2452 int char_count = endPos - startPos + 1; |
| 2452 if (char_count < 1) { | 2453 if (char_count < 1) { |
| 2453 return FALSE; | 2454 return FALSE; |
| 2454 } | 2455 } |
| 2455 if (char_count == 1 && csPageText.GetAt(startPos) > 255) { | 2456 if (char_count == 1 && csPageText.GetAt(startPos) > 255) { |
| 2456 return TRUE; | 2457 return TRUE; |
| 2457 } | 2458 } |
| 2458 if (startPos - 1 >= 0) { | 2459 if (startPos - 1 >= 0) { |
| 2459 char_left = csPageText.GetAt(startPos - 1); | 2460 char_left = csPageText.GetAt(startPos - 1); |
| 2460 } | 2461 } |
| 2461 if (startPos + char_count < csPageText.GetLength()) { | 2462 if (startPos + char_count < csPageText.GetLength()) { |
| 2462 char_right = csPageText.GetAt(startPos + char_count); | 2463 char_right = csPageText.GetAt(startPos + char_count); |
| 2463 } | 2464 } |
| 2464 if ((char_left > 'A' && char_left < 'a') || | 2465 if ((char_left > 'A' && char_left < 'a') || |
| 2465 (char_left > 'a' && char_left < 'z') || | 2466 (char_left > 'a' && char_left < 'z') || |
| 2466 (char_left > 0xfb00 && char_left < 0xfb06) || | 2467 (char_left > 0xfb00 && char_left < 0xfb06) || std::iswdigit(char_left) || |
| 2467 (char_left >= '0' && char_left <= '9') || | |
| 2468 (char_right > 'A' && char_right < 'a') || | 2468 (char_right > 'A' && char_right < 'a') || |
| 2469 (char_right > 'a' && char_right < 'z') || | 2469 (char_right > 'a' && char_right < 'z') || |
| 2470 (char_right > 0xfb00 && char_right < 0xfb06) || | 2470 (char_right > 0xfb00 && char_right < 0xfb06) || |
| 2471 (char_right >= '0' && char_right <= '9')) { | 2471 std::iswdigit(char_right)) { |
| 2472 return FALSE; | 2472 return FALSE; |
| 2473 } | 2473 } |
| 2474 if (!(('A' > char_left || char_left > 'Z') && | 2474 if (!(('A' > char_left || char_left > 'Z') && |
| 2475 ('a' > char_left || char_left > 'z') && | 2475 ('a' > char_left || char_left > 'z') && |
| 2476 ('A' > char_right || char_right > 'Z') && | 2476 ('A' > char_right || char_right > 'Z') && |
| 2477 ('a' > char_right || char_right > 'z'))) { | 2477 ('a' > char_right || char_right > 'z'))) { |
| 2478 return FALSE; | 2478 return FALSE; |
| 2479 } | 2479 } |
| 2480 if (char_count > 0) { | 2480 if (char_count > 0) { |
| 2481 if (csPageText.GetAt(startPos) >= L'0' && | 2481 if (csPageText.GetAt(startPos) >= L'0' && |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2756 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { | 2756 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { |
| 2757 return; | 2757 return; |
| 2758 } | 2758 } |
| 2759 CPDF_LinkExt* link = NULL; | 2759 CPDF_LinkExt* link = NULL; |
| 2760 link = m_LinkList.GetAt(index); | 2760 link = m_LinkList.GetAt(index); |
| 2761 if (!link) { | 2761 if (!link) { |
| 2762 return; | 2762 return; |
| 2763 } | 2763 } |
| 2764 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2764 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
| 2765 } | 2765 } |
| OLD | NEW |