[gnumeric] xls: export line styles right.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] xls: export line styles right.
- Date: Thu, 15 Oct 2009 23:28:07 +0000 (UTC)
commit 4a606bc23a832974822e13b1da605b6e235d96c3
Author: Morten Welinder <terra gnome org>
Date: Thu Oct 15 19:27:45 2009 -0400
xls: export line styles right.
NEWS | 4 ++-
plugins/excel/ChangeLog | 2 +
plugins/excel/ms-chart.c | 2 +-
plugins/excel/ms-escher.c | 43 ++++++++++++++++++++++++++++++++++++++++
plugins/excel/ms-escher.h | 3 ++
plugins/excel/ms-excel-read.c | 24 +--------------------
plugins/excel/ms-excel-read.h | 2 -
plugins/excel/ms-excel-write.c | 12 +++++++++++
8 files changed, 66 insertions(+), 26 deletions(-)
---
diff --git a/NEWS b/NEWS
index f7d681a..88ff877 100644
--- a/NEWS
+++ b/NEWS
@@ -15,7 +15,9 @@ Morten:
* Add xls export of list widgets. [Part of #597035]
* Add xls export of combo widgets. [Part of #597035]
* Add xls export of button widgets. [Part of #597035]
- * Fix xls import of line styles.
+ * Make it possible for arrows to have arrow heads in both ends.
+ * Implement round arrow heads.
+ * Fix xls import and export of line styles.
--------------------------------------------------------------------------
Gnumeric 1.9.14
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index a982ec2..9e410ad 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -2,6 +2,8 @@
* ms-excel-write.c (excel_write_line_v8): Fix handling of
direction.
+ (excel_write_textbox_or_widget_v8, excel_write_line_v8): Export
+ line styles.
2009-10-14 Morten Welinder <terra gnome org>
diff --git a/plugins/excel/ms-chart.c b/plugins/excel/ms-chart.c
index 7ac0021..4d15719 100644
--- a/plugins/excel/ms-chart.c
+++ b/plugins/excel/ms-chart.c
@@ -1357,7 +1357,7 @@ BC_R(lineformat)(XLChartHandler const *handle,
d (0, g_printerr ("Lines have a %s pattern.\n",
ms_line_pattern [pattern]););
- s->style->line.dash_type = xl_pattern_to_line_type (pattern);
+ s->style->line.dash_type = ms_escher_xl_to_line_type (pattern);
if (BC_R(ver)(s) >= MS_BIFF_V8 && s->currentSeries != NULL) {
guint16 const fore = GSF_LE_GET_GUINT16 (q->data + 10);
diff --git a/plugins/excel/ms-escher.c b/plugins/excel/ms-escher.c
index bd5981b..f254e24 100644
--- a/plugins/excel/ms-escher.c
+++ b/plugins/excel/ms-escher.c
@@ -51,6 +51,49 @@
#define d(level, code)
#endif
+GOLineDashType
+ms_escher_xl_to_line_type (guint16 pattern)
+{
+ static GOLineDashType const dash_map []= {
+ GO_LINE_SOLID,
+ GO_LINE_DASH,
+ GO_LINE_DOT,
+ GO_LINE_DASH_DOT,
+ GO_LINE_DASH_DOT_DOT,
+ GO_LINE_DOT, /* ? */
+ GO_LINE_DASH,
+ GO_LINE_DASH, /* Long dash */
+ GO_LINE_DASH_DOT,
+ GO_LINE_DASH_DOT, /* Long dash dot */
+ GO_LINE_DASH_DOT_DOT /* Long dash dot dot */
+ };
+
+ return (pattern >= G_N_ELEMENTS (dash_map))
+ ? GO_LINE_SOLID
+ : dash_map[pattern];
+}
+
+int
+ms_escher_line_type_to_xl (GOLineDashType ld)
+{
+ switch (ld) {
+ default:
+ case GO_LINE_NONE: return -1;
+ case GO_LINE_SOLID: return 0;
+ case GO_LINE_S_DOT: return 2;
+ case GO_LINE_S_DASH_DOT: return 3;
+ case GO_LINE_S_DASH_DOT_DOT: return 4;
+ case GO_LINE_DASH_DOT_DOT_DOT: return 4;
+ case GO_LINE_DOT: return 5;
+ case GO_LINE_S_DASH: return 6;
+ case GO_LINE_DASH: return 7;
+ case GO_LINE_LONG_DASH: return 8;
+ case GO_LINE_DASH_DOT: return 9;
+ case GO_LINE_DASH_DOT_DOT: return 10;
+ }
+}
+
+
/* A storage accumulator for common state information */
typedef struct {
MSContainer *container;
diff --git a/plugins/excel/ms-escher.h b/plugins/excel/ms-escher.h
index 77c958b..019c453 100644
--- a/plugins/excel/ms-escher.h
+++ b/plugins/excel/ms-escher.h
@@ -33,6 +33,7 @@ enum {
MSEP_NOFILLHITTEST = 0x01bf,
MSEP_LINECOLOR = 0x01c0,
MSEP_LINEWIDTH = 0x01cb,
+ MSEP_LINEDASHING = 0x01ce,
MSEP_LINESTARTARROWHEAD = 0x01d0,
MSEP_LINEENDARROWHEAD = 0x01d1,
MSEP_LINESTARTARROWWIDTH = 0x01d2,
@@ -45,6 +46,8 @@ enum {
MSEP_ISBUTTON = 0x03bc
};
+GOLineDashType ms_escher_xl_to_line_type (guint16 pattern);
+int ms_escher_line_type_to_xl (GOLineDashType ld);
struct _MSEscherBlip {
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 690163f..535ae29 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -488,26 +488,6 @@ handle_arrow_head (SheetObject *so, const char *prop_name,
g_object_set (so, prop_name, &arrow, NULL);
}
-unsigned
-xl_pattern_to_line_type (guint16 pattern)
-{
- static GOLineDashType const dash_map []= {
- GO_LINE_SOLID,
- GO_LINE_DASH,
- GO_LINE_DOT,
- GO_LINE_DASH_DOT,
- GO_LINE_DASH_DOT_DOT,
- GO_LINE_DOT, /* ? */
- GO_LINE_DASH,
- GO_LINE_DASH, /* Long dash */
- GO_LINE_DASH_DOT,
- GO_LINE_DASH_DOT, /* Long dash dot */
- GO_LINE_DASH_DOT_DOT /* Long dash dot dot */
- };
-
- return (pattern >= G_N_ELEMENTS (dash_map))? GO_LINE_SOLID: dash_map[pattern];
-}
-
static gboolean
ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
{
@@ -590,7 +570,7 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
(ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_OUTLINE_HIDE) != NULL);
style->line.dash_type = style->line.auto_dash
? GO_LINE_NONE
- : xl_pattern_to_line_type (ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_OUTLINE_STYLE, 0));
+ : ms_escher_xl_to_line_type (ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_OUTLINE_STYLE, 0));
g_object_set (G_OBJECT (so), "style", style, NULL);
g_object_unref (style);
@@ -627,7 +607,7 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
(ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_OUTLINE_HIDE) != NULL);
style->line.dash_type = style->line.auto_dash
? GO_LINE_NONE
- : xl_pattern_to_line_type (ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_OUTLINE_STYLE, 0));
+ : ms_escher_xl_to_line_type (ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_OUTLINE_STYLE, 0));
style->fill.pattern.back = ms_sheet_map_color
(esheet, obj, MS_OBJ_ATTR_FILL_COLOR,
GO_COLOR_WHITE, &style->fill.auto_back);
diff --git a/plugins/excel/ms-excel-read.h b/plugins/excel/ms-excel-read.h
index d87050d..7be81d9 100644
--- a/plugins/excel/ms-excel-read.h
+++ b/plugins/excel/ms-excel-read.h
@@ -174,6 +174,4 @@ void xls_read_SXIVD (BiffQuery *q, ExcelReadSheet *esheet);
void excel_read_cleanup (void);
void excel_read_init (void);
-unsigned xl_pattern_to_line_type (guint16 pattern);
-
#endif /* GNM_MS_EXCEL_READ_H */
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index b9b00a4..eab26f4 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -4394,6 +4394,12 @@ excel_write_textbox_or_widget_v8 (ExcelWriteSheet *esheet,
gint32 w = CLAMP (12700 * style->line.width, 0, G_MAXINT32);
ms_escher_opt_add_simple (escher, optmark, MSEP_LINEWIDTH, w);
}
+ if (style && !style->line.auto_dash) {
+ int d = ms_escher_line_type_to_xl (style->line.dash_type);
+ if (d >= 0)
+ ms_escher_opt_add_simple (escher, optmark,
+ MSEP_LINEDASHING, d);
+ }
if (is_widget)
ms_escher_opt_add_bool (escher, optmark, MSEP_LINE, FALSE);
if (name)
@@ -4655,6 +4661,12 @@ excel_write_line_v8 (ExcelWriteSheet *esheet, SheetObject *so)
gint32 w = CLAMP (12700 * style->line.width, 0, G_MAXINT32);
ms_escher_opt_add_simple (escher, optmark, MSEP_LINEWIDTH, w);
}
+ if (!style->line.auto_dash) {
+ int d = ms_escher_line_type_to_xl (style->line.dash_type);
+ if (d >= 0)
+ ms_escher_opt_add_simple (escher, optmark,
+ MSEP_LINEDASHING, d);
+ }
/* The two arrows' attributes are interleaved. */
write_arrow (start_arrow, escher, optmark, MSEP_LINESTARTARROWHEAD);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]