Commit 8179f517 authored by Michael Meeks's avatar Michael Meeks

Fixed save-as dialog to keep track of the current format.

Fixed writing of gnumeric and excel sheets to preserve sheet order.
parent fd4f134a
......@@ -20,6 +20,8 @@ Miguel
Michael
* Re-wrote the OLE block layer again...
* Tentative alpha Excel sheet writing ( --debug=1 )
* Fix writing code to preserve sheet order.
Nick Lamb
* Lots of work adding excel function mappings.
......
1999-05-26 Michael Meeks <michael@imaginator.com>
* src/file.c (file_saver_is_default_format): Fixed bug causing
incorrect format to be displayed.
(fill_save_menu): Wait until we have populated the option menu
before setting the current item.
(make_format_chooser): Move some code into file_save_menu.
* src/xml-io.c (writeXmlSheetTo): Removed,
(writeXmlWorkbook): Use the order workbook_sheets list.
* src/workbook.c (cb_workbook_sheets): Commented out
(workbook_sheets): Get sheets in order from notebook tabs.
1999-05-25 Morten Welinder <terra@diku.dk>
* src/mathfunc.c, src/mathfunc.h: New files, mostly taken from the
......
1999-05-26 Michael Meeks <michael@imaginator.com>
* src/file.c (file_saver_is_default_format): Fixed bug causing
incorrect format to be displayed.
(fill_save_menu): Wait until we have populated the option menu
before setting the current item.
(make_format_chooser): Move some code into file_save_menu.
* src/xml-io.c (writeXmlSheetTo): Removed,
(writeXmlWorkbook): Use the order workbook_sheets list.
* src/workbook.c (cb_workbook_sheets): Commented out
(workbook_sheets): Get sheets in order from notebook tabs.
1999-05-25 Morten Welinder <terra@diku.dk>
* src/mathfunc.c, src/mathfunc.h: New files, mostly taken from the
......
1999-05-26 Michael Meeks <michael@imaginator.com>
* src/file.c (file_saver_is_default_format): Fixed bug causing
incorrect format to be displayed.
(fill_save_menu): Wait until we have populated the option menu
before setting the current item.
(make_format_chooser): Move some code into file_save_menu.
* src/xml-io.c (writeXmlSheetTo): Removed,
(writeXmlWorkbook): Use the order workbook_sheets list.
* src/workbook.c (cb_workbook_sheets): Commented out
(workbook_sheets): Get sheets in order from notebook tabs.
1999-05-25 Morten Welinder <terra@diku.dk>
* src/mathfunc.c, src/mathfunc.h: New files, mostly taken from the
......
1999-05-26 Michael Meeks <michael@imaginator.com>
* src/file.c (file_saver_is_default_format): Fixed bug causing
incorrect format to be displayed.
(fill_save_menu): Wait until we have populated the option menu
before setting the current item.
(make_format_chooser): Move some code into file_save_menu.
* src/xml-io.c (writeXmlSheetTo): Removed,
(writeXmlWorkbook): Use the order workbook_sheets list.
* src/workbook.c (cb_workbook_sheets): Commented out
(workbook_sheets): Get sheets in order from notebook tabs.
1999-05-25 Morten Welinder <terra@diku.dk>
* src/mathfunc.c, src/mathfunc.h: New files, mostly taken from the
......
......@@ -343,11 +343,9 @@ write_sheet (BIFF_PUT *bp, SHEET *sheet)
}
static void
new_sheet (gpointer key, gpointer val, gpointer iwb)
new_sheet (WORKBOOK *wb, Sheet *value)
{
SHEET *sheet = g_new (SHEET, 1);
Sheet *value = (Sheet *)val;
WORKBOOK *wb = (WORKBOOK *)iwb;
g_return_if_fail (value);
g_return_if_fail (wb);
......@@ -366,12 +364,18 @@ write_workbook (BIFF_PUT *bp, Workbook *gwb, eBiff_version ver)
WORKBOOK *wb = g_new (WORKBOOK, 1);
SHEET *s = 0;
int lp;
GList *sheets;
wb->ver = ver;
wb->gnum_wb = gwb;
wb->sheets = g_ptr_array_new ();
g_hash_table_foreach (gwb->sheets, new_sheet, wb);
sheets = workbook_sheets (gwb);
while (sheets) {
new_sheet (wb, sheets->data);
sheets = g_list_next (sheets);
}
g_list_free (sheets);
/* Workbook */
biff_bof_write (bp, ver, eBiffTWorkbook);
......
#include <gnome-factory.idl>
#include <GnomeObject.idl>
#include <GnomeObject.idl>
module GNOME {
module Gnumeric {
......
......@@ -187,12 +187,13 @@ file_saver_is_default_format (FileSaver *saver)
{
if (current_saver == saver)
return TRUE;
if (strcmp (saver->extension, ".gnumeric") == 0){
if (current_saver == NULL)
if (current_saver == NULL)
if (strcmp (saver->extension, ".gnumeric") == 0) {
current_saver = saver;
return TRUE;
}
return TRUE;
}
return FALSE;
}
......@@ -200,7 +201,7 @@ static void
fill_save_menu (GtkOptionMenu *omenu, GtkMenu *menu)
{
GList *l;
int i;
int i, selected=-1;
for (i = 0, l = gnumeric_file_savers; l; l = l->next, i++){
GtkWidget *menu_item;
......@@ -212,11 +213,15 @@ fill_save_menu (GtkOptionMenu *omenu, GtkMenu *menu)
gtk_menu_append (menu, menu_item);
if (file_saver_is_default_format (fs))
gtk_option_menu_set_history (omenu, i);
selected = i;
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC(saver_activate), fs);
}
gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), GTK_WIDGET (menu));
if (selected > 0)
gtk_option_menu_set_history (omenu, selected);
}
static GtkWidget *
......@@ -236,8 +241,6 @@ make_format_chooser (void)
gtk_box_pack_start (GTK_BOX (box), omenu, FALSE, TRUE, GNOME_PAD);
gtk_widget_show_all (box);
gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
return box;
}
......@@ -283,7 +286,6 @@ workbook_save_as (Workbook *wb)
gtk_box_pack_start (GTK_BOX (fsel->action_area), format_selector,
FALSE, TRUE, 0);
/* Connect the signals for Ok and Cancel */
gtk_signal_connect (GTK_OBJECT (fsel->ok_button), "clicked",
GTK_SIGNAL_FUNC (set_ok), &accepted);
......@@ -311,7 +313,8 @@ workbook_save_as (Workbook *wb)
current_saver = insure_saver (current_saver);
if (!current_saver)
gnumeric_notice (wb, GNOME_MESSAGE_BOX_ERROR, _("Sorry, there are no file savers loaded, I cannot save"));
gnumeric_notice (wb, GNOME_MESSAGE_BOX_ERROR,
_("Sorry, there are no file savers loaded, I cannot save"));
else {
if (strchr (base, '.') == NULL){
name = g_strconcat (name, current_saver->extension, NULL);
......
......@@ -2253,7 +2253,7 @@ workbook_invalidate_references (Workbook *wb, Sheet *sheet, int col, int row,
}
/* Old code discarded the order
static void
cb_workbook_sheets (gpointer key, gpointer value, gpointer user_data)
{
......@@ -2262,16 +2262,32 @@ cb_workbook_sheets (gpointer key, gpointer value, gpointer user_data)
*l = g_list_prepend (*l, sheet);
}
*/
GList *
workbook_sheets (Workbook *wb)
{
GList *sheets = NULL;
GList *list = NULL;
GtkNotebook *notebook;
int sheets, i;
g_return_val_if_fail (wb != NULL, NULL);
g_hash_table_foreach (wb->sheets, cb_workbook_sheets, &sheets);
return sheets;
g_return_val_if_fail (wb, NULL);
g_return_val_if_fail (wb->notebook, NULL);
notebook = GTK_NOTEBOOK (wb->notebook);
sheets = workbook_sheet_count (wb);
for (i = 0; i < sheets; i++){
Sheet *this_sheet;
GtkWidget *w;
w = gtk_notebook_get_nth_page (notebook, i);
this_sheet = gtk_object_get_data (GTK_OBJECT (w), "sheet");
list = g_list_append (list, this_sheet);
}
return list;
}
typedef struct {
......
......@@ -1490,23 +1490,6 @@ readXmlSheet (parseXmlContextPtr ctxt, xmlNodePtr tree)
return ret;
}
/*
* Create an XML subtree equivalent to the given sheet
* and add it to the parent
*/
static void
writeXmlSheetTo (gpointer key, gpointer value, gpointer data)
{
parseXmlContextPtr ctxt = (parseXmlContextPtr) data;
xmlNodePtr cur, parent;
Sheet *sheet = (Sheet *) value;
parent = ctxt->parent;
cur = writeXmlSheet (ctxt, sheet);
ctxt->parent = parent;
xmlAddChild (parent, cur);
}
/*
* Create an XML subtree of doc equivalent to the given Workbook.
*/
......@@ -1515,6 +1498,7 @@ writeXmlWorkbook (parseXmlContextPtr ctxt, Workbook *wb)
{
xmlNodePtr cur;
xmlNodePtr child;
GList *sheets;
/*
* General informations about the Sheet.
......@@ -1537,8 +1521,20 @@ writeXmlWorkbook (parseXmlContextPtr ctxt, Workbook *wb)
*/
child = xmlNewChild (cur, ctxt->ns, "Sheets", NULL);
ctxt->parent = child;
g_hash_table_foreach (wb->sheets, writeXmlSheetTo, ctxt);
sheets = workbook_sheets (wb);
while (sheets) {
xmlNodePtr cur, parent;
Sheet *sheet = sheets->data;
parent = ctxt->parent;
cur = writeXmlSheet (ctxt, sheet);
ctxt->parent = parent;
xmlAddChild (parent, cur);
sheets = g_list_next (sheets);
}
g_list_free (sheets);
return cur;
}
......
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