scribus: update to 1.6.2, build against libpoppler

This commit is contained in:
Mateusz Sylwestrzak 2024-08-22 17:14:15 +02:00 committed by Đoàn Trần Công Danh
parent da0c1aac54
commit 816ec5a7c8
24 changed files with 112 additions and 4785 deletions

View File

@ -1,129 +0,0 @@
From 85c0dff3422fa3c26fbc2e8d8561f597ec24bd92 Mon Sep 17 00:00:00 2001
From: Jean Ghali <jghali@libertysurf.fr>
Date: Wed, 2 Feb 2022 23:12:52 +0000
Subject: [PATCH] #16734: Build break with poppler 22.2.0
git-svn-id: svn://scribus.net/trunk/Scribus@24884 11d20701-8431-0410-a711-e3c959e3b870
---
scribus/plugins/import/pdf/slaoutput.cpp | 47 +++++++++++++++++++-----
1 file changed, 37 insertions(+), 10 deletions(-)
diff --git a/scribus/plugins/import/pdf/slaoutput.cpp b/scribus/plugins/import/pdf/slaoutput.cpp
index 5894bf2ad6..3650c96f52 100644
--- a/scribus/plugins/import/pdf/slaoutput.cpp
+++ b/scribus/plugins/import/pdf/slaoutput.cpp
@@ -7,6 +7,11 @@ for which a new license (GPL+exception) is in place.
#include "slaoutput.h"
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+#include <memory>
+#include <optional>
+#endif
+
#include <poppler/GlobalParams.h>
#include <poppler/poppler-config.h>
#include <poppler/FileSpec.h>
@@ -3027,18 +3032,24 @@ void SlaOutputDev::markPoint(POPPLER_CONST char *name, Dict *properties)
void SlaOutputDev::updateFont(GfxState *state)
{
GfxFont *gfxFont;
- GfxFontLoc *fontLoc;
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+ std::optional<GfxFontLoc> fontLoc;
+ const GooString * fileName = nullptr;
+ std::unique_ptr<FoFiTrueType> ff;
+#else
+ GfxFontLoc * fontLoc = nullptr;
+ GooString * fileName = nullptr;
+ FoFiTrueType * ff = nullptr;
+#endif
GfxFontType fontType;
SlaOutFontFileID *id;
SplashFontFile *fontFile;
SplashFontSrc *fontsrc = nullptr;
- FoFiTrueType *ff;
Object refObj, strObj;
- GooString *fileName;
- char *tmpBuf;
+ char *tmpBuf = nullptr;
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,9 +3057,6 @@ void SlaOutputDev::updateFont(GfxState *state)
SplashCoord matrix[6];
m_font = nullptr;
- fileName = nullptr;
- tmpBuf = nullptr;
- fontLoc = nullptr;
gfxFont = state->getFont();
if (!gfxFont)
@@ -3083,7 +3091,11 @@ void SlaOutputDev::updateFont(GfxState *state)
}
else
{ // gfxFontLocExternal
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+ fileName = fontLoc->pathAsGooString();
+#else
fileName = fontLoc->path;
+#endif
fontType = fontLoc->fontType;
}
@@ -3136,9 +3148,14 @@ void SlaOutputDev::updateFont(GfxState *state)
ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
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
{
@@ -3209,8 +3226,13 @@ void SlaOutputDev::updateFont(GfxState *state)
ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
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 +3269,19 @@ void SlaOutputDev::updateFont(GfxState *state)
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();

View File

@ -1,52 +0,0 @@
From f19410ac3b27e33dd62105746784e61e85b90a1d Mon Sep 17 00:00:00 2001
From: Jean Ghali <jghali@libertysurf.fr>
Date: Wed, 2 Mar 2022 22:22:53 +0000
Subject: [PATCH] #16764: Build break with poppler 22.03.0
git-svn-id: svn://scribus.net/trunk/Scribus@24982 11d20701-8431-0410-a711-e3c959e3b870
---
scribus/plugins/import/pdf/importpdf.cpp | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/scribus/plugins/import/pdf/importpdf.cpp b/scribus/plugins/import/pdf/importpdf.cpp
index 154e58a3f0..392dcd9e64 100644
--- a/scribus/plugins/import/pdf/importpdf.cpp
+++ b/scribus/plugins/import/pdf/importpdf.cpp
@@ -89,7 +89,11 @@ QImage PdfPlug::readThumbnail(const QString& fName)
#endif
globalParams->setErrQuiet(gTrue);
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 3, 0)
+ PDFDoc pdfDoc{ std::make_unique<GooString>(fname) };
+#else
PDFDoc pdfDoc{fname, nullptr, nullptr, nullptr};
+#endif
if (!pdfDoc.isOk() || pdfDoc.getErrorCode() == errEncrypted)
return QImage();
@@ -342,7 +346,11 @@ bool PdfPlug::convert(const QString& fn)
globalParams->setErrQuiet(gTrue);
// globalParams->setPrintCommands(gTrue);
QList<OptionalContentGroup*> ocgGroups;
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 3, 0)
+ auto pdfDoc = std::make_unique<PDFDoc>(std::make_unique<GooString>(fname));
+#else
auto pdfDoc = std::unique_ptr<PDFDoc>(new PDFDoc(fname, nullptr, nullptr, nullptr));
+#endif
if (pdfDoc)
{
if (pdfDoc->getErrorCode() == errEncrypted)
@@ -361,8 +369,13 @@ bool PdfPlug::convert(const QString& fn)
#else
auto fname = new GooString(QFile::encodeName(fn).data());
#endif
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 3, 0)
+ std::optional<GooString> userPW(std::in_place, text.toLocal8Bit().data());
+ pdfDoc.reset(new PDFDoc(std::make_unique<GooString>(fname), userPW, userPW, nullptr));
+#else
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))

View File

@ -1,526 +0,0 @@
From e013e8126d2100e8e56dea5b836ad43275429389 Mon Sep 17 00:00:00 2001
From: Jean Ghali <jghali@libertysurf.fr>
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<GlobalParams> 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<GooString>(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<GlobalParams> 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<OptionalContentGroup*> ocgGroups;
#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 3, 0)
auto pdfDoc = std::make_unique<PDFDoc>(std::make_unique<GooString>(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<LinkAction> 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<LinkAction> SlaOutputDev::SC_getAdditionalAction(const char *key, AnnotWidget *ano)
{
std::unique_ptr<LinkAction> 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<LinkDest> 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<LinkDest> 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<LinkDest> 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<LinkDest> 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 <poppler/goo/gtypes.h>
-#endif
#include <poppler/Object.h>
#include <poppler/OutputDev.h>
#include <poppler/Gfx.h>
@@ -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<LinkAction> 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);

View File

@ -1,94 +0,0 @@
From 48263954a7dee0be815b00f417ae365ab26cdd85 Mon Sep 17 00:00:00 2001
From: Jean Ghali <jghali@libertysurf.fr>
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<GooString>(fname) };
+ auto fname = std::make_unique<GooString>(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<OptionalContentGroup*> 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<PDFDoc>(std::make_unique<GooString>(fname));
+ auto fname = std::make_unique<GooString>(encodedFileName.data());
+ auto pdfDoc = std::make_unique<PDFDoc>(std::move(fname));
#else
- auto pdfDoc = std::unique_ptr<PDFDoc>(new PDFDoc(fname, nullptr, nullptr, nullptr));
+ auto fname = new GooString(encodedFileName.data());
+ auto pdfDoc = std::make_unique<PDFDoc>(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<GooString>(encodedFileName.data());
std::optional<GooString> userPW(std::in_place, text.toLocal8Bit().data());
- pdfDoc.reset(new PDFDoc(std::make_unique<GooString>(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 <QtGlobal>
+#include "util_os.h"
+
bool os_is_osx()
{
#ifdef Q_OS_MACOS

View File

@ -1,288 +0,0 @@
From f2237b8f0b5cf7690e864a22ef7a63a6d769fa36 Mon Sep 17 00:00:00 2001
From: Jean Ghali <jghali@libertysurf.fr>
Date: Fri, 1 Apr 2022 23:52:32 +0000
Subject: [PATCH] Fix build with poppler 22.04.0
git-svn-id: svn://scribus.net/trunk/Scribus@25074 11d20701-8431-0410-a711-e3c959e3b870
---
scribus/plugins/import/pdf/slaoutput.cpp | 123 ++++++++++++++---------
1 file changed, 78 insertions(+), 45 deletions(-)
diff --git a/scribus/plugins/import/pdf/slaoutput.cpp b/scribus/plugins/import/pdf/slaoutput.cpp
index e20a81f99e..5626fe3477 100644
--- a/scribus/plugins/import/pdf/slaoutput.cpp
+++ b/scribus/plugins/import/pdf/slaoutput.cpp
@@ -174,8 +174,13 @@ void AnoOutputDev::drawString(GfxState *state, POPPLER_CONST GooString *s)
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();
}
@@ -357,7 +362,12 @@ std::unique_ptr<LinkAction> SlaOutputDev::SC_getAdditionalAction(const char *key
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;
@@ -684,7 +694,12 @@ bool SlaOutputDev::handleWidgetAnnot(Annot* annota, double xCoor, double yCoor,
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;
@@ -2916,22 +2931,27 @@ void SlaOutputDev::markPoint(POPPLER_CONST char *name, Dict *properties)
void SlaOutputDev::updateFont(GfxState *state)
{
- GfxFont *gfxFont;
-#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 4, 0)
+ std::optional<GfxFontLoc> fontLoc;
+ std::string fileName;
+ std::unique_ptr<FoFiTrueType> ff;
+ std::optional<std::vector<unsigned char>> tmpBuf;
+#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
std::optional<GfxFontLoc> fontLoc;
const GooString * fileName = nullptr;
std::unique_ptr<FoFiTrueType> 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;
Object refObj, strObj;
- char *tmpBuf = nullptr;
int tmpBufLen = 0;
int *codeToGID = nullptr;
const double *textMat = nullptr;
@@ -2943,7 +2963,11 @@ void SlaOutputDev::updateFont(GfxState *state)
m_font = 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;
@@ -2968,15 +2992,23 @@ void SlaOutputDev::updateFont(GfxState *state)
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, 2, 0)
+#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;
@@ -2985,52 +3017,54 @@ void SlaOutputDev::updateFont(GfxState *state)
}
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)
@@ -3047,24 +3081,17 @@ void SlaOutputDev::updateFont(GfxState *state)
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;
@@ -3080,10 +3107,7 @@ void SlaOutputDev::updateFont(GfxState *state)
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)");
@@ -3105,10 +3129,17 @@ void SlaOutputDev::updateFont(GfxState *state)
}
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)
@@ -3119,13 +3150,9 @@ void SlaOutputDev::updateFont(GfxState *state)
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;
@@ -3269,9 +3296,15 @@ void SlaOutputDev::drawChar(GfxState* state, double x, double y, double dx, doub
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;

View File

@ -1,22 +0,0 @@
Index: scribus-1.5.8/scribus/plugins/import/pdf/slaoutput.cpp
===================================================================
--- scribus-1.5.8.orig/scribus/plugins/import/pdf/slaoutput.cpp
+++ scribus-1.5.8/scribus/plugins/import/pdf/slaoutput.cpp
@@ -3741,9 +3741,16 @@ void SlaOutputDev::getPenState(GfxState
break;
}
double lw = state->getLineWidth();
- double *dashPattern;
int dashLength;
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 9, 0)
+ const double *dashPattern;
+ const std::vector<double> &dash = state->getLineDash(&DashOffset);
+ dashPattern = dash.data();
+ dashLength = dash.size();
+#else
+ double *dashPattern;
state->getLineDash(&dashPattern, &dashLength, &DashOffset);
+#endif
QVector<double> pattern(dashLength);
for (int i = 0; i < dashLength; ++i)
{

View File

@ -1,37 +0,0 @@
From 3d02faaa2e17eef67826abd52d56b4a9b2b9c1ba Mon Sep 17 00:00:00 2001
From: Craig Bradney <mrb@scribus.info>
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)

View File

@ -1,109 +0,0 @@
From 45ed6b8664675d78de1b3dbde2c9684111805811 Mon Sep 17 00:00:00 2001
From: Craig Bradney <mrb@scribus.info>
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
+option(WITH_PODOFO "Enable support for PDF embedded in AI" ON)
+if (WITH_PODOFO)
+ find_package(LIBPODOFO)
+ if (LIBPODOFO_FOUND)
+ message("PoDoFo found OK")
+ set(HAVE_PODOFO ON)
+ if(LIBPODOFO_VERSION VERSION_GREATER "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")
+ message(STATUS "Enabling C++17 compiler features")
+ set(CMAKE_CXX_STANDARD 17)
+ endif()
+ endif()
+ else()
+ message("PoDoFo NOT found - Disabling support for PDF embedded in AI")
+ endif()
+endif()
+#>>PoDoFo for AI PDF import
+
+#<<Poppler for PDF import
+find_package(poppler REQUIRED)
+if (poppler_FOUND)
+ set(HAVE_POPPLER ON)
+ message(STATUS "Found poppler")
+ message(STATUS "Found poppler libs: ${poppler_LIBRARY}")
+ message(STATUS "Found poppler includes: ${poppler_INCLUDE_DIR}")
+ if (poppler_VERSION VERSION_GREATER_EQUAL 22.01.0)
+ message(STATUS "Poppler Version:" ${poppler_VERSION})
+ if (CMAKE_CXX_STANDARD LESS 17)
+ message(STATUS "C++17 is the minimum C++ standard since poppler 22.01.0")
+ message(STATUS "Enabling C++17 compiler features")
+ set(CMAKE_CXX_STANDARD 17)
+ endif()
+ endif()
+else()
+ message(FATAL_ERROR "Could not find poppler library")
+endif()
+#>>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
-option(WITH_PODOFO "Enable support for PDF embedded in AI" ON)
-if (WITH_PODOFO)
- find_package(LIBPODOFO)
- if (LIBPODOFO_FOUND)
- message("PoDoFo found OK")
- set(HAVE_PODOFO ON)
- else()
- message("PoDoFo NOT found - Disabling support for PDF embedded in AI")
- endif()
-endif()
-#>>PoDoFo for AI PDF import
+
#<<Boost for 2Geom Tools
option(WITH_BOOST "Enable support for Boost based enhancements" ON)
@@ -298,24 +329,7 @@ else()
endif()
#>> GraphicsMagick for image import
-#<<Poppler for PDF import
-find_package(poppler REQUIRED)
-if (poppler_FOUND)
- set(HAVE_POPPLER ON)
- message(STATUS "Found poppler")
- message(STATUS "Found poppler libs: ${poppler_LIBRARY}")
- message(STATUS "Found poppler includes: ${poppler_INCLUDE_DIR}")
- if (poppler_VERSION VERSION_GREATER_EQUAL 22.01.0)
- message(STATUS "Poppler Version:" ${poppler_VERSION})
- message(STATUS "C++17 is the minimum C++ standard since poppler 22.01.0")
- if (CMAKE_CXX_STANDARD LESS 17)
- message(FATAL_ERROR "Please set -DWANT_CPP17=ON on your CMake command line")
- endif()
- endif()
-else()
- message(FATAL_ERROR "Could not find poppler library")
-endif()
-#>>Poppler for PDF import
+
# librevenge for MsPub import
pkg_check_modules(LIBREVENGE librevenge-0.0)

View File

@ -1,22 +0,0 @@
From 2a2c95fda05bbb089c12807261b7a9339635b488 Mon Sep 17 00:00:00 2001
From: Craig Bradney <mrb@scribus.info>
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 @@
#<<PoDoFo for AI PDF import
option(WITH_PODOFO "Enable support for PDF embedded in AI" ON)
if (WITH_PODOFO)
- find_package(LIBPODOFO)
+ find_package(LIBPODOFO 0.9.0)
if (LIBPODOFO_FOUND)
message("PoDoFo found OK")
set(HAVE_PODOFO ON)

View File

@ -1,48 +0,0 @@
From 60007314a17cfd9ef4d81689868ca1b4e91d5c89 Mon Sep 17 00:00:00 2001
From: Jean Ghali <jghali@libertysurf.fr>
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<qlonglong>(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");

View File

@ -1,67 +0,0 @@
From 99e2d400ad6ad7fbf4e2ad1a4277521eaad46d28 Mon Sep 17 00:00:00 2001
From: Craig Bradney <mrb@scribus.info>
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<PDFColorSpace> & usedColorSpaces, bool & hasTransparency, QList<PDFFont> & usedFonts, QList<PDFImage> & 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;

View File

@ -1,22 +0,0 @@
From ed854091944c93a74cdb3a4dbd6ed14e95ab6a9c Mon Sep 17 00:00:00 2001
From: Jean Ghali <jghali@libertysurf.fr>
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);

View File

@ -1,141 +0,0 @@
From 9cd60ef7831fff69f2dacc2bf216c3537b2cd6e9 Mon Sep 17 00:00:00 2001
From: Jean Ghali <jghali@libertysurf.fr>
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<PDFColorSpace> & usedColorSpaces, bool & hasTransparency, QList<PDFFont> & usedFonts, QList<PDFImage> & 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<PdfName, PDFColorSpace> processedNamedCS;
QMap<PdfName, PDFFont> processedNamedFont;
QList<PdfName> processedNamedXObj;
QList<PdfName> 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<PdfPage*>(canvas);
- PdfObject* canvasObject = page?(page->GetObject()):((dynamic_cast<PdfXObject*>(canvas))->GetObject());
+ PdfObject* canvasObject = page ? (page->GetObject()) : ((dynamic_cast<PdfXObject*>(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;

View File

@ -1,514 +0,0 @@
From bb6c0716035bcdc9fd4bd536d1ed6f01a1c6e9fa Mon Sep 17 00:00:00 2001
From: Jean Ghali <jghali@libertysurf.fr>
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<PDFColorSpace> & usedColorSpaces, bool & hasTransparency, QList<PDFFont> & usedFonts, QList<PDFImage> & 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<PdfName, PDFColorSpace> processedNamedCS;
QMap<PdfName, PDFFont> processedNamedFont;
QList<PdfName> processedNamedXObj;
@@ -182,30 +181,41 @@ bool PDFAnalyzer::inspectCanvas(PdfCanva
// needed for the finding resources code below to work
PdfPage* page = dynamic_cast<PdfPage*>(canvas);
PdfObject* canvasObject = page ? (page->GetObject()) : ((dynamic_cast<PdfXObject*>(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<PDFColorSpace> & usedColorSpaces, bool & hasTransparency, QList<PDFFont> & 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<PoDoFo::PdfReference, PdfId> importedObjects;
QList<PoDoFo::PdfReference> 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<qlonglong>(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<qlonglong>(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();

View File

@ -1,853 +0,0 @@
From 000d73d22b362a010bd4c80e6076343bc62119f3 Mon Sep 17 00:00:00 2001
From: Jean Ghali <jghali@libertysurf.fr>
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<QString, PDFContentStreamKeyword> 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<PDFColorSpace> & usedColorSpaces, bool & hasTransparency, QList<PDFFont> & usedFonts, QList<PDFImage> & 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<PdfPage*>(canvas);
-#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(0, 10, 0))
PdfObject* canvasObject = page ? &(page->GetObject()) : &(dynamic_cast<PdfXObject*>(canvas)->GetObject());
-
-#else
- PdfObject* canvasObject = page ? (page->GetObject()) : ((dynamic_cast<PdfXObject*>(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<PdfVariant> args;
QStack<PDFGraphicState> 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<PdfName, PDFColorSpace> processedNamedCS;
+ QMap<PdfName, PDFFont> processedNamedFont;
+ QList<PdfName> processedNamedXObj;
+ QList<PdfName> processedNamedGS;
+ try
+ {
+ // get hold of a PdfObject pointer of this canvas
+ // needed for the finding resources code below to work
+ PdfPage* page = dynamic_cast<PdfPage*>(canvas);
+ PdfObject* canvasObject = page ? (page->GetObject()) : ((dynamic_cast<PdfXObject*>(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<PDFColorSpace> & usedColorSpaces, bool & hasTransparency, QList<PDFFont> & 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<PoDoFo::PdfReference, PdfId> importedObjects;
QList<PoDoFo::PdfReference> 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<qlonglong>(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;
}

View File

@ -1,22 +0,0 @@
From 148fc05557975267b05ebe670822793999ea3e0a Mon Sep 17 00:00:00 2001
From: Craig Bradney <mrb@scribus.info>
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")

View File

@ -1,107 +0,0 @@
From 6ae729e1b45f92428168475c316f3b45a8e99d74 Mon Sep 17 00:00:00 2001
From: Craig Bradney <mrb@scribus.info>
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)

View File

@ -1,30 +0,0 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,11 +75,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
#RPATH setup - more below too
-if (WANT_NORPATH OR WANT_DISTROBUILD)
- set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
-else()
- set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
-endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
set(CMAKE_SKIP_BUILD_RPATH TRUE)
@@ -344,15 +339,6 @@ include (CMakeLists_Directories.cmake)
#Convert our simpler command line option to the CMake style
#None, Debug, Release, .. or custom ones
-if(WANT_DEBUG)
- set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Set Debug Build Type" FORCE)
-endif()
-if (WANT_RELEASEWITHDEBUG)
- set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Set Release with Debug Info Build Type" FORCE)
-endif()
-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)

View File

@ -1,31 +0,0 @@
--- a/scribus/util.cpp 2019-07-31 00:35:04.000000000 +0200
+++ b/scribus/util.cpp 2019-07-31 00:35:04.000000000 +0200
@@ -40,7 +40,7 @@
#include <csignal>
-#if !defined(_WIN32) && !defined(Q_OS_MAC)
+#if defined(__GLIBC__)
#include <execinfo.h>
#include <cxxabi.h>
#endif
--- a/scribus/util_debug.cpp 2019-07-31 00:35:07.000000000 +0200
+++ b/scribus/util_debug.cpp 2019-07-31 00:35:07.000000000 +0200
@@ -24,7 +24,7 @@
#include <QDateTime>
#include <QtGlobal>
-#if !defined(_WIN32) && !defined(Q_OS_MAC)
+#if defined(__GLIBC__)
#include <execinfo.h>
#include <cxxabi.h>
#endif
@@ -54,7 +54,7 @@
*/
void printBacktrace ( int nFrames )
{
-#if !defined(_WIN32) && !defined(Q_OS_MAC) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_FREEBSD)
+#if defined(__GLIBC__)
void ** trace = new void*[nFrames + 1];
char **messages = ( char ** ) nullptr;
int i, trace_size = 0;

View File

@ -0,0 +1,69 @@
--- a/scribus/third_party/pgf/PGFplatform.h
+++ b/scribus/third_party/pgf/PGFplatform.h
@@ -341,14 +341,6 @@
#define __POSIX__
#endif
-#ifndef off64_t
-#define off64_t off_t
-#endif
-
-#ifndef lseek64
-#define lseek64 lseek
-#endif
-
#endif // __NetBSD__ or __OpenBSD__ or __FreeBSD__ or __HAIKU__
@@ -529,39 +521,21 @@
}
__inline OSError GetFPos(HANDLE hFile, UINT64 *pos) {
- #ifdef __APPLE__
- off_t ret;
- if ((ret = lseek(hFile, 0, SEEK_CUR)) == -1) {
- return errno;
- } else {
- *pos = (UINT64)ret;
- return NoError;
- }
- #else
- off64_t ret;
- if ((ret = lseek64(hFile, 0, SEEK_CUR)) == -1) {
- return errno;
- } else {
- *pos = (UINT64)ret;
- return NoError;
- }
- #endif
+ off_t ret;
+ if ((ret = lseek(hFile, 0, SEEK_CUR)) == -1) {
+ return errno;
+ } else {
+ *pos = (UINT64)ret;
+ return NoError;
+ }
}
__inline OSError SetFPos(HANDLE hFile, int posMode, INT64 posOff) {
- #ifdef __APPLE__
- if ((lseek(hFile, (off_t)posOff, posMode)) == -1) {
- return errno;
- } else {
- return NoError;
- }
- #else
- if ((lseek64(hFile, (off64_t)posOff, posMode)) == -1) {
- return errno;
- } else {
- return NoError;
- }
- #endif
+ if ((lseek(hFile, (off_t)posOff, posMode)) == -1) {
+ return errno;
+ } else {
+ return NoError;
+ }
}
#endif /* __POSIX__ */

View File

@ -0,0 +1,33 @@
dirty hack to remove execinfo
diff --git a/scribus/util.cpp b/scribus/util.cpp
--- a/scribus/util.cpp
+++ b/scribus/util.cpp
@@ -43,7 +43,7 @@
#include <csignal>
-#if !defined(_WIN32) && !defined(Q_OS_MACOS)
+#if !defined(_WIN32) && !defined(Q_OS_MACOS) && defined(__GLIBC__)
#include <execinfo.h>
#include <cxxabi.h>
#endif
--- a/scribus/util_debug.cpp
+++ b/scribus/util_debug.cpp
@@ -24,7 +24,7 @@
#include <QDateTime>
#include <QtGlobal>
-#if !defined(_WIN32) && !defined(Q_OS_MACOS)
+#if !defined(_WIN32) && !defined(Q_OS_MACOS) && defined(__GLIBC__)
#include <execinfo.h>
#include <cxxabi.h>
#endif
@@ -53,7 +53,7 @@
*/
void printBacktrace ( int nFrames )
{
-#if !defined(_WIN32) && !defined(Q_OS_MACOS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_FREEBSD)
+#if !defined(_WIN32) && !defined(Q_OS_MACOS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_FREEBSD) && defined(__GLIBC__)
void ** trace = new void*[nFrames + 1];
char **messages = ( char ** ) nullptr;
int i, trace_size = 0;

View File

@ -1,64 +0,0 @@
--- ./scribus/plugins/scriptplugin/cmdgetsetprop.cpp.orig 2023-09-28 09:13:21.384565229 -0400
+++ ./scribus/plugins/scriptplugin/cmdgetsetprop.cpp 2023-09-28 09:21:08.298879558 -0400
@@ -409,10 +409,10 @@
success = obj->setProperty(propertyName, QString::fromUtf8(PyBytes_AsString(objValue)));
else if (PyUnicode_Check(objValue))
{
- // Get a pointer to the internal buffer of the Py_Unicode object, which is UCS2 formatted
- const unsigned short * ucs2Data = (const unsigned short *) PyUnicode_AS_UNICODE(objValue);
- // and make a new QString from it (the string is copied)
- success = obj->setProperty(propertyName, QString::fromUtf16(ucs2Data));
+ // Get the data as a wchar_t array and copy to a QString
+ Py_ssize_t wcsize = 0;
+ const wchar_t * const wcdata = PyUnicode_AsWideCharString(objValue, &wcsize);
+ success = obj->setProperty(propertyName, QString::fromWCharArray(wcdata, wcsize));
}
else
matched = false;
@@ -429,10 +429,10 @@
}
else if (PyUnicode_Check(objValue))
{
- // Get a pointer to the internal buffer of the Py_Unicode object, which is UCS2 formatted
- const unsigned short * utf16Data = (const unsigned short *)PyUnicode_AS_UNICODE(objValue);
- // and make a new QString from it (the string is copied)
- success = obj->setProperty(propertyName, QString::fromUtf16(utf16Data).toLatin1());
+ // Get the data as a wchar_t array and copy to a QString
+ Py_ssize_t wcsize = 0;
+ const wchar_t * const wcdata = PyUnicode_AsWideCharString(objValue, &wcsize);
+ success = obj->setProperty(propertyName, QString::fromWCharArray(wcdata, wcsize));
}
else
matched = false;
--- ./scribus/plugins/scriptplugin_py2x/cmdgetsetprop.cpp.orig 2023-09-28 09:13:07.372484278 -0400
+++ ./scribus/plugins/scriptplugin_py2x/cmdgetsetprop.cpp 2023-09-28 09:22:02.366125450 -0400
@@ -406,10 +406,10 @@
success = obj->setProperty(propertyName, QString::fromUtf8(PyString_AsString(objValue)));
else if (PyUnicode_Check(objValue))
{
- // Get a pointer to the internal buffer of the Py_Unicode object, which is UCS2 formatted
- const unsigned short * ucs2Data = (const unsigned short *)PyUnicode_AS_UNICODE(objValue);
- // and make a new QString from it (the string is copied)
- success = obj->setProperty(propertyName, QString::fromUtf16(ucs2Data));
+ // Get the data as a wchar_t array and copy to a QString
+ Py_ssize_t wcsize = 0;
+ const wchar_t * const wcdata = PyUnicode_AsWideCharString(objValue, &wcsize);
+ success = obj->setProperty(propertyName, QString::fromWCharArray(wcdata, wcsize));
}
else
matched = false;
@@ -426,10 +426,10 @@
}
else if (PyUnicode_Check(objValue))
{
- // Get a pointer to the internal buffer of the Py_Unicode object, which is UCS2 formatted
- const unsigned short * utf16Data = (const unsigned short *)PyUnicode_AS_UNICODE(objValue);
- // and make a new QString from it (the string is copied)
- success = obj->setProperty(propertyName, QString::fromUtf16(utf16Data).toLatin1());
+ // Get the data as a wchar_t array and copy to a QString
+ Py_ssize_t wcsize = 0;
+ const wchar_t * const wcdata = PyUnicode_AsWideCharString(objValue, &wcsize);
+ success = obj->setProperty(propertyName, QString::fromWCharArray(wcdata, wcsize));
}
else
matched = false;

View File

@ -1,10 +1,10 @@
# Template file for 'scribus'
pkgname=scribus
version=1.5.8
revision=13
version=1.6.2
revision=1
build_style=cmake
configure_args="-DCMAKE_SKIP_RPATH=TRUE -DQT_PREFIX=${XBPS_CROSS_BASE}/usr
-DWANT_GRAPHICSMAGICK=1 -DWANT_CPP17=ON"
-DWANT_GRAPHICSMAGICK=1 -DWANT_CPP20=ON"
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
@ -16,6 +16,11 @@ short_desc="Open Source DTP (Desktop Publishing) application"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="GPL-2.0-or-later"
homepage="https://scribus.net"
distfiles="$SOURCEFORGE_SITE/scribus/scribus-devel/${version}/scribus-${version}.tar.xz"
checksum=47816e8fcf6d05788ff16aa4499f97ff22431c777a7789149b0a88b451e16b74
distfiles="$SOURCEFORGE_SITE/scribus/scribus/${version}/scribus-${version}.tar.xz"
checksum=7eff9b1f47e372e56bb369f1dbe18fe49101789b5e6bcfdb7890e0346b641383
python_version=3
do_patch() {
vsed -i CMakeLists.txt -e 's|WANT_CPP17|WANT_CPP20|g' \
-e 's|CMAKE_CXX_STANDARD 17|CMAKE_CXX_STANDARD 20|g'
}