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

silence warning due to kludge.

2006-12-16  Jody Goldberg <jody@gnome.org>

	* ms-excel-read.c (excel_read_COLINFO) : silence warning due to
	  kludge.

2006-12-16  Jody Goldberg <jody@gnome.org>

	Start work on autofilters, only Top10 is implemented for in or out.
	* xlsx-read.c (xlsx_CT_Filters_begin) : new.
	  Massive renaming to use '_begin' rather than '_start' just because I
	  like the sound better.
	* xlsx-write.c (xlsx_write_autofilters) : new.

2006-12-16  Jody Goldberg <jody@gnome.org>

	* src/sheet-filter.h : add GNM_FILTER_OP_BOTTOM_MASK, and
	  GNM_FILTER_OP_PERCENT_MASK.

	* src/xml-sax-read.c (xml_sax_filter_condition) : make bucket count a
	  float.
	* src/xml-sax-write.c (xml_write_filter_field) : ditto.
	* src/xml-io.c (xml_read_filter_field) : ditto.
	* src/sheet-filter.c (gnm_filter_condition_new_bucket) : ditto.
	* gnumeric.xsd : ditto.
parent af763f29
2006-12-16 Jody Goldberg <jody@gnome.org>
* src/sheet-filter.h : add GNM_FILTER_OP_BOTTOM_MASK, and
GNM_FILTER_OP_PERCENT_MASK.
* src/xml-sax-read.c (xml_sax_filter_condition) : make bucket count a
float.
* src/xml-sax-write.c (xml_write_filter_field) : ditto.
* src/xml-io.c (xml_read_filter_field) : ditto.
* src/sheet-filter.c (gnm_filter_condition_new_bucket) : ditto.
* gnumeric.xsd : ditto.
2006-12-16 Jody Goldberg <jody@gnome.org> 2006-12-16 Jody Goldberg <jody@gnome.org>
* src/sheet-object-widget.c : implement combos and lists. * src/sheet-object-widget.c : implement combos and lists.
......
...@@ -5,6 +5,7 @@ Jody: ...@@ -5,6 +5,7 @@ Jody:
* Fix autofilter lists with only 1 combo. [#383400] * Fix autofilter lists with only 1 combo. [#383400]
* Implement sax import of sheet objects. * Implement sax import of sheet objects.
* Implement List and Combo objects. * Implement List and Combo objects.
* XLSX support for import and export of autofilters.
Morten: Morten:
* Fix title problem. [#382643] * Fix title problem. [#382643]
......
...@@ -840,7 +840,7 @@ ...@@ -840,7 +840,7 @@
<!-- Only valid for Type=bucket --> <!-- Only valid for Type=bucket -->
<xsd:attribute name="Top" type="xsd:boolean" use="optional"/> <!-- top vs bottom --> <xsd:attribute name="Top" type="xsd:boolean" use="optional"/> <!-- top vs bottom -->
<xsd:attribute name="Items" type="xsd:boolean" use="optional"/> <!-- top n vs top n% --> <xsd:attribute name="Items" type="xsd:boolean" use="optional"/> <!-- top n vs top n% -->
<xsd:attribute name="Count" type="xsd:integer" use="optional"/> <!-- top COUNT --> <xsd:attribute name="Count" type="xsd:double" use="optional"/> <!-- top COUNT -->
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:sequence> </xsd:sequence>
......
2006-12-16 Jody Goldberg <jody@gnome.org>
* ms-excel-read.c (excel_read_COLINFO) : silence warning due to
kludge.
2006-12-16 Jody Goldberg <jody@gnome.org>
Start work on autofilters, only Top10 is implemented for in or out.
* xlsx-read.c (xlsx_CT_Filters_begin) : new.
Massive renaming to use '_begin' rather than '_start' just because I
like the sound better.
* xlsx-write.c (xlsx_write_autofilters) : new.
2006-12-16 Jody Goldberg <jody@gnome.org> 2006-12-16 Jody Goldberg <jody@gnome.org>
* ms-excel-read.c (ms_sheet_realize_obj) : link in the content * ms-excel-read.c (ms_sheet_realize_obj) : link in the content
......
...@@ -3633,7 +3633,7 @@ excel_read_COLINFO (BiffQuery *q, ExcelReadSheet *esheet) ...@@ -3633,7 +3633,7 @@ excel_read_COLINFO (BiffQuery *q, ExcelReadSheet *esheet)
guint16 const xf = GSF_LE_GET_GUINT16 (q->data + 6); guint16 const xf = GSF_LE_GET_GUINT16 (q->data + 6);
guint16 const options = GSF_LE_GET_GUINT16 (q->data + 8); guint16 const options = GSF_LE_GET_GUINT16 (q->data + 8);
gboolean hidden = (options & 0x0001) != 0; gboolean hidden = (options & 0x0001) != 0;
gboolean const customWidth= (options & 0x0002) != 0; /* undocumented */ /*gboolean const customWidth= (options & 0x0002) != 0; /* undocumented */
gboolean const bestFit = (options & 0x0004) != 0; /* undocumented */ gboolean const bestFit = (options & 0x0004) != 0; /* undocumented */
gboolean const collapsed = (options & 0x1000) != 0; gboolean const collapsed = (options & 0x1000) != 0;
unsigned const outline_level = (unsigned)((options >> 8) & 0x7); unsigned const outline_level = (unsigned)((options >> 8) & 0x7);
......
This diff is collapsed.
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "sheet.h" #include "sheet.h"
#include "sheet-style.h" #include "sheet-style.h"
#include "sheet-view.h" #include "sheet-view.h"
#include "sheet-filter.h"
#include "ranges.h" #include "ranges.h"
#include "value.h" #include "value.h"
#include "cell.h" #include "cell.h"
...@@ -818,6 +819,64 @@ xlsx_write_cols (XLSXWriteState *state, GsfXMLOut *xml, GnmRange const *extent) ...@@ -818,6 +819,64 @@ xlsx_write_cols (XLSXWriteState *state, GsfXMLOut *xml, GnmRange const *extent)
gsf_xml_out_end_element (xml); /* </cols> */ gsf_xml_out_end_element (xml); /* </cols> */
} }
static void
xlsx_write_autofilters (XLSXWriteState *state, GsfXMLOut *xml)
{
GnmFilter const *filter;
GnmFilterCondition const *cond;
unsigned i;
if (NULL == state->sheet->filters)
return;
filter = state->sheet->filters->data;
gsf_xml_out_start_element (xml, "autoFilter");
xlsx_add_range (xml, "ref", &filter->r);
for (i = 0; i < filter->fields->len ; i++) {
/* filter unused or bucket filters in excel5 */
if (NULL == (cond = gnm_filter_get_condition (filter, i)) ||
cond->op[0] == GNM_FILTER_UNUSED)
continue;
gsf_xml_out_start_element (xml, "filterColumn");
gsf_xml_out_add_int (xml, "colId", i);
switch (cond->op[0]) {
case GNM_FILTER_OP_EQUAL :
case GNM_FILTER_OP_GT :
case GNM_FILTER_OP_LT :
case GNM_FILTER_OP_GTE :
case GNM_FILTER_OP_LTE :
case GNM_FILTER_OP_NOT_EQUAL :
break;
case GNM_FILTER_OP_BLANKS :
case GNM_FILTER_OP_NON_BLANKS :
break;
case GNM_FILTER_OP_TOP_N :
case GNM_FILTER_OP_BOTTOM_N :
case GNM_FILTER_OP_TOP_N_PERCENT :
case GNM_FILTER_OP_BOTTOM_N_PERCENT :
gsf_xml_out_start_element (xml, "top10");
gsf_xml_out_add_float (xml, "val", cond->count, -1);
if (cond->op[0] & GNM_FILTER_OP_BOTTOM_MASK)
gsf_xml_out_add_cstr_unchecked (xml, "top", "0");
if (cond->op[0] & GNM_FILTER_OP_PERCENT_MASK)
gsf_xml_out_add_cstr_unchecked (xml, "percent", "1");
gsf_xml_out_end_element (xml); /* </top10> */
break;
default :
continue;
}
gsf_xml_out_end_element (xml); /* </filterColumn> */
}
gsf_xml_out_end_element (xml); /* </autoFilter> */
}
static void static void
xlsx_write_print_info (XLSXWriteState *state, GsfXMLOut *xml) xlsx_write_print_info (XLSXWriteState *state, GsfXMLOut *xml)
{ {
...@@ -917,6 +976,7 @@ xlsx_write_sheet (XLSXWriteState *state, GsfOutfile *dir, GsfOutfile *wb_part, u ...@@ -917,6 +976,7 @@ xlsx_write_sheet (XLSXWriteState *state, GsfOutfile *dir, GsfOutfile *wb_part, u
gsf_xml_out_end_element (xml); /* </mergeCells> */ gsf_xml_out_end_element (xml); /* </mergeCells> */
} }
xlsx_write_autofilters (state, xml);
xlsx_write_print_info (state, xml); xlsx_write_print_info (state, xml);
gsf_xml_out_end_element (xml); /* </worksheet> */ gsf_xml_out_end_element (xml); /* </worksheet> */
...@@ -1038,6 +1098,5 @@ xlsx_file_save (GOFileSaver const *fs, IOContext *io_context, ...@@ -1038,6 +1098,5 @@ xlsx_file_save (GOFileSaver const *fs, IOContext *io_context,
* rich text * rich text
* shared expressions * shared expressions
* external refs * external refs
* autofilters
* ... * ...
* */ * */
...@@ -65,7 +65,7 @@ gnm_filter_condition_new_double (GnmFilterOp op0, GnmValue *v0, ...@@ -65,7 +65,7 @@ gnm_filter_condition_new_double (GnmFilterOp op0, GnmValue *v0,
} }
GnmFilterCondition * GnmFilterCondition *
gnm_filter_condition_new_bucket (gboolean top, gboolean absolute, unsigned n) gnm_filter_condition_new_bucket (gboolean top, gboolean absolute, float n)
{ {
GnmFilterCondition *res = g_new0 (GnmFilterCondition, 1); GnmFilterCondition *res = g_new0 (GnmFilterCondition, 1);
res->op[0] = GNM_FILTER_OP_TOP_N | (top ? 0 : 1) | (absolute ? 0 : 2); res->op[0] = GNM_FILTER_OP_TOP_N | (top ? 0 : 1) | (absolute ? 0 : 2);
......
...@@ -20,6 +20,8 @@ typedef enum { ...@@ -20,6 +20,8 @@ typedef enum {
GNM_FILTER_OP_BOTTOM_N = 0x31, GNM_FILTER_OP_BOTTOM_N = 0x31,
GNM_FILTER_OP_TOP_N_PERCENT = 0x32, GNM_FILTER_OP_TOP_N_PERCENT = 0x32,
GNM_FILTER_OP_BOTTOM_N_PERCENT = 0x33, GNM_FILTER_OP_BOTTOM_N_PERCENT = 0x33,
GNM_FILTER_OP_BOTTOM_MASK = 0x01,
GNM_FILTER_OP_PERCENT_MASK = 0x02,
/* Added in 1.7.5 */ /* Added in 1.7.5 */
GNM_FILTER_OP_GT_AVERAGE = 0x40, GNM_FILTER_OP_GT_AVERAGE = 0x40,
...@@ -34,7 +36,7 @@ struct _GnmFilterCondition { ...@@ -34,7 +36,7 @@ struct _GnmFilterCondition {
GnmFilterOp op[2]; GnmFilterOp op[2];
GnmValue *value[2]; GnmValue *value[2];
gboolean is_and; gboolean is_and;
int count; float count;
}; };
struct _GnmFilter { struct _GnmFilter {
...@@ -51,7 +53,7 @@ GnmFilterCondition *gnm_filter_condition_new_double (GnmFilterOp op1, GnmValue * ...@@ -51,7 +53,7 @@ GnmFilterCondition *gnm_filter_condition_new_double (GnmFilterOp op1, GnmValue *
GnmFilterOp op2, GnmValue *v2); GnmFilterOp op2, GnmValue *v2);
GnmFilterCondition *gnm_filter_condition_new_bucket (gboolean top, GnmFilterCondition *gnm_filter_condition_new_bucket (gboolean top,
gboolean absolute, gboolean absolute,
unsigned n); float n);
GnmFilterCondition *gnm_filter_condition_dup (GnmFilterCondition const *src); GnmFilterCondition *gnm_filter_condition_dup (GnmFilterCondition const *src);
void gnm_filter_condition_unref (GnmFilterCondition *cond); void gnm_filter_condition_unref (GnmFilterCondition *cond);
......
...@@ -1421,11 +1421,11 @@ xml_read_filter_field (XmlParseContext *ctxt, xmlNode *field, GnmFilter *filter) ...@@ -1421,11 +1421,11 @@ xml_read_filter_field (XmlParseContext *ctxt, xmlNode *field, GnmFilter *filter)
GNM_FILTER_OP_NON_BLANKS, NULL); GNM_FILTER_OP_NON_BLANKS, NULL);
else if (!g_ascii_strcasecmp (type, "bucket")) { else if (!g_ascii_strcasecmp (type, "bucket")) {
gboolean top, items; gboolean top, items;
int count; double count;
if (xml_node_get_bool (field, CC2XML ("Top"), &top) && if (xml_node_get_bool (field, CC2XML ("Top"), &top) &&
xml_node_get_bool (field, CC2XML ("Items"), &items) && xml_node_get_bool (field, CC2XML ("Items"), &items) &&
xml_node_get_int (field, CC2XML ("Count"), &count)) xml_node_get_double (field, CC2XML ("Count"), &count))
cond = gnm_filter_condition_new_bucket ( cond = gnm_filter_condition_new_bucket (
top, items, count); top, items, count);
} }
......
...@@ -1528,7 +1528,8 @@ xml_sax_filter_condition (GsfXMLIn *xin, xmlChar const **attrs) ...@@ -1528,7 +1528,8 @@ xml_sax_filter_condition (GsfXMLIn *xin, xmlChar const **attrs)
GnmFilterOp op0, op1; GnmFilterOp op0, op1;
GnmFilterCondition *cond = NULL; GnmFilterCondition *cond = NULL;
gboolean top = TRUE, items = TRUE, is_and = FALSE; gboolean top = TRUE, items = TRUE, is_and = FALSE;
int i, tmp, bucket_count = 10, cond_num = 0; int i, tmp, cond_num = 0;
double bucket_count = 10.;
if (NULL == state->filter) return; if (NULL == state->filter) return;
...@@ -1537,7 +1538,7 @@ xml_sax_filter_condition (GsfXMLIn *xin, xmlChar const **attrs) ...@@ -1537,7 +1538,7 @@ xml_sax_filter_condition (GsfXMLIn *xin, xmlChar const **attrs)
else if (gnm_xml_attr_int (attrs+i, "Index", &cond_num)) ; else if (gnm_xml_attr_int (attrs+i, "Index", &cond_num)) ;
else if (xml_sax_attr_bool (attrs, "Top", &top)) ; else if (xml_sax_attr_bool (attrs, "Top", &top)) ;
else if (xml_sax_attr_bool (attrs, "Items", &items)) ; else if (xml_sax_attr_bool (attrs, "Items", &items)) ;
else if (gnm_xml_attr_int (attrs, "Count", &bucket_count)) ; else if (gnm_xml_attr_double (attrs, "Count", &bucket_count)) ;
else if (xml_sax_attr_bool (attrs, "IsAnd", &is_and)) ; else if (xml_sax_attr_bool (attrs, "IsAnd", &is_and)) ;
else if (!strcmp (attrs[i], "Op0")) xml_sax_filter_operator (state, &op0, attrs[i+1]); else if (!strcmp (attrs[i], "Op0")) xml_sax_filter_operator (state, &op0, attrs[i+1]);
else if (!strcmp (attrs[i], "Op1")) xml_sax_filter_operator (state, &op1, attrs[i+1]); else if (!strcmp (attrs[i], "Op1")) xml_sax_filter_operator (state, &op1, attrs[i+1]);
......
...@@ -845,7 +845,7 @@ xml_write_filter_field (GnmOutputXML *state, ...@@ -845,7 +845,7 @@ xml_write_filter_field (GnmOutputXML *state,
cond->op[0] & 1 ? TRUE : FALSE); cond->op[0] & 1 ? TRUE : FALSE);
gsf_xml_out_add_bool (state->output, "items", gsf_xml_out_add_bool (state->output, "items",
cond->op[0] & 2 ? TRUE : FALSE); cond->op[0] & 2 ? TRUE : FALSE);
gsf_xml_out_add_int (state->output, "count", cond->count); gsf_xml_out_add_float (state->output, "count", cond->count, 4);
break; break;
} }
......
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