r23188 by jghali - #15801: multiple duplicate on pages: allow duplicating items from facing pages <ale>

scribus-commit scribus-commit at lists.scribus.net
Mon Sep 9 12:47:12 UTC 2019


Author: jghali
Date: Mon Sep  9 12:47:12 2019
New Revision: 23188

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23188
Log:
#15801: multiple duplicate on pages: allow duplicating items from facing pages <ale>

Modified:
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/selection.cpp
    trunk/Scribus/scribus/selection.h
    trunk/Scribus/scribus/ui/multipleduplicate.cpp

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23188&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp	(original)
+++ trunk/Scribus/scribus/pageitem.cpp	Mon Sep  9 12:47:12 2019
@@ -10032,18 +10032,6 @@
 	return last;
 }
 
-bool PageItem::areNextInChainOnSamePage() const
-{
-	const PageItem* next = this;
-	while (next->nextInChain() != nullptr)
-	{
-		next = next->nextInChain();
-		if (next->OwnPage != this->OwnPage)
-			return false;
-	}
-	return true;
-}
-
 QRect PageItem::getRedrawBounding(double viewScale) const
 {
 	int x = qRound(floor(BoundingX - m_oldLineWidth / 2.0 - 5) * viewScale);

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23188&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h	(original)
+++ trunk/Scribus/scribus/pageitem.h	Mon Sep  9 12:47:12 2019
@@ -473,7 +473,6 @@
 	const PageItem* prevInChain() const { return BackBox; }
 	const PageItem* nextInChain() const { return NextBox; }
 	bool isInChain() const { return ((BackBox != nullptr) || (NextBox != nullptr)); }
-	bool areNextInChainOnSamePage() const;
 
 	bool canBeLinkedTo(const PageItem* nextFrame) const;
 	void unlink(bool createUndo = true);
@@ -1691,8 +1690,8 @@
 protected: // Start protected variables
 	PageItem *BackBox;
 	PageItem *NextBox;
-	uint firstChar;
-	uint m_maxChars;
+	int  firstChar;
+	int  m_maxChars;
 	bool m_sampleItem; ///< Used to not draw the frame for sample items
 	MarginStruct m_textDistanceMargins; ///< Left, Top, Bottom, Right distances of text from the frame
 	int verticalAlign;

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23188&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Mon Sep  9 12:47:12 2019
@@ -13609,7 +13609,30 @@
 	std::vector<int> pages;
 	QString pageRange;
 
-	if (dialogData.pageSelection == 1)
+	if (!m_Selection->itemsAreOnSamePage())
+	{
+		int firstPage = Pages->count(), lastPage = 0;
+		for (auto item: selection.items())
+		{
+			if ((item->OwnPage >= 0) && (item->OwnPage < firstPage))
+				firstPage = item->OwnPage;
+			if ((item->OwnPage) >= 0 && (item->OwnPage > lastPage))
+				lastPage = item->OwnPage;
+		}
+		setCurrentPage(Pages->at(firstPage));
+		int pageSpread = lastPage - firstPage + 1;
+		QStringList pageList;
+		if (dialogData.pageSelection == 1)
+			for (int i = lastPage + 2; i < Pages->count(); i += pageSpread)
+				pageList << QString::number(i);
+		else if (dialogData.pageSelection == 4)
+		{
+			// TODO: what to do with manual selections?
+			pageRange = dialogData.pageRange;
+		}
+		pageRange = pageList.join(',');
+	}
+	else if (dialogData.pageSelection == 1)
 		pageRange = QString("%1-%2").arg(currPageNumber + 2).arg(Pages->count());
 	else if ((dialogData.pageSelection == 2) || dialogData.pageSelection == 3)
 	{
@@ -13639,15 +13662,10 @@
 			// get the first text frame in the selection, the first frame in the chain
 			if (item->itemType() != PageItem::TextFrame)
 				continue;
-			if (item->isInChain() && item->areNextInChainOnSamePage())
-			{
+			if (item->isInChain())
 				lastInChain = item->lastInChain();
-				assert( !lastInChain->nextInChain() );
-			}
 			else
-			{
 				lastInChain = item;
-			}
 			break;
 		}
 	}

Modified: trunk/Scribus/scribus/selection.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23188&path=/trunk/Scribus/scribus/selection.cpp
==============================================================================
--- trunk/Scribus/scribus/selection.cpp	(original)
+++ trunk/Scribus/scribus/selection.cpp	Mon Sep  9 12:47:12 2019
@@ -532,6 +532,24 @@
 	return true;
 }
 
+bool Selection::itemsAreOnSamePage() const
+{
+	//CB Putting count=1 before isempty test as its probably the most likely, given our view code.
+	if (m_SelList.count() == 1)
+		return true;
+	if (m_SelList.isEmpty())
+		return false;
+	auto it = m_SelList.begin();
+	auto itend = m_SelList.end();
+	auto ownPage = (*it)->OwnPage;
+	for ( ; it!=itend ; ++it)
+	{
+		if ((*it)->OwnPage != ownPage)
+			return false;
+	}
+	return true;
+}
+
 int Selection::objectsLayer() const
 {
 	if (m_SelList.isEmpty())

Modified: trunk/Scribus/scribus/selection.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23188&path=/trunk/Scribus/scribus/selection.h
==============================================================================
--- trunk/Scribus/scribus/selection.h	(original)
+++ trunk/Scribus/scribus/selection.h	Mon Sep  9 12:47:12 2019
@@ -158,6 +158,8 @@
 		bool containsItemType(PageItem::ItemType type) const;
 		//!\brief Test to see if all items in the selection are the same typedef
 		bool itemsAreSameType() const;
+		//!\brief Test to see if all items in the selection are on same page
+		bool itemsAreOnSamePage() const;
 
 		/**
 		 * \brief get the layer ID of items in the selection

Modified: trunk/Scribus/scribus/ui/multipleduplicate.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23188&path=/trunk/Scribus/scribus/ui/multipleduplicate.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/multipleduplicate.cpp	(original)
+++ trunk/Scribus/scribus/ui/multipleduplicate.cpp	Mon Sep  9 12:47:12 2019
@@ -15,6 +15,7 @@
 
 #include "iconmanager.h"
 #include "scribusdoc.h"
+#include "selection.h"
 #include "scrspinbox.h"
 #include "units.h"
 #include "ui/createrange.h"
@@ -43,6 +44,12 @@
 	rotationSpinBox->setValues(-180.0, 180.0, 6, 0.0);
 	rotationSpinBox->setDecimals(1);
 	rotationSpinBox->setNewUnit(6);
+
+	if (!m_Doc->m_Selection->itemsAreOnSamePage())
+	{
+		radioButtonPageOdd->setEnabled(false);
+		radioButtonPageEven->setEnabled(false);
+	}
 	
 	createGapRadioButton->setChecked(true);
 	setCopiesGap();




More information about the scribus-commit mailing list