[gnumeric] Fix hyperlinks import from ODF (Part 2). [#779635]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Fix hyperlinks import from ODF (Part 2). [#779635]
- Date: Tue, 7 Mar 2017 05:30:12 +0000 (UTC)
commit dc8d02129635e91c68c3fd71745f9434706ba8fb
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Mon Mar 6 22:33:06 2017 -0700
Fix hyperlinks import from ODF (Part 2). [#779635]
2017-01-30 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_cell_content_link) local links may be prefixed with #
* openoffice-write.c (odf_write_objects) prefix local links with #
plugins/openoffice/ChangeLog | 5 +++++
plugins/openoffice/openoffice-read.c | 5 ++++-
plugins/openoffice/openoffice-write.c | 15 ++++++++++++++-
3 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index b93ff96..04647ee 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,8 @@
+2017-01-30 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (oo_cell_content_link) local links may be prefixed with #
+ * openoffice-write.c (odf_write_objects) prefix local links with #
+
2017-03-06 Morten Welinder <terra gnome org>
* openoffice-read.c: Use GSF_XML_2ND where appropriate.
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index a76bc2c..c27481e 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4287,7 +4287,10 @@ oo_cell_content_link (GsfXMLIn *xin, xmlChar const **attrs)
type = gnm_hlink_email_get_type ();
else if (g_str_has_prefix (link, "file"))
type = gnm_hlink_external_get_type ();
- else
+ else if (g_str_has_prefix (link, "#")) {
+ type = gnm_hlink_cur_wb_get_type ();
+ link++;
+ } else
type = gnm_hlink_cur_wb_get_type ();
hlink = gnm_hlink_new (type, state->pos.sheet);
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index cb65054..c96766a 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3318,12 +3318,25 @@ odf_write_objects (GnmOOExport *state, GSList *objects)
static void
odf_write_link_start (GnmOOExport *state, GnmHLink *link)
{
+ char const *link_text;
if (link == NULL)
return;
+ link_text = gnm_hlink_get_target (link);
+
gsf_xml_out_start_element (state->xml, TEXT "a");
gsf_xml_out_add_cstr (state->xml, XLINK "type", "simple");
gsf_xml_out_add_cstr (state->xml, XLINK "actuate", "onRequest");
- gsf_xml_out_add_cstr (state->xml, XLINK "href", gnm_hlink_get_target (link));
+
+ if (g_str_has_prefix (link_text, "http") ||
+ g_str_has_prefix (link_text, "mail") ||
+ g_str_has_prefix (link_text, "file"))
+ gsf_xml_out_add_cstr (state->xml, XLINK "href", link_text);
+ else {
+ gchar *link_text_complete = g_strconcat ("#",link_text,NULL);
+ gsf_xml_out_add_cstr (state->xml, XLINK "href", link_text_complete);
+ g_free (link_text_complete);
+ }
+
gsf_xml_out_add_cstr (state->xml, OFFICE "title", gnm_hlink_get_tip (link));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]