r14642 by jghali - better behavior of ScribusDoc::addPageToSection() when a specific page is not in a section

scribus-commit scribus-commit at lists.scribus.net
Thu Feb 4 22:50:39 CET 2010


Revision: 14642
Author: jghali
Date: 2010-02-04T21:46:44.332739Z
Commit message: better behavior of ScribusDoc::addPageToSection() when a specific page is not in a section

Changeset: 
M  /trunk/Scribus/scribus/scribusdoc.cpp

Diffs:
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 14641)
+++ scribus/scribusdoc.cpp	(revision 14642)
@@ -4879,36 +4879,20 @@
 
 void ScribusDoc::addPageToSection(const uint otherPageIndex, const uint location, const uint count)
 {
-	//Get the section of the new page index.
-	bool found=false;
+	uint fromIndex, toIndex;
+	uint searchedIndex = (otherPageIndex > 0) ? (otherPageIndex - 1) : 0;
+	if ((location == 0) && (searchedIndex > 0))
+		--searchedIndex;
 	DocumentSectionMap::Iterator it = sections.begin();
-	if (otherPageIndex==0)
-		found=true;
 	for (; it!= sections.end(); ++it)
 	{
-		if (otherPageIndex-1>=it.value().fromindex && otherPageIndex-1<=it.value().toindex)
-		{
-			found=true;
-			break;
-		}
+		fromIndex = it.value().fromindex;
+		toIndex   = it.value().toindex;
+		if  (fromIndex > searchedIndex)
+			it.value().fromindex += count;
+		if  (toIndex >= searchedIndex)
+			it.value().toindex += count;
 	}
-	//Our page was not in a section
-	if (!found)
-		return;
-	DocumentSectionMap::Iterator it2(it);
-
-	//For this if: We are adding before the beginning of a section, so we must put this
-	//new page in the previous section and then increment the rest
-	if (otherPageIndex-1==it.value().fromindex && location==0 && it!=sections.begin())
-		--it2;
-	it2.value().toindex+=count;
-	++it2;
-	while (it2!=sections.end())
-	{
-		it2.value().fromindex+=count;
-		it2.value().toindex+=count;
-		++it2;
-	}
 	//Now update the Pages' internal storage of their page number
 	updateSectionPageNumbersToPages();
 }




More information about the scribus-commit mailing list