diff options
author | Michael Warner <michael.warner.ut+libreoffice@gmail.com> | 2021-05-11 09:22:27 -0400 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-06-23 11:21:00 +0200 |
commit | 648e4106cc002ff5b8184a8c104f93cb06e4b540 (patch) | |
tree | 9b0052d02699d483437301a5a743dcdf54d6b5c7 /sdext | |
parent | 388d52a9193d89058f27b3efd48ab3cd5dedf0a7 (diff) |
tdf#141709: Use poppler_data
Bundle the files from poppler_data and provide the path to them to
poppler when the bundled poppler library is used.
Change-Id: I13a2ef861303a0be17aa0a861ef8ac96ed8a93be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117523
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sdext')
-rw-r--r-- | sdext/Executable_xpdfimport.mk | 7 | ||||
-rw-r--r-- | sdext/source/pdfimport/test/testTdf141709.pdf | bin | 0 -> 11119 bytes | |||
-rw-r--r-- | sdext/source/pdfimport/test/tests.cxx | 29 | ||||
-rw-r--r-- | sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx | 23 |
4 files changed, 57 insertions, 2 deletions
diff --git a/sdext/Executable_xpdfimport.mk b/sdext/Executable_xpdfimport.mk index 360358d450d2..495671a4ecae 100644 --- a/sdext/Executable_xpdfimport.mk +++ b/sdext/Executable_xpdfimport.mk @@ -24,4 +24,11 @@ $(eval $(call gb_Executable_add_exception_objects,xpdfimport,\ $(eval $(call gb_Executable_add_default_nativeres,xpdfimport)) +ifneq ($(SYSTEM_POPPLER),) +# Using system poppler +$(eval $(call gb_Executable_add_defs,xpdfimport,\ + -DSYSTEM_POPPLER \ +)) +endif + # vim:set noet sw=4 ts=4: diff --git a/sdext/source/pdfimport/test/testTdf141709.pdf b/sdext/source/pdfimport/test/testTdf141709.pdf Binary files differnew file mode 100644 index 000000000000..3198782faa73 --- /dev/null +++ b/sdext/source/pdfimport/test/testTdf141709.pdf diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index 6caa07cb2354..7611511aa92a 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -549,6 +549,34 @@ namespace #endif } + void testTdf141709() + { +#if HAVE_FEATURE_POPPLER + rtl::Reference<pdfi::PDFIRawAdaptor> xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext())); + xAdaptor->setTreeVisitorFactory(createDrawTreeVisitorFactory()); + + OString aOutput; + CPPUNIT_ASSERT_MESSAGE("Exporting to ODF", + xAdaptor->odfConvert(m_directories.getURLFromSrc(u"/sdext/source/pdfimport/test/testTdf141709.pdf"), + new OutputWrapString(aOutput), + nullptr)); + std::cout << aOutput << std::endl; + // This ensures that the imported text contains all of the characters + CPPUNIT_ASSERT(aOutput.indexOf("敏") != -1); + CPPUNIT_ASSERT(aOutput.indexOf("捷") != -1); + CPPUNIT_ASSERT(aOutput.indexOf("的") != -1); + CPPUNIT_ASSERT(aOutput.indexOf("狐") != -1); + CPPUNIT_ASSERT(aOutput.indexOf("狸") != -1); + CPPUNIT_ASSERT(aOutput.indexOf("跨") != -1); + CPPUNIT_ASSERT(aOutput.indexOf("过") != -1); + CPPUNIT_ASSERT(aOutput.indexOf("慵") != -1); + CPPUNIT_ASSERT(aOutput.indexOf("懒") != -1); + CPPUNIT_ASSERT(aOutput.indexOf("的") != -1); + CPPUNIT_ASSERT(aOutput.indexOf("狗") != -1); + CPPUNIT_ASSERT(aOutput.indexOf("。") != -1); +#endif + } + CPPUNIT_TEST_SUITE(PDFITest); CPPUNIT_TEST(testXPDFParser); CPPUNIT_TEST(testOdfWriterExport); @@ -556,6 +584,7 @@ namespace CPPUNIT_TEST(testTdf96993); CPPUNIT_TEST(testTdf98421); CPPUNIT_TEST(testTdf105536); + CPPUNIT_TEST(testTdf141709); CPPUNIT_TEST_SUITE_END(); }; diff --git a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx index b1a54bd09c5f..ad6320139473 100644 --- a/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx @@ -22,6 +22,11 @@ # include <io.h> # include <fcntl.h> /*_O_BINARY*/ #endif +#ifndef SYSTEM_POPPLER +#include <string> // std::string +#include <cstddef> // std::size_t +#include <config_folders.h> //LIBO_SHARE_FOLDER +#endif FILE* g_binary_out=stderr; @@ -67,11 +72,25 @@ int main(int argc, char **argv) ++k; } + /* Get data directory location */ +#ifdef SYSTEM_POPPLER + const char* datadir = nullptr; +#else + /* Creates an absolute path to the poppler_data directory, by taking the path + * to the xpdfimport executable (provided in argv[0], and concatenating a + * relative path to the poppler_data directory from the program directory. */ + const std::string execPath = argv[0]; + const std::size_t filenameStartPos = execPath.find_last_of("/\\")+1; + const std::string programPath = execPath.substr(0,filenameStartPos); + const std::string popplerDataPath = programPath + "../" LIBO_SHARE_FOLDER "/xpdfimport/poppler_data"; + const char* datadir = popplerDataPath.c_str(); +#endif + // read config file #if POPPLER_CHECK_VERSION(0, 83, 0) - globalParams = std::make_unique<GlobalParams>(); + globalParams = std::make_unique<GlobalParams>(datadir); #else - globalParams = new GlobalParams(); + globalParams = new GlobalParams(datadir); #endif globalParams->setErrQuiet(true); #if defined(_MSC_VER) |