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 2391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 } | 2410 } |
2410 if (!csWord.IsEmpty()) { | 2411 if (!csWord.IsEmpty()) { |
2411 m_csFindWhatArray.Add(csWord); | 2412 m_csFindWhatArray.Add(csWord); |
2412 } | 2413 } |
2413 index++; | 2414 index++; |
2414 } | 2415 } |
2415 } | 2416 } |
2416 FX_BOOL CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, | 2417 FX_BOOL CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, |
2417 int startPos, | 2418 int startPos, |
2418 int endPos) { | 2419 int endPos) { |
2419 int char_left = 0; | 2420 FX_WCHAR char_left = 0; |
2420 int char_right = 0; | 2421 FX_WCHAR char_right = 0; |
2421 int char_count = endPos - startPos + 1; | 2422 int char_count = endPos - startPos + 1; |
2422 if (char_count < 1) { | 2423 if (char_count < 1) { |
2423 return FALSE; | 2424 return FALSE; |
2424 } | 2425 } |
2425 if (char_count == 1 && csPageText.GetAt(startPos) > 255) { | 2426 if (char_count == 1 && csPageText.GetAt(startPos) > 255) { |
2426 return TRUE; | 2427 return TRUE; |
2427 } | 2428 } |
2428 if (startPos - 1 >= 0) { | 2429 if (startPos - 1 >= 0) { |
2429 char_left = csPageText.GetAt(startPos - 1); | 2430 char_left = csPageText.GetAt(startPos - 1); |
2430 } | 2431 } |
2431 if (startPos + char_count < csPageText.GetLength()) { | 2432 if (startPos + char_count < csPageText.GetLength()) { |
2432 char_right = csPageText.GetAt(startPos + char_count); | 2433 char_right = csPageText.GetAt(startPos + char_count); |
2433 } | 2434 } |
2434 if ((char_left > 'A' && char_left < 'a') || | 2435 if ((char_left > 'A' && char_left < 'a') || |
2435 (char_left > 'a' && char_left < 'z') || | 2436 (char_left > 'a' && char_left < 'z') || |
2436 (char_left > 0xfb00 && char_left < 0xfb06) || | 2437 (char_left > 0xfb00 && char_left < 0xfb06) || std::iswdigit(char_left) || |
2437 (char_left >= '0' && char_left <= '9') || | |
2438 (char_right > 'A' && char_right < 'a') || | 2438 (char_right > 'A' && char_right < 'a') || |
2439 (char_right > 'a' && char_right < 'z') || | 2439 (char_right > 'a' && char_right < 'z') || |
2440 (char_right > 0xfb00 && char_right < 0xfb06) || | 2440 (char_right > 0xfb00 && char_right < 0xfb06) || |
2441 (char_right >= '0' && char_right <= '9')) { | 2441 std::iswdigit(char_right)) { |
2442 return FALSE; | 2442 return FALSE; |
2443 } | 2443 } |
2444 if (!(('A' > char_left || char_left > 'Z') && | 2444 if (!(('A' > char_left || char_left > 'Z') && |
2445 ('a' > char_left || char_left > 'z') && | 2445 ('a' > char_left || char_left > 'z') && |
2446 ('A' > char_right || char_right > 'Z') && | 2446 ('A' > char_right || char_right > 'Z') && |
2447 ('a' > char_right || char_right > 'z'))) { | 2447 ('a' > char_right || char_right > 'z'))) { |
2448 return FALSE; | 2448 return FALSE; |
2449 } | 2449 } |
2450 if (char_count > 0) { | 2450 if (char_count > 0) { |
2451 if (csPageText.GetAt(startPos) >= L'0' && | 2451 if (csPageText.GetAt(startPos) >= L'0' && |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2726 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { | 2726 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { |
2727 return; | 2727 return; |
2728 } | 2728 } |
2729 CPDF_LinkExt* link = NULL; | 2729 CPDF_LinkExt* link = NULL; |
2730 link = m_LinkList.GetAt(index); | 2730 link = m_LinkList.GetAt(index); |
2731 if (!link) { | 2731 if (!link) { |
2732 return; | 2732 return; |
2733 } | 2733 } |
2734 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2734 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
2735 } | 2735 } |
OLD | NEW |