Index: Version135/Scribus/scribus/pageitem_textframe.cpp =================================================================== --- Version135/Scribus/scribus/pageitem_textframe.cpp (wersja 16641) +++ Version135/Scribus/scribus/pageitem_textframe.cpp (kopia robocza) @@ -155,9 +155,7 @@ if ((currentGroup != -1) && (docItem->Groups.count() != 0) && (currentGroup == docItem->Groups.top())) continue; if (docItem->textFlowAroundObject()) - { - result = result.subtract(itemShape(docItem, Mp->xOffset() - Dp->xOffset(), Mp->yOffset() - Dp->yOffset())); - } + result = result.subtracted(itemShape(docItem, Mp->xOffset() - Dp->xOffset(), Mp->yOffset() - Dp->yOffset())); if (docItem->isGroupControl) currentGroup = docItem->Groups.top(); } @@ -192,7 +190,7 @@ if ((currentGroup != -1) && (docItem->Groups.count() != 0) && (currentGroup == docItem->Groups.top())) continue; if (docItem->textFlowAroundObject()) - result = result.subtract(itemShape(docItem, 0, 0)); + result = result.subtracted(itemShape(docItem, 0, 0)); if (docItem->isGroupControl) currentGroup = docItem->Groups.top(); } @@ -377,11 +375,12 @@ { startOfCol = true; colLeft = (colWidth + colGap) * column + insets.Left + lineCorr; + //now colRight is REAL column right edge colRight = colLeft + colWidth; if (legacy) - colRight += insets.Right + lineCorr; //??? + colRight += lineCorr; xPos = colLeft; - yPos = asce + insets.Top + lineCorr + 1; + yPos = asce + insets.Top + lineCorr; } bool isEndOfCol(double morespace = 0) @@ -398,7 +397,8 @@ line.x = xPos; line.y = yPos; line.firstItem = first; - line.ascent = 10; + line.lastItem = 0; + line.ascent = 0; line.descent = 0; line.width = 0; line.naturalWidth = 0; @@ -407,6 +407,7 @@ breakXPos = 0; maxShrink = 0; maxStretch = 0; + width = 0; } @@ -439,12 +440,8 @@ if (newLooseness >= oldLooseness) return; } - breakXPos = colRight; } - else - { - breakXPos = pos; - } + breakXPos = pos; breakIndex = index; } @@ -476,7 +473,7 @@ bool isEndOfLine(double moreSpace = 0) { if (legacy) - return xPos + insets.Right + lineCorr + moreSpace - maxShrink >= colRight; + return xPos + lineCorr + moreSpace - maxShrink >= colRight; else return xPos + moreSpace - maxShrink >= colRight; } @@ -492,7 +489,7 @@ while ((!shape.contains(pf2.map(pt1))) || (!shape.contains(pf2.map(pt2)))) { tmpX++; - if (xPos + (legacy? lineCorr + insets.Right : 0) + lineCorr + morespace >= colRight) + if (xPos + (legacy? lineCorr : 0) + lineCorr + morespace >= colRight) { return tmpX; } @@ -520,10 +517,10 @@ // if we aren't restricted further, we'll end at this maxX: double maxX = colRight - morespace; - if (legacy) maxX -= (lineCorr + insets.Right); + if (legacy) maxX -= lineCorr; - double StartX = floor(qMax(line.x, qMin(colRight,breakXPos) - 1)); - int xPos = static_cast(ceil(maxX + insets.Right)); + double StartX = floor(qMax(line.x, qMin(maxX,breakXPos-maxShrink-1))-1); + int xPos = static_cast(ceil(maxX)); int yDesc = static_cast(yPos+line.descent); int yAsc = static_cast(ceil(yPos-line.ascent)); @@ -542,14 +539,14 @@ // if the intersection only has 1 rectangle, then nothing gets in the way if (lineI.numRects() == 1) { - int xPos = qRound(ceil(StartX + 0.125 + insets.Right)); + int xPos = static_cast(ceil(StartX + 0.125)); pt12.setX(xPos); pt22.setX(xPos); if (shape.contains(pf2.map(pt12)) && shape.contains(pf2.map(pt22))) { QRect rect = lineI.rects().at(0); double mx = qMax(rect.left(), rect.right()) - pf2.dx(); - int steps = static_cast((mx - StartX - insets.Right - 2)/0.125); + int steps = static_cast((mx - StartX - 2)/0.125); if (steps > 0) StartX += steps * 0.125; } @@ -560,7 +557,7 @@ double Interval = 0.125; do { EndX2 += Interval; - int xPos = qRound(ceil(EndX2 + insets.Right)); + int xPos = static_cast(ceil(EndX2)); pt12.setX (xPos); pt22.setX (xPos); } while ((EndX2 < maxX) && shape.contains(pf2.map(pt12)) && shape.contains(pf2.map(pt22))); @@ -570,7 +567,7 @@ qDebug()<view(); QMatrix pf2; QPoint pt1, pt2; + QRect pt; /*QRegion cm;*/ double chs, chsd = 0; - double oldCurY, EndX, OFs, wide, kernVal; + double oldCurY, EndX, OFs, wide=0, kernVal; QString chstr; ScText *hl; ParagraphStyle style; @@ -975,7 +976,8 @@ tTabValues.clear(); bool DropCmode = false; - double desc=0, asce=0, maxDY=0, desc2=0, maxDX=0; + double desc=0, asce=0, desc2=0, realAsce=0, realDesc = 0; + double maxDY=0, maxDX=0; double DropCapDrop = 0; int DropLines = 0; int DropLinesCount = 0; @@ -998,6 +1000,10 @@ current.init(Width, Height, extra, lineCorr); current.initColumns(columnWidth(), ColGap); current.hyphenCount = 0; + + //hold Y position of last line of text (with glyphs descent) + //for moving next line if glyphs are higher than that + double lastLineY; // dump styles /* @@ -1037,6 +1043,7 @@ } current.nextColumn(0); + lastLineY = 0; // find start of first line if (firstInFrame() < itemText.length()) @@ -1075,6 +1082,7 @@ outs = false; OFs = 0; MaxChars = 0; + double xStep = legacy? 1 : 0.125; for (int a = firstInFrame(); a < itemText.length(); ++a) { hl = itemText.item(a); @@ -1326,14 +1334,16 @@ double hlcsize10=charStyle.fontSize() / 10.0; if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem())) { - desc = desc2 = 0; + desc = desc2 = realDesc = 0; } else { desc = desc2 = -charStyle.font().descent(hlcsize10); + realDesc = charStyle.font().realCharDescent(chstr[0], hlcsize10); current.rememberShrinkStretch(hl->ch, wide, style); } asce = charStyle.font().ascent(hlcsize10); + realAsce = charStyle.font().realCharAscent(chstr[0], hlcsize10); // wide = wide * hl->glyph.scaleH; } fBorder = false; @@ -1346,6 +1356,7 @@ { // start next col current.nextColumn(asce); + lastLineY = 0; if (((a > firstInFrame()) && (itemText.text(a-1) == SpecialChars::PARSEP)) || ((a == firstInFrame()) && (BackBox == 0))) { @@ -1394,7 +1405,7 @@ if (current.startOfCol) { // qDebug() << QString("current.startOfCol: %1 + %2 + %3 + 1 =%4").arg(asce).arg(extra.Top).arg(lineCorr).arg(asce + extra.Top + lineCorr + 1); - current.yPos = asce + extra.Top + lineCorr + 1; + current.yPos = TopOffset + extra.Top + lineCorr; // if (((a > 0) && (itemText.at(a-1)->ch == QChar(13))) || ((a == 0) && (BackBox == 0))) // current.yPos += m_Doc->docParagraphStyles[hl->cab].gapBefore; } @@ -1417,28 +1428,42 @@ current.yPos = TopOffset+1; } */ + //find line start + double leftIndent = 0; + if (!current.hasDropCap) + leftIndent = style.leftMargin(); + if (a==0 || (a > 0 && (itemText.text(a-1) == SpecialChars::PARSEP))) + leftIndent += style.firstIndent(); + current.xPos = qMax(leftIndent + current.colLeft, current.xPos); + // find linelength: - pt1 = QPoint(static_cast(ceil(current.xPos)), static_cast(current.yPos+BotOffset)); - pt2 = QPoint(static_cast(ceil(current.xPos)), static_cast(ceil(current.yPos-TopOffset))); + pt = QRect( QPoint(static_cast(ceil(current.xPos)), static_cast(current.yPos+BotOffset)), + QPoint(static_cast(ceil(current.xPos + (1 - style.minGlyphExtension()) * wide)), static_cast(current.yPos-TopOffset))); // increase pt1/pt2 until i-beam reaches end of line // qDebug() << QString("linestart: %1 + %2 + %3 < %4").arg(current.xPos).arg(wide).arg(style.rightMargin()).arg(current.colRight); - double leftIndent = 0; - double xStep = legacy? 1 : 0.125; - while (!cl.contains(pf2.map(pt1)) || !cl.contains(pf2.map(pt2)) || current.isEndOfLine(wide + leftIndent + style.rightMargin())) + while (!QRegion(pf2.mapToPolygon(pt)).subtracted(cl).isEmpty() || current.isEndOfLine((1 - style.minGlyphExtension()) * wide + style.rightMargin())) { fBorder = true; current.xPos += xStep; - if (current.isEndOfLine(wide + leftIndent + style.rightMargin())) + if (current.isEndOfLine((1 - style.minGlyphExtension()) * wide + style.rightMargin())) { // qDebug() << QString("eocol %5? %1 + %2 + %3 + %4").arg(current.yPos).arg(current.startOfCol).arg(style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing).arg(style.lineSpacing()).arg(current.column); // new line fBorder = false; - current.xPos = current.colLeft; - - leftIndent = style.leftMargin(); - if (a > 0 && itemText.text(a-1) == SpecialChars::PARSEP) - leftIndent += style.firstIndent(); - + if (current.hasDropCap) + { + DropLinesCount++; + if (DropLinesCount >= DropLines) + { + current.hasDropCap = false; + current.xPos = current.colLeft; + maxDX = 0; + } + } + if (current.hasDropCap) + current.xPos = maxDX; + else + current.xPos = current.colLeft - extra.Left + leftIndent; if (current.startOfCol) current.yPos++; else @@ -1461,6 +1486,7 @@ if (current.column < Cols) { current.nextColumn(asce); + lastLineY = 0; if (((a > firstInFrame()) && (itemText.text(a-1) == SpecialChars::PARSEP)) || ((a == firstInFrame()) && (BackBox == 0))) { if (chstr[0] != SpecialChars::PARSEP) @@ -1497,26 +1523,23 @@ } } } - pt1 = QPoint(static_cast(ceil(current.xPos)), static_cast(current.yPos+BotOffset)); - pt2 = QPoint(static_cast(ceil(current.xPos)), static_cast(ceil(current.yPos-TopOffset))); + pt.moveTopLeft(QPoint(static_cast(ceil(current.xPos)), static_cast(current.yPos+BotOffset))); } - if (((fBorder)) && (!current.hasDropCap)) - current.xPos += extra.Left; + if (current.hasDropCap) + current.xPos = qMax(maxDX, current.xPos); + else + current.xPos = qMax(current.colLeft, current.xPos); // indent first line of par - if (a > 0) - { - if (itemText.text(a-1) == SpecialChars::PARSEP) - current.xPos += style.firstIndent(); - } - else - { - if (legacy) - current.xPos += style.firstIndent(); - } + leftIndent = 0; + if (a==0 || (a > 0 && (itemText.text(a-1) == SpecialChars::PARSEP))) + leftIndent = style.firstIndent(); // add left margin if (!current.hasDropCap) - current.xPos += style.leftMargin(); + leftIndent += style.leftMargin(); + if (leftIndent+current.colLeft < current.xPos) + leftIndent = 0; + current.xPos = qMax(leftIndent + current.colLeft, current.xPos); if (opticalMargins & ParagraphStyle::OM_LeftHangingPunct) { current.xPos += opticalLeftMargin(itemText, current.line); } @@ -1528,6 +1551,30 @@ else { // qDebug() << QString("cont.' line: '%1'").arg(a); } + + //ATTENTION + // that variable is used in lastLineY computing + //it should be set in document preferences or/and depends on current paragraph language + //as not all languages use ascented chars + bool preventingAscents = true; + //never for first line + //check if line must start at new Y position due to current glyph height or previous line descent + //not working for AutomaticLineSpacing (it is buggy case), so I skip it + + if (lastLineY > 0 && style.lineSpacingMode() != ParagraphStyle::AutomaticLineSpacing + && qMin(asce, realAsce) > current.yPos - lastLineY) + { + if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing) + current.yPos += m_Doc->typographicSettings.valueBaseGrid; + else + current.yPos += style.lineSpacing(); + a = current.breakIndex = current.line.firstItem -1; + current.itemsInLine = current.maxShrink = 0; + current.xPos = current.breakXPos = current.colLeft; + current.startOfCol = false; + continue; + } + // right tab stuff if (tabs.active) { @@ -1631,28 +1678,29 @@ { if (hl->effects() & ScStyle_HyphenationPossible || hl->ch == SpecialChars::SHYPHEN) { - pt1 = QPoint(qRound(ceil(current.xPos+extra.Right - current.maxShrink + charStyle.font().charWidth('-', charStyle.fontSize() / 10.0) * (charStyle.scaleH() / 1000.0))), qRound(current.yPos+desc)); - pt2 = QPoint(qRound(ceil(current.xPos+extra.Right - current.maxShrink + charStyle.font().charWidth('-', charStyle.fontSize() / 10.0) * (charStyle.scaleH() / 1000.0))), qRound(ceil(current.yPos-asce))); + pt1 = QPoint(static_cast(ceil(current.xPos - current.maxShrink)), static_cast(current.yPos+desc)); + pt2 = QPoint(static_cast(ceil(current.xPos - current.maxShrink + charStyle.font().charWidth('-', charStyle.fontSize() / 10.0) * (charStyle.scaleH() / 1000.0))), static_cast(ceil(current.yPos-asce))); } else { - pt1 = QPoint(qRound(ceil(current.xPos+extra.Right - current.maxShrink )), qRound(current.yPos+desc)); - pt2 = QPoint(qRound(ceil(current.xPos+extra.Right - current.maxShrink )), qRound(ceil(current.yPos-asce))); + pt1 = QPoint(static_cast(ceil(current.xPos - current.maxShrink)), static_cast(current.yPos+desc)); + pt2 = QPoint(static_cast(ceil(current.xPos - current.maxShrink +(1 - style.minGlyphExtension()) * wide)), static_cast(ceil(current.yPos-asce))); } } else if (!legacy && SpecialChars::isBreakingSpace(hl->ch)) { - pt1 = QPoint(qRound(ceil(breakPos + extra.Right - current.maxShrink )), qRound(current.yPos+desc)); - pt2 = QPoint(qRound(ceil(breakPos + extra.Right - current.maxShrink )), qRound(ceil(current.yPos-asce))); + pt1 = QPoint(static_cast(ceil(breakPos - current.maxShrink)), static_cast(current.yPos+desc)); + pt2 = QPoint(static_cast(ceil(breakPos - current.maxShrink +(1 - style.minGlyphExtension()) * wide)), static_cast(ceil(current.yPos-asce))); } else { - pt1 = QPoint(qRound(ceil(current.xPos+extra.Right - current.maxShrink)), qRound(current.yPos+desc)); - pt2 = QPoint(qRound(ceil(current.xPos+extra.Right - current.maxShrink)), qRound(ceil(current.yPos-asce))); + pt1 = QPoint(static_cast(ceil(current.xPos - current.maxShrink)), static_cast(current.yPos-realAsce)); + pt2 = QPoint(static_cast(ceil(current.xPos - current.maxShrink +(1 - style.minGlyphExtension()) * wide)), static_cast(ceil(current.yPos+realDesc))); } + pt = QRect(pt1, pt2); // test if end of line reached - if ((!cl.contains(pf2.map(pt1))) || (!cl.contains(pf2.map(pt2))) || (legacy && current.isEndOfLine(style.rightMargin()))) + if (!QRegion(pf2.mapToPolygon(pt)).subtracted(cl).isEmpty() || (legacy && current.isEndOfLine(style.rightMargin()))) outs = true; if (current.isEndOfCol()) outs = true; @@ -1661,7 +1709,6 @@ if ((hl->ch == SpecialChars::COLBREAK) && (Cols > 1)) goNextColumn = true; - // remember possible break // #5783 : comment out "&& !outs" as this make it possible to perform a line break // before a space which contradicts unicode line breaking rules @@ -1728,7 +1775,6 @@ // qDebug() << QString("dropcapoffset: %1 -> %2").arg(current.xPos-style.dropCapOffset()).arg(current.xPos); current.xPos = qMax(current.xPos, current.colLeft); maxDX = current.xPos; - QPolygon tcli(4); if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing) { current.yPos -= m_Doc->typographicSettings.valueBaseGrid * (DropLines-1); @@ -1739,9 +1785,6 @@ int ol2 = static_cast(ol1 / m_Doc->typographicSettings.valueBaseGrid); // qDebug() << QString("baseline adjust after dropcaps: y=%1->%2").arg(current.yPos).arg(ceil( ol2 / 10000.0 ) * m_Doc->typographicSettings.valueBaseGrid + m_Doc->typographicSettings.offsetBaseGrid - by); current.yPos = ceil( ol2 / 10000.0 ) * m_Doc->typographicSettings.valueBaseGrid + m_Doc->typographicSettings.offsetBaseGrid - by; - //FIXME: use current.colLeft instead of xOffset? - tcli.setPoint(0, QPoint(qRound(hl->glyph.xoffset), qRound(maxDY-DropLines*m_Doc->typographicSettings.valueBaseGrid))); - tcli.setPoint(1, QPoint(qRound(maxDX), qRound(maxDY-DropLines*m_Doc->typographicSettings.valueBaseGrid))); } else { @@ -1749,25 +1792,14 @@ { current.yPos -= style.lineSpacing() * (DropLines-1); // qDebug() << QString("after dropcaps: y=%1").arg(current.yPos); - tcli.setPoint(0, QPoint(qRound(hl->glyph.xoffset), qRound(maxDY - DropLines * style.lineSpacing()))); - tcli.setPoint(1, QPoint(qRound(maxDX), qRound(maxDY-DropLines*style.lineSpacing()))); } else { double currasce = charStyle.font().height(style.charStyle().fontSize() / 10.0); current.yPos -= currasce * (DropLines-1); // qDebug() << QString("after dropcaps: y=%1").arg(current.yPos); - tcli.setPoint(0, QPoint(qRound(hl->glyph.xoffset), qRound(maxDY-DropLines*currasce))); - tcli.setPoint(1, QPoint(qRound(maxDX), qRound(maxDY-DropLines*currasce))); } } - tcli.setPoint(2, QPoint(qRound(maxDX), qRound(maxDY))); - tcli.setPoint(3, QPoint(qRound(hl->glyph.xoffset), qRound(maxDY))); - // #6821 : the following two lines are causing bad text flow around drop caps - // in some case, discarding them put more emphasis on user control of line spacing - /*cm = QRegion(pf2.map(tcli)); - cl = cl.subtract(cm);*/ -// current.yPos = maxDY; } // end of line if ( SpecialChars::isBreak(hl->ch, Cols > 1) || (outs)) @@ -1853,7 +1885,7 @@ //??? current.breakXPos = current.line.x; //??? for (int j=current.line.firstItem; j <= a; ++j) //??? current.breakXPos += itemText.item(j)->glyph.wide(); - + double hyphWidth = 0.0; if ((hl->effects() & ScStyle_HyphenationPossible) || hl->ch == SpecialChars::SHYPHEN) { // insert hyphen @@ -1862,6 +1894,7 @@ hl->glyph.grow(); hl->glyph.more->glyph = charStyle.font().char2CMap(QChar('-')); hl->glyph.more->xadvance = charStyle.font().charWidth('-', itemText.charStyle(a).fontSize() / 10.0) * (itemText.charStyle(a).scaleH() / 1000.0); + hyphWidth = hl->glyph.more->xadvance; } else { @@ -1876,6 +1909,8 @@ { if (opticalMargins & ParagraphStyle::OM_RightHangingPunct) current.line.width += opticalRightMargin(itemText, current.line); + else + current.line.naturalWidth += hyphWidth; OFs = 0; if (style.alignment() == ParagraphStyle::Rightaligned) @@ -1902,15 +1937,16 @@ { if (a >= current.line.firstItem) { - if ((hl->effects() & ScStyle_HyphenationPossible) || hl->ch == SpecialChars::SHYPHEN) + if ((hl->effects() & ScStyle_HyphenationPossible) || hl->ch == SpecialChars::SHYPHEN + || current.line.lastItem == 0) { current.itemsInLine = 0; a = current.line.firstItem - 1; } else { - --a; - --current.itemsInLine; + current.itemsInLine = 0; + a = current.line.firstItem - 1; } } if (a >= 0) @@ -1925,17 +1961,17 @@ else if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing) style.setLineSpacing(m_Doc->typographicSettings.valueBaseGrid); } - current.breakLine(itemText, style, firstLineOffset(), a); + //current.breakLine(itemText, style, firstLineOffset(), a); // qDebug() << QString("style no break pos %1: %2 (%3)").arg(a).arg(style.alignment()).arg(style.parent()); // qDebug() << QString("style nb @%6: %1 -- %2, %4/%5 char: %3").arg(style.leftMargin()).arg(style.rightMargin()) // .arg(style.charStyle().asString()).arg(style.name()).arg(style.parent()) // .arg(a); - EndX = current.endOfLine(cl, pf2, style.rightMargin()); - current.finishLine(EndX); + //EndX = current.endOfLine(cl, pf2, style.rightMargin()); + //current.finishLine(EndX); // qDebug() << QString("no break pos: %1-%2 @ %3 wid %4 nat %5 endX %6") // .arg(current.line.firstItem).arg(current.line.firstItem) // .arg(current.line.x).arg(current.line.width).arg(current.line.naturalWidth).arg(EndX); - indentLine(itemText, current.line, 0); + //indentLine(itemText, current.line, 0); } } if ( outs || SpecialChars::isBreak(hl->ch, (Cols > 1)) ) @@ -1954,9 +1990,12 @@ double BotOffset = desc+extra.Bottom+lineCorr; while (!current.isEndOfLine(style.rightMargin())) { - current.xPos++; + current.xPos += xStep; if (current.isEndOfLine(style.rightMargin())) { + lastLineY = current.yPos + 1; + if (!preventingAscents) + lastLineY += current.line.descent -1; fromOut = false; // qDebug() << QString("layout: next lower2 grid=%1 x %2").arg(style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing).arg(m_Doc->typographicSettings.valueBaseGrid); // qDebug() << QString("nextline: y=%1+%2").arg(current.yPos).arg(style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing? m_Doc->typographicSettings.valueBaseGrid : style.lineSpacing()); @@ -1965,13 +2004,6 @@ current.yPos += m_Doc->typographicSettings.valueBaseGrid; else current.yPos += style.lineSpacing(); - if (current.isEndOfCol(desc) && (current.column+1 == Cols)) - { - goNoRoom = true; - MaxChars = a + 1; -// qDebug() << QString("go no room 1: %1").arg(a)); - break; - } if (current.hasDropCap) { ++DropLinesCount; @@ -1979,6 +2011,7 @@ { current.hasDropCap = false; current.xPos = current.colLeft; + maxDX = 0; } else current.xPos = maxDX; @@ -2000,8 +2033,8 @@ // performed at lines 1488-1512 and can trigger hang due to changing region detection //pt1 = QPoint(qRound(current.xPos+extra.Right), static_cast(current.yPos+BotOffset)); //pt2 = QPoint(qRound(current.xPos+extra.Right), static_cast(ceil(current.yPos-asce))); - pt1 = QPoint(qRound(current.xPos+extra.Right), qRound(current.yPos+BotOffset)); - pt2 = QPoint(qRound(current.xPos+extra.Right), qRound(ceil(current.yPos-asce))); + pt1 = QPoint(static_cast(current.xPos), static_cast(current.yPos+BotOffset)); + pt2 = QPoint(static_cast(current.xPos), static_cast(ceil(current.yPos-asce))); if (cl.contains(pf2.map(pt1)) && cl.contains(pf2.map(pt2))) break; // else @@ -2009,14 +2042,7 @@ } if (fromOut) { - if (current.isEndOfCol(desc) && (current.column+1 == Cols)) - { - goNoRoom = true; - MaxChars = a + 1; -// qDebug() << QString("go no room 2: %1").arg(a); - break; - } - current.xPos--; + current.xPos-=xStep; current.xPos = qMax(current.xPos, current.colLeft); } } @@ -2033,10 +2059,12 @@ // qDebug() << QString("layout: next lower3 grid=%1 x %2").arg(style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing).arg(m_Doc->typographicSettings.valueBaseGrid); + lastLineY = current.yPos + 1; + if (!preventingAscents) + lastLineY += current.line.descent -1; if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing) { // qDebug() << QString("next line (grid): y=%1+%2").arg(current.yPos).arg(m_Doc->typographicSettings.valueBaseGrid); - current.yPos += m_Doc->typographicSettings.valueBaseGrid; } else @@ -2059,6 +2087,7 @@ { current.hasDropCap = false; current.xPos = current.colLeft; + maxDX = 0; } else current.xPos = maxDX; @@ -2077,10 +2106,9 @@ } } - // calc. needed vertical space // Let’s try to change into "calc. _wanted_ vertical space" - pm - if (current.itemsInLine != 0) + if (current.itemsInLine > 0) { if ( itemText.charStyle(current.line.firstItem).effects() & ScStyle_DropCap) { @@ -2090,12 +2118,12 @@ } } - fillInTabLeaders(itemText, current.line); - + if (current.itemsInLine > 1) + fillInTabLeaders(itemText, current.line); current.startOfCol = false; // qDebug() << QString("layout: line %1 - %2 @ (%3,%4) wd %5/%6").arg(current.line.firstItem).arg(current.line.lastItem) // .arg(current.line.x).arg(current.line.y).arg(current.line.naturalWidth).arg(current.line.width); - if (current.line.firstItem > current.line.lastItem) + if (current.line.firstItem >= current.line.lastItem) ; //qDebug() << QString("layout: empty line %1 - %2").arg(current.line.firstItem).arg(current.line.lastItem); else if (current.itemsInLine > 0) itemText.appendLine(current.line); @@ -2115,6 +2143,7 @@ if (current.column < Cols) { current.nextColumn(asce); + lastLineY = 0; } else { }