r19115 by avox - oops2

scribus-commit scribus-commit at lists.scribus.net
Sun May 11 22:31:13 UTC 2014


Author: avox
Date: Sun May 11 22:31:12 2014
New Revision: 19115

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19115
Log:
oops2

Modified:
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/pdflib_core.h

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19115&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Sun May 11 22:31:12 2014
@@ -72,7 +72,7 @@
 #include "scpage.h"
 #include "scpaths.h"
 #include "scpattern.h"
-#include "scribus.h"
+
 #include "scribuscore.h"
 #include "scribusdoc.h"
 #include "scstreamfilter_flate.h"
@@ -172,6 +172,28 @@
 	return QString::number(v, 'f', 5);
 };
 
+bool PDFLibCore::PDF_IsPDFX()
+{
+	if (Options.Version == PDFOptions::PDFVersion_X1a)
+		return true;
+	if (Options.Version == PDFOptions::PDFVersion_X3)
+		return true;
+	if (Options.Version == PDFOptions::PDFVersion_X4)
+		return true;
+	return false;
+}
+
+bool PDFLibCore::PDF_IsPDFX(PDFOptions::PDFVersion ver)
+{
+	if (ver == PDFOptions::PDFVersion_X1a)
+		return true;
+	if (ver == PDFOptions::PDFVersion_X3)
+		return true;
+	if (ver == PDFOptions::PDFVersion_X4)
+		return true;
+	return false;
+}
+
 bool PDFLibCore::doExport(const QString& fn, const QString& nam, int Components,
 					  const std::vector<int> & pageNs, const QMap<int,QPixmap> & thumbs)
 {
@@ -253,7 +275,7 @@
 		ret = true;//Even when aborting we return true. Dont want that "couldnt write msg"
 		if (!abortExport)
 		{
-			if ((doc.pdfOptions().Version == PDFOptions::PDFVersion_X3) || (doc.pdfOptions().Version == PDFOptions::PDFVersion_X1a) || (doc.pdfOptions().Version == PDFOptions::PDFVersion_X4))
+			if (PDF_IsPDFX(doc.pdfOptions().Version))
 				ret = PDF_End_Doc(ScCore->PrinterProfiles[doc.pdfOptions().PrintProf], nam, Components);
 			else
 				ret = PDF_End_Doc();
@@ -783,14 +805,14 @@
 			PutDoc("%PDF-1.5\n");
 			break;
 	}
-	if ((Options.Version == PDFOptions::PDFVersion_X3) || (Options.Version == PDFOptions::PDFVersion_X1a) || (Options.Version == PDFOptions::PDFVersion_X4))
+	if (PDF_IsPDFX())
 		ObjCounter++;
 	PutDoc("%\xc7\xec\x8f\xa2\n");
 	StartObj(1);
 	PutDoc("<<\n/Type /Catalog\n/Outlines 3 0 R\n/Pages 4 0 R\n/Dests 5 0 R\n/AcroForm 6 0 R\n/Names 7 0 R\n/Threads 8 0 R\n");
 	if (((Options.Version == PDFOptions::PDFVersion_15) || (Options.Version == PDFOptions::PDFVersion_X4)) && (Options.useLayers))
 		PutDoc("/OCProperties 9 0 R\n");
-	if ((Options.Version == PDFOptions::PDFVersion_X3) || (Options.Version == PDFOptions::PDFVersion_X1a) || (Options.Version == PDFOptions::PDFVersion_X4))
+	if (PDF_IsPDFX())
 		PutDoc("/OutputIntents [ "+QString::number(ObjCounter-1)+" 0 R ]\n");
 	if ((Options.Version == PDFOptions::PDFVersion_X4))
 	{
@@ -918,7 +940,7 @@
 	PutDoc("<<\n/Creator " + EncString("Scribus "+QString(VERSION), 2) + "\n");
 	PutDoc("/Producer " + EncString("Scribus PDF Library "+QString(VERSION), 2) + "\n");
 	QString docTitle = doc.documentInfo().title();
-	if (((Options.Version == PDFOptions::PDFVersion_X3) || (Options.Version == PDFOptions::PDFVersion_X1a) || (Options.Version == PDFOptions::PDFVersion_X4)) && (docTitle.isEmpty()))
+	if ((PDF_IsPDFX()) && (docTitle.isEmpty()))
 		PutDoc("/Title " + EncStringUTF16(doc.DocName, 2) + "\n");
 	else
 		PutDoc("/Title " + EncStringUTF16(doc.documentInfo().title(), 2) + "\n");
@@ -927,13 +949,13 @@
 	PutDoc("/Keywords " + EncStringUTF16(doc.documentInfo().keywords(), 2) + "\n");
 	PutDoc("/CreationDate " + EncString(Datum, 2) + "\n");
 	PutDoc("/ModDate " + EncString(Datum, 2) + "\n");
+	if (Options.Version == PDFOptions::PDFVersion_X1a)
+	{
+		PutDoc("/GTS_PDFXVersion (PDF/X-1:2001)\n");
+		PutDoc("/GTS_PDFXConformance (PDF/X-1a:2001)\n");
+	}
 	if (Options.Version == PDFOptions::PDFVersion_X3)
 		PutDoc("/GTS_PDFXVersion (PDF/X-3:2002)\n");
-	if (Options.Version == PDFOptions::PDFVersion_X1a)
-	{
-		PutDoc("/GTS_PDFXVersion (PDF/X-1:2001)\n");
-		PutDoc("/GTS_PDFXConformance (PDF/X-1a:2001)\n");
-	}
 	if (Options.Version == PDFOptions::PDFVersion_X4)
 		PutDoc("/GTS_PDFXVersion (PDF/X-4)\n");
 	PutDoc("/Trapped /False\n>>\nendobj\n");
@@ -941,7 +963,7 @@
 		XRef.append(bytesWritten());
 	if (((Options.Version == PDFOptions::PDFVersion_15) || (Options.Version == PDFOptions::PDFVersion_X4)) && (Options.useLayers))
 		XRef.append(bytesWritten());
-	if ((Options.Version == PDFOptions::PDFVersion_X3) || (Options.Version == PDFOptions::PDFVersion_X1a) || (Options.Version == PDFOptions::PDFVersion_X4))
+	if (PDF_IsPDFX())
 		XRef.append(bytesWritten());
 	if (Options.Version == PDFOptions::PDFVersion_X4)
 		XRef.append(bytesWritten());
@@ -1849,7 +1871,7 @@
 		Transpar[HTName] = writeGState("/HT "+QString::number(halftones)+" 0 R\n");
 		ResCount++;
 	}
-	if ((doc.HasCMS) && (Options.UseProfiles) && (Options.Version != PDFOptions::PDFVersion_X1a ))
+	if ((doc.HasCMS) && (Options.UseProfiles) && (Options.Version != PDFOptions::PDFVersion_X1a))
 	{
 		uint iccProfileObject = newObject();
 		StartObj(iccProfileObject);
@@ -2266,13 +2288,13 @@
 							multiLine ml = doc.MLineStyles[ite->NamedLStyle];
 							for (int it = ml.size()-1; it > -1; it--)
 							{
-									if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
-									{
-										PutPage(setStrokeMulti(&ml[it]));
-										PutPage("0 0 m\n");
-										PutPage(FToStr(ite->width())+" 0 l\n");
-										PutPage("S\n");
-									}
+								if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
+								{
+									PutPage(setStrokeMulti(&ml[it]));
+									PutPage("0 0 m\n");
+									PutPage(FToStr(ite->width())+" 0 l\n");
+									PutPage("S\n");
+								}
 							}
 						}
 						if (ite->startArrowIndex() != 0)
@@ -2392,7 +2414,7 @@
 						break;
 					case PageItem::PolyLine:
 					case PageItem::Spiral:
-						if (ite->PoLine.size() > 4) // && ((ite->PoLine.point(0) != ite->PoLine.point(1)) || (ite->PoLine.point(2) != ite->PoLine.point(3))))
+						if (ite->PoLine.size() > 3) // && ((ite->PoLine.point(0) != ite->PoLine.point(1)) || (ite->PoLine.point(2) != ite->PoLine.point(3))))
 						{
 							PutPage("q\n");
 							if (((ite->GrMask > 0) || (ite->fillTransparency() != 0) || (ite->fillBlendmode() != 0)) && ((Options.Version >= PDFOptions::PDFVersion_14) || (Options.Version == PDFOptions::PDFVersion_X4)))
@@ -3874,7 +3896,7 @@
 			}
 			break;
 		case PageItem::TextFrame:
-			if ((ite->isAnnotation()) && (Options.Version != PDFOptions::PDFVersion_X3) && (Options.Version != PDFOptions::PDFVersion_X1a) && (Options.Version != PDFOptions::PDFVersion_X4))
+			if ((ite->isAnnotation()) && (!PDF_IsPDFX()))
 			{
 				if (ite->annotation().Type() == Annotation::RadioButton)
 				{
@@ -4165,7 +4187,7 @@
 			break;
 		case PageItem::PolyLine:
 		case PageItem::Spiral:
-			if (ite->PoLine.size() > 4)  // && ((ite->PoLine.point(0) != ite->PoLine.point(1)) || (ite->PoLine.point(2) != ite->PoLine.point(3))))
+			if (ite->PoLine.size() > 3)  // && ((ite->PoLine.point(0) != ite->PoLine.point(1)) || (ite->PoLine.point(2) != ite->PoLine.point(3))))
 			{
 				tmp += "q\n";
 				if (((ite->GrMask > 0) || (ite->fillTransparency() != 0) || (ite->fillBlendmode() != 0)) && ((Options.Version >= PDFOptions::PDFVersion_14) || (Options.Version == PDFOptions::PDFVersion_X4)))
@@ -6211,7 +6233,10 @@
 		else
 			PutDoc("/ShadingType 3\n");
 		PutDoc("/ColorSpace /DeviceGray\n");
-		PutDoc("/Extend [true true]\n");
+		if (gradient.repeatMethod() == VGradient::none)
+			PutDoc("/Extend [false false]\n");
+		else
+			PutDoc("/Extend [true true]\n");
 		if ((GType == 1) || (GType == 4))
 			PutDoc("/Coords ["+FToStr(StartX)+" "+FToStr(-StartY)+" "+FToStr(EndX)+" "+FToStr(-EndY)+"]\n");
 		else
@@ -6568,7 +6593,7 @@
 			mpa.rotate(-currItem->rotation());
 		}
 	}
-	double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, patternSpace;
+	double patternScaleX=0.0, patternScaleY=0.0, patternOffsetX=0.0, patternOffsetY=0.0, patternRotation=0.0, patternSkewX=0.0, patternSkewY=0.0, patternSpace=0.0;
 	bool mirrorX=false, mirrorY=false;
 	if (kind == 0)
 	{
@@ -8283,7 +8308,10 @@
 		else
 			PutDoc("/ShadingType 3\n");
 		PutDoc("/ColorSpace /DeviceGray\n");
-		PutDoc("/Extend [true true]\n");
+		if (gradient.repeatMethod() == VGradient::none)
+			PutDoc("/Extend [false false]\n");
+		else
+			PutDoc("/Extend [true true]\n");
 		if (GType == 6)
 			PutDoc("/Coords ["+FToStr(StartX)+" "+FToStr(-StartY)+" "+FToStr(EndX)+" "+FToStr(-EndY)+"]\n");
 		else
@@ -8404,7 +8432,10 @@
 		else
 			PutDoc("/ColorSpace /DeviceCMYK\n");
 	}
-	PutDoc("/Extend [true true]\n");
+	if (gradient.repeatMethod() == VGradient::none)
+		PutDoc("/Extend [false false]\n");
+	else
+		PutDoc("/Extend [true true]\n");
 	if (GType == 6)
 		PutDoc("/Coords ["+FToStr(StartX)+" "+FToStr(-StartY)+" "+FToStr(EndX)+" "+FToStr(-EndY)+"]\n");
 	else
@@ -11151,7 +11182,7 @@
 		PutDoc("]\n");
 		PutDoc(">>\nendobj\n");
 	}
-	if ((Options.Version == PDFOptions::PDFVersion_X3) || (Options.Version == PDFOptions::PDFVersion_X1a) || (Options.Version == PDFOptions::PDFVersion_X4))
+	if (PDF_IsPDFX())
 	{
 		StartObj(ObjCounter);
 		ObjCounter++;
@@ -11289,7 +11320,7 @@
 	li1.setAttribute("xml:lang", "x-default");
 	alt1.appendChild(li1);
 	QString docTitle = doc.documentInfo().title();
-	if (((Options.Version == PDFOptions::PDFVersion_X3) || (Options.Version == PDFOptions::PDFVersion_X1a) || (Options.Version == PDFOptions::PDFVersion_X4)) && (docTitle.isEmpty()))
+	if ((PDF_IsPDFX()) && (docTitle.isEmpty()))
 		docTitle = doc.DocName;
 	li1.appendChild(xmpDoc.createTextNode(docTitle));
 	QDomElement creator = xmpDoc.createElement("dc:creator");
@@ -11309,7 +11340,7 @@
 	alt2.appendChild(li3);
 	li3.appendChild(xmpDoc.createTextNode(doc.documentInfo().subject()));
 
-	if ((Options.Version == PDFOptions::PDFVersion_X3) || (Options.Version == PDFOptions::PDFVersion_X1a) || (Options.Version == PDFOptions::PDFVersion_X4))
+	if (PDF_IsPDFX())
 	{
 		QDomElement descPDFXID = desc.cloneNode().toElement();
 		rdf.appendChild(descPDFXID);
@@ -11324,7 +11355,6 @@
 		else if (Options.Version == PDFOptions::PDFVersion_X4)
 			descPDFXID.setAttributeNS(pdfxidNS, "pdfxid:GTS_PDFXVersion", "PDF/X-4");
 	}
-
 
 	QDomElement descXMPMM = desc.cloneNode().toElement();
 	rdf.appendChild(descXMPMM);

Modified: trunk/Scribus/scribus/pdflib_core.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19115&path=/trunk/Scribus/scribus/pdflib_core.h
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.h (original)
+++ trunk/Scribus/scribus/pdflib_core.h Sun May 11 22:31:12 2014
@@ -31,6 +31,7 @@
 class ScLayer;
 class ScText;
 
+#include "pdfoptions.h"
 #include "scribusstructs.h"
 #include "scimagestructs.h"
 #include "tableborder.h"
@@ -81,6 +82,9 @@
 		double origYsc;
 		QMap<int, ImageLoadRequest> RequestProps;
 	};
+
+	bool PDF_IsPDFX();
+	bool PDF_IsPDFX(PDFOptions::PDFVersion ver);
 
 	bool PDF_Begin_Doc(const QString& fn, SCFonts &AllFonts, QMap<QString, QMap<uint, FPointArray> > DocFonts, BookMView* vi);
 	void PDF_Begin_Page(const ScPage* pag, QPixmap pm);




More information about the scribus-commit mailing list