summaryrefslogtreecommitdiff
path: root/core/fpdftext/cpdf_linkextract.h
blob: db82deb684d19a6ba6d7af75879d44caa121e2e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef CORE_FPDFTEXT_CPDF_LINKEXTRACT_H_
#define CORE_FPDFTEXT_CPDF_LINKEXTRACT_H_

#include <vector>

#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"

class CPDF_TextPage;

class CPDF_LinkExtract {
 public:
  explicit CPDF_LinkExtract(const CPDF_TextPage* pTextPage);
  ~CPDF_LinkExtract();

  void ExtractLinks();
  size_t CountLinks() const { return m_LinkArray.size(); }
  WideString GetURL(size_t index) const;
  std::vector<CFX_FloatRect> GetRects(size_t index) const;

 protected:
  void ParseLink();
  bool CheckWebLink(WideString* str, int32_t* nStart, int32_t* nCount);
  bool CheckMailLink(WideString* str);

 private:
  struct Link {
    int m_Start;
    int m_Count;
    WideString m_strUrl;
  };

  CFX_UnownedPtr<const CPDF_TextPage> const m_pTextPage;
  WideString m_strPageText;
  std::vector<Link> m_LinkArray;
};

#endif  // CORE_FPDFTEXT_CPDF_LINKEXTRACT_H_