[gnumeric] xlsx: export file:// links.



commit ef485dfd4b0049ba4acb47bfa8df692215f17e52
Author: Morten Welinder <terra gnome org>
Date:   Mon Mar 29 19:58:15 2021 -0400

    xlsx: export file:// links.

 NEWS                       | 3 ++-
 plugins/excel/ChangeLog    | 5 +++++
 plugins/excel/xlsx-read.c  | 7 +++++--
 plugins/excel/xlsx-write.c | 4 +++-
 4 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index 167fb9f1e..1b62f56c0 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,8 @@ Morten:
        * Fix undo problem with sorting and cell comments.
        * Python loader cleanups.
        * Use Python's bool type instead of rolling our own.
-       * Export also file links to html.  [#569]
+       * Export file:// links to html.  [#569]
+       * Export file:// links to xlsx.  [#569]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.49
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 353b1c368..7a530edb8 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2021-03-29  Morten Welinder  <terra gnome org>
+
+       * xlsx-read.c (xlsx_CT_HyperLinks): Also handle file:// links.
+       * xlsx-write.c (xlsx_write_hlink): Ditto.
+
 2021-03-14  Morten Welinder <terra gnome org>
 
        * Release 1.12.49
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index ff0b11fb6..06c63f86b 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -3176,10 +3176,13 @@ xlsx_CT_HyperLinks (GsfXMLIn *xin, xmlChar const **attrs)
                                 
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";)) {
                        const char *url = gsf_open_pkg_rel_get_target (rel);
                        if (url) {
-                               if (0 == strncmp (url, "mailto:";, 7))
+                               if (!g_ascii_strncasecmp (url, "mailto:";, 7))
                                        link_type = gnm_hlink_email_get_type ();
-                               else
+                               else if (!g_ascii_strncasecmp (url, "http:", 5) ||
+                                        !g_ascii_strncasecmp (url, "https:", 6))
                                        link_type = gnm_hlink_url_get_type ();
+                               else
+                                       link_type = gnm_hlink_external_get_type ();
                                target = location
                                        ? g_strconcat (url, "#", location, NULL)
                                        : g_strdup (url);
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 68f365bf5..7337564d9 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -2094,7 +2094,9 @@ xlsx_write_hlink (GnmHLink const *lnk, GSList *ranges, XLSXClosure *info)
        gchar const *tip = gnm_hlink_get_tip (lnk);
        GType const t = G_OBJECT_TYPE (lnk);
 
-       if (target && g_type_is_a (t, gnm_hlink_url_get_type ())) {
+       if (target &&
+           (g_type_is_a (t, gnm_hlink_url_get_type ()) ||
+            GNM_IS_HLINK_EXTERNAL (lnk))) {
                // URLs, including email.
 
                char *hash = strchr (target, '#');


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]