Combination of upstream commits to fix building with newer poppler versions: r24884: #16734: Build break with poppler 22.2.0 https://github.com/scribusproject/scribus/commit/85c0dff3422fa3c26fbc2e8d8561f597ec24bd92 r24982: #16764: Build break with poppler 22.03.0 https://github.com/scribusproject/scribus/commit/f19410ac3b27e33dd62105746784e61e85b90a1d r24985: Enforce poppler version >= 0.86.0 https://github.com/scribusproject/scribus/commit/e013e8126d2100e8e56dea5b836ad43275429389 r24989: #16764: Better patch, avoid a memory leak https://github.com/scribusproject/scribus/commit/48263954a7dee0be815b00f417ae365ab26cdd85 r25000: #16767: Dashed lines imported from PDF have incorrect segment lengths https://github.com/scribusproject/scribus/commit/a9236cd44254339e64d1e422dcbbfd31913c8c11 r25074: Fix build with poppler 22.04.0 https://github.com/scribusproject/scribus/commit/f2237b8f0b5cf7690e864a22ef7a63a6d769fa36 r25140: Fix build with poppler 22.09.0 https://github.com/scribusproject/scribus/commit/8acd29e97813b9132e3b51b2f05e8fac65819ed7 r26042: Fix build failure with poppler 24.03.0 https://github.com/scribusproject/scribus/commit/c57362c4f7bdef67904bf2f3d8126073792bdcf9 --- cmake/modules/Findpoppler.cmake.orig 2022-01-23 10:16:42.000000000 -0600 +++ cmake/modules/Findpoppler.cmake 2023-06-30 03:49:11.000000000 -0500 @@ -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 --- scribus/plugins/import/pdf/importpdf.cpp.orig 2023-06-30 03:49:02.000000000 -0500 +++ scribus/plugins/import/pdf/importpdf.cpp 2023-06-30 03:49:11.000000000 -0500 @@ -58,6 +58,7 @@ #include "util.h" #include "util_formats.h" #include "util_math.h" +#include "util_os.h" #include "ui/customfdialog.h" #include "ui/missing.h" @@ -75,22 +76,18 @@ 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 - -#if defined(Q_OS_WIN32) && POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 62, 0) - auto fname = new GooString(pdfFile.toUtf8().data()); -#else - auto fname = new GooString(QFile::encodeName(pdfFile).data()); -#endif globalParams->setErrQuiet(gTrue); + QString pdfFile = QDir::toNativeSeparators(fName); + QByteArray encodedFileName = os_is_win() ? pdfFile.toUtf8() : QFile::encodeName(pdfFile); +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 3, 0) + 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) return QImage(); @@ -329,21 +326,18 @@ 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) - 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; - auto pdfDoc = std::unique_ptr(new PDFDoc(fname, nullptr, nullptr, nullptr)); + QByteArray encodedFileName = os_is_win() ? fn.toUtf8() : QFile::encodeName(fn); +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 3, 0) + auto fname = std::make_unique(encodedFileName.data()); + auto pdfDoc = std::make_unique(std::move(fname)); +#else + auto fname = new GooString(encodedFileName.data()); + auto pdfDoc = std::make_unique(fname, nullptr, nullptr, nullptr); +#endif if (pdfDoc) { if (pdfDoc->getErrorCode() == errEncrypted) @@ -357,22 +351,21 @@ 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) - auto fname = new GooString(fn.toUtf8().data()); +#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::move(fname), userPW, userPW, nullptr)); #else - auto fname = new GooString(QFile::encodeName(fn).data()); -#endif + auto fname = new GooString(encodedFileName.data()); auto userPW = new GooString(text.toLocal8Bit().data()); pdfDoc.reset(new PDFDoc(fname, userPW, userPW, nullptr)); +#endif qApp->changeOverrideCursor(QCursor(Qt::WaitCursor)); } if ((!pdfDoc) || (pdfDoc->getErrorCode() != errNone)) { if (m_progressDialog) m_progressDialog->close(); -#if POPPLER_ENCODED_VERSION < POPPLER_VERSION_ENCODE(0, 83, 0) - delete globalParams; -#endif return false; } if (m_progressDialog) @@ -482,7 +475,6 @@ } else { -#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 69, 0) const auto& ocgs = ocg->getOCGs (); for (const auto& ocg : ocgs) { @@ -494,25 +486,11 @@ 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) { @@ -524,19 +502,6 @@ 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 } } @@ -775,13 +740,8 @@ 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; @@ -849,11 +809,7 @@ } 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"; --- scribus/plugins/import/pdf/slaoutput.cpp.orig 2023-06-30 03:49:02.000000000 -0500 +++ scribus/plugins/import/pdf/slaoutput.cpp 2024-03-08 15:23:01 @@ -7,6 +7,11 @@ #include "slaoutput.h" +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0) +#include +#include +#endif + #include #include #include @@ -169,8 +174,13 @@ int shade = 100; currColorText = getColor(state->getFillColorSpace(), state->getFillColor(), &shade); fontSize = state->getFontSize(); +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0) + if (state->getFont() && state->getFont()->getName()) + fontName = new GooString(state->getFont()->getName().value()); +#else if (state->getFont()) fontName = state->getFont()->getName()->copy(); +#endif itemText = s->copy(); } @@ -327,15 +337,9 @@ } /* 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(); @@ -358,7 +362,12 @@ GBool SlaOutputDev::annotations_callback(Annot *annota, void *user_data) { SlaOutputDev *dev = (SlaOutputDev*)user_data; +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0) + const PDFRectangle& annotRect = annota->getRect();; + const PDFRectangle* box = &annotRect; +#else PDFRectangle *box = annota->getRect(); +#endif double xCoor = dev->m_doc->currentPage()->xOffset() + box->x1 - dev->cropOffsetX; double yCoor = dev->m_doc->currentPage()->yOffset() + dev->m_doc->currentPage()->height() - box->y2 + dev->cropOffsetY; double width = box->x2 - box->x1; @@ -462,11 +471,7 @@ 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(); @@ -480,11 +485,7 @@ 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) @@ -492,11 +493,7 @@ 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(); @@ -528,11 +525,7 @@ 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) @@ -701,7 +694,12 @@ if (apa || !achar) { AnoOutputDev *annotOutDev = new AnoOutputDev(m_doc, m_importedColors); +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0) + const PDFRectangle& annotaRect = annota->getRect(); + Gfx* gfx = new Gfx(pdfDoc, annotOutDev, pdfDoc->getPage(m_actPage)->getResourceDict(), &annotaRect, nullptr); +#else Gfx *gfx = new Gfx(pdfDoc, annotOutDev, pdfDoc->getPage(m_actPage)->getResourceDict(), annota->getRect(), nullptr); +#endif ano->draw(gfx, false); if (!bgFound) m_currColorFill = annotOutDev->currColorFill; @@ -980,11 +978,7 @@ 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(); @@ -1000,11 +994,7 @@ 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) @@ -1012,11 +1002,7 @@ 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(); @@ -1056,11 +1042,7 @@ 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) @@ -1134,143 +1116,91 @@ { 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())); @@ -1278,22 +1208,14 @@ 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())); @@ -1301,33 +1223,21 @@ 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 } } @@ -1337,11 +1247,7 @@ 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 *) @@ -1821,7 +1727,11 @@ VGradient FillGradient = VGradient(VGradient::linear); FillGradient.clearStops(); GfxColorSpace *color_space = shading->getColorSpace(); +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 3, 0) + if (func->getType() == Function::Type::Stitching) +#else if (func->getType() == 3) +#endif { StitchingFunction *stitchingFunc = (StitchingFunction*)func; const double *bounds = stitchingFunc->getBounds(); @@ -1843,7 +1753,11 @@ FillGradient.addStop( ScColorEngine::getShadeColor(m_doc->PageColors[stopColor], m_doc, shade), stopPoint, 0.5, 1.0, stopColor, shade ); } } +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 3, 0) + else if ((func->getType() == Function::Type::Exponential) || (func->getType() == Function::Type::Identity)) +#else else if ((func->getType() == 2) || (func->getType() == 0)) +#endif { GfxColor stop1; shading->getColor(0.0, &stop1); @@ -1953,7 +1867,11 @@ VGradient FillGradient = VGradient(VGradient::linear); FillGradient.clearStops(); GfxColorSpace *color_space = shading->getColorSpace(); +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 3, 0) + if (func->getType() == Function::Type::Stitching) +#else if (func->getType() == 3) +#endif { StitchingFunction *stitchingFunc = (StitchingFunction*)func; const double *bounds = stitchingFunc->getBounds(); @@ -1975,7 +1893,11 @@ FillGradient.addStop( ScColorEngine::getShadeColor(m_doc->PageColors[stopColor], m_doc, shade), stopPoint, 0.5, 1.0, stopColor, shade ); } } +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 3, 0) + else if ((func->getType() == Function::Type::Exponential) || (func->getType() == Function::Type::Identity)) +#else else if ((func->getType() == 2) || (func->getType() == 0)) +#endif { GfxColor stop1; shading->getColor(0.0, &stop1); @@ -3026,19 +2948,30 @@ void SlaOutputDev::updateFont(GfxState *state) { - GfxFont *gfxFont; - GfxFontLoc *fontLoc; +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0) + std::optional fontLoc; + std::string fileName; + std::unique_ptr ff; + std::optional> tmpBuf; +#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0) + std::optional fontLoc; + const GooString * fileName = nullptr; + std::unique_ptr ff; + char* tmpBuf = nullptr; +#else + GfxFontLoc * fontLoc = nullptr; + GooString * fileName = nullptr; + FoFiTrueType * ff = nullptr; + char* tmpBuf = nullptr; +#endif GfxFontType fontType; SlaOutFontFileID *id; SplashFontFile *fontFile; SplashFontSrc *fontsrc = nullptr; - FoFiTrueType *ff; Object refObj, strObj; - GooString *fileName; - char *tmpBuf; int tmpBufLen = 0; - int *codeToGID; - const double *textMat; + int *codeToGID = nullptr; + const double *textMat = nullptr; double m11, m12, m21, m22, fontSize; SplashCoord mat[4]; int n = 0; @@ -3046,11 +2979,12 @@ SplashCoord matrix[6]; m_font = nullptr; - fileName = nullptr; - tmpBuf = nullptr; - fontLoc = nullptr; - gfxFont = state->getFont(); +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0) + GfxFont* gfxFont = state->getFont().get(); +#else + GfxFont* gfxFont = state->getFont(); +#endif if (!gfxFont) goto err1; @@ -3075,94 +3009,106 @@ if (fontLoc->locType == gfxFontLocEmbedded) { // if there is an embedded font, read it to memory - tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen); +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0) + tmpBuf = gfxFont->readEmbFontFile((xref) ? xref : pdfDoc->getXRef()); if (! tmpBuf) goto err2; +#else + tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen); + if (!tmpBuf) + goto err2; +#endif // external font } else { // gfxFontLocExternal +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0) fileName = fontLoc->path; +#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0) + fileName = fontLoc->pathAsGooString(); +#else + fileName = fontLoc->path; +#endif fontType = fontLoc->fontType; } fontsrc = new SplashFontSrc; +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0) + if (!fileName.empty()) + fontsrc->setFile(fileName); + else + fontsrc->setBuf(std::move(tmpBuf.value())); +#else if (fileName) fontsrc->setFile(fileName, gFalse); else fontsrc->setBuf(tmpBuf, tmpBufLen, gTrue); +#endif // load the font file switch (fontType) { case fontType1: - if (!(fontFile = m_fontEngine->loadType1Font( - id, - fontsrc, - (const char **)((Gfx8BitFont *) gfxFont)->getEncoding()))) + if (!(fontFile = m_fontEngine->loadType1Font(id, fontsrc, (const char **)((Gfx8BitFont *) gfxFont)->getEncoding()))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontType1C: - if (!(fontFile = m_fontEngine->loadType1CFont( - id, - fontsrc, - (const char **)((Gfx8BitFont *) gfxFont)->getEncoding()))) + if (!(fontFile = m_fontEngine->loadType1CFont(id, fontsrc, (const char **)((Gfx8BitFont *) gfxFont)->getEncoding()))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontType1COT: - if (!(fontFile = m_fontEngine->loadOpenTypeT1CFont( - id, - fontsrc, - (const char **)((Gfx8BitFont *) gfxFont)->getEncoding()))) + if (!(fontFile = m_fontEngine->loadOpenTypeT1CFont(id, fontsrc, (const char **)((Gfx8BitFont *) gfxFont)->getEncoding()))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontTrueType: case fontTrueTypeOT: +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0) + if (!fileName.empty()) + ff = FoFiTrueType::load(fileName.c_str()); + else + ff = FoFiTrueType::make(fontsrc->buf.data(), fontsrc->buf.size()); +#else if (fileName) ff = FoFiTrueType::load(fileName->getCString()); else ff = FoFiTrueType::make(tmpBuf, tmpBufLen); +#endif if (ff) { +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0) + codeToGID = ((Gfx8BitFont*) gfxFont)->getCodeToGIDMap(ff.get()); + ff.reset(); +#else codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff); - n = 256; delete ff; +#endif + n = 256; } else { codeToGID = nullptr; n = 0; } - if (!(fontFile = m_fontEngine->loadTrueTypeFont( - id, - fontsrc, - codeToGID, n))) + if (!(fontFile = m_fontEngine->loadTrueTypeFont(id, fontsrc, codeToGID, n))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; case fontCIDType0: case fontCIDType0C: - if (!(fontFile = m_fontEngine->loadCIDFont( - id, - fontsrc))) + if (!(fontFile = m_fontEngine->loadCIDFont(id, fontsrc))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; @@ -3178,10 +3124,7 @@ codeToGID = nullptr; n = 0; } - if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont( - id, - fontsrc, - codeToGID, n))) + if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont(id, fontsrc, codeToGID, n))) { error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); @@ -3203,22 +3146,30 @@ } else { +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0) + if (!fileName.empty()) + ff = FoFiTrueType::load(fileName.c_str()); + else + ff = FoFiTrueType::make(fontsrc->buf.data(), fontsrc->buf.size()); +#else if (fileName) ff = FoFiTrueType::load(fileName->getCString()); else ff = FoFiTrueType::make(tmpBuf, tmpBufLen); +#endif if (! ff) goto err2; +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0) + codeToGID = ((GfxCIDFont*) gfxFont)->getCodeToGIDMap(ff.get(), &n); + ff.reset(); +#else codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n); delete ff; +#endif } - if (!(fontFile = m_fontEngine->loadTrueTypeFont( - id, - fontsrc, - codeToGID, n, faceIndex))) + if (!(fontFile = m_fontEngine->loadTrueTypeFont(id, fontsrc, codeToGID, n, faceIndex))) { - error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", - gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)"); goto err2; } break; @@ -3247,14 +3198,19 @@ mat[3] = -m22; m_font = m_fontEngine->getFont(fontFile, mat, matrix); +#if POPPLER_ENCODED_VERSION < POPPLER_VERSION_ENCODE(22, 2, 0) delete fontLoc; +#endif if (fontsrc && !fontsrc->isFile) fontsrc->unref(); return; err2: delete id; +#if POPPLER_ENCODED_VERSION < POPPLER_VERSION_ENCODE(22, 2, 0) delete fontLoc; +#endif + err1: if (fontsrc && !fontsrc->isFile) fontsrc->unref(); @@ -3357,9 +3313,15 @@ GBool SlaOutputDev::beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, POPPLER_CONST_082 Unicode *u, int uLen) { // qDebug() << "beginType3Char"; +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0) GfxFont *gfxFont; + if (!(gfxFont = state->getFont().get())) + return gTrue; +#else + GfxFont* gfxFont; if (!(gfxFont = state->getFont())) return gTrue; +#endif if (gfxFont->getType() != fontType3) return gTrue; F3Entry f3e; @@ -3680,16 +3642,21 @@ m_lineJoin = Qt::BevelJoin; break; } - double lw = state->getLineWidth(); - double *dashPattern; +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 9, 0) + const auto& dashPattern = state->getLineDash(&DashOffset); + QVector pattern(dashPattern.size()); + for (size_t i = 0; i < dashPattern.size(); ++i) + pattern[i] = dashPattern[i]; + DashValues = pattern; +#else + double* dashPattern; int dashLength; state->getLineDash(&dashPattern, &dashLength, &DashOffset); QVector pattern(dashLength); for (int i = 0; i < dashLength; ++i) - { - pattern[i] = dashPattern[i] / lw; - } + pattern[i] = dashPattern[i]; DashValues = pattern; +#endif } int SlaOutputDev::getBlendMode(GfxState *state) --- scribus/plugins/import/pdf/slaoutput.h.orig 2023-06-30 03:49:02.000000000 -0500 +++ scribus/plugins/import/pdf/slaoutput.h 2023-06-30 03:49:11.000000000 -0500 @@ -30,9 +30,6 @@ #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 @@ 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); --- scribus/util_os.cpp.orig 2022-01-23 10:16:21.000000000 -0600 +++ scribus/util_os.cpp 2023-06-30 03:49:11.000000000 -0500 @@ -22,6 +22,8 @@ #include +#include "util_os.h" + bool os_is_osx() { #ifdef Q_OS_MACOS