Commit 30415942 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

rename from xml_sax_color for consistency. (xml_sax_attr_range) : ditto.

2002-01-14  Jody Goldberg <jody@gnome.org>

	* xml-sax-read.c (xml_sax_attr_color) : rename from xml_sax_color for
	  consistency.
	(xml_sax_attr_range) : ditto.
	(xml_sax_sheet_start) : read the optional tab colour.
	(xml_sax_sheet_name) : assign the tab colour.

	* src/commands.c (cmd_set_text) : Be smarter about the undo label
	  generated for text with embedded new lines or leading white space.

	* gnumeric.xsd : Add the tab color.

	* src/xml-io.c (xml_sheet_read) : read tab optional tab colours.
	(xml_sheet_write) : write the tab colour if it is set.
parent 99b0121d
2002-01-14 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_set_text) : Be smarter about the undo label
generated for text with embedded new lines or leading white space.
* gnumeric.xsd : Add the tab color.
* src/xml-io.c (xml_sheet_read) : read tab optional tab colours.
(xml_sheet_write) : write the tab colour if it is set.
2002-01-14 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/datetime.c (coupdays) : moved from src/functions/fn-financial.c
......
2002-01-14 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_set_text) : Be smarter about the undo label
generated for text with embedded new lines or leading white space.
* gnumeric.xsd : Add the tab color.
* src/xml-io.c (xml_sheet_read) : read tab optional tab colours.
(xml_sheet_write) : write the tab colour if it is set.
2002-01-14 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/datetime.c (coupdays) : moved from src/functions/fn-financial.c
......
2002-01-14 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_set_text) : Be smarter about the undo label
generated for text with embedded new lines or leading white space.
* gnumeric.xsd : Add the tab color.
* src/xml-io.c (xml_sheet_read) : read tab optional tab colours.
(xml_sheet_write) : write the tab colour if it is set.
2002-01-14 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/datetime.c (coupdays) : moved from src/functions/fn-financial.c
......
2002-01-14 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_set_text) : Be smarter about the undo label
generated for text with embedded new lines or leading white space.
* gnumeric.xsd : Add the tab color.
* src/xml-io.c (xml_sheet_read) : read tab optional tab colours.
(xml_sheet_write) : write the tab colour if it is set.
2002-01-14 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/datetime.c (coupdays) : moved from src/functions/fn-financial.c
......
......@@ -180,6 +180,7 @@
<xsd:attribute name="DisplayOutlines" type="xsd:boolean" use="required"/>
<xsd:attribute name="OutlineSymbolsBelow" type="xsd:boolean" use="required"/>
<xsd:attribute name="OutlineSymbolsRight" type="xsd:boolean" use="required"/>
<xsd:attribute name="TabColor" type="gmr:color" use="optional"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
......
2002-01-14 Jody Goldberg <jody@gnome.org>
* xml-sax-read.c (xml_sax_attr_color) : rename from xml_sax_color for
consistency.
(xml_sax_attr_range) : ditto.
(xml_sax_sheet_start) : read the optional tab colour.
(xml_sax_sheet_name) : assign the tab colour.
2002-01-10 Jody Goldberg <jody@gnome.org>
* xml-sax-read.c (xml_sax_attr_bool) : fix return type
......
......@@ -163,7 +163,7 @@ xml_sax_attr_cellpos (xmlChar const * const *attrs, char const *name, CellPos *v
}
static gboolean
xml_sax_color (xmlChar const * const *attrs, char const *name, StyleColor **res)
xml_sax_attr_color (xmlChar const * const *attrs, char const *name, StyleColor **res)
{
int red, green, blue;
......@@ -184,7 +184,7 @@ xml_sax_color (xmlChar const * const *attrs, char const *name, StyleColor **res)
}
static gboolean
xml_sax_range (xmlChar const * const *attrs, Range *res)
xml_sax_attr_range (xmlChar const * const *attrs, Range *res)
{
int flags = 0;
for (; attrs[0] && attrs[1] ; attrs += 2)
......@@ -478,6 +478,7 @@ typedef struct _XMLSaxParseState
int display_outlines;
int outline_symbols_below;
int outline_symbols_right;
StyleColor *tab_color;
/* expressions with ref > 1 a map from index -> expr pointer */
GHashTable *expr_map;
......@@ -697,11 +698,13 @@ static void
xml_sax_sheet_start (XMLSaxParseState *state, xmlChar const **attrs)
{
gboolean tmp;
StyleColor *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 = -1;
state->tab_color = NULL;
state->sheet_zoom = 1.; /* default */
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
......@@ -721,6 +724,8 @@ xml_sax_sheet_start (XMLSaxParseState *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_color (attrs, "TabColor", &color))
state->tab_color = color;
else
xml_sax_unknown_attr (state, attrs, "Sheet");
}
......@@ -773,6 +778,7 @@ xml_sax_sheet_name (XMLSaxParseState *state)
state->sheet->outline_symbols_below = state->outline_symbols_below;
if (state->outline_symbols_right >= 0)
state->sheet->outline_symbols_right = state->outline_symbols_right;
state->sheet->tab_color = state->tab_color;
}
static void
......@@ -866,7 +872,7 @@ static void
xml_sax_selection_range (XMLSaxParseState *state, xmlChar const **attrs)
{
Range r;
if (xml_sax_range (attrs, &r))
if (xml_sax_attr_range (attrs, &r))
sheet_selection_add_range (state->sheet,
r.start.col, r.start.row,
r.start.col, r.start.row,
......@@ -1017,7 +1023,7 @@ xml_sax_style_region_start (XMLSaxParseState *state, xmlChar const **attrs)
state->style = mstyle_new ();
state->style_range_init =
xml_sax_range (attrs, &state->style_range);
xml_sax_attr_range (attrs, &state->style_range);
}
static void
......@@ -1059,11 +1065,11 @@ xml_sax_styleregion_start (XMLSaxParseState *state, xmlChar const **attrs)
mstyle_set_pattern (state->style, val);
else if (xml_sax_attr_int (attrs, "Indent", &val))
mstyle_set_indent (state->style, val);
else if (xml_sax_color (attrs, "Fore", &colour))
else if (xml_sax_attr_color (attrs, "Fore", &colour))
mstyle_set_color (state->style, MSTYLE_COLOR_FORE, colour);
else if (xml_sax_color (attrs, "Back", &colour))
else if (xml_sax_attr_color (attrs, "Back", &colour))
mstyle_set_color (state->style, MSTYLE_COLOR_BACK, colour);
else if (xml_sax_color (attrs, "PatternColor", &colour))
else if (xml_sax_attr_color (attrs, "PatternColor", &colour))
mstyle_set_color (state->style, MSTYLE_COLOR_PATTERN, colour);
else if (!strcmp (attrs[0], "Format"))
mstyle_set_format_text (state->style, (char *)attrs[1]);
......@@ -1251,7 +1257,7 @@ xml_sax_style_region_borders (XMLSaxParseState *state, xmlChar const **attrs)
/* Colour is optional */
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
if (xml_sax_color (attrs, "Color", &colour)) ;
if (xml_sax_attr_color (attrs, "Color", &colour)) ;
else if (xml_sax_attr_int (attrs, "Style", &pattern)) ;
else
xml_sax_unknown_attr (state, attrs, "StyleBorder");
......
......@@ -59,6 +59,7 @@
#include <libgnome/gnome-i18n.h>
#include <gal/util/e-util.h>
#include <ctype.h>
#define MAX_DESCRIPTOR_WIDTH 15
......@@ -626,7 +627,7 @@ cmd_set_text (WorkbookControl *wbc,
GtkObject *obj;
CmdSetText *me;
gchar *pad = "";
gchar *text, *corrected_text;
gchar *text, *corrected_text, *tmp, c = '\0';
Cell const *cell;
g_return_val_if_fail (IS_SHEET (sheet), TRUE);
......@@ -650,8 +651,20 @@ cmd_set_text (WorkbookControl *wbc,
me->pos.eval = *pos;
me->text = corrected_text;
/* strip leading white space from labels */
while (*corrected_text != '\0' && isspace (*(unsigned char *)corrected_text))
++corrected_text;
/* truncate at newlines */
for (tmp = corrected_text ; *tmp != '\0' ; ++tmp)
if (*tmp == '\r' || *tmp == '\n') {
c = *tmp;
*tmp = '\0';
break;
}
/* Limit the size of the descriptor to something reasonable */
if (strlen (corrected_text) > MAX_DESCRIPTOR_WIDTH) {
if (strlen (corrected_text) > MAX_DESCRIPTOR_WIDTH || c != '\0') {
pad = "..."; /* length of 3 */
text = g_strndup (corrected_text,
MAX_DESCRIPTOR_WIDTH - 3);
......@@ -666,6 +679,8 @@ cmd_set_text (WorkbookControl *wbc,
if (text != corrected_text)
g_free (text);
else if (c != '\0')
*tmp = c;
/* Register the command object */
return command_push_undo (wbc, obj);
......
......@@ -2219,6 +2219,9 @@ xml_sheet_write (XmlParseContext *ctxt, Sheet const *sheet)
e_xml_set_bool_prop_by_name (sheetNode, (xmlChar *)"OutlineSymbolsRight",
sheet->outline_symbols_right);
if (sheet->tab_color != NULL)
xml_node_set_color (sheetNode, "TabColor", sheet->tab_color);
tstr = xmlEncodeEntitiesReentrant (ctxt->doc, (xmlChar *)sheet->name_unquoted);
xmlNewChild (sheetNode, ctxt->ns, (xmlChar *)"Name", tstr);
if (tstr) xmlFree (tstr); {
......@@ -2548,6 +2551,7 @@ xml_sheet_read (XmlParseContext *ctxt, xmlNodePtr tree)
(xmlChar *)"OutlineSymbolsBelow", TRUE);
sheet->outline_symbols_right = e_xml_get_bool_prop_by_name_with_default (tree,
(xmlChar *)"OutlineSymbolsRight", TRUE);
sheet->tab_color = xml_node_get_color (tree, "TabColor");
xml_node_get_double (e_xml_get_child_by_name (tree, (xmlChar *)"Zoom"), NULL,
&zoom_factor);
......
......@@ -163,7 +163,7 @@ xml_sax_attr_cellpos (xmlChar const * const *attrs, char const *name, CellPos *v
}
static gboolean
xml_sax_color (xmlChar const * const *attrs, char const *name, StyleColor **res)
xml_sax_attr_color (xmlChar const * const *attrs, char const *name, StyleColor **res)
{
int red, green, blue;
......@@ -184,7 +184,7 @@ xml_sax_color (xmlChar const * const *attrs, char const *name, StyleColor **res)
}
static gboolean
xml_sax_range (xmlChar const * const *attrs, Range *res)
xml_sax_attr_range (xmlChar const * const *attrs, Range *res)
{
int flags = 0;
for (; attrs[0] && attrs[1] ; attrs += 2)
......@@ -478,6 +478,7 @@ typedef struct _XMLSaxParseState
int display_outlines;
int outline_symbols_below;
int outline_symbols_right;
StyleColor *tab_color;
/* expressions with ref > 1 a map from index -> expr pointer */
GHashTable *expr_map;
......@@ -697,11 +698,13 @@ static void
xml_sax_sheet_start (XMLSaxParseState *state, xmlChar const **attrs)
{
gboolean tmp;
StyleColor *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 = -1;
state->tab_color = NULL;
state->sheet_zoom = 1.; /* default */
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
......@@ -721,6 +724,8 @@ xml_sax_sheet_start (XMLSaxParseState *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_color (attrs, "TabColor", &color))
state->tab_color = color;
else
xml_sax_unknown_attr (state, attrs, "Sheet");
}
......@@ -773,6 +778,7 @@ xml_sax_sheet_name (XMLSaxParseState *state)
state->sheet->outline_symbols_below = state->outline_symbols_below;
if (state->outline_symbols_right >= 0)
state->sheet->outline_symbols_right = state->outline_symbols_right;
state->sheet->tab_color = state->tab_color;
}
static void
......@@ -866,7 +872,7 @@ static void
xml_sax_selection_range (XMLSaxParseState *state, xmlChar const **attrs)
{
Range r;
if (xml_sax_range (attrs, &r))
if (xml_sax_attr_range (attrs, &r))
sheet_selection_add_range (state->sheet,
r.start.col, r.start.row,
r.start.col, r.start.row,
......@@ -1017,7 +1023,7 @@ xml_sax_style_region_start (XMLSaxParseState *state, xmlChar const **attrs)
state->style = mstyle_new ();
state->style_range_init =
xml_sax_range (attrs, &state->style_range);
xml_sax_attr_range (attrs, &state->style_range);
}
static void
......@@ -1059,11 +1065,11 @@ xml_sax_styleregion_start (XMLSaxParseState *state, xmlChar const **attrs)
mstyle_set_pattern (state->style, val);
else if (xml_sax_attr_int (attrs, "Indent", &val))
mstyle_set_indent (state->style, val);
else if (xml_sax_color (attrs, "Fore", &colour))
else if (xml_sax_attr_color (attrs, "Fore", &colour))
mstyle_set_color (state->style, MSTYLE_COLOR_FORE, colour);
else if (xml_sax_color (attrs, "Back", &colour))
else if (xml_sax_attr_color (attrs, "Back", &colour))
mstyle_set_color (state->style, MSTYLE_COLOR_BACK, colour);
else if (xml_sax_color (attrs, "PatternColor", &colour))
else if (xml_sax_attr_color (attrs, "PatternColor", &colour))
mstyle_set_color (state->style, MSTYLE_COLOR_PATTERN, colour);
else if (!strcmp (attrs[0], "Format"))
mstyle_set_format_text (state->style, (char *)attrs[1]);
......@@ -1251,7 +1257,7 @@ xml_sax_style_region_borders (XMLSaxParseState *state, xmlChar const **attrs)
/* Colour is optional */
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
if (xml_sax_color (attrs, "Color", &colour)) ;
if (xml_sax_attr_color (attrs, "Color", &colour)) ;
else if (xml_sax_attr_int (attrs, "Style", &pattern)) ;
else
xml_sax_unknown_attr (state, attrs, "StyleBorder");
......
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