From 179af30116fcee661c68d64885f4a6fe6c0cd679 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Tue, 21 Dec 2004 21:47:36 +0000 Subject: Import of xpdf code from gpdf. Tue Dec 21 16:30:58 2004 Owen Taylor * pdf/**: Import of xpdf code from gpdf. * pdf/xpdf/xpdfconfig.h: Move the non-config.h config.h to xpdfconfig.h * pdf/splash/SplashFTFont.{cc,h} pdf/splash/SplashFTFont.h pdf/splash/SplashFTFontEngine.h pdf/splash/SplashFTFontFile.h: Fix FreeType includes. * pdf/xpdf/{Error.h GnomeVFSStream.cc ImageOutputDev.cc PDFDoc.cc\ pdffonts.cc pdfimages.cc pdfinfo.cc pdftoppm.cc pdftops.cc pdftotext.cc PSOutputDev.cc PSOutputDev.h SplashOutputDev.h Stream.cc TextOutputDev.cc XPDFApp.cc xpdf.cc XPDFViewer.cc pdf/xpdf/Error.h PSOutputDev.h SplashOutputDev.h}: Include xpdfconfig.h --- (limited to 'pdf') diff --git a/pdf/.cvsignore b/pdf/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/pdf/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/pdf/Makefile.am b/pdf/Makefile.am new file mode 100644 index 0000000..b8fe1da --- /dev/null +++ b/pdf/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = goo fofi splash xpdf + +EXTRA_DIST = aconf.h aconf2.h diff --git a/pdf/aconf.h b/pdf/aconf.h new file mode 100644 index 0000000..c223a98 --- /dev/null +++ b/pdf/aconf.h @@ -0,0 +1,2 @@ +#include +#include diff --git a/pdf/fofi/Makefile.am b/pdf/fofi/Makefile.am index 5459b05..ad20a88 100644 --- a/pdf/fofi/Makefile.am +++ b/pdf/fofi/Makefile.am @@ -1,6 +1,7 @@ INCLUDES = \ -I$(top_srcdir) \ - -I$(top_srcdir)/goo + -I$(top_srcdir)/pdf \ + -I$(top_srcdir)/pdf/goo noinst_LIBRARIES = libfofi.a diff --git a/pdf/goo/Makefile.am b/pdf/goo/Makefile.am index 2e38b52..65502ab 100644 --- a/pdf/goo/Makefile.am +++ b/pdf/goo/Makefile.am @@ -1,5 +1,6 @@ -INCLUDES = \ - -I$(top_srcdir) +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/pdf noinst_LIBRARIES = libGoo.a @@ -30,4 +31,4 @@ EXTRA_DIST = \ vms_unix_time.h \ vms_unix_times.c\ vms_unlink.c \ - vms_make.com \ No newline at end of file + vms_make.com diff --git a/pdf/splash/Makefile.am b/pdf/splash/Makefile.am index b115112..180a470 100644 --- a/pdf/splash/Makefile.am +++ b/pdf/splash/Makefile.am @@ -1,7 +1,9 @@ -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/goo \ - -I$(top_srcdir)/fofi +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/pdf \ + -I$(top_srcdir)/pdf/goo \ + -I$(top_srcdir)/pdf/fofi \ + $(FREETYPE_CFLAGS) noinst_LIBRARIES = libsplash.a diff --git a/pdf/splash/SplashFTFont.cc b/pdf/splash/SplashFTFont.cc index a7d0396..8234014 100644 --- a/pdf/splash/SplashFTFont.cc +++ b/pdf/splash/SplashFTFont.cc @@ -12,8 +12,6 @@ #pragma implementation #endif -#include "freetype/ftoutln.h" -#include "freetype/internal/ftobjs.h" // needed for FT_New_Size decl #include "gmem.h" #include "SplashMath.h" #include "SplashGlyphBitmap.h" @@ -22,6 +20,9 @@ #include "SplashFTFontFile.h" #include "SplashFTFont.h" +#include FT_OUTLINE_H +#include FT_INTERNAL_OBJECTS_H // needed for FT_New_Size decl + //------------------------------------------------------------------------ static int glyphPathMoveTo(FT_Vector *pt, void *path); diff --git a/pdf/splash/SplashFTFont.h b/pdf/splash/SplashFTFont.h index 7628a2b..efd0eda 100644 --- a/pdf/splash/SplashFTFont.h +++ b/pdf/splash/SplashFTFont.h @@ -15,7 +15,8 @@ #pragma interface #endif -#include +#include +#include FT_FREETYPE_H #include "SplashFont.h" class SplashFTFontFile; diff --git a/pdf/splash/SplashFTFontEngine.h b/pdf/splash/SplashFTFontEngine.h index 0497a46..c87108d 100644 --- a/pdf/splash/SplashFTFontEngine.h +++ b/pdf/splash/SplashFTFontEngine.h @@ -15,7 +15,8 @@ #pragma interface #endif -#include +#include +#include FT_FREETYPE_H #include "gtypes.h" class SplashFontFile; diff --git a/pdf/splash/SplashFTFontFile.h b/pdf/splash/SplashFTFontFile.h index 522d055..76f1f81 100644 --- a/pdf/splash/SplashFTFontFile.h +++ b/pdf/splash/SplashFTFontFile.h @@ -15,7 +15,8 @@ #pragma interface #endif -#include +#include +#include FT_FREETYPE_H #include "SplashFontFile.h" class SplashFontFileID; diff --git a/pdf/xpdf/.cvsignore b/pdf/xpdf/.cvsignore index 0267abf..760a964 100644 --- a/pdf/xpdf/.cvsignore +++ b/pdf/xpdf/.cvsignore @@ -17,4 +17,5 @@ pdftopbm pdftops pdftotext semantic.cache +test-gdk-output-dev xpdf diff --git a/pdf/xpdf/Error.h b/pdf/xpdf/Error.h index 0ce55e9..da2f831 100644 --- a/pdf/xpdf/Error.h +++ b/pdf/xpdf/Error.h @@ -16,7 +16,7 @@ #endif #include -#include "config.h" +#include "xpdfconfig.h" extern void CDECL error(int pos, char *msg, ...); diff --git a/pdf/xpdf/GDKSplashOutputDev.cc b/pdf/xpdf/GDKSplashOutputDev.cc new file mode 100644 index 0000000..4ef3bb3 --- /dev/null +++ b/pdf/xpdf/GDKSplashOutputDev.cc @@ -0,0 +1,184 @@ +//======================================================================== +// +// GDKSplashOutputDev.cc +// +// Copyright 2003 Glyph & Cog, LLC +// Copyright 2004 Red Hat, Inc. (GDK port) +// +//======================================================================== + +#include + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include "gmem.h" +#include "SplashTypes.h" +#include "SplashBitmap.h" +#include "Object.h" +#include "GfxState.h" +#include "TextOutputDev.h" +#include "GDKSplashOutputDev.h" + +//------------------------------------------------------------------------ +// Constants and macros +//------------------------------------------------------------------------ + +#define xoutRound(x) ((int)(x + 0.5)) + +//------------------------------------------------------------------------ +// GDKSplashOutputDev +//------------------------------------------------------------------------ + +static SplashColor makeSplashColor(int r, int g, int b) +{ + SplashColor c; + c.rgb8 = splashMakeRGB8 (r, g, b); + return c; +} + +GDKSplashOutputDev::GDKSplashOutputDev(GdkScreen *screen, + void (*redrawCbkA)(void *data), + void *redrawCbkDataA): + SplashOutputDev(splashModeRGB8, gFalse, makeSplashColor (255,255,255)), + incrementalUpdate (1) +{ + redrawCbk = redrawCbkA; + redrawCbkData = redrawCbkDataA; + + // create text object + text = new TextPage(gFalse); +} + +GDKSplashOutputDev::~GDKSplashOutputDev() { + delete text; +} + +void GDKSplashOutputDev::drawChar(GfxState *state, double x, double y, + double dx, double dy, + double originX, double originY, + CharCode code, Unicode *u, int uLen) { + text->addChar(state, x, y, dx, dy, code, u, uLen); + SplashOutputDev::drawChar(state, x, y, dx, dy, originX, originY, + code, u, uLen); +} + +GBool GDKSplashOutputDev::beginType3Char(GfxState *state, double x, double y, + double dx, double dy, + CharCode code, Unicode *u, int uLen) { + text->addChar(state, x, y, dx, dy, code, u, uLen); + return SplashOutputDev::beginType3Char(state, x, y, dx, dy, code, u, uLen); +} + +void GDKSplashOutputDev::clear() { + startDoc(NULL); + startPage(0, NULL); +} + +void GDKSplashOutputDev::startPage(int pageNum, GfxState *state) { + SplashOutputDev::startPage(pageNum, state); + text->startPage(state); +} + +void GDKSplashOutputDev::endPage() { + SplashOutputDev::endPage(); + if (!incrementalUpdate) { + (*redrawCbk)(redrawCbkData); + } + text->coalesce(gTrue); +} + +void GDKSplashOutputDev::dump() { + if (incrementalUpdate) { + (*redrawCbk)(redrawCbkData); + } +} + +void GDKSplashOutputDev::updateFont(GfxState *state) { + SplashOutputDev::updateFont(state); + text->updateFont(state); +} + +void GDKSplashOutputDev::redraw(int srcX, int srcY, + GdkDrawable *drawable, + int destX, int destY, + int width, int height) { + SplashColorPtr dataPtr; + GdkGC *gc; + guchar *gdk_buf; + int gdk_rowstride; + int bw, x, y, r, g, b; + + gdk_rowstride = width * 3; + + /* better to draw nothing than crash on a huge image */ + gdk_buf = (guchar*) g_try_malloc (height * gdk_rowstride); + if (gdk_buf == NULL) + return; + + bw = getBitmap()->getWidth(); + dataPtr = getBitmap()->getDataPtr(); + + for (y = 0; y < height; ++y) + { + SplashRGB8 *p; + SplashRGB8 rgb; + guchar *gdk_p; + + p = dataPtr.rgb8 + (y + srcY) * bw + srcX; + gdk_p = gdk_buf + y * gdk_rowstride; + for (x = 0; x < width; ++x) + { + rgb = *p++; + r = splashRGB8R(rgb); + g = splashRGB8G(rgb); + b = splashRGB8B(rgb); + + *gdk_p++ = r; + *gdk_p++ = g; + *gdk_p++ = b; + } + } + + gc = gdk_gc_new (drawable); + + gdk_draw_rgb_image (drawable, gc, + destX, destY, + width, height, + GDK_RGB_DITHER_NORMAL, + gdk_buf, + gdk_rowstride); + + g_object_unref (gc); + + g_free (gdk_buf); +} + +GBool GDKSplashOutputDev::findText(Unicode *s, int len, + GBool startAtTop, GBool stopAtBottom, + GBool startAtLast, GBool stopAtLast, + int *xMin, int *yMin, + int *xMax, int *yMax) { + double xMin1, yMin1, xMax1, yMax1; + + xMin1 = (double)*xMin; + yMin1 = (double)*yMin; + xMax1 = (double)*xMax; + yMax1 = (double)*yMax; + if (text->findText(s, len, startAtTop, stopAtBottom, + startAtLast, stopAtLast, + &xMin1, &yMin1, &xMax1, &yMax1)) { + *xMin = xoutRound(xMin1); + *xMax = xoutRound(xMax1); + *yMin = xoutRound(yMin1); + *yMax = xoutRound(yMax1); + return gTrue; + } + return gFalse; +} + +GString *GDKSplashOutputDev::getText(int xMin, int yMin, int xMax, int yMax) { + return text->getText((double)xMin, (double)yMin, + (double)xMax, (double)yMax); +} diff --git a/pdf/xpdf/GDKSplashOutputDev.h b/pdf/xpdf/GDKSplashOutputDev.h new file mode 100644 index 0000000..753ef93 --- /dev/null +++ b/pdf/xpdf/GDKSplashOutputDev.h @@ -0,0 +1,100 @@ +//======================================================================== +// +// GDKSplashOutputDev.h +// +// Copyright 2003 Glyph & Cog, LLC +// Copyright 2004 Red Hat, Inc. (GDK port) +// +//======================================================================== + +#ifndef XSPLASHOUTPUTDEV_H +#define XSPLASHOUTPUTDEV_H + +#ifdef USE_GCC_PRAGMAS +#pragma interface +#endif + +#include "gpdf-g-switch.h" +# include +#include "gpdf-g-switch.h" +#include "SplashTypes.h" +#include "SplashOutputDev.h" +#include "TextOutputDev.h" + +//------------------------------------------------------------------------ + +#define xOutMaxRGBCube 6 // max size of RGB color cube + +//------------------------------------------------------------------------ +// GDKSplashOutputDev +//------------------------------------------------------------------------ + +class GDKSplashOutputDev: public SplashOutputDev { +public: + + GDKSplashOutputDev(GdkScreen *screen, + void (*redrawCbkA)(void *data), + void *redrawCbkDataA); + + virtual ~GDKSplashOutputDev(); + + //----- initialization and control + + // Start a page. + virtual void startPage(int pageNum, GfxState *state); + + // End a page. + virtual void endPage(); + + // Dump page contents to display. + virtual void dump(); + + //----- update text state + virtual void updateFont(GfxState *state); + + //----- text drawing + virtual void drawChar(GfxState *state, double x, double y, + double dx, double dy, + double originX, double originY, + CharCode code, Unicode *u, int uLen); + virtual GBool beginType3Char(GfxState *state, double x, double y, + double dx, double dy, + CharCode code, Unicode *u, int uLen); + + //----- special access + + // Clear out the document (used when displaying an empty window). + void clear(); + + // Copy the rectangle (srcX, srcY, width, height) to (destX, destY) + // in destDC. + void redraw(int srcX, int srcY, + GdkDrawable *drawable, + int destX, int destY, + int width, int height); + + // Find a string. If is true, starts looking at the + // top of the page; else if is true, starts looking + // immediately after the last find result; else starts looking at + // ,. If is true, stops looking at the + // bottom of the page; else if is true, stops looking + // just before the last find result; else stops looking at + // ,. + GBool findText(Unicode *s, int len, + GBool startAtTop, GBool stopAtBottom, + GBool startAtLast, GBool stopAtLast, + int *xMin, int *yMin, + int *xMax, int *yMax); + + // Get the text which is inside the specified rectangle. + GString *getText(int xMin, int yMin, int xMax, int yMax); + +private: + + int incrementalUpdate; + void (*redrawCbk)(void *data); + void *redrawCbkData; + TextPage *text; // text from the current page +}; + +#endif diff --git a/pdf/xpdf/GnomeVFSStream.cc b/pdf/xpdf/GnomeVFSStream.cc index 4ff30a5..06735ee 100644 --- a/pdf/xpdf/GnomeVFSStream.cc +++ b/pdf/xpdf/GnomeVFSStream.cc @@ -12,7 +12,7 @@ #endif #include -#include "config.h" +#include "xpdfconfig.h" #include "GnomeVFSStream.h" #include "gpdf-g-switch.h" diff --git a/pdf/xpdf/ImageOutputDev.cc b/pdf/xpdf/ImageOutputDev.cc index 29c7f0f..5ca14ac 100644 --- a/pdf/xpdf/ImageOutputDev.cc +++ b/pdf/xpdf/ImageOutputDev.cc @@ -17,7 +17,7 @@ #include #include #include "gmem.h" -#include "config.h" +#include "xpdfconfig.h" #include "Error.h" #include "GfxState.h" #include "Object.h" diff --git a/pdf/xpdf/Makefile.am b/pdf/xpdf/Makefile.am index 7d86dbd..5d93140 100644 --- a/pdf/xpdf/Makefile.am +++ b/pdf/xpdf/Makefile.am @@ -1,26 +1,15 @@ -SUBDIRS = . tests - INCLUDES = \ -I$(top_srcdir) \ - -I$(top_srcdir)/goo \ - -I$(top_srcdir)/lib/ggv-sidebar \ - -I$(top_srcdir)/fofi \ - -I$(top_srcdir)/splash \ - -DDATADIR=\""$(datadir)"\" \ - -DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ - -DGNOMEICONDIR=\""$(datadir)/pixmaps"\" \ - $(EXTRA_GNOME_CFLAGS) \ - $(GNOME_PRINT_PRIVATE_CFLAGS) \ - $(GPDF_DEPRECATED_CFLAGS) \ - $(libpaper_CFLAGS) - -marshal_sources = \ - gpdf-marshal.c \ - gpdf-marshal.h + -I$(top_srcdir)/pdf \ + -I$(top_srcdir)/pdf/goo \ + -I$(top_srcdir)/pdf/fofi \ + -I$(top_srcdir)/pdf/splash \ + $(GTK_CFLAGS) \ + -DDATADIR=\""$(datadir)"\" -libexec_PROGRAMS = gnome-pdf-viewer +noinst_PROGRAMS = test-gdk-output-dev -noinst_LIBRARIES = libxpdf.a libgpdf.a +noinst_LIBRARIES = libxpdf.a libxpdf_a_SOURCES = \ Annot.cc \ @@ -104,191 +93,19 @@ common_sources = \ TextOutputDev.h \ UTF8.h -ANNOTS_VIEW_SRCS = - -if USE_ANNOTS_VIEW - ANNOTS_VIEW_SRCS += \ - gpdf-annots-view.cc \ - gpdf-annots-view.h -endif - -libgpdf_a_SOURCES = \ - BonoboStream.cc \ - BonoboStream.h \ - GnomeVFSStream.cc \ - GnomeVFSStream.h \ - GPOutputDev.cc \ - GPOutputDev.h \ - PSOutputDev.cc \ - PSOutputDev.h \ - Thumb.cc \ - Thumb.h \ - gpdf-control.cc \ - gpdf-control.h \ - gpdf-control-private.h \ - gpdf-g-switch.h \ - gpdf-link-canvas-item.cc \ - gpdf-link-canvas-item.h \ - gpdf-links-canvas-layer.cc \ - gpdf-links-canvas-layer.h \ - gpdf-persist-file.cc \ - gpdf-persist-file.h \ - gpdf-persist-stream.cc \ - gpdf-persist-stream.h \ - gpdf-stock-icons.c \ - gpdf-stock-icons.h \ - gpdf-util.h \ - gpdf-view.cc \ - gpdf-view.h \ - gpdf-bookmarks-view.cc \ - gpdf-bookmarks-view.h \ - gpdf-thumbnails-view.cc \ - gpdf-thumbnails-view.h \ - $(ANNOTS_VIEW_SRCS) \ - eel-gconf-extensions.c \ - eel-gconf-extensions.h \ - prefs-strings.h \ - gpdf-sidebar.c \ - gpdf-sidebar.h \ - gtkgesture.c \ - gtkgesture.h \ - page-control.c \ - page-control.h \ - pdf-info-dict-util.cc \ - pdf-info-dict-util.h \ - pdf-properties-display.c \ - pdf-properties-display.h \ - gpdf-font-face.c \ - gpdf-font-face.h \ - $(marshal_sources) - -gnome_pdf_viewer_SOURCES = \ - $(common_sources) \ - bonobo-application-x-pdf.cc \ - nautilus-pdf-property-page.cc \ - nautilus-pdf-property-page.h - -# Old files -# GOutputDev.cc \ -# GOutputDev.h \ -# pdf-view.cc \ -# pdf-view.h \ -# gpdf-embeddable.cc \ -# gpdf-embeddable.h \ -# gpdf-embeddable-view.cc \ -# gpdf-embeddable-view.h - -gnome_pdf_viewer_LDADD = \ - libxpdf.a \ - libgpdf.a \ - $(top_builddir)/goo/libGoo.a \ - $(top_builddir)/fofi/libfofi.a \ - $(top_builddir)/lib/ggv-sidebar/libggv-sidebar.a \ - $(EXTRA_GNOME_LIBS) \ - $(libpaper_LIBS) - -gpdf-marshal.h: gpdf-marshal.list $(GLIB_GENMARSHAL) - $(GLIB_GENMARSHAL) $< --header --prefix=gpdf_marshal > $@ - -gpdf-marshal.c: gpdf-marshal.list $(GLIB_GENMARSHAL) - echo "#include \"gpdf-marshal.h\"" > $@ && \ - $(GLIB_GENMARSHAL) $< --body --prefix=gpdf_marshal >> $@ - -BUILT_SOURCES = $(marshal_sources) -DONT_DIST_SOURCE = $(marshal_sources) - -dist-hook: - for file in $(DONT_DIST_SOURCE) ; do \ - rm -f $(distdir)/$$file ; \ - done - -STOCK_ANNOTS_ICONS = - -if USE_ANNOTS_VIEW - STOCK_ANNOTS_ICONS += \ - stock-annot-circle.png \ - stock-annot-fileattachment.png \ - stock-annot-freetext.png \ - stock-annot-highlight.png \ - stock-annot-ink.png \ - stock-annot-line.png \ - stock-annot-link.png \ - stock-annot-movie.png \ - stock-annot-popup.png \ - stock-annot-sound.png \ - stock-annot-square.png \ - stock-annot-stamp.png \ - stock-annot-strikeout.png \ - stock-annot-text.png \ - stock-annot-trapnet.png \ - stock-annot-underline.png \ - stock-annot-widget.png \ - stock-annot-unknown.png -endif - -stockdir = $(datadir)/pixmaps/gpdf -stock_DATA = \ - fitwidth.png \ - stock_book-closed-mark.png \ - stock_book-closed.png \ - stock_book-opened-mark.png \ - stock_book-opened.png \ - stock_bookmarks.png \ - $(STOCK_ANNOTS_ICONS) - -gladedir = $(datadir)/gpdf/glade -glade_DATA = \ - gpdf-print-progress-dialog.glade \ - gpdf-properties-dialog.glade - -server_in_files = GNOME_PDF.server.in.in -serverdir = $(libdir)/bonobo/servers -server_DATA = $(server_in_files:%.server.in.in=%.server) - -$(server_in_files:%.server.in.in=%.server.in): $(server_in_files) - sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ - -@INTLTOOL_SERVER_RULE@ - -uidir = $(datadir)/gnome-2.0/ui -ui_DATA = \ - gpdf-control-ui.xml - -CLEANFILES = \ - $(server_DATA) \ - $(server_in_files:.server.in.in=.server.in) \ - $(marshal_sources) - -if USE_ANNOTS_VIEW - EXTRA_DIST = $(stock_DATA) \ - gpdf-marshal.list \ - $(server_in_files) \ - config.h \ - $(ui_DATA) \ - $(glade_DATA) -else - EXTRA_DIST = $(stock_DATA) \ - gpdf-marshal.list \ - $(server_in_files) \ - config.h \ - $(ui_DATA) \ - $(glade_DATA) \ - stock-annot-circle.png \ - stock-annot-fileattachment.png \ - stock-annot-freetext.png \ - stock-annot-highlight.png \ - stock-annot-ink.png \ - stock-annot-line.png \ - stock-annot-link.png \ - stock-annot-movie.png \ - stock-annot-popup.png \ - stock-annot-sound.png \ - stock-annot-square.png \ - stock-annot-stamp.png \ - stock-annot-strikeout.png \ - stock-annot-text.png \ - stock-annot-trapnet.png \ - stock-annot-underline.png \ - stock-annot-widget.png \ - stock-annot-unknown.png -endif +test_gdk_output_dev_SOURCES = \ + GDKSplashOutputDev.cc \ + GDKSplashOutputDev.h \ + SplashOutputDev.cc \ + SplashOutputDev.h \ + $(common_sources) \ + test-gdk-output-dev.cc + +test_gdk_output_dev_LDADD = \ + libxpdf.a \ + $(top_builddir)/pdf/goo/libGoo.a \ + $(top_builddir)/pdf/fofi/libfofi.a \ + $(top_builddir)/pdf/splash/libsplash.a \ + $(GTK_LIBS) + +EXTRA_DIST = config.h diff --git a/pdf/xpdf/PDFDoc.cc b/pdf/xpdf/PDFDoc.cc index e156c3f..031ffc5 100644 --- a/pdf/xpdf/PDFDoc.cc +++ b/pdf/xpdf/PDFDoc.cc @@ -18,7 +18,7 @@ #include #include #include "GString.h" -#include "config.h" +#include "xpdfconfig.h" #include "GlobalParams.h" #include "Page.h" #include "Catalog.h" diff --git a/pdf/xpdf/PSOutputDev.cc b/pdf/xpdf/PSOutputDev.cc index 6170dfd..28811a8 100644 --- a/pdf/xpdf/PSOutputDev.cc +++ b/pdf/xpdf/PSOutputDev.cc @@ -19,7 +19,7 @@ #include #include "GString.h" #include "GList.h" -#include "config.h" +#include "xpdfconfig.h" #include "GlobalParams.h" #include "Object.h" #include "Error.h" diff --git a/pdf/xpdf/PSOutputDev.h b/pdf/xpdf/PSOutputDev.h index 6c379a9..fed328a 100644 --- a/pdf/xpdf/PSOutputDev.h +++ b/pdf/xpdf/PSOutputDev.h @@ -16,7 +16,7 @@ #endif #include -#include "config.h" +#include "xpdfconfig.h" #include "Object.h" #include "GlobalParams.h" #include "OutputDev.h" diff --git a/pdf/xpdf/SplashOutputDev.h b/pdf/xpdf/SplashOutputDev.h index 9300fe4..b2ecfea 100644 --- a/pdf/xpdf/SplashOutputDev.h +++ b/pdf/xpdf/SplashOutputDev.h @@ -17,7 +17,7 @@ #include "gtypes.h" #include "SplashTypes.h" -#include "config.h" +#include "xpdfconfig.h" #include "OutputDev.h" class GfxState; @@ -30,6 +30,7 @@ class SplashPattern; class SplashFontEngine; class SplashFont; class T3FontCache; +class XRef; struct T3FontCacheTag; struct T3GlyphStack; struct GfxRGB; diff --git a/pdf/xpdf/Stream.cc b/pdf/xpdf/Stream.cc index 49bbb46..3d19436 100644 --- a/pdf/xpdf/Stream.cc +++ b/pdf/xpdf/Stream.cc @@ -22,7 +22,7 @@ #include #include "gmem.h" #include "gfile.h" -#include "config.h" +#include "xpdfconfig.h" #include "Error.h" #include "Object.h" #ifndef NO_DECRYPTION diff --git a/pdf/xpdf/TextOutputDev.cc b/pdf/xpdf/TextOutputDev.cc index c6fdfb9..a492e7f 100644 --- a/pdf/xpdf/TextOutputDev.cc +++ b/pdf/xpdf/TextOutputDev.cc @@ -24,7 +24,7 @@ #include "gmem.h" #include "GString.h" #include "GList.h" -#include "config.h" +#include "xpdfconfig.h" #include "Error.h" #include "GlobalParams.h" #include "UnicodeMap.h" diff --git a/pdf/xpdf/XPDFApp.cc b/pdf/xpdf/XPDFApp.cc index 34bde23..ae8d009 100644 --- a/pdf/xpdf/XPDFApp.cc +++ b/pdf/xpdf/XPDFApp.cc @@ -17,7 +17,7 @@ #include "Error.h" #include "XPDFViewer.h" #include "XPDFApp.h" -#include "config.h" +#include "xpdfconfig.h" // these macro defns conflict with xpdf's Object class #ifdef LESSTIF_VERSION diff --git a/pdf/xpdf/XPDFViewer.cc b/pdf/xpdf/XPDFViewer.cc index b7e5532..a638c02 100644 --- a/pdf/xpdf/XPDFViewer.cc +++ b/pdf/xpdf/XPDFViewer.cc @@ -42,7 +42,7 @@ #include "XPDFApp.h" #include "XPDFViewer.h" #include "PSOutputDev.h" -#include "config.h" +#include "xpdfconfig.h" // these macro defns conflict with xpdf's Object class #ifdef LESSTIF_VERSION diff --git a/pdf/xpdf/pdffonts.cc b/pdf/xpdf/pdffonts.cc index 2f17995..66d9c37 100644 --- a/pdf/xpdf/pdffonts.cc +++ b/pdf/xpdf/pdffonts.cc @@ -22,7 +22,7 @@ #include "GfxFont.h" #include "Annot.h" #include "PDFDoc.h" -#include "config.h" +#include "xpdfconfig.h" static char *fontTypeNames[] = { "unknown", diff --git a/pdf/xpdf/pdfimages.cc b/pdf/xpdf/pdfimages.cc index 20e1add..319e141 100644 --- a/pdf/xpdf/pdfimages.cc +++ b/pdf/xpdf/pdfimages.cc @@ -25,7 +25,7 @@ #include "PDFDoc.h" #include "ImageOutputDev.h" #include "Error.h" -#include "config.h" +#include "xpdfconfig.h" static int firstPage = 1; static int lastPage = 0; diff --git a/pdf/xpdf/pdfinfo.cc b/pdf/xpdf/pdfinfo.cc index 4a50fee..3389837 100644 --- a/pdf/xpdf/pdfinfo.cc +++ b/pdf/xpdf/pdfinfo.cc @@ -28,7 +28,7 @@ #include "CharTypes.h" #include "UnicodeMap.h" #include "Error.h" -#include "config.h" +#include "xpdfconfig.h" static void printInfoString(Dict *infoDict, char *key, char *text, UnicodeMap *uMap); diff --git a/pdf/xpdf/pdftoppm.cc b/pdf/xpdf/pdftoppm.cc index 9be5c64..c12a151 100644 --- a/pdf/xpdf/pdftoppm.cc +++ b/pdf/xpdf/pdftoppm.cc @@ -17,7 +17,7 @@ #include "SplashBitmap.h" #include "Splash.h" #include "SplashOutputDev.h" -#include "config.h" +#include "xpdfconfig.h" static int firstPage = 1; static int lastPage = 0; diff --git a/pdf/xpdf/pdftops.cc b/pdf/xpdf/pdftops.cc index 3042006..cb230a7 100644 --- a/pdf/xpdf/pdftops.cc +++ b/pdf/xpdf/pdftops.cc @@ -25,7 +25,7 @@ #include "PDFDoc.h" #include "PSOutputDev.h" #include "Error.h" -#include "config.h" +#include "xpdfconfig.h" static int firstPage = 1; static int lastPage = 0; diff --git a/pdf/xpdf/pdftotext.cc b/pdf/xpdf/pdftotext.cc index 2de03e3..cb8c896 100644 --- a/pdf/xpdf/pdftotext.cc +++ b/pdf/xpdf/pdftotext.cc @@ -27,7 +27,7 @@ #include "CharTypes.h" #include "UnicodeMap.h" #include "Error.h" -#include "config.h" +#include "xpdfconfig.h" static void printInfoString(FILE *f, Dict *infoDict, char *key, char *text1, char *text2, UnicodeMap *uMap); diff --git a/pdf/xpdf/test-gdk-output-dev.cc b/pdf/xpdf/test-gdk-output-dev.cc new file mode 100644 index 0000000..df08aed --- /dev/null +++ b/pdf/xpdf/test-gdk-output-dev.cc @@ -0,0 +1,179 @@ +/** + * render a PDF to GDKSplashOutputDev + * + * Copyright 2004 Red Hat, Inc. + */ + +#include + +#include +#include +#include + +#include "gpdf-g-switch.h" +#include +#include "gpdf-g-switch.h" + +#include "GlobalParams.h" +#include "GDKSplashOutputDev.h" +#include "PDFDoc.h" +#include "ErrorCodes.h" + +typedef struct +{ + GtkWidget *window; + GtkWidget *sw; + GtkWidget *drawing_area; + GDKSplashOutputDev *out; + PDFDoc *doc; +} View; + +static void +drawing_area_expose (GtkWidget *drawing_area, + GdkEventExpose *event, + void *data) +{ + View *v = (View*) data; + int x, y, w, h; + GdkRectangle document; + GdkRectangle draw; + + gdk_window_clear (drawing_area->window); + + document.x = 0; + document.y = 0; + document.width = v->out->getBitmapWidth(); + document.height = v->out->getBitmapHeight(); + + if (gdk_rectangle_intersect (&document, &event->area, &draw)) + { + v->out->redraw (draw.x, draw.y, + drawing_area->window, + draw.x, draw.y, + draw.width, draw.height); + } +} + +static int +view_load (View *v, + const char *filename) +{ + PDFDoc *newDoc; + int err; + GString *filename_g; + GtkAdjustment *hadj; + GtkAdjustment *vadj; + int w, h; + + filename_g = new GString (filename); + + // open the PDF file + newDoc = new PDFDoc(filename_g, 0, 0); + + delete filename_g; + + if (!newDoc->isOk()) + { + err = newDoc->getErrorCode(); + delete newDoc; + return err; + } + + if (v->doc) + delete v->doc; + v->doc = newDoc; + + v->out->startDoc(v->doc->getXRef()); + + v->doc->displayPage (v->out, 1, 72, 72, 0, gTrue, gTrue); + + w = v->out->getBitmapWidth(); + h = v->out->getBitmapHeight(); + + gtk_widget_set_size_request (v->drawing_area, w, h); +} + +static void +view_show (View *v) +{ + gtk_widget_show (v->window); +} + +static void +redraw_callback (void *data) +{ + View *v = (View*) data; + + gtk_widget_queue_draw (v->drawing_area); +} + +static View* +view_new (void) +{ + View *v; + GtkWidget *window; + GtkWidget *drawing_area; + GtkWidget *sw; + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + drawing_area = gtk_drawing_area_new (); + + sw = gtk_scrolled_window_new (NULL, NULL); + + gtk_container_add (GTK_CONTAINER (window), sw); + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), drawing_area); + + gtk_widget_show_all (sw); + + v = g_new0 (View, 1); + + v->window = window; + v->drawing_area = drawing_area; + v->sw = sw; + v->out = new GDKSplashOutputDev (gtk_widget_get_screen (window), + redraw_callback, (void*) v); + v->doc = 0; + + g_signal_connect (drawing_area, + "expose_event", + G_CALLBACK (drawing_area_expose), + (void*) v); + + return v; +} + +int +main (int argc, char *argv []) +{ + View *v; + int i; + + gtk_init (&argc, &argv); + + globalParams = new GlobalParams("/etc/xpdfrc"); + globalParams->setupBaseFonts(NULL); + + i = 1; + while (i < argc) + { + int err; + + v = view_new (); + + err = view_load (v, argv[i]); + + if (err != errNone) + g_printerr ("Error loading document!\n"); + + view_show (v); + + ++i; + } + + gtk_main (); + + delete globalParams; + + return 0; +} diff --git a/pdf/xpdf/xpdf.cc b/pdf/xpdf/xpdf.cc index 0824e4c..2705cf6 100644 --- a/pdf/xpdf/xpdf.cc +++ b/pdf/xpdf/xpdf.cc @@ -15,7 +15,7 @@ #include "GlobalParams.h" #include "Object.h" #include "XPDFApp.h" -#include "config.h" +#include "xpdfconfig.h" //------------------------------------------------------------------------ // command line options -- cgit v0.9.1