File 0001-Fix-build-with-PoDoFo-1.0.0.patch of Package scribus

From 857b62b7e88eb024539650a3de3c9b26c338ff64 Mon Sep 17 00:00:00 2001
From: jghali <jghali@11d20701-8431-0410-a711-e3c959e3b870>
Date: Fri, 6 Jun 2025 23:40:58 +0000
Subject: [PATCH] Fix build with PoDoFo 1.0.0

git-svn-id: svn://scribus.net/trunk/Scribus@26920 11d20701-8431-0410-a711-e3c959e3b870
---
 scribus/pdf_analyzer.cpp | 31 +++++++++++++++++++++++++++++++
 scribus/pdflib_core.cpp  | 18 ++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/scribus/pdf_analyzer.cpp b/scribus/pdf_analyzer.cpp
index d923148..3ecff48 100644
--- a/scribus/pdf_analyzer.cpp
+++ b/scribus/pdf_analyzer.cpp
@@ -276,7 +276,11 @@ bool PDFAnalyzer::inspectCanvas(PdfCanvas* canvas, QList<PDFColorSpace> & usedCo
 	try
 	{
 		// start parsing the content stream
+#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0))
+		PdfContentReaderArgs tokenizerArgs;
+#else
 		PdfContentReaderArgs tokenizerArgs = { PdfContentReaderFlags::DontFollowXObjectForms };
+#endif
 		PdfContentStreamReader tokenizer(*canvas, tokenizerArgs);
 		PdfContent pdfContent;
 		PdfVariant var;
@@ -289,13 +293,29 @@ bool PDFAnalyzer::inspectCanvas(PdfCanvas* canvas, QList<PDFColorSpace> & usedCo
 		while (tokenizer.TryReadNext(pdfContent))
 		{
 			++tokenNumber;
+#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0))
+			if (pdfContent.GetType() == PdfContentType::Operator)
+#else
 			if (pdfContent.Type == PdfContentType::Operator)
+#endif
 			{
 				args.clear();
+#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0))
+				const auto& pdfContentStack = pdfContent.GetStack();
+				size_t stackSize = pdfContentStack.size();
+				for (size_t i = 0; i < stackSize; ++i)
+					args.append(pdfContentStack[stackSize - 1 - i]);
+#else
+
 				size_t stackSize = pdfContent.Stack.size();
 				for (size_t i = 0; i < stackSize; ++i)
 					args.append(pdfContent.Stack[stackSize - 1 - i]);
+#endif
+#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0))
+				switch (pdfContent.GetOperator())
+#else
 				switch (pdfContent.Operator)
+#endif
 				{
 				case PdfOperator::q:
 					gsStack.push(currGS);
@@ -677,12 +697,23 @@ bool PDFAnalyzer::inspectCanvas(PdfCanvas* canvas, QList<PDFColorSpace> & usedCo
 				}
 				args.clear();
 			}
+#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0))
+			if (pdfContent.GetType() == PdfContentType::DoXObject)
+#else
 			if (pdfContent.Type == PdfContentType::DoXObject)
+#endif
 			{
 				args.clear();
+#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0))
+				const auto& pdfContentStack = pdfContent.GetStack();
+				size_t stackSize = pdfContentStack.size();
+				for (size_t i = 0; i < stackSize; ++i)
+					args.append(pdfContentStack[stackSize - 1 - i]);
+#else
 				size_t stackSize = pdfContent.Stack.size();
 				for (size_t i = 0; i < stackSize; ++i)
 					args.append(pdfContent.Stack[stackSize - 1 - i]);
+#endif
 				if (!processedNamedXObj.contains(args[0].GetName()))
 				{
 					if (args.size() == 1 && args[0].IsName() && xObjectsDict)
diff --git a/scribus/pdflib_core.cpp b/scribus/pdflib_core.cpp
index 3465ccd..5c6ebd1 100644
--- a/scribus/pdflib_core.cpp
+++ b/scribus/pdflib_core.cpp
@@ -9834,7 +9834,11 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, doub
 		PoDoFo::PdfPage& page = doc->GetPages().GetPageAt(qMin(qMax(1, c->pixm.imgInfo.actualPageNumber), c->pixm.imgInfo.numberOfPages) - 1);
 		PoDoFo::PdfObject& pageObj = page.GetObject();
 		PoDoFo::PdfObject* contents = page.GetContents() ? &(page.GetContents()->GetObject()) : nullptr;
+#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0))
+		const PoDoFo::PdfObject* resources = &(page.GetResources().GetObject());
+#else
 		PoDoFo::PdfObject* resources = page.GetResources() ? &(page.GetResources()->GetObject()) : nullptr;
+#endif
 		PoDoFo::PdfDictionary* pageObjDict = pageObj.IsDictionary() ? &(pageObj.GetDictionary()) : nullptr;
 		for (PoDoFo::PdfDictionary* par = pageObjDict, *parentDict = nullptr; par && !resources; par = parentDict)
 		{
@@ -9855,8 +9859,15 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, doub
 			importedObjects[page.GetObject().GetIndirectReference()] = xObj;
 			writer.startObj(xObj);
 			PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1");
+#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0))
+			PoDoFo::Rect pageRect = page.GetArtBoxRaw().GetNormalized(); // Because scimagedataloader_pdf use ArtBox
+			double rotation = 0;
+			if (!page.TryGetRotationRaw(rotation))
+				rotation = 0;
+#else
 			PoDoFo::Rect pageRect = page.GetArtBox(true); // Because scimagedataloader_pdf use ArtBox
 			int rotation = page.GetRotationRaw();
+#endif
 			double imgWidth  = (rotation == 90 || rotation == 270) ? pageRect.Height : pageRect.Width;
 			double imgHeight = (rotation == 90 || rotation == 270) ? pageRect.Width : pageRect.Height;
 			QTransform pageM;
@@ -9976,8 +9987,15 @@ bool PDFLibCore::PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, doub
 			importedObjects[page.GetObject().GetIndirectReference()] = xObj;
 			writer.startObj(xObj);
 			PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1");
+#if (PODOFO_VERSION >= PODOFO_MAKE_VERSION(1, 0, 0))
+			PoDoFo::Rect pageRect = page.GetArtBoxRaw().GetNormalized(); // Because scimagedataloader_pdf use ArtBox
+			double rotation = 0;
+			if (!page.TryGetRotationRaw(rotation))
+				rotation = 0;
+#else
 			PoDoFo::Rect pageRect = page.GetArtBox(true); // Because scimagedataloader_pdf use ArtBox
 			int rotation = page.GetRotationRaw();
+#endif
 			double imgWidth  = (rotation == 90 || rotation == 270) ? pageRect.Height : pageRect.Width;
 			double imgHeight = (rotation == 90 || rotation == 270) ? pageRect.Width : pageRect.Height;
 			QTransform pageM;
-- 
2.49.0

openSUSE Build Service is sponsored by