Subversion Repositories Kolibri OS

Rev

Rev 7475 | Rev 8429 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7475 Rev 7621
Line 1... Line 1...
1
#include "fitz.h"
1
#include "fitz.h"
2
#include "mupdf.h"
2
#include "mupdf.h"
3
#include "muxps.h"
-
 
4
#include "pdfapp.h"
3
#include "pdfapp.h"
Line 5... Line 4...
5
 
4
 
Line 6... Line 5...
6
#include  /* for tolower() */
5
#include  /* for tolower() */
Line 64... Line 63...
64
		"123g\t\t-- go to page 123\n"
63
		"123g\t\t-- go to page 123\n"
65
		"/\t\t-- search for text\n"
64
		"/\t\t-- search for text\n"
66
		"n\t\t-- find next search result\n"
65
		"n\t\t-- find next search result\n"
67
		"N\t\t-- find previous search result\n"
66
		"N\t\t-- find previous search result\n"
68
		"c\t\t-- toggle between color and grayscale\n"
67
		"c\t\t-- toggle between color and grayscale\n"
-
 
68
	;
69
	; */
69
	*/
70
}
70
}
Line 71... Line 71...
71
 
71
 
72
void pdfapp_init(pdfapp_t *app)
72
void pdfapp_init(pdfapp_t *app)
73
{
73
{
Line 170... Line 170...
170
__menuet__debug_out("Page counter\n");
170
__menuet__debug_out("Page counter\n");
171
	app->pagecount = pdf_count_pages(app->xref);
171
	app->pagecount = pdf_count_pages(app->xref);
172
	__menuet__debug_out("All is set!\n");
172
	__menuet__debug_out("All is set!\n");
173
}
173
}
Line 174... Line -...
174
 
-
 
175
static void pdfapp_open_xps(pdfapp_t *app, char *filename, int fd)
-
 
176
{
-
 
177
	fz_error error;
-
 
178
	fz_stream *file;
-
 
179
 
-
 
180
	file = fz_open_fd(fd);
-
 
181
	error = xps_open_stream(&app->xps, file);
-
 
182
	if (error)
-
 
183
		pdfapp_error(app, fz_rethrow(error, "cannot open document '%s'", filename));
-
 
184
	fz_close(file);
-
 
185
 
-
 
186
	app->doctitle = filename;
-
 
187
 
-
 
188
	app->pagecount = xps_count_pages(app->xps);
-
 
189
}
-
 
190
 
174
 
191
void pdfapp_open(pdfapp_t *app, char *filename, int fd, int reload)
175
void pdfapp_open(pdfapp_t *app, char *filename, int fd, int reload)
192
{
-
 
193
	if (strstr(filename, ".xps") || strstr(filename, ".XPS") || strstr(filename, ".rels"))
-
 
194
		pdfapp_open_xps(app, filename, fd);
-
 
195
	else
176
{
Line 196... Line 177...
196
		pdfapp_open_pdf(app, filename, fd);
177
	pdfapp_open_pdf(app, filename, fd);
Line 197... Line 178...
197
 
178
 
Line 239... Line 220...
239
 
220
 
240
		pdf_free_xref(app->xref);
221
		pdf_free_xref(app->xref);
241
		app->xref = NULL;
222
		app->xref = NULL;
Line 242... Line -...
242
	}
-
 
243
 
-
 
244
	if (app->xps)
-
 
245
	{
-
 
246
		xps_free_context(app->xps);
-
 
247
		app->xps = NULL;
-
 
248
	}
223
	}
249
 
224
 
Line 250... Line 225...
250
	fz_flush_warnings();
225
	fz_flush_warnings();
251
}
226
}
Line 331... Line 306...
331
	pdf_free_page(page);
306
	pdf_free_page(page);
Line 332... Line 307...
332
 
307
 
333
	pdf_age_store(app->xref->store, 3);
308
	pdf_age_store(app->xref->store, 3);
Line 334... Line -...
334
}
-
 
335
 
-
 
336
static void pdfapp_loadpage_xps(pdfapp_t *app)
-
 
337
{
-
 
338
	xps_page *page;
-
 
339
	fz_device *mdev;
-
 
340
	fz_error error;
-
 
341
 
-
 
342
	error = xps_load_page(&page, app->xps, app->pageno - 1);
-
 
343
	if (error)
-
 
344
		pdfapp_error(app, fz_rethrow(error, "cannot load page %d in file '%s'", app->pageno, app->doctitle));
-
 
345
 
-
 
346
	app->page_bbox.x0 = 0;
-
 
347
	app->page_bbox.y0 = 0;
-
 
348
	app->page_bbox.x1 = page->width;
-
 
349
	app->page_bbox.y1 = page->height;
-
 
350
	app->page_rotate = 0;
-
 
351
	app->page_links = NULL;
-
 
352
 
-
 
353
	/* Create display list */
-
 
354
	app->page_list = fz_new_display_list();
-
 
355
	mdev = fz_new_list_device(app->page_list);
-
 
356
	app->xps->dev = mdev;
-
 
357
	xps_parse_fixed_page(app->xps, fz_identity, page);
-
 
358
	app->xps->dev = NULL;
-
 
359
	fz_free_device(mdev);
-
 
360
 
-
 
361
	xps_free_page(app->xps, page);
-
 
362
}
309
}
363
 
310
 
364
static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repaint)
311
static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repaint)
365
{
312
{
366
	char buf[256];
313
	char buf[256];
Line 381... Line 328...
381
		if (app->page_links)
328
		if (app->page_links)
382
			pdf_free_link(app->page_links);
329
			pdf_free_link(app->page_links);
Line 383... Line 330...
383
 
330
 
384
		if (app->xref)
331
		if (app->xref)
385
			pdfapp_loadpage_pdf(app);
-
 
386
		if (app->xps)
-
 
Line 387... Line 332...
387
			pdfapp_loadpage_xps(app);
332
			pdfapp_loadpage_pdf(app);
388
 
333
 
389
		/* Zero search hit position */
334
		/* Zero search hit position */
Line 397... Line 342...
397
		fz_free_device(tdev);
342
		fz_free_device(tdev);
398
	}
343
	}
Line 399... Line 344...
399
 
344
 
400
	if (drawpage)
345
	if (drawpage)
401
	{
346
	{
402
		// sprintf(buf, "%s - %d/%d (%d dpi)", app->doctitle,
347
		sprintf(buf, "%s - %d/%d (%d dpi)", app->doctitle,
403
		// 		app->pageno, app->pagecount, app->resolution);
348
				app->pageno, app->pagecount, app->resolution);
Line 404... Line 349...
404
		// wintitle(app, buf);
349
		wintitle(app, buf);
405
 
350
 
Line 406... Line 351...
406
		ctm = pdfapp_viewctm(app);
351
		ctm = pdfapp_viewctm(app);
Line 428... Line 373...
428
	{
373
	{
429
		pdfapp_panview(app, app->panx, app->pany);
374
		pdfapp_panview(app, app->panx, app->pany);
Line 430... Line 375...
430
 
375
 
431
		if (app->shrinkwrap)
376
		if (app->shrinkwrap)
432
		{
377
		{
433
			//__menuet__debug_out ("SHRINK\n");
378
			__menuet__debug_out ("SHRINK\n");
434
			int w = app->image->w;
379
			int w = app->image->w;
435
			int h = app->image->h;
380
			int h = app->image->h;
436
			if (app->winw == w)
381
			if (app->winw == w)
437
				app->panx = 0;
382
				app->panx = 0;