r20642 by fschmid -
scribus-commit
scribus-commit at lists.scribus.net
Wed Dec 30 18:57:17 UTC 2015
Author: fschmid
Date: Wed Dec 30 18:57:17 2015
New Revision: 20642
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20642
Log:
Better rendering of paragraph backgrounds.
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=20642&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Wed Dec 30 18:57:17 2015
@@ -518,6 +518,7 @@
colRight += lineCorr;
xPos = colLeft;
yPos = asce + insets.top() + lineCorr;
+ line.colLeft = colLeft;
}
bool isEndOfCol(double morespace = 0)
@@ -3697,6 +3698,59 @@
assert( lastInFrame() < itemText.length() );
LineSpec ls;
+ uint llp = 0;
+ while (llp < textLayout.lines())
+ {
+ ls = textLayout.line(llp++);
+ const ParagraphStyle& LineStyle = itemText.paragraphStyle(ls.firstItem);
+ if (LineStyle.backgroundColor() != CommonStrings::None)
+ {
+ QColor tmp;
+ SetQColor(&tmp, LineStyle.backgroundColor(), LineStyle.backgroundShade());
+ double y0 = ls.y;
+ double y2 = 0;
+ double ascent = ls.ascent;
+ double descent = ls.descent;
+ double rMarg = LineStyle.rightMargin();
+ double lMarg = ls.colLeft;
+ double adjX = 0;
+ if (LineStyle.firstIndent() <= 0)
+ adjX += LineStyle.leftMargin() + LineStyle.firstIndent();
+ while (llp < textLayout.lines())
+ {
+ ls = textLayout.line(llp);
+ if ((ls.colLeft > lMarg) || (itemText.paragraphStyle(ls.firstItem) != LineStyle))
+ {
+ if (y2 == 0)
+ y2 = y0;
+ break;
+ }
+ if (itemText.text(ls.lastItem) == SpecialChars::PARSEP)
+ {
+ y2 = ls.y;
+ descent = ls.descent;
+ if ((llp + 1) < textLayout.lines())
+ descent += LineStyle.lineSpacing() - (ls.descent + textLayout.line(llp + 1).ascent);
+ llp++;
+ break;
+ }
+ y2 = ls.y;
+ descent = ls.descent;
+ if ((llp + 1) < textLayout.lines())
+ descent += LineStyle.lineSpacing() - (ls.descent + textLayout.line(llp + 1).ascent);
+ llp++;
+ }
+ p->save();
+ p->setAntialiasing(false);
+ p->setFillMode(1);
+ p->setStrokeMode(0);
+ p->setBrush(tmp);
+ p->drawRect(lMarg + adjX, y0 - ascent, columnWidth() - adjX - rMarg, y2 - y0 + descent + ascent);
+ p->setAntialiasing(true);
+ p->restore();
+ }
+ }
+/*
for (uint ll = 0; ll < textLayout.lines(); ++ll)
{
ls = textLayout.line(ll);
@@ -3740,7 +3794,7 @@
}
// 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=20642&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Wed Dec 30 18:57:17 2015
@@ -5382,37 +5382,47 @@
straightPath.PRot = 0;
straightPath.PDx = 0;
tmp += "BT\n";
- for (uint ll = 0; ll < ite->textLayout.lines(); ++ll)
- {
- LineSpec ls = ite->textLayout.line(ll);
+ uint llp = 0;
+ while (llp < ite->textLayout.lines())
+ {
+ LineSpec ls = ite->textLayout.line(llp++);
const ParagraphStyle& LineStyle = ite->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)
{
- double y1 = ls.y;
- double hl = ls.height;
+ double y0 = ls.y;
+ double y2 = 0;
+ double ascent = ls.ascent;
+ double descent = ls.descent;
+ double rMarg = LineStyle.rightMargin();
+ double lMarg = ls.colLeft;
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 (ite->textLayout.lines() == 1)
- hl = ls.ascent + ls.descent;
- if (LineStyle.hasDropCap())
- hl *= LineStyle.dropCapLines();
- }
- if (LineStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- y1 -= LineStyle.lineSpacing();
- else if (ite->firstLineOffset() == FLOPRealGlyphHeight || ite->firstLineOffset() == FLOPFontAscent)
- y1 -= ls.ascent;
- else
- y1 -= ls.ascent + (hl - (ls.ascent + ls.descent)) / 2.0;
- QRectF scr(ls.colLeft + adjX, y1, ite->asTextFrame()->columnWidth() - adjX - LineStyle.rightMargin(), hl);
+ while (llp < ite->textLayout.lines())
+ {
+ ls = ite->textLayout.line(llp);
+ if ((ls.colLeft > lMarg) || (ite->itemText.paragraphStyle(ls.firstItem) != LineStyle))
+ {
+ if (y2 == 0)
+ y2 = y0;
+ break;
+ }
+ if (ite->itemText.text(ls.lastItem) == SpecialChars::PARSEP)
+ {
+ y2 = ls.y;
+ descent = ls.descent;
+ if ((llp + 1) < ite->textLayout.lines())
+ descent += LineStyle.lineSpacing() - (ls.descent + ite->textLayout.line(llp + 1).ascent);
+ llp++;
+ break;
+ }
+ y2 = ls.y;
+ descent = ls.descent;
+ if ((llp + 1) < ite->textLayout.lines())
+ descent += LineStyle.lineSpacing() - (ls.descent + ite->textLayout.line(llp + 1).ascent);
+ llp++;
+ }
+ QRectF scr(lMarg + adjX, y0 - ascent, ite->asTextFrame()->columnWidth() - adjX - rMarg, y2 - y0 + descent + ascent);
tmp += "q\n";
tmp += "n\n";
tmp += putColor(LineStyle.backgroundColor(), LineStyle.backgroundShade(), true);
@@ -5423,7 +5433,6 @@
tmp += "h\nf\n";
tmp += "Q\n";
}
- // end background code
}
for (uint ll=0; ll < ite->textLayout.lines(); ++ll)
{
Modified: trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20642&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 Wed Dec 30 18:57:17 2015
@@ -1169,37 +1169,47 @@
}
double x, y, wide;
QString chstr;
- for (uint ll = 0; ll < Item->textLayout.lines(); ++ll)
- {
- LineSpec ls = Item->textLayout.line(ll);
+ uint llp = 0;
+ while (llp < Item->textLayout.lines())
+ {
+ LineSpec ls = Item->textLayout.line(llp++);
const ParagraphStyle& LineStyle = Item->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)
{
- double y1 = ls.y;
- double hl = ls.height;
+ double y0 = ls.y;
+ double y2 = 0;
+ double ascent = ls.ascent;
+ double descent = ls.descent;
+ double rMarg = LineStyle.rightMargin();
+ double lMarg = ls.colLeft;
double adjX = 0;
if (LineStyle.firstIndent() <= 0)
adjX += LineStyle.leftMargin() + LineStyle.firstIndent();
- if (LineStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- hl = m_Doc->guidesPrefs().valueBaselineGrid;
- else if (LineStyle.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
- hl = LineStyle.lineSpacing();
- if (ls.isFirstLine)
- {
- if (Item->textLayout.lines() == 1)
- hl = ls.ascent + ls.descent;
- if (LineStyle.hasDropCap())
- hl *= LineStyle.dropCapLines();
- }
- if (LineStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- y1 -= LineStyle.lineSpacing();
- else if (Item->firstLineOffset() == FLOPRealGlyphHeight || Item->firstLineOffset() == FLOPFontAscent)
- y1 -= ls.ascent;
- else
- y1 -= ls.ascent + (hl - (ls.ascent + ls.descent)) / 2.0;
- QRectF scr(ls.colLeft + adjX, y1, Item->asTextFrame()->columnWidth() - adjX - LineStyle.rightMargin(), hl);
+ while (llp < Item->textLayout.lines())
+ {
+ ls = Item->textLayout.line(llp);
+ if ((ls.colLeft > lMarg) || (Item->itemText.paragraphStyle(ls.firstItem) != LineStyle))
+ {
+ if (y2 == 0)
+ y2 = y0;
+ break;
+ }
+ if (Item->itemText.text(ls.lastItem) == SpecialChars::PARSEP)
+ {
+ y2 = ls.y;
+ descent = ls.descent;
+ if ((llp + 1) < Item->textLayout.lines())
+ descent += LineStyle.lineSpacing() - (ls.descent + Item->textLayout.line(llp + 1).ascent);
+ llp++;
+ break;
+ }
+ y2 = ls.y;
+ descent = ls.descent;
+ if ((llp + 1) < Item->textLayout.lines())
+ descent += LineStyle.lineSpacing() - (ls.descent + Item->textLayout.line(llp + 1).ascent);
+ llp++;
+ }
+ QRectF scr(lMarg + adjX, y0 - ascent, Item->asTextFrame()->columnWidth() - adjX - rMarg, y2 - y0 + descent + ascent);
QString paS = QString("M %1 %2 ").arg(scr.x()).arg(scr.y());
paS += QString("L %1 %2 ").arg(scr.x() + scr.width()).arg(scr.y());
paS += QString("L %1 %2 ").arg(scr.x() + scr.width()).arg(scr.y() + scr.height());
@@ -1210,7 +1220,6 @@
glyS.setAttribute("style", "fill:"+SetColor(LineStyle.backgroundColor(), LineStyle.backgroundShade())+";" + "stroke:none;");
ob.appendChild(glyS);
}
- // end background code
}
for (uint ll=0; ll < Item->textLayout.lines(); ++ll)
{
Modified: trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20642&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 Wed Dec 30 18:57:17 2015
@@ -879,37 +879,47 @@
grp.appendChild(ob);
}
}
- for (uint ll = 0; ll < Item->textLayout.lines(); ++ll)
- {
- LineSpec ls = Item->textLayout.line(ll);
+ uint llp = 0;
+ while (llp < Item->textLayout.lines())
+ {
+ LineSpec ls = Item->textLayout.line(llp++);
const ParagraphStyle& LineStyle = Item->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)
{
- double y1 = ls.y;
- double hl = ls.height;
+ double y0 = ls.y;
+ double y2 = 0;
+ double ascent = ls.ascent;
+ double descent = ls.descent;
+ double rMarg = LineStyle.rightMargin();
+ double lMarg = ls.colLeft;
double adjX = 0;
if (LineStyle.firstIndent() <= 0)
adjX += LineStyle.leftMargin() + LineStyle.firstIndent();
- if (LineStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- hl = m_Doc->guidesPrefs().valueBaselineGrid;
- else if (LineStyle.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
- hl = LineStyle.lineSpacing();
- if (ls.isFirstLine)
- {
- if (Item->textLayout.lines() == 1)
- hl = ls.ascent + ls.descent;
- if (LineStyle.hasDropCap())
- hl *= LineStyle.dropCapLines();
- }
- if (LineStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- y1 -= LineStyle.lineSpacing();
- else if (Item->firstLineOffset() == FLOPRealGlyphHeight || Item->firstLineOffset() == FLOPFontAscent)
- y1 -= ls.ascent;
- else
- y1 -= LineStyle.lineSpacing();
- QRectF scr(ls.colLeft + adjX, y1, Item->asTextFrame()->columnWidth() - adjX - LineStyle.rightMargin(), hl);
+ while (llp < Item->textLayout.lines())
+ {
+ ls = Item->textLayout.line(llp);
+ if ((ls.colLeft > lMarg) || (Item->itemText.paragraphStyle(ls.firstItem) != LineStyle))
+ {
+ if (y2 == 0)
+ y2 = y0;
+ break;
+ }
+ if (Item->itemText.text(ls.lastItem) == SpecialChars::PARSEP)
+ {
+ y2 = ls.y;
+ descent = ls.descent;
+ if ((llp + 1) < Item->textLayout.lines())
+ descent += LineStyle.lineSpacing() - (ls.descent + Item->textLayout.line(llp + 1).ascent);
+ llp++;
+ break;
+ }
+ y2 = ls.y;
+ descent = ls.descent;
+ if ((llp + 1) < Item->textLayout.lines())
+ descent += LineStyle.lineSpacing() - (ls.descent + Item->textLayout.line(llp + 1).ascent);
+ llp++;
+ }
+ QRectF scr(lMarg + adjX, y0 - ascent, Item->asTextFrame()->columnWidth() - adjX - rMarg, y2 - y0 + descent + ascent);
QString paS = QString("M%1,%2 ").arg(scr.x() * conversionFactor).arg(scr.y() * conversionFactor);
paS += QString("L%1,%2 ").arg((scr.x() + scr.width()) * conversionFactor).arg(scr.y() * conversionFactor);
paS += QString("L%1,%2 ").arg((scr.x() + scr.width()) * conversionFactor).arg((scr.y() + scr.height()) * conversionFactor);
@@ -920,7 +930,6 @@
glyS.setAttribute("Fill", SetColor(LineStyle.backgroundColor(), LineStyle.backgroundShade(), 0));
grp.appendChild(glyS);
}
- // end background code
}
for (uint ll=0; ll < Item->textLayout.lines(); ++ll)
{
Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20642&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp (original)
+++ trunk/Scribus/scribus/pslib.cpp Wed Dec 30 18:57:17 2015
@@ -5068,37 +5068,47 @@
if (ite->lineColor() != CommonStrings::None)
tabDist += ite->lineWidth() / 2.0;
- for (uint ll = 0; ll < ite->textLayout.lines(); ++ll)
- {
- LineSpec ls = ite->textLayout.line(ll);
+ uint llp = 0;
+ while (llp < ite->textLayout.lines())
+ {
+ LineSpec ls = ite->textLayout.line(llp++);
const ParagraphStyle& LineStyle = ite->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)
{
- double y1 = ls.y;
- double hl = ls.height;
+ double y0 = ls.y;
+ double y2 = 0;
+ double ascent = ls.ascent;
+ double descent = ls.descent;
+ double rMarg = LineStyle.rightMargin();
+ double lMarg = ls.colLeft;
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 (ite->textLayout.lines() == 1)
- hl = ls.ascent + ls.descent;
- if (LineStyle.hasDropCap())
- hl *= LineStyle.dropCapLines();
- }
- if (LineStyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- y1 -= LineStyle.lineSpacing();
- else if (ite->firstLineOffset() == FLOPRealGlyphHeight || ite->firstLineOffset() == FLOPFontAscent)
- y1 -= ls.ascent;
- else
- y1 -= ls.ascent + (hl - (ls.ascent + ls.descent)) / 2.0;
- QRectF scr(ls.colLeft + adjX, y1, ite->asTextFrame()->columnWidth() - adjX - LineStyle.rightMargin(), hl);
+ while (llp < ite->textLayout.lines())
+ {
+ ls = ite->textLayout.line(llp);
+ if ((ls.colLeft > lMarg) || (ite->itemText.paragraphStyle(ls.firstItem) != LineStyle))
+ {
+ if (y2 == 0)
+ y2 = y0;
+ break;
+ }
+ if (ite->itemText.text(ls.lastItem) == SpecialChars::PARSEP)
+ {
+ y2 = ls.y;
+ descent = ls.descent;
+ if ((llp + 1) < ite->textLayout.lines())
+ descent += LineStyle.lineSpacing() - (ls.descent + ite->textLayout.line(llp + 1).ascent);
+ llp++;
+ break;
+ }
+ y2 = ls.y;
+ descent = ls.descent;
+ if ((llp + 1) < ite->textLayout.lines())
+ descent += LineStyle.lineSpacing() - (ls.descent + ite->textLayout.line(llp + 1).ascent);
+ llp++;
+ }
+ QRectF scr(lMarg + adjX, y0 - ascent, ite->asTextFrame()->columnWidth() - adjX - rMarg, y2 - y0 + descent + ascent);
PS_save();
int h, s, v, k;
SetColor(LineStyle.backgroundColor(), LineStyle.backgroundShade(), &h, &s, &v, &k);
@@ -5111,7 +5121,6 @@
putColor(LineStyle.backgroundColor(), LineStyle.backgroundShade(), true);
PS_restore();
}
- // end background code
}
for (uint ll=0; ll < ite->textLayout.lines(); ++ll)
More information about the scribus-commit
mailing list