Index: Scribus/scribus/pageitem.h
===================================================================
--- Scribus/scribus/pageitem.h	(wersja 15999)
+++ Scribus/scribus/pageitem.h	(kopia robocza)
@@ -1060,6 +1060,8 @@
 
 	void restoreShapeContour(UndoState *state, bool isUndo);
 	void restoreImageEffects(UndoState *state, bool isUndo);
+	void restoreEditText(SimpleState *state, bool isUndo);
+
 	/*@}*/
 
 	/**

Index: Scribus/scribus/pageitem.cpp
===================================================================
--- Scribus/scribus/pageitem.cpp	(wersja 15999)
+++ Scribus/scribus/pageitem.cpp	(kopia robocza)
@@ -60,6 +60,7 @@
 #include "scribusstructs.h"
 #include "scribuswin.h"
 #include "sctextstream.h"
+#include "serializer.h"
 #include "selection.h"
 #include "sclimits.h"
 #include "text/nlsconfig.h"
@@ -3209,6 +3210,9 @@
                        restoreShapeContour(ss, isUndo);
                else if (ss->contains("APPLY_IMAGE_EFFECTS"))
                        restoreImageEffects(ss, isUndo);
+		else if (ss->contains("STEXT"))
+			restoreEditText(ss, isUndo);
+
        }
        if (!OnMasterPage.isEmpty())
                m_Doc->setCurrentPage(oldCurrentPage);
@@ -3707,6 +3711,31 @@
        }
 }

+void PageItem::restoreEditText(SimpleState *state, bool isUndo)
+{
+	qDebug() << "EditText " << itemName() << "Undo " << isUndo;
+	if (!this->isTextFrame())
+		return;
+
+	if (isUndo)
+	{
+		QString buffer;
+		buffer.append(state->get("STEXT"));
+
+		Serializer dig(*m_Doc);
+		dig.store<ScribusDoc>("<scribusdoc>", m_Doc);
+		StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
+		dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
+qDebug() << buffer.toStdString().c_str();
+		dig.parseMemory(buffer.toStdString().c_str(), buffer.length());
+		StoryText* story = dig.result<StoryText>();
+		this->itemText.clear();
+		this->itemText.append(*story);
+		delete story;
+		invalidateLayout();
+	}
+}
+
 void PageItem::select()
 {
        m_Doc->view()->Deselect(false);
Index: Scribus/scribus/pageitem_textframe.cpp
===================================================================
--- Scribus/scribus/pageitem_textframe.cpp	(wersja 15812)
+++ Scribus/scribus/pageitem_textframe.cpp	(kopia robocza)
@@ -30,7 +30,11 @@
 #include <QRegion>
 #include <cassert>
 
+#include <iostream>
+#include <sstream>
+#include <string>
 
+
 #include "canvas.h"
 #include "commonstrings.h"
 #include "guidemanager.h"
@@ -45,7 +49,11 @@
 #include "scraction.h"
 #include "scribus.h"
 #include "scribusdoc.h"
+#include "scribusview.h"
 #include "scribusstructs.h"
+#include "scribusXml.h"
+#include "desaxe/saxXML.h"
+#include "serializer.h"
 #include "selection.h"
 #include "text/nlsconfig.h"
 #include "undomanager.h"
@@ -3555,4 +3563,23 @@
 void PageItem_TextFrame::slotInvalidateLayout()
 {
 	invalidateLayout();
+	if (UndoManager::undoEnabled())
+	{
+		StoryText iT(m_Doc);
+		iT.setDefaultStyle(itemText.defaultStyle());
+		iT.insert(0, itemText, false);
+
+		std::ostringstream xmlString;
+		SaxXML xmlStream(xmlString);
+		xmlStream.beginDoc();
+		iT.saxx(xmlStream, "SCRIBUSTEXT");
+		xmlStream.endDoc();
+		std::string xml(xmlString.str());
+
+		SimpleState* ss = new SimpleState(UndoManager::EditText);
+		ss->set("STEXT", QString(xml.c_str()));
+		ss->set("STEXT_LEN", int(xml.length()));
+		undoManager->action(this, ss);
+		setUName(itemName()); // set the name for the UndoObject too
+	}
 }
Index: Scribus/scribus/undomanager.cpp
===================================================================
--- Scribus/scribus/undomanager.cpp	(wersja 15812)
+++ Scribus/scribus/undomanager.cpp	(kopia robocza)
@@ -958,6 +958,7 @@
 	UndoManager::Copy               = tr("Copy");
 	UndoManager::CopyPage           = tr("Copy page");
 	UndoManager::ToOutlines         = tr("Convert to outlines");
+	UndoManager::EditText		= tr("Edit text");
 }
 
 void UndoManager::initIcons()
@@ -1158,6 +1159,7 @@
 QString UndoManager::Copy               = "";
 QString UndoManager::CopyPage           = "";
 QString UndoManager::ToOutlines         = "";
+QString UndoManager::EditText		 = "";
 
 /*** Icons for UndoObjects *******************************************/
 QPixmap *UndoManager::IImageFrame      = 0;
Index: Scribus/scribus/undomanager.h
===================================================================
--- Scribus/scribus/undomanager.h	(wersja 15812)
+++ Scribus/scribus/undomanager.h	(kopia robocza)
@@ -585,6 +585,7 @@
 	static QString Copy;
 	static QString CopyPage;
 	static QString ToOutlines;
+	static QString EditText;
 	/*@}*/
 
 	/**
