All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Callback.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_CPPPDFCallback
6 #define PDFTRON_H_CPPPDFCallback
7 
8 #ifdef SWIG
9 
10 #include <C/Common/TRN_Types.h>
11 #include <Common/BasicTypes.h>
12 #include <PDF/Selection.h>
13 
14 namespace pdftron {
15  namespace PDF {
16 
25 class Callback
26 {
27 public:
28  Callback() {}
29  virtual ~Callback() {
30  }
31 
32 // PDFView Callbacks
33  virtual void RenderBeginEventProc(){}
34 
35  static void StaticRenderBeginEventProc(void* data)
36  {
37  Callback* cb = (Callback*) data;
38  cb->RenderBeginEventProc();
39  }
40 
41  virtual void RenderFinishEventProc(bool cancelled){}
42 
43  static void StaticRenderFinishEventProc(void* data, bool cancelled)
44  {
45  Callback* cb = (Callback*) data;
46  cb->RenderFinishEventProc(cancelled);
47  }
48 
49  virtual void ErrorReportProc (const char* message) {}
50 
51  static void StaticErrorReportProc (const char* message, void* data)
52  {
53  Callback* cb = (Callback*) data;
54  cb->ErrorReportProc(message);
55  }
56 
57  virtual void CurrentPageProc(int current_page, int num_pages) {}
58 
59  static void StaticCurrentPageProc(int current_page, int num_pages, void* data)
60  {
61  Callback* cb = (Callback*) data;
62  cb->CurrentPageProc(current_page, num_pages);
63  }
64 
65  virtual void JavaScriptEventProc(const char* event_type, const char* json) {}
66 
67  static void StaticJavaScriptEventProc(const char* event_type, const char* json, void* data)
68  {
69  Callback* cb= (Callback*) data;
70  cb->JavaScriptEventProc(event_type,json);
71  }
72 
73  virtual void CurrentZoomProc(double curr_zoom_proc) {}
74 
75  static void StaticCurrentZoomProc(double curr_zoom_proc, void* data)
76  {
77  Callback* cb = (Callback*) data;
78  cb->CurrentZoomProc(curr_zoom_proc);
79  }
80 
81  virtual void ThumbAsyncHandler(int page_num, bool was_thumb_found, const char* thumb_buf, int thumb_width, int thumb_height) {}
82 
83  static void StaticThumbAsyncHandler(int page_num, bool was_thumb_found, const char* thumb_buf, int thumb_width, int thumb_height, void* custom_data)
84  {
85  Callback* cb = (Callback*) custom_data;
86  cb->ThumbAsyncHandler(page_num, was_thumb_found, thumb_buf, thumb_width, thumb_height);
87  }
88 
89  virtual void RequestRenderInWorkerThread() {}
90 
91  static void StaticRequestRenderInWorkerThread(void* custom_data)
92  {
93  Callback* cb = (Callback*) custom_data;
94  cb->RequestRenderInWorkerThread();
95  }
96 
97  virtual void FindTextHandler(bool success, PDF::Selection selection) {}
98 
99  static void StaticFindTextHandler(bool success, PDF::Selection selection, void* custom_data)
100  {
101  Callback* cb = (Callback*) custom_data;
102  cb->FindTextHandler(success, selection);
103  }
104 
105  virtual void CreateTileProc(
106  char* buffer, int originX, int originY, int width, int height,
107  int pagNum, long long cellNumber,
108  bool finalRender, bool predictionRender,
109  int tilesRemaining, bool firstTile,
110  int canvasWidth, int canvasHeight, int cellSideLength, int cellPerRow, int cellPerCol,
111  int thumbnailId
112  ) { }
113 
114  static void StaticCreateTileProc(
115  void* customData,
116  char* buffer, int originX, int originY, int width, int height,
117  int pageNum, long long cellNumber,
118  bool finalRender, bool predictionRender,
119  int tilesRemaining, bool firstTile,
120  int canvasWidth, int canvasHeight, int cellSideLength, int cellPerRow, int cellPerCol,
121  int thumbnailId
122  )
123  {
124  Callback* cb = (Callback*) customData;
125  cb->CreateTileProc(
126  buffer, originX, originY, width, height,
127  pageNum, cellNumber,
128  finalRender, predictionRender,
129  tilesRemaining, firstTile,
130  canvasWidth, canvasHeight, cellSideLength, cellPerRow, cellPerCol,
131  thumbnailId
132  );
133  }
134 
135  virtual void AnnotBitmapProc(int operation_type,
136  char* buffer, UInt32 width, UInt32 height, UInt32 stride,
137  UInt32 page_num, UInt32 annot_index, const void* annot_key,
138  Int64 x_in_page, Int64 y_in_page, int x_offset, int y_offset,
139  int remaining_tiles, int sequence_number, Int64 x_page_size, Int64 y_page_size) {}
140 
141  static void StaticAnnotBitmapProc(void* me, int operation_type,
142  char* buffer, UInt32 width, UInt32 height, UInt32 stride,
143  UInt32 page_num, UInt32 annot_index, const void* annot_key,
144  Int64 x_in_page, Int64 y_in_page, int x_offset, int y_offset,
145  int remaining_tiles, int sequence_number, Int64 x_page_size, Int64 y_page_size)
146  {
147  Callback* cb = (Callback*) me;
148  cb->AnnotBitmapProc(operation_type, buffer,
149  width, height, stride,
150  page_num, annot_index, annot_key,
151  x_in_page, y_in_page, x_offset, y_offset,
152  remaining_tiles, sequence_number, x_page_size, y_page_size);
153  }
154 
155 
156  /* deluxe start */
157 
158 virtual void DeluxeCreateTileProc(
159  char* buffer, unsigned int width, unsigned int height, unsigned int stride,
160  unsigned int page_num, UInt64 x_page_loc, UInt64 y_page_loc,
161  unsigned int zoomed_page_width, unsigned int zoomed_page_height,
162  unsigned int tile_id, unsigned int x_in_page, unsigned int y_in_page,
163  int canvas_id, int remaining_tiles, int tile_type,
164  int sequence_number
165  ) { }
166 
167  static void StaticDeluxeCreateTileProc(
168  void* me,
169  char* buffer, unsigned int width, unsigned int height, unsigned int stride,
170  unsigned int page_num, UInt64 x_page_loc, UInt64 y_page_loc,
171  unsigned int zoomed_page_width, unsigned int zoomed_page_height,
172  unsigned int tile_id, unsigned int x_in_page, unsigned int y_in_page,
173  int canvas_id, int remaining_tiles, int tile_type,
174  int sequence_number
175  )
176  {
177  Callback* cb = (Callback*) me;
178  cb->DeluxeCreateTileProc(
179  buffer, width, height, stride,
180  page_num, x_page_loc, y_page_loc,
181  zoomed_page_width, zoomed_page_height,
182  tile_id, x_in_page, y_in_page,
183  canvas_id, remaining_tiles, tile_type,
184  sequence_number
185  );
186  }
187 
188  /* deluxe end */
189 
190  virtual void RemoveTileProc(int canvasNumber, Int64 cellNumber, int thumbnailId, int sequenceNumber) { }
191 
192  static void StaticRemoveTileProc(void* customData, int canvasNumber, Int64 cellNumber, int thumbnailId, int sequenceNumber)
193  {
194  Callback* cb = (Callback*) customData;
195  cb->RemoveTileProc(canvasNumber, cellNumber, thumbnailId, sequenceNumber);
196  }
197 
198  virtual void PartDownloadedProc(int dlType, TRN_PDFDoc doc, unsigned int pageNum, unsigned int objNum, const char* message) { }
199 
200  static void StaticPartDownloadedProc(int dlType, TRN_PDFDoc doc, unsigned int pageNum, unsigned int objNum, const char* message, void* customData)
201  {
202  Callback* cb = (Callback*) customData;
203  cb->PartDownloadedProc(dlType, doc, pageNum, objNum, message);
204  }
205 };
206 
207  }; // namespace PDF
208 }; // namespace pdftron
209 
210 #endif // SWIG
211 
212 #endif // PDFTRON_H_CPPPDFCallback
TRN_Int64 Int64
Definition: BasicTypes.h:20
TRN_UInt64 UInt64
Definition: BasicTypes.h:21
TRN_UInt32 UInt32
Definition: BasicTypes.h:13