Commit ea3662cf authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Write visibility.

2005-06-10  Morten Welinder  <terra@gnome.org>

	* src/xml-sax-write.c (xml_write_sheet): Write visibility.

	* src/xml-sax-read.c (xml_sax_attr_enum): New function.
	(xml_sax_sheet_start): Restore visibility.

	* src/xml-io.c (xml_read_selection_info): Don't crash if we lack a
	view.
	(xml_write_selection_info): Ditto.
	(xml_sheet_read): Restore visibility.
	(xml_sheet_write): Write visibility.
parent 883a9adf
2005-06-10 Morten Welinder <terra@gnome.org>
* src/xml-sax-write.c (xml_write_sheet): Write visibility.
* src/xml-sax-read.c (xml_sax_attr_enum): New function.
(xml_sax_sheet_start): Restore visibility.
* src/xml-io.c (xml_read_selection_info): Don't crash if we lack a
view.
(xml_write_selection_info): Ditto.
(xml_sheet_read): Restore visibility.
(xml_sheet_write): Write visibility.
2005-06-09 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_realize) : init the menu prefs on
......
......@@ -74,6 +74,7 @@ Morten:
* Fix problem with hiding sheets.
* Fix sheet removal undo to also undo changes to names and
cells in other sheets.
* Save and load visibility sheet attribute.
--------------------------------------------------------------------------
Gnumeric 1.5.1
......
2005-06-10 Morten Welinder <terra@gnome.org>
* src/xml-sax-write.c (xml_write_sheet): Write visibility.
* src/xml-sax-read.c (xml_sax_attr_enum): New function.
(xml_sax_sheet_start): Restore visibility.
* src/xml-io.c (xml_read_selection_info): Don't crash if we lack a
view.
(xml_write_selection_info): Ditto.
(xml_sheet_read): Restore visibility.
(xml_sheet_write): Write visibility.
2005-06-09 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_realize) : init the menu prefs on
......
......@@ -337,9 +337,12 @@ xml_read_selection_info (XmlParseContext *ctxt, xmlNodePtr tree)
{
GnmRange r;
GnmCellPos pos;
xmlNodePtr sel, selections;
SheetView *sv = sheet_get_view (ctxt->sheet, ctxt->wb_view);
xmlNodePtr sel, selections = e_xml_get_child_by_name (tree, CC2XML ("Selections"));
if (!sv) return; /* Hidden. */
selections = e_xml_get_child_by_name (tree, CC2XML ("Selections"));
if (selections == NULL)
return;
......@@ -363,6 +366,9 @@ xml_write_selection_info (XmlParseContext *ctxt, Sheet const *sheet,
GList *ptr, *copy;
SheetView *sv = sheet_get_view (sheet, ctxt->wb_view);
if (!sv)
return; /* Hidden, for example. */
tree = xmlNewChild (tree, ctxt->ns,
CC2XML ("Selections"), NULL);
......@@ -1981,6 +1987,7 @@ static void
xml_write_sheet_layout (XmlParseContext *ctxt, xmlNodePtr tree, Sheet const *sheet)
{
SheetView const *sv = sheet_get_view (sheet, ctxt->wb_view);
if (!sv) return; /* Hidden. */
tree = xmlNewChild (tree, ctxt->ns, CC2XML ("SheetLayout"), NULL);
......@@ -2704,6 +2711,7 @@ xml_sheet_write (XmlParseContext *ctxt, Sheet const *sheet)
xml_node_set_bool (sheetNode, "OutlineSymbolsRight", sheet->outline_symbols_right);
if (sheet->text_is_rtl)
xml_node_set_bool (sheetNode, "RTL_Layout", sheet->text_is_rtl);
xml_node_set_enum (sheetNode, "Visibility", GNM_SHEET_VISIBILITY_TYPE, sheet->visibility);
if (sheet->tab_color != NULL)
xml_node_set_color (sheetNode, "TabColor", sheet->tab_color);
......@@ -2991,6 +2999,7 @@ xml_sheet_read (XmlParseContext *ctxt, xmlNodePtr tree)
double zoom_factor;
gboolean tmp;
xmlChar *val;
int tmpi;
if (strcmp (tree->name, "Sheet")){
fprintf (stderr,
......@@ -3034,6 +3043,8 @@ xml_sheet_read (XmlParseContext *ctxt, xmlNodePtr tree)
g_object_set (sheet, "display-outlines-right", tmp, NULL);
if (xml_node_get_bool (tree, "RTL_Layout", &tmp))
g_object_set (sheet, "text-is-rtl", tmp, NULL);
if (xml_node_get_enum (tree, "Visibility", GNM_SHEET_VISIBILITY_TYPE, &tmpi))
g_object_set (sheet, "visibility", tmpi, NULL);
sheet->tab_color = xml_node_get_color (tree, "TabColor");
sheet->tab_text_color = xml_node_get_color (tree, "TabTextColor");
......
......@@ -141,6 +141,37 @@ xml_sax_attr_int (xmlChar const * const *attrs, char const *name, int *res)
return TRUE;
}
static gboolean
xml_sax_attr_enum (xmlChar const * const *attrs,
char const *name,
GType etype,
gint *val)
{
GEnumClass *eclass;
GEnumValue *ev;
int i;
g_return_val_if_fail (attrs != NULL, FALSE);
g_return_val_if_fail (attrs[0] != NULL, FALSE);
g_return_val_if_fail (attrs[1] != NULL, FALSE);
if (strcmp (attrs[0], name))
return FALSE;
eclass = G_ENUM_CLASS (g_type_class_peek (etype));
ev = g_enum_get_value_by_name (eclass, attrs[1]);
if (!ev) ev = g_enum_get_value_by_nick (eclass, attrs[1]);
if (!ev && xml_sax_attr_int (attrs, name, &i))
/* Check that the value is valid. */
ev = g_enum_get_value (eclass, i);
if (!ev) return FALSE;
*val = ev->value;
return TRUE;
}
static gboolean
xml_sax_attr_cellpos (xmlChar const * const *attrs, char const *name, GnmCellPos *val)
{
......@@ -254,6 +285,7 @@ typedef struct {
int outline_symbols_below;
int outline_symbols_right;
int text_is_rtl;
GnmSheetVisibility visibility;
GnmColor *tab_color;
/* expressions with ref > 1 a map from index -> expr pointer */
......@@ -413,12 +445,14 @@ xml_sax_sheet_start (GsfXMLIn *gsf_state, xmlChar const **attrs)
XMLSaxParseState *state = (XMLSaxParseState *)gsf_state;
gboolean tmp;
gint tmpi;
GnmColor *color = NULL;
state->hide_col_header = state->hide_row_header =
state->display_formulas = state->hide_zero =
state->hide_grid = state->display_outlines =
state->outline_symbols_below = state->outline_symbols_right = state->text_is_rtl = -1;
state->visibility = GNM_SHEET_VISIBILITY_VISIBLE;
state->tab_color = NULL;
state->sheet_zoom = 1.; /* default */
......@@ -439,6 +473,8 @@ xml_sax_sheet_start (GsfXMLIn *gsf_state, xmlChar const **attrs)
state->outline_symbols_below = tmp;
else if (xml_sax_attr_bool (attrs, "OutlineSymbolsRight", &tmp))
state->outline_symbols_right = tmp;
else if (xml_sax_attr_enum (attrs, "Visibility", GNM_SHEET_VISIBILITY_TYPE, &tmpi))
state->visibility = tmpi;
else if (xml_sax_attr_bool (attrs, "RTL_Layout", &tmp))
state->text_is_rtl = tmp;
else if (xml_sax_attr_color (attrs, "TabColor", &color))
......@@ -500,6 +536,7 @@ xml_sax_sheet_name (GsfXMLIn *gsf_state, G_GNUC_UNUSED GsfXMLBlob *blob)
g_object_set (state->sheet, "display-outlines-right", state->outline_symbols_right, NULL);
if (state->text_is_rtl >= 0)
g_object_set (state->sheet, "text-is-rtl", state->text_is_rtl, NULL);
g_object_set (state->sheet, "visibility", state->visibility, NULL);
state->sheet->tab_color = state->tab_color;
}
......
......@@ -608,7 +608,8 @@ static void
xml_write_selection_info (GnmOutputXML *state)
{
GList *ptr, *copy;
SheetView *sv = sheet_get_view (state->sheet, state->wb_view);
const SheetView *sv = sheet_get_view (state->sheet, state->wb_view);
if (!sv) return; /* Hidden. */
gsf_xml_out_start_element (state->output, GNM "Selections");
gsf_xml_out_add_int (state->output, "CursorCol", sv->edit_pos_real.col);
......@@ -728,6 +729,7 @@ static void
xml_write_sheet_layout (GnmOutputXML *state)
{
SheetView const *sv = sheet_get_view (state->sheet, state->wb_view);
if (!sv) return; /* Hidden. */
gsf_xml_out_start_element (state->output, GNM "SheetLayout");
gnm_xml_out_add_cellpos (state->output, "TopLeft", &sv->initial_top_left);
......@@ -1019,6 +1021,8 @@ xml_write_sheet (GnmOutputXML *state, Sheet const *sheet)
if (sheet->text_is_rtl)
gsf_xml_out_add_bool (state->output,
"RTL_Layout", sheet->text_is_rtl);
gsf_xml_out_add_enum (state->output,
"Visibility", GNM_SHEET_VISIBILITY_TYPE, sheet->visibility);
if (sheet->tab_color != NULL)
gnm_xml_out_add_color (state->output, "TabColor", sheet->tab_color);
......
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