r16696 by jghali - #9969: Table of Contents generates incorrect page numbers

scribus-commit scribus-commit at lists.scribus.net
Mon Jun 27 21:56:25 UTC 2011


Author: jghali
Date: Mon Jun 27 21:56:24 2011
New Revision: 16696

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16696
Log:
#9969: Table of Contents generates incorrect page numbers

Modified:
    branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
    branches/Version135/Scribus/scribus/scribusdoc.cpp
    branches/Version135/Scribus/scribus/scribusdoc.h

Modified: branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16696&path=/branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp (original)
+++ branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp Mon Jun 27 21:56:24 2011
@@ -1542,6 +1542,9 @@
 	m_Doc->setMasterPageMode(false);
 	m_Doc->reformPages();
 
+	// Some old long doc may have page owner somewhat broken
+	m_Doc->fixItemPageOwner();
+
 	if (m_Doc->Layers.count() == 0)
 		m_Doc->Layers.newLayer( QObject::tr("Background") );
 

Modified: branches/Version135/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16696&path=/branches/Version135/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/scribusdoc.cpp (original)
+++ branches/Version135/Scribus/scribus/scribusdoc.cpp Mon Jun 27 21:56:24 2011
@@ -4366,6 +4366,47 @@
 	}
 }
 
+void  ScribusDoc::fixItemPageOwner()
+{
+	int pageNr;
+	Page* page;
+	PageItem* currItem;
+	MarginStruct pageBleeds;
+
+	for (int i = 0; i < Items->count(); ++i)
+	{
+		currItem = Items->at(i);
+		pageNr = currItem->OwnPage;
+
+		// TODO check group owner
+		if (currItem->Groups.count() != 0)
+			continue;
+
+		// If item has a valid page, check that
+		// specified page effectively contain the item
+		if (pageNr >= 0 && pageNr < Pages->count())
+		{
+			page = Pages->at(pageNr);
+			getBleeds(page, pageBleeds);
+			double x1 = page->xOffset() - pageBleeds.Left;
+			double y1 = page->yOffset() - pageBleeds.Top;
+			double w1 = page->width()   + pageBleeds.Left + pageBleeds.Right;
+			double h1 = page->height()  + pageBleeds.Bottom + pageBleeds.Top;
+			double x2 = currItem->BoundingX;
+			double y2 = currItem->BoundingY;
+			double w2 = currItem->BoundingW;
+			double h2 = currItem->BoundingH;
+			if (( qMax(x1, x2) <= qMin(x1 + w1, x2 + w2) && qMax(y1, y2) <= qMin(y1 + h1, y2 + h2)))
+			{
+				continue;
+			}
+		}
+
+		// If no or page owner is incorrect, recompute page owner
+		currItem->OwnPage = OnPage(currItem);
+ 	}
+}
+
 
 struct oldPageVar
 {
@@ -4480,7 +4521,7 @@
 		for (uint ite = 0; ite < docItemsCount; ++ite)
 		{
 			PageItem *item = Items->at(ite);
-			if (item->OwnPage < 0)
+			if ((item->OwnPage < 0) || (!moveObjects))
 			{
 				if (item->Groups.count() != 0)
 					GroupOnPage(item);
@@ -4489,19 +4530,9 @@
 			}
 			else
 			{
-				if (moveObjects)
-				{
-					oldPg = pageTable[item->OwnPage];
-					item->moveBy(-oldPg.oldXO + Pages->at(oldPg.newPg)->xOffset(), -oldPg.oldYO + Pages->at(oldPg.newPg)->yOffset());
-					item->OwnPage = static_cast<int>(oldPg.newPg);
-				}
-				else
-				{
-					if (item->Groups.count() != 0)
-						GroupOnPage(item);
-					else
-						item->OwnPage = OnPage(item);
-				}
+				oldPg = pageTable[item->OwnPage];
+				item->moveBy(-oldPg.oldXO + Pages->at(oldPg.newPg)->xOffset(), -oldPg.oldYO + Pages->at(oldPg.newPg)->yOffset());
+				item->OwnPage = static_cast<int>(oldPg.newPg);
 			}
 			item->setRedrawBounding();
 		}

Modified: branches/Version135/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16696&path=/branches/Version135/Scribus/scribus/scribusdoc.h
==============================================================================
--- branches/Version135/Scribus/scribus/scribusdoc.h (original)
+++ branches/Version135/Scribus/scribus/scribusdoc.h Mon Jun 27 21:56:24 2011
@@ -693,11 +693,11 @@
 	 */
 	void canvasMinMax(FPoint&, FPoint&);
 	
-	int OnPage(double x2, double  y2);
-	int OnPage(PageItem *currItem);
+	int  OnPage(double x2, double  y2);
+	int  OnPage(PageItem *currItem);
 	void GroupOnPage(PageItem *currItem);
-	//void reformPages(double& maxX, double& maxY, bool moveObjects = true);
 	void reformPages(bool moveObjects = true);
+	void fixItemPageOwner();
 	
 	/**
 	 * @brief Return the x or y offset for a page on the canvas




More information about the scribus-commit mailing list