r22244 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Mon Dec 11 18:10:59 UTC 2017


Author: jghali
Date: Mon Dec 11 18:10:59 2017
New Revision: 22244

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22244
Log:
#15067: Undoing text paste over causes old and new text merge

Modified:
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/scribus.cpp

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22244&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp	(original)
+++ trunk/Scribus/scribus/pageitem.cpp	Mon Dec 11 18:10:59 2017
@@ -4951,6 +4951,8 @@
 				restoreBottomTextFrameDist(ss, isUndo);
 			else if (ss->contains("FIRSTLINEOFFSET"))
 				restoreFirstLineOffset(ss, isUndo);
+			else if (ss->contains("PASTE_PLAINTEXT"))
+				restorePastePlainText(ss, isUndo);
 			else if (ss->contains("PASTE_TEXT"))
 				restorePasteText(ss, isUndo);
 			else if (ss->contains("CORNER_RADIUS"))
@@ -6504,13 +6506,27 @@
 		itemText.insertObject(is->getInt("INDEX"));
 }
 
+void PageItem::restorePastePlainText(SimpleState *ss, bool isUndo)
+{
+	int start = ss->getInt("START");
+	QString text = ss->get("TEXT");
+	if (isUndo)
+	{
+		itemText.select(start, text.length());
+		asTextFrame()->deleteSelectedTextFromFrame();
+	}
+	else
+		itemText.insertChars(text, true);
+}
+
 void PageItem::restorePasteText(SimpleState *ss, bool isUndo)
 {
 	ScItemState<StoryText> *is = dynamic_cast<ScItemState<StoryText>*>(ss);
 	if (!is)
 		qFatal("PageItem::restorePasteText: dynamic cast failed");
 	int start = is->getInt("START");
-	if (isUndo){
+	if (isUndo)
+	{
 		itemText.select(start,is->getItem().length());
 		asTextFrame()->deleteSelectedTextFromFrame();
 	}

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22244&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h	(original)
+++ trunk/Scribus/scribus/pageitem.h	Mon Dec 11 18:10:59 2017
@@ -1625,6 +1625,7 @@
 	void restorePStyle(SimpleState *state, bool isUndo);
 	void restoreParagraphStyle(SimpleState *state, bool isUndo);
 	void restorePasteInline(SimpleState *state, bool isUndo);
+	void restorePastePlainText(SimpleState *state, bool isUndo);
 	void restorePasteText(SimpleState *state, bool isUndo);
 	void restorePathOperation(UndoState *state, bool isUndo);
 	void restorePoly(SimpleState *state, bool isUndo, bool isContour);

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22244&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Mon Dec 11 18:10:59 2017
@@ -4773,7 +4773,7 @@
 			{
 				ScItemState<StoryText> *is = new ScItemState<StoryText>(Um::Paste);
 				is->set("PASTE_TEXT");
-				is->set("START",currItem->itemText.cursorPosition());
+				is->set("START", currItem->itemText.cursorPosition());
 				is->setItem(*story);
 				m_undoManager->action(currItem, is);
 			}
@@ -4851,8 +4851,8 @@
 			{
 				SimpleState *is = new SimpleState(Um::Paste,"",Um::IPaste);
 				is->set("PASTE_INLINE");
-				is->set("START",currItem->itemText.cursorPosition());
-				is->set("INDEX",fIndex);
+				is->set("START", currItem->itemText.cursorPosition());
+				is->set("INDEX", fIndex);
 				m_undoManager->action(currItem, is);
 			}
 			currItem->itemText.insertObject(fIndex);
@@ -4918,10 +4918,10 @@
 				m_undoManager->setUndoEnabled(true);
 				if (UndoManager::undoEnabled())
 				{
-					SimpleState *is = new SimpleState(Um::Paste,"",Um::IPaste);
+					SimpleState *is = new SimpleState(Um::Paste, "", Um::IPaste);
 					is->set("PASTE_INLINE");
-					is->set("START",currItem->itemText.cursorPosition());
-					is->set("INDEX",fIndex);
+					is->set("START", currItem->itemText.cursorPosition());
+					is->set("INDEX", fIndex);
 					m_undoManager->action(currItem, is);
 				}
 				currItem->itemText.insertObject(fIndex);
@@ -4936,6 +4936,14 @@
 			QString text = QApplication::clipboard()->text(QClipboard::Clipboard);
 			text = text.replace("\r\n", SpecialChars::PARSEP);
 			text = text.replace('\n', SpecialChars::PARSEP);
+			if (UndoManager::undoEnabled())
+			{
+				SimpleState *is = new SimpleState(Um::Paste, "", Um::IPaste);
+				is->set("PASTE_PLAINTEXT");
+				is->set("START", currItem->itemText.cursorPosition());
+				is->set("TEXT", text);
+				m_undoManager->action(currItem, is);
+			}
 			currItem->itemText.insertChars(text, true);
 		}
 		if (doc->appMode == modeEditTable)




More information about the scribus-commit mailing list