summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTünde Tóth <tundeth@gmail.com>2019-08-09 09:30:50 +0200
committerLászló Németh <nemeth@numbertext.org>2019-08-09 15:31:47 +0200
commita81ef7f4ae8021e3f6ce782ebc526e798a814a5e (patch)
treef4d9563a60344e6debfc85a776eb63365dae266c
parentd03c92b93d6ba1808a6641b4aa8cb4aae38058bf (diff)
tdf#126768 DOCX import: fix absolute hyperlinks to documents
file:///absolute\\path\\to\\file didn't work in Writer. Change-Id: I61135668e47bc1d67afb4ed6bec6a90744d295cf Reviewed-on: https://gerrit.libreoffice.org/77184 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf126768.docxbin0 -> 12242 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmllinks.cxx9
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx4
3 files changed, 13 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf126768.docx b/sw/qa/extras/ooxmlexport/data/tdf126768.docx
new file mode 100644
index 000000000000..7a3440e79171
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf126768.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
index 0a9ab492e0e7..406af22d6ada 100644
--- a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
@@ -250,6 +250,15 @@ DECLARE_LINKS_EXPORT_TEST(testTdf126590_export, "tdf126590.docx", USE_ABSOLUTE,
"file:///C:/TEMP/test.docx");
}
+DECLARE_LINKS_EXPORT_TEST(testTdf126768_export, "tdf126768.docx", USE_ABSOLUTE, DONT_MODIFY_LINK)
+{
+ xmlDocPtr pXmlDoc = parseExport("word/_rels/document.xml.rels");
+ if (!pXmlDoc)
+ return;
+ // in the original file: "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 c5acf081afb9..e077d2bed52f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4514,6 +4514,10 @@ void DomainMapper_Impl::CloseFieldCommand()
{
if (sURL.startsWith("file:///"))
{
+ // file:///absolute\\path\\to\\file => invalid file URI (Writer cannot open)
+ // convert all double backslashes to slashes:
+ sURL = sURL.replaceAll("\\\\", "/");
+
// file:///absolute\path\to\file => invalid file URI (Writer cannot open)
// convert all backslashes to slashes:
sURL = sURL.replace('\\', '/');