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 #ifndef CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_ | 7 #ifndef CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_ |
8 #define CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_ | 8 #define CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_ |
9 | 9 |
| 10 #include <vector> |
| 11 |
10 #include "core/fxcrt/include/fx_basic.h" | 12 #include "core/fxcrt/include/fx_basic.h" |
11 #include "core/fxcrt/include/fx_coordinates.h" | 13 #include "core/fxcrt/include/fx_coordinates.h" |
12 #include "core/fxcrt/include/fx_string.h" | 14 #include "core/fxcrt/include/fx_string.h" |
13 #include "core/fxcrt/include/fx_system.h" | 15 #include "core/fxcrt/include/fx_system.h" |
14 | 16 |
15 class CPDF_TextPage; | 17 class CPDF_TextPage; |
16 | 18 |
17 class CPDF_LinkExt { | |
18 public: | |
19 CPDF_LinkExt() {} | |
20 ~CPDF_LinkExt() {} | |
21 | |
22 int m_Start; | |
23 int m_Count; | |
24 CFX_WideString m_strUrl; | |
25 }; | |
26 | |
27 class CPDF_LinkExtract { | 19 class CPDF_LinkExtract { |
28 public: | 20 public: |
29 CPDF_LinkExtract(); | 21 explicit CPDF_LinkExtract(const CPDF_TextPage* pTextPage); |
30 ~CPDF_LinkExtract(); | 22 ~CPDF_LinkExtract(); |
31 | 23 |
32 FX_BOOL ExtractLinks(const CPDF_TextPage* pTextPage); | 24 void ExtractLinks(); |
33 int CountLinks() const; | 25 size_t CountLinks() const { return m_LinkArray.size(); } |
34 CFX_WideString GetURL(int index) const; | 26 CFX_WideString GetURL(size_t index) const; |
35 void GetBoundedSegment(int index, int& start, int& count) const; | 27 void GetRects(size_t index, CFX_RectArray* pRects) const; |
36 void GetRects(int index, CFX_RectArray& rects) const; | |
37 | |
38 FX_BOOL IsExtract() const { return m_bIsParsed; } | |
39 | 28 |
40 protected: | 29 protected: |
41 void ParseLink(); | 30 void ParseLink(); |
42 void DeleteLinkList(); | 31 bool CheckWebLink(CFX_WideString& str); |
43 FX_BOOL CheckWebLink(CFX_WideString& strBeCheck); | |
44 bool CheckMailLink(CFX_WideString& str); | 32 bool CheckMailLink(CFX_WideString& str); |
45 void AppendToLinkList(int start, int count, const CFX_WideString& strUrl); | |
46 | 33 |
47 private: | 34 private: |
48 CFX_ArrayTemplate<CPDF_LinkExt*> m_LinkList; | 35 struct Link { |
49 const CPDF_TextPage* m_pTextPage; | 36 int m_Start; |
| 37 int m_Count; |
| 38 CFX_WideString m_strUrl; |
| 39 }; |
| 40 |
| 41 const CPDF_TextPage* const m_pTextPage; |
50 CFX_WideString m_strPageText; | 42 CFX_WideString m_strPageText; |
51 bool m_bIsParsed; | 43 std::vector<Link> m_LinkArray; |
52 }; | 44 }; |
53 | 45 |
54 #endif // CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_ | 46 #endif // CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_ |
OLD | NEW |