| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdftext/cpdf_linkextract.h" | 7 #include "core/fpdftext/cpdf_linkextract.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // Check the local part. | 101 // Check the local part. |
| 102 int pPos = aPos; // Used to track the position of '@' or '.'. | 102 int pPos = aPos; // Used to track the position of '@' or '.'. |
| 103 for (int i = aPos - 1; i >= 0; i--) { | 103 for (int i = aPos - 1; i >= 0; i--) { |
| 104 FX_WCHAR ch = str.GetAt(i); | 104 FX_WCHAR ch = str.GetAt(i); |
| 105 if (ch == L'_' || ch == L'-' || FXSYS_iswalnum(ch)) | 105 if (ch == L'_' || ch == L'-' || FXSYS_iswalnum(ch)) |
| 106 continue; | 106 continue; |
| 107 | 107 |
| 108 if (ch != L'.' || i == pPos - 1 || i == 0) { | 108 if (ch != L'.' || i == pPos - 1 || i == 0) { |
| 109 if (i == aPos - 1) { | 109 if (i == aPos - 1) { |
| 110 // There is '.' or invalid char before '@'. | 110 // There is '.' or invalid char before '@'. |
| 111 return FALSE; | 111 return false; |
| 112 } | 112 } |
| 113 // End extracting for other invalid chars, '.' at the beginning, or | 113 // End extracting for other invalid chars, '.' at the beginning, or |
| 114 // consecutive '.'. | 114 // consecutive '.'. |
| 115 int removed_len = i == pPos - 1 ? i + 2 : i + 1; | 115 int removed_len = i == pPos - 1 ? i + 2 : i + 1; |
| 116 str = str.Right(str.GetLength() - removed_len); | 116 str = str.Right(str.GetLength() - removed_len); |
| 117 break; | 117 break; |
| 118 } | 118 } |
| 119 // Found a valid '.'. | 119 // Found a valid '.'. |
| 120 pPos = i; | 120 pPos = i; |
| 121 } | 121 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 return index < m_LinkArray.size() ? m_LinkArray[index].m_strUrl : L""; | 164 return index < m_LinkArray.size() ? m_LinkArray[index].m_strUrl : L""; |
| 165 } | 165 } |
| 166 | 166 |
| 167 std::vector<CFX_FloatRect> CPDF_LinkExtract::GetRects(size_t index) const { | 167 std::vector<CFX_FloatRect> CPDF_LinkExtract::GetRects(size_t index) const { |
| 168 if (index >= m_LinkArray.size()) | 168 if (index >= m_LinkArray.size()) |
| 169 return std::vector<CFX_FloatRect>(); | 169 return std::vector<CFX_FloatRect>(); |
| 170 | 170 |
| 171 return m_pTextPage->GetRectArray(m_LinkArray[index].m_Start, | 171 return m_pTextPage->GetRectArray(m_LinkArray[index].m_Start, |
| 172 m_LinkArray[index].m_Count); | 172 m_LinkArray[index].m_Count); |
| 173 } | 173 } |
| OLD | NEW |