r24414 by jghali - #16431: Page numbers placed in masterpages not displayed correctly when objects are grouped

scribus-commit scribus-commit at lists.scribus.net
Wed Jan 20 23:21:26 UTC 2021


Author: jghali
Date: Wed Jan 20 23:21:26 2021
New Revision: 24414

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24414
Log:
#16431: Page numbers placed in masterpages not displayed correctly when objects are grouped

Modified:
    trunk/Scribus/scribus/canvas.cpp

Modified: trunk/Scribus/scribus/canvas.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24414&path=/trunk/Scribus/scribus/canvas.cpp
==============================================================================
--- trunk/Scribus/scribus/canvas.cpp	(original)
+++ trunk/Scribus/scribus/canvas.cpp	Wed Jan 20 23:21:26 2021
@@ -27,6 +27,7 @@
 #include "canvasmode.h"
 #include "pageitem_textframe.h"
 #include "pageitem_group.h"
+#include "pageitemiterator.h"
 #include "prefsmanager.h"
 #include "scpage.h"
 #include "scpainter.h"
@@ -1385,21 +1386,33 @@
 			continue;
 		if ((m_viewMode.viewAsPreview) && (!currItem->printEnabled()))
 			continue;
-		double OldX = currItem->xPos();
-		double OldY = currItem->yPos();
-		double OldBX = currItem->BoundingX;
-		double OldBY = currItem->BoundingY;
+		double oldX = currItem->xPos();
+		double oldY = currItem->yPos();
+		double oldBX = currItem->BoundingX;
+		double oldBY = currItem->BoundingY;
 		if (!currItem->ChangedMasterItem)
 		{
 			//Hack to not check for undo changes, indicate drawing only
 			currItem->moveBy(-Mp->xOffset() + page->xOffset(), -Mp->yOffset() + page->yOffset(), true);
-			currItem->BoundingX = OldBX - Mp->xOffset() + page->xOffset();
-			currItem->BoundingY = OldBY - Mp->yOffset() + page->yOffset();
-		}
+			currItem->BoundingX = oldBX - Mp->xOffset() + page->xOffset();
+			currItem->BoundingY = oldBY - Mp->yOffset() + page->yOffset();
+		}
+		// Save PageItem's OwnPage and set its value to page number
+		// so that page number placed in text frames can work, also modify
+		// OwnPage of items embeded inside groups for same reason
 		currItem->savedOwnPage = currItem->OwnPage;
 		currItem->OwnPage = page->pageNr();
-//FIXME						if (!evSpon || forceRedraw)
-//					currItem->invalid = true;
+		if (currItem->isGroup())
+		{
+			PageItem_Group *groupItem = currItem->asGroupFrame();
+			PageItemIterator itemIt(groupItem->groupItemList, PageItemIterator::IterateInGroups);
+			for ( ; *itemIt; ++itemIt)
+			{
+				PageItem* item = *itemIt;
+				item->savedOwnPage = currItem->OwnPage;
+				item->OwnPage = page->pageNr();
+			}
+		}
 		if (cullingArea.intersects(currItem->getBoundingRect().adjusted(0.0, 0.0, 1.0, 1.0)))
 		{
 			if (!((m_viewMode.operItemMoving) && (currItem->isSelected())))
@@ -1409,16 +1422,27 @@
 				currItem->DrawObj(painter, cullingArea);
 				currItem->DrawObj_Decoration(painter);
 			}
-//							else 
-//								qDebug() << "skip masterpage item (move/resizeEdit/selected)" << m_viewMode.operItemMoving << currItem->isSelected();
+//			else 
+//				qDebug() << "skip masterpage item (move/resizeEdit/selected)" << m_viewMode.operItemMoving << currItem->isSelected();
+		}
+		// Restore items' OwnPage including those of item embedded inside groups 
+		if (currItem->isGroup())
+		{
+			PageItem_Group *groupItem = currItem->asGroupFrame();
+			PageItemIterator itemIt(groupItem->groupItemList, PageItemIterator::IterateInGroups);
+			for ( ; *itemIt; ++itemIt)
+			{
+				PageItem* item = *itemIt;
+				item->OwnPage = item->savedOwnPage;
+			}
 		}
 		currItem->OwnPage = currItem->savedOwnPage;
 		if (!currItem->ChangedMasterItem)
 		{
 			//Hack to not check for undo changes, indicate drawing only
-			currItem->setXYPos(OldX, OldY, true);
-			currItem->BoundingX = OldBX;
-			currItem->BoundingY = OldBY;
+			currItem->setXYPos(oldX, oldY, true);
+			currItem->BoundingX = oldBX;
+			currItem->BoundingY = oldBY;
 		}
 	}
 	if ((layerCount > 1) && ((layer.blendMode != 0) || (layer.transparency != 1.0)) && (!layer.outlineMode))




More information about the scribus-commit mailing list