r20647 by fschmid -

scribus-commit scribus-commit at lists.scribus.net
Thu Dec 31 09:53:01 UTC 2015


Author: fschmid
Date: Thu Dec 31 09:53:01 2015
New Revision: 20647

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20647
Log:
Clip paragraph backgrounds to text item shape.

Modified:
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
    trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
    trunk/Scribus/scribus/pslib.cpp

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20647&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Thu Dec 31 09:53:01 2015
@@ -3708,7 +3708,7 @@
 				QColor tmp;
 				SetQColor(&tmp, LineStyle.backgroundColor(), LineStyle.backgroundShade());
 				double y0 = ls.y;
-				double y2 = 0;
+				double y2 = ls.y;
 				double ascent = ls.ascent;
 				double descent = ls.descent;
 				double rMarg = LineStyle.rightMargin();
@@ -3741,6 +3741,8 @@
 					llp++;
 				}
 				p->save();
+				p->setupPolygon(&PoLine);
+				p->setClipPath();
 				p->setAntialiasing(false);
 				p->setFillMode(1);
 				p->setStrokeMode(0);
@@ -3750,51 +3752,6 @@
 				p->restore();
 			}
 		}
-/*
-		for (uint ll = 0; ll < textLayout.lines(); ++ll)
-		{
-			ls = textLayout.line(ll);
-			const ParagraphStyle& LineStyle = itemText.paragraphStyle(ls.firstItem);
-			// This code is for rendering paragraph background color.
-			// We just need to define this attribute for the paragraphs now.
-			if (LineStyle.backgroundColor() != CommonStrings::None)
-			{
-				p->save();
-				p->setAntialiasing(false);
-				p->setFillMode(1);
-				p->setStrokeMode(0);
-				QColor tmp;
-				SetQColor(&tmp, LineStyle.backgroundColor(), LineStyle.backgroundShade());
-				p->setBrush(tmp);
-				double y1 = ls.y;
-				double hl = ls.height;
-				double adjX = 0;
-				if (LineStyle.firstIndent() <= 0)
-					adjX += LineStyle.leftMargin() + LineStyle.firstIndent();
-				if (LineStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
-					hl = doc()->guidesPrefs().valueBaselineGrid;
-				else if (LineStyle.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
-					hl = LineStyle.lineSpacing();
-				if (ls.isFirstLine)
-				{
-					if (textLayout.lines() == 1)
-						hl = ls.ascent + ls.descent;
-					if (LineStyle.hasDropCap())
-						hl *= LineStyle.dropCapLines();
-				}
-				if (LineStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
-					y1 -= LineStyle.lineSpacing();
-				else if (firstLineOffset() == FLOPRealGlyphHeight || firstLineOffset() == FLOPFontAscent)
-					y1 -= ls.ascent;
-				else
-					y1 -= ls.ascent + (hl - (ls.ascent + ls.descent)) / 2.0;
-				p->drawRect(ls.colLeft + adjX, y1, columnWidth() - adjX - LineStyle.rightMargin(), hl);
-				p->setAntialiasing(true);
-				p->restore();
-			}
-			// end background code
-		}
-*/
 		for (uint ll=0; ll < textLayout.lines(); ++ll)
 		{
 			ls = textLayout.line(ll);

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20647&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp	(original)
+++ trunk/Scribus/scribus/pdflib_core.cpp	Thu Dec 31 09:53:01 2015
@@ -5390,7 +5390,7 @@
 			if (LineStyle.backgroundColor() != CommonStrings::None)
 			{
 				double y0 = ls.y;
-				double y2 = 0;
+				double y2 = ls.y;
 				double ascent = ls.ascent;
 				double descent = ls.descent;
 				double rMarg = LineStyle.rightMargin();
@@ -5425,6 +5425,7 @@
 				QRectF scr(lMarg + adjX, y0 - ascent, ite->asTextFrame()->columnWidth() - adjX - rMarg, y2 - y0 + descent + ascent);
 				tmp += "q\n";
 				tmp += "n\n";
+				tmp += SetPathAndClip(ite);
 				tmp += putColor(LineStyle.backgroundColor(), LineStyle.backgroundShade(), true);
 				tmp += FToStr(scr.x())     +" "+FToStr(-scr.y())+" m\n";
 				tmp += FToStr(scr.x() + scr.width())+" "+FToStr(-scr.y())+" l\n";

Modified: trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20647&path=/trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp	(original)
+++ trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp	Thu Dec 31 09:53:01 2015
@@ -1167,6 +1167,27 @@
 			ob.appendChild(ob1);
 		}
 	}
+	bool bFound = false;
+	for (uint ll=0; ll < Item->textLayout.lines(); ++ll)
+	{
+		if (Item->itemText.paragraphStyle(Item->textLayout.line(ll).firstItem).backgroundColor() != CommonStrings::None)
+		{
+			bFound = true;
+			break;
+		}
+	}
+	if (bFound)
+	{
+		QDomElement cl;
+		QDomElement ob2 = createClipPathElement(&Item->PoLine, &cl);
+			if (!ob2.isNull())
+		{
+			ob2.setAttribute("clipPathUnits", "userSpaceOnUse");
+			ob2.setAttribute("clip-rule", "evenodd");
+		}
+		if (!ob2.isNull())
+			ob.setAttribute("clip-path", "url(#" + ob2.attribute("id") + ")");
+	}
 	double x, y, wide;
 	QString chstr;
 	uint llp = 0;

Modified: trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20647&path=/trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp	(original)
+++ trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp	Thu Dec 31 09:53:01 2015
@@ -879,6 +879,21 @@
 			grp.appendChild(ob);
 		}
 	}
+	bool bFound = false;
+	for (uint ll=0; ll < Item->textLayout.lines(); ++ll)
+	{
+		if (Item->itemText.paragraphStyle(Item->textLayout.line(ll).firstItem).backgroundColor() != CommonStrings::None)
+		{
+			bFound = true;
+			break;
+		}
+	}
+	if (bFound)
+	{
+		FPointArray path = Item->PoLine.copy();
+		path.scale(conversionFactor, conversionFactor);
+		SetClipAttr(grp, &path, Item->fillRule);
+	}
 	uint llp = 0;
 	while (llp < Item->textLayout.lines())
 	{
@@ -887,7 +902,7 @@
 		if (LineStyle.backgroundColor() != CommonStrings::None)
 		{
 			double y0 = ls.y;
-			double y2 = 0;
+			double y2 = ls.y;
 			double ascent = ls.ascent;
 			double descent = ls.descent;
 			double rMarg = LineStyle.rightMargin();

Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20647&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp	(original)
+++ trunk/Scribus/scribus/pslib.cpp	Thu Dec 31 09:53:01 2015
@@ -5076,7 +5076,7 @@
 		if (LineStyle.backgroundColor() != CommonStrings::None)
 		{
 			double y0 = ls.y;
-			double y2 = 0;
+			double y2 = ls.y;
 			double ascent = ls.ascent;
 			double descent = ls.descent;
 			double rMarg = LineStyle.rightMargin();
@@ -5110,6 +5110,7 @@
 			}
 			QRectF scr(lMarg + adjX, y0 - ascent, ite->asTextFrame()->columnWidth() - adjX - rMarg, y2 - y0 + descent + ascent);
 			PS_save();
+			SetPathAndClip(ite->PoLine, true);
 			int h, s, v, k;
 			SetColor(LineStyle.backgroundColor(), LineStyle.backgroundShade(), &h, &s, &v, &k);
 			PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);




More information about the scribus-commit mailing list