From: Owen Taylor Date: Tue, 21 Dec 2004 21:47:36 +0000 (+0000) Subject: Import of xpdf code from gpdf. X-Git-Tag: EVINCE_0_1_0~119 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=179af30116fcee661c68d64885f4a6fe6c0cd679;p=evince.git 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 --- diff --git a/ChangeLog b/ChangeLog index 6882d413..6c4ea852 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +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 + Tue Dec 21 16:08:17 2004 Jonathan Blandford * shell/ev-window.c (ev_window_dispose): dispose can be called diff --git a/Makefile.am b/Makefile.am index 5eef06ab..44217588 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = cut-n-paste data shell viewer po +SUBDIRS = cut-n-paste data shell viewer po pdf intltool_extra = intltool-extract.in intltool-merge.in intltool-update.in diff --git a/autogen.sh b/autogen.sh index 7eaf1f1e..9008f64c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -17,4 +17,4 @@ which gnome-autogen.sh || { exit 1 } -USE_COMMON_DOC_BUILD=yes REQUIRED_AUTOMAKE_VERSION=1.8 USE_GNOME2_MACROS=1 . gnome-autogen.sh +USE_COMMON_DOC_BUILD=yes REQUIRED_AUTOMAKE_VERSION=1.7 USE_GNOME2_MACROS=1 . gnome-autogen.sh diff --git a/configure.ac b/configure.ac index 6a45bb0d..97517c5a 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,7 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.]) PKG_CHECK_MODULES(LIBEVPRIVATE, gtk+-2.0 >= 2.4.0) PKG_CHECK_MODULES(RECENT_FILES, gtk+-2.0 >= 2.4.0 libgnomeui-2.0 >= 2.4.0 libbonobo-2.0) PKG_CHECK_MODULES(SHELL, gtk+-2.0 >= 2.5.0 libgnomeui-2.0 gnome-vfs-2.0 libbonoboui-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libglade-2.0) +PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6.0) dnl Compile with disable-deprecated switches @@ -44,7 +45,7 @@ if test -f $srcdir/autogen.sh; then set_enable_deprecated=no else set_enable_deprecated=yes -fi + fi ]) AC_MSG_CHECKING([whether to disable deprecated glib/gtk+/etc. features]) if test "$set_enable_deprecated" != "yes"; then @@ -56,6 +57,218 @@ else fi AC_SUBST(EVINCE_DISABLE_DEPRECATED) +dnl ================== Xpdf aconf.h.in checks ================================== + +AH_TEMPLATE([HAVE_LIBSM], [Define to 1 if you have session management.]) +AH_TEMPLATE([ENABLE_NLS], [Use Native Language Support.]) +AH_TEMPLATE([HAVE_CATGETS], [Use catgets functions.]) +AH_TEMPLATE([HAVE_GETTEXT], [Use gettext functions.]) + +dnl Optional features. +AH_TEMPLATE([A4_PAPER], + [Use A4 paper size instead of Letter for PostScript output.]) +AC_ARG_ENABLE(a4-paper, + AC_HELP_STRING([--enable-a4-paper], + [use A4 paper size instead of Letter for + PostScript output]), + AC_DEFINE(A4_PAPER)) + +dnl never define NO_TEXT_SELECT, just remember this Xpdf setting. +AH_TEMPLATE([NO_TEXT_SELECT], [Do not allow text selection.]) + +AH_TEMPLATE([OPI_SUPPORT], + [Include support for OPI comments.]) +AC_ARG_ENABLE(opi, + AC_HELP_STRING([--enable-opi], + [include support for OPI comments]), + AC_DEFINE(OPI_SUPPORT)) + +dnl enable these unconditionally. +AC_DEFINE([MULTITHREADED], [1], [Enable multithreading support.]) +AC_DEFINE([TEXTOUT_WORD_LIST], [1], [Enable word list support.]) + +AH_TEMPLATE([APPDEFDIR], + [Directory with the Xpdf app-defaults file.]) +AC_ARG_WITH(appdef-dir, + AC_HELP_STRING([--with-appdef-dir], + [set app-defaults directory]), + AC_DEFINE_UNQUOTED(APPDEFDIR, "$with_appdef_dir")) + +dnl Path to xpdfrc. +dnl This ugly kludge to get the sysconfdir path is needed because +dnl autoconf doesn't actually set the prefix variable until later. +if test "$sysconfdir" = '${prefix}/etc'; then + if test "x$prefix" = xNONE; then + system_xpdfrc="$ac_default_prefix/etc/xpdfrc" + else + system_xpdfrc="$prefix/etc/xpdfrc" + fi +else + system_xpdfrc="$sysconfdir/xpdfrc" +fi +AC_DEFINE_UNQUOTED(SYSTEM_XPDFRC, "$system_xpdfrc", + [Full path for the system-wide xpdfrc file.]) + +dnl Checks for header files. +AC_HEADER_DIRENT + +dnl Switch over to C++. This will make the checks below a little +dnl bit stricter (requiring function prototypes in include files). +dnl (99% of xpdf is written in C++.) +AC_LANG_CPLUSPLUS + +dnl Look for header that defines select() and fd_set. +AC_MSG_CHECKING([select() and fd_set in sys/select.h and sys/bsdtypes.h]) +AC_TRY_COMPILE([#include +#include +#include +#include ], + [fd_set fds; +select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no) +if test $xpdf_ok = yes; then + AC_MSG_RESULT([not needed]) +else + AC_TRY_COMPILE([#include +#include +#include +#include +#include ], + [fd_set fds; +select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no) + if test $xpdf_ok = yes; then + AC_DEFINE(HAVE_SYS_SELECT_H, 1, [Have sys/select.h.]) + AC_MSG_RESULT([need sys/select.h]) + else + AC_TRY_COMPILE([#include +#include +#include +#include +#include ], + [fd_set fds; +select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no) + if test $xpdf_ok = yes; then + AC_DEFINE(HAVE_SYS_BSDTYPES_H, 1, [Have sys/bsdtypes.h.]) + AC_MSG_RESULT([need sys/bsdtypes.h]) + else + AC_MSG_RESULT([problem]) + fi + fi +fi + +dnl Look for header that defines FD_ZERO. +AC_MSG_CHECKING([FD_ZERO and strings.h or bstring.h]) +AC_TRY_COMPILE([#include +#include +#ifdef HAVE_SYS_SELECT_H +#include +#endif], +[fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no) +if test $xpdf_ok = yes; then + AC_MSG_RESULT([not needed]) +else + AC_TRY_COMPILE([#include +#include +#include +#ifdef HAVE_SYS_SELECT_H +#include +#endif], + [fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no) + if test $xpdf_ok = yes; then + AC_DEFINE(HAVE_STRINGS_H, 1, [Have strings.h.]) + AC_MSG_RESULT([need strings.h]) + else + AC_TRY_COMPILE([#include +#include +#include +#ifdef HAVE_SYS_SELECT_H +#include +#endif], + [fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no) + if test $xpdf_ok = yes; then + AC_DEFINE(HAVE_BSTRING_H, 1, [Have bstring.h.]) + AC_MSG_RESULT([need bstring.h]) + else + AC_MSG_RESULT([problem]) + fi + fi +fi + +dnl Look for rewinddir. +AC_CHECK_FUNCS(rewinddir) +if test $ac_cv_func_rewinddir = no; then + AC_CHECK_LIB(cposix, rewinddir) +fi + +dnl Checks for library functions. +AC_CHECK_FUNCS(popen) +dnl # This should use 'AC_CHECK_FUNCS(mkstemp)' but that fails if +dnl # the mkstemp exists in the library but isn't declared in the +dnl # include file (e.g., in cygwin 1.1.2). +AC_CACHE_CHECK([for mkstemp], +xpdf_cv_func_mkstemp, +[AC_TRY_LINK([#include +#include ], +[mkstemp("foo");], +xpdf_cv_func_mkstemp=yes, xpdf_cv_func_mkstemp=no)]) +if test "$xpdf_cv_func_mkstemp" = yes; then + AC_DEFINE(HAVE_MKSTEMP, 1, [Have mkstemp().]) +fi +dnl Check for mkstemps, just like mkstemp. +AC_CACHE_CHECK([for mkstemps], +xpdf_cv_func_mkstemps, +[AC_TRY_LINK([#include +#include ], +[mkstemps("foo", 0);], +xpdf_cv_func_mkstemps=yes, xpdf_cv_func_mkstemps=no)]) +if test "$xpdf_cv_func_mkstemps" = yes; then + AC_DEFINE(HAVE_MKSTEMPS, 1, [Have mkstemps().]) +fi + +dnl Check select argument type: on HP-UX before version 10, select +dnl takes (int *) instead of (fd_set *). +AC_CACHE_CHECK([whether select takes fd_set arguments], +xpdf_cv_func_select_arg, +[AC_TRY_COMPILE([#include +#include +#include +#ifdef HAVE_SYS_SELECT_H +#include +#endif], +[fd_set fds; +select(1, &fds, &fds, &fds, 0);], +xpdf_cv_func_select_arg=yes, xpdf_cv_func_select_arg=no)]) +if test "$xpdf_cv_func_select_arg" != yes; then + AC_DEFINE(SELECT_TAKES_INT, 1, [select() takes int, not fd_set arguments.]) +fi + +dnl Back to C for the library tests. +AC_LANG_C + +dnl Check for fseeko/ftello or fseek64/ftell64 +dnl The LARGEFILE and FSEEKO macros have to be called in C, not C++, mode. +AC_SYS_LARGEFILE +AC_FUNC_FSEEKO +AC_CHECK_FUNCS(fseek64, xpdf_cv_func_fseek64=yes, xpdf_cv_func_fseek64=no) +AC_CHECK_FUNCS(ftell64, xpdf_cv_func_ftell64=yes, xpdf_cv_func_ftell64=no) +if test "$xpdf_cv_func_fseek64" = yes -a "$xpdf_cv_func_ftell64" = yes; then + AC_DEFINE(HAVE_FSEEK64, 1, [Have fseek64().]) +fi + +dnl Check for freetype headers +FREETYPE_LIBS= +FREETYPE_CFLAGS= +AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no) +if test "x$FREETYPE_CONFIG" != "xno" ; then + FREETYPE_CFLAGS=`$FREETYPE_CONFIG --cflags` + FREETYPE_LIBS=`$FREETYPE_CONFIG --libs` + AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include files]) +fi + +AC_SUBST(FREETYPE_CFLAGS) +AC_SUBST(FREETYPE_LIBS) + +dnl ================== End of xpdf checks =========================================== + dnl Turn on the additional warnings last, so -Werror doesn't affect other tests. dnl stolen from nautilus and gnome-common @@ -115,6 +328,11 @@ Makefile cut-n-paste/Makefile cut-n-paste/recent-files/Makefile data/Makefile +pdf/Makefile +pdf/goo/Makefile +pdf/fofi/Makefile +pdf/splash/Makefile +pdf/xpdf/Makefile po/Makefile.in shell/Makefile viewer/Makefile diff --git a/pdf/.cvsignore b/pdf/.cvsignore new file mode 100644 index 00000000..282522db --- /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 00000000..b8fe1da7 --- /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 00000000..c223a98e --- /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 5459b054..ad20a885 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 2e38b52f..65502abb 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 b1151124..180a470f 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 a7d0396e..82340148 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 7628a2ba..efd0eda7 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 0497a46e..c87108d2 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 522d0552..76f1f813 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 0267abf6..760a9640 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 0ce55e9a..da2f8310 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 00000000..4ef3bb35 --- /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 00000000..753ef93f --- /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 4ff30a5f..06735eef 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 29c7f0f9..5ca14ac5 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 7d86dbd1..5d931401 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 e156c3f7..031ffc50 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 6170dfd2..28811a83 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 6c379a9c..fed328ab 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 9300fe47..b2ecfea1 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 49bbb461..3d194367 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 c6fdfb92..a492e7f3 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 34bde231..ae8d0099 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 b7e5532c..a638c02d 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 2f17995c..66d9c37e 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 20e1add9..319e141c 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 4a50fee2..33898375 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 9be5c648..c12a1510 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 30420060..cb230a7f 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 2de03e36..cb8c8961 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 00000000..df08aed1 --- /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 0824e4cd..2705cf65 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