summaryrefslogtreecommitdiff
path: root/vcl/qa
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-06-28 10:12:17 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-06-29 14:35:37 +0200
commit440cb3fb80d9fd356871eac410b9797f23433722 (patch)
treed9c21ba1bfaeef1a5a4f895af72d94b5d31dc82b /vcl/qa
parent34745b022d0c58e262c7ad3bfd103e769b2cdd18 (diff)
pdf: add PDFiumTextPage and PDFiumPageObject + test
Also use it in ImpSdrPdfImport. Change-Id: I6d353ef60d036c3516448e64a50b25a9befd5db8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97364 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r--vcl/qa/cppunit/PDFiumLibraryTest.cxx37
1 files changed, 36 insertions, 1 deletions
diff --git a/vcl/qa/cppunit/PDFiumLibraryTest.cxx b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
index 61b3981731f6..9c0c92607b14 100644
--- a/vcl/qa/cppunit/PDFiumLibraryTest.cxx
+++ b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
@@ -35,6 +35,7 @@ class PDFiumLibraryTest : public test::BootstrapFixtureBase
void testDocument();
void testPages();
+ void testPageObjects();
void testAnnotationsMadeInEvince();
void testAnnotationsMadeInAcrobat();
void testTools();
@@ -42,6 +43,7 @@ class PDFiumLibraryTest : public test::BootstrapFixtureBase
CPPUNIT_TEST_SUITE(PDFiumLibraryTest);
CPPUNIT_TEST(testDocument);
CPPUNIT_TEST(testPages);
+ CPPUNIT_TEST(testPageObjects);
CPPUNIT_TEST(testAnnotationsMadeInEvince);
CPPUNIT_TEST(testAnnotationsMadeInAcrobat);
CPPUNIT_TEST(testTools);
@@ -74,12 +76,35 @@ void PDFiumLibraryTest::testDocument()
auto aSize = pDocument->getPageSize(0);
CPPUNIT_ASSERT_EQUAL(612.0, aSize.getX());
CPPUNIT_ASSERT_EQUAL(792.0, aSize.getY());
+}
+
+void PDFiumLibraryTest::testPages()
+{
+ OUString aURL = getFullUrl("Pangram.pdf");
+ SvFileStream aStream(aURL, StreamMode::READ);
+ GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+ Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
+ aGraphic.makeAvailable();
+
+ auto pVectorGraphicData = aGraphic.getVectorGraphicData();
+ CPPUNIT_ASSERT(pVectorGraphicData);
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+
+ const void* pData = pVectorGraphicData->getVectorGraphicDataArray().getConstArray();
+ int nLength = pVectorGraphicData->getVectorGraphicDataArrayLength();
+
+ auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+ auto pDocument = pPdfium->openDocument(pData, nLength);
+ CPPUNIT_ASSERT(pDocument);
+
+ CPPUNIT_ASSERT_EQUAL(1, pDocument->getPageCount());
auto pPage = pDocument->openPage(0);
CPPUNIT_ASSERT(pPage);
}
-void PDFiumLibraryTest::testPages()
+void PDFiumLibraryTest::testPageObjects()
{
OUString aURL = getFullUrl("Pangram.pdf");
SvFileStream aStream(aURL, StreamMode::READ);
@@ -103,6 +128,16 @@ void PDFiumLibraryTest::testPages()
auto pPage = pDocument->openPage(0);
CPPUNIT_ASSERT(pPage);
+
+ CPPUNIT_ASSERT_EQUAL(12, pPage->getObjectCount());
+
+ auto pPageObject = pPage->getObject(0);
+ auto pTextPage = pPage->getTextPage();
+
+ CPPUNIT_ASSERT_EQUAL(1, pPageObject->getType());
+ CPPUNIT_ASSERT_EQUAL(OUString("The quick, brown fox jumps over a lazy dog. DJs flock by when "
+ "MTV ax quiz prog. Junk MTV quiz "),
+ pPageObject->getText(pTextPage));
}
void PDFiumLibraryTest::testAnnotationsMadeInEvince()