| 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 <ctype.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 | 9 |
| 10 #include "../../../third_party/base/nonstd_unique_ptr.h" | 10 #include "../../../third_party/base/nonstd_unique_ptr.h" |
| (...skipping 2556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2567 FX_WCHAR ch = strBeCheck.GetAt(strBeCheck.GetLength() - 1); | 2567 FX_WCHAR ch = strBeCheck.GetAt(strBeCheck.GetLength() - 1); |
| 2568 if (ch == L')' || ch == L',' || ch == L'>' || ch == L'.') { | 2568 if (ch == L')' || ch == L',' || ch == L'>' || ch == L'.') { |
| 2569 strBeCheck = strBeCheck.Mid(0, strBeCheck.GetLength() - 1); | 2569 strBeCheck = strBeCheck.Mid(0, strBeCheck.GetLength() - 1); |
| 2570 nCount--; | 2570 nCount--; |
| 2571 } else { | 2571 } else { |
| 2572 break; | 2572 break; |
| 2573 } | 2573 } |
| 2574 } | 2574 } |
| 2575 if (nCount > 5 && | 2575 if (nCount > 5 && |
| 2576 (CheckWebLink(strBeCheck) || CheckMailLink(strBeCheck))) { | 2576 (CheckWebLink(strBeCheck) || CheckMailLink(strBeCheck))) { |
| 2577 if (!AppendToLinkList(start, nCount, strBeCheck)) { | 2577 AppendToLinkList(start, nCount, strBeCheck); |
| 2578 break; | |
| 2579 } | |
| 2580 } | 2578 } |
| 2581 } | 2579 } |
| 2582 start = ++pos; | 2580 start = ++pos; |
| 2583 } else { | 2581 } else { |
| 2584 pos++; | 2582 pos++; |
| 2585 } | 2583 } |
| 2586 } | 2584 } |
| 2587 } | 2585 } |
| 2588 FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) { | 2586 FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) { |
| 2589 CFX_WideString str = strBeCheck; | 2587 CFX_WideString str = strBeCheck; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2683 continue; | 2681 continue; |
| 2684 } else { | 2682 } else { |
| 2685 return FALSE; | 2683 return FALSE; |
| 2686 } | 2684 } |
| 2687 } | 2685 } |
| 2688 if (str.Find(L"mailto:") == -1) { | 2686 if (str.Find(L"mailto:") == -1) { |
| 2689 str = L"mailto:" + str; | 2687 str = L"mailto:" + str; |
| 2690 } | 2688 } |
| 2691 return TRUE; | 2689 return TRUE; |
| 2692 } | 2690 } |
| 2693 FX_BOOL CPDF_LinkExtract::AppendToLinkList(int start, | 2691 |
| 2694 int count, | 2692 void CPDF_LinkExtract::AppendToLinkList(int start, |
| 2695 const CFX_WideString& strUrl) { | 2693 int count, |
| 2694 const CFX_WideString& strUrl) { |
| 2696 CPDF_LinkExt* linkInfo = new CPDF_LinkExt; | 2695 CPDF_LinkExt* linkInfo = new CPDF_LinkExt; |
| 2697 linkInfo->m_strUrl = strUrl; | 2696 linkInfo->m_strUrl = strUrl; |
| 2698 linkInfo->m_Start = start; | 2697 linkInfo->m_Start = start; |
| 2699 linkInfo->m_Count = count; | 2698 linkInfo->m_Count = count; |
| 2700 m_LinkList.Add(linkInfo); | 2699 m_LinkList.Add(linkInfo); |
| 2701 return TRUE; | |
| 2702 } | 2700 } |
| 2701 |
| 2703 CFX_WideString CPDF_LinkExtract::GetURL(int index) const { | 2702 CFX_WideString CPDF_LinkExtract::GetURL(int index) const { |
| 2704 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { | 2703 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { |
| 2705 return L""; | 2704 return L""; |
| 2706 } | 2705 } |
| 2707 CPDF_LinkExt* link = NULL; | 2706 CPDF_LinkExt* link = NULL; |
| 2708 link = m_LinkList.GetAt(index); | 2707 link = m_LinkList.GetAt(index); |
| 2709 if (!link) { | 2708 if (!link) { |
| 2710 return L""; | 2709 return L""; |
| 2711 } | 2710 } |
| 2712 return link->m_strUrl; | 2711 return link->m_strUrl; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2729 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { | 2728 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { |
| 2730 return; | 2729 return; |
| 2731 } | 2730 } |
| 2732 CPDF_LinkExt* link = NULL; | 2731 CPDF_LinkExt* link = NULL; |
| 2733 link = m_LinkList.GetAt(index); | 2732 link = m_LinkList.GetAt(index); |
| 2734 if (!link) { | 2733 if (!link) { |
| 2735 return; | 2734 return; |
| 2736 } | 2735 } |
| 2737 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2736 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
| 2738 } | 2737 } |
| OLD | NEW |