r16458 by jghali - restore properly user text selections temporarily modified by text undo code

scribus-commit scribus-commit at lists.scribus.net
Fri Mar 18 00:04:48 CET 2011


Author: jghali
Date: Thu Mar 17 23:04:47 2011
New Revision: 16458

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16458
Log:
restore properly user text selections temporarily modified by text undo code

Modified:
    branches/Version135/Scribus/scribus/pageitem.cpp
    branches/Version135/Scribus/scribus/pageitem_textframe.cpp

Modified: branches/Version135/Scribus/scribus/pageitem.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16458&path=/branches/Version135/Scribus/scribus/pageitem.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/pageitem.cpp (original)
+++ branches/Version135/Scribus/scribus/pageitem.cpp Thu Mar 17 23:04:47 2011
@@ -3925,9 +3925,10 @@
 		iT.insert(0, itemText);
 	else
 	{
-		int StartOldSel = 0, LenOldSel = 0;
+		int StartOldSel = -1, LenOldSel = -1;
 		if (undoItem == PARAGRAPH)
 		{
+			LenOldSel = 0;
 			if (HasSel)
 			{
 				StartOldSel = itemText.startOfSelection();
@@ -3937,6 +3938,9 @@
 		}
 		else if (undoItem == CHAR || (undoItem == SELECTION && !HasSel))
 		{
+			LenOldSel = itemText.lengthOfSelection();
+			if (LenOldSel > 0)
+				StartOldSel = itemText.startOfSelection();
 			itemText.select(CPos,1);
 			HasSel = true;
 		}
@@ -3946,6 +3950,11 @@
 		{
 			itemText.select(StartOldSel, LenOldSel);
 			HasSel = true;
+		}
+		else if (LenOldSel == 0)
+		{
+			itemText.deselectAll();
+			HasSel = false;
 		}
 	}
 	//saxing text

Modified: branches/Version135/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16458&path=/branches/Version135/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/pageitem_textframe.cpp (original)
+++ branches/Version135/Scribus/scribus/pageitem_textframe.cpp Thu Mar 17 23:04:47 2011
@@ -3677,6 +3677,10 @@
 		}
 		else
 		{
+			int oldSelStart = -1, oldSelLen = -1;
+			oldSelLen = itemText.lengthOfSelection();
+			if (oldSelLen > 0)
+				oldSelStart = itemText.startOfSelection();
 			if (action == PARAMFULL && m_Doc->appMode == modeEdit)
 			{
 				//action is for paragraph where cursor is
@@ -3692,6 +3696,16 @@
 			ss->set("STEXT_OLD", itemTextSaxed);
 			itemTextSaxed = getItemTextSaxed((action == PARAMSEL) ? SELECTION : FRAME);
 			ss->set("STEXT_NEW", itemTextSaxed);
+			if (oldSelLen > 0)
+			{
+				itemText.select(oldSelStart, oldSelLen);
+				HasSel = true;
+			}
+			else if (oldSelLen == 0)
+			{
+				itemText.deselectAll();
+				HasSel = false;
+			}
 			if (QString::compare(ss->get("STEXT_OLD"),ss->get("STEXT_NEW")) == 0)
 			{
 				//nothing change - quit without set new Undo step




More information about the scribus-commit mailing list