r23047 by jghali - Readability improvement for PageItem_TextFrame calcAvailableRegion()

scribus-commit scribus-commit at lists.scribus.net
Sat Jun 22 12:22:50 UTC 2019


Author: jghali
Date: Sat Jun 22 12:22:49 2019
New Revision: 23047

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23047
Log:
Readability improvement for PageItem_TextFrame calcAvailableRegion()

Modified:
    trunk/Scribus/scribus/pageitem_textframe.cpp

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23047&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Sat Jun 22 12:22:49 2019
@@ -101,107 +101,107 @@
 QRegion PageItem_TextFrame::calcAvailableRegion()
 {
 	QRegion result(this->Clip);
-	if ((!isEmbedded) || (isGroupChild()))
-	{
-		bool invertible(false);
-		QTransform canvasToLocalMat;
+	if (isEmbedded && !isGroupChild())
+		return result;
+
+	bool invertible(false);
+	QTransform canvasToLocalMat;
+	if (isGroupChild())
+		canvasToLocalMat.translate(gXpos, gYpos);
+	else
+		canvasToLocalMat.translate(m_xPos, m_yPos);
+	canvasToLocalMat.rotate(m_rotation);
+	canvasToLocalMat = canvasToLocalMat.inverted(&invertible);
+
+	if (!invertible)
+		return QRegion();
+
+	int LayerLev = m_Doc->layerLevelFromID(m_layerID);
+	int docItemsCount = m_Doc->Items->count();
+	ScPage* Mp = nullptr;
+	ScPage* Dp = nullptr;
+	PageItem* docItem = nullptr;
+	int LayerLevItem;
+	QList<PageItem*> thisList;
+	if (!OnMasterPage.isEmpty())
+	{
+		if ((savedOwnPage == -1) || (savedOwnPage >= signed(m_Doc->Pages->count())))
+			return result;
+		Mp = m_Doc->MasterPages.at(m_Doc->MasterNames[OnMasterPage]);
+		Dp = m_Doc->Pages->at(savedOwnPage);
 		if (isGroupChild())
-			canvasToLocalMat.translate(gXpos, gYpos);
+			thisList = Parent->asGroupFrame()->groupItemList;
 		else
-			canvasToLocalMat.translate(m_xPos, m_yPos);
-		canvasToLocalMat.rotate(m_rotation);
-		canvasToLocalMat = canvasToLocalMat.inverted(&invertible);
-
-		if (!invertible) return QRegion();
-
-		int LayerLev = m_Doc->layerLevelFromID(m_layerID);
-		int docItemsCount = m_Doc->Items->count();
-		ScPage* Mp = nullptr;
-		ScPage* Dp = nullptr;
-		PageItem* docItem = nullptr;
-		int LayerLevItem;
-		QList<PageItem*> thisList;
-		if (!OnMasterPage.isEmpty())
-		{
-			if ((savedOwnPage == -1) || (savedOwnPage >= signed(m_Doc->Pages->count())))
-				return result;
-			Mp = m_Doc->MasterPages.at(m_Doc->MasterNames[OnMasterPage]);
-			Dp = m_Doc->Pages->at(savedOwnPage);
-			if (isGroupChild())
-				thisList = Parent->asGroupFrame()->groupItemList;
-			else
-				thisList = m_Doc->MasterItems;
-			int thisid = thisList.indexOf(this);
-			for (int a = 0; a < m_Doc->MasterItems.count(); ++a)
-			{
-				docItem = m_Doc->MasterItems.at(a);
-				// #10642 : masterpage items interact only with items placed on same masterpage
-				if (docItem->OnMasterPage != OnMasterPage)
-					continue;
+			thisList = m_Doc->MasterItems;
+		int thisid = thisList.indexOf(this);
+		for (int a = 0; a < m_Doc->MasterItems.count(); ++a)
+		{
+			docItem = m_Doc->MasterItems.at(a);
+			// #10642 : masterpage items interact only with items placed on same masterpage
+			if (docItem->OnMasterPage != OnMasterPage)
+				continue;
+			LayerLevItem = m_Doc->layerLevelFromID(docItem->m_layerID);
+			if (((a > thisid) && (docItem->m_layerID == m_layerID)) || (LayerLevItem > LayerLev && m_Doc->layerFlow(docItem->m_layerID)))
+			{
+				if (docItem->textFlowAroundObject())
+				{
+					QRegion itemRgn = docItem->textInteractionRegion(Mp->xOffset() - Dp->xOffset(), Mp->yOffset() - Dp->yOffset());
+					result = result.subtracted( canvasToLocalMat.map(itemRgn) );
+				}
+			}
+		} // for all masterItems
+		// (JG) #6009 : disable possible interaction between master text frames and normal frames
+		// which have the text flow option set
+		/*if (!m_Doc->masterPageMode())
+		{
+			for (uint a = 0; a < docItemsCount; ++a)
+			{
+				docItem = m_Doc->Items->at(a);
+				Mp = m_Doc->MasterPages.at(m_Doc->MasterNames[OnMasterPage]);
+				Dp = m_Doc->Pages->at(OwnPage);
+				if ((docItem->textFlowAroundObject()) && (docItem->OwnPage == OwnPage))
+				{
+					result = result.subtract(itemShape(docItem, m_Doc->view(), Mp->xOffset() - Dp->xOffset(), Mp->yOffset() - Dp->yOffset()));
+				}
+			} // for all docItems
+		} // if (! masterPageMode) */
+	} // if (!OnMasterPage.isEmpty())
+	else
+	{
+		int thisid = 0;
+		if (isGroupChild())
+		{
+			thisid = Parent->asGroupFrame()->groupItemList.indexOf(this);
+			docItemsCount = Parent->asGroupFrame()->groupItemList.count();
+			for (int a = thisid + 1; a < docItemsCount; ++a)
+			{
+				docItem = Parent->asGroupFrame()->groupItemList.at(a);
+				if (docItem->textFlowAroundObject())
+				{
+					QRegion itemRgn = docItem->textInteractionRegion(0, 0);
+					result = result.subtracted( canvasToLocalMat.map(itemRgn) );
+				}
+			}
+		}
+		else
+		{
+			thisid = m_Doc->Items->indexOf(this);
+			for (int a = 0; a < docItemsCount; ++a)
+			{
+				docItem = m_Doc->Items->at(a);
 				LayerLevItem = m_Doc->layerLevelFromID(docItem->m_layerID);
 				if (((a > thisid) && (docItem->m_layerID == m_layerID)) || (LayerLevItem > LayerLev && m_Doc->layerFlow(docItem->m_layerID)))
 				{
 					if (docItem->textFlowAroundObject())
 					{
-						QRegion itemRgn = docItem->textInteractionRegion(Mp->xOffset() - Dp->xOffset(), Mp->yOffset() - Dp->yOffset());
-						result = result.subtracted( canvasToLocalMat.map(itemRgn) );
-					}
-				}
-			} // for all masterItems
-			// (JG) #6009 : disable possible interaction between master text frames and normal frames
-			// which have the text flow option set
-			/*if (!m_Doc->masterPageMode())
-			{
-				for (uint a = 0; a < docItemsCount; ++a)
-				{
-					docItem = m_Doc->Items->at(a);
-					Mp = m_Doc->MasterPages.at(m_Doc->MasterNames[OnMasterPage]);
-					Dp = m_Doc->Pages->at(OwnPage);
-					if ((docItem->textFlowAroundObject()) && (docItem->OwnPage == OwnPage))
-					{
-						result = result.subtract(itemShape(docItem, m_Doc->view(), Mp->xOffset() - Dp->xOffset(), Mp->yOffset() - Dp->yOffset()));
-					}
-				} // for all docItems
-			} // if (! masterPageMode) */
-		} // if (!OnMasterPage.isEmpty())
-		else
-		{
-			int thisid = 0;
-			if (isGroupChild())
-			{
-				thisid = Parent->asGroupFrame()->groupItemList.indexOf(this);
-				docItemsCount = Parent->asGroupFrame()->groupItemList.count();
-				for (int a = thisid + 1; a < docItemsCount; ++a)
-				{
-					docItem = Parent->asGroupFrame()->groupItemList.at(a);
-					if (docItem->textFlowAroundObject())
-					{
 						QRegion itemRgn = docItem->textInteractionRegion(0, 0);
 						result = result.subtracted( canvasToLocalMat.map(itemRgn) );
 					}
 				}
 			}
-			else
-			{
-				thisid = m_Doc->Items->indexOf(this);
-				for (int a = 0; a < docItemsCount; ++a)
-				{
-					docItem = m_Doc->Items->at(a);
-					LayerLevItem = m_Doc->layerLevelFromID(docItem->m_layerID);
-					if (((a > thisid) && (docItem->m_layerID == m_layerID)) || (LayerLevItem > LayerLev && m_Doc->layerFlow(docItem->m_layerID)))
-					{
-						if (docItem->textFlowAroundObject())
-						{
-							QRegion itemRgn = docItem->textInteractionRegion(0, 0);
-							result = result.subtracted( canvasToLocalMat.map(itemRgn) );
-						}
-					}
-				}
-			} // for all docItems
-		} // if(OnMasterPage.isEmpty()
-	} // if(!Embedded)
-	//else
-	//	qDebug() << "QRegion empty";
+		} // for all docItems
+	} // if(OnMasterPage.isEmpty()
+
 	return result;
 }
 




More information about the scribus-commit mailing list