sw/qa/extras/ooxmlexport/data/tdf123627.docx |binary sw/qa/extras/ooxmlexport/ooxmllinks.cxx | 27 ++++++++++++++++++++-- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 2 - writerfilter/source/dmapper/DomainMapper_Impl.hxx | 2 - 4 files changed, 26 insertions(+), 5 deletions(-)
New commits: commit 4c30848c852c44cbad8509c770feed5244f1940f Author: Tünde Tóth <tund...@gmail.com> AuthorDate: Thu Jul 18 15:10:26 2019 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Thu Jul 25 09:31:34 2019 +0200 tdf#123627 DOCX import: fix relative hyperlinks to documents Revert "tdf#86087 DOCX Import link as relative if preferred" This reverts commit 40acf8d6447065077acba9e800c56239f58c8262. Relative urls aren't converted to absolute urls, if the "Save URLs relative to filesystem" setting is checked. Change-Id: I209fa57e508dd425772e0019c1749a2bdc92e3ed Reviewed-on: https://gerrit.libreoffice.org/75863 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/ooxmlexport/data/tdf123627.docx b/sw/qa/extras/ooxmlexport/data/tdf123627.docx new file mode 100644 index 000000000000..a85d440005f0 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf123627.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx index 5b03e7ddf532..66cd8319ce3c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx @@ -141,7 +141,9 @@ DECLARE_LINKS_IMPORT_TEST(testRelativeToRelativeImport, "relative-link.docx", US { uno::Reference<text::XTextRange> xParagraph = getParagraph(1); uno::Reference<text::XTextRange> xText = getRun(xParagraph, 1); - CPPUNIT_ASSERT_EQUAL(OUString("relative.docx"), getProperty<OUString>(xText, "HyperLinkURL")); + OUString sTarget = getProperty<OUString>(xText, "HyperLinkURL"); + CPPUNIT_ASSERT(sTarget.startsWith("file:///")); + CPPUNIT_ASSERT(sTarget.endsWith("relative.docx")); } DECLARE_LINKS_IMPORT_TEST(testRelativeToAbsoluteImport, "relative-link.docx", USE_ABSOLUTE) @@ -171,6 +173,14 @@ DECLARE_LINKS_IMPORT_TEST(testAbsoluteToRelativeImport, "absolute-link.docx", US getProperty<OUString>(xText, "HyperLinkURL")); } +DECLARE_LINKS_IMPORT_TEST(testTdf123627_import, "tdf123627.docx", USE_RELATIVE) +{ + uno::Reference<text::XTextRange> xText = getRun(getParagraph(1), 1); + OUString sTarget = getProperty<OUString>(xText, "HyperLinkURL"); + CPPUNIT_ASSERT(sTarget.startsWith("file:///")); + CPPUNIT_ASSERT(sTarget.endsWith("New/test.docx")); +} + /* EXPORT */ DECLARE_LINKS_EXPORT_TEST(testRelativeToRelativeExport, "relative-link.docx", USE_RELATIVE, @@ -180,7 +190,9 @@ DECLARE_LINKS_EXPORT_TEST(testRelativeToRelativeExport, "relative-link.docx", US if (!pXmlDoc) return; - assertXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[2]", "Target", "relative.docx"); + OUString sTarget = getXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[2]", "Target"); + CPPUNIT_ASSERT(!sTarget.startsWith("file:///")); + CPPUNIT_ASSERT(sTarget.endsWith("relative.docx")); } DECLARE_LINKS_EXPORT_TEST(testRelativeToAbsoluteExport, "relative-link.docx", USE_ABSOLUTE, @@ -217,6 +229,17 @@ DECLARE_LINKS_EXPORT_TEST(testAbsoluteToAbsoluteExport, "absolute-link.docx", US CPPUNIT_ASSERT(sTarget.endsWith("test.docx")); } +DECLARE_LINKS_EXPORT_TEST(testTdf123627_export, "tdf123627.docx", USE_RELATIVE, DONT_MODIFY_LINK) +{ + xmlDocPtr pXmlDoc = parseExport("word/_rels/document.xml.rels"); + if (!pXmlDoc) + return; + + OUString sTarget = getXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[2]", "Target"); + CPPUNIT_ASSERT(!sTarget.startsWith("file:///")); + CPPUNIT_ASSERT(sTarget.endsWith("New/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 632eb860e146..2e1b7c710980 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -4514,7 +4514,7 @@ void DomainMapper_Impl::CloseFieldCommand() // Try to make absolute any relative URLs, except // for relative same-document URLs that only contain // a fragment part: - if (!sURL.startsWith("#") && !m_aSaveOpt.IsSaveRelFSys()) { + if (!sURL.startsWith("#")) { try { sURL = rtl::Uri::convertRelToAbs( m_aBaseUrl, sURL); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 40317732273b..fab77099ae56 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -27,7 +27,6 @@ #include <com/sun/star/text/XTextFrame.hpp> #include <com/sun/star/style/TabStop.hpp> #include <com/sun/star/container/XNameContainer.hpp> -#include <unotools/saveopt.hxx> #include <queue> #include <stack> #include <tuple> @@ -407,7 +406,6 @@ public: private: SourceDocumentType const m_eDocumentType; DomainMapper& m_rDMapper; - SvtSaveOptions const m_aSaveOpt; OUString m_aBaseUrl; css::uno::Reference<css::text::XTextDocument> m_xTextDocument; css::uno::Reference<css::beans::XPropertySet> m_xDocumentSettings; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits