r16661 by jghali - #10048: Updating linespacing changes text selection

scribus-commit scribus-commit at lists.scribus.net
Wed Jun 15 21:35:25 UTC 2011


Author: jghali
Date: Wed Jun 15 21:35:25 2011
New Revision: 16661

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16661
Log:
#10048: Updating linespacing changes text selection

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

Modified: branches/Version135/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16661&path=/branches/Version135/Scribus/scribus/pageitem.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/pageitem.cpp (original)
+++ branches/Version135/Scribus/scribus/pageitem.cpp Wed Jun 15 21:35:25 2011
@@ -4024,39 +4024,25 @@
 		iT.insert(0, itemText);
 	else
 	{
-		int StartOldSel = -1, LenOldSel = -1;
+		int StartOldSel = 0, LenOldSel = 0;
+		if (HasSel)
+		{
+			StartOldSel = itemText.startOfSelection();
+			LenOldSel = itemText.lengthOfSelection();
+		}
 		if (undoItem == PARAGRAPH)
-		{
-			LenOldSel = 0;
-			if (HasSel)
-			{
-				StartOldSel = itemText.startOfSelection();
-				LenOldSel = itemText.lengthOfSelection();
-			}
 			asTextFrame()->expandParaSelection(true);
-		}
-		else if (undoItem == CHAR || (undoItem == SELECTION && !HasSel))
-		{
-			LenOldSel = itemText.lengthOfSelection();
-			if (LenOldSel > 0)
-				StartOldSel = itemText.startOfSelection();
+		else if (undoItem == CHAR || !HasSel)
+		{
 			if (itemText.cursorPosition() >= itemText.length())
 				return  "";
 			itemText.select(itemText.cursorPosition(), 1);
-			HasSel = true;
 		}
 		//is SELECTION
-		iT.insert(0, itemText, HasSel);
+		iT.insert(0, itemText, true);
+		itemText.deselectAll();
 		if (LenOldSel > 0) //restoring old selection if undoItem was PARAPGRAPH
-		{
 			itemText.select(StartOldSel, LenOldSel);
-			HasSel = true;
-		}
-		else if (LenOldSel == 0)
-		{
-			itemText.deselectAll();
-			HasSel = false;
-		}
 	}
 	//saxing text
 	std::ostringstream xmlString;
@@ -4076,23 +4062,8 @@
 	StoryText it(m_Doc);
 	it.setDefaultStyle(itemText.defaultStyle());
 
-	int oldSelStart = -1, oldSelLength = -1;
-	oldSelStart  = itemText.startOfSelection();
-	oldSelLength = itemText.lengthOfSelection();
-
 	itemText.select(selStart, selLength);
 	it.insert(0, itemText, (selLength > 0));
-	
-	if (oldSelLength > 0) //restoring old selection if undoItem was PARAPGRAPH
-	{
-		itemText.select(oldSelStart, oldSelLength);
-		HasSel = true;
-	}
-	else if (oldSelLength == 0)
-	{
-		itemText.deselectAll();
-		HasSel = false;
-	}
 
 	//saxing text
 	std::ostringstream xmlString;

Modified: branches/Version135/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16661&path=/branches/Version135/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/pageitem_textframe.cpp (original)
+++ branches/Version135/Scribus/scribus/pageitem_textframe.cpp Wed Jun 15 21:35:25 2011
@@ -3850,6 +3850,7 @@
 
 void PageItem_TextFrame::restoreTextSelection(int oldSelStart, int oldSelLength)
 {
+	itemText.deselectAll();
 	if (oldSelLength > 0)
 		itemText.select(oldSelStart, oldSelLength);
 	else if (oldSelLength == 0)

Modified: branches/Version135/Scribus/scribus/propertiespalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16661&path=/branches/Version135/Scribus/scribus/propertiespalette.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/propertiespalette.cpp (original)
+++ branches/Version135/Scribus/scribus/propertiespalette.cpp Wed Jun 15 21:35:25 2011
@@ -2947,11 +2947,7 @@
 	if ((HaveDoc) && (HaveItem))
 	{
 		if (CurItem->asTextFrame())
-		{
-//			CurItem->asTextFrame()->ExpandParSel();
 			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME);
-//			CurItem->asTextFrame()->lastAction4Paragraph = true;
-		}
 		doc->itemSelection_SetLineSpacingMode(id);
 		updateStyle(doc->appMode == modeEdit? CurItem->currentStyle() : CurItem->itemText.defaultStyle());
 		if (CurItem->asTextFrame())
@@ -3874,11 +3870,7 @@
 	if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
 	if (CurItem->asTextFrame())
-	{
-//		CurItem->asTextFrame()->ExpandParSel();
 		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME);
-//		CurItem->asTextFrame()->lastAction4Paragraph = true;
-	}
 	doc->itemSelection_SetLineSpacing(LineSp->value());
 	if (CurItem->asTextFrame())
 		CurItem->asTextFrame()->updateUndo();
@@ -4276,32 +4268,10 @@
 
 void PropertiesPalette::NewAlignement(int a)
 {
-	int selStart = 0, selEnd = 0, selLength = 0;
 	if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
 	if (CurItem->asTextFrame())
-	{
-		// hack for apply left align for text with no align at all
-		//so during Undo/Redo some align will be applied
-		StoryText& itemText(CurItem->itemText);
-		if (doc->appMode == modeEdit)
-		{
-			//selected parapgraph(s) only
-			selStart = (itemText.lengthOfSelection() > 0) ? itemText.startOfSelection() : CurItem->itemText.cursorPosition();
-			selEnd   = (itemText.lengthOfSelection() > 0) ? itemText.endOfSelection() : CurItem->itemText.cursorPosition();
-			selStart = itemText.startOfParagraph( itemText.nrOfParagraph(selStart) );
-			selEnd   = itemText.endOfParagraph  ( itemText.nrOfParagraph(selEnd) );
-		}
-		else
-		{
-			//for whole frame
-			selStart = itemText.startOfParagraph( 0 );
-			selEnd   = itemText.endOfParagraph  ( itemText.nrOfParagraph(itemText.lastInFrame()) );
-		}
-		selLength = qMin(selEnd - selStart + 1, itemText.length() - selStart);
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(selStart, selLength);
-//		CurItem->asTextFrame()->lastAction4Paragraph = true;
-	}
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME);
 	doc->itemSelection_SetAlignment(a);
 	if (CurItem->asTextFrame())
 		CurItem->asTextFrame()->updateUndo();




More information about the scribus-commit mailing list