Fold branches/goffice-update/ back into trunk/.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12096 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Joshua Sled 2005-12-04 21:27:17 +00:00
parent b73d9ce74a
commit 94e9fe5e6f
927 changed files with 420021 additions and 55983 deletions

View File

@ -1,3 +1,7 @@
2005-12-04 Joshua Sled <jsled@asynchronous.org>
* All: Fold branches/goffice-update/ back into trunk/.
2005-12-04 David Hampton <hampton@employees.org>
* src/gnome-utils/test/test-gnc-recurrence.c:
@ -155,6 +159,12 @@
* src/engine/Transaction.c: Initialize the qof entity in the new
split, not the old one.
2005-11-26 David Hampton <hampton@employees.org>
* lib/goffice-0.0.4/plugins/plot_radar/gog-radar.c:
* lib/goffice-0.0.4/goffice/app/go-plugin.c: Compile cleanly using
gcc4.
2005-11-25 David Hampton <hampton@employees.org>
* src/business/dialog-tax-table/dialog-tax-table.c: Andreas
@ -205,6 +215,24 @@
* src/gnome/gnc-plugin-page-account-tree.c: Update default
accelerator keys as per the HIG.
2005-11-25 Derek Atkins <derek@ihtfp.com>
* src/gnome-utils/Makefile.am:
add GSF_CFLAGS
* lib/goffice-0.0.4/goffice/utils/go-libxml-extras.c
lib/goffice-0.0.4/goffice/utils/datetime.c:
lib/goffice-0.0.4/goffice/graph/gog-chart.c
lib/goffice-0.0.4/goffice/graph/gog-plot.c
lib/goffice-0.0.4/goffice/graph/gog-object.c
lib/goffice-0.0.4/goffice/gtk/goffice-gtk.c:
look for goffice/glib24_26-compat.h
* lib/goffice-0.0.4/goffice/Makefile.am:
don't deal with goffice-features.h anymore
* configure.in:
fix for FC3 dependencies
* Makefile.am:
create goffice -> , symlink when building internal goffice
2005-11-23 David Hampton <hampton@employees.org>
* src/report/report-gnome/report-gnome.scm:
@ -560,6 +588,53 @@
* po/glossary/no.po: Updated Norwegian/Bokmaal glossary
translation by Tor Harald Thorland <linux@strigen.com>.
2005-11-20 Neil Williams <linux@codehelp.co.uk>
* goffice-config.h.in : svn moved from
lib/goffice-0.0.4/goffice to prevent unnecessary
subdirectory inclusion in make outside lib.
* goffice-features.h.in : svn moved from
lib/goffice-0.0.4/goffice.
* gsf-config.h.in : svn moved from lib/libsf-1.12.3
* configure.in : Create AC_CONFIG_HEADERS only in
$(top_srcdir) and stop using LDFLAGS = -no-undeclared
* lib/goffice-0.0.4/goffice-plugins.mk : handle new config
header location.
* lib/goffice-0.0.4/tests/Makefile.am : Don't overwrite AM_LDFLAGS
* lib/goffice-0.0.4/goffice/cut-n-paste/foocanvas/Makefile.am :
handle new config header location.
* lib/goffice-0.0.4/goffice.mk : Handle new config header location.
2005-11-20 Neil Williams <linux@codehelp.co.uk>
* lib/goffice-0.0.4/plugins/plot_radar/gog-radar.c :
Mac OSX fix: comment out #warning
* lib/goffice-0.0.4/plugins/plot_xy/gog-bubble-prefs.c :
* lib/goffice-0.0.4/plugins/plot_xy/gog-xy.c :
* lib/goffice-0.0.4/goffice/app/file.c :
* lib/goffice-0.0.4/goffice/gtk/go-combo-pixmaps.c :
* lib/goffice-0.0.4/goffice/gtk/go-action-combo-color.c :
* lib/goffice-0.0.4/goffice/gtk/go-font-sel.c :
* lib/goffice-0.0.4/goffice/gtk/go-color-palette.c :
* lib/goffice-0.0.4/goffice/gtk/go-combo-color.c :
* lib/goffice-0.0.4/goffice/gtk/go-combo-box.c :
* lib/goffice-0.0.4/goffice/cut-n-paste/foocanvas/foo-canvas-line.c
* lib/goffice-0.0.4/goffice/cut-n-paste/foocanvas/foo-canvas-polygon.c
* lib/goffice-0.0.4/goffice/utils/go-pattern.c
* lib/goffice-0.0.4/goffice/graph/gog-guru.c
* lib/goffice-0.0.4/goffice/graph/gog-legend.c
* lib/goffice-0.0.4/goffice/graph/gog-graph.c
* lib/goffice-0.0.4/goffice/graph/gog-error-bar.c
* lib/goffice-0.0.4/goffice/graph/gog-style.c
* lib/goffice-0.0.4/goffice/graph/gog-theme.c
* lib/libgsf-1.12.3/gsf-gnome/gsf-input-bonobo.c :
* lib/goffice-0.0.4/goffice.mk :
Adding AM_LDFLAGS for OSX build
* lib/goffice-0.0.4/ : setting svn:ignore
* lib/libgsf-1.12.3/ : setting svn:ignore
2005-11-19 David Hampton <hampton@employees.org>
* various: More include file tweaking. Don't include gtk.h from
@ -913,6 +988,11 @@
Make sure x_offset gets reset when changing cells via the keyboard.
2005-11-09 Josh Sled <jsled@asynchronous.org>
* lib/goffice-0.0.4/, lib/libgsf-1.12.3/: imported with changes to
update previously hacked-together versions.
2005-11-09 David Hampton <hampton@employees.org>
* src/gnome-utils/gnc-tree-view-account.[ch]: Add a function that

View File

@ -1,12 +1,12 @@
SUBDIRS = doc lib src intl-scm po rpm accounts
SUBDIRS = . doc lib src intl-scm po rpm accounts
docdir = ${GNC_DOC_INSTALL_DIR}
GNC_CTAGS_FILE = @GNC_CTAGS_FILE@
GNC_ETAGS_FILE = @GNC_ETAGS_FILE@
noinst_DATA = make-gnucash-patch make-gnucash-potfiles
noinst_DATA = make-gnucash-patch make-gnucash-potfiles .goffice-links
doc_DATA = \
AUTHORS \
@ -93,10 +93,19 @@ make-gnucash-potfiles: make-gnucash-potfiles.in Makefile
chmod +x $@.tmp
mv $@.tmp $@
.goffice-links:
rm -f goffice
if !HAVE_GOFFICE
ln -sf . goffice
endif
touch .goffice-links
DISTCLEANFILES = \
intltool-extract intltool-update intltool-merge\
cscope.files cscope.out etags.files make-gnucash-patch \
make-gnucash-potfiles po/.intltool-merge-cache
make-gnucash-potfiles po/.intltool-merge-cache \
goffice .goffice-links
cscope.files:
find . -name '*.[ch]' > cscope.files

View File

@ -99,13 +99,6 @@ AC_CHECK_FUNCS(setenv,,[
])
])
## +jsled
# copied from gnumeric for our lib/goffice/ stuffs.
AC_CHECK_HEADERS(ieeefp.h ieee754.h)
dnl Check for some functions
AC_CHECK_FUNCS(random drand48 finite memmove mkdtemp uname times sysconf fmin)
## --jsled
STRUCT_TM_GMTOFF_CHECK
SCANF_LLD_CHECK
if test $am_cv_scanf_lld = "no"; then
@ -243,6 +236,8 @@ AC_MSG_RESULT($G_WRAP_COMPILE_ARGS)
AC_MSG_CHECKING(for g-wrap link args)
G_WRAP_LINK_ARGS=`${G_WRAP_CONFIG} --c-link-args guile`
# Dear g-wrap: adding -L/usr/lib is very silly. Do not do this.
G_WRAP_LINK_ARGS=`echo ${G_WRAP_LINK_ARGS} | sed -e 's|-L/usr/lib ||'`
AC_MSG_RESULT($G_WRAP_LINK_ARGS)
AC_MSG_CHECKING(for g-wrap module directory)
@ -447,75 +442,819 @@ AC_SUBST(QOF_XML_DIR)
### --------------------------------------------------------------------------
### for GOG/goffice...
dnl If libgoffice-1 >= 0.0.3-2 and libgsf >= 1.12.2-1 are found,
dnl we need to omit lib/goffice and use the external library
dnl because lib/goffice will not build with newer versions of libgsf.
AC_MSG_CHECKING(for GTK - version >= 2.6.0)
if $PKG_CONFIG 'gtk+-2.0 >= 2.6.0'
then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GTK26,1,[System has gtk 2.6.0 or better])
HAVE_GTK26=yes
else
AC_MSG_RESULT(no)
fi
AM_CONDITIONAL(HAVE_GTK26, test "x$HAVE_GTK26" = "xyes" )
GOFFICE_REQUIRED=0.0.3
GSF_REQUIRED=1.12.2
AC_MSG_CHECKING([for GOffice and GSF])
LIBGOFFICE_CFLAGS=`$PKG_CONFIG --silence-errors --cflags " libgoffice-1 >= $GOFFICE_REQUIRED"`
LIBGOFFICE_LIBS=`$PKG_CONFIG --silence-errors --libs " libgoffice-1 >= $GOFFICE_REQUIRED"`
LIBGSF_CFLAGS=`$PKG_CONFIG --silence-errors --cflags " libgsf-1 >= $GSF_REQUIRED"`
LIBGSF_LIBS=`$PKG_CONFIG --silence-errors --libs " libgsf-1 >= $GSF_REQUIRED"`
AC_SUBST(LIBGOFFICE_CFLAGS)
AC_SUBST(LIBGOFFICE_LIBS)
if test x"$LIBGOFFICE_LIBS" = x; then
AC_MSG_RESULT([No, GOffice not found, will build using internal goffice library.])
if test x"$LIBGSF_LIBS" != x; then
AC_MSG_NOTICE([Sorry, the internal goffice code cannot build with libgsf >= $GSF_REQUIRED.])
AC_MSG_ERROR([Please either install goffice or downgrade libgsf to earlier than $GSF_REQUIRED])
exit 1
AC_MSG_CHECKING(for pango version >= 1.8.0)
if $PKG_CONFIG 'pango >= 1.8.0'
then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_PANGO18,1,[System has pango 1.8.0 or better])
HAVE_PANGO18=yes
else
AC_MSG_RESULT(no)
fi
AM_CONDITIONAL(HAVE_PANGO18, test "x$HAVE_PANGO18" = "xyes" )
dnl @@fixme
dnl use both PKG_CHECK_MODULES and `$PKG_CONFIG`; the first importantly sets
dnl MUMBLE_{LIBS,CFLAGS}...
dnl Q: What does PKG_CHECK_MODULES create?
dnl A: Just _CFLAGS and _LIBS, apparently [pkg.m4]
dnl $4=true => don't die in case of failure.
PKG_CHECK_MODULES(GSF, libgsf-1 >= 1.12.2
libgsf-gnome-1 >= 1.12.2,,true)
if $PKG_CONFIG 'libgsf-1 >= 1.12.2'
then
AC_DEFINE(HAVE_LIBGSF,1,[System has libgsf-1.12.2 or better])
HAVE_LIBGSF=yes
else
AC_MSG_NOTICE(using internally-packaged libgsf)
GSF_CFLAGS='-I${top_srcdir}/lib/libgsf-1.12.3'
GSF_LIBS='${top_builddir}/lib/libgsf-1.12.3/gsf/libgsf-1.la'
NEED_LIBGSF=yes
fi
AM_CONDITIONAL(HAVE_LIBGSF, test "x$HAVE_LIBGSF" = "xyes")
AC_SUBST(GSF_CFLAGS)
AC_SUBST(GSF_LIBS)
dnl $4=true => don't die if failure.
PKG_CHECK_MODULES(GOFFICE, libgoffice-1 >= 0.0.4,,true)
if $PKG_CONFIG 'libgoffice-1 >= 0.0.4'
then
AC_DEFINE(HAVE_GOFFICE,1,[System has goffice-0.0.4 or better])
HAVE_GOFFICE=yes
else
AC_MSG_NOTICE(using internally-packaged goffice)
GOFFICE_CFLAGS='-I${top_srcdir}/lib/goffice-0.0.4'
GOFFICE_LIBS='${top_builddir}/lib/goffice-0.0.4/goffice/libgoffice-1.la'
NEED_GOFFICE=yes
fi
AM_CONDITIONAL(HAVE_GOFFICE, test "x$HAVE_GOFFICE" = "xyes")
AC_SUBST(GOFFICE_CFLAGS)
AC_SUBST(GOFFICE_LIBS)
### ----------
### +libgsf-1.12.3
if test "x$HAVE_LIBGSF" != xyes; then
AC_MSG_NOTICE('internal libgsf configuration...')
m4_define([libgsf_version_major], [1])
m4_define([libgsf_version_minor], [12])
m4_define([libgsf_version_micro], [3])
m4_define([libgsf_version_extra], [])
m4_define([libgsf_full_version],
[libgsf_version_major.libgsf_version_minor.libgsf_version_micro[]libgsf_version_extra])
dnl AC_CONFIG_SRCDIR(lib/libgsf-1.12.3/gsf/gsf.h)
AC_SUBST(LIBGSF_MAJOR_VERSION, libgsf_version_major)
AC_SUBST(LIBGSF_MINOR_VERSION, libgsf_version_minor)
AC_SUBST(LIBGSF_MICRO_VERSION, libgsf_version_micro)
dnl Version info for libraries = CURRENT:REVISION:AGE
AC_SUBST(VERSION_INFO,
m4_eval(libgsf_version_major + libgsf_version_minor)[]dnl
:libgsf_version_micro:libgsf_version_minor)
dnl 2005-11-19,jsled, this doesn't seem to work... :(
dnl ifelse(x$HAVE_LIBGSF, xyes,,
AC_CONFIG_HEADERS(gsf-config.h)
dnl)
AC_FUNC_FSEEKO
AC_SYS_LARGEFILE
dnl Checks for libraries.
ifelse([
If we defined the module lists on the M4 level, we could have problems
with PKG_CHECK_MODULES from pkgconfig 0.16.0, which double quotes its
second argument (the module list).
As a handy workaround, we use shell variables.
])
dnl Modules common to libgsf and libgsf-gnome
libgsf_reqs="
gobject-2.0 >= 2.4.0
glib-2.0 >= 2.4.0
libxml-2.0 >= 2.4.16
"
dnl Modules required for libgsf-gnome
libgsf_gnome_reqs="
$libgsf_reqs
libbonobo-2.0 >= 2.0.0
gnome-vfs-2.0 >= 2.2.0
gnome-vfs-module-2.0 >= 2.2.0
"
PKG_CHECK_MODULES(LIBGSF, $libgsf_reqs)
# this should come after `AC_PROG_CC'
#ifdef([GNOME_COMPILE_WARNINGS],[GNOME_COMPILE_WARNINGS],)
#CFLAGS="$CFLAGS $WARN_CFLAGS -DG_DISABLE_DEPRECATED"
#if test "$GCC" = "yes"; then
# for option in -Wno-system-headers -Wfloat-equal -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wformat -Wnested-externs -Winline -Wdeclaration-after-statement -Wundef -W -Wmissing-noreturn -Wmissing-format-attribute; do
# SAVE_CFLAGS="$CFLAGS"
# CFLAGS="$CFLAGS $option"
# AC_MSG_CHECKING([whether gcc understands $option])
# AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
# has_option=yes,
# has_option=no)
# if test $has_option = no; then
# CFLAGS="$SAVE_CFLAGS"
# fi
# AC_MSG_RESULT($has_option)
# unset has_option
# unset SAVE_CFLAGS
# done
# unset option
#fi
AC_CHECK_DECL(fdopen, fdopen_works=yes, fdopen_works=no)
if test $fdopen_works = no ; then
unset ac_cv_have_decl_fdopen
CFLAGS="$CFLAGS -D_POSIX_SOURCE"
AC_MSG_NOTICE([adding -D_POSIX_SOURCE to CFLAGS])
AC_CHECK_DECL(fdopen, fdopen_works=yes, fdopen_works=no)
if test $fdopen_works = no ; then
AC_MSG_ERROR([fdopen is not available])
fi
fi
# Unfortunately, -D_POSIX_SOURCE turns off struct timeval on Solaris
AC_MSG_CHECKING([whether struct timeval is available])
for try in 1 2; do
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <sys/time.h>]],
[[struct timeval tv;]])],
struct_timeval_works=yes,
struct_timeval_works=no)
test $struct_timeval_works = yes && break
# Try this for the second attempt:
test $try = 1 && CFLAGS="$CFLAGS -D__EXTENSIONS__"
done
AC_MSG_RESULT($struct_timeval_works)
if test $struct_timeval_works = no ; then
AC_MSG_ERROR([struct timeval is not available])
fi
AC_MSG_CHECKING([whether -D_BSD_SOURCE is needed for caddr_t])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <sys/types.h>]], [[caddr_t ca]])],
need_bsd1=no,
need_bsd1=yes)
AC_MSG_RESULT($need_bsd1)
AC_MSG_CHECKING([whether -D_BSD_SOURCE is needed for lstat])
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>]],
[[void *ptr = &lstat]])],
need_bsd2=no, need_bsd2=yes)
AC_MSG_RESULT($need_bsd2)
if test $need_bsd1 = yes -o $need_bsd2 = yes; then
CFLAGS="$CFLAGS -D_BSD_SOURCE"
fi
AC_TYPE_MODE_T
AC_CHECK_HEADERS(fcntl.h malloc.h unistd.h io.h)
AC_FUNC_MMAP
AC_CHECK_FUNCS(chown)
SAVE_CFLAGS=$CFLAGS
SAVE_LIBS=$LIBS
CFLAGS="$CFLAGS $LIBGSF_CFLAGS"
LIBS="$LIBGSF_LIBS $LIBS"
AC_MSG_CHECKING([for g_chmod])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <glib/gstdio.h>]], [[(void)g_chmod("/xxx",0777);]])],
[AC_DEFINE(HAVE_G_CHMOD, 1, [Define if g_chmod is available as macro or function])
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
AC_MSG_CHECKING([for g_access])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <glib/gstdio.h>]], [[(void)g_access("/xxx",0777);]])],
[AC_DEFINE(HAVE_G_ACCESS, 1, [Define if g_access is available as macro or function])
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
CFLAGS=$SAVE_CFLAGS
LIBS=$SAVE_LIBS
AC_MSG_CHECKING([whether macro S_ISREG is available])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#include <sys/types.h>
#include <sys/stat.h>]],
[[S_ISREG(S_IFMT);]])],
[macro_s_isreg=yes],
[AH_TEMPLATE([S_ISREG], [Define S_ISREG if stat.h doesn't])
AC_DEFINE([S_ISREG(m)], [(((m) & S_IFMT) == S_IFREG)])
macro_s_isreg=no])
AC_MSG_RESULT($macro_s_isreg)
AC_MSG_CHECKING([for native Win32])
case $host in
*-*-mingw*)
native_win32=yes
;;
*)
native_win32=no
;;
esac
AC_MSG_RESULT([$native_win32])
AM_CONDITIONAL(OS_WIN32, test "$native_win32" = yes)
AC_MSG_CHECKING([for Win32 platform in general])
case $host in
*-*-mingw*|*-*-cygwin*)
platform_win32=yes
;;
*)
platform_win32=no
;;
esac
AC_MSG_RESULT($platform_win32)
AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = yes)
##################################################
# Checks for gtk-doc and docbook-tools
##################################################
gtk_doc_installed=true
#ifdef([GTK_DOC_CHECK],[GTK_DOC_CHECK([1.0])],[gtk_doc_installed=false])
# I would have liked to conditionalize this, but
# that appears to break other things http://bugzilla.gnome.org/show_bug.cgi?id=156399
GTK_DOC_CHECK([1.0])
AM_CONDITIONAL(GTK_DOC_INSTALLED, $gtk_doc_installed)
dnl ***********************************************************************************
# Check for zlib.
_cppflags=$CPPFLAGS
_ldflags=$LDFLAGS
Z_DIR= Z_LIBS= Z_CPPFLAGS=
AC_ARG_WITH(zlib,
[[ --with-zlib=DIR use libz in DIR]],
[case $withval in
yes|no) ;;
*) Z_DIR=$withval
CPPFLAGS="${CPPFLAGS} -I$withval/include"
LDFLAGS="${LDFLAGS} -L$withval/lib"
;;
esac])
if test "x$with_zlib" != xno; then
with_zlib=no
AC_CHECK_HEADER(zlib.h, [AC_CHECK_LIB(z, gzread, [with_zlib=yes])])
fi
if test "$with_zlib" = no; then
AC_MSG_ERROR([*** zlib is required])
fi
if test "x$Z_DIR" != "x"; then
Z_CPPFLAGS="-I$Z_DIR/include"
case $host in
*-*-solaris*) Z_LIBS="-L$Z_DIR/lib -R$Z_DIR/lib -lz" ;;
*) Z_LIBS="-L$Z_DIR/lib -lz" ;;
esac
else
Z_LIBS="-lz"
fi
AC_SUBST(Z_CPPFLAGS)
AC_SUBST(Z_LIBS)
CPPFLAGS=${_cppflags}
LDFLAGS=${_ldflags}
dnl bz2
dnl
BZ2_LIBS=
test_bz2=true
AC_ARG_WITH(bz2,
[--{with,without}-bz2 Build additional wrappers for BZ2],
if test "x$withval" = xno; then
test_bz2=false
fi
)
with_bz2=false
if test "x$test_bz2" = xtrue ; then
AC_CHECK_LIB(bz2, BZ2_bzDecompressInit,
bz2_ok=yes,
bz2_ok=no
AC_MSG_WARN(*** BZ2 support disabled (BZ2 library not found) ***))
if test "$bz2_ok" = yes; then
AC_MSG_CHECKING([for bzlib.h])
AC_PREPROC_IFELSE(
[AC_LANG_SOURCE(
[[#include <stdio.h>
#undef PACKAGE
#undef VERSION
#undef HAVE_STDLIB_H
#include <bzlib.h>]])],
bz2_ok=yes,
bz2_ok=no)
AC_MSG_RESULT($bz2_ok)
fi
if test "$bz2_ok" = yes; then
AC_DEFINE(HAVE_BZ2, 1, [Is bzip2 available and enabled])
BZ2_LIBS="-lbz2"
else
AC_MSG_WARN(*** BZ2 support disabled (BZ2 header not found) ***)
fi
else
AC_MSG_RESULT([Yes, using GOffice])
AC_DEFINE(HAVE_GOFFICE,,[We have found an external GOffice])
HAVE_GOFFICE="use_external"
AC_MSG_WARN([BZ2 support disabled, as requested (Use --with-bz2 to enable)])
fi
AM_CONDITIONAL(USE_LIBGOFFICE, [test x$HAVE_GOFFICE != x])
AM_CONDITIONAL(USE_LIBGOFFICE, [test $HAVE_GOFFICE = "use_external"])
AC_SUBST(USE_LIBGOFFICE)
###
### GSF
PKG_CHECK_MODULES(GSF, libgsf-1 >= 1.8.0
libgsf-gnome-1 >= 1.8.0)
AC_SUBST(GSF_LIBS)
AC_SUBST(GSF_CFLAGS)
AC_SUBST(BZ2_LIBS)
### libart
PKG_CHECK_MODULES(ART, libart-2.0 >= 2.3.11)
AC_SUBST(ART_LIBS)
AC_SUBST(ART_CFLAGS)
dnl ***********************************************************************************
### silence convention-difference from cut-n-paste'd gnumeric Makefile.am's:
AM_CONDITIONAL(WITH_GNOME, true)
# for lib/goffice/graph/plugins/plot_barcol/gog-1.5d.c's use of
# goffice/graph/gog-error-bar.h:gog_error_bar_prefs, which is bounded by
# WITH_GTK for some reason... :/
AM_CONDITIONAL(WITH_GTK, true)
AC_DEFINE(WITH_GTK, 1, [Define if UI is built])
dnl gnome
dnl
want_gnome=auto
AC_ARG_WITH(gnome,
[--{with,without}-gnome Build additional wrappers for GNOME-VFS and BONOBO],
[case $withval in
yes) want_gnome=yes;;
no) want_gnome=no;;
esac[]dnl
])
have_gnome=no
if test $want_gnome = no ; then
AC_MSG_WARN([GNOME support disabled, as requested (Use --with-gnome to enable)])
else
PKG_CHECK_MODULES(LIBGSF_GNOME, $libgsf_gnome_reqs,
[have_gnome=yes],
[if test $want_gnome = yes; then
AC_MSG_ERROR([GNOME support requested, but not available.])
else
AC_MSG_WARN([GNOME support disabled, unable to find required version of VFS and/or Bonobo])
fi])
fi
AM_CONDITIONAL(WITH_LIBGSF_GNOME, test $have_gnome = yes)
### gnome-print [= gnome-font]
PKG_CHECK_MODULES(PRINT, libgnomeprint-2.2 >= 2.5.2)
AC_SUBST(PRINT_LIBS)
AC_SUBST(PRINT_CFLAGS)
# GConf configuration
dnl Don't publish the GCONFTOOL variable, AM_GCONF_SOURCE_2 has ``gconftool-2'' hardwired.
GCONFTOOL=
AC_CHECK_PROG([GCONFTOOL], [gconftool-2], [gconftool-2], [no])
if test "x$GCONFTOOL" = "xno"; then
AC_MSG_WARN([thumbnailer will not be built, unable to find gconftool-2])
else
AM_GCONF_SOURCE_2
fi
AM_CONDITIONAL(WITH_GCONF, test "x$GCONFTOOL" != "xno")
AC_ARG_VAR(GLIB_GENMARSHAL, [Absolute path of the glib-genmarshal executable.])
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
dnl # LDFLAGS="-no-undefined $LDFLAGS"
gog_plugindir='${GNC_LIBDIR}/plugins'
# do this to minimize changes in the plugin makefiles...
gnumeric_plugindir='${gog_plugindir}'
AC_SUBST(gog_plugindir)
AC_SUBST(gnumeric_plugindir)
#AC_SUBST(pkglibdir) -- this breaks builds into /opt.
gnumeric_icondir='${GNC_SHAREDIR}/pixmaps'
AC_SUBST(gnumeric_icondir)
# turn off unneeded python support
AM_CONDITIONAL(WITH_PYTHON, false)
else
# /GOG
AM_CONDITIONAL(OS_WIN32, false)
AM_CONDITIONAL(PLATFORM_WIN32, false)
AM_CONDITIONAL(GTK_DOC_INSTALLED, false)
AM_CONDITIONAL(ENABLE_GTK_DOC, false)
AM_CONDITIONAL(GTK_DOC_USE_LIBTOOL, false)
AM_CONDITIONAL(WITH_LIBGSF_GNOME, false)
AM_CONDITIONAL(WITH_GCONF, false)
AM_CONDITIONAL(WITH_PYTHON, false)
fi
# -libgsf-1.12.3
# +goffice-0.0.4
if test "x$HAVE_GOFFICE" != xyes; then
AC_MSG_NOTICE('internal goffice configuration...')
m4_define([goffice_version_epoch], [0])
m4_define([goffice_version_major], [0])
m4_define([goffice_version_minor], [4])
m4_define([goffice_version_extra], [])
m4_define([goffice_full_version],
[goffice_version_epoch.goffice_version_major.goffice_version_minor[]goffice_version_extra])
AC_CONFIG_SRCDIR(lib/goffice-0.0.4/goffice/goffice.h)
AC_SUBST(GOFFICE_LIB_VERSION,
m4_eval(goffice_version_epoch + goffice_version_major)[]dnl
:goffice_version_minor:goffice_version_major)
dnl This one is created by autoheader, ...
AC_CONFIG_HEADERS(goffice-config.h)
dnl ... and this one is a small subset, maintained manually,
dnl which will be installed.
AC_CONFIG_HEADERS(goffice-features.h)
dnl
dnl Make sure these two won't clash. Put the following to goffice-config.h:
AH_BOTTOM([/* Don't include goffice-features.h, it's a subset of goffice-config.h. */
#define GOFFICE_FEATURES_H])
dnl We use $host_os:
dnl AC_CANONICAL_HOST
AC_ISC_POSIX
AC_PROG_CC
AC_PROG_YACC
AM_PROG_LEX
AC_PROG_LN_S
AM_PROG_LIBTOOL
AC_STDC_HEADERS
AC_SYS_LARGEFILE
dnl Propagate Gnome-specific variable ACLOCAL_FLAGS to Makefile.
AC_SUBST(ACLOCAL_AMFLAGS, $ACLOCAL_FLAGS)
dnl The first call to PKG_CHECK_MODULES is inside an `if.'
dnl We have to call PKG_PROG_PKG_CONFIG explicitly; otherwise it would
dnl get expanded just before the first occurence of PKG_CHECK_MODULES
dnl and might escape execution.
dnl PKG_PROG_PKG_CONFIG
dnl *****************************
# libgsf-1 >= 1.12.2
goffice_reqs="
glib-2.0 >= 2.4.8
gobject-2.0 >= 2.4.8
gmodule-2.0 >= 2.4.8
libxml-2.0 >= 2.4.12
pango >= 1.6.0
pangoft2 >= 1.6.0
"
goffice_cairo_reqs="
cairo >= 0.5.0
"
goffice_gtk_reqs="
gtk+-2.0 >= 2.4.14
libglade-2.0 >= 2.3.6
libgnomeprint-2.2 >= 2.8.0
libart-2.0 >= 2.3.11
"
goffice_gnome_reqs="
gconf-2.0
libgnomeui-2.0 >= 2.0.0
libgsf-gnome-1 >= 1.12.2
"
dnl *********************
dnl Should we use cairo ?
dnl *********************
goffice_with_cairo=false
AC_ARG_WITH(cairo, [ --{with,without}-cairo Use cairo for graph rendering])
if test "x$with_cairo" = xyes; then
cairo_msg="Enabled"
PKG_CHECK_MODULES(CAIRO, [$goffice_cairo_reqs])
AC_DEFINE(WITH_CAIRO, 1, [Define if goffice is build with cairo])
goffice_reqs="$goffice_reqs $goffice_cairo_reqs"
goffice_with_cairo=true
else
cairo_msg="Disabled"
goffice_with_cairo=false
fi
dnl *******************
dnl Should we use gtk ?
dnl *******************
goffice_with_gtk=true
AC_ARG_WITH(gtk, [ --without-gtk Build without UI])
if test "x$with_gtk" = xno; then
ui_msg="None (Gtk disabled by request)"
goffice_with_gtk=false
else
dnl We shouldn't silently default to --without-gtk.
dnl If the requirements are not met, fail.
ui_msg="Gtk"
PKG_CHECK_MODULES(GTK, [$goffice_gtk_reqs])
fi
goffice_with_gnome=$goffice_with_gtk
if test "x$goffice_with_gtk" = "xtrue" ; then
AC_DEFINE(WITH_GTK, 1, [Define if UI is built])
goffice_reqs="$goffice_reqs $goffice_gtk_reqs"
dnl ************************************
dnl Are the GNOME extensions available ?
dnl ************************************
goffice_with_gnome=true
AC_ARG_WITH(gnome,
[ --{with,without}-gnome Use GNOME extensions],
[if test "x$withval" = xno; then
goffice_with_gnome=false
ui_msg="Gtk+ (Gnome disabled by request)"
fi]
)
if test "x$goffice_with_gnome" = "xtrue"; then
PKG_CHECK_MODULES(GNOME, [$goffice_gnome_reqs],
[ui_msg="Gnome"],
[ui_msg="Gtk (missing gnome dependencies)" ; goffice_with_gnome=false])
fi
if test "x$goffice_with_gnome" = "xtrue"; then
AC_DEFINE(WITH_GNOME, 1, [Define if GNOME extensions are available])
goffice_reqs="$goffice_reqs $goffice_gnome_reqs"
fi
fi
AM_CONDITIONAL(WITH_CAIRO, $goffice_with_cairo)
AM_CONDITIONAL(WITH_GTK, $goffice_with_gtk)
AM_CONDITIONAL(WITH_GNOME, $goffice_with_gnome)
dnl ****************************
dnl now that we have selected out libraries the whole collection in one
dnl shot so that we can have a nice neat compile/link line
dnl ****************************
PKG_CHECK_MODULES(GOFFICE_DEPS, $goffice_reqs)
dnl Checks for Xft/XRender
AC_CHECK_LIB(Xrender, XRenderFindFormat,
[AC_SUBST(RENDER_LIBS, "-lXrender -lXext")
AC_DEFINE(HAVE_RENDER, 1, [Define if libXrender is available.])],
[AC_SUBST(RENDER_LIBS, "")],
[-lXext])
dnl *****************************
AC_MSG_CHECKING([for Win32 platform])
with_win32=no
case $host_os in
mingw* | pw32* | cygwin*)
with_win32=yes
GOFFICE_PLUGIN_LDFLAGS="-Wl,--enable-runtime-pseudo-relo,--export-all-symbols $GOFFICE_PLUGIN_LDFLAGS"
AC_ARG_VAR(WINDRES, [The windres executable (used by win32 builds only).])
AC_CHECK_TOOL(WINDRES, windres, :)
;;
esac
AC_MSG_RESULT($with_win32)
AM_CONDITIONAL(WITH_WIN32, test $with_win32 = yes)
dnl *****************************
dnl FIXME: perhaps declare with AC_ARG_VAR?
dnl If we use the initial value of a variable, we have to make it precious.
dnl
GOFFICE_PLUGIN_LDFLAGS="-avoid-version -no-undefined $GOFFICE_PLUGIN_LDFLAGS"
GOFFICE_PLUGIN_LIBADD="\$(top_builddir)/lib/goffice-0.0.4/goffice/libgoffice-1.la $GOFFICE_DEPS_LIBS $GOFFICE_PLUGIN_LIBADD"
AC_SUBST(GOFFICE_PLUGIN_LDFLAGS)
AC_SUBST(GOFFICE_PLUGIN_LIBADD)
dnl disable for in stable release, re-enable for development series
# FIXME - we should enable these, but maybe not right now... -jsled
# CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED"
# CFLAGS="$CFLAGS -DPANGO_DISABLE_DEPRECATED"
# if test "x$goffice_with_gtk" = "xtrue"; then
# CFLAGS="$CFLAGS -DGDK_PIXBUF_DISABLE_DEPRECATED"
# CFLAGS="$CFLAGS -DGDK_DISABLE_DEPRECATED"
# CFLAGS="$CFLAGS -DGDK_MULTIHEAD_SAFE"
# CFLAGS="$CFLAGS -DGTK_DISABLE_DEPRECATED"
# CFLAGS="$CFLAGS -DLIBGLADE_DISABLE_DEPRECATED"
# fi
# if test "x$goffice_with_gnome" = "xtrue"; then
# CFLAGS="$CFLAGS -DGNOME_DISABLE_DEPRECATED"
# CFLAGS="$CFLAGS -DBONOBO_DISABLE_DEPRECATED"
# CFLAGS="$CFLAGS -DBONOBO_UI_DISABLE_DEPRECATED"
# fi
dnl ****************************
dnl prep the pixmap generator
dnl ****************************
AC_ARG_VAR(GLIB_GENMARSHAL, [The glib-genmarshal executable.])
AC_CHECK_PROG(GLIB_GENMARSHAL, glib-genmarshal, glib-genmarshal)
AC_ARG_VAR(GDK_PIXBUF_CSOURCE, [The gdk-pixbuf-csource executable.])
AC_CHECK_PROG(GDK_PIXBUF_CSOURCE, gdk-pixbuf-csource, gdk-pixbuf-csource)
## this should come after `AC_PROG_CC'
#ifdef([GNOME_COMPILE_WARNINGS],
# [GNOME_COMPILE_WARNINGS] CFLAGS="$CFLAGS $WARN_CFLAGS",
# []
#)
#set_more_warnings=yes
#if test "$GCC" = "yes" -a "x$set_more_warnings" != "xno"; then
# for option in -Wsign-compare -Wpointer-arith -Wnested-externs -Wchar-subscripts -Wwrite-strings -Wdeclaration-after-statement -Wmissing-noreturn -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wmissing-format-attribute; do
# SAVE_CFLAGS="$CFLAGS"
# CFLAGS="$CFLAGS $option"
# AC_MSG_CHECKING([whether gcc understands $option])
# AC_TRY_COMPILE([], [],
# has_option=yes,
# has_option=no,)
# if test $has_option = no; then
# CFLAGS="$SAVE_CFLAGS"
# fi
# AC_MSG_RESULT($has_option)
# unset has_option
# unset SAVE_CFLAGS
# done
# unset option
#fi
#AC_SUBST(WARN_CFLAGS)
AC_CHECK_FUNC(gettimeofday,
[AC_DEFINE(HAVE_GETTIMEOFDAY, 1,
[Define if the gettimeofday function is available]
)])
dnl M_PI
AC_MSG_CHECKING([whether M_PI is available])
AC_TRY_COMPILE([#include <math.h>], [double f = M_PI], works_without_bsd_source=yes, works_without_bsd_source=no)
AC_MSG_RESULT($works_without_bsd_source)
if test $works_without_bsd_source = no ; then
CFLAGS="$CFLAGS -D_BSD_SOURCE"
AC_MSG_CHECKING([whether M_PI is available with -D_BSD_SOURCE])
AC_TRY_COMPILE([#include <math.h>], [double f = M_PI], m_pi_works=yes, m_pi_works=no)
AC_MSG_RESULT($m_pi_works)
if test $m_pi_works = no ; then
AC_MSG_ERROR([M_PI is not available])
fi
fi
dnl
dnl On Solaris finite() needs ieeefp.h
dnl Either of these seem to signal IEEE754 math, see mathfunc.c
dnl
AC_CHECK_HEADERS(ieeefp.h ieee754.h)
dnl Check for some functions
AC_CHECK_FUNCS(random drand48 finite memmove mkdtemp uname times sysconf)
dnl FIXME: Does this really belong here?
AC_CHECK_FUNC(bind_textdomain_codeset,,[AC_CHECK_LIB(intl,bind_textdomain_codeset)])
dnl isfinite is a macro on HPUX
AC_TRY_COMPILE([#include <math.h>], [int a = isfinite(0.0)],
[AC_DEFINE(HAVE_ISFINITE, 1,
[Define if the isfinite() macro is available]
)
], [])
dnl
dnl On BSD, we seem to need -lm for finite
dnl
if test $ac_cv_func_finite = no; then
AC_CHECK_LIB(m, finite,
[AC_DEFINE(HAVE_FINITE, 1,
[Define if the finite function is available]
)
LIBS="$LIBS -lm"])
fi
dnl check for complete locale implementation
AC_CHECK_HEADERS(langinfo.h)
dnl Handle systems that have stuff in -lm.
AC_CHECK_FUNCS(log)
if test $ac_cv_func_log = no; then
AC_CHECK_LIB(m, log,
[AC_DEFINE(HAVE_LOG, 1,
[Define if the log function is available]
)
LIBS="$LIBS -lm"])
fi
AC_DEFUN([GOFFICE_CHECK_FUNC],
[AC_CHECK_FUNC([$1],
[],
[AC_DEFINE([GOFFICE_SUPPLIED_]AS_TR_CPP([$1]),
1,
[Define if G Office supplies $1.])])dnl
])
GOFFICE_CHECK_FUNC(log1p)
GOFFICE_CHECK_FUNC(expm1)
GOFFICE_CHECK_FUNC(asinh)
GOFFICE_CHECK_FUNC(acosh)
GOFFICE_CHECK_FUNC(atanh)
float_msg=no
EXTRA_LIBS= EXTRA_INCLUDES=
AC_C_LONG_DOUBLE
if test $ac_cv_c_long_double = yes; then
have_mandatory_funcs=yes
need_sunmath=0
sunmathlinkstuff='-L/opt/SUNWspro/lib -R/opt/SUNWspro/lib -lsunmath'
for ldfunc in fabsl logl log10l ceill floorl powl isnanl finitel; do
AC_CHECK_FUNC($ldfunc,
,
[AC_CHECK_LIB(m,
$ldfunc,
,
[AC_CHECK_LIB(sunmath,
$ldfunc,
[ if test $need_sunmath = 0; then
# FIXME: better idea?
LDFLAGS="$LDFLAGS $sunmathlinkstuff"
sunmathinclude=`ls -d /opt/SUNWspro/*/include/cc | sed '$!d'`
CPPFLAGS="$CPPFLAGS -I$sunmathinclude"
fi
need_sunmath=1 ],
[have_mandatory_funcs=no],
[-L/opt/SUNWspro/lib $GOFFICE_DEPS_LIBS])])])
done
if test $need_sunmath = 1; then
EXTRA_LIBS="$EXTRA_LIBS $sunmathlinkstuff"
EXTRA_INCLUDES="$EXTRA_INCLUDES -I$sunmathinclude"
AC_CHECK_HEADERS([sunmath.h floatingpoint.h],
,
[AC_MSG_WARN([Long doubles require the $ac_header header.])
have_mandatory_funcs=no])
fi
unset need_sunmath
unset sunmathlinkstuff
unset sunmathinclude
GOFFICE_CHECK_FUNC(modfl)
GOFFICE_CHECK_FUNC(ldexpl)
GOFFICE_CHECK_FUNC(frexpl)
AC_CHECK_FUNCS(strtold)
if test "$ac_cv_func_strtold" = yes; then
AC_MSG_CHECKING([if we must prototype strtold ourselves])
AC_TRY_RUN([#include <stdlib.h>
int main ()
{
const char *s = "+3.1415e+0";
char *theend;
long double res = strtold (s, &theend);
return !(*theend == 0 && finitel (res) &&
res >= 3.14 && res <= 3.15);
}],
[AC_MSG_RESULT(no)],
[AC_MSG_RESULT(yes)
AC_DEFINE([GOFFICE_SUPPLIED_STRTOLD], 1,
[Define if G Office supplies strtold.])
],
[AC_MSG_RESULT(assuming not)])
else
AC_DEFINE([GOFFICE_SUPPLIED_STRTOLD], 1,
[Define if G Office supplies strtold.])
AC_CHECK_FUNCS(string_to_decimal decimal_to_quadruple)
if test "x$ac_cv_func_string_to_decimal" != "xyes" || \
test "x$ac_cv_func_decimal_to_quadruple" != "xyes" || \
test "x$ac_cv_header_floatingpoint_h" != "xyes"; then
AC_MSG_WARN([You lack the strtold function -- precision will be impaired])
fi
fi
if test "$have_mandatory_funcs" = yes; then
float_msg=yes
AC_DEFINE([GOFFICE_WITH_LONG_DOUBLE], 1,
[Define if G Office supports long double.])
else
AC_MSG_WARN([Long double support disabled because of library problems])
fi
unset have_mandatory_funcs
fi
AC_SUBST(EXTRA_LIBS)
AC_SUBST(EXTRA_INCLUDES)
dnl ******************
dnl * Config defaults
dnl ******************
dnl
dnl These are changed in goffice.c for WIN32 packages
AC_SUBST(goffice_datadir, '${datadir}/goffice/${GOFFICE_VERSION}')
AC_SUBST(goffice_libdir, '${libdir}/goffice/${GOFFICE_VERSION}')
AC_SUBST(goffice_icondir, '${datadir}/pixmaps/goffice')
AC_SUBST(goffice_localedir, '${prefix}/${DATADIRNAME}/locale')
dnl
AC_SUBST(goffice_plugindir, '${goffice_libdir}/plugins')
AC_SUBST(goffice_gladedir, '${goffice_datadir}/glade')
dnl Export to goffice-config.h and goffice-features.h
AC_DEFINE(GOFFICE_VERSION, "goffice_full_version",
[The version number of this release, possibly with additional suffix])
AC_DEFINE(GO_VERSION_EPOCH, goffice_version_epoch,
[The Epoch of this release])
AC_DEFINE(GO_VERSION_MAJOR, goffice_version_major,
[The Major version number of this release])
AC_DEFINE(GO_VERSION_MINOR, goffice_version_minor,
[The Minor version number of this release])
AC_DEFINE(GO_VERSION_EXTRA, "goffice_version_extra",
[Extra, possibly empty tag for this release])
else
AM_CONDITIONAL(WITH_CAIRO, false)
AM_CONDITIONAL(WITH_GTK, false)
AM_CONDITIONAL(WITH_GNOME, false)
AM_CONDITIONAL(WITH_WIN32, false)
fi
# -goffice-0.0.4
# -gog2
### --------------------------------------------------------------------------
### Variables
@ -1253,23 +1992,47 @@ AC_CONFIG_FILES(po/Makefile.in
lib/guile-www/Makefile
lib/srfi/Makefile
lib/libc/Makefile
lib/goffice/Makefile
lib/goffice/split/Makefile
lib/goffice/split/widgets/Makefile
lib/goffice/app/Makefile
lib/goffice/graph/Makefile
lib/goffice/graph/plugins/Makefile
lib/goffice/graph/plugins/plot_barcol/Makefile
lib/goffice/graph/plugins/plot_pie/Makefile
lib/goffice/graph/plugins/plot_radar/Makefile
lib/goffice/graph/plugins/plot_surface/Makefile
lib/goffice/graph/plugins/plot_xy/Makefile
lib/goffice/utils/Makefile
lib/goffice/gui-utils/Makefile
lib/goffice/drawing/Makefile
lib/goffice/pixmaps/Makefile
lib/goffice/cut-n-paste/Makefile
lib/goffice/cut-n-paste/pcre/Makefile
lib/libgsf-1.12.3/Makefile
lib/libgsf-1.12.3/doc/Makefile
lib/libgsf-1.12.3/gsf/Makefile
lib/libgsf-1.12.3/gsf-gnome/Makefile
lib/libgsf-1.12.3/gsf-win32/Makefile
lib/libgsf-1.12.3/tests/Makefile
lib/libgsf-1.12.3/python/Makefile
lib/libgsf-1.12.3/thumbnailer/Makefile
lib/libgsf-1.12.3/po/Makefile.in
lib/libgsf-1.12.3/gsf/version.c
lib/libgsf-1.12.3/doc/version.xml
lib/libgsf-1.12.3/libgsf-1.pc
lib/libgsf-1.12.3/libgsf-1.spec
lib/libgsf-1.12.3/libgsf-gnome-1.pc
lib/libgsf-1.12.3/libgsf-gnome-1.spec
lib/libgsf-1.12.3/libgsf-win32-1.pc
lib/libgsf-1.12.3/libgsf-zip
lib/goffice-0.0.4/Makefile
lib/goffice-0.0.4/libgoffice-1.pc
lib/goffice-0.0.4/goffice/Makefile
lib/goffice-0.0.4/goffice/app/Makefile
lib/goffice-0.0.4/goffice/utils/Makefile
lib/goffice-0.0.4/goffice/data/Makefile
lib/goffice-0.0.4/goffice/gtk/Makefile
lib/goffice-0.0.4/goffice/graph/Makefile
lib/goffice-0.0.4/goffice/drawing/Makefile
lib/goffice-0.0.4/goffice/ms-compat/Makefile
lib/goffice-0.0.4/goffice/cut-n-paste/Makefile
lib/goffice-0.0.4/goffice/cut-n-paste/foocanvas/Makefile
lib/goffice-0.0.4/goffice/cut-n-paste/pcre/Makefile
lib/goffice-0.0.4/plugins/Makefile
lib/goffice-0.0.4/plugins/plot_barcol/Makefile
lib/goffice-0.0.4/plugins/plot_pie/Makefile
lib/goffice-0.0.4/plugins/plot_radar/Makefile
lib/goffice-0.0.4/plugins/plot_xy/Makefile
lib/goffice-0.0.4/plugins/plot_surface/Makefile
lib/goffice-0.0.4/plugins/plot_boxes/Makefile
lib/goffice-0.0.4/plugins/reg_linear/Makefile
lib/goffice-0.0.4/pixmaps/Makefile
lib/goffice-0.0.4/po/Makefile.in
lib/goffice-0.0.4/tests/Makefile
lib/libqof/Makefile
lib/libqof/qof/Makefile
lib/libqof/backend/Makefile
@ -1399,8 +2162,12 @@ AC_MSG_RESULT([
CPPFLAGS ............. : $CPPFLAGS
CFLAGS ............... : $CFLAGS
LDFLAGS .............. : $LDFLAGS
Have libgsf............: $HAVE_LIBGSF
Have goffice...........: $HAVE_GOFFICE
QOF support ...........: $QOF_VERSION
QOF location ..........: $QOF_PREFIX
QOF library dir .......: $QOF_LIB_DIR
QOF backend config ....: $QOF_XML_DIR
])

220
goffice-config.h.in Normal file
View File

@ -0,0 +1,220 @@
/* goffice/goffice-config.h.in. Generated from configure.in by autoheader. */
/* Conditionally include >2.4 pieces we use. */
#undef HAVE_GLIB26
#undef HAVE_GTK26
/* Conditionally work around exposed-in-1.8-functionality. */
#undef HAVE_PANGO18
/* always defined to indicate that i18n is enabled */
#undef ENABLE_NLS
/* The package name, for gettext */
#undef GETTEXT_PACKAGE
/* Define if G Office supplies acosh. */
#undef GOFFICE_SUPPLIED_ACOSH
/* Define if G Office supplies asinh. */
#undef GOFFICE_SUPPLIED_ASINH
/* Define if G Office supplies atanh. */
#undef GOFFICE_SUPPLIED_ATANH
/* Define if G Office supplies expm1. */
#undef GOFFICE_SUPPLIED_EXPM1
/* Define if G Office supplies frexpl. */
#undef GOFFICE_SUPPLIED_FREXPL
/* Define if G Office supplies ldexpl. */
#undef GOFFICE_SUPPLIED_LDEXPL
/* Define if G Office supplies log1p. */
#undef GOFFICE_SUPPLIED_LOG1P
/* Define if G Office supplies modfl. */
#undef GOFFICE_SUPPLIED_MODFL
/* Define if G Office supplies strtold. */
#undef GOFFICE_SUPPLIED_STRTOLD
/* The version number of this release, possibly with additional suffix */
#undef GOFFICE_VERSION
/* Define if G Office supports long double. */
#undef GOFFICE_WITH_LONG_DOUBLE
/* The Epoch of this release */
#undef GO_VERSION_EPOCH
/* Extra, possibly empty tag for this release */
#undef GO_VERSION_EXTRA
/* The Major version number of this release */
#undef GO_VERSION_MAJOR
/* The Minor version number of this release */
#undef GO_VERSION_MINOR
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
#undef HAVE_BIND_TEXTDOMAIN_CODESET
/* Define to 1 if you have the `dcgettext' function. */
#undef HAVE_DCGETTEXT
/* Define to 1 if you have the `decimal_to_quadruple' function. */
#undef HAVE_DECIMAL_TO_QUADRUPLE
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the `drand48' function. */
#undef HAVE_DRAND48
/* Define if the finite function is available */
#undef HAVE_FINITE
/* Define to 1 if you have the <floatingpoint.h> header file. */
#undef HAVE_FLOATINGPOINT_H
/* Define if the GNU gettext() function is already present or preinstalled. */
#undef HAVE_GETTEXT
/* Define if the gettimeofday function is available */
#undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the <ieee754.h> header file. */
#undef HAVE_IEEE754_H
/* Define to 1 if you have the <ieeefp.h> header file. */
#undef HAVE_IEEEFP_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define if the isfinite() macro is available */
#undef HAVE_ISFINITE
/* Define to 1 if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
/* Define if your <locale.h> file defines LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
/* Define to 1 if you have the `intl' library (-lintl). */
#undef HAVE_LIBINTL
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define if the log function is available */
#undef HAVE_LOG
/* Define to 1 if long double works and has more range or precision than
double. */
#undef HAVE_LONG_DOUBLE
/* Define to 1 if you have the `memmove' function. */
#undef HAVE_MEMMOVE
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `mkdtemp' function. */
#undef HAVE_MKDTEMP
/* Define to 1 if you have the `random' function. */
#undef HAVE_RANDOM
/* Define if libXrender is available. */
#undef HAVE_RENDER
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `string_to_decimal' function. */
#undef HAVE_STRING_TO_DECIMAL
/* Define to 1 if you have the `strtold' function. */
#undef HAVE_STRTOLD
/* Define to 1 if you have the <sunmath.h> header file. */
#undef HAVE_SUNMATH_H
/* Define to 1 if you have the `sysconf' function. */
#undef HAVE_SYSCONF
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the `times' function. */
#undef HAVE_TIMES
/* Define to 1 if you have the `uname' function. */
#undef HAVE_UNAME
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Define if goffice is build with cairo */
#undef WITH_CAIRO
/* Define if GNOME extensions are available */
#undef WITH_GNOME
/* Define if UI is built */
#undef WITH_GTK
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
`char[]'. */
#undef YYTEXT_POINTER
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Don't include goffice-features.h, it's a subset of goffice-config.h. */
#define GOFFICE_FEATURES_H

51
goffice-features.h.in Normal file
View File

@ -0,0 +1,51 @@
/*
* goffice-features.h.in:
*
* Copyright (C) 2005 Morten Welinder (terra@gnome.org)
*/
#ifndef GOFFICE_FEATURES_H
#define GOFFICE_FEATURES_H
/* Define if G Office supports long double. */
#undef GOFFICE_WITH_LONG_DOUBLE
/* Define if G Office supplies acosh. */
#undef GOFFICE_SUPPLIED_ACOSH
/* Define if G Office supplies asinh. */
#undef GOFFICE_SUPPLIED_ASINH
/* Define if G Office supplies atanh. */
#undef GOFFICE_SUPPLIED_ATANH
/* Define if G Office supplies expm1. */
#undef GOFFICE_SUPPLIED_EXPM1
/* Define if G Office supplies frexpl. */
#undef GOFFICE_SUPPLIED_FREXPL
/* Define if G Office supplies ldexpl. */
#undef GOFFICE_SUPPLIED_LDEXPL
/* Define if G Office supplies modfl. */
#undef GOFFICE_SUPPLIED_MODFL
/* Define if G Office supplies strtold. */
#undef GOFFICE_SUPPLIED_STRTOLD
/* The version number of this release, possibly with additional suffix */
#undef GOFFICE_VERSION
/* The Epoch of this release */
#undef GO_VERSION_EPOCH
/* The Major version number of this release */
#undef GO_VERSION_MAJOR
/* The Minor version number of this release */
#undef GO_VERSION_MINOR
/* Extra, possibly empty tag for this release */
#undef GO_VERSION_EXTRA
#endif /* GOFFICE_FEATURES_H */

124
gsf-config.h.in Normal file
View File

@ -0,0 +1,124 @@
/* gsf-config.h.in. Generated from configure.in by autoheader. */
/* always defined to indicate that i18n is enabled */
#undef ENABLE_NLS
/* Gettext package. */
#undef GETTEXT_PACKAGE
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
#undef HAVE_BIND_TEXTDOMAIN_CODESET
/* Conditionally include glib-2.0 > 2.4 functionality. */
#undef HAVE_GLIB26
/* Is bzip2 available and enabled */
#undef HAVE_BZ2
/* Define to 1 if you have the `chown' function. */
#undef HAVE_CHOWN
/* Define to 1 if you have the `dcgettext' function. */
#undef HAVE_DCGETTEXT
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
#undef HAVE_FSEEKO
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
/* Define if the GNU gettext() function is already present or preinstalled. */
#undef HAVE_GETTEXT
/* Define if g_access is available as macro or function */
#undef HAVE_G_ACCESS
/* Define if g_chmod is available as macro or function */
#undef HAVE_G_CHMOD
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <io.h> header file. */
#undef HAVE_IO_H
/* Define if your <locale.h> file defines LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define S_ISREG if stat.h doesn't */
#undef S_ISREG
/* Version number of package */
#undef VERSION
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
#undef _LARGEFILE_SOURCE
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Define to `int' if <sys/types.h> does not define. */
#undef mode_t

View File

@ -1,9 +1,10 @@
SUBDIRS = libc glib26 guile-www srfi
if USE_LIBGOFFICE
SUBDIRS +=
else
SUBDIRS += goffice
if !HAVE_GOFFICE
if !HAVE_LIBGSF
SUBDIRS += libgsf-1.12.3
endif
SUBDIRS += goffice-0.0.4
endif
if USE_LIBQOF

View File

@ -0,0 +1,8 @@
Jody Goldberg, maintainer.
Jean Brefort, Core charting engine.
Emmanuel Pacaud, Many plot types for charting engine.
Morten Welinder, Gnumeric hacker and leak plugging demi-god.
Chris Lahey, number format engine, and powerpoint/escher code
NOTE : Keep this in sync with the about dialog and the webpage.
NOTE : Get an about dialog and a webpage :-)

278
lib/goffice-0.0.4/BUGS Normal file
View File

@ -0,0 +1,278 @@
To report libgoffice bugs, please visit bugzilla.gnome.org.
This file is used as a scratch pad by developers. It is a list of known
issues that need to be addressed. Divided into, things that will prevent
release, and longer term bugs.
-------------------------------------------------------------------------------
Release Critical
----------------
: src/cut-n-paste-code/goffice/gui-utils/go-format-sel.c:
g_warning ("TESTING TESTING 123 res = '%s'", res ? res : "(null)");
goffice/goffice/graph/gog-graph.c uses pointers as quarks. That cannot
work.
goffice/goffice/utils/go-format.c: go_format_value don't use the format
argument.
TODO
----
0) Move gnome depends into a plugin
0.1) egg-recent-files
1) Format and number match rewrite
: Why does the number matching bother comparing against formats that are
covered by 'General' ?
: When applying a currency symbol we need to store the NON-localized id.
: hour month and year format strings need to be internationalized.
eg tt:ss instead of hh:ss for other locales.
: formats with AM/PM need to be internationalized.
: We do not format fractional seconds correctly.
: Parsing should handle embedded strings
: It incorrectly accepts mmm:ss as some sort of minute spec.
: When entering "ppp/qqq" into a cell with non-fractional format, do not
make it a fraction.
: Consider adding "%" to entry text when typing a text with a percentage
format. (I.e., user has "44%" in cell and presses "5" -- that causes
"5%" to be shown the the cursor between "5" and "%".)
2) GOActionComboText
2.1) stub (DONE)
2.2) Move to TreeModel to simplify sharing
2.3) Support custom menu item
3) Plugin Framework
3.1) "De-activate all" should take the dependency tree
into account and handle the python loader last.
- i18n support for third-party plugins.
- Add extra info (authors, etc.) to XML file.
- Beautify ErrorInfo dialog (it's ugly).
- Mark plugin as "broken" if deactivation failed.
3.2) pluginize paste types
3.3) plugin manager needs dependency tracking. (Deactivate
all python plugins before the python loader, for example.)
1) graphs
1.1) Split plot xml file engine, type, and family plugins (DONE)
1.2) Use the registered engines to create plots (DONE)
1.3) XML
1.3.1) Use libglade code parse GObject properties (DONE)
1.3.2) remove GdkColor from boxed type support (DONE)
1.3.3) Walk GogObject tree and build DOM (DONE)
1.3.4) Build GogObject treee from DOM (DONE)
1.3.5) For flagged properties store value in DOM (DONE)
1.3.6) Read properties from DOM (DONE)
1.3.7) XMLWriter interface for extra object content (DONE)
1.3.8) Use it for series (DONE)
1.3.9) Extend GOData to support deserialization (DONE)
1.3.10) Implement deserialization for GnmData (DONE)
1.3.11) Use the XMLWriter for series for all datasets (DONE)
1.3.12) Persist names (DONE)
1.3.13) Use XMLWriter for properties of type object (DONE)
1.3.14) implement it for styles (DONE)
1.3.15) position
1.3.16) image data
1.4) Decide on model vs view structure (DONE)
1.5) Graph Guru (DONE)
1.5.1) update when someone else changes the model (DONE)
1.5.2) remove prop pages for deleted items (DONE)
1.5.3) Keep state::chart,plot safe for typeselector (DONE)
in case they get deleted
1.5.4) Allow going backwards if there is only chart (DONE)
1.6) data allocator in gnumeric (DONE)
1.6.1) initial interface (DONE)
1.6.2) generalize container to be a DataSet (DONE)
1.6.3) editor to specify pref for vector or scalar (DONE)
1.7) Single point formating
1.7.1) Basic (DONE)
1.7.2) Improve selection of single points for pies (DONE)
1.8) data sources (DONE)
1.8.1) vector and scalar data sources from gnumeric (DONE)
1.8.2) Add min/max elements to vector (DONE)
1.8.3) const scalar value (DONE)
1.8.4) const scalar string (DONE)
1.8.5) const vector value (DONE)
1.8.6) const vector string (DONE)
1.8.7) translation of const vector strings (DONE)
1.9) Pie Plot (DONE)
1.9.1) Make the segments curve (DONE)
1.9.2) extracted segments (DONE)
1.9.3) Rings (DONE)
1.9.4) extracting single wedges (DONE)
1.9.5) formating single wedges (DONE)
1.10) Bar/Col Plot (DONE)
1.10.1) merge bar/col stack type bools into 1 enum (DONE)
1.10.2) normal (DONE)
1.10.3) stacked (DONE)
1.10.4) percentage (DONE)
1.10.5) Skip over bars/cols when too narrow
1.10.6) Work around bleed through with overlap 100 (DONE)
1.10.7) Check for short vectors (DONE)
1.10.8) Clip when values are out of range (DONE)
1.10.9) Support vary style by element for type=normal
1.11) Line/Area Plot (DONE)
1.11.1) Normal (DONE)
1.11.2) Stacked (DONE)
1.11.3) Percentage (DONE)
1.11.4) sub type with no-marker by default (DONE)
1.11.5) center points on X index values for Line (DONE)
1.11.6) handle missing points in unstacked lines (DONE)
1.12) X/Y (Scatter) Plot
1.12.1) Add simple implementation (DONE)
1.12.2) Take marker sizes into account at bounds (DONE)
1.12.3) Bounds on 1 axis explicitly clip the other
1.12.4) Splined interpolation (DONE)
1.12.5) Bubbles (DONE)
1.13) Decide on recalc strategy (DONE)
1.13.1) Getting data from sheet -> graphs (DONE)
1.13.2) linking unlinking (DONE)
1.14) Axis management
1.14.1) Charts/plots have axis layout type (DONE)
1.14.2) Add any missing axis when chart type is set (DONE)
1.14.3) Remove any existing axis that do not correspond (DONE)
to chart type.
1.14.2) Life cycle of plots/axis to maintain connection (DONE)
1.14.3) UI for adding an axis (DONE)
1.14.4) Only permit removal of unused axes (DONE)
1.14.6) Create plot1.5d as base for bar/col & line (DONE)
1.14.7) do range allocation and filtering in chart (DONE)
1.14.7) Draw ticks and allocate space for them (DONE)
1.14.8) Make the major labels optional (DONE)
1.14.9) Add a font selector to the editor (DONE)
1.14.10) Value formating (at least percentage and date) (DONE)
1.14.11) Support index type axis (DONE)
1.14.12) Use a map function (log, invert, date) (DONE)
1.14.13) Allow a plot to select a different axis (DONE)
1.14.14) Filter add plot in guru to matching types (DONE)
1.14.15) Editor for min/max/major/minor (DONE)
1.14.16) Respect user supplied min/max/major/minor (DONE)
1.14.17) Draw major ticks in (DONE)
1.14.18) Draw major ticks out (DONE)
1.14.19) Draw minor ticks in (DONE)
1.14.20) Draw minor ticks out (DONE)
1.14.21) Why don't we honour selected font ? (DONE)
1.14.22) Selectable label format for non-discrete data (DONE)
1.14.23) Editor for label format (DONE)
1.14.24) Persist label format (DONE)
1.14.25) Auto selection of label format (DONE)
1.15) per series plot type specific data (DONE)
1.16) libart based render akin to guppicanvas. (DONE)
1.16.1) Solid background fills (DONE)
1.16.2) Gradient fills (DONE)
1.16.3) Pattern fills (DONE)
1.16.4) Image fills (DONE)
1.16.5) path (DONE)
1.16.6) text (DONE)
1.16.7) markers (DONE)
1.16.8) Rework text drawing to _not_ use libart (DONE)
1.16.9) Add anchor flags to draw_text (DONE)
1.16.10) Clip text to keep it in bounds (DONE)
1.19) Precedence (DONE)
1.19.1) Sort GogObject::children (DONE)
1.19.2) Keep corresponding views in sync (DONE)
1.19.3) Have guru maintain order for add/remove (DONE)
1.19.4) api for changing order (DONE)
1.19.5) Extend Guru to support changing precedence (DONE)
1.20) GogStyle Editor page
1.20.1) fill type (DONE)
1.20.1.1) none (DONE)
1.20.1.2) solid (DONE)
1.20.1.3) basic gradients (DONE)
1.20.1.4) advanced gradients via combo (DONE)
1.20.1.5) pixmaps fills (DONE)
1.20.1.6) patterns (DONE)
1.20.2) outline line pattern
1.20.3) font selector (DONE)
1.20.4) Support 'auto' settings (DONE)
1.20.4.1) outline (colour) (DONE)
1.20.4.2) line (color) (DONE)
1.20.4.3) fill (colors) (DONE)
1.20.4.4) marker (DONE)
1.20.5) image selector
1.20.5.1) drag destination for background images
1.20.5.2) scale image preview (DONE)
1.20.5.3) Use file selector with image preview (DONE)
1.20.6) De-sensitize (out)line colour when size == -1
1.21) themes
1.21.1) Actually use the themes to initialize styles (DONE)
1.21.2) load from xml
1.21.3) selector for graphs
1.21.4) How to change a graph's theme
1.21.5) Use Roles rather than Types to enumerate (DONE)
1.21.5) Allow type aliases (DONE)
1.22) Legend
1.22.1) Set up cardinality framework. (DONE)
1.22.2) Get things to update when chart changes (DONE)
1.22.2) smarter layout
1.23) Layout engine
1.23.1) In ChartView::size_allocate use the positions (DONE)
1.23.2) For compass placement use the alignment flags (DONE)
1.23.3) support NW, NE, SW, SE (DONE)
1.23.4) Move ChartView::size_allocate -> GogView (DONE)
1.24.5) Have Graph, Chart, Legend and Axis use it (DONE)
1.23.6) Add some notion of padding (DONE)
1.23.7) remove request_valid (DONE)
1.23.8) pass in available space (DONE)
1.23.9) How to support axis labels (siblings need
common residual)
1.23.10) Create a common base for outlined objects (DONE)
1.24) Sizing units (DONE)
1.24.1) Have the legend use pts to size swatches (DONE)
1.24.2) Test renderers mapping between pts & pixels (DONE)
1.25) Printing (DONE)
1.25.1) gog-renderer-gnomeprint (DONE)
1.25.2) sheet object wrapper for printing (DONE)
1.25.3) paths (DONE)
1.25.4) solid and empty polygons (DONE)
1.25.5) image filled polygons (DONE)
1.25.6) gradient filled polygons (DONE)
1.25.7) measure text (DONE)
1.25.8) draw text (DONE)
1.25.9) why doesn't text appear in preview (DONE)
1.25.10) why is font selection bogus (DONE)
1.25.11) text anchors (DONE)
1.25.12) Check the zoom handling for fonts (DONE)
1.26) Move 'use_one_style' from pie -> plot with 1 series (DONE)
1.27) Add a flag to gobject to go with its role indicating (DONE)
whether the instance was autocreated or assigned.
1.28) Rethink GraphItem lifecyle to simplify removal (DONE)
1.29) Extend GogObjectRole to include more handlers (DONE)
1.30) Grid Object
1.30.1) Create (DONE)
1.30.2) Theme it (DONE)
1.30.3) Add or remove it depending on chart axis set (DONE)
1.30.4) Render background (DONE)
1.30.5) Support grid lines (added to axis) (DONE)
1.30.6) XLS import of grid lines
1.30.7) XLS export of grid lines
1.31) SVG Render
1.31.1) Paths (DONE)
1.31.2) Solid Fills (DONE)
1.31.3) Gradient Fills (DONE)
1.31.4) Pattern Fills (DONE)
1.31.5) Image Fills (DONE)
1.31.6) Markers (DONE)
1.31.7) Text (DONE)
1.31.8) Text alignment (DONE)
1.31.9) Text clipping (DONE)
1.32) Radar plots
1.32.1) line (DONE)
1.32.2) area (DONE)
1.32.3) axis labels (DONE)
1.32.4) fix xls import of marker vs no marker
1.33) Contour plots {Jean}
1.33.1) Initial implementation (DONE)
1.33.2) GOMatrix (DONE)
1.33.3) Axis changes
1.33.4) XLS import (DONE)
1.33.4) XLS export
Misc things to fix
------------------
: Open guru, click on forward, then back. Now navigating through plot
list is very slow. That's because at each object addition/removal in
object tree, an object editor is created.
: Current GogGrid object is not used for grid display. We should rename
it to GogBackplane, GogWall or GogBackground.

340
lib/goffice-0.0.4/COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

File diff suppressed because it is too large Load Diff

229
lib/goffice-0.0.4/INSTALL Normal file
View File

@ -0,0 +1,229 @@
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the `--target=TYPE' option to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
will cause the specified gcc to be used as the C compiler (unless it is
overridden in the site shell script).
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View File

@ -0,0 +1,2 @@
Email: jody@gnome.org
Email: terra@gnome.org

View File

@ -0,0 +1,17 @@
# Makefile.am for goffice
SUBDIRS = goffice tests pixmaps plugins
# po
EXTRA_DIST = README NEWS BUGS MAINTAINERS AUTHORS \
goffice.mk \
goffice-plugins.mk \
intltool-extract.in \
intltool-update.in \
intltool-merge.in
DISTCLEANFILES = intltool-extract intltool-merge intltool-update
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libgoffice-1.pc
include $(top_srcdir)/lib/goffice-0.0.4/goffice.mk

101
lib/goffice-0.0.4/NEWS Normal file
View File

@ -0,0 +1,101 @@
goffice 0.0.4:
Emmanuel Pacaud:
* Fix polar plot clipping.
* Fix line/area/barcol data position.
* Let user change bounds for discrete axes [#309468].
Jean Brefort:
* Box-plots use raw data [#308136].
Jody:
* GOFormat now matches against all tuples.
* Add GORotationSel from Gnumeric.
* fixed number of digits for denominator regexp [#144112]
--------------------------------------------------------------------------
goffice 0.0.3:
Emmanuel Pacaud:
* Add support for manual position/size of graph objects.
* Add rotated text support.
* Add optional cairo renderer.
* Fix swatch position in legends.
* Sample graph in guru has the same aspect ratio than the edited graph
[#150458].
* Displays Y axis labels vertically by default [#301582].
* Add pattern support for SVG output [#310320].
Jean Brefort:
* Add series lines in bars and columns plots.
* Add drop lines in lines and xy plots.
* Add lines to min/max plots and dropbars.
Morten:
* Fix problem with currency formats and problem with Euro [#305313].
* Support fd://1 syntax for go_file_create.
* Fix ABR (or worse) for formats ending in "[$...]".
--------------------------------------------------------------------------
goffice 0.0.2:
Emmanuel Pacaud:
* Make compass position and alignment of graph object persistent and
add a GUI for these properties [#124322].
* Fix some libglade warnings [#305010].
* Fix contour plots axes.
Ivan, Y.C. Wong:
* Fix encoding bug when open file with non-ascii name in shell.
* Fix Mime Type detection on Win32 [#304074].
Jean Brefort:
* Add linear regressions in scatter plots.
* Fix shotcut in format selector [#305635].
* Add MinMax and DropBar plots.
* Fixed various concerns in contour plots.
J.H.M. Dassen (Ray):
* Ensure at link time that the shared objects, both the library and
the plugins, contain complete dependency information for all
symbols they use from elsewhere.
Jody:
* Fix foocanvas's show/hide item for widgets.
* Fix the format selector preview.
* Improve selection of a default plot style.
Morten:
* Fix theme bug. [#303707]
* Fix insert-image criticals. [#305009]
--------------------------------------------------------------------------
goffice 0.0.1
Emmanuel Pacaud:
* Add support for polar plots.
* Add multiple axes support for xy, line, barcol, bubble plots.
* Fix axis rendering order for contour, area and radar plots.
* avoid use of setlocale in svg renderer. [#172726]
* Add radar axis labels [#152695]
* Fix crash in print preview with log plots. [#170547]
* Fix crahs when deleting a serie. [#166403]
* Fix transparency in pixbuf renderer. [159368]
Jean Brefort
* Fixed opacity problem in color selector (#135434)
Jody:
* Split from gnumeric
Ivan Wong:
* Become more robust when reading .hhmap files and finding help
topics on Win32.
Morten:
* Fix various old number rendering bugs. [#170000]
* Update to PCRE 5.0
* Give GOComboBox a themable add-tearoffs style.
* Fix icon sizes in color action combos. [#302880]
--------------------------------------------------------------------------

41
lib/goffice-0.0.4/README Normal file
View File

@ -0,0 +1,41 @@
GOffice -- A glib/gtk set of document centric objects and utilities
Jody Goldberg <jody@gnome.org>
There are common operations for document centric applications that are
conceptually simple, but complex to implement fully.
- plugins
- load/save documents
- undo/redo
To report goffice bugs, please visit bugzilla.gnome.org.
goffice is licensed under the terms of the GNU GPL included in the
file COPYING.
Requirements
------------
You need: Debian package name
glib >= 2.6.0 libglib2.0-dev
gtk+ >= 2.6.0 libgtk2.0-dev
pango >= 1.8.1 libpango1.0-dev
libgnomeprint >= 2.8.2 libgnomeprint2.2-dev
libgsf >= 1.12.2 libgsf-1-dev
libglade >= 2.3.6 libglade2-dev
gnome-xml >= 2.4.12 libxml2-dev
libart >= 2.3.11 libart-2.0-dev
NOTE: gnome-xml is also known as libxml
Mailing lists
-------------
There is a mailing list used to discuss Gnumeric, to subscribe
send a mail to:
gnumeric-list-request@gnome.org
And in the body of the message write "subscribe"
An archive of the mailing lists is available in:
http://www.gnome.org/mailing-lists/archives/gnumeric-list/

7683
lib/goffice-0.0.4/aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

1466
lib/goffice-0.0.4/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1579
lib/goffice-0.0.4/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

28301
lib/goffice-0.0.4/configure vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,503 @@
-*- mode: m4 -*-
dnl We require Automake 1.7.2, which requires Autoconf 2.54.
dnl (It needs _AC_AM_CONFIG_HEADER_HOOK, for example.)
AC_PREREQ(2.54)
m4_define([goffice_version_epoch], [0])
m4_define([goffice_version_major], [0])
m4_define([goffice_version_minor], [4])
m4_define([goffice_version_extra], [])
m4_define([goffice_full_version],
[goffice_version_epoch.goffice_version_major.goffice_version_minor[]goffice_version_extra])
dnl Emphasize some of the checks.
m4_define([BIG_CHECKING], [AC_MSG_CHECKING([
======== $1])])
AC_INIT([goffice], [goffice_full_version],
[http://bugzilla.gnome.org/enter_bug.cgi?product=libgoffice])
AC_CONFIG_SRCDIR(goffice/goffice.h)
AM_INIT_AUTOMAKE([dist-bzip2])
dnl Version info for libraries = CURRENT:REVISION:AGE
dnl
dnl FIXME: This formula is wrong. --kasal
dnl
AC_SUBST(GOFFICE_LIB_VERSION,
m4_eval(goffice_version_epoch + goffice_version_major)[]dnl
:goffice_version_minor:goffice_version_major)
dnl This one is created by autoheader, ...
AC_CONFIG_HEADERS(goffice/goffice-config.h)
dnl ... and this one is a small subset, maintained manually,
dnl which will be installed.
AC_CONFIG_HEADERS(goffice/goffice-features.h)
dnl
dnl Make sure these two won't clash. Put the following to goffice-config.h:
AH_BOTTOM([/* Don't include goffice-features.h, it's a subset of goffice-config.h. */
#define GOFFICE_FEATURES_H])
AM_MAINTAINER_MODE
# Make --disable-static the default
AC_DISABLE_STATIC
dnl We need intltool >= 0.27.2 to extract the UTF-8 chars from source code
AC_PROG_INTLTOOL([0.27.2])
dnl We use $host_os:
AC_CANONICAL_HOST
AC_ISC_POSIX
AC_PROG_CC
AC_PROG_YACC
AM_PROG_LEX
AC_PROG_LN_S
AM_PROG_LIBTOOL
AC_STDC_HEADERS
AC_SYS_LARGEFILE
dnl Propagate Gnome-specific variable ACLOCAL_FLAGS to Makefile.
AC_SUBST(ACLOCAL_AMFLAGS, $ACLOCAL_FLAGS)
dnl The first call to PKG_CHECK_MODULES is inside an `if.'
dnl We have to call PKG_PROG_PKG_CONFIG explicitly; otherwise it would
dnl get expanded just before the first occurence of PKG_CHECK_MODULES
dnl and might escape execution.
PKG_PROG_PKG_CONFIG
dnl *****************************
goffice_reqs="
glib-2.0 >= 2.4.8
gobject-2.0 >= 2.4.8
gmodule-2.0 >= 2.4.8
libgsf-1 >= 1.12.2
libxml-2.0 >= 2.4.12
pango >= 1.6.0
pangoft2 >= 1.6.0
"
goffice_cairo_reqs="
cairo >= 0.5.0
"
goffice_gtk_reqs="
gtk+-2.0 >= 2.4.14
libglade-2.0 >= 2.3.6
libgnomeprint-2.2 >= 2.8.2
libart-2.0 >= 2.3.11
"
goffice_gnome_reqs="
gconf-2.0
libgnomeui-2.0 >= 2.0.0
libgsf-gnome-1 >= 1.12.2
"
dnl *********************
dnl Should we use cairo ?
dnl *********************
goffice_with_cairo=false
AC_ARG_WITH(cairo, [ --{with,without}-cairo Use cairo for graph rendering])
if test "x$with_cairo" = xyes; then
cairo_msg="Enabled"
PKG_CHECK_MODULES(CAIRO, [$goffice_cairo_reqs])
AC_DEFINE(WITH_CAIRO, 1, [Define if goffice is build with cairo])
goffice_reqs="$goffice_reqs $goffice_cairo_reqs"
goffice_with_cairo=true
else
cairo_msg="Disabled"
goffice_with_cairo=false
fi
dnl *******************
dnl Should we use gtk ?
dnl *******************
goffice_with_gtk=true
AC_ARG_WITH(gtk, [ --without-gtk Build without UI])
if test "x$with_gtk" = xno; then
ui_msg="None (Gtk disabled by request)"
goffice_with_gtk=false
else
dnl We shouldn't silently default to --without-gtk.
dnl If the requirements are not met, fail.
ui_msg="Gtk"
PKG_CHECK_MODULES(GTK, [$goffice_gtk_reqs])
fi
goffice_with_gnome=$goffice_with_gtk
if test "x$goffice_with_gtk" = "xtrue" ; then
AC_DEFINE(WITH_GTK, 1, [Define if UI is built])
goffice_reqs="$goffice_reqs $goffice_gtk_reqs"
dnl ************************************
dnl Are the GNOME extensions available ?
dnl ************************************
goffice_with_gnome=true
AC_ARG_WITH(gnome,
[ --{with,without}-gnome Use GNOME extensions],
[if test "x$withval" = xno; then
goffice_with_gnome=false
ui_msg="Gtk+ (Gnome disabled by request)"
fi]
)
if test "x$goffice_with_gnome" = "xtrue"; then
PKG_CHECK_MODULES(GNOME, [$goffice_gnome_reqs],
[ui_msg="Gnome"],
[ui_msg="Gtk (missing gnome dependencies)" ; goffice_with_gnome=false])
fi
if test "x$goffice_with_gnome" = "xtrue"; then
AC_DEFINE(WITH_GNOME, 1, [Define if GNOME extensions are available])
goffice_reqs="$goffice_reqs $goffice_gnome_reqs"
fi
fi
AM_CONDITIONAL(WITH_CAIRO, $goffice_with_cairo)
AM_CONDITIONAL(WITH_GTK, $goffice_with_gtk)
AM_CONDITIONAL(WITH_GNOME, $goffice_with_gnome)
dnl ****************************
dnl now that we have selected out libraries the whole collection in one
dnl shot so that we can have a nice neat compile/link line
dnl ****************************
PKG_CHECK_MODULES(GOFFICE, $goffice_reqs)
dnl Checks for Xft/XRender
AC_CHECK_LIB(Xrender, XRenderFindFormat,
[AC_SUBST(RENDER_LIBS, "-lXrender -lXext")
AC_DEFINE(HAVE_RENDER, 1, [Define if libXrender is available.])],
[AC_SUBST(RENDER_LIBS, "")],
[-lXext])
dnl *****************************
AC_MSG_CHECKING([for Win32 platform])
with_win32=no
case $host_os in
mingw* | pw32* | cygwin*)
with_win32=yes
GOFFICE_PLUGIN_LDFLAGS="-Wl,--enable-runtime-pseudo-relo,--export-all-symbols $GOFFICE_PLUGIN_LDFLAGS"
AC_ARG_VAR(WINDRES, [The windres executable (used by win32 builds only).])
AC_CHECK_TOOL(WINDRES, windres, :)
;;
esac
AC_MSG_RESULT($with_win32)
AM_CONDITIONAL(WITH_WIN32, test $with_win32 = yes)
dnl *****************************
dnl FIXME: perhaps declare with AC_ARG_VAR?
dnl If we use the initial value of a variable, we have to make it precious.
dnl
GOFFICE_PLUGIN_LDFLAGS="-avoid-version -no-undefined $GOFFICE_PLUGIN_LDFLAGS"
GOFFICE_PLUGIN_LIBADD="\$(top_builddir)/goffice/libgoffice-1.la $GOFFICE_LIBS $GOFFICE_PLUGIN_LIBADD"
AC_SUBST(GOFFICE_PLUGIN_LDFLAGS)
AC_SUBST(GOFFICE_PLUGIN_LIBADD)
dnl disable for in stable release, re-enable for development series
CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DPANGO_DISABLE_DEPRECATED"
if test "x$goffice_with_gtk" = "xtrue"; then
CFLAGS="$CFLAGS -DGDK_PIXBUF_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DGDK_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DGDK_MULTIHEAD_SAFE"
CFLAGS="$CFLAGS -DGTK_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DLIBGLADE_DISABLE_DEPRECATED"
fi
if test "x$goffice_with_gnome" = "xtrue"; then
CFLAGS="$CFLAGS -DGNOME_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DBONOBO_DISABLE_DEPRECATED"
CFLAGS="$CFLAGS -DBONOBO_UI_DISABLE_DEPRECATED"
fi
dnl ****************************
dnl prep the pixmap generator
dnl ****************************
AC_ARG_VAR(GLIB_GENMARSHAL, [The glib-genmarshal executable.])
AC_CHECK_PROG(GLIB_GENMARSHAL, glib-genmarshal, glib-genmarshal)
AC_ARG_VAR(GDK_PIXBUF_CSOURCE, [The gdk-pixbuf-csource executable.])
AC_CHECK_PROG(GDK_PIXBUF_CSOURCE, gdk-pixbuf-csource, gdk-pixbuf-csource)
## this should come after `AC_PROG_CC'
ifdef([GNOME_COMPILE_WARNINGS],
[GNOME_COMPILE_WARNINGS] CFLAGS="$CFLAGS $WARN_CFLAGS",
[]
)
set_more_warnings=yes
if test "$GCC" = "yes" -a "x$set_more_warnings" != "xno"; then
for option in -Wsign-compare -Wpointer-arith -Wnested-externs -Wchar-subscripts -Wwrite-strings -Wdeclaration-after-statement -Wmissing-noreturn -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wmissing-format-attribute; do
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $option"
AC_MSG_CHECKING([whether gcc understands $option])
AC_TRY_COMPILE([], [],
has_option=yes,
has_option=no,)
if test $has_option = no; then
CFLAGS="$SAVE_CFLAGS"
fi
AC_MSG_RESULT($has_option)
unset has_option
unset SAVE_CFLAGS
done
unset option
fi
AC_SUBST(WARN_CFLAGS)
AC_CHECK_DECL(fdopen, fdopen_works=yes, fdopen_works=no)
if test $fdopen_works = no ; then
unset ac_cv_have_decl_fdopen
CFLAGS="$CFLAGS -D_POSIX_SOURCE"
AC_MSG_NOTICE([adding -D_POSIX_SOURCE to CFLAGS])
AC_CHECK_DECL(fdopen, fdopen_works=yes, fdopen_works=no)
if test $fdopen_works = no ; then
AC_MSG_ERROR([fdopen is not available])
fi
fi
# Unfortunately, -D_POSIX_SOURCE turns off struct timeval on Solaris
AC_MSG_CHECKING([whether struct timeval is available])
AC_TRY_COMPILE([#include <sys/time.h>], [struct timeval tv;], struct_timeval_works=yes, struct_timeval_works=no)
AC_MSG_RESULT($struct_timeval_works)
if test $struct_timeval_works = no ; then
CFLAGS="$CFLAGS -D__EXTENSIONS__"
AC_MSG_CHECKING([whether struct timeval is available with -D__EXTENSIONS__])
AC_TRY_COMPILE([#include <sys/time.h>], [struct timeval tv;], struct_timeval_works=yes, struct_timeval_works=no)
AC_MSG_RESULT($struct_timeval_works)
if test $struct_timeval_works = no ; then
AC_MSG_ERROR([struct timeval is not available])
fi
fi
AC_CHECK_FUNC(gettimeofday,
[AC_DEFINE(HAVE_GETTIMEOFDAY, 1,
[Define if the gettimeofday function is available]
)])
dnl M_PI
AC_MSG_CHECKING([whether M_PI is available])
AC_TRY_COMPILE([#include <math.h>], [double f = M_PI], works_without_bsd_source=yes, works_without_bsd_source=no)
AC_MSG_RESULT($works_without_bsd_source)
if test $works_without_bsd_source = no ; then
CFLAGS="$CFLAGS -D_BSD_SOURCE"
AC_MSG_CHECKING([whether M_PI is available with -D_BSD_SOURCE])
AC_TRY_COMPILE([#include <math.h>], [double f = M_PI], m_pi_works=yes, m_pi_works=no)
AC_MSG_RESULT($m_pi_works)
if test $m_pi_works = no ; then
AC_MSG_ERROR([M_PI is not available])
fi
fi
dnl **************************************************
AC_SUBST(ALL_LINGUAS,
"am az bg ca cs da de el en_CA en_GB es et fi fr ga gl he hr hu it ja ko lv ml mr ms nb nl nn no pl pt pt_BR ro ru sk sr sr@Latn sv tr uk vi zh_CN zh_TW")
AC_SUBST(GETTEXT_PACKAGE, goffice)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
[The package name, for gettext])
AM_GLIB_GNU_GETTEXT
dnl
dnl On Solaris finite() needs ieeefp.h
dnl Either of these seem to signal IEEE754 math, see mathfunc.c
dnl
AC_CHECK_HEADERS(ieeefp.h ieee754.h)
dnl Check for some functions
AC_CHECK_FUNCS(random drand48 finite memmove mkdtemp uname times sysconf)
dnl FIXME: Does this really belong here?
AC_CHECK_FUNC(bind_textdomain_codeset,,[AC_CHECK_LIB(intl,bind_textdomain_codeset)])
dnl isfinite is a macro on HPUX
AC_TRY_COMPILE([#include <math.h>], [int a = isfinite(0.0)],
[AC_DEFINE(HAVE_ISFINITE, 1,
[Define if the isfinite() macro is available]
)
], [])
dnl
dnl On BSD, we seem to need -lm for finite
dnl
if test $ac_cv_func_finite = no; then
AC_CHECK_LIB(m, finite,
[AC_DEFINE(HAVE_FINITE, 1,
[Define if the finite function is available]
)
LIBS="$LIBS -lm"])
fi
dnl check for complete locale implementation
AC_CHECK_HEADERS(langinfo.h)
dnl Handle systems that have stuff in -lm.
AC_CHECK_FUNCS(log)
if test $ac_cv_func_log = no; then
AC_CHECK_LIB(m, log,
[AC_DEFINE(HAVE_LOG, 1,
[Define if the log function is available]
)
LIBS="$LIBS -lm"])
fi
AC_DEFUN([GOFFICE_CHECK_FUNC],
[AC_CHECK_FUNC([$1],
[],
[AC_DEFINE([GOFFICE_SUPPLIED_]AS_TR_CPP([$1]),
1,
[Define if G Office supplies $1.])])dnl
])
GOFFICE_CHECK_FUNC(log1p)
GOFFICE_CHECK_FUNC(expm1)
GOFFICE_CHECK_FUNC(asinh)
GOFFICE_CHECK_FUNC(acosh)
GOFFICE_CHECK_FUNC(atanh)
float_msg=no
EXTRA_LIBS= EXTRA_INCLUDES=
AC_C_LONG_DOUBLE
if test $ac_cv_c_long_double = yes; then
have_mandatory_funcs=yes
need_sunmath=0
sunmathlinkstuff='-L/opt/SUNWspro/lib -R/opt/SUNWspro/lib -lsunmath'
for ldfunc in fabsl logl log10l ceill floorl powl isnanl finitel; do
AC_CHECK_FUNC($ldfunc,
,
[AC_CHECK_LIB(m,
$ldfunc,
,
[AC_CHECK_LIB(sunmath,
$ldfunc,
[ if test $need_sunmath = 0; then
# FIXME: better idea?
LDFLAGS="$LDFLAGS $sunmathlinkstuff"
sunmathinclude=`ls -d /opt/SUNWspro/*/include/cc | sed '$!d'`
CPPFLAGS="$CPPFLAGS -I$sunmathinclude"
fi
need_sunmath=1 ],
[have_mandatory_funcs=no],
[-L/opt/SUNWspro/lib $GOFFICE_LIBS])])])
done
if test $need_sunmath = 1; then
EXTRA_LIBS="$EXTRA_LIBS $sunmathlinkstuff"
EXTRA_INCLUDES="$EXTRA_INCLUDES -I$sunmathinclude"
AC_CHECK_HEADERS([sunmath.h floatingpoint.h],
,
[AC_MSG_WARN([Long doubles require the $ac_header header.])
have_mandatory_funcs=no])
fi
unset need_sunmath
unset sunmathlinkstuff
unset sunmathinclude
GOFFICE_CHECK_FUNC(modfl)
GOFFICE_CHECK_FUNC(ldexpl)
GOFFICE_CHECK_FUNC(frexpl)
AC_CHECK_FUNCS(strtold)
if test "$ac_cv_func_strtold" = yes; then
AC_MSG_CHECKING([if we must prototype strtold ourselves])
AC_TRY_RUN([#include <stdlib.h>
int main ()
{
const char *s = "+3.1415e+0";
char *theend;
long double res = strtold (s, &theend);
return !(*theend == 0 && finitel (res) &&
res >= 3.14 && res <= 3.15);
}],
[AC_MSG_RESULT(no)],
[AC_MSG_RESULT(yes)
AC_DEFINE([GOFFICE_SUPPLIED_STRTOLD], 1,
[Define if G Office supplies strtold.])
],
[AC_MSG_RESULT(assuming not)])
else
AC_DEFINE([GOFFICE_SUPPLIED_STRTOLD], 1,
[Define if G Office supplies strtold.])
AC_CHECK_FUNCS(string_to_decimal decimal_to_quadruple)
if test "x$ac_cv_func_string_to_decimal" != "xyes" || \
test "x$ac_cv_func_decimal_to_quadruple" != "xyes" || \
test "x$ac_cv_header_floatingpoint_h" != "xyes"; then
AC_MSG_WARN([You lack the strtold function -- precision will be impaired])
fi
fi
if test "$have_mandatory_funcs" = yes; then
float_msg=yes
AC_DEFINE([GOFFICE_WITH_LONG_DOUBLE], 1,
[Define if G Office supports long double.])
else
AC_MSG_WARN([Long double support disabled because of library problems])
fi
unset have_mandatory_funcs
fi
AC_SUBST(EXTRA_LIBS)
AC_SUBST(EXTRA_INCLUDES)
dnl ******************
dnl * Config defaults
dnl ******************
dnl
dnl These are changed in goffice.c for WIN32 packages
AC_SUBST(goffice_datadir, '${datadir}/goffice/${VERSION}')
AC_SUBST(goffice_libdir, '${libdir}/goffice/${VERSION}')
AC_SUBST(goffice_icondir, '${datadir}/pixmaps/goffice')
AC_SUBST(goffice_localedir, '${prefix}/${DATADIRNAME}/locale')
dnl
AC_SUBST(goffice_plugindir, '${goffice_libdir}/plugins')
AC_SUBST(goffice_gladedir, '${goffice_datadir}/glade')
dnl Export to goffice-config.h and goffice-features.h
AC_DEFINE(GOFFICE_VERSION, "goffice_full_version",
[The version number of this release, possibly with additional suffix])
AC_DEFINE(GO_VERSION_EPOCH, goffice_version_epoch,
[The Epoch of this release])
AC_DEFINE(GO_VERSION_MAJOR, goffice_version_major,
[The Major version number of this release])
AC_DEFINE(GO_VERSION_MINOR, goffice_version_minor,
[The Minor version number of this release])
AC_DEFINE(GO_VERSION_EXTRA, "goffice_version_extra",
[Extra, possibly empty tag for this release])
AC_CONFIG_FILES([
Makefile
libgoffice-1.pc
goffice/Makefile
goffice/app/Makefile
goffice/utils/Makefile
goffice/data/Makefile
goffice/gtk/Makefile
goffice/graph/Makefile
goffice/drawing/Makefile
goffice/ms-compat/Makefile
goffice/cut-n-paste/Makefile
goffice/cut-n-paste/foocanvas/Makefile
goffice/cut-n-paste/pcre/Makefile
plugins/Makefile
plugins/plot_barcol/Makefile
plugins/plot_pie/Makefile
plugins/plot_radar/Makefile
plugins/plot_xy/Makefile
plugins/plot_surface/Makefile
plugins/plot_boxes/Makefile
plugins/reg_linear/Makefile
pixmaps/Makefile
po/Makefile.in
tests/Makefile
])
AC_OUTPUT
echo "
Configuration:
Source code location: ${srcdir}
Compiler: ${CC}
Compiler flags: ${CFLAGS}
Long double support: ${float_msg}
Cairo support: ${cairo_msg}
UI: ${ui_msg}
"

479
lib/goffice-0.0.4/depcomp Executable file
View File

@ -0,0 +1,479 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
# Copyright 1999, 2000, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# `libtool' can also be set to `yes' or `no'.
if test -z "$depfile"; then
base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
dir=`echo "$object" | sed 's,/.*$,/,'`
if test "$dir" = "$object"; then
dir=
fi
# FIXME: should be _deps on DOS.
depfile="$dir.deps/$base"
fi
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test -f "$tmpdepfile"; then :
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
outname="$stripped.o"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
tmpdepfile1="$dir.libs/$base.lo.d"
tmpdepfile2="$dir.libs/$base.d"
"$@" -Wc,-MD
else
tmpdepfile1="$dir$base.o.d"
tmpdepfile2="$dir$base.d"
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
if test -f "$tmpdepfile1"; then
tmpdepfile="$tmpdepfile1"
else
tmpdepfile="$tmpdepfile2"
fi
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0

View File

@ -0,0 +1,7 @@
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/libgsf-1.12.3 \
-I$(top_srcdir)/lib/goffice-0.0.4 \
-I$(top_builddir)/lib/goffice-0.0.4 \
$(GOFFICE_DEPS_CFLAGS)
GOFFICE_PLUGIN_FLAGS = $(GOFFICE_PLUGIN_LDFLAGS)

View File

@ -0,0 +1,11 @@
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/libgsf-1.12.3 \
-I$(top_builddir)/lib/goffice-0.0.4 \
-I$(top_srcdir)/lib/goffice-0.0.4 \
$(GOFFICE_DEPS_CFLAGS)
AM_LDFLAGS = \
$(GSF_LIBS)
GOFFICE_PLUGIN_FLAGS = $(GOFFICE_PLUGIN_LDFLAGS)
goffice_include_dir = $(includedir)/libgoffice-1/goffice

View File

@ -0,0 +1,58 @@
SUBDIRS = utils data app graph gtk drawing ms-compat cut-n-paste
lib_LTLIBRARIES = libgoffice-1.la
libgoffice_1_la_LIBADD = \
cut-n-paste/pcre/libpcre.la \
utils/libgoffice-utils.la \
app/libgoffice-app.la \
data/libgoffice-data.la \
gtk/libgoffice-gtk.la \
cut-n-paste/foocanvas/libfoocanvas.la \
graph/libgoffice-graph.la \
drawing/libgoffice-drawing.la \
ms-compat/libgoffice-ms-compat.la \
$(GOFFICE_DEPS_LIBS)
libgoffice_1_la_LDFLAGS = -version-info $(GOFFICE_LIB_VERSION)
if WITH_WIN32
libgoffice_1_la_LDFLAGS += -no-undefined -Wl,-export-all-symbols
libgoffice_1_la_LIBADD += utils/libgoffice-win32-stub.la
endif
BUILT_SOURCES = goffice-paths.h
CLEANFILES = $(BUILT_SOURCES)
libgoffice_1_la_SOURCES = \
$(BUILT_SOURCES) \
goffice.c \
goffice-priv.h
if !HAVE_GLIB26
libgoffice_1_la_SOURCES += glib24_26-compat.c
endif
libgoffice_1_ladir = $(goffice_include_dir)
libgoffice_1_la_HEADERS = \
goffice.h
if !HAVE_GLIB26
libgoffice_1_la_HEADERS += glib24_26-compat.h
endif
# Depends on this Makefile, because it uses make variables.
goffice-paths.h: Makefile
@echo 'creating $@'
@( \
echo '/* This file has been automatically generated. Do not edit. */'; \
echo ''; \
echo '#ifndef GOFFICE_PATHS_H'; \
echo '#define GOFFICE_PATHS_H'; \
echo ''; \
echo '#define GOFFICE_DATADIR "$(goffice_datadir)"'; \
echo '#define GOFFICE_LIBDIR "$(goffice_libdir)"'; \
echo '#define GOFFICE_ICONDIR "$(goffice_icondir)"'; \
echo '#define GOFFICE_LOCALEDIR "$(goffice_localedir)"'; \
echo ''; \
echo '#endif /* GOFFICE_PATHS_H */'; \
) >$@
include $(top_srcdir)/lib/goffice-0.0.4/goffice.mk

View File

@ -0,0 +1,54 @@
noinst_LTLIBRARIES = libgoffice-app.la
noinst_HEADERS = \
file-priv.h \
io-context-priv.h
libgoffice_app_la_SOURCES = \
go-doc.c \
go-doc-control.c \
\
go-plugin.c \
go-plugin-loader.c \
go-plugin-loader-module.c \
go-plugin-service.c \
\
file.c \
error-info.c \
io-context.c \
go-cmd-context.c
libgoffice_app_ladir = $(goffice_include_dir)/app
libgoffice_app_la_HEADERS = \
goffice-app.h \
\
go-doc.h \
go-doc-impl.h \
go-doc-control.h \
go-doc-control-impl.h \
go-plugin.h \
go-plugin-loader.h \
go-plugin-loader-module.h \
module-plugin-defs.h \
go-plugin-service.h \
go-plugin-service-impl.h \
file.h \
error-info.h \
io-context.h \
io-context-priv.h \
go-cmd-context.h \
go-cmd-context-impl.h
# This list should be empty when we reach a stable phase.
UNUSED = \
go-app.h \
go-error-stack.h \
go-object.c \
go-object.h \
go-service.c \
go-service.h \
go-service-impl.h
EXTRA_DIST = $(UNUSED)
include $(top_srcdir)/lib/goffice-0.0.4/goffice.mk

View File

@ -5,16 +5,15 @@
* Zbigniew Chyla (cyba@gnome.pl)
*/
#include <config.h>
#include "gnumeric.h"
#include "error-info.h"
#include <goffice/goffice-config.h>
#include <goffice/app/error-info.h>
#include <stdio.h>
#include <errno.h>
struct _ErrorInfo {
gchar *msg;
GnmSeverity severity;
GOSeverity severity;
GSList *details; /* list of ErrorInfo */
};
@ -23,19 +22,19 @@ error_info_new_str (char const *msg)
{
ErrorInfo *error = g_new (ErrorInfo, 1);
error->msg = g_strdup (msg);
error->severity = GNM_ERROR;
error->severity = GO_ERROR;
error->details = NULL;
return error;
}
ErrorInfo *
error_info_new_vprintf (GnmSeverity severity, char const *msg_format,
error_info_new_vprintf (GOSeverity severity, char const *msg_format,
va_list args)
{
ErrorInfo *error;
g_return_val_if_fail (severity >= GNM_WARNING, NULL);
g_return_val_if_fail (severity <= GNM_ERROR, NULL);
g_return_val_if_fail (severity >= GO_WARNING, NULL);
g_return_val_if_fail (severity <= GO_ERROR, NULL);
error = g_new (ErrorInfo, 1);
error->msg = g_strdup_vprintf (msg_format, args);
@ -52,7 +51,7 @@ error_info_new_printf (char const *msg_format, ...)
va_list args;
va_start (args, msg_format);
error = error_info_new_vprintf (GNM_ERROR, msg_format, args);
error = error_info_new_vprintf (GO_ERROR, msg_format, args);
va_end (args);
return error;
@ -161,7 +160,7 @@ error_info_print_with_offset (ErrorInfo *error, gint offset)
if (error->msg != NULL) {
char c = 'E';
if (error->severity == GNM_WARNING)
if (error->severity == GO_WARNING)
c = 'W';
fprintf (stderr, "%*s%c %s\n", offset, "", c, error->msg);
offset += 2;
@ -194,10 +193,10 @@ error_info_peek_details (ErrorInfo *error)
return error->details;
}
GnmSeverity
GOSeverity
error_info_peek_severity (ErrorInfo *error)
{
g_return_val_if_fail (error != NULL, GNM_ERROR);
g_return_val_if_fail (error != NULL, GO_ERROR);
return error->severity;
}

View File

@ -0,0 +1,39 @@
#ifndef GO_ERROR_INFO_H
#define GO_ERROR_INFO_H
#include <goffice/app/goffice-app.h>
#include <glib.h>
G_BEGIN_DECLS
typedef enum {
GO_WARNING = 1,
GO_ERROR
} GOSeverity;
ErrorInfo *error_info_new_str (char const *msg);
ErrorInfo *error_info_new_printf (char const *msg_format, ...) G_GNUC_PRINTF (1, 2);
ErrorInfo *error_info_new_vprintf (GOSeverity severity,
char const *msg_format,
va_list args);
ErrorInfo *error_info_new_str_with_details (char const *msg, ErrorInfo *details);
ErrorInfo *error_info_new_str_with_details_list (char const *msg, GSList *details);
ErrorInfo *error_info_new_from_error_list (GSList *errors);
ErrorInfo *error_info_new_from_errno (void);
void error_info_add_details (ErrorInfo *error, ErrorInfo *details);
void error_info_add_details_list (ErrorInfo *error, GSList *details);
void error_info_free (ErrorInfo *error);
void error_info_print (ErrorInfo *error);
char const*error_info_peek_message (ErrorInfo *error);
GSList *error_info_peek_details (ErrorInfo *error);
GOSeverity error_info_peek_severity (ErrorInfo *error);
#define GO_INIT_RET_ERROR_INFO(ret_error) \
G_STMT_START { \
g_assert (ret_error != NULL); \
*ret_error = NULL; \
} G_STMT_END
G_END_DECLS
#endif /* GO_ERROR_INFO_H */

View File

@ -0,0 +1,95 @@
#ifndef GO_FILE_PRIV_H
#define GO_FILE_PRIV_H
#include <goffice/app/goffice-app.h>
G_BEGIN_DECLS
/*
* GOFileOpener
*/
#define GO_FILE_OPENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GO_FILE_OPENER, GOFileOpenerClass))
#define IS_GO_FILE_OPENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GO_FILE_OPENER))
#define GO_FILE_OPENER_METHOD(obj,name) \
((GO_FILE_OPENER_CLASS (G_OBJECT_GET_CLASS (obj)))->name)
struct _GOFileOpenerClass {
GObjectClass parent_class;
gboolean (*can_probe) (GOFileOpener const *fo,
FileProbeLevel pl);
gboolean (*probe) (GOFileOpener const *fo,
GsfInput *input,
FileProbeLevel pl);
void (*open) (GOFileOpener const *fo,
gchar const *opt_enc,
IOContext *io_context,
gpointer fixme_fixme_workbook_view,
GsfInput *input);
};
struct _GOFileOpener {
GObject parent;
gchar *id;
gchar *description;
GSList *suffixes;
GSList *mimes;
gboolean encoding_dependent;
GOFileOpenerProbeFunc probe_func;
GOFileOpenerOpenFunc open_func;
};
void go_file_opener_setup (GOFileOpener *fo, const gchar *id,
const gchar *description,
GSList *suffixes,
GSList *mimes,
gboolean encoding_dependent,
GOFileOpenerProbeFunc probe_func,
GOFileOpenerOpenFunc open_func);
/*
* GOFileSaver
*/
#define GO_FILE_SAVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GO_FILE_SAVER, GOFileSaverClass))
#define IS_GO_FILE_SAVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GO_FILE_SAVER))
#define GO_FILE_SAVER_METHOD(obj,name) \
((GO_FILE_SAVER_CLASS (G_OBJECT_GET_CLASS (obj)))->name)
struct _GOFileSaverClass {
GObjectClass parent_class;
void (*save) (GOFileSaver const *fs,
IOContext *io_context,
gconstpointer wbv,
GsfOutput *output);
};
struct _GOFileSaver {
GObject parent;
gchar *id;
const gchar *mime_type;
gchar *extension;
gchar *description;
gboolean overwrite_files;
FileFormatLevel format_level;
FileSaveScope save_scope;
GOFileSaverSaveFunc save_func;
};
void go_file_saver_setup (GOFileSaver *fs,
const gchar *id,
const gchar *extension,
const gchar *description,
FileFormatLevel level,
GOFileSaverSaveFunc save_func);
G_END_DECLS
#endif /* GO_FILE_PRIV_H */

View File

@ -0,0 +1,869 @@
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* file.c: File loading and saving routines
*
* Authors:
* Miguel de Icaza (miguel@kernel.org)
* Zbigniew Chyla (cyba@gnome.pl)
*/
#include <goffice/goffice-config.h>
#include <goffice/utils/go-file.h>
#include <goffice/utils/go-glib-extras.h>
#include <goffice/app/file.h>
#include <goffice/app/file-priv.h>
#include <goffice/app/error-info.h>
#include <goffice/app/io-context.h>
#include <gsf/gsf-input.h>
#include <gsf/gsf-output.h>
#include <gsf/gsf-output-stdio.h>
#include <gsf/gsf-impl-utils.h>
#include <gsf/gsf-output-stdio.h>
#include <gsf/gsf-utils.h>
#include <string.h>
#include <glib/gi18n.h>
static void
go_file_opener_init (GOFileOpener *fo)
{
fo->id = NULL;
fo->description = NULL;
fo->probe_func = NULL;
fo->open_func = NULL;
}
static void
go_file_opener_finalize (GObject *obj)
{
GOFileOpener *fo;
g_return_if_fail (IS_GO_FILE_OPENER (obj));
fo = GO_FILE_OPENER (obj);
g_free (fo->id);
g_free (fo->description);
g_slist_foreach (fo->suffixes, (GFunc)g_free, NULL);
g_slist_free (fo->suffixes);
g_slist_foreach (fo->mimes, (GFunc)g_free, NULL);
g_slist_free (fo->mimes);
G_OBJECT_CLASS (g_type_class_peek (G_TYPE_OBJECT))->finalize (obj);
}
static gboolean
go_file_opener_can_probe_real (GOFileOpener const *fo, FileProbeLevel pl)
{
return fo->probe_func != NULL;
}
static gboolean
go_file_opener_probe_real (GOFileOpener const *fo, GsfInput *input,
FileProbeLevel pl)
{
gboolean ret = FALSE;
if (fo->probe_func != NULL) {
ret = fo->probe_func (fo, input, pl);
gsf_input_seek (input, 0, G_SEEK_SET);
}
return ret;
}
static void
go_file_opener_open_real (GOFileOpener const *fo, gchar const *opt_enc,
IOContext *io_context,
gpointer FIXME_FIXME_workbook_view,
GsfInput *input)
{
if (fo->open_func != NULL) {
if (fo->encoding_dependent)
((GOFileOpenerOpenFuncWithEnc)fo->open_func)
(fo, opt_enc, io_context, FIXME_FIXME_workbook_view, input);
else
fo->open_func (fo, io_context, FIXME_FIXME_workbook_view, input);
} else
gnumeric_io_error_unknown (io_context);
}
static void
go_file_opener_class_init (GOFileOpenerClass *klass)
{
G_OBJECT_CLASS (klass)->finalize = go_file_opener_finalize;
klass->can_probe = go_file_opener_can_probe_real;
klass->probe = go_file_opener_probe_real;
klass->open = go_file_opener_open_real;
}
GSF_CLASS (GOFileOpener, go_file_opener,
go_file_opener_class_init, go_file_opener_init,
G_TYPE_OBJECT)
/**
* go_file_opener_setup:
* @fo : Newly created GOFileOpener object
* @id : Optional ID of the opener (or NULL)
* @description : Description of supported file format
* @encoding_dependent: whether the opener depends on an encoding sel.
* @probe_func : Optional pointer to "probe" function (or NULL)
* @open_func : Pointer to "open" function
*
* Sets up GOFileOpener object, newly created with g_object_new function.
* This is intended to be used only by GOFileOpener derivates.
* Use go_file_opener_new, if you want to create GOFileOpener object.
*/
void
go_file_opener_setup (GOFileOpener *fo, gchar const *id,
gchar const *description,
GSList *suffixes,
GSList *mimes,
gboolean encoding_dependent,
GOFileOpenerProbeFunc probe_func,
GOFileOpenerOpenFunc open_func)
{
g_return_if_fail (IS_GO_FILE_OPENER (fo));
fo->id = g_strdup (id);
fo->description = g_strdup (description);
fo->suffixes = suffixes;
fo->mimes = mimes;
fo->encoding_dependent = encoding_dependent;
fo->probe_func = probe_func;
fo->open_func = open_func;
}
/**
* go_file_opener_new:
* @id : Optional ID of the opener (or NULL)
* @description : Description of supported file format
* @probe_func : Optional pointer to "probe" function (or NULL)
* @open_func : Pointer to "open" function
*
* Creates new GOFileOpener object. Optional @id will be used
* after registering it with go_file_opener_register function.
*
* Return value: newly created GOFileOpener object.
*/
GOFileOpener *
go_file_opener_new (gchar const *id,
gchar const *description,
GSList *suffixes,
GSList *mimes,
GOFileOpenerProbeFunc probe_func,
GOFileOpenerOpenFunc open_func)
{
GOFileOpener *fo;
fo = GO_FILE_OPENER (g_object_new (TYPE_GO_FILE_OPENER, NULL));
go_file_opener_setup (fo, id, description, suffixes, mimes, FALSE,
probe_func, open_func);
return fo;
}
/**
* go_file_opener_new_with_enc:
* @id : Optional ID of the opener (or NULL)
* @description : Description of supported file format
* @probe_func : Optional pointer to "probe" function (or NULL)
* @open_func : Pointer to "open" function
*
* Creates new GOFileOpener object. Optional @id will be used
* after registering it with go_file_opener_register function.
*
* Return value: newly created GOFileOpener object.
*/
GOFileOpener *
go_file_opener_new_with_enc (gchar const *id,
gchar const *description,
GSList *suffixes,
GSList *mimes,
GOFileOpenerProbeFunc probe_func,
GOFileOpenerOpenFuncWithEnc open_func)
{
GOFileOpener *fo;
fo = GO_FILE_OPENER (g_object_new (TYPE_GO_FILE_OPENER, NULL));
go_file_opener_setup (fo, id, description, suffixes, mimes, TRUE,
probe_func, (GOFileOpenerOpenFunc)open_func);
return fo;
}
gchar const *
go_file_opener_get_id (GOFileOpener const *fo)
{
g_return_val_if_fail (IS_GO_FILE_OPENER (fo), NULL);
return fo->id;
}
gchar const *
go_file_opener_get_description (GOFileOpener const *fo)
{
g_return_val_if_fail (IS_GO_FILE_OPENER (fo), NULL);
return fo->description;
}
gboolean
go_file_opener_is_encoding_dependent (GOFileOpener const *fo)
{
g_return_val_if_fail (IS_GO_FILE_OPENER (fo), FALSE);
return fo->encoding_dependent;
}
gboolean
go_file_opener_can_probe (GOFileOpener const *fo, FileProbeLevel pl)
{
g_return_val_if_fail (IS_GO_FILE_OPENER (fo), FALSE);
return GO_FILE_OPENER_METHOD (fo, can_probe) (fo, pl);
}
GSList const *
go_file_opener_get_suffixes (GOFileOpener const *fo)
{
g_return_val_if_fail (IS_GO_FILE_OPENER (fo), NULL);
return fo->suffixes;
}
GSList const *
go_file_opener_get_mimes (GOFileOpener const *fo)
{
g_return_val_if_fail (IS_GO_FILE_OPENER (fo), NULL);
return fo->mimes;
}
/**
* go_file_opener_probe:
* @fo : GOFileOpener object
* @input : The input source
*
* Checks if a given file is supported by the opener.
*
* Return value: TRUE, if the opener can read given file and FALSE
* otherwise.
*/
gboolean
go_file_opener_probe (GOFileOpener const *fo, GsfInput *input, FileProbeLevel pl)
{
g_return_val_if_fail (IS_GO_FILE_OPENER (fo), FALSE);
g_return_val_if_fail (GSF_IS_INPUT (input), FALSE);
#if 0
g_print ("Trying format %s at level %d...\n",
go_file_opener_get_id (fo),
(int)pl);
#endif
return GO_FILE_OPENER_METHOD (fo, probe) (fo, input, pl);
}
/**
* go_file_opener_open:
* @fo : GOFileOpener object
* @opt_enc : Optional encoding
* @io_context : Context for i/o operation
* @wbv : Workbook View
* @input : Gsf input stream
*
* Reads content of @file_name file into workbook @wbv is attached to.
* Results are reported using @io_context object, use
* gnumeric_io_error_occurred to find out if operation was successful.
* The state of @wbv and its workbook is undefined if operation fails, you
* should destroy them in that case.
*/
void
go_file_opener_open (GOFileOpener const *fo, gchar const *opt_enc,
IOContext *io_context,
gpointer FIXME_FIXME_workbook_view, GsfInput *input)
{
g_return_if_fail (IS_GO_FILE_OPENER (fo));
g_return_if_fail (GSF_IS_INPUT (input));
GO_FILE_OPENER_METHOD (fo, open) (fo, opt_enc, io_context, FIXME_FIXME_workbook_view, input);
}
/*
* GOFileSaver
*/
static void
go_file_saver_init (GOFileSaver *fs)
{
fs->id = NULL;
fs->extension = NULL;
fs->mime_type = NULL;
fs->description = NULL;
fs->overwrite_files = TRUE;
fs->format_level = FILE_FL_NEW;
fs->save_scope = FILE_SAVE_WORKBOOK;
fs->save_func = NULL;
}
static void
go_file_saver_finalize (GObject *obj)
{
GOFileSaver *fs;
g_return_if_fail (IS_GO_FILE_SAVER (obj));
fs = GO_FILE_SAVER (obj);
g_free (fs->id);
g_free (fs->extension);
g_free (fs->description);
G_OBJECT_CLASS (g_type_class_peek (G_TYPE_OBJECT))->finalize (obj);
}
static void
go_file_saver_save_real (GOFileSaver const *fs, IOContext *io_context,
gconstpointer FIXME_FIXME_workbook_view, GsfOutput *output)
{
if (fs->save_func == NULL) {
gnumeric_io_error_unknown (io_context);
return;
}
fs->save_func (fs, io_context, FIXME_FIXME_workbook_view, output);
}
static void
go_file_saver_class_init (GOFileSaverClass *klass)
{
G_OBJECT_CLASS (klass)->finalize = go_file_saver_finalize;
klass->save = go_file_saver_save_real;
}
GSF_CLASS (GOFileSaver, go_file_saver,
go_file_saver_class_init, go_file_saver_init,
G_TYPE_OBJECT)
/**
* go_file_saver_setup:
* @fs : Newly created GOFileSaver object
* @id : Optional ID of the saver (or NULL)
* @extension : Optional default extension of saved files (or NULL)
* @description : Description of supported file format
* @level : File format level
* @save_func : Pointer to "save" function
*
* Sets up GOFileSaver object, newly created with g_object_new function.
* This is intended to be used only by GOFileSaver derivates.
* Use go_file_saver_new, if you want to create GOFileSaver object.
*/
void
go_file_saver_setup (GOFileSaver *fs, gchar const *id,
gchar const *extension,
gchar const *description,
FileFormatLevel level,
GOFileSaverSaveFunc save_func)
{
g_return_if_fail (IS_GO_FILE_SAVER (fs));
fs->id = g_strdup (id);
fs->mime_type = NULL;
//#warning mime disabled
#if 0
gchar *tmp = g_strdup_printf ("SomeFile.%s", extension);
gnome_mime_type_or_default (tmp,
"application/application/x-gnumeric");
g_free (tmp);
#endif
fs->extension = g_strdup (extension);
fs->description = g_strdup (description);
fs->format_level = level;
fs->save_func = save_func;
}
/**
* go_file_saver_new:
* @id : Optional ID of the saver (or NULL)
* @extension : Optional default extension of saved files (or NULL)
* @description : Description of supported file format
* @level : File format level
* @save_func : Pointer to "save" function
*
* Creates new GOFileSaver object. Optional @id will be used
* after registering it with go_file_saver_register or
* go_file_saver_register_as_default function.
*
* Return value: newly created GOFileSaver object.
*/
GOFileSaver *
go_file_saver_new (gchar const *id,
gchar const *extension,
gchar const *description,
FileFormatLevel level,
GOFileSaverSaveFunc save_func)
{
GOFileSaver *fs;
fs = GO_FILE_SAVER (g_object_new (TYPE_GO_FILE_SAVER, NULL));
go_file_saver_setup (fs, id, extension, description, level, save_func);
return fs;
}
void
go_file_saver_set_save_scope (GOFileSaver *fs, FileSaveScope scope)
{
g_return_if_fail (IS_GO_FILE_SAVER (fs));
g_return_if_fail (scope < FILE_SAVE_LAST);
fs->save_scope = scope;
}
FileSaveScope
go_file_saver_get_save_scope (GOFileSaver const *fs)
{
g_return_val_if_fail (IS_GO_FILE_SAVER (fs), FILE_SAVE_WORKBOOK);
return fs->save_scope;
}
gchar const *
go_file_saver_get_id (GOFileSaver const *fs)
{
g_return_val_if_fail (IS_GO_FILE_SAVER (fs), NULL);
return fs->id;
}
gchar const *
go_file_saver_get_mime_type (GOFileSaver const *fs)
{
g_return_val_if_fail (IS_GO_FILE_SAVER (fs), NULL);
return fs->mime_type;
}
gchar const *
go_file_saver_get_extension (GOFileSaver const *fs)
{
g_return_val_if_fail (IS_GO_FILE_SAVER (fs), NULL);
return fs->extension;
}
gchar const *
go_file_saver_get_description (GOFileSaver const *fs)
{
g_return_val_if_fail (IS_GO_FILE_SAVER (fs), NULL);
return fs->description;
}
FileFormatLevel
go_file_saver_get_format_level (GOFileSaver const *fs)
{
g_return_val_if_fail (IS_GO_FILE_SAVER (fs), FILE_FL_NEW);
return fs->format_level;
}
/**
* go_file_saver_save:
* @fs : GOFileSaver object
* @io_context : Context for i/o operation
* @wbv : Workbook View
* @output : Output stream
*
* Saves @wbv and the workbook it is attached to into @output stream.
* Results are reported using @io_context object, use
* gnumeric_io_error_occurred to find out if operation was successful.
* It's possible that @file_name is created and contain some data if
* operation fails, you should remove the file in that case.
*/
void
go_file_saver_save (GOFileSaver const *fs, IOContext *io_context,
gconstpointer FIXME_FIXME_workbook_view,
GsfOutput *output)
{
char *file_name;
g_return_if_fail (IS_GO_FILE_SAVER (fs));
g_return_if_fail (GSF_IS_OUTPUT (output));
if (GSF_IS_OUTPUT_STDIO (output)) {
file_name = (char *) gsf_output_name (output);
if (file_name == NULL) {
ErrorInfo *save_error = error_info_new_str(
_("Not a valid UTF-8 filename."));
gnumeric_io_error_info_set (io_context, save_error);
return;
}
if (!fs->overwrite_files &&
g_file_test ((file_name), G_FILE_TEST_EXISTS)) {
ErrorInfo *save_error;
save_error = error_info_new_str_with_details (
_("Saving over old files of this type is disabled for safety."),
error_info_new_str (
_("You can turn this safety feature off by editing appropriate plugin.xml file.")));
gnumeric_io_error_info_set (io_context, save_error);
return;
}
}
GO_FILE_SAVER_METHOD (fs, save) (fs, io_context, FIXME_FIXME_workbook_view, output);
}
/**
* go_file_saver_set_overwrite_files:
* @fs : GOFileSaver object
* @overwrite : A boolean value saying whether the saver should overwrite
* existing files.
*
* Changes behaviour of the saver when saving a file. If @overwrite is set
* to TRUE, existing file will be overwritten. Otherwise, the saver will
* report an error without saving anything.
*/
void
go_file_saver_set_overwrite_files (GOFileSaver *fs, gboolean overwrite)
{
g_return_if_fail (IS_GO_FILE_SAVER (fs));
fs->overwrite_files = overwrite;
}
/*
* ------
*/
typedef struct {
gint priority;
GOFileSaver *saver;
} DefaultFileSaver;
static GHashTable *file_opener_id_hash = NULL,
*file_saver_id_hash = NULL;
static GList *file_opener_list = NULL, *file_opener_priority_list = NULL;
static GList *file_saver_list = NULL, *default_file_saver_list = NULL;
static gint
cmp_int_less_than (gconstpointer list_i, gconstpointer i)
{
return !(GPOINTER_TO_INT (list_i) < GPOINTER_TO_INT (i));
}
/**
* go_file_opener_register:
* @fo : GOFileOpener object
* @priority : Opener's priority
*
* Adds @fo opener to the list of available file openers, making it
* available for Gnumeric i/o routines. The opener is registered with given
* @priority. The priority is used to determine the order in which openers
* will be tried when reading a file. The higher the priority, the sooner it
* will be tried. Default XML-based Gnumeric file opener is registered at
* priority 50. Recommended range for @priority is [0, 100].
* Reference count for the opener is incremented inside the function, but
* you don't have to (and shouldn't) call g_object_unref on it if it's
* floating object (for example, when you pass object newly created with
* go_file_opener_new and not referenced anywhere).
*/
void
go_file_opener_register (GOFileOpener *fo, gint priority)
{
gint pos;
gchar const *id;
g_return_if_fail (IS_GO_FILE_OPENER (fo));
g_return_if_fail (priority >=0 && priority <= 100);
pos = go_list_index_custom (file_opener_priority_list,
GINT_TO_POINTER (priority),
cmp_int_less_than);
file_opener_priority_list = g_list_insert (
file_opener_priority_list,
GINT_TO_POINTER (priority), pos);
file_opener_list = g_list_insert (file_opener_list, fo, pos);
g_object_ref (G_OBJECT (fo));
id = go_file_opener_get_id (fo);
if (id != NULL) {
if (file_opener_id_hash == NULL)
file_opener_id_hash = g_hash_table_new (&g_str_hash, &g_str_equal);
g_hash_table_insert (file_opener_id_hash, (gpointer) id, fo);
}
}
/**
* go_file_opener_unregister:
* @fo : GOFileOpener object previously registered using
* go_file_opener_register
*
* Removes @fo opener from list of available file openers. Reference count
* for the opener is decremented inside the function.
*/
void
go_file_opener_unregister (GOFileOpener *fo)
{
gint pos;
GList *l;
gchar const *id;
g_return_if_fail (IS_GO_FILE_OPENER (fo));
pos = g_list_index (file_opener_list, fo);
g_return_if_fail (pos != -1);
l = g_list_nth (file_opener_list, pos);
file_opener_list = g_list_remove_link (file_opener_list, l);
g_list_free_1 (l);
l = g_list_nth (file_opener_priority_list, pos);
file_opener_priority_list = g_list_remove_link (file_opener_priority_list, l);
g_list_free_1 (l);
id = go_file_opener_get_id (fo);
if (id != NULL) {
g_hash_table_remove (file_opener_id_hash, (gpointer) id);
if (g_hash_table_size (file_opener_id_hash) == 0) {
g_hash_table_destroy (file_opener_id_hash);
file_opener_id_hash = NULL;
}
}
g_object_unref (G_OBJECT (fo));
}
static gint
default_file_saver_cmp_priority (gconstpointer a, gconstpointer b)
{
DefaultFileSaver const *dfs_a = a, *dfs_b = b;
return dfs_b->priority - dfs_a->priority;
}
/**
* go_file_saver_register:
* @fs : GOFileSaver object
*
* Adds @fs saver to the list of available file savers, making it
* available for the user when selecting file format for save.
*/
void
go_file_saver_register (GOFileSaver *fs)
{
gchar const *id;
g_return_if_fail (IS_GO_FILE_SAVER (fs));
file_saver_list = g_list_prepend (file_saver_list, fs);
g_object_ref (G_OBJECT (fs));
id = go_file_saver_get_id (fs);
if (id != NULL) {
if (file_saver_id_hash == NULL)
file_saver_id_hash = g_hash_table_new (&g_str_hash,
&g_str_equal);
g_hash_table_insert (file_saver_id_hash, (gpointer) id, fs);
}
}
/**
* go_file_saver_register_as_default:
* @fs : GOFileSaver object
* @priority : Saver's priority
*
* Adds @fs saver to the list of available file savers, making it
* available for the user when selecting file format for save.
* The saver is also marked as default saver with given priority.
* When Gnumeric needs default file saver, it chooses the one with the
* highest priority. Recommended range for @priority is [0, 100].
*/
void
go_file_saver_register_as_default (GOFileSaver *fs, gint priority)
{
DefaultFileSaver *dfs;
g_return_if_fail (IS_GO_FILE_SAVER (fs));
g_return_if_fail (priority >=0 && priority <= 100);
go_file_saver_register (fs);
dfs = g_new (DefaultFileSaver, 1);
dfs->priority = priority;
dfs->saver = fs;
default_file_saver_list = g_list_insert_sorted (
default_file_saver_list, dfs,
default_file_saver_cmp_priority);
}
/**
* go_file_saver_unregister:
* @fs : GOFileSaver object previously registered using
* go_file_saver_register or go_file_saver_register_as_default
*
* Removes @fs saver from list of available file savers. Reference count
* for the saver is decremented inside the function.
*/
void
go_file_saver_unregister (GOFileSaver *fs)
{
GList *l;
gchar const *id;
g_return_if_fail (IS_GO_FILE_SAVER (fs));
l = g_list_find (file_saver_list, fs);
g_return_if_fail (l != NULL);
file_saver_list = g_list_remove_link (file_saver_list, l);
g_list_free_1 (l);
id = go_file_saver_get_id (fs);
if (id != NULL) {
g_hash_table_remove (file_saver_id_hash, (gpointer) id);
if (g_hash_table_size (file_saver_id_hash) == 0) {
g_hash_table_destroy (file_saver_id_hash);
file_saver_id_hash = NULL;
}
}
for (l = default_file_saver_list; l != NULL; l = l->next) {
if (((DefaultFileSaver *) l->data)->saver == fs) {
default_file_saver_list = g_list_remove_link (default_file_saver_list, l);
g_free (l->data);
g_list_free_1 (l);
break;
}
}
g_object_unref (G_OBJECT (fs));
}
/**
* go_file_saver_get_default:
*
* Returns file saver registered as default saver with the highest priority.
* Reference count for the saver is NOT incremented.
*
* Return value: GOFileSaver object or NULL if default saver is not
* available.
*/
GOFileSaver *
go_file_saver_get_default (void)
{
if (default_file_saver_list == NULL)
return NULL;
return ((DefaultFileSaver *) default_file_saver_list->data)->saver;
}
/**
* go_file_saver_for_mime_type:
* @mime_type: A mime type
*
* Returns a file saver that claims to save files with given mime type.
*
* Return value: GOFileSaver object or NULL if no suitable file saver could
* be found.
*/
GOFileSaver *
go_file_saver_for_mime_type (gchar const *mime_type)
{
GList *l;
for (l = file_saver_list; l != NULL; l = l->next) {
if (!strcmp (go_file_saver_get_mime_type (l->data), mime_type)) {
return (l->data);
}
}
return (NULL);
}
/**
* go_file_saver_for_file_name :
* @file_name :
*
* Searches for file opener with given @filename, registered using
* go_file_opener_register
*
* Return value: GOFileOpener object or NULL if opener cannot be found.
**/
GOFileSaver *
go_file_saver_for_file_name (char const *file_name)
{
GList *l;
char const *extension = gsf_extension_pointer (file_name);
for (l = file_saver_list; l != NULL; l = l->next)
if (!strcmp (go_file_saver_get_extension (l->data), extension))
return l->data;
return NULL;
}
/**
* go_file_opener_for_id:
* @id : File opener's ID
*
* Searches for file opener with given @id, registered using
* go_file_opener_register
*
* Return value: GOFileOpener object or NULL if opener cannot be found.
*/
GOFileOpener *
go_file_opener_for_id (gchar const *id)
{
g_return_val_if_fail (id != NULL, NULL);
if (file_opener_id_hash == NULL)
return NULL;
return GO_FILE_OPENER (g_hash_table_lookup (file_opener_id_hash, id));
}
/**
* go_file_saver_for_id:
* @id : File saver's ID
*
* Searches for file saver with given @id, registered using
* go_file_saver_register or register_file_opener_as_default.
*
* Return value: GOFileSaver object or NULL if saver cannot be found.
*/
GOFileSaver *
go_file_saver_for_id (gchar const *id)
{
g_return_val_if_fail (id != NULL, NULL);
if (file_saver_id_hash == NULL)
return NULL;
return GO_FILE_SAVER (g_hash_table_lookup (file_saver_id_hash, id));
}
/**
* get_file_savers:
*
* Returns the list of registered file savers (using go_file_saver_register or
* go_file_saver_register_as_default).
*
* Return value: list of GOFileSaver objects, which you shouldn't modify.
*/
GList *
get_file_savers (void)
{
return file_saver_list;
}
/**
* get_file_openers:
*
* Returns the list of registered file openers (using go_file_opener_register).
*
* Return value: list of GOFileOpener objects, which you shouldn't modify.
*/
GList *
get_file_openers (void)
{
return file_opener_list;
}

View File

@ -0,0 +1,148 @@
#ifndef _GOFFICE_FILE_H_
#define _GOFFICE_FILE_H_
#include <glib-object.h>
#include <gsf/gsf.h>
#include <goffice/app/goffice-app.h>
G_BEGIN_DECLS
/*
* File format levels. They are ordered. When we save a file, we
* remember the name, but not if we already have a name at a higher level.
* When created, workbooks are assigned a name at level FILE_FL_NEW.
*/
typedef enum {
FILE_FL_NONE, /* No name assigned, won't happen */
FILE_FL_WRITE_ONLY, /* PostScript etc, won't be remembered */
FILE_FL_NEW, /* Wb just created */
FILE_FL_MANUAL, /* Save gets punted to save as */
FILE_FL_MANUAL_REMEMBER, /* Ditto, but remember in history */
FILE_FL_AUTO, /* Save will save to this filename */
FILE_FL_LAST
} FileFormatLevel;
/*
* FileSaveScope specifies what information file saver can save in a file.
* Many savers can save the whole workbook (with all sheets), but others
* save only current sheet, usually because of file format limitations.
*/
typedef enum {
FILE_SAVE_WORKBOOK,
FILE_SAVE_SHEET,
FILE_SAVE_RANGE,
FILE_SAVE_LAST
} FileSaveScope;
/*
* GOFileOpener
*/
typedef struct _GOFileOpenerClass GOFileOpenerClass;
#define TYPE_GO_FILE_OPENER (go_file_opener_get_type ())
#define GO_FILE_OPENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GO_FILE_OPENER, GOFileOpener))
#define IS_GO_FILE_OPENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GO_FILE_OPENER))
typedef gboolean (*GOFileOpenerProbeFunc) (GOFileOpener const *fo,
GsfInput *input,
FileProbeLevel pl);
typedef void (*GOFileOpenerOpenFunc) (GOFileOpener const *fo,
IOContext *io_context,
gpointer FIXME_FIXME_workbook_view,
GsfInput *input);
typedef void (*GOFileOpenerOpenFuncWithEnc) (GOFileOpener const *fo,
gchar const *enc,
IOContext *io_context,
gpointer FIXME_FIXME_workbook_view,
GsfInput *input);
GType go_file_opener_get_type (void);
GOFileOpener *go_file_opener_new (char const *id,
char const *description,
GSList *suffixes,
GSList *mimes,
GOFileOpenerProbeFunc probe_func,
GOFileOpenerOpenFunc open_func);
GOFileOpener *go_file_opener_new_with_enc (char const *id,
char const *description,
GSList *suffixes,
GSList *mimes,
GOFileOpenerProbeFunc probe_func,
GOFileOpenerOpenFuncWithEnc open_func);
gboolean go_file_opener_probe (GOFileOpener const *fo, GsfInput *input,
FileProbeLevel pl);
void go_file_opener_open (GOFileOpener const *fo, gchar const *opt_enc,
IOContext *io_context,
gpointer FIXME_FIXME_workbook_view,
GsfInput *input);
char const *go_file_opener_get_id (GOFileOpener const *fo);
char const *go_file_opener_get_description (GOFileOpener const *fo);
gboolean go_file_opener_is_encoding_dependent (GOFileOpener const *fo);
gboolean go_file_opener_can_probe (GOFileOpener const *fo,
FileProbeLevel pl);
GSList const *go_file_opener_get_suffixes (GOFileOpener const *fo);
GSList const *go_file_opener_get_mimes (GOFileOpener const *fo);
/*
* GOFileSaver
*/
typedef struct _GOFileSaverClass GOFileSaverClass;
#define TYPE_GO_FILE_SAVER (go_file_saver_get_type ())
#define GO_FILE_SAVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GO_FILE_SAVER, GOFileSaver))
#define IS_GO_FILE_SAVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GO_FILE_SAVER))
typedef void (*GOFileSaverSaveFunc) (GOFileSaver const *fs,
IOContext *io_context,
gconstpointer FIXME_FIXME_workbook_view,
GsfOutput *output);
GType go_file_saver_get_type (void);
GOFileSaver *go_file_saver_new (char const *id,
char const *extension,
char const *description,
FileFormatLevel level,
GOFileSaverSaveFunc save_func);
void go_file_saver_set_save_scope (GOFileSaver *fs, FileSaveScope scope);
FileSaveScope go_file_saver_get_save_scope (GOFileSaver const *fs);
void go_file_saver_save (GOFileSaver const *fs, IOContext *io_context,
gconstpointer FIXME_FIXME_workbook_view,
GsfOutput *output);
void go_file_saver_set_overwrite_files (GOFileSaver *fs,
gboolean overwrite);
char const *go_file_saver_get_id (GOFileSaver const *fs);
char const *go_file_saver_get_extension (GOFileSaver const *fs);
char const *go_file_saver_get_mime_type (GOFileSaver const *fs);
char const *go_file_saver_get_description (GOFileSaver const *fs);
FileFormatLevel go_file_saver_get_format_level (GOFileSaver const *fs);
/*
*
*/
GList *get_file_openers (void);
void go_file_opener_unregister (GOFileOpener *fo);
void go_file_opener_register (GOFileOpener *fo, gint priority);
GOFileOpener *go_file_opener_for_id (char const *id);
GList *get_file_savers (void);
void go_file_saver_unregister (GOFileSaver *fs);
void go_file_saver_register (GOFileSaver *fs);
void go_file_saver_register_as_default (GOFileSaver *fs, gint priority);
GOFileSaver *go_file_saver_get_default (void);
GOFileSaver *go_file_saver_for_mime_type (char const *mime_type);
GOFileSaver *go_file_saver_for_file_name (char const *file_name);
GOFileSaver *go_file_saver_for_id (char const *id);
G_END_DECLS
#endif /* _GOFFICE_FILE_H_ */

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_APP_H

View File

@ -3,6 +3,8 @@
#include <goffice/app/go-cmd-context.h>
G_BEGIN_DECLS
typedef struct {
GTypeInterface base;
@ -12,7 +14,7 @@ typedef struct {
gboolean sensitive);
struct {
void (*error) (GOCmdContext *gcc, GError *err);
void (*error_info) (GOCmdContext *gcc, GOErrorStack *stack);
void (*error_info) (GOCmdContext *gcc, ErrorInfo *err);
} error;
void (*progress_set) (GOCmdContext *gcc, float val);
@ -23,7 +25,9 @@ typedef struct {
#define IS_GO_CMD_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GO_CMD_CONTEXT_TYPE))
/* protected, these do not really belong here, they are associated with io-context */
void cmd_context_progress_set (GOCmdContext *gcc, float f);
void cmd_context_progress_message_set (GOCmdContext *gcc, char const *msg);
void go_cmd_context_progress_set (GOCmdContext *gcc, float f);
void go_cmd_context_progress_message_set (GOCmdContext *gcc, char const *msg);
G_END_DECLS
#endif /* GO_CMD_CONTEXT_IMPL_H */

View File

@ -29,7 +29,7 @@ go_cmd_context_error (GOCmdContext *context, GError *err)
}
void
go_cmd_context_error_info (GOCmdContext *context, GOErrorStack *stack)
go_cmd_context_error_info (GOCmdContext *context, ErrorInfo *stack)
{
g_return_if_fail (IS_GO_CMD_CONTEXT (context));
GCC_CLASS (context)->error.error_info (context, stack);
@ -101,7 +101,7 @@ go_error_invalid (void)
}
void
cmd_context_progress_set (GOCmdContext *context, gfloat f)
go_cmd_context_progress_set (GOCmdContext *context, gfloat f)
{
g_return_if_fail (IS_GO_CMD_CONTEXT (context));
@ -109,7 +109,7 @@ cmd_context_progress_set (GOCmdContext *context, gfloat f)
}
void
cmd_context_progress_message_set (GOCmdContext *context, gchar const *msg)
go_cmd_context_progress_message_set (GOCmdContext *context, gchar const *msg)
{
g_return_if_fail (IS_GO_CMD_CONTEXT (context));

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_CMD_CONTEXT_H
@ -24,6 +24,8 @@
#include <goffice/app/goffice-app.h>
#include <glib-object.h>
G_BEGIN_DECLS
#define GO_CMD_CONTEXT_TYPE (go_cmd_context_get_type ())
#define GO_CMD_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_CMD_CONTEXT_TYPE, GOCmdContext))
#define IS_GO_CMD_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_CMD_CONTEXT_TYPE))
@ -40,7 +42,7 @@ void go_cmd_context_error_import (GOCmdContext *cc, char const *msg);
void go_cmd_context_error_export (GOCmdContext *cc, char const *msg);
void go_cmd_context_error_invalid (GOCmdContext *cc,
char const *msg, char const *val);
void go_cmd_context_error_info (GOCmdContext *cc, GOErrorStack *stack);
void go_cmd_context_error_info (GOCmdContext *cc, ErrorInfo *stack);
/* An initial set of std errors */
GQuark go_error_system (void);
@ -48,4 +50,6 @@ GQuark go_error_import (void);
GQuark go_error_export (void);
GQuark go_error_invalid (void);
G_END_DECLS
#endif /* GO_CMD_CONTEXT_H */

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_DOC_CONTROL_IMPL_H

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
@ -38,3 +38,4 @@ go_doc_control_init (GODocControl *obj)
GSF_CLASS (GODocControl, go_doc_control,
go_doc_control_class_init, go_doc_control_init,
G_TYPE_OBJECT)

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_DOC_CONTROL_H

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_DOC_IMPL_H

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
@ -38,3 +38,4 @@ go_doc_init (GODoc *obj)
GSF_CLASS (GODoc, go_doc,
go_doc_class_init, go_doc_init,
G_TYPE_OBJECT)

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_DOC_H

View File

@ -15,18 +15,23 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_ERROR_STACK_H
#define GO_ERROR_STACK_H
#include <glib-object.h>
#include <goffice/app/goffice-app.h>
GOErrorStack *gog_error_stack_new (GOErrorStack *child,
char const *msg, ...) G_GNUC_PRINTF (2, 3);
G_BEGIN_DECLS
GOErrorStack *go_error_stack_new (GOErrorStack *parent,
char const *fmt, ...) G_GNUC_PRINTF (2, 3);
void go_error_stack_add_child (GOErrorStack *estack, GOErrorStack *child);
void go_error_stack_dump (GOErrorStack *estack);
void go_error_stack_free (GOErrorStack *estack);
G_END_DECLS
#endif /* GO_ERROR_STACK_H */

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
@ -35,11 +35,14 @@ struct _GOServiceObject {
};
typedef GOServiceClass GOServiceObjectClass;
static GObjectClass *go_service_object_parent_class;
static GHashTable *plugin_types = NULL;
static void
go_service_object_finalize (GObject *obj)
{
go_service_object_finalize->finalize (obj);
}
static char *
@ -52,6 +55,7 @@ static void
go_service_object_class_init (GObjectClass *gobj_class)
{
GOServiceClass *serv_class = (GOServiceClass *)gobj_class;
go_combo_box_parent_class = g_type_class_peek_parent (gobj_class);
gobj_class->finalize = go_service_object_finalize;
serv_class->description = go_service_object_description;
plugin_types = g_hash_table_new (g_str_hash, g_str_equal);
@ -98,11 +102,13 @@ go_object_new_valist (char const *type, char const *first_prop, va_list args)
if (!go_plugin_is_loaded (plugin))
err = go_plugin_load (plugin);
if (err == NULL) {
t = g_type_from_name (type);
if (t == 0)
err = gog_error_stack_new (err,
err = go_error_stack_new (err,
_("Loading plugin '%s' that contains the object '%s'"),
go_plugin_get_id (plugin), type);;
}
if (err != NULL) {
go_error_stack_dump (err);
go_error_stack_free (err);

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_OBJECT_H
@ -23,6 +23,8 @@
#include <glib-object.h>
G_BEGIN_DECLS
gpointer go_object_new (char const *type, char const *first_prop, ...);
gpointer go_object_new_valist (char const *type, char const *first_prop,
va_list vargs);
@ -38,4 +40,6 @@ GType go_service_object_get_type (void);
char const *go_service_object_primary_type (GOServiceObject const *service);
GSList const *go_service_object_interfaces (GOServiceObject const *service);
G_END_DECLS
#endif /* GO_OBJECT_H */

View File

@ -0,0 +1,409 @@
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* plugin-loader-module.c: Support for "g_module" (shared libraries) plugins.
*
* Author: Zbigniew Chyla (cyba@gnome.pl)
*/
#include <goffice/goffice-config.h>
#include "go-plugin-loader-module.h"
#include "module-plugin-defs.h"
#include <goffice/app/file.h>
#include <goffice/app/go-plugin.h>
#include <goffice/app/go-plugin-service.h>
#include <goffice/app/go-plugin-loader.h>
#include <goffice/app/error-info.h>
#include <gsf/gsf-impl-utils.h>
#include <gsf/gsf-output.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlmemory.h>
#include <glib/gi18n.h>
#include <string.h>
static void go_plugin_loader_module_set_attributes (GOPluginLoader *loader, GHashTable *attrs, ErrorInfo **ret_error);
static void go_plugin_loader_module_load_base (GOPluginLoader *loader, ErrorInfo **ret_error);
static void go_plugin_loader_module_unload_base (GOPluginLoader *loader, ErrorInfo **ret_error);
static void go_plugin_loader_module_load_service_file_opener (GOPluginLoader *loader, GOPluginService *service, ErrorInfo **ret_error);
static void go_plugin_loader_module_load_service_file_saver (GOPluginLoader *loader, GOPluginService *service, ErrorInfo **ret_error);
static void go_plugin_loader_module_load_service_plugin_loader (GOPluginLoader *loader, GOPluginService *service, ErrorInfo **ret_error);
static GHashTable *go_plugin_loader_module_known_deps = NULL;
void
go_plugin_loader_module_register_version (char const *id, char const *version)
{
if (NULL == go_plugin_loader_module_known_deps)
go_plugin_loader_module_known_deps =
g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_replace (go_plugin_loader_module_known_deps,
(gpointer)id, (gpointer)version);
}
static void
go_plugin_loader_module_set_attributes (GOPluginLoader *loader, GHashTable *attrs,
ErrorInfo **err)
{
GOPluginLoaderModule *loader_module = GO_PLUGIN_LOADER_MODULE (loader);
gchar *module_file_name = g_hash_table_lookup (attrs, "module_file");
if (module_file_name != NULL)
loader_module->module_file_name = g_strdup (module_file_name);
else
*err = error_info_new_str ( _("Module file name not given."));
}
static ErrorInfo *
check_version (GOPluginModuleDepend const *deps, guint32 num_deps, char const *module_file)
{
unsigned i;
char const *ver;
if (deps == NULL && num_deps != 0)
return error_info_new_printf (
_("Module \"%s\" has an inconsistent dependency list."),
module_file);
g_return_val_if_fail (go_plugin_loader_module_known_deps != NULL, NULL);
for (i = 0; i < num_deps ; i++) {
if (deps[i].key == NULL)
return error_info_new_printf (
_("Module \"%s\" depends on an invalid null dependency."),
module_file);
ver = g_hash_table_lookup (go_plugin_loader_module_known_deps, deps[i].key);
if (ver == NULL)
return error_info_new_printf (
_("Module \"%s\" depends on an unknown dependency '%s'."),
module_file, deps[i].key);
if (strcmp (ver, deps[i].version))
return error_info_new_printf (
_("Module \"%s\" was built with version %s of %s, but this executable supplied version %s."),
module_file, deps[i].version, deps[i].key, ver);
}
return NULL;
}
static void
go_plugin_loader_module_load_base (GOPluginLoader *loader, ErrorInfo **err)
{
GOPluginLoaderModule *loader_module = GO_PLUGIN_LOADER_MODULE (loader);
gchar *full_module_file_name;
GModule *handle;
GOPluginModuleHeader const *go_plugin_header = NULL;
GOPluginModuleDepend const *go_plugin_depends = NULL;
GO_INIT_RET_ERROR_INFO (err);
if (!g_module_supported ()) {
*err = error_info_new_str (
_("Dynamic module loading is not supported in this system."));
return;
}
full_module_file_name = g_build_filename (go_plugin_get_dir_name (
go_plugin_loader_get_plugin (loader)),
loader_module->module_file_name, NULL);
handle = g_module_open (full_module_file_name, 0);
if (handle == NULL) {
*err = error_info_new_printf (
_("Unable to open module file \"%s\"."),
full_module_file_name);
error_info_add_details (*err, error_info_new_str (g_module_error()));
} else {
g_module_symbol (handle, "go_plugin_header", (gpointer) &go_plugin_header);
g_module_symbol (handle, "go_plugin_depends", (gpointer) &go_plugin_depends);
if (go_plugin_header == NULL) {
*err = error_info_new_printf (
_("Module \"%s\" doesn't contain (\"go_plugin_header\" symbol)."),
full_module_file_name);
} else if (go_plugin_header->magic_number != GOFFICE_MODULE_PLUGIN_MAGIC_NUMBER) {
*err = error_info_new_printf (
_("Module \"%s\" has an invalid magic number."),
full_module_file_name);
} else if (NULL == (*err = check_version (go_plugin_depends, go_plugin_header->num_depends, full_module_file_name))) {
loader_module->handle = handle;
g_module_symbol (handle, "go_plugin_init", (gpointer)&loader_module->plugin_init);
g_module_symbol (handle, "go_plugin_shutdown", (gpointer)&loader_module->plugin_shutdown);
if (loader_module->plugin_init != NULL)
(loader_module->plugin_init) (go_plugin_loader_get_plugin (loader), NULL);
}
if (*err != NULL)
g_module_close (handle);
}
g_free (full_module_file_name);
}
static void
go_plugin_loader_module_unload_base (GOPluginLoader *loader, ErrorInfo **ret_error)
{
GOPluginLoaderModule *loader_module = GO_PLUGIN_LOADER_MODULE (loader);
GO_INIT_RET_ERROR_INFO (ret_error);
if (loader_module->plugin_shutdown != NULL) {
loader_module->plugin_shutdown (go_plugin_loader_get_plugin (loader), NULL);
}
if (!g_module_close (loader_module->handle)) {
*ret_error = error_info_new_printf (
_("Unable to close module file \"%s\"."),
loader_module->module_file_name);
error_info_add_details (*ret_error, error_info_new_str (g_module_error()));
}
loader_module->handle = NULL;
loader_module->plugin_init = NULL;
loader_module->plugin_shutdown = NULL;
}
static void
go_plugin_loader_module_init (GOPluginLoaderModule *loader_module)
{
g_return_if_fail (IS_GO_PLUGIN_LOADER_MODULE (loader_module));
loader_module->module_file_name = NULL;
loader_module->handle = NULL;
}
static void
go_plugin_loader_module_finalize (GObject *obj)
{
GOPluginLoaderModule *loader_module = GO_PLUGIN_LOADER_MODULE (obj);
g_free (loader_module->module_file_name);
loader_module->module_file_name = NULL;
G_OBJECT_CLASS (g_type_class_peek (G_TYPE_OBJECT))->finalize (obj);
}
static void
go_plugin_loader_module_class_init (GObjectClass *gobject_class)
{
gobject_class->finalize = go_plugin_loader_module_finalize;
go_plugin_loader_module_register_version ("goffice", GOFFICE_API_VERSION);
}
static void
go_plugin_loader_init (GOPluginLoaderClass *go_plugin_loader_class)
{
go_plugin_loader_class->set_attributes = go_plugin_loader_module_set_attributes;
go_plugin_loader_class->load_base = go_plugin_loader_module_load_base;
go_plugin_loader_class->unload_base = go_plugin_loader_module_unload_base;
go_plugin_loader_class->load_service_file_opener = go_plugin_loader_module_load_service_file_opener;
go_plugin_loader_class->load_service_file_saver = go_plugin_loader_module_load_service_file_saver;
go_plugin_loader_class->load_service_plugin_loader = go_plugin_loader_module_load_service_plugin_loader;
}
GSF_CLASS_FULL (GOPluginLoaderModule, go_plugin_loader_module,
NULL, NULL, go_plugin_loader_module_class_init, NULL,
go_plugin_loader_module_init, G_TYPE_OBJECT, 0,
GSF_INTERFACE (go_plugin_loader_init, GO_PLUGIN_LOADER_TYPE))
/*
* Service - file_opener
*/
typedef struct {
gboolean (*module_func_file_probe) (GOFileOpener const *fo, GsfInput *input,
FileProbeLevel pl);
void (*module_func_file_open) (GOFileOpener const *fo, IOContext *io_context,
gpointer FIXME_FIXME_workbook_view,
GsfInput *input);
} ServiceLoaderDataFileOpener;
static gboolean
go_plugin_loader_module_func_file_probe (GOFileOpener const *fo, GOPluginService *service,
GsfInput *input, FileProbeLevel pl)
{
ServiceLoaderDataFileOpener *loader_data;
g_return_val_if_fail (IS_GO_PLUGIN_SERVICE_FILE_OPENER (service), FALSE);
g_return_val_if_fail (input != NULL, FALSE);
loader_data = g_object_get_data (G_OBJECT (service), "loader_data");
return loader_data->module_func_file_probe (fo, input, pl);
}
static void
go_plugin_loader_module_func_file_open (GOFileOpener const *fo, GOPluginService *service,
IOContext *io_context,
gpointer FIXME_FIXME_workbook_view,
GsfInput *input)
{
ServiceLoaderDataFileOpener *loader_data;
g_return_if_fail (IS_GO_PLUGIN_SERVICE_FILE_OPENER (service));
g_return_if_fail (input != NULL);
loader_data = g_object_get_data (G_OBJECT (service), "loader_data");
loader_data->module_func_file_open (fo, io_context,
FIXME_FIXME_workbook_view, input);
}
static void
go_plugin_loader_module_load_service_file_opener (GOPluginLoader *loader,
GOPluginService *service,
ErrorInfo **ret_error)
{
GOPluginLoaderModule *loader_module = GO_PLUGIN_LOADER_MODULE (loader);
gchar *func_name_file_probe, *func_name_file_open;
gpointer module_func_file_probe = NULL, module_func_file_open = NULL;
g_return_if_fail (IS_GO_PLUGIN_SERVICE_FILE_OPENER (service));
GO_INIT_RET_ERROR_INFO (ret_error);
func_name_file_probe = g_strconcat (
plugin_service_get_id (service), "_file_probe", NULL);
g_module_symbol (loader_module->handle, func_name_file_probe, &module_func_file_probe);
func_name_file_open = g_strconcat (
plugin_service_get_id (service), "_file_open", NULL);
g_module_symbol (loader_module->handle, func_name_file_open, &module_func_file_open);
if (module_func_file_open != NULL) {
PluginServiceFileOpenerCallbacks *cbs;
ServiceLoaderDataFileOpener *loader_data;
cbs = plugin_service_get_cbs (service);
cbs->plugin_func_file_probe = go_plugin_loader_module_func_file_probe;
cbs->plugin_func_file_open = go_plugin_loader_module_func_file_open;
loader_data = g_new (ServiceLoaderDataFileOpener, 1);
loader_data->module_func_file_probe = module_func_file_probe;
loader_data->module_func_file_open = module_func_file_open;
g_object_set_data_full (
G_OBJECT (service), "loader_data", loader_data, g_free);
} else {
*ret_error = error_info_new_printf (
_("Module file \"%s\" has invalid format."),
loader_module->module_file_name);
error_info_add_details (*ret_error, error_info_new_printf (
_("File doesn't contain \"%s\" function."), func_name_file_open));
}
g_free (func_name_file_probe);
g_free (func_name_file_open);
}
/*
* Service - file_saver
*/
typedef struct {
void (*module_func_file_save) (GOFileSaver const *fs, IOContext *io_context,
gconstpointer FIXME_FIXME_workbook_view,
GsfOutput *output);
} ServiceLoaderDataFileSaver;
static void
go_plugin_loader_module_func_file_save (GOFileSaver const *fs, GOPluginService *service,
IOContext *io_context,
gconstpointer FIXME_FIXME_workbook_view,
GsfOutput *output)
{
ServiceLoaderDataFileSaver *loader_data;
g_return_if_fail (IS_GO_PLUGIN_SERVICE_FILE_SAVER (service));
g_return_if_fail (GSF_IS_OUTPUT (output));
loader_data = g_object_get_data (G_OBJECT (service), "loader_data");
loader_data->module_func_file_save (fs, io_context,
FIXME_FIXME_workbook_view, output);
}
static void
go_plugin_loader_module_load_service_file_saver (GOPluginLoader *loader,
GOPluginService *service,
ErrorInfo **ret_error)
{
GOPluginLoaderModule *loader_module = GO_PLUGIN_LOADER_MODULE (loader);
gchar *func_name_file_save;
gpointer module_func_file_save = NULL;
g_return_if_fail (IS_GO_PLUGIN_SERVICE_FILE_SAVER (service));
GO_INIT_RET_ERROR_INFO (ret_error);
func_name_file_save = g_strconcat (
plugin_service_get_id (service), "_file_save", NULL);
g_module_symbol (loader_module->handle, func_name_file_save, &module_func_file_save);
if (module_func_file_save != NULL) {
PluginServiceFileSaverCallbacks *cbs;
ServiceLoaderDataFileSaver *loader_data;
cbs = plugin_service_get_cbs (service);
cbs->plugin_func_file_save = go_plugin_loader_module_func_file_save;
loader_data = g_new (ServiceLoaderDataFileSaver, 1);
loader_data->module_func_file_save = module_func_file_save;
g_object_set_data_full (
G_OBJECT (service), "loader_data", loader_data, g_free);
} else {
*ret_error = error_info_new_printf (
_("Module file \"%s\" has invalid format."),
loader_module->module_file_name);
error_info_add_details (*ret_error, error_info_new_printf (
_("File doesn't contain \"%s\" function."),
func_name_file_save));
}
g_free (func_name_file_save);
}
/*
* Service - plugin_loader
*/
typedef struct {
GType (*module_func_get_loader_type) (ErrorInfo **ret_error);
} ServiceLoaderDataPluginLoader;
static GType
go_plugin_loader_module_func_get_loader_type (GOPluginService *service,
ErrorInfo **ret_error)
{
ServiceLoaderDataPluginLoader *loader_data;
ErrorInfo *error = NULL;
GType loader_type;
g_return_val_if_fail (IS_GO_PLUGIN_SERVICE_PLUGIN_LOADER (service), 0);
GO_INIT_RET_ERROR_INFO (ret_error);
loader_data = g_object_get_data (G_OBJECT (service), "loader_data");
loader_type = loader_data->module_func_get_loader_type (&error);
if (error == NULL) {
return loader_type;
} else {
*ret_error = error;
return (GType) 0;
}
}
static void
go_plugin_loader_module_load_service_plugin_loader (GOPluginLoader *loader,
GOPluginService *service,
ErrorInfo **ret_error)
{
GOPluginLoaderModule *loader_module = GO_PLUGIN_LOADER_MODULE (loader);
gchar *func_name_get_loader_type;
gpointer module_func_get_loader_type = NULL;
g_return_if_fail (IS_GO_PLUGIN_SERVICE_PLUGIN_LOADER (service));
GO_INIT_RET_ERROR_INFO (ret_error);
func_name_get_loader_type = g_strconcat (
plugin_service_get_id (service), "_get_loader_type", NULL);
g_module_symbol (loader_module->handle, func_name_get_loader_type,
&module_func_get_loader_type);
if (module_func_get_loader_type != NULL) {
PluginServicePluginLoaderCallbacks *cbs;
ServiceLoaderDataPluginLoader *loader_data;
cbs = plugin_service_get_cbs (service);
cbs->plugin_func_get_loader_type = go_plugin_loader_module_func_get_loader_type;
loader_data = g_new (ServiceLoaderDataPluginLoader, 1);
loader_data->module_func_get_loader_type = module_func_get_loader_type;
g_object_set_data_full (G_OBJECT (service),
"loader_data", loader_data, g_free);
} else
*ret_error = error_info_new_printf (
_("Module doesn't contain \"%s\" function."),
func_name_get_loader_type);
g_free (func_name_get_loader_type);
}

View File

@ -0,0 +1,33 @@
#ifndef GO_PLUGIN_LOADER_MODULE_H
#define GO_PLUGIN_LOADER_MODULE_H
#include <goffice/app/goffice-app.h>
#include <glib-object.h>
#include <gmodule.h>
G_BEGIN_DECLS
#define GO_PLUGIN_LOADER_MODULE_TYPE (go_plugin_loader_module_get_type ())
#define GO_PLUGIN_LOADER_MODULE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_PLUGIN_LOADER_MODULE_TYPE, GOPluginLoaderModule))
#define IS_GO_PLUGIN_LOADER_MODULE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_PLUGIN_LOADER_MODULE_TYPE))
#define GO_PLUGIN_LOADER_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GO_PLUGIN_LOADER_MODULE_TYPE, GOPluginLoaderModuleClass))
#define IS_GO_PLUGIN_LOADER_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GO_PLUGIN_LOADER_MODULE_TYPE))
typedef struct {
GObject base;
gchar *module_file_name;
GModule *handle;
void (*plugin_init) (GOPlugin *plugin, GOCmdContext *cc);
void (*plugin_shutdown) (GOPlugin *plugin, GOCmdContext *cc);
} GOPluginLoaderModule;
typedef GObjectClass GOPluginLoaderModuleClass;
GType go_plugin_loader_module_get_type (void);
void go_plugin_loader_module_register_version (char const *id, char const *ver);
G_END_DECLS
#endif /* GO_PLUGIN_LOADER_MODULE_H */

View File

@ -0,0 +1,181 @@
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* go-plugin-loader.c: Base class for plugin loaders.
*
* Author: Zbigniew Chyla (cyba@gnome.pl)
*/
#include <goffice/goffice-config.h>
#include <goffice/app/go-plugin-loader.h>
#include <goffice/app/go-plugin.h>
#include <goffice/app/go-plugin-service.h>
#include <goffice/app/error-info.h>
#include <gsf/gsf-impl-utils.h>
#include <glib/gi18n.h>
#define PL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), GO_PLUGIN_LOADER_TYPE, GOPluginLoaderClass))
gboolean
go_plugin_loader_is_base_loaded (GOPluginLoader *loader)
{
return g_object_get_data (G_OBJECT (loader), "is-base-loaded") != NULL;
}
GOPlugin *
go_plugin_loader_get_plugin (GOPluginLoader *l)
{
return g_object_get_data (G_OBJECT (l), "plugin");
}
void
go_plugin_loader_set_plugin (GOPluginLoader *l, GOPlugin *p)
{
g_object_set_data (G_OBJECT (l), "plugin", p);
}
void
go_plugin_loader_set_attributes (GOPluginLoader *loader, GHashTable *attrs,
ErrorInfo **err)
{
g_return_if_fail (IS_GO_PLUGIN_LOADER (loader));
GO_INIT_RET_ERROR_INFO (err);
if (PL_GET_CLASS (loader)->set_attributes)
PL_GET_CLASS (loader)->set_attributes (loader, attrs, err);
else
*err = error_info_new_printf (_("Loader has no set_attributes method.\n"));
}
void
go_plugin_loader_load_base (GOPluginLoader *loader, ErrorInfo **err)
{
GOPluginLoaderClass *go_plugin_loader_class;
g_return_if_fail (IS_GO_PLUGIN_LOADER (loader));
g_return_if_fail (!go_plugin_loader_is_base_loaded (loader));
go_plugin_loader_class = PL_GET_CLASS (loader);
if (go_plugin_loader_class->load_base != NULL)
go_plugin_loader_class->load_base (loader, err);
else
*err = error_info_new_printf (_("Loader has no load_base method.\n"));
if (*err == NULL)
g_object_set_data (G_OBJECT (loader), "is-base-loaded", GINT_TO_POINTER (1));
}
void
go_plugin_loader_unload_base (GOPluginLoader *loader, ErrorInfo **err)
{
GOPluginLoaderClass *go_plugin_loader_class;
g_return_if_fail (IS_GO_PLUGIN_LOADER (loader));
go_plugin_loader_class = PL_GET_CLASS (loader);
if (go_plugin_loader_class->unload_base != NULL) {
go_plugin_loader_class->unload_base (loader, err);
if (*err == NULL)
g_object_set_data (G_OBJECT (loader), "is-base-loaded", NULL);
}
}
void
go_plugin_loader_load_service (GOPluginLoader *l, GOPluginService *s, ErrorInfo **err)
{
GOPluginLoaderClass *klass;
void (*load_service_method) (GOPluginLoader *, GOPluginService *, ErrorInfo **) = NULL;
g_return_if_fail (IS_GO_PLUGIN_LOADER (l));
g_return_if_fail (IS_GO_PLUGIN_SERVICE (s));
g_return_if_fail (go_plugin_loader_is_base_loaded (l));
GO_INIT_RET_ERROR_INFO (err);
klass = PL_GET_CLASS (l);
if (klass->service_load && (klass->service_load) (l, s, err))
return;
if (IS_GO_PLUGIN_SERVICE_FILE_OPENER (s)) {
load_service_method = klass->load_service_file_opener;
} else if (IS_GO_PLUGIN_SERVICE_FILE_SAVER (s)) {
load_service_method = klass->load_service_file_saver;
} else if (IS_GO_PLUGIN_SERVICE_PLUGIN_LOADER (s)) {
load_service_method = klass->load_service_plugin_loader;
} else if (IS_GO_PLUGIN_SERVICE_SIMPLE (s)) {
load_service_method = NULL;
} else {
*err = error_info_new_printf (_("Service '%s' not supported by l."),
G_OBJECT_TYPE_NAME (s));
}
if (load_service_method != NULL)
load_service_method (l, s, err);
if (*err == NULL) {
gpointer num_services = g_object_get_data (G_OBJECT (l), "num-services");
g_object_set_data (G_OBJECT (l), "num-services",
GINT_TO_POINTER (GPOINTER_TO_INT (num_services) + 1));;
}
}
void
go_plugin_loader_unload_service (GOPluginLoader *l, GOPluginService *s, ErrorInfo **err)
{
GOPluginLoaderClass *klass;
void (*unload_service_method) (GOPluginLoader *, GOPluginService *, ErrorInfo **) = NULL;
ErrorInfo *error = NULL;
g_return_if_fail (IS_GO_PLUGIN_LOADER (l));
g_return_if_fail (IS_GO_PLUGIN_SERVICE (s));
GO_INIT_RET_ERROR_INFO (err);
klass = PL_GET_CLASS (l);
if (klass->service_unload && (klass->service_unload) (l, s, err))
return;
if (IS_GO_PLUGIN_SERVICE_FILE_OPENER (s)) {
unload_service_method = klass->unload_service_file_opener;
} else if (IS_GO_PLUGIN_SERVICE_FILE_SAVER (s)) {
unload_service_method = klass->unload_service_file_saver;
} else if (IS_GO_PLUGIN_SERVICE_PLUGIN_LOADER (s)) {
unload_service_method = klass->unload_service_plugin_loader;
} else if (IS_GO_PLUGIN_SERVICE_SIMPLE (s)) {
unload_service_method = NULL;
} else
*err = error_info_new_printf (_("Service '%s' not supported by l."),
G_OBJECT_TYPE_NAME (s));
if (unload_service_method != NULL)
unload_service_method (l, s, &error);
if (error == NULL) {
gpointer num_services = g_object_get_data (G_OBJECT (l), "num-services");
g_return_if_fail (num_services != NULL);
g_object_set_data (G_OBJECT (l), "num-services",
GINT_TO_POINTER (GPOINTER_TO_INT (num_services) - 1));;
if (GPOINTER_TO_INT (num_services) == 1) {
go_plugin_loader_unload_base (l, &error);
error_info_free (error);
}
} else
*err = error;
}
GType
go_plugin_loader_get_type (void)
{
static GType go_plugin_loader_type = 0;
if (!go_plugin_loader_type) {
static GTypeInfo const go_plugin_loader_info = {
sizeof (GOPluginLoaderClass), /* class_size */
NULL, /* base_init */
NULL, /* base_finalize */
};
go_plugin_loader_type = g_type_register_static (G_TYPE_INTERFACE,
"GOPluginLoader", &go_plugin_loader_info, 0);
}
return go_plugin_loader_type;
}

View File

@ -0,0 +1,50 @@
#ifndef GO_PLUGIN_LOADER_H
#define GO_PLUGIN_LOADER_H
#include <glib.h>
#include <glib-object.h>
#include <libxml/tree.h>
#include <goffice/app/go-plugin.h>
#include <goffice/app/goffice-app.h>
G_BEGIN_DECLS
#define GO_PLUGIN_LOADER_TYPE (go_plugin_loader_get_type ())
#define GO_PLUGIN_LOADER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_PLUGIN_LOADER_TYPE, GOPluginLoader))
#define IS_GO_PLUGIN_LOADER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_PLUGIN_LOADER_TYPE))
#define GO_PLUGIN_LOADER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GO_PLUGIN_LOADER_TYPE, GOPluginLoaderClass))
#define IS_GO_PLUGIN_LOADER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GO_PLUGIN_LOADER_TYPE))
typedef struct {
GTypeInterface base;
void (*load_base) (GOPluginLoader *l, ErrorInfo **err);
void (*unload_base) (GOPluginLoader *l, ErrorInfo **err);
void (*set_attributes) (GOPluginLoader *l, GHashTable *attrs, ErrorInfo **err);
gboolean (*service_load) (GOPluginLoader *l, GOPluginService *s, ErrorInfo **err);
gboolean (*service_unload) (GOPluginLoader *l, GOPluginService *s, ErrorInfo **err);
void (*load_service_file_opener) (GOPluginLoader *l, GOPluginService *s, ErrorInfo **err);
void (*unload_service_file_opener) (GOPluginLoader *l, GOPluginService *s, ErrorInfo **err);
void (*load_service_file_saver) (GOPluginLoader *l, GOPluginService *s, ErrorInfo **err);
void (*unload_service_file_saver) (GOPluginLoader *l, GOPluginService *s, ErrorInfo **err);
void (*load_service_plugin_loader) (GOPluginLoader *l, GOPluginService *s, ErrorInfo **err);
void (*unload_service_plugin_loader) (GOPluginLoader *l, GOPluginService *s, ErrorInfo **err);
} GOPluginLoaderClass;
GType go_plugin_loader_get_type (void);
void go_plugin_loader_set_attributes (GOPluginLoader *l, GHashTable *attrs,
ErrorInfo **err);
GOPlugin *go_plugin_loader_get_plugin (GOPluginLoader *l);
void go_plugin_loader_set_plugin (GOPluginLoader *l, GOPlugin *p);
void go_plugin_loader_load_base (GOPluginLoader *l, ErrorInfo **err);
void go_plugin_loader_unload_base (GOPluginLoader *l, ErrorInfo **err);
void go_plugin_loader_load_service (GOPluginLoader *l, GOPluginService *s, ErrorInfo **err);
void go_plugin_loader_unload_service (GOPluginLoader *l, GOPluginService *s, ErrorInfo **err);
gboolean go_plugin_loader_is_base_loaded (GOPluginLoader *l);
G_END_DECLS
#endif /* GO_PLUGIN_LOADER_H */

View File

@ -16,24 +16,24 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_GRAPH_ITEM_IMPL_H
#define GO_GRAPH_ITEM_IMPL_H
#ifndef GO_PLUGIN_SERVICE_IMPL_H
#define GO_PLUGIN_SERVICE_IMPL_H
#include "gnumeric.h"
#include "plugin-service.h"
#include <goffice/app/goffice-app.h>
#include <glib-object.h>
#include <libxml/tree.h>
G_BEGIN_DECLS
struct _GnmPluginService {
struct _GOPluginService {
GObject g_object;
char *id;
GnmPlugin *plugin;
GOPlugin *plugin;
gboolean is_loaded;
/* protected */
@ -47,36 +47,36 @@ struct _GnmPluginService {
typedef struct{
GObjectClass g_object_class;
void (*read_xml) (GnmPluginService *service, xmlNode *tree, ErrorInfo **ret_error);
void (*activate) (GnmPluginService *service, ErrorInfo **ret_error);
void (*deactivate) (GnmPluginService *service, ErrorInfo **ret_error);
char *(*get_description) (GnmPluginService *service);
} GnmPluginServiceClass;
void (*read_xml) (GOPluginService *service, xmlNode *tree, ErrorInfo **ret_error);
void (*activate) (GOPluginService *service, ErrorInfo **ret_error);
void (*deactivate) (GOPluginService *service, ErrorInfo **ret_error);
char *(*get_description) (GOPluginService *service);
} GOPluginServiceClass;
#define GPS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNM_PLUGIN_SERVICE_TYPE, GnmPluginServiceClass))
#define GPS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GO_PLUGIN_SERVICE_TYPE, GOPluginServiceClass))
#define GPS_GET_CLASS(o) GPS_CLASS (G_OBJECT_GET_CLASS (o))
typedef struct{
GnmPluginServiceClass plugin_service_class;
GOPluginServiceClass plugin_service_class;
GHashTable *pending; /* has service instances by type names */
} PluginServiceGObjectLoaderClass;
struct _PluginServiceGObjectLoader {
GnmPluginService plugin_service;
GOPluginService plugin_service;
};
#define GPS_GOBJECT_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNM_PLUGIN_SERVICE_TYPE, PluginServiceGObjectLoaderClass))
#define GPS_GOBJECT_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GO_PLUGIN_SERVICE_TYPE, PluginServiceGObjectLoaderClass))
#define GPS_GOBJECT_LOADER_GET_CLASS(o) GPS_GOBJECT_LOADER_CLASS (G_OBJECT_GET_CLASS (o))
typedef struct{
GnmPluginServiceClass plugin_service_class;
GOPluginServiceClass plugin_service_class;
} PluginServiceSimpleClass;
struct _PluginServiceSimple {
GnmPluginService plugin_service;
GOPluginService plugin_service;
};
G_END_DECLS
#endif /* GO_GRAPH_ITEM_IMPL_H */
#endif /* GO_PLUGIN_SERVICE_IMPL_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,112 @@
#ifndef PLUGIN_SERVICE_H
#define PLUGIN_SERVICE_H
#include <goffice/app/goffice-app.h>
#include <goffice/app/go-plugin.h>
#include <glib.h>
#include <gmodule.h>
#include <libxml/tree.h>
#include <gsf/gsf.h>
G_BEGIN_DECLS
#define GO_PLUGIN_SERVICE_TYPE (plugin_service_get_type ())
#define GO_PLUGIN_SERVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_PLUGIN_SERVICE_TYPE, GOPluginService))
#define IS_GO_PLUGIN_SERVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_PLUGIN_SERVICE_TYPE))
GType plugin_service_get_type (void);
#define GO_PLUGIN_SERVICE_GENERAL_TYPE (plugin_service_general_get_type ())
#define GO_PLUGIN_SERVICE_GENERAL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_PLUGIN_SERVICE_GENERAL_TYPE, PluginServiceGeneral))
#define IS_GO_PLUGIN_SERVICE_GENERAL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_PLUGIN_SERVICE_GENERAL_TYPE))
GType plugin_service_general_get_type (void);
typedef struct _PluginServiceGeneral PluginServiceGeneral;
typedef struct {
void (*plugin_func_init) (GOPluginService *service, ErrorInfo **ret_error);
void (*plugin_func_cleanup) (GOPluginService *service, ErrorInfo **ret_error);
} PluginServiceGeneralCallbacks;
#define GO_PLUGIN_SERVICE_FILE_OPENER_TYPE (plugin_service_file_opener_get_type ())
#define GO_PLUGIN_SERVICE_FILE_OPENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_PLUGIN_SERVICE_FILE_OPENER_TYPE, PluginServiceFileOpener))
#define IS_GO_PLUGIN_SERVICE_FILE_OPENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_PLUGIN_SERVICE_FILE_OPENER_TYPE))
GType plugin_service_file_opener_get_type (void);
typedef struct _PluginServiceFileOpener PluginServiceFileOpener;
typedef struct {
/* plugin_func_file_probe may be NULL */
gboolean (*plugin_func_file_probe) (
GOFileOpener const *fo, GOPluginService *service,
GsfInput *input, FileProbeLevel pl);
void (*plugin_func_file_open) (
GOFileOpener const *fo, GOPluginService *service,
IOContext *io_context, gpointer fixme_workbook_view,
GsfInput *input);
} PluginServiceFileOpenerCallbacks;
#define GO_PLUGIN_SERVICE_FILE_SAVER_TYPE (plugin_service_file_saver_get_type ())
#define GO_PLUGIN_SERVICE_FILE_SAVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_PLUGIN_SERVICE_FILE_SAVER_TYPE, PluginServiceFileSaver))
#define IS_GO_PLUGIN_SERVICE_FILE_SAVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_PLUGIN_SERVICE_FILE_SAVER_TYPE))
GType plugin_service_file_saver_get_type (void);
typedef struct _PluginServiceFileSaver PluginServiceFileSaver;
typedef struct {
void (*plugin_func_file_save) (
GOFileSaver const *fs, GOPluginService *service,
IOContext *io_context, gconstpointer fixme_workbook_view,
GsfOutput *output);
} PluginServiceFileSaverCallbacks;
#define GO_PLUGIN_SERVICE_PLUGIN_LOADER_TYPE (plugin_service_plugin_loader_get_type ())
#define GO_PLUGIN_SERVICE_PLUGIN_LOADER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_PLUGIN_SERVICE_PLUGIN_LOADER_TYPE, PluginServicePluginLoader))
#define IS_GO_PLUGIN_SERVICE_PLUGIN_LOADER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_PLUGIN_SERVICE_PLUGIN_LOADER_TYPE))
GType plugin_service_plugin_loader_get_type (void);
typedef struct _PluginServicePluginLoader PluginServicePluginLoader;
typedef struct {
GType (*plugin_func_get_loader_type) (
GOPluginService *service, ErrorInfo **ret_error);
} PluginServicePluginLoaderCallbacks;
GType plugin_service_plugin_loader_generate_type (GOPluginService *service,
ErrorInfo **ret_error);
/****************************************************************************/
#define GO_PLUGIN_SERVICE_GOBJECT_LOADER_TYPE (plugin_service_gobject_loader_get_type ())
#define GO_PLUGIN_SERVICE_GOBJECT_LOADER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_PLUGIN_SERVICE_GOBJECT_LOADER_TYPE, PluginServiceGObjectLoader))
#define IS_GO_PLUGIN_SERVICE_GOBJECT_LOADER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_PLUGIN_SERVICE_GOBJECT_LOADER_TYPE))
GType plugin_service_gobject_loader_get_type (void);
typedef struct _PluginServiceGObjectLoader PluginServiceGObjectLoader;
/****************************************************************************/
#define GO_PLUGIN_SERVICE_SIMPLE_TYPE (plugin_service_simple_get_type ())
#define GO_PLUGIN_SERVICE_SIMPLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_PLUGIN_SERVICE_SIMPLE_TYPE, PluginServiceSimple))
#define IS_GO_PLUGIN_SERVICE_SIMPLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_PLUGIN_SERVICE_SIMPLE_TYPE))
GType plugin_service_simple_get_type (void);
typedef struct _PluginServiceSimple PluginServiceSimple;
/****************************************************************************/
GOPluginService *plugin_service_new (GOPlugin *plugin, xmlNode *tree, ErrorInfo **ret_error);
char const *plugin_service_get_id (GOPluginService *service);
char const *plugin_service_get_description (GOPluginService *service);
GOPlugin *plugin_service_get_plugin (GOPluginService *service);
gpointer plugin_service_get_cbs (GOPluginService *service);
void plugin_service_activate (GOPluginService *service, ErrorInfo **ret_error);
void plugin_service_deactivate (GOPluginService *service, ErrorInfo **ret_error);
void plugin_service_load (GOPluginService *service, ErrorInfo **ret_error);
void plugin_service_unload (GOPluginService *service, ErrorInfo **ret_error);
typedef GType (*GOPluginServiceCreate) (void);
void plugin_services_init (void);
void plugin_services_shutdown (void);
void plugin_service_define (char const *type_str,
GOPluginServiceCreate ctor);
G_END_DECLS
#endif /* PLUGIN_SERVICE_H */

View File

@ -0,0 +1,67 @@
#ifndef GO_PLUGIN_H
#define GO_PLUGIN_H
#include <goffice/app/goffice-app.h>
#include <glib-object.h>
G_BEGIN_DECLS
/*
* Use "#define PLUGIN_DEBUG x" to enable some plugin related debugging
* messages.
#undef PLUGIN_DEBUG
* Define PLUGIN_ALWAYS_LOAD to disable loading on demand feature
*/
#define GO_PLUGIN_TYPE (go_plugin_get_type ())
#define GO_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_PLUGIN_TYPE, GOPlugin))
#define IS_GO_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_PLUGIN_TYPE))
GType go_plugin_get_type (void);
void go_plugin_activate (GOPlugin *plugin, ErrorInfo **ret_error);
void go_plugin_deactivate (GOPlugin *plugin, ErrorInfo **ret_error);
gboolean go_plugin_is_active (GOPlugin *plugin);
gboolean go_plugin_can_deactivate (GOPlugin *plugin);
void go_plugin_load_service (GOPlugin *plugin, GOPluginService *service, ErrorInfo **ret_error);
void go_plugin_unload_service (GOPlugin *plugin, GOPluginService *service, ErrorInfo **ret_error);
gboolean go_plugin_is_loaded (GOPlugin *plugin);
void go_plugin_use_ref (GOPlugin *plugin);
void go_plugin_use_unref (GOPlugin *plugin);
GTypeModule *go_plugin_get_type_module (GOPlugin *plugin);
char const *go_plugin_get_dir_name (GOPlugin *plugin);
char const *go_plugin_get_id (GOPlugin *plugin);
char const *go_plugin_get_name (GOPlugin *plugin);
char const *go_plugin_get_description (GOPlugin *plugin);
char const *go_plugin_get_textdomain (GOPlugin *plugin);
GSList *go_plugin_get_services (GOPlugin *plugin);
GSList *go_plugin_get_dependencies_ids (GOPlugin *plugin);
/*
*
*/
void go_plugins_init (GOCmdContext *context,
GSList const *known_states,
GSList const *active_plugins,
GSList *plugin_dirs,
gboolean activate_new_plugins,
GType default_loader_type);
GSList *go_plugins_shutdown (void);
void go_plugins_register_loader (const gchar *id_str, GOPluginService *service);
void go_plugins_unregister_loader (const gchar *id_str);
GOPlugin *go_plugins_get_plugin_by_id (const gchar *plugin_id);
GSList *go_plugins_get_available_plugins (void);
GSList *go_plugins_get_active_plugins (void);
void go_plugins_rescan (ErrorInfo **ret_error, GSList **ret_new_plugins);
char *go_plugins_get_plugin_dir (void);
void go_plugin_db_mark_plugin_for_deactivation (GOPlugin *plugin, gboolean mark);
gboolean go_plugin_db_is_plugin_marked_for_deactivation (GOPlugin *plugin);
void go_plugin_db_activate_plugin_list (GSList *plugins, ErrorInfo **ret_error);
void go_plugin_db_deactivate_plugin_list (GSList *plugins, ErrorInfo **ret_error);
G_END_DECLS
#endif /* GO_PLUGIN_H */

View File

@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/

View File

@ -0,0 +1,2 @@
#include <goffice/goffice-config.h>
#include "go-service.h"

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_SERVICE_H
@ -24,6 +24,8 @@
#include <goffice/app/goffice-app.h>
#include <glib-object.h>
G_BEGIN_DECLS
#define GO_SERVICE_TYPE (go_service_get_type ())
#define GO_SERVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_SERVICE_TYPE, GOService))
#define IS_GO_SERVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_SERVICE_TYPE))
@ -37,4 +39,6 @@ GOPlugin *go_service_get_plugin (GOService const *service);
typedef struct _GOServiceSimple GOServiceSimple;
GType go_service_simple_get_type (void);
G_END_DECLS
#endif /* GO_SERVICE_H */

View File

@ -0,0 +1,62 @@
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* goffice-app.h:
*
* Copyright (C) 2004 Jody Goldberg (jody@gnome.org)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GOFFICE_APP_H
#define GOFFICE_APP_H
#include <glib/gmacros.h>
G_BEGIN_DECLS
typedef struct _GOApp GOApp;
typedef struct _GODoc GODoc;
typedef struct _GODocControl GODocControl;
typedef struct _GOCmdContext GOCmdContext;
typedef struct _GOPlugin GOPlugin;
typedef struct _GOPluginService GOPluginService;
typedef struct _GOPluginLoader GOPluginLoader;
/* temporary */
typedef struct _ErrorInfo ErrorInfo;
typedef struct _GOFileSaver GOFileSaver;
typedef struct _GOFileOpener GOFileOpener;
typedef struct _IOContext IOContext;
/*
* File probe level tells file opener (its probe method to be exact), how
* hard it should try to recognize the type of the file. File openers may
* ignore this or support only some probe levels, but if specifies
* "reccomened" behaviour.
* Before opening any file we detect its type by calling probe for
* every registered file opener (in order of priority) and passing
* FILE_PROBE_FILE_NAME as probe level. If none of them recogizes the file,
* we increase probe level and try again...
*/
typedef enum {
FILE_PROBE_FILE_NAME, /* Test only file name, don't read file contents */
FILE_PROBE_CONTENT, /* Read the whole file if it's necessary */
FILE_PROBE_LAST
} FileProbeLevel;
G_END_DECLS
#endif /* GOFFICE_GRAPH_H */

View File

@ -1,27 +1,24 @@
#ifndef GNUMERIC_IO_CONTEXT_PRIV_H
#define GNUMERIC_IO_CONTEXT_PRIV_H
#ifndef GO_IO_CONTEXT_PRIV_H
#define GO_IO_CONTEXT_PRIV_H
#include "gnumeric.h"
#include "io-context.h"
#include "error-info.h"
#include "command-context-priv.h"
#include <stdio.h>
#include <goffice/app/io-context.h>
#include <goffice/app/error-info.h>
#include <goffice/app/go-cmd-context-impl.h>
G_BEGIN_DECLS
#define IO_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_IO_CONTEXT, IOContextClass))
#define IS_IO_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_IO_CONTEXT))
typedef enum {
GNM_PROGRESS_HELPER_NONE,
GNM_PROGRESS_HELPER_FILE,
GNM_PROGRESS_HELPER_MEM,
GNM_PROGRESS_HELPER_COUNT,
GNM_PROGRESS_HELPER_VALUE,
GNM_PROGRESS_HELPER_WORKBOOK,
GNM_PROGRESS_HELPER_LAST
} GnmProgressHelperType;
GO_PROGRESS_HELPER_NONE,
GO_PROGRESS_HELPER_COUNT,
GO_PROGRESS_HELPER_VALUE,
GO_PROGRESS_HELPER_LAST
} GOProgressHelperType;
typedef struct {
GnmProgressHelperType helper_type;
GOProgressHelperType helper_type;
union {
struct {
gchar *start;
@ -40,7 +37,7 @@ typedef struct {
gint step;
} workbook;
} v;
} GnmProgressHelper;
} GOProgressHelper;
typedef struct {
gfloat min, max;
@ -49,7 +46,7 @@ typedef struct {
struct _IOContext {
GObject base;
GnmCmdContext *impl;
GOCmdContext *impl;
ErrorInfo *info;
gboolean error_occurred;
gboolean warning_occurred;
@ -58,7 +55,7 @@ struct _IOContext {
gfloat progress_min, progress_max;
gdouble last_progress;
gdouble last_time;
GnmProgressHelper helper;
GOProgressHelper helper;
};
struct _IOContextClass {
@ -67,4 +64,6 @@ struct _IOContextClass {
void (*processing_file) (IOContext *ioc, char const *name);
};
#endif /* GNUMERIC_IO_CONTEXT_PRIV_H */
G_END_DECLS
#endif /* GO_IO_CONTEXT_PRIV_H */

View File

@ -9,17 +9,12 @@
* Jody Goldberg <jody@gnome.org>
* Zbigniew Chyla <cyba@gnome.pl>
*
* (C) 2000-2002 Jody Goldberg
* (C) 2000-2005 Jody Goldberg
*/
#include <config.h>
#include "gnumeric.h"
#include <goffice/goffice-config.h>
#include "io-context-priv.h"
//#include "sheet.h"
//#include "workbook.h"
#include "command-context.h"
#include "gui-util.h"
#include "go-cmd-context.h"
#include <goffice/utils/go-file.h>
#include <gsf/gsf-impl-utils.h>
#include <gtk/gtkmain.h>
@ -42,7 +37,7 @@ io_context_init (IOContext *ioc)
ioc->progress_max = 1.0;
ioc->last_progress = -1.0;
ioc->last_time = 0.0;
ioc->helper.helper_type = GNM_PROGRESS_HELPER_NONE;
ioc->helper.helper_type = GO_PROGRESS_HELPER_NONE;
}
static void
@ -55,8 +50,8 @@ ioc_finalize (GObject *obj)
ioc = IO_CONTEXT (obj);
error_info_free (ioc->info);
if (ioc->impl) {
cmd_context_progress_set (ioc->impl, 0.0);
cmd_context_progress_message_set (ioc->impl, NULL);
go_cmd_context_progress_set (ioc->impl, 0.0);
go_cmd_context_progress_message_set (ioc->impl, NULL);
g_object_unref (G_OBJECT (ioc->impl));
}
@ -64,26 +59,26 @@ ioc_finalize (GObject *obj)
}
static char *
ioc_get_password (GnmCmdContext *cc, char const *filename)
ioc_get_password (GOCmdContext *cc, char const *filename)
{
IOContext *ioc = (IOContext *)cc;
return gnm_cmd_context_get_password (ioc->impl, filename);
return go_cmd_context_get_password (ioc->impl, filename);
}
static void
ioc_set_sensitive (GnmCmdContext *cc, gboolean sensitive)
ioc_set_sensitive (GOCmdContext *cc, gboolean sensitive)
{
(void)cc; (void)sensitive;
}
static void
ioc_error_error (GnmCmdContext *cc, GError *err)
ioc_error_error (GOCmdContext *cc, GError *err)
{
gnumeric_io_error_string (IO_CONTEXT (cc), err->message);
}
static void
ioc_error_error_info (G_GNUC_UNUSED GnmCmdContext *ctxt,
ioc_error_error_info (G_GNUC_UNUSED GOCmdContext *ctxt,
ErrorInfo *error)
{
/* TODO what goes here */
@ -103,7 +98,7 @@ gnumeric_io_error_string (IOContext *context, const gchar *str)
}
static void
io_context_gnm_cmd_context_init (GnmCmdContextClass *cc_class)
io_context_gnm_cmd_context_init (GOCmdContextClass *cc_class)
{
cc_class->get_password = ioc_get_password;
cc_class->set_sensitive = ioc_set_sensitive;
@ -117,16 +112,16 @@ io_context_class_init (GObjectClass *klass)
}
GSF_CLASS_FULL (IOContext, io_context,
io_context_class_init, io_context_init,
G_TYPE_OBJECT, 0,
GSF_INTERFACE (io_context_gnm_cmd_context_init, GNM_CMD_CONTEXT_TYPE))
NULL, NULL, io_context_class_init, NULL,
io_context_init, G_TYPE_OBJECT, 0,
GSF_INTERFACE (io_context_gnm_cmd_context_init, GO_CMD_CONTEXT_TYPE))
IOContext *
gnumeric_io_context_new (GnmCmdContext *cc)
gnumeric_io_context_new (GOCmdContext *cc)
{
IOContext *ioc;
g_return_val_if_fail (IS_GNM_CMD_CONTEXT (cc), NULL);
g_return_val_if_fail (IS_GO_CMD_CONTEXT (cc), NULL);
ioc = g_object_new (TYPE_IO_CONTEXT, NULL);
/* The cc is optional for subclasses, but mandatory in this class. */
@ -169,7 +164,7 @@ gnumeric_io_error_push (IOContext *context, ErrorInfo *error)
void
gnumeric_io_error_display (IOContext *context)
{
GnmCmdContext *cc;
GOCmdContext *cc;
g_return_if_fail (context != NULL);
@ -177,8 +172,8 @@ gnumeric_io_error_display (IOContext *context)
if (context->impl)
cc = context->impl;
else
cc = GNM_CMD_CONTEXT (context);
gnm_cmd_context_error_info (cc, context->info);
cc = GO_CMD_CONTEXT (context);
go_cmd_context_error_info (cc, context->info);
}
}
@ -227,13 +222,13 @@ io_progress_update (IOContext *ioc, gdouble f)
(void) g_get_current_time (&tv);
t = tv.tv_sec + tv.tv_usec / 1000000.0;
if (at_end || t - ioc->last_time >= PROGRESS_UPDATE_PERIOD_SEC) {
GnmCmdContext *cc;
GOCmdContext *cc;
if (ioc->impl)
cc = ioc->impl;
else
cc = GNM_CMD_CONTEXT (ioc);
cmd_context_progress_set (cc, f);
cc = GO_CMD_CONTEXT (ioc);
go_cmd_context_progress_set (cc, f);
ioc->last_time = t;
ioc->last_progress = f;
}
@ -247,15 +242,15 @@ io_progress_update (IOContext *ioc, gdouble f)
void
io_progress_message (IOContext *ioc, const gchar *msg)
{
GnmCmdContext *cc;
GOCmdContext *cc;
g_return_if_fail (IS_IO_CONTEXT (ioc));
if (ioc->impl)
cc = ioc->impl;
else
cc = GNM_CMD_CONTEXT (ioc);
cmd_context_progress_message_set (cc, msg);
cc = GO_CMD_CONTEXT (ioc);
go_cmd_context_progress_message_set (cc, msg);
}
void
@ -313,7 +308,7 @@ value_io_progress_set (IOContext *ioc, gint total, gint step)
g_return_if_fail (IS_IO_CONTEXT (ioc));
g_return_if_fail (total >= 0);
ioc->helper.helper_type = GNM_PROGRESS_HELPER_VALUE;
ioc->helper.helper_type = GO_PROGRESS_HELPER_VALUE;
ioc->helper.v.value.total = MAX (total, 1);
ioc->helper.v.value.last = -step;
ioc->helper.v.value.step = step;
@ -326,7 +321,7 @@ value_io_progress_update (IOContext *ioc, gint value)
gint step, total;
g_return_if_fail (IS_IO_CONTEXT (ioc));
g_return_if_fail (ioc->helper.helper_type == GNM_PROGRESS_HELPER_VALUE);
g_return_if_fail (ioc->helper.helper_type == GO_PROGRESS_HELPER_VALUE);
total = ioc->helper.v.value.total;
step = ioc->helper.v.value.step;
@ -347,7 +342,7 @@ count_io_progress_set (IOContext *ioc, gint total, gint step)
g_return_if_fail (IS_IO_CONTEXT (ioc));
g_return_if_fail (total >= 0);
ioc->helper.helper_type = GNM_PROGRESS_HELPER_COUNT;
ioc->helper.helper_type = GO_PROGRESS_HELPER_COUNT;
ioc->helper.v.count.total = MAX (total, 1);
ioc->helper.v.count.last = -step;
ioc->helper.v.count.current = 0;
@ -361,7 +356,7 @@ count_io_progress_update (IOContext *ioc, gint inc)
gint current, step, total;
g_return_if_fail (IS_IO_CONTEXT (ioc));
g_return_if_fail (ioc->helper.helper_type == GNM_PROGRESS_HELPER_COUNT);
g_return_if_fail (ioc->helper.helper_type == GO_PROGRESS_HELPER_COUNT);
current = (ioc->helper.v.count.current += inc);
step = ioc->helper.v.count.step;
@ -376,57 +371,12 @@ count_io_progress_update (IOContext *ioc, gint inc)
io_progress_update (ioc, complete);
}
#if 0
void
workbook_io_progress_set (IOContext *ioc, Workbook const *wb, gint step)
{
gint n = 0;
GList *sheets, *l;
g_return_if_fail (IS_IO_CONTEXT (ioc));
g_return_if_fail (IS_WORKBOOK (wb));
sheets = workbook_sheets (wb);
for (l = sheets; l != NULL; l = l->next) {
Sheet *sheet = l->data;
n += g_hash_table_size (sheet->cell_hash);
}
g_list_free (sheets);
ioc->helper.helper_type = GNM_PROGRESS_HELPER_WORKBOOK;
ioc->helper.v.workbook.n_elements = MAX (n, 1);
ioc->helper.v.workbook.last = -step;
ioc->helper.v.workbook.current = 0;
ioc->helper.v.workbook.step = step;
}
void
workbook_io_progress_update (IOContext *ioc, gint inc)
{
gdouble complete;
g_return_if_fail (IS_IO_CONTEXT (ioc));
g_return_if_fail (ioc->helper.helper_type == GNM_PROGRESS_HELPER_WORKBOOK);
ioc->helper.v.workbook.current += inc;
if (ioc->helper.v.workbook.current - ioc->helper.v.workbook.last
< ioc->helper.v.workbook.step) {
return;
}
ioc->helper.v.workbook.last = ioc->helper.v.workbook.current;
complete = 1.0 * ioc->helper.v.workbook.current
/ ioc->helper.v.workbook.n_elements;
io_progress_update (ioc, complete);
}
#endif // 0
void
io_progress_unset (IOContext *ioc)
{
g_return_if_fail (IS_IO_CONTEXT (ioc));
ioc->helper.helper_type = GNM_PROGRESS_HELPER_NONE;
ioc->helper.helper_type = GO_PROGRESS_HELPER_NONE;
}
void
@ -438,13 +388,23 @@ gnm_io_context_set_num_files (IOContext *ioc, guint count)
klass->set_num_files (ioc, count);
}
/**
* gnm_io_context_processing_file :
* @ioc : #IOContext
* @uri : An escaped uri (eg foo%20bar)
**/
void
gnm_io_context_processing_file (IOContext *ioc, char const *name)
gnm_io_context_processing_file (IOContext *ioc, char const *uri)
{
char *basename;
IOContextClass *klass = IOC_CLASS(ioc);
g_return_if_fail (klass != NULL);
if (klass->processing_file != NULL)
klass->processing_file (ioc, name);
basename = go_basename_from_uri (uri); /* unescape the uri */
if (basename != NULL && klass->processing_file != NULL)
klass->processing_file (ioc, basename);
g_free (basename);
}
void
@ -461,7 +421,7 @@ gnm_io_warning (G_GNUC_UNUSED IOContext *context,
void
gnm_io_warning_varargs (IOContext *context, char const *fmt, va_list args)
{
context->info = error_info_new_vprintf (GNM_WARNING, fmt, args);
context->info = error_info_new_vprintf (GO_WARNING, fmt, args);
context->warning_occurred = TRUE;
}

View File

@ -1,11 +1,12 @@
#ifndef GNUMERIC_IO_CONTEXT_H
#define GNUMERIC_IO_CONTEXT_H
#ifndef GO_IO_CONTEXT_H
#define GO_IO_CONTEXT_H
#include "gnumeric.h"
#include <goffice/app/goffice-app.h>
#include <glib-object.h>
#include <stdarg.h>
/* typedef struct _IOContext IOContext; */
G_BEGIN_DECLS
typedef struct _IOContextClass IOContextClass;
#define TYPE_IO_CONTEXT (io_context_get_type ())
@ -13,7 +14,7 @@ typedef struct _IOContextClass IOContextClass;
#define IS_IO_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_IO_CONTEXT))
GType io_context_get_type (void);
IOContext *gnumeric_io_context_new (GnmCmdContext *cc);
IOContext *gnumeric_io_context_new (GOCmdContext *cc);
void gnumeric_io_error_unknown (IOContext *ioc);
@ -37,17 +38,16 @@ void count_io_progress_update (IOContext *io_context, gint inc);
void value_io_progress_set (IOContext *io_context, gint total, gint step);
void value_io_progress_update (IOContext *io_context, gint value);
void workbook_io_progress_set (IOContext *io_context, Workbook const *wb, gint step);
void workbook_io_progress_update (IOContext *io_context, gint inc);
void io_progress_unset (IOContext *io_context);
void gnm_io_context_set_num_files (IOContext *ioc, guint count);
void gnm_io_context_processing_file (IOContext *ioc, char const *name);
void gnm_io_context_processing_file (IOContext *ioc, char const *uri);
void gnm_io_warning (IOContext *ioc, char const *fmt, ...) G_GNUC_PRINTF (2, 3);
void gnm_io_warning_varargs (IOContext *ioc, char const *fmt, va_list args);
void gnm_io_warning_unknown_font (IOContext *ioc, char const *font_name);
void gnm_io_warning_unknown_function (IOContext *ioc, char const *funct_name);
void gnm_io_warning_unsupported_feature (IOContext *ioc, char const *feature);
#endif /* GNUMERIC_IO_CONTEXT_H */
G_END_DECLS
#endif /* GO_IO_CONTEXT_H */

View File

@ -0,0 +1,39 @@
#ifndef GOFFICE_MODULE_PLUGIN_DEFS_H
#define GOFFICE_MODULE_PLUGIN_DEFS_H
#include <goffice/app/go-plugin.h>
#include <goffice/app/goffice-app.h>
#include <gmodule.h>
G_BEGIN_DECLS
void go_plugin_init (GOPlugin *p, GOCmdContext *cc); /* optional, called after dlopen */
void go_plugin_shutdown (GOPlugin *p, GOCmdContext *cc); /* optional, called before close */
typedef struct {
char const * const key; /* object being versioned */
char const * const version; /* version id (strict equality is required) */
} GOPluginModuleDepend;
typedef struct {
guint32 const magic_number;
guint32 const num_depends;
} GOPluginModuleHeader;
/* Cheesy api versioning
* bump this when external api changes. eventually we will just push this out
* into the module's link dependencies */
#define GOFFICE_API_VERSION "0.0"
#define GOFFICE_MODULE_PLUGIN_MAGIC_NUMBER 0x476e756d
/* convenience header for goffice plugins */
#define GOFFICE_PLUGIN_MODULE_HEADER \
G_MODULE_EXPORT GOPluginModuleDepend const go_plugin_depends [] = { \
{ "goffice", GOFFICE_API_VERSION } \
}; \
G_MODULE_EXPORT GOPluginModuleHeader const go_plugin_header = \
{ GOFFICE_MODULE_PLUGIN_MAGIC_NUMBER, G_N_ELEMENTS (go_plugin_depends) }
G_END_DECLS
#endif /* GOFFICE_MODULE_PLUGIN_DEFS_H */

View File

@ -0,0 +1 @@
SUBDIRS = pcre foocanvas

View File

@ -0,0 +1,68 @@
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/libgsf-1.12.3 \
-I$(top_srcdir)/lib/goffice-0.0.4 \
-I$(top_builddir)/lib/goffice-0.0.4 \
$(WARN_CFLAGS) \
$(GOFFICE_DEPS_CFLAGS) \
-DFOOCANVASLIBDIR=\""$(libdir)"\" \
-DFOOCANVASDATADIR=\""$(datadir)"\" \
-DFOOCANVASPIXMAPDIR=\""$(datadir)/pixmaps"\" \
-DFOOCANVASBINDIR=\""$(bindir)"\" \
-DFOOCANVASLOCALSTATEDIR=\""$(localstatedir)"\" \
-DFOOCANVASLOCALEDIR=\""$(gnomelocaledir)"\" \
-DG_LOG_DOMAIN=\"Foocanvas\" \
-DVERSION=\"$(VERSION)\"
noinst_LTLIBRARIES = libfoocanvas.la
libfoocanvas_la_LIBADD = \
$(RENDER_LIBS) \
$(LIBFOOCANVAS_LIBS)
libfoocanvasincludedir = $(includedir)/libgoffice-1/goffice/cut-n-paste/foocanvas/
libfoocanvasinclude_HEADERS = \
foo-canvas-line.h \
foo-canvas-pixbuf.h \
foo-canvas-polygon.h \
foo-canvas-rect-ellipse.h \
foo-canvas-text.h \
foo-canvas-util.h \
foo-canvas-widget.h \
foo-canvas.h \
libfoocanvas.h
libfoocanvas_la_SOURCES = \
$(libfoocanvasinclude_HEADERS) \
foo-canvas-marshal.list \
foo-canvas-i18n.h \
foo-canvas-line.c \
foo-canvas-pixbuf.c \
foo-canvas-polygon.c \
foo-canvas-rect-ellipse.c \
foo-canvas-text.c \
foo-canvas-util.c \
foo-canvas-widget.c \
foo-canvas.c \
libfoocanvastypes.c
GENMARSHAL_COMMAND = $(GLIB_GENMARSHAL) --prefix=foo_canvas_marshal
SUFFIXES = .list
.list.h:
$(GENMARSHAL_COMMAND) --header $< >$@
.list.c:
(echo '/* This file has been automatically generated. Do not edit. */' && \
echo '#include <goffice/goffice-config.h>' && \
echo '#include "$*.h"' && \
$(GENMARSHAL_COMMAND) --body $< ) >$@
# A hint is needed to build the header first:
BUILT_SOURCES = foo-canvas-marshal.h
# Another hint, see bugs #172211 and #172212:
non-intermediate: foo-canvas-marshal.c
CLEANFILES = foo-canvas-marshal.h foo-canvas-marshal.c

View File

@ -0,0 +1,70 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
/*
* Handles all of the internationalization configuration options.
* Author: Tom Tromey <tromey@creche.cygnus.com>
*/
#ifndef __LIBFOO_CANVAS_I18N_H__
#define __LIBFOO_CANVAS_I18N_H__
#include <glib.h>
G_BEGIN_DECLS
#if !defined(__LIBFOO_CANVAS_I18NP_H__)
#ifdef ENABLE_NLS
# include <libintl.h>
# ifdef GNOME_EXPLICIT_TRANSLATION_DOMAIN
# undef _
# define _(String) dgettext (GNOME_EXPLICIT_TRANSLATION_DOMAIN, String)
# else
# define _(String) gettext (String)
# endif
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
/* Stubs that do something close enough. */
# define textdomain(String) (String)
# define gettext(String) (String)
# define dgettext(Domain,Message) (Message)
# define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String)
# define N_(String) (String)
#endif
#endif
G_END_DECLS
#endif /* __LIBFOO_CANVAS_I18N_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,152 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
/* Line/curve item type for FooCanvas widget
*
* FooCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
*
*
* Author: Federico Mena <federico@nuclecu.unam.mx>
*/
#ifndef FOO_CANVAS_LINE_H
#define FOO_CANVAS_LINE_H
#include <goffice/cut-n-paste/foocanvas/foo-canvas.h>
G_BEGIN_DECLS
/* Line item for the canvas. This is a polyline with configurable width, cap/join styles, and arrowheads.
* If arrowheads are enabled, then three values are used to specify their shape:
*
* arrow_shape_a: Distance from tip of arrowhead to the center point.
* arrow_shape_b: Distance from tip of arrowhead to trailing point, measured along the shaft.
* arrow_shape_c: Distance of trailing point from outside edge of shaft.
*
* The following object arguments are available:
*
* name type read/write description
* ------------------------------------------------------------------------------------------
* points FooCanvasPoints* RW Pointer to a FooCanvasPoints structure.
* This can be created by a call to
* foo_canvas_points_new() (in foo-canvas-util.h).
* X coordinates are in the even indices of the
* points->coords array, Y coordinates are in
* the odd indices.
* fill_color string W X color specification for line
* fill_color_gdk GdkColor* RW Pointer to an allocated GdkColor
* fill_stipple GdkBitmap* RW Stipple pattern for the line
* width_pixels uint R Width of the line in pixels. The line width
* will not be scaled when the canvas zoom factor changes.
* width_units double R Width of the line in canvas units. The line width
* will be scaled when the canvas zoom factor changes.
* cap_style GdkCapStyle RW Cap ("endpoint") style for the line.
* join_style GdkJoinStyle RW Join ("vertex") style for the line.
* line_style GdkLineStyle RW Line dash style
* first_arrowhead boolean RW Specifies whether to draw an arrowhead on the
* first point of the line.
* last_arrowhead boolean RW Specifies whether to draw an arrowhead on the
* last point of the line.
* smooth boolean RW Specifies whether to smooth the line using
* parabolic splines.
* spline_steps uint RW Specifies the number of steps to use when rendering curves.
* arrow_shape_a double RW First arrow shape specifier.
* arrow_shape_b double RW Second arrow shape specifier.
* arrow_shape_c double RW Third arrow shape specifier.
*/
#define FOO_TYPE_CANVAS_LINE (foo_canvas_line_get_type ())
#define FOO_CANVAS_LINE(obj) (GTK_CHECK_CAST ((obj), FOO_TYPE_CANVAS_LINE, FooCanvasLine))
#define FOO_CANVAS_LINE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FOO_TYPE_CANVAS_LINE, FooCanvasLineClass))
#define FOO_IS_CANVAS_LINE(obj) (GTK_CHECK_TYPE ((obj), FOO_TYPE_CANVAS_LINE))
#define FOO_IS_CANVAS_LINE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FOO_TYPE_CANVAS_LINE))
#define FOO_CANVAS_LINE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FOO_TYPE_CANVAS_LINE, FooCanvasLineClass))
typedef struct _FooCanvasLine FooCanvasLine;
typedef struct _FooCanvasLineClass FooCanvasLineClass;
struct _FooCanvasLine {
FooCanvasItem item;
double *coords; /* Array of coordinates for the line's points. X coords are in the
* even indices, Y coords are in the odd indices. If the line has
* arrowheads then the first and last points have been adjusted to
* refer to the necks of the arrowheads rather than their tips. The
* actual endpoints are stored in the first_arrow and last_arrow
* arrays, if they exist.
*/
double *first_coords; /* Array of points describing polygon for the first arrowhead */
double *last_coords; /* Array of points describing polygon for the last arrowhead */
GdkGC *gc; /* GC for drawing line */
GdkBitmap *stipple; /* Stipple pattern */
double width; /* Width of the line */
double shape_a; /* Distance from tip of arrowhead to center */
double shape_b; /* Distance from tip of arrowhead to trailing point, measured along shaft */
double shape_c; /* Distance of trailing points from outside edge of shaft */
GdkCapStyle cap; /* Cap style for line */
GdkJoinStyle join; /* Join style for line */
GdkLineStyle line_style;/* Style for the line */
gulong fill_pixel; /* Color for line */
guint32 fill_rgba; /* RGBA color for outline */ /*AA*/
int num_points; /* Number of points in the line */
guint fill_color; /* Fill color, RGBA */
int spline_steps; /* Number of steps in each spline segment */
guint width_pixels : 1; /* Is the width specified in pixels or units? */
guint first_arrow : 1; /* Draw first arrowhead? */
guint last_arrow : 1; /* Draw last arrowhead? */
guint smooth : 1; /* Smooth line (with parabolic splines)? */
};
struct _FooCanvasLineClass {
FooCanvasItemClass parent_class;
};
/* Standard Gtk function */
GtkType foo_canvas_line_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif

View File

@ -0,0 +1,4 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
VOID:INT,INT,INT,INT
BOOLEAN:BOXED

View File

@ -0,0 +1,864 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
#undef GTK_DISABLE_DEPRECATED
#include <goffice/goffice-config.h>
#include <glib/gi18n.h>
#include <gsf/gsf-impl-utils.h>
/* GNOME libraries - GdkPixbuf item for the GNOME canvas
*
* Copyright (C) 1999 The Free Software Foundation
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA.
*/
#include <math.h>
#include <goffice/cut-n-paste/foocanvas/foo-canvas.h>
#include <goffice/cut-n-paste/foocanvas/foo-canvas-util.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "foo-canvas-pixbuf.h"
/* Private part of the FooCanvasPixbuf structure */
typedef struct {
/* Our gdk-pixbuf */
GdkPixbuf *pixbuf, *pixbuf_scaled;
/* Width value */
double width;
/* Height value */
double height;
/* X translation */
double x;
/* Y translation */
double y;
/* Whether dimensions are set and whether they are in pixels or units */
guint width_set : 1;
guint width_in_pixels : 1;
guint height_set : 1;
guint height_in_pixels : 1;
guint x_in_pixels : 1;
guint y_in_pixels : 1;
/* Whether the pixbuf has changed */
guint need_pixbuf_update : 1;
/* Whether the transformation or size have changed */
guint need_xform_update : 1;
/* Should the point method ignore transparent areas */
guint point_ignores_alpha : 1;
/* Anchor */
GtkAnchorType anchor;
/* Approximation method used for transformations */
GdkInterpType interp_type;
} PixbufPrivate;
/* Object argument IDs */
enum {
PROP_0,
PROP_PIXBUF,
PROP_WIDTH,
PROP_WIDTH_SET,
PROP_WIDTH_IN_PIXELS,
PROP_HEIGHT,
PROP_HEIGHT_SET,
PROP_HEIGHT_IN_PIXELS,
PROP_X,
PROP_X_IN_PIXELS,
PROP_Y,
PROP_Y_IN_PIXELS,
PROP_ANCHOR,
PROP_INTERP_TYPE,
PROP_POINT_IGNORES_ALPHA
};
static void foo_canvas_pixbuf_class_init (FooCanvasPixbufClass *class);
static void foo_canvas_pixbuf_init (FooCanvasPixbuf *cpb);
static void foo_canvas_pixbuf_destroy (GtkObject *object);
static void foo_canvas_pixbuf_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec);
static void foo_canvas_pixbuf_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec);
static void foo_canvas_pixbuf_update (FooCanvasItem *item,
double i2w_dx, double i2w_dy,
int flags);
static void foo_canvas_pixbuf_draw (FooCanvasItem *item, GdkDrawable *drawable,
GdkEventExpose *expose);
static double foo_canvas_pixbuf_point (FooCanvasItem *item, double x, double y, int cx, int cy,
FooCanvasItem **actual_item);
static void foo_canvas_pixbuf_translate (FooCanvasItem *item, double dx, double dy);
static void foo_canvas_pixbuf_bounds (FooCanvasItem *item,
double *x1, double *y1, double *x2, double *y2);
static FooCanvasItemClass *parent_class;
/**
* foo_canvas_pixbuf_get_type:
* @void:
*
* Registers the #FooCanvasPixbuf class if necessary, and returns the type ID
* associated to it.
*
* Return value: The type ID of the #FooCanvasPixbuf class.
**/
GtkType
foo_canvas_pixbuf_get_type (void)
{
static GtkType canvas_pixbuf_type = 0;
if (!canvas_pixbuf_type) {
/* FIXME: Convert to gobject style. */
static const GtkTypeInfo canvas_pixbuf_info = {
(char *)"FooCanvasPixbuf",
sizeof (FooCanvasPixbuf),
sizeof (FooCanvasPixbufClass),
(GtkClassInitFunc) foo_canvas_pixbuf_class_init,
(GtkObjectInitFunc) foo_canvas_pixbuf_init,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
};
canvas_pixbuf_type = gtk_type_unique (foo_canvas_item_get_type (),
&canvas_pixbuf_info);
}
return canvas_pixbuf_type;
}
/* Class initialization function for the pixbuf canvas item */
static void
foo_canvas_pixbuf_class_init (FooCanvasPixbufClass *class)
{
GObjectClass *gobject_class;
GtkObjectClass *object_class;
FooCanvasItemClass *item_class;
gobject_class = (GObjectClass *) class;
object_class = (GtkObjectClass *) class;
item_class = (FooCanvasItemClass *) class;
parent_class = gtk_type_class (foo_canvas_item_get_type ());
gobject_class->set_property = foo_canvas_pixbuf_set_property;
gobject_class->get_property = foo_canvas_pixbuf_get_property;
g_object_class_install_property
(gobject_class,
PROP_PIXBUF,
g_param_spec_object ("pixbuf", NULL, NULL,
GDK_TYPE_PIXBUF,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_WIDTH,
g_param_spec_double ("width", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_WIDTH_SET,
g_param_spec_boolean ("width-set", NULL, NULL,
FALSE,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_WIDTH_IN_PIXELS,
g_param_spec_boolean ("width-in-pixels", NULL, NULL,
FALSE,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_HEIGHT,
g_param_spec_double ("height", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_HEIGHT_SET,
g_param_spec_boolean ("height-set", NULL, NULL,
FALSE,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_HEIGHT_IN_PIXELS,
g_param_spec_boolean ("height-in-pixels", NULL, NULL,
FALSE,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_X,
g_param_spec_double ("x", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_X_IN_PIXELS,
g_param_spec_boolean ("x-in-pixels", NULL, NULL,
FALSE,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_Y,
g_param_spec_double ("y", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_Y_IN_PIXELS,
g_param_spec_boolean ("y-in-pixels", NULL, NULL,
FALSE,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_ANCHOR,
g_param_spec_enum ("anchor", NULL, NULL,
GTK_TYPE_ANCHOR_TYPE,
GTK_ANCHOR_NW,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_INTERP_TYPE,
g_param_spec_enum ("interp-type", NULL, NULL,
GDK_TYPE_INTERP_TYPE,
GDK_INTERP_BILINEAR,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_POINT_IGNORES_ALPHA,
g_param_spec_boolean ("point-ignores-alpha", NULL, NULL,
FALSE,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
object_class->destroy = foo_canvas_pixbuf_destroy;
item_class->update = foo_canvas_pixbuf_update;
item_class->draw = foo_canvas_pixbuf_draw;
item_class->point = foo_canvas_pixbuf_point;
item_class->translate = foo_canvas_pixbuf_translate;
item_class->bounds = foo_canvas_pixbuf_bounds;
}
/* Object initialization function for the pixbuf canvas item */
static void
foo_canvas_pixbuf_init (FooCanvasPixbuf *gcp)
{
PixbufPrivate *priv;
priv = g_new0 (PixbufPrivate, 1);
gcp->priv = priv;
priv->width = 0.0;
priv->height = 0.0;
priv->x = 0.0;
priv->y = 0.0;
priv->anchor = GTK_ANCHOR_NW;
priv->interp_type = GDK_INTERP_BILINEAR;
priv->point_ignores_alpha = FALSE;
}
/* Destroy handler for the pixbuf canvas item */
static void
foo_canvas_pixbuf_destroy (GtkObject *object)
{
FooCanvasItem *item;
FooCanvasPixbuf *gcp;
PixbufPrivate *priv;
g_return_if_fail (object != NULL);
g_return_if_fail (FOO_IS_CANVAS_PIXBUF (object));
item = FOO_CANVAS_ITEM (object);
gcp = (FOO_CANVAS_PIXBUF (object));
priv = gcp->priv;
/* remember, destroy can be run multiple times! */
if (priv) {
foo_canvas_item_request_redraw (item);
if (priv->pixbuf)
g_object_unref (priv->pixbuf);
if (priv->pixbuf_scaled)
g_object_unref (priv->pixbuf_scaled);
g_free (priv);
gcp->priv = NULL;
}
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
/* Set_property handler for the pixbuf canvas item */
static void
foo_canvas_pixbuf_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec)
{
FooCanvasItem *item;
FooCanvasPixbuf *gcp;
PixbufPrivate *priv;
GdkPixbuf *pixbuf;
double val;
g_return_if_fail (object != NULL);
g_return_if_fail (FOO_IS_CANVAS_PIXBUF (object));
item = FOO_CANVAS_ITEM (object);
gcp = FOO_CANVAS_PIXBUF (object);
priv = gcp->priv;
switch (param_id) {
case PROP_PIXBUF:
if (g_value_get_object (value))
pixbuf = GDK_PIXBUF (g_value_get_object (value));
else
pixbuf = NULL;
if (pixbuf != priv->pixbuf) {
if (pixbuf) {
g_return_if_fail
(gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB);
g_return_if_fail
(gdk_pixbuf_get_n_channels (pixbuf) == 3
|| gdk_pixbuf_get_n_channels (pixbuf) == 4);
g_return_if_fail
(gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
g_object_ref (pixbuf);
}
if (priv->pixbuf)
g_object_unref (priv->pixbuf);
priv->pixbuf = pixbuf;
if (priv->pixbuf_scaled) {
g_object_unref (priv->pixbuf_scaled);
priv->pixbuf_scaled = NULL;
}
}
priv->need_pixbuf_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_WIDTH:
val = g_value_get_double (value);
g_return_if_fail (val >= 0.0);
priv->width = val;
priv->need_xform_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_WIDTH_SET:
priv->width_set = g_value_get_boolean (value);
priv->need_xform_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_WIDTH_IN_PIXELS:
priv->width_in_pixels = g_value_get_boolean (value);
priv->need_xform_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_HEIGHT:
val = g_value_get_double (value);
g_return_if_fail (val >= 0.0);
priv->height = val;
priv->need_xform_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_HEIGHT_SET:
priv->height_set = g_value_get_boolean (value);
priv->need_xform_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_HEIGHT_IN_PIXELS:
priv->height_in_pixels = g_value_get_boolean (value);
priv->need_xform_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_X:
priv->x = g_value_get_double (value);
priv->need_xform_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_X_IN_PIXELS:
priv->x_in_pixels = g_value_get_boolean (value);
priv->need_xform_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_Y:
priv->y = g_value_get_double (value);
priv->need_xform_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_Y_IN_PIXELS:
priv->y_in_pixels = g_value_get_boolean (value);
priv->need_xform_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_ANCHOR:
priv->anchor = g_value_get_enum (value);
priv->need_xform_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_INTERP_TYPE:
priv->interp_type = g_value_get_enum (value);
priv->need_xform_update = TRUE;
foo_canvas_item_request_update (item);
break;
case PROP_POINT_IGNORES_ALPHA:
priv->point_ignores_alpha = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
/* Get_property handler for the pixbuf canvasi item */
static void
foo_canvas_pixbuf_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec)
{
FooCanvasPixbuf *gcp;
PixbufPrivate *priv;
g_return_if_fail (object != NULL);
g_return_if_fail (FOO_IS_CANVAS_PIXBUF (object));
gcp = FOO_CANVAS_PIXBUF (object);
priv = gcp->priv;
switch (param_id) {
case PROP_PIXBUF:
g_value_set_object (value, G_OBJECT (priv->pixbuf));
break;
case PROP_WIDTH:
g_value_set_double (value, priv->width);
break;
case PROP_WIDTH_SET:
g_value_set_boolean (value, priv->width_set);
break;
case PROP_WIDTH_IN_PIXELS:
g_value_set_boolean (value, priv->width_in_pixels);
break;
case PROP_HEIGHT:
g_value_set_double (value, priv->height);
break;
case PROP_HEIGHT_SET:
g_value_set_boolean (value, priv->height_set);
break;
case PROP_HEIGHT_IN_PIXELS:
g_value_set_boolean (value, priv->height_in_pixels);
break;
case PROP_X:
g_value_set_double (value, priv->x);
break;
case PROP_X_IN_PIXELS:
g_value_set_boolean (value, priv->x_in_pixels);
break;
case PROP_Y:
g_value_set_double (value, priv->y);
break;
case PROP_Y_IN_PIXELS:
g_value_set_boolean (value, priv->y_in_pixels);
break;
case PROP_ANCHOR:
g_value_set_enum (value, priv->anchor);
break;
case PROP_INTERP_TYPE:
g_value_set_enum (value, priv->interp_type);
break;
case PROP_POINT_IGNORES_ALPHA:
g_value_set_boolean (value, priv->point_ignores_alpha);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
/* Bounds and utilities */
/* Recomputes the bounding box of a pixbuf canvas item. The horizontal and
* vertical dimensions may be specified in units or pixels, separately, so we
* have to compute the components individually for each dimension.
*
* Returns the coordinates with respect to the parent items coordinates.
*/
static void
compute_bounding_box (FooCanvasPixbuf *gcp,
double i2w_dx, double i2w_dy,
double *bbox_x0, double *bbox_y0,
double *bbox_x1, double *bbox_y1)
{
FooCanvasItem *item;
PixbufPrivate *priv;
double x, y;
double width, height;
item = FOO_CANVAS_ITEM (gcp);
priv = gcp->priv;
if (!priv->pixbuf) {
*bbox_x0 = *bbox_y0 = *bbox_x1 = *bbox_y1 = 0.0;
return;
}
if (priv->x_in_pixels) {
x = i2w_dx + priv->x / item->canvas->pixels_per_unit;
} else {
x = i2w_dx + priv->x;
}
if (priv->y_in_pixels) {
y = i2w_dy + priv->y / item->canvas->pixels_per_unit;
} else {
y = i2w_dy + priv->y;
}
if (priv->width_set) {
width = priv->width;
} else {
width = gdk_pixbuf_get_width (priv->pixbuf);
}
if (priv->width_in_pixels)
width /= item->canvas->pixels_per_unit;
if (priv->height_set) {
height = priv->height;
} else {
height = gdk_pixbuf_get_height (priv->pixbuf);
}
if (priv->height_in_pixels)
height /= item->canvas->pixels_per_unit;
switch (priv->anchor) {
case GTK_ANCHOR_NW:
case GTK_ANCHOR_W:
case GTK_ANCHOR_SW:
break;
case GTK_ANCHOR_N:
case GTK_ANCHOR_CENTER:
case GTK_ANCHOR_S:
x -= width / 2.0;
break;
case GTK_ANCHOR_NE:
case GTK_ANCHOR_E:
case GTK_ANCHOR_SE:
x -= width;
break;
default:
break;
}
switch (priv->anchor) {
case GTK_ANCHOR_NW:
case GTK_ANCHOR_N:
case GTK_ANCHOR_NE:
break;
case GTK_ANCHOR_W:
case GTK_ANCHOR_CENTER:
case GTK_ANCHOR_E:
y -= height / 2.0;
break;
case GTK_ANCHOR_SW:
case GTK_ANCHOR_S:
case GTK_ANCHOR_SE:
y -= height;
break;
default:
break;
}
*bbox_x0 = x;
*bbox_y0 = y;
*bbox_x1 = x + width;
*bbox_y1 = y + height;
}
/* Update sequence */
/* Update handler for the pixbuf canvas item */
static void
foo_canvas_pixbuf_update (FooCanvasItem *item,
double i2w_dx, double i2w_dy,
int flags)
{
FooCanvasPixbuf *gcp;
PixbufPrivate *priv;
double bbox_x0, bbox_y0, bbox_x1, bbox_y1;
int w, h;
gcp = FOO_CANVAS_PIXBUF (item);
priv = gcp->priv;
if (parent_class->update)
(* parent_class->update) (item, i2w_dx, i2w_dy, flags);
/* If we need a pixbuf update, or if the item changed visibility to
* shown, recompute the bounding box.
*/
if (priv->need_pixbuf_update || priv->need_xform_update ||
(flags & FOO_CANVAS_UPDATE_DEEP)) {
foo_canvas_item_request_redraw (item);
compute_bounding_box (gcp, i2w_dx, i2w_dy,
&bbox_x0, &bbox_y0,
&bbox_x1, &bbox_y1);
foo_canvas_w2c_d (item->canvas,
bbox_x0, bbox_y0,
&item->x1, &item->y1);
foo_canvas_w2c_d (item->canvas,
bbox_x1, bbox_y1,
&item->x2, &item->y2);
item->x1 = floor (item->x1);
item->y1 = floor (item->y1);
item->x2 = ceil (item->x2);
item->y2 = ceil (item->y2);
#ifdef FOO_CANVAS_PIXBUF_VERBOSE
g_print ("BBox is %g %g %g %g\n", item->x1, item->y1, item->x2, item->y2);
#endif
if (priv->pixbuf) {
w = item->x2 - item->x1;
h = item->y2 - item->y1;
if (priv->pixbuf_scaled)
g_object_unref (priv->pixbuf_scaled);
if (gdk_pixbuf_get_width (priv->pixbuf) != w ||
gdk_pixbuf_get_height (priv->pixbuf) != h)
priv->pixbuf_scaled = gdk_pixbuf_scale_simple (
priv->pixbuf, w, h, priv->interp_type);
else
priv->pixbuf_scaled = g_object_ref (priv->pixbuf);
}
foo_canvas_item_request_redraw (item);
priv->need_pixbuf_update = FALSE;
priv->need_xform_update = FALSE;
}
}
/* Draw handler for the pixbuf canvas item */
static void
foo_canvas_pixbuf_draw (FooCanvasItem *item, GdkDrawable *drawable,
GdkEventExpose *expose)
{
FooCanvasPixbuf *gcp;
PixbufPrivate *priv;
GdkRectangle display_rect, draw_rect;
GdkRegion *draw_region;
int w, h;
gcp = FOO_CANVAS_PIXBUF (item);
priv = gcp->priv;
if (!priv->pixbuf)
return;
/* Compute the area we need to repaint */
w = item->x2 - item->x1;
h = item->y2 - item->y1;
display_rect.x = item->x1;
display_rect.y = item->y1;
display_rect.width = w;
display_rect.height = h;
draw_region = gdk_region_rectangle (&display_rect);
gdk_region_intersect (draw_region, expose->region);
if (!gdk_region_empty (draw_region)) {
gdk_region_get_clipbox (draw_region, &draw_rect);
gdk_draw_pixbuf (drawable, NULL, priv->pixbuf_scaled,
/* pixbuf 0, 0 is at pix_rect.x, pix_rect.y */
draw_rect.x - display_rect.x,
draw_rect.y - display_rect.y,
draw_rect.x,
draw_rect.y,
draw_rect.width,
draw_rect.height,
GDK_RGB_DITHER_NORMAL, 0, 0);
}
gdk_region_destroy (draw_region);
}
/* Point handler for the pixbuf canvas item */
static double
foo_canvas_pixbuf_point (FooCanvasItem *item, double x, double y, int cx, int cy,
FooCanvasItem **actual_item)
{
FooCanvasPixbuf *gcp;
PixbufPrivate *priv;
double x1, y1, x2, y2;
int px, py;
double no_hit;
guchar *src;
GdkPixbuf *pixbuf;
gcp = FOO_CANVAS_PIXBUF (item);
priv = gcp->priv;
pixbuf = priv->pixbuf;
*actual_item = item;
no_hit = item->canvas->pixels_per_unit * 2 + 10;
if (!priv->pixbuf)
return no_hit;
compute_bounding_box (gcp, 0.0, 0.0,
&x1, &y1, &x2, &y2);
if (x < x1 || x >= x2 ||
y < y1 || y >= y2)
return no_hit;
if (!gdk_pixbuf_get_has_alpha (pixbuf) || priv->point_ignores_alpha)
return 0.0;
px = (x - x1) * gdk_pixbuf_get_width (pixbuf) / (x2 - x1);
py = (y - y1) * gdk_pixbuf_get_height (pixbuf) / (y2 - y1);
src = gdk_pixbuf_get_pixels (pixbuf) +
py * gdk_pixbuf_get_rowstride (pixbuf) +
px * gdk_pixbuf_get_n_channels (pixbuf);
if (src[3] < 128)
return no_hit;
else
return 0.0;
}
static void
foo_canvas_pixbuf_translate (FooCanvasItem *item, double dx, double dy)
{
FooCanvasPixbuf *gcp;
PixbufPrivate *priv;
gcp = FOO_CANVAS_PIXBUF (item);
priv = gcp->priv;
if (priv->x_in_pixels) {
priv->x += dx * item->canvas->pixels_per_unit;
} else {
priv->x += dx;
}
if (priv->y_in_pixels) {
priv->y += dy * item->canvas->pixels_per_unit;
} else {
priv->y += dy;
}
priv->need_xform_update = TRUE;
}
/* Bounds handler for the pixbuf canvas item */
static void
foo_canvas_pixbuf_bounds (FooCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
{
FooCanvasPixbuf *gcp;
PixbufPrivate *priv;
gcp = FOO_CANVAS_PIXBUF (item);
priv = gcp->priv;
if (!priv->pixbuf) {
*x1 = *y1 = *x2 = *y2 = 0.0;
return;
}
compute_bounding_box (gcp, 0.0, 0.0,
x1, y1, x2, y2);
}

View File

@ -0,0 +1,64 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
/* GNOME libraries - GdkPixbuf item for the GNOME canvas
*
* Copyright (C) 1999 The Free Software Foundation
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA.
*/
#ifndef FOO_CANVAS_PIXBUF_H
#define FOO_CANVAS_PIXBUF_H
#include <goffice/cut-n-paste/foocanvas/foo-canvas.h>
G_BEGIN_DECLS
#define FOO_TYPE_CANVAS_PIXBUF (foo_canvas_pixbuf_get_type ())
#define FOO_CANVAS_PIXBUF(obj) (GTK_CHECK_CAST ((obj), FOO_TYPE_CANVAS_PIXBUF, FooCanvasPixbuf))
#define FOO_CANVAS_PIXBUF_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FOO_TYPE_CANVAS_PIXBUF, FooCanvasPixbufClass))
#define FOO_IS_CANVAS_PIXBUF(obj) (GTK_CHECK_TYPE ((obj), FOO_TYPE_CANVAS_PIXBUF))
#define FOO_IS_CANVAS_PIXBUF_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FOO_TYPE_CANVAS_PIXBUF))
#define FOO_CANVAS_PIXBUF_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FOO_TYPE_CANVAS_PIXBUF, FooCanvasPixbufClass))
typedef struct _FooCanvasPixbuf FooCanvasPixbuf;
typedef struct _FooCanvasPixbufClass FooCanvasPixbufClass;
struct _FooCanvasPixbuf {
FooCanvasItem item;
/* Private data */
gpointer priv;
};
struct _FooCanvasPixbufClass {
FooCanvasItemClass parent_class;
};
GtkType foo_canvas_pixbuf_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif

View File

@ -0,0 +1,854 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
#undef GTK_DISABLE_DEPRECATED
#include <goffice/goffice-config.h>
#include <glib/gi18n.h>
#include <gsf/gsf-impl-utils.h>
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
/* Polygon item type for FooCanvas widget
*
* FooCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
*
* Author: Federico Mena <federico@nuclecu.unam.mx>
*/
#include <math.h>
#include <string.h>
#include "libfoocanvas.h"
#define NUM_STATIC_POINTS 256 /* Number of static points to use to avoid allocating arrays */
#define GROW_BOUNDS(bx1, by1, bx2, by2, x, y) { \
if (x < bx1) \
bx1 = x; \
\
if (x > bx2) \
bx2 = x; \
\
if (y < by1) \
by1 = y; \
\
if (y > by2) \
by2 = y; \
}
enum {
PROP_0,
PROP_POINTS,
PROP_FILL_COLOR,
PROP_FILL_COLOR_GDK,
PROP_FILL_COLOR_RGBA,
PROP_OUTLINE_COLOR,
PROP_OUTLINE_COLOR_GDK,
PROP_OUTLINE_COLOR_RGBA,
PROP_FILL_STIPPLE,
PROP_OUTLINE_STIPPLE,
PROP_WIDTH_PIXELS,
PROP_WIDTH_UNITS
};
static void foo_canvas_polygon_class_init (FooCanvasPolygonClass *class);
static void foo_canvas_polygon_init (FooCanvasPolygon *poly);
static void foo_canvas_polygon_destroy (GtkObject *object);
static void foo_canvas_polygon_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec);
static void foo_canvas_polygon_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec);
static void foo_canvas_polygon_update (FooCanvasItem *item,
double i2w_dx, double i2w_dy,
int flags);
static void foo_canvas_polygon_realize (FooCanvasItem *item);
static void foo_canvas_polygon_unrealize (FooCanvasItem *item);
static void foo_canvas_polygon_draw (FooCanvasItem *item, GdkDrawable *drawable,
GdkEventExpose *expose);
static double foo_canvas_polygon_point (FooCanvasItem *item, double x, double y,
int cx, int cy, FooCanvasItem **actual_item);
static void foo_canvas_polygon_translate (FooCanvasItem *item, double dx, double dy);
static void foo_canvas_polygon_bounds (FooCanvasItem *item, double *x1, double *y1, double *x2, double *y2);
static FooCanvasItemClass *parent_class;
GtkType
foo_canvas_polygon_get_type (void)
{
static GtkType polygon_type = 0;
if (!polygon_type) {
/* FIXME: Convert to gobject style. */
static const GtkTypeInfo polygon_info = {
(char *)"FooCanvasPolygon",
sizeof (FooCanvasPolygon),
sizeof (FooCanvasPolygonClass),
(GtkClassInitFunc) foo_canvas_polygon_class_init,
(GtkObjectInitFunc) foo_canvas_polygon_init,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
};
polygon_type = gtk_type_unique (foo_canvas_item_get_type (), &polygon_info);
}
return polygon_type;
}
static void
foo_canvas_polygon_class_init (FooCanvasPolygonClass *class)
{
GObjectClass *gobject_class;
GtkObjectClass *object_class;
FooCanvasItemClass *item_class;
gobject_class = (GObjectClass *) class;
object_class = (GtkObjectClass *) class;
item_class = (FooCanvasItemClass *) class;
parent_class = gtk_type_class (foo_canvas_item_get_type ());
gobject_class->set_property = foo_canvas_polygon_set_property;
gobject_class->get_property = foo_canvas_polygon_get_property;
g_object_class_install_property
(gobject_class,
PROP_POINTS,
g_param_spec_boxed ("points", NULL, NULL,
FOO_TYPE_CANVAS_POINTS,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_FILL_COLOR,
g_param_spec_string ("fill-color", NULL, NULL,
NULL,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_FILL_COLOR_GDK,
g_param_spec_boxed ("fill-color-gdk", NULL, NULL,
GDK_TYPE_COLOR,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_FILL_COLOR_RGBA,
g_param_spec_uint ("fill-color-rgba", NULL, NULL,
0, G_MAXUINT, 0,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_OUTLINE_COLOR,
g_param_spec_string ("outline-color", NULL, NULL,
NULL,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_OUTLINE_COLOR_GDK,
g_param_spec_boxed ("outline-color-gdk", NULL, NULL,
GDK_TYPE_COLOR,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_OUTLINE_COLOR_RGBA,
g_param_spec_uint ("outline-color-rgba", NULL, NULL,
0, G_MAXUINT, 0,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_FILL_STIPPLE,
g_param_spec_object ("fill-stipple", NULL, NULL,
GDK_TYPE_DRAWABLE,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_OUTLINE_STIPPLE,
g_param_spec_object ("outline-stipple", NULL, NULL,
GDK_TYPE_DRAWABLE,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_WIDTH_PIXELS,
g_param_spec_uint ("width-pixels", NULL, NULL,
0, G_MAXUINT, 0,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_WIDTH_UNITS,
g_param_spec_double ("width-units", NULL, NULL,
0.0, G_MAXDOUBLE, 0.0,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
object_class->destroy = foo_canvas_polygon_destroy;
item_class->update = foo_canvas_polygon_update;
item_class->realize = foo_canvas_polygon_realize;
item_class->unrealize = foo_canvas_polygon_unrealize;
item_class->draw = foo_canvas_polygon_draw;
item_class->point = foo_canvas_polygon_point;
item_class->translate = foo_canvas_polygon_translate;
item_class->bounds = foo_canvas_polygon_bounds;
}
static void
foo_canvas_polygon_init (FooCanvasPolygon *poly)
{
poly->width = 0.0;
}
static void
foo_canvas_polygon_destroy (GtkObject *object)
{
FooCanvasPolygon *poly;
g_return_if_fail (object != NULL);
g_return_if_fail (FOO_IS_CANVAS_POLYGON (object));
poly = FOO_CANVAS_POLYGON (object);
/* remember, destroy can be run multiple times! */
if (poly->coords)
g_free (poly->coords);
poly->coords = NULL;
if (poly->fill_stipple)
g_object_unref (poly->fill_stipple);
poly->fill_stipple = NULL;
if (poly->outline_stipple)
g_object_unref (poly->outline_stipple);
poly->outline_stipple = NULL;
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
/* Computes the bounding box of the polygon. Assumes that the number of points in the polygon is
* not zero.
*/
static gboolean
get_bounds (FooCanvasPolygon *poly, double *bx1, double *by1, double *bx2, double *by2)
{
double *coords;
double x1, y1, x2, y2;
double width;
int i;
if (poly->num_points == 0)
return FALSE;
/* Compute bounds of vertices */
x1 = x2 = poly->coords[0];
y1 = y2 = poly->coords[1];
for (i = 1, coords = poly->coords + 2; i < poly->num_points; i++, coords += 2) {
GROW_BOUNDS (x1, y1, x2, y2, coords[0], coords[1]);
}
/* Add outline width */
if (poly->width_pixels)
width = poly->width / poly->item.canvas->pixels_per_unit;
else
width = poly->width;
width /= 2.0;
x1 -= width;
y1 -= width;
x2 += width;
y2 += width;
/* Done */
*bx1 = x1;
*by1 = y1;
*bx2 = x2;
*by2 = y2;
return TRUE;
}
/* Computes the bounding box of the polygon, in canvas coordinates. Assumes that the number of points in the polygon is
* not zero.
*/
static gboolean
get_bounds_canvas (FooCanvasPolygon *poly,
double *bx1, double *by1, double *bx2, double *by2,
double i2w_dx, double i2w_dy)
{
FooCanvasItem *item;
double bbox_x0, bbox_y0, bbox_x1, bbox_y1;
item = FOO_CANVAS_ITEM (poly);
if (!get_bounds (poly, &bbox_x0, &bbox_y0, &bbox_x1, &bbox_y1))
return FALSE;
bbox_x0 += i2w_dx;
bbox_y0 += i2w_dy;
bbox_x1 += i2w_dx;
bbox_y1 += i2w_dy;
foo_canvas_w2c_rect_d (item->canvas,
&bbox_x0, &bbox_y0, &bbox_x1, &bbox_y1);
/* include 1 pixel of fudge */
*bx1 = bbox_x0 - 1;
*by1 = bbox_y0 - 1;
*bx2 = bbox_x1 + 1;
*by2 = bbox_y1 + 1;
return TRUE;
}
/* Sets the points of the polygon item to the specified ones. If needed, it will add a point to
* close the polygon.
*/
static void
set_points (FooCanvasPolygon *poly, FooCanvasPoints *points)
{
int duplicate;
/* See if we need to duplicate the first point */
duplicate = ((points->coords[0] != points->coords[2 * points->num_points - 2])
|| (points->coords[1] != points->coords[2 * points->num_points - 1]));
if (duplicate)
poly->num_points = points->num_points + 1;
else
poly->num_points = points->num_points;
poly->coords = g_new (double, 2 * poly->num_points);
memcpy (poly->coords, points->coords, 2 * points->num_points * sizeof (double));
if (duplicate) {
poly->coords[2 * poly->num_points - 2] = poly->coords[0];
poly->coords[2 * poly->num_points - 1] = poly->coords[1];
}
}
/* Convenience function to set a GC's foreground color to the specified pixel value */
static void
set_gc_foreground (GdkGC *gc, gulong pixel)
{
GdkColor c;
if (!gc)
return;
c.pixel = pixel;
gdk_gc_set_foreground (gc, &c);
}
/* Sets the stipple pattern for the specified gc */
static void
set_stipple (GdkGC *gc, GdkBitmap **internal_stipple, GdkBitmap *stipple, int reconfigure)
{
if (*internal_stipple && !reconfigure)
g_object_unref (*internal_stipple);
*internal_stipple = stipple;
if (stipple && !reconfigure)
g_object_ref (stipple);
if (gc) {
if (stipple) {
gdk_gc_set_stipple (gc, stipple);
gdk_gc_set_fill (gc, GDK_STIPPLED);
} else
gdk_gc_set_fill (gc, GDK_SOLID);
}
}
/* Recalculate the outline width of the polygon and set it in its GC */
static void
set_outline_gc_width (FooCanvasPolygon *poly)
{
int width;
if (!poly->outline_gc)
return;
if (poly->width_pixels)
width = (int) poly->width;
else
width = (int) (poly->width * poly->item.canvas->pixels_per_unit + 0.5);
gdk_gc_set_line_attributes (poly->outline_gc, width,
GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
}
static void
foo_canvas_polygon_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec)
{
FooCanvasItem *item;
FooCanvasPolygon *poly;
FooCanvasPoints *points;
GdkColor color = { 0, 0, 0, 0, };
GdkColor *pcolor;
int have_pixel;
g_return_if_fail (object != NULL);
g_return_if_fail (FOO_IS_CANVAS_POLYGON (object));
item = FOO_CANVAS_ITEM (object);
poly = FOO_CANVAS_POLYGON (object);
have_pixel = FALSE;
switch (param_id) {
case PROP_POINTS:
points = g_value_get_boxed (value);
if (poly->coords) {
g_free (poly->coords);
poly->coords = NULL;
}
if (!points)
poly->num_points = 0;
else
set_points (poly, points);
foo_canvas_item_request_update (item);
break;
case PROP_FILL_COLOR:
case PROP_FILL_COLOR_GDK:
case PROP_FILL_COLOR_RGBA:
switch (param_id) {
case PROP_FILL_COLOR:
if (g_value_get_string (value) &&
gdk_color_parse (g_value_get_string (value), &color))
poly->fill_set = TRUE;
else
poly->fill_set = FALSE;
poly->fill_color = ((color.red & 0xff00) << 16 |
(color.green & 0xff00) << 8 |
(color.blue & 0xff00) |
0xff);
break;
case PROP_FILL_COLOR_GDK:
pcolor = g_value_get_boxed (value);
poly->fill_set = pcolor != NULL;
if (pcolor) {
GdkColormap *colormap;
color = *pcolor;
colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas));
gdk_rgb_find_color (colormap, &color);
have_pixel = TRUE;
}
poly->fill_color = ((color.red & 0xff00) << 16 |
(color.green & 0xff00) << 8 |
(color.blue & 0xff00) |
0xff);
break;
case PROP_FILL_COLOR_RGBA:
poly->fill_set = TRUE;
poly->fill_color = g_value_get_uint (value);
break;
}
#ifdef VERBOSE
g_print ("poly fill color = %08x\n", poly->fill_color);
#endif
if (have_pixel)
poly->fill_pixel = color.pixel;
else
poly->fill_pixel = foo_canvas_get_color_pixel (item->canvas,
poly->fill_color);
set_gc_foreground (poly->fill_gc, poly->fill_pixel);
foo_canvas_item_request_redraw (item);
break;
case PROP_OUTLINE_COLOR:
case PROP_OUTLINE_COLOR_GDK:
case PROP_OUTLINE_COLOR_RGBA:
switch (param_id) {
case PROP_OUTLINE_COLOR:
if (g_value_get_string (value) &&
gdk_color_parse (g_value_get_string (value), &color))
poly->outline_set = TRUE;
else
poly->outline_set = FALSE;
poly->outline_color = ((color.red & 0xff00) << 16 |
(color.green & 0xff00) << 8 |
(color.blue & 0xff00) |
0xff);
break;
case PROP_OUTLINE_COLOR_GDK:
pcolor = g_value_get_boxed (value);
poly->outline_set = pcolor != NULL;
if (pcolor) {
GdkColormap *colormap;
color = *pcolor;
colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas));
gdk_rgb_find_color (colormap, &color);
have_pixel = TRUE;
}
poly->outline_color = ((color.red & 0xff00) << 16 |
(color.green & 0xff00) << 8 |
(color.blue & 0xff00) |
0xff);
break;
case PROP_OUTLINE_COLOR_RGBA:
poly->outline_set = TRUE;
poly->outline_color = g_value_get_uint (value);
break;
}
#ifdef VERBOSE
g_print ("poly outline color = %08x\n", poly->outline_color);
#endif
if (have_pixel)
poly->outline_pixel = color.pixel;
else
poly->outline_pixel = foo_canvas_get_color_pixel (item->canvas,
poly->outline_color);
set_gc_foreground (poly->outline_gc, poly->outline_pixel);
foo_canvas_item_request_redraw (item);
break;
case PROP_FILL_STIPPLE:
set_stipple (poly->fill_gc, &poly->fill_stipple, (GdkBitmap *) g_value_get_object (value), FALSE);
foo_canvas_item_request_update (item);
break;
case PROP_OUTLINE_STIPPLE:
set_stipple (poly->outline_gc, &poly->outline_stipple, (GdkBitmap *) g_value_get_object (value), FALSE);
foo_canvas_item_request_update (item);
break;
case PROP_WIDTH_PIXELS:
poly->width = g_value_get_uint (value);
poly->width_pixels = TRUE;
set_outline_gc_width (poly);
#ifdef OLD_XFORM
recalc_bounds (poly);
#else
foo_canvas_item_request_update (item);
#endif
break;
case PROP_WIDTH_UNITS:
poly->width = fabs (g_value_get_double (value));
poly->width_pixels = FALSE;
set_outline_gc_width (poly);
#ifdef OLD_XFORM
recalc_bounds (poly);
#else
foo_canvas_item_request_update (item);
#endif
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
/* Allocates a GdkColor structure filled with the specified pixel, and puts it into the specified
* value for returning it in the get_property method.
*/
static void
get_color_value (FooCanvasPolygon *poly, gulong pixel, GValue *value)
{
GdkColor *color;
GdkColormap *colormap;
color = g_new (GdkColor, 1);
color->pixel = pixel;
colormap = gtk_widget_get_colormap (GTK_WIDGET (poly));
gdk_rgb_find_color (colormap, color);
g_value_set_boxed (value, color);
}
static void
foo_canvas_polygon_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec)
{
FooCanvasPolygon *poly;
FooCanvasPoints *points;
g_return_if_fail (object != NULL);
g_return_if_fail (FOO_IS_CANVAS_POLYGON (object));
poly = FOO_CANVAS_POLYGON (object);
switch (param_id) {
case PROP_POINTS:
if (poly->num_points != 0) {
points = foo_canvas_points_new (poly->num_points);
memcpy (points->coords, poly->coords, 2 * poly->num_points * sizeof (double));
g_value_set_boxed (value, points);
} else
g_value_set_boxed (value, NULL);
break;
case PROP_FILL_COLOR_GDK:
get_color_value (poly, poly->fill_pixel, value);
break;
case PROP_OUTLINE_COLOR_GDK:
get_color_value (poly, poly->outline_pixel, value);
break;
case PROP_FILL_COLOR_RGBA:
g_value_set_uint (value, poly->fill_color);
break;
case PROP_OUTLINE_COLOR_RGBA:
g_value_set_uint (value, poly->outline_color);
break;
case PROP_FILL_STIPPLE:
g_value_set_object (value, (GObject *) poly->fill_stipple);
break;
case PROP_OUTLINE_STIPPLE:
g_value_set_object (value, (GObject *) poly->outline_stipple);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
static void
foo_canvas_polygon_update (FooCanvasItem *item,
double i2w_dx, double i2w_dy,
int flags)
{
FooCanvasPolygon *poly;
double x1, y1, x2, y2;
poly = FOO_CANVAS_POLYGON (item);
if (parent_class->update)
(* parent_class->update) (item, i2w_dx, i2w_dy, flags);
set_outline_gc_width (poly);
set_gc_foreground (poly->fill_gc, poly->fill_pixel);
set_gc_foreground (poly->outline_gc, poly->outline_pixel);
set_stipple (poly->fill_gc, &poly->fill_stipple, poly->fill_stipple, TRUE);
set_stipple (poly->outline_gc, &poly->outline_stipple, poly->outline_stipple, TRUE);
if (get_bounds_canvas (poly, &x1, &y1, &x2, &y2, i2w_dx, i2w_dy))
foo_canvas_update_bbox (item, x1, y1, x2, y2);
}
static void
foo_canvas_polygon_realize (FooCanvasItem *item)
{
FooCanvasPolygon *poly;
poly = FOO_CANVAS_POLYGON (item);
if (parent_class->realize)
(* parent_class->realize) (item);
poly->fill_gc = gdk_gc_new (item->canvas->layout.bin_window);
poly->outline_gc = gdk_gc_new (item->canvas->layout.bin_window);
//#warning "FIXME: Need to recalc pixel values, set colours, etc."
#ifdef OLD_XFORM
(* FOO_CANVAS_ITEM_CLASS (item->object.klass)->update) (item, NULL, NULL, 0);
#endif
}
static void
foo_canvas_polygon_unrealize (FooCanvasItem *item)
{
FooCanvasPolygon *poly;
poly = FOO_CANVAS_POLYGON (item);
g_object_unref (poly->fill_gc);
poly->fill_gc = NULL;
g_object_unref (poly->outline_gc);
poly->outline_gc = NULL;
if (parent_class->unrealize)
(* parent_class->unrealize) (item);
}
/* Converts an array of world coordinates into an array of canvas pixel coordinates. Takes in the
* item->world deltas and the drawable deltas.
*/
static void
item_to_canvas (FooCanvas *canvas, double *item_coords, GdkPoint *canvas_coords, int num_points,
double i2w_dx, double i2w_dy)
{
int i;
for (i = 0; i < num_points; i++) {
foo_canvas_w2c (canvas,
item_coords[i*2] + i2w_dx,
item_coords[i*2+1] + i2w_dy,
&canvas_coords->x, &canvas_coords->y);
canvas_coords++;
}
}
static void
foo_canvas_polygon_draw (FooCanvasItem *item, GdkDrawable *drawable,
GdkEventExpose *expose)
{
FooCanvasPolygon *poly;
GdkPoint static_points[NUM_STATIC_POINTS];
GdkPoint *points;
double i2w_dx, i2w_dy;
poly = FOO_CANVAS_POLYGON (item);
if (poly->num_points == 0)
return;
/* Build array of canvas pixel coordinates */
if (poly->num_points <= NUM_STATIC_POINTS)
points = static_points;
else
points = g_new (GdkPoint, poly->num_points);
i2w_dx = 0.0;
i2w_dy = 0.0;
foo_canvas_item_i2w (item, &i2w_dx, &i2w_dy);
item_to_canvas (item->canvas,
poly->coords, points, poly->num_points,
i2w_dx, i2w_dy);
if (poly->fill_set) {
if (poly->fill_stipple)
foo_canvas_set_stipple_origin (item->canvas, poly->fill_gc);
gdk_draw_polygon (drawable, poly->fill_gc, TRUE, points, poly->num_points);
}
if (poly->outline_set) {
if (poly->outline_stipple)
foo_canvas_set_stipple_origin (item->canvas, poly->outline_gc);
gdk_draw_polygon (drawable, poly->outline_gc, FALSE, points, poly->num_points);
}
/* Done */
if (points != static_points)
g_free (points);
}
static double
foo_canvas_polygon_point (FooCanvasItem *item, double x, double y,
int cx, int cy, FooCanvasItem **actual_item)
{
FooCanvasPolygon *poly;
double dist;
double width;
poly = FOO_CANVAS_POLYGON (item);
*actual_item = item;
dist = foo_canvas_polygon_to_point (poly->coords, poly->num_points, x, y);
if (poly->outline_set) {
if (poly->width_pixels)
width = poly->width / item->canvas->pixels_per_unit;
else
width = poly->width;
dist -= width / 2.0;
if (dist < 0.0)
dist = 0.0;
}
return dist;
}
static void
foo_canvas_polygon_translate (FooCanvasItem *item, double dx, double dy)
{
FooCanvasPolygon *poly;
int i;
double *coords;
poly = FOO_CANVAS_POLYGON (item);
for (i = 0, coords = poly->coords; i < poly->num_points; i++, coords += 2) {
coords[0] += dx;
coords[1] += dy;
}
}
static void
foo_canvas_polygon_bounds (FooCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
{
FooCanvasPolygon *poly;
g_return_if_fail (item != NULL);
g_return_if_fail (FOO_IS_CANVAS_POLYGON (item));
poly = FOO_CANVAS_POLYGON (item);
if (poly->num_points == 0) {
*x1 = *y1 = *x2 = *y2 = 0.0;
return;
}
get_bounds (poly, x1, y1, x2, y2);
}

View File

@ -0,0 +1,123 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
/* Polygon item type for FooCanvas widget
*
* FooCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
*
*
* Author: Federico Mena <federico@nuclecu.unam.mx>
*/
#ifndef FOO_CANVAS_POLYGON_H
#define FOO_CANVAS_POLYGON_H
#include <goffice/cut-n-paste/foocanvas/foo-canvas.h>
G_BEGIN_DECLS
/* Polygon item for the canvas. A polygon is a bit different from rectangles and ellipses in that
* points inside it will always be considered "inside", even if the fill color is not set. If you
* want to have a hollow polygon, use a line item instead.
*
* The following object arguments are available:
*
* name type read/write description
* ------------------------------------------------------------------------------------------
* points FooCanvasPoints* RW Pointer to a FooCanvasPoints structure.
* This can be created by a call to
* foo_canvas_points_new() (in foo-canvas-util.h).
* X coordinates are in the even indices of the
* points->coords array, Y coordinates are in
* the odd indices.
* fill_color string W X color specification for fill color,
* or NULL pointer for no color (transparent).
* fill_color_gdk GdkColor* RW Allocated GdkColor for fill.
* outline_color string W X color specification for outline color,
* or NULL pointer for no color (transparent).
* outline_color_gdk GdkColor* RW Allocated GdkColor for outline.
* fill_stipple GdkBitmap* RW Stipple pattern for fill
* outline_stipple GdkBitmap* RW Stipple pattern for outline
* width_pixels uint RW Width of the outline in pixels. The outline will
* not be scaled when the canvas zoom factor is changed.
* width_units double RW Width of the outline in canvas units. The outline
* will be scaled when the canvas zoom factor is changed.
*/
#define FOO_TYPE_CANVAS_POLYGON (foo_canvas_polygon_get_type ())
#define FOO_CANVAS_POLYGON(obj) (GTK_CHECK_CAST ((obj), FOO_TYPE_CANVAS_POLYGON, FooCanvasPolygon))
#define FOO_CANVAS_POLYGON_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FOO_TYPE_CANVAS_POLYGON, FooCanvasPolygonClass))
#define FOO_IS_CANVAS_POLYGON(obj) (GTK_CHECK_TYPE ((obj), FOO_TYPE_CANVAS_POLYGON))
#define FOO_IS_CANVAS_POLYGON_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FOO_TYPE_CANVAS_POLYGON))
#define FOO_CANVAS_POLYGON_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FOO_TYPE_CANVAS_POLYGON, FooCanvasPolygonClass))
typedef struct _FooCanvasPolygon FooCanvasPolygon;
typedef struct _FooCanvasPolygonClass FooCanvasPolygonClass;
struct _FooCanvasPolygon {
FooCanvasItem item;
double *coords; /* Array of coordinates for the polygon's points. X coords
* are in the even indices, Y coords are in the odd indices.
*/
GdkBitmap *fill_stipple; /* Stipple for fill */
GdkBitmap *outline_stipple; /* Stipple for outline */
GdkGC *fill_gc; /* GC for filling */
GdkGC *outline_gc; /* GC for outline */
gulong fill_pixel; /* Color for fill */
gulong outline_pixel; /* Color for outline */
double width; /* Width of polygon's outline */
int num_points; /* Number of points in the polygon */
guint fill_color; /* Fill color, RGBA */
guint outline_color; /* Outline color, RGBA */
guint32 fill_rgba; /* RGBA color for filling */ /*AA*/
guint32 outline_rgba; /* RGBA color for outline */ /*AA*/
guint fill_set : 1; /* Is fill color set? */
guint outline_set : 1; /* Is outline color set? */
guint width_pixels : 1; /* Is outline width specified in pixels or units? */
};
struct _FooCanvasPolygonClass {
FooCanvasItemClass parent_class;
};
/* Standard Gtk function */
GtkType foo_canvas_polygon_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,176 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
/* Rectangle and ellipse item types for FooCanvas widget
*
* FooCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
*
*
* Author: Federico Mena <federico@nuclecu.unam.mx>
*/
#ifndef FOO_CANVAS_RECT_ELLIPSE_H
#define FOO_CANVAS_RECT_ELLIPSE_H
#include <goffice/cut-n-paste/foocanvas/foo-canvas.h>
G_BEGIN_DECLS
/* Base class for rectangle and ellipse item types. These are defined by their top-left and
* bottom-right corners. Rectangles and ellipses share the following arguments:
*
* name type read/write description
* ------------------------------------------------------------------------------------------
* x1 double RW Leftmost coordinate of rectangle or ellipse
* y1 double RW Topmost coordinate of rectangle or ellipse
* x2 double RW Rightmost coordinate of rectangle or ellipse
* y2 double RW Bottommost coordinate of rectangle or ellipse
* fill_color string W X color specification for fill color,
* or NULL pointer for no color (transparent)
* fill_color_gdk GdkColor* RW Allocated GdkColor for fill
* outline_color string W X color specification for outline color,
* or NULL pointer for no color (transparent)
* outline_color_gdk GdkColor* RW Allocated GdkColor for outline
* fill_stipple GdkBitmap* RW Stipple pattern for fill
* outline_stipple GdkBitmap* RW Stipple pattern for outline
* width_pixels uint RW Width of the outline in pixels. The outline will
* not be scaled when the canvas zoom factor is changed.
* width_units double RW Width of the outline in canvas units. The outline
* will be scaled when the canvas zoom factor is changed.
*/
#define FOO_TYPE_CANVAS_RE (foo_canvas_re_get_type ())
#define FOO_CANVAS_RE(obj) (GTK_CHECK_CAST ((obj), FOO_TYPE_CANVAS_RE, FooCanvasRE))
#define FOO_CANVAS_RE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FOO_TYPE_CANVAS_RE, FooCanvasREClass))
#define FOO_IS_CANVAS_RE(obj) (GTK_CHECK_TYPE ((obj), FOO_TYPE_CANVAS_RE))
#define FOO_IS_CANVAS_RE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FOO_TYPE_CANVAS_RE))
#define FOO_CANVAS_RE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FOO_TYPE_CANVAS_RE, FooCanvasREClass))
typedef struct _FooCanvasRE FooCanvasRE;
typedef struct _FooCanvasREClass FooCanvasREClass;
struct _FooCanvasRE {
FooCanvasItem item;
GdkBitmap *fill_stipple; /* Stipple for fill */
GdkBitmap *outline_stipple; /* Stipple for outline */
GdkGC *fill_gc; /* GC for filling */
GdkGC *outline_gc; /* GC for outline */
gulong fill_pixel; /* Fill color */
gulong outline_pixel; /* Outline color */
double x1, y1, x2, y2; /* Corners of item */
double width; /* Outline width */
guint fill_color; /* Fill color, RGBA */
guint outline_color; /* Outline color, RGBA */
/* Configuration flags */
unsigned int fill_set : 1; /* Is fill color set? */
unsigned int outline_set : 1; /* Is outline color set? */
unsigned int width_pixels : 1; /* Is outline width specified in pixels or units? */
};
struct _FooCanvasREClass {
FooCanvasItemClass parent_class;
};
/* Standard Gtk function */
GType foo_canvas_re_get_type (void) G_GNUC_CONST;
/* Rectangle item. No configurable or queryable arguments are available (use those in
* FooCanvasRE).
*/
#define FOO_TYPE_CANVAS_RECT (foo_canvas_rect_get_type ())
#define FOO_CANVAS_RECT(obj) (GTK_CHECK_CAST ((obj), FOO_TYPE_CANVAS_RECT, FooCanvasRect))
#define FOO_CANVAS_RECT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FOO_TYPE_CANVAS_RECT, FooCanvasRectClass))
#define FOO_IS_CANVAS_RECT(obj) (GTK_CHECK_TYPE ((obj), FOO_TYPE_CANVAS_RECT))
#define FOO_IS_CANVAS_RECT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FOO_TYPE_CANVAS_RECT))
#define FOO_CANVAS_RECT_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FOO_TYPE_CANVAS_RECT, FooCanvasRectClass))
typedef struct _FooCanvasRect FooCanvasRect;
typedef struct _FooCanvasRectPrivate FooCanvasRectPrivate;
typedef struct _FooCanvasRectClass FooCanvasRectClass;
struct _FooCanvasRect {
FooCanvasRE re;
FooCanvasRectPrivate *priv;
};
struct _FooCanvasRectClass {
FooCanvasREClass parent_class;
};
/* Standard Gtk function */
GType foo_canvas_rect_get_type (void) G_GNUC_CONST;
/* Ellipse item. No configurable or queryable arguments are available (use those in
* FooCanvasRE).
*/
#define FOO_TYPE_CANVAS_ELLIPSE (foo_canvas_ellipse_get_type ())
#define FOO_CANVAS_ELLIPSE(obj) (GTK_CHECK_CAST ((obj), FOO_TYPE_CANVAS_ELLIPSE, FooCanvasEllipse))
#define FOO_CANVAS_ELLIPSE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FOO_TYPE_CANVAS_ELLIPSE, FooCanvasEllipseClass))
#define FOO_IS_CANVAS_ELLIPSE(obj) (GTK_CHECK_TYPE ((obj), FOO_TYPE_CANVAS_ELLIPSE))
#define FOO_IS_CANVAS_ELLIPSE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FOO_TYPE_CANVAS_ELLIPSE))
#define FOO_CANVAS_ELLIPSE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FOO_TYPE_CANVAS_ELLIPSE, FooCanvasEllipseClass))
typedef struct _FooCanvasEllipse FooCanvasEllipse;
typedef struct _FooCanvasEllipseClass FooCanvasEllipseClass;
struct _FooCanvasEllipse {
FooCanvasRE re;
};
struct _FooCanvasEllipseClass {
FooCanvasREClass parent_class;
};
/* Standard Gtk function */
GType foo_canvas_ellipse_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,170 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
/* Text item type for FooCanvas widget
*
* FooCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
*
*
* Author: Federico Mena <federico@nuclecu.unam.mx>
* Port to Pango co-done by Gergõ Érdi <cactus@cactus.rulez.org>
*/
#ifndef FOO_CANVAS_TEXT_H
#define FOO_CANVAS_TEXT_H
#include <goffice/cut-n-paste/foocanvas/foo-canvas.h>
G_BEGIN_DECLS
/* Text item for the canvas. Text items are positioned by an anchor point and an anchor direction.
*
* A clipping rectangle may be specified for the text. The rectangle is anchored at the text's anchor
* point, and is specified by clipping width and height parameters. If the clipping rectangle is
* enabled, it will clip the text.
*
* In addition, x and y offset values may be specified. These specify an offset from the anchor
* position. If used in conjunction with the clipping rectangle, these could be used to implement
* simple scrolling of the text within the clipping rectangle.
*
* Properties marked with [*] also have _set properties associated
* with them, that determine if the specified value should be used
* instead of the default (style-defined) values
*
* The following object arguments are available:
*
* name type read/write description
* ------------------------------------------------------------------------------------------
* text string RW The string of the text label
* markup string W A Pango markup string for the text label
*
* x double RW X coordinate of anchor point
* y double RW Y coordinate of anchor point
*
* font string W A string describing the font
* font_desc PangoFontDescription* RW Pointer to a PangoFontDescriptor
* attributes PangoAttrList* RW Pointer to a Pango attribute list
* style PangoStyle RW Pango style of font to use [*]
* variant PangoVariant RW Pango variant of font to use [*]
* weight int RW Pango weight of font to use [*]
* stretch PangoStretch RW Pango stretch of font to use [*]
* size int RW Size (in pixels) of font [*]
* size_points double RW Size (in points) of font
* scale double RW Ratio to scale font [*]
*
* anchor GtkAnchorType RW Anchor side for the text
* justification GtkJustification RW Justification for multiline text
* clip_width double RW Width of clip rectangle
* clip_height double RW Height of clip rectangle
* clip boolean RW Use clipping rectangle?
* x_offset double RW Horizontal offset distance from anchor position
* y_offset double RW Vertical offset distance from anchor position
*
* text_width double R Used to query the width of the rendered text
* text_height double R Used to query the rendered height of the text
*
* fill_color string W X color specification for text
* fill_color_gdk GdkColor* RW Pointer to an allocated GdkColor
* fill_color_rgba guint RW RGBA value used for AA color.
* fill_stipple GdkBitmap* RW Stipple pattern for filling the text
*/
#define FOO_TYPE_CANVAS_TEXT (foo_canvas_text_get_type ())
#define FOO_CANVAS_TEXT(obj) (GTK_CHECK_CAST ((obj), FOO_TYPE_CANVAS_TEXT, FooCanvasText))
#define FOO_CANVAS_TEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FOO_TYPE_CANVAS_TEXT, FooCanvasTextClass))
#define FOO_IS_CANVAS_TEXT(obj) (GTK_CHECK_TYPE ((obj), FOO_TYPE_CANVAS_TEXT))
#define FOO_IS_CANVAS_TEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FOO_TYPE_CANVAS_TEXT))
#define FOO_CANVAS_TEXT_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FOO_TYPE_CANVAS_TEXT, FooCanvasTextClass))
typedef struct _FooCanvasText FooCanvasText;
typedef struct _FooCanvasTextClass FooCanvasTextClass;
typedef struct _FooCanvasTextPrivate FooCanvasTextPrivate;
struct _FooCanvasText {
FooCanvasItem item;
PangoFontDescription *font_desc; /* Font description for text */
PangoAttrList *attr_list; /* Attribute list of the text (caching) */
PangoUnderline underline;
gboolean strikethrough;
int rise;
double scale;
char *text; /* Text to display */
GdkBitmap *stipple; /* Stipple for text */
GdkGC *gc; /* GC for drawing text */
PangoLayout *layout; /* The PangoLayout containing the text */
gulong pixel; /* Fill color */
double x, y; /* Position at anchor */
double clip_width; /* Width of optional clip rectangle */
double clip_height; /* Height of optional clip rectangle */
double xofs, yofs; /* Text offset distance from anchor position */
GtkAnchorType anchor; /* Anchor side for text */
GtkJustification justification; /* Justification for text */
int cx, cy; /* Top-left canvas coordinates for text */
int clip_cx, clip_cy; /* Top-left canvas coordinates for clip rectangle */
int clip_cwidth, clip_cheight; /* Size of clip rectangle in pixels */
int max_width; /* Maximum width of text lines */
int height; /* Rendered text height in pixels */
guint32 rgba; /* RGBA color for text */ /*AA*/
guint clip : 1; /* Use clip rectangle? */
guint underline_set : 1; /* Apply specified underline style? */
guint strike_set : 1; /* Apply specified strikethrough style? */
guint rise_set : 1; /* Apply specified ascension/descension? */
guint scale_set : 1; /* Apply specified font scaling ratio? */
FooCanvasTextPrivate *priv;
};
struct _FooCanvasTextClass {
FooCanvasItemClass parent_class;
};
/* Standard Gtk function */
GtkType foo_canvas_text_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif

View File

@ -0,0 +1,400 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
#include <goffice/goffice-config.h>
#include <glib/gi18n.h>
#include <gsf/gsf-impl-utils.h>
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
/* Miscellaneous utility functions for the FooCanvas widget
*
* FooCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
*
*
* Author: Federico Mena <federico@nuclecu.unam.mx>
*/
#include <sys/types.h>
#include <glib.h>
#include <math.h>
#include "foo-canvas.h"
#include "foo-canvas-util.h"
/*
* Ok, so some systems require magic incantations for M_PI to be defined.
* It's not important enough to worry about.
*/
#ifndef M_PI
#define M_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117
#endif
/**
* foo_canvas_points_new:
* @num_points: The number of points to allocate space for in the array.
*
* Creates a structure that should be used to pass an array of points to
* items.
*
* Return value: A newly-created array of points. It should be filled in
* by the user.
**/
FooCanvasPoints *
foo_canvas_points_new (int num_points)
{
FooCanvasPoints *points;
g_return_val_if_fail (num_points > 1, NULL);
points = g_new (FooCanvasPoints, 1);
points->num_points = num_points;
points->coords = g_new (double, 2 * num_points);
points->ref_count = 1;
return points;
}
/**
* foo_canvas_points_ref:
* @points: A canvas points structure.
*
* Increases the reference count of the specified points structure.
*
* Return value: The canvas points structure itself.
**/
FooCanvasPoints *
foo_canvas_points_ref (FooCanvasPoints *points)
{
g_return_val_if_fail (points != NULL, NULL);
points->ref_count += 1;
return points;
}
/**
* foo_canvas_points_free:
* @points: A canvas points structure.
*
* Decreases the reference count of the specified points structure. If it
* reaches zero, then the structure is freed.
**/
void
foo_canvas_points_free (FooCanvasPoints *points)
{
g_return_if_fail (points != NULL);
points->ref_count -= 1;
if (points->ref_count == 0) {
g_free (points->coords);
g_free (points);
}
}
/**
* foo_canvas_get_miter_points:
* @x1: X coordinate of the first point
* @y1: Y coordinate of the first point
* @x2: X coordinate of the second (angle) point
* @y2: Y coordinate of the second (angle) point
* @x3: X coordinate of the third point
* @y3: Y coordinate of the third point
* @width: Width of the line
* @mx1: The X coordinate of the first miter point is returned here.
* @my1: The Y coordinate of the first miter point is returned here.
* @mx2: The X coordinate of the second miter point is returned here.
* @my2: The Y coordinate of the second miter point is returned here.
*
* Given three points forming an angle, computes the coordinates of the inside
* and outside points of the mitered corner formed by a line of a given width at
* that angle.
*
* Return value: FALSE if the angle is less than 11 degrees (this is the same
* threshold as X uses. If this occurs, the return points are not modified.
* Otherwise, returns TRUE.
**/
int
foo_canvas_get_miter_points (double x1, double y1, double x2, double y2, double x3, double y3,
double width,
double *mx1, double *my1, double *mx2, double *my2)
{
double theta1; /* angle of segment p2-p1 */
double theta2; /* angle of segment p2-p3 */
double theta; /* angle between line segments */
double theta3; /* angle that bisects theta1 and theta2 and points to p1 */
double dist; /* distance of miter points from p2 */
double dx, dy; /* x and y offsets corresponding to dist */
double ELEVEN_DEGREES = 11.0 * M_PI / 180.0;
/* Degenerate cases. */
if ((x1 == x2 && y1 == y2) || (x2 == x3 && y2 == y3))
return FALSE;
theta1 = atan2 (y1 - y2, x1 - x2);
theta2 = atan2 (y3 - y2, x3 - x2);
theta = theta1 - theta2;
/* Normalize to (-pi; pi]. */
if (theta > M_PI)
theta -= 2.0 * M_PI;
else if (theta <= -M_PI)
theta += 2.0 * M_PI;
if (fabs (theta) < ELEVEN_DEGREES)
return FALSE;
dist = fabs (0.5 * width / sin (0.5 * theta));
theta3 = (theta1 + theta2) / 2.0;
if (sin (theta3 - theta1) > 0.0)
theta3 += M_PI;
dx = dist * cos (theta3);
dy = dist * sin (theta3);
*mx1 = x2 + dx;
*mx2 = x2 - dx;
*my1 = y2 + dy;
*my2 = y2 - dy;
return TRUE;
}
/**
* foo_canvas_get_butt_points:
* @x1: X coordinate of first point in the line
* @y1: Y cooordinate of first point in the line
* @x2: X coordinate of second point (endpoint) of the line
* @y2: Y coordinate of second point (endpoint) of the line
* @width: Width of the line
* @project: Whether the butt points should project out by width/2 distance
* @bx1: X coordinate of first butt point is returned here
* @by1: Y coordinate of first butt point is returned here
* @bx2: X coordinate of second butt point is returned here
* @by2: Y coordinate of second butt point is returned here
*
* Computes the butt points of a line segment.
**/
void
foo_canvas_get_butt_points (double x1, double y1, double x2, double y2,
double width, int project,
double *bx1, double *by1, double *bx2, double *by2)
{
double length;
double dx, dy;
width *= 0.5;
dx = x2 - x1;
dy = y2 - y1;
length = sqrt (dx * dx + dy * dy);
if (length < FOO_CANVAS_EPSILON) {
*bx1 = *bx2 = x2;
*by1 = *by2 = y2;
} else {
dx = -width * (y2 - y1) / length;
dy = width * (x2 - x1) / length;
*bx1 = x2 + dx;
*bx2 = x2 - dx;
*by1 = y2 + dy;
*by2 = y2 - dy;
if (project) {
*bx1 += dy;
*bx2 += dy;
*by1 -= dx;
*by2 -= dx;
}
}
}
/**
* foo_canvas_polygon_to_point:
* @poly: Vertices of the polygon. X coordinates are in the even indices, and Y
* coordinates are in the odd indices
* @num_points: Number of points in the polygon
* @x: X coordinate of the point
* @y: Y coordinate of the point
*
* Computes the distance between a point and a polygon.
*
* Return value: The distance from the point to the polygon, or zero if the
* point is inside the polygon.
**/
double
foo_canvas_polygon_to_point (double *poly, int num_points, double x, double y)
{
double best;
int intersections;
int i;
double *p;
double dx, dy;
/* Iterate through all the edges in the polygon, updating best and intersections.
*
* When computing intersections, include left X coordinate of line within its range, but not
* Y coordinate. Otherwise if the point lies exactly below a vertex we'll count it as two
* intersections.
*/
best = 1.0e36;
intersections = 0;
for (i = num_points, p = poly; i > 1; i--, p += 2) {
double px, py, dist;
/* Compute the point on the current edge closest to the point and update the
* intersection count. This must be done separately for vertical edges, horizontal
* edges, and others.
*/
if (p[2] == p[0]) {
/* Vertical edge */
px = p[0];
if (p[1] >= p[3]) {
py = MIN (p[1], y);
py = MAX (py, p[3]);
} else {
py = MIN (p[3], y);
py = MAX (py, p[1]);
}
} else if (p[3] == p[1]) {
/* Horizontal edge */
py = p[1];
if (p[0] >= p[2]) {
px = MIN (p[0], x);
px = MAX (px, p[2]);
if ((y < py) && (x < p[0]) && (x >= p[2]))
intersections++;
} else {
px = MIN (p[2], x);
px = MAX (px, p[0]);
if ((y < py) && (x < p[2]) && (x >= p[0]))
intersections++;
}
} else {
double m1, b1, m2, b2;
int lower;
/* Diagonal edge. Convert the edge to a line equation (y = m1*x + b1), then
* compute a line perpendicular to this edge but passing through the point,
* (y = m2*x + b2).
*/
m1 = (p[3] - p[1]) / (p[2] - p[0]);
b1 = p[1] - m1 * p[0];
m2 = -1.0 / m1;
b2 = y - m2 * x;
px = (b2 - b1) / (m1 - m2);
py = m1 * px + b1;
if (p[0] > p[2]) {
if (px > p[0]) {
px = p[0];
py = p[1];
} else if (px < p[2]) {
px = p[2];
py = p[3];
}
} else {
if (px > p[2]) {
px = p[2];
py = p[3];
} else if (px < p[0]) {
px = p[0];
py = p[1];
}
}
lower = (m1 * x + b1) > y;
if (lower && (x >= MIN (p[0], p[2])) && (x < MAX (p[0], p[2])))
intersections++;
}
/* Compute the distance to the closest point, and see if that is the best so far */
dx = x - px;
dy = y - py;
dist = sqrt (dx * dx + dy * dy);
if (dist < best)
best = dist;
}
/* We've processed all the points. If the number of intersections is odd, the point is
* inside the polygon.
*/
if (intersections & 0x1)
return 0.0;
else
return best;
}
/**
* foo_canvas_item_reset_bounds:
* @item: A canvas item
*
* Resets the bounding box of a canvas item to an empty rectangle.
**/
void
foo_canvas_item_reset_bounds (FooCanvasItem *item)
{
item->x1 = 0.0;
item->y1 = 0.0;
item->x2 = 0.0;
item->y2 = 0.0;
}
/**
* foo_canvas_update_bbox:
* @canvas: the canvas needing update
* @x1: Left coordinate of the new bounding box
* @y1: Top coordinate of the new bounding box
* @x2: Right coordinate of the new bounding box
* @y2: Bottom coordinate of the new bounding box
*
* Sets the bbox to the new value, requesting full repaint.
**/
void
foo_canvas_update_bbox (FooCanvasItem *item, int x1, int y1, int x2, int y2)
{
foo_canvas_item_request_redraw (item);
item->x1 = x1;
item->y1 = y1;
item->x2 = x2;
item->y2 = y2;
foo_canvas_item_request_redraw (item);
}

View File

@ -0,0 +1,107 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
/* Miscellaneous utility functions for the FooCanvas widget
*
* FooCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
*
* Author: Federico Mena <federico@nuclecu.unam.mx>
*/
#ifndef FOO_CANVAS_UTIL_H
#define FOO_CANVAS_UTIL_H
G_BEGIN_DECLS
/* This structure defines an array of points. X coordinates are stored in the even-numbered
* indices, and Y coordinates are stored in the odd-numbered indices. num_points indicates the
* number of points, so the array is 2*num_points elements big.
*/
typedef struct {
double *coords;
int num_points;
int ref_count;
} FooCanvasPoints;
/* Allocate a new FooCanvasPoints structure with enough space for the specified number of points */
FooCanvasPoints *foo_canvas_points_new (int num_points);
/* Increate ref count */
FooCanvasPoints *foo_canvas_points_ref (FooCanvasPoints *points);
#define foo_canvas_points_unref foo_canvas_points_free
/* Decrease ref count and free structure if it has reached zero */
void foo_canvas_points_free (FooCanvasPoints *points);
/* Given three points forming an angle, compute the coordinates of the inside and outside points of
* the mitered corner formed by a line of a given width at that angle.
*
* If the angle is less than 11 degrees, then FALSE is returned and the return points are not
* modified. Otherwise, TRUE is returned.
*/
int foo_canvas_get_miter_points (double x1, double y1, double x2, double y2, double x3, double y3,
double width,
double *mx1, double *my1, double *mx2, double *my2);
/* Compute the butt points of a line segment. If project is FALSE, then the results are as follows:
*
* -------------------* (bx1, by1)
* |
* (x1, y1) *------------------* (x2, y2)
* |
* -------------------* (bx2, by2)
*
* that is, the line is not projected beyond (x2, y2). If project is TRUE, then the results are as
* follows:
*
* -------------------* (bx1, by1)
* (x2, y2) |
* (x1, y1) *-------------* |
* |
* -------------------* (bx2, by2)
*/
void foo_canvas_get_butt_points (double x1, double y1, double x2, double y2,
double width, int project,
double *bx1, double *by1, double *bx2, double *by2);
/* Calculate the distance from a polygon to a point. The polygon's X coordinates are in the even
* indices of the poly array, and the Y coordinates are in the odd indices.
*/
double foo_canvas_polygon_to_point (double *poly, int num_points, double x, double y);
void foo_canvas_item_reset_bounds (FooCanvasItem *item);
/* Sets the bbox to the new value, requesting full repaint. */
void foo_canvas_update_bbox (FooCanvasItem *item, int x1, int y1, int x2, int y2);
G_END_DECLS
#endif

View File

@ -0,0 +1,619 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
#undef GTK_DISABLE_DEPRECATED
#include <goffice/goffice-config.h>
#include <glib/gi18n.h>
#include <gsf/gsf-impl-utils.h>
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
/* Widget item type for FooCanvas widget
*
* FooCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
*
*
* Author: Federico Mena <federico@nuclecu.unam.mx>
*/
#include <math.h>
#include <gtk/gtksignal.h>
#include "foo-canvas-widget.h"
enum {
PROP_0,
PROP_WIDGET,
PROP_X,
PROP_Y,
PROP_WIDTH,
PROP_HEIGHT,
PROP_ANCHOR,
PROP_SIZE_PIXELS
};
static void foo_canvas_widget_class_init (FooCanvasWidgetClass *class);
static void foo_canvas_widget_init (FooCanvasWidget *witem);
static void foo_canvas_widget_destroy (GtkObject *object);
static void foo_canvas_widget_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec);
static void foo_canvas_widget_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec);
static void foo_canvas_widget_update (FooCanvasItem *item, double i2w_dx, double i2w_dy, int flags);
static double foo_canvas_widget_point (FooCanvasItem *item, double x, double y,
int cx, int cy, FooCanvasItem **actual_item);
static void foo_canvas_widget_translate (FooCanvasItem *item, double dx, double dy);
static void foo_canvas_widget_bounds (FooCanvasItem *item, double *x1, double *y1, double *x2, double *y2);
static void foo_canvas_widget_draw (FooCanvasItem *item,
GdkDrawable *drawable,
GdkEventExpose *event);
static void foo_canvas_widget_map (FooCanvasItem *item);
static void foo_canvas_widget_unmap (FooCanvasItem *item);
static FooCanvasItemClass *parent_class;
GtkType
foo_canvas_widget_get_type (void)
{
static GtkType witem_type = 0;
if (!witem_type) {
/* FIXME: Convert to gobject style. */
static const GtkTypeInfo witem_info = {
(char *)"FooCanvasWidget",
sizeof (FooCanvasWidget),
sizeof (FooCanvasWidgetClass),
(GtkClassInitFunc) foo_canvas_widget_class_init,
(GtkObjectInitFunc) foo_canvas_widget_init,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
};
witem_type = gtk_type_unique (foo_canvas_item_get_type (), &witem_info);
}
return witem_type;
}
static void
foo_canvas_widget_class_init (FooCanvasWidgetClass *class)
{
GObjectClass *gobject_class;
GtkObjectClass *object_class;
FooCanvasItemClass *item_class;
gobject_class = (GObjectClass *) class;
object_class = (GtkObjectClass *) class;
item_class = (FooCanvasItemClass *) class;
parent_class = gtk_type_class (foo_canvas_item_get_type ());
gobject_class->set_property = foo_canvas_widget_set_property;
gobject_class->get_property = foo_canvas_widget_get_property;
g_object_class_install_property
(gobject_class,
PROP_WIDGET,
g_param_spec_object ("widget", NULL, NULL,
GTK_TYPE_WIDGET,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_X,
g_param_spec_double ("x", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_Y,
g_param_spec_double ("y", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_WIDTH,
g_param_spec_double ("width", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_HEIGHT,
g_param_spec_double ("height", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_ANCHOR,
g_param_spec_enum ("anchor", NULL, NULL,
GTK_TYPE_ANCHOR_TYPE,
GTK_ANCHOR_NW,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_SIZE_PIXELS,
g_param_spec_boolean ("size-pixels", NULL, NULL,
FALSE,
GSF_PARAM_STATIC | G_PARAM_READWRITE));
object_class->destroy = foo_canvas_widget_destroy;
item_class->update = foo_canvas_widget_update;
item_class->point = foo_canvas_widget_point;
item_class->translate = foo_canvas_widget_translate;
item_class->bounds = foo_canvas_widget_bounds;
item_class->draw = foo_canvas_widget_draw;
item_class->map = foo_canvas_widget_map;
item_class->unmap = foo_canvas_widget_unmap;
}
static void
foo_canvas_widget_init (FooCanvasWidget *witem)
{
witem->x = 0.0;
witem->y = 0.0;
witem->width = 0.0;
witem->height = 0.0;
witem->anchor = GTK_ANCHOR_NW;
witem->size_pixels = FALSE;
}
static void
foo_canvas_widget_destroy (GtkObject *object)
{
FooCanvasWidget *witem;
g_return_if_fail (object != NULL);
g_return_if_fail (FOO_IS_CANVAS_WIDGET (object));
witem = FOO_CANVAS_WIDGET (object);
if (witem->widget && !witem->in_destroy) {
gtk_signal_disconnect (GTK_OBJECT (witem->widget), witem->destroy_id);
gtk_widget_destroy (witem->widget);
witem->widget = NULL;
}
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
recalc_bounds (FooCanvasWidget *witem)
{
FooCanvasItem *item;
double wx, wy;
item = FOO_CANVAS_ITEM (witem);
/* Get world coordinates */
wx = witem->x;
wy = witem->y;
foo_canvas_item_i2w (item, &wx, &wy);
/* Get canvas pixel coordinates */
foo_canvas_w2c (item->canvas, wx, wy, &witem->cx, &witem->cy);
/* Anchor widget item */
switch (witem->anchor) {
case GTK_ANCHOR_NW:
case GTK_ANCHOR_W:
case GTK_ANCHOR_SW:
break;
case GTK_ANCHOR_N:
case GTK_ANCHOR_CENTER:
case GTK_ANCHOR_S:
witem->cx -= witem->cwidth / 2;
break;
case GTK_ANCHOR_NE:
case GTK_ANCHOR_E:
case GTK_ANCHOR_SE:
witem->cx -= witem->cwidth;
break;
default:
break;
}
switch (witem->anchor) {
case GTK_ANCHOR_NW:
case GTK_ANCHOR_N:
case GTK_ANCHOR_NE:
break;
case GTK_ANCHOR_W:
case GTK_ANCHOR_CENTER:
case GTK_ANCHOR_E:
witem->cy -= witem->cheight / 2;
break;
case GTK_ANCHOR_SW:
case GTK_ANCHOR_S:
case GTK_ANCHOR_SE:
witem->cy -= witem->cheight;
break;
default:
break;
}
/* Bounds */
item->x1 = witem->cx;
item->y1 = witem->cy;
item->x2 = witem->cx + witem->cwidth;
item->y2 = witem->cy + witem->cheight;
if (witem->widget)
gtk_layout_move (GTK_LAYOUT (item->canvas), witem->widget,
witem->cx,
witem->cy);
}
static void
do_destroy (GtkObject *object, gpointer data)
{
FooCanvasWidget *witem;
witem = data;
witem->in_destroy = TRUE;
gtk_object_destroy (data);
}
static void
foo_canvas_widget_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec)
{
FooCanvasItem *item;
FooCanvasWidget *witem;
GObject *obj;
int update;
int calc_bounds;
g_return_if_fail (object != NULL);
g_return_if_fail (FOO_IS_CANVAS_WIDGET (object));
item = FOO_CANVAS_ITEM (object);
witem = FOO_CANVAS_WIDGET (object);
update = FALSE;
calc_bounds = FALSE;
switch (param_id) {
case PROP_WIDGET:
if (witem->widget) {
gtk_signal_disconnect (GTK_OBJECT (witem->widget), witem->destroy_id);
gtk_container_remove (GTK_CONTAINER (item->canvas), witem->widget);
}
obj = g_value_get_object (value);
if (obj) {
witem->widget = GTK_WIDGET (obj);
witem->destroy_id = gtk_signal_connect (GTK_OBJECT (obj),
"destroy",
(GtkSignalFunc) do_destroy,
witem);
gtk_layout_put (GTK_LAYOUT (item->canvas), witem->widget,
witem->cx + item->canvas->zoom_xofs,
witem->cy + item->canvas->zoom_yofs);
}
update = TRUE;
break;
case PROP_X:
if (witem->x != g_value_get_double (value))
{
witem->x = g_value_get_double (value);
calc_bounds = TRUE;
}
break;
case PROP_Y:
if (witem->y != g_value_get_double (value))
{
witem->y = g_value_get_double (value);
calc_bounds = TRUE;
}
break;
case PROP_WIDTH:
if (witem->width != fabs (g_value_get_double (value)))
{
witem->width = fabs (g_value_get_double (value));
update = TRUE;
}
break;
case PROP_HEIGHT:
if (witem->height != fabs (g_value_get_double (value)))
{
witem->height = fabs (g_value_get_double (value));
update = TRUE;
}
break;
case PROP_ANCHOR:
if (witem->anchor != (GtkAnchorType)g_value_get_enum (value))
{
witem->anchor = g_value_get_enum (value);
update = TRUE;
}
break;
case PROP_SIZE_PIXELS:
if (witem->size_pixels != g_value_get_boolean (value))
{
witem->size_pixels = g_value_get_boolean (value);
update = TRUE;
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
if (update)
(* FOO_CANVAS_ITEM_GET_CLASS (item)->update) (item, 0, 0, 0);
if (calc_bounds)
recalc_bounds (witem);
}
static void
foo_canvas_widget_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec)
{
FooCanvasWidget *witem;
g_return_if_fail (object != NULL);
g_return_if_fail (FOO_IS_CANVAS_WIDGET (object));
witem = FOO_CANVAS_WIDGET (object);
switch (param_id) {
case PROP_WIDGET:
g_value_set_object (value, (GObject *) witem->widget);
break;
case PROP_X:
g_value_set_double (value, witem->x);
break;
case PROP_Y:
g_value_set_double (value, witem->y);
break;
case PROP_WIDTH:
g_value_set_double (value, witem->width);
break;
case PROP_HEIGHT:
g_value_set_double (value, witem->height);
break;
case PROP_ANCHOR:
g_value_set_enum (value, witem->anchor);
break;
case PROP_SIZE_PIXELS:
g_value_set_boolean (value, witem->size_pixels);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
static void
foo_canvas_widget_update (FooCanvasItem *item, double i2w_dx, double i2w_dy, int flags)
{
FooCanvasWidget *witem;
witem = FOO_CANVAS_WIDGET (item);
if (parent_class->update)
(* parent_class->update) (item, i2w_dx, i2w_dy, flags);
if (witem->widget) {
if (witem->size_pixels) {
witem->cwidth = (int) (witem->width + 0.5);
witem->cheight = (int) (witem->height + 0.5);
} else {
witem->cwidth = (int) (witem->width * item->canvas->pixels_per_unit + 0.5);
witem->cheight = (int) (witem->height * item->canvas->pixels_per_unit + 0.5);
}
gtk_widget_set_usize (witem->widget, witem->cwidth, witem->cheight);
} else {
witem->cwidth = 0.0;
witem->cheight = 0.0;
}
recalc_bounds (witem);
}
static void
foo_canvas_widget_draw (FooCanvasItem *item,
GdkDrawable *drawable,
GdkEventExpose *event)
{
#if 0
FooCanvasWidget *witem;
witem = FOO_CANVAS_WIDGET (item);
if (witem->widget)
gtk_widget_queue_draw (witem->widget);
#endif
}
static void
foo_canvas_widget_map (FooCanvasItem *item)
{
FooCanvasWidget *witem = FOO_CANVAS_WIDGET (item);
if (parent_class->map)
(* parent_class->map) (item);
if (witem->widget && GTK_WIDGET_VISIBLE (witem->widget))
gtk_widget_map (witem->widget);
}
static void
foo_canvas_widget_unmap (FooCanvasItem *item)
{
FooCanvasWidget *witem = FOO_CANVAS_WIDGET (item);
if (parent_class->unmap)
(* parent_class->unmap) (item);
gtk_widget_unmap (witem->widget);
}
static double
foo_canvas_widget_point (FooCanvasItem *item, double x, double y,
int cx, int cy, FooCanvasItem **actual_item)
{
FooCanvasWidget *witem;
double x1, y1, x2, y2;
double dx, dy;
witem = FOO_CANVAS_WIDGET (item);
*actual_item = item;
foo_canvas_c2w (item->canvas, witem->cx, witem->cy, &x1, &y1);
x2 = x1 + (witem->cwidth - 1) / item->canvas->pixels_per_unit;
y2 = y1 + (witem->cheight - 1) / item->canvas->pixels_per_unit;
/* Is point inside widget bounds? */
if ((x >= x1) && (y >= y1) && (x <= x2) && (y <= y2))
return 0.0;
/* Point is outside widget bounds */
if (x < x1)
dx = x1 - x;
else if (x > x2)
dx = x - x2;
else
dx = 0.0;
if (y < y1)
dy = y1 - y;
else if (y > y2)
dy = y - y2;
else
dy = 0.0;
return sqrt (dx * dx + dy * dy);
}
static void
foo_canvas_widget_translate (FooCanvasItem *item, double dx, double dy)
{
FooCanvasWidget *witem;
witem = FOO_CANVAS_WIDGET (item);
witem->x += dx;
witem->y += dy;
}
static void
foo_canvas_widget_bounds (FooCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
{
FooCanvasWidget *witem;
witem = FOO_CANVAS_WIDGET (item);
*x1 = witem->x;
*y1 = witem->y;
switch (witem->anchor) {
case GTK_ANCHOR_NW:
case GTK_ANCHOR_W:
case GTK_ANCHOR_SW:
break;
case GTK_ANCHOR_N:
case GTK_ANCHOR_CENTER:
case GTK_ANCHOR_S:
*x1 -= witem->width / 2.0;
break;
case GTK_ANCHOR_NE:
case GTK_ANCHOR_E:
case GTK_ANCHOR_SE:
*x1 -= witem->width;
break;
default:
break;
}
switch (witem->anchor) {
case GTK_ANCHOR_NW:
case GTK_ANCHOR_N:
case GTK_ANCHOR_NE:
break;
case GTK_ANCHOR_W:
case GTK_ANCHOR_CENTER:
case GTK_ANCHOR_E:
*y1 -= witem->height / 2.0;
break;
case GTK_ANCHOR_SW:
case GTK_ANCHOR_S:
case GTK_ANCHOR_SE:
*y1 -= witem->height;
break;
default:
break;
}
*x2 = *x1 + witem->width;
*y2 = *y1 + witem->height;
}

View File

@ -0,0 +1,105 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
/* Widget item type for FooCanvas widget
*
* FooCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
*
*
* Author: Federico Mena <federico@nuclecu.unam.mx>
*/
#ifndef FOO_CANVAS_WIDGET_H
#define FOO_CANVAS_WIDGET_H
#include <goffice/cut-n-paste/foocanvas/foo-canvas.h>
G_BEGIN_DECLS
/* Widget item for canvas. The widget is positioned with respect to an anchor point.
* The following object arguments are available:
*
* name type read/write description
* ------------------------------------------------------------------------------------------
* widget GtkWidget* RW Pointer to the widget
* x double RW X coordinate of anchor point
* y double RW Y coordinate of anchor point
* width double RW Width of widget (see below)
* height double RW Height of widget (see below)
* anchor GtkAnchorType RW Anchor side for widget
* size_pixels boolean RW Specifies whether the widget size
* is specified in pixels or canvas units.
* If it is in pixels, then the widget will not
* be scaled when the canvas zoom factor changes.
* Otherwise, it will be scaled.
*/
#define FOO_TYPE_CANVAS_WIDGET (foo_canvas_widget_get_type ())
#define FOO_CANVAS_WIDGET(obj) (GTK_CHECK_CAST ((obj), FOO_TYPE_CANVAS_WIDGET, FooCanvasWidget))
#define FOO_CANVAS_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FOO_TYPE_CANVAS_WIDGET, FooCanvasWidgetClass))
#define FOO_IS_CANVAS_WIDGET(obj) (GTK_CHECK_TYPE ((obj), FOO_TYPE_CANVAS_WIDGET))
#define FOO_IS_CANVAS_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FOO_TYPE_CANVAS_WIDGET))
#define FOO_CANVAS_WIDGET_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FOO_TYPE_CANVAS_WIDGET, FooCanvasWidgetClass))
typedef struct _FooCanvasWidget FooCanvasWidget;
typedef struct _FooCanvasWidgetClass FooCanvasWidgetClass;
struct _FooCanvasWidget {
FooCanvasItem item;
GtkWidget *widget; /* The child widget */
double x, y; /* Position at anchor */
double width, height; /* Dimensions of widget */
GtkAnchorType anchor; /* Anchor side for widget */
int cx, cy; /* Top-left canvas coordinates for widget */
int cwidth, cheight; /* Size of widget in pixels */
guint destroy_id; /* Signal connection id for destruction of child widget */
guint size_pixels : 1; /* Is size specified in (unchanging) pixels or units (get scaled)? */
guint in_destroy : 1; /* Is child widget being destroyed? */
};
struct _FooCanvasWidgetClass {
FooCanvasItemClass parent_class;
};
/* Standard Gtk function */
GtkType foo_canvas_widget_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,532 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
/* FooCanvas widget - Tk-like canvas widget for Gnome
*
* FooCanvas is basically a port of the Tk toolkit's most excellent canvas
* widget. Tk is copyrighted by the Regents of the University of California,
* Sun Microsystems, and other parties.
*
*
* Authors: Federico Mena <federico@nuclecu.unam.mx>
* Raph Levien <raph@gimp.org>
*/
#ifndef FOO_CANVAS_H
#define FOO_CANVAS_H
#include <gtk/gtklayout.h>
#include <gdk/gdkevents.h>
#include <stdarg.h>
G_BEGIN_DECLS
/* "Small" value used by canvas stuff */
#define FOO_CANVAS_EPSILON 1e-10
/* Macros for building colors that fit in a 32-bit integer. The values are in
* [0, 255].
*/
#define FOO_CANVAS_COLOR(r, g, b) ((((int) (r) & 0xff) << 24) \
| (((int) (g) & 0xff) << 16) \
| (((int) (b) & 0xff) << 8) \
| 0xff)
#define FOO_CANVAS_COLOR_A(r, g, b, a) ((((int) (r) & 0xff) << 24) \
| (((int) (g) & 0xff) << 16) \
| (((int) (b) & 0xff) << 8) \
| ((int) (a) & 0xff))
typedef struct _FooCanvas FooCanvas;
typedef struct _FooCanvasClass FooCanvasClass;
typedef struct _FooCanvasItem FooCanvasItem;
typedef struct _FooCanvasItemClass FooCanvasItemClass;
typedef struct _FooCanvasGroup FooCanvasGroup;
typedef struct _FooCanvasGroupClass FooCanvasGroupClass;
/* FooCanvasItem - base item class for canvas items
*
* All canvas items are derived from FooCanvasItem. The only information a
* FooCanvasItem contains is its parent canvas, its parent canvas item group,
* and its bounding box in world coordinates.
*
* Items inside a canvas are organized in a tree of FooCanvasItemGroup nodes
* and FooCanvasItem leaves. Each canvas has a single root group, which can
* be obtained with the foo_canvas_get_root() function.
*
* The abstract FooCanvasItem class does not have any configurable or
* queryable attributes.
*/
/* Object flags for items */
enum {
FOO_CANVAS_ITEM_REALIZED = 1 << 4,
FOO_CANVAS_ITEM_MAPPED = 1 << 5,
FOO_CANVAS_ITEM_ALWAYS_REDRAW = 1 << 6,
FOO_CANVAS_ITEM_VISIBLE = 1 << 7,
FOO_CANVAS_ITEM_NEED_UPDATE = 1 << 8,
FOO_CANVAS_ITEM_NEED_DEEP_UPDATE = 1 << 9
};
/* Update flags for items */
enum {
FOO_CANVAS_UPDATE_REQUESTED = 1 << 0,
FOO_CANVAS_UPDATE_DEEP = 1 << 1
};
#define FOO_TYPE_CANVAS_ITEM (foo_canvas_item_get_type ())
#define FOO_CANVAS_ITEM(obj) (GTK_CHECK_CAST ((obj), FOO_TYPE_CANVAS_ITEM, FooCanvasItem))
#define FOO_CANVAS_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FOO_TYPE_CANVAS_ITEM, FooCanvasItemClass))
#define FOO_IS_CANVAS_ITEM(obj) (GTK_CHECK_TYPE ((obj), FOO_TYPE_CANVAS_ITEM))
#define FOO_IS_CANVAS_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FOO_TYPE_CANVAS_ITEM))
#define FOO_CANVAS_ITEM_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FOO_TYPE_CANVAS_ITEM, FooCanvasItemClass))
struct _FooCanvasItem {
GtkObject object;
/* Parent canvas for this item */
FooCanvas *canvas;
/* Parent canvas group for this item (a FooCanvasGroup) */
FooCanvasItem *parent;
/* Bounding box for this item (in canvas coordinates) */
double x1, y1, x2, y2;
};
struct _FooCanvasItemClass {
GtkObjectClass parent_class;
/* Tell the item to update itself. The flags are from the update flags
* defined above. The item should update its internal state from its
* queued state, and recompute and request its repaint area. The
* update method also recomputes the bounding box of the item.
*/
void (* update) (FooCanvasItem *item, double i2w_dx, double i2w_dy, int flags);
/* Realize an item -- create GCs, etc. */
void (* realize) (FooCanvasItem *item);
/* Unrealize an item */
void (* unrealize) (FooCanvasItem *item);
/* Map an item - normally only need by items with their own GdkWindows */
void (* map) (FooCanvasItem *item);
/* Unmap an item */
void (* unmap) (FooCanvasItem *item);
/* Draw an item of this type. (x, y) are the upper-left canvas pixel
* coordinates of the drawable, a temporary pixmap, where things get
* drawn. (width, height) are the dimensions of the drawable.
*/
void (* draw) (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose);
/* Calculate the distance from an item to the specified point. It also
* returns a canvas item which is the item itself in the case of the
* object being an actual leaf item, or a child in case of the object
* being a canvas group. (cx, cy) are the canvas pixel coordinates that
* correspond to the item-relative coordinates (x, y).
*/
double (* point) (FooCanvasItem *item, double x, double y, int cx, int cy,
FooCanvasItem **actual_item);
void (* translate) (FooCanvasItem *item, double dx, double dy);
/* Fetch the item's bounding box (need not be exactly tight). This
* should be in item-relative coordinates.
*/
void (* bounds) (FooCanvasItem *item, double *x1, double *y1, double *x2, double *y2);
/* Signal: an event ocurred for an item of this type. The (x, y)
* coordinates are in the canvas world coordinate system.
*/
gboolean (* event) (FooCanvasItem *item, GdkEvent *event);
/* Reserved for future expansion */
gpointer spare_vmethods [4];
};
/* Standard Gtk function */
GType foo_canvas_item_get_type (void) G_GNUC_CONST;
/* Create a canvas item using the standard Gtk argument mechanism. The item is
* automatically inserted at the top of the specified canvas group. The last
* argument must be a NULL pointer.
*/
FooCanvasItem *foo_canvas_item_new (FooCanvasGroup *parent, GType type,
const gchar *first_arg_name, ...);
/* Constructors for use in derived classes and language wrappers */
void foo_canvas_item_construct (FooCanvasItem *item, FooCanvasGroup *parent,
const gchar *first_arg_name, va_list args);
/* Configure an item using the standard Gtk argument mechanism. The last
* argument must be a NULL pointer.
*/
void foo_canvas_item_set (FooCanvasItem *item, const gchar *first_arg_name, ...);
/* Used only for language wrappers and the like */
void foo_canvas_item_set_valist (FooCanvasItem *item,
const gchar *first_arg_name, va_list args);
/* Move an item by the specified amount */
void foo_canvas_item_move (FooCanvasItem *item, double dx, double dy);
/* Raise an item in the z-order of its parent group by the specified number of
* positions.
*/
void foo_canvas_item_raise (FooCanvasItem *item, int positions);
/* Lower an item in the z-order of its parent group by the specified number of
* positions.
*/
void foo_canvas_item_lower (FooCanvasItem *item, int positions);
/* Raise an item to the top of its parent group's z-order. */
void foo_canvas_item_raise_to_top (FooCanvasItem *item);
/* Lower an item to the bottom of its parent group's z-order */
void foo_canvas_item_lower_to_bottom (FooCanvasItem *item);
/* Send an item behind another item */
void foo_canvas_item_send_behind (FooCanvasItem *item,
FooCanvasItem *behind_item);
/* Show an item (make it visible). If the item is already shown, it has no
* effect.
*/
void foo_canvas_item_show (FooCanvasItem *item);
/* Hide an item (make it invisible). If the item is already invisible, it has
* no effect.
*/
void foo_canvas_item_hide (FooCanvasItem *item);
/* Grab the mouse for the specified item. Only the events in event_mask will be
* reported. If cursor is non-NULL, it will be used during the duration of the
* grab. Time is a proper X event time parameter. Returns the same values as
* XGrabPointer().
*/
int foo_canvas_item_grab (FooCanvasItem *item, unsigned int event_mask,
GdkCursor *cursor, guint32 etime);
/* Ungrabs the mouse -- the specified item must be the same that was passed to
* foo_canvas_item_grab(). Time is a proper X event time parameter.
*/
void foo_canvas_item_ungrab (FooCanvasItem *item, guint32 etime);
/* These functions convert from a coordinate system to another. "w" is world
* coordinates and "i" is item coordinates.
*/
void foo_canvas_item_w2i (FooCanvasItem *item, double *x, double *y);
void foo_canvas_item_i2w (FooCanvasItem *item, double *x, double *y);
/* Remove the item from its parent group and make the new group its parent. The
* item will be put on top of all the items in the new group. The item's
* coordinates relative to its new parent to *not* change -- this means that the
* item could potentially move on the screen.
*
* The item and the group must be in the same canvas. An item cannot be
* reparented to a group that is the item itself or that is an inferior of the
* item.
*/
void foo_canvas_item_reparent (FooCanvasItem *item, FooCanvasGroup *new_group);
/* Used to send all of the keystroke events to a specific item as well as
* GDK_FOCUS_CHANGE events.
*/
void foo_canvas_item_grab_focus (FooCanvasItem *item);
/* Fetch the bounding box of the item. The bounding box may not be exactly
* tight, but the canvas items will do the best they can. The returned bounding
* box is in the coordinate system of the item's parent.
*/
void foo_canvas_item_get_bounds (FooCanvasItem *item,
double *x1, double *y1, double *x2, double *y2);
/* Request that the update method eventually get called. This should be used
* only by item implementations.
*/
void foo_canvas_item_request_update (FooCanvasItem *item);
/* Request a redraw of the bounding box of the canvas item */
void foo_canvas_item_request_redraw (FooCanvasItem *item);
/* FooCanvasGroup - a group of canvas items
*
* A group is a node in the hierarchical tree of groups/items inside a canvas.
* Groups serve to give a logical structure to the items.
*
* Consider a circuit editor application that uses the canvas for its schematic
* display. Hierarchically, there would be canvas groups that contain all the
* components needed for an "adder", for example -- this includes some logic
* gates as well as wires. You can move stuff around in a convenient way by
* doing a foo_canvas_item_move() of the hierarchical groups -- to move an
* adder, simply move the group that represents the adder.
*
* The following arguments are available:
*
* name type read/write description
* --------------------------------------------------------------------------------
* x double RW X coordinate of group's origin
* y double RW Y coordinate of group's origin
*/
#define FOO_TYPE_CANVAS_GROUP (foo_canvas_group_get_type ())
#define FOO_CANVAS_GROUP(obj) (GTK_CHECK_CAST ((obj), FOO_TYPE_CANVAS_GROUP, FooCanvasGroup))
#define FOO_CANVAS_GROUP_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FOO_TYPE_CANVAS_GROUP, FooCanvasGroupClass))
#define FOO_IS_CANVAS_GROUP(obj) (GTK_CHECK_TYPE ((obj), FOO_TYPE_CANVAS_GROUP))
#define FOO_IS_CANVAS_GROUP_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FOO_TYPE_CANVAS_GROUP))
#define FOO_CANVAS_GROUP_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FOO_TYPE_CANVAS_GROUP, FooCanvasGroupClass))
struct _FooCanvasGroup {
FooCanvasItem item;
double xpos, ypos;
/* Children of the group */
GList *item_list;
GList *item_list_end;
};
struct _FooCanvasGroupClass {
FooCanvasItemClass parent_class;
};
/* Standard Gtk function */
GType foo_canvas_group_get_type (void) G_GNUC_CONST;
/*** FooCanvas ***/
#define FOO_TYPE_CANVAS (foo_canvas_get_type ())
#define FOO_CANVAS(obj) (GTK_CHECK_CAST ((obj), FOO_TYPE_CANVAS, FooCanvas))
#define FOO_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FOO_TYPE_CANVAS, FooCanvasClass))
#define FOO_IS_CANVAS(obj) (GTK_CHECK_TYPE ((obj), FOO_TYPE_CANVAS))
#define FOO_IS_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FOO_TYPE_CANVAS))
#define FOO_CANVAS_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FOO_TYPE_CANVAS, FooCanvasClass))
struct _FooCanvas {
GtkLayout layout;
/* Root canvas group */
FooCanvasItem *root;
/* The item containing the mouse pointer, or NULL if none */
FooCanvasItem *current_item;
/* Item that is about to become current (used to track deletions and such) */
FooCanvasItem *new_current_item;
/* Item that holds a pointer grab, or NULL if none */
FooCanvasItem *grabbed_item;
/* If non-NULL, the currently focused item */
FooCanvasItem *focused_item;
/* GC for temporary draw pixmap */
GdkGC *pixmap_gc;
/* Event on which selection of current item is based */
GdkEvent pick_event;
/* Scrolling region */
double scroll_x1, scroll_y1;
double scroll_x2, scroll_y2;
/* Scaling factor to be used for display */
double pixels_per_unit;
/* Idle handler ID */
guint idle_id;
/* Signal handler ID for destruction of the root item */
guint root_destroy_id;
/* Internal pixel offsets when zoomed out */
int zoom_xofs, zoom_yofs;
/* Last known modifier state, for deferred repick when a button is down */
int state;
/* Event mask specified when grabbing an item */
guint grabbed_event_mask;
/* Tolerance distance for picking items */
int close_enough;
/* Whether the canvas should center the canvas in the middle of
* the window if the scroll region is smaller than the window */
unsigned int center_scroll_region : 1;
/* Whether items need update at next idle loop iteration */
unsigned int need_update : 1;
/* Are we in the midst of an update */
unsigned int doing_update : 1;
/* Whether the canvas needs redrawing at the next idle loop iteration */
unsigned int need_redraw : 1;
/* Whether current item will be repicked at next idle loop iteration */
unsigned int need_repick : 1;
/* For use by internal pick_current_item() function */
unsigned int left_grabbed_item : 1;
/* For use by internal pick_current_item() function */
unsigned int in_repick : 1;
};
struct _FooCanvasClass {
GtkLayoutClass parent_class;
/* Draw the background for the area given.
*/
void (* draw_background) (FooCanvas *canvas,
int x, int y, int width, int height);
/* Private Virtual methods for groping the canvas inside bonobo */
void (* request_update) (FooCanvas *canvas);
/* Reserved for future expansion */
gpointer spare_vmethods [4];
};
/* Standard Gtk function */
GType foo_canvas_get_type (void) G_GNUC_CONST;
/* Creates a new canvas. You should check that the canvas is created with the
* proper visual and colormap. Any visual will do unless you intend to insert
* gdk_imlib images into it, in which case you should use the gdk_imlib visual.
*
* You should call foo_canvas_set_scroll_region() soon after calling this
* function to set the desired scrolling limits for the canvas.
*/
GtkWidget *foo_canvas_new (void);
/* Returns the root canvas item group of the canvas */
FooCanvasGroup *foo_canvas_root (FooCanvas *canvas);
/* Sets the limits of the scrolling region, in world coordinates */
void foo_canvas_set_scroll_region (FooCanvas *canvas,
double x1, double y1, double x2, double y2);
/* Gets the limits of the scrolling region, in world coordinates */
void foo_canvas_get_scroll_region (FooCanvas *canvas,
double *x1, double *y1, double *x2, double *y2);
/* Sets the number of pixels that correspond to one unit in world coordinates */
void foo_canvas_set_pixels_per_unit (FooCanvas *canvas, double n);
/* Wether the canvas centers the scroll region if it is smaller than the window */
void foo_canvas_set_center_scroll_region (FooCanvas *canvas, gboolean center_scroll_region);
/* Scrolls the canvas to the specified offsets, given in canvas pixel coordinates */
void foo_canvas_scroll_to (FooCanvas *canvas, int cx, int cy);
/* Returns the scroll offsets of the canvas in canvas pixel coordinates. You
* can specify NULL for any of the values, in which case that value will not be
* queried.
*/
void foo_canvas_get_scroll_offsets (FooCanvas *canvas, int *cx, int *cy);
/* Requests that the canvas be repainted immediately instead of in the idle
* loop.
*/
void foo_canvas_update_now (FooCanvas *canvas);
/* Returns the item that is at the specified position in world coordinates, or
* NULL if no item is there.
*/
FooCanvasItem *foo_canvas_get_item_at (FooCanvas *canvas, double x, double y);
/* For use only by item type implementations. Request that the canvas
* eventually redraw the specified region, specified in canvas pixel
* coordinates. The region contains (x1, y1) but not (x2, y2).
*/
void foo_canvas_request_redraw (FooCanvas *canvas, int x1, int y1, int x2, int y2);
/* These functions convert from a coordinate system to another. "w" is world
* coordinates, "c" is canvas pixel coordinates (pixel coordinates that are
* (0,0) for the upper-left scrolling limit and something else for the
* lower-left scrolling limit).
*/
void foo_canvas_w2c_rect_d (FooCanvas *canvas,
double *x1, double *y1,
double *x2, double *y2);
void foo_canvas_w2c (FooCanvas *canvas, double wx, double wy, int *cx, int *cy);
void foo_canvas_w2c_d (FooCanvas *canvas, double wx, double wy, double *cx, double *cy);
void foo_canvas_c2w (FooCanvas *canvas, int cx, int cy, double *wx, double *wy);
/* This function takes in coordinates relative to the GTK_LAYOUT
* (canvas)->bin_window and converts them to world coordinates.
* These days canvas coordinates and window coordinates are the same, but
* these are left for backwards compat reasons.
*/
void foo_canvas_window_to_world (FooCanvas *canvas,
double winx, double winy, double *worldx, double *worldy);
/* This is the inverse of foo_canvas_window_to_world() */
void foo_canvas_world_to_window (FooCanvas *canvas,
double worldx, double worldy, double *winx, double *winy);
/* Takes a string specification for a color and allocates it into the specified
* GdkColor. If the string is null, then it returns FALSE. Otherwise, it
* returns TRUE.
*/
int foo_canvas_get_color (FooCanvas *canvas, const char *spec, GdkColor *color);
/* Allocates a color from the RGB value passed into this function. */
gulong foo_canvas_get_color_pixel (FooCanvas *canvas,
guint rgba);
/* Sets the stipple origin of the specified gc so that it will be aligned with
* all the stipples used in the specified canvas. This is intended for use only
* by canvas item implementations.
*/
void foo_canvas_set_stipple_origin (FooCanvas *canvas, GdkGC *gc);
G_END_DECLS
#endif

View File

@ -0,0 +1,47 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
#ifndef LIBFOOCANVAS_H
#define LIBFOOCANVAS_H
#include <goffice/cut-n-paste/foocanvas/foo-canvas.h>
#include <goffice/cut-n-paste/foocanvas/foo-canvas-line.h>
#include <goffice/cut-n-paste/foocanvas/foo-canvas-text.h>
#include <goffice/cut-n-paste/foocanvas/foo-canvas-polygon.h>
#include <goffice/cut-n-paste/foocanvas/foo-canvas-pixbuf.h>
#include <goffice/cut-n-paste/foocanvas/foo-canvas-widget.h>
#include <goffice/cut-n-paste/foocanvas/foo-canvas-rect-ellipse.h>
#include <goffice/cut-n-paste/foocanvas/foo-canvas-util.h>
G_BEGIN_DECLS
GType foo_canvas_points_get_type (void);
#define FOO_TYPE_CANVAS_POINTS foo_canvas_points_get_type()
G_END_DECLS
#endif /* LIBFOOCANVAS_H */

View File

@ -0,0 +1,47 @@
/* File import from foocanvas to libgoffice by import-foocanvas. Do not edit. */
#include <goffice/goffice-config.h>
#include <glib/gi18n.h>
#include <gsf/gsf-impl-utils.h>
/*
* Copyright (C) 1999, 2000 Red Hat, Inc.
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
@NOTATION@
*/
#include <glib-object.h>
#include <goffice/cut-n-paste/foocanvas/libfoocanvas.h>
GType
foo_canvas_points_get_type (void)
{
static GType type_canvas_points = 0;
if (!type_canvas_points)
type_canvas_points = g_boxed_type_register_static
("FooCanvasPoints",
(GBoxedCopyFunc) foo_canvas_points_ref,
(GBoxedFreeFunc) foo_canvas_points_unref);
return type_canvas_points;
}

View File

@ -0,0 +1,45 @@
PCRE LICENCE
------------
PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Release 5 of PCRE is distributed under the terms of the "BSD" licence, as
specified below. The documentation for PCRE, supplied in the "doc"
directory, is distributed under the same terms as the software itself.
Written by: Philip Hazel <ph10@cam.ac.uk>
University of Cambridge Computing Service,
Cambridge, England. Phone: +44 1223 334714.
Copyright (c) 1997-2004 University of Cambridge
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
End

View File

@ -0,0 +1,17 @@
noinst_LTLIBRARIES = libpcre.la
libpcre_la_SOURCES = maketables.c get.c study.c pcre.c pcreposix.c
EXTRA_DIST = COPYING
libpcre_a_ladir = $(includedir)/libgoffice-1/goffice/cut-n-paste/pcre
libpcre_a_la_HEADERS = pcreposix.h
noinst_HEADERS = internal.h pcre.h
AM_CPPFLAGS = \
$(GOFFICE_DEPS_CFLAGS) \
-I$(top_builddir)/lib/goffice-0.0.4 \
-DSUPPORT_UTF8 \
-DNEWLINE=10 \
-DPOSIX_MALLOC_THRESHOLD=100 \
-DLINK_SIZE=2 \
-DMATCH_LIMIT=10000000

View File

@ -0,0 +1,378 @@
/* File import from pcre to goffice by import-pcre. Do not edit. */
/* This file has been programatically changed. */
/* This makes the following file fall under GPL license, see below. */
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/*
This is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language. See
the file Tech.Notes for some information on the internals.
Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2003 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This module contains some convenience functions for extracting substrings
from the subject string after a regex match has succeeded. The original idea
for these functions came from Scott Wimer. */
/* Include the internals header, which itself includes Standard C headers plus
the external pcre header. */
#include <goffice/goffice-config.h>
#include "internal.h"
/*************************************************
* Find number for named string *
*************************************************/
/* This function is used by the two extraction functions below, as well
as being generally available.
Arguments:
code the compiled regex
stringname the name whose number is required
Returns: the number of the named parentheses, or a negative number
(PCRE_ERROR_NOSUBSTRING) if not found
*/
int
pcre_get_stringnumber (const pcre * code, const char *stringname)
{
int rc;
int entrysize;
int top, bot;
uschar *nametable;
if ((rc = pcre_fullinfo (code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
return rc;
if (top <= 0)
return PCRE_ERROR_NOSUBSTRING;
if (
(rc =
pcre_fullinfo (code, NULL, PCRE_INFO_NAMEENTRYSIZE,
&entrysize)) != 0) return rc;
if ((rc = pcre_fullinfo (code, NULL, PCRE_INFO_NAMETABLE, &nametable))
!= 0)
return rc;
bot = 0;
while (top > bot) {
int mid = (top + bot) / 2;
uschar *entry = nametable + entrysize * mid;
int c = strcmp (stringname, (char *) (entry + 2));
if (c == 0)
return (entry[0] << 8) + entry[1];
if (c > 0)
bot = mid + 1;
else
top = mid;
}
return PCRE_ERROR_NOSUBSTRING;
}
/*************************************************
* Copy captured string to given buffer *
*************************************************/
/* This function copies a single captured substring into a given buffer.
Note that we use memcpy() rather than strncpy() in case there are binary zeros
in the string.
Arguments:
subject the subject string that was matched
ovector pointer to the offsets table
stringcount the number of substrings that were captured
(i.e. the yield of the pcre_exec call, unless
that was zero, in which case it should be 1/3
of the offset table size)
stringnumber the number of the required substring
buffer where to put the substring
size the size of the buffer
Returns: if successful:
the length of the copied string, not including the zero
that is put on the end; can be zero
if not successful:
PCRE_ERROR_NOMEMORY (-6) buffer too small
PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
*/
int
pcre_copy_substring (const char *subject, int *ovector, int stringcount,
int stringnumber, char *buffer, int size)
{
int yield;
if (stringnumber < 0 || stringnumber >= stringcount)
return PCRE_ERROR_NOSUBSTRING;
stringnumber *= 2;
yield = ovector[stringnumber + 1] - ovector[stringnumber];
if (size < yield + 1)
return PCRE_ERROR_NOMEMORY;
memcpy (buffer, subject + ovector[stringnumber], yield);
buffer[yield] = 0;
return yield;
}
/*************************************************
* Copy named captured string to given buffer *
*************************************************/
/* This function copies a single captured substring into a given buffer,
identifying it by name.
Arguments:
code the compiled regex
subject the subject string that was matched
ovector pointer to the offsets table
stringcount the number of substrings that were captured
(i.e. the yield of the pcre_exec call, unless
that was zero, in which case it should be 1/3
of the offset table size)
stringname the name of the required substring
buffer where to put the substring
size the size of the buffer
Returns: if successful:
the length of the copied string, not including the zero
that is put on the end; can be zero
if not successful:
PCRE_ERROR_NOMEMORY (-6) buffer too small
PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
*/
int
pcre_copy_named_substring (const pcre * code, const char *subject,
int *ovector, int stringcount,
const char *stringname, char *buffer, int size)
{
int n = pcre_get_stringnumber (code, stringname);
if (n <= 0)
return n;
return pcre_copy_substring (subject, ovector, stringcount, n, buffer,
size);
}
/*************************************************
* Copy all captured strings to new store *
*************************************************/
/* This function gets one chunk of store and builds a list of pointers and all
of the captured substrings in it. A NULL pointer is put on the end of the list.
Arguments:
subject the subject string that was matched
ovector pointer to the offsets table
stringcount the number of substrings that were captured
(i.e. the yield of the pcre_exec call, unless
that was zero, in which case it should be 1/3
of the offset table size)
listptr set to point to the list of pointers
Returns: if successful: 0
if not successful:
PCRE_ERROR_NOMEMORY (-6) failed to get store
*/
int
pcre_get_substring_list (const char *subject, int *ovector,
int stringcount, const char ***listptr)
{
int i;
int size = sizeof (char *);
int double_count = stringcount * 2;
char **stringlist;
char *p;
for (i = 0; i < double_count; i += 2)
size += sizeof (char *) + ovector[i + 1] - ovector[i] + 1;
stringlist = (char **) (pcre_malloc) (size);
if (stringlist == NULL)
return PCRE_ERROR_NOMEMORY;
*listptr = (const char **) stringlist;
p = (char *) (stringlist + stringcount + 1);
for (i = 0; i < double_count; i += 2) {
int len = ovector[i + 1] - ovector[i];
memcpy (p, subject + ovector[i], len);
*stringlist++ = p;
p += len;
*p++ = 0;
}
*stringlist = NULL;
return 0;
}
/*************************************************
* Free store obtained by get_substring_list *
*************************************************/
/* This function exists for the benefit of people calling PCRE from non-C
programs that can call its functions, but not free() or (pcre_free)() directly.
Argument: the result of a previous pcre_get_substring_list()
Returns: nothing
*/
void
pcre_free_substring_list (const char **pointer)
{
(pcre_free) ((void *) pointer);
}
/*************************************************
* Copy captured string to new store *
*************************************************/
/* This function copies a single captured substring into a piece of new
store
Arguments:
subject the subject string that was matched
ovector pointer to the offsets table
stringcount the number of substrings that were captured
(i.e. the yield of the pcre_exec call, unless
that was zero, in which case it should be 1/3
of the offset table size)
stringnumber the number of the required substring
stringptr where to put a pointer to the substring
Returns: if successful:
the length of the string, not including the zero that
is put on the end; can be zero
if not successful:
PCRE_ERROR_NOMEMORY (-6) failed to get store
PCRE_ERROR_NOSUBSTRING (-7) substring not present
*/
int
pcre_get_substring (const char *subject, int *ovector, int stringcount,
int stringnumber, const char **stringptr)
{
int yield;
char *substring;
if (stringnumber < 0 || stringnumber >= stringcount)
return PCRE_ERROR_NOSUBSTRING;
stringnumber *= 2;
yield = ovector[stringnumber + 1] - ovector[stringnumber];
substring = (char *) (pcre_malloc) (yield + 1);
if (substring == NULL)
return PCRE_ERROR_NOMEMORY;
memcpy (substring, subject + ovector[stringnumber], yield);
substring[yield] = 0;
*stringptr = substring;
return yield;
}
/*************************************************
* Copy named captured string to new store *
*************************************************/
/* This function copies a single captured substring, identified by name, into
new store.
Arguments:
code the compiled regex
subject the subject string that was matched
ovector pointer to the offsets table
stringcount the number of substrings that were captured
(i.e. the yield of the pcre_exec call, unless
that was zero, in which case it should be 1/3
of the offset table size)
stringname the name of the required substring
stringptr where to put the pointer
Returns: if successful:
the length of the copied string, not including the zero
that is put on the end; can be zero
if not successful:
PCRE_ERROR_NOMEMORY (-6) couldn't get memory
PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
*/
int
pcre_get_named_substring (const pcre * code, const char *subject,
int *ovector, int stringcount,
const char *stringname, const char **stringptr)
{
int n = pcre_get_stringnumber (code, stringname);
if (n <= 0)
return n;
return pcre_get_substring (subject, ovector, stringcount, n,
stringptr);
}
/*************************************************
* Free store obtained by get_substring *
*************************************************/
/* This function exists for the benefit of people calling PCRE from non-C
programs that can call its functions, but not free() or (pcre_free)() directly.
Argument: the result of a previous pcre_get_substring()
Returns: nothing
*/
void
pcre_free_substring (const char *pointer)
{
(pcre_free) ((void *) pointer);
}
/* End of get.c */

View File

@ -0,0 +1,760 @@
/* File import from pcre to goffice by import-pcre. Do not edit. */
/* This file has been programatically changed. */
/* This makes the following file fall under GPL license, see internal.c. */
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* This is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language. See
the file doc/Tech.Notes for some information on the internals.
Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2004 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This header contains definitions that are shared between the different
modules, but which are not relevant to the outside. */
/* Get the definitions provided by running "configure" */
/* Standard C headers plus the external interface definition. The only time
setjmp and stdarg are used is when NO_RECURSE is set. */
/* Whatever the question is, ctype.h is not the answer. */
/* #include <ctype.h> */
#include <limits.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef PCRE_SPY
#define PCRE_DEFINITION /* Win32 __declspec(export) trigger for .dll */
#endif
/* We need to have types that specify unsigned 16-bit and 32-bit integers. We
cannot determine these outside the compilation (e.g. by running a program as
part of "configure") because PCRE is often cross-compiled for use on other
systems. Instead we make use of the maximum sizes that are available at
preprocessor time in standard C environments. */
#if USHRT_MAX == 65535
typedef unsigned short pcre_uint16;
#elif UINT_MAX == 65535
typedef unsigned int pcre_uint16;
#else
#error Cannot determine a type for 16-bit unsigned integers
#endif
#if UINT_MAX == 4294967295
typedef unsigned int pcre_uint32;
#elif ULONG_MAX == 4294967295
typedef unsigned long int pcre_uint32;
#else
#error Cannot determine a type for 32-bit unsigned integers
#endif
/* All character handling must be done as unsigned characters. Otherwise there
are problems with top-bit-set characters and functions such as g_unichar_isspace().
However, we leave the interface to the outside world as char *, because that
should make things easier for callers. We define a short type for unsigned char
to save lots of typing. I tried "uchar", but it causes problems on Digital
Unix, where it is defined in sys/types, so use "uschar" instead. */
typedef unsigned char uschar;
/* Include the public PCRE header */
#include "pcre.h"
/* When compiling for use with the Virtual Pascal compiler, these functions
need to have their names changed. PCRE must be compiled with the -DVPCOMPAT
option on the command line. */
#ifdef VPCOMPAT
#define strncmp(s1,s2,m) _strncmp(s1,s2,m)
#define memcpy(d,s,n) _memcpy(d,s,n)
#define memmove(d,s,n) _memmove(d,s,n)
#define memset(s,c,n) _memset(s,c,n)
#else /* VPCOMPAT */
/* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),
define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY
is set. Otherwise, include an emulating function for those systems that have
neither (there some non-Unix environments where this is the case). This assumes
that all calls to memmove are moving strings upwards in store, which is the
case in PCRE. */
#if ! HAVE_MEMMOVE
#undef memmove /* some systems may have a macro */
#if HAVE_BCOPY
#define memmove(a, b, c) bcopy(b, a, c)
#else /* HAVE_BCOPY */
void *
pcre_memmove (unsigned char *dest, const unsigned char *src, size_t n)
{
int i;
dest += n;
src += n;
for (i = 0; i < n; ++i)
*(--dest) = *(--src);
}
#define memmove(a, b, c) pcre_memmove(a, b, c)
#endif /* not HAVE_BCOPY */
#endif /* not HAVE_MEMMOVE */
#endif /* not VPCOMPAT */
/* PCRE keeps offsets in its compiled code as 2-byte quantities (always stored
in big-endian order) by default. These are used, for example, to link from the
start of a subpattern to its alternatives and its end. The use of 2 bytes per
offset limits the size of the compiled regex to around 64K, which is big enough
for almost everybody. However, I received a request for an even bigger limit.
For this reason, and also to make the code easier to maintain, the storing and
loading of offsets from the byte string is now handled by the macros that are
defined here.
The macros are controlled by the value of LINK_SIZE. This defaults to 2 in
the config.h file, but can be overridden by using -D on the command line. This
is automated on Unix systems via the "configure" command. */
#if LINK_SIZE == 2
#define PUT(a,n,d) \
(a[n] = (d) >> 8), \
(a[(n)+1] = (d) & 255)
#define GET(a,n) \
(((a)[n] << 8) | (a)[(n)+1])
#define MAX_PATTERN_SIZE (1 << 16)
#elif LINK_SIZE == 3
#define PUT(a,n,d) \
(a[n] = (d) >> 16), \
(a[(n)+1] = (d) >> 8), \
(a[(n)+2] = (d) & 255)
#define GET(a,n) \
(((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])
#define MAX_PATTERN_SIZE (1 << 24)
#elif LINK_SIZE == 4
#define PUT(a,n,d) \
(a[n] = (d) >> 24), \
(a[(n)+1] = (d) >> 16), \
(a[(n)+2] = (d) >> 8), \
(a[(n)+3] = (d) & 255)
#define GET(a,n) \
(((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])
#define MAX_PATTERN_SIZE (1 << 30) /* Keep it positive */
#else
#error LINK_SIZE must be either 2, 3, or 4
#endif
/* Convenience macro defined in terms of the others */
#define PUTINC(a,n,d) PUT(a,n,d), a += LINK_SIZE
/* PCRE uses some other 2-byte quantities that do not change when the size of
offsets changes. There are used for repeat counts and for other things such as
capturing parenthesis numbers in back references. */
#define PUT2(a,n,d) \
a[n] = (d) >> 8; \
a[(n)+1] = (d) & 255
#define GET2(a,n) \
(((a)[n] << 8) | (a)[(n)+1])
#define PUT2INC(a,n,d) PUT2(a,n,d), a += 2
/* In case there is no definition of offsetof() provided - though any proper
Standard C system should have one. */
#ifndef offsetof
#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
#endif
/* These are the public options that can change during matching. */
#define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
/* Private options flags start at the most significant end of the four bytes,
but skip the top bit so we can use ints for convenience without getting tangled
with negative values. The public options defined in pcre.h start at the least
significant end. Make sure they don't overlap, though now that we have expanded
to four bytes, there is plenty of space. */
#define PCRE_FIRSTSET 0x40000000 /* first_byte is set */
#define PCRE_REQCHSET 0x20000000 /* req_byte is set */
#define PCRE_STARTLINE 0x10000000 /* start after \n for multiline */
#define PCRE_ICHANGED 0x08000000 /* i option changes within regex */
#define PCRE_NOPARTIAL 0x04000000 /* can't use partial with this regex */
/* Options for the "extra" block produced by pcre_study(). */
#define PCRE_STUDY_MAPPED 0x01 /* a map of starting chars exists */
/* Masks for identifying the public options which are permitted at compile
time, run time or study time, respectively. */
#define PUBLIC_OPTIONS \
(PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT)
#define PUBLIC_EXEC_OPTIONS \
(PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \
PCRE_PARTIAL)
#define PUBLIC_STUDY_OPTIONS 0 /* None defined */
/* Magic number to provide a small check against being handed junk. */
#define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */
/* Negative values for the firstchar and reqchar variables */
#define REQ_UNSET (-2)
#define REQ_NONE (-1)
/* Flags added to firstbyte or reqbyte; a "non-literal" item is either a
variable-length repeat, or a anything other than literal characters. */
#define REQ_CASELESS 0x0100 /* indicates caselessness */
#define REQ_VARY 0x0200 /* reqbyte followed non-literal item */
/* Miscellaneous definitions */
typedef int BOOL;
#define FALSE 0
#define TRUE 1
/* Escape items that are just an encoding of a particular data value. Note that
ESC_n is defined as yet another macro, which is set in config.h to either \n
(the default) or \r (which some people want). */
#ifndef ESC_e
#define ESC_e 27
#endif
#ifndef ESC_f
#define ESC_f '\f'
#endif
#ifndef ESC_n
#define ESC_n NEWLINE
#endif
#ifndef ESC_r
#define ESC_r '\r'
#endif
/* We can't officially use ESC_t because it is a POSIX reserved identifier
(presumably because of all the others like size_t). */
#ifndef ESC_tee
#define ESC_tee '\t'
#endif
/* These are escaped items that aren't just an encoding of a particular data
value such as \n. They must have non-zero values, as check_escape() returns
their negation. Also, they must appear in the same order as in the opcode
definitions below, up to ESC_z. There's a dummy for OP_ANY because it
corresponds to "." rather than an escape sequence. The final one must be
ESC_REF as subsequent values are used for \1, \2, \3, etc. There is are two
tests in the code for an escape greater than ESC_b and less than ESC_Z to
detect the types that may be repeated. These are the types that consume
characters. If any new escapes are put in between that don't consume a
character, that code will have to change. */
enum { ESC_A = 1, ESC_G, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W,
ESC_w, ESC_dum1, ESC_C, ESC_P, ESC_p, ESC_X, ESC_Z, ESC_z, ESC_E,
ESC_Q, ESC_REF
};
/* Flag bits and data types for the extended class (OP_XCLASS) for classes that
contain UTF-8 characters with values greater than 255. */
#define XCL_NOT 0x01 /* Flag: this is a negative class */
#define XCL_MAP 0x02 /* Flag: a 32-byte map is present */
#define XCL_END 0 /* Marks end of individual items */
#define XCL_SINGLE 1 /* Single item (one multibyte char) follows */
#define XCL_RANGE 2 /* A range (two multibyte chars) follows */
#define XCL_PROP 3 /* Unicode property (one property code) follows */
#define XCL_NOTPROP 4 /* Unicode inverted property (ditto) */
/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
that extract substrings. Starting from 1 (i.e. after OP_END), the values up to
OP_EOD must correspond in order to the list of escapes immediately above.
Note that whenever this list is updated, the two macro definitions that follow
must also be updated to match. */
enum {
OP_END, /* 0 End of pattern */
/* Values corresponding to backslashed metacharacters */
OP_SOD, /* 1 Start of data: \A */
OP_SOM, /* 2 Start of match (subject + offset): \G */
OP_NOT_WORD_BOUNDARY, /* 3 \B */
OP_WORD_BOUNDARY, /* 4 \b */
OP_NOT_DIGIT, /* 5 \D */
OP_DIGIT, /* 6 \d */
OP_NOT_WHITESPACE, /* 7 \S */
OP_WHITESPACE, /* 8 \s */
OP_NOT_WORDCHAR, /* 9 \W */
OP_WORDCHAR, /* 10 \w */
OP_ANY, /* 11 Match any character */
OP_ANYBYTE, /* 12 Match any byte (\C); different to OP_ANY for UTF-8 */
OP_NOTPROP, /* 13 \P (not Unicode property) */
OP_PROP, /* 14 \p (Unicode property) */
OP_EXTUNI, /* 15 \X (extended Unicode sequence */
OP_EODN, /* 16 End of data or \n at end of data: \Z. */
OP_EOD, /* 17 End of data: \z */
OP_OPT, /* 18 Set runtime options */
OP_CIRC, /* 19 Start of line - varies with multiline switch */
OP_DOLL, /* 20 End of line - varies with multiline switch */
OP_CHAR, /* 21 Match one character, casefully */
OP_CHARNC, /* 22 Match one character, caselessly */
OP_NOT, /* 23 Match anything but the following char */
OP_STAR, /* 24 The maximizing and minimizing versions of */
OP_MINSTAR, /* 25 all these opcodes must come in pairs, with */
OP_PLUS, /* 26 the minimizing one second. */
OP_MINPLUS, /* 27 This first set applies to single characters */
OP_QUERY, /* 28 */
OP_MINQUERY, /* 29 */
OP_UPTO, /* 30 From 0 to n matches */
OP_MINUPTO, /* 31 */
OP_EXACT, /* 32 Exactly n matches */
OP_NOTSTAR, /* 33 The maximizing and minimizing versions of */
OP_NOTMINSTAR, /* 34 all these opcodes must come in pairs, with */
OP_NOTPLUS, /* 35 the minimizing one second. */
OP_NOTMINPLUS, /* 36 This set applies to "not" single characters */
OP_NOTQUERY, /* 37 */
OP_NOTMINQUERY, /* 38 */
OP_NOTUPTO, /* 39 From 0 to n matches */
OP_NOTMINUPTO, /* 40 */
OP_NOTEXACT, /* 41 Exactly n matches */
OP_TYPESTAR, /* 42 The maximizing and minimizing versions of */
OP_TYPEMINSTAR, /* 43 all these opcodes must come in pairs, with */
OP_TYPEPLUS, /* 44 the minimizing one second. These codes must */
OP_TYPEMINPLUS, /* 45 be in exactly the same order as those above. */
OP_TYPEQUERY, /* 46 This set applies to character types such as \d */
OP_TYPEMINQUERY, /* 47 */
OP_TYPEUPTO, /* 48 From 0 to n matches */
OP_TYPEMINUPTO, /* 49 */
OP_TYPEEXACT, /* 50 Exactly n matches */
OP_CRSTAR, /* 51 The maximizing and minimizing versions of */
OP_CRMINSTAR, /* 52 all these opcodes must come in pairs, with */
OP_CRPLUS, /* 53 the minimizing one second. These codes must */
OP_CRMINPLUS, /* 54 be in exactly the same order as those above. */
OP_CRQUERY, /* 55 These are for character classes and back refs */
OP_CRMINQUERY, /* 56 */
OP_CRRANGE, /* 57 These are different to the three sets above. */
OP_CRMINRANGE, /* 58 */
OP_CLASS, /* 59 Match a character class, chars < 256 only */
OP_NCLASS, /* 60 Same, but the bitmap was created from a negative
class - the difference is relevant only when a UTF-8
character > 255 is encountered. */
OP_XCLASS, /* 61 Extended class for handling UTF-8 chars within the
class. This does both positive and negative. */
OP_REF, /* 62 Match a back reference */
OP_RECURSE, /* 63 Match a numbered subpattern (possibly recursive) */
OP_CALLOUT, /* 64 Call out to external function if provided */
OP_ALT, /* 65 Start of alternation */
OP_KET, /* 66 End of group that doesn't have an unbounded repeat */
OP_KETRMAX, /* 67 These two must remain together and in this */
OP_KETRMIN, /* 68 order. They are for groups the repeat for ever. */
/* The assertions must come before ONCE and COND */
OP_ASSERT, /* 69 Positive lookahead */
OP_ASSERT_NOT, /* 70 Negative lookahead */
OP_ASSERTBACK, /* 71 Positive lookbehind */
OP_ASSERTBACK_NOT, /* 72 Negative lookbehind */
OP_REVERSE, /* 73 Move pointer back - used in lookbehind assertions */
/* ONCE and COND must come after the assertions, with ONCE first, as there's
a test for >= ONCE for a subpattern that isn't an assertion. */
OP_ONCE, /* 74 Once matched, don't back up into the subpattern */
OP_COND, /* 75 Conditional group */
OP_CREF, /* 76 Used to hold an extraction string number (cond ref) */
OP_BRAZERO, /* 77 These two must remain together and in this */
OP_BRAMINZERO, /* 78 order. */
OP_BRANUMBER, /* 79 Used for extracting brackets whose number is greater
than can fit into an opcode. */
OP_BRA /* 80 This and greater values are used for brackets that
extract substrings up to EXTRACT_BASIC_MAX. After
that, use is made of OP_BRANUMBER. */
};
/* WARNING WARNING WARNING: There is an implicit assumption in pcre.c and
study.c that all opcodes are less than 128 in value. This makes handling UTF-8
character sequences easier. */
/* The highest extraction number before we have to start using additional
bytes. (Originally PCRE didn't have support for extraction counts highter than
this number.) The value is limited by the number of opcodes left after OP_BRA,
i.e. 255 - OP_BRA. We actually set it a bit lower to leave room for additional
opcodes. */
#define EXTRACT_BASIC_MAX 100
/* This macro defines textual names for all the opcodes. There are used only
for debugging, in pcre.c when DEBUG is defined, and also in pcretest.c. The
macro is referenced only in printint.c. */
#define OP_NAME_LIST \
"End", "\\A", "\\G", "\\B", "\\b", "\\D", "\\d", \
"\\S", "\\s", "\\W", "\\w", "Any", "Anybyte", \
"notprop", "prop", "extuni", \
"\\Z", "\\z", \
"Opt", "^", "$", "char", "charnc", "not", \
"*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
"*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
"*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
"*", "*?", "+", "+?", "?", "??", "{", "{", \
"class", "nclass", "xclass", "Ref", "Recurse", "Callout", \
"Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not", \
"AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cond ref",\
"Brazero", "Braminzero", "Branumber", "Bra"
/* This macro defines the length of fixed length operations in the compiled
regex. The lengths are used when searching for specific things, and also in the
debugging printing of a compiled regex. We use a macro so that it can be
incorporated both into pcre.c and pcretest.c without being publicly exposed.
As things have been extended, some of these are no longer fixed lenths, but are
minima instead. For example, the length of a single-character repeat may vary
in UTF-8 mode. The code that uses this table must know about such things. */
#define OP_LENGTHS \
1, /* End */ \
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* \A, \G, \B, \B, \D, \d, \S, \s, \W, \w */ \
1, 1, /* Any, Anybyte */ \
2, 2, 1, /* NOTPROP, PROP, EXTUNI */ \
1, 1, 2, 1, 1, /* \Z, \z, Opt, ^, $ */ \
2, /* Char - the minimum length */ \
2, /* Charnc - the minimum length */ \
2, /* not */ \
/* Positive single-char repeats ** These are */ \
2, 2, 2, 2, 2, 2, /* *, *?, +, +?, ?, ?? ** minima in */ \
4, 4, 4, /* upto, minupto, exact ** UTF-8 mode */ \
/* Negative single-char repeats - only for chars < 256 */ \
2, 2, 2, 2, 2, 2, /* NOT *, *?, +, +?, ?, ?? */ \
4, 4, 4, /* NOT upto, minupto, exact */ \
/* Positive type repeats */ \
2, 2, 2, 2, 2, 2, /* Type *, *?, +, +?, ?, ?? */ \
4, 4, 4, /* Type upto, minupto, exact */ \
/* Character class & ref repeats */ \
1, 1, 1, 1, 1, 1, /* *, *?, +, +?, ?, ?? */ \
5, 5, /* CRRANGE, CRMINRANGE */ \
33, /* CLASS */ \
33, /* NCLASS */ \
0, /* XCLASS - variable length */ \
3, /* REF */ \
1+LINK_SIZE, /* RECURSE */ \
2+2*LINK_SIZE, /* CALLOUT */ \
1+LINK_SIZE, /* Alt */ \
1+LINK_SIZE, /* Ket */ \
1+LINK_SIZE, /* KetRmax */ \
1+LINK_SIZE, /* KetRmin */ \
1+LINK_SIZE, /* Assert */ \
1+LINK_SIZE, /* Assert not */ \
1+LINK_SIZE, /* Assert behind */ \
1+LINK_SIZE, /* Assert behind not */ \
1+LINK_SIZE, /* Reverse */ \
1+LINK_SIZE, /* Once */ \
1+LINK_SIZE, /* COND */ \
3, /* CREF */ \
1, 1, /* BRAZERO, BRAMINZERO */ \
3, /* BRANUMBER */ \
1+LINK_SIZE /* BRA */ \
/* A magic value for OP_CREF to indicate the "in recursion" condition. */
#define CREF_RECURSE 0xffff
/* The texts of compile-time error messages are defined as macros here so that
they can be accessed by the POSIX wrapper and converted into error codes. Yes,
I could have used error codes in the first place, but didn't feel like changing
just to accommodate the POSIX wrapper. */
#define ERR1 "\\ at end of pattern"
#define ERR2 "\\c at end of pattern"
#define ERR3 "unrecognized character follows \\"
#define ERR4 "numbers out of order in {} quantifier"
#define ERR5 "number too big in {} quantifier"
#define ERR6 "missing terminating ] for character class"
#define ERR7 "invalid escape sequence in character class"
#define ERR8 "range out of order in character class"
#define ERR9 "nothing to repeat"
#define ERR10 "operand of unlimited repeat could match the empty string"
#define ERR11 "internal error: unexpected repeat"
#define ERR12 "unrecognized character after (?"
#define ERR13 "POSIX named classes are supported only within a class"
#define ERR14 "missing )"
#define ERR15 "reference to non-existent subpattern"
#define ERR16 "erroffset passed as NULL"
#define ERR17 "unknown option bit(s) set"
#define ERR18 "missing ) after comment"
#define ERR19 "parentheses nested too deeply"
#define ERR20 "regular expression too large"
#define ERR21 "failed to get memory"
#define ERR22 "unmatched parentheses"
#define ERR23 "internal error: code overflow"
#define ERR24 "unrecognized character after (?<"
#define ERR25 "lookbehind assertion is not fixed length"
#define ERR26 "malformed number after (?("
#define ERR27 "conditional group contains more than two branches"
#define ERR28 "assertion expected after (?("
#define ERR29 "(?R or (?digits must be followed by )"
#define ERR30 "unknown POSIX class name"
#define ERR31 "POSIX collating elements are not supported"
#define ERR32 "this version of PCRE is not compiled with PCRE_UTF8 support"
#define ERR33 "spare error"
#define ERR34 "character value in \\x{...} sequence is too large"
#define ERR35 "invalid condition (?(0)"
#define ERR36 "\\C not allowed in lookbehind assertion"
#define ERR37 "PCRE does not support \\L, \\l, \\N, \\U, or \\u"
#define ERR38 "number after (?C is > 255"
#define ERR39 "closing ) for (?C expected"
#define ERR40 "recursive call could loop indefinitely"
#define ERR41 "unrecognized character after (?P"
#define ERR42 "syntax error after (?P"
#define ERR43 "two named groups have the same name"
#define ERR44 "invalid UTF-8 string"
#define ERR45 "support for \\P, \\p, and \\X has not been compiled"
#define ERR46 "malformed \\P or \\p sequence"
#define ERR47 "unknown property name after \\P or \\p"
/* The real format of the start of the pcre block; the index of names and the
code vector run on as long as necessary after the end. We store an explicit
offset to the name table so that if a regex is compiled on one host, saved, and
then run on another where the size of pointers is different, all might still
be well. For the case of compiled-on-4 and run-on-8, we include an extra
pointer that is always NULL. For future-proofing, we also include a few dummy
fields - even though you can never get this planning right!
NOTE NOTE NOTE:
Because people can now save and re-use compiled patterns, any additions to this
structure should be made at the end, and something earlier (e.g. a new
flag in the options or one of the dummy fields) should indicate that the new
fields are present. Currently PCRE always sets the dummy fields to zero.
NOTE NOTE NOTE:
*/
typedef struct real_pcre {
pcre_uint32 magic_number;
pcre_uint32 size; /* Total that was malloced */
pcre_uint32 options;
pcre_uint32 dummy1; /* For future use, maybe */
pcre_uint16 top_bracket;
pcre_uint16 top_backref;
pcre_uint16 first_byte;
pcre_uint16 req_byte;
pcre_uint16 name_table_offset; /* Offset to name table that follows */
pcre_uint16 name_entry_size; /* Size of any name items */
pcre_uint16 name_count; /* Number of name items */
pcre_uint16 dummy2; /* For future use, maybe */
const unsigned char *tables; /* Pointer to tables or NULL for std */
const unsigned char *nullpad; /* NULL padding */
} real_pcre;
/* The format of the block used to store data from pcre_study(). The same
remark (see NOTE above) about extending this structure applies. */
typedef struct pcre_study_data {
pcre_uint32 size; /* Total that was malloced */
pcre_uint32 options;
uschar start_bits[32];
} pcre_study_data;
/* Structure for passing "static" information around between the functions
doing the compiling, so that they are thread-safe. */
typedef struct compile_data {
const uschar *lcc; /* Points to lower casing table */
const uschar *fcc; /* Points to case-flipping table */
const uschar *cbits; /* Points to character type table */
const uschar *ctypes; /* Points to table of type maps */
const uschar *start_code; /* The start of the compiled code */
const uschar *start_pattern; /* The start of the pattern */
uschar *name_table; /* The name/number table */
int names_found; /* Number of entries so far */
int name_entry_size; /* Size of each entry */
int top_backref; /* Maximum back reference */
unsigned int backref_map; /* Bitmap of low back refs */
int req_varyopt; /* "After variable item" flag for reqbyte */
BOOL nopartial; /* Set TRUE if partial won't work */
} compile_data;
/* Structure for maintaining a chain of pointers to the currently incomplete
branches, for testing for left recursion. */
typedef struct branch_chain {
struct branch_chain *outer;
uschar *current;
} branch_chain;
/* Structure for items in a linked list that represents an explicit recursive
call within the pattern. */
typedef struct recursion_info {
struct recursion_info *prevrec; /* Previous recursion record (or NULL) */
int group_num; /* Number of group that was called */
const uschar *after_call; /* "Return value": points after the call in the expr */
const uschar *save_start; /* Old value of md->start_match */
int *offset_save; /* Pointer to start of saved offsets */
int saved_max; /* Number of saved offsets */
} recursion_info;
/* When compiling in a mode that doesn't use recursive calls to match(),
a structure is used to remember local variables on the heap. It is defined in
pcre.c, close to the match() function, so that it is easy to keep it in step
with any changes of local variable. However, the pointer to the current frame
must be saved in some "static" place over a longjmp(). We declare the
structure here so that we can put a pointer in the match_data structure.
NOTE: This isn't used for a "normal" compilation of pcre. */
struct heapframe;
/* Structure for passing "static" information around between the functions
doing the matching, so that they are thread-safe. */
typedef struct match_data {
unsigned long int match_call_count; /* As it says */
unsigned long int match_limit; /* As it says */
int *offset_vector; /* Offset vector */
int offset_end; /* One past the end */
int offset_max; /* The maximum usable for return data */
const uschar *lcc; /* Points to lower casing table */
const uschar *ctypes; /* Points to table of type maps */
BOOL offset_overflow; /* Set if too many extractions */
BOOL notbol; /* NOTBOL flag */
BOOL noteol; /* NOTEOL flag */
BOOL utf8; /* UTF8 flag */
BOOL endonly; /* Dollar not before final \n */
BOOL notempty; /* Empty string match not wanted */
BOOL partial; /* PARTIAL flag */
BOOL hitend; /* Hit the end of the subject at some point */
const uschar *start_code; /* For use when recursing */
const uschar *start_subject; /* Start of the subject string */
const uschar *end_subject; /* End of the subject string */
const uschar *start_match; /* Start of this match attempt */
const uschar *end_match_ptr; /* Subject position at end match */
int end_offset_top; /* Highwater mark at end of match */
int capture_last; /* Most recent capture number */
int start_offset; /* The start offset value */
recursion_info *recursive; /* Linked list of recursion data */
void *callout_data; /* To pass back to callouts */
struct heapframe *thisframe; /* Used only when compiling for no recursion */
} match_data;
/* Bit definitions for entries in the pcre_ctypes table. */
#define ctype_space 0x01
#define ctype_letter 0x02
#define ctype_digit 0x04
#define ctype_xdigit 0x08
#define ctype_word 0x10 /* alphameric or '_' */
#define ctype_meta 0x80 /* regexp meta char or zero (end pattern) */
/* Offsets for the bitmap tables in pcre_cbits. Each table contains a set
of bits for a class map. Some classes are built by combining these tables. */
#define cbit_space 0 /* [:space:] or \s */
#define cbit_xdigit 32 /* [:xdigit:] */
#define cbit_digit 64 /* [:digit:] or \d */
#define cbit_upper 96 /* [:upper:] */
#define cbit_lower 128 /* [:lower:] */
#define cbit_word 160 /* [:word:] or \w */
#define cbit_graph 192 /* [:graph:] */
#define cbit_print 224 /* [:print:] */
#define cbit_punct 256 /* [:punct:] */
#define cbit_cntrl 288 /* [:cntrl:] */
#define cbit_length 320 /* Length of the cbits table */
/* Offsets of the various tables from the base tables pointer, and
total length. */
#define lcc_offset 0
#define fcc_offset 256
#define cbits_offset 512
#define ctypes_offset (cbits_offset + cbit_length)
#define tables_length (ctypes_offset + 256)
/* End of internal.h */

View File

@ -0,0 +1,168 @@
/* File import from pcre to goffice by import-pcre. Do not edit. */
/* This file has been programatically changed. */
/* This makes the following file fall under GPL license, see below. */
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/*
PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2003 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This file is compiled on its own as part of the PCRE library. However,
it is also included in the compilation of dftables.c, in which case the macro
DFTABLES is defined. */
#ifndef DFTABLES
#include <goffice/goffice-config.h>
#include "internal.h"
#include <glib.h>
#endif
/*************************************************
* Create PCRE character tables *
*************************************************/
/* This function builds a set of character tables for use by PCRE and returns
a pointer to them. They are build using the ctype functions, and consequently
their contents will depend upon the current locale setting. When compiled as
part of the library, the store is obtained via pcre_malloc(), but when compiled
inside dftables, use malloc().
Arguments: none
Returns: pointer to the contiguous block of data
*/
const unsigned char *
pcre_maketables (void)
{
unsigned char *yield, *p;
int i;
#ifndef DFTABLES
yield = (unsigned char *) (pcre_malloc) (tables_length);
#else
yield = (unsigned char *) malloc (tables_length);
#endif
if (yield == NULL)
return NULL;
p = yield;
/* First comes the lower casing table */
for (i = 0; i < 256; i++)
*p++ = g_unichar_tolower (i);
/* Next the case-flipping table */
for (i = 0; i < 256; i++)
*p++ =
g_unichar_islower (i) ? g_unichar_toupper (i) :
g_unichar_tolower (i);
/* Then the character class tables. Don't try to be clever and save effort
on exclusive ones - in some locales things may be different. Note that the
table for "space" includes everything "g_unichar_isspace" gives, including VT in the
default locale. This makes it work for the POSIX class [:space:]. */
memset (p, 0, cbit_length);
for (i = 0; i < 256; i++) {
if (g_unichar_isdigit (i)) {
p[cbit_digit + i / 8] |= 1 << (i & 7);
p[cbit_word + i / 8] |= 1 << (i & 7);
}
if (g_unichar_isupper (i)) {
p[cbit_upper + i / 8] |= 1 << (i & 7);
p[cbit_word + i / 8] |= 1 << (i & 7);
}
if (g_unichar_islower (i)) {
p[cbit_lower + i / 8] |= 1 << (i & 7);
p[cbit_word + i / 8] |= 1 << (i & 7);
}
if (i == '_')
p[cbit_word + i / 8] |= 1 << (i & 7);
if (g_unichar_isspace (i))
p[cbit_space + i / 8] |= 1 << (i & 7);
if (g_unichar_isxdigit (i))
p[cbit_xdigit + i / 8] |= 1 << (i & 7);
if (g_unichar_isgraph (i))
p[cbit_graph + i / 8] |= 1 << (i & 7);
if (g_unichar_isprint (i))
p[cbit_print + i / 8] |= 1 << (i & 7);
if (g_unichar_ispunct (i))
p[cbit_punct + i / 8] |= 1 << (i & 7);
if (g_unichar_iscntrl (i))
p[cbit_cntrl + i / 8] |= 1 << (i & 7);
}
p += cbit_length;
/* Finally, the character type table. In this, we exclude VT from the white
space chars, because Perl doesn't recognize it as such for \s and for comments
within regexes. */
for (i = 0; i < 256; i++) {
int x = 0;
if (i != 0x0b && g_unichar_isspace (i))
x += ctype_space;
if (g_unichar_isalpha (i))
x += ctype_letter;
if (g_unichar_isdigit (i))
x += ctype_digit;
if (g_unichar_isxdigit (i))
x += ctype_xdigit;
if (g_unichar_isalnum (i) || i == '_')
x += ctype_word;
/* Note: strchr includes the terminating zero in the characters it considers.
In this instance, that is ok because we want binary zero to be flagged as a
meta-character, which in this sense is any character that terminates a run
of data characters. */
if (strchr ("*+?{^.$|()[", i) != 0)
x += ctype_meta;
*p++ = x;
}
return yield;
}
/* End of maketables.c */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,245 @@
/* File import from pcre to goffice by import-pcre. Do not edit. */
/* This file has been programatically changed. */
/* This makes the following file fall under GPL license, see pcre.c. */
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* In its original form, this is the .in file that is transformed by
"configure" into pcre.h.
Copyright (c) 1997-2004 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifndef _PCRE_H
#define _PCRE_H
/* The file pcre.h is build by "configure". Do not edit it; instead
make changes to pcre.in. */
#define PCRE_MAJOR 5
#define PCRE_MINOR 0
#define PCRE_DATE 13-Sep-2004
/* Win32 uses DLL by default */
#ifdef _WIN32
# ifdef PCRE_DEFINITION
# ifdef DLL_EXPORT
# define PCRE_DATA_SCOPE __declspec(dllexport)
# endif
# else
# ifndef PCRE_STATIC
# define PCRE_DATA_SCOPE extern __declspec(dllimport)
# endif
# endif
#endif
#ifndef PCRE_DATA_SCOPE
# define PCRE_DATA_SCOPE extern
#endif
/* Have to include stdlib.h in order to ensure that size_t is defined;
it is needed here for malloc. */
#include <stdlib.h>
/* Allow for C++ users */
#ifdef __cplusplus
extern "C" {
#endif
/* Options */
#define PCRE_CASELESS 0x0001
#define PCRE_MULTILINE 0x0002
#define PCRE_DOTALL 0x0004
#define PCRE_EXTENDED 0x0008
#define PCRE_ANCHORED 0x0010
#define PCRE_DOLLAR_ENDONLY 0x0020
#define PCRE_EXTRA 0x0040
#define PCRE_NOTBOL 0x0080
#define PCRE_NOTEOL 0x0100
#define PCRE_UNGREEDY 0x0200
#define PCRE_NOTEMPTY 0x0400
#define PCRE_UTF8 0x0800
#define PCRE_NO_AUTO_CAPTURE 0x1000
#define PCRE_NO_UTF8_CHECK 0x2000
#define PCRE_AUTO_CALLOUT 0x4000
#define PCRE_PARTIAL 0x8000
/* Exec-time and get/set-time error codes */
#define PCRE_ERROR_NOMATCH (-1)
#define PCRE_ERROR_NULL (-2)
#define PCRE_ERROR_BADOPTION (-3)
#define PCRE_ERROR_BADMAGIC (-4)
#define PCRE_ERROR_UNKNOWN_NODE (-5)
#define PCRE_ERROR_NOMEMORY (-6)
#define PCRE_ERROR_NOSUBSTRING (-7)
#define PCRE_ERROR_MATCHLIMIT (-8)
#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
#define PCRE_ERROR_BADUTF8 (-10)
#define PCRE_ERROR_BADUTF8_OFFSET (-11)
#define PCRE_ERROR_PARTIAL (-12)
#define PCRE_ERROR_BADPARTIAL (-13)
#define PCRE_ERROR_INTERNAL (-14)
#define PCRE_ERROR_BADCOUNT (-15)
/* Request types for pcre_fullinfo() */
#define PCRE_INFO_OPTIONS 0
#define PCRE_INFO_SIZE 1
#define PCRE_INFO_CAPTURECOUNT 2
#define PCRE_INFO_BACKREFMAX 3
#define PCRE_INFO_FIRSTBYTE 4
#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */
#define PCRE_INFO_FIRSTTABLE 5
#define PCRE_INFO_LASTLITERAL 6
#define PCRE_INFO_NAMEENTRYSIZE 7
#define PCRE_INFO_NAMECOUNT 8
#define PCRE_INFO_NAMETABLE 9
#define PCRE_INFO_STUDYSIZE 10
#define PCRE_INFO_DEFAULT_TABLES 11
/* Request types for pcre_config() */
#define PCRE_CONFIG_UTF8 0
#define PCRE_CONFIG_NEWLINE 1
#define PCRE_CONFIG_LINK_SIZE 2
#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3
#define PCRE_CONFIG_MATCH_LIMIT 4
#define PCRE_CONFIG_STACKRECURSE 5
#define PCRE_CONFIG_UNICODE_PROPERTIES 6
/* Bit flags for the pcre_extra structure */
#define PCRE_EXTRA_STUDY_DATA 0x0001
#define PCRE_EXTRA_MATCH_LIMIT 0x0002
#define PCRE_EXTRA_CALLOUT_DATA 0x0004
#define PCRE_EXTRA_TABLES 0x0008
/* Types */
struct real_pcre; /* declaration; the definition is private */
typedef struct real_pcre pcre;
/* The structure for passing additional data to pcre_exec(). This is defined in
such as way as to be extensible. Always add new fields at the end, in order to
remain compatible. */
typedef struct pcre_extra {
unsigned long int flags; /* Bits for which fields are set */
void *study_data; /* Opaque data from pcre_study() */
unsigned long int match_limit; /* Maximum number of calls to match() */
void *callout_data; /* Data passed back in callouts */
const unsigned char *tables; /* Pointer to character tables */
} pcre_extra;
/* The structure for passing out data via the pcre_callout_function. We use a
structure so that new fields can be added on the end in future versions,
without changing the API of the function, thereby allowing old clients to work
without modification. */
typedef struct pcre_callout_block {
int version; /* Identifies version of block */
/* ------------------------ Version 0 ------------------------------- */
int callout_number; /* Number compiled into pattern */
int *offset_vector; /* The offset vector */
const char *subject; /* The subject being matched */
int subject_length; /* The length of the subject */
int start_match; /* Offset to start of this match attempt */
int current_position; /* Where we currently are in the subject */
int capture_top; /* Max current capture */
int capture_last; /* Most recently closed capture */
void *callout_data; /* Data passed in with the call */
/* ------------------- Added for Version 1 -------------------------- */
int pattern_position; /* Offset to next item in the pattern */
int next_item_length; /* Length of next item in the pattern */
/* ------------------------------------------------------------------ */
} pcre_callout_block;
/* Indirection for store get and free functions. These can be set to
alternative malloc/free functions if required. Special ones are used in the
non-recursive case for "frames". There is also an optional callout function
that is triggered by the (?) regex item. Some magic is required for Win32 DLL;
it is null on other OS. For Virtual Pascal, these have to be different again.
*/
#ifndef VPCOMPAT
PCRE_DATA_SCOPE void *(*pcre_malloc) (size_t);
PCRE_DATA_SCOPE void (*pcre_free) (void *);
PCRE_DATA_SCOPE void *(*pcre_stack_malloc) (size_t);
PCRE_DATA_SCOPE void (*pcre_stack_free) (void *);
PCRE_DATA_SCOPE int (*pcre_callout) (pcre_callout_block *);
#else /* VPCOMPAT */
extern void *pcre_malloc (size_t);
extern void pcre_free (void *);
extern void *pcre_stack_malloc (size_t);
extern void pcre_stack_free (void *);
extern int pcre_callout (pcre_callout_block *);
#endif /* VPCOMPAT */
/* Exported PCRE functions */
extern pcre *pcre_compile (const char *, int, const char **,
int *, const unsigned char *);
extern int pcre_config (int, void *);
extern int pcre_copy_named_substring (const pcre *, const char *,
int *, int, const char *, char *,
int);
extern int pcre_copy_substring (const char *, int *, int, int, char *,
int);
extern int pcre_exec (const pcre *, const pcre_extra *, const char *,
int, int, int, int *, int);
extern void pcre_free_substring (const char *);
extern void pcre_free_substring_list (const char **);
extern int pcre_fullinfo (const pcre *, const pcre_extra *, int,
void *);
extern int pcre_get_named_substring (const pcre *, const char *,
int *, int, const char *,
const char **);
extern int pcre_get_stringnumber (const pcre *, const char *);
extern int pcre_get_substring (const char *, int *, int, int,
const char **);
extern int pcre_get_substring_list (const char *, int *, int,
const char ***);
extern int pcre_info (const pcre *, int *, int *);
extern const unsigned char *pcre_maketables (void);
extern pcre_extra *pcre_study (const pcre *, int, const char **);
extern const char *pcre_version (void);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* End of pcre.h */

View File

@ -0,0 +1,339 @@
/* File import from pcre to goffice by import-pcre. Do not edit. */
/* This file has been programatically changed. */
/* This makes the following file fall under GPL license, see below. */
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/*
This is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language. See
the file Tech.Notes for some information on the internals.
This module is a wrapper that provides a POSIX API to the underlying PCRE
functions.
Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2004 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#include <goffice/goffice-config.h>
#include "internal.h"
#include "pcreposix.h"
#include "stdlib.h"
/* Corresponding tables of PCRE error messages and POSIX error codes. */
static const char *const estring[] = {
ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9, ERR10,
ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19, ERR20,
ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR29, ERR29, ERR30,
ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39, ERR40,
ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47
};
static const int eint[] = {
REG_EESCAPE, /* "\\ at end of pattern" */
REG_EESCAPE, /* "\\c at end of pattern" */
REG_EESCAPE, /* "unrecognized character follows \\" */
REG_BADBR, /* "numbers out of order in {} quantifier" */
REG_BADBR, /* "number too big in {} quantifier" */
REG_EBRACK, /* "missing terminating ] for character class" */
REG_ECTYPE, /* "invalid escape sequence in character class" */
REG_ERANGE, /* "range out of order in character class" */
REG_BADRPT, /* "nothing to repeat" */
REG_BADRPT, /* "operand of unlimited repeat could match the empty string" */
REG_ASSERT, /* "internal error: unexpected repeat" */
REG_BADPAT, /* "unrecognized character after (?" */
REG_BADPAT, /* "POSIX named classes are supported only within a class" */
REG_EPAREN, /* "missing )" */
REG_ESUBREG, /* "reference to non-existent subpattern" */
REG_INVARG, /* "erroffset passed as NULL" */
REG_INVARG, /* "unknown option bit(s) set" */
REG_EPAREN, /* "missing ) after comment" */
REG_ESIZE, /* "parentheses nested too deeply" */
REG_ESIZE, /* "regular expression too large" */
REG_ESPACE, /* "failed to get memory" */
REG_EPAREN, /* "unmatched brackets" */
REG_ASSERT, /* "internal error: code overflow" */
REG_BADPAT, /* "unrecognized character after (?<" */
REG_BADPAT, /* "lookbehind assertion is not fixed length" */
REG_BADPAT, /* "malformed number after (?(" */
REG_BADPAT, /* "conditional group containe more than two branches" */
REG_BADPAT, /* "assertion expected after (?(" */
REG_BADPAT, /* "(?R or (?digits must be followed by )" */
REG_ECTYPE, /* "unknown POSIX class name" */
REG_BADPAT, /* "POSIX collating elements are not supported" */
REG_INVARG, /* "this version of PCRE is not compiled with PCRE_UTF8 support" */
REG_BADPAT, /* "spare error" */
REG_BADPAT, /* "character value in \x{...} sequence is too large" */
REG_BADPAT, /* "invalid condition (?(0)" */
REG_BADPAT, /* "\\C not allowed in lookbehind assertion" */
REG_EESCAPE, /* "PCRE does not support \\L, \\l, \\N, \\U, or \\u" */
REG_BADPAT, /* "number after (?C is > 255" */
REG_BADPAT, /* "closing ) for (?C expected" */
REG_BADPAT, /* "recursive call could loop indefinitely" */
REG_BADPAT, /* "unrecognized character after (?P" */
REG_BADPAT, /* "syntax error after (?P" */
REG_BADPAT, /* "two named groups have the same name" */
REG_BADPAT, /* "invalid UTF-8 string" */
REG_BADPAT, /* "support for \\P, \\p, and \\X has not been compiled" */
REG_BADPAT, /* "malformed \\P or \\p sequence" */
REG_BADPAT /* "unknown property name after \\P or \\p" */
};
/* Table of texts corresponding to POSIX error codes */
static const char *const pstring[] = {
"", /* Dummy for value 0 */
"internal error", /* REG_ASSERT */
"invalid repeat counts in {}", /* BADBR */
"pattern error", /* BADPAT */
"? * + invalid", /* BADRPT */
"unbalanced {}", /* EBRACE */
"unbalanced []", /* EBRACK */
"collation error - not relevant", /* ECOLLATE */
"bad class", /* ECTYPE */
"bad escape sequence", /* EESCAPE */
"empty expression", /* EMPTY */
"unbalanced ()", /* EPAREN */
"bad range inside []", /* ERANGE */
"expression too big", /* ESIZE */
"failed to get memory", /* ESPACE */
"bad back reference", /* ESUBREG */
"bad argument", /* INVARG */
"match failed" /* NOMATCH */
};
/*************************************************
* Translate PCRE text code to int *
*************************************************/
/* PCRE compile-time errors are given as strings defined as macros. We can just
look them up in a table to turn them into POSIX-style error codes. */
static int
pcre_posix_error_code (const char *s)
{
size_t i;
for (i = 0; i < sizeof (estring) / sizeof (char *); i++)
if (strcmp (s, estring[i]) == 0)
return eint[i];
return REG_ASSERT;
}
/*************************************************
* Translate error code to string *
*************************************************/
size_t
go_regerror (int errcode, const GORegexp * preg, char *errbuf,
size_t errbuf_size)
{
const char *message, *addmessage;
size_t length, addlength;
message = (errcode >= (int) (sizeof (pstring) / sizeof (char *)))?
"unknown error code" : pstring[errcode];
length = strlen (message) + 1;
addmessage = " at offset ";
addlength = (preg != NULL && (int) preg->re_erroffset != -1) ?
strlen (addmessage) + 6 : 0;
if (errbuf_size > 0) {
if (addlength > 0 && errbuf_size >= length + addlength)
sprintf (errbuf, "%s%s%-6d", message, addmessage,
(int) preg->re_erroffset);
else {
strncpy (errbuf, message, errbuf_size - 1);
errbuf[errbuf_size - 1] = 0;
}
}
return length + addlength;
}
/*************************************************
* Free store held by a regex *
*************************************************/
void
go_regfree (GORegexp * preg)
{
(pcre_free) (preg->re_pcre);
}
/*************************************************
* Compile a regular expression *
*************************************************/
/*
Arguments:
preg points to a structure for recording the compiled expression
pattern the pattern to compile
cflags compilation flags
Returns: 0 on success
various non-zero codes on failure
*/
int
go_regcomp (GORegexp * preg, const char *pattern, int cflags)
{
const char *errorptr;
int erroffset;
int options = 0;
if ((cflags & REG_ICASE) != 0)
options |= PCRE_CASELESS;
if ((cflags & REG_NEWLINE) != 0)
options |= PCRE_MULTILINE;
preg->re_pcre =
pcre_compile (pattern, options | PCRE_UTF8 | PCRE_NO_UTF8_CHECK,
&errorptr, &erroffset, NULL);
preg->re_erroffset = erroffset;
if (preg->re_pcre == NULL)
return pcre_posix_error_code (errorptr);
preg->re_nsub = pcre_info ((const pcre *) preg->re_pcre, NULL, NULL);
return 0;
}
/*************************************************
* Match a regular expression *
*************************************************/
/* Unfortunately, PCRE requires 3 ints of working space for each captured
substring, so we have to get and release working store instead of just using
the POSIX structures as was done in earlier releases when PCRE needed only 2
ints. However, if the number of possible capturing brackets is small, use a
block of store on the stack, to reduce the use of malloc/free. The threshold is
in a macro that can be changed at configure time. */
int
go_regexec (const GORegexp * preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags)
{
int rc;
int options = 0;
int *ovector = NULL;
int small_ovector[POSIX_MALLOC_THRESHOLD * 3];
BOOL allocated_ovector = FALSE;
if ((eflags & REG_NOTBOL) != 0)
options |= PCRE_NOTBOL;
if ((eflags & REG_NOTEOL) != 0)
options |= PCRE_NOTEOL;
((GORegexp *) preg)->re_erroffset = (size_t) (-1); /* Only has meaning after compile */
if (nmatch > 0) {
if (nmatch <= POSIX_MALLOC_THRESHOLD) {
ovector = &(small_ovector[0]);
} else {
ovector = (int *) malloc (sizeof (int) * nmatch * 3);
if (ovector == NULL)
return REG_ESPACE;
allocated_ovector = TRUE;
}
}
rc =
pcre_exec ((const pcre *) preg->re_pcre, NULL, string,
(int) strlen (string), 0, options, ovector, nmatch * 3);
if (rc == 0)
rc = nmatch; /* All captured slots were filled in */
if (rc >= 0) {
size_t i;
for (i = 0; i < (size_t) rc; i++) {
pmatch[i].rm_so = ovector[i * 2];
pmatch[i].rm_eo = ovector[i * 2 + 1];
}
if (allocated_ovector)
free (ovector);
for (; i < nmatch; i++)
pmatch[i].rm_so = pmatch[i].rm_eo = -1;
return 0;
}
else {
if (allocated_ovector)
free (ovector);
switch (rc) {
case PCRE_ERROR_NOMATCH:
return REG_NOMATCH;
case PCRE_ERROR_NULL:
return REG_INVARG;
case PCRE_ERROR_BADOPTION:
return REG_INVARG;
case PCRE_ERROR_BADMAGIC:
return REG_INVARG;
case PCRE_ERROR_UNKNOWN_NODE:
return REG_ASSERT;
case PCRE_ERROR_NOMEMORY:
return REG_ESPACE;
case PCRE_ERROR_MATCHLIMIT:
return REG_ESPACE;
case PCRE_ERROR_BADUTF8:
return REG_INVARG;
case PCRE_ERROR_BADUTF8_OFFSET:
return REG_INVARG;
default:
return REG_ASSERT;
}
}
}
/* End of pcreposix.c */

View File

@ -0,0 +1,123 @@
/* File import from pcre to goffice by import-pcre. Do not edit. */
/* This file has been programatically changed. */
/* This makes the following file fall under GPL license, see pcreposix.c. */
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
#ifndef _PCREPOSIX_H
#define _PCREPOSIX_H
/* This is the header for the POSIX wrapper interface to the PCRE Perl-
Compatible Regular Expression library. It defines the things POSIX says should
be there. I hope.
Copyright (c) 1997-2004 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* Have to include stdlib.h in order to ensure that size_t is defined. */
#include <stdlib.h>
/* Allow for C++ users */
#ifdef __cplusplus
extern "C" {
#endif
/* Options defined by POSIX. */
#define REG_ICASE 0x01
#define REG_NEWLINE 0x02
#define REG_NOTBOL 0x04
#define REG_NOTEOL 0x08
/* These are not used by PCRE, but by defining them we make it easier
to slot PCRE into existing programs that make POSIX calls. */
#define REG_EXTENDED 0
#define REG_NOSUB 0
/* Error values. Not all these are relevant or used by the wrapper. */
enum {
REG_OK = 0,
REG_ASSERT = 1, /* internal error ? */
REG_BADBR, /* invalid repeat counts in {} */
REG_BADPAT, /* pattern error */
REG_BADRPT, /* ? * + invalid */
REG_EBRACE, /* unbalanced {} */
REG_EBRACK, /* unbalanced [] */
REG_ECOLLATE, /* collation error - not relevant */
REG_ECTYPE, /* bad class */
REG_EESCAPE, /* bad escape sequence */
REG_EMPTY, /* empty expression */
REG_EPAREN, /* unbalanced () */
REG_ERANGE, /* bad range inside [] */
REG_ESIZE, /* expression too big */
REG_ESPACE, /* failed to get memory */
REG_ESUBREG, /* bad back reference */
REG_INVARG, /* bad argument */
REG_NOMATCH /* match failed */
};
/* The structure representing a compiled regular expression. */
typedef struct {
void *re_pcre;
size_t re_nsub;
size_t re_erroffset;
} GORegexp;
/* The structure in which a captured offset is returned. */
typedef int go_regoff_t;
typedef struct {
go_regoff_t rm_so;
go_regoff_t rm_eo;
} regmatch_t;
/* The functions */
extern int go_regcomp (GORegexp *, const char *, int);
extern int go_regexec (const GORegexp *, const char *, size_t,
regmatch_t *, int);
extern size_t go_regerror (int, const GORegexp *, char *, size_t);
extern void go_regfree (GORegexp *);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* End of pcreposix.h */

View File

@ -0,0 +1,493 @@
/* File import from pcre to goffice by import-pcre. Do not edit. */
/* This file has been programatically changed. */
/* This makes the following file fall under GPL license, see below. */
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/*
This is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language. See
the file Tech.Notes for some information on the internals.
Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2004 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* Include the internals header, which itself includes Standard C headers plus
the external pcre header. */
#include <goffice/goffice-config.h>
#include "internal.h"
/*************************************************
* Set a bit and maybe its alternate case *
*************************************************/
/* Given a character, set its bit in the table, and also the bit for the other
version of a letter if we are caseless.
Arguments:
start_bits points to the bit map
c is the character
caseless the caseless flag
cd the block with char table pointers
Returns: nothing
*/
static void
set_bit (uschar * start_bits, unsigned int c, BOOL caseless,
compile_data * cd)
{
start_bits[c / 8] |= (1 << (c & 7));
if (caseless && (cd->ctypes[c] & ctype_letter) != 0)
start_bits[cd->fcc[c] / 8] |= (1 << (cd->fcc[c] & 7));
}
/*************************************************
* Create bitmap of starting chars *
*************************************************/
/* This function scans a compiled unanchored expression and attempts to build a
bitmap of the set of initial characters. If it can't, it returns FALSE. As time
goes by, we may be able to get more clever at doing this.
Arguments:
code points to an expression
start_bits points to a 32-byte table, initialized to 0
caseless the current state of the caseless flag
utf8 TRUE if in UTF-8 mode
cd the block with char table pointers
Returns: TRUE if table built, FALSE otherwise
*/
static BOOL
set_start_bits (const uschar * code, uschar * start_bits, BOOL caseless,
BOOL utf8, compile_data * cd)
{
register int c;
/* This next statement and the later reference to dummy are here in order to
trick the optimizer of the IBM C compiler for OS/2 into generating correct
code. Apparently IBM isn't going to fix the problem, and we would rather not
disable optimization (in this module it actually makes a big difference, and
the pcre module can use all the optimization it can get). */
volatile int dummy;
do {
const uschar *tcode = code + 1 + LINK_SIZE;
BOOL try_next = TRUE;
while (try_next) {
/* If a branch starts with a bracket or a positive lookahead assertion,
recurse to set bits from within them. That's all for this branch. */
if ((int) *tcode >= OP_BRA || *tcode == OP_ASSERT) {
if (!set_start_bits
(tcode, start_bits, caseless, utf8, cd)) return FALSE;
try_next = FALSE;
}
else
switch (*tcode) {
default:
return FALSE;
/* Skip over callout */
case OP_CALLOUT:
tcode += 2 + 2 * LINK_SIZE;
break;
/* Skip over extended extraction bracket number */
case OP_BRANUMBER:
tcode += 3;
break;
/* Skip over lookbehind and negative lookahead assertions */
case OP_ASSERT_NOT:
case OP_ASSERTBACK:
case OP_ASSERTBACK_NOT:
do
tcode += GET (tcode, 1);
while (*tcode == OP_ALT);
tcode += 1 + LINK_SIZE;
break;
/* Skip over an option setting, changing the caseless flag */
case OP_OPT:
caseless = (tcode[1] & PCRE_CASELESS) != 0;
tcode += 2;
break;
/* BRAZERO does the bracket, but carries on. */
case OP_BRAZERO:
case OP_BRAMINZERO:
if (!set_start_bits
(++tcode, start_bits, caseless, utf8, cd))
return FALSE;
dummy = 1;
do
tcode += GET (tcode, 1);
while (*tcode == OP_ALT);
tcode += 1 + LINK_SIZE;
break;
/* Single-char * or ? sets the bit and tries the next item */
case OP_STAR:
case OP_MINSTAR:
case OP_QUERY:
case OP_MINQUERY:
set_bit (start_bits, tcode[1], caseless, cd);
tcode += 2;
#ifdef SUPPORT_UTF8
if (1 /* utf8 */ )
while ((*tcode & 0xc0) == 0x80)
tcode++;
#endif
break;
/* Single-char upto sets the bit and tries the next */
case OP_UPTO:
case OP_MINUPTO:
set_bit (start_bits, tcode[3], caseless, cd);
tcode += 4;
#ifdef SUPPORT_UTF8
if (1 /* utf8 */ )
while ((*tcode & 0xc0) == 0x80)
tcode++;
#endif
break;
/* At least one single char sets the bit and stops */
case OP_EXACT: /* Fall through */
tcode += 2;
case OP_CHAR:
case OP_CHARNC:
case OP_PLUS:
case OP_MINPLUS:
set_bit (start_bits, tcode[1], caseless, cd);
try_next = FALSE;
break;
/* Single character type sets the bits and stops */
case OP_NOT_DIGIT:
for (c = 0; c < 32; c++)
start_bits[c] |= ~cd->cbits[c + cbit_digit];
try_next = FALSE;
break;
case OP_DIGIT:
for (c = 0; c < 32; c++)
start_bits[c] |= cd->cbits[c + cbit_digit];
try_next = FALSE;
break;
case OP_NOT_WHITESPACE:
for (c = 0; c < 32; c++)
start_bits[c] |= ~cd->cbits[c + cbit_space];
try_next = FALSE;
break;
case OP_WHITESPACE:
for (c = 0; c < 32; c++)
start_bits[c] |= cd->cbits[c + cbit_space];
try_next = FALSE;
break;
case OP_NOT_WORDCHAR:
for (c = 0; c < 32; c++)
start_bits[c] |= ~cd->cbits[c + cbit_word];
try_next = FALSE;
break;
case OP_WORDCHAR:
for (c = 0; c < 32; c++)
start_bits[c] |= cd->cbits[c + cbit_word];
try_next = FALSE;
break;
/* One or more character type fudges the pointer and restarts, knowing
it will hit a single character type and stop there. */
case OP_TYPEPLUS:
case OP_TYPEMINPLUS:
tcode++;
break;
case OP_TYPEEXACT:
tcode += 3;
break;
/* Zero or more repeats of character types set the bits and then
try again. */
case OP_TYPEUPTO:
case OP_TYPEMINUPTO:
tcode += 2; /* Fall through */
case OP_TYPESTAR:
case OP_TYPEMINSTAR:
case OP_TYPEQUERY:
case OP_TYPEMINQUERY:
switch (tcode[1]) {
case OP_ANY:
return FALSE;
case OP_NOT_DIGIT:
for (c = 0; c < 32; c++)
start_bits[c] |= ~cd->cbits[c + cbit_digit];
break;
case OP_DIGIT:
for (c = 0; c < 32; c++)
start_bits[c] |= cd->cbits[c + cbit_digit];
break;
case OP_NOT_WHITESPACE:
for (c = 0; c < 32; c++)
start_bits[c] |= ~cd->cbits[c + cbit_space];
break;
case OP_WHITESPACE:
for (c = 0; c < 32; c++)
start_bits[c] |= cd->cbits[c + cbit_space];
break;
case OP_NOT_WORDCHAR:
for (c = 0; c < 32; c++)
start_bits[c] |= ~cd->cbits[c + cbit_word];
break;
case OP_WORDCHAR:
for (c = 0; c < 32; c++)
start_bits[c] |= cd->cbits[c + cbit_word];
break;
}
tcode += 2;
break;
/* Character class where all the information is in a bit map: set the
bits and either carry on or not, according to the repeat count. If it was
a negative class, and we are operating with UTF-8 characters, any byte
with a value >= 0xc4 is a potentially valid starter because it starts a
character with a value > 255. */
case OP_NCLASS:
if (1 /* utf8 */ ) {
start_bits[24] |= 0xf0; /* Bits for 0xc4 - 0xc8 */
memset (start_bits + 25, 0xff, 7); /* Bits for 0xc9 - 0xff */
}
/* Fall through */
case OP_CLASS:
{
tcode++;
/* In UTF-8 mode, the bits in a bit map correspond to character
values, not to byte values. However, the bit map we are constructing is
for byte values. So we have to do a conversion for characters whose
value is > 127. In fact, there are only two possible starting bytes for
characters in the range 128 - 255. */
if (1 /* utf8 */ ) {
for (c = 0; c < 16; c++)
start_bits[c] |= tcode[c];
for (c = 128; c < 256; c++) {
if ((tcode[c / 8] && (1 << (c & 7))) != 0) {
int d = (c >> 6) | 0xc0; /* Set bit for this starter */
start_bits[d / 8] |= (1 << (d & 7)); /* and then skip on to the */
c = (c & 0xc0) + 0x40 - 1; /* next relevant character. */
}
}
}
/* In non-UTF-8 mode, the two bit maps are completely compatible. */
else {
for (c = 0; c < 32; c++)
start_bits[c] |= tcode[c];
}
/* Advance past the bit map, and act on what follows */
tcode += 32;
switch (*tcode) {
case OP_CRSTAR:
case OP_CRMINSTAR:
case OP_CRQUERY:
case OP_CRMINQUERY:
tcode++;
break;
case OP_CRRANGE:
case OP_CRMINRANGE:
if (((tcode[1] << 8) + tcode[2]) == 0)
tcode += 5;
else
try_next = FALSE;
break;
default:
try_next = FALSE;
break;
}
}
break; /* End of bitmap class handling */
} /* End of switch */
} /* End of try_next loop */
code += GET (code, 1); /* Advance to next branch */
}
while (*code == OP_ALT);
return TRUE;
}
/*************************************************
* Study a compiled expression *
*************************************************/
/* This function is handed a compiled expression that it must study to produce
information that will speed up the matching. It returns a pcre_extra block
which then gets handed back to pcre_exec().
Arguments:
re points to the compiled expression
options contains option bits
errorptr points to where to place error messages;
set NULL unless error
Returns: pointer to a pcre_extra block, with study_data filled in and the
appropriate flag set;
NULL on error or if no optimization possible
*/
pcre_extra *
pcre_study (const pcre * external_re, int options, const char **errorptr)
{
uschar start_bits[32];
pcre_extra *extra;
pcre_study_data *study;
const uschar *tables;
const real_pcre *re = (const real_pcre *) external_re;
uschar *code = (uschar *) re + re->name_table_offset +
(re->name_count * re->name_entry_size);
compile_data compile_block;
*errorptr = NULL;
if (re == NULL || re->magic_number != MAGIC_NUMBER) {
*errorptr = "argument is not a compiled regular expression";
return NULL;
}
if ((options & ~PUBLIC_STUDY_OPTIONS) != 0) {
*errorptr = "unknown or incorrect option bit(s) set";
return NULL;
}
/* For an anchored pattern, or an unanchored pattern that has a first char, or
a multiline pattern that matches only at "line starts", no further processing
at present. */
if ((re->options & (PCRE_ANCHORED | PCRE_FIRSTSET | PCRE_STARTLINE)) !=
0) return NULL;
/* Set the character tables in the block that is passed around */
tables = re->tables;
if (tables == NULL)
(void) pcre_fullinfo (external_re, NULL, PCRE_INFO_DEFAULT_TABLES, &tables);
compile_block.lcc = tables + lcc_offset;
compile_block.fcc = tables + fcc_offset;
compile_block.cbits = tables + cbits_offset;
compile_block.ctypes = tables + ctypes_offset;
/* See if we can find a fixed set of initial characters for the pattern. */
memset (start_bits, 0, 32 * sizeof (uschar));
if (!set_start_bits
(code, start_bits, (re->options & PCRE_CASELESS) != 0,
(re->options & PCRE_UTF8) != 0, &compile_block))
return NULL;
/* Get a pcre_extra block and a pcre_study_data block. The study data is put in
the latter, which is pointed to by the former, which may also get additional
data set later by the calling program. At the moment, the size of
pcre_study_data is fixed. We nevertheless save it in a field for returning via
the pcre_fullinfo() function so that if it becomes variable in the future, we
don't have to change that code. */
extra = (pcre_extra *) (pcre_malloc)
(sizeof (pcre_extra) + sizeof (pcre_study_data));
if (extra == NULL) {
*errorptr = "failed to get memory";
return NULL;
}
study = (pcre_study_data *) ((char *) extra + sizeof (pcre_extra));
extra->flags = PCRE_EXTRA_STUDY_DATA;
extra->study_data = study;
study->size = sizeof (pcre_study_data);
study->options = PCRE_STUDY_MAPPED;
memcpy (study->start_bits, start_bits, sizeof (start_bits));
return extra;
}
/* End of study.c */

View File

@ -0,0 +1,14 @@
noinst_LTLIBRARIES = libgoffice-data.la
libgoffice_data_la_SOURCES = \
go-data.c \
go-data-simple.c
libgoffice_data_ladir = $(goffice_include_dir)/data
libgoffice_data_la_HEADERS = \
goffice-data.h \
go-data.h \
go-data-impl.h \
go-data-simple.h
include $(top_srcdir)/lib/goffice-0.0.4/goffice.mk

View File

@ -15,14 +15,14 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_DATA_IMPL_H
#define GO_DATA_IMPL_H
#include <goffice/graph/goffice-graph.h>
#include <goffice/graph/go-data.h>
#include <goffice/data/goffice-data.h>
#include <goffice/data/go-data.h>
#include <glib-object.h>
G_BEGIN_DECLS
@ -83,7 +83,7 @@ typedef struct {
struct _GODataMatrix {
GOData base;
GOMatrixSize size; /* negative if dirty, includes missing values */
GODataMatrixSize size; /* negative if dirty, includes missing values */
double *values; /* NULL = uninitialized/unsupported, nan = missing */
double minimum, maximum;
};

View File

@ -2,7 +2,7 @@
/*
* go-data-simple.c :
*
* Copyright (C) 2003-2004 Jody Goldberg (jody@gnome.org)
* Copyright (C) 2003-2005 Jody Goldberg (jody@gnome.org)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
@ -15,12 +15,13 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#include <goffice/goffice-config.h>
#include <goffice/graph/go-data-simple.h>
#include <goffice/graph/go-data-impl.h>
#include "go-data-simple.h"
#include "go-data-impl.h"
#include <goffice/utils/go-format.h>
#include <goffice/utils/go-math.h>
#include <gsf/gsf-impl-utils.h>
@ -269,7 +270,8 @@ go_data_scalar_str_set_str (GODataScalarStr *str,
struct _GODataVectorVal {
GODataVector base;
unsigned n;
double const *val;
double *val;
GDestroyNotify notify;
};
typedef GODataVectorClass GODataVectorValClass;
@ -278,7 +280,9 @@ static GObjectClass *vector_val_parent_klass;
static void
go_data_vector_val_finalize (GObject *obj)
{
/* GODataVectorVal *val = (GODataVectorVal *)obj; */
GODataVectorVal *vec = (GODataVectorVal *)obj;
if (vec->notify && vec->val)
(*vec->notify) (vec->val);
(*vector_val_parent_klass->finalize) (obj);
}
@ -288,6 +292,11 @@ go_data_vector_val_dup (GOData const *src)
{
GODataVectorVal *dst = g_object_new (G_OBJECT_TYPE (src), NULL);
GODataVectorVal const *src_val = (GODataVectorVal const *)src;
if (src_val->notify) {
dst->val = g_new (double, src_val->n);
memcpy (dst->val, src_val->val, src_val->n * sizeof (double));
dst->notify = g_free;
} else
dst->val = src_val->val;
dst->n = src_val->n;
return GO_DATA (dst);
@ -329,15 +338,90 @@ go_data_vector_val_load_values (GODataVector *vec)
vec->maximum = maximum;
vec->base.flags |= GO_DATA_CACHE_IS_VALID;
}
static double
go_data_vector_val_get_value (GODataVector *vec, unsigned i)
{
return vec->values[i];
GODataVectorVal const *val = (GODataVectorVal const *)vec;
g_return_val_if_fail (val != NULL && val->val != NULL && i < val->n, go_nan);
return val->val[i];
}
static char *
go_data_vector_val_get_str (GODataVector *vec, unsigned i)
{
return g_strdup_printf ("%g", vec->values[i]);
GODataVectorVal const *val = (GODataVectorVal const *)vec;
g_return_val_if_fail (val != NULL && val->val != NULL && i < val->n, NULL);
return g_strdup_printf ("%g", val->val[i]);
}
static char *
go_data_vector_val_as_str (GOData const *dat)
{
GODataVectorVal *vec = GO_DATA_VECTOR_VAL (dat);
GString *str;
char sep, sz[G_ASCII_DTOSTR_BUF_SIZE];
unsigned i;
if (vec->n ==0)
return g_strdup ("");
sep = format_get_col_sep ();
g_snprintf (sz, sizeof (sz), "%g", vec->val[0]);
str = g_string_new (sz);
for (i = 1; i < vec->n; i++) {
g_string_append_c (str, sep);
g_snprintf (sz, sizeof (sz), "%g", vec->val[i]);
g_string_append (str, sz);
}
return g_string_free (str, FALSE);
}
static gboolean
go_data_vector_val_from_str (GOData *dat, char const *str)
{
GODataVectorVal *vec = GO_DATA_VECTOR_VAL (dat);
char sep, *end = (char*) str;
double val;
GArray *values;
g_return_val_if_fail (str != NULL, TRUE);
if (vec->notify && vec->val)
(*vec->notify) (vec->val);
values = g_array_sized_new (FALSE, FALSE, sizeof(double), 16);
sep = 0;
vec->val = NULL;
vec->n = 0;
vec->notify = (GDestroyNotify) g_free;
while (1) {
val = g_strtod (end, &end);
g_array_append_val (values, val);
if (*end) {
if (!sep) {
/* allow the use of all possible seps */
if ((sep = format_get_arg_sep ()) != *end)
if ((sep = format_get_col_sep ()) != *end)
sep = format_get_row_sep ();
}
if (*end != sep) {
g_array_free (values, TRUE);
return FALSE;
}
end++;
} else
break;
}
if (values->len == 0) {
g_array_free (values, TRUE);
return TRUE;
}
vec->n = values->len;
vec->val = (double*) values->data;
g_array_free (values, FALSE);
go_data_emit_changed (GO_DATA (vec));
return TRUE;
}
static void
@ -350,8 +434,8 @@ go_data_vector_val_class_init (GObjectClass *gobject_klass)
gobject_klass->finalize = go_data_vector_val_finalize;
godata_klass->dup = go_data_vector_val_dup;
godata_klass->eq = go_data_vector_val_eq;
godata_klass->as_str = NULL;
godata_klass->from_str = NULL;
godata_klass->as_str = go_data_vector_val_as_str;
godata_klass->from_str = go_data_vector_val_from_str;
vector_klass->load_len = go_data_vector_val_load_len;
vector_klass->load_values = go_data_vector_val_load_values;
vector_klass->get_value = go_data_vector_val_get_value;
@ -363,11 +447,12 @@ GSF_CLASS (GODataVectorVal, go_data_vector_val,
GO_DATA_VECTOR_TYPE)
GOData *
go_data_vector_val_new (double const *val, unsigned n)
go_data_vector_val_new (double *val, unsigned n, GDestroyNotify notify)
{
GODataVectorVal *res = g_object_new (GO_DATA_VECTOR_VAL_TYPE, NULL);
res->val = val;
res->n = n;
res->notify = notify;
return GO_DATA (res);
}
@ -376,7 +461,8 @@ go_data_vector_val_new (double const *val, unsigned n)
struct _GODataVectorStr {
GODataVector base;
char const * const *str;
unsigned n;
int n;
GDestroyNotify notify;
GOTranslateFunc translate_func;
gpointer translate_data;
@ -386,10 +472,29 @@ typedef GODataVectorClass GODataVectorStrClass;
static GObjectClass *vector_str_parent_klass;
static void
cb_strings_destroy_notify (gpointer data)
{
char **str = (char **) data;
unsigned i = 0;
while (str[i] != NULL)
g_free (str[i++]);
g_free (str);
}
static void
go_data_vector_str_finalize (GObject *obj)
{
/* GODataVectorStr *str = (GODataVectorStr *)obj; */
GODataVectorStr *str = (GODataVectorStr *)obj;
if (str->notify && str->str != NULL)
(*str->notify) ((gpointer)str->str);
if (str->translate_notify != NULL)
(*str->translate_notify) (str->translate_data);
if (str->base.values != NULL)
g_free (str->base.values);
str->base.values = NULL;
(*vector_str_parent_klass->finalize) (obj);
}
@ -400,6 +505,15 @@ go_data_vector_str_dup (GOData const *src)
GODataVectorStr *dst = g_object_new (G_OBJECT_TYPE (src), NULL);
GODataVectorStr const *src_val = (GODataVectorStr const *)src;
dst->n = src_val->n;
if (src_val->notify) {
int i;
char const * *str = g_new (char const *, src_val->n + 1);
for (i = 0; i < src_val->n; i++)
str[i] = g_strdup (src_val->str[i]);
str[src_val->n] = NULL;
dst->str = str;
dst->notify = cb_strings_destroy_notify;
} else
dst->str = src_val->str;
return GO_DATA (dst);
}
@ -412,21 +526,155 @@ go_data_vector_str_eq (GOData const *a, GOData const *b)
return str_a->str == str_b->str && str_a->n == str_b->n;
}
static char *
go_data_vector_str_as_str (GOData const *dat)
{
GODataVectorStr *vec = GO_DATA_VECTOR_STR (dat);
GString *str;
char sep;
int i;
sep = format_get_col_sep ();
if (vec->n ==0)
return g_strdup ("");
str = g_string_new ("");
g_string_append_c (str, '\"');
g_string_append (str, vec->str[0]);
g_string_append_c (str, '\"');
for (i = 1; i < vec->n; i++) {
g_string_append_c (str, sep);
g_string_append_c (str, '\"');
g_string_append (str, vec->str[i]);
g_string_append_c (str, '\"');
}
return g_string_free (str, FALSE);
}
static gboolean
go_data_vector_str_from_str (GOData *dat, char const *str)
{
GODataVectorStr *vec = GO_DATA_VECTOR_STR (dat);
char sep, *cur = (char*) str, *end, *val;
GArray *values;
g_return_val_if_fail (str != NULL, TRUE);
if (vec->notify && vec->str)
(*vec->notify) ((gpointer)vec->str);
values = g_array_sized_new (FALSE, FALSE, sizeof(char*), 16);
/* search which separator has been used */
sep = format_get_col_sep ();
end = strchr (cur, sep);
if (end == NULL) {
sep = format_get_arg_sep ();
end = strchr (cur, sep);
if (end ==NULL)
sep = format_get_row_sep ();
}
vec->str = NULL;
vec->n = 0;
vec->notify = cb_strings_destroy_notify;
while (*cur) {
if (*cur == '\"') {
cur++;
end = strchr (cur, '\"');
if (end == NULL) {
g_array_free (values, TRUE);
return FALSE;
}
val = g_strndup (cur, end - cur);
g_array_append_val (values, val);
if (end[1] == 0)
break;
if (end[1] != sep) {
g_array_free (values, TRUE);
return FALSE;
}
cur = end + 2;
} else {
/* the string is not quotes delimited */
end = strchr (cur, sep);
if (end == NULL) {
if (strchr (cur, '\"')) {
/* string containg quotes are not allowed */
g_array_free (values, TRUE);
return FALSE;
}
val = g_strdup (cur);
g_array_append_val (values, val);
break;
}
val = g_strndup (cur, end - cur);
g_array_append_val (values, val);
if (strchr (val, '\"')) {
/* string containg quotes are not allowed */
g_array_free (values, TRUE);
return FALSE;
}
cur = end + 1;
}
}
if (values->len == 0) {
g_array_free (values, TRUE);
return TRUE;
}
vec->n = values->len;
val = NULL;
g_array_append_val (values, val);
vec->str = (char const*const*) values->data;
g_array_free (values, FALSE);
go_data_emit_changed (GO_DATA (vec));
return TRUE;
}
static void
go_data_vector_str_load_len (GODataVector *vec)
{
vec->base.flags |= GO_DATA_VECTOR_LEN_CACHED;
if (vec->values && vec->len != ((GODataVectorStr *)vec)->n) {
g_free (vec->values);
vec->values = NULL;
}
vec->len = ((GODataVectorStr *)vec)->n;
}
static void
go_data_vector_str_load_values (GODataVector *vec)
{
char *end;
GODataVectorStr const *strs = (GODataVectorStr const *)vec;
double minimum = DBL_MAX, maximum = -DBL_MAX;
int i = vec->len = strs->n;
if (vec->values == NULL)
vec->values = g_new (double, strs->n);
while (i-- > 0) {
vec->values[i] = g_strtod (strs->str[i], &end);
if (*end) {
vec->values[i] = go_nan;
continue;
}
if (minimum > vec->values[i])
minimum = vec->values[i];
if (maximum < vec->values[i])
maximum = vec->values[i];
}
vec->minimum = minimum;
vec->maximum = maximum;
vec->base.flags |= GO_DATA_CACHE_IS_VALID;
}
static double
go_data_vector_str_get_value (GODataVector *vec, unsigned i)
{
return go_nan;
char *end;
GODataVectorStr *strs = (GODataVectorStr *)vec;
double d = g_strtod (strs->str[i], &end);
return (*end)? go_nan: d;
}
static char *
go_data_vector_str_get_str (GODataVector *vec, unsigned i)
{
@ -447,8 +695,8 @@ go_data_vector_str_class_init (GObjectClass *gobject_klass)
gobject_klass->finalize = go_data_vector_str_finalize;
godata_klass->dup = go_data_vector_str_dup;
godata_klass->eq = go_data_vector_str_eq;
godata_klass->as_str = NULL;
godata_klass->from_str = NULL;
godata_klass->as_str = go_data_vector_str_as_str;
godata_klass->from_str = go_data_vector_str_from_str;
vector_klass->load_len = go_data_vector_str_load_len;
vector_klass->load_values = go_data_vector_str_load_values;
vector_klass->get_value = go_data_vector_str_get_value;
@ -461,6 +709,7 @@ go_data_vector_str_init (GObject *obj)
GODataVectorStr *str = (GODataVectorStr *)obj;
str->str = NULL;
str->n = 0;
str->notify = NULL;
str->translate_func = NULL;
str->translate_data = NULL;
str->translate_notify = NULL;
@ -471,11 +720,12 @@ GSF_CLASS (GODataVectorStr, go_data_vector_str,
GO_DATA_VECTOR_TYPE)
GOData *
go_data_vector_str_new (char const * const *str, unsigned n)
go_data_vector_str_new (char const * const *str, unsigned n, GDestroyNotify notify)
{
GODataVectorStr *res = g_object_new (GO_DATA_VECTOR_STR_TYPE, NULL);
res->str = str;
res->n = n;
res->notify = notify;
return GO_DATA (res);
}
@ -535,3 +785,222 @@ go_data_vector_str_set_translation_domain (GODataVectorStr *vec,
go_data_vector_str_set_translate_func (vec,
(GOTranslateFunc)dgettext_swapped, g_strdup (domain), g_free);
}
/*****************************************************************************/
struct _GODataMatrixVal {
GODataMatrix base;
GODataMatrixSize size;
double *val;
GDestroyNotify notify;
};
typedef GODataMatrixClass GODataMatrixValClass;
static GObjectClass *matrix_val_parent_klass;
static void
go_data_matrix_val_finalize (GObject *obj)
{
GODataMatrixVal *mat = (GODataMatrixVal *)obj;
if (mat->notify && mat->val)
(*mat->notify) (mat->val);
(*matrix_val_parent_klass->finalize) (obj);
}
static GOData *
go_data_matrix_val_dup (GOData const *src)
{
GODataMatrixVal *dst = g_object_new (G_OBJECT_TYPE (src), NULL);
GODataMatrixVal const *src_val = (GODataMatrixVal const *)src;
if (src_val->notify) {
dst->val = g_new (double, src_val->size.rows * src_val->size.columns);
memcpy (dst->val, src_val->val, src_val->size.rows * src_val->size.columns * sizeof (double));
dst->notify = g_free;
} else
dst->val = src_val->val;
dst->size = src_val->size;
return GO_DATA (dst);
}
static gboolean
go_data_matrix_val_eq (GOData const *a, GOData const *b)
{
GODataMatrixVal const *val_a = (GODataMatrixVal const *)a;
GODataMatrixVal const *val_b = (GODataMatrixVal const *)b;
/* GOData::eq is used for identity, not arithmetic */
return val_a->val == val_b->val &&
val_a->size.rows == val_b->size.rows &&
val_a->size.columns == val_b->size.columns;
}
static void
go_data_matrix_val_load_size (GODataMatrix *mat)
{
mat->base.flags |= GO_DATA_MATRIX_SIZE_CACHED;
mat->size = ((GODataMatrixVal *)mat)->size;
}
static void
go_data_matrix_val_load_values (GODataMatrix *mat)
{
GODataMatrixVal const *val = (GODataMatrixVal const *)mat;
double minimum = DBL_MAX, maximum = -DBL_MAX;
int i = val->size.rows * val->size.columns;
mat->values = (double *)val->val;
while (i-- > 0) {
if (minimum > val->val[i])
minimum = val->val[i];
if (maximum < val->val[i])
maximum = val->val[i];
}
mat->minimum = minimum;
mat->maximum = maximum;
mat->base.flags |= GO_DATA_CACHE_IS_VALID;
}
static double
go_data_matrix_val_get_value (GODataMatrix *mat, unsigned i, unsigned j)
{
return mat->values[i * mat->size.columns + j];
}
static char *
go_data_matrix_val_get_str (GODataMatrix *mat, unsigned i, unsigned j)
{
return g_strdup_printf ("%g", mat->values[i * mat->size.columns + j]);
}
static char *
go_data_matrix_val_as_str (GOData const *dat)
{
GODataMatrixVal *mat = GO_DATA_MATRIX_VAL (dat);
GString *str;
char row_sep, col_sep, sz[G_ASCII_DTOSTR_BUF_SIZE];
int i, j;
if (mat->size.rows == 0 || mat->size.columns == 0)
return g_strdup ("");
col_sep = format_get_col_sep ();
row_sep = format_get_row_sep ();
g_snprintf (sz, sizeof (sz), "%g", mat->val[0]);
str = g_string_new (sz);
for (j = 1; j < mat->size.columns; j++) {
g_string_append_c (str, col_sep);
g_snprintf (sz, sizeof (sz), "%g", mat->val[j]);
g_string_append (str, sz);
}
for (i = 1; i < mat->size.rows; i++) {
g_string_append_c (str, row_sep);
g_snprintf (sz, sizeof (sz), "%g", mat->val[i * mat->size.columns]);
g_string_append (str, sz);
for (j = 1; j < mat->size.columns; j++) {
g_string_append_c (str, col_sep);
g_snprintf (sz, sizeof (sz), "%g", mat->val[i * mat->size.columns + j]);
g_string_append (str, sz);
}
}
return g_string_free (str, FALSE);
}
static gboolean
go_data_matrix_val_from_str (GOData *dat, char const *str)
{
GODataMatrixVal *mat = GO_DATA_MATRIX_VAL (dat);
char row_sep, col_sep, *end = (char*) str;
int i, j, columns;
double val;
GArray *values;
g_return_val_if_fail (str != NULL, TRUE);
values = g_array_sized_new (FALSE, FALSE, sizeof(double), 16);
col_sep = format_get_col_sep ();
row_sep = format_get_row_sep ();
i = j = columns = 0;
if (mat->notify && mat->val)
(*mat->notify) (mat->val);
mat->val = NULL;
mat->size.rows = 0;
mat->size.columns = 0;
mat->notify = g_free;
while (1) {
val = g_strtod (end, &end);
g_array_append_val (values, val);
if (*end) {
if (*end == col_sep)
j++;
else if (*end == row_sep) {
if (columns > 0) {
if (j == columns - 1) {
i++;
j = 0;
} else {
g_array_free (values, TRUE);
return FALSE;
}
} else {
columns = j + 1;
i++;
j = 0;
}
} else {
g_array_free (values, TRUE);
return FALSE;
}
end++;
} else
break;
}
if (j != columns - 1) {
g_array_free (values, TRUE);
return FALSE;
}
if (columns == 0) {
g_array_free (values, TRUE);
return TRUE;
}
mat->size.columns = columns;
mat->size.rows = i + 1;
mat->val = (double*) values->data;
g_array_free (values, FALSE);
go_data_emit_changed (GO_DATA (mat));
return TRUE;
}
static void
go_data_matrix_val_class_init (GObjectClass *gobject_klass)
{
GODataClass *godata_klass = (GODataClass *) gobject_klass;
GODataMatrixClass *matrix_klass = (GODataMatrixClass *) gobject_klass;
matrix_val_parent_klass = g_type_class_peek_parent (gobject_klass);
gobject_klass->finalize = go_data_matrix_val_finalize;
godata_klass->dup = go_data_matrix_val_dup;
godata_klass->eq = go_data_matrix_val_eq;
godata_klass->as_str = go_data_matrix_val_as_str;
godata_klass->from_str = go_data_matrix_val_from_str;
matrix_klass->load_size = go_data_matrix_val_load_size;
matrix_klass->load_values = go_data_matrix_val_load_values;
matrix_klass->get_value = go_data_matrix_val_get_value;
matrix_klass->get_str = go_data_matrix_val_get_str;
}
GSF_CLASS (GODataMatrixVal, go_data_matrix_val,
go_data_matrix_val_class_init, NULL,
GO_DATA_MATRIX_TYPE)
GOData *
go_data_matrix_val_new (double *val, unsigned rows, unsigned columns, GDestroyNotify notify)
{
GODataMatrixVal *res = g_object_new (GO_DATA_MATRIX_VAL_TYPE, NULL);
res->val = val;
res->size.rows = rows;
res->size.columns = columns;
res->notify = notify;
return GO_DATA (res);
}

View File

@ -15,14 +15,16 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_DATA_SIMPLE_H
#define GO_DATA_SIMPLE_H
#include <goffice/graph/goffice-graph.h>
#include <goffice/graph/go-data.h>
#include <goffice/data/goffice-data.h>
#include <goffice/data/go-data.h>
G_BEGIN_DECLS
#define GO_DATA_SCALAR_VAL_TYPE (go_data_scalar_val_get_type ())
#define GO_DATA_SCALAR_VAL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_DATA_SCALAR_VAL_TYPE, GODataScalarVal))
@ -48,7 +50,7 @@ void go_data_scalar_str_set_str (GODataScalarStr *str,
typedef struct _GODataVectorVal GODataVectorVal;
GType go_data_vector_val_get_type (void);
GOData *go_data_vector_val_new (double const *val, unsigned n);
GOData *go_data_vector_val_new (double *val, unsigned n, GDestroyNotify notify);
#define GO_DATA_VECTOR_STR_TYPE (go_data_vector_str_get_type ())
#define GO_DATA_VECTOR_STR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_DATA_VECTOR_STR_TYPE, GODataVectorStr))
@ -56,7 +58,7 @@ GOData *go_data_vector_val_new (double const *val, unsigned n);
typedef struct _GODataVectorStr GODataVectorStr;
GType go_data_vector_str_get_type (void);
GOData *go_data_vector_str_new (char const * const *str, unsigned n);
GOData *go_data_vector_str_new (char const * const *str, unsigned n, GDestroyNotify notify);
void go_data_vector_str_set_translate_func (GODataVectorStr *vector,
GOTranslateFunc func,
gpointer data,
@ -64,4 +66,14 @@ void go_data_vector_str_set_translate_func (GODataVectorStr *vector,
void go_data_vector_str_set_translation_domain (GODataVectorStr *vec,
char const *domain);
#define GO_DATA_MATRIX_VAL_TYPE (go_data_matrix_val_get_type ())
#define GO_DATA_MATRIX_VAL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_DATA_MATRIX_VAL_TYPE, GODataMatrixVal))
#define IS_GO_DATA_MATRIX_VAL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_DATA_MATRIX_VAL_TYPE))
typedef struct _GODataMatrixVal GODataMatrixVal;
GType go_data_matrix_val_get_type (void);
GOData *go_data_matrix_val_new (double *val, unsigned rows, unsigned columns, GDestroyNotify notify);
G_END_DECLS
#endif /* GO_DATA_SIMPLE_H */

View File

@ -2,7 +2,7 @@
/*
* go-data.c :
*
* Copyright (C) 2003-2004 Jody Goldberg (jody@gnome.org)
* Copyright (C) 2003-2005 Jody Goldberg (jody@gnome.org)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
@ -15,13 +15,13 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#include <goffice/goffice-config.h>
#include <goffice/graph/go-data.h>
#include <goffice/graph/go-data-impl.h>
#include "go-data.h"
#include "go-data-impl.h"
#include <goffice/utils/go-math.h>
#include <gsf/gsf-impl-utils.h>
@ -352,12 +352,12 @@ GSF_CLASS_ABSTRACT (GODataMatrix, go_data_matrix,
go_data_matrix_class_init, NULL,
GO_DATA_TYPE)
GOMatrixSize
GODataMatrixSize
go_data_matrix_get_size (GODataMatrix *mat)
{
if (! (mat->base.flags & GO_DATA_MATRIX_SIZE_CACHED)) {
GODataMatrixClass const *klass = GO_DATA_MATRIX_GET_CLASS (mat);
static GOMatrixSize null_size = {0, 0};
static GODataMatrixSize null_size = {0, 0};
g_return_val_if_fail (klass != NULL, null_size);
@ -388,13 +388,13 @@ go_data_matrix_get_values (GODataMatrix *mat)
double
go_data_matrix_get_value (GODataMatrix *mat, unsigned i, unsigned j)
{
g_return_val_if_fail (((int)i < mat->size.rows) && ((int)j < mat->size.columns), go_nan);
if (! (mat->base.flags & GO_DATA_CACHE_IS_VALID)) {
GODataMatrixClass const *klass = GO_DATA_MATRIX_GET_CLASS (mat);
g_return_val_if_fail (klass != NULL, go_nan);
return (*klass->get_value) (mat, i, j);
}
g_return_val_if_fail (((int)i < mat->size.rows) && ((int)j < mat->size.columns), go_nan);
return mat->values[i * mat->size.columns + j];
}
@ -405,6 +405,7 @@ go_data_matrix_get_str (GODataMatrix *mat, unsigned i, unsigned j)
char *res;
g_return_val_if_fail (klass != NULL, NULL);
g_return_val_if_fail (((int)i < mat->size.rows) && ((int)j < mat->size.columns), g_strdup (""));
res = (*klass->get_str) (mat, i, j);
if (res == NULL)

View File

@ -15,13 +15,13 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GO_DATA_H
#define GO_DATA_H
#include <goffice/graph/goffice-graph.h>
#include <goffice/data/goffice-data.h>
#include <goffice/utils/goffice-utils.h>
#include <glib-object.h>
@ -73,7 +73,7 @@ void go_data_vector_get_minmax (GODataVector *vec, double *min, double *max);
GType go_data_matrix_get_type (void);
GOMatrixSize go_data_matrix_get_size (GODataMatrix *mat);
GODataMatrixSize go_data_matrix_get_size (GODataMatrix *mat);
double *go_data_matrix_get_values (GODataMatrix *mat);
double go_data_matrix_get_value (GODataMatrix *mat, unsigned i, unsigned j);
char *go_data_matrix_get_str (GODataMatrix *mat, unsigned i, unsigned j);

View File

@ -1,8 +1,8 @@
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* goffice-app.h:
* goffice-data.h:
*
* Copyright (C) 2004 Jody Goldberg (jody@gnome.org)
* Copyright (C) 2005 Jody Goldberg (jody@gnome.org)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
@ -15,25 +15,27 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GOFFICE_APP_H
#define GOFFICE_APP_H
#ifndef GOFFICE_DATA_H
#define GOFFICE_DATA_H
#include <glib/gmacros.h>
#include <glib.h>
G_BEGIN_DECLS
typedef struct _GOApp GOApp;
typedef struct _GODoc GODoc;
typedef struct _GODocControl GODocControl;
typedef struct _GOPlugin GOPlugin;
typedef struct _GOPluginService GOPluginService;
typedef struct _GOPluginLoader GOPluginLoader;
typedef struct _GOErrorInfo GOErrorInfo;
/* Data */
typedef struct _GOData GOData;
typedef struct _GODataScalar GODataScalar;
typedef struct _GODataVector GODataVector;
typedef struct _GODataMatrix GODataMatrix;
typedef struct {
int rows; /* negative if dirty, includes missing values */
int columns; /* negative if dirty, includes missing values */
} GODataMatrixSize;
G_END_DECLS
#endif /* GOFFICE_GRAPH_H */
#endif /* GOFFICE_DATA_H */

Some files were not shown because too many files have changed in this diff Show More