#484576: Support goffice >= 0.5.1.

For us, goffice 0.5.1 differs from 0.4 in that it lacks GogRendererCairo
and we can use GogRenderer and gog_renderer_render_to_cairo() (new)
directly.
goffice 0.5.0 will not work with GnuCash.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16572 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andreas Köhler 2007-10-28 12:27:48 +00:00
parent fce9bff550
commit 40a4db7a41
2 changed files with 54 additions and 19 deletions

View File

@ -1113,33 +1113,49 @@ then
AC_SUBST(GLADE_CFLAGS)
AC_SUBST(GLADE_LIBS)
PKG_CHECK_MODULES(GOFFICE, libgoffice-0.4 >= 0.4.0, [], [
PKG_CHECK_MODULES(GOFFICE, libgoffice-0.3 >= 0.3.0, [], [
PKG_CHECK_MODULES(GOFFICE, libgoffice-1 >= 0.0.4, [], [
AC_MSG_ERROR([Cannot find libgoffice.])
# checks for goffice
goffice=0
goffice_with_cairo=0
PKG_CHECK_MODULES(GOFFICE, libgoffice-0.5 >= 0.5.0, [
AC_DEFINE(HAVE_GOFFICE_0_5,1,[System has goffice 0.5 or better])
AC_DEFINE(GOFFICE_WITH_CAIRO,1,[GOffice has been built with cairo support])
goffice=1
goffice_with_cairo=1
], [goffice=0])
if test x$goffice = x0
then
PKG_CHECK_MODULES(GOFFICE, libgoffice-0.4 >= 0.4.0, [goffice=1], [
PKG_CHECK_MODULES(GOFFICE, libgoffice-0.3 >= 0.3.0, [goffice=1], [
PKG_CHECK_MODULES(GOFFICE, libgoffice-1 >= 0.0.4, [goffice=1], [
AC_MSG_ERROR([Cannot find libgoffice.])
])
])
])
])
fi
AS_SCRUB_INCLUDE(GOFFICE_CFLAGS)
AC_SUBST(GOFFICE_CFLAGS)
AC_SUBST(GOFFICE_LIBS)
saved_CPPFLAGS="${CPPFLAGS}"
CPPFLAGS="${GOFFICE_CFLAGS} ${CPPFLAGS}"
AC_CHECK_HEADER(goffice/graph/gog-renderer-cairo.h, [
AC_DEFINE(GOFFICE_WITH_CAIRO,1,[GOffice has been built with cairo support])
goffice_with_cairo=yes
], [
goffice_with_cairo=no
])
CPPFLAGS="${saved_CPPFLAGS}"
if test x$goffice_with_cairo = x0
then
saved_CPPFLAGS="${CPPFLAGS}"
CPPFLAGS="${GOFFICE_CFLAGS} ${CPPFLAGS}"
AC_CHECK_HEADER(goffice/graph/gog-renderer-cairo.h, [
AC_DEFINE(GOFFICE_WITH_CAIRO,1,[GOffice has been built with cairo support])
goffice_with_cairo=1
], [
goffice_with_cairo=0
])
CPPFLAGS="${saved_CPPFLAGS}"
fi
# check for gtkhtml >= 3.14 with gtkprint support
gtkhtml=0
PKG_CHECK_MODULES(GTKHTML, libgtkhtml-3.14, [
if test "x$HAVE_GTK_2_10" != "xyes"; then
AC_MSG_NOTICE([Found libgtkhtml-3.14, but not gtk+-2.0 >= 2.10])
elif test "x$goffice_with_cairo" != "xyes"; then
elif test "x$goffice_with_cairo" != "x1"; then
AC_MSG_NOTICE([Found libgtkhtml-3.14, but goffice lacks a cairo renderer])
else
gtkhtml=1

View File

@ -36,7 +36,9 @@
#include <goffice/graph/gog-chart.h>
#include <goffice/graph/gog-graph.h>
#include <goffice/graph/gog-object.h>
#ifdef GOFFICE_WITH_CAIRO
#if defined(HAVE_GOFFICE_0_5)
# include <goffice/graph/gog-renderer.h>
#elif defined(GOFFICE_WITH_CAIRO)
# include <goffice/graph/gog-renderer-cairo.h>
#else
# include <goffice/graph/gog-renderer-pixbuf.h>
@ -170,7 +172,9 @@ static void
add_pixbuf_graph_widget( GtkHTMLEmbedded *eb, GogObject *graph )
{
GtkWidget *widget;
#ifdef GOFFICE_WITH_CAIRO
#if defined(HAVE_GOFFICE_0_5)
GogRenderer *renderer;
#elif defined(GOFFICE_WITH_CAIRO)
GogRendererCairo *cairo_renderer;
#else
GogRendererPixbuf *pixbuf_renderer;
@ -184,7 +188,13 @@ add_pixbuf_graph_widget( GtkHTMLEmbedded *eb, GogObject *graph )
// gnumeric uses. We probably _should_ do something like that, though.
gog_object_update (GOG_OBJECT (graph));
#ifdef GOFFICE_WITH_CAIRO
#if defined(HAVE_GOFFICE_0_5)
renderer = GOG_RENDERER (g_object_new (GOG_RENDERER_TYPE,
"model", graph,
NULL));
update_status = gog_renderer_update (renderer, eb->width, eb->height);
buf = gog_renderer_get_pixbuf (renderer);
#elif defined(GOFFICE_WITH_CAIRO)
cairo_renderer = GOG_RENDERER_CAIRO (g_object_new (GOG_RENDERER_CAIRO_TYPE,
"model", graph,
NULL));
@ -198,7 +208,7 @@ add_pixbuf_graph_widget( GtkHTMLEmbedded *eb, GogObject *graph )
update_status = gog_renderer_pixbuf_update (pixbuf_renderer,
eb->width, eb->height, 1.0);
buf = gog_renderer_pixbuf_get (pixbuf_renderer);
#endif /* GOFFICE_WITH_CAIRO */
#endif
widget = gtk_image_new_from_pixbuf (buf);
gtk_widget_set_size_request (widget, eb->width, eb->height);
@ -628,14 +638,23 @@ static void
draw_print_cb(GtkHTMLEmbedded *eb, cairo_t *cr, gpointer unused)
{
GogGraph *graph = GOG_GRAPH(g_object_get_data(G_OBJECT(eb), "graph"));
# ifdef HAVE_GOFFICE_0_5
GogRenderer *rend = g_object_new(GOG_RENDERER_TYPE, "model", graph, NULL);
# else
GogRendererCairo *rend = g_object_new(GOG_RENDERER_CAIRO_TYPE, "model", graph,
"cairo", cr, "is-vector", TRUE, NULL);
# endif
/* assuming pixel size is 0.5, cf. gtkhtml/src/htmlprinter.c */
cairo_scale(cr, 0.5, 0.5);
cairo_translate(cr, 0, -eb->height);
# ifdef HAVE_GOFFICE_0_5
gog_renderer_render_to_cairo(rend, cr, eb->width, eb->height);
# else
gog_renderer_cairo_update(rend, eb->width, eb->height, 1.0);
# endif
g_object_unref(rend);
}