1 /* Copyright Krzysztof Kowalczyk 2006-2007
16 class SplashOutputDev
;
20 extern const char* const LINK_ACTION_GOTO
;
21 extern const char* const LINK_ACTION_GOTOR
;
22 extern const char* const LINK_ACTION_LAUNCH
;
23 extern const char* const LINK_ACTION_URI
;
24 extern const char* const LINK_ACTION_NAMED
;
25 extern const char* const LINK_ACTION_MOVIE
;
27 /* For simplicity, all in one file. Would be cleaner if they were
28 in separate files PdfEngineFitz.h and PdfEnginePoppler.h */
30 #define INVALID_PAGE_NO -1
31 #define INVALID_ROTATION -1
32 /* It seems that PDF documents are encoded assuming DPI of 72.0 */
33 #define PDF_FILE_DPI 72
35 void SplashColorsInit(void);
37 /* Abstract class representing cached bitmap. Allows different implementations
38 on different platforms. */
39 class RenderedBitmap
{
41 virtual ~RenderedBitmap() {};
44 virtual int rowSize() = 0;
45 virtual unsigned char *data() = 0;
47 // TODO: this is for WINDOWS only
48 virtual HBITMAP
createDIBitmap(HDC
) = 0;
49 virtual void stretchDIBits(HDC
, int, int, int, int) = 0;
52 class RenderedBitmapFitz
: public RenderedBitmap
{
54 RenderedBitmapFitz(fz_pixmap
*);
55 virtual ~RenderedBitmapFitz();
57 virtual int dx() { return _bitmap
->w
; }
58 virtual int dy() { return _bitmap
->h
; }
59 virtual int rowSize();
60 virtual unsigned char *data();
62 virtual HBITMAP
createDIBitmap(HDC
);
63 virtual void stretchDIBits(HDC
, int, int, int, int);
68 class RenderedBitmapSplash
: public RenderedBitmap
{
70 RenderedBitmapSplash(SplashBitmap
*);
71 virtual ~RenderedBitmapSplash();
75 virtual int rowSize();
76 virtual unsigned char *data();
78 virtual HBITMAP
createDIBitmap(HDC
);
79 virtual void stretchDIBits(HDC
, int, int, int, int);
82 SplashBitmap
*_bitmap
;
89 , _pageCount(INVALID_PAGE_NO
)
92 virtual ~PdfEngine() { free((void*)_fileName
); }
94 const char *fileName(void) const { return _fileName
; };
96 void setFileName(const char *fileName
) {
98 _fileName
= (const char*)strdup(fileName
);
101 bool validPageNo(int pageNo
) const {
102 if ((pageNo
>= 1) && (pageNo
<= pageCount()))
107 int pageCount(void) const { return _pageCount
; }
109 virtual bool load(const char *fileName
, WindowInfo
*windowInfo
) = 0;
110 virtual int pageRotation(int pageNo
) = 0;
111 virtual SizeD
pageSize(int pageNo
) = 0;
112 virtual RenderedBitmap
*renderBitmap(int pageNo
, double zoomReal
, int rotation
,
113 BOOL (*abortCheckCbkA
)(void *data
),
114 void *abortCheckCbkDataA
) = 0;
116 virtual bool printingAllowed() = 0;
117 virtual int linkCount(int pageNo
) = 0;
118 virtual const char* linkType(int pageNo
, int linkNo
) = 0;
121 const char *_fileName
;
123 WindowInfo
*_windowInfo
;
126 class PdfEnginePoppler
: public PdfEngine
{
129 virtual ~PdfEnginePoppler();
130 virtual bool load(const char *fileName
, WindowInfo
* windowInfo
);
131 virtual int pageRotation(int pageNo
);
132 virtual SizeD
pageSize(int pageNo
);
133 virtual RenderedBitmap
*renderBitmap(int pageNo
, double zoomReal
, int rotation
,
134 BOOL (*abortCheckCbkA
)(void *data
),
135 void *abortCheckCbkDataA
);
137 virtual bool printingAllowed();
138 virtual int linkCount(int pageNo
);
139 virtual const char* linkType(int pageNo
, int linkNo
);
141 PDFDoc
* pdfDoc() { return _pdfDoc
; }
142 SplashOutputDev
* outputDevice();
144 Links
* getLinksForPage(int pageNo
);
147 SplashOutputDev
* _outputDev
;
148 Links
** _linksForPage
;
151 class PdfEngineFitz
: public PdfEngine
{
154 virtual ~PdfEngineFitz();
155 virtual bool load(const char *fileName
, WindowInfo
* windowInfo
);
156 virtual int pageRotation(int pageNo
);
157 virtual SizeD
pageSize(int pageNo
);
158 virtual RenderedBitmap
*renderBitmap(int pageNo
, double zoomReal
, int rotation
,
159 BOOL (*abortCheckCbkA
)(void *data
),
160 void *abortCheckCbkDataA
);
162 virtual bool printingAllowed();
163 virtual int linkCount(int pageNo
);
164 virtual const char* linkType(int pageNo
, int linkNo
);
166 fz_matrix
viewctm (pdf_page
*page
, float zoom
, int rotate
);
168 pdf_page
* getPdfPage(int pageNo
);
171 PdfEnginePoppler
* _popplerEngine
;
175 pdf_xref
* xref() { return _xref
; }
176 pdf_pagetree
* pages() { return _pageTree
; }
178 void dropPdfPage(int pageNo
);
181 pdf_outline
* _outline
;
182 pdf_pagetree
* _pageTree
;