r16636 by jghali - merge trunk revisions up to r16629

scribus-commit scribus-commit at lists.scribus.net
Mon May 30 22:38:48 UTC 2011


Author: jghali
Date: Mon May 30 22:38:48 2011
New Revision: 16636

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16636
Log:
merge trunk revisions up to r16629

Modified:
    branches/ScribusOIF/scribus/actionmanager.cpp
    branches/ScribusOIF/scribus/canvasmode_edit.cpp
    branches/ScribusOIF/scribus/gtaction.cpp
    branches/ScribusOIF/scribus/pageitem.cpp
    branches/ScribusOIF/scribus/pageitem.h
    branches/ScribusOIF/scribus/pageitem_textframe.cpp
    branches/ScribusOIF/scribus/pageitem_textframe.h
    branches/ScribusOIF/scribus/pdflib_core.cpp
    branches/ScribusOIF/scribus/plugins/scriptplugin/cmdtext.cpp
    branches/ScribusOIF/scribus/scribus.cpp
    branches/ScribusOIF/scribus/scribusdoc.cpp
    branches/ScribusOIF/scribus/scribusview.cpp
    branches/ScribusOIF/scribus/styles/paragraphstyle.cpp
    branches/ScribusOIF/scribus/styles/paragraphstyle.h
    branches/ScribusOIF/scribus/text/sctext_shared.cpp
    branches/ScribusOIF/scribus/text/sctext_shared.h
    branches/ScribusOIF/scribus/text/storytext.cpp
    branches/ScribusOIF/scribus/text/storytext.h
    branches/ScribusOIF/scribus/text/storytext_shared.cpp
    branches/ScribusOIF/scribus/text/storytext_shared.h
    branches/ScribusOIF/scribus/ui/about.cpp
    branches/ScribusOIF/scribus/ui/charselect.cpp
    branches/ScribusOIF/scribus/ui/search.cpp
    branches/ScribusOIF/scribus/ui/storyeditor.cpp

Modified: branches/ScribusOIF/scribus/actionmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/actionmanager.cpp
==============================================================================
--- branches/ScribusOIF/scribus/actionmanager.cpp (original)
+++ branches/ScribusOIF/scribus/actionmanager.cpp Mon May 30 22:38:48 2011
@@ -1407,7 +1407,7 @@
 	(*scrActions)["itemConvertToTextFrame"]->setTexts( tr("&Text Frame"));
 
 	//Insert Menu
-	(*scrActions)["insertFrame"]->setTexts( tr("&Frame..."));
+	(*scrActions)["insertFrame"]->setTexts( tr("&Frames..."));
 	(*scrActions)["insertGlyph"]->setTexts( tr("&Glyph..."));
 	(*scrActions)["insertSampleText"]->setTexts( tr("Sample Text"));
 	(*scrActions)["stickyTools"]->setTexts( tr("Sticky Tools"));

Modified: branches/ScribusOIF/scribus/canvasmode_edit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/canvasmode_edit.cpp
==============================================================================
--- branches/ScribusOIF/scribus/canvasmode_edit.cpp (original)
+++ branches/ScribusOIF/scribus/canvasmode_edit.cpp Mon May 30 22:38:48 2011
@@ -241,8 +241,8 @@
 		cPen.setCosmetic(true);
 
 		// normalize Current Position
-		textframe->CPos = qMax ( 0,qMin ( textframe->CPos, textframe->itemText.length() ) );
-		int textCursorPos ( textframe->CPos );
+		textframe->itemText.setCursorPosition( qMax ( 0, qMin( textframe->itemText.cursorPosition(), textframe->itemText.length() ) ) );
+		int textCursorPos ( textframe->itemText.cursorPosition() );
 
 		bool cursorDirection(true); // true => LTR; false => RTL
 		FRect bbox;
@@ -478,7 +478,7 @@
 				if (m->modifiers() & Qt::ShiftModifier)
 				{//Double click with Ctrl+Shift in a frame to select few paragraphs
 					uint oldPar = currItem->itemText.nrOfParagraph(oldCp);
-					uint newPar = currItem->itemText.nrOfParagraph(currItem->CPos);
+					uint newPar = currItem->itemText.nrOfParagraph();
 					if (oldPar < newPar)
 					{
 						start = currItem->itemText.startOfParagraph(oldPar);
@@ -492,19 +492,19 @@
 				}
 				else
 				{//Double click with Ctrl in a frame to select a paragraph
-					oldCp = currItem->CPos;
+					oldCp = currItem->itemText.cursorPosition();
 					uint nrPar = currItem->itemText.nrOfParagraph(oldCp);
 					start = currItem->itemText.startOfParagraph(nrPar);
 					stop = currItem->itemText.endOfParagraph(nrPar);
 				}
 				currItem->itemText.deselectAll();
 				currItem->itemText.extendSelection(start, stop);
-				currItem->CPos = stop;
+				currItem->itemText.setCursorPosition(stop);
 			}
 			else
 			{	//Double click in a frame to select a word
-				oldCp = currItem->CPos;
-				currItem->CPos = currItem->itemText.selectWord(currItem->CPos);
+				oldCp = currItem->itemText.cursorPosition();
+				currItem->itemText.setCursorPosition(currItem->itemText.selectWord(currItem->itemText.cursorPosition()));
 			}
 			currItem->HasSel = (currItem->itemText.lengthOfSelection() > 0);
 		}
@@ -585,14 +585,14 @@
 				//Make sure we dont go here if the old cursor position was not set
 				if (oldCp!=-1 && currItem->itemText.length() > 0)
 				{
-					if (currItem->CPos < oldCp)
-					{
-						currItem->itemText.select(currItem->CPos, oldCp - currItem->CPos);
+					if (currItem->itemText.cursorPosition() < oldCp)
+					{
+						currItem->itemText.select(currItem->itemText.cursorPosition(), oldCp - currItem->itemText.cursorPosition());
 						currItem->HasSel = true;
 					}
-					if (currItem->CPos > oldCp)
-					{
-						currItem->itemText.select(oldCp, currItem->CPos - oldCp);
+					if (currItem->itemText.cursorPosition() > oldCp)
+					{
+						currItem->itemText.select(oldCp, currItem->itemText.cursorPosition() - oldCp);
 						currItem->HasSel = true;
 					}
 				}
@@ -749,7 +749,7 @@
 				return;
 			}
 		}
-		oldP = currItem->CPos;
+		oldP = currItem->itemText.cursorPosition();
 		//CB Where we set the cursor for a click in text frame
 		if (currItem->asTextFrame())
 		{
@@ -772,32 +772,32 @@
 				{
 					if (currItem->itemText.lengthOfSelection() > 0)
 					{
-						if (currItem->CPos < (currItem->itemText.startOfSelection() + currItem->itemText.endOfSelection()) / 2)
+						if (currItem->itemText.cursorPosition() < (currItem->itemText.startOfSelection() + currItem->itemText.endOfSelection()) / 2)
 						{
 							if (m->modifiers() & Qt::ControlModifier)
-								currItem->CPos = currItem->itemText.startOfParagraph(currItem->itemText.nrOfParagraph(currItem->CPos));
+								currItem->itemText.setCursorPosition(currItem->itemText.startOfParagraph());
 							oldP = currItem->itemText.startOfSelection();
 						}
 						else
 						{
 							if (m->modifiers() & Qt::ControlModifier)
-								currItem->CPos = currItem->itemText.endOfParagraph(currItem->itemText.nrOfParagraph(currItem->CPos));
+								currItem->itemText.setCursorPosition(currItem->itemText.endOfParagraph());
 							oldP = currItem->itemText.endOfSelection();
 						}
-						currItem->asTextFrame()->itemText.extendSelection(oldP, currItem->CPos);
-						oldCp = currItem->CPos;
+						currItem->asTextFrame()->itemText.extendSelection(oldP, currItem->itemText.cursorPosition());
+						oldCp = currItem->itemText.cursorPosition();
 					}
 					else
 					{
 						int dir=1;
-						if (oldCp > currItem->CPos)
+						if (oldCp > currItem->itemText.cursorPosition())
 							dir=-1;
 						if (m->modifiers() & Qt::ControlModifier) //no selection but Ctrl+Shift+click still select paragraphs
 						{
 							if (dir == 1)
-								currItem->CPos = currItem->itemText.endOfParagraph(currItem->itemText.nrOfParagraph(currItem->CPos));
+								currItem->itemText.setCursorPosition(currItem->itemText.endOfParagraph());
 							else
-								currItem->CPos = currItem->itemText.startOfParagraph(currItem->itemText.nrOfParagraph(currItem->CPos));
+								currItem->itemText.setCursorPosition(currItem->itemText.startOfParagraph());
 						}
 						currItem->asTextFrame()->ExpandSel(dir, oldP);
 						oldCp = oldP;
@@ -805,7 +805,7 @@
 				}
 				else //>>CB
 				{
-					oldCp = currItem->CPos;
+					oldCp = currItem->itemText.cursorPosition();
 					currItem->itemText.deselectAll();
 					currItem->HasSel = false;
 				}

Modified: branches/ScribusOIF/scribus/gtaction.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/gtaction.cpp
==============================================================================
--- branches/ScribusOIF/scribus/gtaction.cpp (original)
+++ branches/ScribusOIF/scribus/gtaction.cpp Mon May 30 22:38:48 2011
@@ -104,7 +104,6 @@
 void gtAction::clearFrame()
 {
 	textFrame->itemText.clear();
-	textFrame->CPos = 0;
 }
 
 void gtAction::writeUnstyled(const QString& text)
@@ -119,12 +118,10 @@
 				while (nextItem != 0)
 				{
 					nextItem->itemText.clear();
-					nextItem->CPos = 0;
 					nextItem = nextItem->nextInChain();
 				}
 			}
 			it->itemText.clear();
-			it->CPos = 0;
 		}
 	}
 
@@ -157,12 +154,10 @@
 				while (nextItem != 0)
 				{
 					nextItem->itemText.clear();
-					nextItem->CPos = 0;
 					nextItem = nextItem->nextInChain();
 				}
 			}
 			it->itemText.clear();
-			it->CPos = 0;
 		}
 	}
 	int paragraphStyle = -1;

Modified: branches/ScribusOIF/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/pageitem.cpp
==============================================================================
--- branches/ScribusOIF/scribus/pageitem.cpp (original)
+++ branches/ScribusOIF/scribus/pageitem.cpp Mon May 30 22:38:48 2011
@@ -159,7 +159,6 @@
 	BBoxH(other.BBoxH),
 	CurX(other.CurX),
 	CurY(other.CurY),
-	CPos(other.CPos),
 	itemText(other.itemText),
 	isBookmark(other.isBookmark),
 	HasSel(other.HasSel),
@@ -463,7 +462,6 @@
 	FrameType = 0;
 	CurX = 0;
 	CurY = 0;
-	CPos = 0;
 	Extra = m_Doc->itemToolPrefs().textDistances.Left;
 	TExtra = m_Doc->itemToolPrefs().textDistances.Top;
 	BExtra = m_Doc->itemToolPrefs().textDistances.Bottom;
@@ -1055,6 +1053,24 @@
 	Reverse=newReversed;
 }
 
+//return frame where is text end
+PageItem * PageItem::frameTextEnd()
+{
+	PageItem * LastBox = this;
+	if (frameOverflows() && NextBox)
+	{ // text ending in some next frame
+		LastBox = NextBox;
+		while (LastBox != 0 && !LastBox->frameDisplays(itemText.length()-1))
+			LastBox = LastBox->nextInChain();
+	}
+	else if (frameUnderflows() && BackBox)
+	{ //text ending in some previous frame
+		LastBox = BackBox;
+		while (LastBox != 0 && !LastBox->frameDisplays(itemText.length()-1))
+			LastBox = LastBox->prevInChain();
+	}
+	return LastBox;
+}
 
 /// returns true if text overflows
 bool PageItem::frameOverflows() const
@@ -1071,6 +1087,17 @@
 #else
 	return false; // FIXME:NLS
 #endif
+}
+
+/// returns true if text is ending before that frame
+bool PageItem::frameUnderflows() const
+{
+	if (BackBox == NULL)
+		return false;
+	//FIX ME - I have found that condition if frame is empty
+	//and has been linked with previous frame
+	//if you will find any better solution - fix that function
+	return (firstInFrame() > lastInFrame());
 }
 
 int PageItem::firstInFrame() const
@@ -1255,8 +1282,8 @@
 /// returns the style at the current charpos
 const ParagraphStyle& PageItem::currentStyle() const
 {
-	if (frameDisplays(CPos))
-		return itemText.paragraphStyle(CPos);
+	if (frameDisplays(itemText.cursorPosition()))
+		return itemText.paragraphStyle(itemText.cursorPosition());
 	else
 		return itemText.defaultStyle();
 }
@@ -1264,8 +1291,8 @@
 /// returns the style at the current charpos for changing
 ParagraphStyle& PageItem::changeCurrentStyle()
 {
-	if (frameDisplays(CPos))
-		return const_cast<ParagraphStyle&>(itemText.paragraphStyle(CPos));
+	if (frameDisplays(itemText.cursorPosition()))
+		return const_cast<ParagraphStyle&>(itemText.paragraphStyle(itemText.cursorPosition()));
 	else
 		return const_cast<ParagraphStyle&>(itemText.defaultStyle());
 }
@@ -1273,8 +1300,8 @@
 /// returns the style at the current charpos
 const CharStyle& PageItem::currentCharStyle() const
 {
-	if (frameDisplays(CPos))
-		return itemText.charStyle(CPos);
+	if (frameDisplays(itemText.cursorPosition()))
+		return itemText.charStyle(itemText.cursorPosition());
 	else
 		return itemText.defaultStyle().charStyle();
 }

Modified: branches/ScribusOIF/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/pageitem.h
==============================================================================
--- branches/ScribusOIF/scribus/pageitem.h (original)
+++ branches/ScribusOIF/scribus/pageitem.h Mon May 30 22:38:48 2011
@@ -342,8 +342,11 @@
 	virtual void invalidateLayout() {}
 	/// creates valid layout information
 	virtual void layout() {}
+	/// returns frame where is text end
+	PageItem * frameTextEnd();
 	/// returns true if text overflows
 	bool frameOverflows() const;
+	bool frameUnderflows() const;
 	/// returns index of first char displayed in this frame, used to be 0
 	int firstInFrame() const;
 	/// returns index of last char displayed in this frame, used to be MaxChars-1
@@ -501,8 +504,6 @@
 	double CurX;
   /** Zeichen Y-Position */
 	double CurY;
-  /** Cursorposition */
-	int CPos;
   /** Text des Elements */
 	StoryText itemText;
 	TextLayout* textLayout;

Modified: branches/ScribusOIF/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/pageitem_textframe.cpp
==============================================================================
--- branches/ScribusOIF/scribus/pageitem_textframe.cpp (original)
+++ branches/ScribusOIF/scribus/pageitem_textframe.cpp Mon May 30 22:38:48 2011
@@ -749,7 +749,6 @@
 
 	while (nextItem != 0)
 	{
-		nextItem->CPos = 0;
 		nextItem->textLayout->invalidate();
 		nextItem = nextItem->nextInChain();
 	}
@@ -757,7 +756,39 @@
 
 void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat)
 {
-	int oldPos = CPos; // 15-mar-2004 jjsa for cursor movement with Shift + Arrow key
+	if (frameUnderflows())
+	{
+		itemText.setCursorPosition( itemText.length() );
+		m_Doc->view()->Deselect(true);
+		PageItem * jumpFrame = frameTextEnd();
+		if (jumpFrame)
+		{
+			m_Doc->scMW()->selectItemsFromOutlines(jumpFrame);
+			m_Doc->scMW()->setTBvals(jumpFrame);
+			jumpFrame->update();
+			update();
+			switch (k->key())
+			{
+			case Qt::Key_PageDown:
+			case Qt::Key_PageUp:
+			case Qt::Key_End:
+			case Qt::Key_Home:
+			case Qt::Key_Right:
+			case Qt::Key_Left:
+			case Qt::Key_Up:
+			case Qt::Key_Down:
+			case Qt::Key_Delete:
+			case Qt::Key_Backspace:
+				break;
+			default:
+				jumpFrame->handleModeEditKey(k, keyRepeat);
+				jumpFrame->layout();
+				break;
+				}
+			return;
+		}
+	}
+	int oldPos = itemText.cursorPosition(); // 15-mar-2004 jjsa for cursor movement with Shift + Arrow key
 	int kk = k->key();
 	int as = k->text()[0].unicode();
 	QString uc = k->text();
@@ -827,8 +858,7 @@
 					deleteSelectedTextFromFrame();
 				if (conv < 31)
 					conv = 32;
-				itemText.insertChars(CPos, QString(QChar(conv)), true);
-				CPos += 1;
+				itemText.insertChars(QString(QChar(conv)), true);
 //				Tinput = true;
 				m_Doc->scMW()->setTBvals(this);
 				update();
@@ -855,7 +885,7 @@
 	{
 	case Qt::Key_Home:
 		// go to begin of line
-		if ( (pos = CPos) == firstInFrame() )
+		if ( (pos = itemText.cursorPosition()) == firstInFrame() )
 			break; // at begin of frame
 		len = lastInFrame();
 		if ( pos >= len )
@@ -869,7 +899,7 @@
 			//Control Home for start of frame text
 			pos = textLayout->startOfFrame();
 		}
-		CPos = pos;
+		itemText.setCursorPosition(pos);
 		if ( buttonModifiers & Qt::ShiftModifier )
 			ExpandSel(-1, oldPos);
 //		if ( this->itemText.lengthOfSelection() > 0 )
@@ -879,16 +909,16 @@
 	case Qt::Key_End:
 		// go to end of line
 		len = lastInFrame();
-		if ( CPos >= len )
+		if ( itemText.cursorPosition() >= len )
 			break; // at end of frame
 		if ( (buttonModifiers & Qt::ControlModifier) == 0 )
 		{
-			CPos = textLayout->endOfLine(CPos);
+			itemText.setCursorPosition( textLayout->endOfLine(itemText.cursorPosition()) );
 		}
 		else
 		{
 			//Control End for end of frame text
-			CPos = textLayout->endOfFrame();
+			itemText.setCursorPosition( textLayout->endOfFrame() );
 		}
 		if ( buttonModifiers & Qt::ShiftModifier )
 			ExpandSel(1, oldPos);
@@ -901,34 +931,33 @@
 		{
 			// go to end of paragraph
 			len = itemText.length();
-			CPos = itemText.nextParagraph(CPos);
+			itemText.setCursorPosition(itemText.nextParagraph(itemText.cursorPosition()));
 			if ( buttonModifiers & Qt::ShiftModifier )
 				ExpandSel(1, oldPos);
 		}
 		else
 		{
-			if (CPos <= lastInFrame())
-			{
-				CPos = textLayout->nextLine(CPos);
+			if (itemText.cursorPosition() <= lastInFrame())
+			{
+				itemText.setCursorPosition( textLayout->nextLine(itemText.cursorPosition()) );
 				if ( buttonModifiers & Qt::ShiftModifier )
 				{
 					if ( buttonModifiers & Qt::AltModifier )
-						CPos = lastInFrame()+1;
+						itemText.setCursorPosition (lastInFrame()+1);
 					ExpandSel(1, oldPos);
 				}
 				else 
 					if ((textLayout->startOfFrame() != textLayout->endOfFrame())
 //						&& (oldPos >= textLayout->line(itemText.lines()-1).firstItem)
-						&& (CPos >= lastInFrame())
+						&& (itemText.cursorPosition() >= lastInFrame())
 						&& (NextBox != 0))
 					{
-						if (NextBox->frameDisplays(CPos))
+						if (NextBox->frameDisplays(itemText.cursorPosition()))
 						{
 							view->Deselect(true);
 							// we position the cursor at the beginning of the next frame
 							// TODO position at the right place in next frame
-							NextBox->CPos = lastInFrame() + 1;
-							view->SelectItemNr(NextBox->ItemNr);
+							m_Doc->scMW()->selectItemsFromOutlines(NextBox);
 						}
 					}
 			}
@@ -939,8 +968,7 @@
 					if (NextBox->frameDisplays(lastInFrame()+1))
 					{
 						view->Deselect(true);
-						NextBox->CPos = lastInFrame()+1;
-						view->SelectItemNr(NextBox->ItemNr);
+						m_Doc->scMW()->selectItemsFromOutlines(NextBox);
 					}
 				}
 			}
@@ -952,46 +980,46 @@
 	case Qt::Key_Up:
 		if (buttonModifiers & Qt::ControlModifier)
 		{
-			if ( (pos = CPos) == firstInFrame() )
+			if ( (pos = itemText.cursorPosition()) == firstInFrame() )
 				break; // at begin of frame
 			len = itemText.length();
-			CPos = itemText.prevParagraph(CPos);
+			itemText.setCursorPosition( itemText.prevParagraph(itemText.cursorPosition()) );
 			if ( buttonModifiers & Qt::ShiftModifier )
 				ExpandSel(-1, oldPos);
 		}
 		else
 		{
-			if (CPos > firstInFrame())
-			{
-				if (CPos > lastInFrame() || CPos >= itemText.length())
-					CPos = lastInFrame();
-				CPos = textLayout->prevLine(CPos);
+			if (itemText.cursorPosition() > firstInFrame())
+			{
+				if (itemText.cursorPosition() > lastInFrame() || itemText.cursorPosition() >= itemText.length())
+					itemText.setCursorPosition( lastInFrame() );
+				itemText.setCursorPosition( textLayout->prevLine(itemText.cursorPosition()) );
 				if ( buttonModifiers & Qt::ShiftModifier )
 				{
 					if ( buttonModifiers & Qt::AltModifier )
-						CPos = firstInFrame();
+						itemText.setCursorPosition( firstInFrame() );
 					ExpandSel(-1, oldPos);
 				}
 				else
 					if ((textLayout->startOfFrame() != textLayout->endOfFrame())
 //						&& (oldPos <= itemText.line(0).lastItem)
-						&& (CPos == firstInFrame())
+						&& (itemText.cursorPosition() == firstInFrame())
 						&& (BackBox != 0))
 					{
 						view->Deselect(true);
 						// TODO position at the right place in previous frame
-						BackBox->CPos = BackBox->lastInFrame();
-						view->SelectItemNr(BackBox->ItemNr);
+						itemText.setCursorPosition( BackBox->lastInFrame() );
+						m_Doc->scMW()->selectItemsFromOutlines(BackBox);
 					}
 			}
 			else
 			{
-				CPos = firstInFrame();
+				itemText.setCursorPosition( firstInFrame() );
 				if (BackBox != 0)
 				{
 					view->Deselect(true);
-					BackBox->CPos = BackBox->lastInFrame();
-					view->SelectItemNr(BackBox->ItemNr);
+					itemText.setCursorPosition( BackBox->lastInFrame() );
+					m_Doc->scMW()->selectItemsFromOutlines(BackBox);
 				}
 			}
 		}
@@ -1000,13 +1028,13 @@
 		m_Doc->scMW()->setTBvals(this);
 		break;
 	case Qt::Key_PageUp:
-		CPos = textLayout->startOfFrame();
+		itemText.setCursorPosition( textLayout->startOfFrame() );
 		if ( buttonModifiers & Qt::ShiftModifier )
 			ExpandSel(-1, oldPos);
 		m_Doc->scMW()->setTBvals(this);
 		break;
 	case Qt::Key_PageDown:
-		CPos = textLayout->endOfFrame();
+		itemText.setCursorPosition( textLayout->endOfFrame() );
 		if ( buttonModifiers & Qt::ShiftModifier )
 			ExpandSel(1, oldPos);
 		m_Doc->scMW()->setTBvals(this);
@@ -1020,47 +1048,46 @@
 		}
 		else if ( buttonModifiers & Qt::ShiftModifier )
 		{
-			--CPos;
-			if ( CPos < 0 )
-				CPos = 0;
-			else
+			int pos = itemText.cursorPosition();
+			itemText.setCursorPosition(-1, true);
+			if (pos > 0)
 				ExpandSel(-1, oldPos);
 		}
 		else
 		{
-			--CPos;
-			if (CPos < firstInFrame())
-			{
-				CPos = firstInFrame();
+			itemText.setCursorPosition(-1, true);
+			if (itemText.cursorPosition() < firstInFrame())
+			{
+				itemText.setCursorPosition( firstInFrame() );
 				if (BackBox != 0)
 				{
 					view->Deselect(true);
-					BackBox->CPos = BackBox->lastInFrame();
-					view->SelectItemNr(BackBox->ItemNr);
+					itemText.setCursorPosition( BackBox->lastInFrame() );
+					m_Doc->scMW()->selectItemsFromOutlines(BackBox);
 					//currItem = currItem->BackBox;
 				}
 			}
 		}
-		if ((CPos > 0) && (CPos >= lastInFrame())) // I do not see how its possible, may be dead code - pm
-		{
-			CPos = lastInFrame();
+		if ((itemText.cursorPosition() > 0) && (itemText.cursorPosition() >= lastInFrame())) // I do not see how its possible, may be dead code - pm
+		{
+			itemText.setCursorPosition( lastInFrame() );
 //			if (itemText.charStyle(CPos-1).effects() & ScStyle_SuppressSpace)
 //			{
 //				--CPos;
-				while ((CPos > 1) && (itemText.charStyle(CPos).effects() & ScStyle_SuppressSpace) && (itemText.charStyle(CPos - 1).effects() & ScStyle_SuppressSpace))
-				{
-					--CPos;
-					if (CPos == 0)
+				while ((itemText.cursorPosition() > 1) && (itemText.charStyle().effects() & ScStyle_SuppressSpace) && (itemText.charStyle(itemText.cursorPosition() - 1).effects() & ScStyle_SuppressSpace))
+				{
+					itemText.setCursorPosition(-1, true);
+					if (itemText.cursorPosition() == 0)
 						break;
 				}
 //			}
 		}
 		else
 		{
-			while ((CPos > 1) && (itemText.charStyle(CPos).effects() & ScStyle_SuppressSpace) && (itemText.charStyle(CPos - 1).effects() & ScStyle_SuppressSpace))
-			{
-				--CPos;
-				if (CPos == 0)
+			while ((itemText.cursorPosition() > 1) && (itemText.charStyle().effects() & ScStyle_SuppressSpace) && (itemText.charStyle(itemText.cursorPosition() - 1).effects() & ScStyle_SuppressSpace))
+			{
+				itemText.setCursorPosition(-1, true);
+				if (itemText.cursorPosition() == 0)
 					break;
 			}
 		}
@@ -1077,26 +1104,24 @@
 		}
 		else if ( buttonModifiers & Qt::ShiftModifier )
 		{
-			++CPos;
-			if ( CPos > itemText.length() )
-				--CPos;
-			else
+			int pos = itemText.cursorPosition();
+			itemText.setCursorPosition(1, true);
+			if ( pos < itemText.length() )
 				ExpandSel(1, oldPos);
 		}
 		else
 		{
-			++CPos; // new position within text ?
-			if (CPos > lastInFrame())
+			itemText.setCursorPosition(1, true); // new position within text ?
+			if (itemText.cursorPosition() > lastInFrame())
 			{
 //				--CPos;
-				CPos = lastInFrame() + 1;
+				itemText.setCursorPosition(lastInFrame() + 1);
 				if (NextBox != 0)
 				{
-					if (NextBox->frameDisplays(CPos))
+					if (NextBox->frameDisplays(itemText.cursorPosition()))
 					{
 						view->Deselect(true);
-						NextBox->CPos = CPos;
-						view->SelectItemNr(NextBox->ItemNr);
+						m_Doc->scMW()->selectItemsFromOutlines(NextBox);
 						//currItem = currItem->NextBox;
 					}
 				}
@@ -1107,7 +1132,7 @@
 		m_Doc->scMW()->setTBvals(this);
 		break;
 	case Qt::Key_Delete:
-		if (CPos == itemText.length())
+		if (itemText.cursorPosition() == itemText.length())
 		{
 			if (itemText.lengthOfSelection() > 0)
 			{
@@ -1124,22 +1149,22 @@
 			keyRepeat = false;
 			return;
 		}
-		cr = itemText.text(CPos,1);
+		cr = itemText.text(itemText.cursorPosition(), 1);
 		if (itemText.lengthOfSelection() == 0)
-			itemText.select(CPos, 1, true);
+			itemText.select(itemText.cursorPosition(), 1, true);
 		deleteSelectedTextFromFrame();
 		update();
 //		Tinput = false;
 		if ((cr == QChar(13)) && (itemText.length() != 0))
 		{
-//			m_Doc->chAbStyle(this, findParagraphStyle(m_Doc, itemText.paragraphStyle(qMax(CPos-1,0))));
+//			m_Doc->chAbStyle(this, findParagraphStyle(m_Doc, itemText.paragraphStyle(qMax(itemText.cursorPosition()-1,0))));
 //			Tinput = false;
 		}
 		m_Doc->scMW()->setTBvals(this);
 //		view->RefreshItem(this);
 		break;
 	case Qt::Key_Backspace:
-		if (CPos == 0)
+		if (itemText.cursorPosition() == 0)
 		{
 			if (itemText.lengthOfSelection() > 0)
 			{
@@ -1151,11 +1176,11 @@
 		}
 		if (itemText.length() == 0)
 			break;
-		cr = itemText.text(qMax(CPos-1,0),1);
+		cr = itemText.text(qMax((int) itemText.cursorPosition() - 1, 0), 1);
 		if (itemText.lengthOfSelection() == 0)
 		{
-			--CPos;
-			itemText.select(CPos, 1, true);
+			itemText.setCursorPosition(-1, true);
+			itemText.select(itemText.cursorPosition(), 1, true);
 		}
 		deleteSelectedTextFromFrame();
 //		Tinput = false;
@@ -1163,6 +1188,17 @@
 		{
 //			m_Doc->chAbStyle(this, findParagraphStyle(m_Doc, itemText.paragraphStyle(qMax(CPos-1,0))));
 //			Tinput = false;
+		}
+		if (itemText.cursorPosition() < firstInFrame())
+		{
+			itemText.setCursorPosition( firstInFrame() );
+			if (BackBox != 0)
+			{
+				view->Deselect(true);
+				itemText.setCursorPosition( BackBox->lastInFrame() );
+				m_Doc->scMW()->selectItemsFromOutlines(BackBox);
+				//currItem = currItem->BackBox;
+			}
 		}
 		m_Doc->scMW()->setTBvals(this);
 		update();
@@ -1201,21 +1237,19 @@
 		//if ((kk == Qt::Key_Tab) || ((kk == Qt::Key_Return) && (buttonState & Qt::ShiftButton)))
 		if (kk == Qt::Key_Tab)
 		{
-			itemText.insertChars(CPos, QString(SpecialChars::TAB), true);
-			CPos += 1;
+			itemText.insertChars(QString(SpecialChars::TAB), true);
 //			Tinput = true;
 //			view->RefreshItem(this);
 			doUpdate = true;
 		}
 		else if ((uc[0] > QChar(31) && m_Doc->currentStyle.charStyle().font().canRender(uc[0])) || (as == 13) || (as == 30))
 		{
-			itemText.insertChars(CPos, uc, true);
-			CPos += 1;
-			if ((m_Doc->docHyphenator->AutoCheck) && (CPos > 1))
+			itemText.insertChars(uc, true);
+			if ((m_Doc->docHyphenator->AutoCheck) && (itemText.cursorPosition() > 1))
 			{
 				Twort = "";
 				Tcoun = 0;
-				for (int hych = CPos-1; hych > -1; hych--)
+				for (int hych = itemText.cursorPosition()-1; hych > -1; hych--)
 				{
 					Tcha = itemText.text(hych,1);
 					if (Tcha[0] == ' ')
@@ -1235,7 +1269,16 @@
 //			view->RefreshItem(this);
 			doUpdate = true;
 		}
-		if (doUpdate) update();
+		if (doUpdate)
+			update();
+		//check if cursor need to jump to next linked frame
+		if (lastInFrame() < (itemText.length() -2) && NextBox != 0)
+		{
+			view->Deselect(true);
+			//NextBox->CPos = CPos;
+			m_Doc->scMW()->selectItemsFromOutlines(NextBox);
+			NextBox->update();
+		}
 		break;
 	}
 // 	update();
@@ -1250,7 +1293,7 @@
 void PageItem_TextFrame::deleteSelectedTextFromFrame()
 {
 	if (itemText.lengthOfSelection() > 0) {
-		CPos = itemText.startOfSelection();
+		itemText.setCursorPosition( itemText.startOfSelection() );
 		itemText.removeSelection();
 		HasSel = false;
 	}
@@ -1270,13 +1313,13 @@
 	if ( dir > 0 && oldPos < len )
 	{
 		wasSpace = itemText.text(oldPos).isSpace();
-		CPos=oldPos+1;
-		while (CPos<len)
-		{
-			isSpace = itemText.text(CPos).isSpace();
+		itemText.setCursorPosition(oldPos + 1);
+		while (itemText.cursorPosition() < len)
+		{
+			isSpace = itemText.text().isSpace();
 			if (wasSpace && !isSpace)
 				break;
-			++CPos;
+			itemText.setCursorPosition(1, true);
 			wasSpace=isSpace;
 			
 		}
@@ -1293,19 +1336,18 @@
 	}
 	else if ( dir < 0 && oldPos > 0 )
 	{
-		CPos=oldPos-1;
-		wasSpace = itemText.text(CPos).isSpace();
-		while (CPos>0)
-		{
-			isSpace = itemText.text(CPos).isSpace();
+		itemText.setCursorPosition(oldPos - 1);
+		wasSpace = itemText.text().isSpace();
+		while (itemText.cursorPosition() > 0)
+		{
+			isSpace = itemText.text().isSpace();
 			if (!wasSpace && isSpace)
 			{
-				++CPos;
+				itemText.setCursorPosition(1, true);
 				break;
 			}
-			--CPos;
+			itemText.setCursorPosition(-1, true);
 			wasSpace=isSpace;
-			
 		}
 		/*
 		oldPos--;
@@ -1368,19 +1410,19 @@
 	// preventing it to be less than 0 here.
 	int end = qMax(0,itemText.endOfSelection());
 	
-	if (oldPos >= end && CPos < start)
+	if (oldPos >= end && itemText.cursorPosition() < start)
 	{
 		itemText.deselectAll();
-		itemText.select(CPos, start - CPos);
-	}
-	else if (oldPos <= start && CPos > end)
+		itemText.select(itemText.cursorPosition(), start - itemText.cursorPosition());
+	}
+	else if (oldPos <= start && itemText.cursorPosition() > end)
 	{
 		itemText.deselectAll();
-		itemText.select(end, CPos - end);
+		itemText.select(end, itemText.cursorPosition() - end);
 	}
 	else
 	{
-		itemText.extendSelection(oldPos, CPos);
+		itemText.extendSelection(oldPos, itemText.cursorPosition());
 	}
 	HasSel = (itemText.lengthOfSelection() > 0);
 	if (HasSel)
@@ -1394,7 +1436,7 @@
 		//CB Replace with direct call for now //emit  HasNoTextSel();
 		m_Doc->scMW()->DisableTxEdit();
 	}
-	cursorBiasBackward = (oldPos > CPos);
+	cursorBiasBackward = (oldPos > itemText.cursorPosition());
 
 // 	layoutWeakLock = true;
 // 	update();

Modified: branches/ScribusOIF/scribus/pageitem_textframe.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/pageitem_textframe.h
==============================================================================
--- branches/ScribusOIF/scribus/pageitem_textframe.h (original)
+++ branches/ScribusOIF/scribus/pageitem_textframe.h Mon May 30 22:38:48 2011
@@ -83,6 +83,7 @@
 	virtual void DrawObj_Post(ScPainter *p);
 	virtual void DrawObj_Decoration(ScPainter *p);
 	void drawOverflowMarker(ScPainter *p);
+	void drawUnderflowMarker(ScPainter *p);
 	void drawColumnBorders(ScPainter *p);
 
 #ifdef NLS_PROTO

Modified: branches/ScribusOIF/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/pdflib_core.cpp
==============================================================================
--- branches/ScribusOIF/scribus/pdflib_core.cpp (original)
+++ branches/ScribusOIF/scribus/pdflib_core.cpp Mon May 30 22:38:48 2011
@@ -4694,30 +4694,8 @@
 			putColor(sl->Color, sl->Shade, false) +
 			FToStr(sl->Width)+" w\n"
 			);
-	QString Dt = FToStr(qMax(1*sl->Width, 1.0));
-	QString Sp = FToStr(qMax(2*sl->Width, 1.0));
-	QString Da = FToStr(qMax(4*sl->Width, 1.0));
-	switch (static_cast<Qt::PenStyle>(sl->Dash))
-	{
-		case Qt::SolidLine:
-			tmp += "[] 0 d\n";
-			break;
-		case Qt::DashLine:
-			tmp += "["+Da+" "+Sp+"] 0 d\n";
-			break;
-		case Qt::DotLine:
-			tmp += "["+Dt+" "+Sp+"] 0 d\n";
-			break;
-		case Qt::DashDotLine:
-			tmp += "["+Da+" "+Sp+" "+Dt+" "+Sp+"] 0 d\n";
-			break;
-		case Qt::DashDotDotLine:
-			tmp += "["+Da+" "+Sp+" "+Dt+" "+Sp+" "+Dt+" "+Sp+"] 0 d\n";
-			break;
-		default:
-			tmp += "[] 0 d\n";
-			break;
-		}
+	QString Ds = getDashString(sl->Dash, sl->Width);
+	tmp += Ds.isEmpty() ? "[] 0 d\n" : QString("[%1] 0 d\n").arg(Ds);
 	switch (static_cast<Qt::PenCapStyle>(sl->LineEnd))
 	{
 		case Qt::FlatCap:

Modified: branches/ScribusOIF/scribus/plugins/scriptplugin/cmdtext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/plugins/scriptplugin/cmdtext.cpp
==============================================================================
--- branches/ScribusOIF/scribus/plugins/scriptplugin/cmdtext.cpp (original)
+++ branches/ScribusOIF/scribus/plugins/scriptplugin/cmdtext.cpp Mon May 30 22:38:48 2011
@@ -263,7 +263,6 @@
 	Daten.replace(QChar('\n') , SpecialChars::PARSEP);
 	PyMem_Free(Text);
 	currItem->itemText.clear();
-	currItem->CPos = 0;
 	for (int a = 0; a < ScCore->primaryMainWindow()->doc->FrameItems.count(); ++a)
 	{
 		ScCore->primaryMainWindow()->doc->FrameItems.at(a)->ItemNr = a;
@@ -305,7 +304,6 @@
 	if (pos == -1)
 		pos = it->itemText.length();
 	it->itemText.insertChars(pos, Daten);
-	it->CPos = pos + Daten.length();
 	it->Dirty = true;
 	if (ScCore->primaryMainWindow()->doc->DoDrawing)
 	{
@@ -646,7 +644,6 @@
 	else
 	{
 		it->itemText.clear();
-		it->CPos = 0;
 		for (int a = 0; a < ScCore->primaryMainWindow()->doc->FrameItems.count(); ++a)
 		{
 			ScCore->primaryMainWindow()->doc->FrameItems.at(a)->ItemNr = a;

Modified: branches/ScribusOIF/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/scribus.cpp
==============================================================================
--- branches/ScribusOIF/scribus/scribus.cpp (original)
+++ branches/ScribusOIF/scribus/scribus.cpp Mon May 30 22:38:48 2011
@@ -1136,8 +1136,7 @@
 						if (currItem->HasSel && currItem->itemType()==PageItem::TextFrame)
 							currItem->asTextFrame()->deleteSelectedTextFromFrame();
 
-						currItem->itemText.insertChars(currItem->CPos, QString(QChar(unicodevalue)), true);
-						currItem->CPos += 1;
+						currItem->itemText.insertChars(QString(QChar(unicodevalue)), true);
 //						currItem->Tinput = true;
 						currItem->update();
 					}
@@ -1145,15 +1144,14 @@
 					{
 						// this code is currently dead since unicodeSoftHyphen
 						// doesnt have unicodevalue == -1 any more
-						if (currItem->CPos-1>0)
+						if (currItem->itemText.cursorPosition() > 1)
 						{
 #if 0
 							StyleFlag fl = currItem->itemText.item(qMax(currItem->CPos-1,0))->effects();
 							fl |= ScStyle_HyphenationPossible;
 							currItem->itemText.item(qMax(currItem->CPos-1,0))->setEffects(fl);
 #else
-							currItem->itemText.insertChars(currItem->CPos, QString(SpecialChars::SHYPHEN), true);
-							currItem->CPos += 1;
+							currItem->itemText.insertChars(QString(SpecialChars::SHYPHEN), true);
 #endif
 //							currItem->Tinput = true;
 							currItem->update();
@@ -4991,10 +4989,10 @@
 			if (currItem->HasSel)
 				currItem->deleteSelectedTextFromFrame();
 
-			if (currItem->CPos < 0)
+			/*if (currItem->CPos < 0)
 				currItem->CPos = 0;
 			if (currItem->CPos > currItem->itemText.length())
-				currItem->CPos = currItem->itemText.length();
+				currItem->CPos = currItem->itemText.length();*/
 
 			if (ScMimeData::clipboardHasScribusText())
 			{
@@ -5008,8 +5006,7 @@
 
 				StoryText* story = dig.result<StoryText>();
 
-				currItem->itemText.insert(currItem->CPos, *story);
-				currItem->CPos += story->length();
+				currItem->itemText.insert(*story);
 
 				delete story;
 			}
@@ -5082,8 +5079,7 @@
 				doc->maxCanvasCoordinate = maxSize;
 				if (outlinePalette->isVisible())
 					outlinePalette->BuildTree();
-				currItem->itemText.insertObject(currItem->CPos, currItem3);
-				currItem->CPos += 1;
+				currItem->itemText.insertObject(currItem3);
 				undoManager->setUndoEnabled(true);
 			}
 			else
@@ -5092,7 +5088,7 @@
 				QString text = QApplication::clipboard()->text(QClipboard::Clipboard);
 				text = text.replace("\r\n", SpecialChars::PARSEP);
 				text = text.replace('\n', SpecialChars::PARSEP);
-				currItem->itemText.insertChars(currItem->CPos, text, true);
+				currItem->itemText.insertChars(text, true);
 			}
 			currItem->update();
 		}
@@ -6378,7 +6374,7 @@
 //					return;
 //				}
 				setTBvals(currItem);
-				currItem->CPos = 0;
+				currItem->itemText.setCursorPosition(0);
 			}
 			scrActions["editPaste"]->setEnabled(false);
 			charPalette->setEnabled(true, currItem);
@@ -9422,7 +9418,7 @@
 {
 	PageItem *currItem = doc->m_Selection->itemAt(0);
 	view->requestMode(modeEdit);
-	currItem->CPos = 0;
+	currItem->itemText.setCursorPosition(0);
 	SearchReplace* dia = new SearchReplace(this, doc, currItem);
 	connect(dia, SIGNAL(NewFont(const QString&)), this, SLOT(SetNewFont(const QString&)));
 	connect(dia, SIGNAL(NewAbs(int)), this, SLOT(setAlignmentValue(int)));

Modified: branches/ScribusOIF/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/scribusdoc.cpp
==============================================================================
--- branches/ScribusOIF/scribus/scribusdoc.cpp (original)
+++ branches/ScribusOIF/scribus/scribusdoc.cpp Mon May 30 22:38:48 2011
@@ -6952,7 +6952,7 @@
 				start = currItem->itemText.startOfSelection();
 				stop = currItem->itemText.endOfSelection();
 				if (start >= stop)
-					start = stop = qMax(0, qMin(currItem->itemText.length(), currItem->CPos));
+					start = stop = qMax(0, qMin(currItem->itemText.length(), currItem->itemText.cursorPosition()));
 			}
 			for (int pos=start; pos < stop; ++pos)
 			{
@@ -7006,7 +7006,7 @@
 				start = currItem->itemText.startOfSelection();
 				stop = currItem->itemText.endOfSelection();
 				if (start >= stop)
-					start = stop = qMax(0, qMin(currItem->itemText.length(), currItem->CPos));
+					start = stop = qMax(0, qMin(currItem->itemText.length(), currItem->itemText.cursorPosition()));
 			}
 			for (int pos=start; pos < stop; ++pos)
 			{
@@ -7070,7 +7070,7 @@
 				start = currItem->itemText.startOfSelection();
 				stop = currItem->itemText.endOfSelection();
 				if (start >= stop)
-					start = stop = qMax(0, qMin(currItem->itemText.length(), currItem->CPos));
+					start = stop = qMax(0, qMin(currItem->itemText.length(), currItem->itemText.cursorPosition()));
 			}
 			for (int pos=start; pos < stop; ++pos)
 			{
@@ -7125,7 +7125,7 @@
 				}
 				else
 				{
-					start = qMax(currItem->firstInFrame(), currItem->CPos);
+					start = qMax(currItem->firstInFrame(), currItem->itemText.cursorPosition());
 					length = (start + 1) < currItem->itemText.length()? 1 : 0;
 				}
 			}
@@ -7184,7 +7184,7 @@
 				}
 				else
 				{
-					start = qMax(currItem->firstInFrame(), currItem->CPos);
+					start = qMax(currItem->firstInFrame(), currItem->itemText.cursorPosition());
 					length = (start + 1) < currItem->itemText.length()? 1 : 0;
 				}
 			}
@@ -7242,7 +7242,7 @@
 				}
 				else
 				{
-					start = qMax(currItem->firstInFrame(), currItem->CPos);
+					start = qMax(currItem->firstInFrame(), currItem->itemText.cursorPosition());
 					length = (start + 1) < currItem->itemText.length()? 1 : 0;
 				}
 			}
@@ -12562,38 +12562,43 @@
 void ScribusDoc::itemSelection_SplitItems(Selection* /*customSelection*/)
 {
 	PageItem *bb;
-	uint StartInd = 0;
 	m_Selection->delaySignalsOn();
-	PageItem *currItem = m_Selection->itemAt(0);
-	int currItemNr = currItem->ItemNr;
-	uint EndInd = currItem->PoLine.size();
-	for (uint a = EndInd-1; a > 0; --a)
-	{
-		if (currItem->PoLine.point(a).x() > 900000)
-		{
-			StartInd = a + 1;
-			bb = new PageItem_Polygon(*currItem);
-			currItemNr++;
-			Items->insert(currItemNr, bb);
-			bb->ItemNr = currItemNr;
-			bb->convertTo(PageItem::Polygon);
-			bb->Frame = false;
-			bb->FrameType = 3;
-			bb->PoLine.resize(0);
-			bb->PoLine.putPoints(0, EndInd - StartInd, currItem->PoLine, StartInd);
-			bb->setRotation(currItem->rotation());
-			AdjustItemSize(bb);
-			bb->ContourLine = bb->PoLine.copy();
-			bb->ClipEdited = true;
-			m_Selection->addItem(bb, false);
-			a -= 3;
-			EndInd = StartInd - 4;
-		}
-	}
-	currItem->PoLine.resize(StartInd-4);
-	AdjustItemSize(currItem);
-	currItem->ContourLine = currItem->PoLine.copy();
-	currItem->ClipEdited = true;
+	for (int i = 0; i < m_Selection->count(); ++i)
+	{
+		PageItem *currItem = m_Selection->itemAt(i);
+		if (!currItem->isPolygon() || currItem->Segments.count() <= 0)
+			continue;
+		uint StartInd = 0;
+		int currItemNr = currItem->ItemNr;
+		uint EndInd = currItem->PoLine.size();
+		for (uint a = EndInd-1; a > 0; --a)
+		{
+			if (currItem->PoLine.point(a).x() > 900000)
+			{
+				StartInd = a + 1;
+				bb = new PageItem_Polygon(*currItem);
+				currItemNr++;
+				Items->insert(currItemNr, bb);
+				bb->ItemNr = currItemNr;
+				bb->convertTo(PageItem::Polygon);
+				bb->Frame = false;
+				bb->FrameType = 3;
+				bb->PoLine.resize(0);
+				bb->PoLine.putPoints(0, EndInd - StartInd, currItem->PoLine, StartInd);
+				bb->setRotation(currItem->rotation());
+				AdjustItemSize(bb);
+				bb->ContourLine = bb->PoLine.copy();
+				bb->ClipEdited = true;
+				m_Selection->addItem(bb, false);
+				a -= 3;
+				EndInd = StartInd - 4;
+			}
+		}
+		currItem->PoLine.resize(StartInd-4);
+		AdjustItemSize(currItem);
+		currItem->ContourLine = currItem->PoLine.copy();
+		currItem->ClipEdited = true;
+	}
 	m_Selection->delaySignalsOff();
 	renumberItemsInListOrder();
 	//FIXME: stop using m_View

Modified: branches/ScribusOIF/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/scribusview.cpp
==============================================================================
--- branches/ScribusOIF/scribus/scribusview.cpp (original)
+++ branches/ScribusOIF/scribus/scribusview.cpp Mon May 30 22:38:48 2011
@@ -977,7 +977,7 @@
 						txt.replace(QRegExp("\r"), QChar(13));
 						txt.replace(QRegExp("\n"), QChar(13));
 						txt.replace(QRegExp("\t"), QChar(9));
-						b->itemText.insertChars(b->CPos, txt, true);
+						b->itemText.insertChars(txt, true);
 						if (Doc->docHyphenator->AutoCheck)
 							Doc->docHyphenator->slotHyphenate(b);
 						b->invalidateLayout();
@@ -1581,22 +1581,22 @@
 			if(currItem->reversed())
 			{ //handle Right to Left writing
 				FPoint point(currItem->width()-(pf.x() - currItem->xPos()), pf.y() - currItem->yPos());
-				currItem->CPos = currItem->itemText.length() == 0 ? 0 :
-					/*currItem->itemText.screenToPosition(point)*/ currItem->textLayout->screenToPosition(point);
+				currItem->itemText.setCursorPosition( currItem->itemText.length() == 0 ? 0 :
+					/*currItem->itemText.screenToPosition(point)*/ currItem->textLayout->screenToPosition(point) );
 			}
 			else
 			{
 				FPoint point(pf.x() - currItem->xPos(), pf.y() - currItem->yPos());
 				int screenToPos(currItem->textLayout->screenToPosition(point));
-				currItem->CPos = currItem->itemText.length() == 0 ? 0 :
-										    (screenToPos < 0 ? currItem->itemText.length() : screenToPos);
+				currItem->itemText.setCursorPosition( currItem->itemText.length() == 0 ? 0 :
+										    (screenToPos < 0 ? currItem->itemText.length() : screenToPos) );
 			}
 
 			if (currItem->itemText.length() > 0)
 			{
-				int b=qMin(currItem->CPos-1, currItem->itemText.length());
-				if (b<0)
-					b=0;
+				int b = qMin(currItem->itemText.cursorPosition()- 1, currItem->itemText.length());
+				if (b < 0)
+					b = 0;
 				Doc->currentStyle.charStyle() = currItem->itemText.charStyle(b);
 				emit ItemCharStyle(Doc->currentStyle.charStyle());
 				emit ItemTextEffects(Doc->currentStyle.charStyle().effects());

Modified: branches/ScribusOIF/scribus/styles/paragraphstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/styles/paragraphstyle.cpp
==============================================================================
--- branches/ScribusOIF/scribus/styles/paragraphstyle.cpp (original)
+++ branches/ScribusOIF/scribus/styles/paragraphstyle.cpp Mon May 30 22:38:48 2011
@@ -21,6 +21,11 @@
 #include "desaxe/simple_actions.h"
 #include "util_math.h"
 
+bool ParagraphStyle::TabRecord::operator==(const TabRecord& other) const
+{
+	return isequiv(tabPosition, other.tabPosition) && tabType==other.tabType && tabFillChar == other.tabFillChar;
+}
+
 ParagraphStyle::ParagraphStyle() : Style(), cstyleContext(NULL), cstyleContextIsInh(true), cstyle()
 {
 	setParent("");

Modified: branches/ScribusOIF/scribus/styles/paragraphstyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/styles/paragraphstyle.h
==============================================================================
--- branches/ScribusOIF/scribus/styles/paragraphstyle.h (original)
+++ branches/ScribusOIF/scribus/styles/paragraphstyle.h Mon May 30 22:38:48 2011
@@ -57,9 +57,7 @@
 		qreal tabPosition;
 		int tabType;
 		QChar tabFillChar;
-		bool operator==(const TabRecord& other) const {
-			return tabPosition==other.tabPosition && tabType==other.tabType && tabFillChar == other.tabFillChar;
-		}
+		bool operator==(const TabRecord& other) const;
 		bool operator<(const TabRecord& other)  const { return tabPosition < other.tabPosition; }
 		bool operator<=(const TabRecord& other) const { return tabPosition <= other.tabPosition; }
 		bool operator>(const TabRecord& other)  const { return tabPosition > other.tabPosition; }

Modified: branches/ScribusOIF/scribus/text/sctext_shared.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/text/sctext_shared.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/sctext_shared.cpp (original)
+++ branches/ScribusOIF/scribus/text/sctext_shared.cpp Mon May 30 22:38:48 2011
@@ -12,7 +12,7 @@
 ScText_Shared::ScText_Shared(const StyleContext* pstyles) : QList<ScText*>(), 
 	defaultStyle(), 
 	pstyleContext(NULL),
-	refs(1), len(0), trailingStyle()
+	refs(1), len(0), cursorPosition(0), trailingStyle()
 {
 	pstyleContext.setDefaultStyle( & defaultStyle );
 	defaultStyle.setContext( pstyles );
@@ -25,7 +25,8 @@
 ScText_Shared::ScText_Shared(const ScText_Shared& other) : QList<ScText*>(), 
 	defaultStyle(other.defaultStyle), 
 	pstyleContext(other.pstyleContext),
-	refs(1), len(0), trailingStyle(other.trailingStyle)
+	refs(1), len(0), cursorPosition(other.cursorPosition),
+	trailingStyle(other.trailingStyle)
 {
 	pstyleContext.setDefaultStyle( &defaultStyle );
 	trailingStyle.setContext( &pstyleContext );
@@ -51,15 +52,17 @@
 	while(!this->isEmpty())
 		delete this->takeFirst(); 
 	QList<ScText*>::clear();
+	cursorPosition = 0;
 }
 
 ScText_Shared& ScText_Shared::operator= (const ScText_Shared& other) 
 {
 	if (this != &other) 
 	{
-		defaultStyle = other.defaultStyle;
-		trailingStyle = other.trailingStyle;
-		pstyleContext = other.pstyleContext;
+		cursorPosition = other.cursorPosition;
+		defaultStyle   = other.defaultStyle;
+		trailingStyle  = other.trailingStyle;
+		pstyleContext  = other.pstyleContext;
 		pstyleContext.setDefaultStyle( &defaultStyle );
 		defaultStyle.setContext( other.defaultStyle.context() );
 		trailingStyle.setContext( &pstyleContext );

Modified: branches/ScribusOIF/scribus/text/sctext_shared.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/text/sctext_shared.h
==============================================================================
--- branches/ScribusOIF/scribus/text/sctext_shared.h (original)
+++ branches/ScribusOIF/scribus/text/sctext_shared.h Mon May 30 22:38:48 2011
@@ -21,6 +21,7 @@
 	StyleContextProxy pstyleContext;
 	uint refs;
 	uint len;
+	uint  cursorPosition;
 	ParagraphStyle trailingStyle;
 	ScText_Shared(const StyleContext* pstyles);	
 

Modified: branches/ScribusOIF/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/text/storytext.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/storytext.cpp (original)
+++ branches/ScribusOIF/scribus/text/storytext.cpp Mon May 30 22:38:48 2011
@@ -126,6 +126,10 @@
 	invalidateAll();
 }
 
+void StoryText::insert(const StoryText& other, bool onlySelection)
+{
+	insert(data->cursorPosition(), other, onlySelection);
+}
 
 void StoryText::insert(int pos, const StoryText& other, bool onlySelection)
 {
@@ -273,6 +277,7 @@
 		// consistent in functions such as select()
 		if (i <= selLast) --selLast;
 		if (i < selFirst) --selFirst;
+		if ((i + 1 )<= d->cursorPosition && d->cursorPosition > 0) d->cursorPosition -= 1;
 	}
 */
 	if (selFirst > selLast)
@@ -281,6 +286,11 @@
 		selLast  = -1;
 	}
 	invalidate(pos, length());
+}
+
+void StoryText::insertChars(QString txt, bool applyNeighbourStyle) //, const CharStyle & charstyle)
+{
+	insertChars(data->cursorPosition(), txt, applyNeighbourStyle);
 }
 
 void StoryText::insertChars(int pos, QString txt, bool applyNeighbourStyle) //, const CharStyle & charstyle)
@@ -317,6 +327,9 @@
 		if (item->ch == SpecialChars::PARSEP) {
 //			qDebug() << QString("new PARSEP %2 at %1").arg(pos).arg(paragraphStyle(pos).name());
 			insertParSep(pos + i);
+		}
+		if (d->cursorPosition >= (pos + i)) {
+			d->cursorPosition += 1;
 		}
 	}
 
@@ -377,6 +390,9 @@
 			if (item->ch == SpecialChars::PARSEP) {
 				insertParSep(index);
 			}
+			if (d->cursorPosition >= index) {
+				d->cursorPosition += 1;
+			}
 			++inserted;
 		}
 	}
@@ -409,6 +425,16 @@
 	invalidate(pos, pos + 1);
 }
 
+int StoryText::cursorPosition() const
+{
+	return data->cursorPosition();
+}
+
+void StoryText::setCursorPosition(int pos, bool relative)
+{
+	data->setCursorPosition(pos, relative);
+}
+
 void StoryText::hyphenateWord(int pos, uint len, char* hyphens, bool doUpdate)
 {
 	assert(pos >= 0);
@@ -437,6 +463,11 @@
 	doc->docHyphenator->slotHyphenateWord(this, str, pos, false);
 }
 
+void StoryText::insertObject(PageItem* ob)
+{
+	insertObject(data->cursorPosition(), ob);
+}
+
 void StoryText::insertObject(int pos, PageItem* ob)
 {
 	if (pos < 0)
@@ -450,6 +481,11 @@
 int StoryText::length() const
 {
 	return data->length();
+}
+
+QChar StoryText::text() const
+{
+	return text(data->cursorPosition());
 }
 
 QChar StoryText::text(int pos) const
@@ -531,6 +567,10 @@
 	return data->object(pos);
 }
 
+const CharStyle & StoryText::charStyle() const
+{
+	return charStyle(data->cursorPosition());
+}
 
 const CharStyle & StoryText::charStyle(int pos) const
 {
@@ -710,6 +750,10 @@
 	replaceNamedResources(newnames);
 }
 
+uint StoryText::nrOfParagraph() const
+{
+	return nrOfParagraph(data->cursorPosition());
+}
 
 uint StoryText::nrOfParagraphs() const
 {
@@ -721,9 +765,19 @@
 	return data->nrOfParagraph(pos);
 }
 
+int StoryText::startOfParagraph() const
+{
+	return startOfParagraph(nrOfParagraph());
+}
+
 int StoryText::startOfParagraph(uint index) const
 {
 	return data->startOfParagraph(index);
+}
+
+int StoryText::endOfParagraph() const
+{
+	return endOfParagraph(nrOfParagraph());
 }
 
 int StoryText::endOfParagraph(uint index) const

Modified: branches/ScribusOIF/scribus/text/storytext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/text/storytext.h
==============================================================================
--- branches/ScribusOIF/scribus/text/storytext.h (original)
+++ branches/ScribusOIF/scribus/text/storytext.h Mon May 30 22:38:48 2011
@@ -100,18 +100,25 @@
 	
  	void clear();
 	StoryText copy() const;
+	void insert(const StoryText& other, bool onlySelection = false);
 	void insert(int pos, const StoryText& other, bool onlySelection = false);
 	void append(const StoryText& other) { insert(length(), other, false); }
  	void removeChars(int pos, uint len);
+	void insertChars(QString txt, bool applyNeighbourStyle = false);
  	void insertChars(int pos, QString txt, bool applyNeighbourStyle = false);
+	void insertObject(PageItem* obj);
  	void insertObject(int pos, PageItem* obj);
  	void replaceChar(int pos, QChar ch);
 
+	int  cursorPosition() const;
+	void setCursorPosition(int pos, bool relative = false);
+
 	void hyphenateWord(int pos, uint len, char* hyphens, bool doUpdate = true);
 	void selfHyphenateWord(int pos, uint len);
 	
  	virtual int length() const;
- 	virtual QChar text(int pos) const;
+	virtual QChar   text() const;
+ 	virtual QChar   text(int pos) const;
  	virtual QString text(int pos, uint len) const;
 	virtual QString wordAt(int pos) const;
 	virtual TextFlags& charAttributes(int pos);
@@ -129,6 +136,7 @@
 	int nextFramePos(int c);
 	int prevFramePos(int c);*/
 	
+	const CharStyle& charStyle() const;
  	const CharStyle& charStyle(int pos) const;
  	virtual const ParagraphStyle& paragraphStyle(int pos) const;
  	const ParagraphStyle& defaultStyle() const;
@@ -146,9 +154,12 @@
 	void replaceNamedResources(ResourceCollection& newNames);
 	
  	uint nrOfParagraphs() const;
+	uint nrOfParagraph() const;
 	uint nrOfParagraph(int pos) const;
- 	int startOfParagraph(uint index) const;
- 	int endOfParagraph(uint index) const;
+	int  startOfParagraph() const;
+ 	int  startOfParagraph(uint index) const;
+	int  endOfParagraph() const;
+ 	int  endOfParagraph(uint index) const;
 
  	uint nrOfRuns() const;
  	int startOfRun(uint index) const;

Modified: branches/ScribusOIF/scribus/text/storytext_shared.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/text/storytext_shared.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/storytext_shared.cpp (original)
+++ branches/ScribusOIF/scribus/text/storytext_shared.cpp Mon May 30 22:38:48 2011
@@ -88,6 +88,21 @@
 	}
 	//FIXME: update stuff assert(0);
 }
+
+
+int  Storytext_Shared::cursorPosition()
+{
+	return this->cursorPos;
+}
+
+
+void Storytext_Shared::setCursorPosition(int pos, bool relative)
+{
+	if (relative)
+		pos += this->cursorPos;
+	this->cursorPos = qMin(qMax(pos, 0), this->length());
+}
+
 
 int Storytext_Shared::length() const
 {
@@ -318,6 +333,11 @@
 	{
 		if (text(i) == SpecialChars::PARSEP)
 			splitPar(i, false);
+	}
+
+	if (this->cursorPos >= pos)
+	{
+		this->cursorPos = qMax(pos, this->cursorPos - (int) len)+ txt.length();
 	}
 }
 
@@ -589,6 +609,9 @@
 	par.text.insert(pos - pars.offset(idx), ch);
 	par.charAttr.insert(pos, 1, 0);
 	adjust(pos, 1);
+
+	if (cursorPos >= pos)
+		cursorPos += 1;
 }
 
 void Storytext_Shared::removeChar(int pos)
@@ -599,6 +622,9 @@
 	par.text.remove(pos - pars.offset(idx), 1);
 	par.charAttr.remove(pos);
 	adjust(pos, -1);
+
+	if (cursorPos >= (pos + 1) && cursorPos > 0)
+		cursorPos -= 1;
 }
 
 

Modified: branches/ScribusOIF/scribus/text/storytext_shared.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/text/storytext_shared.h
==============================================================================
--- branches/ScribusOIF/scribus/text/storytext_shared.h (original)
+++ branches/ScribusOIF/scribus/text/storytext_shared.h Mon May 30 22:38:48 2011
@@ -81,7 +81,8 @@
 	QList<InlineFrame> objects;
 	
 	QList<TextChange*> undoList;
-	
+
+	int cursorPos;
 
 public:
 	Storytext_Shared();
@@ -90,10 +91,11 @@
 	ScribusDoc* document() const;
 	void setDocument(ScribusDoc* doc);
 	
+	int  cursorPosition();
+	void setCursorPosition(int pos, bool relative = false);
 		
 	void clear(int start = 0, int end = -1);
 	void insert(int pos, const Storytext_Shared& other, int start = 0, int end = -1);
-	
 	
  	int length() const;
  	QChar text(int pos) const;

Modified: branches/ScribusOIF/scribus/ui/about.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/ui/about.cpp
==============================================================================
--- branches/ScribusOIF/scribus/ui/about.cpp (original)
+++ branches/ScribusOIF/scribus/ui/about.cpp Mon May 30 22:38:48 2011
@@ -112,8 +112,8 @@
 	buildID = new QLabel( tab );
 	buildID->setAlignment(Qt::AlignCenter);
 	buildID->setTextInteractionFlags(Qt::TextSelectableByMouse);
-	QString BUILD_DAY = "30";
-	QString BUILD_MONTH = CommonStrings::april;
+	QString BUILD_DAY = "23";
+	QString BUILD_MONTH = CommonStrings::may;
 	QString BUILD_YEAR = "2011";
 	QString BUILD_TIME = "";
 	QString BUILD_TZ = "";

Modified: branches/ScribusOIF/scribus/ui/charselect.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/ui/charselect.cpp
==============================================================================
--- branches/ScribusOIF/scribus/ui/charselect.cpp (original)
+++ branches/ScribusOIF/scribus/ui/charselect.cpp Mon May 30 22:38:48 2011
@@ -123,8 +123,7 @@
 			ch = QChar(13);
 		if (ch == QChar(9))
 			ch = QChar(32);
-		m_Item->itemText.insertChars(m_Item->CPos, ch, true);
-		m_Item->CPos += 1;
+		m_Item->itemText.insertChars(ch, true);
 	}
 	m_doc->updateFrameItems();
 	m_doc->view()->DrawNew();
@@ -145,9 +144,8 @@
 		ch = QChar(13);
 	if (ch == QChar(9))
 		ch = QChar(32);
-	m_Item->itemText.insertChars(m_Item->CPos, ch, true);
+	m_Item->itemText.insertChars(ch, true);
 	m_doc->updateFrameItems();
-	m_Item->CPos += 1;
 	m_doc->view()->DrawNew();
 	m_doc->changed();
 }

Modified: branches/ScribusOIF/scribus/ui/search.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/ui/search.cpp
==============================================================================
--- branches/ScribusOIF/scribus/ui/search.cpp (original)
+++ branches/ScribusOIF/scribus/ui/search.cpp Mon May 30 22:38:48 2011
@@ -397,7 +397,7 @@
 	if (sText.length() > 0)
 		found = false;
 	int inde = 0;
-	uint as = Item->CPos;
+	uint as = Item->itemText.cursorPosition();
 	ReplStart = as;
 	int a;
 	if (SMode)
@@ -466,7 +466,7 @@
 					DoReplace->setEnabled(true);
 					AllReplace->setEnabled(true);
 				}
-				Item->CPos = a+1;
+				Item->itemText.setCursorPosition(a + 1);
 				if (SText->isChecked())
 				{
 					if (inde == 0)
@@ -513,7 +513,7 @@
 			DoReplace->setEnabled(false);
 			AllReplace->setEnabled(false);
 			QMessageBox::information(this, tr("Search/Replace"), tr("Search finished"), CommonStrings::tr_OK);
-			Item->CPos = 0;
+			Item->itemText.setCursorPosition(0);
 			NotFound = false;
 		}
 	}
@@ -657,14 +657,14 @@
 					for (cx = cs; cx < repl.length(); ++cx)
 						Item->itemText.insertChars(ReplStart+cx, repl.mid(cx,1), true); 
 					// FIXME:NLS also replace styles!!
-					Item->CPos = ReplStart+cx;
+					Item->itemText.setCursorPosition(ReplStart + cx);
 				}
 				else
 				{
 					for (cs = 0; cs < repl.length(); ++cs)
 						Item->itemText.replaceChar(ReplStart+cs, repl[cs]);
 					Item->itemText.removeChars(ReplStart+cs, sear.length() - cs);
-					Item->CPos = ReplStart+cs;
+					Item->itemText.setCursorPosition(ReplStart + cs);
 				}
 			}
 		}

Modified: branches/ScribusOIF/scribus/ui/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16636&path=/branches/ScribusOIF/scribus/ui/storyeditor.cpp
==============================================================================
--- branches/ScribusOIF/scribus/ui/storyeditor.cpp (original)
+++ branches/ScribusOIF/scribus/ui/storyeditor.cpp Mon May 30 22:38:48 2011
@@ -569,7 +569,6 @@
 
 void SEditor::saveItemText(PageItem *currItem)
 {
-	currItem->CPos = 0;
 	currItem->itemText.clear();
 	currItem->itemText.setDefaultStyle(StyledText.defaultStyle());
 	currItem->itemText.append(StyledText);
@@ -635,10 +634,10 @@
 	int npars = currItem->itemText.nrOfParagraphs();
 	SelParaStart = 0;
 	while (SelParaStart < npars
-		   && currItem->CPos >= (SelCharStart = currItem->itemText.endOfParagraph(SelParaStart)))
+		   && currItem->itemText.cursorPosition() >= (SelCharStart = currItem->itemText.endOfParagraph(SelParaStart)))
 		++SelParaStart;
-	if (currItem->CPos < SelCharStart)
-		SelCharStart = currItem->CPos;
+	if (currItem->itemText.cursorPosition() < SelCharStart)
+		SelCharStart = currItem->itemText.cursorPosition();
 	SelCharStart -= currItem->itemText.startOfParagraph(SelParaStart);
 	StoredSel = false;
 	//qDebug() << "SE::loadItemText: cursor";




More information about the scribus-commit mailing list