[gnumeric] xls: export line and textbox colours.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] xls: export line and textbox colours.
- Date: Wed, 7 Oct 2009 14:05:37 +0000 (UTC)
commit 728dfba9dd3712de9aa9b0dc19bf08a220ee9f55
Author: Morten Welinder <terra gnome org>
Date: Wed Oct 7 10:05:20 2009 -0400
xls: export line and textbox colours.
NEWS | 1 +
plugins/excel/ChangeLog | 6 ++++-
plugins/excel/ms-escher.c | 11 +++++++++
plugins/excel/ms-escher.h | 9 +++++++
plugins/excel/ms-excel-write.c | 47 +++++++++++++++++++++++++++------------
5 files changed, 58 insertions(+), 16 deletions(-)
---
diff --git a/NEWS b/NEWS
index c464436..80caec7 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,7 @@ Morten:
* Plug xls export leaks.
* Implement export of lines and arrows to xls. [Part of #597035]
* Fix xls reading of sheet object colours.
+ * Export line and textbox colouring. [Part of #597035]
--------------------------------------------------------------------------
Gnumeric 1.9.13
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index ed0c670..5113e4b 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,7 +1,11 @@
2009-10-07 Morten Welinder <terra gnome org>
+ * ms-escher.c (ms_escher_opt_add_color): New function.
+
* ms-excel-write.c (excel_write_textbox_v8): Make sure the textbox
- gets to be part of the container.
+ gets to be part of the container. Export line and background
+ colours.
+ (excel_write_line_v8): Export line colour.
* ms-escher.c (ms_escher_opt_end): Docs were wrong. Do not
include own header in length.
diff --git a/plugins/excel/ms-escher.c b/plugins/excel/ms-escher.c
index 9de5ba6..2f7c7b0 100644
--- a/plugins/excel/ms-escher.c
+++ b/plugins/excel/ms-escher.c
@@ -2260,6 +2260,17 @@ ms_escher_opt_add_simple (GString *buf, gsize marker, guint16 pid, gint32 val)
}
void
+ms_escher_opt_add_color (GString *buf, gsize marker,
+ guint16 pid, GOColor c)
+{
+ guint8 r = GO_COLOR_UINT_R (c);
+ guint8 g = GO_COLOR_UINT_G (c);
+ guint8 b = GO_COLOR_UINT_B (c);
+ guint32 val = r | (g << 8) | (b << 16);
+ ms_escher_opt_add_simple (buf, marker, pid, val);
+}
+
+void
ms_escher_opt_add_str_wchar (GString *buf, gsize marker, GString *extra,
guint16 pid, const char *str)
{
diff --git a/plugins/excel/ms-escher.h b/plugins/excel/ms-escher.h
index 8bb9c9b..51e81b6 100644
--- a/plugins/excel/ms-escher.h
+++ b/plugins/excel/ms-escher.h
@@ -17,6 +17,13 @@
#include "ms-obj.h"
#include <sheet-object.h>
+enum {
+ MSEP_FILLCOLOR = 0x0181,
+ MSEP_LINECOLOR = 0x01c0
+};
+
+
+
struct _MSEscherBlip {
char const *type;
guint8 *data;
@@ -42,6 +49,8 @@ void ms_escher_sp (GString *buf, guint32 spid, guint16 shape, guint32 flags);
gsize ms_escher_opt_start (GString *buf);
void ms_escher_opt_add_simple (GString *buf, gsize marker,
guint16 pid, gint32 val);
+void ms_escher_opt_add_color (GString *buf, gsize marker,
+ guint16 pid, GOColor c);
void ms_escher_opt_add_str_wchar (GString *buf, gsize marker, GString *extra,
guint16 pid, const char *str);
void ms_escher_opt_end (GString *buf, gsize marker);
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index 5cb677a..36b9578 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -4267,6 +4267,7 @@ excel_write_textbox_v8 (ExcelWriteSheet *esheet, SheetObject *so)
gboolean do_textbox;
gsize draw_len = 0;
char *name;
+ GOStyle *style;
if (IS_CELL_COMMENT (so)) {
static float const offset [4] = { .5, .5, .5, .5 };
@@ -4284,6 +4285,9 @@ excel_write_textbox_v8 (ExcelWriteSheet *esheet, SheetObject *so)
do_textbox = TRUE;
g_hash_table_insert (esheet->commentshash,
so, GINT_TO_POINTER (esheet->cur_obj));
+
+ g_object_get (so, "name", &name, NULL);
+ style = NULL;
} else if (IS_GNM_SO_FILLED (so)) {
gboolean is_oval;
char *label;
@@ -4295,6 +4299,8 @@ excel_write_textbox_v8 (ExcelWriteSheet *esheet, SheetObject *so)
g_object_get (so,
"is-oval", &is_oval,
"text", &label,
+ "name", &name,
+ "style", &style,
NULL);
do_textbox = (label != NULL);
if (is_oval) {
@@ -4323,18 +4329,19 @@ excel_write_textbox_v8 (ExcelWriteSheet *esheet, SheetObject *so)
0x0085, 1); /* wrap_text_at_margin */
ms_escher_opt_add_simple (escher, optmark,
0x00bf, 0x000a0008); /* wrap_text_at_margin */
- ms_escher_opt_add_simple (escher, optmark,
- 0x0181, 0x08000041); /* fillColor */
+ ms_escher_opt_add_color (escher, optmark, MSEP_FILLCOLOR,
+ style == NULL || style->fill.auto_back
+ ? GO_COLOR_WHITE
+ : style->fill.pattern.back);
ms_escher_opt_add_simple (escher, optmark,
0x01bf, 0x00010000); /* fNoFillHitTest */
- ms_escher_opt_add_simple (escher, optmark,
- 0x01c0, 0x08000040); /* lineColor */
- g_object_get (so, "name", &name, NULL);
- if (name) {
+ ms_escher_opt_add_color (escher, optmark, MSEP_LINECOLOR,
+ style == NULL || style->line.auto_color
+ ? GO_COLOR_BLACK
+ : style->line.color);
+ if (name)
ms_escher_opt_add_str_wchar (escher, optmark, extra,
0x0380, name);
- g_free (name);
- }
ms_escher_opt_add_simple (escher, optmark,
0x03bf, 0x00080000); /* fPrint */
go_string_append_gstring (escher, extra);
@@ -4374,6 +4381,9 @@ excel_write_textbox_v8 (ExcelWriteSheet *esheet, SheetObject *so)
ms_biff_put_abs_write (bp, sppos + 4, &splen, 4);
}
+ g_free (name);
+ if (style) g_object_unref (style);
+
return draw_len;
}
@@ -4394,8 +4404,13 @@ excel_write_line_v8 (ExcelWriteSheet *esheet, SheetObject *so)
gsize spmark, optmark;
char *name;
guint8 zero[4] = { 0, 0, 0, 0 };
+ GOStyle *style;
- g_object_get (so, "is-arrow", &is_arrow, NULL);
+ g_object_get (so,
+ "is-arrow", &is_arrow,
+ "name", &name,
+ "style", &style,
+ NULL);
spmark = ms_escher_spcontainer_start (escher);
@@ -4411,8 +4426,10 @@ excel_write_line_v8 (ExcelWriteSheet *esheet, SheetObject *so)
0x017f, 0x00010000);
ms_escher_opt_add_simple (escher, optmark,
0x01bf, 0x00110001);
- ms_escher_opt_add_simple (escher, optmark,
- 0x01c0, 0x0800000a); /* lineColor */
+ ms_escher_opt_add_color (escher, optmark, MSEP_LINECOLOR,
+ style->line.auto_color
+ ? GO_COLOR_BLACK
+ : style->line.color);
ms_escher_opt_add_simple (escher, optmark,
0x01cb, 19050); /* lineWidth */
if (is_arrow)
@@ -4420,12 +4437,9 @@ excel_write_line_v8 (ExcelWriteSheet *esheet, SheetObject *so)
0x01d1, 1); /* lineEndArrowhead */
ms_escher_opt_add_simple (escher, optmark,
0x1ff, 0x00180018);
- g_object_get (so, "name", &name, NULL);
- if (name) {
+ if (name)
ms_escher_opt_add_str_wchar (escher, optmark, extra,
0x0380, name);
- g_free (name);
- }
ms_escher_opt_add_simple (escher, optmark,
0x03bf, 0x00080008); /* fPrint */
go_string_append_gstring (escher, extra);
@@ -4450,6 +4464,9 @@ excel_write_line_v8 (ExcelWriteSheet *esheet, SheetObject *so)
ms_biff_put_commit (bp);
+ g_free (name);
+ g_object_unref (style);
+
return draw_len;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]