r20638 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Tue Dec 29 16:37:15 UTC 2015
Author: jghali
Date: Tue Dec 29 16:37:14 2015
New Revision: 20638
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20638
Log:
enable printing of text background on Windows
Modified:
trunk/Scribus/scribus/scpageoutput.cpp
Modified: trunk/Scribus/scribus/scpageoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20638&path=/trunk/Scribus/scribus/scpageoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/scpageoutput.cpp (original)
+++ trunk/Scribus/scribus/scpageoutput.cpp Tue Dec 29 16:37:14 2015
@@ -1650,10 +1650,143 @@
wm.scale(1, -1);
}
+ for (uint ll = 0; ll < item->textLayout.lines(); ++ll)
+ {
+ const LineSpec& ls = item->textLayout.line(ll);
+ 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)
+ {
+ painter->save();
+ painter->setFillMode(1);
+ painter->setStrokeMode(0);
+ ScColorShade colorShade(m_doc->PageColors[lineStyle.backgroundColor()], lineStyle.backgroundShade());
+ painter->setBrush(colorShade);
+ 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 = item->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;
+ painter->drawRect(ls.colLeft + adjX, y1, item->columnWidth() - adjX - lineStyle.rightMargin(), hl);
+ painter->restore();
+ }
+ // end background code
+ }
+
for (uint ll=0; ll < item->textLayout.lines(); ++ll)
{
LineSpec ls = item->textLayout.line(ll);
double CurX = ls.x;
+
+ // Draw text background
+ ScColorShade tmpShade;
+ double curXB = ls.x;
+ QRectF scrG;
+ QString oldBack;
+ double oldShade = 100;
+ for (int a = ls.firstItem; a <= ls.lastItem; ++a)
+ {
+ GlyphLayout* glyphs = item->itemText.getGlyphs(a);
+ const CharStyle& charStyle(item->itemText.charStyle(a));
+ if (charStyle.backColor() != CommonStrings::None)
+ {
+ tmpShade.color = m_doc->PageColors[charStyle.backColor()];
+ tmpShade.shade = charStyle.backShade();
+ const ParagraphStyle& lineStyle = item->itemText.paragraphStyle(ls.firstItem);
+ double y1 = ls.y;
+ double hl = ls.height;
+ 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() && (a == ls.firstItem))
+ 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();
+ }
+ else
+ y1 -= ls.ascent + (hl - (ls.ascent + ls.descent)) / 2.0;
+ QRectF scr;
+ if (item->itemText.hasObject(a))
+ {
+ PageItem* obj = item->itemText.object(a);
+ double ww = (obj->width() + obj->lineWidth()) * glyphs->scaleH;
+ double hh = (obj->height() + obj->lineWidth()) * glyphs->scaleV;
+ scr = QRectF(curXB, ls.y - hh, ww , hh);
+ }
+ else
+ scr = QRectF(curXB, y1, glyphs->wide(), hl);
+ if ((oldBack.isEmpty()) || ((oldBack == charStyle.backColor()) && (oldShade == charStyle.backShade())))
+ scrG |= scr;
+ else if ((oldBack != charStyle.backColor()) || (oldShade != charStyle.backShade()))
+ {
+ tmpShade.color = m_doc->PageColors[oldBack];
+ tmpShade.shade = oldShade;
+ painter->save();
+ painter->setFillMode(1);
+ painter->setStrokeMode(0);
+ painter->setBrush(tmpShade);
+ painter->drawRect(scrG.x(), scrG.y(), scrG.width(), scrG.height());
+ painter->restore();
+ scrG = scr;
+ }
+ oldBack = charStyle.backColor();
+ oldShade = charStyle.backShade();
+ }
+ else
+ {
+ oldBack.clear();
+ oldShade = 100;
+ if (!scrG.isNull())
+ {
+ painter->save();
+ painter->setFillMode(1);
+ painter->setStrokeMode(0);
+ painter->setBrush(tmpShade);
+ painter->drawRect(scrG.x(), scrG.y(), scrG.width(), scrG.height());
+ painter->restore();
+ }
+ scrG = QRectF();
+ }
+ curXB += glyphs->wide();
+ }
+ if (!scrG.isNull())
+ {
+ painter->save();
+ painter->setFillMode(1);
+ painter->setStrokeMode(0);
+ painter->setBrush(tmpShade);
+ painter->drawRect(scrG.x(), scrG.y(), scrG.width(), scrG.height());
+ painter->restore();
+ }
+
+ // Draw text
for (a = ls.firstItem; a <= ls.lastItem; ++a)
{
GlyphLayout* glyphs = item->itemText.getGlyphs(a);
More information about the scribus-commit
mailing list