rpms/gnumeric/devel gnumeric-1.6.3-gda3.patch, NONE, 1.1 gnumeric.spec, 1.24, 1.25
Hans de Goede (jwrdegoede)
fedora-extras-commits at redhat.com
Mon May 28 07:42:22 UTC 2007
Author: jwrdegoede
Update of /cvs/extras/rpms/gnumeric/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv18305
Modified Files:
gnumeric.spec
Added Files:
gnumeric-1.6.3-gda3.patch
Log Message:
* Sun May 27 2007 Hans de Goede <j.w.r.degoede at hhs.nl> 1:1.6.3-7
- Build against new libgda + libgnomedb
gnumeric-1.6.3-gda3.patch:
--- NEW FILE gnumeric-1.6.3-gda3.patch ---
--- gnumeric-1.6.3/configure.in.orig 2007-05-01 18:21:36.000000000 -0400
+++ gnumeric-1.6.3/configure.in 2007-05-01 18:22:54.000000000 -0400
@@ -369,11 +369,11 @@
fi
)
if test "$try_gda" = "true"; then
- PKG_CHECK_MODULES(GDA, [libgda-2.0 >= 1.3.0],
+ PKG_CHECK_MODULES(GDA, [libgda-3.0 >= 1.3.0],
[gda_msg=yes],
[gda_msg="NO. libgda problem"])
if test "$gda_msg" = "yes"; then
- PKG_CHECK_MODULES(GNOMEDB, [libgnomedb-2.0 >= 1.3.0],
+ PKG_CHECK_MODULES(GNOMEDB, [libgnomedb-3.0 >= 1.3.0],
[gnomedb_msg="yes"],
[gnomedb_msg="NO. libgnomedb problem"])
if test "$gnomedb_msg" = "yes"; then
--- gnumeric-1.6.3/plugins/gda/plugin-gda.c.orig 2007-05-01 18:52:12.000000000 -0400
+++ gnumeric-1.6.3/plugins/gda/plugin-gda.c 2007-05-01 19:01:11.000000000 -0400
@@ -1,6 +1,8 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Interface Gnumeric to Databases
* Copyright (C) 1998,1999 Michael Lausch
* Copyright (C) 2000-2002 Rodrigo Moya
+ * Copyright (C) 2006 Vivien Malerba
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -20,6 +22,7 @@
#include <gnumeric-config.h>
#include <gnumeric.h>
#include <libgda/libgda.h>
+#include <string.h>
#ifdef HAVE_LIBGNOMEDB
#include <libgnomedb/gnome-db-login-dialog.h>
#include <libgnomedb/gnome-db-login.h>
@@ -28,18 +31,116 @@
#include "func.h"
#include "expr.h"
#include "value.h"
+#include "workbook.h"
+#include "sheet.h"
#include "gnm-i18n.h"
#include <goffice/app/go-plugin.h>
#include <goffice/app/error-info.h>
+#include <goffice/utils/datetime.h>
+#include <goffice/utils/go-format.h>
#include <gnm-plugin.h>
GNM_PLUGIN_MODULE_HEADER;
-static GdaClient* connection_pool = NULL;
+static GdaClient *connection_pool = NULL;
+static gboolean libgda_init_done = FALSE;
+static GHashTable *cnc_hash = NULL;
+
+static GnmValue *
+gnm_value_new_from_gda (GValue const *gval,
+ GODateConventions const *date_conv)
+{
+ GnmValue *res;
+ GType t;
+
+ if (NULL == gval)
+ return value_new_empty ();
+
+ g_return_val_if_fail (G_IS_VALUE (gval), value_new_empty ());
+
+ t = G_VALUE_TYPE (gval);
+ if (t == GDA_TYPE_SHORT)
+ return value_new_int (gda_value_get_short (gval));
+ if (t == GDA_TYPE_USHORT)
+ return value_new_int (gda_value_get_ushort (gval));
+ if (t == G_TYPE_DATE) {
+ res = value_new_int (datetime_g_to_serial (
+ (GDate const *) g_value_get_boxed (gval), date_conv));
+ value_set_fmt (res, go_format_default_date ());
+ return res;
+ }
+
+ if (t == GDA_TYPE_TIME) {
+ GdaTime const *time = gda_value_get_time (gval);
+ res = value_new_float ( (time->hour +
+ (time->minute +
+ time->second / 60.) / 60.) / 24.),
+ value_set_fmt (res, go_format_default_time ());
+ return res;
+ }
+
+ switch (t) {
+ case G_TYPE_BOOLEAN :
+ return value_new_bool (g_value_get_boolean (gval));
+
+ case G_TYPE_DOUBLE :
+ return value_new_float (g_value_get_double (gval));
+ case G_TYPE_FLOAT :
+ return value_new_float (g_value_get_float (gval));
+#if 0
+ case G_TYPE_INT64 : /* g_value_get_int64 (gval) */
+ case G_TYPE_UINT64 : /* g_value_get_uint64 (gval) */
+#endif
+ case G_TYPE_INT :
+ return value_new_int (g_value_get_int (gval));
+ case G_TYPE_UINT :
+ return value_new_int (g_value_get_uint (gval));
+
+#if 0
+ /* No way to represent a timezone, leave it as a string for now */
+ case GDA_TYPE_TIMESTAMP:
+#endif
+#if 0
+ /* Do we want to consider nested arrays ??
+ * The rest of the system is not strong enough yet. */
+ case GDA_TYPE_LIST : {
+ GList const *ptr;
+ for (ptr = gda_value_get_list (gval) ; NULL != ptr ; ptr = ptr->next) {
+ }
+ return array;
+ }
+#endif
+
+#if 0
+ /* Use the default gvalue conversions for these */
+ case G_TYPE_CHAR :
+ case G_TYPE_UCHAR :
+ case G_TYPE_STRING :
+ case GDA_TYPE_GEOMETRIC_POINT :
+ case GDA_TYPE_BINARY :
+
+ /* this is stored as a string, let gda handle it */
+ case GDA_TYPE_NUMERIC :
+#endif
+ default :
+ break;
+ }
+
+ if (g_value_type_transformable (G_VALUE_TYPE (gval), G_TYPE_STRING)) {
+ GValue str = { 0 };
+ g_value_init (&str, G_TYPE_STRING);
+ if (g_value_transform (gval, &str))
+ return value_new_string (g_value_get_string (&str));
+ g_value_unset (&str);
+ }
+
+ return value_new_empty ();
+}
static GnmValue *
display_recordset (GdaDataModel *recset, FunctionEvalInfo *ei)
{
+ GODateConventions const *date_conv;
GnmValue* array = NULL;
gint col;
gint row;
@@ -48,8 +149,8 @@
g_return_val_if_fail (GDA_IS_DATA_MODEL (recset), NULL);
- fieldcount = gda_data_model_get_n_columns (GDA_DATA_MODEL (recset));
- rowcount = gda_data_model_get_n_rows (GDA_DATA_MODEL (recset));
+ fieldcount = gda_data_model_get_n_columns (recset);
+ rowcount = gda_data_model_get_n_rows (recset);
/* convert the GdaDataModel in an array */
if (rowcount <= 0)
@@ -58,31 +159,75 @@
if (rowcount >= SHEET_MAX_ROWS)
return value_new_error (ei->pos, _("Too much data returned"));
+ date_conv = workbook_date_conv (ei->pos->sheet->workbook);
array = value_new_array_empty (fieldcount, rowcount);
for (row = 0; row < rowcount; row++) {
for (col = 0; col < fieldcount; col++) {
- gchar *str;
- const GdaValue *value;
-
- value = gda_data_model_get_value_at (GDA_DATA_MODEL (recset),
- col, row);
- str = gda_value_stringify ((GdaValue *) value);
- value_array_set (array,
- col,
- row,
- value_new_string(str));
-
- g_free (str);
+ value_array_set (array, col, row,
+ gnm_value_new_from_gda (
+ gda_data_model_get_value_at (recset, col, row),
+ date_conv));
}
}
return array;
}
+/*
+ * Key structure and hash functions for that structure
+ */
+typedef struct {
+ gchar *dsn;
+ gchar *user;
+ gchar *pass;
+} CncKey;
+
+static guint
+cnc_key_hash_func (CncKey *key)
+{
+ guint retval = 0;
+
+ if (key->dsn)
+ retval = g_str_hash (key->dsn);
+ if (key->user)
+ retval = (retval << 4) + g_str_hash (key->user);
+ if (key->pass)
+ retval = (retval << 4) + g_str_hash (key->pass);
+
+ return retval;
+}
+
+static gboolean
+cnc_key_equal_func (CncKey *key1, CncKey *key2)
+{
+ if ((key1->dsn && !key2->dsn) ||
+ (!key1->dsn && key2->dsn) ||
+ (key1->dsn && key2->dsn && strcmp (key1->dsn, key2->dsn)))
+ return FALSE;
+ if ((key1->user && !key2->user) ||
+ (!key1->user && key2->user) ||
+ (key1->user && key2->user && strcmp (key1->user, key2->user)))
+ return FALSE;
+ if ((key1->pass && !key2->pass) ||
+ (!key1->pass && key2->pass) ||
+ (key1->pass && key2->pass && strcmp (key1->pass, key2->pass)))
+ return FALSE;
+ return TRUE;
+}
+
+static void
+cnc_key_free (CncKey *key)
+{
+ g_free (key->dsn);
+ g_free (key->user);
+ g_free (key->pass);
+ g_free (key);
+}
+
static GdaConnection *
open_connection (const gchar *dsn, const gchar *user, const gchar *password, GdaConnectionOptions options)
{
- GdaConnection *cnc;
+ GdaConnection *cnc = NULL;
gchar *real_dsn, *real_user, *real_password;
#ifdef HAVE_LIBGNOMEDB
GtkWidget *dialog, *login;
@@ -91,44 +236,77 @@
/* initialize connection pool if first time */
if (!GDA_IS_CLIENT (connection_pool)) {
+ if (!libgda_init_done) {
+ gda_init (NULL, NULL, 0, NULL);
+ libgda_init_done = TRUE;
+ }
connection_pool = gda_client_new ();
if (!connection_pool)
return NULL;
}
-#ifdef HAVE_LIBGNOMEDB
- dialog = gnome_db_login_dialog_new (_("Database Connection"));
- login = gnome_db_login_dialog_get_login_widget (GNOME_DB_LOGIN_DIALOG (dialog));
+ /* try to find a cnc object if we already have one */
+ if (!cnc_hash)
+ cnc_hash = g_hash_table_new_full ((GHashFunc) cnc_key_hash_func,
+ (GEqualFunc) cnc_key_equal_func,
+ (GDestroyNotify) cnc_key_free,
+ (GDestroyNotify) g_object_unref);
+ else {
+ CncKey key;
+
+ key.dsn = (gchar *) dsn;
+ key.user = (gchar *) user;
+ key.pass = (gchar *) password;
- gnome_db_login_set_dsn (GNOME_DB_LOGIN (login), dsn);
- gnome_db_login_set_username (GNOME_DB_LOGIN (login), user);
- gnome_db_login_set_password (GNOME_DB_LOGIN (login), password);
-
- if (gnome_db_login_dialog_run (GNOME_DB_LOGIN_DIALOG (dialog))) {
- real_dsn = g_strdup (gnome_db_login_get_dsn (GNOME_DB_LOGIN (login)));
- real_user = g_strdup (gnome_db_login_get_username (GNOME_DB_LOGIN (login)));
- real_password = g_strdup (gnome_db_login_get_password (GNOME_DB_LOGIN (login)));
-
- gtk_widget_destroy (dialog);
- } else {
- gtk_widget_destroy (dialog);
- return NULL;
+ cnc = g_hash_table_lookup (cnc_hash, &key);
}
-#else
- real_dsn = g_strdup (dsn);
- real_user = g_strdup (user);
- real_password = g_strdup (password);
-#endif
- cnc = gda_client_open_connection (connection_pool, real_dsn, real_user, real_password, options, &error);
if (!cnc) {
- g_warning ("Libgda error: %s\n", error->message);
- g_error_free (error);
- }
+ CncKey *key;
- g_free (real_dsn);
- g_free (real_user);
- g_free (real_password);
+#ifdef HAVE_LIBGNOMEDB
+ dialog = gnome_db_login_dialog_new (_("Database Connection"));
+ login = gnome_db_login_dialog_get_login_widget (GNOME_DB_LOGIN_DIALOG (dialog));
+
+ gnome_db_login_set_dsn (GNOME_DB_LOGIN (login), dsn);
+ gnome_db_login_set_username (GNOME_DB_LOGIN (login), user);
+ gnome_db_login_set_password (GNOME_DB_LOGIN (login), password);
+
+ if (gnome_db_login_dialog_run (GNOME_DB_LOGIN_DIALOG (dialog))) {
+ real_dsn = g_strdup (gnome_db_login_get_dsn (GNOME_DB_LOGIN (login)));
+ real_user = g_strdup (gnome_db_login_get_username (GNOME_DB_LOGIN (login)));
+ real_password = g_strdup (gnome_db_login_get_password (GNOME_DB_LOGIN (login)));
+
+ gtk_widget_destroy (dialog);
+ } else {
+ gtk_widget_destroy (dialog);
+ return NULL;
+ }
+#else
+ real_dsn = g_strdup (dsn);
+ real_user = g_strdup (user);
+ real_password = g_strdup (password);
+#endif
+
+ cnc = gda_client_open_connection (connection_pool, real_dsn, real_user, real_password, options, &error);
+ if (!cnc) {
+ g_warning ("Libgda error: %s\n", error->message);
+ g_error_free (error);
+ }
+
+ g_free (real_dsn);
+ g_free (real_user);
+ g_free (real_password);
+
+ key = g_new0 (CncKey, 1);
+ if (dsn)
+ key->dsn = g_strdup (dsn);
+ if (user)
+ key->user = g_strdup (user);
+ if (password)
+ key->pass = g_strdup (password);
+ g_hash_table_insert (cnc_hash, key, cnc);
+ }
return cnc;
}
@@ -293,7 +471,13 @@
}
GnmFuncDescriptor gdaif_functions[] = {
- {"execSQL", "ssss", "dsn,username,password,sql", help_execSQL, &gnumeric_execSQL, NULL, NULL, NULL },
- {"readDBTable", "ssss", "dsn,username,password,table", help_readDBTable, &gnumeric_readDBTable, NULL, NULL, NULL },
+ {
+ "execSQL", "ssss", "dsn,username,password,sql",
+ help_execSQL, &gnumeric_execSQL, NULL, NULL, NULL
+ },
+ {
+ "readDBTable", "ssss", "dsn,username,password,table",
+ help_readDBTable, &gnumeric_readDBTable, NULL, NULL, NULL
+ },
{NULL}
};
--- gnumeric-1.6.3/plugins/gnome-db/plugin-gnomedb.c.orig 2005-03-03 02:50:56.000000000 -0500
+++ gnumeric-1.6.3/plugins/gnome-db/plugin-gnomedb.c 2007-05-01 19:02:19.000000000 -0400
@@ -1,5 +1,5 @@
#include <gnumeric-config.h>
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
#include <glib.h>
#include <workbook-control-gui.h>
Index: gnumeric.spec
===================================================================
RCS file: /cvs/extras/rpms/gnumeric/devel/gnumeric.spec,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- gnumeric.spec 19 Feb 2007 10:37:28 -0000 1.24
+++ gnumeric.spec 28 May 2007 07:41:47 -0000 1.25
@@ -1,7 +1,7 @@
Name: gnumeric
Epoch: 1
Version: 1.6.3
-Release: 6%{?dist}
+Release: 7%{?dist}
Summary: Spreadsheet program for GNOME
Group: Applications/Productivity
License: GPL
@@ -10,6 +10,7 @@
Patch0: gnumeric-1.6.1-desktop.patch
Patch1: gnumeric-1.4.1-excelcrash.patch
Patch2: gnumeric-1.6.3-helppath.patch
+Patch3: gnumeric-1.6.3-gda3.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: desktop-file-utils >= 0.9
BuildRequires: libgnomeui-devel >= 2.4.0
@@ -18,7 +19,7 @@
BuildRequires: libgsf-gnome-devel >= 1.13.2
BuildRequires: automake autoconf libtool
BuildRequires: intltool scrollkeeper gettext
-BuildRequires: libgnomedb-devel >= 1.0.4
+BuildRequires: libgnomedb-devel >= 3.0.0
BuildRequires: pygtk2-devel >= 2.6.0
BuildRequires: goffice-devel >= 0.2.0
BuildRequires: guile-devel
@@ -49,6 +50,7 @@
%patch0 -p1 -b .desktop
%patch1 -p1 -b .excelcrash
%patch2 -p1 -b .helppath
+%patch3 -p1 -b .gda3
chmod -x plugins/excel/rc4.?
@@ -71,9 +73,7 @@
mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications
desktop-file-install --vendor fedora --delete-original \
--dir $RPM_BUILD_ROOT%{_datadir}/applications \
- --add-category X-Fedora \
--add-category Office \
- --add-category Application \
--add-category Spreadsheet \
$RPM_BUILD_ROOT%{_datadir}/applications/*.desktop
@@ -83,22 +83,22 @@
$RPM_BUILD_ROOT/usr/share/icons/hicolor/48x48/apps/%{name}.png
#remove unused mime type icons
-rm -rf $RPM_BUILD_ROOT/%{_datadir}/pixmaps/gnome-application-*.png
-rm -rf $RPM_BUILD_ROOT/%{_datadir}/pixmaps/%{name}-gnome-application-*.png
+rm $RPM_BUILD_ROOT/%{_datadir}/pixmaps/gnome-application-*.png
+rm $RPM_BUILD_ROOT/%{_datadir}/pixmaps/%{name}/gnome-application-*.png
#remove spurious .ico thing
-rm -rf $RPM_BUILD_ROOT/usr/share/pixmaps/win32-%{name}.ico
-rm -rf $RPM_BUILD_ROOT/usr/share/pixmaps/%{name}/win32-%{name}.ico
+rm $RPM_BUILD_ROOT/usr/share/pixmaps/win32-%{name}.ico
+rm $RPM_BUILD_ROOT/usr/share/pixmaps/%{name}/win32-%{name}.ico
#remove scrollkeeper stuff
rm -rf $RPM_BUILD_ROOT/var
#remove .la files
-rm -rf $RPM_BUILD_ROOT/%{_libdir}/libspreadsheet.la
-rm -rf $RPM_BUILD_ROOT/%{_libdir}/%{name}/%{version}/plugins/*/*.la
+rm $RPM_BUILD_ROOT/%{_libdir}/libspreadsheet.la
+rm $RPM_BUILD_ROOT/%{_libdir}/%{name}/%{version}/plugins/*/*.la
#remove bogus mc stuff
-rm -rf $RPM_BUILD_ROOT/%{_datadir}/mc
+rm -r $RPM_BUILD_ROOT/%{_datadir}/mc
%clean
@@ -168,6 +168,9 @@
%changelog
+* Sun May 27 2007 Hans de Goede <j.w.r.degoede at hhs.nl> 1:1.6.3-7
+- Build against new libgda + libgnomedb
+
* Mon Feb 19 2007 Hans de Goede <j.w.r.degoede at hhs.nl> 1:1.6.3-6
- Change BuildRequires: libgsf-devel to libgsf-gnome-devel to fix rawhide build
More information about the scm-commits
mailing list