r22334 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Sun Jan 7 01:47:06 UTC 2018


Author: jghali
Date: Sun Jan  7 01:47:05 2018
New Revision: 22334

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22334
Log:
#15092: Background color for paragraph style apply to all text area instead of paragraph only

Modified:
    trunk/Scribus/scribus/text/textlayout.cpp

Modified: trunk/Scribus/scribus/text/textlayout.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22334&path=/trunk/Scribus/scribus/text/textlayout.cpp
==============================================================================
--- trunk/Scribus/scribus/text/textlayout.cpp	(original)
+++ trunk/Scribus/scribus/text/textlayout.cpp	Sun Jan  7 01:47:05 2018
@@ -120,18 +120,60 @@
 
 void TextLayout::renderBackground(TextLayoutPainter *p)
 {
+	QString backColor, lastColor;
+	double backShade, lastShade = 100;
+	QRectF lastRect;
+
 	foreach (const Box* column, m_box->boxes())
 	{
-		const ParagraphStyle& style = m_story->paragraphStyle(column->firstChar());
-		if (style.backgroundColor() != CommonStrings::None)
-		{
+		const QList<const Box*>& lineBoxes = column->boxes();
+		QRectF colBBox = column->bbox();
+
+		for (int j = 0; j < lineBoxes.count(); ++j)
+		{
+			const Box* box = lineBoxes.at(j);
+			
+			const ParagraphStyle& style = m_story->paragraphStyle(box->firstChar());
+			backColor = style.backgroundColor();
+			backShade = style.backgroundShade();
+
+			if ((lastColor != backColor) || (lastShade != backShade))
+			{
+				if (!lastRect.isEmpty())
+				{
+					TextLayoutColor bkColor(lastColor, lastShade);
+					p->save();
+					p->setFillColor(bkColor);
+					p->setStrokeColor(bkColor);
+					p->drawRect(lastRect);
+					p->restore();
+					lastRect = QRectF();
+				}
+			}
+
+			if (backColor != CommonStrings::None)
+			{
+				QRectF rect(colBBox.x(), box->y(), colBBox.width(), box->height());
+				lastRect |= rect;
+			}
+
+			lastColor = backColor;
+			lastShade = backShade;
+		}
+
+		if (!lastRect.isEmpty())
+		{
+			TextLayoutColor bkColor(lastColor, lastShade);
 			p->save();
-			TextLayoutColor backColor(style.backgroundColor(), style.backgroundShade());
-			p->setFillColor(backColor);
-			p->setStrokeColor(backColor);
-			p->drawRect(column->bbox());
+			p->setFillColor(bkColor);
+			p->setStrokeColor(bkColor);
+			p->drawRect(lastRect);
 			p->restore();
 		}
+
+		lastColor.clear();
+		lastShade = 100;
+		lastRect = QRectF();
 	}
 }
 




More information about the scribus-commit mailing list