[gnumeric] xlsx: improve arrow import.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xlsx: improve arrow import.
- Date: Thu, 12 Feb 2015 23:00:50 +0000 (UTC)
commit 9718e265a173674210ffb881163f2b33d2e2f9a5
Author: Morten Welinder <terra gnome org>
Date: Thu Feb 12 18:00:30 2015 -0500
xlsx: improve arrow import.
plugins/excel/ChangeLog | 6 +++++
plugins/excel/ms-excel-read.c | 38 +----------------------------------
plugins/excel/ms-excel-util.c | 40 +++++++++++++++++++++++++++++++++++++
plugins/excel/ms-excel-util.h | 1 +
plugins/excel/xlsx-read-drawing.c | 19 +++++++++++------
5 files changed, 60 insertions(+), 44 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index d991a9b..ab7c826 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,5 +1,11 @@
2015-02-12 Morten Welinder <terra gnome org>
+ * xlsx-read-drawing.c (xlsx_chart_line_headtail): Improve arrow
+ import with xls_arrow_from_xl.
+
+ * ms-excel-util.c (xls_arrow_from_xl): New function extrated...
+ * ms-excel-read.c (handle_arrow_head): ...from here.
+
* xlsx-write-drawing.c (xlsx_write_go_style_full): Improve arrow
export with xls_arrow_to_xl.
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 68f1b3e..709e6f5 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -455,44 +455,8 @@ handle_arrow_head (SheetObject *so, const char *prop_name,
GOArrow arrow;
int w = ms_obj_attr_get_int (attrs, wid, 1);
int l = ms_obj_attr_get_int (attrs, lid, 1);
-
- /* NOTE: This mess should match code in ms-excel-write.c */
-
int typ = ms_obj_attr_get_int (attrs, typid, 0);
- switch (typ) {
- case 0:
- go_arrow_clear (&arrow);
- break;
- default:
- case 1: /* Regular */
- go_arrow_init_kite (&arrow,
- 3.5 * (l + 1),
- 3.5 * (l + 1),
- 2.5 * (w + 1));
- break;
- case 2: /* Stealth */
- go_arrow_init_kite (&arrow,
- 2.5 * (l + 1),
- 4.0 * (l + 1),
- 2.0 * (w + 1));
- break;
- case 3: /* Diamond */
- go_arrow_init_kite (&arrow,
- 5 * (l + 1),
- 2.5 * (l + 1),
- 2.5 * (w + 1));
- break;
- case 4: /* Oval */
- go_arrow_init_oval (&arrow, (l + 1) * 2.5, (w + 1) * 2.5);
- break;
- case 5: /* Open -- Approximation! */
- go_arrow_init_kite (&arrow,
- 1.0 * (l + 1),
- 2.5 * (l + 1),
- 1.5 * (w + 1));
- break;
- }
-
+ xls_arrow_from_xl (&arrow, typ, l, w);
g_object_set (so, prop_name, &arrow, NULL);
}
diff --git a/plugins/excel/ms-excel-util.c b/plugins/excel/ms-excel-util.c
index 15d396a..62fbd5c 100644
--- a/plugins/excel/ms-excel-util.c
+++ b/plugins/excel/ms-excel-util.c
@@ -861,3 +861,43 @@ xls_arrow_to_xl (GOArrow const *arrow, XLArrowType *ptyp, int *pl, int *pw)
g_assert_not_reached ();
}
}
+
+void
+xls_arrow_from_xl (GOArrow *arrow, XLArrowType typ, int l, int w)
+{
+ switch (typ) {
+ case XL_ARROW_NONE:
+ go_arrow_clear (arrow);
+ break;
+ default:
+ case XL_ARROW_REGULAR:
+ go_arrow_init_kite (arrow,
+ 3.5 * (l + 1),
+ 3.5 * (l + 1),
+ 2.5 * (w + 1));
+ break;
+ case XL_ARROW_STEALTH:
+ go_arrow_init_kite (arrow,
+ 2.5 * (l + 1),
+ 4.0 * (l + 1),
+ 2.0 * (w + 1));
+ break;
+ case XL_ARROW_DIAMOND:
+ go_arrow_init_kite (arrow,
+ 5 * (l + 1),
+ 2.5 * (l + 1),
+ 2.5 * (w + 1));
+ break;
+ case XL_ARROW_OVAL:
+ go_arrow_init_oval (arrow, (l + 1) * 2.5, (w + 1) * 2.5);
+ break;
+ case XL_ARROW_OPEN: /* Approximation! */
+ go_arrow_init_kite (arrow,
+ 1.0 * (l + 1),
+ 2.5 * (l + 1),
+ 1.5 * (w + 1));
+ break;
+ }
+}
+
+/*****************************************************************************/
diff --git a/plugins/excel/ms-excel-util.h b/plugins/excel/ms-excel-util.h
index 1eb91cb..aad77d8 100644
--- a/plugins/excel/ms-excel-util.h
+++ b/plugins/excel/ms-excel-util.h
@@ -117,6 +117,7 @@ typedef enum {
} XLArrowType;
void xls_arrow_to_xl (GOArrow const *arrow, XLArrowType *ptyp, int *pl, int *pw);
+void xls_arrow_from_xl (GOArrow *arrow, XLArrowType typ, int l, int w);
/*****************************************************************************/
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index 203d34a..5f5e9dd 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -1831,21 +1831,26 @@ xlsx_chart_line_headtail (GsfXMLIn *xin, xmlChar const **attrs)
{ "triangle", GO_ARROW_KITE },
{ NULL, 0 }
};
- int typ = GO_ARROW_NONE;
- double a = 8, b = 10, c = 3;
+ static EnumVal const sizes[] = {
+ { "sm", 0 },
+ { "med", 1 },
+ { "lg", 2 },
+ { NULL, 0 }
+ };
+ int typ = XL_ARROW_NONE;
+ int w = 1, l = 1;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
- if (attr_enum (xin, attrs, "type", types, &typ)) {
+ if (attr_enum (xin, attrs, "type", types, &typ) ||
+ attr_enum (xin, attrs, "w", sizes, &w) ||
+ attr_enum (xin, attrs, "len", sizes, &l)) {
/* Nothing */
}
}
if (IS_GNM_SO_LINE (state->so)) {
GOArrow arrow;
- arrow.typ = typ;
- arrow.a = a;
- arrow.b = b;
- arrow.c = c;
+ xls_arrow_from_xl (&arrow, typ, l, w);
g_object_set (state->so,
(is_tail ? "end-arrow" : "start-arrow"), &arrow,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]