summaryrefslogtreecommitdiff
path: root/vcl/qa
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2018-04-29 01:00:20 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2018-04-29 10:48:04 +0200
commitd33722235957d7cec3019606ddf5a4d221c2bb6c (patch)
treeae27caf1d9a53e2294445b736c73cecc58cb1bdf /vcl/qa
parentd78257b39d76077d8ef1659e32553430a6440fd0 (diff)
tdf66597: Fix a typo in detecting cluster start
Looks like I accidentally broke the LTR case while iterating on commit c688b01d9102832226251fc84045408afe392459 and the existing test tested only the RTL case. Add a test for LTR to catch this in the future. Change-Id: Ie0bbde44fcd94c8e1b299f14fa0860e98977e850 Reviewed-on: https://gerrit.libreoffice.org/53615 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
Diffstat (limited to 'vcl/qa')
-rw-r--r--vcl/qa/cppunit/pdfexport/data/tdf66597-3.odtbin0 -> 8251 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx85
2 files changed, 84 insertions, 1 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf66597-3.odt b/vcl/qa/cppunit/pdfexport/data/tdf66597-3.odt
new file mode 100644
index 000000000000..6db91fe81bd0
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf66597-3.odt
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index d280f561fc64..e1a7b711a29d 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -79,8 +79,10 @@ public:
void testTdf115117_2a();
/// Test writing ToUnicode CMAP for doubly encoded glyphs.
void testTdf66597_1();
- /// Test writing ActualText for many to one glyph to Unicode mapping.
+ /// Test writing ActualText for RTL many to one glyph to Unicode mapping.
void testTdf66597_2();
+ /// Test writing ActualText for LTR many to one glyph to Unicode mapping.
+ void testTdf66597_3();
#endif
#endif
@@ -107,6 +109,7 @@ public:
CPPUNIT_TEST(testTdf115117_2a);
CPPUNIT_TEST(testTdf66597_1);
CPPUNIT_TEST(testTdf66597_2);
+ CPPUNIT_TEST(testTdf66597_3);
#endif
#endif
CPPUNIT_TEST_SUITE_END();
@@ -1170,6 +1173,86 @@ void PdfExportTest::testTdf66597_2()
}
#endif
}
+
+// This requires Gentium Basic font, if it is missing the test will fail.
+void PdfExportTest::testTdf66597_3()
+{
+ vcl::filter::PDFDocument aDocument;
+ load("tdf66597-3.odt", aDocument);
+
+ {
+ // Get access to ToUnicode of the first font
+ vcl::filter::PDFObjectElement* pToUnicode = nullptr;
+ for (const auto& aElement : aDocument.GetElements())
+ {
+ auto pObject = dynamic_cast<vcl::filter::PDFObjectElement*>(aElement.get());
+ if (!pObject)
+ continue;
+ auto pType = dynamic_cast<vcl::filter::PDFNameElement*>(pObject->Lookup("Type"));
+ if (pType && pType->GetValue() == "Font")
+ {
+ auto pName = dynamic_cast<vcl::filter::PDFNameElement*>(pObject->Lookup("BaseFont"));
+ auto aName = pName->GetValue().copy(7); // skip the subset id
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected font name", OString("GentiumBasic"), aName);
+
+ auto pToUnicodeRef = dynamic_cast<vcl::filter::PDFReferenceElement*>(pObject->Lookup("ToUnicode"));
+ CPPUNIT_ASSERT(pToUnicodeRef);
+ pToUnicode = pToUnicodeRef->LookupObject();
+ break;
+ }
+ }
+
+ CPPUNIT_ASSERT(pToUnicode);
+ auto pStream = pToUnicode->GetStream();
+ CPPUNIT_ASSERT(pStream);
+ SvMemoryStream aObjectStream;
+ ZCodec aZCodec;
+ aZCodec.BeginCompression();
+ pStream->GetMemory().Seek(0);
+ aZCodec.Decompress(pStream->GetMemory(), aObjectStream);
+ CPPUNIT_ASSERT(aZCodec.EndCompression());
+ aObjectStream.Seek(0);
+ std::string aCmap("2 beginbfchar\n"
+ "<01> <1ECB0331030B>\n"
+ "<05> <0020>\n"
+ "endbfchar");
+ std::string aData(static_cast<const char*>(aObjectStream.GetData()), aObjectStream.GetSize());
+ auto nPos = aData.find(aCmap);
+ CPPUNIT_ASSERT(nPos != std::string::npos);
+ }
+
+ {
+ auto aPages = aDocument.GetPages();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPages.size());
+ // Get page contents and stream.
+ auto pContents = aPages[0]->LookupObject("Contents");
+ CPPUNIT_ASSERT(pContents);
+ auto pStream = pContents->GetStream();
+ CPPUNIT_ASSERT(pStream);
+ auto& rObjectStream = pStream->GetMemory();
+
+ // Uncompress the stream.
+ SvMemoryStream aUncompressed;
+ ZCodec aZCodec;
+ aZCodec.BeginCompression();
+ rObjectStream.Seek(0);
+ aZCodec.Decompress(rObjectStream, aUncompressed);
+ CPPUNIT_ASSERT(aZCodec.EndCompression());
+
+ // Make sure the expected ActualText is present.
+ std::string aData(static_cast<const char*>(aUncompressed.GetData()), aUncompressed.GetSize());
+
+ std::string aActualText("/Span<</ActualText<FEFF1ECB0331030B>>>");
+ size_t nCount = 0;
+ size_t nPos = 0;
+ while ((nPos = aData.find(aActualText, nPos)) != std::string::npos)
+ {
+ nCount++;
+ nPos += aActualText.length();
+ }
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of ActualText entries does not match!", static_cast<size_t>(4), nCount);
+ }
+}
#endif
#endif