View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0009890 | Scribus | Undo/Redo | public | 2011-03-28 13:59 | 2016-05-15 23:08 |
Reporter | cezaryece | Assigned To | jghali | ||
Priority | normal | Severity | tweak | Reproducibility | have not tried |
Status | assigned | Resolution | open | ||
Product Version | 1.4.0svn | ||||
Target Version | 1.5.5 | ||||
Summary | 0009890: [PATCH] text undo/redo ver. 2 | ||||
Description | I know that is no time to verify and commit it in 1.4.0, but maybe I am wrong. At least it can go to 1.4.1 Fix for text undo. Main changes: 1. detailed created sequence of changes - separately changes of line spacing, separately changes of font color, separately glyph extensions and so on 2. more detailed undo state description Additionally few small fixes, simplification whole undo processing. | ||||
Tags | No tags attached. | ||||
Patch | Yes | ||||
child of | 0012500 | acknowledged | Metabug: Undo/Redo (1.5.x.svn) |
|
textUndo_280311.patch (65,562 bytes)
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(); }; |
|
New feature in this patch is also undo for set optical margins. Jghali patches are also in it: -new paragraph selection routine (text selection is done in getItemTextSaxed with restoration of previous selection) - hacks for selection PARSEP char and for last story paragraph Two enum types for place of changes and type of changes are merged in one enum type with change FRAME/PARAMFULL into STORY and PARAMSELL is changed into PARAGRAPH for paragraph based properties and into SELECTION for char based properties - it is first step for moving text undo from Page Item into Story Text. New enum type is exactlyTextEditAct which enumerate all parameters changing actions and is passed as parameter into updateUndo for selecting undo state detailed description and for condition of new undo state creation. Undo does not work properly with text without paragraph style - undoing changes in paragraph based properties (align, line spacing) cannot be restored as "no style" paragraph style is not applicable. But I think it is not undo problem - this is problem with whole "no style" concept and IMHO that "style" should disappear from user point. |
|
BTW this patch perhaps need some translation work. As string is closed in 1.4.0 rc3 this patch is for future release (1.4.1?). |
|
If jghali approves this for inclusion in 1.4.0, then we can live with the string issue. We will have an RC4. |
|
Stop! patch need fix, Scribus crash after change of horizontal text scaling. Working on it. |
|
in patch is: @@ -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); } SHOULD BE: @@ -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, ETEANewTScale); } change is in last line in second parameter for updateUndo. |
|
textUndo_310311.patch (83,064 bytes)
Index: Scribus/scribus/canvasmode_legacy.cpp =================================================================== --- Scribus/scribus/canvasmode_legacy.cpp (wersja 16539) +++ Scribus/scribus/canvasmode_legacy.cpp (kopia robocza) @@ -1802,7 +1802,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,ETEAinsertingText, cc); if (m_doc->docHyphenator->AutoCheck) m_doc->docHyphenator->slotHyphenate(currItem); m_ScMW->BookMarkTxT(currItem); Index: Scribus/scribus/pageitem.cpp =================================================================== --- Scribus/scribus/pageitem.cpp (wersja 16539) +++ Scribus/scribus/pageitem.cpp (kopia robocza) @@ -957,6 +957,46 @@ void PageItem::setGridOffset(double) { } // FIXME void PageItem::setGridDistance(double) { } // FIXME +void PageItem::setColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom) +{ + if (UndoManager::undoEnabled()) + { + SimpleState * ss; + if (asTextFrame()->getLastUndoAction() == STORY) + ss = (SimpleState*) undoManager->getLastUndoState(); + if (ss && ss->undoObject() == this && ss->contains("OLD_COLS")) + { + ss->set("NEW_COLS", newCols); + ss->set("NEW_GAP", newGap); + ss->set("NEW_DLEFT", newLeft); + ss->set("NEW_DRIGHT", newRight); + ss->set("NEW_DTOP", newTop); + ss->set("NEW_DBOTTOM", newBottom); + } + else + { + ss = new SimpleState(Um::setColsGapDist, QString(Um::setColsGapDist)); + ss->set("OLD_COLS", Cols); + ss->set("NEW_COLS", newCols); + ss->set("OLD_GAP", ColGap); + ss->set("NEW_GAP", newGap); + ss->set("OLD_DLEFT", Extra); + ss->set("NEW_DLEFT", newLeft); + ss->set("OLD_DRIGHT", RExtra); + ss->set("NEW_DRIGHT", newRight); + ss->set("OLD_DTOP", TExtra); + ss->set("NEW_DTOP", newTop); + ss->set("OLD_DBOTTOM", BExtra); + ss->set("NEW_DBOTTOM", newBottom); + undoManager->action(this, ss); + asTextFrame()->setLastUndoAction(STORY); + } + } + setColumns(newCols); + setColumnGap(newGap); + setTextToFrameDist(newLeft, newRight, newTop, newBottom); +} + void PageItem::setColumns(int n) { Cols = qMax(1, n); //FIXME: undo @@ -3256,6 +3296,8 @@ restoreLinkTextFrame(ss,isUndo); else if (ss->contains("UNLINK_TEXT_FRAME")) restoreUnlinkTextFrame(ss,isUndo); + else if (ss->contains("OLD_COLS")) + restoreColsGapDist(ss, isUndo); } if (!OnMasterPage.isEmpty()) m_Doc->setCurrentPage(oldCurrentPage); @@ -3506,6 +3548,16 @@ // m_Doc->chAbStyle(this, styleid); } +void PageItem::restoreColsGapDist(SimpleState *state, bool isUndo) +{ + if (isUndo) + setColsGapDist(state->getInt("OLD_COLS"), state->getDouble("OLD_GAP"), state->getDouble("OLD_DLEFT"), state->getDouble("OLD_DRIGHT"), state->getDouble("OLD_DTOP"), state->getDouble("OLD_DBOTTOM")); + else + setColsGapDist(state->getInt("NEW_COLS"), state->getDouble("NEW_GAP"), state->getDouble("NEW_DLEFT"), state->getDouble("NEW_DRIGHT"), state->getDouble("NEW_DTOP"), state->getDouble("NEW_DBOTTOM")); + select(); + update(); + asTextFrame()->clearLastUndoAction(); +} // FIXME: This must go into class ScribusDoc! // For now we'll just make it independent of 'this' -- AV @@ -3844,10 +3896,16 @@ { if (!isTextFrame()) return; + int oldSelStart = 0, oldSelLen = 0; + if (HasSel) + { + oldSelStart = itemText.startOfSelection(); + oldSelLen = itemText.lengthOfSelection(); + } 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 +3920,28 @@ 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(); + itemText.insert(SelStart, *story); int ItemLength = itemText.length(); - itemText.insert(SelStart, *story); // 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.select(SelStart, story->length()); - HasSel = true; + itemText.setStyle(-1, story->paragraphStyle(story->length())); + CPos = state->getInt("STEXT_CPOS"); } - CPos = itemText.endOfSelection(); delete story; } else { qDebug() << "UNDO buffer EMPTY";} @@ -3967,55 +4024,55 @@ } } // after Undo or Redo new actions should create new undoStates - asTextFrame()->lastUndoAction = NOACTION; + asTextFrame()->clearLastUndoAction(); + + if (oldSelLen >0 && (action == PARAGRAPH || action == SELECTION)) + asTextFrame()->restoreTextSelection(oldSelStart, oldSelLen); 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); @@ -4026,42 +4083,6 @@ return QString(xml.c_str()); } -QString PageItem::getItemTextSaxed(int selStart, int selLength) -{ - if (selStart < 0 || selLength < 0) - return QString(); - - StoryText it(m_Doc); - it.setDefaultStyle(itemText.defaultStyle()); - - int oldSelStart = -1, oldSelLength = -1; - oldSelStart = itemText.startOfSelection(); - oldSelLength = itemText.lengthOfSelection(); - - itemText.select(selStart, selLength); - it.insert(0, itemText, (selLength > 0)); - - if (oldSelLength > 0) //restoring old selection if undoItem was PARAPGRAPH - { - itemText.select(oldSelStart, oldSelLength); - HasSel = true; - } - else if (oldSelLength == 0) - { - itemText.deselectAll(); - HasSel = false; - } - - //saxing text - std::ostringstream xmlString; - SaxXML xmlStream(xmlString); - xmlStream.beginDoc(); - it.saxx(xmlStream, "SCRIBUSTEXT"); - xmlStream.endDoc(); - std::string xml(xmlString.str()); - return QString(xml.c_str()); -} - QString PageItem::getTextSaxed(QString str) { StoryText iT(m_Doc); @@ -4079,7 +4100,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 16539) +++ 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, ETEAclearContents); //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,22 +2743,19 @@ { 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; if (itemTextSaxed.isEmpty()) - updateUndo(INS, QString(QChar(conv))); + updateUndo(INS, ETEAinsertingText, QString(QChar(conv))); else - updateUndo(REPSAX, getTextSaxed(QString(QChar(conv)))); + updateUndo(REPSAX, ETEAreplacingText, getTextSaxed(QString(QChar(conv)))); // Tinput = true; m_Doc->scMW()->setTBvals(this); update(); @@ -3040,7 +3035,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); m_Doc->scMW()->setTBvals(this); update(); // view->RefreshItem(this); @@ -3062,7 +3057,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); update(); // Tinput = false; if ((cr == QChar(13)) && (itemText.length() != 0)) @@ -3081,7 +3076,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); m_Doc->scMW()->setTBvals(this); update(); } @@ -3099,7 +3094,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); // Tinput = false; if ((cr == QChar(13)) && (itemText.length() != 0)) { @@ -3130,7 +3125,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); doUpdate = true; } /* @@ -3149,11 +3144,11 @@ oldCPos = CPos; itemText.insertChars(CPos, QString(SpecialChars::TAB), true); CPos += 1; - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); if (itemTextSaxed.isEmpty()) - updateUndo(INS, QString(SpecialChars::TAB)); + updateUndo(INS, ETEAinsertingTabs, QString(SpecialChars::TAB)); else - updateUndo(REPSAX, getTextSaxed(QString(SpecialChars::TAB))); + updateUndo(REPSAX, ETEAinsertingTabs, getTextSaxed(QString(SpecialChars::TAB))); // Tinput = true; // view->RefreshItem(this); doUpdate = true; @@ -3161,15 +3156,15 @@ 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); CPos += 1; if (itemTextSaxed.isEmpty()) - updateUndo(INS, uc); + updateUndo(INS, ETEAinsertingText, uc); else - updateUndo(REPSAX, getTextSaxed(uc)); + updateUndo(REPSAX, ETEAreplacingText, getTextSaxed(uc)); if ((m_Doc->docHyphenator->AutoCheck) && (CPos > 1)) { Twort = ""; @@ -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,39 @@ invalidateLayout(); } -void PageItem_TextFrame::updateUndo(EditAct action, QString 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 +3689,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 +3714,33 @@ } 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: + case DELSAX: + case REPSAX: + case NOACTION: + default: + break; + } + if (newAction >0) + { + if (!descript.isEmpty()) + descript += "\n"; + descript += doc()->scMW()->actionManager->textEditActionDescriptions.value(newAction,""); + } + ss = new SimpleState(UndoManager::EditText, descript); ss->set("STEXT_CPOS", oldCPos); } if (action == INSSAX || action == INS) @@ -3727,24 +3754,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 +3775,7 @@ } itemTextSaxed.clear(); lastUndoAction = action; + lastExactEditAction = newAction; ss->set("STEXT",(int) action); if (newState) undoManager->action(this, ss); @@ -3764,6 +3786,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 16539) +++ Scribus/scribus/scribus.cpp (kopia robocza) @@ -1118,9 +1118,9 @@ currItem->oldCPos = currItem->CPos; currItem->itemText.insertChars(currItem->CPos, QString(QChar(unicodevalue)), true); if (currItem->itemTextSaxed.isEmpty()) - currItem->asTextFrame()->updateUndo(PageItem::INS, QString(QChar(unicodevalue))); + currItem->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingText, QString(QChar(unicodevalue))); else - currItem->asTextFrame()->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(QString(QChar(unicodevalue)))); + currItem->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAreplacingText, currItem->getTextSaxed(QString(QChar(unicodevalue)))); currItem->CPos += 1; // currItem->Tinput = true; currItem->update(); @@ -1139,7 +1139,7 @@ currItem->itemText.insertChars(currItem->CPos, QString(SpecialChars::SHYPHEN), true); currItem->oldCPos = currItem->CPos; currItem->CPos += 1; - currItem->asTextFrame()->updateUndo(PageItem::INS, QString(SpecialChars::SHYPHEN)); + currItem->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingText, QString(SpecialChars::SHYPHEN)); #endif // currItem->Tinput = true; currItem->update(); @@ -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, ETEAslotGetContent); } 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, ETEAslotGetContent); 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, ETEAslotFileAppend); } 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, ETEAdeletingText, 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, ETEAinsertingText, 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, ETEAinsertingText, currItem->getItemTextSaxed(PageItem::SELECTION)); } else { @@ -5280,9 +5281,9 @@ currItem->HasSel = true; //if itemTextSaxed is not empty there was selection if (currItem->itemTextSaxed.isEmpty()) - currItem->updateUndo(PageItem::INS, text); + currItem->updateUndo(PageItem::INS, ETEAinsertingText, text); else - currItem->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(text)); + currItem->updateUndo(PageItem::REPSAX, ETEAreplacingText, currItem->getTextSaxed(text)); } currItem->update(); @@ -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 16539) +++ 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,14 +3306,18 @@ doc->itemSelection_SetOpticalMargins(omt); if (CurItem->asTextFrame()) - CurItem->asTextFrame()->updateUndo(); + CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAsetOpticalMargins); } void PropertiesPalette::resetOpticalMargins() { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; + if (CurItem->asTextFrame()) + CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY); doc->itemSelection_resetOpticalMargins(); + if (CurItem->asTextFrame()) + CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAsetOpticalMargins); } void PropertiesPalette::updateOpticalMargins(const ParagraphStyle & pStyle) @@ -3339,12 +3339,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 +3353,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 +3367,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 +3380,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 +3404,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 +3415,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 +3446,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, ETEANewTScale); } void PropertiesPalette::NewX() @@ -3874,14 +3874,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() @@ -3901,7 +3897,7 @@ { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; - CurItem->Cols = DCol->value(); + CurItem->setColsGapDist(DCol->value(), CurItem->ColGap, CurItem->textToFrameDistLeft(), CurItem->textToFrameDistRight(), CurItem->textToFrameDistTop(), CurItem->textToFrameDistBottom()); setCols(CurItem->Cols, CurItem->ColGap); CurItem->update(); emit DocChanged(); @@ -3922,8 +3918,9 @@ { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; + double newGap; if (colgapLabel->currentIndex() == 0) - CurItem->ColGap = dGap->value() / m_unitRatio; + newGap = dGap->value() / m_unitRatio; else { double lineCorr; @@ -3932,9 +3929,9 @@ else lineCorr = 0; double newWidth = dGap->value() / m_unitRatio; - double newGap = qMax(((CurItem->width() - CurItem->textToFrameDistLeft() - CurItem->textToFrameDistRight() - lineCorr) - (newWidth * CurItem->Cols)) / (CurItem->Cols - 1), 0.0); - CurItem->ColGap = newGap; + newGap = qMax(((CurItem->width() - CurItem->textToFrameDistLeft() - CurItem->textToFrameDistRight() - lineCorr) - (newWidth * CurItem->Cols)) / (CurItem->Cols - 1), 0.0); } + CurItem->setColsGapDist(CurItem->Cols, newGap, CurItem->textToFrameDistLeft(), CurItem->textToFrameDistRight(), CurItem->textToFrameDistTop(), CurItem->textToFrameDistBottom()); CurItem->update(); emit DocChanged(); } @@ -3944,10 +3941,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 +3952,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 +4273,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 +4287,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 +4298,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 +4324,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 +4350,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 +4386,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); } } @@ -4677,7 +4652,7 @@ return; if ((HaveDoc) && (HaveItem)) { - CurItem->setTextToFrameDist(DLeft->value() / m_unitRatio, DRight->value() / m_unitRatio, DTop->value() / m_unitRatio, DBottom->value() / m_unitRatio); + CurItem->setColsGapDist(CurItem->Cols, CurItem->ColGap, DLeft->value() / m_unitRatio, DRight->value() / m_unitRatio, DTop->value() / m_unitRatio, DBottom->value() / m_unitRatio); setCols(CurItem->Cols, CurItem->ColGap); CurItem->update(); emit DocChanged(); @@ -4742,10 +4717,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 +4732,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 +4884,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 +4895,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 +4908,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 +4920,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 +5070,7 @@ CurItem->update(); qDebug() << "PropertiesPalette::handleFillRule() updateUNDO"; if (CurItem->asTextFrame()) - CurItem->asTextFrame()->updateUndo(); + CurItem->asTextFrame()->updateUndo(PageItem::STORY); emit DocChanged(); } @@ -5142,6 +5113,7 @@ if (CurItem->itemName() != NameEdit->text()) { CurItem->setItemName(NameEdit->text()); + CurItem->AutoName = false; emit DocChanged(); } } @@ -5184,10 +5156,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 +5171,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/undomanager.cpp =================================================================== --- Scribus/scribus/undomanager.cpp (wersja 16539) +++ Scribus/scribus/undomanager.cpp (kopia robocza) @@ -882,6 +882,7 @@ UndoManager::StartAndEndArrow = tr("Set start and end arrows"); UndoManager::CreateTable = tr("Create table"); UndoManager::RowsCols = tr("Rows: %1, Cols: %2"); + UndoManager::setColsGapDist = tr("Set columns, gap and text distances"); UndoManager::SetFont = tr("Set font"); UndoManager::SetFontSize = tr("Set font size"); UndoManager::SetFontWidth = tr("Set font width"); @@ -1094,6 +1095,7 @@ QString UndoManager::StartAndEndArrow = ""; QString UndoManager::CreateTable = ""; QString UndoManager::RowsCols = ""; +QString UndoManager::setColsGapDist = ""; QString UndoManager::SetFont = ""; QString UndoManager::SetFontSize = ""; QString UndoManager::SetFontWidth = ""; Index: Scribus/scribus/actionmanager.h =================================================================== --- Scribus/scribus/actionmanager.h (wersja 16539) +++ 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 16539) +++ 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,9 +346,9 @@ 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, ETEAinsertLoremIpsum, Lorip); else - currItem->asTextFrame()->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(Lorip)); + currItem->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertLoremIpsum, currItem->getTextSaxed(Lorip)); delete lp; //if (ScMW->view->SelItem.at(i)->Doc->docHyphenator->AutoCheck) Index: Scribus/scribus/undomanager.h =================================================================== --- Scribus/scribus/undomanager.h (wersja 16539) +++ Scribus/scribus/undomanager.h (kopia robocza) @@ -508,6 +508,7 @@ static QString StartAndEndArrow; static QString CreateTable; static QString RowsCols; + static QString setColsGapDist; static QString SetFont; static QString SetFontSize; static QString SetFontWidth; Index: Scribus/scribus/charselect.cpp =================================================================== --- Scribus/scribus/charselect.cpp (wersja 16539) +++ 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(); @@ -133,9 +133,9 @@ txtIns.append(ch); } if (m_Item->itemTextSaxed.isEmpty()) - m_Item->asTextFrame()->updateUndo(PageItem::INS, txtIns); + m_Item->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, txtIns); else - m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, m_Item->getTextSaxed(txtIns)); + m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertingSpecChar, m_Item->getTextSaxed(txtIns)); m_doc->updateFrameItems(); m_doc->view()->DrawNew(); m_doc->changed(); @@ -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(); @@ -162,9 +162,9 @@ m_Item->oldCPos = m_Item->CPos; m_Item->itemText.insertChars(m_Item->CPos, ch, true); if (m_Item->itemTextSaxed.isEmpty()) - m_Item->asTextFrame()->updateUndo(PageItem::INS, QString(ch)); + m_Item->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, QString(ch)); else - m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, m_Item->getTextSaxed(QString(ch))); + m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertingSpecChar, m_Item->getTextSaxed(QString(ch))); m_doc->updateFrameItems(); m_Item->CPos += 1; m_doc->view()->DrawNew(); Index: Scribus/scribus/canvasmode_edit.cpp =================================================================== --- Scribus/scribus/canvasmode_edit.cpp (wersja 16539) +++ Scribus/scribus/canvasmode_edit.cpp (kopia robocza) @@ -413,7 +413,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()) { @@ -660,7 +660,7 @@ if (currItem->asTextFrame()) { m_view->slotSetCurs(m->globalPos().x(), m->globalPos().y()); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); } } else @@ -678,7 +678,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) @@ -688,7 +688,7 @@ //m_view->slotDoCurs(true); m_view->requestMode(modeNormal); if (currItem->isTextFrame()) - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); return; } @@ -713,7 +713,7 @@ oldP = currItem->itemText.endOfSelection(); } currItem->asTextFrame()->itemText.extendSelection(oldP, currItem->CPos); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); oldCp = currItem->CPos; } else @@ -729,7 +729,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; } } @@ -737,7 +737,7 @@ { oldCp = currItem->CPos; currItem->itemText.deselectAll(); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); currItem->HasSel = false; } currItem->emitAllToGUI(); @@ -754,7 +754,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, ETEAinsertingText, 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 16539) +++ 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,8 +462,7 @@ // for itemText undo purpose int oldCPos; QString itemTextSaxed; - QString getItemTextSaxed(EditActPlace undoItem); - QString getItemTextSaxed(int selStart, int selLength); + QString getItemTextSaxed(EditAct action); QString getTextSaxed(QString str); /** Flag fuer PDF-Bookmark */ bool isBookmark; @@ -649,6 +642,7 @@ void setTextToFrameDistRight(double); void setTextToFrameDistTop(double); void setTextToFrameDistBottom(double); + void setColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom); void setColumns(int); void setColumnGap(double); void setGridOffset(double); @@ -1068,7 +1062,7 @@ void restoreArrow(SimpleState *state, bool isUndo, bool isStart); void restorePStyle(SimpleState *state, bool isUndo); - + void restoreColsGapDist(SimpleState *state, bool isUndo); void restoreType(SimpleState *state, bool isUndo); void restoreTextFlowing(SimpleState *state, bool isUndo); void restoreImageScaleMode(SimpleState *state, bool isUndo); @@ -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 16539) +++ Scribus/scribus/scribusstructs.h (kopia robocza) @@ -472,6 +472,51 @@ } }; + +//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, + ETEAclearContents = 30, + ETEAslotGetContent = 31, + ETEAslotFileAppend = 32, + ETEAinsertingText = 33, + ETEAinsertingSpecChar = 34, + ETEAinsertLoremIpsum = 35, + ETEAreplacingText = 36, + ETEAdeletingText = 37, + ETEAinsertingTabs = 38 +} exactlyEditAct; + #endif Index: Scribus/scribus/actionmanager.cpp =================================================================== --- Scribus/scribus/actionmanager.cpp (wersja 16539) +++ 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,53 @@ 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 text effects")); + 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 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")); + textEditActionDescriptions.insert(ETEAclearContents, QObject::tr("Clear contents")); + textEditActionDescriptions.insert(ETEAslotGetContent, QObject::tr("Load text file")); + textEditActionDescriptions.insert(ETEAslotFileAppend, QObject::tr("Append text file")); + textEditActionDescriptions.insert(ETEAinsertingText, QObject::tr("Inserting text")); + textEditActionDescriptions.insert(ETEAinsertingSpecChar, QObject::tr("Inserting special char")); + textEditActionDescriptions.insert(ETEAinsertLoremIpsum, QObject::tr("Inserting text example")); + textEditActionDescriptions.insert(ETEAreplacingText, QObject::tr("Replacing text")); + textEditActionDescriptions.insert(ETEAdeletingText, QObject::tr("Deleting text")); + textEditActionDescriptions.insert(ETEAinsertingTabs, QObject::tr("Inserting Tabs")); } - void ActionManager::initFileMenuActions() { QString name; @@ -1499,6 +1546,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 16539) +++ 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,8 @@ 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 restoreTextSelection(int selStart, int selLength); void deselectAll(); virtual void invalidateLayout(); @@ -104,12 +105,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() { lastUndoAction = PageItem::NOACTION; }; + EditAct getLastUndoAction() { return lastUndoAction; }; + void setLastUndoAction(EditAct action) { lastUndoAction = action; }; + void updateUndo(EditAct action, exactlyEditAct newAction, QString str = ""); + void updateUndo(EditAct action, QString str = "") { updateUndo(action, ETEAotherEditAction, str); }; private slots: void slotInvalidateLayout(); }; |
|
New fixed version of undo v. 2 patch. Bring fixes and new cool undo feature - undo/redo for columns, gaps and text distances. Hope it will be working well now. |
|
This is not Prima Aprilis... Another version of undo ver. 2 patch. Now it brings also undo for first line offset and for changing indents and margins by dragging indicators on ruler. As usual also some fixes and code cleaning. Enjoy! |
|
textUndo_010411.patch (91,884 bytes)
Index: Scribus/scribus/canvasmode_legacy.cpp =================================================================== --- Scribus/scribus/canvasmode_legacy.cpp (wersja 16545) +++ Scribus/scribus/canvasmode_legacy.cpp (kopia robocza) @@ -1802,7 +1802,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,ETEAinsertingText, cc); if (m_doc->docHyphenator->AutoCheck) m_doc->docHyphenator->slotHyphenate(currItem); m_ScMW->BookMarkTxT(currItem); Index: Scribus/scribus/pageitem.cpp =================================================================== --- Scribus/scribus/pageitem.cpp (wersja 16545) +++ Scribus/scribus/pageitem.cpp (kopia robocza) @@ -957,6 +957,50 @@ void PageItem::setGridOffset(double) { } // FIXME void PageItem::setGridDistance(double) { } // FIXME +void PageItem::setColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom) +{ + setUndoColsGapDist(newCols, newGap, newLeft, newRight, newTop, newBottom); + setColumns(newCols); + setColumnGap(newGap); + setTextToFrameDist(newLeft, newRight, newTop, newBottom); +} +void PageItem::setUndoColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom) +{ + if (UndoManager::undoEnabled()) + { + SimpleState * ss = NULL; + if (asTextFrame()->getLastUndoAction() == STORY && asTextFrame()->getLastETEA() == ETEAsetColsGapDist) + ss = (SimpleState*) undoManager->getLastUndoState(); + if (ss && ss->undoObject() == this && ss->contains("OLD_COLS")) + { + ss->set("NEW_COLS", newCols); + ss->set("NEW_GAP", newGap); + ss->set("NEW_DLEFT", newLeft); + ss->set("NEW_DRIGHT", newRight); + ss->set("NEW_DTOP", newTop); + ss->set("NEW_DBOTTOM", newBottom); + } + else + { + ss = new SimpleState(Um::setColsGapDist); + ss->set("OLD_COLS", Cols); + ss->set("NEW_COLS", newCols); + ss->set("OLD_GAP", ColGap); + ss->set("NEW_GAP", newGap); + ss->set("OLD_DLEFT", Extra); + ss->set("NEW_DLEFT", newLeft); + ss->set("OLD_DRIGHT", RExtra); + ss->set("NEW_DRIGHT", newRight); + ss->set("OLD_DTOP", TExtra); + ss->set("NEW_DTOP", newTop); + ss->set("OLD_DBOTTOM", BExtra); + ss->set("NEW_DBOTTOM", newBottom); + undoManager->action(this, ss); + asTextFrame()->setLastUndoAction(STORY); + asTextFrame()->setLastETEA(ETEAsetColsGapDist); + } + } +} void PageItem::setColumns(int n) { Cols = qMax(1, n); //FIXME: undo @@ -3143,6 +3187,9 @@ } if (ss) { + //for autoselecting item on undo/redo + m_Doc->scMW()->selectItemsFromOutlines(this); + if (ss->contains("OLD_XPOS")) restoreMove(ss, isUndo); else if (ss->contains("OLD_HEIGHT")) @@ -3256,6 +3303,8 @@ restoreLinkTextFrame(ss,isUndo); else if (ss->contains("UNLINK_TEXT_FRAME")) restoreUnlinkTextFrame(ss,isUndo); + else if (ss->contains("OLD_COLS")) + restoreColsGapDist(ss, isUndo); } if (!OnMasterPage.isEmpty()) m_Doc->setCurrentPage(oldCurrentPage); @@ -3506,6 +3555,15 @@ // m_Doc->chAbStyle(this, styleid); } +void PageItem::restoreColsGapDist(SimpleState *state, bool isUndo) +{ + if (isUndo) + setColsGapDist(state->getInt("OLD_COLS"), state->getDouble("OLD_GAP"), state->getDouble("OLD_DLEFT"), state->getDouble("OLD_DRIGHT"), state->getDouble("OLD_DTOP"), state->getDouble("OLD_DBOTTOM")); + else + setColsGapDist(state->getInt("NEW_COLS"), state->getDouble("NEW_GAP"), state->getDouble("NEW_DLEFT"), state->getDouble("NEW_DRIGHT"), state->getDouble("NEW_DTOP"), state->getDouble("NEW_DBOTTOM")); + update(); + asTextFrame()->clearLastUndoAction(); +} // FIXME: This must go into class ScribusDoc! // For now we'll just make it independent of 'this' -- AV @@ -3671,7 +3729,17 @@ } } +void PageItem::restoreFirstLineOffset(SimpleState *state, bool isUndo) +{ + if (isUndo) + setFirstLineOffset((FirstLineOffsetPolicy)state->getInt("OLD_FLOP")); + else + setFirstLineOffset((FirstLineOffsetPolicy)state->getInt("NEW_FLOP")); + update(); + asTextFrame()->clearLastUndoAction(); +} + void PageItem::restorePoly(SimpleState *state, bool isUndo, bool isContour) { int mode = state->getInt("MODE"); @@ -3844,10 +3912,16 @@ { if (!isTextFrame()) return; + int oldSelStart = 0, oldSelLen = 0; + if (HasSel) + { + oldSelStart = itemText.startOfSelection(); + oldSelLen = itemText.lengthOfSelection(); + } 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 +3936,28 @@ 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(); + itemText.insert(SelStart, *story); int ItemLength = itemText.length(); - itemText.insert(SelStart, *story); // 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.select(SelStart, story->length()); - HasSel = true; + itemText.setStyle(-1, story->paragraphStyle(story->length())); + CPos = state->getInt("STEXT_CPOS"); } - CPos = itemText.endOfSelection(); delete story; } else { qDebug() << "UNDO buffer EMPTY";} @@ -3967,55 +4040,55 @@ } } // after Undo or Redo new actions should create new undoStates - asTextFrame()->lastUndoAction = NOACTION; + asTextFrame()->clearLastUndoAction(); + + if (oldSelLen >0 && (action == PARAGRAPH || action == SELECTION)) + asTextFrame()->restoreTextSelection(oldSelStart, oldSelLen); 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); @@ -4026,42 +4099,6 @@ return QString(xml.c_str()); } -QString PageItem::getItemTextSaxed(int selStart, int selLength) -{ - if (selStart < 0 || selLength < 0) - return QString(); - - StoryText it(m_Doc); - it.setDefaultStyle(itemText.defaultStyle()); - - int oldSelStart = -1, oldSelLength = -1; - oldSelStart = itemText.startOfSelection(); - oldSelLength = itemText.lengthOfSelection(); - - itemText.select(selStart, selLength); - it.insert(0, itemText, (selLength > 0)); - - if (oldSelLength > 0) //restoring old selection if undoItem was PARAPGRAPH - { - itemText.select(oldSelStart, oldSelLength); - HasSel = true; - } - else if (oldSelLength == 0) - { - itemText.deselectAll(); - HasSel = false; - } - - //saxing text - std::ostringstream xmlString; - SaxXML xmlStream(xmlString); - xmlStream.beginDoc(); - it.saxx(xmlStream, "SCRIBUSTEXT"); - xmlStream.endDoc(); - std::string xml(xmlString.str()); - return QString(xml.c_str()); -} - QString PageItem::getTextSaxed(QString str) { StoryText iT(m_Doc); @@ -4079,7 +4116,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); @@ -5985,6 +6022,31 @@ return firstLineOffsetP; } +void PageItem::setFirstLineOffset(FirstLineOffsetPolicy flop, bool createUndo) +{ + if(firstLineOffsetP != flop) + { + if (createUndo && UndoManager::undoEnabled()) + { + SimpleState * ss = NULL; + if (asTextFrame()->getLastUndoAction() == STORY && asTextFrame()->getLastETEA() == ETEAsetFirstLineOffset) + ss = (SimpleState*) undoManager->getLastUndoState(); + if (ss && ss->undoObject() == this && ss->contains("OLD_FLOP")) + ss->set("NEW_FLOP", flop); + else + { + ss = new SimpleState(Um::SetFirstLineOffset); + ss->set("OLD_FLOP", (int) firstLineOffsetP); + ss->set("NEW_FLOP", flop); + undoManager->action(this, ss); + asTextFrame()->setLastUndoAction(STORY); + asTextFrame()->setLastETEA(ETEAsetFirstLineOffset); + } + } + firstLineOffsetP = flop; + } +} + void PageItem::setFirstLineOffset(FirstLineOffsetPolicy flop) { if(firstLineOffsetP != flop) @@ -5994,6 +6056,3 @@ } - - - Index: Scribus/scribus/pageitem_textframe.cpp =================================================================== --- Scribus/scribus/pageitem_textframe.cpp (wersja 16539) +++ 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" @@ -69,8 +69,7 @@ unicodeTextEditMode = false; unicodeInputCount = 0; unicodeInputString = ""; - lastUndoAction = NOACTION; -// lastAction4Paragraph = false; + clearLastUndoAction(); connect(&itemText,SIGNAL(changed()), this, SLOT(slotInvalidateLayout())); } @@ -82,8 +81,7 @@ unicodeTextEditMode = false; unicodeInputCount = 0; unicodeInputString = ""; - lastUndoAction = NOACTION; -// lastAction4Paragraph = false; + clearLastUndoAction(); 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, ETEAclearContents); //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,22 +2743,19 @@ { 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; if (itemTextSaxed.isEmpty()) - updateUndo(INS, QString(QChar(conv))); + updateUndo(INS, ETEAinsertingText, QString(QChar(conv))); else - updateUndo(REPSAX, getTextSaxed(QString(QChar(conv)))); + updateUndo(REPSAX, ETEAreplacingText, getTextSaxed(QString(QChar(conv)))); // Tinput = true; m_Doc->scMW()->setTBvals(this); update(); @@ -3040,7 +3035,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); m_Doc->scMW()->setTBvals(this); update(); // view->RefreshItem(this); @@ -3062,7 +3057,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); update(); // Tinput = false; if ((cr == QChar(13)) && (itemText.length() != 0)) @@ -3081,7 +3076,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); m_Doc->scMW()->setTBvals(this); update(); } @@ -3099,7 +3094,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); // Tinput = false; if ((cr == QChar(13)) && (itemText.length() != 0)) { @@ -3130,7 +3125,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); doUpdate = true; } /* @@ -3149,11 +3144,11 @@ oldCPos = CPos; itemText.insertChars(CPos, QString(SpecialChars::TAB), true); CPos += 1; - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); if (itemTextSaxed.isEmpty()) - updateUndo(INS, QString(SpecialChars::TAB)); + updateUndo(INS, ETEAManageTabs, QString(SpecialChars::TAB)); else - updateUndo(REPSAX, getTextSaxed(QString(SpecialChars::TAB))); + updateUndo(REPSAX, ETEAManageTabs, getTextSaxed(QString(SpecialChars::TAB))); // Tinput = true; // view->RefreshItem(this); doUpdate = true; @@ -3161,15 +3156,15 @@ 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; - if (lastUndoAction != PageItem::INS) + clearLastUndoAction(); + if (getLastUndoAction() != PageItem::INS) oldCPos = CPos; itemText.insertChars(CPos, uc, true); CPos += 1; if (itemTextSaxed.isEmpty()) - updateUndo(INS, uc); + updateUndo(INS, ETEAinsertingText, uc); else - updateUndo(REPSAX, getTextSaxed(uc)); + updateUndo(REPSAX, ETEAreplacingText, getTextSaxed(uc)); if ((m_Doc->docHyphenator->AutoCheck) && (CPos > 1)) { Twort = ""; @@ -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,48 +3646,62 @@ invalidateLayout(); } -void PageItem_TextFrame::updateUndo(EditAct action, QString str) +void PageItem_TextFrame::updateUndo(EditAct action, exactlyTextEditAct 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; } SimpleState* ss; bool newState = true; // indicate when new undoState should be created - if (lastUndoAction == action && action != REPSAX && action != DELSAX) + if (getLastUndoAction() == action && action != REPSAX && action != DELSAX) { 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 (getLastETEA() == 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 +3714,33 @@ } 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: + case DELSAX: + case REPSAX: + case NOACTION: + default: + break; + } + if (newAction >0) + { + if (!descript.isEmpty()) + descript += "\n"; + descript += doc()->scMW()->actionManager->textEditActionDescriptions.value(newAction,""); + } + ss = new SimpleState(UndoManager::EditText, descript); ss->set("STEXT_CPOS", oldCPos); } if (action == INSSAX || action == INS) @@ -3727,24 +3754,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) @@ -3753,7 +3774,8 @@ } } itemTextSaxed.clear(); - lastUndoAction = action; + setLastUndoAction(action); + setLastETEA(newAction); ss->set("STEXT",(int) action); if (newState) undoManager->action(this, ss); @@ -3764,6 +3786,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 16545) +++ Scribus/scribus/scribus.cpp (kopia robocza) @@ -1118,9 +1118,9 @@ currItem->oldCPos = currItem->CPos; currItem->itemText.insertChars(currItem->CPos, QString(QChar(unicodevalue)), true); if (currItem->itemTextSaxed.isEmpty()) - currItem->asTextFrame()->updateUndo(PageItem::INS, QString(QChar(unicodevalue))); + currItem->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingText, QString(QChar(unicodevalue))); else - currItem->asTextFrame()->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(QString(QChar(unicodevalue)))); + currItem->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAreplacingText, currItem->getTextSaxed(QString(QChar(unicodevalue)))); currItem->CPos += 1; // currItem->Tinput = true; currItem->update(); @@ -1139,7 +1139,7 @@ currItem->itemText.insertChars(currItem->CPos, QString(SpecialChars::SHYPHEN), true); currItem->oldCPos = currItem->CPos; currItem->CPos += 1; - currItem->asTextFrame()->updateUndo(PageItem::INS, QString(SpecialChars::SHYPHEN)); + currItem->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, QString(SpecialChars::SHYPHEN)); #endif // currItem->Tinput = true; currItem->update(); @@ -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, ETEAslotGetContent); } 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, ETEAslotGetContent); 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, ETEAslotFileAppend); } 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, ETEAdeletingText, 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, ETEAinsertingText, 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, ETEAinsertingText, currItem->getItemTextSaxed(PageItem::SELECTION)); } else { @@ -5280,9 +5281,9 @@ currItem->HasSel = true; //if itemTextSaxed is not empty there was selection if (currItem->itemTextSaxed.isEmpty()) - currItem->updateUndo(PageItem::INS, text); + currItem->updateUndo(PageItem::INS, ETEAinsertingText, text); else - currItem->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(text)); + currItem->updateUndo(PageItem::REPSAX, ETEAreplacingText, currItem->getTextSaxed(text)); } currItem->update(); @@ -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 16545) +++ 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,14 +3306,18 @@ doc->itemSelection_SetOpticalMargins(omt); if (CurItem->asTextFrame()) - CurItem->asTextFrame()->updateUndo(); + CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAsetOpticalMargins); } void PropertiesPalette::resetOpticalMargins() { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; + if (CurItem->asTextFrame()) + CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY); doc->itemSelection_resetOpticalMargins(); + if (CurItem->asTextFrame()) + CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAsetOpticalMargins); } void PropertiesPalette::updateOpticalMargins(const ParagraphStyle & pStyle) @@ -3339,12 +3339,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 +3353,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 +3367,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 +3380,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 +3404,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 +3415,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 +3446,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, ETEANewTScale); } void PropertiesPalette::NewX() @@ -3874,14 +3874,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() @@ -3901,7 +3897,7 @@ { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; - CurItem->Cols = DCol->value(); + CurItem->setColsGapDist(DCol->value(), CurItem->ColGap, CurItem->textToFrameDistLeft(), CurItem->textToFrameDistRight(), CurItem->textToFrameDistTop(), CurItem->textToFrameDistBottom()); setCols(CurItem->Cols, CurItem->ColGap); CurItem->update(); emit DocChanged(); @@ -3922,8 +3918,9 @@ { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; + double newGap; if (colgapLabel->currentIndex() == 0) - CurItem->ColGap = dGap->value() / m_unitRatio; + newGap = dGap->value() / m_unitRatio; else { double lineCorr; @@ -3932,9 +3929,9 @@ else lineCorr = 0; double newWidth = dGap->value() / m_unitRatio; - double newGap = qMax(((CurItem->width() - CurItem->textToFrameDistLeft() - CurItem->textToFrameDistRight() - lineCorr) - (newWidth * CurItem->Cols)) / (CurItem->Cols - 1), 0.0); - CurItem->ColGap = newGap; + newGap = qMax(((CurItem->width() - CurItem->textToFrameDistLeft() - CurItem->textToFrameDistRight() - lineCorr) - (newWidth * CurItem->Cols)) / (CurItem->Cols - 1), 0.0); } + CurItem->setColsGapDist(CurItem->Cols, newGap, CurItem->textToFrameDistLeft(), CurItem->textToFrameDistRight(), CurItem->textToFrameDistTop(), CurItem->textToFrameDistBottom()); CurItem->update(); emit DocChanged(); } @@ -3944,10 +3941,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 +3952,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 +4273,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 +4287,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 +4298,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 +4324,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 +4350,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 +4386,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); } } @@ -4677,7 +4652,7 @@ return; if ((HaveDoc) && (HaveItem)) { - CurItem->setTextToFrameDist(DLeft->value() / m_unitRatio, DRight->value() / m_unitRatio, DTop->value() / m_unitRatio, DBottom->value() / m_unitRatio); + CurItem->setColsGapDist(CurItem->Cols, CurItem->ColGap, DLeft->value() / m_unitRatio, DRight->value() / m_unitRatio, DTop->value() / m_unitRatio, DBottom->value() / m_unitRatio); setCols(CurItem->Cols, CurItem->ColGap); CurItem->update(); emit DocChanged(); @@ -4742,10 +4717,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 +4732,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 +4884,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 +4895,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 +4908,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 +4920,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) @@ -5097,10 +5068,6 @@ return; CurItem->fillRule = EvenOdd->isChecked(); CurItem->update(); - qDebug() << "PropertiesPalette::handleFillRule() updateUNDO"; - if (CurItem->asTextFrame()) - CurItem->asTextFrame()->updateUndo(); - emit DocChanged(); } @@ -5142,6 +5109,7 @@ if (CurItem->itemName() != NameEdit->text()) { CurItem->setItemName(NameEdit->text()); + CurItem->AutoName = false; emit DocChanged(); } } @@ -5184,10 +5152,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 +5167,7 @@ } CurItem->update(); if (CurItem->asTextFrame()) - CurItem->asTextFrame()->updateUndo(); + CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAManageTabs); emit DocChanged(); } @@ -5915,11 +5880,11 @@ return; // qDebug("%s", QString("rF %1").arg(radioFlop).toAscii()); if( radioFlop == 0) - CurItem->setFirstLineOffset(FLOPRealGlyphHeight); + CurItem->setFirstLineOffset(FLOPRealGlyphHeight, true); else if( radioFlop == 1) - CurItem->setFirstLineOffset(FLOPFontAscent); + CurItem->setFirstLineOffset(FLOPFontAscent, true); else if( radioFlop == 2) - CurItem->setFirstLineOffset(FLOPLineSpacing); + CurItem->setFirstLineOffset(FLOPLineSpacing, true); CurItem->update(); emit DocChanged(); } Index: Scribus/scribus/undomanager.cpp =================================================================== --- Scribus/scribus/undomanager.cpp (wersja 16545) +++ Scribus/scribus/undomanager.cpp (kopia robocza) @@ -882,6 +882,7 @@ UndoManager::StartAndEndArrow = tr("Set start and end arrows"); UndoManager::CreateTable = tr("Create table"); UndoManager::RowsCols = tr("Rows: %1, Cols: %2"); + UndoManager::setColsGapDist = tr("Set columns, gap and text distances"); UndoManager::SetFont = tr("Set font"); UndoManager::SetFontSize = tr("Set font size"); UndoManager::SetFontWidth = tr("Set font width"); @@ -896,6 +897,7 @@ UndoManager::SetLanguage = tr("Set language"); UndoManager::AlignText = tr("Align text"); UndoManager::SetFontEffect = tr("Set font effect"); + UndoManager::SetFirstLineOffset = tr("Set first line offset"); UndoManager::ImageFrame = tr("Image frame"); UndoManager::TextFrame = tr("Text frame"); UndoManager::LatexFrame = tr("Render frame"); @@ -1094,6 +1096,7 @@ QString UndoManager::StartAndEndArrow = ""; QString UndoManager::CreateTable = ""; QString UndoManager::RowsCols = ""; +QString UndoManager::setColsGapDist = ""; QString UndoManager::SetFont = ""; QString UndoManager::SetFontSize = ""; QString UndoManager::SetFontWidth = ""; @@ -1108,6 +1111,7 @@ QString UndoManager::SetLanguage = ""; QString UndoManager::AlignText = ""; QString UndoManager::SetFontEffect = ""; +QString UndoManager::SetFirstLineOffset = ""; QString UndoManager::ImageFrame = ""; QString UndoManager::TextFrame = ""; QString UndoManager::LatexFrame = ""; Index: Scribus/scribus/actionmanager.h =================================================================== --- Scribus/scribus/actionmanager.h (wersja 16545) +++ 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<exactlyTextEditAct,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 16545) +++ 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,9 +346,9 @@ 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, ETEAinsertLoremIpsum, Lorip); else - currItem->asTextFrame()->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(Lorip)); + currItem->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertLoremIpsum, currItem->getTextSaxed(Lorip)); delete lp; //if (ScMW->view->SelItem.at(i)->Doc->docHyphenator->AutoCheck) Index: Scribus/scribus/undomanager.h =================================================================== --- Scribus/scribus/undomanager.h (wersja 16545) +++ Scribus/scribus/undomanager.h (kopia robocza) @@ -508,6 +508,7 @@ static QString StartAndEndArrow; static QString CreateTable; static QString RowsCols; + static QString setColsGapDist; static QString SetFont; static QString SetFontSize; static QString SetFontWidth; @@ -522,6 +523,7 @@ static QString SetLanguage; static QString AlignText; static QString SetFontEffect; + static QString SetFirstLineOffset; static QString ImageFrame; static QString TextFrame; static QString LatexFrame; Index: Scribus/scribus/hruler.cpp =================================================================== --- Scribus/scribus/hruler.cpp (wersja 16545) +++ Scribus/scribus/hruler.cpp (kopia robocza) @@ -34,6 +34,7 @@ #include "canvasgesture_rulermove.h" #include "hruler.h" #include "page.h" +#include "pageitem_textframe.h" #include "prefsmanager.h" #include "scribus.h" #include "scribusdoc.h" @@ -241,14 +242,17 @@ { bool mustApplyStyle = false; ParagraphStyle paraStyle; - double ColWidth = (textWidth() - ColGap * (Cols - 1)) / Cols; + double ColWidth = (textWidth() - ColGap * (Cols - 1)) / Cols; + exactlyTextEditAct ETEA = ETEAsetIndentMargs; switch (RulerCode) { case rc_leftFrameDist: + currDoc->m_Selection->itemAt(0)->setUndoColsGapDist(Cols, ColGap, Extra, RExtra, currDoc->m_Selection->itemAt(0)->textToFrameDistTop(), currDoc->m_Selection->itemAt(0)->textToFrameDistBottom()); currDoc->m_Selection->itemAt(0)->setTextToFrameDistLeft(Extra); emit DocChanged(false); break; case rc_rightFrameDist: + currDoc->m_Selection->itemAt(0)->setUndoColsGapDist(Cols, ColGap, Extra, RExtra, currDoc->m_Selection->itemAt(0)->textToFrameDistTop(), currDoc->m_Selection->itemAt(0)->textToFrameDistBottom()); currDoc->m_Selection->itemAt(0)->setTextToFrameDistRight(RExtra); emit DocChanged(false); break; @@ -269,6 +273,7 @@ emit DocChanged(false); break; case rc_tab: + ETEA = ETEAManageTabs; if (m->button() == Qt::RightButton) { TabValues[ActTab].tabType += 1; @@ -284,9 +289,11 @@ } if (mustApplyStyle) { + currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::PARAGRAPH); Selection tempSelection(this, false); tempSelection.addItem(currItem); currDoc->itemSelection_ApplyParagraphStyle(paraStyle, &tempSelection); + currItem->asTextFrame()->updateUndo(PageItem::PARAGRAPH, ETEA); } else { @@ -297,6 +304,7 @@ { if (RulerCode == rc_tab) { + currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::PARAGRAPH); TabValues.removeAt(ActTab); ActTab = 0; ParagraphStyle paraStyle; @@ -304,6 +312,7 @@ Selection tempSelection(this, false); tempSelection.addItem(currItem); currDoc->itemSelection_ApplyParagraphStyle(paraStyle, &tempSelection); + currItem->asTextFrame()->updateUndo(PageItem::PARAGRAPH, ETEAManageTabs); emit DocChanged(false); qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); } Index: Scribus/scribus/charselect.cpp =================================================================== --- Scribus/scribus/charselect.cpp (wersja 16545) +++ 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(); @@ -133,9 +133,9 @@ txtIns.append(ch); } if (m_Item->itemTextSaxed.isEmpty()) - m_Item->asTextFrame()->updateUndo(PageItem::INS, txtIns); + m_Item->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, txtIns); else - m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, m_Item->getTextSaxed(txtIns)); + m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertingSpecChar, m_Item->getTextSaxed(txtIns)); m_doc->updateFrameItems(); m_doc->view()->DrawNew(); m_doc->changed(); @@ -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(); @@ -162,9 +162,9 @@ m_Item->oldCPos = m_Item->CPos; m_Item->itemText.insertChars(m_Item->CPos, ch, true); if (m_Item->itemTextSaxed.isEmpty()) - m_Item->asTextFrame()->updateUndo(PageItem::INS, QString(ch)); + m_Item->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, QString(ch)); else - m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, m_Item->getTextSaxed(QString(ch))); + m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertingSpecChar, m_Item->getTextSaxed(QString(ch))); m_doc->updateFrameItems(); m_Item->CPos += 1; m_doc->view()->DrawNew(); Index: Scribus/scribus/canvasmode_edit.cpp =================================================================== --- Scribus/scribus/canvasmode_edit.cpp (wersja 16545) +++ Scribus/scribus/canvasmode_edit.cpp (kopia robocza) @@ -413,7 +413,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()) { @@ -660,7 +660,7 @@ if (currItem->asTextFrame()) { m_view->slotSetCurs(m->globalPos().x(), m->globalPos().y()); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); } } else @@ -678,7 +678,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) @@ -688,7 +688,7 @@ //m_view->slotDoCurs(true); m_view->requestMode(modeNormal); if (currItem->isTextFrame()) - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); return; } @@ -713,7 +713,7 @@ oldP = currItem->itemText.endOfSelection(); } currItem->asTextFrame()->itemText.extendSelection(oldP, currItem->CPos); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); oldCp = currItem->CPos; } else @@ -729,7 +729,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; } } @@ -737,7 +737,7 @@ { oldCp = currItem->CPos; currItem->itemText.deselectAll(); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); currItem->HasSel = false; } currItem->emitAllToGUI(); @@ -754,7 +754,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, ETEAinsertingText, 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 16545) +++ 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,8 +462,7 @@ // for itemText undo purpose int oldCPos; QString itemTextSaxed; - QString getItemTextSaxed(EditActPlace undoItem); - QString getItemTextSaxed(int selStart, int selLength); + QString getItemTextSaxed(EditAct action); QString getTextSaxed(QString str); /** Flag fuer PDF-Bookmark */ bool isBookmark; @@ -649,12 +642,15 @@ void setTextToFrameDistRight(double); void setTextToFrameDistTop(double); void setTextToFrameDistBottom(double); + void setColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom); + void setUndoColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom); void setColumns(int); void setColumnGap(double); void setGridOffset(double); void setGridDistance(double); FirstLineOffsetPolicy firstLineOffset()const; void setFirstLineOffset(FirstLineOffsetPolicy); + void setFirstLineOffset(FirstLineOffsetPolicy, bool createundo); /** * \brief Set the text to frame distances all at once * @param newLeft left distance @@ -1068,7 +1064,7 @@ void restoreArrow(SimpleState *state, bool isUndo, bool isStart); void restorePStyle(SimpleState *state, bool isUndo); - + void restoreColsGapDist(SimpleState *state, bool isUndo); void restoreType(SimpleState *state, bool isUndo); void restoreTextFlowing(SimpleState *state, bool isUndo); void restoreImageScaleMode(SimpleState *state, bool isUndo); @@ -1087,6 +1083,8 @@ void restoreEditText(SimpleState *state, bool isUndo); void restoreLinkTextFrame(UndoState *state, bool isUndo); void restoreUnlinkTextFrame(UndoState *state, bool isUndo); + void restoreFirstLineOffset(SimpleState *state, bool isUndo); + /*@}*/ /** Index: Scribus/scribus/scribusstructs.h =================================================================== --- Scribus/scribus/scribusstructs.h (wersja 16545) +++ Scribus/scribus/scribusstructs.h (kopia robocza) @@ -472,6 +472,54 @@ } }; + +//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, + ETEAclearContents = 30, + ETEAslotGetContent = 31, + ETEAslotFileAppend = 32, + ETEAinsertingText = 33, + ETEAinsertingSpecChar = 34, + ETEAinsertLoremIpsum = 35, + ETEAreplacingText = 36, + ETEAdeletingText = 37, + //ETEAinsertingTabs = 38, + ETEAsetColsGapDist = 39, + ETEAsetIndentMargs = 40, + ETEAsetFirstLineOffset = 41 +} exactlyTextEditAct; + #endif Index: Scribus/scribus/actionmanager.cpp =================================================================== --- Scribus/scribus/actionmanager.cpp (wersja 16545) +++ 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,56 @@ 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 text effects")); + 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 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")); + textEditActionDescriptions.insert(ETEAclearContents, QObject::tr("Clear contents")); + textEditActionDescriptions.insert(ETEAslotGetContent, QObject::tr("Load text file")); + textEditActionDescriptions.insert(ETEAslotFileAppend, QObject::tr("Append text file")); + textEditActionDescriptions.insert(ETEAinsertingText, QObject::tr("Inserting text")); + textEditActionDescriptions.insert(ETEAinsertingSpecChar, QObject::tr("Inserting special char")); + textEditActionDescriptions.insert(ETEAinsertLoremIpsum, QObject::tr("Inserting text example")); + textEditActionDescriptions.insert(ETEAreplacingText, QObject::tr("Replacing text")); + textEditActionDescriptions.insert(ETEAdeletingText, QObject::tr("Deleting text")); + // better merge it with "ManageTabs" + //textEditActionDescriptions.insert(ETEAinsertingTabs, QObject::tr("Inserting Tabs")); + textEditActionDescriptions.insert(ETEAsetColsGapDist, QObject::tr("Manage columns, gaps, distances")); + textEditActionDescriptions.insert(ETEAsetIndentMargs, QObject::tr("Manage indents and margins")); + textEditActionDescriptions.insert(ETEAsetFirstLineOffset, QObject::tr("Set first line offset")); +} void ActionManager::initFileMenuActions() { QString name; @@ -1499,6 +1549,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 16545) +++ 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,8 @@ 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 restoreTextSelection(int selStart, int selLength); void deselectAll(); virtual void invalidateLayout(); @@ -104,12 +105,20 @@ bool cursorBiasBackward; void setShadow(); - void restoreTextSelection(int selStart, int selLength); QString currentShadow; QMap<QString,StoryText> shadows; + + EditAct lastTextUndoAction; + exactlyTextEditAct lastETEA; + public: - void updateUndo(EditAct action = PARAMFULL, QString str = ""); - EditAct lastUndoAction; + void clearLastUndoAction() { lastTextUndoAction = PageItem::NOACTION; }; + EditAct getLastUndoAction() { return lastTextUndoAction; }; + exactlyTextEditAct getLastETEA() { return lastETEA; }; + void setLastUndoAction(EditAct action) { lastTextUndoAction = action; }; + void setLastETEA(exactlyTextEditAct ETEA) { lastETEA = ETEA; }; + void updateUndo(EditAct action, exactlyTextEditAct newAction, QString str = ""); + void updateUndo(EditAct action, QString str = "") { updateUndo(action, ETEAotherEditAction, str); }; private slots: void slotInvalidateLayout(); }; |
|
Cezary, as I noted recently, you *must* have a unique identifier in the texts going into the undo functions, eg setUndoColsGapDist should have something like the image scale code has: ss->set("IMAGE_SCALE", "image_scale"); ss->set("OLD_IMAGEXSCALE", oldLocalScX); ss->set("OLD_IMAGEYSCALE", oldLocalScY); ss->set("NEW_IMAGEXSCALE", LocalScX); ss->set("NEW_IMAGEYSCALE", LocalScY); Ie, you need to record the action, in this case IMAGE_SCALE along with the values, or the else if (ss->contains("IMAGE_SCALE")) etc code in the ::restore() functions can find any, eg the SCALE_TYPE function could find the other scale stuff it it only searched for OLD_IMAGEXSCALE. |
|
OK, I fix that in new version of patch. |
|
textUndo_050411.patch (92,127 bytes)
Index: Scribus/scribus/canvasmode_legacy.cpp =================================================================== --- Scribus/scribus/canvasmode_legacy.cpp (wersja 16552) +++ Scribus/scribus/canvasmode_legacy.cpp (kopia robocza) @@ -1802,7 +1802,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,ETEAinsertingText, cc); if (m_doc->docHyphenator->AutoCheck) m_doc->docHyphenator->slotHyphenate(currItem); m_ScMW->BookMarkTxT(currItem); Index: Scribus/scribus/pageitem.cpp =================================================================== --- Scribus/scribus/pageitem.cpp (wersja 16552) +++ Scribus/scribus/pageitem.cpp (kopia robocza) @@ -957,6 +957,51 @@ void PageItem::setGridOffset(double) { } // FIXME void PageItem::setGridDistance(double) { } // FIXME +void PageItem::setColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom) +{ + setUndoColsGapDist(newCols, newGap, newLeft, newRight, newTop, newBottom); + setColumns(newCols); + setColumnGap(newGap); + setTextToFrameDist(newLeft, newRight, newTop, newBottom); +} +void PageItem::setUndoColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom) +{ + if (UndoManager::undoEnabled()) + { + SimpleState * ss = NULL; + if (asTextFrame()->getLastUndoAction() == STORY && asTextFrame()->getLastETEA() == ETEAsetColsGapDist) + ss = (SimpleState*) undoManager->getLastUndoState(); + if (ss && ss->undoObject() == this && ss->contains("COLSGAPDIST")) + { + ss->set("NEW_COLS", newCols); + ss->set("NEW_GAP", newGap); + ss->set("NEW_DLEFT", newLeft); + ss->set("NEW_DRIGHT", newRight); + ss->set("NEW_DTOP", newTop); + ss->set("NEW_DBOTTOM", newBottom); + } + else + { + ss = new SimpleState(Um::setColsGapDist); + ss->set("COLSGAPDIST","ColsGapDist"); + ss->set("OLD_COLS", Cols); + ss->set("NEW_COLS", newCols); + ss->set("OLD_GAP", ColGap); + ss->set("NEW_GAP", newGap); + ss->set("OLD_DLEFT", Extra); + ss->set("NEW_DLEFT", newLeft); + ss->set("OLD_DRIGHT", RExtra); + ss->set("NEW_DRIGHT", newRight); + ss->set("OLD_DTOP", TExtra); + ss->set("NEW_DTOP", newTop); + ss->set("OLD_DBOTTOM", BExtra); + ss->set("NEW_DBOTTOM", newBottom); + undoManager->action(this, ss); + asTextFrame()->setLastUndoAction(STORY); + asTextFrame()->setLastETEA(ETEAsetColsGapDist); + } + } +} void PageItem::setColumns(int n) { Cols = qMax(1, n); //FIXME: undo @@ -3143,6 +3188,9 @@ } if (ss) { + //for autoselecting item on undo/redo + m_Doc->scMW()->selectItemsFromOutlines(this); + if (ss->contains("OLD_XPOS")) restoreMove(ss, isUndo); else if (ss->contains("OLD_HEIGHT")) @@ -3256,6 +3304,10 @@ restoreLinkTextFrame(ss,isUndo); else if (ss->contains("UNLINK_TEXT_FRAME")) restoreUnlinkTextFrame(ss,isUndo); + else if (ss->contains("COLSGAPDIST")) + restoreColsGapDist(ss, isUndo); + else if (ss->contains("FIRSTLINEOFFS")) + restoreFirstLineOffset(ss, isUndo); } if (!OnMasterPage.isEmpty()) m_Doc->setCurrentPage(oldCurrentPage); @@ -3506,6 +3558,15 @@ // m_Doc->chAbStyle(this, styleid); } +void PageItem::restoreColsGapDist(SimpleState *state, bool isUndo) +{ + if (isUndo) + setColsGapDist(state->getInt("OLD_COLS"), state->getDouble("OLD_GAP"), state->getDouble("OLD_DLEFT"), state->getDouble("OLD_DRIGHT"), state->getDouble("OLD_DTOP"), state->getDouble("OLD_DBOTTOM")); + else + setColsGapDist(state->getInt("NEW_COLS"), state->getDouble("NEW_GAP"), state->getDouble("NEW_DLEFT"), state->getDouble("NEW_DRIGHT"), state->getDouble("NEW_DTOP"), state->getDouble("NEW_DBOTTOM")); + update(); + asTextFrame()->clearLastUndoAction(); +} // FIXME: This must go into class ScribusDoc! // For now we'll just make it independent of 'this' -- AV @@ -3671,6 +3732,15 @@ } } +void PageItem::restoreFirstLineOffset(SimpleState *state, bool isUndo) +{ + if (isUndo) + setFirstLineOffset((FirstLineOffsetPolicy)state->getInt("OLD_FLOP")); + else + setFirstLineOffset((FirstLineOffsetPolicy)state->getInt("NEW_FLOP")); + update(); + asTextFrame()->clearLastUndoAction(); +} void PageItem::restorePoly(SimpleState *state, bool isUndo, bool isContour) { @@ -3844,10 +3914,16 @@ { if (!isTextFrame()) return; + int oldSelStart = 0, oldSelLen = 0; + if (HasSel) + { + oldSelStart = itemText.startOfSelection(); + oldSelLen = itemText.lengthOfSelection(); + } 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 +3938,28 @@ 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(); + itemText.insert(SelStart, *story); int ItemLength = itemText.length(); - itemText.insert(SelStart, *story); // 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.select(SelStart, story->length()); - HasSel = true; + itemText.setStyle(-1, story->paragraphStyle(story->length())); + CPos = state->getInt("STEXT_CPOS"); } - CPos = itemText.endOfSelection(); delete story; } else { qDebug() << "UNDO buffer EMPTY";} @@ -3967,55 +4042,55 @@ } } // after Undo or Redo new actions should create new undoStates - asTextFrame()->lastUndoAction = NOACTION; + asTextFrame()->clearLastUndoAction(); + + if (oldSelLen >0 && (action == PARAGRAPH || action == SELECTION)) + asTextFrame()->restoreTextSelection(oldSelStart, oldSelLen); 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); @@ -4026,42 +4101,6 @@ return QString(xml.c_str()); } -QString PageItem::getItemTextSaxed(int selStart, int selLength) -{ - if (selStart < 0 || selLength < 0) - return QString(); - - StoryText it(m_Doc); - it.setDefaultStyle(itemText.defaultStyle()); - - int oldSelStart = -1, oldSelLength = -1; - oldSelStart = itemText.startOfSelection(); - oldSelLength = itemText.lengthOfSelection(); - - itemText.select(selStart, selLength); - it.insert(0, itemText, (selLength > 0)); - - if (oldSelLength > 0) //restoring old selection if undoItem was PARAPGRAPH - { - itemText.select(oldSelStart, oldSelLength); - HasSel = true; - } - else if (oldSelLength == 0) - { - itemText.deselectAll(); - HasSel = false; - } - - //saxing text - std::ostringstream xmlString; - SaxXML xmlStream(xmlString); - xmlStream.beginDoc(); - it.saxx(xmlStream, "SCRIBUSTEXT"); - xmlStream.endDoc(); - std::string xml(xmlString.str()); - return QString(xml.c_str()); -} - QString PageItem::getTextSaxed(QString str) { StoryText iT(m_Doc); @@ -4079,7 +4118,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); @@ -5980,11 +6019,38 @@ return htmlText; } + FirstLineOffsetPolicy PageItem::firstLineOffset() const { return firstLineOffsetP; } +void PageItem::setFirstLineOffset(FirstLineOffsetPolicy flop, bool createUndo) +{ + if(firstLineOffsetP != flop) + { + if (createUndo && UndoManager::undoEnabled()) + { + SimpleState * ss = NULL; + if (asTextFrame()->getLastUndoAction() == STORY && asTextFrame()->getLastETEA() == ETEAsetFirstLineOffset) + ss = (SimpleState*) undoManager->getLastUndoState(); + if (ss && ss->undoObject() == this && ss->contains("FIRSTLINEOFFS")) + ss->set("NEW_FLOP", flop); + else + { + ss = new SimpleState(Um::SetFirstLineOffset); + ss->set("FIRSTLINEOFFS", "FirstLineOffset"); + ss->set("OLD_FLOP", (int) firstLineOffsetP); + ss->set("NEW_FLOP", flop); + undoManager->action(this, ss); + asTextFrame()->setLastUndoAction(STORY); + asTextFrame()->setLastETEA(ETEAsetFirstLineOffset); + } + } + firstLineOffsetP = flop; + } +} + void PageItem::setFirstLineOffset(FirstLineOffsetPolicy flop) { if(firstLineOffsetP != flop) @@ -5993,7 +6059,3 @@ } } - - - - Index: Scribus/scribus/pageitem_textframe.cpp =================================================================== --- Scribus/scribus/pageitem_textframe.cpp (wersja 16539) +++ 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" @@ -69,8 +69,7 @@ unicodeTextEditMode = false; unicodeInputCount = 0; unicodeInputString = ""; - lastUndoAction = NOACTION; -// lastAction4Paragraph = false; + clearLastUndoAction(); connect(&itemText,SIGNAL(changed()), this, SLOT(slotInvalidateLayout())); } @@ -82,8 +81,7 @@ unicodeTextEditMode = false; unicodeInputCount = 0; unicodeInputString = ""; - lastUndoAction = NOACTION; -// lastAction4Paragraph = false; + clearLastUndoAction(); 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, ETEAclearContents); //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,22 +2743,19 @@ { 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; if (itemTextSaxed.isEmpty()) - updateUndo(INS, QString(QChar(conv))); + updateUndo(INS, ETEAinsertingText, QString(QChar(conv))); else - updateUndo(REPSAX, getTextSaxed(QString(QChar(conv)))); + updateUndo(REPSAX, ETEAreplacingText, getTextSaxed(QString(QChar(conv)))); // Tinput = true; m_Doc->scMW()->setTBvals(this); update(); @@ -3040,7 +3035,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); m_Doc->scMW()->setTBvals(this); update(); // view->RefreshItem(this); @@ -3062,7 +3057,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); update(); // Tinput = false; if ((cr == QChar(13)) && (itemText.length() != 0)) @@ -3081,7 +3076,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); m_Doc->scMW()->setTBvals(this); update(); } @@ -3099,7 +3094,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); // Tinput = false; if ((cr == QChar(13)) && (itemText.length() != 0)) { @@ -3130,7 +3125,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); doUpdate = true; } /* @@ -3149,11 +3144,11 @@ oldCPos = CPos; itemText.insertChars(CPos, QString(SpecialChars::TAB), true); CPos += 1; - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); if (itemTextSaxed.isEmpty()) - updateUndo(INS, QString(SpecialChars::TAB)); + updateUndo(INS, ETEAManageTabs, QString(SpecialChars::TAB)); else - updateUndo(REPSAX, getTextSaxed(QString(SpecialChars::TAB))); + updateUndo(REPSAX, ETEAManageTabs, getTextSaxed(QString(SpecialChars::TAB))); // Tinput = true; // view->RefreshItem(this); doUpdate = true; @@ -3161,15 +3156,15 @@ 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; - if (lastUndoAction != PageItem::INS) + clearLastUndoAction(); + if (getLastUndoAction() != PageItem::INS) oldCPos = CPos; itemText.insertChars(CPos, uc, true); CPos += 1; if (itemTextSaxed.isEmpty()) - updateUndo(INS, uc); + updateUndo(INS, ETEAinsertingText, uc); else - updateUndo(REPSAX, getTextSaxed(uc)); + updateUndo(REPSAX, ETEAreplacingText, getTextSaxed(uc)); if ((m_Doc->docHyphenator->AutoCheck) && (CPos > 1)) { Twort = ""; @@ -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,48 +3646,62 @@ invalidateLayout(); } -void PageItem_TextFrame::updateUndo(EditAct action, QString str) +void PageItem_TextFrame::updateUndo(EditAct action, exactlyTextEditAct 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; } SimpleState* ss; bool newState = true; // indicate when new undoState should be created - if (lastUndoAction == action && action != REPSAX && action != DELSAX) + if (getLastUndoAction() == action && action != REPSAX && action != DELSAX) { 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 (getLastETEA() == 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 +3714,33 @@ } 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: + case DELSAX: + case REPSAX: + case NOACTION: + default: + break; + } + if (newAction >0) + { + if (!descript.isEmpty()) + descript += "\n"; + descript += doc()->scMW()->actionManager->textEditActionDescriptions.value(newAction,""); + } + ss = new SimpleState(UndoManager::EditText, descript); ss->set("STEXT_CPOS", oldCPos); } if (action == INSSAX || action == INS) @@ -3727,24 +3754,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) @@ -3753,7 +3774,8 @@ } } itemTextSaxed.clear(); - lastUndoAction = action; + setLastUndoAction(action); + setLastETEA(newAction); ss->set("STEXT",(int) action); if (newState) undoManager->action(this, ss); @@ -3764,6 +3786,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 16552) +++ Scribus/scribus/scribus.cpp (kopia robocza) @@ -1118,9 +1118,9 @@ currItem->oldCPos = currItem->CPos; currItem->itemText.insertChars(currItem->CPos, QString(QChar(unicodevalue)), true); if (currItem->itemTextSaxed.isEmpty()) - currItem->asTextFrame()->updateUndo(PageItem::INS, QString(QChar(unicodevalue))); + currItem->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingText, QString(QChar(unicodevalue))); else - currItem->asTextFrame()->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(QString(QChar(unicodevalue)))); + currItem->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAreplacingText, currItem->getTextSaxed(QString(QChar(unicodevalue)))); currItem->CPos += 1; // currItem->Tinput = true; currItem->update(); @@ -1139,7 +1139,7 @@ currItem->itemText.insertChars(currItem->CPos, QString(SpecialChars::SHYPHEN), true); currItem->oldCPos = currItem->CPos; currItem->CPos += 1; - currItem->asTextFrame()->updateUndo(PageItem::INS, QString(SpecialChars::SHYPHEN)); + currItem->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, QString(SpecialChars::SHYPHEN)); #endif // currItem->Tinput = true; currItem->update(); @@ -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, ETEAslotGetContent); } 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, ETEAslotGetContent); 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, ETEAslotFileAppend); } 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, ETEAdeletingText, 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, ETEAinsertingText, 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, ETEAinsertingText, currItem->getItemTextSaxed(PageItem::SELECTION)); } else { @@ -5280,9 +5281,9 @@ currItem->HasSel = true; //if itemTextSaxed is not empty there was selection if (currItem->itemTextSaxed.isEmpty()) - currItem->updateUndo(PageItem::INS, text); + currItem->updateUndo(PageItem::INS, ETEAinsertingText, text); else - currItem->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(text)); + currItem->updateUndo(PageItem::REPSAX, ETEAreplacingText, currItem->getTextSaxed(text)); } currItem->update(); @@ -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 16552) +++ 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,14 +3306,18 @@ doc->itemSelection_SetOpticalMargins(omt); if (CurItem->asTextFrame()) - CurItem->asTextFrame()->updateUndo(); + CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAsetOpticalMargins); } void PropertiesPalette::resetOpticalMargins() { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; + if (CurItem->asTextFrame()) + CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY); doc->itemSelection_resetOpticalMargins(); + if (CurItem->asTextFrame()) + CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAsetOpticalMargins); } void PropertiesPalette::updateOpticalMargins(const ParagraphStyle & pStyle) @@ -3339,12 +3339,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 +3353,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 +3367,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 +3380,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 +3404,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 +3415,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 +3446,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, ETEANewTScale); } void PropertiesPalette::NewX() @@ -3874,14 +3874,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() @@ -3901,7 +3897,7 @@ { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; - CurItem->Cols = DCol->value(); + CurItem->setColsGapDist(DCol->value(), CurItem->ColGap, CurItem->textToFrameDistLeft(), CurItem->textToFrameDistRight(), CurItem->textToFrameDistTop(), CurItem->textToFrameDistBottom()); setCols(CurItem->Cols, CurItem->ColGap); CurItem->update(); emit DocChanged(); @@ -3922,8 +3918,9 @@ { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; + double newGap; if (colgapLabel->currentIndex() == 0) - CurItem->ColGap = dGap->value() / m_unitRatio; + newGap = dGap->value() / m_unitRatio; else { double lineCorr; @@ -3932,9 +3929,9 @@ else lineCorr = 0; double newWidth = dGap->value() / m_unitRatio; - double newGap = qMax(((CurItem->width() - CurItem->textToFrameDistLeft() - CurItem->textToFrameDistRight() - lineCorr) - (newWidth * CurItem->Cols)) / (CurItem->Cols - 1), 0.0); - CurItem->ColGap = newGap; + newGap = qMax(((CurItem->width() - CurItem->textToFrameDistLeft() - CurItem->textToFrameDistRight() - lineCorr) - (newWidth * CurItem->Cols)) / (CurItem->Cols - 1), 0.0); } + CurItem->setColsGapDist(CurItem->Cols, newGap, CurItem->textToFrameDistLeft(), CurItem->textToFrameDistRight(), CurItem->textToFrameDistTop(), CurItem->textToFrameDistBottom()); CurItem->update(); emit DocChanged(); } @@ -3944,10 +3941,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 +3952,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 +4273,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 +4287,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 +4298,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 +4324,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 +4350,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 +4386,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); } } @@ -4677,7 +4652,7 @@ return; if ((HaveDoc) && (HaveItem)) { - CurItem->setTextToFrameDist(DLeft->value() / m_unitRatio, DRight->value() / m_unitRatio, DTop->value() / m_unitRatio, DBottom->value() / m_unitRatio); + CurItem->setColsGapDist(CurItem->Cols, CurItem->ColGap, DLeft->value() / m_unitRatio, DRight->value() / m_unitRatio, DTop->value() / m_unitRatio, DBottom->value() / m_unitRatio); setCols(CurItem->Cols, CurItem->ColGap); CurItem->update(); emit DocChanged(); @@ -4742,10 +4717,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 +4732,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 +4884,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 +4895,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 +4908,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 +4920,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) @@ -5097,10 +5068,6 @@ return; CurItem->fillRule = EvenOdd->isChecked(); CurItem->update(); - qDebug() << "PropertiesPalette::handleFillRule() updateUNDO"; - if (CurItem->asTextFrame()) - CurItem->asTextFrame()->updateUndo(); - emit DocChanged(); } @@ -5142,6 +5109,7 @@ if (CurItem->itemName() != NameEdit->text()) { CurItem->setItemName(NameEdit->text()); + CurItem->AutoName = false; emit DocChanged(); } } @@ -5184,10 +5152,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 +5167,7 @@ } CurItem->update(); if (CurItem->asTextFrame()) - CurItem->asTextFrame()->updateUndo(); + CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAManageTabs); emit DocChanged(); } @@ -5915,11 +5880,11 @@ return; // qDebug("%s", QString("rF %1").arg(radioFlop).toAscii()); if( radioFlop == 0) - CurItem->setFirstLineOffset(FLOPRealGlyphHeight); + CurItem->setFirstLineOffset(FLOPRealGlyphHeight, true); else if( radioFlop == 1) - CurItem->setFirstLineOffset(FLOPFontAscent); + CurItem->setFirstLineOffset(FLOPFontAscent, true); else if( radioFlop == 2) - CurItem->setFirstLineOffset(FLOPLineSpacing); + CurItem->setFirstLineOffset(FLOPLineSpacing, true); CurItem->update(); emit DocChanged(); } Index: Scribus/scribus/undomanager.cpp =================================================================== --- Scribus/scribus/undomanager.cpp (wersja 16552) +++ Scribus/scribus/undomanager.cpp (kopia robocza) @@ -882,6 +882,7 @@ UndoManager::StartAndEndArrow = tr("Set start and end arrows"); UndoManager::CreateTable = tr("Create table"); UndoManager::RowsCols = tr("Rows: %1, Cols: %2"); + UndoManager::setColsGapDist = tr("Set columns, gap and text distances"); UndoManager::SetFont = tr("Set font"); UndoManager::SetFontSize = tr("Set font size"); UndoManager::SetFontWidth = tr("Set font width"); @@ -896,6 +897,7 @@ UndoManager::SetLanguage = tr("Set language"); UndoManager::AlignText = tr("Align text"); UndoManager::SetFontEffect = tr("Set font effect"); + UndoManager::SetFirstLineOffset = tr("Set first line offset"); UndoManager::ImageFrame = tr("Image frame"); UndoManager::TextFrame = tr("Text frame"); UndoManager::LatexFrame = tr("Render frame"); @@ -1094,6 +1096,7 @@ QString UndoManager::StartAndEndArrow = ""; QString UndoManager::CreateTable = ""; QString UndoManager::RowsCols = ""; +QString UndoManager::setColsGapDist = ""; QString UndoManager::SetFont = ""; QString UndoManager::SetFontSize = ""; QString UndoManager::SetFontWidth = ""; @@ -1108,6 +1111,7 @@ QString UndoManager::SetLanguage = ""; QString UndoManager::AlignText = ""; QString UndoManager::SetFontEffect = ""; +QString UndoManager::SetFirstLineOffset = ""; QString UndoManager::ImageFrame = ""; QString UndoManager::TextFrame = ""; QString UndoManager::LatexFrame = ""; Index: Scribus/scribus/actionmanager.h =================================================================== --- Scribus/scribus/actionmanager.h (wersja 16552) +++ 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<exactlyTextEditAct,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 16552) +++ 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,9 +346,9 @@ 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, ETEAinsertLoremIpsum, Lorip); else - currItem->asTextFrame()->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(Lorip)); + currItem->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertLoremIpsum, currItem->getTextSaxed(Lorip)); delete lp; //if (ScMW->view->SelItem.at(i)->Doc->docHyphenator->AutoCheck) Index: Scribus/scribus/undomanager.h =================================================================== --- Scribus/scribus/undomanager.h (wersja 16552) +++ Scribus/scribus/undomanager.h (kopia robocza) @@ -508,6 +508,7 @@ static QString StartAndEndArrow; static QString CreateTable; static QString RowsCols; + static QString setColsGapDist; static QString SetFont; static QString SetFontSize; static QString SetFontWidth; @@ -522,6 +523,7 @@ static QString SetLanguage; static QString AlignText; static QString SetFontEffect; + static QString SetFirstLineOffset; static QString ImageFrame; static QString TextFrame; static QString LatexFrame; Index: Scribus/scribus/hruler.cpp =================================================================== --- Scribus/scribus/hruler.cpp (wersja 16552) +++ Scribus/scribus/hruler.cpp (kopia robocza) @@ -34,6 +34,7 @@ #include "canvasgesture_rulermove.h" #include "hruler.h" #include "page.h" +#include "pageitem_textframe.h" #include "prefsmanager.h" #include "scribus.h" #include "scribusdoc.h" @@ -241,14 +242,17 @@ { bool mustApplyStyle = false; ParagraphStyle paraStyle; - double ColWidth = (textWidth() - ColGap * (Cols - 1)) / Cols; + double ColWidth = (textWidth() - ColGap * (Cols - 1)) / Cols; + exactlyTextEditAct ETEA = ETEAsetIndentMargs; switch (RulerCode) { case rc_leftFrameDist: + currDoc->m_Selection->itemAt(0)->setUndoColsGapDist(Cols, ColGap, Extra, RExtra, currDoc->m_Selection->itemAt(0)->textToFrameDistTop(), currDoc->m_Selection->itemAt(0)->textToFrameDistBottom()); currDoc->m_Selection->itemAt(0)->setTextToFrameDistLeft(Extra); emit DocChanged(false); break; case rc_rightFrameDist: + currDoc->m_Selection->itemAt(0)->setUndoColsGapDist(Cols, ColGap, Extra, RExtra, currDoc->m_Selection->itemAt(0)->textToFrameDistTop(), currDoc->m_Selection->itemAt(0)->textToFrameDistBottom()); currDoc->m_Selection->itemAt(0)->setTextToFrameDistRight(RExtra); emit DocChanged(false); break; @@ -269,6 +273,7 @@ emit DocChanged(false); break; case rc_tab: + ETEA = ETEAManageTabs; if (m->button() == Qt::RightButton) { TabValues[ActTab].tabType += 1; @@ -284,9 +289,11 @@ } if (mustApplyStyle) { + currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::PARAGRAPH); Selection tempSelection(this, false); tempSelection.addItem(currItem); currDoc->itemSelection_ApplyParagraphStyle(paraStyle, &tempSelection); + currItem->asTextFrame()->updateUndo(PageItem::PARAGRAPH, ETEA); } else { @@ -297,6 +304,7 @@ { if (RulerCode == rc_tab) { + currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::PARAGRAPH); TabValues.removeAt(ActTab); ActTab = 0; ParagraphStyle paraStyle; @@ -304,6 +312,7 @@ Selection tempSelection(this, false); tempSelection.addItem(currItem); currDoc->itemSelection_ApplyParagraphStyle(paraStyle, &tempSelection); + currItem->asTextFrame()->updateUndo(PageItem::PARAGRAPH, ETEAManageTabs); emit DocChanged(false); qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); } Index: Scribus/scribus/charselect.cpp =================================================================== --- Scribus/scribus/charselect.cpp (wersja 16552) +++ 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(); @@ -133,9 +133,9 @@ txtIns.append(ch); } if (m_Item->itemTextSaxed.isEmpty()) - m_Item->asTextFrame()->updateUndo(PageItem::INS, txtIns); + m_Item->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, txtIns); else - m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, m_Item->getTextSaxed(txtIns)); + m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertingSpecChar, m_Item->getTextSaxed(txtIns)); m_doc->updateFrameItems(); m_doc->view()->DrawNew(); m_doc->changed(); @@ -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(); @@ -162,9 +162,9 @@ m_Item->oldCPos = m_Item->CPos; m_Item->itemText.insertChars(m_Item->CPos, ch, true); if (m_Item->itemTextSaxed.isEmpty()) - m_Item->asTextFrame()->updateUndo(PageItem::INS, QString(ch)); + m_Item->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, QString(ch)); else - m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, m_Item->getTextSaxed(QString(ch))); + m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertingSpecChar, m_Item->getTextSaxed(QString(ch))); m_doc->updateFrameItems(); m_Item->CPos += 1; m_doc->view()->DrawNew(); Index: Scribus/scribus/canvasmode_edit.cpp =================================================================== --- Scribus/scribus/canvasmode_edit.cpp (wersja 16552) +++ Scribus/scribus/canvasmode_edit.cpp (kopia robocza) @@ -413,7 +413,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()) { @@ -660,7 +660,7 @@ if (currItem->asTextFrame()) { m_view->slotSetCurs(m->globalPos().x(), m->globalPos().y()); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); } } else @@ -678,7 +678,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) @@ -688,7 +688,7 @@ //m_view->slotDoCurs(true); m_view->requestMode(modeNormal); if (currItem->isTextFrame()) - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); return; } @@ -713,7 +713,7 @@ oldP = currItem->itemText.endOfSelection(); } currItem->asTextFrame()->itemText.extendSelection(oldP, currItem->CPos); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); oldCp = currItem->CPos; } else @@ -729,7 +729,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; } } @@ -737,7 +737,7 @@ { oldCp = currItem->CPos; currItem->itemText.deselectAll(); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); currItem->HasSel = false; } currItem->emitAllToGUI(); @@ -754,7 +754,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, ETEAinsertingText, 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 16552) +++ 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,8 +462,7 @@ // for itemText undo purpose int oldCPos; QString itemTextSaxed; - QString getItemTextSaxed(EditActPlace undoItem); - QString getItemTextSaxed(int selStart, int selLength); + QString getItemTextSaxed(EditAct action); QString getTextSaxed(QString str); /** Flag fuer PDF-Bookmark */ bool isBookmark; @@ -649,12 +642,15 @@ void setTextToFrameDistRight(double); void setTextToFrameDistTop(double); void setTextToFrameDistBottom(double); + void setColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom); + void setUndoColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom); void setColumns(int); void setColumnGap(double); void setGridOffset(double); void setGridDistance(double); FirstLineOffsetPolicy firstLineOffset()const; void setFirstLineOffset(FirstLineOffsetPolicy); + void setFirstLineOffset(FirstLineOffsetPolicy, bool createundo); /** * \brief Set the text to frame distances all at once * @param newLeft left distance @@ -1068,7 +1064,7 @@ void restoreArrow(SimpleState *state, bool isUndo, bool isStart); void restorePStyle(SimpleState *state, bool isUndo); - + void restoreColsGapDist(SimpleState *state, bool isUndo); void restoreType(SimpleState *state, bool isUndo); void restoreTextFlowing(SimpleState *state, bool isUndo); void restoreImageScaleMode(SimpleState *state, bool isUndo); @@ -1087,6 +1083,8 @@ void restoreEditText(SimpleState *state, bool isUndo); void restoreLinkTextFrame(UndoState *state, bool isUndo); void restoreUnlinkTextFrame(UndoState *state, bool isUndo); + void restoreFirstLineOffset(SimpleState *state, bool isUndo); + /*@}*/ /** Index: Scribus/scribus/scribusstructs.h =================================================================== --- Scribus/scribus/scribusstructs.h (wersja 16552) +++ Scribus/scribus/scribusstructs.h (kopia robocza) @@ -472,6 +472,54 @@ } }; + +//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, + ETEAclearContents = 30, + ETEAslotGetContent = 31, + ETEAslotFileAppend = 32, + ETEAinsertingText = 33, + ETEAinsertingSpecChar = 34, + ETEAinsertLoremIpsum = 35, + ETEAreplacingText = 36, + ETEAdeletingText = 37, + //ETEAinsertingTabs = 38, + ETEAsetColsGapDist = 39, + ETEAsetIndentMargs = 40, + ETEAsetFirstLineOffset = 41 +} exactlyTextEditAct; + #endif Index: Scribus/scribus/actionmanager.cpp =================================================================== --- Scribus/scribus/actionmanager.cpp (wersja 16552) +++ 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,56 @@ 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 text effects")); + 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 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")); + textEditActionDescriptions.insert(ETEAclearContents, QObject::tr("Clear contents")); + textEditActionDescriptions.insert(ETEAslotGetContent, QObject::tr("Load text file")); + textEditActionDescriptions.insert(ETEAslotFileAppend, QObject::tr("Append text file")); + textEditActionDescriptions.insert(ETEAinsertingText, QObject::tr("Inserting text")); + textEditActionDescriptions.insert(ETEAinsertingSpecChar, QObject::tr("Inserting special char")); + textEditActionDescriptions.insert(ETEAinsertLoremIpsum, QObject::tr("Inserting text example")); + textEditActionDescriptions.insert(ETEAreplacingText, QObject::tr("Replacing text")); + textEditActionDescriptions.insert(ETEAdeletingText, QObject::tr("Deleting text")); + // better merge it with "ManageTabs" + //textEditActionDescriptions.insert(ETEAinsertingTabs, QObject::tr("Inserting Tabs")); + textEditActionDescriptions.insert(ETEAsetColsGapDist, QObject::tr("Manage columns, gaps, distances")); + textEditActionDescriptions.insert(ETEAsetIndentMargs, QObject::tr("Manage indents and margins")); + textEditActionDescriptions.insert(ETEAsetFirstLineOffset, QObject::tr("Set first line offset")); +} void ActionManager::initFileMenuActions() { QString name; @@ -1499,6 +1549,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 16552) +++ 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,8 @@ 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 restoreTextSelection(int selStart, int selLength); void deselectAll(); virtual void invalidateLayout(); @@ -104,12 +105,20 @@ bool cursorBiasBackward; void setShadow(); - void restoreTextSelection(int selStart, int selLength); QString currentShadow; QMap<QString,StoryText> shadows; + + EditAct lastTextUndoAction; + exactlyTextEditAct lastETEA; + public: - void updateUndo(EditAct action = PARAMFULL, QString str = ""); - EditAct lastUndoAction; + void clearLastUndoAction() { lastTextUndoAction = PageItem::NOACTION; }; + EditAct getLastUndoAction() { return lastTextUndoAction; }; + exactlyTextEditAct getLastETEA() { return lastETEA; }; + void setLastUndoAction(EditAct action) { lastTextUndoAction = action; }; + void setLastETEA(exactlyTextEditAct ETEA) { lastETEA = ETEA; }; + void updateUndo(EditAct action, exactlyTextEditAct newAction, QString str = ""); + void updateUndo(EditAct action, QString str = "") { updateUndo(action, ETEAotherEditAction, str); }; private slots: void slotInvalidateLayout(); }; |
|
Are you online now? IRC? I dont get why ActionManager is getting this stuff: textEditActionDescriptions ?? IT doesn't seem related to Actions (QActions) that people use to interact with the Scribus GUI.. looks like something more text/undo related??? Or do you see this being accessible via shortcuts or something in the future? |
|
Simply I dont know when to insert this. In fact it is not action but undo related. I search place to initialization of this strings once Scribus is open, not for each document opened, like actions, so I place them here, but I agree that maybe it is not good place. If so where such undo related thing should be defined and initialized? |
|
Due to time limits, I am setting this to be completed for 1.4.1 |
|
Ping on this.. where did this patch get up to.. does it still apply to 1.4.1.svn ? |
|
ping.... |
|
I have start working at it... |
|
newTextUndo.patch (81,125 bytes)
Index: scribus/canvasmode_legacy.cpp =================================================================== --- scribus/canvasmode_legacy.cpp (wersja 17243) +++ scribus/canvasmode_legacy.cpp (kopia robocza) @@ -1800,7 +1800,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,ETEAinsertingText, cc); if (m_doc->docHyphenator->AutoCheck) m_doc->docHyphenator->slotHyphenate(currItem); m_ScMW->BookMarkTxT(currItem); Index: scribus/pageitem.cpp =================================================================== --- scribus/pageitem.cpp (wersja 17243) +++ scribus/pageitem.cpp (kopia robocza) @@ -1004,6 +1023,51 @@ void PageItem::setGridOffset(double) { } // FIXME void PageItem::setGridDistance(double) { } // FIXME +void PageItem::setColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom) +{ + setUndoColsGapDist(newCols, newGap, newLeft, newRight, newTop, newBottom); + setColumns(newCols); + setColumnGap(newGap); + setTextToFrameDist(newLeft, newRight, newTop, newBottom); +} +void PageItem::setUndoColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom) +{ + if (UndoManager::undoEnabled()) + { + SimpleState * ss = NULL; + if (asTextFrame()->getLastUndoAction() == STORY && asTextFrame()->getLastETEA() == ETEAsetColsGapDist) + ss = (SimpleState*) undoManager->getLastUndoState(); + if (ss && ss->undoObject() == this && ss->contains("COLSGAPDIST")) + { + ss->set("NEW_COLS", newCols); + ss->set("NEW_GAP", newGap); + ss->set("NEW_DLEFT", newLeft); + ss->set("NEW_DRIGHT", newRight); + ss->set("NEW_DTOP", newTop); + ss->set("NEW_DBOTTOM", newBottom); + } + else + { + ss = new SimpleState(Um::setColsGapDist); + ss->set("COLSGAPDIST","ColsGapDist"); + ss->set("OLD_COLS", Cols); + ss->set("NEW_COLS", newCols); + ss->set("OLD_GAP", ColGap); + ss->set("NEW_GAP", newGap); + ss->set("OLD_DLEFT", Extra); + ss->set("NEW_DLEFT", newLeft); + ss->set("OLD_DRIGHT", RExtra); + ss->set("NEW_DRIGHT", newRight); + ss->set("OLD_DTOP", TExtra); + ss->set("NEW_DTOP", newTop); + ss->set("OLD_DBOTTOM", BExtra); + ss->set("NEW_DBOTTOM", newBottom); + undoManager->action(this, ss); + asTextFrame()->setLastUndoAction(STORY); + asTextFrame()->setLastETEA(ETEAsetColsGapDist); + } + } +} void PageItem::setColumns(int n) { Cols = qMax(1, n); //FIXME: undo @@ -3300,6 +3434,10 @@ restoreUnlinkTextFrame(ss, isUndo); else if (ss->contains("REVERSE_TEXT")) restoreReverseText(ss, isUndo); + else if (ss->contains("COLSGAPDIST")) + restoreColsGapDist(ss, isUndo); + else if (ss->contains("FIRSTLINEOFFS")) + restoreFirstLineOffset(ss, isUndo); } if (!OnMasterPage.isEmpty()) m_Doc->setCurrentPage(oldCurrentPage); @@ -3550,6 +3688,16 @@ // m_Doc->chAbStyle(this, styleid); } +void PageItem::restoreColsGapDist(SimpleState *state, bool isUndo) +{ + if (isUndo) + setColsGapDist(state->getInt("OLD_COLS"), state->getDouble("OLD_GAP"), state->getDouble("OLD_DLEFT"), state->getDouble("OLD_DRIGHT"), state->getDouble("OLD_DTOP"), state->getDouble("OLD_DBOTTOM")); + else + setColsGapDist(state->getInt("NEW_COLS"), state->getDouble("NEW_GAP"), state->getDouble("NEW_DLEFT"), state->getDouble("NEW_DRIGHT"), state->getDouble("NEW_DTOP"), state->getDouble("NEW_DBOTTOM")); + m_Doc->scMW()->selectItemsFromOutlines(this); + update(); + asTextFrame()->clearLastUndoAction(); +} // FIXME: This must go into class ScribusDoc! // For now we'll just make it independent of 'this' -- AV @@ -3715,6 +3863,16 @@ } } +void PageItem::restoreFirstLineOffset(SimpleState *state, bool isUndo) +{ + if (isUndo) + setFirstLineOffset((FirstLineOffsetPolicy)state->getInt("OLD_FLOP")); + else + setFirstLineOffset((FirstLineOffsetPolicy)state->getInt("NEW_FLOP")); + update(); + asTextFrame()->clearLastUndoAction(); +} + void PageItem::restoreReverseText(UndoState *state, bool /*isUndo*/) { if (!isTextFrame()) @@ -3897,7 +4055,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) @@ -3912,27 +4070,29 @@ 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); + itemText.setCursorPosition(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(); + itemText.insert(SelStart, *story); int ItemLength = itemText.length(); - itemText.insert(SelStart, *story); // 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; + itemText.setCursorPosition(state->getInt("STEXT_CPOS")); } itemText.setCursorPosition( itemText.endOfSelection() ); delete story; @@ -3976,6 +4136,7 @@ } else if (action == INSSAX || action == DELSAX) { + itemText.deselectAll(); QString str = state->get("STEXT_STR"); if (str.isEmpty()) str = itemTextSaxed; @@ -4001,6 +4162,7 @@ } else if (action == INS) { + itemText.deselectAll(); QString str = state->get("STEXT_STR"); int pos = state->getInt("STEXT_CPOS"); if (isUndo) @@ -4014,18 +4176,19 @@ } } // 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 ""; + if (itemText.length() <= 0) return ""; StoryText iT(m_Doc); iT.setDefaultStyle(itemText.defaultStyle()); - if (undoItem == FRAME) + if (action == STORY) iT.insert(0, itemText); else { @@ -4035,13 +4198,23 @@ StartOldSel = itemText.startOfSelection(); LenOldSel = itemText.lengthOfSelection(); } - if (undoItem == PARAGRAPH) + if (action == PARAGRAPH) asTextFrame()->expandParaSelection(true); - else if (undoItem == CHAR || !HasSel) + else if (action == SELECTION && !HasSel) { - if (itemText.cursorPosition() >= itemText.length()) - return ""; - itemText.select(itemText.cursorPosition(), 1); + //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 + int CPos = itemText.cursorPosition(); + 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 ""; + itemText.select(CPos, 1); } //is SELECTION iT.insert(0, itemText, true); @@ -4097,7 +4270,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); @@ -6025,6 +6194,32 @@ return firstLineOffsetP; } +void PageItem::setFirstLineOffset(FirstLineOffsetPolicy flop, bool createUndo) +{ + if(firstLineOffsetP != flop) + { + if (createUndo && UndoManager::undoEnabled()) + { + SimpleState * ss = NULL; + if (asTextFrame()->getLastUndoAction() == STORY && asTextFrame()->getLastETEA() == ETEAsetFirstLineOffset) + ss = (SimpleState*) undoManager->getLastUndoState(); + if (ss && ss->undoObject() == this && ss->contains("FIRSTLINEOFFS")) + ss->set("NEW_FLOP", flop); + else + { + ss = new SimpleState(Um::SetFirstLineOffset); + ss->set("FIRSTLINEOFFS", "FirstLineOffset"); + ss->set("OLD_FLOP", (int) firstLineOffsetP); + ss->set("NEW_FLOP", flop); + undoManager->action(this, ss); + asTextFrame()->setLastUndoAction(STORY); + asTextFrame()->setLastETEA(ETEAsetFirstLineOffset); + } + } + firstLineOffsetP = flop; + } +} + void PageItem::setFirstLineOffset(FirstLineOffsetPolicy flop) { if(firstLineOffsetP != flop) Index: scribus/pageitem_textframe.cpp =================================================================== --- scribus/pageitem_textframe.cpp (wersja 17243) +++ scribus/pageitem_textframe.cpp (kopia robocza) @@ -30,11 +30,13 @@ #include <QRegion> #include <cassert> - +#include "actionmanager.h" #include "canvas.h" #include "commonstrings.h" #include "guidemanager.h" +#include "fonts/scface.h" #include "hyphenator.h" +#include "markers.h" #include "page.h" #include "pageitem.h" #include "pageitem_textframe.h" @@ -2821,11 +2887,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, ETEAclearContents); //for undo while (nextItem != 0) { nextItem->invalid = true; @@ -2909,7 +2981,7 @@ case Qt::Key_Down: if ( (buttonModifiers & Qt::ShiftModifier) == 0 ) deselectAll(); - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); } if (unicodeTextEditMode) @@ -2938,21 +3010,18 @@ { 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 = itemText.cursorPosition(); itemText.insertChars(QString(QChar(conv)), true); if (itemTextSaxed.isEmpty()) - updateUndo(INS, QString(QChar(conv))); + updateUndo(INS, ETEAinsertingText, QString(QChar(conv))); else - updateUndo(REPSAX, getTextSaxed(QString(QChar(conv)))); + updateUndo(REPSAX, ETEAreplacingText, getTextSaxed(QString(QChar(conv)))); // Tinput = true; m_Doc->scMW()->setTBvals(this); update(); @@ -2977,6 +3046,7 @@ } int oldLast = lastInFrame(); + int tempCPos; switch (kk) { case Qt::Key_Home: @@ -3245,12 +3315,20 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); m_Doc->scMW()->setTBvals(this); update(); // view->RefreshItem(this); } keyRepeat = false; + if (oldLast != lastInFrame() && NextBox != NULL) + { + tempCPos = itemText.cursorPosition(); + NextBox->update(); + NextBox->layout(); + itemText.setCursorPosition(tempCPos); + } + return; } if (itemText.length() == 0) @@ -3267,14 +3345,53 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); + invalidateLayout(); + tempCPos = itemText.cursorPosition(); update(); + layout(); + itemText.setCursorPosition(tempCPos); + if (oldLast != lastInFrame() && NextBox != NULL) + { + tempCPos = itemText.cursorPosition(); + NextBox->update(); + NextBox->layout(); + itemText.setCursorPosition(tempCPos); + } + if (itemText.cursorPosition() > lastInFrame() && NextBox != NULL) + { + lastUndoAction = PageItem::NOACTION; + view->Deselect(true); + NextBox->update(); + NextBox->layout(); + m_Doc->scMW()->selectItemsFromOutlines(NextBox); + } + else if (itemText.cursorPosition() < firstInFrame() && BackBox != NULL) + { + lastUndoAction = PageItem::NOACTION; + view->Deselect(true); + BackBox->update(); + BackBox->layout(); + m_Doc->scMW()->selectItemsFromOutlines(BackBox); + } + // Tinput = false; if ((cr == QChar(13)) && (itemText.length() != 0)) { // 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); // view->RefreshItem(this); break; @@ -3286,10 +3403,17 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); m_Doc->scMW()->setTBvals(this); update(); } + if (oldLast != lastInFrame() && NextBox != NULL) + { + tempCPos = itemText.cursorPosition(); + NextBox->update(); + NextBox->layout(); + itemText.setCursorPosition(tempCPos); + } break; } if (itemText.length() == 0) @@ -3304,13 +3428,24 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); // Tinput = false; if ((cr == QChar(13)) && (itemText.length() != 0)) { // m_Doc->chAbStyle(this, findParagraphStyle(m_Doc, itemText.paragraphStyle(qMax(itemText.cursorPosition()-1,0)))); // Tinput = false; } + tempCPos = itemText.cursorPosition(); + update(); + layout(); + itemText.setCursorPosition(tempCPos); + if (oldLast != lastInFrame() && NextBox != NULL) + { + tempCPos = itemText.cursorPosition(); + NextBox->update(); + NextBox->layout(); + itemText.setCursorPosition(tempCPos); + } updateLayout(); if (oldLast != lastInFrame() && NextBox != 0 && NextBox->invalid) NextBox->updateLayout(); @@ -3319,16 +3454,15 @@ itemText.setCursorPosition(firstInFrame()); if (BackBox != 0) { - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); view->Deselect(true); - if (BackBox->invalid) - BackBox->updateLayout(); - BackBox->itemText.setCursorPosition( BackBox->lastInFrame() ); + BackBox->update(); + BackBox->layout(); + itemText.setCursorPosition( BackBox->lastInFrame() ); m_Doc->scMW()->selectItemsFromOutlines(BackBox); } } m_Doc->scMW()->setTBvals(this); - update(); // view->RefreshItem(this); break; default: @@ -3351,7 +3485,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); doUpdate = true; } /* @@ -3369,11 +3503,11 @@ { oldCPos = itemText.cursorPosition(); itemText.insertChars(QString(SpecialChars::TAB), true); - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); if (itemTextSaxed.isEmpty()) - updateUndo(INS, QString(SpecialChars::TAB)); + updateUndo(INS, ETEAManageTabs, QString(SpecialChars::TAB)); else - updateUndo(REPSAX, getTextSaxed(QString(SpecialChars::TAB))); + updateUndo(REPSAX, ETEAManageTabs, getTextSaxed(QString(SpecialChars::TAB))); // Tinput = true; // view->RefreshItem(this); doUpdate = true; @@ -3381,14 +3515,14 @@ 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 = itemText.cursorPosition(); itemText.insertChars(uc, true); if (itemTextSaxed.isEmpty()) - updateUndo(INS, uc); + updateUndo(INS, ETEAinsertingText, uc); else - updateUndo(REPSAX, getTextSaxed(uc)); + updateUndo(REPSAX, ETEAreplacingText, getTextSaxed(uc)); if ((m_Doc->docHyphenator->AutoCheck) && (itemText.cursorPosition() > 1)) { Twort = ""; @@ -3415,19 +3549,29 @@ } if (doUpdate) { - // update layout immediately, we need MaxChars to be correct to detect - // if we need to move to next frame or not - updateLayout(); - if (oldLast != lastInFrame() && NextBox != 0 && NextBox->invalid) - NextBox->updateLayout(); + tempCPos = itemText.cursorPosition(); + update(); + layout(); + itemText.setCursorPosition(tempCPos); + if (oldLast != lastInFrame() && NextBox != NULL) + { + tempCPos = itemText.cursorPosition(); + NextBox->update(); + NextBox->layout(); + itemText.setCursorPosition(tempCPos); + } } //check if cursor need to jump to next linked frame - if ((itemText.cursorPosition() > lastInFrame() + 1) && (lastInFrame() < (itemText.length() - 2)) && NextBox != 0) + if ((itemText.cursorPosition() > lastInFrame() + 1) && (lastInFrame() < (itemText.length() - 2)) && NextBox != NULL) { lastUndoAction = PageItem::NOACTION; view->Deselect(true); + tempCPos = itemText.cursorPosition(); NextBox->update(); + NextBox->layout(); m_Doc->scMW()->selectItemsFromOutlines(NextBox); + itemText.setCursorPosition(tempCPos); + view->DrawNew(); } break; } @@ -3566,46 +3709,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(); - LenSel = itemText.endOfParagraph() - StartSel; - } - itemText.select(StartSel, LenSel); - HasSel = true; -} - void PageItem_TextFrame::expandParaSelection(bool includeEOL) { int selStart, selLength; - if (HasSel) + if (itemText.lengthOfSelection() >0) { + if (itemText.cursorPosition() == itemText.endOfSelection() && itemText.cursorPosition() < 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(); selLength = itemText.endOfParagraph() - selStart; } - if (includeEOL) + if (includeEOL && itemText.text(selStart + selLength -1) != SpecialChars::PARSEP) selLength += 1; selLength = qMin(selLength, itemText.length() - selStart); @@ -3874,25 +4058,41 @@ invalidateLayout(); } -void PageItem_TextFrame::updateUndo(EditAct action, QString str) + +void PageItem_TextFrame::updateUndo(EditAct action, exactlyTextEditAct newAction, QString str) { if (UndoManager::undoEnabled() && undoManager->undoEnabled()) { - int oldSelStart = -1, oldSelLen = -1; + int oldSelStart = itemText.cursorPosition(), oldSelLen = 0; oldSelLen = itemText.lengthOfSelection(); if (oldSelLen > 0) oldSelStart = itemText.startOfSelection(); - if (action == PARAMFULL && m_Doc->appMode == modeEdit) + int CPos = itemText.cursorPosition(); + 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.item(CPos)->hasObject() + || itemText.text(CPos) == SpecialChars::SHYPHEN) + //case if after cursor is special char, no selection, 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 (itemText.cursorPosition() >= itemText.length() && itemTextSaxed.isEmpty() && action == PARAMFULL && m_Doc->appMode == modeEdit) + if (itemText.cursorPosition() >= 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; } @@ -3903,19 +4103,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 (lastExactTextEditAction == 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) { @@ -3928,7 +4128,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) @@ -3942,24 +4172,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", itemText.cursorPosition()); 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) @@ -3969,6 +4193,7 @@ } itemTextSaxed.clear(); lastUndoAction = action; + lastExactTextEditAction = newAction; ss->set("STEXT",(int) action); if (newState) undoManager->action(this, ss); Index: scribus/scribus.cpp =================================================================== --- scribus/scribus.cpp (wersja 17243) +++ scribus/scribus.cpp (kopia robocza) @@ -1118,9 +1193,10 @@ currItem->oldCPos = currItem->itemText.cursorPosition(); currItem->itemText.insertChars(QString(QChar(unicodevalue)), true); if (currItem->itemTextSaxed.isEmpty()) - currItem->asTextFrame()->updateUndo(PageItem::INS, QString(QChar(unicodevalue))); + currItem->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingText, QString(QChar(unicodevalue))); else - currItem->asTextFrame()->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(QString(QChar(unicodevalue)))); + currItem->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAreplacingText, currItem->getTextSaxed(QString(QChar(unicodevalue)))); + currItem->itemText.setCursorPosition(currItem->itemText.cursorPosition() + 1); // currItem->Tinput = true; currItem->update(); } @@ -1137,7 +1213,7 @@ #else currItem->oldCPos = currItem->itemText.cursorPosition() ; currItem->itemText.insertChars(QString(SpecialChars::SHYPHEN), true); - currItem->asTextFrame()->updateUndo(PageItem::INS, QString(SpecialChars::SHYPHEN)); + currItem->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, QString(SpecialChars::SHYPHEN)); #endif // currItem->Tinput = true; currItem->update(); @@ -4346,7 +4464,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); @@ -4354,7 +4472,7 @@ return; } gt->launchImporter(impsetup.importer, impsetup.filename, impsetup.textOnly, impsetup.encoding, false); - currItem->asTextFrame()->updateUndo(); + currItem->asTextFrame()->updateUndo(PageItem::STORY, ETEAslotGetContent); } delete gt; if (doc->docHyphenator->AutoCheck) @@ -4381,7 +4500,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); @@ -4390,7 +4509,7 @@ if (doc->Items->at(a)->isBookmark) bookmarkPalette->BView->ChangeText(doc->Items->at(a)); } - currItem->asTextFrame()->updateUndo(); + currItem->asTextFrame()->updateUndo(PageItem::STORY, ETEAslotGetContent); view->DrawNew(); slotDocCh(); } @@ -4447,9 +4566,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, ETEAslotFileAppend); } delete gt; //CB Hyphenating now emits doc changed, plus we change lang as appropriate @@ -5030,6 +5153,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); @@ -5050,7 +5174,7 @@ dynamic_cast<PageItem_TextFrame*>(currItem)->deleteSelectedTextFromFrame(); //for undo - currItem->asTextFrame()->updateUndo(PageItem::DELSAX); + currItem->asTextFrame()->updateUndo(PageItem::DELSAX, ETEAdeletingText, oldstr); currItem->update(); } else @@ -5186,7 +5310,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 @@ -5214,7 +5338,7 @@ currItem->itemText.select(currItem->oldCPos, 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, ETEAinsertingText, currItem->getItemTextSaxed(PageItem::SELECTION)); currItem->itemText.deselectAll(); delete story; @@ -5247,6 +5371,7 @@ // update style lists: styleManager->setDoc(doc); + markersManager->setDoc(doc); propertiesPalette->unsetDoc(); propertiesPalette->setDoc(doc); @@ -5303,7 +5428,7 @@ currItem->itemText.select(currItem->oldCPos, currItem->itemText.cursorPosition() - 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, ETEAinsertingText, currItem->getItemTextSaxed(PageItem::SELECTION)); } else { @@ -5318,10 +5443,9 @@ currItem->HasSel = true; //if itemTextSaxed is not empty there was selection if (currItem->itemTextSaxed.isEmpty()) - currItem->updateUndo(PageItem::INS, text); + currItem->updateUndo(PageItem::INS, ETEAinsertingText, text); else - currItem->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(text)); - + currItem->updateUndo(PageItem::REPSAX, ETEAreplacingText, currItem->getTextSaxed(text)); } currItem->update(); } @@ -7052,11 +7186,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(); @@ -7067,8 +7200,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); @@ -7084,8 +7216,7 @@ } } 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(); } @@ -7098,6 +7229,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)) @@ -7121,6 +7254,8 @@ } delete dia; } + if (currItem->asTextFrame()) + currItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY, ETEAsetItemShade); } // slotDocCh(); } @@ -7485,15 +7285,19 @@ 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); + bool parSel = false; + if (doc->appMode == modeEdit && currItem->itemText.lengthOfSelection() == 0 && currItem->asTextFrame()) + { + currItem->asTextFrame()->expandParaSelection(); + parSel = true; + } + if (parSel) + currItem->itemText.deselectAll(); } } @@ -7509,10 +7313,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/propertiespalette.cpp =================================================================== --- scribus/propertiespalette.cpp (wersja 17243) +++ scribus/propertiespalette.cpp (kopia robocza) @@ -2947,11 +2961,10 @@ if ((HaveDoc) && (HaveItem)) { if (CurItem->asTextFrame()) - CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME); + 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); } } @@ -3294,7 +3305,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()) @@ -3306,7 +3317,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() @@ -3335,12 +3346,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); } @@ -3349,13 +3360,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() @@ -3363,12 +3374,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() @@ -3376,12 +3387,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); } @@ -3400,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_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() @@ -3411,10 +3422,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) @@ -3442,10 +3453,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, ETEANewTScale); } void PropertiesPalette::NewX() @@ -3870,10 +3881,10 @@ if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; if (CurItem->asTextFrame()) - CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME); + 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() @@ -3893,7 +3904,7 @@ { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; - CurItem->Cols = DCol->value(); + CurItem->setColsGapDist(DCol->value(), CurItem->ColGap, CurItem->textToFrameDistLeft(), CurItem->textToFrameDistRight(), CurItem->textToFrameDistTop(), CurItem->textToFrameDistBottom());CurItem->setColsGapDist(DCol->value(), CurItem->ColGap, CurItem->textToFrameDistLeft(), CurItem->textToFrameDistRight(), CurItem->textToFrameDistTop(), CurItem->textToFrameDistBottom()); setCols(CurItem->Cols, CurItem->ColGap); CurItem->update(); emit DocChanged(); @@ -3914,8 +3925,9 @@ { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; + double newGap; if (colgapLabel->currentIndex() == 0) - CurItem->ColGap = dGap->value() / m_unitRatio; + newGap = dGap->value() / m_unitRatio; else { double lineCorr; @@ -3924,9 +3936,9 @@ else lineCorr = 0; double newWidth = dGap->value() / m_unitRatio; - double newGap = qMax(((CurItem->width() - CurItem->textToFrameDistLeft() - CurItem->textToFrameDistRight() - lineCorr) - (newWidth * CurItem->Cols)) / (CurItem->Cols - 1), 0.0); - CurItem->ColGap = newGap; + newGap = qMax(((CurItem->width() - CurItem->textToFrameDistLeft() - CurItem->textToFrameDistRight() - lineCorr) - (newWidth * CurItem->Cols)) / (CurItem->Cols - 1), 0.0); } + CurItem->setColsGapDist(CurItem->Cols, newGap, CurItem->textToFrameDistLeft(), CurItem->textToFrameDistRight(), CurItem->textToFrameDistTop(), CurItem->textToFrameDistBottom()); CurItem->update(); emit DocChanged(); } @@ -3936,10 +3948,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() @@ -3947,10 +3959,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() @@ -4271,10 +4283,10 @@ if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; if (CurItem->asTextFrame()) - CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME); + 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) @@ -4282,10 +4294,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() @@ -4293,12 +4305,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); } } @@ -4319,12 +4331,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); } } @@ -4345,12 +4357,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); } } @@ -4381,10 +4393,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); } } @@ -4647,7 +4659,7 @@ return; if ((HaveDoc) && (HaveItem)) { - CurItem->setTextToFrameDist(DLeft->value() / m_unitRatio, DRight->value() / m_unitRatio, DTop->value() / m_unitRatio, DBottom->value() / m_unitRatio); + CurItem->setColsGapDist(CurItem->Cols, CurItem->ColGap, DLeft->value() / m_unitRatio, DRight->value() / m_unitRatio, DTop->value() / m_unitRatio, DBottom->value() / m_unitRatio); setCols(CurItem->Cols, CurItem->ColGap); CurItem->update(); emit DocChanged(); @@ -4708,10 +4720,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); } } @@ -4723,16 +4735,20 @@ if (HaveDoc) { if (CurItem->asTextFrame()) - { -// CurItem->asTextFrame()->ExpandParSel(); - CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME); -// CurItem->asTextFrame()->lastAction4Paragraph = true; - } - doc->itemSelection_EraseParagraphStyle(); + CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY); + doc->itemSelection_ResetParagraphStyle(); 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); + bool parSel = false; + if (doc->appMode == modeEdit && CurItem->itemText.lengthOfSelection() == 0 && CurItem->asTextFrame()) + { + CurItem->asTextFrame()->expandParaSelection(); + parSel = true; + } + if (parSel) + CurItem->itemText.deselectAll(); } } @@ -4879,10 +4895,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() @@ -4890,10 +4906,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); } @@ -4903,7 +4919,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(); @@ -4915,7 +4931,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) @@ -5065,7 +5081,7 @@ CurItem->update(); qDebug() << "PropertiesPalette::handleFillRule() updateUNDO"; if (CurItem->asTextFrame()) - CurItem->asTextFrame()->updateUndo(); + CurItem->asTextFrame()->updateUndo(PageItem::STORY); emit DocChanged(); } @@ -5150,10 +5167,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()); @@ -5168,7 +5182,7 @@ } CurItem->update(); if (CurItem->asTextFrame()) - CurItem->asTextFrame()->updateUndo(); + CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAManageTabs); emit DocChanged(); } Index: scribus/undomanager.cpp =================================================================== --- scribus/undomanager.cpp (wersja 17243) +++ scribus/undomanager.cpp (kopia robocza) @@ -882,6 +882,7 @@ UndoManager::StartAndEndArrow = tr("Set start and end arrows"); UndoManager::CreateTable = tr("Create table"); UndoManager::RowsCols = tr("Rows: %1, Cols: %2"); + UndoManager::setColsGapDist = tr("Set columns, gap and text distances"); UndoManager::SetFont = tr("Set font"); UndoManager::SetFontSize = tr("Set font size"); UndoManager::SetFontWidth = tr("Set font width"); @@ -896,6 +897,7 @@ UndoManager::SetLanguage = tr("Set language"); UndoManager::AlignText = tr("Align text"); UndoManager::SetFontEffect = tr("Set font effect"); + UndoManager::SetFirstLineOffset = tr("Set first line offset"); UndoManager::ImageFrame = tr("Image frame"); UndoManager::TextFrame = tr("Text frame"); UndoManager::LatexFrame = tr("Render frame"); @@ -1095,6 +1097,7 @@ QString UndoManager::StartAndEndArrow = ""; QString UndoManager::CreateTable = ""; QString UndoManager::RowsCols = ""; +QString UndoManager::setColsGapDist = ""; QString UndoManager::SetFont = ""; QString UndoManager::SetFontSize = ""; QString UndoManager::SetFontWidth = ""; @@ -1109,6 +1112,7 @@ QString UndoManager::SetLanguage = ""; QString UndoManager::AlignText = ""; QString UndoManager::SetFontEffect = ""; +QString UndoManager::SetFirstLineOffset = ""; QString UndoManager::ImageFrame = ""; QString UndoManager::TextFrame = ""; QString UndoManager::LatexFrame = ""; Index: scribus/actionmanager.h =================================================================== --- scribus/actionmanager.h (wersja 17243) +++ 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<exactlyTextEditAct,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/loremipsum.cpp =================================================================== --- scribus/loremipsum.cpp (wersja 17243) +++ 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,9 +346,9 @@ 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, ETEAinsertLoremIpsum, Lorip); else - currItem->asTextFrame()->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(Lorip)); + currItem->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertLoremIpsum, currItem->getTextSaxed(Lorip)); delete lp; //if (ScMW->view->SelItem.at(i)->Doc->docHyphenator->AutoCheck) Index: scribus/undomanager.h =================================================================== --- scribus/undomanager.h (wersja 17243) +++ scribus/undomanager.h (kopia robocza) @@ -508,6 +508,7 @@ static QString StartAndEndArrow; static QString CreateTable; static QString RowsCols; + static QString setColsGapDist; static QString SetFont; static QString SetFontSize; static QString SetFontWidth; @@ -522,6 +523,7 @@ static QString SetLanguage; static QString AlignText; static QString SetFontEffect; + static QString SetFirstLineOffset; static QString ImageFrame; static QString TextFrame; static QString LatexFrame; Index: scribus/hruler.cpp =================================================================== --- scribus/hruler.cpp (wersja 17243) +++ scribus/hruler.cpp (kopia robocza) @@ -34,6 +34,7 @@ #include "canvasgesture_rulermove.h" #include "hruler.h" #include "page.h" +#include "pageitem_textframe.h" #include "prefsmanager.h" #include "scribus.h" #include "scribusdoc.h" @@ -241,14 +242,17 @@ { bool mustApplyStyle = false; ParagraphStyle paraStyle; - double ColWidth = (textWidth() - ColGap * (Cols - 1)) / Cols; + double ColWidth = (textWidth() - ColGap * (Cols - 1)) / Cols; + exactlyTextEditAct ETEA = ETEAsetIndentMargs; switch (RulerCode) { case rc_leftFrameDist: - currDoc->m_Selection->itemAt(0)->setTextToFrameDistLeft(Extra); + currDoc->m_Selection->itemAt(0)->setUndoColsGapDist(Cols, ColGap, Extra, RExtra, currDoc->m_Selection->itemAt(0)->textToFrameDistTop(), currDoc->m_Selection->itemAt(0)->textToFrameDistBottom()); + currDoc->m_Selection->itemAt(0)->setTextToFrameDistLeft(Extra); emit DocChanged(false); break; case rc_rightFrameDist: + currDoc->m_Selection->itemAt(0)->setUndoColsGapDist(Cols, ColGap, Extra, RExtra, currDoc->m_Selection->itemAt(0)->textToFrameDistTop(), currDoc->m_Selection->itemAt(0)->textToFrameDistBottom()); currDoc->m_Selection->itemAt(0)->setTextToFrameDistRight(RExtra); emit DocChanged(false); break; @@ -269,6 +273,7 @@ emit DocChanged(false); break; case rc_tab: + ETEA = ETEAManageTabs; if (m->button() == Qt::RightButton) { TabValues[ActTab].tabType += 1; @@ -284,9 +289,11 @@ } if (mustApplyStyle) { + currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::PARAGRAPH); Selection tempSelection(this, false); tempSelection.addItem(currItem); currDoc->itemSelection_ApplyParagraphStyle(paraStyle, &tempSelection); + currItem->asTextFrame()->updateUndo(PageItem::PARAGRAPH, ETEA); } else { @@ -303,7 +310,9 @@ paraStyle.setTabValues(TabValues); Selection tempSelection(this, false); tempSelection.addItem(currItem); + currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::PARAGRAPH); currDoc->itemSelection_ApplyParagraphStyle(paraStyle, &tempSelection); + currItem->asTextFrame()->updateUndo(PageItem::PARAGRAPH, ETEAManageTabs); emit DocChanged(false); qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); } Index: scribus/charselect.cpp =================================================================== --- scribus/charselect.cpp (wersja 17243) +++ 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(); @@ -132,9 +132,9 @@ txtIns.append(ch); } if (m_Item->itemTextSaxed.isEmpty()) - m_Item->asTextFrame()->updateUndo(PageItem::INS, txtIns); + m_Item->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, txtIns); else - m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, m_Item->getTextSaxed(txtIns)); + m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertingSpecChar, m_Item->getTextSaxed(txtIns)); m_doc->updateFrameItems(); m_doc->view()->DrawNew(); m_doc->changed(); @@ -149,7 +149,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(); @@ -161,9 +161,9 @@ m_Item->oldCPos = m_Item->itemText.cursorPosition(); m_Item->itemText.insertChars(ch, true); if (m_Item->itemTextSaxed.isEmpty()) - m_Item->asTextFrame()->updateUndo(PageItem::INS, QString(ch)); + m_Item->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, QString(ch)); else - m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, m_Item->getTextSaxed(QString(ch))); + m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertingSpecChar, m_Item->getTextSaxed(QString(ch))); m_doc->updateFrameItems(); m_doc->view()->DrawNew(); m_doc->changed(); Index: scribus/canvasmode_edit.cpp =================================================================== --- scribus/canvasmode_edit.cpp (wersja 17243) +++ scribus/canvasmode_edit.cpp (kopia robocza) @@ -410,7 +410,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()) { @@ -650,7 +655,7 @@ if (currItem->asTextFrame()) { m_view->slotSetCurs(m->globalPos().x(), m->globalPos().y()); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); } } else @@ -668,7 +673,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) @@ -678,7 +683,7 @@ //m_view->slotDoCurs(true); m_view->requestMode(modeNormal); if (currItem->isTextFrame()) - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); return; } @@ -703,7 +708,7 @@ oldP = currItem->itemText.endOfSelection(); } currItem->asTextFrame()->itemText.extendSelection(oldP, currItem->itemText.cursorPosition()); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); oldCp = currItem->itemText.cursorPosition(); } else @@ -719,7 +724,7 @@ currItem->itemText.setCursorPosition( currItem->itemText.startOfParagraph() ); } currItem->asTextFrame()->ExpandSel(dir, oldP); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); oldCp = oldP; } } @@ -727,7 +732,7 @@ { oldCp = currItem->itemText.cursorPosition(); currItem->itemText.deselectAll(); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); currItem->HasSel = false; } currItem->emitAllToGUI(); @@ -744,7 +749,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, ETEAinsertingText, cc); if (m_doc->docHyphenator->AutoCheck) m_doc->docHyphenator->slotHyphenate(currItem); m_ScMW->BookMarkTxT(currItem); Index: scribus/pageitem.h =================================================================== --- scribus/pageitem.h (wersja 17243) +++ scribus/pageitem.h (kopia robocza) @@ -170,21 +171,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; } @@ -474,7 +466,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 */ @@ -657,12 +652,15 @@ void setTextToFrameDistRight(double); void setTextToFrameDistTop(double); void setTextToFrameDistBottom(double); + void setColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom); + void setUndoColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom); void setColumns(int); void setColumnGap(double); void setGridOffset(double); void setGridDistance(double); FirstLineOffsetPolicy firstLineOffset()const; void setFirstLineOffset(FirstLineOffsetPolicy); + void setFirstLineOffset(FirstLineOffsetPolicy, bool createundo); /** * \brief Set the text to frame distances all at once * @param newLeft left distance @@ -1076,7 +1079,7 @@ void restoreArrow(SimpleState *state, bool isUndo, bool isStart); void restorePStyle(SimpleState *state, bool isUndo); - + void restoreColsGapDist(SimpleState *state, bool isUndo); void restoreType(SimpleState *state, bool isUndo); void restoreTextFlowing(SimpleState *state, bool isUndo); void restoreImageScaleMode(SimpleState *state, bool isUndo); @@ -1095,6 +1098,7 @@ void restoreEditText(SimpleState *state, bool isUndo); void restoreLinkTextFrame(UndoState *state, bool isUndo); void restoreUnlinkTextFrame(UndoState *state, bool isUndo); + void restoreFirstLineOffset(SimpleState *state, bool isUndo); void restoreReverseText(UndoState *state, bool isUndo); /*@}*/ Index: scribus/scribusstructs.h =================================================================== --- scribus/scribusstructs.h (wersja 17243) +++ scribus/scribusstructs.h (kopia robocza) @@ -472,6 +475,53 @@ } }; + +//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, + ETEAclearContents = 30, + ETEAslotGetContent = 31, + ETEAslotFileAppend = 32, + ETEAinsertingText = 33, + ETEAinsertingSpecChar = 34, + ETEAinsertLoremIpsum = 35, + ETEAreplacingText = 36, + ETEAdeletingText = 37, +// ETEAinsertingTabs = 38, + ETEAsetColsGapDist = 39, + ETEAsetIndentMargs = 40, + ETEAsetFirstLineOffset = 41 +} exactlyTextEditAct; + #endif - Index: scribus/actionmanager.cpp =================================================================== --- scribus/actionmanager.cpp (wersja 17243) +++ scribus/actionmanager.cpp (kopia robocza) @@ -94,9 +94,58 @@ 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 text effects")); + 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 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")); + textEditActionDescriptions.insert(ETEAclearContents, QObject::tr("Clear contents")); + textEditActionDescriptions.insert(ETEAslotGetContent, QObject::tr("Load text file")); + textEditActionDescriptions.insert(ETEAslotFileAppend, QObject::tr("Append text file")); + textEditActionDescriptions.insert(ETEAinsertingText, QObject::tr("Inserting text")); + textEditActionDescriptions.insert(ETEAinsertingSpecChar, QObject::tr("Inserting special char")); + textEditActionDescriptions.insert(ETEAinsertLoremIpsum, QObject::tr("Inserting text example")); + textEditActionDescriptions.insert(ETEAreplacingText, QObject::tr("Replacing text")); + textEditActionDescriptions.insert(ETEAdeletingText, QObject::tr("Deleting text")); + // better merge it with "ManageTabs" + //textEditActionDescriptions.insert(ETEAinsertingTabs, QObject::tr("Inserting Tabs")); + textEditActionDescriptions.insert(ETEAsetColsGapDist, QObject::tr("Manage columns, gaps, distances")); + textEditActionDescriptions.insert(ETEAsetIndentMargs, QObject::tr("Manage indents and margins")); + textEditActionDescriptions.insert(ETEAsetFirstLineOffset, QObject::tr("Set first line offset")); +} + void ActionManager::initFileMenuActions() { QString name; @@ -1503,6 +1658,7 @@ (*scrActions)["specialUnicodeSequenceBegin"]->setTexts( tr("Insert Unicode Character Begin Sequence")); languageChangeUnicodeActions(scrActions); languageChangeActions(); + initTextEditActionsDescriptions(); } void ActionManager::languageChangeUnicodeActions(QMap<QString, QPointer<ScrAction> > *actionMap) Index: scribus/pageitem_textframe.h =================================================================== --- scribus/pageitem_textframe.h (wersja 17243) +++ 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,8 @@ 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 restoreTextSelection(int selStart, int selLength); void deselectAll(); virtual void invalidateLayout(); @@ -105,14 +106,43 @@ bool cursorBiasBackward; void setShadow(); - void restoreTextSelection(int selStart, int selLength); QString currentShadow; QMap<QString,StoryText> shadows; + + //saving columns Start/End char positions for validate orphan/widow + //next this positions will be compared with start/end of paragraphs + struct SEColumn + { + int start; + int end; + }; + QMap<int,SEColumn> SEColumnsMap; //contains start/end data for columns in frame + bool setColumnSE(int col, int Cstart, int Cend); // sets start/end positions for column col in QMap startendColumn field + + // set text frame height to last line of text + // if Cols ==1 and all text fit in frame and frame is not linked + double maxY; + void setMaxY(double y); + + EditAct lastUndoAction; + exactlyTextEditAct lastExactTextEditAction; + public: - void updateUndo(EditAct action = PARAMFULL, QString str = ""); - EditAct lastUndoAction; + void setTextFrameHeight(); + int getColumnSE(int col, bool start); // return start or end position for column col from QMap startendColumn field, start default value is true + + void clearLastUndoAction() { lastUndoAction = PageItem::NOACTION; }; + EditAct getLastUndoAction() { return lastUndoAction; }; + exactlyTextEditAct getLastETEA() { return lastExactTextEditAction; }; + void setLastUndoAction(EditAct action) { lastUndoAction = action; }; + void setLastETEA(exactlyTextEditAct ETEA) { lastExactTextEditAction = ETEA; }; + void updateUndo(EditAct action, exactlyTextEditAct newAction, QString str = ""); + void updateUndo(EditAct action, QString str = "") { updateUndo(action, ETEAotherEditAction, str); }; private slots: void slotInvalidateLayout(); +public: + void insertMarkerDlg(MarkerType mT = MARKERAnchorType); + void editMarkerDlg(Marker * marker); }; #endif |
|
OK, now you have uploaded a new patch with enhanced version of text undo. Patch is for current 1.4.1svn. In addition I had fix cursor placing after undo/redo for deleting chars by Delete/Backspace keys and rulers update after undo/redo for changing paragraph`s indents. |
|
Seems I have upload not last version of my patch, sorry. Last one is better. |
|
_newTextUndo_.patch (77,646 bytes)
Index: scribus/canvasmode_legacy.cpp =================================================================== --- scribus/canvasmode_legacy.cpp (wersja 17243) +++ scribus/canvasmode_legacy.cpp (kopia robocza) @@ -1800,7 +1800,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,ETEAinsertingText, cc); if (m_doc->docHyphenator->AutoCheck) m_doc->docHyphenator->slotHyphenate(currItem); m_ScMW->BookMarkTxT(currItem); Index: scribus/pageitem.cpp =================================================================== --- scribus/pageitem.cpp (wersja 17243) +++ scribus/pageitem.cpp (kopia robocza) @@ -44,6 +44,7 @@ #include "commonstrings.h" #include "cpalette.h" #include "guidemanager.h" +#include "hruler.h" #include "page.h" #include "pageitem_latexframe.h" #include "pageitem_textframe.h" @@ -1004,6 +1005,51 @@ void PageItem::setGridOffset(double) { } // FIXME void PageItem::setGridDistance(double) { } // FIXME +void PageItem::setColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom) +{ + setUndoColsGapDist(newCols, newGap, newLeft, newRight, newTop, newBottom); + setColumns(newCols); + setColumnGap(newGap); + setTextToFrameDist(newLeft, newRight, newTop, newBottom); +} +void PageItem::setUndoColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom) +{ + if (UndoManager::undoEnabled()) + { + SimpleState * ss = NULL; + if (asTextFrame()->getLastUndoAction() == STORY && asTextFrame()->getLastETEA() == ETEAsetColsGapDist) + ss = (SimpleState*) undoManager->getLastUndoState(); + if (ss && ss->undoObject() == this && ss->contains("COLSGAPDIST")) + { + ss->set("NEW_COLS", newCols); + ss->set("NEW_GAP", newGap); + ss->set("NEW_DLEFT", newLeft); + ss->set("NEW_DRIGHT", newRight); + ss->set("NEW_DTOP", newTop); + ss->set("NEW_DBOTTOM", newBottom); + } + else + { + ss = new SimpleState(Um::SetColsGapDist); + ss->set("COLSGAPDIST","ColsGapDist"); + ss->set("OLD_COLS", Cols); + ss->set("NEW_COLS", newCols); + ss->set("OLD_GAP", ColGap); + ss->set("NEW_GAP", newGap); + ss->set("OLD_DLEFT", Extra); + ss->set("NEW_DLEFT", newLeft); + ss->set("OLD_DRIGHT", RExtra); + ss->set("NEW_DRIGHT", newRight); + ss->set("OLD_DTOP", TExtra); + ss->set("NEW_DTOP", newTop); + ss->set("OLD_DBOTTOM", BExtra); + ss->set("NEW_DBOTTOM", newBottom); + undoManager->action(this, ss); + asTextFrame()->setLastUndoAction(STORY); + asTextFrame()->setLastETEA(ETEAsetColsGapDist); + } + } +} void PageItem::setColumns(int n) { Cols = qMax(1, n); //FIXME: undo @@ -3300,6 +3346,10 @@ restoreUnlinkTextFrame(ss, isUndo); else if (ss->contains("REVERSE_TEXT")) restoreReverseText(ss, isUndo); + else if (ss->contains("COLSGAPDIST")) + restoreColsGapDist(ss, isUndo); + else if (ss->contains("FIRSTLINEOFFS")) + restoreFirstLineOffset(ss, isUndo); } if (!OnMasterPage.isEmpty()) m_Doc->setCurrentPage(oldCurrentPage); @@ -3550,6 +3600,16 @@ // m_Doc->chAbStyle(this, styleid); } +void PageItem::restoreColsGapDist(SimpleState *state, bool isUndo) +{ + if (isUndo) + setColsGapDist(state->getInt("OLD_COLS"), state->getDouble("OLD_GAP"), state->getDouble("OLD_DLEFT"), state->getDouble("OLD_DRIGHT"), state->getDouble("OLD_DTOP"), state->getDouble("OLD_DBOTTOM")); + else + setColsGapDist(state->getInt("NEW_COLS"), state->getDouble("NEW_GAP"), state->getDouble("NEW_DLEFT"), state->getDouble("NEW_DRIGHT"), state->getDouble("NEW_DTOP"), state->getDouble("NEW_DBOTTOM")); + m_Doc->scMW()->selectItemsFromOutlines(this); + update(); + asTextFrame()->clearLastUndoAction(); +} // FIXME: This must go into class ScribusDoc! // For now we'll just make it independent of 'this' -- AV @@ -3715,6 +3775,16 @@ } } +void PageItem::restoreFirstLineOffset(SimpleState *state, bool isUndo) +{ + if (isUndo) + setFirstLineOffset((FirstLineOffsetPolicy)state->getInt("OLD_FLOP")); + else + setFirstLineOffset((FirstLineOffsetPolicy)state->getInt("NEW_FLOP")); + update(); + asTextFrame()->clearLastUndoAction(); +} + void PageItem::restoreReverseText(UndoState *state, bool /*isUndo*/) { if (!isTextFrame()) @@ -3894,10 +3964,13 @@ { if (!isTextFrame()) return; - itemText.deselectAll(); - HasSel = false; + if (HasSel) + { + 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) @@ -3912,29 +3985,35 @@ 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); } - 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(true); asTextFrame()->deleteSelectedTextFromFrame(); + itemText.insert(SelStart, *story); int ItemLength = itemText.length(); - itemText.insert(SelStart, *story); // 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.deselectAll(); + if (action == SELECTION) { - itemText.setStyle(-1, story->paragraphStyle(story->length())); + itemText.select(SelStart, story->length()); + HasSel = true; + itemText.setCursorPosition(itemText.endOfSelection() -1); } - itemText.select(SelStart, story->length()); - HasSel = true; + else // action == PARAPGRAPH + itemText.setCursorPosition(state->getInt("STEXT_CPOS")); } - itemText.setCursorPosition( itemText.endOfSelection() ); delete story; } else { qDebug() << "UNDO buffer EMPTY";} @@ -3973,6 +4052,7 @@ itemText.select(pos, story->length()); HasSel = true; delete story; + itemText.setCursorPosition(itemText.endOfSelection()); } else if (action == INSSAX || action == DELSAX) { @@ -3995,7 +4075,10 @@ else { //undo for DELSAX, redo for INSSAX + if (state->getBool("STEXT_DELBACK")) + pos -=story->length(); itemText.insert(pos, *story); + itemText.setCursorPosition(state->getInt("STEXT_CPOS")); } delete story; } @@ -4014,18 +4097,18 @@ } } // 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 ""; + if (itemText.length() <= 0) return ""; StoryText iT(m_Doc); iT.setDefaultStyle(itemText.defaultStyle()); - if (undoItem == FRAME) + if (action == STORY) iT.insert(0, itemText); else { @@ -4035,13 +4118,23 @@ StartOldSel = itemText.startOfSelection(); LenOldSel = itemText.lengthOfSelection(); } - if (undoItem == PARAGRAPH) + if (action == PARAGRAPH) asTextFrame()->expandParaSelection(true); - else if (undoItem == CHAR || !HasSel) + else if (action == SELECTION && !HasSel) { - if (itemText.cursorPosition() >= itemText.length()) - return ""; - itemText.select(itemText.cursorPosition(), 1); + //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 + int CPos = itemText.cursorPosition(); + 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 ""; + itemText.select(CPos, 1); } //is SELECTION iT.insert(0, itemText, true); @@ -4097,7 +4190,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); @@ -6028,12 +6121,30 @@ void PageItem::setFirstLineOffset(FirstLineOffsetPolicy flop) { if(firstLineOffsetP != flop) + firstLineOffsetP = flop; +} +void PageItem::setUndoFirstLineOffset(FirstLineOffsetPolicy flop) +{ + if(firstLineOffsetP != flop) { + if (UndoManager::undoEnabled()) + { + SimpleState * ss = NULL; + if (asTextFrame()->getLastUndoAction() == STORY && asTextFrame()->getLastETEA() == ETEAsetFirstLineOffset) + ss = (SimpleState*) undoManager->getLastUndoState(); + if (ss && ss->undoObject() == this && ss->contains("FIRSTLINEOFFS")) + ss->set("NEW_FLOP", flop); + else + { + ss = new SimpleState(Um::SetFirstLineOffset); + ss->set("FIRSTLINEOFFS", "FirstLineOffset"); + ss->set("OLD_FLOP", (int) firstLineOffsetP); + ss->set("NEW_FLOP", flop); + undoManager->action(this, ss); + asTextFrame()->setLastUndoAction(STORY); + asTextFrame()->setLastETEA(ETEAsetFirstLineOffset); + } + } firstLineOffsetP = flop; } } - - - - - Index: scribus/pageitem_textframe.cpp =================================================================== --- scribus/pageitem_textframe.cpp (wersja 17243) +++ 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" @@ -2821,11 +2821,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, ETEAclearContents); //for undo while (nextItem != 0) { nextItem->invalid = true; @@ -2909,7 +2909,7 @@ case Qt::Key_Down: if ( (buttonModifiers & Qt::ShiftModifier) == 0 ) deselectAll(); - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); } if (unicodeTextEditMode) @@ -2938,21 +2938,18 @@ { 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 = itemText.cursorPosition(); itemText.insertChars(QString(QChar(conv)), true); if (itemTextSaxed.isEmpty()) - updateUndo(INS, QString(QChar(conv))); + updateUndo(INS, ETEAinsertingText, QString(QChar(conv))); else - updateUndo(REPSAX, getTextSaxed(QString(QChar(conv)))); + updateUndo(REPSAX, ETEAreplacingText, getTextSaxed(QString(QChar(conv)))); // Tinput = true; m_Doc->scMW()->setTBvals(this); update(); @@ -3245,7 +3242,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); m_Doc->scMW()->setTBvals(this); update(); // view->RefreshItem(this); @@ -3267,7 +3264,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingText); update(); // Tinput = false; if ((cr == QChar(13)) && (itemText.length() != 0)) @@ -3283,10 +3280,10 @@ { if (itemText.lengthOfSelection() > 0) { - oldCPos = itemText.startOfSelection(); + oldCPos = itemText.startOfSelection() + itemText.lengthOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingBackText); m_Doc->scMW()->setTBvals(this); update(); } @@ -3297,14 +3294,16 @@ cr = itemText.text(qMax(itemText.cursorPosition() - 1,0),1); if (itemText.lengthOfSelection() == 0) { + oldCPos = itemText.cursorPosition(); itemText.setCursorPosition(-1, true); itemText.select(itemText.cursorPosition(), 1, true); HasSel = true; } - oldCPos = itemText.startOfSelection(); + else + oldCPos = itemText.startOfSelection() + itemText.lengthOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - updateUndo(DELSAX); + updateUndo(DELSAX, ETEAdeletingBackText); // Tinput = false; if ((cr == QChar(13)) && (itemText.length() != 0)) { @@ -3319,7 +3318,7 @@ itemText.setCursorPosition(firstInFrame()); if (BackBox != 0) { - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); view->Deselect(true); if (BackBox->invalid) BackBox->updateLayout(); @@ -3327,8 +3326,8 @@ m_Doc->scMW()->selectItemsFromOutlines(BackBox); } } + update(); m_Doc->scMW()->setTBvals(this); - update(); // view->RefreshItem(this); break; default: @@ -3351,7 +3350,7 @@ oldCPos = itemText.startOfSelection(); itemTextSaxed = getItemTextSaxed(PageItem::SELECTION); deleteSelectedTextFromFrame(); - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); doUpdate = true; } /* @@ -3369,11 +3368,11 @@ { oldCPos = itemText.cursorPosition(); itemText.insertChars(QString(SpecialChars::TAB), true); - lastUndoAction = PageItem::NOACTION; + clearLastUndoAction(); if (itemTextSaxed.isEmpty()) - updateUndo(INS, QString(SpecialChars::TAB)); + updateUndo(INS, ETEAmanageTabs, QString(SpecialChars::TAB)); else - updateUndo(REPSAX, getTextSaxed(QString(SpecialChars::TAB))); + updateUndo(REPSAX, ETEAmanageTabs, getTextSaxed(QString(SpecialChars::TAB))); // Tinput = true; // view->RefreshItem(this); doUpdate = true; @@ -3381,14 +3380,14 @@ 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 = itemText.cursorPosition(); itemText.insertChars(uc, true); if (itemTextSaxed.isEmpty()) - updateUndo(INS, uc); + updateUndo(INS, ETEAinsertingText, uc); else - updateUndo(REPSAX, getTextSaxed(uc)); + updateUndo(REPSAX, ETEAreplacingText, getTextSaxed(uc)); if ((m_Doc->docHyphenator->AutoCheck) && (itemText.cursorPosition() > 1)) { Twort = ""; @@ -3566,46 +3565,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(); - LenSel = itemText.endOfParagraph() - StartSel; - } - itemText.select(StartSel, LenSel); - HasSel = true; -} - void PageItem_TextFrame::expandParaSelection(bool includeEOL) { int selStart, selLength; - if (HasSel) + if (itemText.lengthOfSelection() >0) { + if (itemText.cursorPosition() == itemText.endOfSelection() && itemText.cursorPosition() < 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(); selLength = itemText.endOfParagraph() - selStart; } - if (includeEOL) + if (includeEOL && itemText.text(selStart + selLength -1) != SpecialChars::PARSEP) selLength += 1; selLength = qMin(selLength, itemText.length() - selStart); @@ -3874,25 +3865,41 @@ invalidateLayout(); } -void PageItem_TextFrame::updateUndo(EditAct action, QString str) + +void PageItem_TextFrame::updateUndo(EditAct action, exactlyTextEditAct newAction, QString str) { if (UndoManager::undoEnabled() && undoManager->undoEnabled()) { - int oldSelStart = -1, oldSelLen = -1; + int oldSelStart = itemText.cursorPosition(), oldSelLen = 0; oldSelLen = itemText.lengthOfSelection(); if (oldSelLen > 0) oldSelStart = itemText.startOfSelection(); - if (action == PARAMFULL && m_Doc->appMode == modeEdit) + int CPos = itemText.cursorPosition(); + 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.item(CPos)->hasObject() + || itemText.text(CPos) == SpecialChars::SHYPHEN) + //case if after cursor is special char, no selection, 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 (itemText.cursorPosition() >= itemText.length() && itemTextSaxed.isEmpty() && action == PARAMFULL && m_Doc->appMode == modeEdit) + if (itemText.cursorPosition() >= 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; } @@ -3903,19 +3910,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 (lastExactTextEditAction == 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) { @@ -3928,13 +3935,49 @@ } 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 != ETEAotherEditAction) + descript += "\n" + doc()->scMW()->actionManager->textEditActionDescriptions.value(newAction,""); + ss = new SimpleState(UndoManager::EditText, descript); ss->set("STEXT_CPOS", oldCPos); } if (action == INSSAX || action == INS) ss->set("STEXT_STR",str); else if (action == DELSAX) + { ss->set("STEXT_STR",itemTextSaxed); + if (newAction == ETEAdeletingBackText) + ss->set("STEXT_DELBACK", 1); + else + ss->set("STEXT_DELBACK", 0); + } else if (action == REPSAX) { ss->set("STEXT_NEW",str); @@ -3942,24 +3985,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(true); ss->set("STEXT_CPOS", itemText.cursorPosition()); 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) @@ -3969,6 +4006,7 @@ } itemTextSaxed.clear(); lastUndoAction = action; + lastExactTextEditAction = newAction; ss->set("STEXT",(int) action); if (newState) undoManager->action(this, ss); Index: scribus/scribus.cpp =================================================================== --- scribus/scribus.cpp (wersja 17243) +++ scribus/scribus.cpp (kopia robocza) @@ -1118,9 +1118,10 @@ currItem->oldCPos = currItem->itemText.cursorPosition(); currItem->itemText.insertChars(QString(QChar(unicodevalue)), true); if (currItem->itemTextSaxed.isEmpty()) - currItem->asTextFrame()->updateUndo(PageItem::INS, QString(QChar(unicodevalue))); + currItem->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingText, QString(QChar(unicodevalue))); else - currItem->asTextFrame()->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(QString(QChar(unicodevalue)))); + currItem->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAreplacingText, currItem->getTextSaxed(QString(QChar(unicodevalue)))); + currItem->itemText.setCursorPosition(currItem->itemText.cursorPosition() + 1); // currItem->Tinput = true; currItem->update(); } @@ -1137,7 +1138,7 @@ #else currItem->oldCPos = currItem->itemText.cursorPosition() ; currItem->itemText.insertChars(QString(SpecialChars::SHYPHEN), true); - currItem->asTextFrame()->updateUndo(PageItem::INS, QString(SpecialChars::SHYPHEN)); + currItem->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, QString(SpecialChars::SHYPHEN)); #endif // currItem->Tinput = true; currItem->update(); @@ -4346,7 +4347,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); @@ -4354,7 +4355,7 @@ return; } gt->launchImporter(impsetup.importer, impsetup.filename, impsetup.textOnly, impsetup.encoding, false); - currItem->asTextFrame()->updateUndo(); + currItem->asTextFrame()->updateUndo(PageItem::STORY, ETEAgetContent); } delete gt; if (doc->docHyphenator->AutoCheck) @@ -4381,7 +4382,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); @@ -4390,7 +4391,7 @@ if (doc->Items->at(a)->isBookmark) bookmarkPalette->BView->ChangeText(doc->Items->at(a)); } - currItem->asTextFrame()->updateUndo(); + currItem->asTextFrame()->updateUndo(PageItem::STORY, ETEAgetContent); view->DrawNew(); slotDocCh(); } @@ -4447,9 +4448,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, ETEAfileAppend); } delete gt; //CB Hyphenating now emits doc changed, plus we change lang as appropriate @@ -5030,6 +5031,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); @@ -5050,7 +5052,7 @@ dynamic_cast<PageItem_TextFrame*>(currItem)->deleteSelectedTextFromFrame(); //for undo - currItem->asTextFrame()->updateUndo(PageItem::DELSAX); + currItem->asTextFrame()->updateUndo(PageItem::DELSAX, ETEAdeletingText, oldstr); currItem->update(); } else @@ -5186,7 +5188,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 @@ -5214,7 +5216,7 @@ currItem->itemText.select(currItem->oldCPos, 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, ETEAinsertingText, currItem->getItemTextSaxed(PageItem::SELECTION)); currItem->itemText.deselectAll(); delete story; @@ -5303,7 +5305,7 @@ currItem->itemText.select(currItem->oldCPos, currItem->itemText.cursorPosition() - 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, ETEAinsertingText, currItem->getItemTextSaxed(PageItem::SELECTION)); } else { @@ -5318,10 +5320,9 @@ currItem->HasSel = true; //if itemTextSaxed is not empty there was selection if (currItem->itemTextSaxed.isEmpty()) - currItem->updateUndo(PageItem::INS, text); + currItem->updateUndo(PageItem::INS, ETEAinsertingText, text); else - currItem->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(text)); - + currItem->updateUndo(PageItem::REPSAX, ETEAreplacingText, currItem->getTextSaxed(text)); } currItem->update(); } @@ -7052,11 +7053,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(); @@ -7067,8 +7067,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); @@ -7084,8 +7083,7 @@ } } 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(); } @@ -7098,6 +7096,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)) @@ -7121,6 +7121,8 @@ } delete dia; } + if (currItem->asTextFrame()) + currItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::STORY, ETEAsetItemShade); } // slotDocCh(); } @@ -7485,15 +7487,19 @@ 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); + bool parSel = false; + if (doc->appMode == modeEdit && currItem->itemText.lengthOfSelection() == 0 && currItem->asTextFrame()) + { + currItem->asTextFrame()->expandParaSelection(); + parSel = true; + } + if (parSel) + currItem->itemText.deselectAll(); } } @@ -7509,10 +7515,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/propertiespalette.cpp =================================================================== --- scribus/propertiespalette.cpp (wersja 17243) +++ scribus/propertiespalette.cpp (kopia robocza) @@ -2947,11 +2947,10 @@ if ((HaveDoc) && (HaveItem)) { if (CurItem->asTextFrame()) - CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME); + 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); } } @@ -3294,7 +3293,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()) @@ -3306,7 +3305,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() @@ -3335,12 +3334,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); } @@ -3349,13 +3348,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() @@ -3363,12 +3362,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() @@ -3376,12 +3375,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); } @@ -3400,10 +3399,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() @@ -3411,10 +3410,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) @@ -3442,10 +3441,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, ETEAnewTScale); } void PropertiesPalette::NewX() @@ -3870,10 +3869,10 @@ if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; if (CurItem->asTextFrame()) - CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME); + 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() @@ -3893,7 +3892,7 @@ { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; - CurItem->Cols = DCol->value(); + CurItem->setColsGapDist(DCol->value(), CurItem->ColGap, CurItem->textToFrameDistLeft(), CurItem->textToFrameDistRight(), CurItem->textToFrameDistTop(), CurItem->textToFrameDistBottom()); setCols(CurItem->Cols, CurItem->ColGap); CurItem->update(); emit DocChanged(); @@ -3914,8 +3913,9 @@ { if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; + double newGap; if (colgapLabel->currentIndex() == 0) - CurItem->ColGap = dGap->value() / m_unitRatio; + newGap = dGap->value() / m_unitRatio; else { double lineCorr; @@ -3924,9 +3924,9 @@ else lineCorr = 0; double newWidth = dGap->value() / m_unitRatio; - double newGap = qMax(((CurItem->width() - CurItem->textToFrameDistLeft() - CurItem->textToFrameDistRight() - lineCorr) - (newWidth * CurItem->Cols)) / (CurItem->Cols - 1), 0.0); - CurItem->ColGap = newGap; + newGap = qMax(((CurItem->width() - CurItem->textToFrameDistLeft() - CurItem->textToFrameDistRight() - lineCorr) - (newWidth * CurItem->Cols)) / (CurItem->Cols - 1), 0.0); } + CurItem->setColsGapDist(CurItem->Cols, newGap, CurItem->textToFrameDistLeft(), CurItem->textToFrameDistRight(), CurItem->textToFrameDistTop(), CurItem->textToFrameDistBottom()); CurItem->update(); emit DocChanged(); } @@ -3936,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() @@ -3947,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() @@ -4271,10 +4271,10 @@ if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; if (CurItem->asTextFrame()) - CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME); + 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) @@ -4282,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() @@ -4293,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); } } @@ -4319,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); } } @@ -4345,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); } } @@ -4381,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); } } @@ -4647,7 +4647,7 @@ return; if ((HaveDoc) && (HaveItem)) { - CurItem->setTextToFrameDist(DLeft->value() / m_unitRatio, DRight->value() / m_unitRatio, DTop->value() / m_unitRatio, DBottom->value() / m_unitRatio); + CurItem->setColsGapDist(CurItem->Cols, CurItem->ColGap, DLeft->value() / m_unitRatio, DRight->value() / m_unitRatio, DTop->value() / m_unitRatio, DBottom->value() / m_unitRatio); setCols(CurItem->Cols, CurItem->ColGap); CurItem->update(); emit DocChanged(); @@ -4708,10 +4708,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, ETEAclearCStyle); } } @@ -4723,16 +4723,20 @@ 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, ETEAclearPStyle); + bool parSel = false; + if (doc->appMode == modeEdit && CurItem->itemText.lengthOfSelection() == 0 && CurItem->asTextFrame()) + { + CurItem->asTextFrame()->expandParaSelection(); + parSel = true; + } + if (parSel) + CurItem->itemText.deselectAll(); } } @@ -4879,10 +4883,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() @@ -4890,10 +4894,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); } @@ -4903,7 +4907,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(); @@ -4915,7 +4919,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) @@ -5065,7 +5069,7 @@ CurItem->update(); qDebug() << "PropertiesPalette::handleFillRule() updateUNDO"; if (CurItem->asTextFrame()) - CurItem->asTextFrame()->updateUndo(); + CurItem->asTextFrame()->updateUndo(PageItem::STORY); emit DocChanged(); } @@ -5150,10 +5154,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()); @@ -5168,7 +5169,7 @@ } CurItem->update(); if (CurItem->asTextFrame()) - CurItem->asTextFrame()->updateUndo(); + CurItem->asTextFrame()->updateUndo(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::STORY, ETEAmanageTabs); emit DocChanged(); } @@ -5890,11 +5891,11 @@ return; // qDebug("%s", QString("rF %1").arg(radioFlop).toAscii()); if( radioFlop == 0) - CurItem->setFirstLineOffset(FLOPRealGlyphHeight); + CurItem->setUndoFirstLineOffset(FLOPRealGlyphHeight); else if( radioFlop == 1) - CurItem->setFirstLineOffset(FLOPFontAscent); + CurItem->setUndoFirstLineOffset(FLOPFontAscent); else if( radioFlop == 2) - CurItem->setFirstLineOffset(FLOPLineSpacing); + CurItem->setUndoFirstLineOffset(FLOPLineSpacing); CurItem->update(); emit DocChanged(); } Index: scribus/undomanager.cpp =================================================================== --- scribus/undomanager.cpp (wersja 17243) +++ scribus/undomanager.cpp (kopia robocza) @@ -882,6 +882,7 @@ UndoManager::StartAndEndArrow = tr("Set start and end arrows"); UndoManager::CreateTable = tr("Create table"); UndoManager::RowsCols = tr("Rows: %1, Cols: %2"); + UndoManager::SetColsGapDist = tr("Set columns, gap and text distances"); UndoManager::SetFont = tr("Set font"); UndoManager::SetFontSize = tr("Set font size"); UndoManager::SetFontWidth = tr("Set font width"); @@ -896,6 +897,7 @@ UndoManager::SetLanguage = tr("Set language"); UndoManager::AlignText = tr("Align text"); UndoManager::SetFontEffect = tr("Set font effect"); + UndoManager::SetFirstLineOffset = tr("Set first line offset"); UndoManager::ImageFrame = tr("Image frame"); UndoManager::TextFrame = tr("Text frame"); UndoManager::LatexFrame = tr("Render frame"); @@ -1095,6 +1097,7 @@ QString UndoManager::StartAndEndArrow = ""; QString UndoManager::CreateTable = ""; QString UndoManager::RowsCols = ""; +QString UndoManager::SetColsGapDist = ""; QString UndoManager::SetFont = ""; QString UndoManager::SetFontSize = ""; QString UndoManager::SetFontWidth = ""; @@ -1109,6 +1112,7 @@ QString UndoManager::SetLanguage = ""; QString UndoManager::AlignText = ""; QString UndoManager::SetFontEffect = ""; +QString UndoManager::SetFirstLineOffset = ""; QString UndoManager::ImageFrame = ""; QString UndoManager::TextFrame = ""; QString UndoManager::LatexFrame = ""; Index: scribus/actionmanager.h =================================================================== --- scribus/actionmanager.h (wersja 17243) +++ 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<exactlyTextEditAct,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/loremipsum.cpp =================================================================== --- scribus/loremipsum.cpp (wersja 17243) +++ 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,9 +346,9 @@ 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, ETEAinsertLoremIpsum, Lorip); else - currItem->asTextFrame()->updateUndo(PageItem::REPSAX, currItem->getTextSaxed(Lorip)); + currItem->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertLoremIpsum, currItem->getTextSaxed(Lorip)); delete lp; //if (ScMW->view->SelItem.at(i)->Doc->docHyphenator->AutoCheck) Index: scribus/undomanager.h =================================================================== --- scribus/undomanager.h (wersja 17243) +++ scribus/undomanager.h (kopia robocza) @@ -508,6 +508,7 @@ static QString StartAndEndArrow; static QString CreateTable; static QString RowsCols; + static QString SetColsGapDist; static QString SetFont; static QString SetFontSize; static QString SetFontWidth; @@ -522,6 +523,7 @@ static QString SetLanguage; static QString AlignText; static QString SetFontEffect; + static QString SetFirstLineOffset; static QString ImageFrame; static QString TextFrame; static QString LatexFrame; Index: scribus/hruler.cpp =================================================================== --- scribus/hruler.cpp (wersja 17243) +++ scribus/hruler.cpp (kopia robocza) @@ -34,6 +34,7 @@ #include "canvasgesture_rulermove.h" #include "hruler.h" #include "page.h" +#include "pageitem_textframe.h" #include "prefsmanager.h" #include "scribus.h" #include "scribusdoc.h" @@ -241,14 +242,17 @@ { bool mustApplyStyle = false; ParagraphStyle paraStyle; - double ColWidth = (textWidth() - ColGap * (Cols - 1)) / Cols; + double ColWidth = (textWidth() - ColGap * (Cols - 1)) / Cols; + exactlyTextEditAct ETEA = ETEAsetIndentMargs; switch (RulerCode) { case rc_leftFrameDist: + currDoc->m_Selection->itemAt(0)->setUndoColsGapDist(Cols, ColGap, Extra, RExtra, currDoc->m_Selection->itemAt(0)->textToFrameDistTop(), currDoc->m_Selection->itemAt(0)->textToFrameDistBottom()); currDoc->m_Selection->itemAt(0)->setTextToFrameDistLeft(Extra); emit DocChanged(false); break; case rc_rightFrameDist: + currDoc->m_Selection->itemAt(0)->setUndoColsGapDist(Cols, ColGap, Extra, RExtra, currDoc->m_Selection->itemAt(0)->textToFrameDistTop(), currDoc->m_Selection->itemAt(0)->textToFrameDistBottom()); currDoc->m_Selection->itemAt(0)->setTextToFrameDistRight(RExtra); emit DocChanged(false); break; @@ -269,6 +273,7 @@ emit DocChanged(false); break; case rc_tab: + ETEA = ETEAmanageTabs; if (m->button() == Qt::RightButton) { TabValues[ActTab].tabType += 1; @@ -284,9 +289,11 @@ } if (mustApplyStyle) { + currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::PARAGRAPH); Selection tempSelection(this, false); tempSelection.addItem(currItem); currDoc->itemSelection_ApplyParagraphStyle(paraStyle, &tempSelection); + currItem->asTextFrame()->updateUndo(PageItem::PARAGRAPH, ETEA); } else { @@ -303,7 +310,9 @@ paraStyle.setTabValues(TabValues); Selection tempSelection(this, false); tempSelection.addItem(currItem); + currItem->itemTextSaxed = currItem->getItemTextSaxed(PageItem::PARAGRAPH); currDoc->itemSelection_ApplyParagraphStyle(paraStyle, &tempSelection); + currItem->asTextFrame()->updateUndo(PageItem::PARAGRAPH, ETEAmanageTabs); emit DocChanged(false); qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); } Index: scribus/charselect.cpp =================================================================== --- scribus/charselect.cpp (wersja 17243) +++ 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(); @@ -132,9 +132,9 @@ txtIns.append(ch); } if (m_Item->itemTextSaxed.isEmpty()) - m_Item->asTextFrame()->updateUndo(PageItem::INS, txtIns); + m_Item->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, txtIns); else - m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, m_Item->getTextSaxed(txtIns)); + m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertingSpecChar, m_Item->getTextSaxed(txtIns)); m_doc->updateFrameItems(); m_doc->view()->DrawNew(); m_doc->changed(); @@ -149,7 +149,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(); @@ -161,9 +161,9 @@ m_Item->oldCPos = m_Item->itemText.cursorPosition(); m_Item->itemText.insertChars(ch, true); if (m_Item->itemTextSaxed.isEmpty()) - m_Item->asTextFrame()->updateUndo(PageItem::INS, QString(ch)); + m_Item->asTextFrame()->updateUndo(PageItem::INS, ETEAinsertingSpecChar, QString(ch)); else - m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, m_Item->getTextSaxed(QString(ch))); + m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, ETEAinsertingSpecChar, m_Item->getTextSaxed(QString(ch))); m_doc->updateFrameItems(); m_doc->view()->DrawNew(); m_doc->changed(); Index: scribus/canvasmode_edit.cpp =================================================================== --- scribus/canvasmode_edit.cpp (wersja 17243) +++ scribus/canvasmode_edit.cpp (kopia robocza) @@ -410,7 +410,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()) { @@ -650,7 +650,7 @@ if (currItem->asTextFrame()) { m_view->slotSetCurs(m->globalPos().x(), m->globalPos().y()); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); } } else @@ -668,7 +668,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) @@ -678,7 +678,7 @@ //m_view->slotDoCurs(true); m_view->requestMode(modeNormal); if (currItem->isTextFrame()) - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); return; } @@ -703,7 +703,7 @@ oldP = currItem->itemText.endOfSelection(); } currItem->asTextFrame()->itemText.extendSelection(oldP, currItem->itemText.cursorPosition()); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); oldCp = currItem->itemText.cursorPosition(); } else @@ -719,7 +719,7 @@ currItem->itemText.setCursorPosition( currItem->itemText.startOfParagraph() ); } currItem->asTextFrame()->ExpandSel(dir, oldP); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); oldCp = oldP; } } @@ -727,7 +727,7 @@ { oldCp = currItem->itemText.cursorPosition(); currItem->itemText.deselectAll(); - currItem->asTextFrame()->lastUndoAction = PageItem::NOACTION; + currItem->asTextFrame()->clearLastUndoAction(); currItem->HasSel = false; } currItem->emitAllToGUI(); @@ -744,7 +744,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, ETEAinsertingText, cc); if (m_doc->docHyphenator->AutoCheck) m_doc->docHyphenator->slotHyphenate(currItem); m_ScMW->BookMarkTxT(currItem); Index: scribus/pageitem.h =================================================================== --- scribus/pageitem.h (wersja 17243) +++ 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; } @@ -474,7 +468,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 */ @@ -657,12 +651,18 @@ void setTextToFrameDistRight(double); void setTextToFrameDistTop(double); void setTextToFrameDistBottom(double); + + // sets columns, gaps and text distances and create undo step invoking setUndoColsGapDist + void setColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom); + void setUndoColsGapDist(int newCols, double newGap, double newLeft, double newRight, double newTop, double newBottom); + void setColumns(int); void setColumnGap(double); void setGridOffset(double); void setGridDistance(double); FirstLineOffsetPolicy firstLineOffset()const; void setFirstLineOffset(FirstLineOffsetPolicy); + void setUndoFirstLineOffset(FirstLineOffsetPolicy); /** * \brief Set the text to frame distances all at once * @param newLeft left distance @@ -1076,7 +1076,7 @@ void restoreArrow(SimpleState *state, bool isUndo, bool isStart); void restorePStyle(SimpleState *state, bool isUndo); - + void restoreColsGapDist(SimpleState *state, bool isUndo); void restoreType(SimpleState *state, bool isUndo); void restoreTextFlowing(SimpleState *state, bool isUndo); void restoreImageScaleMode(SimpleState *state, bool isUndo); @@ -1095,6 +1095,7 @@ void restoreEditText(SimpleState *state, bool isUndo); void restoreLinkTextFrame(UndoState *state, bool isUndo); void restoreUnlinkTextFrame(UndoState *state, bool isUndo); + void restoreFirstLineOffset(SimpleState *state, bool isUndo); void restoreReverseText(UndoState *state, bool isUndo); /*@}*/ Index: scribus/scribusstructs.h =================================================================== --- scribus/scribusstructs.h (wersja 17243) +++ scribus/scribusstructs.h (kopia robocza) @@ -472,6 +472,53 @@ } }; + +//ETEA = Exactly Text Edit Action +//for Undo state comparising and detailed description +typedef enum { + ETEAotherEditAction, + ETEAsetLineSpacingMode, + ETEAsetOpticalMargins, + ETEAsetMinWordTracking, + ETEAsetNormWordTracking, + ETEAsetMinGlyphExtension, + ETEAsetMaxGlyphExtension, + ETEAnewTScaleV, + ETEAnewTBase, + ETEAnewTScale, + ETEAnewLineSpacing, + ETEAnewSize, + ETEAnewTracking, + ETEAnewAlignement, + ETEAsetTypeStyle, + ETEAnewShadowOffs, + ETEAnewUnderline, + ETEAnewStrike, + ETEAnewOutlineW, + ETEAclearCStyle, + ETEAclearPStyle, + ETEAnewTxtFill, + ETEAnewTxtStroke, + ETEAsetActShade, + ETEAmanageTabs, + ETEAsetNewFont, + ETEAsetItemFSize, + ETEAsetItemShade, + ETEAsetNewParStyle, + ETEAsetNewCharStyle, + ETEAclearContents, + ETEAgetContent, + ETEAfileAppend, + ETEAinsertingText, + ETEAinsertingSpecChar, + ETEAinsertLoremIpsum, + ETEAreplacingText, + ETEAdeletingText, + ETEAdeletingBackText, + ETEAsetColsGapDist, + ETEAsetIndentMargs, + ETEAsetFirstLineOffset +} exactlyTextEditAct; + #endif - Index: scribus/actionmanager.cpp =================================================================== --- scribus/actionmanager.cpp (wersja 17243) +++ scribus/actionmanager.cpp (kopia robocza) @@ -94,9 +94,59 @@ 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 text effects")); + 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(ETEAclearCStyle, QObject::tr("Clear character formatting")); + textEditActionDescriptions.insert(ETEAclearPStyle, 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 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")); + textEditActionDescriptions.insert(ETEAclearContents, QObject::tr("Clear contents")); + textEditActionDescriptions.insert(ETEAgetContent, QObject::tr("Load text file")); + textEditActionDescriptions.insert(ETEAfileAppend, QObject::tr("Append text file")); + textEditActionDescriptions.insert(ETEAinsertingText, QObject::tr("Inserting text")); + textEditActionDescriptions.insert(ETEAinsertingSpecChar, QObject::tr("Inserting special char")); + textEditActionDescriptions.insert(ETEAinsertLoremIpsum, QObject::tr("Inserting text example")); + textEditActionDescriptions.insert(ETEAreplacingText, QObject::tr("Replacing text")); + textEditActionDescriptions.insert(ETEAdeletingText, QObject::tr("Deleting text")); + textEditActionDescriptions.insert(ETEAdeletingBackText, QObject::tr("Deleting text backward")); + // better merge it with "ManageTabs" + //textEditActionDescriptions.insert(ETEAinsertingTabs, QObject::tr("Inserting Tabs")); + textEditActionDescriptions.insert(ETEAsetColsGapDist, QObject::tr("Manage columns, gaps, distances")); + textEditActionDescriptions.insert(ETEAsetIndentMargs, QObject::tr("Manage indents and margins")); + textEditActionDescriptions.insert(ETEAsetFirstLineOffset, QObject::tr("Set first line offset")); +} + void ActionManager::initFileMenuActions() { QString name; @@ -1503,6 +1553,7 @@ (*scrActions)["specialUnicodeSequenceBegin"]->setTexts( tr("Insert Unicode Character Begin Sequence")); languageChangeUnicodeActions(scrActions); languageChangeActions(); + initTextEditActionsDescriptions(); } void ActionManager::languageChangeUnicodeActions(QMap<QString, QPointer<ScrAction> > *actionMap) Index: scribus/pageitem_textframe.h =================================================================== --- scribus/pageitem_textframe.h (wersja 17243) +++ 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,8 @@ 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 restoreTextSelection(int selStart, int selLength); void deselectAll(); virtual void invalidateLayout(); @@ -105,12 +106,20 @@ bool cursorBiasBackward; void setShadow(); - void restoreTextSelection(int selStart, int selLength); QString currentShadow; QMap<QString,StoryText> shadows; + + EditAct lastUndoAction; + exactlyTextEditAct lastExactTextEditAction; + public: - void updateUndo(EditAct action = PARAMFULL, QString str = ""); - EditAct lastUndoAction; + void clearLastUndoAction() { lastUndoAction = PageItem::NOACTION; } + EditAct getLastUndoAction() { return lastUndoAction; } + exactlyTextEditAct getLastETEA() { return lastExactTextEditAction; } + void setLastUndoAction(EditAct action) { lastUndoAction = action; } + void setLastETEA(exactlyTextEditAct ETEA) { lastExactTextEditAction = ETEA; } + void updateUndo(EditAct action, exactlyTextEditAct newAction, QString str = ""); + void updateUndo(EditAct action, QString str = "") { updateUndo(action, ETEAotherEditAction, str); } private slots: void slotInvalidateLayout(); }; |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-03-28 13:59 | cezaryece | New Issue | |
2011-03-28 13:59 | cezaryece | File Added: textUndo_280311.patch | |
2011-03-28 18:53 | cbradney | Assigned To | => jghali |
2011-03-28 18:53 | cbradney | Status | new => assigned |
2011-03-29 05:30 | cezaryece | Note Added: 0025973 | |
2011-03-29 05:41 | cezaryece | Note Edited: 0025973 | |
2011-03-29 06:11 | cezaryece | Note Added: 0025974 | |
2011-03-29 16:10 | cbradney | Note Added: 0025975 | |
2011-03-30 13:50 | cezaryece | Note Added: 0025980 | |
2011-03-30 14:00 | cezaryece | Note Added: 0025981 | |
2011-03-31 11:16 | cezaryece | File Added: textUndo_310311.patch | |
2011-03-31 11:18 | cezaryece | Note Added: 0025987 | |
2011-03-31 11:20 | cezaryece | Note Edited: 0025987 | |
2011-04-01 13:41 | cezaryece | Note Added: 0025992 | |
2011-04-01 13:41 | cezaryece | File Added: textUndo_010411.patch | |
2011-04-04 20:39 | cbradney | Note Added: 0026002 | |
2011-04-05 07:27 | cezaryece | Note Added: 0026004 | |
2011-04-05 07:28 | cezaryece | File Added: textUndo_050411.patch | |
2011-04-05 19:21 | cbradney | Note Added: 0026006 | |
2011-04-05 21:04 | cbradney | Target Version | => 1.4.0 |
2011-04-06 05:16 | cezaryece | Note Added: 0026009 | |
2011-04-16 09:03 | cbradney | Target Version | 1.4.0 => 1.4.1 |
2011-04-16 09:04 | cbradney | Note Added: 0026100 | |
2012-01-03 19:54 | cbradney | Note Added: 0027441 | |
2012-01-23 21:57 | cbradney | Note Added: 0027591 | |
2012-01-26 14:36 | cezaryece | Note Added: 0027598 | |
2012-01-29 11:59 | cezaryece | File Added: newTextUndo.patch | |
2012-01-29 12:05 | cezaryece | Note Added: 0027614 | |
2012-01-30 06:36 | cezaryece | Note Added: 0027622 | |
2012-01-30 06:37 | cezaryece | File Added: _newTextUndo_.patch | |
2012-04-29 21:14 | cbradney | Target Version | 1.4.1 => 1.4.2 |
2013-01-13 21:33 | cbradney | Target Version | 1.4.2 => 1.4.3 |
2013-07-04 20:26 | cbradney | Target Version | 1.4.3 => 1.5.0 |
2014-07-03 19:41 | Kunda | Target Version | 1.5.0 => 1.5.1 |
2014-10-07 23:51 | Kunda | Summary | [FIX] text undo/redo ver. 2 => [PATCH] text undo/redo ver. 2 |
2014-10-24 22:57 | Kunda | Patch | => Yes |
2015-11-29 13:55 | Kunda | Target Version | 1.5.1 => 1.5.2 |
2016-01-23 17:15 | cbradney | Target Version | 1.5.2 => 1.5.4.svn |
2016-05-15 23:06 | Kunda | Target Version | 1.5.4.svn => 1.5.5 |
2016-05-15 23:08 | Kunda | Relationship added | child of 0012500 |