diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-09-24 09:44:46 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-09-24 10:56:34 +0200 |
commit | 13251ea5da9a1761740cc65ce6c50c897f12c698 (patch) | |
tree | 68312b9c99e5fac38894c34a596852fc3d10daed /vcl/qa | |
parent | 1e0ac737e620a6a3e5c54021c77f299e89e3a9ef (diff) |
More fixes of PDFium-provided strings, in test code
...similar to 08705b75ff8b5a10dc039a9aa1042e04a281729a "These PDFium-provided
strings are always in UTF-16LE".
Change-Id: Ic2945470db12a50e90b0feb3bbc6b63449fc39ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103289
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 96dce4aff82a..94d583a0c52f 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -29,6 +29,7 @@ #include <comphelper/scopeguard.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> +#include <osl/endian.h> #include <test/bootstrapfixture.hxx> #include <unotest/macros_test.hxx> #include <unotools/mediadescriptor.hxx> @@ -1700,6 +1701,12 @@ void PdfExportTest::testTdf115262() unsigned long nTextSize = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 0); std::vector<sal_Unicode> aText(nTextSize); FPDFTextObj_GetText(pPageObject, pTextPage, aText.data(), nTextSize); +#if defined OSL_BIGENDIAN + // The data returned by FPDFTextObj_GetText is documented to always be UTF-16LE: + for (auto & j: aText) { + j = OSL_SWAPWORD(j); + } +#endif OUString sText(aText.data(), nTextSize / 2 - 1); if (sText == "400") nRowTop = fTop; @@ -1735,6 +1742,12 @@ void PdfExportTest::testTdf121962() unsigned long nTextSize = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 0); std::vector<sal_Unicode> aText(nTextSize); FPDFTextObj_GetText(pPageObject, pTextPage, aText.data(), nTextSize); +#if defined OSL_BIGENDIAN + // The data returned by FPDFTextObj_GetText is documented to always be UTF-16LE: + for (auto & j: aText) { + j = OSL_SWAPWORD(j); + } +#endif OUString sText(aText.data(), nTextSize / 2 - 1); CPPUNIT_ASSERT(sText != "** Expression is faulty **"); } @@ -1767,6 +1780,12 @@ void PdfExportTest::testTdf115967() unsigned long nTextSize = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 2); std::vector<sal_Unicode> aText(nTextSize); FPDFTextObj_GetText(pPageObject, pTextPage, aText.data(), nTextSize); +#if defined OSL_BIGENDIAN + // The data returned by FPDFTextObj_GetText is documented to always be UTF-16LE: + for (auto & j: aText) { + j = OSL_SWAPWORD(j); + } +#endif OUString sChar(aText.data(), nTextSize / 2 - 1); sText += sChar.trim(); } @@ -2298,8 +2317,16 @@ void PdfExportTest::testFormFontName() CPPUNIT_ASSERT(FPDFAnnot_HasKey(pAnnot.get(), "DA")); CPPUNIT_ASSERT_EQUAL(FPDF_OBJECT_STRING, FPDFAnnot_GetValueType(pAnnot.get(), "DA")); size_t nDALength = FPDFAnnot_GetStringValue(pAnnot.get(), "DA", nullptr, 0); - std::vector<FPDF_WCHAR> aDABuf(nDALength); - FPDFAnnot_GetStringValue(pAnnot.get(), "DA", aDABuf.data(), nDALength); + CPPUNIT_ASSERT_EQUAL(std::size_t(0), nDALength % 2); + std::vector<sal_Unicode> aDABuf(nDALength / 2); + FPDFAnnot_GetStringValue( + pAnnot.get(), "DA", reinterpret_cast<FPDF_WCHAR *>(aDABuf.data()), nDALength); +#if defined OSL_BIGENDIAN + // The data returned by FPDFAnnot_GetStringValue is documented to always be UTF-16LE: + for (auto & i: aDABuf) { + i = OSL_SWAPWORD(i); + } +#endif OUString aDA(reinterpret_cast<sal_Unicode*>(aDABuf.data())); // Without the accompanying fix in place, this test would have failed with: |