From db1514b878f6d35837f96e31b33793d35ef21496 Mon Sep 17 00:00:00 2001 From: Marek Kasik Date: Aug 08 2022 14:02:49 +0000 Subject: Rebuild for poppler-22.08.0 Backport necessary changes from upstream --- diff --git a/scribus-1.5.8-poppler-22.08.0.patch b/scribus-1.5.8-poppler-22.08.0.patch new file mode 100644 index 0000000..65a40ce --- /dev/null +++ b/scribus-1.5.8-poppler-22.08.0.patch @@ -0,0 +1,312 @@ +--- scribus-1.5.8/scribus/plugins/import/pdf/importpdf.cpp ++++ scribus-1.5.8/scribus/plugins/import/pdf/importpdf.cpp +@@ -82,15 +82,21 @@ QImage PdfPlug::readThumbnail(const QStr + 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) +- auto fname = new GooString(pdfFile.toUtf8().data()); ++#if defined(Q_OS_WIN32) ++ QByteArray encodedFileName = pdfFile.toUtf8(); + #else +- auto fname = new GooString(QFile::encodeName(pdfFile).data()); ++ QByteArray encodedFileName = QFile::encodeName(pdfFile); + #endif +- globalParams->setErrQuiet(gTrue); +- ++#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(); + +@@ -335,15 +341,23 @@ bool PdfPlug::convert(const QString& fn) + 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)); ++ ++#if defined(Q_OS_WIN32) ++ QByteArray encodedFileName = fn.toUtf8(); ++#else ++ QByteArray encodedFileName = QFile::encodeName(fn); ++#endif ++#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,13 +371,15 @@ 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) +- 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)) +--- scribus-1.5.8/scribus/plugins/import/pdf/slaoutput.cpp ++++ scribus-1.5.8/scribus/plugins/import/pdf/slaoutput.cpp +@@ -169,8 +169,13 @@ void AnoOutputDev::drawString(GfxState * + 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(); + } + +@@ -358,7 +363,12 @@ LinkAction* SlaOutputDev::SC_getAddition + 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; +@@ -701,7 +711,12 @@ bool SlaOutputDev::handleWidgetAnnot(Ann + 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; +@@ -3026,16 +3041,27 @@ void SlaOutputDev::markPoint(POPPLER_CON + + 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; +@@ -3046,11 +3072,12 @@ void SlaOutputDev::updateFont(GfxState * + 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,23 +3102,42 @@ void SlaOutputDev::updateFont(GfxState * + 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); ++ fontsrc->setFile(fileName, false); + else +- fontsrc->setBuf(tmpBuf, tmpBufLen, gTrue); ++ fontsrc->setBuf(tmpBuf, tmpBufLen, true); ++#endif + + // load the font file + switch (fontType) { +@@ -3130,15 +3176,27 @@ void SlaOutputDev::updateFont(GfxState * + 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()); ++ ff = FoFiTrueType::load(fileName->c_str()); + 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 + { +@@ -3203,14 +3261,26 @@ void SlaOutputDev::updateFont(GfxState * + } + 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()); ++ ff = FoFiTrueType::load(fileName->c_str()); + 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, +@@ -3247,14 +3317,19 @@ void SlaOutputDev::updateFont(GfxState * + 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 +3432,15 @@ void SlaOutputDev::drawChar(GfxState* st + 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 true; ++#else ++ GfxFont* gfxFont; + if (!(gfxFont = state->getFont())) +- return gTrue; ++ return true; ++#endif + if (gfxFont->getType() != fontType3) + return gTrue; + F3Entry f3e; diff --git a/scribus.spec b/scribus.spec index 977c9dd..55e6eab 100644 --- a/scribus.spec +++ b/scribus.spec @@ -1,6 +1,6 @@ Name: scribus Version: 1.5.8 -Release: 5%{?dist} +Release: 6%{?dist} Summary: Desktop Publishing application written in Qt # swatches bring in the fun licenses License: GPLv2+ and OGL and CC0 and CC-BY and CC-BY-SA and Public Domain and ASL 2.0 and LGPLv2+ @@ -14,6 +14,8 @@ Source0: %{name}-%{version}-free.tar.xz #Source0: http://downloads.sourceforge.net/%%{name}/%%{name}-%%{version}.tar.xz #Source1: http://downloads.sourceforge.net/%%{name}/%%{name}-%%{version}.tar.xz.asc +Patch0: scribus-1.5.8-poppler-22.08.0.patch + BuildRequires: boost-devel BuildRequires: cmake BuildRequires: cups-devel @@ -137,6 +139,10 @@ appstream-util validate-relax --nonet \ %changelog +* Mon Aug 08 2022 Marek Kasik - 1.5.8-6 +- Rebuild for poppler-22.08.0 +- Backport necessary changes from upstream + * Mon Aug 01 2022 Frantisek Zatloukal - 1.5.8-5 - Rebuilt for ICU 71.1