All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Selection.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2020 by PDFTron Systems Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPSelection
6 #define PDFTRON_H_CPPSelection
7 
8 #include <C/Common/TRN_Types.h>
9 #include <C/PDF/TRN_PDFView.h>
10 namespace pdftron {
11  namespace PDF {
15  class Selection {
16  friend class PDFView;
17  friend class PDFViewCtrl;
18  public:
22  int GetPageNum() const;
23 
48  std::vector<QuadPoint> GetQuads() const;
49 
50 
54  UString GetAsUnicode() const;
55 
56 
63  const char* GetAsHtml() const;
64 
65 #if !defined(SWIG)
66  int GetQuads(const double* & quads) const;
67  void GetAsUnicode(UString& out_str) const;
68 #endif // !defined(SWIG)
69 
70  // @cond PRIVATE_DOC
71 
72 #ifndef SWIGHIDDEN
73  ~Selection();
74  Selection();
75  Selection(const Selection&);
76  Selection& operator=(const Selection&);
77  Selection(TRN_PDFViewSelection impl);
78  private:
79  TRN_PDFViewSelection mp_selection;
80 #endif
81  // @endcond
82 
83  };
84 
85  inline Selection::Selection()
86  {
87  REX(TRN_PDFViewSelectionCreate(&mp_selection));
88  }
89 
90  inline Selection::~Selection()
91  {
92  DREX(mp_selection, TRN_PDFViewSelectionDestroy(mp_selection));
93  }
94 
95  inline Selection::Selection(const Selection& s)
96  {
97  REX(TRN_PDFViewSelectionCreate(&mp_selection));
98  REX(TRN_PDFViewSelectionAssign(mp_selection,s.mp_selection));
99  }
100 
101  inline Selection::Selection(TRN_PDFViewSelection impl) : mp_selection(impl)
102  {
103 
104  }
105 
106  inline Selection& Selection::operator=(const Selection& s)
107  {
108  REX(TRN_PDFViewSelectionAssign(mp_selection,s.mp_selection));
109  return *this;
110  }
111 
112 
113 
114  inline int Selection::GetPageNum() const
115  {
116  RetInt(TRN_PDFViewSelectionGetPageNum(mp_selection,&result));
117  }
118 
119  //inline int Selection::GetRects(const double* &rects) const
120  //{
121  // RetInt(TRN_PDFViewSelectionGetRects(&mp_selection,&rects,&result));
122  //}
123 
124  inline std::vector<QuadPoint> Selection::GetQuads() const
125  {
126  int num;
127  double* quads;
128  TRN_PDFViewSelectionGetQuads(mp_selection,(const double**)&quads,&num);
129  std::vector<QuadPoint> result(num);
130  int i;
131  for(i = 0; i < num; i++) {
132  Point p1 = Point(quads[i*8+0], quads[i*8+1]);
133  Point p2 = Point(quads[i*8+2], quads[i*8+3]);
134  Point p3 = Point(quads[i*8+4], quads[i*8+5]);
135  Point p4 = Point(quads[i*8+6], quads[i*8+7]);
136  result[i] = QuadPoint(p1, p2, p3, p4);
137  }
138  return result;
139  }
140 
142  {
143  UString unicodeStr;
144  REX(TRN_PDFViewSelectionGetAsUnicode(mp_selection, unicodeStr.mp_impl));
145  return unicodeStr;
146  }
147 
148  inline const char* Selection::GetAsHtml() const
149  {
150  RetCCS(TRN_PDFViewSelectionGetAsHtml(mp_selection, &result));
151  }
152 
153 #if !defined(SWIG)
154  inline int Selection::GetQuads(const double* & quads) const
155  {
156  RetInt(TRN_PDFViewSelectionGetQuads(mp_selection,&quads,&result));
157  }
158 
159  inline void Selection::GetAsUnicode(UString& out_str) const
160  {
161  REX(TRN_PDFViewSelectionGetAsUnicode(mp_selection, out_str.mp_impl));
162  }
163 #endif // !defined(SWIG)
164 
165  } // PDF
166 } // PDFTron
167 
168 
169 #endif // PDFTRON_H_CPPSelection
std::vector< QuadPoint > GetQuads() const
Definition: Selection.h:124
#define RetCCS(ex)
Definition: Common.h:24
#define RetInt(ex)
Definition: Common.h:23
int GetPageNum() const
Definition: Selection.h:114
#define REX(action)
Definition: Common.h:13
#define DREX(impl, destroy_action)
Definition: Common.h:14
const char * GetAsHtml() const
Definition: Selection.h:148
UString GetAsUnicode() const
Definition: Selection.h:141