r18742 by jghali - fix xps export issue with doc from #11884 caused by incorrect export of clipping path

scribus-commit scribus-commit at lists.scribus.net
Sat Jan 18 14:51:03 UTC 2014


Author: jghali
Date: Sat Jan 18 14:51:02 2014
New Revision: 18742

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18742
Log:
fix xps export issue with doc from #11884 caused by incorrect export of clipping path

Modified:
    trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.cpp
    trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.h

Modified: trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18742&path=/trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.cpp Sat Jan 18 14:51:02 2014
@@ -471,12 +471,7 @@
 					}
 					FPointArray path = Item->PoLine.copy();
 					path.scale(conversionFactor, conversionFactor);
-					QString pa = SetClipPath(&path, true);
-					if (Item->fillRule)
-						pa.prepend("F 0 ");
-					else
-						pa.prepend("F 1 ");
-					ob.setAttribute("Clip", pa);
+					SetClipAttr(ob, &path, Item->fillRule);
 					QTransform mpx;
 					mpx.translate(xOffset * conversionFactor, yOffset * conversionFactor);
 					mpx.scale(Item->width() / Item->groupWidth, Item->height() / Item->groupHeight);
@@ -1434,12 +1429,7 @@
 	QDomElement ob = p_docu.createElement("Canvas");
 	FPointArray path = Item->PoLine.copy();
 	path.scale(conversionFactor, conversionFactor);
-	QString pa = SetClipPath(&path, true);
-	if (Item->fillRule)
-		pa.prepend("F 0 ");
-	else
-		pa.prepend("F 1 ");
-	ob.setAttribute("Clip", pa);
+	SetClipAttr(ob, &path, Item->fillRule);
 	ScPattern pat = m_Doc->docPatterns[Item->pattern()];
 	QTransform mpx;
 	mpx.translate(xOffset * conversionFactor, yOffset * conversionFactor);
@@ -2516,42 +2506,55 @@
 	return "#" + alpha + color;
 }
 
+void XPSExPlug::SetClipAttr(QDomElement &elem, FPointArray *ite, bool fillRule)
+{
+	QString pathStr = SetClipPath(ite, true);
+	if (pathStr.length() > 0)
+	{
+		if (fillRule)
+			pathStr.prepend("F 0 ");
+		else
+			pathStr.prepend("F 1 ");
+		elem.setAttribute("Clip", pathStr);
+	}
+}
+
 QString XPSExPlug::SetClipPath(FPointArray *ite, bool closed)
 {
-	QString tmp = "";
+	QString tmp;
 	FPoint np, np1, np2, np3, np4, firstP;
 	bool nPath = true;
 	bool first = true;
-	if (ite->size() > 3)
-	{
-		for (int poi=0; poi<ite->size()-3; poi += 4)
-		{
-			if (ite->point(poi).x() > 900000)
-			{
-				nPath = true;
-				continue;
-			}
-			if (nPath)
-			{
-				np = ite->point(poi);
-				if ((!first) && (closed) && (np4 == firstP))
-					tmp += "Z ";
-				tmp += QString("M%1,%2 ").arg(np.x()).arg(np.y());
-				nPath = false;
-				first = false;
-				firstP = np;
-				np4 = np;
-			}
+	if (ite->size() <= 3)
+		return tmp;
+
+	for (int poi=0; poi<ite->size()-3; poi += 4)
+	{
+		if (ite->point(poi).x() > 900000)
+		{
+			nPath = true;
+			continue;
+		}
+		if (nPath)
+		{
 			np = ite->point(poi);
-			np1 = ite->point(poi+1);
-			np2 = ite->point(poi+3);
-			np3 = ite->point(poi+2);
-			if ((np == np1) && (np2 == np3))
-				tmp += QString("L%1,%2 ").arg(np3.x()).arg(np3.y());
-			else
-				tmp += QString("C%1,%2 %3,%4 %5,%6 ").arg(np1.x()).arg(np1.y()).arg(np2.x()).arg(np2.y()).arg(np3.x()).arg(np3.y());
-			np4 = np3;
-		}
+			if ((!first) && (closed) && (np4 == firstP))
+				tmp += "Z ";
+			tmp += QString("M%1,%2 ").arg(np.x()).arg(np.y());
+			nPath = false;
+			first = false;
+			firstP = np;
+			np4 = np;
+		}
+		np = ite->point(poi);
+		np1 = ite->point(poi+1);
+		np2 = ite->point(poi+3);
+		np3 = ite->point(poi+2);
+		if ((np == np1) && (np2 == np3))
+			tmp += QString("L%1,%2 ").arg(np3.x()).arg(np3.y());
+		else
+			tmp += QString("C%1,%2 %3,%4 %5,%6 ").arg(np1.x()).arg(np1.y()).arg(np2.x()).arg(np2.y()).arg(np3.x()).arg(np3.y());
+		np4 = np3;
 	}
 	if (closed)
 		tmp += "Z";

Modified: trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18742&path=/trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.h
==============================================================================
--- trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.h (original)
+++ trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.h Sat Jan 18 14:51:02 2014
@@ -94,6 +94,7 @@
 	void getFillStyle(PageItem *Item, QDomElement &parentElem, QDomElement &rel_root, double xOffset, double yOffset, bool withTransparency = true);
 	void handleMask(int type, PageItem *Item, QDomElement &parentElem, QDomElement &rel_root, double xOffset, double yOffset);
 	QString SetColor(QString farbe, int shad, double transparency);
+	void    SetClipAttr(QDomElement &elem, FPointArray *ite, bool fillRule);
 	QString SetClipPath(FPointArray *ite, bool closed);
 	void writeDocRels();
 	void writeCore();




More information about the scribus-commit mailing list