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

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 21 10:31:36 UTC 2019


 oox/source/core/xmlfilterbase.cxx                 |    3 ++-
 sw/qa/extras/ooxmlexport/data/non_ascii_link.docx |binary
 sw/qa/extras/ooxmlexport/ooxmllinks.cxx           |   14 ++++++++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit d053d573d8bb70ba02ed60eecc590485e2e19497
Author:     Tünde Tóth <tundeth at gmail.com>
AuthorDate: Wed Aug 14 12:37:00 2019 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Wed Aug 21 12:30:28 2019 +0200

    tdf#127070 DOCX export:fix encoding of hyperlinks with non-ASCII letters
    
    Non-ASCII file links in DOCX documents created with Microsoft Word
    didn't work in Word after export.
    
    non_ascii_link.docx: Test file from Word 2016.
    
    Change-Id: Ib8c4e2e7b0402b88419d200c55cc1b881a4cde86
    Reviewed-on: https://gerrit.libreoffice.org/77450
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 54f8b9f6ca83..a5d565e93839 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -67,6 +67,7 @@
 #include <oox/crypto/DocumentEncryption.hxx>
 #include <tools/date.hxx>
 #include <tools/datetime.hxx>
+#include <tools/urlobj.hxx>
 #include <com/sun/star/util/Duration.hpp>
 #include <sax/tools/converter.hxx>
 #include <oox/token/namespacemap.hxx>
@@ -516,7 +517,7 @@ OUString lclAddRelation( const Reference< XRelationshipAccess >& rRelations, sal
     aEntry[0].First = "Type";
     aEntry[0].Second = rType;
     aEntry[1].First = "Target";
-    aEntry[1].Second = rTarget;
+    aEntry[1].Second = INetURLObject::decode(rTarget, INetURLObject::DecodeMechanism::Unambiguous, RTL_TEXTENCODING_UTF8);
     if( bExternal )
     {
         aEntry[2].First = "TargetMode";
diff --git a/sw/qa/extras/ooxmlexport/data/non_ascii_link.docx b/sw/qa/extras/ooxmlexport/data/non_ascii_link.docx
new file mode 100644
index 000000000000..345a55b5cff7
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/non_ascii_link.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
index 406af22d6ada..4be6351a12f1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
@@ -259,6 +259,20 @@ DECLARE_LINKS_EXPORT_TEST(testTdf126768_export, "tdf126768.docx", USE_ABSOLUTE,
     assertXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[@TargetMode='External']", "Target",
                 "file:///C:/TEMP/test.docx");
 }
+
+DECLARE_LINKS_EXPORT_TEST(testNon_ascii_link_export, "non_ascii_link.docx", USE_ABSOLUTE,
+                          DONT_MODIFY_LINK)
+{
+    xmlDocPtr pXmlDoc = parseExport("word/_rels/document.xml.rels");
+    if (!pXmlDoc)
+        return;
+
+    OUString sTarget = "file:///C:/TEMP/%C3%A9kezet.docx";
+    assertXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[@TargetMode='External']", "Target",
+                INetURLObject::decode( sTarget, INetURLObject::DecodeMechanism::Unambiguous,
+                RTL_TEXTENCODING_UTF8));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list