r24376 by jghali - Fix build failure with clang compiler

scribus-commit scribus-commit at lists.scribus.net
Tue Jan 5 21:09:24 UTC 2021


Author: jghali
Date: Tue Jan  5 21:09:24 2021
New Revision: 24376

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24376
Log:
Fix build failure with clang compiler

Modified:
    trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp
    trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.h

Modified: trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24376&path=/trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp	Tue Jan  5 21:09:24 2021
@@ -12,7 +12,8 @@
 */
 PdfTextRecognition::PdfTextRecognition()
 {
-	m_pdfTextRegions.push_back(activePdfTextRegion);
+	m_pdfTextRegions.push_back(PdfTextRegion());
+	activePdfTextRegion = &(m_pdfTextRegions.back());
 	setCharMode(AddCharMode::ADDFIRSTCHAR);
 }
 
@@ -28,8 +29,8 @@
 */
 void PdfTextRecognition::addPdfTextRegion()
 {
-	activePdfTextRegion = PdfTextRegion();
-	m_pdfTextRegions.push_back(activePdfTextRegion);
+	m_pdfTextRegions.push_back(PdfTextRegion());
+	activePdfTextRegion = &(m_pdfTextRegions.back());
 	setCharMode(PdfTextRecognition::AddCharMode::ADDFIRSTCHAR);
 }
 
@@ -61,10 +62,10 @@
 */
 bool PdfTextRecognition::isNewLineOrRegion(QPointF newPosition)
 {
-	return (activePdfTextRegion.collinear(activePdfTextRegion.lastXY.y(), activePdfTextRegion.pdfTextRegionLines.back().baseOrigin.y()) &&
-		!activePdfTextRegion.collinear(newPosition.y(), activePdfTextRegion.lastXY.y()))
-		|| (activePdfTextRegion.collinear(newPosition.y(), activePdfTextRegion.lastXY.y())
-			&& !activePdfTextRegion.isCloseToX(newPosition.x(), activePdfTextRegion.lastXY.x()));
+	return (activePdfTextRegion->collinear(activePdfTextRegion->lastXY.y(), activePdfTextRegion->pdfTextRegionLines.back().baseOrigin.y()) &&
+		!activePdfTextRegion->collinear(newPosition.y(), activePdfTextRegion->lastXY.y()))
+		|| (activePdfTextRegion->collinear(newPosition.y(), activePdfTextRegion->lastXY.y())
+			&& !activePdfTextRegion->isCloseToX(newPosition.x(), activePdfTextRegion->lastXY.x()));
 }
 
 
@@ -97,11 +98,11 @@
 {
 	//qDebug() << "AddFirstChar() '" << u << " : " << uLen;
 	PdfGlyph newGlyph = PdfTextRecognition::AddCharCommon(state, x, y, dx, dy, u, uLen);
-	activePdfTextRegion.glyphs.push_back(newGlyph);
+	activePdfTextRegion->glyphs.push_back(newGlyph);
 	setCharMode(AddCharMode::ADDBASICCHAR);
 
 	//only need to be called for the very first point
-	auto success = activePdfTextRegion.addGlyphAtPoint(QPointF(x, y), newGlyph);
+	auto success = activePdfTextRegion->addGlyphAtPoint(QPointF(x, y), newGlyph);
 	if (success == PdfTextRegion::LineType::FAIL)
 		qDebug("FIXME: Rogue glyph detected, this should never happen because the cursor should move before glyphs in new regions are added.");
 	return newGlyph;
@@ -113,8 +114,8 @@
 PdfGlyph PdfTextRecognition::AddBasicChar(GfxState* state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, Unicode const* u, int uLen)
 {
 	PdfGlyph newGlyph = AddCharCommon(state, x, y, dx, dy, u, uLen);
-	activePdfTextRegion.lastXY = QPointF(x, y);
-	activePdfTextRegion.glyphs.push_back(newGlyph);
+	activePdfTextRegion->lastXY = QPointF(x, y);
+	activePdfTextRegion->glyphs.push_back(newGlyph);
 	return newGlyph;
 }
 
@@ -126,7 +127,7 @@
 {
 	//qDebug() << "AddCharWithNewStyle() '" << u << " : " << uLen;
 	auto newGlyph = AddCharCommon(state, x, y, dx, dy, u, uLen);
-	activePdfTextRegion.glyphs.push_back(newGlyph);
+	activePdfTextRegion->glyphs.push_back(newGlyph);
 	return newGlyph;
 }
 
@@ -138,7 +139,7 @@
 {
 	//qDebug() << "AddCharWithPreviousStyle() '" << u << " : " << uLen;
 	auto newGlyph = AddCharCommon(state, x, y, dx, dy, u, uLen);
-	activePdfTextRegion.glyphs.push_back(newGlyph);
+	activePdfTextRegion->glyphs.push_back(newGlyph);
 	return newGlyph;
 }
 
@@ -435,10 +436,9 @@
 void PdfTextOutputDev::updateTextPos(GfxState* state)
 {
 	QPointF newPosition = QPointF(state->getCurX(), state->getCurY());
-	PdfTextRegion* activePdfTextRegion = &m_pdfTextRecognition.activePdfTextRegion;
-
-	if (activePdfTextRegion->isNew()
-		)
+	PdfTextRegion *activePdfTextRegion = m_pdfTextRecognition.activePdfTextRegion;
+
+	if (activePdfTextRegion->isNew())
 	{
 		activePdfTextRegion->pdfTextRegionBasenOrigin = newPosition;
 		m_pdfTextRecognition.setCharMode(PdfTextRecognition::AddCharMode::ADDFIRSTCHAR);
@@ -480,7 +480,7 @@
 void PdfTextOutputDev::renderTextFrame()
 {
 	//qDebug() << "_flushText()    m_doc->currentPage()->xOffset():" << m_doc->currentPage()->xOffset();
-	auto activePdfTextRegion = &m_pdfTextRecognition.activePdfTextRegion;
+	auto activePdfTextRegion = m_pdfTextRecognition.activePdfTextRegion;
 	if (activePdfTextRegion->glyphs.empty())
 		return;
 
@@ -598,7 +598,7 @@
 void PdfTextOutputDev::beginTextObject(GfxState* state)
 {
 	pushGroup();
-	if (!m_pdfTextRecognition.activePdfTextRegion.pdfTextRegionLines.empty())
+	if (!m_pdfTextRecognition.activePdfTextRegion->pdfTextRegionLines.empty())
 	{
 #ifdef DEBUG_TEXT_IMPORT
 		qDebug("beginTextObject: m_textRecognition.addTextRegion()");
@@ -609,12 +609,12 @@
 
 void PdfTextOutputDev::endTextObject(GfxState* state)
 {
-	if (!m_pdfTextRecognition.activePdfTextRegion.pdfTextRegionLines.empty())
+	if (!m_pdfTextRecognition.activePdfTextRegion->pdfTextRegionLines.empty())
 	{
 		// Add the last glyph to the textregion
-		QPointF glyphXY = m_pdfTextRecognition.activePdfTextRegion.lastXY;
-		m_pdfTextRecognition.activePdfTextRegion.lastXY.setX(m_pdfTextRecognition.activePdfTextRegion.lastXY.x() - m_pdfTextRecognition.activePdfTextRegion.glyphs.back().dx);
-		if (m_pdfTextRecognition.activePdfTextRegion.addGlyphAtPoint(glyphXY, m_pdfTextRecognition.activePdfTextRegion.glyphs.back()) == PdfTextRegion::LineType::FAIL)
+		QPointF glyphXY = m_pdfTextRecognition.activePdfTextRegion->lastXY;
+		m_pdfTextRecognition.activePdfTextRegion->lastXY.setX(m_pdfTextRecognition.activePdfTextRegion->lastXY.x() - m_pdfTextRecognition.activePdfTextRegion->glyphs.back().dx);
+		if (m_pdfTextRecognition.activePdfTextRegion->addGlyphAtPoint(glyphXY, m_pdfTextRecognition.activePdfTextRegion->glyphs.back()) == PdfTextRegion::LineType::FAIL)
 		{
 			qDebug("FIXME: Rogue glyph detected, this should never happen because the cursor should move before glyphs in new regions are added.");
 		}
@@ -623,7 +623,7 @@
 #endif
 		renderTextFrame();
 	}
-	else if (!m_pdfTextRecognition.activePdfTextRegion.pdfTextRegionLines.empty())
+	else if (!m_pdfTextRecognition.activePdfTextRegion->pdfTextRegionLines.empty())
 		qDebug("FIXME:Rogue textblock");
 
 	m_pdfTextRecognition.setCharMode(PdfTextRecognition::AddCharMode::ADDFIRSTCHAR);

Modified: trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24376&path=/trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.h	(original)
+++ trunk/Scribus/scribus/plugins/import/pdf/pdftextrecognition.h	Tue Jan  5 21:09:24 2021
@@ -120,10 +120,12 @@
 		m_addCharMode = mode;
 	}
 
-	PdfTextRegion&& activePdfTextRegion = PdfTextRegion(); //faster and cleaner than calling back on the vector all the time.
+	PdfTextRegion* activePdfTextRegion = nullptr; //faster and cleaner than calling back on the vector all the time.
+
 	void addPdfTextRegion();
 	void addChar(GfxState* state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, POPPLER_CONST_082 Unicode* u, int uLen);
 	bool isNewLineOrRegion(QPointF newPosition);
+
 private:
 	std::vector<PdfTextRegion> m_pdfTextRegions = std::vector<PdfTextRegion>();
 	AddCharMode m_addCharMode = AddCharMode::ADDFIRSTCHAR;




More information about the scribus-commit mailing list