]> www.fi.muni.cz Git - evince.git/commitdiff
Import of xpdf code from gpdf.
authorOwen Taylor <otaylor@redhat.com>
Tue, 21 Dec 2004 21:47:36 +0000 (21:47 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Tue, 21 Dec 2004 21:47:36 +0000 (21:47 +0000)
Tue Dec 21 16:30:58 2004  Owen Taylor  <otaylor@redhat.com>

        * 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

37 files changed:
ChangeLog
Makefile.am
autogen.sh
configure.ac
pdf/.cvsignore [new file with mode: 0644]
pdf/Makefile.am [new file with mode: 0644]
pdf/aconf.h [new file with mode: 0644]
pdf/fofi/Makefile.am
pdf/goo/Makefile.am
pdf/splash/Makefile.am
pdf/splash/SplashFTFont.cc
pdf/splash/SplashFTFont.h
pdf/splash/SplashFTFontEngine.h
pdf/splash/SplashFTFontFile.h
pdf/xpdf/.cvsignore
pdf/xpdf/Error.h
pdf/xpdf/GDKSplashOutputDev.cc [new file with mode: 0644]
pdf/xpdf/GDKSplashOutputDev.h [new file with mode: 0644]
pdf/xpdf/GnomeVFSStream.cc
pdf/xpdf/ImageOutputDev.cc
pdf/xpdf/Makefile.am
pdf/xpdf/PDFDoc.cc
pdf/xpdf/PSOutputDev.cc
pdf/xpdf/PSOutputDev.h
pdf/xpdf/SplashOutputDev.h
pdf/xpdf/Stream.cc
pdf/xpdf/TextOutputDev.cc
pdf/xpdf/XPDFApp.cc
pdf/xpdf/XPDFViewer.cc
pdf/xpdf/pdffonts.cc
pdf/xpdf/pdfimages.cc
pdf/xpdf/pdfinfo.cc
pdf/xpdf/pdftoppm.cc
pdf/xpdf/pdftops.cc
pdf/xpdf/pdftotext.cc
pdf/xpdf/test-gdk-output-dev.cc [new file with mode: 0644]
pdf/xpdf/xpdf.cc

index 6882d41333a923bacf51d41f53fc56edaa1d20dd..6c4ea852a6bcf430c52c25b5f136e5333c726148 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Tue Dec 21 16:30:58 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * 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  <jrb@redhat.com>
 
        * shell/ev-window.c (ev_window_dispose): dispose can be called
index 5eef06ab6a74594aac4a0843239ada96db4ce7f2..4421758834d472bf6eb12ba7423e6819e9dbed06 100644 (file)
@@ -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
 
index 7eaf1f1edce74ddf12ac347d9b92eb238bd9b522..9008f64cb1ff265e2e17b9f9fb9dd392999f6257 100755 (executable)
@@ -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
index 6a45bb0dbd9fb06efd201d8fd36623cad6b618dc..97517c5ac441b6c7b0f3e2e27807f182a70016f9 100644 (file)
@@ -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 <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/types.h>],
+  [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 <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/select.h>],
+    [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 <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/bsdtypes.h>],
+      [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 <stdlib.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#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 <stdlib.h>
+#include <sys/types.h>
+#include <strings.h>
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#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 <stdlib.h>
+#include <sys/types.h>
+#include <bstring.h>
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#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 <stdlib.h>
+#include <unistd.h>],
+[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 <stdlib.h>
+#include <unistd.h>],
+[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 <sys/types.h>
+#include <sys/time.h>
+#include <unistd.h>
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#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 (file)
index 0000000..282522d
--- /dev/null
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/pdf/Makefile.am b/pdf/Makefile.am
new file mode 100644 (file)
index 0000000..b8fe1da
--- /dev/null
@@ -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 (file)
index 0000000..c223a98
--- /dev/null
@@ -0,0 +1,2 @@
+#include <aconf2.h>
+#include <config.h>
index 5459b0546498293c8c0a8af9c6901875c7f56aa7..ad20a885c6f5c11d10717715392befc16f251b11 100644 (file)
@@ -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
 
index 2e38b52fbec67063bf1e554b48b88872e948bcdf..65502abb57540144fef9ff21f9ecad37a7b0b356 100644 (file)
@@ -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
index b1151124d1b273919160ecc05c99e2d8ff8d3852..180a470f445622634c26e998df9ff1ed46d1ba64 100644 (file)
@@ -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
 
index a7d0396e8370dd96cadfa061e2a2e7e3dafd73b2..82340148f88ba4c464907745b85e25b9a832f9a0 100644 (file)
@@ -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);
index 7628a2bad2752a549db07ad32f6701a0e436d126..efd0eda7b505d34a19863390db5fd32af5ee894c 100644 (file)
@@ -15,7 +15,8 @@
 #pragma interface
 #endif
 
-#include <freetype/freetype.h>
+#include <ft2build.h>
+#include FT_FREETYPE_H
 #include "SplashFont.h"
 
 class SplashFTFontFile;
index 0497a46e572eb71faea8f3d1720ae7a05823a638..c87108d249d5f4c9ec1152ca999083adc393c5f1 100644 (file)
@@ -15,7 +15,8 @@
 #pragma interface
 #endif
 
-#include <freetype/freetype.h>
+#include <ft2build.h>
+#include FT_FREETYPE_H
 #include "gtypes.h"
 
 class SplashFontFile;
index 522d055284497998aeb9b7c63fd32060e1a9cec8..76f1f813bd77651c0ef34096ff605e32f5f55f4e 100644 (file)
@@ -15,7 +15,8 @@
 #pragma interface
 #endif
 
-#include <freetype/freetype.h>
+#include <ft2build.h>
+#include FT_FREETYPE_H
 #include "SplashFontFile.h"
 
 class SplashFontFileID;
index 0267abf6d4cd6244c7cc82019d2274aeabc87090..760a9640621501a13cd5bd9fa1de7b7bceff43a3 100644 (file)
@@ -17,4 +17,5 @@ pdftopbm
 pdftops
 pdftotext
 semantic.cache
+test-gdk-output-dev
 xpdf
index 0ce55e9ab41505e2dacc2e833ef211e20c1dc660..da2f83107827a5a7e59608f33a5eeec58ddf4828 100644 (file)
@@ -16,7 +16,7 @@
 #endif
 
 #include <stdio.h>
-#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 (file)
index 0000000..4ef3bb3
--- /dev/null
@@ -0,0 +1,184 @@
+//========================================================================
+//
+// GDKSplashOutputDev.cc
+//
+// Copyright 2003 Glyph & Cog, LLC
+// Copyright 2004 Red Hat, Inc. (GDK port)
+//
+//========================================================================
+
+#include <aconf.h>
+
+#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 (file)
index 0000000..753ef93
--- /dev/null
@@ -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 <gdk/gdk.h>
+#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 <startAtTop> is true, starts looking at the
+  // top of the page; else if <startAtLast> is true, starts looking
+  // immediately after the last find result; else starts looking at
+  // <xMin>,<yMin>.  If <stopAtBottom> is true, stops looking at the
+  // bottom of the page; else if <stopAtLast> is true, stops looking
+  // just before the last find result; else stops looking at
+  // <xMax>,<yMax>.
+  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
index 4ff30a5f9616de4b0d967e170184923a7f52c475..06735eef146e46f55eea78aafd1a6a216a460dda 100644 (file)
@@ -12,7 +12,7 @@
 #endif
 
 #include <aconf.h>
-#include "config.h"
+#include "xpdfconfig.h"
 
 #include "GnomeVFSStream.h"
 #include "gpdf-g-switch.h"
index 29c7f0f956c137c4c1750de605b9a9dab427d744..5ca14ac5a1b6d4e3192ae1c0d568b5a5e35f7f35 100644 (file)
@@ -17,7 +17,7 @@
 #include <stddef.h>
 #include <ctype.h>
 #include "gmem.h"
-#include "config.h"
+#include "xpdfconfig.h"
 #include "Error.h"
 #include "GfxState.h"
 #include "Object.h"
index 7d86dbd18a70075f69a0d84c2ff810920f143a3d..5d931401247f3d266751f6cb543c72e793a11fae 100644 (file)
@@ -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
index e156c3f7232e5c247ba1109ffca4e4d1cac86f75..031ffc50df93beb099d43ba53dfdc1cbd8566d18 100644 (file)
@@ -18,7 +18,7 @@
 #include <stddef.h>
 #include <string.h>
 #include "GString.h"
-#include "config.h"
+#include "xpdfconfig.h"
 #include "GlobalParams.h"
 #include "Page.h"
 #include "Catalog.h"
index 6170dfd2c9c4d6d7c5e5b6828a1ab061efd7c2c5..28811a8320593679d91553dc4aa227c648d94eee 100644 (file)
@@ -19,7 +19,7 @@
 #include <math.h>
 #include "GString.h"
 #include "GList.h"
-#include "config.h"
+#include "xpdfconfig.h"
 #include "GlobalParams.h"
 #include "Object.h"
 #include "Error.h"
index 6c379a9c51a6624e9ef51b4b71c8e0d44a7aeaaa..fed328abe6756cc5ac7f462e8866845090752758 100644 (file)
@@ -16,7 +16,7 @@
 #endif
 
 #include <stddef.h>
-#include "config.h"
+#include "xpdfconfig.h"
 #include "Object.h"
 #include "GlobalParams.h"
 #include "OutputDev.h"
index 9300fe471f472f3fda69a914eec7700f38398346..b2ecfea17c06f01a21ac5a285c79e311a597369f 100644 (file)
@@ -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;
index 49bbb461524ea6e59d4eecaf6ac3d5f9ecb11a07..3d19436774229ebc9b34245c2e9d856c43edc232 100644 (file)
@@ -22,7 +22,7 @@
 #include <ctype.h>
 #include "gmem.h"
 #include "gfile.h"
-#include "config.h"
+#include "xpdfconfig.h"
 #include "Error.h"
 #include "Object.h"
 #ifndef NO_DECRYPTION
index c6fdfb92bb7627d040149200dda70547f97aa539..a492e7f3e178c2b1c4d90bb2953af97059acacb8 100644 (file)
@@ -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"
index 34bde23154be36a2e3fac3a617c224d1acc9a90e..ae8d0099e241114509e556bd66e19efcdc881e09 100644 (file)
@@ -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
index b7e5532c628fb737f36356f93658807d9410730d..a638c02daf81557bddbe6061b81deea55c90e1b0 100644 (file)
@@ -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
index 2f17995cea97bdd8bb0db906d8837e944a238a51..66d9c37e39ef6699b41587c09b115e6c6565934e 100644 (file)
@@ -22,7 +22,7 @@
 #include "GfxFont.h"
 #include "Annot.h"
 #include "PDFDoc.h"
-#include "config.h"
+#include "xpdfconfig.h"
 
 static char *fontTypeNames[] = {
   "unknown",
index 20e1add911f8908bfe8373105992ee66e64cb185..319e141c4df4ea389b33bfa66f343c5b8955a321 100644 (file)
@@ -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;
index 4a50fee2afe6f928b96bce2309847c5ee315f577..33898375182c5bf198df32fadb07c38b63d3306d 100644 (file)
@@ -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);
index 9be5c6486c7f0f923875155d3ca7cff1adb2a65a..c12a15107d85b6a2227be724f5bde7d4297a33c0 100644 (file)
@@ -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;
index 30420060997f93797e64500ce5cab22b79c81df7..cb230a7fb80d29ff5609ed86c71e5d15e666cefd 100644 (file)
@@ -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;
index 2de03e360c28c66f03c0d96db29ee9ae3475a96f..cb8c8961a494ecefa5f02340a62b2d69e907e8f0 100644 (file)
@@ -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 (file)
index 0000000..df08aed
--- /dev/null
@@ -0,0 +1,179 @@
+/**
+ * render a PDF to GDKSplashOutputDev
+ *
+ * Copyright 2004 Red Hat, Inc.
+ */
+
+#include <config.h>
+
+#include <aconf.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gpdf-g-switch.h"
+#include <gtk/gtk.h>
+#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;
+}
index 0824e4cdd43b348b4991e252cc04442665798bb8..2705cf653582bff0a7578d8bf454cab3ce745ed5 100644 (file)
@@ -15,7 +15,7 @@
 #include "GlobalParams.h"
 #include "Object.h"
 #include "XPDFApp.h"
-#include "config.h"
+#include "xpdfconfig.h"
 
 //------------------------------------------------------------------------
 // command line options