summaryrefslogtreecommitdiff
path: root/sw/qa/extras/ooxmlexport
diff options
context:
space:
mode:
authorAdam Kovacs <christo161@gmail.com>2019-05-17 11:30:26 +0200
committerLászló Németh <nemeth@numbertext.org>2019-05-18 00:07:55 +0200
commit1cbf0ee54519bf81d934609352e8a1a641d8a534 (patch)
tree8988ab365ea01095facba791b110aea97ccae2e3 /sw/qa/extras/ooxmlexport
parent75ef0e41ea8a9096ac619356d2b837c5333b47e6 (diff)
tdf#125298 DOCX export: fix bookmark name truncation
The 40-character bookmark name truncation for MSO was applied on percent encoded Unicode letters, resulting shorter bookmark names, than needed (for example, only 6 letters instead of 40). This is a clean-up of the commit b9afb9959c31c3c57d0f2fe91107a92abfd82cdb "tdf#113483: DOCX: fix encoding of bookmarks with non-ASCII letters". Change-Id: I6fbcdc47c57ef228abcf29e0a68d3d8bb66c5661 Reviewed-on: https://gerrit.libreoffice.org/72456 Tested-by: László Németh <nemeth@numbertext.org> Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa/extras/ooxmlexport')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf125298_crossreflink_nonascii_charlimit.docxbin0 -> 5194 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport13.cxx25
2 files changed, 25 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf125298_crossreflink_nonascii_charlimit.docx b/sw/qa/extras/ooxmlexport/data/tdf125298_crossreflink_nonascii_charlimit.docx
new file mode 100644
index 000000000000..d15739971c23
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf125298_crossreflink_nonascii_charlimit.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index ff2030df8b5f..b056ad16071d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -277,10 +277,35 @@ DECLARE_OOXMLEXPORT_TEST(testTdf113483, "tdf113483_crossreflink_nonascii_bookmar
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
+ // check whether test file keeps non-ascii values or not
assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:bookmarkStart[1]", "name", OUString::fromUtf8("Els\u0151"));
assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[5]/w:r[2]/w:instrText[1]", OUString::fromUtf8(" REF Els\u0151 \\h "));
}
+//tdf#125298: fix charlimit restrictions in bookmarknames and field references if they contain non-ascii characters
+DECLARE_OOXMLEXPORT_TEST(testTdf125298, "tdf125298_crossreflink_nonascii_charlimit.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ // check whether test file keeps non-ascii values or not
+ OUString bookmarkName1 = getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:bookmarkStart[1]", "name");
+ CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8("\u00e1rv\u00edzt\u0171r\u0151_t\u00fck\u00f6rf\u00far\u00f3g\u00e9p"), bookmarkName1);
+
+ OUString bookmarkName2 = getXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:bookmarkStart[1]", "name");
+ CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8("\u00e91\u00e12\u01713\u01514\u00fa5\u00f66\u00fc7\u00f38\u00ed9"), bookmarkName2);
+ OUString fieldName1 = getXPathContent(pXmlDoc, "/w:document/w:body/w:p[5]/w:r[2]/w:instrText[1]");
+ OUString expectedFieldName1(" REF ");
+ expectedFieldName1 += bookmarkName1;
+ expectedFieldName1 += " \\h ";
+ CPPUNIT_ASSERT_EQUAL(expectedFieldName1, fieldName1);
+ OUString fieldName2 = getXPathContent(pXmlDoc, "/w:document/w:body/w:p[7]/w:r[2]/w:instrText[1]");
+ OUString expectedFieldName2(" REF ");
+ expectedFieldName2 += bookmarkName2;
+ expectedFieldName2 += " \\h ";
+ CPPUNIT_ASSERT_EQUAL(expectedFieldName2, fieldName2);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */