Commit 4278ed64 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

move the tabulate and random numbers into Edit -> Fill ditto.

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

	* src/GNOME_Gnumeric.xml : move the tabulate and random numbers into
	  Edit -> Fill
	* src/workbook-control-gui.c : ditto.

	* src/xml-io.c (xml_read_cell_copy) : handle content with and without
	  the 'Content' node.
	(xml_read_cell) : do the version checks before the strcmps.

	* gnumeric.xsd : Add MergedRegions, do not require the Cell's Content node.
parent 9056f7b5
2002-01-19 Jody Goldberg <jody@gnome.org>
* src/GNOME_Gnumeric.xml : move the tabulate and random numbers into
Edit -> Fill
* src/workbook-control-gui.c : ditto.
* src/xml-io.c (xml_read_cell_copy) : handle content with and without
the 'Content' node.
(xml_read_cell) : do the version checks before the strcmps.
* gnumeric.xsd : Add MergedRegions, do not require the Cell's Content node.
2002-01-19 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/workbook-control-gui.c : new cb_tool_... functions, add
......
2002-01-19 Jody Goldberg <jody@gnome.org>
* src/GNOME_Gnumeric.xml : move the tabulate and random numbers into
Edit -> Fill
* src/workbook-control-gui.c : ditto.
* src/xml-io.c (xml_read_cell_copy) : handle content with and without
the 'Content' node.
(xml_read_cell) : do the version checks before the strcmps.
* gnumeric.xsd : Add MergedRegions, do not require the Cell's Content node.
2002-01-19 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/workbook-control-gui.c : new cb_tool_... functions, add
......
2002-01-19 Jody Goldberg <jody@gnome.org>
* src/GNOME_Gnumeric.xml : move the tabulate and random numbers into
Edit -> Fill
* src/workbook-control-gui.c : ditto.
* src/xml-io.c (xml_read_cell_copy) : handle content with and without
the 'Content' node.
(xml_read_cell) : do the version checks before the strcmps.
* gnumeric.xsd : Add MergedRegions, do not require the Cell's Content node.
2002-01-19 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/workbook-control-gui.c : new cb_tool_... functions, add
......
2002-01-19 Jody Goldberg <jody@gnome.org>
* src/GNOME_Gnumeric.xml : move the tabulate and random numbers into
Edit -> Fill
* src/workbook-control-gui.c : ditto.
* src/xml-io.c (xml_read_cell_copy) : handle content with and without
the 'Content' node.
(xml_read_cell) : do the version checks before the strcmps.
* gnumeric.xsd : Add MergedRegions, do not require the Cell's Content node.
2002-01-19 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/workbook-control-gui.c : new cb_tool_... functions, add
......
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:gmr="http://www.gnumeric.org/v9.dtd"
targetNamespace="http://www.gnumeric.org/v9.dtd"
xmlns:gmr="http://www.gnumeric.org/v10.dtd"
targetNamespace="http://www.gnumeric.org/v10.dtd"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:annotation>
<xsd:documentation xml:lang="en">
Schema for gnumeric spreadsheet documents
Assumes v.71 of gnumeric
Assumes Gnumeric 1.0.3
Based on gnumeric source code and sample gnumeric documents
Author: Marc Johnson (marc_johnson27591@hotmail.com)
</xsd:documentation>
......@@ -43,7 +43,7 @@
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<!-- version number should be v8 - - &gt;
<!-- version number should be v10 - - &gt;
<xsd:attribute name="gmr" type="gmr:namespace" use="required"/> -->
</xsd:complexType>
<!--
......@@ -166,6 +166,7 @@
<xsd:element name="Selections" type="gmr:Selections"/>
<xsd:element name="Objects" type="gmr:Objects" minOccurs="0" maxOccurs="1"/>
<xsd:element name="Cells" type="gmr:Cells"/>
<xsd:element name="MergedRegions" type="gmr:MergedRegions"/>
<xsd:element name="Solver" type="gmr:Solver"/>
</xsd:sequence>
<!-- note: xsd:boolean values can be true, false, 1, 0;
......@@ -510,15 +511,15 @@
<!-- size in points -->
<xsd:attribute name="Unit" type="xsd:double" use="required"/>
<!-- top/left margin, in points -->
<xsd:attribute name="MarginA" type="gmr:col_row_margin" use="required"/>
<xsd:attribute name="MarginA" type="gmr:col_row_margin" use="required"/>
<!-- bottom/right margin, in points -->
<xsd:attribute name="MarginB" type="gmr:col_row_margin" use="required"/>
<xsd:attribute name="MarginB" type="gmr:col_row_margin" use="required"/>
<!-- true if size is explicitly set -->
<xsd:attribute name="HardSize" type="xsd:boolean" use="optional" default="0"/>
<xsd:attribute name="Hidden" type="xsd:boolean" use="optional" default="0"/>
<xsd:attribute name="Collapsed" type="xsd:boolean" use="optional" default="0"/>
<xsd:attribute name="OutlineLevel" type="xsd:integer" use="optional" default="0"/>
<!-- rle count ... whatever THAT means -->
<!-- The number of consequitive identically sized cols/rows -->
<xsd:attribute name="Count" type="xsd:integer" use="optional" default="1"/>
</xsd:complexType>
......@@ -674,16 +675,13 @@
<xsd:complexType name="Cells">
<xsd:sequence>
<xsd:element name="Cell" minOccurs="0" maxOccurs="unbounded">
<xsd:element name="Cell" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<!-- expressions are stored as entered, with a leading '='.
However, if the expression is a shared expression, it
does NOT get a leading '='. Once a shared expression has
been defined, subsequent Cell elements using that same
shared expression simply use the "ExprID" attribute to
indicate which shared expression is used, and no Content
element is included
Once a shared expression has been defined, subsequent
Cell elements using that same shared expression simply
use the "ExprID" attribute to indicate which shared
expression is used, and no Content element is included
-->
<xsd:element name="Content" type="xsd:string" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
......@@ -721,6 +719,12 @@
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="MergedRegions">
<xsd:sequence>
<xsd:element name="Merge" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Solver">
<xsd:sequence>
<xsd:element name="Constr" minOccurs="0" maxOccurs="unbounded">
......@@ -731,7 +735,7 @@
<xsd:attribute name="Rrow" type="xsd:nonNegativeInteger" use="required"/>
<xsd:attribute name="Cols" type="xsd:positiveInteger" use="required"/>
<xsd:attribute name="Rows" type="xsd:positiveInteger" use="required"/>
<xsd:attribute name="Type" type="gmr:constraint_type" use="required"/>
<xsd:attribute name="Type" type="gmr:constraint_type" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
......
......@@ -254,8 +254,15 @@
<menuitem name="EditFillAutofill" verb=""
_label="Auto_fill"
_top="Automatically fill the current selection"/>
<menuitem name="ToolsTabulate" verb=""
_label="_Tabulate Dependency..."
_tip="Make a table of a cell's value as a function of other cells"/>
<menuitem name="RandomGenerator" verb=""
_label="_Random Generator..."
_tip="Generate random numbers of a selection of distributions"/>
</submenu>
<menuitem name="EditSearch" verb=""
_label="Search..."
......@@ -292,14 +299,14 @@
_tip="Create a new unshared view of the workbook"/>
<separator/>
<menuitem name="ViewZoom" verb=""
_label="_Zoom..."
_tip="Zoom the spreadsheet in or out"/>
<menuitem name="ViewFreezeThawPanes" verb=""/>
<separator/>
<menuitem name="ViewToolbars" verb="BonoboCustomize"
_label="_Toolbars..."
_tip="Configure toolbars"/>
......@@ -475,10 +482,6 @@
_label="_Goal Seek..."
_tip="Iteratively recalculate to find a target value"/>
<menuitem name="ToolsTabulate" verb=""
_label="_Tabulate Dependency..."
_tip="Make a table of a cell's value as a function of other cells"/>
<menuitem name="ToolsSolver" verb=""
_label="_Solver..."
_tip="Iteratively recalculate with constraints to approach a target value"/>
......@@ -546,10 +549,6 @@
_tip="Comparing two population variances"/>
</submenu>
<menuitem name="RandomGenerator" verb=""
_label="_Random Generator..."
_tip="Generate random numbers of a selection of distributions"/>
</submenu>
<submenu name="Data" _label="_Data">
......
......@@ -489,50 +489,6 @@ sheet_selection_reset (Sheet *sheet)
sheet_menu_state_enable_insert (sheet, TRUE, TRUE);
}
static void
reference_append (GString *result_str, CellPos const *pos)
{
g_string_append_c (result_str, '$');
g_string_append (result_str, col_name (pos->col));
g_string_append_c (result_str, '$');
g_string_append (result_str, row_name (pos->row));
}
char *
sheet_selection_to_string (Sheet *sheet, gboolean include_sheet_name_prefix)
{
GString *result_str;
GList *selections;
char *result;
g_return_val_if_fail (IS_SHEET (sheet), NULL);
g_return_val_if_fail (sheet->selections, NULL);
result_str = g_string_new ("");
for (selections = sheet->selections; selections; selections = selections->next){
Range *ss = selections->data;
if (*result_str->str)
g_string_append_c (result_str, ',');
if (include_sheet_name_prefix){
g_string_append (result_str, sheet->name_quoted);
g_string_append_c (result_str, '!');
}
reference_append (result_str, &ss->start);
if ((ss->start.col != ss->end.col) ||
(ss->start.row != ss->end.row)){
g_string_append_c (result_str, ':');
reference_append (result_str, &ss->end);
}
}
result = result_str->str;
g_string_free (result_str, FALSE);
return result;
}
gboolean
sheet_selection_copy (WorkbookControl *wbc, Sheet *sheet)
{
......
......@@ -21,7 +21,6 @@ void sheet_selection_add_range (Sheet *sheet,
void sheet_selection_reset (Sheet *sheet);
void sheet_selection_free (Sheet *sheet);
char *sheet_selection_to_string (Sheet *sheet, gboolean include_sheet_name_prefix);
/* Cut/Copy/Paste on the workbook selection */
gboolean sheet_selection_copy (WorkbookControl *context, Sheet *sheet);
......
......@@ -2681,10 +2681,15 @@ static GnomeUIInfo workbook_menu_edit_select [] = {
};
static GnomeUIInfo workbook_menu_edit_fill [] = {
{ GNOME_APP_UI_ITEM, N_("Auto_fill"),
N_("Automatically fill the current selection"),
cb_edit_fill_autofill, NULL,
NULL, 0, 0, 0, 0 },
GNOMEUIINFO_ITEM_NONE (N_("Auto_fill"),
N_("Automatically fill the current selection"),
cb_edit_fill_autofill),
GNOMEUIINFO_ITEM_NONE (N_("_Tabulate Dependency..."),
N_("Make a table of a cell's value as a function of other cells"),
cb_tools_tabulate),
GNOMEUIINFO_ITEM_NONE (N_("_Random Generator..."),
N_("Generate random numbers of a selection of distributions"),
cb_tools_random_generator),
GNOMEUIINFO_END
};
......@@ -3073,9 +3078,7 @@ static GnomeUIInfo workbook_menu_tools [] = {
GNOMEUIINFO_ITEM_NONE (N_("_Goal Seek..."),
N_("Iteratively recalculate to find a target value"),
cb_tools_goal_seek),
GNOMEUIINFO_ITEM_NONE (N_("_Tabulate Dependency..."),
N_("Make a table of a cell's value as a function of other cells"),
cb_tools_tabulate),
GNOMEUIINFO_ITEM_NONE (N_("_Solver..."),
N_("Iteratively recalculate with constraints to approach a target value"),
cb_tools_solver),
......@@ -3084,10 +3087,6 @@ static GnomeUIInfo workbook_menu_tools [] = {
GNOMEUIINFO_SUBTREE(N_("Statistical Anal_ysis"), workbook_menu_tools_analysis),
GNOMEUIINFO_ITEM_NONE (N_("_Random Generator..."),
N_("Generate random numbers of a selection of distributions"),
cb_tools_random_generator),
GNOMEUIINFO_END
};
......
......@@ -14,9 +14,10 @@ typedef enum
GNUM_XML_V7, /* >= 0.66 */
GNUM_XML_V8, /* >= 0.71 */
GNUM_XML_V9, /* >= 0.73 add print scaling */
GNUM_XML_V10, /* >= 1.03 remove useless Content node in cells */
/* NOTE : Keep this up to date (and in sync with the schema) */
GNUM_XML_LATEST = GNUM_XML_V9
GNUM_XML_LATEST = GNUM_XML_V10
} GnumericXMLVersion;
#endif /* GNUMERIC_XML_IO_VERSION_H */
......@@ -1637,20 +1637,20 @@ xml_write_colrow_info (ColRowInfo *info, void *user_data)
static xmlNodePtr
xml_write_cell_and_position (XmlParseContext *ctxt, Cell const *cell, ParsePos const *pp)
{
xmlNodePtr cur, child = NULL;
xmlNodePtr cellNode;
xmlChar *text, *tstr;
ExprArray const *ar;
gboolean write_contents = TRUE;
gboolean const is_shared_expr =
(cell_has_expr (cell) && expr_tree_is_shared (cell->base.expression));
cur = xmlNewDocNode (ctxt->doc, ctxt->ns, (xmlChar *)"Cell", NULL);
xml_node_set_int (cur, "Col", pp->eval.col);
xml_node_set_int (cur, "Row", pp->eval.row);
cellNode = xmlNewDocNode (ctxt->doc, ctxt->ns, (xmlChar *)"Cell", NULL);
xml_node_set_int (cellNode, "Col", pp->eval.col);
xml_node_set_int (cellNode, "Row", pp->eval.row);
/* Only the top left corner of an array needs to be saved (>= 0.53) */
if (NULL != (ar = cell_is_array (cell)) && (ar->y != 0 || ar->x != 0))
return cur;
return cellNode;
/* As of version 0.53 we save the ID of shared expressions */
if (is_shared_expr) {
......@@ -1663,7 +1663,7 @@ xml_write_cell_and_position (XmlParseContext *ctxt, Cell const *cell, ParsePos c
} else if (ar == NULL)
write_contents = FALSE;
xml_node_set_int (cur, "ExprID", GPOINTER_TO_INT (id));
xml_node_set_int (cellNode, "ExprID", GPOINTER_TO_INT (id));
}
if (write_contents) {
......@@ -1678,18 +1678,17 @@ xml_write_cell_and_position (XmlParseContext *ctxt, Cell const *cell, ParsePos c
tstr = xmlEncodeEntitiesReentrant (ctxt->doc, text);
/* FIXME : Remove this useless node. set the content directly */
child = xmlNewChild (cur, ctxt->ns, (xmlChar *)"Content", tstr);
xmlNodeSetContent (cellNode, (xmlChar *)tstr);
if (tstr)
xmlFree (tstr);
g_free (text);
if (!cell_has_expr (cell)) {
xml_node_set_int (cur, "ValueType",
xml_node_set_int (cellNode, "ValueType",
cell->value->type);
if (cell->format) {
char *fmt = style_format_as_XL (cell->format, FALSE);
xmlSetProp (cur, (xmlChar *)"ValueFormat", (xmlChar *)fmt);
xmlSetProp (cellNode, (xmlChar *)"ValueFormat", (xmlChar *)fmt);
g_free (fmt);
}
}
......@@ -1698,11 +1697,11 @@ xml_write_cell_and_position (XmlParseContext *ctxt, Cell const *cell, ParsePos c
/* As of version 0.53 we save the size of the array as attributes */
/* As of version 0.57 the attributes are in the Cell not the Content */
if (ar != NULL) {
xml_node_set_int (cur, "Rows", ar->rows);
xml_node_set_int (cur, "Cols", ar->cols);
xml_node_set_int (cellNode, "Rows", ar->rows);
xml_node_set_int (cellNode, "Cols", ar->cols);
}
return cur;
return cellNode;
}
/*
......@@ -1869,41 +1868,44 @@ xml_read_cell (XmlParseContext *ctxt, xmlNodePtr tree)
}
}
for (child = tree->xmlChildrenNode; child != NULL ; child = child->next) {
/*
* This style code is a gross anachronism that slugs performance
* in the common case this data won't exist. In the long term all
* files will make the 0.41 - 0.42 transition and this can go.
* This is even older backwards compatibility than 0.41 - 0.42
*/
if (!strcmp (child->name, "Style")) {
if (!style_read) {
MStyle *mstyle;
mstyle = xml_read_style (ctxt, child);
if (ctxt->version < GNUM_XML_V10)
for (child = tree->xmlChildrenNode; child != NULL ; child = child->next) {
/*
* This style code is a gross anachronism that slugs performance
* in the common case this data won't exist. In the long term all
* files will make the 0.41 - 0.42 transition and this can go.
* This is even older backwards compatibility than 0.41 - 0.42
*/
if (!style_read && !strcmp (child->name, "Style")) {
MStyle *mstyle = xml_read_style (ctxt, child);
if (mstyle)
sheet_style_set_pos (ctxt->sheet, col, row,
mstyle);
}
} else if (!strcmp (child->name, "Content")) {
content = (char *)xmlNodeGetContent (child);
/* Is this a post 0.52 array */
if (ctxt->version == GNUM_XML_V3) {
is_post_52_array =
xml_node_get_int (child, "Rows", &array_rows) &&
xml_node_get_int (child, "Cols", &array_cols);
}
} else if (!strcmp (child->name, "Comment")) {
comment = (char *)xmlNodeGetContent (child);
if (comment) {
cell_set_comment (cell->base.sheet,
&cell->pos, NULL, comment);
xmlFree (comment);
sheet_style_set_pos (ctxt->sheet, col, row, mstyle);
/* This is a pre version 1.0.3 file */
} else if (!strcmp (child->name, "Content")) {
content = (char *)xmlNodeGetContent (child);
/* Is this a post 0.52 array */
if (ctxt->version == GNUM_XML_V3) {
is_post_52_array =
xml_node_get_int (child, "Rows", &array_rows) &&
xml_node_get_int (child, "Cols", &array_cols);
}
} else if (!strcmp (child->name, "Comment")) {
comment = (char *)xmlNodeGetContent (child);
if (comment) {
cell_set_comment (cell->base.sheet,
&cell->pos, NULL, comment);
xmlFree (comment);
}
}
}
}
}
/* As of 1.0.3 we are back to storing the cell content directly as the content in cell
* rather than creating piles and piles of useless nodes.
*/
if (content == NULL) {
content = (char *)xmlNodeGetContent (tree);
/* Early versions had newlines at the end of their content */
if (ctxt->version <= GNUM_XML_V1) {
char *tmp = strchr (content, '\n');
......@@ -2697,7 +2699,7 @@ xml_read_cell_copy (XmlParseContext *ctxt, xmlNodePtr tree,
}
child = e_xml_get_child_by_name (tree, (xmlChar *)"Content");
content = xmlNodeGetContent (child);
content = xmlNodeGetContent ((child != NULL) ? child : tree);
if (content != NULL) {
if (is_post_52_array) {
ExprTree *expr;
......@@ -2930,6 +2932,8 @@ static const struct {
char const * const id;
GnumericXMLVersion const version;
} GnumericVersions [] = {
{ "http://www.gnumeric.org/v10.dtd", GNUM_XML_V10 }, /* 1.0.3 */
{ "http://www.gnumeric.org/v9.dtd", GNUM_XML_V9 }, /* 0.73 */
{ "http://www.gnumeric.org/v8.dtd", GNUM_XML_V8 }, /* 0.71 */
{ "http://www.gnome.org/gnumeric/v7", GNUM_XML_V7 }, /* 0.66 */
{ "http://www.gnome.org/gnumeric/v6", GNUM_XML_V6 }, /* 0.62 */
......
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