[Libreoffice-commits] core.git: sw/qa writerfilter/source

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 1 08:24:57 UTC 2019


 sw/qa/extras/ooxmlexport/data/tdf126590.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmllinks.cxx           |   10 ++++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    8 +++++++-
 3 files changed, 17 insertions(+), 1 deletion(-)

New commits:
commit a912df26c6bd9251802f853775753d20f3b3de2b
Author:     Tünde Tóth <tundeth at gmail.com>
AuthorDate: Tue Jul 30 09:29:24 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Aug 1 10:24:21 2019 +0200

    tdf#126590 DOCX import: fix absolute hyperlinks to documents
    
    Absolute links in DOCX documents created with Word didn't work.
    
    Change-Id: Ie23c9ded1c88752768b925ec26df3061beeddd8e
    Reviewed-on: https://gerrit.libreoffice.org/76581
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf126590.docx b/sw/qa/extras/ooxmlexport/data/tdf126590.docx
new file mode 100644
index 000000000000..147db4565275
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf126590.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
index dc5deaf30df4..0a9ab492e0e7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
@@ -240,6 +240,16 @@ DECLARE_LINKS_EXPORT_TEST(testTdf123627_export, "tdf123627.docx", USE_RELATIVE,
     CPPUNIT_ASSERT(sTarget.endsWith("New/test.docx"));
 }
 
+DECLARE_LINKS_EXPORT_TEST(testTdf126590_export, "tdf126590.docx", USE_ABSOLUTE, DONT_MODIFY_LINK)
+{
+    xmlDocPtr pXmlDoc = parseExport("word/_rels/document.xml.rels");
+    if (!pXmlDoc)
+        return;
+    // in the original file: Target="file:///C:\TEMP\test.docx" => invalid file URI
+    assertXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[@TargetMode='External']", "Target",
+                "file:///C:/TEMP/test.docx");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 215a5c6f0c65..7e42d4af1233 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4511,10 +4511,16 @@ void DomainMapper_Impl::CloseFieldCommand()
 
                         if (!sURL.isEmpty())
                         {
+                            if (sURL.startsWith("file:///"))
+                            {
+                                // file:///absolute\path\to\file => invalid file URI (Writer cannot open)
+                                // convert all blackslashes to slashes:
+                                sURL = sURL.replace('\\', '/');
+                            }
                             // Try to make absolute any relative URLs, except
                             // for relative same-document URLs that only contain
                             // a fragment part:
-                            if (!sURL.startsWith("#")) {
+                            else if (!sURL.startsWith("#")) {
                                 try {
                                     sURL = rtl::Uri::convertRelToAbs(
                                         m_aBaseUrl, sURL);


More information about the Libreoffice-commits mailing list