r16702 by jghali - #9894: Undoing reversing write direction

scribus-commit scribus-commit at lists.scribus.net
Sat Jul 2 22:14:02 UTC 2011


Author: jghali
Date: Sat Jul  2 22:14:02 2011
New Revision: 16702

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16702
Log:
#9894: Undoing reversing write direction

Modified:
    branches/Version135/Scribus/scribus/pageitem.cpp
    branches/Version135/Scribus/scribus/pageitem.h
    branches/Version135/Scribus/scribus/scribusdoc.cpp

Modified: branches/Version135/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16702&path=/branches/Version135/Scribus/scribus/pageitem.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/pageitem.cpp (original)
+++ branches/Version135/Scribus/scribus/pageitem.cpp Sat Jul  2 22:14:02 2011
@@ -693,23 +693,25 @@
 {
 	if (dX==0.0 && dY==0.0)
 		return;
-	if (dX!=0.0)
-		LocalX+=dX;
-	if (dY!=0.0)
-		LocalY+=dY;
+	if (dX != 0.0)
+		LocalX += dX;
+	if (dY != 0.0)
+		LocalY += dY;
 	checkChanges();
 	emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
 }
 
 void PageItem::setReversed(bool newReversed)
 {
+	if (Reverse == newReversed)
+		return;
 	if (UndoManager::undoEnabled())
 	{
 		SimpleState *ss = new SimpleState(Um::FlipH, 0, Um::IFlipH);
-		ss->set("REVERSE_TEXT", "REVERSE_TEXT");
+		ss->set("REVERSE_TEXT", newReversed);
 		undoManager->action(this, ss);
 	}
-	Reverse=newReversed;
+	Reverse = newReversed;
 }
 
 //return frame where is text end
@@ -3300,7 +3302,9 @@
 		else if (ss->contains("LINK_TEXT_FRAME"))
 			restoreLinkTextFrame(ss,isUndo);
 		else if (ss->contains("UNLINK_TEXT_FRAME"))
-			restoreUnlinkTextFrame(ss,isUndo);
+			restoreUnlinkTextFrame(ss, isUndo);
+		else if (ss->contains("REVERSE_TEXT"))
+			restoreReverseText(ss, isUndo);
 	}
 	if (!OnMasterPage.isEmpty())
 		m_Doc->setCurrentPage(oldCurrentPage);
@@ -3716,6 +3720,12 @@
 	}
 }
 
+void PageItem::restoreReverseText(UndoState *state, bool /*isUndo*/)
+{
+	if (!isTextFrame())
+		return;
+	Reverse = !Reverse;
+}
 
 void PageItem::restorePoly(SimpleState *state, bool isUndo, bool isContour)
 {

Modified: branches/Version135/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16702&path=/branches/Version135/Scribus/scribus/pageitem.h
==============================================================================
--- branches/Version135/Scribus/scribus/pageitem.h (original)
+++ branches/Version135/Scribus/scribus/pageitem.h Sat Jul  2 22:14:02 2011
@@ -1095,6 +1095,7 @@
 	void restoreEditText(SimpleState *state, bool isUndo);
 	void restoreLinkTextFrame(UndoState *state, bool isUndo);
 	void restoreUnlinkTextFrame(UndoState *state, bool isUndo);
+	void restoreReverseText(UndoState *state, bool isUndo);
 	/*@}*/
 
 	/**

Modified: branches/Version135/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16702&path=/branches/Version135/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/scribusdoc.cpp (original)
+++ branches/Version135/Scribus/scribus/scribusdoc.cpp Sat Jul  2 22:14:02 2011
@@ -7708,14 +7708,27 @@
 
 void ScribusDoc::itemSelection_SetItemTextReversed(bool reversed)
 {
-	uint selectedItemCount=m_Selection->count();
+	uint selectedItemCount = m_Selection->count();
 	if (selectedItemCount != 0)
 	{
+		UndoTransaction *activeTransaction = NULL;
+		if (UndoManager::undoEnabled())
+			activeTransaction = new UndoTransaction(undoManager->beginTransaction());
 		for (uint i = 0; i < selectedItemCount; ++i)
 		{
 			PageItem *currItem = m_Selection->itemAt(i);
 			currItem->setImageFlippedH(reversed);
 			currItem->setReversed(reversed);
+		}
+		if (activeTransaction)
+		{
+			activeTransaction->commit(Um::Selection,
+									  Um::IGroup,
+									  Um::FlipH,
+									  0,
+									  Um::IFlipH);
+			delete activeTransaction;
+			activeTransaction = NULL;
 		}
 		regionsChanged()->update(QRectF());
 		changed();




More information about the scribus-commit mailing list