diff options
author | Kevin Suo <suokunlong@126.com> | 2022-11-19 19:01:04 +0800 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-11-20 12:00:08 +0100 |
commit | bc48dbe08db537f41e42839a0493317298606413 (patch) | |
tree | 0d489c4a1a30572a661d0502bdf97dacc6a19dc5 | |
parent | 346cda683763aa352cf67a035340e48133790f7f (diff) |
sdext.pdfimport: Use string() in xpath for testTdf104597_textrun
...and remove the TODO comments.
Also, comment out the test for string ٱلسََّل which is related to tdf#152083 and will be fixed in a separate commit.
Change-Id: I075145be1ff58c16e976c710fbf8f55fc6752af1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142962
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sdext/source/pdfimport/test/testdocs/testTdf152083_rtl-ligatures.pdf | bin | 0 -> 23760 bytes | |||
-rw-r--r-- | sdext/source/pdfimport/test/tests.cxx | 54 |
2 files changed, 28 insertions, 26 deletions
diff --git a/sdext/source/pdfimport/test/testdocs/testTdf152083_rtl-ligatures.pdf b/sdext/source/pdfimport/test/testdocs/testTdf152083_rtl-ligatures.pdf Binary files differnew file mode 100644 index 000000000000..635004c2e302 --- /dev/null +++ b/sdext/source/pdfimport/test/testdocs/testTdf152083_rtl-ligatures.pdf diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index 786815941445..c199c2cc4547 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -796,28 +796,33 @@ namespace xmlDocUniquePtr pXmlDoc(xmlParseDoc(reinterpret_cast<xmlChar const *>(aOutput.getStr()))); // Test for امُ عَلَيْكَ - // TODO: How to get the "عَلَيْكَ" in xpath, as shown after the <text:s> tag? - OString xpath = "//draw:frame[@draw:transform='matrix(917.222222222222 0 0 917.222222222222 14821.9583333333 2159.23861112778)']/draw:text-box/text:p/text:span"; - OUString sContent = getXPathContent(pXmlDoc, xpath); // u"\nا\nُ\nم\n" - CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"اُم"), sContent.replaceAll("\n", "")); - - // Test for ٱلَّسَل . It appears in the 3rd frame, i.e. after the امُ عَلَيْكَ which is in the 2nd frame (from left to right) - // thus these two frames together appear as ٱلَّسَل امُ عَلَيْكَ in Draw. - xpath = "//draw:frame[@draw:transform='matrix(917.222222222222 0 0 917.222222222222 17420.1666666667 2159.23861112778)']/draw:text-box/text:p/text:span"; + OString xpath = "string(//draw:frame[@draw:transform='matrix(917.222222222222 0 0 917.222222222222 14821.9583333333 2159.23861112778)']/draw:text-box/text:p/text:span)"; + OUString sContent = getXPathContent(pXmlDoc, xpath); + CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"اُم َعَلْيَك"), sContent.replaceAll("\n\n", " ").replaceAll("\n", "")); + + // Test for ٱلسََّل . It appears in the 3rd frame, i.e. after the امُ عَلَيْكَ which is in the 2nd frame (from left to right) + // thus these two frames together appear as ٱلسََّل امُ عَلَيْكَ in Draw. + // FIXME: Should be ٱلسَّلَامُ عَلَيْكَ (i.e. the two text frames should be merged into one so that the ل and the ا will show as لَا rather than ل ا) + // Note: this is commented due to ٱلسََّل is currently shown as ٱلَّسَل and will be fixed in a separate commit. + //xpath = "string(//draw:frame[@draw:transform='matrix(917.222222222222 0 0 917.222222222222 17420.1666666667 2159.23861112778)']/draw:text-box/text:p/text:span)"; + //sContent = getXPathContent(pXmlDoc, xpath); + //CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"ٱلسََّل"), sContent.replaceAll("\n\n", " ").replaceAll("\n", "")); + + // Test for "LibreOffice RTL" + xpath = "string(//draw:frame[@draw:transform='matrix(917.222222222222 0 0 917.222222222222 12779.375 5121.79583335)']/draw:text-box/text:p/text:span)"; sContent = getXPathContent(pXmlDoc, xpath); - CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"ٱلَّسَل"), sContent.replaceAll("\n", "")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"LibreOffice RTL"), sContent.replaceAll("\n\n", " ").replaceAll("\n", "")); - // Test for "LibreOffice LTR" - // TODO: How to get the "LTR" as shown after the <text:s> tag? - xpath = "//draw:frame[@draw:transform='matrix(917.222222222222 0 0 917.222222222222 12779.375 5121.79583335)']/draw:text-box/text:p/text:span"; + // Test for "LibreOffice LTR (test)" + xpath = "string(//draw:frame[last()-1]/draw:text-box/text:p/text:span[last()])"; sContent = getXPathContent(pXmlDoc, xpath); - CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"LibreOffice"), sContent.replaceAll("\n", "")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"LibreOffice LTR (test)"), sContent.replaceAll("\n\n", " ").replaceAll("\n", "")); /* Test for Chinese characters */ // Use last() instead of matrix below, because the matrix may be different on different OS due to fallback of Chinese fonts. - xpath = "//draw:frame[last()]/draw:text-box/text:p/text:span"; + xpath = "string(//draw:frame[last()]/draw:text-box/text:p/text:span)"; sContent = getXPathContent(pXmlDoc, xpath); - CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"中文测试,中文"), sContent.replaceAll("\n", "")); + CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput.getStr(), OUString(u"中文测试,中文"), sContent.replaceAll("\n\n", " ").replaceAll("\n", "")); // Test pdf text run in the Writer PDF import filter xAdaptor->setTreeVisitorFactory(createWriterTreeVisitorFactory()); @@ -825,19 +830,16 @@ namespace xAdaptor->odfConvert(m_directories.getURLFromSrc(u"/sdext/source/pdfimport/test/testdocs/tdf104597_textrun.pdf"), new OutputWrapString(aOutput2), nullptr); - // FIXME: the same draw:frame is duplicated in the xml output, - // e.g. there are two draw:frame with draw:z-index="3" with the same content. xmlDocUniquePtr pXmlDoc2(xmlParseDoc(reinterpret_cast<xmlChar const *>(aOutput2.getStr()))); - xpath = "//draw:frame[@draw:z-index='3'][1]/draw:text-box/text:p/text:span"; - sContent = getXPathContent(pXmlDoc2, xpath).replaceAll("\n", ""); + xpath = "string(//draw:frame[@draw:z-index='3'][1]/draw:text-box/text:p/text:span)"; + sContent = getXPathContent(pXmlDoc2, xpath).replaceAll("\n\n", " ").replaceAll("\n", ""); CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput2.getStr(), OUString(u"ٱلَّسَل"), sContent); - xpath = "//draw:frame[@draw:z-index='2'][1]/draw:text-box/text:p/text:span"; - sContent = getXPathContent(pXmlDoc2, xpath).replaceAll("\n", ""); - // need to use اُم rather than اُم َعَلْيَك here, because this node may be different on different systems - CPPUNIT_ASSERT_EQUAL(true, sContent.match(u"اُم")); - xpath = "//draw:frame[last()]/draw:text-box/text:p/text:span"; - sContent = getXPathContent(pXmlDoc2, xpath); - CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput2.getStr(), OUString(u"中文测试,中文"), sContent.replaceAll("\n", "")); + xpath = "string(//draw:frame[@draw:z-index='2'][1]/draw:text-box/text:p/text:span)"; + sContent = getXPathContent(pXmlDoc2, xpath).replaceAll("\n\n", " ").replaceAll("\n", ""); + CPPUNIT_ASSERT_EQUAL(true, sContent.match(u"اُم َعَلْيَك")); + xpath = "string(//draw:frame[last()]/draw:text-box/text:p/text:span)"; + sContent = getXPathContent(pXmlDoc2, xpath).replaceAll("\n\n", " ").replaceAll("\n", ""); + CPPUNIT_ASSERT_EQUAL_MESSAGE(aOutput2.getStr(), OUString(u"中文测试,中文"), sContent); #endif } |