1 // Copyright 2014 The PDFium Authors 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 <stddef.h> 11 #include <stdint.h> 12 13 #include <vector> 14 15 #include "core/fxcrt/fx_coordinates.h" 16 #include "core/fxcrt/unowned_ptr.h" 17 #include "core/fxcrt/widestring.h" 18 #include "third_party/abseil-cpp/absl/types/optional.h" 19 20 class CPDF_TextPage; 21 22 class CPDF_LinkExtract { 23 public: 24 struct Range { 25 size_t m_Start; 26 size_t m_Count; 27 }; 28 29 explicit CPDF_LinkExtract(const CPDF_TextPage* pTextPage); 30 ~CPDF_LinkExtract(); 31 32 void ExtractLinks(); CountLinks()33 size_t CountLinks() const { return m_LinkArray.size(); } 34 WideString GetURL(size_t index) const; 35 std::vector<CFX_FloatRect> GetRects(size_t index) const; 36 absl::optional<Range> GetTextRange(size_t index) const; 37 38 protected: 39 struct Link : public Range { 40 WideString m_strUrl; 41 }; 42 43 absl::optional<Link> CheckWebLink(const WideString& str); 44 bool CheckMailLink(WideString* str); 45 46 UnownedPtr<const CPDF_TextPage> const m_pTextPage; 47 std::vector<Link> m_LinkArray; 48 }; 49 50 #endif // CORE_FPDFTEXT_CPDF_LINKEXTRACT_H_ 51