sd/qa/unit/data/sample.pdf |binary sd/qa/unit/export-tests.cxx | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
New commits: commit b93f880259bdf93083007b854b9ff197b61f7fbd Author: Caolán McNamara <[email protected]> AuthorDate: Mon Sep 15 14:37:56 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Oct 2 15:36:00 2025 +0200 add basic test of exploding pdf Change-Id: I96c070a072af45c3b361f34d769832a5f047d748 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190975 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191769 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sd/qa/unit/data/sample.pdf b/sd/qa/unit/data/sample.pdf new file mode 100644 index 000000000000..dcd1283df1b6 Binary files /dev/null and b/sd/qa/unit/data/sample.pdf differ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 7369e4fe9bd0..3442a0873142 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -18,10 +18,12 @@ #include <editeng/outlobj.hxx> #include <editeng/colritem.hxx> #include <editeng/eeitem.hxx> +#include <osl/process.h> #include <unotools/saveopt.hxx> #include <svx/svdotext.hxx> #include <svx/svdograf.hxx> +#include <svx/svdogrp.hxx> #include <svx/svdomedia.hxx> #include <rtl/ustring.hxx> @@ -55,6 +57,25 @@ public: { } + struct UsePdfium + { + // We need to enable PDFium import (and make sure to disable after the test) + bool bResetEnvVar = false; + UsePdfium() + { + if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr) + { + bResetEnvVar = true; + osl_setEnvironment(u"LO_IMPORT_USE_PDFIUM"_ustr.pData, u"1"_ustr.pData); + } + } + ~UsePdfium() + { + if (bResetEnvVar) + osl_clearEnvironment(u"LO_IMPORT_USE_PDFIUM"_ustr.pData); + }; + }; + protected: uno::Reference<awt::XBitmap> getBitmapFromTable(OUString const& rName); }; @@ -987,6 +1008,29 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testEmbeddedPdf) CPPUNIT_ASSERT(xGraphic.is()); } +CPPUNIT_TEST_FIXTURE(SdExportTest, testExplodedPdf) +{ + auto pPdfium = vcl::pdf::PDFiumLibrary::get(); + if (!pPdfium) + return; + UsePdfium aGuard; + + loadFromFile(u"sample.pdf"); + + setFilterOptions("{\"DecomposePDF\":{\"type\":\"boolean\",\"value\":\"true\"}}"); + setImportFilterName(u"OpenDocument Drawing Flat XML"_ustr); + saveAndReload(u"OpenDocument Drawing Flat XML"_ustr); + + const SdrPage* pPage = GetPage(1); + + const SdrObject* pObj = pPage->GetObj(0); + CPPUNIT_ASSERT(pObj); + const SdrObjGroup* pObjGroup = dynamic_cast<const SdrObjGroup*>(pObj); + CPPUNIT_ASSERT(pObjGroup); + // Should have exploded to 7 shapes, would be just 1 if not exploded + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), pObjGroup->GetObjCount()); +} + CPPUNIT_TEST_FIXTURE(SdExportTest, testEmbeddedText) { createSdDrawDoc("objectwithtext.fodg");
