r21301 by fschmid -

scribus-commit scribus-commit at lists.scribus.net
Tue May 10 19:02:37 UTC 2016


Author: fschmid
Date: Tue May 10 19:02:36 2016
New Revision: 21301

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21301
Log:
Fixed Bug #12067: Inline Items are wrongly placed in Text Frames

Modified:
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/pslib.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/text/boxes.cpp
    trunk/Scribus/scribus/text/screenpainter.cpp
    trunk/Scribus/scribus/text/textshaper.cpp

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21301&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Tue May 10 19:02:36 2016
@@ -804,10 +804,11 @@
 		if (run.object())
 		{
 			result = new ObjectBox(run);
+			QRectF bBox = run.object()->getVisualBoundingRect();
 			if (run.hasFlag(ScLayout_DropCap))
-				result->setAscent((run.object()->height() - run.object()->lineWidth()) * run.glyphs().first().scaleV - run.glyphs().first().yoffset);
+				result->setAscent(bBox.height() * run.glyphs().first().scaleV - run.glyphs().first().yoffset);
 			else
-				result->setAscent(run.object()->height() - run.object()->lineWidth());
+				result->setAscent(bBox.height());
 			result->setDescent(0);
 		}
 		else
@@ -1469,6 +1470,9 @@
 			int a = glyphRuns[i].firstChar();
 			bool HasObject = itemText.hasObject(a);
 			PageItem* currentObject = itemText.object(a);
+			QRectF currentObjectBox = QRectF();
+			if (HasObject)
+				currentObjectBox = currentObject->getVisualBoundingRect();
 			bool HasMark = itemText.hasMark(a);
 
 			// set StartOfLine
@@ -1669,14 +1673,17 @@
 //				glyphRuns[i].glyphs().first().yoffset += DropCapDrop;
 				if (HasObject)
 				{
-					chs = qRound((currentObject->height() + currentObject->lineWidth()) * 10);
-					chsd = qRound((currentObject->height() + currentObject->lineWidth()) * 10);
+				//	chs = qRound((currentObject->height() + currentObject->lineWidth()) * 10);
+				//	chsd = qRound((currentObject->height() + currentObject->lineWidth()) * 10);
+					chs = currentObjectBox.height() * 10;
+					chsd = currentObjectBox.height() * 10;
 				}
 			}
 			else // ! dropCapMode
 			{
 				if (HasObject)
-					chs = qRound((currentObject->height() + currentObject->lineWidth()) * 10);
+					chs = currentObjectBox.height() * 10;
+				//	chs = qRound((currentObject->height() + currentObject->lineWidth()) * 10);
 				else
 					chs = charStyle.fontSize();
 			}
@@ -1762,11 +1769,16 @@
 				// drop caps are wider...
 				if (HasObject)
 				{
-					double itemHeight = currentObject->height() + currentObject->lineWidth();
+				//	double itemHeight = currentObject->height() + currentObject->lineWidth();
+				//	if (itemHeight == 0)
+				//		itemHeight = font.height(style.charStyle().fontSize() / 10.0);
+				//	asce = currentObject->height() + currentObject->lineWidth();
+				//	wide = currentObject->width() + currentObject->lineWidth();
+					double itemHeight = currentObjectBox.height();
 					if (itemHeight == 0)
 						itemHeight = font.height(style.charStyle().fontSize() / 10.0);
-					asce = currentObject->height() + currentObject->lineWidth();
-					wide = currentObject->width() + currentObject->lineWidth();
+					asce = currentObjectBox.height();
+					wide = currentObjectBox.width();
 					realAsce = calculateLineSpacing (style, this) * DropLines;
 					firstGlyph.scaleH /= firstGlyph.scaleV;
 					firstGlyph.scaleV = (realAsce / itemHeight);
@@ -1815,7 +1827,8 @@
 				{
 					if (itemText.text(a) != SpecialChars::OBJECT)
 					{
-						foreach (GlyphLayout gl, glyphRuns[i].glyphs()) {
+						foreach (GlyphLayout gl, glyphRuns[i].glyphs())
+						{
 							GlyphMetrics gm = font.glyphBBox(gl.glyph, hlcsize10);
 							realDesc = qMax(realDesc, gm.descent * scaleV - offset);
 							realAsce = gm.ascent;
@@ -1826,8 +1839,10 @@
 				}
 				if (HasObject)
 				{
-					asce = currentObject->height() + currentObject->lineWidth();
+				//	asce = currentObject->height() + currentObject->lineWidth();
+					asce = currentObjectBox.height();
 					realAsce = asce * scaleV + offset;
+					wide = currentObjectBox.width() * scaleH;
 				}
 				else
 				{
@@ -1947,7 +1962,7 @@
 			maxYAsc = qMax(maxYAsc, 0.0);
 			maxYDesc = current.yPos + realDesc;
 
-			if (true||style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
+			if (style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
 			{
 				regionMinY = static_cast<int>(floor(maxYAsc));
 				regionMaxY = static_cast<int>(floor(maxYDesc));
@@ -2104,14 +2119,16 @@
 				else if (style.lineSpacingMode() != ParagraphStyle::FixedLineSpacing)
 				{
 					if (HasObject)
-						diff = (currentObject->height() + currentObject->lineWidth()) * scaleV + offset - (current.yPos - lastLineY);
+					//	diff = (currentObject->height() + currentObject->lineWidth()) * scaleV + offset - (current.yPos - lastLineY);
+						diff = (currentObjectBox.height() * scaleV + offset) - (current.yPos - lastLineY);
 					else
-						diff = font.capHeight(hlcsize10) * scaleV + offset - (current.yPos - lastLineY);
+						diff = font.capHeight(hlcsize10) * scaleV + offset - (current.yPos - lastLineY) - desc;
 				}
 				else
 				{
 					if (HasObject)
-						diff = (currentObject->height() + currentObject->lineWidth()) * scaleV + offset - (current.yPos - lastLineY);
+					//	diff = (currentObject->height() + currentObject->lineWidth()) * scaleV + offset - (current.yPos - lastLineY);
+						diff = currentObjectBox.height() * scaleV + offset - (current.yPos - lastLineY);
 				}
 				if (diff >= 1 || (!DropCmode && diff > 0))
 				{
@@ -2736,7 +2753,10 @@
 						current.restartIndex = current.line.lastRun + 1;
 						i = current.line.lastRun;
 						a = glyphRuns[i].firstChar();
-						current.rowDesc = qMax(current.rowDesc,current.yPos + current.line.descent);
+					//	if (glyphRuns[current.line.firstRun].hasFlag(ScLayout_DropCap))
+					//		current.rowDesc = qMax(current.rowDesc,current.yPos + current.line.descent);
+					//	else
+							current.rowDesc = qMax(current.rowDesc,current.yPos - current.line.descent);
 						if (!current.lastInRowLine)
 						{
 							current.restartX = current.xPos;

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21301&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp	(original)
+++ trunk/Scribus/scribus/pdflib_core.cpp	Tue May 10 19:02:36 2016
@@ -461,7 +461,7 @@
 		m_pathBuffer = "";
 
 		m_pathBuffer += "q\n";
-		m_pathBuffer += FToStr(scaleH()) + " 0 0 " + FToStr(scaleV()) + " " + FToStr(x()) + " " + FToStr(-y()) + " cm\n";
+		m_pathBuffer += FToStr(scaleH()) + " 0 0 " + FToStr(scaleV()) + " " + FToStr(x() + embedded->gXpos) + " " + FToStr(-(y() + embedded->gYpos)) + " cm\n";
 
 		QByteArray output;
 		if (!m_pdf->PDF_ProcessItem(output, embedded, m_page, m_PNr, true))

Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21301&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp	(original)
+++ trunk/Scribus/scribus/pslib.cpp	Tue May 10 19:02:36 2016
@@ -199,7 +199,7 @@
 void PSPainter::drawObject(PageItem* item)
 {
 	m_ps->PS_save();
-	m_ps->PS_translate(x(), -y());
+	m_ps->PS_translate(x() + item->gXpos, -(y() + item->gYpos));
 	applyTransform();
 	if (scaleH() != 1 || scaleV() != 1)
 		m_ps->PS_scale(scaleH(), scaleV());

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21301&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Tue May 10 19:02:36 2016
@@ -7523,8 +7523,9 @@
 	m_storedPageNum = qMin(m_storedPageNum, doc->DocPages.count() - 1);
 	doc->setCurrentPage(doc->DocPages.at(m_storedPageNum));
 	view->setContentsPos(static_cast<int>(m_storedViewXCoor * m_storedViewScale), static_cast<int>(m_storedViewYCoor * m_storedViewScale));
-	if (doc->currentEditedTextframe != NULL)
-		doc->currentEditedTextframe->invalidateLayout();
+	doc->invalidateAll();
+//	if (doc->currentEditedTextframe != NULL)
+//		doc->currentEditedTextframe->invalidateLayout();
 	doc->currentEditedTextframe = NULL;
 	view->DrawNew();
 	pagePalette->Rebuild();

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21301&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Tue May 10 19:02:36 2016
@@ -6636,7 +6636,8 @@
 		PageItem *pa = FrameItems[id];
 		pa->isEmbedded = false;
 		m_currentEditedIFrame = id;
-		ScPage* addedPage = new ScPage(m_docPrefsData.displayPrefs.scratch.left(), m_docPrefsData.displayPrefs.scratch.top(), pa->visualWidth(), pa->visualHeight());
+		QRectF bBox = pa->getVisualBoundingRect();
+		ScPage* addedPage = new ScPage(m_docPrefsData.displayPrefs.scratch.left(), m_docPrefsData.displayPrefs.scratch.top(), bBox.width(), bBox.height());
 		addedPage->setDocument(this);
 		addedPage->Margins.set(0, 0, 0, 0);
 		addedPage->initialMargins.set(0, 0, 0, 0);

Modified: trunk/Scribus/scribus/text/boxes.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21301&path=/trunk/Scribus/scribus/text/boxes.cpp
==============================================================================
--- trunk/Scribus/scribus/text/boxes.cpp	(original)
+++ trunk/Scribus/scribus/text/boxes.cpp	Tue May 10 19:02:36 2016
@@ -652,7 +652,8 @@
 	p->save();
 	double oldX = m_item->xPos();
 	double oldY = m_item->yPos();
-
+	bool oldEM = m_item->isEmbedded;
+	m_item->isEmbedded = false;
 	const CharStyle& charStyle = style();
 
 	p->translate(x(), y() - ascent());
@@ -662,8 +663,9 @@
 		p->setScale(charStyle.scaleH() / 1000.0, charStyle.scaleV() / 1000.0);
 	p->setMatrix(m_matrix);
 
-	m_item->setXPos(m_item->gXpos);
-	m_item->setYPos((m_item->gHeight * (charStyle.scaleV() / 1000.0)) + m_item->gYpos);
+	m_item->setXPos(m_item->gXpos, true);
+	m_item->setYPos(m_item->gYpos, true);
+//	m_item->setYPos((m_item->gHeight * (charStyle.scaleV() / 1000.0)) + m_item->gYpos, true);
 
 	if (charStyle.baselineOffset() != 0)
 	{
@@ -673,8 +675,9 @@
 
 	p->drawObject(m_item);
 
-	m_item->setXPos(oldX);
-	m_item->setYPos(oldY);
+	m_item->setXPos(oldX, true);
+	m_item->setYPos(oldY, true);
+	m_item->isEmbedded = oldEM;
 	p->restore();
 }
 

Modified: trunk/Scribus/scribus/text/screenpainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21301&path=/trunk/Scribus/scribus/text/screenpainter.cpp
==============================================================================
--- trunk/Scribus/scribus/text/screenpainter.cpp	(original)
+++ trunk/Scribus/scribus/text/screenpainter.cpp	Tue May 10 19:02:36 2016
@@ -298,7 +298,8 @@
 		int fm = m_painter->fillMode();
 		m_painter->setPen(PrefsManager::instance()->appPrefs.displayPrefs.frameNormColor, 0, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin);
 		m_painter->setFillMode(ScPainter::None);
-		m_painter->drawSharpRect(0, 0, embedded->width(), embedded->height());
+		QRectF bBox = embedded->getVisualBoundingRect();
+		m_painter->drawSharpRect(0, 0, bBox.width(), bBox.height());
 		m_painter->setFillMode(fm);
 	}
 

Modified: trunk/Scribus/scribus/text/textshaper.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21301&path=/trunk/Scribus/scribus/text/textshaper.cpp
==============================================================================
--- trunk/Scribus/scribus/text/textshaper.cpp	(original)
+++ trunk/Scribus/scribus/text/textshaper.cpp	Tue May 10 19:02:36 2016
@@ -216,7 +216,7 @@
 		gl.xadvance *= runStyle.wordTracking();
 
 	if (itemText.hasObject(a))
-		gl.xadvance = itemText.object(a)->width() + itemText.object(a)->lineWidth();
+		gl.xadvance = itemText.object(a)->getVisualBoundingRect().width();
 
 	run.glyphs().append(gl);
 }




More information about the scribus-commit mailing list