From 8e0d2f95db873c4619f089900b41fd558c5c4c4b Mon Sep 17 00:00:00 2001 From: triallax Date: Sun, 17 Sep 2023 21:52:28 +0100 Subject: [PATCH 1/8] poppler: update to 23.12.0. --- common/shlibs | 2 +- srcpkgs/poppler/template | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/common/shlibs b/common/shlibs index 66d0045a2898f..393b7436cefa2 100644 --- a/common/shlibs +++ b/common/shlibs @@ -345,7 +345,7 @@ libMagickCore-7.Q16HDRI.so.10 libmagick-7.1.0.10_1 libMagickWand-7.Q16HDRI.so.10 libmagick-7.1.0.10_1 libMagick++-7.Q16HDRI.so.5 libmagick-7.0.11.1_1 libltdl.so.7 libltdl-2.2.6_1 -libpoppler.so.130 libpoppler-23.08.0_1 +libpoppler.so.133 libpoppler-23.12.0_1 libpoppler-glib.so.8 poppler-glib-0.18.2_1 libpoppler-cpp.so.0 poppler-cpp-0.18.2_1 libpoppler-qt5.so.1 poppler-qt5-0.31.0_1 diff --git a/srcpkgs/poppler/template b/srcpkgs/poppler/template index 2be3e5ab35e47..456e5c2fecb22 100644 --- a/srcpkgs/poppler/template +++ b/srcpkgs/poppler/template @@ -1,18 +1,17 @@ # Template file for 'poppler' # # THIS PKG MUST BE SYNCHRONIZED WITH "srcpkgs/poppler-qt5". -# -# Revbump libreoffice on SO version bumps. pkgname=poppler -version=23.08.0 +version=23.12.0 revision=1 -_testVersion=920c89f8f43bdfe8966c8e397e7f67f5302e9435 +_testVersion=400f3ff05b2b1c0ae17797a0bd50e75e35c1f1b1 create_wrksrc=yes build_style=cmake build_helper="gir" configure_args="-DENABLE_UNSTABLE_API_ABI_HEADERS=ON -DENABLE_CPP=ON -DENABLE_GLIB=ON -DENABLE_GOBJECT_INTROSPECTION=$(vopt_if gir ON OFF) - -DENABLE_QT5=OFF -DENABLE_UTILS=ON -DENABLE_BOOST=$(vopt_if boost ON OFF) + -DENABLE_QT5=OFF -DENABLE_QT6=OFF -DENABLE_UTILS=ON + -DENABLE_BOOST=$(vopt_if boost ON OFF) -DTESTDATADIR='${XBPS_BUILDDIR}/poppler-${version}/testdatadir'" hostmakedepends="pkg-config glib-devel" makedepends="libpng-devel libglib-devel cairo-devel tiff-devel lcms2-devel @@ -25,8 +24,8 @@ homepage="https://poppler.freedesktop.org" changelog="https://gitlab.freedesktop.org/poppler/poppler/-/raw/master/NEWS" distfiles="https://poppler.freedesktop.org/poppler-${version}.tar.xz https://gitlab.freedesktop.org/poppler/test/-/archive/${_testVersion}/test-${_testVersion}.tar.gz" -checksum="4a4bf7fc903b9f1a2ab7d04b7c5d8220db9bc6261cc73fdb9a826dc272f49aa8 - ca35f168a18038a2d817ea30d6c7b4ab8294a40a5f5950f3c2a15183ba08c900" +checksum="beba398c9d37a9b6d02486496635e08f1df3d437cfe61dab2593f47c4d14cdbb + 0d850a1d06944671c991be6822b7146ade401b06aad560ff39b254a028074525" build_options="gir boost" build_options_default="gir boost" From 7fde63053384f7c48fece7447f976d2597653984 Mon Sep 17 00:00:00 2001 From: triallax Date: Sun, 17 Sep 2023 21:52:28 +0100 Subject: [PATCH 2/8] poppler-qt5: update to 23.12.0. --- srcpkgs/poppler-qt5/template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srcpkgs/poppler-qt5/template b/srcpkgs/poppler-qt5/template index 2a48ed659920e..8dc1d149bf0c5 100644 --- a/srcpkgs/poppler-qt5/template +++ b/srcpkgs/poppler-qt5/template @@ -4,7 +4,7 @@ # IT IS SPLIT TO AVOID A CYCLIC DEPENDENCY: qt5 -> cups -> poppler -> qt5. # pkgname=poppler-qt5 -version=23.08.0 +version=23.12.0 revision=1 build_style=cmake configure_args="-DENABLE_UNSTABLE_API_ABI_HEADERS=ON -DENABLE_GLIB=OFF @@ -21,7 +21,7 @@ license="GPL-2.0-or-later, GPL-3.0-or-later" homepage="https://poppler.freedesktop.org" changelog="https://gitlab.freedesktop.org/poppler/poppler/-/raw/master/NEWS" distfiles="https://poppler.freedesktop.org/poppler-${version}.tar.xz" -checksum=4a4bf7fc903b9f1a2ab7d04b7c5d8220db9bc6261cc73fdb9a826dc272f49aa8 +checksum=beba398c9d37a9b6d02486496635e08f1df3d437cfe61dab2593f47c4d14cdbb # fails to find a bunch of files make_check=no From 60324c04159585411e3fd10f578b4f966d8e4e06 Mon Sep 17 00:00:00 2001 From: Mohammed Anas Date: Tue, 12 Dec 2023 11:48:03 +0000 Subject: [PATCH 3/8] inkscape: revbump for poppler-23.12.0. --- srcpkgs/inkscape/template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcpkgs/inkscape/template b/srcpkgs/inkscape/template index 916822078cd27..a23bf4e87e61c 100644 --- a/srcpkgs/inkscape/template +++ b/srcpkgs/inkscape/template @@ -1,7 +1,7 @@ # Template file for 'inkscape' pkgname=inkscape version=1.3.2 -revision=1 +revision=2 build_style=cmake make_check_target="check" hostmakedepends="automake gettext glib-devel intltool libgraphicsmagick-devel From 9bf5d2641b2933c1409a721e910b41d0fb133475 Mon Sep 17 00:00:00 2001 From: Mohammed Anas Date: Tue, 12 Dec 2023 11:48:03 +0000 Subject: [PATCH 4/8] ipe: revbump for poppler-23.12.0. --- srcpkgs/ipe/template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcpkgs/ipe/template b/srcpkgs/ipe/template index 65b92385af994..06347934d9897 100644 --- a/srcpkgs/ipe/template +++ b/srcpkgs/ipe/template @@ -1,7 +1,7 @@ # Template file for 'ipe' pkgname=ipe version=7.2.26 -revision=10 +revision=11 _tools_commit=v7.2.24.1 create_wrksrc=yes hostmakedepends="pkg-config doxygen qt5-qmake qt5-tools qt5-host-tools" From 991ecd0a466d6b94fede8b71402c6137df017cef Mon Sep 17 00:00:00 2001 From: Mohammed Anas Date: Tue, 12 Dec 2023 11:48:03 +0000 Subject: [PATCH 5/8] kitinerary: revbump for poppler-23.12.0. --- srcpkgs/kitinerary/template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcpkgs/kitinerary/template b/srcpkgs/kitinerary/template index 31236a166ef2c..5575e4dfb57f5 100644 --- a/srcpkgs/kitinerary/template +++ b/srcpkgs/kitinerary/template @@ -1,7 +1,7 @@ # Template file for 'kitinerary' pkgname=kitinerary version=23.08.0 -revision=1 +revision=2 build_style=cmake hostmakedepends="extra-cmake-modules gettext kcoreaddons pkg-config qt5-host-tools qt5-qmake qt5-tools-devel" From d0632ce4b2a7dd01c3b422581c45d217d311102c Mon Sep 17 00:00:00 2001 From: Mohammed Anas Date: Tue, 12 Dec 2023 11:48:03 +0000 Subject: [PATCH 6/8] pdf2djvu: revbump for poppler-23.12.0. Close: #46107 --- srcpkgs/pdf2djvu/template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcpkgs/pdf2djvu/template b/srcpkgs/pdf2djvu/template index 5a6f3ddf4ed35..982ce2458751c 100644 --- a/srcpkgs/pdf2djvu/template +++ b/srcpkgs/pdf2djvu/template @@ -1,7 +1,7 @@ # Template file for 'pdf2djvu' pkgname=pdf2djvu version=0.9.19 -revision=5 +revision=6 build_style=gnu-configure hostmakedepends="pkg-config djvulibre gettext" makedepends="djvulibre-devel poppler-devel libgraphicsmagick-devel exiv2-devel libuuid-devel" From b4d16c7eba506c6d09de9df5777caea6fe60acbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Thu, 14 Dec 2023 14:01:26 +0700 Subject: [PATCH 7/8] scribus: for poppler 23.12.0 --- ...r-22.03.0-force-poppler-0.86-minimum.patch | 526 ++++++ .../0002-poppler-22.03.0-memleak.patch | 94 + .../0005-podofo-0.10-find-podofo.patch | 37 + ...-swap-podofo-poppler-dep-check-order.patch | 109 ++ .../0007-podofo-0.10-minimum-0.9.0.patch | 22 + .../0008-podofo-0.10-drop-old-compat.patch | 48 + ...dofo-0.10-avoid-confusion-with-m_doc.patch | 67 + .../0010-podofo-0.10-indentation-fix.patch | 22 + .../patches/0011-podofo-0.10-code-style.patch | 141 ++ .../0012-podofo-0.10-preparation.patch | 514 ++++++ ...013-podofo-0.10-compat-podofo-0.10.x.patch | 1602 +++++++++++++++++ ...0014-podofo-0.10-compat-podofo-0.9.6.patch | 853 +++++++++ .../patches/0015-podofo-0.10-cmake-fix.patch | 22 + .../0016-podofo-0.10-use-pkgconfig.patch | 107 ++ .../patches/cmake-buildtype-none.patch | 7 +- srcpkgs/scribus/template | 4 +- 16 files changed, 4170 insertions(+), 5 deletions(-) create mode 100644 srcpkgs/scribus/patches/0002-poppler-22.03.0-force-poppler-0.86-minimum.patch create mode 100644 srcpkgs/scribus/patches/0002-poppler-22.03.0-memleak.patch create mode 100644 srcpkgs/scribus/patches/0005-podofo-0.10-find-podofo.patch create mode 100644 srcpkgs/scribus/patches/0006-podofo-0.10-swap-podofo-poppler-dep-check-order.patch create mode 100644 srcpkgs/scribus/patches/0007-podofo-0.10-minimum-0.9.0.patch create mode 100644 srcpkgs/scribus/patches/0008-podofo-0.10-drop-old-compat.patch create mode 100644 srcpkgs/scribus/patches/0009-podofo-0.10-avoid-confusion-with-m_doc.patch create mode 100644 srcpkgs/scribus/patches/0010-podofo-0.10-indentation-fix.patch create mode 100644 srcpkgs/scribus/patches/0011-podofo-0.10-code-style.patch create mode 100644 srcpkgs/scribus/patches/0012-podofo-0.10-preparation.patch create mode 100644 srcpkgs/scribus/patches/0013-podofo-0.10-compat-podofo-0.10.x.patch create mode 100644 srcpkgs/scribus/patches/0014-podofo-0.10-compat-podofo-0.9.6.patch create mode 100644 srcpkgs/scribus/patches/0015-podofo-0.10-cmake-fix.patch create mode 100644 srcpkgs/scribus/patches/0016-podofo-0.10-use-pkgconfig.patch diff --git a/srcpkgs/scribus/patches/0002-poppler-22.03.0-force-poppler-0.86-minimum.patch b/srcpkgs/scribus/patches/0002-poppler-22.03.0-force-poppler-0.86-minimum.patch new file mode 100644 index 0000000000000..f205f45dea3d5 --- /dev/null +++ b/srcpkgs/scribus/patches/0002-poppler-22.03.0-force-poppler-0.86-minimum.patch @@ -0,0 +1,526 @@ +From e013e8126d2100e8e56dea5b836ad43275429389 Mon Sep 17 00:00:00 2001 +From: Jean Ghali +Date: Wed, 2 Mar 2022 22:48:29 +0000 +Subject: [PATCH] Enforce poppler version >= 0.86.0 + +git-svn-id: svn://scribus.net/trunk/Scribus@24985 11d20701-8431-0410-a711-e3c959e3b870 +--- + cmake/modules/Findpoppler.cmake | 4 +- + scribus/plugins/import/pdf/importpdf.cpp | 65 ++----------- + scribus/plugins/import/pdf/slaoutput.cpp | 114 ----------------------- + scribus/plugins/import/pdf/slaoutput.h | 7 -- + 4 files changed, 10 insertions(+), 180 deletions(-) + +--- a/cmake/modules/Findpoppler.cmake ++++ b/cmake/modules/Findpoppler.cmake +@@ -1,8 +1,8 @@ + #include(FindPkgConfig) + find_package(PkgConfig QUIET) +-pkg_search_module(poppler libpoppler>=0.62.0 poppler>=0.62.0) ++pkg_search_module(poppler libpoppler>=0.86.0 poppler>=0.86.0) + if (poppler_FOUND) +- pkg_search_module(poppler_cpp REQUIRED libpoppler-cpp>=0.62.0 poppler-cpp>=0.62.0) ++ pkg_search_module(poppler_cpp REQUIRED libpoppler-cpp>=0.86.0 poppler-cpp>=0.86.0) + endif(poppler_FOUND) + + find_path(poppler_INCLUDE_DIR +--- a/scribus/plugins/import/pdf/importpdf.cpp ++++ b/scribus/plugins/import/pdf/importpdf.cpp +@@ -75,20 +75,15 @@ PdfPlug::PdfPlug(ScribusDoc* doc, int fl + + QImage PdfPlug::readThumbnail(const QString& fName) + { +- QString pdfFile = QDir::toNativeSeparators(fName); +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 83, 0) + globalParams.reset(new GlobalParams()); +-#else +- std::unique_ptr globalParamsPtr(new GlobalParams()); +- globalParams = globalParamsPtr.get(); +-#endif ++ globalParams->setErrQuiet(gTrue); + +-#if defined(Q_OS_WIN32) && POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 62, 0) ++ QString pdfFile = QDir::toNativeSeparators(fName); ++#if defined(Q_OS_WIN32) + auto fname = new GooString(pdfFile.toUtf8().data()); + #else + auto fname = new GooString(QFile::encodeName(pdfFile).data()); + #endif +- globalParams->setErrQuiet(gTrue); + + #if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 3, 0) + PDFDoc pdfDoc{ std::make_unique(fname) }; +@@ -333,19 +328,15 @@ bool PdfPlug::convert(const QString& fn) + qApp->processEvents(); + } + +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 83, 0) + globalParams.reset(new GlobalParams()); +-#else +- std::unique_ptr globalParamsPtr(new GlobalParams()); +- globalParams = globalParamsPtr.get(); +-#endif +-#if defined(Q_OS_WIN32) && POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 62, 0) ++ globalParams->setErrQuiet(gTrue); ++ ++#if defined(Q_OS_WIN32) + auto fname = new GooString(fn.toUtf8().data()); + #else + auto fname = new GooString(QFile::encodeName(fn).data()); + #endif +- globalParams->setErrQuiet(gTrue); +-// globalParams->setPrintCommands(gTrue); ++ + QList ocgGroups; + #if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 3, 0) + auto pdfDoc = std::make_unique(std::make_unique(fname)); +@@ -365,7 +356,7 @@ bool PdfPlug::convert(const QString& fn) + QString text = QInputDialog::getText(mw, tr("Open PDF-File"), tr("Password"), QLineEdit::Normal, "", &ok); + if (ok && !text.isEmpty()) + { +-#if defined(Q_OS_WIN32) && POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 62, 0) ++#if defined(Q_OS_WIN32) + auto fname = new GooString(fn.toUtf8().data()); + #else + auto fname = new GooString(QFile::encodeName(fn).data()); +@@ -383,9 +374,6 @@ bool PdfPlug::convert(const QString& fn) + { + if (m_progressDialog) + m_progressDialog->close(); +-#if POPPLER_ENCODED_VERSION < POPPLER_VERSION_ENCODE(0, 83, 0) +- delete globalParams; +-#endif + return false; + } + if (m_progressDialog) +@@ -495,7 +483,6 @@ bool PdfPlug::convert(const QString& fn) + } + else + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 69, 0) + const auto& ocgs = ocg->getOCGs (); + for (const auto& ocg : ocgs) + { +@@ -507,25 +494,11 @@ bool PdfPlug::convert(const QString& fn) + ocgNames.append(ocgName); + } + } +-#else +- GooList *ocgs = ocg->getOCGs (); +- for (int i = 0; i < ocgs->getLength (); ++i) +- { +- OptionalContentGroup *oc = (OptionalContentGroup *)ocgs->get(i); +- QString ocgName = UnicodeParsedString(oc->getName()); +- if (!ocgNames.contains(ocgName)) +- { +- ocgGroups.prepend(oc); +- ocgNames.append(ocgName); +- } +- } +-#endif + } + } + } + else + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 69, 0) + const auto& ocgs = ocg->getOCGs (); + for (const auto& ocg : ocgs) + { +@@ -537,19 +510,6 @@ bool PdfPlug::convert(const QString& fn) + ocgNames.append(ocgName); + } + } +-#else +- GooList *ocgs = ocg->getOCGs (); +- for (int i = 0; i < ocgs->getLength (); ++i) +- { +- OptionalContentGroup *oc = (OptionalContentGroup *)ocgs->get(i); +- QString ocgName = UnicodeParsedString(oc->getName()); +- if (!ocgNames.contains(ocgName)) +- { +- ocgGroups.prepend(oc); +- ocgNames.append(ocgName); +- } +- } +-#endif + } + } + +@@ -788,13 +748,8 @@ bool PdfPlug::convert(const QString& fn) + names = catDict.dictLookup("OpenAction"); + if (names.isDict()) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + std::unique_ptr linkActionUPtr = LinkAction::parseAction(&names, pdfDoc->getCatalog()->getBaseURI()); + LinkAction *linkAction = linkActionUPtr.get(); +-#else +- LinkAction *linkAction = nullptr; +- linkAction = LinkAction::parseAction(&names, pdfDoc->getCatalog()->getBaseURI()); +-#endif + if (linkAction && (linkAction->getKind() == actionJavaScript)) + { + LinkJavaScript *jsa = (LinkJavaScript*) linkAction; +@@ -862,11 +817,7 @@ bool PdfPlug::convert(const QString& fn) + } + pdfDoc.reset(); + } +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 83, 0) + globalParams.reset(); +-#else +- globalParams = nullptr; +-#endif + + // qDebug() << "converting finished"; + // qDebug() << "Imported" << m_elements.count() << "Elements"; +--- a/scribus/plugins/import/pdf/slaoutput.cpp ++++ b/scribus/plugins/import/pdf/slaoutput.cpp +@@ -332,15 +332,9 @@ LinkAction* SlaOutputDev::SC_getAction(A + } + + /* Replacement for the crippled Poppler function LinkAction* AnnotWidget::getAdditionalAction(AdditionalActionsType type) */ +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + std::unique_ptr SlaOutputDev::SC_getAdditionalAction(const char *key, AnnotWidget *ano) + { + std::unique_ptr linkAction; +-#else +-LinkAction* SlaOutputDev::SC_getAdditionalAction(const char *key, AnnotWidget *ano) +-{ +- LinkAction *linkAction = nullptr; +-#endif + Object obj; + Ref refa = ano->getRef(); + +@@ -467,11 +461,7 @@ bool SlaOutputDev::handleLinkAnnot(Annot + if (dst->isPageRef()) + { + Ref dstr = dst->getPageRef(); +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 76, 0) + pagNum = pdfDoc->findPage(dstr); +-#else +- pagNum = pdfDoc->findPage(dstr.num, dstr.gen); +-#endif + } + else + pagNum = dst->getPageNum(); +@@ -485,11 +475,7 @@ bool SlaOutputDev::handleLinkAnnot(Annot + POPPLER_CONST GooString *ndst = gto->getNamedDest(); + if (ndst) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + std::unique_ptr dstn = pdfDoc->findDest(ndst); +-#else +- LinkDest *dstn = pdfDoc->findDest(ndst); +-#endif + if (dstn) + { + if (dstn->getKind() == destXYZ) +@@ -497,11 +483,7 @@ bool SlaOutputDev::handleLinkAnnot(Annot + if (dstn->isPageRef()) + { + Ref dstr = dstn->getPageRef(); +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 76, 0) + pagNum = pdfDoc->findPage(dstr); +-#else +- pagNum = pdfDoc->findPage(dstr.num, dstr.gen); +-#endif + } + else + pagNum = dstn->getPageNum(); +@@ -533,11 +515,7 @@ bool SlaOutputDev::handleLinkAnnot(Annot + POPPLER_CONST GooString *ndst = gto->getNamedDest(); + if (ndst) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + std::unique_ptr dstn = pdfDoc->findDest(ndst); +-#else +- LinkDest *dstn = pdfDoc->findDest(ndst); +-#endif + if (dstn) + { + if (dstn->getKind() == destXYZ) +@@ -985,11 +963,7 @@ void SlaOutputDev::handleActions(PageIte + if (dst->isPageRef()) + { + Ref dstr = dst->getPageRef(); +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 76, 0) + pagNum = pdfDoc->findPage(dstr); +-#else +- pagNum = pdfDoc->findPage(dstr.num, dstr.gen); +-#endif + } + else + pagNum = dst->getPageNum(); +@@ -1005,11 +979,7 @@ void SlaOutputDev::handleActions(PageIte + POPPLER_CONST GooString *ndst = gto->getNamedDest(); + if (ndst) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + std::unique_ptr dstn = pdfDoc->findDest(ndst); +-#else +- LinkDest *dstn = pdfDoc->findDest(ndst); +-#endif + if (dstn) + { + if (dstn->getKind() == destXYZ) +@@ -1017,11 +987,7 @@ void SlaOutputDev::handleActions(PageIte + if (dstn->isPageRef()) + { + Ref dstr = dstn->getPageRef(); +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 76, 0) + pagNum = pdfDoc->findPage(dstr); +-#else +- pagNum = pdfDoc->findPage(dstr.num, dstr.gen); +-#endif + } + else + pagNum = dstn->getPageNum(); +@@ -1061,11 +1027,7 @@ void SlaOutputDev::handleActions(PageIte + POPPLER_CONST GooString *ndst = gto->getNamedDest(); + if (ndst) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + std::unique_ptr dstn = pdfDoc->findDest(ndst); +-#else +- LinkDest *dstn = pdfDoc->findDest(ndst); +-#endif + if (dstn) + { + if (dstn->getKind() == destXYZ) +@@ -1139,143 +1101,91 @@ void SlaOutputDev::handleActions(PageIte + { + if (Aact->getKind() == actionJavaScript) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + LinkJavaScript *jsa = (LinkJavaScript*) Aact.get(); +-#else +- LinkJavaScript *jsa = (LinkJavaScript*) Aact; +-#endif + if (jsa->isOk()) + { + ite->annotation().setD_act(UnicodeParsedString(jsa->getScript())); + ite->annotation().setAAact(true); + } + } +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + Aact.reset(); +-#else +- Aact = nullptr; +-#endif + } + Aact = SC_getAdditionalAction("E", ano); + if (Aact) + { + if (Aact->getKind() == actionJavaScript) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + LinkJavaScript *jsa = (LinkJavaScript*) Aact.get(); +-#else +- LinkJavaScript *jsa = (LinkJavaScript*) Aact; +-#endif + if (jsa->isOk()) + { + ite->annotation().setE_act(UnicodeParsedString(jsa->getScript())); + ite->annotation().setAAact(true); + } + } +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + Aact.reset(); +-#else +- Aact = nullptr; +-#endif + } + Aact = SC_getAdditionalAction("X", ano); + if (Aact) + { + if (Aact->getKind() == actionJavaScript) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + LinkJavaScript *jsa = (LinkJavaScript*) Aact.get(); +-#else +- LinkJavaScript *jsa = (LinkJavaScript*) Aact; +-#endif + if (jsa->isOk()) + { + ite->annotation().setX_act(UnicodeParsedString(jsa->getScript())); + ite->annotation().setAAact(true); + } + } +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + Aact.reset(); +-#else +- Aact = nullptr; +-#endif + } + Aact = SC_getAdditionalAction("Fo", ano); + if (Aact) + { + if (Aact->getKind() == actionJavaScript) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + LinkJavaScript *jsa = (LinkJavaScript*) Aact.get(); +-#else +- LinkJavaScript *jsa = (LinkJavaScript*) Aact; +-#endif + if (jsa->isOk()) + { + ite->annotation().setFo_act(UnicodeParsedString(jsa->getScript())); + ite->annotation().setAAact(true); + } + } +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + Aact.reset(); +-#else +- Aact = nullptr; +-#endif + } + Aact = SC_getAdditionalAction("Bl", ano); + if (Aact) + { + if (Aact->getKind() == actionJavaScript) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + LinkJavaScript *jsa = (LinkJavaScript*) Aact.get(); +-#else +- LinkJavaScript *jsa = (LinkJavaScript*) Aact; +-#endif + if (jsa->isOk()) + { + ite->annotation().setBl_act(UnicodeParsedString(jsa->getScript())); + ite->annotation().setAAact(true); + } + } +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + Aact.reset(); +-#else +- Aact = nullptr; +-#endif + } + Aact = SC_getAdditionalAction("C", ano); + if (Aact) + { + if (Aact->getKind() == actionJavaScript) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + LinkJavaScript *jsa = (LinkJavaScript*) Aact.get(); +-#else +- LinkJavaScript *jsa = (LinkJavaScript*) Aact; +-#endif + if (jsa->isOk()) + { + ite->annotation().setC_act(UnicodeParsedString(jsa->getScript())); + ite->annotation().setAAact(true); + } + } +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + Aact.reset(); +-#else +- Aact = nullptr; +-#endif + } + Aact = SC_getAdditionalAction("F", ano); + if (Aact) + { + if (Aact->getKind() == actionJavaScript) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + LinkJavaScript *jsa = (LinkJavaScript*) Aact.get(); +-#else +- LinkJavaScript *jsa = (LinkJavaScript*) Aact; +-#endif + if (jsa->isOk()) + { + ite->annotation().setF_act(UnicodeParsedString(jsa->getScript())); +@@ -1283,22 +1193,14 @@ void SlaOutputDev::handleActions(PageIte + ite->annotation().setFormat(5); + } + } +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + Aact.reset(); +-#else +- Aact = nullptr; +-#endif + } + Aact = SC_getAdditionalAction("K", ano); + if (Aact) + { + if (Aact->getKind() == actionJavaScript) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + LinkJavaScript *jsa = (LinkJavaScript*) Aact.get(); +-#else +- LinkJavaScript *jsa = (LinkJavaScript*) Aact; +-#endif + if (jsa->isOk()) + { + ite->annotation().setK_act(UnicodeParsedString(jsa->getScript())); +@@ -1306,33 +1208,21 @@ void SlaOutputDev::handleActions(PageIte + ite->annotation().setFormat(5); + } + } +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + Aact.reset(); +-#else +- Aact = nullptr; +-#endif + } + Aact = SC_getAdditionalAction("V", ano); + if (Aact) + { + if (Aact->getKind() == actionJavaScript) + { +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + LinkJavaScript *jsa = (LinkJavaScript*) Aact.get(); +-#else +- LinkJavaScript *jsa = (LinkJavaScript*) Aact; +-#endif + if (jsa->isOk()) + { + ite->annotation().setV_act(UnicodeParsedString(jsa->getScript())); + ite->annotation().setAAact(true); + } + } +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + Aact.reset(); +-#else +- Aact = nullptr; +-#endif + } + } + +@@ -1342,11 +1232,7 @@ void SlaOutputDev::startDoc(PDFDoc *doc, + catalog = catA; + pdfDoc = doc; + updateGUICounter = 0; +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 84, 0) + m_fontEngine = new SplashFontEngine(true, false, false, true); +-#else +- m_fontEngine = new SplashFontEngine(globalParams->getEnableFreeType(), false, false, true); +-#endif + } + + void SlaOutputDev::startPage(int pageNum, GfxState *, XRef *) +--- a/scribus/plugins/import/pdf/slaoutput.h ++++ b/scribus/plugins/import/pdf/slaoutput.h +@@ -30,9 +30,6 @@ for which a new license (GPL+exception) + #include "selection.h" + #include "vgradient.h" + +-#if POPPLER_ENCODED_VERSION < POPPLER_VERSION_ENCODE(0, 73, 0) +-#include +-#endif + #include + #include + #include +@@ -163,11 +160,7 @@ public: + virtual ~SlaOutputDev(); + + LinkAction* SC_getAction(AnnotWidget *ano); +-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) + std::unique_ptr SC_getAdditionalAction(const char *key, AnnotWidget *ano); +-#else +- LinkAction* SC_getAdditionalAction(const char *key, AnnotWidget *ano); +-#endif + static GBool annotations_callback(Annot *annota, void *user_data); + bool handleTextAnnot(Annot* annota, double xCoor, double yCoor, double width, double height); + bool handleLinkAnnot(Annot* annota, double xCoor, double yCoor, double width, double height); diff --git a/srcpkgs/scribus/patches/0002-poppler-22.03.0-memleak.patch b/srcpkgs/scribus/patches/0002-poppler-22.03.0-memleak.patch new file mode 100644 index 0000000000000..d40f35ad966e9 --- /dev/null +++ b/srcpkgs/scribus/patches/0002-poppler-22.03.0-memleak.patch @@ -0,0 +1,94 @@ +From 48263954a7dee0be815b00f417ae365ab26cdd85 Mon Sep 17 00:00:00 2001 +From: Jean Ghali +Date: Thu, 3 Mar 2022 00:18:06 +0000 +Subject: [PATCH] #16764: Better patch, avoid a memory leak + +git-svn-id: svn://scribus.net/trunk/Scribus@24989 11d20701-8431-0410-a711-e3c959e3b870 +--- + scribus/plugins/import/pdf/importpdf.cpp | 34 +++++++++--------------- + scribus/util_os.cpp | 2 ++ + 2 files changed, 15 insertions(+), 21 deletions(-) + +--- a/scribus/plugins/import/pdf/importpdf.cpp ++++ b/scribus/plugins/import/pdf/importpdf.cpp +@@ -58,6 +58,7 @@ for which a new license (GPL+exception) + #include "util.h" + #include "util_formats.h" + #include "util_math.h" ++#include "util_os.h" + + #include "ui/customfdialog.h" + #include "ui/missing.h" +@@ -79,15 +80,12 @@ QImage PdfPlug::readThumbnail(const QStr + globalParams->setErrQuiet(gTrue); + + QString pdfFile = QDir::toNativeSeparators(fName); +-#if defined(Q_OS_WIN32) +- auto fname = new GooString(pdfFile.toUtf8().data()); +-#else +- auto fname = new GooString(QFile::encodeName(pdfFile).data()); +-#endif +- ++ QByteArray encodedFileName = os_is_win() ? pdfFile.toUtf8() : QFile::encodeName(pdfFile); + #if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 3, 0) +- PDFDoc pdfDoc{ std::make_unique(fname) }; ++ auto fname = std::make_unique(encodedFileName.data()); ++ PDFDoc pdfDoc{ std::move(fname) }; + #else ++ auto fname = new GooString(encodedFileName.data()); + PDFDoc pdfDoc{fname, nullptr, nullptr, nullptr}; + #endif + if (!pdfDoc.isOk() || pdfDoc.getErrorCode() == errEncrypted) +@@ -331,17 +329,14 @@ bool PdfPlug::convert(const QString& fn) + globalParams.reset(new GlobalParams()); + globalParams->setErrQuiet(gTrue); + +-#if defined(Q_OS_WIN32) +- auto fname = new GooString(fn.toUtf8().data()); +-#else +- auto fname = new GooString(QFile::encodeName(fn).data()); +-#endif +- + QList ocgGroups; ++ QByteArray encodedFileName = os_is_win() ? fn.toUtf8() : QFile::encodeName(fn); + #if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 3, 0) +- auto pdfDoc = std::make_unique(std::make_unique(fname)); ++ auto fname = std::make_unique(encodedFileName.data()); ++ auto pdfDoc = std::make_unique(std::move(fname)); + #else +- auto pdfDoc = std::unique_ptr(new PDFDoc(fname, nullptr, nullptr, nullptr)); ++ auto fname = new GooString(encodedFileName.data()); ++ auto pdfDoc = std::make_unique(fname, nullptr, nullptr, nullptr); + #endif + if (pdfDoc) + { +@@ -356,15 +351,12 @@ bool PdfPlug::convert(const QString& fn) + QString text = QInputDialog::getText(mw, tr("Open PDF-File"), tr("Password"), QLineEdit::Normal, "", &ok); + if (ok && !text.isEmpty()) + { +-#if defined(Q_OS_WIN32) +- auto fname = new GooString(fn.toUtf8().data()); +-#else +- auto fname = new GooString(QFile::encodeName(fn).data()); +-#endif + #if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 3, 0) ++ auto fname = std::make_unique(encodedFileName.data()); + std::optional userPW(std::in_place, text.toLocal8Bit().data()); +- pdfDoc.reset(new PDFDoc(std::make_unique(fname), userPW, userPW, nullptr)); ++ pdfDoc.reset(new PDFDoc(std::move(fname), userPW, userPW, nullptr)); + #else ++ auto fname = new GooString(encodedFileName.data()); + auto userPW = new GooString(text.toLocal8Bit().data()); + pdfDoc.reset(new PDFDoc(fname, userPW, userPW, nullptr)); + #endif +--- a/scribus/util_os.cpp ++++ b/scribus/util_os.cpp +@@ -22,6 +22,8 @@ for which a new license (GPL+exception) + + #include + ++#include "util_os.h" ++ + bool os_is_osx() + { + #ifdef Q_OS_MACOS diff --git a/srcpkgs/scribus/patches/0005-podofo-0.10-find-podofo.patch b/srcpkgs/scribus/patches/0005-podofo-0.10-find-podofo.patch new file mode 100644 index 0000000000000..261428153a96f --- /dev/null +++ b/srcpkgs/scribus/patches/0005-podofo-0.10-find-podofo.patch @@ -0,0 +1,37 @@ +From 3d02faaa2e17eef67826abd52d56b4a9b2b9c1ba Mon Sep 17 00:00:00 2001 +From: Craig Bradney +Date: Sun, 4 Jun 2023 17:00:34 +0000 +Subject: [PATCH 01/13] Update CMake PoDoFo finder to allow for PoDoFo 0.10.0 + podofo-config.h location + +git-svn-id: svn://scribus.net/trunk/Scribus@25493 11d20701-8431-0410-a711-e3c959e3b870 +(cherry picked from commit bd70705c05bd383d1a9b3ab12224988ff8475722) +--- + cmake/modules/FindLIBPODOFO.cmake | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +--- a/cmake/modules/FindLIBPODOFO.cmake ++++ b/cmake/modules/FindLIBPODOFO.cmake +@@ -32,7 +32,14 @@ find_library(LIBPODOFO_LIBRARY + + if(LIBPODOFO_INCLUDE_DIR AND LIBPODOFO_LIBRARY) + if(NOT LIBPODOFO_CONFIG_H) +- set(LIBPODOFO_CONFIG_H "${LIBPODOFO_INCLUDE_DIR}/podofo/base/podofo_config.h" CACHE FILEPATH "Alternative place of podofo_config.h") ++ #PoDoFo before 0.10.0 ++ if (EXISTS "${LIBPODOFO_INCLUDE_DIR}/podofo/base/podofo_config.h") ++ set(LIBPODOFO_CONFIG_H "${LIBPODOFO_INCLUDE_DIR}/podofo/base/podofo_config.h" CACHE FILEPATH "Alternative place of podofo_config.h. PoDoFo <=0.10.0") ++ endif() ++ #PoDoFo 0.10.0 or higher ++ if (EXISTS "${LIBPODOFO_INCLUDE_DIR}/podofo/auxiliary/podofo_config.h") ++ set(LIBPODOFO_CONFIG_H "${LIBPODOFO_INCLUDE_DIR}/podofo/auxiliary/podofo_config.h" CACHE FILEPATH "Alternative place of podofo_config.h. PoDoFo >=0.10.0") ++ endif() + endif() + + file(STRINGS "${LIBPODOFO_CONFIG_H}" PODOFO_MAJOR_VER_LINE REGEX "^#define[ \t]+PODOFO_VERSION_MAJOR[ \t]+[0-9]+$") +@@ -79,4 +86,6 @@ if(NOT LIBPODOFO_FIND_QUIETLY) + message("podofo lib: not found") + endif(LIBPODOFO_LIBRARY) + message("PoDoFo cflags: ${useshared}") ++ message("PoDoFo config file ${LIBPODOFO_CONFIG_H}") ++ message("PoDoFo version ${LIBPODOFO_VERSION}") + endif(NOT LIBPODOFO_FIND_QUIETLY) diff --git a/srcpkgs/scribus/patches/0006-podofo-0.10-swap-podofo-poppler-dep-check-order.patch b/srcpkgs/scribus/patches/0006-podofo-0.10-swap-podofo-poppler-dep-check-order.patch new file mode 100644 index 0000000000000..47c644f418b22 --- /dev/null +++ b/srcpkgs/scribus/patches/0006-podofo-0.10-swap-podofo-poppler-dep-check-order.patch @@ -0,0 +1,109 @@ +From 45ed6b8664675d78de1b3dbde2c9684111805811 Mon Sep 17 00:00:00 2001 +From: Craig Bradney +Date: Mon, 5 Jun 2023 20:57:47 +0000 +Subject: [PATCH 02/13] Swap dependency checking for podofo and poppler to the + beginning to force C++17 when their versions require it + +git-svn-id: svn://scribus.net/trunk/Scribus@25500 11d20701-8431-0410-a711-e3c959e3b870 +(cherry picked from commit 81b3cf609ff01400f6f804c98ee58febc4494908) +--- + CMakeLists_Dependencies.cmake | 74 +++++++++++++++++++++-------------- + 1 file changed, 44 insertions(+), 30 deletions(-) + +--- a/CMakeLists_Dependencies.cmake ++++ b/CMakeLists_Dependencies.cmake +@@ -1,6 +1,48 @@ + ############################################################################################################## + ########## Find Dependencies ########## + ++#<>PoDoFo for AI PDF import ++ ++#<>Poppler for PDF import ++ ++ + #<< Qt + #Qt less than 6 + set(CMAKE_PREFIX_PATH "${QT_PREFIX}/lib/cmake") +@@ -257,18 +299,7 @@ if (WANT_HUNSPELL) + endif() + #>>HUNSPELL for Spelling support + +-#<>PoDoFo for AI PDF import ++ + + #<> GraphicsMagick for image import + +-#<>Poppler for PDF import ++ + + # librevenge for MsPub import + pkg_check_modules(LIBREVENGE librevenge-0.0) diff --git a/srcpkgs/scribus/patches/0007-podofo-0.10-minimum-0.9.0.patch b/srcpkgs/scribus/patches/0007-podofo-0.10-minimum-0.9.0.patch new file mode 100644 index 0000000000000..d5503bf50d7e6 --- /dev/null +++ b/srcpkgs/scribus/patches/0007-podofo-0.10-minimum-0.9.0.patch @@ -0,0 +1,22 @@ +From 2a2c95fda05bbb089c12807261b7a9339635b488 Mon Sep 17 00:00:00 2001 +From: Craig Bradney +Date: Mon, 5 Jun 2023 21:32:27 +0000 +Subject: [PATCH 03/13] Bump minimum podofo version to 0.9.0 + +git-svn-id: svn://scribus.net/trunk/Scribus@25506 11d20701-8431-0410-a711-e3c959e3b870 +(cherry picked from commit 9233e1e20a006155e90e2893cb2a133949ec7a68) +--- + CMakeLists_Dependencies.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/CMakeLists_Dependencies.cmake ++++ b/CMakeLists_Dependencies.cmake +@@ -4,7 +4,7 @@ + #< +Date: Mon, 5 Jun 2023 21:37:40 +0000 +Subject: [PATCH 04/13] Code cleanup now possible thanks to podofo >= 0.9.0 + requirement + +git-svn-id: svn://scribus.net/trunk/Scribus@25509 11d20701-8431-0410-a711-e3c959e3b870 +(cherry picked from commit a43ad2030f6a6a7ccc1d7fc6cdcd7a652e1263c3) +--- + scribus/pdflib_core.cpp | 8 -------- + 1 file changed, 8 deletions(-) + +--- a/scribus/pdflib_core.cpp ++++ b/scribus/pdflib_core.cpp +@@ -9861,16 +9861,12 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + char * mbuffer = nullptr; + long mlen = 0; + +-#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 7, 99)) + // seems more complicated at first, but in fact it makes the code more stable wrt podofo changes + PoDoFo::PdfMemoryOutputStream oStream(1); + stream->GetCopy(&oStream); + oStream.Close(); + mlen = oStream.GetLength(); + mbuffer = oStream.TakeBuffer(); +-#else +- stream->GetCopy(&mbuffer, &mlen); +-#endif + if (mbuffer[mlen-1] == '\n') + --mlen; + PutDoc("\n/Length " + Pdf::toPdf(static_cast(mlen))); +@@ -10158,16 +10154,12 @@ void PDFLibCore::copyPoDoFoObject(const + char * mbuffer = nullptr; + long mlen = 0; + +-#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 7, 99)) + // seems more complicated at first, but in fact it makes the code more stable wrt podofo changes + PoDoFo::PdfMemoryOutputStream oStream(1); + stream->GetCopy(&oStream); + oStream.Close(); + mlen = oStream.GetLength(); + mbuffer = oStream.TakeBuffer(); +-#else +- stream->GetCopy(&mbuffer, &mlen); +-#endif + if (mbuffer[mlen-1] == '\n') + --mlen; + PutDoc("\nstream\n"); diff --git a/srcpkgs/scribus/patches/0009-podofo-0.10-avoid-confusion-with-m_doc.patch b/srcpkgs/scribus/patches/0009-podofo-0.10-avoid-confusion-with-m_doc.patch new file mode 100644 index 0000000000000..d545d347e28e1 --- /dev/null +++ b/srcpkgs/scribus/patches/0009-podofo-0.10-avoid-confusion-with-m_doc.patch @@ -0,0 +1,67 @@ +From 99e2d400ad6ad7fbf4e2ad1a4277521eaad46d28 Mon Sep 17 00:00:00 2001 +From: Craig Bradney +Date: Sun, 4 Jun 2023 21:31:53 +0000 +Subject: [PATCH 05/13] Rename m_doc in pdf_analyser to avoid confusion with + m_doc in other code + +git-svn-id: svn://scribus.net/trunk/Scribus@25495 11d20701-8431-0410-a711-e3c959e3b870 +(cherry picked from commit b5aeed8093e06cf3df456f5ad26f76f6ca442bff) +--- + scribus/pdf_analyzer.cpp | 12 ++++++------ + scribus/pdf_analyzer.h | 2 +- + 2 files changed, 7 insertions(+), 7 deletions(-) + +--- a/scribus/pdf_analyzer.cpp ++++ b/scribus/pdf_analyzer.cpp +@@ -75,11 +75,11 @@ PDFAnalyzer::PDFAnalyzer(QString & filen + nameMapInited = true; + } + +- m_doc = nullptr; ++ m_pdfdoc = nullptr; + + PdfError::EnableDebug( false ); + try { +- m_doc = new PdfMemDocument(filename.toLocal8Bit().data()); ++ m_pdfdoc = new PdfMemDocument(filename.toLocal8Bit().data()); + } + catch (PdfError & e) + { +@@ -91,14 +91,14 @@ PDFAnalyzer::PDFAnalyzer(QString & filen + + PDFAnalyzer::~PDFAnalyzer() + { +- delete m_doc; ++ delete m_pdfdoc; + } + + bool PDFAnalyzer::inspectPDF(int pageNum, QList & usedColorSpaces, bool & hasTransparency, QList & usedFonts, QList & imgs) + { +- if (!m_doc) ++ if (!m_pdfdoc) + return false; +- PdfPage* page = m_doc->GetPage(pageNum); ++ PdfPage* page = m_pdfdoc->GetPage(pageNum); + return page?inspectCanvas(page, usedColorSpaces, hasTransparency, usedFonts, imgs):false; + } + +@@ -725,7 +725,7 @@ void PDFAnalyzer::inspectExtGStateObj(Pd + if (arr[0].IsReference()) + { + PdfReference ref = arr[0].GetReference(); +- PdfObject* fontObject = m_doc->GetObjects().GetObject(ref); ++ PdfObject* fontObject = m_pdfdoc->GetObjects().GetObject(ref); + if (fontObject) + { + PDFFont font = getFontInfo(fontObject); +--- a/scribus/pdf_analyzer.h ++++ b/scribus/pdf_analyzer.h +@@ -162,7 +162,7 @@ public: + #ifdef HAVE_PODOFO + private: + // pointer to the PoDoFo Pdf's object +- PoDoFo::PdfMemDocument* m_doc; ++ PoDoFo::PdfMemDocument* m_pdfdoc; + + // Path to the analyzed file + QString m_filename; diff --git a/srcpkgs/scribus/patches/0010-podofo-0.10-indentation-fix.patch b/srcpkgs/scribus/patches/0010-podofo-0.10-indentation-fix.patch new file mode 100644 index 0000000000000..f6c890ebf60d9 --- /dev/null +++ b/srcpkgs/scribus/patches/0010-podofo-0.10-indentation-fix.patch @@ -0,0 +1,22 @@ +From ed854091944c93a74cdb3a4dbd6ed14e95ab6a9c Mon Sep 17 00:00:00 2001 +From: Jean Ghali +Date: Mon, 5 Jun 2023 21:03:08 +0000 +Subject: [PATCH 06/13] Small indentation fix + +git-svn-id: svn://scribus.net/trunk/Scribus@25503 11d20701-8431-0410-a711-e3c959e3b870 +(cherry picked from commit fd576ca6d40856ca3cfb32482b24fa15783665d5) +--- + scribus/pdf_analyzer.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/scribus/pdf_analyzer.cpp ++++ b/scribus/pdf_analyzer.cpp +@@ -725,7 +725,7 @@ void PDFAnalyzer::inspectExtGStateObj(Pd + if (arr[0].IsReference()) + { + PdfReference ref = arr[0].GetReference(); +- PdfObject* fontObject = m_pdfdoc->GetObjects().GetObject(ref); ++ PdfObject* fontObject = m_pdfdoc->GetObjects().GetObject(ref); + if (fontObject) + { + PDFFont font = getFontInfo(fontObject); diff --git a/srcpkgs/scribus/patches/0011-podofo-0.10-code-style.patch b/srcpkgs/scribus/patches/0011-podofo-0.10-code-style.patch new file mode 100644 index 0000000000000..973eb17f714b5 --- /dev/null +++ b/srcpkgs/scribus/patches/0011-podofo-0.10-code-style.patch @@ -0,0 +1,141 @@ +From 9cd60ef7831fff69f2dacc2bf216c3537b2cd6e9 Mon Sep 17 00:00:00 2001 +From: Jean Ghali +Date: Sat, 12 Aug 2023 21:12:49 +0000 +Subject: [PATCH 07/13] PDFAnalyzer: code style fixes and cleanups + +git-svn-id: svn://scribus.net/trunk/Scribus@25573 11d20701-8431-0410-a711-e3c959e3b870 +(cherry picked from commit 9be7a29f08a00bb3c10024cd9a31a82742d42e22) +--- + scribus/pdf_analyzer.cpp | 56 +++++++++++++++++++++------------------- + 1 file changed, 30 insertions(+), 26 deletions(-) + +--- a/scribus/pdf_analyzer.cpp ++++ b/scribus/pdf_analyzer.cpp +@@ -78,7 +78,8 @@ PDFAnalyzer::PDFAnalyzer(QString & filen + m_pdfdoc = nullptr; + + PdfError::EnableDebug( false ); +- try { ++ try ++ { + m_pdfdoc = new PdfMemDocument(filename.toLocal8Bit().data()); + } + catch (PdfError & e) +@@ -99,12 +100,13 @@ bool PDFAnalyzer::inspectPDF(int pageNum + if (!m_pdfdoc) + return false; + PdfPage* page = m_pdfdoc->GetPage(pageNum); +- return page?inspectCanvas(page, usedColorSpaces, hasTransparency, usedFonts, imgs):false; ++ return page ? inspectCanvas(page, usedColorSpaces, hasTransparency, usedFonts, imgs) : false; + } + + PDFColorSpace PDFAnalyzer::getCSType(PdfObject* cs) + { +- try { ++ try ++ { + // colorspace is either a name or an array + if (cs && cs->IsName()) + { +@@ -165,20 +167,21 @@ PDFColorSpace PDFAnalyzer::getCSType(Pdf + bool PDFAnalyzer::inspectCanvas(PdfCanvas* canvas, QList & usedColorSpaces, bool & hasTransparency, QList & usedFonts, QList & imgs) + { + // this method can be used to get used color spaces, detect transparency, and get used fonts in either PdfPage or PdfXObject +- PdfObject* colorSpaceRes; +- PdfObject* xObjects; +- PdfObject* transGroup; +- PdfObject* extGState; +- PdfObject* fontRes; ++ PdfObject* colorSpaceRes { nullptr }; ++ PdfObject* xObjects { nullptr }; ++ PdfObject* transGroup { nullptr }; ++ PdfObject* extGState { nullptr }; ++ PdfObject* fontRes { nullptr }; + QMap processedNamedCS; + QMap processedNamedFont; + QList processedNamedXObj; + QList processedNamedGS; +- try { ++ try ++ { + // get hold of a PdfObject pointer of this canvas + // needed for the finding resources code below to work + PdfPage* page = dynamic_cast(canvas); +- PdfObject* canvasObject = page?(page->GetObject()):((dynamic_cast(canvas))->GetObject()); ++ PdfObject* canvasObject = page ? (page->GetObject()) : ((dynamic_cast(canvas))->GetObject()); + + // find a resource with ColorSpace entry + PdfObject* resources = canvas->GetResources(); +@@ -186,13 +189,13 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + { + resources = par->GetIndirectKey("Resources"); + } +- colorSpaceRes = resources?resources->GetIndirectKey("ColorSpace"):nullptr; +- xObjects = resources?resources->GetIndirectKey("XObject"):nullptr; +- extGState = resources?resources->GetIndirectKey("ExtGState"):nullptr; +- fontRes = resources?resources->GetIndirectKey("Font"):nullptr; ++ colorSpaceRes = resources ? resources->GetIndirectKey("ColorSpace") : nullptr; ++ xObjects = resources ? resources->GetIndirectKey("XObject") : nullptr; ++ extGState = resources ? resources->GetIndirectKey("ExtGState") : nullptr; ++ fontRes = resources ? resources->GetIndirectKey("Font") : nullptr; + + // getting the transparency group of this content stream (if available) +- transGroup = canvasObject?canvasObject->GetIndirectKey("Group"):nullptr; ++ transGroup = canvasObject ? canvasObject->GetIndirectKey("Group") : nullptr; + if (transGroup) + { + PdfObject* subtype = transGroup->GetIndirectKey("S"); +@@ -219,7 +222,8 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + return false; + } + +- try { ++ try ++ { + // start parsing the content stream + PdfContentsTokenizer tokenizer(canvas); + EPdfContentsType t; +@@ -502,7 +506,7 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + if (args.size() == 1 && args[0].IsName() && xObjects) + { + PdfObject* xObject = xObjects->GetIndirectKey(args[0].GetName()); +- PdfObject* subtypeObject = xObject?xObject->GetIndirectKey("Subtype"):nullptr; ++ PdfObject* subtypeObject = xObject ? xObject->GetIndirectKey("Subtype") : nullptr; + if (subtypeObject && subtypeObject->IsName()) + { + if (subtypeObject->GetName() == "Image") +@@ -557,10 +561,10 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + PdfName cs("CS"); + if (args.contains(colorspace) || args.contains(cs)) + { +- int csIdx = args.contains(colorspace)?args.indexOf(colorspace):args.indexOf(cs); +- if (args[csIdx+1].IsName()) ++ int csIdx = args.contains(colorspace) ? args.indexOf(colorspace) : args.indexOf(cs); ++ if (args[csIdx + 1].IsName()) + { +- PdfName csName = args[csIdx+1].GetName(); ++ PdfName csName = args[csIdx + 1].GetName(); + if ((csName == "G" || csName == "DeviceGray") && !usedColorSpaces.contains(CS_DeviceGray)) + usedColorSpaces.append(CS_DeviceGray); + else if ((csName == "RGB" || csName == "DeviceRGB") && !usedColorSpaces.contains(CS_DeviceRGB)) +@@ -594,14 +598,14 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + PdfName w("W"); + if ((args.contains(height) || args.contains(h)) && (args.contains(width) || args.contains(w))) + { +- int heightIdx = args.contains(height)?args.indexOf(height):args.indexOf(h); +- int widthIdx = args.contains(width)?args.indexOf(width):args.indexOf(w); +- double height = args[heightIdx+1].GetReal(); +- double width = args[widthIdx+1].GetReal(); ++ int heightIdx = args.contains(height) ? args.indexOf(height) : args.indexOf(h); ++ int widthIdx = args.contains(width) ? args.indexOf(width) : args.indexOf(w); ++ double height = args[heightIdx + 1].GetReal(); ++ double width = args[widthIdx + 1].GetReal(); + PDFImage img; + img.imgName = "Inline Image"; +- img.dpiX = qRound(width/(currGS.ctm.m11()/72)); +- img.dpiY = qRound(height/(currGS.ctm.m22()/72)); ++ img.dpiX = qRound(width / (currGS.ctm.m11() / 72)); ++ img.dpiY = qRound(height / (currGS.ctm.m22() / 72)); + imgs.append(img); + } + inlineImgDict = false; diff --git a/srcpkgs/scribus/patches/0012-podofo-0.10-preparation.patch b/srcpkgs/scribus/patches/0012-podofo-0.10-preparation.patch new file mode 100644 index 0000000000000..654d870140683 --- /dev/null +++ b/srcpkgs/scribus/patches/0012-podofo-0.10-preparation.patch @@ -0,0 +1,514 @@ +From bb6c0716035bcdc9fd4bd536d1ed6f01a1c6e9fa Mon Sep 17 00:00:00 2001 +From: Jean Ghali +Date: Sat, 12 Aug 2023 23:28:11 +0000 +Subject: [PATCH 08/13] Preparation work for PoDoFo 0.10.0x support: get rid of + GetIndirectKey() calls + +git-svn-id: svn://scribus.net/trunk/Scribus@25579 11d20701-8431-0410-a711-e3c959e3b870 +(cherry picked from commit fbd5eb474e0e6f522c6089756424592ecf0dc0a4) +--- + scribus/pdf_analyzer.cpp | 204 ++++++++++++++----------- + scribus/pdflib_core.cpp | 28 ++-- + scribus/plugins/import/ai/importai.cpp | 21 ++- + 3 files changed, 148 insertions(+), 105 deletions(-) + +--- a/scribus/pdf_analyzer.cpp ++++ b/scribus/pdf_analyzer.cpp +@@ -167,11 +167,10 @@ PDFColorSpace PDFAnalyzer::getCSType(Pdf + bool PDFAnalyzer::inspectCanvas(PdfCanvas* canvas, QList & usedColorSpaces, bool & hasTransparency, QList & usedFonts, QList & imgs) + { + // this method can be used to get used color spaces, detect transparency, and get used fonts in either PdfPage or PdfXObject +- PdfObject* colorSpaceRes { nullptr }; +- PdfObject* xObjects { nullptr }; +- PdfObject* transGroup { nullptr }; +- PdfObject* extGState { nullptr }; +- PdfObject* fontRes { nullptr }; ++ PdfDictionary* colorSpacesDict { nullptr }; ++ PdfDictionary* xObjectsDict { nullptr }; ++ PdfDictionary* extGStatesDict { nullptr }; ++ PdfDictionary* fontsDict { nullptr }; + QMap processedNamedCS; + QMap processedNamedFont; + QList processedNamedXObj; +@@ -182,30 +181,41 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + // needed for the finding resources code below to work + PdfPage* page = dynamic_cast(canvas); + PdfObject* canvasObject = page ? (page->GetObject()) : ((dynamic_cast(canvas))->GetObject()); ++ PdfDictionary* canvasDict = (canvasObject && canvasObject->IsDictionary()) ? &(canvasObject->GetDictionary()) : nullptr; + + // find a resource with ColorSpace entry + PdfObject* resources = canvas->GetResources(); +- for (PdfObject* par = canvasObject; par && !resources; par = par->GetIndirectKey("Parent")) ++ for (PdfDictionary* par = canvasDict, *parentDict = nullptr; par && !resources; par = parentDict) + { +- resources = par->GetIndirectKey("Resources"); ++ resources = par->FindKey("Resources"); ++ PdfObject* parentObj = par->FindKey("Parent"); ++ parentDict = (parentObj && parentObj->IsDictionary()) ? &(parentObj->GetDictionary()) : nullptr; + } +- colorSpaceRes = resources ? resources->GetIndirectKey("ColorSpace") : nullptr; +- xObjects = resources ? resources->GetIndirectKey("XObject") : nullptr; +- extGState = resources ? resources->GetIndirectKey("ExtGState") : nullptr; +- fontRes = resources ? resources->GetIndirectKey("Font") : nullptr; ++ ++ PdfDictionary* resourcesDict = (resources && resources->IsDictionary()) ? &(resources->GetDictionary()) : nullptr; ++ PdfObject* colorSpaceRes = resourcesDict ? resourcesDict->FindKey("ColorSpace") : nullptr; ++ PdfObject* xObjects = resourcesDict ? resourcesDict->FindKey("XObject") : nullptr; ++ PdfObject* extGState = resourcesDict ? resourcesDict->FindKey("ExtGState") : nullptr; ++ PdfObject* fontRes = resourcesDict ? resourcesDict->FindKey("Font") : nullptr; ++ ++ colorSpacesDict = (colorSpaceRes && colorSpaceRes->IsDictionary()) ? &(colorSpaceRes->GetDictionary()) : nullptr; ++ xObjectsDict = (xObjects && xObjects->IsDictionary()) ? &(xObjects->GetDictionary()) : nullptr; ++ extGStatesDict = (extGState && extGState->IsDictionary()) ? &(extGState->GetDictionary()) : nullptr; ++ fontsDict = (fontRes && fontRes->IsDictionary()) ? &(fontRes->GetDictionary()) : nullptr; + + // getting the transparency group of this content stream (if available) +- transGroup = canvasObject ? canvasObject->GetIndirectKey("Group") : nullptr; +- if (transGroup) ++ PdfObject* transGroup = canvasDict ? canvasDict->FindKey("Group") : nullptr; ++ PdfDictionary* transGroupDict = (transGroup && transGroup->IsDictionary()) ? &(transGroup->GetDictionary()) : nullptr; ++ if (transGroupDict) + { +- PdfObject* subtype = transGroup->GetIndirectKey("S"); ++ const PdfObject* subtype = transGroupDict->FindKey("S"); + if (subtype && subtype->GetName() == "Transparency") + { + // having transparency group means there's transparency in the PDF + hasTransparency = true; + + // reporting the color space used in transparency group (Section 7.5.5, PDF 1.6 Spec) +- PdfObject* cs = transGroup->GetIndirectKey("CS"); ++ PdfObject* cs = transGroupDict->FindKey("CS"); + if (cs) + { + PDFColorSpace retval = getCSType(cs); +@@ -380,9 +390,9 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + } + else + { +- if (colorSpaceRes && colorSpaceRes->GetIndirectKey(args[0].GetName())) ++ if (colorSpacesDict && colorSpacesDict->FindKey(args[0].GetName())) + { +- PdfObject* csEntry = colorSpaceRes->GetIndirectKey(args[0].GetName()); ++ PdfObject* csEntry = colorSpacesDict->FindKey(args[0].GetName()); + PDFColorSpace retval = getCSType(csEntry); + if (retval != CS_Unknown && !usedColorSpaces.contains(retval)) + usedColorSpaces.append(retval); +@@ -449,9 +459,9 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + } + else + { +- if (colorSpaceRes && colorSpaceRes->GetIndirectKey(args[0].GetName())) ++ if (colorSpacesDict && colorSpacesDict->FindKey(args[0].GetName())) + { +- PdfObject* csEntry = colorSpaceRes->GetIndirectKey(args[0].GetName()); ++ PdfObject* csEntry = colorSpacesDict->FindKey(args[0].GetName()); + PDFColorSpace retval = getCSType(csEntry); + if (retval != CS_Unknown && !usedColorSpaces.contains(retval)) + usedColorSpaces.append(retval); +@@ -503,28 +513,29 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + { + if (!processedNamedXObj.contains(args[0].GetName())) + { +- if (args.size() == 1 && args[0].IsName() && xObjects) ++ if (args.size() == 1 && args[0].IsName() && xObjectsDict) + { +- PdfObject* xObject = xObjects->GetIndirectKey(args[0].GetName()); +- PdfObject* subtypeObject = xObject ? xObject->GetIndirectKey("Subtype") : nullptr; ++ PdfObject* xObject = xObjectsDict->FindKey(args[0].GetName()); ++ PdfDictionary* xObjectDict = (xObject && xObject->IsDictionary()) ? &(xObject->GetDictionary()) : nullptr; ++ PdfObject* subtypeObject = xObjectDict ? xObjectDict->FindKey("Subtype") : nullptr; + if (subtypeObject && subtypeObject->IsName()) + { + if (subtypeObject->GetName() == "Image") + { +- PdfObject* imgColorSpace = xObject->GetIndirectKey("ColorSpace"); ++ PdfObject* imgColorSpace = xObjectDict->FindKey("ColorSpace"); + if (imgColorSpace) + { + PDFColorSpace retval = getCSType(imgColorSpace); + if (retval != CS_Unknown && !usedColorSpaces.contains(retval)) + usedColorSpaces.append(retval); + } +- PdfObject* sMaskObj = xObject->GetIndirectKey("SMask"); ++ PdfObject* sMaskObj = xObjectDict->FindKey("SMask"); + if (sMaskObj) + hasTransparency = true; + PDFImage img; + img.imgName = args[0].GetName().GetEscapedName().c_str(); +- double width = xObject->GetIndirectKey("Width")->GetReal(); +- double height = xObject->GetIndirectKey("Height")->GetReal(); ++ double width = xObjectDict->FindKey("Width")->GetReal(); ++ double height = xObjectDict->FindKey("Height")->GetReal(); + img.dpiX = qRound(width/(currGS.ctm.m11()/72)); + img.dpiY = qRound(height/(currGS.ctm.m22()/72)); + imgs.append(img); +@@ -573,9 +584,9 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + usedColorSpaces.append(CS_DeviceCMYK); + else if (!processedNamedCS.contains(csName)) + { +- if (colorSpaceRes && colorSpaceRes->GetIndirectKey(csName)) ++ if (colorSpacesDict && colorSpacesDict->FindKey(csName)) + { +- PdfObject* csEntry = colorSpaceRes->GetIndirectKey(csName); ++ PdfObject* csEntry = colorSpacesDict->FindKey(csName); + if (csEntry) + { + PDFColorSpace retval = getCSType(csEntry); +@@ -615,9 +626,9 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + { + if (!processedNamedGS.contains(args[0].GetName())) + { +- if (args.size() == 1 && args[0].IsName() && extGState) ++ if (args.size() == 1 && args[0].IsName() && extGStatesDict) + { +- PdfObject* extGStateObj = extGState->GetIndirectKey(args[0].GetName()); ++ PdfObject* extGStateObj = extGStatesDict->FindKey(args[0].GetName()); + if (extGStateObj) + { + inspectExtGStateObj(extGStateObj, usedColorSpaces, hasTransparency, usedFonts, currGS); +@@ -646,9 +657,9 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + } + else + { +- if (args.size() == 2 && args[0].IsName() && fontRes) ++ if (args.size() == 2 && args[0].IsName() && fontsDict) + { +- PdfObject* fontObj = fontRes->GetIndirectKey(args[0].GetName()); ++ PdfObject* fontObj = fontsDict->FindKey(args[0].GetName()); + if (fontObj) + { + PDFFont retval = getFontInfo(fontObj); +@@ -687,9 +698,11 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + } + return true; + } ++ + void PDFAnalyzer::inspectExtGStateObj(PdfObject* extGStateObj, QList & usedColorSpaces, bool & hasTransparency, QList & usedFonts, PDFGraphicState & currGS) + { +- PdfObject* bmObj = extGStateObj->GetIndirectKey("BM"); ++ PdfDictionary* extGStateDict = extGStateObj->IsDictionary() ? &(extGStateObj->GetDictionary()) : nullptr; ++ PdfObject* bmObj = extGStateDict ? extGStateDict->FindKey("BM") : nullptr; + if (bmObj && bmObj->IsName()) + { + currGS.blendModes.clear(); +@@ -706,23 +719,27 @@ void PDFAnalyzer::inspectExtGStateObj(Pd + if (arr[0].IsName() && !(arr[0].GetName() == "Normal" || arr[0].GetName() == "Compatible")) + hasTransparency = true; + } +- PdfObject* caObj = extGStateObj->GetIndirectKey("ca"); ++ ++ PdfObject* caObj = extGStateDict ? extGStateDict->FindKey("ca") : nullptr; + if (caObj && (caObj->IsReal() || caObj->IsNumber())) + { + currGS.fillAlphaConstant = caObj->GetReal(); + if (caObj->GetReal() < 1) + hasTransparency = true; + } +- PdfObject* cAObj = extGStateObj->GetIndirectKey("CA"); ++ ++ PdfObject* cAObj = extGStateDict ? extGStateDict->FindKey("CA") : nullptr; + if (cAObj && (cAObj->IsReal() || cAObj->IsNumber())) + { + if (cAObj->GetReal() < 1) +- hasTransparency = true; ++ hasTransparency = true; + } +- PdfObject* sMaskObj = extGStateObj->GetIndirectKey("SMask"); ++ ++ PdfObject* sMaskObj = extGStateDict ? extGStateDict->FindKey("SMask") : nullptr; + if (sMaskObj && !(sMaskObj->IsName() && sMaskObj->GetName() == "None")) + hasTransparency = true; +- PdfObject* fontObj = extGStateObj->GetIndirectKey("Font"); ++ ++ PdfObject* fontObj = extGStateDict ? extGStateDict->FindKey("Font") : nullptr; + if (fontObj && fontObj->IsArray()) + { + PdfArray arr = fontObj->GetArray(); +@@ -740,19 +757,24 @@ void PDFAnalyzer::inspectExtGStateObj(Pd + + } + } +- PdfObject* lwObj = extGStateObj->GetIndirectKey("LW"); ++ ++ PdfObject* lwObj = extGStateDict ? extGStateDict->FindKey("LW") : nullptr; + if (lwObj) + currGS.lineWidth = lwObj->GetReal(); +- PdfObject* lcObj = extGStateObj->GetIndirectKey("LC"); ++ ++ PdfObject* lcObj = extGStateDict ? extGStateDict->FindKey("LC") : nullptr; + if (lcObj) + currGS.lineCap = lcObj->GetNumber(); +- PdfObject* ljObj = extGStateObj->GetIndirectKey("LJ"); ++ ++ PdfObject* ljObj = extGStateDict ? extGStateDict->FindKey("LJ") : nullptr; + if (ljObj) + currGS.lineJoin = ljObj->GetNumber(); +- PdfObject* mlObj = extGStateObj->GetIndirectKey("ML"); ++ ++ PdfObject* mlObj = extGStateDict ? extGStateDict->FindKey("ML") : nullptr; + if (mlObj) + currGS.miterLimit = mlObj->GetReal(); +- PdfObject* dObj = extGStateObj->GetIndirectKey("D"); ++ ++ PdfObject* dObj = extGStateDict ? extGStateDict->FindKey("D") : nullptr; + if (dObj) + { + PdfObject dObjA = dObj->GetArray()[0]; +@@ -767,56 +789,64 @@ void PDFAnalyzer::inspectExtGStateObj(Pd + PDFFont PDFAnalyzer::getFontInfo(PdfObject* fontObj) + { + PDFFont currFont; +- PdfObject* subtype = fontObj->GetIndirectKey("Subtype"); +- if (subtype && subtype->IsName()) ++ const PdfDictionary* fontDict = fontObj->IsDictionary() ? &(fontObj->GetDictionary()) : nullptr; ++ if (!fontDict) ++ return currFont; ++ ++ const PdfObject* subtype = fontDict->FindKey("Subtype"); ++ if (!subtype || !subtype->IsName()) ++ return currFont; ++ ++ const PdfObject* fontDesc = fontDict->FindKey("FontDescriptor"); ++ if (subtype->GetName() == "Type1") ++ currFont.fontType = F_Type1; ++ else if (subtype->GetName() == "MMType1") ++ currFont.fontType = F_MMType1; ++ else if (subtype->GetName() == "TrueType") ++ currFont.fontType = F_TrueType; ++ else if (subtype->GetName() == "Type3") ++ { ++ currFont.fontType = F_Type3; ++ currFont.isEmbedded = true; ++ fontDesc = nullptr; ++ } ++ else if (subtype->GetName() == "Type0") + { +- PdfObject* fontDesc = fontObj->GetIndirectKey("FontDescriptor"); +- if (subtype->GetName() == "Type1") +- currFont.fontType = F_Type1; +- else if (subtype->GetName() == "MMType1") +- currFont.fontType = F_MMType1; +- else if (subtype->GetName() == "TrueType") +- currFont.fontType = F_TrueType; +- else if (subtype->GetName() == "Type3") +- { +- currFont.fontType = F_Type3; +- currFont.isEmbedded = true; +- fontDesc = nullptr; +- } +- else if (subtype->GetName() == "Type0") ++ const PdfObject* descendantFonts = fontDict->FindKey("DescendantFonts"); ++ if (descendantFonts && descendantFonts->IsArray()) + { +- PdfObject* descendantFonts = fontObj->GetIndirectKey("DescendantFonts"); +- if (descendantFonts && descendantFonts->IsArray()) ++ const PdfReference& refDescFont = descendantFonts->GetArray()[0].GetReference(); ++ PdfObject* descendantFont = descendantFonts->GetOwner()->GetObject(refDescFont); ++ PdfDictionary* descendantFontDict = (descendantFont && descendantFont->IsDictionary()) ? &(descendantFont->GetDictionary()) : nullptr; ++ const PdfObject* subtypeDescFont = descendantFontDict->FindKey("Subtype"); ++ fontDesc = &(descendantFontDict->MustGetKey("FontDescriptor")); ++ if (subtypeDescFont && subtypeDescFont->IsName()) + { +- PdfReference refDescFont = descendantFonts->GetArray()[0].GetReference(); +- PdfObject* descendantFont = descendantFonts->GetOwner()->GetObject(refDescFont); +- PdfObject* subtypeDescFont = descendantFont->GetIndirectKey("Subtype"); +- fontDesc = descendantFont->MustGetIndirectKey("FontDescriptor"); +- if (subtypeDescFont && subtypeDescFont->IsName()) +- { +- if (subtypeDescFont->GetName() == "CIDFontType0") +- currFont.fontType = F_CIDFontType0; +- else if (subtypeDescFont->GetName() == "CIDFontType2") +- currFont.fontType = F_CIDFontType2; +- } ++ if (subtypeDescFont->GetName() == "CIDFontType0") ++ currFont.fontType = F_CIDFontType0; ++ else if (subtypeDescFont->GetName() == "CIDFontType2") ++ currFont.fontType = F_CIDFontType2; + } + } +- if (fontDesc) ++ } ++ ++ const PdfDictionary* fontDescDict = (fontDesc && fontDesc->IsDictionary()) ? &(fontDesc->GetDictionary()) : nullptr; ++ if (fontDescDict) ++ { ++ const PdfObject* fontFile = fontDescDict->FindKey("FontFile"); ++ const PdfObject* fontFile2 = fontDescDict->FindKey("FontFile2"); ++ const PdfObject* fontFile3 = fontDescDict->FindKey("FontFile3"); ++ if (fontFile && fontFile->HasStream()) ++ currFont.isEmbedded = true; ++ if (fontFile2 && fontFile2->HasStream()) ++ currFont.isEmbedded = true; ++ if (fontFile3 && fontFile3->HasStream()) + { +- PdfObject* fontFile = fontDesc->GetIndirectKey("FontFile"); +- PdfObject* fontFile2 = fontDesc->GetIndirectKey("FontFile2"); +- PdfObject* fontFile3 = fontDesc->GetIndirectKey("FontFile3"); +- if (fontFile && fontFile->HasStream()) +- currFont.isEmbedded = true; +- if (fontFile2 && fontFile2->HasStream()) +- currFont.isEmbedded = true; +- if (fontFile3 && fontFile3->HasStream()) +- { +- currFont.isEmbedded = true; +- PdfObject* ff3Subtype = fontFile3->GetIndirectKey("Subtype"); +- if (ff3Subtype && ff3Subtype->IsName() && ff3Subtype->GetName() == "OpenType") +- currFont.isOpenType = true; +- } ++ currFont.isEmbedded = true; ++ const PdfDictionary* fontFile3Dict = fontFile3->IsDictionary() ? &(fontFile3->GetDictionary()) : nullptr; ++ const PdfObject* ff3Subtype = fontFile3Dict ? fontFile3Dict->FindKey("Subtype") : nullptr; ++ if (ff3Subtype && ff3Subtype->IsName() && ff3Subtype->GetName() == "OpenType") ++ currFont.isOpenType = true; + } + } + return currFont; +--- a/scribus/pdflib_core.cpp ++++ b/scribus/pdflib_core.cpp +@@ -9800,16 +9800,20 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PoDoFo::PdfObject* pageObj = page ? page->GetObject() : nullptr; + PoDoFo::PdfObject* contents = page ? page->GetContents() : nullptr; + PoDoFo::PdfObject* resources = page ? page->GetResources() : nullptr; +- for (PoDoFo::PdfObject* par = pageObj; par && !resources; par = par->GetIndirectKey("Parent")) ++ PoDoFo::PdfDictionary* pageObjDict = (pageObj && pageObj->IsDictionary()) ? &(pageObj->GetDictionary()) : nullptr; ++ for (PoDoFo::PdfDictionary* par = pageObjDict, *parentDict = nullptr; par && !resources; par = parentDict) + { +- resources = par->GetIndirectKey("Resources"); ++ resources = par->FindKey("Resources"); ++ PoDoFo::PdfObject* parentObj = par->FindKey("Parent"); ++ parentDict = (parentObj && parentObj->IsDictionary()) ? &(parentObj->GetDictionary()) : nullptr; + } + if (contents && contents->GetDataType() == PoDoFo::ePdfDataType_Dictionary) + { ++ PoDoFo::PdfDictionary& contentsDict = contents->GetDictionary(); + PoDoFo::PdfStream* stream = contents->GetStream(); + QMap importedObjects; + QList referencedObjects; +- PoDoFo::PdfObject* nextObj; ++ PoDoFo::PdfObject* nextObj { nullptr }; + PdfId xObj = writer.newObject(); + PdfId xResources = writer.newObject(); + PdfId xParents = 0; +@@ -9844,14 +9848,16 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + + Pdf::toPdf(pageM.dy()) + " "); + PutDoc("]"); + PutDoc("\n/Resources " + Pdf::toPdf(xResources) + " 0 R"); +- nextObj = page->GetObject()->GetIndirectKey("Group"); ++ PoDoFo::PdfObject* pageObj = page->GetObject(); ++ PoDoFo::PdfDictionary* pageDict = pageObj->IsDictionary() ? &(pageObj->GetDictionary()) : nullptr; ++ nextObj = pageDict ? pageDict->FindKey("Group") : nullptr; + if (nextObj) + { + PutDoc("\n/Group "); // PDF 1.4 + copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); + } + /* +- PoDoFo::PdfObject parents = page->GetObject()->GetIndirectKey("StructParents"); ++ PoDoFo::PdfObject parents = pageDict->FindKey("StructParents"); + if (parents) + { + xParents = writer.newObject(); +@@ -9870,13 +9876,13 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + if (mbuffer[mlen-1] == '\n') + --mlen; + PutDoc("\n/Length " + Pdf::toPdf(static_cast(mlen))); +- nextObj = contents->GetIndirectKey("Filter"); ++ nextObj = contentsDict.FindKey("Filter"); + if (nextObj) + { + PutDoc("\n/Filter "); + copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); + } +- nextObj = contents->GetIndirectKey("DecodeParms"); ++ nextObj = contentsDict.FindKey("DecodeParms"); + if (nextObj) + { + PutDoc("\n/DecodeParms "); +@@ -9967,7 +9973,9 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + + Pdf::toPdf(pageM.dy()) + " "); + PutDoc("]"); + PutDoc("\n/Resources " + Pdf::toPdf(xResources) + " 0 R"); +- nextObj = page->GetObject()->GetIndirectKey("Group"); ++ PoDoFo::PdfObject* pageObj = page->GetObject(); ++ PoDoFo::PdfDictionary* pageDict = pageObj->IsDictionary() ? &(pageObj->GetDictionary()) : nullptr; ++ nextObj = pageDict ? pageDict->FindKey("Group") : nullptr; + if (nextObj) + { + PutDoc("\n/Group "); // PDF 1.4 +@@ -10012,13 +10020,13 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + // --mlen; + PutDoc("\n/Length " + Pdf::toPdf(static_cast(mlen))); + /* +- nextObj = contents->GetIndirectKey("Filter"); ++ nextObj = contentsDict.FindKey("Filter"); + if (nextObj) + { + PutDoc("\n/Filter "); + copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); + } +- nextObj = contents->GetIndirectKey("DecodeParms"); ++ nextObj = contentsDict.FindKey("DecodeParms"); + if (nextObj) + { + PutDoc("\n/DecodeParms "); +--- a/scribus/plugins/import/ai/importai.cpp ++++ b/scribus/plugins/import/ai/importai.cpp +@@ -587,36 +587,41 @@ bool AIPlug::extractFromPDF(const QStrin + PoDoFo::PdfPage *curPage = doc.GetPage(0); + if (curPage != nullptr) + { +- PoDoFo::PdfObject *piece = curPage->GetObject()->GetIndirectKey("PieceInfo"); ++ PoDoFo::PdfObject* pageObj = curPage->GetObject(); ++ PoDoFo::PdfDictionary* pageDict = (pageObj && pageObj->IsDictionary()) ? &(pageObj->GetDictionary()) : nullptr; ++ PoDoFo::PdfObject *piece = pageDict ? pageDict->FindKey("PieceInfo") : nullptr; + if (piece != nullptr) + { +- PoDoFo::PdfObject *illy = piece->GetIndirectKey("Illustrator"); ++ PoDoFo::PdfDictionary* pieceDict = piece->IsDictionary() ? &(piece->GetDictionary()) : nullptr; ++ PoDoFo::PdfObject *illy = pieceDict ? pieceDict->FindKey("Illustrator") : nullptr; + if (illy != nullptr) + { +- PoDoFo::PdfObject *priv = illy->GetIndirectKey("Private"); ++ PoDoFo::PdfDictionary* illyDict = illy->IsDictionary() ? &(illy->GetDictionary()) : nullptr; ++ PoDoFo::PdfObject *priv = illyDict ? illyDict->FindKey("Private") : nullptr; + if (priv == nullptr) + priv = illy; + int num = 0; +- PoDoFo::PdfObject *numBl = priv->GetIndirectKey("NumBlock"); ++ PoDoFo::PdfDictionary* privDict = priv->IsDictionary() ? &(priv->GetDictionary()) : nullptr; ++ PoDoFo::PdfObject *numBl = privDict ? privDict->FindKey("NumBlock") : nullptr; + if (numBl != nullptr) + num = numBl->GetNumber() + 1; + if (num == 0) + num = 99999; + QString name = "AIPrivateData%1"; + QString Key = name.arg(1); +- PoDoFo::PdfObject *data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data())); ++ PoDoFo::PdfObject *data = privDict ? privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())) : nullptr; + if (data == nullptr) + { + name = "AIPDFPrivateData%1"; + Key = name.arg(1); +- data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data())); ++ data = privDict ? privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())) : nullptr; + } + if (data != nullptr) + { + if (num == 2) + { + Key = name.arg(1); +- data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data())); ++ data = privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())); + PoDoFo::PdfStream const *stream = data->GetStream(); + PoDoFo::PdfMemoryOutputStream oStream(1); + stream->GetFilteredCopy(&oStream); +@@ -631,7 +636,7 @@ bool AIPlug::extractFromPDF(const QStrin + for (int a = 2; a < num; a++) + { + Key = name.arg(a); +- data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data())); ++ data = privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())); + if (data == nullptr) + break; + PoDoFo::PdfStream const *stream = data->GetStream(); diff --git a/srcpkgs/scribus/patches/0013-podofo-0.10-compat-podofo-0.10.x.patch b/srcpkgs/scribus/patches/0013-podofo-0.10-compat-podofo-0.10.x.patch new file mode 100644 index 0000000000000..5810becb56446 --- /dev/null +++ b/srcpkgs/scribus/patches/0013-podofo-0.10-compat-podofo-0.10.x.patch @@ -0,0 +1,1602 @@ +From bbaa1944d83a2c68e49927d5bcc462cd870beb2d Mon Sep 17 00:00:00 2001 +From: Jean Ghali +Date: Tue, 15 Aug 2023 02:43:52 +0000 +Subject: [PATCH 09/13] #16948: Fix build with podofo 0.10.x + +git-svn-id: svn://scribus.net/trunk/Scribus@25601 11d20701-8431-0410-a711-e3c959e3b870 +(cherry picked from commit 33580ae8371e993b6e199e710950702c78d7dde1) +--- + scribus/documentchecker.cpp | 18 +- + .../imagedataloaders/scimgdataloader_pdf.cpp | 12 +- + scribus/pdf_analyzer.cpp | 533 +++++++++++++++++- + scribus/pdflib_core.cpp | 480 +++++++++++++--- + scribus/pdflib_core.h | 4 +- + scribus/plugins/import/ai/importai.cpp | 41 +- + 6 files changed, 985 insertions(+), 103 deletions(-) + +--- a/scribus/documentchecker.cpp ++++ b/scribus/documentchecker.cpp +@@ -109,7 +109,7 @@ bool DocumentChecker::checkDocument(Scri + void DocumentChecker::checkPages(ScribusDoc *currDoc, const CheckerPrefs& checkerSettings) + { + errorCodes pageError; +- for (int i=0; i < currDoc->DocPages.count(); ++i ) ++ for (int i = 0; i < currDoc->DocPages.count(); ++i) + { + pageError.clear(); + if (checkerSettings.checkAppliedMasterDifferentSide) +@@ -127,11 +127,11 @@ void DocumentChecker::checkPages(Scribus + } + else + { +- if (pageLoc==LeftPage && masterPageLocation==1) ++ if (pageLoc == LeftPage && masterPageLocation == 1) + error = false; +- else if (pageLoc==RightPage && masterPageLocation==0) ++ else if (pageLoc == RightPage && masterPageLocation == 0) + error = false; +- else if (pageLoc==MiddlePage && masterPageLocation==2) ++ else if (pageLoc == MiddlePage && masterPageLocation == 2) + error = false; + else + error = true; +@@ -596,7 +596,7 @@ void DocumentChecker::checkItems(Scribus + } + if (checkerSettings.checkNotCMYKOrSpot) + { +- for (int i=0; iHasCMS) + { +- for (int i=0; iframeOverflows() && (checkerSettings.checkOverflow) && (!((currItem->isAnnotation()) && ((currItem->annotation().Type() == Annotation::Combobox) || (currItem->annotation().Type() == Annotation::Listbox))))) + itemError.insert(TextOverflow, 0); + +- if (checkerSettings.checkEmptyTextFrames && (currItem->itemText.length()==0 || currItem->frameUnderflows())) ++ if (checkerSettings.checkEmptyTextFrames && (currItem->itemText.length() == 0 || currItem->frameUnderflows())) + { + bool isEmptyAnnotation = (currItem->isAnnotation() && + ((currItem->annotation().Type() == Annotation::Link) || +--- a/scribus/imagedataloaders/scimgdataloader_pdf.cpp ++++ b/scribus/imagedataloaders/scimgdataloader_pdf.cpp +@@ -55,10 +55,16 @@ bool ScImgDataLoader_PDF::loadPicture(co + #ifdef HAVE_PODOFO + try + { +- PoDoFo::PdfError::EnableDebug( false ); +- PoDoFo::PdfError::EnableLogging( false ); +- PoDoFo::PdfMemDocument doc( fn.toLocal8Bit().data() ); ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) ++ PoDoFo::PdfMemDocument doc; ++ doc.Load(fn.toLocal8Bit().data()); ++ m_imageInfoRecord.numberOfPages = doc.GetPages().GetCount(); ++#else ++ PoDoFo::PdfError::EnableDebug(false); ++ PoDoFo::PdfError::EnableLogging(false); ++ PoDoFo::PdfMemDocument doc(fn.toLocal8Bit().data()); + m_imageInfoRecord.numberOfPages = doc.GetPageCount(); ++#endif + if (page > m_imageInfoRecord.numberOfPages) + { + qDebug() << "Incorrect page number specified!"; +--- a/scribus/pdf_analyzer.cpp ++++ b/scribus/pdf_analyzer.cpp +@@ -30,6 +30,10 @@ for which a new license (GPL+exception) + #ifdef HAVE_PODOFO + using namespace PoDoFo; + ++#if (PODOFO_VERSION < PODOFO_MAKE_VERSION(0, 10, 0)) ++#define IsRealStrict IsReal ++#endif ++ + static QHash kwNameMap; + + // we gonna need a map from string values to the defined enum of pdf keywords +@@ -77,10 +81,13 @@ PDFAnalyzer::PDFAnalyzer(QString & filen + + m_pdfdoc = nullptr; + ++#if (PODOFO_VERSION < PODOFO_MAKE_VERSION(0, 10, 0)) + PdfError::EnableDebug( false ); ++#endif + try + { +- m_pdfdoc = new PdfMemDocument(filename.toLocal8Bit().data()); ++ m_pdfdoc = new PdfMemDocument(); ++ m_pdfdoc->Load(filename.toLocal8Bit().data()); + } + catch (PdfError & e) + { +@@ -99,7 +106,12 @@ bool PDFAnalyzer::inspectPDF(int pageNum + { + if (!m_pdfdoc) + return false; ++ ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) ++ PdfPage* page = &(m_pdfdoc->GetPages().GetPageAt(pageNum)); ++#else + PdfPage* page = m_pdfdoc->GetPage(pageNum); ++#endif + return page ? inspectCanvas(page, usedColorSpaces, hasTransparency, usedFonts, imgs) : false; + } + +@@ -139,7 +151,13 @@ PDFColorSpace PDFAnalyzer::getCSType(Pdf + PdfObject* pBase = &base; + if (base.IsReference()) + { ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) ++ PdfDocument* pdfdoc = cs->GetDocument(); ++ PdfIndirectObjectList& pdf_iol = pdfdoc->GetObjects(); ++ pBase = pdf_iol.GetObject(base.GetReference()); ++#else + pBase = cs->GetOwner()->GetObject(base.GetReference()); ++#endif + } + #if (PODOFO_VERSION < PODOFO_MAKE_VERSION(0, 9, 7)) + pBase->SetOwner(cs->GetOwner()); +@@ -180,11 +198,21 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + // get hold of a PdfObject pointer of this canvas + // needed for the finding resources code below to work + PdfPage* page = dynamic_cast(canvas); ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) ++ PdfObject* canvasObject = page ? &(page->GetObject()) : &(dynamic_cast(canvas)->GetObject()); ++ ++#else + PdfObject* canvasObject = page ? (page->GetObject()) : ((dynamic_cast(canvas))->GetObject()); ++#endif + PdfDictionary* canvasDict = (canvasObject && canvasObject->IsDictionary()) ? &(canvasObject->GetDictionary()) : nullptr; + + // find a resource with ColorSpace entry ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) ++ PdfResources* canvasRsrc = canvas->GetResources(); ++ PdfObject* resources = &(canvasRsrc->GetObject()); ++#else + PdfObject* resources = canvas->GetResources(); ++#endif + for (PdfDictionary* par = canvasDict, *parentDict = nullptr; par && !resources; par = parentDict) + { + resources = par->FindKey("Resources"); +@@ -234,6 +262,468 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + + try + { ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) ++ // start parsing the content stream ++ PdfContentReaderArgs tokenizerArgs = { PdfContentReaderFlags::DontFollowXObjectForms }; ++ PdfContentStreamReader tokenizer(*canvas, tokenizerArgs); ++ PdfContent pdfContent; ++ PdfVariant var; ++ bool readToken; ++ ++ int tokenNumber = 0; ++ bool inlineImgDict = false; ++ QList args; ++ QStack gsStack; ++ PDFGraphicState currGS; ++ while ((readToken = tokenizer.TryReadNext(pdfContent))) ++ { ++ ++tokenNumber; ++ if (pdfContent.Type == PdfContentType::Operator) ++ { ++ args.clear(); ++ int stackSize = pdfContent.Stack.size(); ++ for (size_t i = 0; i < stackSize; ++i) ++ args.append(pdfContent.Stack[stackSize - 1 - i]); ++ switch (pdfContent.Operator) ++ { ++ case PdfOperator::q: ++ gsStack.push(currGS); ++ break; ++ case PdfOperator::Q: ++ currGS = gsStack.pop(); ++ break; ++ case PdfOperator::cm: ++ { ++ if (args.size() == 6) ++ { ++ double mt[6]; ++ for (int i = 0; i < 6; ++i) ++ { ++ mt[i] = args[i].GetReal(); ++ } ++ QTransform transMatrix(mt[0], mt[1], mt[2], mt[3], mt[4], mt[5]); ++ currGS.ctm = transMatrix * currGS.ctm; ++ } ++ } ++ break; ++ case PdfOperator::w: ++ currGS.lineWidth = args[0].GetReal(); ++ break; ++ case PdfOperator::J: ++ currGS.lineCap = args[0].GetNumber(); ++ break; ++ case PdfOperator::j: ++ currGS.lineJoin = args[0].GetNumber(); ++ break; ++ case PdfOperator::M: ++ currGS.lineJoin = args[0].GetReal(); ++ break; ++ case PdfOperator::d: ++ { ++ currGS.dashPattern.first.clear(); ++ PdfArray dashArr = args[0].GetArray(); ++ for (uint i = 0; i < dashArr.size(); ++i) ++ currGS.dashPattern.first.append(dashArr[i].GetNumber()); ++ currGS.dashPattern.second = args[1].GetNumber(); ++ } ++ break; ++ case PdfOperator::g: ++ if (!usedColorSpaces.contains(CS_DeviceGray)) ++ usedColorSpaces.append(CS_DeviceGray); ++ currGS.fillCS = CS_DeviceGray; ++ currGS.fillColor.clear(); ++ currGS.fillColor.append(args[0].GetReal()); ++ break; ++ case PdfOperator::G: ++ if (!usedColorSpaces.contains(CS_DeviceGray)) ++ usedColorSpaces.append(CS_DeviceGray); ++ currGS.strokeCS = CS_DeviceGray; ++ currGS.strokeColor.clear(); ++ currGS.strokeColor.append(args[0].GetReal()); ++ break; ++ case PdfOperator::rg: ++ if (!usedColorSpaces.contains(CS_DeviceRGB)) ++ usedColorSpaces.append(CS_DeviceRGB); ++ currGS.fillCS = CS_DeviceRGB; ++ currGS.fillColor.clear(); ++ for (int i = 0; i < args.size(); ++i) ++ currGS.fillColor.append(args[i].GetReal()); ++ break; ++ case PdfOperator::RG: ++ if (!usedColorSpaces.contains(CS_DeviceRGB)) ++ usedColorSpaces.append(CS_DeviceRGB); ++ currGS.strokeCS = CS_DeviceRGB; ++ currGS.strokeColor.clear(); ++ for (int i = 0; i < args.size(); ++i) ++ currGS.strokeColor.append(args[i].GetReal()); ++ break; ++ case PdfOperator::k: ++ if (!usedColorSpaces.contains(CS_DeviceCMYK)) ++ usedColorSpaces.append(CS_DeviceCMYK); ++ currGS.fillCS = CS_DeviceCMYK; ++ currGS.fillColor.clear(); ++ for (int i = 0; i < args.size(); ++i) ++ currGS.fillColor.append(args[i].GetReal()); ++ break; ++ case PdfOperator::K: ++ if (!usedColorSpaces.contains(CS_DeviceCMYK)) ++ usedColorSpaces.append(CS_DeviceCMYK); ++ currGS.strokeCS = CS_DeviceCMYK; ++ currGS.strokeColor.clear(); ++ for (int i = 0; i < args.size(); ++i) ++ currGS.strokeColor.append(args[i].GetReal()); ++ break; ++ case PdfOperator::cs: ++ { ++ if (args.size() == 1 && args[0].IsName()) ++ { ++ if (args[0].GetName() == "DeviceGray") ++ { ++ currGS.fillCS = CS_DeviceGray; ++ currGS.fillColor.clear(); ++ currGS.fillColor.append(0); ++ if (!usedColorSpaces.contains(CS_DeviceGray)) ++ usedColorSpaces.append(CS_DeviceGray); ++ } ++ else if (args[0].GetName() == "DeviceRGB") ++ { ++ currGS.fillCS = CS_DeviceRGB; ++ currGS.fillColor.clear(); ++ for (int i = 0; i < 3; ++i) ++ currGS.fillColor.append(0); ++ if (!usedColorSpaces.contains(CS_DeviceRGB)) ++ usedColorSpaces.append(CS_DeviceRGB); ++ } ++ else if (args[0].GetName() == "DeviceCMYK") ++ { ++ currGS.fillCS = CS_DeviceCMYK; ++ currGS.fillColor.clear(); ++ for (int i = 0; i < 3; ++i) ++ currGS.fillColor.append(0); ++ currGS.fillColor.append(1); ++ if (!usedColorSpaces.contains(CS_DeviceCMYK)) ++ usedColorSpaces.append(CS_DeviceCMYK); ++ } ++ else if (args[0].GetName() == "Pattern") ++ { ++ currGS.fillCS = CS_Pattern; ++ if (!usedColorSpaces.contains(CS_Pattern)) ++ usedColorSpaces.append(CS_Pattern); ++ } ++ else ++ { ++ if (processedNamedCS.contains(args[0].GetName())) ++ { ++ currGS.fillCS = processedNamedCS.value(args[0].GetName()); ++ } ++ else ++ { ++ if (colorSpacesDict && colorSpacesDict->FindKey(args[0].GetName())) ++ { ++ PdfObject* csEntry = colorSpacesDict->FindKey(args[0].GetName()); ++ PDFColorSpace retval = getCSType(csEntry); ++ if (retval != CS_Unknown && !usedColorSpaces.contains(retval)) ++ usedColorSpaces.append(retval); ++ currGS.fillCS = retval; ++ processedNamedCS.insert(args[0].GetName(), retval); ++ } ++ else ++ { ++ qDebug() << "Supplied colorspace is undefined! File:" << m_filename; ++ return false; ++ } ++ } ++ } ++ } ++ else ++ { ++ qDebug() << "Wrong syntax in specifying color space! File:" << m_filename; ++ return false; ++ } ++ } ++ break; ++ case PdfOperator::CS: ++ { ++ if (args.size() == 1 && args[0].IsName()) ++ { ++ if (args[0].GetName() == "DeviceGray") ++ { ++ currGS.strokeCS = CS_DeviceGray; ++ currGS.strokeColor.clear(); ++ currGS.strokeColor.append(0); ++ if (!usedColorSpaces.contains(CS_DeviceGray)) ++ usedColorSpaces.append(CS_DeviceGray); ++ } ++ else if (args[0].GetName() == "DeviceRGB") ++ { ++ currGS.fillCS = CS_DeviceRGB; ++ currGS.strokeColor.clear(); ++ for (int i = 0; i < 3; ++i) ++ currGS.strokeColor.append(0); ++ if (!usedColorSpaces.contains(CS_DeviceRGB)) ++ usedColorSpaces.append(CS_DeviceRGB); ++ } ++ else if (args[0].GetName() == "DeviceCMYK") ++ { ++ currGS.fillCS = CS_DeviceCMYK; ++ currGS.strokeColor.clear(); ++ for (int i = 0; i < 3; ++i) ++ currGS.strokeColor.append(0); ++ currGS.strokeColor.append(1); ++ if (!usedColorSpaces.contains(CS_DeviceCMYK)) ++ usedColorSpaces.append(CS_DeviceCMYK); ++ } ++ else if (args[0].GetName() == "Pattern") ++ { ++ currGS.fillCS = CS_Pattern; ++ if (!usedColorSpaces.contains(CS_Pattern)) ++ usedColorSpaces.append(CS_Pattern); ++ } ++ else ++ { ++ if (processedNamedCS.contains(args[0].GetName())) ++ { ++ currGS.strokeCS = processedNamedCS.value(args[0].GetName()); ++ } ++ else ++ { ++ if (colorSpacesDict && colorSpacesDict->FindKey(args[0].GetName())) ++ { ++ PdfObject* csEntry = colorSpacesDict->FindKey(args[0].GetName()); ++ PDFColorSpace retval = getCSType(csEntry); ++ if (retval != CS_Unknown && !usedColorSpaces.contains(retval)) ++ usedColorSpaces.append(retval); ++ currGS.strokeCS = retval; ++ processedNamedCS.insert(args[0].GetName(), retval); ++ } ++ else ++ { ++ qDebug() << "Supplied colorspace is undefined! File:" << m_filename; ++ return false; ++ } ++ } ++ } ++ } ++ else ++ { ++ qDebug() << "Wrong syntax in specifying color space! File:" << m_filename; ++ return false; ++ } ++ } ++ break; ++ case PdfOperator::sc: ++ currGS.fillColor.clear(); ++ for (int i = 0; i < args.size(); ++i) ++ currGS.fillColor.append(args[i].GetReal()); ++ break; ++ case PdfOperator::SC: ++ currGS.strokeColor.clear(); ++ for (int i = 0; i < args.size(); ++i) ++ currGS.strokeColor.append(args[i].GetReal()); ++ break; ++ case PdfOperator::scn: ++ currGS.fillColor.clear(); ++ for (int i = 0; i < args.size(); ++i) ++ { ++ if (args[i].IsRealStrict() || args[i].IsNumber()) ++ currGS.fillColor.append(args[i].GetReal()); ++ } ++ break; ++ case PdfOperator::SCN: ++ currGS.strokeColor.clear(); ++ for (int i = 0; i < args.size(); ++i) ++ { ++ if (args[i].IsRealStrict() || args[i].IsNumber()) ++ currGS.strokeColor.append(args[i].GetReal()); ++ } ++ break; ++ case PdfOperator::Do: // image or form XObject ++ // Handled in PdfContentType::DoXObject ++ break; ++ case PdfOperator::BI: ++ inlineImgDict = true; ++ break; ++ case PdfOperator::ID: ++ if (inlineImgDict) ++ { ++ PdfName colorspace("ColorSpace"); ++ PdfName cs("CS"); ++ if (args.contains(colorspace) || args.contains(cs)) ++ { ++ int csIdx = args.contains(colorspace) ? args.indexOf(colorspace) : args.indexOf(cs); ++ if (args[csIdx + 1].IsName()) ++ { ++ PdfName csName = args[csIdx + 1].GetName(); ++ if ((csName == "G" || csName == "DeviceGray") && !usedColorSpaces.contains(CS_DeviceGray)) ++ usedColorSpaces.append(CS_DeviceGray); ++ else if ((csName == "RGB" || csName == "DeviceRGB") && !usedColorSpaces.contains(CS_DeviceRGB)) ++ usedColorSpaces.append(CS_DeviceRGB); ++ else if ((csName == "CMYK" || csName == "DeviceCMYK") && !usedColorSpaces.contains(CS_DeviceCMYK)) ++ usedColorSpaces.append(CS_DeviceCMYK); ++ else if (!processedNamedCS.contains(csName)) ++ { ++ if (colorSpacesDict && colorSpacesDict->FindKey(csName)) ++ { ++ PdfObject* csEntry = colorSpacesDict->FindKey(csName); ++ if (csEntry) ++ { ++ PDFColorSpace retval = getCSType(csEntry); ++ if (retval != CS_Unknown && !usedColorSpaces.contains(retval)) ++ usedColorSpaces.append(retval); ++ processedNamedCS.insert(csName, retval); ++ } ++ } ++ else ++ { ++ qDebug() << "Supplied colorspace for inline image is undefined!"; ++ return false; ++ } ++ } ++ } ++ } ++ PdfName height("Height"); ++ PdfName h("H"); ++ PdfName width("Width"); ++ PdfName w("W"); ++ if ((args.contains(height) || args.contains(h)) && (args.contains(width) || args.contains(w))) ++ { ++ int heightIdx = args.contains(height) ? args.indexOf(height) : args.indexOf(h); ++ int widthIdx = args.contains(width) ? args.indexOf(width) : args.indexOf(w); ++ double height = args[heightIdx + 1].GetReal(); ++ double width = args[widthIdx + 1].GetReal(); ++ PDFImage img; ++ img.imgName = "Inline Image"; ++ img.dpiX = qRound(width / (currGS.ctm.m11() / 72)); ++ img.dpiY = qRound(height / (currGS.ctm.m22() / 72)); ++ imgs.append(img); ++ } ++ inlineImgDict = false; ++ } ++ break; ++ case PdfOperator::gs: ++ { ++ if (!processedNamedGS.contains(args[0].GetName())) ++ { ++ if (args.size() == 1 && args[0].IsName() && extGStatesDict) ++ { ++ PdfObject* extGStateObj = extGStatesDict->FindKey(args[0].GetName()); ++ if (extGStateObj) ++ { ++ inspectExtGStateObj(extGStateObj, usedColorSpaces, hasTransparency, usedFonts, currGS); ++ } ++ else ++ { ++ qDebug() << "Named graphic state used with gs operator is undefined in current ExtGState. File:" << m_filename; ++ return false; ++ } ++ processedNamedGS.append(args[0].GetName()); ++ } ++ else ++ { ++ qDebug() << "Wrong syntax in applying extended graphic state (gs operator) or there's no ExtGState defined! File:" << m_filename; ++ return false; ++ } ++ } ++ } ++ break; ++ case PdfOperator::Tf: ++ { ++ if (processedNamedFont.contains(args[0].GetName())) ++ { ++ currGS.font.first = processedNamedFont.value(args[0].GetName()); ++ currGS.font.second = args[1].GetReal(); ++ } ++ else ++ { ++ if (args.size() == 2 && args[0].IsName() && fontsDict) ++ { ++ PdfObject* fontObj = fontsDict->FindKey(args[0].GetName()); ++ if (fontObj) ++ { ++ PDFFont retval = getFontInfo(fontObj); ++ usedFonts.append(retval); ++ processedNamedFont.insert(args[0].GetName(), retval); ++ currGS.font.first = retval; ++ currGS.font.second = args[1].GetReal(); ++ } ++ else ++ { ++ qDebug() << "The specified font cannot be found in current Resources! File:" << m_filename; ++ return false; ++ } ++ } ++ else ++ { ++ qDebug() << "Wrong syntax in use of Tf operator or there's no Font defined in current Resources dictionary! File:" << m_filename; ++ return false; ++ } ++ } ++ } ++ break; ++ case PdfOperator::Unknown: ++ default: ++ break; ++ } ++ args.clear(); ++ } ++ if (pdfContent.Type == PdfContentType::DoXObject) ++ { ++ args.clear(); ++ int stackSize = pdfContent.Stack.size(); ++ for (size_t i = 0; i < stackSize; ++i) ++ args.append(pdfContent.Stack[stackSize - 1 - i]); ++ if (!processedNamedXObj.contains(args[0].GetName())) ++ { ++ if (args.size() == 1 && args[0].IsName() && xObjectsDict) ++ { ++ PdfObject* xObject = xObjectsDict->FindKey(args[0].GetName()); ++ PdfDictionary* xObjectDict = (xObject && xObject->IsDictionary()) ? &(xObject->GetDictionary()) : nullptr; ++ PdfObject* subtypeObject = xObjectDict ? xObjectDict->FindKey("Subtype") : nullptr; ++ if (subtypeObject && subtypeObject->IsName()) ++ { ++ if (subtypeObject->GetName() == "Image") ++ { ++ PdfObject* imgColorSpace = xObjectDict->FindKey("ColorSpace"); ++ if (imgColorSpace) ++ { ++ PDFColorSpace retval = getCSType(imgColorSpace); ++ if (retval != CS_Unknown && !usedColorSpaces.contains(retval)) ++ usedColorSpaces.append(retval); ++ } ++ PdfObject* sMaskObj = xObjectDict->FindKey("SMask"); ++ if (sMaskObj) ++ hasTransparency = true; ++ PDFImage img; ++ img.imgName = args[0].GetName().GetEscapedName().c_str(); ++ double width = xObjectDict->FindKey("Width")->GetReal(); ++ double height = xObjectDict->FindKey("Height")->GetReal(); ++ img.dpiX = qRound(width / (currGS.ctm.m11() / 72)); ++ img.dpiY = qRound(height / (currGS.ctm.m22() / 72)); ++ imgs.append(img); ++ } ++ else if (subtypeObject->GetName() == "Form") ++ { ++ std::unique_ptr xObj; ++ PdfXObject::TryCreateFromObject(*xObject, xObj); ++ inspectCanvas(xObj.get(), usedColorSpaces, hasTransparency, usedFonts, imgs); // recursive call ++ } ++ } ++ else ++ { ++ qDebug() << "Supplied external object is undefined! File:" << m_filename; ++ return false; ++ } ++ processedNamedXObj.append(args[0].GetName()); ++ } ++ else ++ { ++ qDebug() << "Wrong syntax for Do operator or there's no XObject defined! File:" << m_filename; ++ return false; ++ } ++ } ++ } ++ } ++#else + // start parsing the content stream + PdfContentsTokenizer tokenizer(canvas); + EPdfContentsType t; +@@ -269,7 +759,7 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + if (args.size() == 6) + { + double mt[6]; +- for (int i=0; i<6; ++i) ++ for (int i = 0; i < 6; ++i) + { + mt[i] = args[i].GetReal(); + } +@@ -294,7 +784,7 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + { + currGS.dashPattern.first.clear(); + PdfArray dashArr = args[0].GetArray(); +- for (uint i=0; iGetArray(); + currGS.blendModes.clear(); +- for(uint i=0; iFindKey("ca") : nullptr; +- if (caObj && (caObj->IsReal() || caObj->IsNumber())) ++ if (caObj && (caObj->IsRealStrict() || caObj->IsNumber())) + { + currGS.fillAlphaConstant = caObj->GetReal(); + if (caObj->GetReal() < 1) +@@ -729,7 +1220,7 @@ void PDFAnalyzer::inspectExtGStateObj(Pd + } + + PdfObject* cAObj = extGStateDict ? extGStateDict->FindKey("CA") : nullptr; +- if (cAObj && (cAObj->IsReal() || cAObj->IsNumber())) ++ if (cAObj && (cAObj->IsRealStrict() || cAObj->IsNumber())) + { + if (cAObj->GetReal() < 1) + hasTransparency = true; +@@ -780,7 +1271,7 @@ void PDFAnalyzer::inspectExtGStateObj(Pd + PdfObject dObjA = dObj->GetArray()[0]; + PdfArray dashArr = dObjA.GetArray(); + currGS.dashPattern.first.clear(); +- for (uint i=0; iGetArray()[1]; + currGS.dashPattern.second = dObjB.GetNumber(); +@@ -816,7 +1307,11 @@ PDFFont PDFAnalyzer::getFontInfo(PdfObje + if (descendantFonts && descendantFonts->IsArray()) + { + const PdfReference& refDescFont = descendantFonts->GetArray()[0].GetReference(); ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) ++ PdfObject* descendantFont = descendantFonts->GetDocument()->GetObjects().GetObject(refDescFont); ++#else + PdfObject* descendantFont = descendantFonts->GetOwner()->GetObject(refDescFont); ++#endif + PdfDictionary* descendantFontDict = (descendantFont && descendantFont->IsDictionary()) ? &(descendantFont->GetDictionary()) : nullptr; + const PdfObject* subtypeDescFont = descendantFontDict->FindKey("Subtype"); + fontDesc = &(descendantFontDict->MustGetKey("FontDescriptor")); +--- a/scribus/pdflib_core.cpp ++++ b/scribus/pdflib_core.cpp +@@ -9783,22 +9783,298 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + QScopedPointer doc; + try + { ++#if (PODOFO_VERSION < PODOFO_MAKE_VERSION(0, 10, 0)) + PoDoFo::PdfError::EnableDebug(false); + PoDoFo::PdfError::EnableLogging(false); +- doc.reset(new PoDoFo::PdfMemDocument(fn.toLocal8Bit().data())); ++#endif ++ doc.reset(new PoDoFo::PdfMemDocument()); ++ doc->Load(fn.toLocal8Bit().data()); + } +- catch(PoDoFo::PdfError& e) ++ catch (PoDoFo::PdfError& e) + { + qDebug() << "PoDoFo error, falling back to raster!"; + e.PrintErrorMsg(); + return false; + } + ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) + try + { +- PoDoFo::PdfPage* page = doc->GetPage(qMin(qMax(1, c->pixm.imgInfo.actualPageNumber), c->pixm.imgInfo.numberOfPages) - 1); +- PoDoFo::PdfObject* pageObj = page ? page->GetObject() : nullptr; +- PoDoFo::PdfObject* contents = page ? page->GetContents() : nullptr; ++ PoDoFo::PdfPage& page = doc->GetPages().GetPageAt(qMin(qMax(1, c->pixm.imgInfo.actualPageNumber), c->pixm.imgInfo.numberOfPages) - 1); ++ PoDoFo::PdfObject& pageObj = page.GetObject(); ++ PoDoFo::PdfObject* contents = page.GetContents() ? &(page.GetContents()->GetObject()) : nullptr; ++ PoDoFo::PdfObject* resources = page.GetResources() ? &(page.GetResources()->GetObject()) : nullptr; ++ PoDoFo::PdfDictionary* pageObjDict = pageObj.IsDictionary() ? &(pageObj.GetDictionary()) : nullptr; ++ for (PoDoFo::PdfDictionary* par = pageObjDict, *parentDict = nullptr; par && !resources; par = parentDict) ++ { ++ resources = par->FindKey("Resources"); ++ PoDoFo::PdfObject* parentObj = par->FindKey("Parent"); ++ parentDict = (parentObj && parentObj->IsDictionary()) ? &(parentObj->GetDictionary()) : nullptr; ++ } ++ if (contents && contents->GetDataType() == PoDoFo::PdfDataType::Dictionary) ++ { ++ PoDoFo::PdfDictionary& contentsDict = contents->GetDictionary(); ++ PoDoFo::PdfObjectStream* stream = contents->GetStream(); ++ QMap importedObjects; ++ QList referencedObjects; ++ PoDoFo::PdfObject* nextObj { nullptr }; ++ PdfId xObj = writer.newObject(); ++ PdfId xResources = writer.newObject(); ++ PdfId xParents = 0; ++ importedObjects[page.GetObject().GetIndirectReference()] = xObj; ++ writer.startObj(xObj); ++ PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1"); ++ PoDoFo::Rect pageRect = page.GetArtBox(); // Because scimagedataloader_pdf use ArtBox ++ int rotation = page.GetRotationRaw(); ++ double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.Height : pageRect.Width; ++ double imgHeight = (rotation == 90 || rotation == 270) ? pageRect.Width : pageRect.Height; ++ QTransform pageM; ++ pageM.translate(pageRect.GetLeft(), pageRect.GetBottom()); ++ pageM.rotate(rotation); ++ if (rotation == 90) ++ pageM.translate(0.0, -imgHeight); ++ else if (rotation == 180) ++ pageM.translate(-imgWidth, -imgHeight); ++ else if (rotation == 270) ++ pageM.translate(-imgWidth, 0.0); ++ pageM.scale(imgWidth, imgHeight); ++ pageM = pageM.inverted(); ++ PutDoc("\n/BBox [" + Pdf::toPdf(pageRect.GetLeft())); ++ PutDoc(" " + Pdf::toPdf(pageRect.GetBottom())); ++ PutDoc(" " + Pdf::toPdf(pageRect.GetLeft() + pageRect.Width)); ++ PutDoc(" " + Pdf::toPdf(pageRect.GetBottom() + pageRect.Height)); ++ PutDoc("]"); ++ PutDoc("\n/Matrix [" + Pdf::toPdf(pageM.m11()) + " " ++ + Pdf::toPdf(pageM.m12()) + " " ++ + Pdf::toPdf(pageM.m21()) + " " ++ + Pdf::toPdf(pageM.m22()) + " " ++ + Pdf::toPdf(pageM.dx()) + " " ++ + Pdf::toPdf(pageM.dy()) + " "); ++ PutDoc("]"); ++ PutDoc("\n/Resources " + Pdf::toPdf(xResources) + " 0 R"); ++ PoDoFo::PdfDictionary* pageDict = pageObj.IsDictionary() ? &(pageObj.GetDictionary()) : nullptr; ++ nextObj = pageDict ? pageDict->FindKey("Group") : nullptr; ++ if (nextObj) ++ { ++ PutDoc("\n/Group "); // PDF 1.4 ++ copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); ++ } ++ /* ++ PoDoFo::PdfObject parents = pageDict->FindKey("StructParents"); ++ if (parents) ++ { ++ xParents = writer.newObject(); ++ PutDoc("\n/StructParents " + Pdf::toPdf(xParents)); // required if page uses structured content ++ } ++ */ ++ ++ const char* mbuffer = nullptr; ++ long mlen = 0; ++ PoDoFo::charbuff strBuff = stream->GetCopy(true); ++ mlen = strBuff.size(); ++ mbuffer = strBuff.c_str(); ++ if (mbuffer[mlen - 1] == '\n') ++ --mlen; ++ PutDoc("\n/Length " + Pdf::toPdf(static_cast(mlen))); ++ nextObj = contentsDict.FindKey("Filter"); ++ if (nextObj) ++ { ++ PutDoc("\n/Filter "); ++ copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); ++ } ++ nextObj = contentsDict.FindKey("DecodeParms"); ++ if (nextObj) ++ { ++ PutDoc("\n/DecodeParms "); ++ copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); ++ } ++ PutDoc("\n>>\nstream\n"); ++ { ++ QByteArray buffer = QByteArray::fromRawData(mbuffer, mlen); ++ EncodeArrayToStream(buffer, xObj); ++ } // disconnect QByteArray from raw data ++ PutDoc("\nendstream"); ++ writer.endObj(xObj); ++ // write resources ++ if (resources) ++ { ++ copyPoDoFoObject(resources, xResources, importedObjects); ++ } ++ else ++ { ++ writer.startObj(xResources); ++ PutDoc("<< >>"); ++ writer.endObj(xResources); ++ } ++ if (xParents) ++ { ++ // create structured parents ++ } ++ // write referenced objects ++ PoDoFo::PdfIndirectObjectList& allObjects = contents->GetDocument()->GetObjects(); ++ for (int i = 0; i < referencedObjects.size(); ++i) ++ { ++ const PoDoFo::PdfReference& pdfRef = referencedObjects[i]; ++ nextObj = allObjects.GetObject(pdfRef); ++ copyPoDoFoObject(nextObj, importedObjects[pdfRef], importedObjects); ++ } ++ ++ pageData.ImgObjects[ResNam + "I" + Pdf::toPdf(ResCount)] = xObj; ++ imgInfo.ResNum = ResCount; ++ ResCount++; ++ // Avoid a divide-by-zero if width/height are less than 1 point: ++ imgInfo.Width = qMax(1, (int) imgWidth); ++ imgInfo.Height = qMax(1, (int) imgHeight); ++ imgInfo.xa = sx * imgWidth / imgInfo.Width; ++ imgInfo.ya = sy * imgHeight / imgInfo.Height; ++ // Width/Height are integers and may not exactly equal pageRect.GetWidth()/ ++ // pageRect.GetHeight(). Adjust scale factor to compensate for the difference. ++ imgInfo.sxa = sx * imgWidth / imgInfo.Width; ++ imgInfo.sya = sy * imgHeight / imgInfo.Height; ++ ++ return true; ++ } ++ if (contents && contents->GetDataType() == PoDoFo::PdfDataType::Array)//Page contents might be an array ++ { ++ QMap importedObjects; ++ QList referencedObjects; ++ PoDoFo::PdfObject* nextObj; ++ PdfId xObj = writer.newObject(); ++ PdfId xResources = writer.newObject(); ++ PdfId xParents = 0; ++ importedObjects[page.GetObject().GetIndirectReference()] = xObj; ++ writer.startObj(xObj); ++ PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1"); ++ PoDoFo::Rect pageRect = page.GetArtBox(); // Because scimagedataloader_pdf use ArtBox ++ int rotation = page.GetRotationRaw(); ++ double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.Height : pageRect.Width; ++ double imgHeight = (rotation == 90 || rotation == 270) ? pageRect.Width : pageRect.Height; ++ QTransform pageM; ++ pageM.translate(pageRect.GetLeft(), pageRect.GetBottom()); ++ pageM.rotate(rotation); ++ if (rotation == 90) ++ pageM.translate(0.0, -imgHeight); ++ else if (rotation == 180) ++ pageM.translate(-imgWidth, -imgHeight); ++ else if (rotation == 270) ++ pageM.translate(-imgWidth, 0.0); ++ pageM.scale(imgWidth, imgHeight); ++ pageM = pageM.inverted(); ++ PutDoc("\n/BBox [" + Pdf::toPdf(pageRect.GetLeft())); ++ PutDoc(" " + Pdf::toPdf(pageRect.GetBottom())); ++ PutDoc(" " + Pdf::toPdf(pageRect.GetLeft() + pageRect.Width)); ++ PutDoc(" " + Pdf::toPdf(pageRect.GetBottom() + pageRect.Height)); ++ PutDoc("]"); ++ PutDoc("\n/Matrix [" + Pdf::toPdf(pageM.m11()) + " " ++ + Pdf::toPdf(pageM.m12()) + " " ++ + Pdf::toPdf(pageM.m21()) + " " ++ + Pdf::toPdf(pageM.m22()) + " " ++ + Pdf::toPdf(pageM.dx()) + " " ++ + Pdf::toPdf(pageM.dy()) + " "); ++ PutDoc("]"); ++ PutDoc("\n/Resources " + Pdf::toPdf(xResources) + " 0 R"); ++ PoDoFo::PdfDictionary* pageDict = pageObj.IsDictionary() ? &(pageObj.GetDictionary()) : nullptr; ++ nextObj = pageDict ? pageDict->FindKey("Group") : nullptr; ++ if (nextObj) ++ { ++ PutDoc("\n/Group "); // PDF 1.4 ++ copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); ++ } ++ ++ const char* mbuffer = nullptr; ++ long mlen = 0; ++ PoDoFo::charbuff strBuffer; ++ PoDoFo::StringStreamDevice strStreamDev(strBuffer); ++ PoDoFo::PdfArray carray(page.GetContents()->GetObject().GetArray()); ++ for (unsigned int ci = 0; ci < carray.size(); ++ci) ++ { ++ if (carray[ci].HasStream()) ++ { ++ carray[ci].GetStream()->CopyTo(strStreamDev, false); ++ } ++ else if (carray[ci].IsReference()) ++ { ++ nextObj = doc->GetObjects().GetObject(carray[ci].GetReference()); ++ ++ while (nextObj != nullptr) ++ { ++ if (nextObj->IsReference()) ++ { ++ nextObj = doc->GetObjects().GetObject(nextObj->GetReference()); ++ } ++ else if (nextObj->HasStream()) ++ { ++ nextObj->GetStream()->CopyTo(strStreamDev, false); ++ break; ++ } ++ } ++ } ++ } ++ // end of copy ++ mlen = strBuffer.size(); ++ mbuffer = strBuffer.c_str(); ++ ++ PutDoc("\n/Length " + Pdf::toPdf(static_cast(mlen))); ++ PutDoc("\n>>\nstream\n"); ++ { ++ QByteArray buffer = QByteArray::fromRawData(mbuffer, mlen); ++ EncodeArrayToStream(buffer, xObj); ++ } // disconnect QByteArray from raw data ++ PutDoc("\nendstream"); ++ writer.endObj(xObj); ++ // write resources ++ if (resources) ++ { ++ copyPoDoFoObject(resources, xResources, importedObjects); ++ } ++ else ++ { ++ writer.startObj(xResources); ++ PutDoc("<< >>"); ++ writer.endObj(xResources); ++ } ++ if (xParents) ++ { ++ // create structured parents ++ } ++ // write referenced objects ++ PoDoFo::PdfIndirectObjectList& allObjects = contents->GetDocument()->GetObjects(); ++ for (int i = 0; i < referencedObjects.size(); ++i) ++ { ++ const PoDoFo::PdfReference& pdfRef = referencedObjects[i]; ++ nextObj = allObjects.GetObject(pdfRef); ++ copyPoDoFoObject(nextObj, importedObjects[pdfRef], importedObjects); ++ } ++ ++ pageData.ImgObjects[ResNam + "I" + Pdf::toPdf(ResCount)] = xObj; ++ imgInfo.ResNum = ResCount; ++ ResCount++; ++ // Avoid a divide-by-zero if width/height are less than 1 point: ++ imgInfo.Width = qMax(1, (int) imgWidth); ++ imgInfo.Height = qMax(1, (int) imgHeight); ++ imgInfo.xa = sx * imgWidth / imgInfo.Width; ++ imgInfo.ya = sy * imgHeight / imgInfo.Height; ++ // Width/Height are integers and may not exactly equal pageRect.GetWidth()/ ++ // pageRect.GetHeight(). Adjust scale factor to compensate for the difference. ++ imgInfo.sxa = sx * imgWidth / imgInfo.Width; ++ imgInfo.sya = sy * imgHeight / imgInfo.Height; ++ ++ return true; ++ } ++ } ++ catch (PoDoFo::PdfError& e) ++ { ++ fatalError = true; ++ qDebug() << "PoDoFo error!"; ++ e.PrintErrorMsg(); ++ return false; ++ } ++#else ++ try ++ { ++ PoDoFo::PdfPage* page = doc->GetPage(qMin(qMax(1, c->pixm.imgInfo.actualPageNumber), c->pixm.imgInfo.numberOfPages) - 1); ++ PoDoFo::PdfObject* pageObj = page ? page->GetObject() : nullptr; ++ PoDoFo::PdfObject* contents = page ? page->GetContents() : nullptr; + PoDoFo::PdfObject* resources = page ? page->GetResources() : nullptr; + PoDoFo::PdfDictionary* pageObjDict = (pageObj && pageObj->IsDictionary()) ? &(pageObj->GetDictionary()) : nullptr; + for (PoDoFo::PdfDictionary* par = pageObjDict, *parentDict = nullptr; par && !resources; par = parentDict) +@@ -9807,13 +10083,13 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PoDoFo::PdfObject* parentObj = par->FindKey("Parent"); + parentDict = (parentObj && parentObj->IsDictionary()) ? &(parentObj->GetDictionary()) : nullptr; + } +- if (contents && contents->GetDataType() == PoDoFo::ePdfDataType_Dictionary) ++ if (contents && contents->GetDataType() == PoDoFo::ePdfDataType_Dictionary) + { + PoDoFo::PdfDictionary& contentsDict = contents->GetDictionary(); + PoDoFo::PdfStream* stream = contents->GetStream(); + QMap importedObjects; + QList referencedObjects; +- PoDoFo::PdfObject* nextObj { nullptr }; ++ const PoDoFo::PdfObject* nextObj { nullptr }; + PdfId xObj = writer.newObject(); + PdfId xResources = writer.newObject(); + PdfId xParents = 0; +@@ -9822,7 +10098,7 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1"); + PoDoFo::PdfRect pageRect = page->GetArtBox(); // Because scimagedataloader_pdf use ArtBox + int rotation = page->GetRotation(); +- double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.GetHeight() : pageRect.GetWidth(); ++ double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.GetHeight() : pageRect.GetWidth(); + double imgHeight = (rotation == 90 || rotation == 270) ? pageRect.GetWidth() : pageRect.GetHeight(); + QTransform pageM; + pageM.translate(pageRect.GetLeft(), pageRect.GetBottom()); +@@ -9841,14 +10117,13 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc(" " + Pdf::toPdf(pageRect.GetBottom() + pageRect.GetHeight())); + PutDoc("]"); + PutDoc("\n/Matrix [" + Pdf::toPdf(pageM.m11()) + " " +- + Pdf::toPdf(pageM.m12()) + " " +- + Pdf::toPdf(pageM.m21()) + " " +- + Pdf::toPdf(pageM.m22()) + " " +- + Pdf::toPdf(pageM.dx()) + " " +- + Pdf::toPdf(pageM.dy()) + " "); ++ + Pdf::toPdf(pageM.m12()) + " " ++ + Pdf::toPdf(pageM.m21()) + " " ++ + Pdf::toPdf(pageM.m22()) + " " ++ + Pdf::toPdf(pageM.dx()) + " " ++ + Pdf::toPdf(pageM.dy()) + " "); + PutDoc("]"); + PutDoc("\n/Resources " + Pdf::toPdf(xResources) + " 0 R"); +- PoDoFo::PdfObject* pageObj = page->GetObject(); + PoDoFo::PdfDictionary* pageDict = pageObj->IsDictionary() ? &(pageObj->GetDictionary()) : nullptr; + nextObj = pageDict ? pageDict->FindKey("Group") : nullptr; + if (nextObj) +@@ -9864,16 +10139,16 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc("\n/StructParents " + Pdf::toPdf(xParents)); // required if page uses structured content + } + */ +- char * mbuffer = nullptr; +- long mlen = 0; + + // seems more complicated at first, but in fact it makes the code more stable wrt podofo changes ++ char* mbuffer = nullptr; ++ long mlen = 0; + PoDoFo::PdfMemoryOutputStream oStream(1); + stream->GetCopy(&oStream); + oStream.Close(); + mlen = oStream.GetLength(); + mbuffer = oStream.TakeBuffer(); +- if (mbuffer[mlen-1] == '\n') ++ if (mbuffer[mlen - 1] == '\n') + --mlen; + PutDoc("\n/Length " + Pdf::toPdf(static_cast(mlen))); + nextObj = contentsDict.FindKey("Filter"); +@@ -9893,7 +10168,7 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + QByteArray buffer = QByteArray::fromRawData(mbuffer, mlen); + EncodeArrayToStream(buffer, xObj); + } // disconnect QByteArray from raw data +- free (mbuffer); ++ free(mbuffer); + PutDoc("\nendstream"); + writer.endObj(xObj); + // write resources +@@ -9915,18 +10190,19 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PoDoFo::PdfVecObjects* allObjects = contents->GetOwner(); + for (int i=0; i < referencedObjects.size(); ++i) + { +- nextObj = allObjects->GetObject(referencedObjects[i]); +- copyPoDoFoObject(nextObj, importedObjects[nextObj->Reference()], importedObjects); ++ const PoDoFo::PdfReference& pdfRef = referencedObjects[i]; ++ nextObj = allObjects->GetObject(pdfRef); ++ copyPoDoFoObject(nextObj, importedObjects[pdfRef], importedObjects); + } + + pageData.ImgObjects[ResNam + "I" + Pdf::toPdf(ResCount)] = xObj; + imgInfo.ResNum = ResCount; + ResCount++; + // Avoid a divide-by-zero if width/height are less than 1 point: +- imgInfo.Width = qMax(1, (int) imgWidth); ++ imgInfo.Width = qMax(1, (int) imgWidth); + imgInfo.Height = qMax(1, (int) imgHeight); +- imgInfo.xa = sx * imgWidth / imgInfo.Width; +- imgInfo.ya = sy * imgHeight / imgInfo.Height; ++ imgInfo.xa = sx * imgWidth / imgInfo.Width; ++ imgInfo.ya = sy * imgHeight / imgInfo.Height; + // Width/Height are integers and may not exactly equal pageRect.GetWidth()/ + // pageRect.GetHeight(). Adjust scale factor to compensate for the difference. + imgInfo.sxa = sx * imgWidth / imgInfo.Width; +@@ -9934,7 +10210,7 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + + return true; + } +- if (contents && contents->GetDataType() == PoDoFo::ePdfDataType_Array)//Page contents might be an array ++ if (contents && contents->GetDataType() == PoDoFo::ePdfDataType_Array)//Page contents might be an array + { + QMap importedObjects; + QList referencedObjects; +@@ -9947,7 +10223,7 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1"); + PoDoFo::PdfRect pageRect = page->GetArtBox(); // Because scimagedataloader_pdf use ArtBox + int rotation = page->GetRotation(); +- double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.GetHeight() : pageRect.GetWidth(); ++ double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.GetHeight() : pageRect.GetWidth(); + double imgHeight = (rotation == 90 || rotation == 270) ? pageRect.GetWidth() : pageRect.GetHeight(); + QTransform pageM; + pageM.translate(pageRect.GetLeft(), pageRect.GetBottom()); +@@ -9966,14 +10242,13 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc(" " + Pdf::toPdf(pageRect.GetBottom() + pageRect.GetHeight())); + PutDoc("]"); + PutDoc("\n/Matrix [" + Pdf::toPdf(pageM.m11()) + " " +- + Pdf::toPdf(pageM.m12()) + " " +- + Pdf::toPdf(pageM.m21()) + " " +- + Pdf::toPdf(pageM.m22()) + " " +- + Pdf::toPdf(pageM.dx()) + " " +- + Pdf::toPdf(pageM.dy()) + " "); ++ + Pdf::toPdf(pageM.m12()) + " " ++ + Pdf::toPdf(pageM.m21()) + " " ++ + Pdf::toPdf(pageM.m22()) + " " ++ + Pdf::toPdf(pageM.dx()) + " " ++ + Pdf::toPdf(pageM.dy()) + " "); + PutDoc("]"); + PutDoc("\n/Resources " + Pdf::toPdf(xResources) + " 0 R"); +- PoDoFo::PdfObject* pageObj = page->GetObject(); + PoDoFo::PdfDictionary* pageDict = pageObj->IsDictionary() ? &(pageObj->GetDictionary()) : nullptr; + nextObj = pageDict ? pageDict->FindKey("Group") : nullptr; + if (nextObj) +@@ -9982,11 +10257,10 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); + } + +- char * mbuffer = nullptr; +- long mlen = 0; + // copied from podofoimpose +- PoDoFo::PdfMemoryOutputStream outMemStream (1); +-// PoDoFo::PdfFilteredEncodeStream outMemStream (outMemStreamRaw, ePdfFilter_FlateDecode, false); ++ char* mbuffer = nullptr; ++ long mlen = 0; ++ PoDoFo::PdfMemoryOutputStream outMemStream(1); + PoDoFo::PdfArray carray(page->GetContents()->GetArray()); + for (unsigned int ci = 0; ci < carray.size(); ++ci) + { +@@ -10000,7 +10274,6 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + + while (nextObj != nullptr) + { +- + if (nextObj->IsReference()) + { + nextObj = doc->GetObjects().GetObject(nextObj->GetReference()); +@@ -10016,29 +10289,13 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + // end of copy + mlen = outMemStream.GetLength(); + mbuffer = outMemStream.TakeBuffer(); +-// if (mbuffer[mlen-1] == '\n') +-// --mlen; + PutDoc("\n/Length " + Pdf::toPdf(static_cast(mlen))); +-/* +- nextObj = contentsDict.FindKey("Filter"); +- if (nextObj) +- { +- PutDoc("\n/Filter "); +- copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); +- } +- nextObj = contentsDict.FindKey("DecodeParms"); +- if (nextObj) +- { +- PutDoc("\n/DecodeParms "); +- copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); +- } +-*/ + PutDoc("\n>>\nstream\n"); + { + QByteArray buffer = QByteArray::fromRawData(mbuffer, mlen); + EncodeArrayToStream(buffer, xObj); + } // disconnect QByteArray from raw data +- free (mbuffer); ++ free(mbuffer); + PutDoc("\nendstream"); + writer.endObj(xObj); + // write resources +@@ -10058,20 +10315,21 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + } + // write referenced objects + PoDoFo::PdfVecObjects* allObjects = contents->GetOwner(); +- for (int i=0; i < referencedObjects.size(); ++i) ++ for (int i = 0; i < referencedObjects.size(); ++i) + { +- nextObj = allObjects->GetObject(referencedObjects[i]); +- copyPoDoFoObject(nextObj, importedObjects[nextObj->Reference()], importedObjects); ++ const PoDoFo::PdfReference& pdfRef = referencedObjects[i]; ++ nextObj = allObjects->GetObject(pdfRef); ++ copyPoDoFoObject(nextObj, importedObjects[pdfRef], importedObjects); + } + + pageData.ImgObjects[ResNam + "I" + Pdf::toPdf(ResCount)] = xObj; + imgInfo.ResNum = ResCount; + ResCount++; + // Avoid a divide-by-zero if width/height are less than 1 point: +- imgInfo.Width = qMax(1, (int) imgWidth); ++ imgInfo.Width = qMax(1, (int) imgWidth); + imgInfo.Height = qMax(1, (int) imgHeight); +- imgInfo.xa = sx * imgWidth / imgInfo.Width; +- imgInfo.ya = sy * imgHeight / imgInfo.Height; ++ imgInfo.xa = sx * imgWidth / imgInfo.Width; ++ imgInfo.ya = sy * imgHeight / imgInfo.Height; + // Width/Height are integers and may not exactly equal pageRect.GetWidth()/ + // pageRect.GetHeight(). Adjust scale factor to compensate for the difference. + imgInfo.sxa = sx * imgWidth / imgInfo.Width; +@@ -10079,24 +10337,76 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + + return true; + } +- + } +- catch(PoDoFo::PdfError& e) ++ catch (PoDoFo::PdfError& e) + { + fatalError = true; + qDebug() << "PoDoFo error!"; + e.PrintErrorMsg(); + return false; + } +-#endif ++#endif // PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0) ++ ++#endif // HAVE_PODOFO + return false; + } + + + #if HAVE_PODOFO + +-void PDFLibCore::copyPoDoFoDirect(const PoDoFo::PdfVariant* obj, QList& referencedObjects, QMap& importedObjects) ++void PDFLibCore::copyPoDoFoDirect(const PoDoFo::PdfObject* obj, QList& referencedObjects, QMap& importedObjects) + { ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) ++ switch (obj->GetDataType()) ++ { ++ case PoDoFo::PdfDataType::Reference: ++ { ++ const PoDoFo::PdfReference& reference(obj->GetReference()); ++ PdfId objNr; ++ if (!importedObjects.contains(reference)) ++ { ++ objNr = writer.newObject(); ++ importedObjects[reference] = objNr; ++ referencedObjects.append(reference); ++ } ++ else ++ { ++ objNr = importedObjects[reference]; ++ } ++ PutDoc(" " + Pdf::toPdf(objNr) + " 0 R"); ++ break; ++ } ++ case PoDoFo::PdfDataType::Array: ++ { ++ const PoDoFo::PdfArray& array(obj->GetArray()); ++ PutDoc("["); ++ for (uint i = 0; i < array.size(); ++i) ++ copyPoDoFoDirect(&(array[i]), referencedObjects, importedObjects); ++ PutDoc("]"); ++ break; ++ } ++ case PoDoFo::PdfDataType::Dictionary: ++ { ++ const PoDoFo::PdfDictionary& dict(obj->GetDictionary()); ++ PutDoc("<<"); ++ for (auto k = dict.begin(); k != dict.end(); ++k) ++ { ++ std::string str("\n/" + k->first.GetEscapedName()); ++ PutDoc(QByteArray::fromRawData(str.data(), str.size())); ++ copyPoDoFoDirect(&k->second, referencedObjects, importedObjects); ++ } ++ PutDoc(" >>"); ++ break; ++ } ++ default: ++ { ++ std::string str; ++ obj->GetVariant().ToString(str); ++ str = " " + str; ++ PutDoc(QByteArray::fromRawData(str.data(), str.size())); ++ } ++ } ++#else + switch (obj->GetDataType()) + { + case PoDoFo::ePdfDataType_Reference: +@@ -10147,11 +10457,41 @@ void PDFLibCore::copyPoDoFoDirect(const + PutDoc(QByteArray::fromRawData(str.data(), str.size())); + } + } +- ++#endif + } + + void PDFLibCore::copyPoDoFoObject(const PoDoFo::PdfObject* obj, PdfId scObjID, QMap& importedObjects) + { ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) ++ const PoDoFo::PdfIndirectObjectList& allObjects = obj->GetDocument()->GetObjects(); ++ QList referencedObjects; ++ writer.startObj(scObjID); ++ copyPoDoFoDirect(obj, referencedObjects, importedObjects); ++ if (obj->HasStream()) ++ { ++ const PoDoFo::PdfObjectStream* stream = obj->GetStream(); ++ PoDoFo::charbuff strBuff = stream->GetCopy(true); ++ const char* mbuffer = strBuff.c_str(); ++ size_t mlen = strBuff.size(); ++ if (mbuffer[mlen - 1] == '\n') ++ --mlen; ++ PutDoc("\nstream\n"); ++ { ++ QByteArray buffer = QByteArray::fromRawData(mbuffer, mlen); ++ EncodeArrayToStream(buffer, scObjID); ++ } ++ PutDoc("\nendstream"); ++ } ++ PutDoc(""); ++ writer.endObj(scObjID); ++ // recurse: ++ for (int i = 0; i < referencedObjects.size(); ++i) ++ { ++ const PoDoFo::PdfReference& pdfRef = referencedObjects[i]; ++ const PoDoFo::PdfObject* nextObj = allObjects.GetObject(pdfRef); ++ copyPoDoFoObject(nextObj, importedObjects[pdfRef], importedObjects); ++ } ++#else + PoDoFo::PdfVecObjects* allObjects = obj->GetOwner(); + QList referencedObjects; + writer.startObj(scObjID); +@@ -10159,7 +10499,7 @@ void PDFLibCore::copyPoDoFoObject(const + if (obj->HasStream()) + { + const PoDoFo::PdfStream* stream = obj->GetStream(); +- char * mbuffer = nullptr; ++ char* mbuffer = nullptr; + long mlen = 0; + + // seems more complicated at first, but in fact it makes the code more stable wrt podofo changes +@@ -10168,14 +10508,14 @@ void PDFLibCore::copyPoDoFoObject(const + oStream.Close(); + mlen = oStream.GetLength(); + mbuffer = oStream.TakeBuffer(); +- if (mbuffer[mlen-1] == '\n') ++ if (mbuffer[mlen - 1] == '\n') + --mlen; + PutDoc("\nstream\n"); + { + QByteArray buffer = QByteArray::fromRawData(mbuffer, mlen); + EncodeArrayToStream(buffer, scObjID); + } // disconnect QByteArray from raw data +- free (mbuffer); ++ free(mbuffer); + PutDoc("\nendstream"); + } + PutDoc(""); +@@ -10183,9 +10523,11 @@ void PDFLibCore::copyPoDoFoObject(const + // recurse: + for (int i=0; i < referencedObjects.size(); ++i) + { +- PoDoFo::PdfObject* nextObj = allObjects->GetObject(referencedObjects[i]); +- copyPoDoFoObject(nextObj, importedObjects[nextObj->Reference()], importedObjects); ++ const PoDoFo::PdfReference& pdfRef = referencedObjects[i]; ++ const PoDoFo::PdfObject* nextObj = allObjects->GetObject(pdfRef); ++ copyPoDoFoObject(nextObj, importedObjects[pdfRef], importedObjects); + } ++#endif + } + #endif + +--- a/scribus/pdflib_core.h ++++ b/scribus/pdflib_core.h +@@ -225,8 +225,8 @@ private: + bool PDF_Image(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN = false, const QString& Profil = "", bool Embedded = false, eRenderIntent Intent = Intent_Relative_Colorimetric, QByteArray* output = nullptr); + bool PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, double sy, double x, double y, ShIm& imgInfo, bool &fatalError); + #if HAVE_PODOFO +- void copyPoDoFoObject(const PoDoFo::PdfObject* obj, uint scObjID, QMap& importedObjects); +- void copyPoDoFoDirect(const PoDoFo::PdfVariant* obj, QList& referencedObjects, QMap& importedObjects); ++ void copyPoDoFoObject(const PoDoFo::PdfObject* obj, PdfId scObjID, QMap& importedObjects); ++ void copyPoDoFoDirect(const PoDoFo::PdfObject* obj, QList& referencedObjects, QMap& importedObjects); + #endif + + quint32 encode32dVal(double val) const; +--- a/scribus/plugins/import/ai/importai.cpp ++++ b/scribus/plugins/import/ai/importai.cpp +@@ -581,13 +581,24 @@ bool AIPlug::extractFromPDF(const QStrin + } + try + { ++#if (PODOFO_VERSION < PODOFO_MAKE_VERSION(0, 10, 0)) + PoDoFo::PdfError::EnableDebug( false ); + PoDoFo::PdfError::EnableLogging( false ); +- PoDoFo::PdfMemDocument doc( infile.toLocal8Bit().data() ); ++#endif ++ PoDoFo::PdfMemDocument doc; ++ doc.Load(infile.toLocal8Bit().data()); ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) ++ PoDoFo::PdfPage* curPage = &(doc.GetPages().GetPageAt(0)); ++#else + PoDoFo::PdfPage *curPage = doc.GetPage(0); ++#endif + if (curPage != nullptr) + { ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) ++ PoDoFo::PdfObject* pageObj = &(curPage->GetObject()); ++#else + PoDoFo::PdfObject* pageObj = curPage->GetObject(); ++#endif + PoDoFo::PdfDictionary* pageDict = (pageObj && pageObj->IsDictionary()) ? &(pageObj->GetDictionary()) : nullptr; + PoDoFo::PdfObject *piece = pageDict ? pageDict->FindKey("PieceInfo") : nullptr; + if (piece != nullptr) +@@ -618,6 +629,33 @@ bool AIPlug::extractFromPDF(const QStrin + } + if (data != nullptr) + { ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) ++ if (num == 2) ++ { ++ Key = name.arg(1); ++ data = privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())); ++ PoDoFo::PdfObjectStream const* stream = data->GetStream(); ++ PoDoFo::charbuff strBuffer = stream->GetCopy(false); ++ qint64 bLen = strBuffer.size(); ++ const char* Buffer = strBuffer.c_str(); ++ outf.write(Buffer, bLen); ++ } ++ else ++ { ++ for (int a = 2; a < num; a++) ++ { ++ Key = name.arg(a); ++ data = privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())); ++ if (data == nullptr) ++ break; ++ PoDoFo::PdfObjectStream const* stream = data->GetStream(); ++ PoDoFo::charbuff strBuffer = stream->GetCopy(false); ++ qint64 bLen = strBuffer.size(); ++ const char* Buffer = strBuffer.c_str(); ++ outf.write(Buffer, bLen); ++ } ++ } ++#else + if (num == 2) + { + Key = name.arg(1); +@@ -649,6 +687,7 @@ bool AIPlug::extractFromPDF(const QStrin + free( Buffer ); + } + } ++#endif + } + ret = true; + } diff --git a/srcpkgs/scribus/patches/0014-podofo-0.10-compat-podofo-0.9.6.patch b/srcpkgs/scribus/patches/0014-podofo-0.10-compat-podofo-0.9.6.patch new file mode 100644 index 0000000000000..750d8fa0a9440 --- /dev/null +++ b/srcpkgs/scribus/patches/0014-podofo-0.10-compat-podofo-0.9.6.patch @@ -0,0 +1,853 @@ +From 000d73d22b362a010bd4c80e6076343bc62119f3 Mon Sep 17 00:00:00 2001 +From: Jean Ghali +Date: Wed, 16 Aug 2023 20:54:40 +0000 +Subject: [PATCH 10/13] #17005: Restore compatibility with podofo <= 0.9.6 + +git-svn-id: svn://scribus.net/trunk/Scribus@25604 11d20701-8431-0410-a711-e3c959e3b870 +(cherry picked from commit 6ca4984f122b46a6ab03300efab6b858b5c77a2d) +--- + scribus/pdf_analyzer.cpp | 274 +++++++++++++++++++++---- + scribus/pdflib_core.cpp | 80 ++++---- + scribus/plugins/import/ai/importai.cpp | 134 +++++++----- + 3 files changed, 350 insertions(+), 138 deletions(-) + +--- a/scribus/pdf_analyzer.cpp ++++ b/scribus/pdf_analyzer.cpp +@@ -30,10 +30,6 @@ for which a new license (GPL+exception) + #ifdef HAVE_PODOFO + using namespace PoDoFo; + +-#if (PODOFO_VERSION < PODOFO_MAKE_VERSION(0, 10, 0)) +-#define IsRealStrict IsReal +-#endif +- + static QHash kwNameMap; + + // we gonna need a map from string values to the defined enum of pdf keywords +@@ -184,6 +180,7 @@ PDFColorSpace PDFAnalyzer::getCSType(Pdf + + bool PDFAnalyzer::inspectCanvas(PdfCanvas* canvas, QList & usedColorSpaces, bool & hasTransparency, QList & usedFonts, QList & imgs) + { ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) + // this method can be used to get used color spaces, detect transparency, and get used fonts in either PdfPage or PdfXObject + PdfDictionary* colorSpacesDict { nullptr }; + PdfDictionary* xObjectsDict { nullptr }; +@@ -198,21 +195,12 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + // get hold of a PdfObject pointer of this canvas + // needed for the finding resources code below to work + PdfPage* page = dynamic_cast(canvas); +-#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) + PdfObject* canvasObject = page ? &(page->GetObject()) : &(dynamic_cast(canvas)->GetObject()); +- +-#else +- PdfObject* canvasObject = page ? (page->GetObject()) : ((dynamic_cast(canvas))->GetObject()); +-#endif + PdfDictionary* canvasDict = (canvasObject && canvasObject->IsDictionary()) ? &(canvasObject->GetDictionary()) : nullptr; + + // find a resource with ColorSpace entry +-#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) + PdfResources* canvasRsrc = canvas->GetResources(); + PdfObject* resources = &(canvasRsrc->GetObject()); +-#else +- PdfObject* resources = canvas->GetResources(); +-#endif + for (PdfDictionary* par = canvasDict, *parentDict = nullptr; par && !resources; par = parentDict) + { + resources = par->FindKey("Resources"); +@@ -262,26 +250,24 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + + try + { +-#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) + // start parsing the content stream + PdfContentReaderArgs tokenizerArgs = { PdfContentReaderFlags::DontFollowXObjectForms }; + PdfContentStreamReader tokenizer(*canvas, tokenizerArgs); + PdfContent pdfContent; + PdfVariant var; +- bool readToken; + + int tokenNumber = 0; + bool inlineImgDict = false; + QList args; + QStack gsStack; + PDFGraphicState currGS; +- while ((readToken = tokenizer.TryReadNext(pdfContent))) ++ while (tokenizer.TryReadNext(pdfContent)) + { + ++tokenNumber; + if (pdfContent.Type == PdfContentType::Operator) + { + args.clear(); +- int stackSize = pdfContent.Stack.size(); ++ size_t stackSize = pdfContent.Stack.size(); + for (size_t i = 0; i < stackSize; ++i) + args.append(pdfContent.Stack[stackSize - 1 - i]); + switch (pdfContent.Operator) +@@ -669,7 +655,7 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + if (pdfContent.Type == PdfContentType::DoXObject) + { + args.clear(); +- int stackSize = pdfContent.Stack.size(); ++ size_t stackSize = pdfContent.Stack.size(); + for (size_t i = 0; i < stackSize; ++i) + args.append(pdfContent.Stack[stackSize - 1 - i]); + if (!processedNamedXObj.contains(args[0].GetName())) +@@ -723,7 +709,73 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + } + } + } ++ } ++ catch (PdfError & e) ++ { ++ qDebug() << "Error in parsing content stream File:" << m_filename; ++ e.PrintErrorMsg(); ++ return false; ++ } ++ return true; + #else ++ // this method can be used to get used color spaces, detect transparency, and get used fonts in either PdfPage or PdfXObject ++ PdfObject* colorSpaceRes { nullptr }; ++ PdfObject* xObjects { nullptr }; ++ PdfObject* transGroup { nullptr }; ++ PdfObject* extGState { nullptr }; ++ PdfObject* fontRes { nullptr }; ++ QMap processedNamedCS; ++ QMap processedNamedFont; ++ QList processedNamedXObj; ++ QList processedNamedGS; ++ try ++ { ++ // get hold of a PdfObject pointer of this canvas ++ // needed for the finding resources code below to work ++ PdfPage* page = dynamic_cast(canvas); ++ PdfObject* canvasObject = page ? (page->GetObject()) : ((dynamic_cast(canvas))->GetObject()); ++ ++ // find a resource with ColorSpace entry ++ PdfObject* resources = canvas->GetResources(); ++ for (PdfObject* par = canvasObject; par && !resources; par = par->GetIndirectKey("Parent")) ++ { ++ resources = par->GetIndirectKey("Resources"); ++ } ++ colorSpaceRes = resources ? resources->GetIndirectKey("ColorSpace") : nullptr; ++ xObjects = resources ? resources->GetIndirectKey("XObject") : nullptr; ++ extGState = resources ? resources->GetIndirectKey("ExtGState") : nullptr; ++ fontRes = resources ? resources->GetIndirectKey("Font") : nullptr; ++ ++ // getting the transparency group of this content stream (if available) ++ transGroup = canvasObject ? canvasObject->GetIndirectKey("Group") : nullptr; ++ if (transGroup) ++ { ++ PdfObject* subtype = transGroup->GetIndirectKey("S"); ++ if (subtype && subtype->GetName() == "Transparency") ++ { ++ // having transparency group means there's transparency in the PDF ++ hasTransparency = true; ++ ++ // reporting the color space used in transparency group (Section 7.5.5, PDF 1.6 Spec) ++ PdfObject* cs = transGroup->GetIndirectKey("CS"); ++ if (cs) ++ { ++ PDFColorSpace retval = getCSType(cs); ++ if (retval != CS_Unknown && !usedColorSpaces.contains(retval)) ++ usedColorSpaces.append(retval); ++ } ++ } ++ } ++ } ++ catch (PdfError & e) ++ { ++ qDebug() << "Error in analyzing stream's resources. File:" << m_filename; ++ e.PrintErrorMsg(); ++ return false; ++ } ++ ++ try ++ { + // start parsing the content stream + PdfContentsTokenizer tokenizer(canvas); + EPdfContentsType t; +@@ -880,9 +932,9 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + } + else + { +- if (colorSpacesDict && colorSpacesDict->FindKey(args[0].GetName())) ++ if (colorSpaceRes && colorSpaceRes->GetIndirectKey(args[0].GetName())) + { +- PdfObject* csEntry = colorSpacesDict->FindKey(args[0].GetName()); ++ PdfObject* csEntry = colorSpaceRes->GetIndirectKey(args[0].GetName()); + PDFColorSpace retval = getCSType(csEntry); + if (retval != CS_Unknown && !usedColorSpaces.contains(retval)) + usedColorSpaces.append(retval); +@@ -949,9 +1001,9 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + } + else + { +- if (colorSpacesDict && colorSpacesDict->FindKey(args[0].GetName())) ++ if (colorSpaceRes && colorSpaceRes->GetIndirectKey(args[0].GetName())) + { +- PdfObject* csEntry = colorSpacesDict->FindKey(args[0].GetName()); ++ PdfObject* csEntry = colorSpaceRes->GetIndirectKey(args[0].GetName()); + PDFColorSpace retval = getCSType(csEntry); + if (retval != CS_Unknown && !usedColorSpaces.contains(retval)) + usedColorSpaces.append(retval); +@@ -1003,29 +1055,28 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + { + if (!processedNamedXObj.contains(args[0].GetName())) + { +- if (args.size() == 1 && args[0].IsName() && xObjectsDict) ++ if (args.size() == 1 && args[0].IsName() && xObjects) + { +- PdfObject* xObject = xObjectsDict->FindKey(args[0].GetName()); +- PdfDictionary* xObjectDict = (xObject && xObject->IsDictionary()) ? &(xObject->GetDictionary()) : nullptr; +- PdfObject* subtypeObject = xObjectDict ? xObjectDict->FindKey("Subtype") : nullptr; ++ PdfObject* xObject = xObjects->GetIndirectKey(args[0].GetName()); ++ PdfObject* subtypeObject = xObject ? xObject->GetIndirectKey("Subtype") : nullptr; + if (subtypeObject && subtypeObject->IsName()) + { + if (subtypeObject->GetName() == "Image") + { +- PdfObject* imgColorSpace = xObjectDict->FindKey("ColorSpace"); ++ PdfObject* imgColorSpace = xObject->GetIndirectKey("ColorSpace"); + if (imgColorSpace) + { + PDFColorSpace retval = getCSType(imgColorSpace); + if (retval != CS_Unknown && !usedColorSpaces.contains(retval)) + usedColorSpaces.append(retval); + } +- PdfObject* sMaskObj = xObjectDict->FindKey("SMask"); ++ PdfObject* sMaskObj = xObject->GetIndirectKey("SMask"); + if (sMaskObj) + hasTransparency = true; + PDFImage img; + img.imgName = args[0].GetName().GetEscapedName().c_str(); +- double width = xObjectDict->FindKey("Width")->GetReal(); +- double height = xObjectDict->FindKey("Height")->GetReal(); ++ double width = xObject->GetIndirectKey("Width")->GetReal(); ++ double height = xObject->GetIndirectKey("Height")->GetReal(); + img.dpiX = qRound(width/(currGS.ctm.m11()/72)); + img.dpiY = qRound(height/(currGS.ctm.m22()/72)); + imgs.append(img); +@@ -1074,9 +1125,9 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + usedColorSpaces.append(CS_DeviceCMYK); + else if (!processedNamedCS.contains(csName)) + { +- if (colorSpacesDict && colorSpacesDict->FindKey(csName)) ++ if (colorSpaceRes && colorSpaceRes->GetIndirectKey(csName)) + { +- PdfObject* csEntry = colorSpacesDict->FindKey(csName); ++ PdfObject* csEntry = colorSpaceRes->GetIndirectKey(csName); + if (csEntry) + { + PDFColorSpace retval = getCSType(csEntry); +@@ -1116,9 +1167,9 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + { + if (!processedNamedGS.contains(args[0].GetName())) + { +- if (args.size() == 1 && args[0].IsName() && extGStatesDict) ++ if (args.size() == 1 && args[0].IsName() && extGState) + { +- PdfObject* extGStateObj = extGStatesDict->FindKey(args[0].GetName()); ++ PdfObject* extGStateObj = extGState->GetIndirectKey(args[0].GetName()); + if (extGStateObj) + { + inspectExtGStateObj(extGStateObj, usedColorSpaces, hasTransparency, usedFonts, currGS); +@@ -1147,9 +1198,9 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + } + else + { +- if (args.size() == 2 && args[0].IsName() && fontsDict) ++ if (args.size() == 2 && args[0].IsName() && fontRes) + { +- PdfObject* fontObj = fontsDict->FindKey(args[0].GetName()); ++ PdfObject* fontObj = fontRes->GetIndirectKey(args[0].GetName()); + if (fontObj) + { + PDFFont retval = getFontInfo(fontObj); +@@ -1179,7 +1230,6 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + args.clear(); + } + } +-#endif + } + catch (PdfError & e) + { +@@ -1188,10 +1238,12 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva + return false; + } + return true; ++#endif + } + + void PDFAnalyzer::inspectExtGStateObj(PdfObject* extGStateObj, QList & usedColorSpaces, bool & hasTransparency, QList & usedFonts, PDFGraphicState & currGS) + { ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) + PdfDictionary* extGStateDict = extGStateObj->IsDictionary() ? &(extGStateObj->GetDictionary()) : nullptr; + PdfObject* bmObj = extGStateDict ? extGStateDict->FindKey("BM") : nullptr; + if (bmObj && bmObj->IsName()) +@@ -1245,7 +1297,6 @@ void PDFAnalyzer::inspectExtGStateObj(Pd + currGS.font.first = font; + currGS.font.second = arr[1].GetReal(); + } +- + } + } + +@@ -1276,9 +1327,96 @@ void PDFAnalyzer::inspectExtGStateObj(Pd + PdfObject dObjB = dObj->GetArray()[1]; + currGS.dashPattern.second = dObjB.GetNumber(); + } ++#else ++ PdfObject* bmObj = extGStateObj->GetIndirectKey("BM"); ++ if (bmObj && bmObj->IsName()) ++ { ++ currGS.blendModes.clear(); ++ currGS.blendModes.append(bmObj->GetName().GetEscapedName().c_str()); ++ if (!(bmObj->GetName() == "Normal" || bmObj->GetName() == "Compatible")) ++ hasTransparency = true; ++ } ++ else if (bmObj && bmObj->IsArray()) ++ { ++ PdfArray arr = bmObj->GetArray(); ++ currGS.blendModes.clear(); ++ for (uint i = 0; i < arr.GetSize(); ++i) ++ currGS.blendModes.append(arr[i].GetName().GetEscapedName().c_str()); ++ if (arr[0].IsName() && !(arr[0].GetName() == "Normal" || arr[0].GetName() == "Compatible")) ++ hasTransparency = true; ++ } ++ ++ PdfObject* caObj = extGStateObj->GetIndirectKey("ca"); ++ if (caObj && (caObj->IsReal() || caObj->IsNumber())) ++ { ++ currGS.fillAlphaConstant = caObj->GetReal(); ++ if (caObj->GetReal() < 1) ++ hasTransparency = true; ++ } ++ ++ PdfObject* cAObj = extGStateObj->GetIndirectKey("CA"); ++ if (cAObj && (cAObj->IsReal() || cAObj->IsNumber())) ++ { ++ if (cAObj->GetReal() < 1) ++ hasTransparency = true; ++ } ++ ++ PdfObject* sMaskObj = extGStateObj->GetIndirectKey("SMask"); ++ if (sMaskObj && !(sMaskObj->IsName() && sMaskObj->GetName() == "None")) ++ hasTransparency = true; ++ ++ PdfObject* fontObj = extGStateObj->GetIndirectKey("Font"); ++ if (fontObj && fontObj->IsArray()) ++ { ++ PdfArray arr = fontObj->GetArray(); ++ if (arr[0].IsReference()) ++ { ++ PdfReference ref = arr[0].GetReference(); ++ PdfObject* fontObject = m_pdfdoc->GetObjects().GetObject(ref); ++ if (fontObject) ++ { ++ PDFFont font = getFontInfo(fontObject); ++ usedFonts.append(font); ++ currGS.font.first = font; ++ currGS.font.second = arr[1].GetReal(); ++ } ++ ++ } ++ } ++ ++ PdfObject* lwObj = extGStateObj->GetIndirectKey("LW"); ++ if (lwObj) ++ currGS.lineWidth = lwObj->GetReal(); ++ ++ PdfObject* lcObj = extGStateObj->GetIndirectKey("LC"); ++ if (lcObj) ++ currGS.lineCap = lcObj->GetNumber(); ++ ++ PdfObject* ljObj = extGStateObj->GetIndirectKey("LJ"); ++ if (ljObj) ++ currGS.lineJoin = ljObj->GetNumber(); ++ ++ PdfObject* mlObj = extGStateObj->GetIndirectKey("ML"); ++ if (mlObj) ++ currGS.miterLimit = mlObj->GetReal(); ++ ++ PdfObject* dObj = extGStateObj->GetIndirectKey("D"); ++ if (dObj) ++ { ++ PdfObject dObjA = dObj->GetArray()[0]; ++ PdfArray dashArr = dObjA.GetArray(); ++ currGS.dashPattern.first.clear(); ++ for (uint i = 0; i < dashArr.GetSize(); ++i) ++ currGS.dashPattern.first.append(dashArr[i].GetNumber()); ++ PdfObject dObjB = dObj->GetArray()[1]; ++ currGS.dashPattern.second = dObjB.GetNumber(); ++ } ++#endif + } ++ + PDFFont PDFAnalyzer::getFontInfo(PdfObject* fontObj) + { ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) + PDFFont currFont; + const PdfDictionary* fontDict = fontObj->IsDictionary() ? &(fontObj->GetDictionary()) : nullptr; + if (!fontDict) +@@ -1307,11 +1445,7 @@ PDFFont PDFAnalyzer::getFontInfo(PdfObje + if (descendantFonts && descendantFonts->IsArray()) + { + const PdfReference& refDescFont = descendantFonts->GetArray()[0].GetReference(); +-#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) + PdfObject* descendantFont = descendantFonts->GetDocument()->GetObjects().GetObject(refDescFont); +-#else +- PdfObject* descendantFont = descendantFonts->GetOwner()->GetObject(refDescFont); +-#endif + PdfDictionary* descendantFontDict = (descendantFont && descendantFont->IsDictionary()) ? &(descendantFont->GetDictionary()) : nullptr; + const PdfObject* subtypeDescFont = descendantFontDict->FindKey("Subtype"); + fontDesc = &(descendantFontDict->MustGetKey("FontDescriptor")); +@@ -1345,6 +1479,62 @@ PDFFont PDFAnalyzer::getFontInfo(PdfObje + } + } + return currFont; ++#else ++ PDFFont currFont; ++ PdfObject* subtype = fontObj->GetIndirectKey("Subtype"); ++ if (!subtype || !subtype->IsName()) ++ return currFont; ++ ++ PdfObject* fontDesc = fontObj->GetIndirectKey("FontDescriptor"); ++ if (subtype->GetName() == "Type1") ++ currFont.fontType = F_Type1; ++ else if (subtype->GetName() == "MMType1") ++ currFont.fontType = F_MMType1; ++ else if (subtype->GetName() == "TrueType") ++ currFont.fontType = F_TrueType; ++ else if (subtype->GetName() == "Type3") ++ { ++ currFont.fontType = F_Type3; ++ currFont.isEmbedded = true; ++ fontDesc = nullptr; ++ } ++ else if (subtype->GetName() == "Type0") ++ { ++ PdfObject* descendantFonts = fontObj->GetIndirectKey("DescendantFonts"); ++ if (descendantFonts && descendantFonts->IsArray()) ++ { ++ PdfReference refDescFont = descendantFonts->GetArray()[0].GetReference(); ++ PdfObject* descendantFont = descendantFonts->GetOwner()->GetObject(refDescFont); ++ PdfObject* subtypeDescFont = descendantFont->GetIndirectKey("Subtype"); ++ fontDesc = descendantFont->MustGetIndirectKey("FontDescriptor"); ++ if (subtypeDescFont && subtypeDescFont->IsName()) ++ { ++ if (subtypeDescFont->GetName() == "CIDFontType0") ++ currFont.fontType = F_CIDFontType0; ++ else if (subtypeDescFont->GetName() == "CIDFontType2") ++ currFont.fontType = F_CIDFontType2; ++ } ++ } ++ } ++ if (fontDesc) ++ { ++ PdfObject* fontFile = fontDesc->GetIndirectKey("FontFile"); ++ PdfObject* fontFile2 = fontDesc->GetIndirectKey("FontFile2"); ++ PdfObject* fontFile3 = fontDesc->GetIndirectKey("FontFile3"); ++ if (fontFile && fontFile->HasStream()) ++ currFont.isEmbedded = true; ++ if (fontFile2 && fontFile2->HasStream()) ++ currFont.isEmbedded = true; ++ if (fontFile3 && fontFile3->HasStream()) ++ { ++ currFont.isEmbedded = true; ++ PdfObject* ff3Subtype = fontFile3->GetIndirectKey("Subtype"); ++ if (ff3Subtype && ff3Subtype->IsName() && ff3Subtype->GetName() == "OpenType") ++ currFont.isOpenType = true; ++ } ++ } ++ return currFont; ++#endif + } + #else + PDFAnalyzer::PDFAnalyzer(QString & filename) : QObject() +--- a/scribus/pdflib_core.cpp ++++ b/scribus/pdflib_core.cpp +@@ -9826,7 +9826,7 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1"); + PoDoFo::Rect pageRect = page.GetArtBox(); // Because scimagedataloader_pdf use ArtBox + int rotation = page.GetRotationRaw(); +- double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.Height : pageRect.Width; ++ double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.Height : pageRect.Width; + double imgHeight = (rotation == 90 || rotation == 270) ? pageRect.Width : pageRect.Height; + QTransform pageM; + pageM.translate(pageRect.GetLeft(), pageRect.GetBottom()); +@@ -9845,11 +9845,11 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc(" " + Pdf::toPdf(pageRect.GetBottom() + pageRect.Height)); + PutDoc("]"); + PutDoc("\n/Matrix [" + Pdf::toPdf(pageM.m11()) + " " +- + Pdf::toPdf(pageM.m12()) + " " +- + Pdf::toPdf(pageM.m21()) + " " +- + Pdf::toPdf(pageM.m22()) + " " +- + Pdf::toPdf(pageM.dx()) + " " +- + Pdf::toPdf(pageM.dy()) + " "); ++ + Pdf::toPdf(pageM.m12()) + " " ++ + Pdf::toPdf(pageM.m21()) + " " ++ + Pdf::toPdf(pageM.m22()) + " " ++ + Pdf::toPdf(pageM.dx()) + " " ++ + Pdf::toPdf(pageM.dy()) + " "); + PutDoc("]"); + PutDoc("\n/Resources " + Pdf::toPdf(xResources) + " 0 R"); + PoDoFo::PdfDictionary* pageDict = pageObj.IsDictionary() ? &(pageObj.GetDictionary()) : nullptr; +@@ -9947,7 +9947,7 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1"); + PoDoFo::Rect pageRect = page.GetArtBox(); // Because scimagedataloader_pdf use ArtBox + int rotation = page.GetRotationRaw(); +- double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.Height : pageRect.Width; ++ double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.Height : pageRect.Width; + double imgHeight = (rotation == 90 || rotation == 270) ? pageRect.Width : pageRect.Height; + QTransform pageM; + pageM.translate(pageRect.GetLeft(), pageRect.GetBottom()); +@@ -9966,11 +9966,11 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc(" " + Pdf::toPdf(pageRect.GetBottom() + pageRect.Height)); + PutDoc("]"); + PutDoc("\n/Matrix [" + Pdf::toPdf(pageM.m11()) + " " +- + Pdf::toPdf(pageM.m12()) + " " +- + Pdf::toPdf(pageM.m21()) + " " +- + Pdf::toPdf(pageM.m22()) + " " +- + Pdf::toPdf(pageM.dx()) + " " +- + Pdf::toPdf(pageM.dy()) + " "); ++ + Pdf::toPdf(pageM.m12()) + " " ++ + Pdf::toPdf(pageM.m21()) + " " ++ + Pdf::toPdf(pageM.m22()) + " " ++ + Pdf::toPdf(pageM.dx()) + " " ++ + Pdf::toPdf(pageM.dy()) + " "); + PutDoc("]"); + PutDoc("\n/Resources " + Pdf::toPdf(xResources) + " 0 R"); + PoDoFo::PdfDictionary* pageDict = pageObj.IsDictionary() ? &(pageObj.GetDictionary()) : nullptr; +@@ -10072,20 +10072,16 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + #else + try + { +- PoDoFo::PdfPage* page = doc->GetPage(qMin(qMax(1, c->pixm.imgInfo.actualPageNumber), c->pixm.imgInfo.numberOfPages) - 1); +- PoDoFo::PdfObject* pageObj = page ? page->GetObject() : nullptr; +- PoDoFo::PdfObject* contents = page ? page->GetContents() : nullptr; ++ PoDoFo::PdfPage* page = doc->GetPage(qMin(qMax(1, c->pixm.imgInfo.actualPageNumber), c->pixm.imgInfo.numberOfPages) - 1); ++ PoDoFo::PdfObject* pageObj = page ? page->GetObject() : nullptr; ++ PoDoFo::PdfObject* contents = page ? page->GetContents() : nullptr; + PoDoFo::PdfObject* resources = page ? page->GetResources() : nullptr; +- PoDoFo::PdfDictionary* pageObjDict = (pageObj && pageObj->IsDictionary()) ? &(pageObj->GetDictionary()) : nullptr; +- for (PoDoFo::PdfDictionary* par = pageObjDict, *parentDict = nullptr; par && !resources; par = parentDict) ++ for (PoDoFo::PdfObject* par = pageObj; par && !resources; par = par->GetIndirectKey("Parent")) + { +- resources = par->FindKey("Resources"); +- PoDoFo::PdfObject* parentObj = par->FindKey("Parent"); +- parentDict = (parentObj && parentObj->IsDictionary()) ? &(parentObj->GetDictionary()) : nullptr; ++ resources = par->GetIndirectKey("Resources"); + } +- if (contents && contents->GetDataType() == PoDoFo::ePdfDataType_Dictionary) ++ if (contents && contents->GetDataType() == PoDoFo::ePdfDataType_Dictionary) + { +- PoDoFo::PdfDictionary& contentsDict = contents->GetDictionary(); + PoDoFo::PdfStream* stream = contents->GetStream(); + QMap importedObjects; + QList referencedObjects; +@@ -10098,7 +10094,7 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1"); + PoDoFo::PdfRect pageRect = page->GetArtBox(); // Because scimagedataloader_pdf use ArtBox + int rotation = page->GetRotation(); +- double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.GetHeight() : pageRect.GetWidth(); ++ double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.GetHeight() : pageRect.GetWidth(); + double imgHeight = (rotation == 90 || rotation == 270) ? pageRect.GetWidth() : pageRect.GetHeight(); + QTransform pageM; + pageM.translate(pageRect.GetLeft(), pageRect.GetBottom()); +@@ -10117,22 +10113,21 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc(" " + Pdf::toPdf(pageRect.GetBottom() + pageRect.GetHeight())); + PutDoc("]"); + PutDoc("\n/Matrix [" + Pdf::toPdf(pageM.m11()) + " " +- + Pdf::toPdf(pageM.m12()) + " " +- + Pdf::toPdf(pageM.m21()) + " " +- + Pdf::toPdf(pageM.m22()) + " " +- + Pdf::toPdf(pageM.dx()) + " " +- + Pdf::toPdf(pageM.dy()) + " "); ++ + Pdf::toPdf(pageM.m12()) + " " ++ + Pdf::toPdf(pageM.m21()) + " " ++ + Pdf::toPdf(pageM.m22()) + " " ++ + Pdf::toPdf(pageM.dx()) + " " ++ + Pdf::toPdf(pageM.dy()) + " "); + PutDoc("]"); + PutDoc("\n/Resources " + Pdf::toPdf(xResources) + " 0 R"); +- PoDoFo::PdfDictionary* pageDict = pageObj->IsDictionary() ? &(pageObj->GetDictionary()) : nullptr; +- nextObj = pageDict ? pageDict->FindKey("Group") : nullptr; ++ nextObj = page->GetObject()->GetIndirectKey("Group"); + if (nextObj) + { + PutDoc("\n/Group "); // PDF 1.4 + copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); + } + /* +- PoDoFo::PdfObject parents = pageDict->FindKey("StructParents"); ++ PoDoFo::PdfObject parents = page->GetObject()->GetIndirectKey("StructParents"); + if (parents) + { + xParents = writer.newObject(); +@@ -10151,13 +10146,13 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + if (mbuffer[mlen - 1] == '\n') + --mlen; + PutDoc("\n/Length " + Pdf::toPdf(static_cast(mlen))); +- nextObj = contentsDict.FindKey("Filter"); ++ nextObj = contents->GetIndirectKey("Filter"); + if (nextObj) + { + PutDoc("\n/Filter "); + copyPoDoFoDirect(nextObj, referencedObjects, importedObjects); + } +- nextObj = contentsDict.FindKey("DecodeParms"); ++ nextObj = contents->GetIndirectKey("DecodeParms"); + if (nextObj) + { + PutDoc("\n/DecodeParms "); +@@ -10168,7 +10163,7 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + QByteArray buffer = QByteArray::fromRawData(mbuffer, mlen); + EncodeArrayToStream(buffer, xObj); + } // disconnect QByteArray from raw data +- free(mbuffer); ++ free (mbuffer); + PutDoc("\nendstream"); + writer.endObj(xObj); + // write resources +@@ -10223,7 +10218,7 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1"); + PoDoFo::PdfRect pageRect = page->GetArtBox(); // Because scimagedataloader_pdf use ArtBox + int rotation = page->GetRotation(); +- double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.GetHeight() : pageRect.GetWidth(); ++ double imgWidth = (rotation == 90 || rotation == 270) ? pageRect.GetHeight() : pageRect.GetWidth(); + double imgHeight = (rotation == 90 || rotation == 270) ? pageRect.GetWidth() : pageRect.GetHeight(); + QTransform pageM; + pageM.translate(pageRect.GetLeft(), pageRect.GetBottom()); +@@ -10242,15 +10237,14 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + PutDoc(" " + Pdf::toPdf(pageRect.GetBottom() + pageRect.GetHeight())); + PutDoc("]"); + PutDoc("\n/Matrix [" + Pdf::toPdf(pageM.m11()) + " " +- + Pdf::toPdf(pageM.m12()) + " " +- + Pdf::toPdf(pageM.m21()) + " " +- + Pdf::toPdf(pageM.m22()) + " " +- + Pdf::toPdf(pageM.dx()) + " " +- + Pdf::toPdf(pageM.dy()) + " "); ++ + Pdf::toPdf(pageM.m12()) + " " ++ + Pdf::toPdf(pageM.m21()) + " " ++ + Pdf::toPdf(pageM.m22()) + " " ++ + Pdf::toPdf(pageM.dx()) + " " ++ + Pdf::toPdf(pageM.dy()) + " "); + PutDoc("]"); + PutDoc("\n/Resources " + Pdf::toPdf(xResources) + " 0 R"); +- PoDoFo::PdfDictionary* pageDict = pageObj->IsDictionary() ? &(pageObj->GetDictionary()) : nullptr; +- nextObj = pageDict ? pageDict->FindKey("Group") : nullptr; ++ nextObj = page->GetObject()->GetIndirectKey("Group"); + if (nextObj) + { + PutDoc("\n/Group "); // PDF 1.4 +@@ -10326,7 +10320,7 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageIte + imgInfo.ResNum = ResCount; + ResCount++; + // Avoid a divide-by-zero if width/height are less than 1 point: +- imgInfo.Width = qMax(1, (int) imgWidth); ++ imgInfo.Width = qMax(1, (int) imgWidth); + imgInfo.Height = qMax(1, (int) imgHeight); + imgInfo.xa = sx * imgWidth / imgInfo.Width; + imgInfo.ya = sy * imgHeight / imgInfo.Height; +--- a/scribus/plugins/import/ai/importai.cpp ++++ b/scribus/plugins/import/ai/importai.cpp +@@ -579,87 +579,115 @@ bool AIPlug::extractFromPDF(const QStrin + qDebug() << "Failed to open QFile outf in AIPlug::extractFromPDF"; + return false; + } ++ ++#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) + try + { +-#if (PODOFO_VERSION < PODOFO_MAKE_VERSION(0, 10, 0)) +- PoDoFo::PdfError::EnableDebug( false ); +- PoDoFo::PdfError::EnableLogging( false ); +-#endif + PoDoFo::PdfMemDocument doc; + doc.Load(infile.toLocal8Bit().data()); +-#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) +- PoDoFo::PdfPage* curPage = &(doc.GetPages().GetPageAt(0)); ++ ++ PoDoFo::PdfPage& curPage = doc.GetPages().GetPageAt(0); ++ PoDoFo::PdfObject& pageObj = curPage.GetObject(); ++ PoDoFo::PdfDictionary* pageDict = pageObj.IsDictionary() ? &(pageObj.GetDictionary()) : nullptr; ++ PoDoFo::PdfObject *piece = pageDict ? pageDict->FindKey("PieceInfo") : nullptr; ++ if (piece != nullptr) ++ { ++ PoDoFo::PdfDictionary* pieceDict = piece->IsDictionary() ? &(piece->GetDictionary()) : nullptr; ++ PoDoFo::PdfObject *illy = pieceDict ? pieceDict->FindKey("Illustrator") : nullptr; ++ if (illy != nullptr) ++ { ++ PoDoFo::PdfDictionary* illyDict = illy->IsDictionary() ? &(illy->GetDictionary()) : nullptr; ++ PoDoFo::PdfObject *priv = illyDict ? illyDict->FindKey("Private") : nullptr; ++ if (priv == nullptr) ++ priv = illy; ++ int num = 0; ++ PoDoFo::PdfDictionary* privDict = priv->IsDictionary() ? &(priv->GetDictionary()) : nullptr; ++ PoDoFo::PdfObject *numBl = privDict ? privDict->FindKey("NumBlock") : nullptr; ++ if (numBl != nullptr) ++ num = numBl->GetNumber() + 1; ++ if (num == 0) ++ num = 99999; ++ QString name = "AIPrivateData%1"; ++ QString Key = name.arg(1); ++ PoDoFo::PdfObject *data = privDict ? privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())) : nullptr; ++ if (data == nullptr) ++ { ++ name = "AIPDFPrivateData%1"; ++ Key = name.arg(1); ++ data = privDict ? privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())) : nullptr; ++ } ++ if (data != nullptr) ++ { ++ if (num == 2) ++ { ++ Key = name.arg(1); ++ data = privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())); ++ PoDoFo::PdfObjectStream const* stream = data->GetStream(); ++ PoDoFo::charbuff strBuffer = stream->GetCopy(false); ++ qint64 bLen = strBuffer.size(); ++ const char* Buffer = strBuffer.c_str(); ++ outf.write(Buffer, bLen); ++ } ++ else ++ { ++ for (int a = 2; a < num; a++) ++ { ++ Key = name.arg(a); ++ data = privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())); ++ if (data == nullptr) ++ break; ++ PoDoFo::PdfObjectStream const* stream = data->GetStream(); ++ PoDoFo::charbuff strBuffer = stream->GetCopy(false); ++ qint64 bLen = strBuffer.size(); ++ const char* Buffer = strBuffer.c_str(); ++ outf.write(Buffer, bLen); ++ } ++ } ++ } ++ ret = true; ++ } ++ } ++ outf.close(); ++ } + #else ++ try ++ { ++ PoDoFo::PdfError::EnableDebug( false ); ++ PoDoFo::PdfError::EnableLogging( false ); ++ PoDoFo::PdfMemDocument doc( infile.toLocal8Bit().data() ); + PoDoFo::PdfPage *curPage = doc.GetPage(0); +-#endif + if (curPage != nullptr) + { +-#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) +- PoDoFo::PdfObject* pageObj = &(curPage->GetObject()); +-#else +- PoDoFo::PdfObject* pageObj = curPage->GetObject(); +-#endif +- PoDoFo::PdfDictionary* pageDict = (pageObj && pageObj->IsDictionary()) ? &(pageObj->GetDictionary()) : nullptr; +- PoDoFo::PdfObject *piece = pageDict ? pageDict->FindKey("PieceInfo") : nullptr; ++ PoDoFo::PdfObject *piece = curPage->GetObject()->GetIndirectKey("PieceInfo"); + if (piece != nullptr) + { +- PoDoFo::PdfDictionary* pieceDict = piece->IsDictionary() ? &(piece->GetDictionary()) : nullptr; +- PoDoFo::PdfObject *illy = pieceDict ? pieceDict->FindKey("Illustrator") : nullptr; ++ PoDoFo::PdfObject *illy = piece->GetIndirectKey("Illustrator"); + if (illy != nullptr) + { +- PoDoFo::PdfDictionary* illyDict = illy->IsDictionary() ? &(illy->GetDictionary()) : nullptr; +- PoDoFo::PdfObject *priv = illyDict ? illyDict->FindKey("Private") : nullptr; ++ PoDoFo::PdfObject *priv = illy->GetIndirectKey("Private"); + if (priv == nullptr) + priv = illy; + int num = 0; +- PoDoFo::PdfDictionary* privDict = priv->IsDictionary() ? &(priv->GetDictionary()) : nullptr; +- PoDoFo::PdfObject *numBl = privDict ? privDict->FindKey("NumBlock") : nullptr; ++ PoDoFo::PdfObject *numBl = priv->GetIndirectKey("NumBlock"); + if (numBl != nullptr) + num = numBl->GetNumber() + 1; + if (num == 0) + num = 99999; + QString name = "AIPrivateData%1"; + QString Key = name.arg(1); +- PoDoFo::PdfObject *data = privDict ? privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())) : nullptr; ++ PoDoFo::PdfObject *data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data())); + if (data == nullptr) + { + name = "AIPDFPrivateData%1"; + Key = name.arg(1); +- data = privDict ? privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())) : nullptr; ++ data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data())); + } + if (data != nullptr) + { +-#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) + if (num == 2) + { + Key = name.arg(1); +- data = privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())); +- PoDoFo::PdfObjectStream const* stream = data->GetStream(); +- PoDoFo::charbuff strBuffer = stream->GetCopy(false); +- qint64 bLen = strBuffer.size(); +- const char* Buffer = strBuffer.c_str(); +- outf.write(Buffer, bLen); +- } +- else +- { +- for (int a = 2; a < num; a++) +- { +- Key = name.arg(a); +- data = privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())); +- if (data == nullptr) +- break; +- PoDoFo::PdfObjectStream const* stream = data->GetStream(); +- PoDoFo::charbuff strBuffer = stream->GetCopy(false); +- qint64 bLen = strBuffer.size(); +- const char* Buffer = strBuffer.c_str(); +- outf.write(Buffer, bLen); +- } +- } +-#else +- if (num == 2) +- { +- Key = name.arg(1); +- data = privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())); ++ data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data())); + PoDoFo::PdfStream const *stream = data->GetStream(); + PoDoFo::PdfMemoryOutputStream oStream(1); + stream->GetFilteredCopy(&oStream); +@@ -674,7 +702,7 @@ bool AIPlug::extractFromPDF(const QStrin + for (int a = 2; a < num; a++) + { + Key = name.arg(a); +- data = privDict->FindKey(PoDoFo::PdfName(Key.toUtf8().data())); ++ data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data())); + if (data == nullptr) + break; + PoDoFo::PdfStream const *stream = data->GetStream(); +@@ -687,7 +715,6 @@ bool AIPlug::extractFromPDF(const QStrin + free( Buffer ); + } + } +-#endif + } + ret = true; + } +@@ -695,6 +722,7 @@ bool AIPlug::extractFromPDF(const QStrin + } + outf.close(); + } ++#endif // (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0)) + catch (PoDoFo::PdfError& e) + { + outf.close(); +@@ -704,7 +732,7 @@ bool AIPlug::extractFromPDF(const QStrin + QFile::remove(outfile); + return false; + } +-#endif ++#endif // HAVE_PODOFO + return ret; + } + diff --git a/srcpkgs/scribus/patches/0015-podofo-0.10-cmake-fix.patch b/srcpkgs/scribus/patches/0015-podofo-0.10-cmake-fix.patch new file mode 100644 index 0000000000000..c01558c04f98d --- /dev/null +++ b/srcpkgs/scribus/patches/0015-podofo-0.10-cmake-fix.patch @@ -0,0 +1,22 @@ +From 148fc05557975267b05ebe670822793999ea3e0a Mon Sep 17 00:00:00 2001 +From: Craig Bradney +Date: Mon, 5 Jun 2023 21:15:35 +0000 +Subject: [PATCH 11/13] Fix typo + +git-svn-id: svn://scribus.net/trunk/Scribus@25504 11d20701-8431-0410-a711-e3c959e3b870 +(cherry picked from commit bd2ba29c16218bc715cde93109e6c0b9be48e4be) +--- + CMakeLists_Dependencies.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/CMakeLists_Dependencies.cmake ++++ b/CMakeLists_Dependencies.cmake +@@ -8,7 +8,7 @@ if (WITH_PODOFO) + if (LIBPODOFO_FOUND) + message("PoDoFo found OK") + set(HAVE_PODOFO ON) +- if(LIBPODOFO_VERSION VERSION_GREATER "0.10.0") ++ if(LIBPODOFO_VERSION VERSION_GREATER_EQUAL "0.10.0") + message(STATUS "PoDoFo Version:" ${LIBPODOFO_VERSION}) + if (CMAKE_CXX_STANDARD LESS 17) + message(STATUS "C++17 is the minimum C++ standard since podofo 0.10.0") diff --git a/srcpkgs/scribus/patches/0016-podofo-0.10-use-pkgconfig.patch b/srcpkgs/scribus/patches/0016-podofo-0.10-use-pkgconfig.patch new file mode 100644 index 0000000000000..2d51a8ef9b793 --- /dev/null +++ b/srcpkgs/scribus/patches/0016-podofo-0.10-use-pkgconfig.patch @@ -0,0 +1,107 @@ +From 6ae729e1b45f92428168475c316f3b45a8e99d74 Mon Sep 17 00:00:00 2001 +From: Craig Bradney +Date: Mon, 4 Sep 2023 21:58:38 +0000 +Subject: [PATCH 12/13] Adapt CMake FindLIBPODOFO.cmake to use pkgconfig, and + allow custom find path. Still testing. + +git-svn-id: svn://scribus.net/trunk/Scribus@25625 11d20701-8431-0410-a711-e3c959e3b870 +(cherry picked from commit 628a630d7c45d942605ac227c530f9c889395832) +--- + cmake/modules/FindLIBPODOFO.cmake | 48 +++++++++++++++++------- + scribus/plugins/import/ai/CMakeLists.txt | 13 +++---- + 2 files changed, 41 insertions(+), 20 deletions(-) + +--- a/cmake/modules/FindLIBPODOFO.cmake ++++ b/cmake/modules/FindLIBPODOFO.cmake +@@ -12,23 +12,45 @@ if(WIN32) + endif(NOT DEFINED LIBPODOFO_SHARED) + endif(WIN32) + +-find_path(LIBPODOFO_INCLUDE_DIR +- NAMES podofo/podofo.h +- PATHS +- "${LIBPODOFO_DIR}/include" +- "${LIBPODOFO_DIR}/src" +- "${LIBPODOFO_DIR}" ++set(LIBPODOFO_FIND_QUIETLY OFF) ++ ++find_package(PkgConfig QUIET) ++if(DEFINED LIBPODOFO_DIR_CUSTOM) ++ set(ENV{PKG_CONFIG_PATH} "${LIBPODOFO_DIR_CUSTOM}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}") ++endif() ++pkg_search_module(libpodofo REQUIRED libpodofo podofo) ++ ++if (DEFINED LIBPODOFO_DIR_CUSTOM) ++ find_path(LIBPODOFO_INCLUDE_DIR ++ NAMES podofo/podofo.h ++ PATHS ++ "${LIBPODOFO_DIR_CUSTOM}/include" ++ "${LIBPODOFO_DIR_CUSTOM}" ++ PATH_SUFFIXES podofo ++ NO_DEFAULT_PATH + ) + +-set(LIBPODOFO_FIND_QUIETLY ON) ++ find_library(LIBPODOFO_LIBRARY ++ NAMES libpodofo podofo ++ PATHS ++ "${LIBPODOFO_DIR_CUSTOM}/lib" ++ "${LIBPODOFO_DIR_CUSTOM}" ++ NO_DEFAULT_PATH ++ ) ++else() ++ find_path(LIBPODOFO_INCLUDE_DIR ++ NAMES podofo/podofo.h ++ PATHS ++ ${libpodofo_INCLUDE_DIRS} ++ ) + +-find_library(LIBPODOFO_LIBRARY +- NAMES libpodofo podofo +- PATHS +- "${LIBPODOFO_DIR}/lib" +- "${LIBPODOFO_DIR}/src" +- "${LIBPODOFO_DIR}" ++ find_library(LIBPODOFO_LIBRARY ++ NAMES libpodofo podofo ++ PATHS ++ ${libpodofo_LIBRARY_DIRS} + ) ++endif() ++ + + if(LIBPODOFO_INCLUDE_DIR AND LIBPODOFO_LIBRARY) + if(NOT LIBPODOFO_CONFIG_H) +--- a/scribus/plugins/import/ai/CMakeLists.txt ++++ b/scribus/plugins/import/ai/CMakeLists.txt +@@ -1,14 +1,15 @@ + include_directories( + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/scribus +- ${PODOFO_INCLUDES} ++ ${LIBPODOFO_INCLUDE_DIR} + ${SCRIBUS_AUTOGEN_INCLUDE_PATH} + ) + + if(HAVE_PODOFO) +- include_directories( +- ${LIBPODOFO_INCLUDE_DIR} +- ) ++ if(OPENSSL_FOUND) ++ include_directories(${OPENSSL_INCLUDE_DIR}) ++ endif() ++ include_directories(BEFORE ${LIBPODOFO_INCLUDE_DIR}) + endif() + + set(IMPORTAI_PLUGIN_SOURCES +@@ -32,9 +33,7 @@ else() + endif() + + if(HAVE_PODOFO) +- target_link_libraries(${SCRIBUS_IMPORTAI_PLUGIN} +- ${LIBPODOFO_LIBRARY} +- ) ++ target_link_libraries(${SCRIBUS_IMPORTAI_PLUGIN} ${LIBPODOFO_LIBRARY}) + endif() + + if(WANT_PCH) diff --git a/srcpkgs/scribus/patches/cmake-buildtype-none.patch b/srcpkgs/scribus/patches/cmake-buildtype-none.patch index ea1df49410ed6..95a3da339b29b 100644 --- a/srcpkgs/scribus/patches/cmake-buildtype-none.patch +++ b/srcpkgs/scribus/patches/cmake-buildtype-none.patch @@ -1,5 +1,3 @@ -Index: CMakeLists.txt -=================================================================== --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,11 +75,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -14,7 +12,7 @@ Index: CMakeLists.txt set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_SKIP_RULE_DEPENDENCY TRUE) set(CMAKE_SKIP_BUILD_RPATH TRUE) -@@ -330,15 +325,6 @@ include (CMakeLists_Directories.cmake) +@@ -344,15 +339,6 @@ include (CMakeLists_Directories.cmake) #Convert our simpler command line option to the CMake style #None, Debug, Release, .. or custom ones @@ -27,3 +25,6 @@ Index: CMakeLists.txt -if(NOT WANT_DEBUG AND NOT WANT_RELEASEWITHDEBUG) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Set Release Build Type" FORCE) -endif() + + set(CMAKE_ENABLE_EXPORTS ON) + set(CMAKE_CXX_VISIBILITY_PRESET hidden) diff --git a/srcpkgs/scribus/template b/srcpkgs/scribus/template index 3138a842546af..a43acf7ccd761 100644 --- a/srcpkgs/scribus/template +++ b/srcpkgs/scribus/template @@ -1,7 +1,7 @@ # Template file for 'scribus' pkgname=scribus version=1.5.8 -revision=12 +revision=13 build_style=cmake configure_args="-DCMAKE_SKIP_RPATH=TRUE -DQT_PREFIX=${XBPS_CROSS_BASE}/usr -DWANT_GRAPHICSMAGICK=1 -DWANT_CPP17=ON" @@ -9,7 +9,7 @@ hostmakedepends="pkg-config qt5-qmake qt5-host-tools python3" makedepends="qt5-devel qt5-tools-devel zlib-devel cairo-devel lcms2-devel cups-devel libxml2-devel hyphen-devel ghostscript-devel boost-devel hunspell-devel poppler-cpp-devel python3-devel harfbuzz-devel - libgraphicsmagick-devel libpodofo0.9.7-devel libpagemaker-devel libqxp-devel + libgraphicsmagick-devel libpodofo-devel libpagemaker-devel libqxp-devel libmspub-devel libcdr-devel libfreehand-devel libvisio-devel" depends="ghostscript" short_desc="Open Source DTP (Desktop Publishing) application" From 7457d86a4dab098ad8de918cfd3c3f7a72f2e6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Thu, 14 Dec 2023 19:33:30 +0700 Subject: [PATCH 8/8] libreoffice: update to 7.6.4.1. --- srcpkgs/libreoffice/template | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/srcpkgs/libreoffice/template b/srcpkgs/libreoffice/template index e4cc15b3b9919..5e82c7c9ae63b 100644 --- a/srcpkgs/libreoffice/template +++ b/srcpkgs/libreoffice/template @@ -1,11 +1,11 @@ # Template file for 'libreoffice' pkgname=libreoffice -version=7.6.0.3 -revision=3 +version=7.6.4.1 +revision=1 build_style=meta make_build_target="build" hostmakedepends="automake flex gperf hyphen icu libtool openldap which gettext xz - perl-Archive-Zip pkg-config qt5-qmake sane unzip zip python3-setuptools + tar perl-Archive-Zip pkg-config qt5-qmake sane unzip zip python3-setuptools fontforge python3-lxml qt6-base gtk4-devel gobject-introspection gnupg" makedepends="CoinMP-devel apr-devel avahi-libs-devel clucene-devel frameworkintegration-devel glyphy-devel gpgmepp-devel gst-plugins-base1-devel @@ -72,7 +72,7 @@ distfiles=" ${_addurl}/d8bd5eed178db6e2b18eeed243f85aa8-flute-1.1.6.zip ${_addurl}/ba2930200c9f019c2d93a8c88c651a0f-flow-engine-0.9.4.zip ${_addurl}/box2d-2.4.1.tar.gz - ${_addurl}/libcmis-0.5.2.tar.xz + ${_addurl}/libcmis-0.6.1.tar.xz ${_addurl}/libstaroffice-0.0.7.tar.xz ${_addurl}/libzmf-0.0.2.tar.xz ${_addurl}/pdfium-5778.tar.bz2 @@ -94,10 +94,10 @@ distfiles=" ${_addurl}/frozen-1.1.1.tar.gz ${_addurl}/dragonbox-1.1.3.tar.gz " -checksum="07f33f11a75b72a3044749d4f2f7d02a0fd79eaed4fb73e618ec5fe3576d0c25 - b932cdd6bd2ee717f3a09766c88fe90100b0c2c0509313c3ee297f95c084ee2e - 210f18ff60e93d366856d84e714d3fd6f184f399b5163afc92b7e11155cbe768 - 667e4ffeacc01bd0f830c2edcc56e2328f924eeac224639babeb3841a44ec5f4 +checksum="13fea7b8f24c776313b9e08628aa590390bea45064be73bc70ee7b1b70aa6a1e + 36c0526e4c12ab38dd1e1766cd878118dd5692578b80411b9b443e389e3712fa + ed784c014096e0e7ff86294eba624bd92ecbe5be881b01950eecd69aed7d8678 + 3a5a0dbe40abdc55cdd9994895f6577d7e547d26a36b20641f32f3640a3b7679 1fb458d6aab06932693cc8a9b6e4e70944ee1ff052fa63606e3131df34e21753 75823776fb51a9c526af904f1503a7afaaab900fba83eda64f8a41073724c870 7d2797fe9f79a77009721e3f14fa4a1dec17a6d706bdc93f85f1f01d124fab66 @@ -106,7 +106,7 @@ checksum="07f33f11a75b72a3044749d4f2f7d02a0fd79eaed4fb73e618ec5fe3576d0c25 1b5b24f7bc543c0362b667692f78db8bab4ed6dafc6172f104d0bd3757d8a133 233f66e8d25c5dd971716d4200203a612a407649686ef3b52075d04b4c9df0dd d6b4650ff897ee1ead27cf77a5933ea197cbeef6705638dd181adc2e816b23c2 - d7b18d9602190e10d437f8a964a32e983afd57e2db316a07d87477a79f5000a2 + d54d19d86153dbc88e2d468f7136269a2cfe71b73227e12fded01d29ac268074 f94fb0ad8216f97127bedef163a45886b43c62deac5e5b0f5e628e234220c8db 27051a30cb057fdb5d5de65a1f165c7153dc76e27fe62251cbb86639eb2caf22 b1052ff24e9ffb11af017c444bb0f6ad508d64c9a0fb88cacb0e8210245dde06 @@ -136,7 +136,7 @@ skip_extraction=" d8bd5eed178db6e2b18eeed243f85aa8-flute-1.1.6.zip ba2930200c9f019c2d93a8c88c651a0f-flow-engine-0.9.4.zip box2d-2.4.1.tar.gz - libcmis-0.5.2.tar.xz + libcmis-0.6.1.tar.xz libstaroffice-0.0.7.tar.xz libzmf-0.0.2.tar.xz pdfium-5778.tar.bz2