1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef CORE_FPDFTEXT_CPDF_LINKEXTRACT_H_ 8 #define CORE_FPDFTEXT_CPDF_LINKEXTRACT_H_ 9 10 #include <vector> 11 12 #include "core/fxcrt/fx_coordinates.h" 13 #include "core/fxcrt/fx_string.h" 14 #include "core/fxcrt/fx_system.h" 15 16 class CPDF_TextPage; 17 18 class CPDF_LinkExtract { 19 public: 20 explicit CPDF_LinkExtract(const CPDF_TextPage* pTextPage); 21 ~CPDF_LinkExtract(); 22 23 void ExtractLinks(); CountLinks()24 size_t CountLinks() const { return m_LinkArray.size(); } 25 WideString GetURL(size_t index) const; 26 std::vector<CFX_FloatRect> GetRects(size_t index) const; 27 28 protected: 29 void ParseLink(); 30 bool CheckWebLink(WideString* str, int32_t* nStart, int32_t* nCount); 31 bool CheckMailLink(WideString* str); 32 33 private: 34 struct Link { 35 int m_Start; 36 int m_Count; 37 WideString m_strUrl; 38 }; 39 40 UnownedPtr<const CPDF_TextPage> const m_pTextPage; 41 WideString m_strPageText; 42 std::vector<Link> m_LinkArray; 43 }; 44 45 #endif // CORE_FPDFTEXT_CPDF_LINKEXTRACT_H_ 46