Index: Scribus/scribus/pageitem.cpp
===================================================================
--- Scribus/scribus/pageitem.cpp	(wersja 16536)
+++ Scribus/scribus/pageitem.cpp	(kopia robocza)
@@ -3847,7 +3847,7 @@
        itemText.deselectAll();
        HasSel = false;
        EditAct action = (EditAct) state->getInt("STEXT");
-	if (action == PARAMFULL || action == PARAMSEL)
+	if (action == STORY || action == PARAGRAPH || action == SELECTION)
        {
                QString buffer;
                if (isUndo)
@@ -3862,29 +3862,30 @@
                        dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
                        dig.parseMemory(buffer.toStdString().c_str(), buffer.length());
                        StoryText* story = dig.result<StoryText>();
-			if (action == PARAMFULL)
+			if (action == STORY)
                        {
                                itemText.selectAll();
                                itemText.clear();
                                itemText.append(*story);
+				CPos = 0;
                        }
-			else if (action == PARAMSEL)
+			else if (action == PARAGRAPH || action == SELECTION)
                        {
-				itemText.deselectAll();
                                int SelStart = state->getInt("STEXT_SELSTART");
-				itemText.select(SelStart,state->getInt("STEXT_SELLEN"));
+				int SelLen = state->getInt("STEXT_SELLEN");
+				itemText.select(SelStart,SelLen);
+				if (action == PARAGRAPH)
+					asTextFrame()->expandParaSelection();
                                asTextFrame()->deleteSelectedTextFromFrame();
-				int ItemLength = itemText.length();
                                itemText.insert(SelStart, *story);
+				int ItemLength = itemText.length();
                                // If we have inserted at end of text we have to restore trailing style
                                if (ItemLength == SelStart && story->length() > 0 && story->text(-1) != SpecialChars::PARSEP)
-				{
-					itemText.setStyle(-1, story->paragraphStyle(story->length()));
-				}
+				    itemText.setStyle(-1, story->paragraphStyle(story->length()));
                                itemText.select(SelStart, story->length());
                                HasSel = true;
+				CPos = state->getInt("STEXT_CPOS");
                        }
-			CPos = itemText.endOfSelection();
                        delete story;
                }
                else { qDebug() << "UNDO buffer EMPTY";}
@@ -3967,55 +3968,52 @@
                }
        }
        // after Undo or Redo new actions should create new undoStates
-	asTextFrame()->lastUndoAction = NOACTION;
+	asTextFrame()->clearLastUndoAction();

        m_Doc->scMW()->setTBvals(this);
        update();
 }

-QString PageItem::getItemTextSaxed(EditActPlace undoItem)
+QString PageItem::getItemTextSaxed(EditAct action)
 {
        if (!isTextFrame()) return "";
        StoryText iT(m_Doc);
        iT.setDefaultStyle(itemText.defaultStyle());
-	if (undoItem == FRAME)
-		iT.insert(0, itemText);
+	int oldSelStart = CPos, oldSelLen = 0;
+	if (action == STORY)
+		HasSel = false;
        else
        {
-		int StartOldSel = -1, LenOldSel = -1;
-		if (undoItem == PARAGRAPH)
+		if (HasSel)
                {
-			LenOldSel = 0;
-			if (HasSel)
+			oldSelStart = itemText.startOfSelection();
+			oldSelLen = itemText.lengthOfSelection();
+		}
+		if (action == PARAGRAPH)
+			asTextFrame()->expandParaSelection();
+		else if (action == SELECTION && !HasSel)
+		{
+			//case when there was not any selection, action was not paragraph related
+			// so changes will be applied for one char on right of cursor position
+			//if cursor is not at the end of paragraph or text
+			if (CPos >= itemText.length()
+			        || itemText.text(CPos) == SpecialChars::PARSEP
+			        || itemText.text(CPos) == SpecialChars::COLBREAK
+			        || itemText.text(CPos) == SpecialChars::FRAMEBREAK
+			        || itemText.text(CPos) == SpecialChars::LINEBREAK
+			        || itemText.text(CPos) == SpecialChars::OBJECT
+			        || itemText.text(CPos) == SpecialChars::SHYPHEN)
+				return "";
+			else
                        {
-				StartOldSel = itemText.startOfSelection();
-				LenOldSel = itemText.lengthOfSelection();
+				itemText.select(CPos, 1);
+				HasSel = true;
                        }
-			asTextFrame()->expandParaSelection(true);
                }
-		else if (undoItem == CHAR || (undoItem == SELECTION && !HasSel))
-		{
-			LenOldSel = itemText.lengthOfSelection();
-			if (LenOldSel > 0)
-				StartOldSel = itemText.startOfSelection();
-			if (CPos >= itemText.length())
-				return  "";
-			itemText.select(CPos,1);
-			HasSel = true;
-		}
-		//is SELECTION
-		iT.insert(0, itemText, HasSel);
-		if (LenOldSel > 0) //restoring old selection if undoItem was PARAPGRAPH
-		{
-			itemText.select(StartOldSel, LenOldSel);
-			HasSel = true;
-		}
-		else if (LenOldSel == 0)
-		{
-			itemText.deselectAll();
-			HasSel = false;
-		}
        }
+	iT.insert(0, itemText, HasSel);
+	asTextFrame()->restoreTextSelection(oldSelStart, oldSelLen);
+
        //saxing text
        std::ostringstream xmlString;
        SaxXML xmlStream(xmlString);
@@ -4079,7 +4077,7 @@
 void PageItem::select()
 {
        if (m_Doc->m_Selection->count() == 1 && m_Doc->m_Selection->itemAt()->isTextFrame())
-		m_Doc->m_Selection->itemAt()->asTextFrame()->lastUndoAction = PageItem::NOACTION;
+		m_Doc->m_Selection->itemAt()->asTextFrame()->clearLastUndoAction();
        m_Doc->view()->Deselect(false);
        //CB #2969 add this true parm to addItem so we dont connectToGUI, the rest of view->SelectItem isnt needed anyway
        m_Doc->m_Selection->addItem(this, true);
Index: Scribus/scribus/pageitem_textframe.cpp
===================================================================
--- Scribus/scribus/pageitem_textframe.cpp	(wersja 16536)
+++ Scribus/scribus/pageitem_textframe.cpp	(kopia robocza)
@@ -30,7 +30,7 @@
 #include <QRegion>
 #include <cassert>

-
+#include "actionmanager.h"
 #include "canvas.h"
 #include "commonstrings.h"
 #include "guidemanager.h"
@@ -70,7 +70,6 @@
        unicodeInputCount = 0;
        unicodeInputString = "";
        lastUndoAction = NOACTION;
-//	lastAction4Paragraph = false;

        connect(&itemText,SIGNAL(changed()), this, SLOT(slotInvalidateLayout()));
 }
@@ -83,7 +82,6 @@
        unicodeInputCount = 0;
        unicodeInputString = "";
        lastUndoAction = NOACTION;
-//	lastAction4Paragraph = false;

        connect(&itemText,SIGNAL(changed()), this, SLOT(slotInvalidateLayout()));
 }
@@ -2659,11 +2657,11 @@
        PageItem *nextItem = this;
        while (nextItem->prevInChain() != 0)
                nextItem = nextItem->prevInChain();
-	nextItem->itemTextSaxed = nextItem->getItemTextSaxed(PageItem::FRAME); //for undo
+	nextItem->itemTextSaxed = nextItem->getItemTextSaxed(PageItem::STORY); //for undo
        ParagraphStyle defaultStyle = nextItem->itemText.defaultStyle();
        nextItem->itemText.clear();
        nextItem->itemText.setDefaultStyle(defaultStyle);
-	nextItem->asTextFrame()->updateUndo(); //for undo
+	nextItem->asTextFrame()->updateUndo(PageItem::STORY); //for undo
        while (nextItem != 0)
        {
                nextItem->CPos = 0;
@@ -2716,7 +2714,7 @@
        case Qt::Key_Down:
                if ( (buttonModifiers & Qt::ShiftModifier) == 0 )
                        deselectAll();
-		lastUndoAction = PageItem::NOACTION;
+		clearLastUndoAction();
        }

        if (unicodeTextEditMode)
@@ -2745,15 +2743,12 @@
                                {
                                        itemTextSaxed = getItemTextSaxed(PageItem::SELECTION);
                                        deleteSelectedTextFromFrame();
-					lastUndoAction = PageItem::NOACTION;
+					clearLastUndoAction();
                                }
                                if (conv < 31)
                                        conv = 32;
                                if (conv == 32)
-				{
-					qDebug() << "SPACE conv?";
-					lastUndoAction = PageItem::NOACTION;
-				}
+					clearLastUndoAction();
                                oldCPos = CPos;
                                itemText.insertChars(CPos, QString(QChar(conv)), true);
                                CPos += 1;
@@ -3130,7 +3125,7 @@
                                oldCPos = itemText.startOfSelection();
                                itemTextSaxed = getItemTextSaxed(PageItem::SELECTION);
                                deleteSelectedTextFromFrame();
-				lastUndoAction = PageItem::NOACTION;
+				clearLastUndoAction();
                                doUpdate = true;
                        }
                        /*
@@ -3149,7 +3144,7 @@
                        oldCPos = CPos;
                        itemText.insertChars(CPos, QString(SpecialChars::TAB), true);
                        CPos += 1;
-			lastUndoAction = PageItem::NOACTION;
+			clearLastUndoAction();
                        if (itemTextSaxed.isEmpty())
                                updateUndo(INS, QString(SpecialChars::TAB));
                        else
@@ -3161,7 +3156,7 @@
                else if ((uc[0] > QChar(31) && m_Doc->currentStyle.charStyle().font().canRender(uc[0])) || (as == 13) || (as == 30))
                {
                        if (uc[0] == QChar(32) || uc[0] == QChar(13))
-				lastUndoAction = PageItem::NOACTION;
+				clearLastUndoAction();
                        if (lastUndoAction != PageItem::INS)
                                oldCPos = CPos;
                        itemText.insertChars(CPos, uc, true);
@@ -3332,46 +3327,38 @@
 // 	layoutWeakLock = true;
 // 	update();
        m_Doc->regionsChanged()->update(getBoundingRect());
-	lastUndoAction = PageItem::NOACTION;
+	clearLastUndoAction();
 }

-void PageItem_TextFrame::ExpandParSel() //expand selection to whole paragrpah(s)
-{
-	if (m_Doc->appMode != modeEdit)
-		return;
-	int StartSel = 0, LenSel = 0;
-	if (HasSel)
-	{
-		//extend selection to whole paragraphs
-		StartSel = itemText.startOfParagraph(itemText.nrOfParagraph(itemText.startOfSelection()));
-		LenSel = itemText.endOfParagraph(itemText.nrOfParagraph(itemText.endOfSelection())) - StartSel;
-	}
-	else
-	{
-		//extend selection to whole paragraph
-		StartSel = itemText.startOfParagraph(itemText.nrOfParagraph(CPos));
-		LenSel = itemText.endOfParagraph(itemText.nrOfParagraph(CPos)) - StartSel;
-	}
-	itemText.select(StartSel, LenSel);
-	HasSel = true;
-}
-
 void PageItem_TextFrame::expandParaSelection(bool includeEOL)
 {
        int selStart, selLength;
-	if (HasSel)
+	if (itemText.lengthOfSelection() >0)
        {
+		if (CPos == itemText.endOfSelection() && CPos < itemText.length())
+			//hack for situation, when CPos is before first char of next paragraph
+			//it add unselected paragraph if cursor is at its beginning
+			itemText.select(itemText.startOfSelection(), itemText.lengthOfSelection() +1);
+
+		//remove PARSEP from end of selection - will be added if includeEOL is true
+		if (itemText.text(itemText.endOfSelection()-1) == SpecialChars::PARSEP)
+		{
+			selStart = itemText.startOfSelection();
+			selLength = itemText.lengthOfSelection() -1;
+			itemText.deselectAll();
+			itemText.select(selStart, selLength);
+		}
                //extend selection to whole paragraphs
                selStart  = itemText.startOfParagraph(itemText.nrOfParagraph(itemText.startOfSelection()));
-		selLength = itemText.endOfParagraph(itemText.nrOfParagraph(itemText.endOfSelection())) - selStart;
+		selLength = itemText.endOfParagraph(itemText.nrOfParagraph(itemText.endOfSelection()-1)) - selStart;
        }
        else
        {
-		//extend selection to whole paragraph
+		//extend selection to whole paragraph where is cursor
                selStart  = itemText.startOfParagraph(itemText.nrOfParagraph(CPos));
                selLength = itemText.endOfParagraph(itemText.nrOfParagraph(CPos)) - selStart;
        }
-	if (includeEOL)
+	if (includeEOL && itemText.text(selStart + selLength -1) != SpecialChars::PARSEP)
                selLength += 1;
        selLength = qMin(selLength, itemText.length() - selStart);

@@ -3398,7 +3385,7 @@
        }
        //CB Replace with direct call for now //emit HasNoTextSel();
        m_Doc->scMW()->DisableTxEdit();
-	lastUndoAction = PageItem::NOACTION;
+	clearLastUndoAction();
 }

 double PageItem_TextFrame::columnWidth()
@@ -3659,25 +3646,49 @@
        invalidateLayout();
 }

+void PageItem_TextFrame::clearLastUndoAction()
+{
+	lastUndoAction = PageItem::NOACTION;
+}
+
 void PageItem_TextFrame::updateUndo(EditAct action, QString str)
 {
+	updateUndo(action, str);
+}
+
+void PageItem_TextFrame::updateUndo(EditAct action, exactlyEditAct newAction, QString str)
+{
        if (UndoManager::undoEnabled() && undoManager->undoEnabled())
        {
-		int oldSelStart = -1, oldSelLen = -1;
+		int oldSelStart = CPos, oldSelLen = 0;
                oldSelLen = itemText.lengthOfSelection();
                if (oldSelLen > 0)
                        oldSelStart = itemText.startOfSelection();
-		if (action == PARAMFULL && m_Doc->appMode == modeEdit)
+		if (m_Doc->appMode == modeEdit && action == STORY && oldSelLen == 0 && CPos <= itemText.length())
                {
-			//action is for paragraph where cursor is
-			expandParaSelection(true);
-			action = PARAMSEL;
+			if (itemText.itemText(CPos) == SpecialChars::PARSEP
+			        || itemText.text(CPos) == SpecialChars::COLBREAK
+			        || itemText.text(CPos) == SpecialChars::FRAMEBREAK
+			        || itemText.text(CPos) == SpecialChars::LINEBREAK
+			        || itemText.text(CPos) == SpecialChars::OBJECT
+			        || itemText.text(CPos) == SpecialChars::SHYPHEN)
+			//case of cursor at the end of paragraph, no slection, no paragraph related change
+			// FIX ME - if changes in PP are not applied for text lets disable it or let select word if nothing is selected
+			{
+				return;
+			}
+			else
+			{
+				//action for one character on the right from cursor
+				action = SELECTION;
+				itemText.select(CPos, 1);
+				HasSel = true;
+			}
                }
-		if (CPos >= itemText.length() && itemTextSaxed.isEmpty() && action == PARAMFULL && m_Doc->appMode == modeEdit)
+		if (CPos >= itemText.length() && itemTextSaxed.isEmpty() && action == STORY && m_Doc->appMode == modeEdit)
                {
-			//case when cursor is after last character without selection and nothing was and will be done
                        //changes will be ignored
-			lastUndoAction = PageItem::NOACTION;
+			clearLastUndoAction();
                        restoreTextSelection(oldSelStart, oldSelLen);
                        return;
                }
@@ -3688,19 +3699,19 @@
                        ss = (SimpleState*) undoManager->getLastUndoState();
                        if (ss && ss->undoObject() == this)
                        {
-				if (action == PARAMFULL || action == PARAMSEL)
+				if (action == STORY || action == PARAGRAPH || action == SELECTION)
                                {
-					newState = false;
-					if (itemTextSaxed.length() > 0)
+					if (lastExactEditAction == newAction)
                                        {
-						/*QString tmpStr = ss->get("STEXT_NEW");
-						newState = (tmpStr.length() > 0 && tmpStr != itemTextSaxed);*/
-						newState = true;
+						newState = false;
+						if (itemTextSaxed.length() > 0)
+						{
+							QString tmpStr = ss->get("STEXT_NEW");
+							newState = (tmpStr.length() > 0 && tmpStr != itemTextSaxed);
+						}
+						if (newState == false)
+							itemTextSaxed = ss->get("STEXT_OLD");
                                        }
-					if (newState == false)
-					{
-						itemTextSaxed = ss->get("STEXT_OLD");
-					}
                                }
                                else if (action == INSSAX || action == INS)
                                {
@@ -3713,7 +3724,37 @@
                }
                if (newState)
                {
-			ss = new SimpleState(UndoManager::EditText);
+			QString descript;
+			switch (action)
+			{
+			case STORY:
+				descript = tr("Changing whole text");
+				break;
+			case PARAGRAPH:
+				descript = tr("Changing selected paragraph(s)");
+				break;
+			case SELECTION:
+				descript = tr("Changing selected text");
+				break;
+			case INSSAX:
+			case INS:
+				descript.append(tr("Inserting text"));
+				break;
+			case DELSAX:
+				descript = tr("Deleting");
+				descript =+ " '" + str.left(20) + "'";
+				break;
+			case REPSAX:
+				descript = tr("Replacing");
+				descript =+ " '" + str.left(20) + "'";
+				break;
+			case NOACTION:
+			default:
+				break;
+			}
+			if (newAction >0)
+				descript += "\n" + doc()->scMW()->actionManager->textEditActionDescriptions.value(newAction,"");
+			ss = new SimpleState(UndoManager::EditText, descript);
                        ss->set("STEXT_CPOS", oldCPos);
                }
                if (action == INSSAX || action == INS)
@@ -3727,24 +3768,18 @@
                }
                else
                {
-			if (action == PARAMFULL && m_Doc->appMode == modeEdit)
+			if (action == PARAGRAPH || action == SELECTION)
                        {
-				//action is for paragraph where cursor is
-				expandParaSelection(true);
-				action = PARAMSEL;
-			}
-			if (action == PARAMSEL)
-			{
+				if (action == PARAGRAPH)
+					expandParaSelection(false);
                                ss->set("STEXT_CPOS",CPos);
                                ss->set("STEXT_SELSTART", itemText.startOfSelection());
                                ss->set("STEXT_SELLEN", itemText.lengthOfSelection());
                        }
                        ss->set("STEXT_OLD", itemTextSaxed);
-			itemTextSaxed = getItemTextSaxed((action == PARAMSEL) ? SELECTION : FRAME);
-			ss->set("STEXT_NEW", itemTextSaxed);
+			ss->set("STEXT_NEW", getItemTextSaxed(action));
                        if (QString::compare(ss->get("STEXT_OLD"),ss->get("STEXT_NEW")) == 0)
                        {
-				//nothing change - quit without set new Undo step
                                itemTextSaxed.clear();
                                restoreTextSelection(oldSelStart, oldSelLen);
                                if (newState)
@@ -3754,6 +3789,7 @@
                }
                itemTextSaxed.clear();
                lastUndoAction = action;
+		lastExactEditAction = newAction;
                ss->set("STEXT",(int) action);
                if (newState)
                        undoManager->action(this, ss);
@@ -3764,6 +3800,7 @@

 void PageItem_TextFrame::restoreTextSelection(int oldSelStart, int oldSelLength)
 {
+	itemText.deselectAll();
        if (oldSelLength > 0)
                itemText.select(oldSelStart, oldSelLength);
        else if (oldSelLength == 0)
Index: Scribus/scribus/scribus.cpp
===================================================================
--- Scribus/scribus/scribus.cpp	(wersja 16536)
+++ Scribus/scribus/scribus.cpp	(kopia robocza)
@@ -4304,7 +4304,7 @@
                        ImportSetup impsetup=gt->run();
                        if (impsetup.runDialog)
                        {
-				currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::FRAME);
+				currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::STORY);
                                if (currItem->itemText.length() != 0)
                                {
                                        int t = QMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
@@ -4312,7 +4312,7 @@
                                                return;
                                }
                                gt->launchImporter(impsetup.importer, impsetup.filename, impsetup.textOnly, impsetup.encoding, false);
-				currItem->asTextFrame()->updateUndo();
+				currItem->asTextFrame()->updateUndo(PageItem::STORY);
                        }
                        delete gt;
                        if (doc->docHyphenator->AutoCheck)
@@ -4339,7 +4339,7 @@
        if (!currItem->asTextFrame())
                return; // not a text frame
        // I dont know what is doing here, but Undo dont hurts
-	currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::FRAME);
+	currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::STORY);
        ScGTPluginManager::instance()->run();
        if (doc->docHyphenator->AutoCheck)
                doc->docHyphenator->slotHyphenate(currItem);
@@ -4348,7 +4348,7 @@
                if (doc->Items->at(a)->isBookmark)
                        bookmarkPalette->BView->ChangeText(doc->Items->at(a));
        }
-	currItem->asTextFrame()->updateUndo();
+	currItem->asTextFrame()->updateUndo(PageItem::STORY);
        view->DrawNew();
        slotDocCh();
 }
@@ -4405,9 +4405,9 @@
                if (impsetup.runDialog)
                {
                        PageItem *currItem = doc->m_Selection->itemAt(0);
-			currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::FRAME);
+			currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::STORY);
                        gt->launchImporter(impsetup.importer, impsetup.filename, impsetup.textOnly, impsetup.encoding, true);
-			currItem->asTextFrame()->updateUndo();
+			currItem->asTextFrame()->updateUndo(PageItem::STORY);
                }
                delete gt;
                //CB Hyphenating now emits doc changed, plus we change lang as appropriate
@@ -4988,6 +4988,7 @@
                                return;
                        currItem->oldCPos = currItem->itemText.startOfSelection();
                        //for undo
+			QString oldstr = currItem->itemText.text(currItem->itemText.startOfSelection(), currItem->itemText.lengthOfSelection());
                        currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::SELECTION);

                        StoryText itemText(doc);
@@ -5008,7 +5009,7 @@

                        dynamic_cast<PageItem_TextFrame*>(currItem)->deleteSelectedTextFromFrame();
                        //for undo
-			currItem->asTextFrame()->updateUndo(PageItem::DELSAX);
+			currItem->asTextFrame()->updateUndo(PageItem::DELSAX, oldstr);
                        currItem->update();
                }
                else
@@ -5144,7 +5145,7 @@
                {
                        PageItem_TextFrame *currItem = dynamic_cast<PageItem_TextFrame*>(doc->m_Selection->itemAt(0));
                        assert(currItem != NULL);
-			currItem->lastUndoAction = PageItem::NOACTION;
+			currItem->clearLastUndoAction();
                        if (currItem->HasSel)
                        {
                                //for text undo, storing current selection
@@ -5175,7 +5176,7 @@
                                currItem->itemText.select(currItem->CPos,story->length());
                                currItem->HasSel = true;
                                //if itemTextSaxed is not empty there was selection
-				currItem->updateUndo(currItem->itemTextSaxed.isEmpty() ? PageItem::INSSAX : PageItem::REPSAX,currItem->getItemTextSaxed(PageItem::SELECTION));
+				currItem->updateUndo(currItem->itemTextSaxed.isEmpty() ? PageItem::INSSAX : PageItem::REPSAX, currItem->getItemTextSaxed(PageItem::SELECTION));

                                currItem->CPos += story->length();

@@ -5266,7 +5267,7 @@
                                currItem->itemText.select(currItem->oldCPos,currItem->CPos - currItem->oldCPos);
                                currItem->HasSel = true;
                                //if itemTextSaxed is not empty there was selection
-				currItem->updateUndo(currItem->itemTextSaxed.isEmpty() ? PageItem::INSSAX : PageItem::REPSAX,currItem->getItemTextSaxed(PageItem::SELECTION));
+				currItem->updateUndo(currItem->itemTextSaxed.isEmpty() ? PageItem::INSSAX : PageItem::REPSAX, currItem->getItemTextSaxed(PageItem::SELECTION));
                        }
                        else
                        {
@@ -7001,11 +7002,10 @@
        //for undo
        PageItem *currItem = doc->m_Selection->itemAt(0);
        if (currItem->asTextFrame())
-		currItem->itemTextSaxed = currItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
-	qDebug() << "setNewFont" << currItem->HasSel;
+		currItem->itemTextSaxed = currItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        doc->itemSelection_SetFont(nf2);
        if (currItem->asTextFrame())
-		currItem->asTextFrame()->updateUndo(currItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		currItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY, ETEASetNewFont);

 //	doc->currentStyle.charStyle().setFont((*doc->AllFonts)[nf2]);
        view->DrawNew();
@@ -7016,8 +7016,7 @@
 {
        PageItem *currItem = doc->m_Selection->itemAt(0);
        if (currItem->asTextFrame())
-		currItem->itemTextSaxed = currItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
-
+		currItem->itemTextSaxed = currItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        int c = id;
        if (c != -1)
                doc->itemSelection_SetFontSize(c*10);
@@ -7034,8 +7033,7 @@
                delete dia;
        }
        if (currItem->asTextFrame())
-		currItem->asTextFrame()->updateUndo(currItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
-
+		currItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY, ETEAsetItemFSize);
        propertiesPalette->setSize(c*10);
 // 	slotDocCh();
 }
@@ -7048,6 +7046,8 @@
        if (doc->m_Selection->count() != 0)
        {
                PageItem *currItem = doc->m_Selection->itemAt(0);
+		if (currItem->asTextFrame())
+			currItem->itemTextSaxed = currItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
                if (c != -1)
                {
                        if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::PathText))
@@ -7071,6 +7071,8 @@
                        }
                        delete dia;
                }
+		if (currItem->asTextFrame())
+			currItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY, ETEAsetItemShade);
        }
 // 	slotDocCh();
 }
@@ -7435,14 +7437,10 @@
                else */
                PageItem *currItem = doc->m_Selection->itemAt(0);
                if (currItem->asTextFrame())
-		{
-//			currItem->asTextFrame()->ExpandParSel();
-//			currItem->asTextFrame()->lastAction4Paragraph = true;
-			currItem->itemTextSaxed = currItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME);
-		}
+			currItem->itemTextSaxed = currItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY);
                doc->itemSelection_SetNamedParagraphStyle(name);
                if (currItem->asTextFrame())
-			currItem->asTextFrame()->updateUndo();
+			currItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAsetNewParStyle);
                setTBvals(currItem);
        }
 }
@@ -7459,10 +7457,10 @@
                else */
                PageItem *currItem = doc->m_Selection->itemAt(0);
                if (currItem->asTextFrame())
-			currItem->itemTextSaxed = currItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+			currItem->itemTextSaxed = currItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
                doc->itemSelection_SetNamedCharStyle(name);
                if (currItem->asTextFrame())
-			currItem->asTextFrame()->updateUndo(currItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+			currItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY, ETEAsetNewCharStyle);
                setTBvals(currItem);
        }
 }
Index: Scribus/scribus/propertiespalette.cpp
===================================================================
--- Scribus/scribus/propertiespalette.cpp	(wersja 16536)
+++ Scribus/scribus/propertiespalette.cpp	(kopia robocza)
@@ -61,6 +61,7 @@
 #include "scribuscore.h"
 #include "scraction.h"
 #include "scribusview.h"
+#include "scribusstructs.h"
 #include "selection.h"
 #include "spalette.h"
 #include "styleselect.h"
@@ -2947,15 +2948,10 @@
        if ((HaveDoc) && (HaveItem))
        {
                if (CurItem->asTextFrame())
-		{
-//			CurItem->asTextFrame()->ExpandParSel();
-			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME);
-//			CurItem->asTextFrame()->lastAction4Paragraph = true;
-		}
+			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY);
                doc->itemSelection_SetLineSpacingMode(id);
-		updateStyle(doc->appMode == modeEdit? CurItem->currentStyle() : CurItem->itemText.defaultStyle());
                if (CurItem->asTextFrame())
-			CurItem->asTextFrame()->updateUndo();
+			CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAsetLineSpacingMode);
        }
 }

@@ -3298,7 +3294,7 @@
        if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY);
        int omt(ParagraphStyle::OM_None);
 //	if (optMarginCheckLeftProtruding->isChecked()) omt+=ParagraphStyle::OM_LeftProtruding;
        if (optMarginRadioBoth->isChecked())
@@ -3310,7 +3306,7 @@

        doc->itemSelection_SetOpticalMargins(omt);
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo();
+		CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAsetOpticalMargins);
 }

 void PropertiesPalette::resetOpticalMargins()
@@ -3339,12 +3335,12 @@
        if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        ParagraphStyle newStyle;
        newStyle.setMinWordTracking(minWordTrackingSpinBox->value() / 100.0);
        doc->itemSelection_ApplyParagraphStyle(newStyle);
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEAsetMinWordTracking);
 }


@@ -3353,13 +3349,13 @@
        if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        ParagraphStyle newStyle;
 //	newStyle.setNormWordTracking(percent / 100.0);
        newStyle.charStyle().setWordTracking(normWordTrackingSpinBox->value() / 100.0);
        doc->itemSelection_ApplyParagraphStyle(newStyle);
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEAsetNormWordTracking);
 }

 void PropertiesPalette::setMinGlyphExtension()
@@ -3367,12 +3363,12 @@
        if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        ParagraphStyle newStyle;
        newStyle.setMinGlyphExtension(minGlyphExtSpinBox->value() / 100.0);
        doc->itemSelection_ApplyParagraphStyle(newStyle);
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEAsetMinGlyphExtension);
 }

 void PropertiesPalette::setMaxGlyphExtension()
@@ -3380,12 +3376,12 @@
        if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        ParagraphStyle newStyle;
        newStyle.setMaxGlyphExtension(maxGlyphExtSpinBox->value() / 100.0);
        doc->itemSelection_ApplyParagraphStyle(newStyle);
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEAsetMaxGlyphExtension);
 }


@@ -3404,10 +3400,10 @@
        if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        doc->itemSelection_SetScaleV(qRound(ChScaleV->value() * 10));
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEANewTScale);
 }

 void PropertiesPalette::NewTBase()
@@ -3415,10 +3411,10 @@
        if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        doc->itemSelection_SetBaselineOffset(qRound(ChBase->value() * 10));
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEANewTBase);
 }

 void PropertiesPalette::setTScale(double e)
@@ -3446,10 +3442,10 @@
        if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        doc->itemSelection_SetScaleH(qRound(ChScale->value() * 10));
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY);
 }

 void PropertiesPalette::NewX()
@@ -3874,14 +3870,10 @@
        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;
-	}
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY);
        doc->itemSelection_SetLineSpacing(LineSp->value());
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo();
+		CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEANewLineSpacing);
 }

 void PropertiesPalette::HandleGapSwitch()
@@ -3944,10 +3936,10 @@
        if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        doc->itemSelection_SetFontSize(qRound(Size->value()*10.0));
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEANewSize);
 }

 void PropertiesPalette::NewTracking()
@@ -3955,10 +3947,10 @@
        if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        doc->itemSelection_SetTracking(qRound(Extra->value() * 10.0));
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEANewTracking);
 }

 void PropertiesPalette::NewLocalXY()
@@ -4276,35 +4268,13 @@

 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->CPos;
-			selEnd   = (itemText.lengthOfSelection() > 0) ? itemText.endOfSelection() : CurItem->CPos;
-			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::STORY);
        doc->itemSelection_SetAlignment(a);
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo();
+		CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEANewAlignement);
 }

 void PropertiesPalette::setTypeStyle(int s)
@@ -4312,10 +4282,10 @@
        if (!m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        emit NewEffects(s);
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEAsetTypeStyle);
 }

 void PropertiesPalette::newShadowOffs()
@@ -4323,12 +4293,12 @@
        if ((HaveDoc) && (HaveItem))
        {
                if (CurItem->asTextFrame())
-			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
                int x = qRound(SeStyle->ShadowVal->Xoffset->value() * 10.0);
                int y = qRound(SeStyle->ShadowVal->Yoffset->value() * 10.0);
                doc->itemSelection_SetShadowOffsets(x, y);
                if (CurItem->asTextFrame())
-			CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+			CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEAnewShadowOffs);
        }
 }

@@ -4349,12 +4319,12 @@
        if ((HaveDoc) && (HaveItem))
        {
                if (CurItem->asTextFrame())
-			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
                int x = qRound(SeStyle->UnderlineVal->LPos->value() * 10.0);
                int y = qRound(SeStyle->UnderlineVal->LWidth->value() * 10.0);
                doc->itemSelection_SetUnderline(x, y);
                if (CurItem->asTextFrame())
-			CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+			CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEAnewUnderline);
        }
 }

@@ -4375,12 +4345,12 @@
        if ((HaveDoc) && (HaveItem))
        {
                if (CurItem->asTextFrame())
-			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
                int x = qRound(SeStyle->StrikeVal->LPos->value() * 10.0);
                int y = qRound(SeStyle->StrikeVal->LWidth->value() * 10.0);
                doc->itemSelection_SetStrikethru(x, y);
                if (CurItem->asTextFrame())
-			CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+			CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEAnewStrike);
        }
 }

@@ -4411,10 +4381,10 @@
        if ((HaveDoc) && (HaveItem))
        {
                if (CurItem->asTextFrame())
-			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
                doc->itemSelection_SetOutlineWidth(x);
                if (CurItem->asTextFrame())
-			CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+			CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEAnewOutlineW);
        }
 }

@@ -4742,10 +4712,10 @@
        if (HaveDoc)
        {
                if (CurItem->asTextFrame())
-			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
                doc->itemSelection_EraseCharStyle();
                if (CurItem->asTextFrame())
-			CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAMSEL : PageItem::PARAMFULL);
+			CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY, ETEAdoClearCStyle);
        }
 }

@@ -4757,16 +4727,12 @@
        if (HaveDoc)
        {
                if (CurItem->asTextFrame())
-		{
-//			CurItem->asTextFrame()->ExpandParSel();
-			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME);
-//			CurItem->asTextFrame()->lastAction4Paragraph = true;
-		}
+			CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY);
                doc->itemSelection_EraseParagraphStyle();
                CharStyle emptyCStyle;
                doc->itemSelection_SetCharStyle(emptyCStyle);
                if (CurItem->asTextFrame())
-			CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit ? PageItem::PARAMSEL : PageItem::PARAMFULL);
+			CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit ? PageItem::SELECTION : PageItem::STORY, ETEAdoClearPStyle);
        }
 }

@@ -4913,10 +4879,10 @@
        if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        doc->itemSelection_SetFillColor(TxFill->currentColor());
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEAnewTxtFill);
 }

 void PropertiesPalette::newTxtStroke()
@@ -4924,10 +4890,10 @@
        if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning())
                return;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        doc->itemSelection_SetStrokeColor(TxStroke->currentColor());
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEAnewTxtStroke);

 }

@@ -4937,7 +4903,7 @@
                return;
        int b;
        if (CurItem->asTextFrame())
-		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME);
+		CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY);
        if (PM1 == sender())
        {
                b = PM1->getValue();
@@ -4949,7 +4915,7 @@
                doc->itemSelection_SetFillShade(b);
        }
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL);
+		CurItem->asTextFrame()->updateUndo(CurItem->HasSel? PageItem::SELECTION : PageItem::STORY, ETEAsetActShade);
 }

 void PropertiesPalette::setActFarben(QString p, QString b, double shp, double shb)
@@ -5099,7 +5065,7 @@
        CurItem->update();
        qDebug() << "PropertiesPalette::handleFillRule() updateUNDO";
        if (CurItem->asTextFrame())
-		CurItem->asTextFrame()->updateUndo();
+		CurItem->asTextFrame()->updateUndo(PageItem::STORY);

        emit DocChanged();
 }
@@ -5142,6 +5108,7 @@
                if (CurItem->itemName() != NameEdit->text())
                {
                        CurItem->setItemName(NameEdit->text());
+			CurItem->AutoName = false;
                        emit DocChanged();
                }
        }
@@ -5184,10 +5151,7 @@
                if (dia->exec())
                {
                        if (CurItem->asTextFrame())
-			{
-				CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME);
-//				CurItem->asTextFrame()->lastAction4Paragraph = true;
-			}
+				CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY);
                        if (doc->appMode != modeEdit)
                        {
                                ParagraphStyle newStyle(CurItem->itemText.defaultStyle());
@@ -5202,7 +5166,7 @@
                        }
                        CurItem->update();
                        if (CurItem->asTextFrame())
-				CurItem->asTextFrame()->updateUndo();
+				CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAManageTabs);

                        emit DocChanged();
                }
Index: Scribus/scribus/actionmanager.h
===================================================================
--- Scribus/scribus/actionmanager.h	(wersja 16536)
+++ Scribus/scribus/actionmanager.h	(kopia robocza)
@@ -37,6 +37,7 @@

 #include "scribusapi.h"
 #include "scraction.h"
+#include "scribusstructs.h"

 class ScribusDoc;
 class ScribusMainWindow;
@@ -69,6 +70,7 @@
                static QString defaultMenuNameEntryTranslated(const QString& index);
                static QVector< QPair<QString, QStringList> >* defaultMenus() {return &defMenus;};
                static QVector< QPair<QString, QStringList> >* defaultNonMenuActions() {return &defNonMenuActions;};
+		QMap<exactlyEditAct,QString> textEditActionDescriptions;
                void createActions();
                void disconnectModeActions();
                void connectModeActions();
@@ -104,6 +106,7 @@
                static void initUnicodeActions(QMap<QString, QPointer<ScrAction> > *actionMap, QWidget *actionParent, QStringList *actionNamesList);
                void initSpecialActions();
                static void languageChangeUnicodeActions(QMap<QString, QPointer<ScrAction> > *actionMap);
+		void initTextEditActionsDescriptions();
                void languageChangeActions();
                static QKeySequence defaultKey(const QString &actionName);

Index: Scribus/scribus/loremipsum.cpp
===================================================================
--- Scribus/scribus/loremipsum.cpp	(wersja 16536)
+++ Scribus/scribus/loremipsum.cpp	(kopia robocza)
@@ -311,7 +311,7 @@
                        continue;
                if (currItem->itemText.length() != 0)
                {
-			currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::FRAME);
+			currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::STORY);
                        m_Doc->itemSelection_ClearItem();
                        /* ClearItem() doesn't return true or false so
                        the following test has to be done */
@@ -346,7 +346,7 @@
                QString Lorip = lp->createLorem(paraCount, random);
                currItem->itemText.insertChars(0, Lorip);
                if (currItem->itemTextSaxed.isEmpty())
-			currItem->asTextFrame()->updateUndo(PageItem::INS,Lorip);
+			currItem->asTextFrame()->updateUndo(PageItem::INS, Lorip);
                else
                        currItem->asTextFrame()->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(Lorip));
                delete lp;
Index: Scribus/scribus/charselect.cpp
===================================================================
--- Scribus/scribus/charselect.cpp	(wersja 16536)
+++ Scribus/scribus/charselect.cpp	(kopia robocza)
@@ -113,7 +113,7 @@
        {
                m_Item->itemTextSaxed = m_Item->getItemTextSaxed(PageItem::SELECTION);
                m_Item->asTextFrame()->deleteSelectedTextFromFrame();
-		m_Item->asTextFrame()->lastUndoAction = PageItem::NOACTION;
+		m_Item->asTextFrame()->clearLastUndoAction();
        }
        if (m_Item->asTextFrame())
                m_Item->asTextFrame()->invalidateLayout();
@@ -150,7 +150,7 @@
        {
                m_Item->itemTextSaxed = m_Item->getItemTextSaxed(PageItem::SELECTION);
                m_Item->asTextFrame()->deleteSelectedTextFromFrame();
-		m_Item->asTextFrame()->lastUndoAction = PageItem::NOACTION;
+		m_Item->asTextFrame()->clearLastUndoAction();
        }
        if (m_Item->asTextFrame())
                m_Item->asTextFrame()->invalidateLayout();
Index: Scribus/scribus/canvasmode_edit.cpp
===================================================================
--- Scribus/scribus/canvasmode_edit.cpp	(wersja 16536)
+++ Scribus/scribus/canvasmode_edit.cpp	(kopia robocza)
@@ -412,7 +412,7 @@
        PageItem *currItem = 0;
        if (GetItem(&currItem) && (m_doc->appMode == modeEdit) && currItem->asTextFrame())
        {
-		currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION;
+		currItem->asTextFrame()->clearLastUndoAction();
                //CB if annotation, open the annotation dialog
                if (currItem->isAnnotation())
                {
@@ -659,7 +659,7 @@
                                        if (currItem->asTextFrame())
                                        {
                                                m_view->slotSetCurs(m->globalPos().x(), m->globalPos().y());
-						currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION;
+						currItem->asTextFrame()->clearLastUndoAction();
                                        }
                                }
                                else
@@ -677,7 +677,7 @@
                //CB Where we set the cursor for a click in text frame
                if (currItem->asTextFrame())
                {
-			currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION;
+			currItem->asTextFrame()->clearLastUndoAction();
                        inText = m_view->slotSetCurs(m->globalPos().x(), m->globalPos().y());
                        //CB If we clicked outside a text frame to go out of edit mode and deselect the frame
                        if (!inText)
@@ -687,7 +687,7 @@
                                //m_view->slotDoCurs(true);
                                m_view->requestMode(modeNormal);
                                if (currItem->isTextFrame())
-					currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION;
+					currItem->asTextFrame()->clearLastUndoAction();
                                return;
                        }

@@ -712,7 +712,7 @@
                                                        oldP = currItem->itemText.endOfSelection();
                                                }
                                                currItem->asTextFrame()->itemText.extendSelection(oldP, currItem->CPos);
-						currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION;
+						currItem->asTextFrame()->clearLastUndoAction();
                                                oldCp = currItem->CPos;
                                        }
                                        else
@@ -728,7 +728,7 @@
                                                                currItem->CPos = currItem->itemText.startOfParagraph(currItem->itemText.nrOfParagraph(currItem->CPos));
                                                }
                                                currItem->asTextFrame()->ExpandSel(dir, oldP);
-						currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION;
+						currItem->asTextFrame()->clearLastUndoAction();
                                                oldCp = oldP;
                                        }
                                }
@@ -736,7 +736,7 @@
                                {
                                        oldCp = currItem->CPos;
                                        currItem->itemText.deselectAll();
-					currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION;
+					currItem->asTextFrame()->clearLastUndoAction();
                                        currItem->HasSel = false;
                                }
                                currItem->emitAllToGUI();
@@ -753,7 +753,7 @@
                                                // K.I.S.S.:
                                                currItem->oldCPos = 0;
                                                currItem->itemText.insertChars(0, cc, true);
-						currItem->asTextFrame()->updateUndo(PageItem::INS,cc);
+						currItem->asTextFrame()->updateUndo(PageItem::INS, cc);
                                                if (m_doc->docHyphenator->AutoCheck)
                                                        m_doc->docHyphenator->slotHyphenate(currItem);
                                                m_ScMW->BookMarkTxT(currItem);
Index: Scribus/scribus/pageitem.h
===================================================================
--- Scribus/scribus/pageitem.h	(wersja 16536)
+++ Scribus/scribus/pageitem.h	(kopia robocza)
@@ -170,21 +170,15 @@
        //enum for actions in updateUndo and restoreEditText
        typedef enum {
                NOACTION = -1, //it is for checking if sequence of actions was done - after deselect text frame new sequence will be
-		PARAMFULL = 0, //parameters for whole frame
-		PARAMSEL = 1,  //paramaters for selected text
-		DELSAX = 2,	//delete with styles
-		INSSAX = 3,	//insert with styles
-		REPSAX = 4,	//replace with styles
-		INS = 5		//inserting chars without styles (from keyboard)
+		STORY = 0,
+		PARAGRAPH = 1,
+		SELECTION = 2,
+		DELSAX = 3,	//delete with styles
+		INSSAX = 4,	//insert with styles
+		REPSAX = 5,	//replace with styles
+		INS = 6		//inserting chars without styles (from keyboard)
        } EditAct;
-
-	typedef enum {  // for recognise what was changing during text edition/changing
-		FRAME = 1,
-		PARAGRAPH = 2,
-		SELECTION = 3,
-		CHAR = 4
-	} EditActPlace;
-
+
        /* these do essentially the same as a dynamic cast but might be more readable */
        virtual PageItem_ImageFrame * asImageFrame() { return NULL; }
        virtual PageItem_Line * asLine() { return NULL; }
@@ -468,7 +462,7 @@
   // for itemText undo purpose
        int oldCPos;
        QString itemTextSaxed;
-	QString getItemTextSaxed(EditActPlace undoItem);
+	QString getItemTextSaxed(EditAct action);
        QString getItemTextSaxed(int selStart, int selLength);
        QString getTextSaxed(QString str);
   /** Flag fuer PDF-Bookmark */
@@ -1087,6 +1081,7 @@
        void restoreEditText(SimpleState *state, bool isUndo);
        void restoreLinkTextFrame(UndoState *state, bool isUndo);
        void restoreUnlinkTextFrame(UndoState *state, bool isUndo);
+
        /*@}*/

        /**
Index: Scribus/scribus/scribusstructs.h
===================================================================
--- Scribus/scribus/scribusstructs.h	(wersja 16536)
+++ Scribus/scribus/scribusstructs.h	(kopia robocza)
@@ -472,6 +472,42 @@
        }
 };

+
+//ETEA = Exactly Text Edit Action
+//for Undo state comparising and detailed description
+typedef enum {
+	ETEAotherEditAction = 0,
+	ETEAsetLineSpacingMode = 1,
+	ETEAsetOpticalMargins = 2,
+	ETEAsetMinWordTracking = 3,
+	ETEAsetNormWordTracking = 4,
+	ETEAsetMinGlyphExtension = 5,
+	ETEAsetMaxGlyphExtension = 6,
+	ETEANewTScaleV = 7,
+	ETEANewTBase = 8,
+	ETEANewTScale = 9,
+	ETEANewLineSpacing = 10,
+	ETEANewSize = 11,
+	ETEANewTracking = 12,
+	ETEANewAlignement = 13,
+	ETEAsetTypeStyle = 14,
+	ETEAnewShadowOffs = 15,
+	ETEAnewUnderline = 16,
+	ETEAnewStrike = 17,
+	ETEAnewOutlineW = 18,
+	ETEAdoClearCStyle = 19,
+	ETEAdoClearPStyle = 20,
+	ETEAnewTxtFill = 21,
+	ETEAnewTxtStroke = 22,
+	ETEAsetActShade = 23,
+	ETEAManageTabs = 24,
+	ETEASetNewFont = 25,
+	ETEAsetItemFSize = 26,
+	ETEAsetItemShade = 27,
+	ETEAsetNewParStyle = 28,
+	ETEAsetNewCharStyle = 29
+} exactlyEditAct;
+
 #endif


Index: Scribus/scribus/actionmanager.cpp
===================================================================
--- Scribus/scribus/actionmanager.cpp	(wersja 16536)
+++ Scribus/scribus/actionmanager.cpp	(kopia robocza)
@@ -19,11 +19,14 @@
 *                                                                         *
 ***************************************************************************/

+#include <QMap>
+
 #include "actionmanager.h"
 #include "scribus.h"
 #include "scribuscore.h"
 #include "scribusdoc.h"
 #include "scribusview.h"
+#include "scribusstructs.h"
 #include "selection.h"
 #include "text/storytext.h"
 #include "undomanager.h"
@@ -94,9 +97,43 @@
        initUnicodeActions(scrActions, mainWindow, unicodeCharActionNames);
        enableUnicodeActions(scrActions, false);
        initSpecialActions();
-
+	initTextEditActionsDescriptions();
 }

+void ActionManager::initTextEditActionsDescriptions()
+{
+	textEditActionDescriptions.clear();
+	textEditActionDescriptions.insert(ETEAotherEditAction, QObject::tr("Other action"));
+	textEditActionDescriptions.insert(ETEAsetLineSpacingMode, QObject::tr("Set line spacing mode"));
+	textEditActionDescriptions.insert(ETEAsetOpticalMargins, QObject::tr("Set optical margins"));
+	textEditActionDescriptions.insert(ETEAsetMinWordTracking, QObject::tr("Set min word tracking"));
+	textEditActionDescriptions.insert(ETEAsetNormWordTracking, QObject::tr("Set normla word tracking"));
+	textEditActionDescriptions.insert(ETEAsetMinGlyphExtension, QObject::tr("Set min glyph extension"));
+	textEditActionDescriptions.insert(ETEAsetMaxGlyphExtension, QObject::tr("Set max glyph extension"));
+	textEditActionDescriptions.insert(ETEANewTScaleV, QObject::tr("Set T scale V"));
+	textEditActionDescriptions.insert(ETEANewTBase, QObject::tr("Set T base"));
+	textEditActionDescriptions.insert(ETEANewTScale, QObject::tr("Set T scale"));
+	textEditActionDescriptions.insert(ETEANewLineSpacing, QObject::tr("Set line spacing"));
+	textEditActionDescriptions.insert(ETEANewSize, QObject::tr("Set size"));
+	textEditActionDescriptions.insert(ETEANewTracking, QObject::tr("Set tracking"));
+	textEditActionDescriptions.insert(ETEANewAlignement, QObject::tr("Apply alignment"));
+	textEditActionDescriptions.insert(ETEAsetTypeStyle, QObject::tr("Set type style"));
+	textEditActionDescriptions.insert(ETEAnewShadowOffs, QObject::tr("Set shadow offset"));
+	textEditActionDescriptions.insert(ETEAnewUnderline, QObject::tr("Set underline"));
+	textEditActionDescriptions.insert(ETEAnewStrike, QObject::tr("Set strike"));
+	textEditActionDescriptions.insert(ETEAnewOutlineW, QObject::tr("Set outline"));
+	textEditActionDescriptions.insert(ETEAdoClearCStyle, QObject::tr("Clear character formatting"));
+	textEditActionDescriptions.insert(ETEAdoClearPStyle, QObject::tr("Clear paragraph style"));
+	textEditActionDescriptions.insert(ETEAnewTxtFill, QObject::tr("Set fill color"));
+	textEditActionDescriptions.insert(ETEAnewTxtStroke, QObject::tr("Set text stroke"));
+	textEditActionDescriptions.insert(ETEAsetActShade, QObject::tr("Set act shade"));
+	textEditActionDescriptions.insert(ETEAManageTabs, QObject::tr("Manage tabs"));
+	textEditActionDescriptions.insert(ETEASetNewFont, QObject::tr("Set font name"));
+	textEditActionDescriptions.insert(ETEAsetItemFSize, QObject::tr("Set font size"));
+	textEditActionDescriptions.insert(ETEAsetItemShade, QObject::tr("Apply shade"));
+	textEditActionDescriptions.insert(ETEAsetNewParStyle, QObject::tr("Apply paragraph style"));
+	textEditActionDescriptions.insert(ETEAsetNewCharStyle, QObject::tr("Apply character style"));
+}
 void ActionManager::initFileMenuActions()
 {
        QString name;
@@ -1499,6 +1536,7 @@
        (*scrActions)["specialUnicodeSequenceBegin"]->setTexts( tr("Insert Unicode Character Begin Sequence"));
        languageChangeUnicodeActions(scrActions);
        languageChangeActions();
+	initTextEditActionsDescriptions();
 }

 void ActionManager::languageChangeUnicodeActions(QMap<QString, QPointer<ScrAction> > *actionMap)
Index: Scribus/scribus/pageitem_textframe.h
===================================================================
--- Scribus/scribus/pageitem_textframe.h	(wersja 16536)
+++ Scribus/scribus/pageitem_textframe.h	(kopia robocza)
@@ -34,6 +34,7 @@
 class ScribusDoc;

 #include "text/nlsconfig.h"
+#include "scribusstructs.h"

 #ifdef NLS_PROTO
 #include "text/sctextengine.h"
@@ -66,8 +67,6 @@
        void deleteSelectedTextFromFrame();
        void setNewPos(int oldPos, int len, int dir);
        void ExpandSel(int dir, int oldPos);
-	void ExpandParSel(); //expand selection to whole paragrpah(s)
-	void expandParaSelection(bool includeEOL = false);
        void deselectAll();

        virtual void invalidateLayout();
@@ -104,12 +103,18 @@
        bool cursorBiasBackward;

        void setShadow();
-	void restoreTextSelection(int selStart, int selLength);
        QString currentShadow;
        QMap<QString,StoryText> shadows;
+
+	EditAct lastUndoAction;
+	exactlyEditAct lastExactEditAction;
+
 public:
-	void updateUndo(EditAct action = PARAMFULL, QString str = "");
-	EditAct lastUndoAction;
+	void clearLastUndoAction();
+	void expandParaSelection(bool includeEOL = true);
+	void updateUndo(EditAct action, exactlyEditAct newAction, QString str = "");
+	void updateUndo(EditAct action, QString str = "");
+	void restoreTextSelection(int selStart, int selLength);
 private slots:
        void slotInvalidateLayout();
 };
