r24572 by craig - #16519: Object larger than page size copied to the scrapbook is resized

scribus-commit scribus-commit at lists.scribus.net
Tue Mar 16 21:37:31 UTC 2021


Author: craig
Date: Tue Mar 16 21:37:31 2021
New Revision: 24572

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24572
Log:
#16519: Object larger than page size copied to the scrapbook is resized
to page size, plus cleanup

Modified:
    trunk/Scribus/scribus/scribusview.cpp
    trunk/Scribus/scribus/ui/scrapbookpalette.cpp

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24572&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp	(original)
+++ trunk/Scribus/scribus/scribusview.cpp	Tue Mar 16 21:37:31 2021
@@ -1033,8 +1033,6 @@
 		update();
 		return;
 	}
-	//if ((SeleItemPos(e->pos())) && (!text.startsWith("<SCRIBUSELEM")))
-	//		if (Doc->m_Selection->count()>0 && (m_canvas->frameHitTest(dropPosDocQ, Doc->m_Selection->itemAt(0)) >= Canvas::INSIDE) && !vectorFile) // && (img))
 	if (selectedItemByDrag && (m_canvas->frameHitTest(dropPosDocQ, m_doc->m_Selection->itemAt(0)) >= Canvas::INSIDE) && ((!vectorFile) || (img)))
 	{
 		PageItem *item = m_doc->m_Selection->itemAt(0);
@@ -1101,13 +1099,15 @@
 	{
 		deselectItems(true);
 		int oldDocItemCount = m_doc->Items->count();
-		if (((!img) || (vectorFile)) && (m_doc->DraggedElem == nullptr))
+		if ((!img || vectorFile) && (m_doc->DraggedElem == nullptr))
 		{
 			activeTransaction = undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create, "", Um::ICreate);
+			bool fromScrapbook = false;
 			if (fi.exists())
 			{
 				if (fi.suffix().toLower() == "sce")
 				{
+					fromScrapbook = true;
 					emit LoadElem(url.toLocalFile(), dropPosDoc.x(), dropPosDoc.y(), true, false, m_doc, this);
 				}
 				else
@@ -1118,7 +1118,7 @@
 					if ((testResult != -1) && (testResult >= FORMATID_FIRSTUSER))
 					{
 						const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult);
-						if( fmt )
+						if (fmt)
 						{
 							// We disable undo here as we are only interested by the item creation undo actions
 							// We create them manually after import
@@ -1163,30 +1163,22 @@
 			}
 			Selection tmpSelection(this, false);
 			tmpSelection.copy(*m_doc->m_Selection, true);
-			for (int as = oldDocItemCount; as < m_doc->Items->count(); ++as)
+			for (int i = oldDocItemCount; i < m_doc->Items->count(); ++i)
 			{
-				currItem = m_doc->Items->at(as);
+				currItem = m_doc->Items->at(i);
 				m_doc->setRedrawBounding(currItem);
 				tmpSelection.addItem(currItem, true);
 				if (currItem->isBookmark)
 					emit AddBM(currItem);
 			}
 			m_doc->m_Selection->copy(tmpSelection, false);
-			if (m_doc->m_Selection->count() == 1)
+			if (!fromScrapbook && m_doc->m_Selection->count() == 1)
 			{
 				PageItem *newItem = m_doc->m_Selection->itemAt(0);
 				if ((newItem->width() > m_doc->currentPage()->width()) || (newItem->height() > m_doc->currentPage()->height()))
 				{
-					//	QMenu *pmen = new QMenu();
-					//	pmen->addAction( tr("Keep original Size"));
-					//	pmen->addAction( tr("Scale to Page Size"));
-					//	re = pmen->actions().indexOf(pmen->exec(QCursor::pos()));
-					//	delete pmen;
-					//	if (re == 1)
-					//	{
 					m_doc->rescaleGroup(newItem, qMin(qMin(m_doc->currentPage()->width() / newItem->width(), m_doc->currentPage()->height() / newItem->height()), 1.0));
 					newItem->update();
-					//	}
 				}
 			}
 			activeTransaction.commit();
@@ -1202,9 +1194,9 @@
 					pmen->addAction( tr("Copy Here"));
 					QAction* mov = pmen->addAction( tr("Move Here"));
 					pmen->addAction( tr("Cancel"));
-					for (int dre=0; dre<m_doc->DragElements.count(); ++dre)
+					for (int i=0; i<m_doc->DragElements.count(); ++i)
 					{
-						if (m_doc->DragElements[dre]->locked())
+						if (m_doc->DragElements[i]->locked())
 						{
 							mov->setEnabled(false);
 							break;
@@ -1225,9 +1217,9 @@
 				{
 					QList<PageItem*> pasted;
 					emit LoadElem(QString(text), dropPosDoc.x(), dropPosDoc.y(), false, false, m_doc, this);
-					for (int as = oldDocItemCount; as < m_doc->Items->count(); ++as)
+					for (int i = oldDocItemCount; i < m_doc->Items->count(); ++i)
 					{
-						pasted.append(m_doc->Items->at(as));
+						pasted.append(m_doc->Items->at(i));
 					}
 					Selection tmpSelection(this, false);
 					tmpSelection.copy(*m_doc->m_Selection, true);
@@ -1238,10 +1230,10 @@
 					m_doc->m_Selection->copy(tmpSelection, false);
 					PageItem* bb;
 					int fin;
-					for (int dre=0; dre<m_doc->DragElements.count(); ++dre)
+					for (int i=0; i<m_doc->DragElements.count(); ++i)
 					{
-						bb = pasted.at(dre);
-						currItem = m_doc->m_Selection->itemAt(dre);
+						bb = pasted.at(i);
+						currItem = m_doc->m_Selection->itemAt(i);
 						if ((currItem->isTextFrame()) && ((currItem->nextInChain() != nullptr) || (currItem->prevInChain() != nullptr)))
 						{
 							PageItem* before = currItem->prevInChain();
@@ -1268,15 +1260,15 @@
 					m_doc->itemSelection_DeleteItem();
 				}
 			}
-			if ((!img) && ((re == 0)))
+			if (!img && (re == 0))
 				emit LoadElem(QString(text), dropPosDoc.x(), dropPosDoc.y(), false, false, m_doc, this);
 			m_doc->DraggedElem = nullptr;
 			m_doc->DragElements.clear();
 			Selection tmpSelection(this, false);
 			tmpSelection.copy(*m_doc->m_Selection, true);
-			for (int as = oldDocItemCount; as < m_doc->Items->count(); ++as)
+			for (int i = oldDocItemCount; i < m_doc->Items->count(); ++i)
 			{
-				currItem = m_doc->Items->at(as);
+				currItem = m_doc->Items->at(i);
 				m_doc->setRedrawBounding(currItem);
 				tmpSelection.addItem(currItem, true);
 				if (currItem->isBookmark)

Modified: trunk/Scribus/scribus/ui/scrapbookpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24572&path=/trunk/Scribus/scribus/ui/scrapbookpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scrapbookpalette.cpp	(original)
+++ trunk/Scribus/scribus/ui/scrapbookpalette.cpp	Tue Mar 16 21:37:31 2021
@@ -1913,7 +1913,7 @@
 
 void Biblio::objFromMainMenu(QString text, int scrapID)
 {
-	QString nam = "";
+	QString nam;
 	QString tmp;
 	int scID = scrapID;
 	if (scID > 0)




More information about the scribus-commit mailing list