Fix for a crash which happened when a document couldn't be opened.
[AROS-Contrib.git] / vpdf / poppler_dummy.cpp
blob94b9b5e2f0ee930dd4cb66abe3a5c1b3a09d0ac8
1 /*
2 * Wrap poppler document class functions into c functions.
3 */
5 //#define USE_SPLASH
7 #include "Object.h"
9 #define AROS_ALMOST_COMPATIBLE
10 #define _NO_PPCINLINE
11 #include <proto/keymap.h>
12 #include <proto/exec.h>
13 #include <proto/dos.h>
14 #include <clib/debug_protos.h>
15 #include <exec/semaphores.h>
16 #include <exec/lists.h>
17 #include <constructor.h>
19 #define USE_FLOAT 1
20 #include <poppler-config.h>
22 #include <stddef.h>
23 #include <stdlib.h>
24 #include <memory.h>
25 #include <math.h>
27 #include "PDFDoc.h"
28 #include "Outline.h"
29 #include "Link.h"
30 #include "GlobalParams.h"
31 #include "goo/GooList.h"
33 #define USE_SPLASH
34 #ifdef USE_SPLASH
35 #include "splash/SplashBitmap.h"
36 #include "splash/Splash.h"
37 #include "SplashOutputDev.h"
38 #include "TextOutputDev.h"
39 #else
40 #include "CairoOutputDev.h"
41 #endif
43 #include "poppler.h"
44 #include "poppler_io.h"
47 extern struct Library *LocaleBase;
48 #define LOCALE_BASE_NAME LocaleBase
49 #define IsUnicode(__p0, __p1) \
50 (((ULONG (*)(APTR , ULONG , void *))*(void**)((long)(LOCALE_BASE_NAME) - 430))(__p0, __p1, (void*)(LOCALE_BASE_NAME)))
52 #warning TODO: make the semaphore per-document
53 static struct SignalSemaphore semaphore;
55 extern struct Library *CairoBase;
57 struct searchresult {
58 struct MinNode n;
59 double x1, y1, x2, y2; // bounding rectangle in pdf points
62 struct searchcontext {
63 MinList searchresultlist;
64 struct searchresult *currentsearchresult; // current node on a page;
65 int page;
66 char *phrase; // on which page we are currently searching
69 #ifdef USE_SPLASH
70 struct devicecontext {
71 PDFDoc *doc;
72 BaseStream *stream;
73 SplashOutputDev *dev;
74 struct searchcontext search;
76 #else
77 struct devicecontext {
78 PDFDoc *doc;
79 BaseStream *stream;
80 CairoOutputDev *dev;
81 cairo_surface_t *surface;
82 cairo_t *cairo;
83 struct searchcontext search;
85 #endif
87 static CONSTRUCTOR_P(init_poppler, 0)
89 InitSemaphore(&semaphore);
90 return 0;
93 static DESTRUCTOR_P(cleanup_poppler, 0)
95 kprintf("destroy poppler:%p\n", &semaphore);
98 #define ENTER_SECTION ObtainSemaphore(&semaphore);
99 //#define ENTER_SECTION
100 #define LEAVE_SECTION ReleaseSemaphore(&semaphore);
101 //#define LEAVE_SECTION
104 void *pdfNew(const char *fname)
106 return NULL;
109 void pdfDelete(void *_ctx)
113 float pdfGetPageMediaWidth(void *_ctx, int page)
115 return 0;
118 float pdfGetPageMediaHeight(void *_ctx, int page)
120 return 0;
123 int pdfGetPagesNum(void *_ctx)
125 return 0;
128 static GBool renderabortchk(void *data)
130 printf("abort check...\n");
131 return 0;
134 void pdfDisplayPageSlice(void *_ctx, int page, double scale, int rotate,
135 int useMediaBox, int crop, int printing, int sliceX, int sliceY, int sliceW, int sliceH, int (*abortcheckcbk)(void *), void *abortcheckcbkdata)
139 unsigned char *pdfGetBitmapRowData(void *_ctx, int row)
141 return NULL;
144 int pdfGetBitmapWidth(void *_ctx)
146 return 0;
149 int pdfGetBitmapHeight(void *_ctx)
151 return 0;
155 struct MinList *pdfGetOutlines(void *_ctx)
157 return NULL;
160 int outlineHasChildren(void *_outline)
162 return FALSE;
165 struct MinList *outlineGetChildren(void *_outline)
167 return NULL;
171 char *outlineGetTitle(void *_outline)
173 return NULL;
176 int outlineGetPage(void *_outline)
178 return 0;
183 void
184 poppler_page_get_size (Page *page,
185 double *width,
186 double *height)
190 void pdfConvertUserToDevice(void *_ctx, double* x, double* y)
194 void pdfConvertDeviceToUser(void *_ctx, int page, double x, double y, int *ix, int *iy)
198 void pdfLock(void *_ctx)
201 void pdfRelease(void *_ctx)
206 void *pdfFindLink(void *_ctx, int pagenum, int x, int y)
208 return NULL;
211 void pdfListLinks(void *_ctx, int pagenum)
215 char *linkGetDescription(void *_link)
217 return NULL;
220 int pdfGetActionPageFromLink(void *_ctx, void *_link)
222 return 0;
225 int pdfSearch(void *_ctx, int *page, char *phrase, double *x1, double *y1, double *x2, double *y2)
227 return 0;