| 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 2596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2607 FX_WCHAR ch = strBeCheck.GetAt(strBeCheck.GetLength() - 1); | 2607 FX_WCHAR ch = strBeCheck.GetAt(strBeCheck.GetLength() - 1); |
| 2608 if (ch == L')' || ch == L',' || ch == L'>' || ch == L'.') { | 2608 if (ch == L')' || ch == L',' || ch == L'>' || ch == L'.') { |
| 2609 strBeCheck = strBeCheck.Mid(0, strBeCheck.GetLength() - 1); | 2609 strBeCheck = strBeCheck.Mid(0, strBeCheck.GetLength() - 1); |
| 2610 nCount--; | 2610 nCount--; |
| 2611 } else { | 2611 } else { |
| 2612 break; | 2612 break; |
| 2613 } | 2613 } |
| 2614 } | 2614 } |
| 2615 if (nCount > 5 && | 2615 if (nCount > 5 && |
| 2616 (CheckWebLink(strBeCheck) || CheckMailLink(strBeCheck))) { | 2616 (CheckWebLink(strBeCheck) || CheckMailLink(strBeCheck))) { |
| 2617 if (!AppendToLinkList(start, nCount, strBeCheck)) { | 2617 AppendToLinkList(start, nCount, strBeCheck); |
| 2618 break; | |
| 2619 } | |
| 2620 } | 2618 } |
| 2621 } | 2619 } |
| 2622 start = ++pos; | 2620 start = ++pos; |
| 2623 } else { | 2621 } else { |
| 2624 pos++; | 2622 pos++; |
| 2625 } | 2623 } |
| 2626 } | 2624 } |
| 2627 } | 2625 } |
| 2628 FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) { | 2626 FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) { |
| 2629 CFX_WideString str = strBeCheck; | 2627 CFX_WideString str = strBeCheck; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2723 continue; | 2721 continue; |
| 2724 } else { | 2722 } else { |
| 2725 return FALSE; | 2723 return FALSE; |
| 2726 } | 2724 } |
| 2727 } | 2725 } |
| 2728 if (str.Find(L"mailto:") == -1) { | 2726 if (str.Find(L"mailto:") == -1) { |
| 2729 str = L"mailto:" + str; | 2727 str = L"mailto:" + str; |
| 2730 } | 2728 } |
| 2731 return TRUE; | 2729 return TRUE; |
| 2732 } | 2730 } |
| 2733 FX_BOOL CPDF_LinkExtract::AppendToLinkList(int start, | 2731 |
| 2734 int count, | 2732 void CPDF_LinkExtract::AppendToLinkList(int start, |
| 2735 const CFX_WideString& strUrl) { | 2733 int count, |
| 2734 const CFX_WideString& strUrl) { |
| 2736 CPDF_LinkExt* linkInfo = new CPDF_LinkExt; | 2735 CPDF_LinkExt* linkInfo = new CPDF_LinkExt; |
| 2737 linkInfo->m_strUrl = strUrl; | 2736 linkInfo->m_strUrl = strUrl; |
| 2738 linkInfo->m_Start = start; | 2737 linkInfo->m_Start = start; |
| 2739 linkInfo->m_Count = count; | 2738 linkInfo->m_Count = count; |
| 2740 m_LinkList.Add(linkInfo); | 2739 m_LinkList.Add(linkInfo); |
| 2741 return TRUE; | |
| 2742 } | 2740 } |
| 2741 |
| 2743 CFX_WideString CPDF_LinkExtract::GetURL(int index) const { | 2742 CFX_WideString CPDF_LinkExtract::GetURL(int index) const { |
| 2744 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { | 2743 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { |
| 2745 return L""; | 2744 return L""; |
| 2746 } | 2745 } |
| 2747 CPDF_LinkExt* link = NULL; | 2746 CPDF_LinkExt* link = NULL; |
| 2748 link = m_LinkList.GetAt(index); | 2747 link = m_LinkList.GetAt(index); |
| 2749 if (!link) { | 2748 if (!link) { |
| 2750 return L""; | 2749 return L""; |
| 2751 } | 2750 } |
| 2752 return link->m_strUrl; | 2751 return link->m_strUrl; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2769 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { | 2768 if (!m_IsParserd || index < 0 || index >= m_LinkList.GetSize()) { |
| 2770 return; | 2769 return; |
| 2771 } | 2770 } |
| 2772 CPDF_LinkExt* link = NULL; | 2771 CPDF_LinkExt* link = NULL; |
| 2773 link = m_LinkList.GetAt(index); | 2772 link = m_LinkList.GetAt(index); |
| 2774 if (!link) { | 2773 if (!link) { |
| 2775 return; | 2774 return; |
| 2776 } | 2775 } |
| 2777 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); | 2776 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); |
| 2778 } | 2777 } |
| OLD | NEW |