Chromium Code Reviews| 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 <memory> | |
| 11 #include <vector> | |
| 12 | |
| 10 #include "core/fxcrt/include/fx_basic.h" | 13 #include "core/fxcrt/include/fx_basic.h" |
| 11 #include "core/fxcrt/include/fx_coordinates.h" | 14 #include "core/fxcrt/include/fx_coordinates.h" |
| 12 #include "core/fxcrt/include/fx_string.h" | 15 #include "core/fxcrt/include/fx_string.h" |
| 13 #include "core/fxcrt/include/fx_system.h" | 16 #include "core/fxcrt/include/fx_system.h" |
| 14 | 17 |
| 15 class CPDF_TextPage; | 18 class CPDF_TextPage; |
| 16 | 19 |
| 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 { | 20 class CPDF_LinkExtract { |
| 28 public: | 21 public: |
| 29 CPDF_LinkExtract(); | 22 CPDF_LinkExtract(const CPDF_TextPage* pTextPage); |
|
Lei Zhang
2016/04/19 23:52:06
explicit
| |
| 30 ~CPDF_LinkExtract(); | 23 ~CPDF_LinkExtract(); |
| 31 | 24 |
| 32 FX_BOOL ExtractLinks(const CPDF_TextPage* pTextPage); | 25 FX_BOOL ExtractLinks(); |
| 33 int CountLinks() const; | 26 int CountLinks() const; |
| 34 CFX_WideString GetURL(int index) const; | 27 CFX_WideString GetURL(int index) const; |
| 35 void GetBoundedSegment(int index, int& start, int& count) const; | 28 void GetBoundedSegment(int index, int& start, int& count) const; |
| 36 void GetRects(int index, CFX_RectArray& rects) const; | 29 void GetRects(int index, CFX_RectArray& rects) const; |
| 37 | 30 |
| 38 FX_BOOL IsExtract() const { return m_bIsParsed; } | 31 FX_BOOL IsExtract() const { return m_bIsParsed; } |
| 39 | 32 |
| 40 protected: | 33 protected: |
| 41 void ParseLink(); | 34 void ParseLink(); |
| 42 void DeleteLinkList(); | 35 void DeleteLinkList(); |
| 43 FX_BOOL CheckWebLink(CFX_WideString& strBeCheck); | 36 FX_BOOL CheckWebLink(CFX_WideString& strBeCheck); |
| 44 bool CheckMailLink(CFX_WideString& str); | 37 bool CheckMailLink(CFX_WideString& str); |
| 45 void AppendToLinkList(int start, int count, const CFX_WideString& strUrl); | |
| 46 | 38 |
| 47 private: | 39 private: |
| 48 CFX_ArrayTemplate<CPDF_LinkExt*> m_LinkList; | 40 class Item { |
| 49 const CPDF_TextPage* m_pTextPage; | 41 public: |
| 42 Item(int start, int count, const CFX_WideString& url) | |
| 43 : m_Start(start), m_Count(count), m_strUrl(url) {} | |
| 44 | |
| 45 int m_Start; | |
| 46 int m_Count; | |
| 47 CFX_WideString m_strUrl; | |
| 48 }; | |
| 49 | |
| 50 const CPDF_TextPage* const m_pTextPage; | |
| 51 bool m_bIsParsed; | |
| 50 CFX_WideString m_strPageText; | 52 CFX_WideString m_strPageText; |
| 51 bool m_bIsParsed; | 53 std::vector<std::unique_ptr<Item>> m_LinkList; |
|
Lei Zhang
2016/04/19 23:52:06
It's not actually a linked list.
dsinclair
2016/04/20 13:05:19
Why unique_ptr<Item> instead of just Item?
Tom Sepez
2016/04/20 19:07:39
Renamed.
Tom Sepez
2016/04/20 19:07:40
Even better. Then I can get rid of the ctor and j
| |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 #endif // CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_ | 56 #endif // CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_ |
| OLD | NEW |