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-2026 by Apryse Software 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 ConnectionErrorProc(const char* message, const int error_code, UChar switch_to_demo) {}
82 
83  static void StaticConnectionErrorProc(const char* message, const int error_code, UChar switch_to_demo, void* data)
84  {
85  Callback* cb = (Callback*)data;
86  cb->ConnectionErrorProc(message, error_code, switch_to_demo);
87  }
88 
89  virtual void APIDataOfflineProc(const char* api_data_json) {}
90 
91  static void StaticAPIDataOfflineProc(const char* api_data_json, void* user_data)
92  {
93  Callback* cb = (Callback*)user_data;
94  cb->APIDataOfflineProc(api_data_json);
95  }
96 
97  virtual void ThumbAsyncHandler(int page_num, bool was_thumb_found, const char* thumb_buf, int thumb_width, int thumb_height) {}
98 
99  static void StaticThumbAsyncHandler(int page_num, bool was_thumb_found, const char* thumb_buf, int thumb_width, int thumb_height, void* custom_data)
100  {
101  Callback* cb = (Callback*) custom_data;
102  cb->ThumbAsyncHandler(page_num, was_thumb_found, thumb_buf, thumb_width, thumb_height);
103  }
104 
105  virtual void RequestRenderInWorkerThread() {}
106 
107  static void StaticRequestRenderInWorkerThread(void* custom_data)
108  {
109  Callback* cb = (Callback*) custom_data;
110  cb->RequestRenderInWorkerThread();
111  }
112 
113  virtual void FindTextHandler(bool success, PDF::Selection selection) {}
114 
115  static void StaticFindTextHandler(bool success, PDF::Selection selection, void* custom_data)
116  {
117  Callback* cb = (Callback*) custom_data;
118  cb->FindTextHandler(success, selection);
119  }
120 
121  virtual void CreateTileProc(
122  char* buffer, int originX, int originY, int width, int height,
123  int pagNum, long long cellNumber,
124  bool finalRender, bool predictionRender,
125  int tilesRemaining, bool firstTile,
126  int canvasWidth, int canvasHeight, int cellSideLength, int cellPerRow, int cellPerCol,
127  int thumbnailId
128  ) { }
129 
130  static void StaticCreateTileProc(
131  void* customData,
132  char* buffer, int originX, int originY, int width, int height,
133  int pageNum, long long cellNumber,
134  bool finalRender, bool predictionRender,
135  int tilesRemaining, bool firstTile,
136  int canvasWidth, int canvasHeight, int cellSideLength, int cellPerRow, int cellPerCol,
137  int thumbnailId
138  )
139  {
140  Callback* cb = (Callback*) customData;
141  cb->CreateTileProc(
142  buffer, originX, originY, width, height,
143  pageNum, cellNumber,
144  finalRender, predictionRender,
145  tilesRemaining, firstTile,
146  canvasWidth, canvasHeight, cellSideLength, cellPerRow, cellPerCol,
147  thumbnailId
148  );
149  }
150 
151  virtual void AnnotBitmapProc(int operation_type,
152  char* buffer, UInt32 width, UInt32 height, UInt32 stride,
153  UInt32 page_num, UInt32 annot_index, const void* annot_key,
154  Int64 x_in_page, Int64 y_in_page, int x_offset, int y_offset,
155  int remaining_tiles, int sequence_number, Int64 x_page_size, Int64 y_page_size) {}
156 
157  static void StaticAnnotBitmapProc(void* me, int operation_type,
158  char* buffer, UInt32 width, UInt32 height, UInt32 stride,
159  UInt32 page_num, UInt32 annot_index, const void* annot_key,
160  Int64 x_in_page, Int64 y_in_page, int x_offset, int y_offset,
161  int remaining_tiles, int sequence_number, Int64 x_page_size, Int64 y_page_size)
162  {
163  Callback* cb = (Callback*) me;
164  cb->AnnotBitmapProc(operation_type, buffer,
165  width, height, stride,
166  page_num, annot_index, annot_key,
167  x_in_page, y_in_page, x_offset, y_offset,
168  remaining_tiles, sequence_number, x_page_size, y_page_size);
169  }
170 
171 
172  /* deluxe start */
173 
174 virtual void DeluxeCreateTileProc(
175  char* buffer, unsigned int width, unsigned int height, unsigned int stride,
176  unsigned int page_num, UInt64 x_page_loc, UInt64 y_page_loc,
177  unsigned int zoomed_page_width, unsigned int zoomed_page_height,
178  unsigned int tile_id, unsigned int x_in_page, unsigned int y_in_page,
179  int canvas_id, int remaining_tiles, int tile_type,
180  int sequence_number
181  ) { }
182 
183  static void StaticDeluxeCreateTileProc(
184  void* me,
185  char* buffer, unsigned int width, unsigned int height, unsigned int stride,
186  unsigned int page_num, UInt64 x_page_loc, UInt64 y_page_loc,
187  unsigned int zoomed_page_width, unsigned int zoomed_page_height,
188  unsigned int tile_id, unsigned int x_in_page, unsigned int y_in_page,
189  int canvas_id, int remaining_tiles, int tile_type,
190  int sequence_number
191  )
192  {
193  Callback* cb = (Callback*) me;
194  cb->DeluxeCreateTileProc(
195  buffer, width, height, stride,
196  page_num, x_page_loc, y_page_loc,
197  zoomed_page_width, zoomed_page_height,
198  tile_id, x_in_page, y_in_page,
199  canvas_id, remaining_tiles, tile_type,
200  sequence_number
201  );
202  }
203 
204  /* deluxe end */
205 
206  virtual void RemoveTileProc(int canvasNumber, Int64 cellNumber, int thumbnailId, int sequenceNumber) { }
207 
208  static void StaticRemoveTileProc(void* customData, int canvasNumber, Int64 cellNumber, int thumbnailId, int sequenceNumber)
209  {
210  Callback* cb = (Callback*) customData;
211  cb->RemoveTileProc(canvasNumber, cellNumber, thumbnailId, sequenceNumber);
212  }
213 
214  virtual void PartDownloadedProc(int dlType, TRN_PDFDoc doc, unsigned int pageNum, unsigned int objNum, const char* message) { }
215 
216  static void StaticPartDownloadedProc(int dlType, TRN_PDFDoc doc, unsigned int pageNum, unsigned int objNum, const char* message, void* customData)
217  {
218  Callback* cb = (Callback*) customData;
219  cb->PartDownloadedProc(dlType, doc, pageNum, objNum, message);
220  }
221 };
222 
223  }; // namespace PDF
224 }; // namespace pdftron
225 
226 #endif // SWIG
227 
228 #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
TRN_UChar UChar
Definition: BasicTypes.h:12