Commit 5fb774c0 authored by Michael Meeks's avatar Michael Meeks Committed by Michael Meeks

kill warning.

2000-11-11  Michael Meeks  <michael@helixcode.com>

	* src/clipboard.c (apply_paste_oper_to_values): kill warning.

	* src/xml-io-autoft.c: remove stale enum.

	* src/xml-io.c (xml_check_version): publicized.
	(xml_parse_ctx_new_full): add version parameter.
	(xml_parse_ctx_new): update.

	* src/bonobo-io.c (gnumeric_bonobo_read_workbook): use
	xml_check_version.

	* src/bonobo-io.c (gnumeric_bonobo_write_workbook): open the
	stream with the correct permissions.
	(gnumeric_bonobo_io_probe): update to like directories too.
	(gnumeric_bonobo_io_init): register for '.efs'
	(gnumeric_bonobo_read_workbook): beef up exception reporting.

2000-11-11  Michael Meeks  <michael@helixcode.com>

	* POTFILES.in: add src/bonobo-io.c
parent 528e1b9a
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/clipboard.c (apply_paste_oper_to_values): kill warning.
* src/xml-io-autoft.c: remove stale enum.
* src/xml-io.c (xml_check_version): publicized.
(xml_parse_ctx_new_full): add version parameter.
(xml_parse_ctx_new): update.
* src/bonobo-io.c (gnumeric_bonobo_read_workbook): use
xml_check_version.
* src/bonobo-io.c (gnumeric_bonobo_write_workbook): open the
stream with the correct permissions.
(gnumeric_bonobo_io_probe): update to like directories too.
(gnumeric_bonobo_io_init): register for '.efs'
(gnumeric_bonobo_read_workbook): beef up exception reporting.
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/gnumeric.xml: fiddle, lots of strange mangling, needs HEAD
......
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/clipboard.c (apply_paste_oper_to_values): kill warning.
* src/xml-io-autoft.c: remove stale enum.
* src/xml-io.c (xml_check_version): publicized.
(xml_parse_ctx_new_full): add version parameter.
(xml_parse_ctx_new): update.
* src/bonobo-io.c (gnumeric_bonobo_read_workbook): use
xml_check_version.
* src/bonobo-io.c (gnumeric_bonobo_write_workbook): open the
stream with the correct permissions.
(gnumeric_bonobo_io_probe): update to like directories too.
(gnumeric_bonobo_io_init): register for '.efs'
(gnumeric_bonobo_read_workbook): beef up exception reporting.
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/gnumeric.xml: fiddle, lots of strange mangling, needs HEAD
......
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/clipboard.c (apply_paste_oper_to_values): kill warning.
* src/xml-io-autoft.c: remove stale enum.
* src/xml-io.c (xml_check_version): publicized.
(xml_parse_ctx_new_full): add version parameter.
(xml_parse_ctx_new): update.
* src/bonobo-io.c (gnumeric_bonobo_read_workbook): use
xml_check_version.
* src/bonobo-io.c (gnumeric_bonobo_write_workbook): open the
stream with the correct permissions.
(gnumeric_bonobo_io_probe): update to like directories too.
(gnumeric_bonobo_io_init): register for '.efs'
(gnumeric_bonobo_read_workbook): beef up exception reporting.
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/gnumeric.xml: fiddle, lots of strange mangling, needs HEAD
......
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/clipboard.c (apply_paste_oper_to_values): kill warning.
* src/xml-io-autoft.c: remove stale enum.
* src/xml-io.c (xml_check_version): publicized.
(xml_parse_ctx_new_full): add version parameter.
(xml_parse_ctx_new): update.
* src/bonobo-io.c (gnumeric_bonobo_read_workbook): use
xml_check_version.
* src/bonobo-io.c (gnumeric_bonobo_write_workbook): open the
stream with the correct permissions.
(gnumeric_bonobo_io_probe): update to like directories too.
(gnumeric_bonobo_io_init): register for '.efs'
(gnumeric_bonobo_read_workbook): beef up exception reporting.
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/gnumeric.xml: fiddle, lots of strange mangling, needs HEAD
......
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/clipboard.c (apply_paste_oper_to_values): kill warning.
* src/xml-io-autoft.c: remove stale enum.
* src/xml-io.c (xml_check_version): publicized.
(xml_parse_ctx_new_full): add version parameter.
(xml_parse_ctx_new): update.
* src/bonobo-io.c (gnumeric_bonobo_read_workbook): use
xml_check_version.
* src/bonobo-io.c (gnumeric_bonobo_write_workbook): open the
stream with the correct permissions.
(gnumeric_bonobo_io_probe): update to like directories too.
(gnumeric_bonobo_io_init): register for '.efs'
(gnumeric_bonobo_read_workbook): beef up exception reporting.
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/gnumeric.xml: fiddle, lots of strange mangling, needs HEAD
......
2000-11-11 Michael Meeks <michael@helixcode.com>
* POTFILES.in: add src/bonobo-io.c
2000-11-08 Andrew V. Samoilov <sav@bcs.zp.ua>
* ru.po: updated Russian translation.
......
......@@ -23,6 +23,7 @@ plugins/xbase/boot.c
plugins/xml2/xml2.c
src/about.c
src/analysis-tools.c
src/bonobo-io.c
src/cell.c
src/clipboard.c
src/cmd-edit.c
......
......@@ -241,11 +241,11 @@ gnumeric_bonobo_write_workbook (IOContext *context, WorkbookView *wb_view,
g_return_val_if_fail (wb_view != NULL, -1);
g_return_val_if_fail (filename != NULL, -1);
flags = Bonobo_Storage_CREATE | Bonobo_Storage_READ |
Bonobo_Storage_WRITE | Bonobo_Storage_FAILIFEXIST;
flags = Bonobo_Storage_CREATE | Bonobo_Storage_WRITE |
Bonobo_Storage_FAILIFEXIST;
storage = bonobo_storage_open (BONOBO_IO_DRIVER_EFS,
filename, flags, 0);
storage = bonobo_storage_open (BONOBO_IO_DRIVER_FS,
filename, flags, 0664);
if (!storage) {
char *msg = g_strdup_printf ("Can't open '%s'", filename);
......@@ -263,8 +263,10 @@ gnumeric_bonobo_write_workbook (IOContext *context, WorkbookView *wb_view,
bonobo_object_unref (BONOBO_OBJECT (storage));
return -1;
}
ctxt = xml_parse_ctx_new_full (xml, NULL, NULL, gnumeric_bonobo_obj_write,
storage);
ctxt = xml_parse_ctx_new_full (
xml, NULL, GNUM_XML_V5, NULL,
gnumeric_bonobo_obj_write, storage);
xml->root = xml_workbook_write (ctxt, wb_view);
xml_parse_ctx_destroy (ctxt);
......@@ -419,16 +421,17 @@ static int
gnumeric_bonobo_read_workbook (IOContext *context, WorkbookView *wb_view,
const char *filename)
{
CORBA_Environment ev;
xmlDocPtr res;
xmlNsPtr gmr;
XmlParseContext *ctxt;
BonoboStorage *storage;
Bonobo_Stream stream;
CORBA_Environment ev;
xmlDoc *doc;
xmlNs *gmr;
XmlParseContext *ctxt;
BonoboStorage *storage;
Bonobo_Stream stream;
GnumericXMLVersion version;
g_return_val_if_fail (filename != NULL, -1);
storage = bonobo_storage_open (BONOBO_IO_DRIVER_EFS,
storage = bonobo_storage_open (BONOBO_IO_DRIVER_FS,
filename, Bonobo_Storage_READ, 0);
if (!storage) {
char *msg = g_strdup_printf ("Can't open '%s'", filename);
......@@ -443,20 +446,23 @@ gnumeric_bonobo_read_workbook (IOContext *context, WorkbookView *wb_view,
"Workbook", Bonobo_Storage_READ, &ev);
if (BONOBO_EX (&ev) || stream == CORBA_OBJECT_NIL) {
gnumeric_io_error_save (context, "Error opening workbook stream");
char *txt = g_strdup_printf (_("Error '%s' opening workbook stream"),
bonobo_exception_get_text (&ev));
gnumeric_io_error_save (context, txt);
g_free (txt);
goto storage_err;
}
/*
* Load the file into an XML tree.
*/
res = hack_xmlSAXParseFile (stream);
if (!res) {
doc = hack_xmlSAXParseFile (stream);
if (!doc) {
gnumeric_io_error_read (context, "Failed to parse file");
goto storage_err;
}
if (!res->root) {
xmlFreeDoc (res);
if (!doc->root) {
xmlFreeDoc (doc);
gnumeric_io_error_read (context,
_("Invalid xml file. Tree is empty ?"));
goto storage_err;
......@@ -465,29 +471,26 @@ gnumeric_bonobo_read_workbook (IOContext *context, WorkbookView *wb_view,
/*
* Do a bit of checking, get the namespaces, and check the top elem.
*/
gmr = xmlSearchNsByHref (res, res->root, "http://www.gnome.org/gnumeric/v3");
if (gmr == NULL)
gmr = xmlSearchNsByHref (res, res->root, "http://www.gnome.org/gnumeric/v2");
if (gmr == NULL)
gmr = xmlSearchNsByHref (res, res->root, "http://www.gnome.org/gnumeric/");
if (strcmp (res->root->name, "Workbook") || (gmr == NULL)) {
xmlFreeDoc (res);
gnumeric_io_error_read (context,
_("Is not an Workbook file"));
gmr = xml_check_version (doc, &version);
if (!gmr) {
xmlFreeDoc (doc);
gnumeric_io_error_read (context, _("Does not contain a Workbook file"));
goto storage_err;
}
ctxt = xml_parse_ctx_new_full (res, gmr, gnumeric_bonobo_obj_read, NULL,
storage);
ctxt = xml_parse_ctx_new_full (
doc, gmr, version,
gnumeric_bonobo_obj_read,
NULL, storage);
xml_workbook_read (context, wb_view, ctxt, res->root);
xml_workbook_read (context, wb_view, ctxt, doc->root);
workbook_set_saveinfo (wb_view_workbook (wb_view),
(char *) filename, FILE_FL_AUTO,
gnumeric_bonobo_write_workbook);
xml_parse_ctx_destroy (ctxt);
xmlFreeDoc (res);
xmlFreeDoc (doc);
bonobo_object_unref (BONOBO_OBJECT (storage));
CORBA_exception_free (&ev);
return 0;
......@@ -503,11 +506,15 @@ gnumeric_bonobo_io_probe (const char *filename)
{
char *p;
if ((p = strrchr (filename, '.')) &&
!g_strncasecmp (p + 1, "efs", 3))
if (((p = strrchr (filename, '.')) &&
!g_strncasecmp (p + 1, "efs", 3)) ||
filename [strlen (filename) - 1] == '/') {
/* g_warning ("I like '%s'", filename);*/
return TRUE;
else
} else {
/* g_warning ("I don't like '%s'", filename);*/
return FALSE;
}
}
void
......@@ -517,6 +524,6 @@ gnumeric_bonobo_io_init (void)
file_format_register_open (100, desc, gnumeric_bonobo_io_probe,
gnumeric_bonobo_read_workbook);
file_format_register_save ("", desc, FILE_FL_AUTO,
file_format_register_save (".efs", desc, FILE_FL_AUTO,
gnumeric_bonobo_write_workbook);
}
......@@ -103,8 +103,10 @@ apply_paste_oper_to_values (Cell const *old_cell, Cell const *copied_cell,
op = OPER_MULT;
else if (paste_flags & PASTE_OPER_DIV)
op = OPER_DIV;
else
else {
op = OPER_ADD;
g_assert_not_reached ();
}
*((Operation *)&(arg_a.constant.oper)) = OPER_CONSTANT;
arg_a.constant.value = old_cell->value;
......
......@@ -36,13 +36,6 @@
* A parsing context.
* FIXME : Structure copied from xml-io.c, not very nice.
*/
typedef enum
{
GNUM_XML_V1,
GNUM_XML_V2,
GNUM_XML_V3, /* >= 0.52 */
GNUM_XML_V4, /* >= 0.57 */
} GnumericXMLVersion;
struct _XmlParseContext {
xmlDocPtr doc; /* Xml document */
......
......@@ -43,14 +43,6 @@
/*
* A parsing context.
*/
typedef enum
{
GNUM_XML_V1,
GNUM_XML_V2,
GNUM_XML_V3, /* >= 0.52 */
GNUM_XML_V4, /* >= 0.57 */
GNUM_XML_V5, /* >= 0.58 */
} GnumericXMLVersion;
struct _XmlParseContext {
xmlDocPtr doc; /* Xml document */
......@@ -73,12 +65,14 @@ struct _XmlParseContext {
XmlParseContext *
xml_parse_ctx_new_full (xmlDocPtr doc,
xmlNsPtr ns,
GnumericXMLVersion version,
XmlSheetObjectReadFn read_fn,
XmlSheetObjectWriteFn write_fn,
gpointer user_data)
{
XmlParseContext *ctxt = g_new0 (XmlParseContext, 1);
ctxt->version = version;
ctxt->doc = doc;
ctxt->ns = ns;
ctxt->expr_map = g_hash_table_new (g_direct_hash, g_direct_equal);
......@@ -94,7 +88,8 @@ XmlParseContext *
xml_parse_ctx_new (xmlDocPtr doc,
xmlNsPtr ns)
{
return xml_parse_ctx_new_full (doc, ns, NULL, NULL, NULL);
return xml_parse_ctx_new_full (
doc, ns, GNUM_XML_V5, NULL, NULL, NULL);
}
void
......@@ -3277,7 +3272,7 @@ static const struct {
{ NULL }
};
static xmlNsPtr
xmlNsPtr
xml_check_version (xmlDocPtr doc, GnumericXMLVersion *version)
{
xmlNsPtr gmr;
......
......@@ -13,6 +13,15 @@
#include "sheet-object.h"
#include "gnome-xml/tree.h"
typedef enum
{
GNUM_XML_V1,
GNUM_XML_V2,
GNUM_XML_V3, /* >= 0.52 */
GNUM_XML_V4, /* >= 0.57 */
GNUM_XML_V5, /* >= 0.58 */
} GnumericXMLVersion;
typedef struct _XmlParseContext XmlParseContext;
typedef gboolean (*XmlSheetObjectWriteFn) (xmlNodePtr cur,
......@@ -37,17 +46,21 @@ XmlParseContext *xml_parse_ctx_new (xmlDocPtr doc,
xmlNsPtr ns);
XmlParseContext *xml_parse_ctx_new_full (xmlDocPtr doc,
xmlNsPtr ns,
GnumericXMLVersion version,
XmlSheetObjectReadFn read_fn,
XmlSheetObjectWriteFn write_fn,
gpointer user_data);
void xml_parse_ctx_destroy (XmlParseContext *ctxt);
xmlNodePtr xml_workbook_write (XmlParseContext *ctx,
WorkbookView *wb_view);
gboolean xml_workbook_read (IOContext *context,
WorkbookView *new_wb,
XmlParseContext *ctx,
xmlNodePtr tree);
xmlNodePtr xml_workbook_write (XmlParseContext *ctx,
WorkbookView *wb_view);
gboolean xml_workbook_read (IOContext *context,
WorkbookView *new_wb,
XmlParseContext *ctx,
xmlNodePtr tree);
xmlNsPtr xml_check_version (xmlDocPtr doc,
GnumericXMLVersion *version);
int gnumeric_xml_write_selection_clipboard (WorkbookControl *context, Sheet *sheet,
xmlChar **buffer, int *size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment