#7740 Add undo for change of text language with LFUN_BUFFER_LANGUAGE

When a document is not multi-lingual the text contents is changed
to the new language. This should be recorded for Undo.
Because Undo wants a cursor the implemantation has to be
moved to the BufferView class.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39508 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stephan Witt 2011-08-23 10:22:14 +00:00
parent c9d9bde0b2
commit 1a0b35288d
2 changed files with 18 additions and 12 deletions

View File

@ -2333,18 +2333,6 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
break;
}
case LFUN_BUFFER_LANGUAGE: {
Language const * oldL = params().language;
Language const * newL = languages.getLanguage(argument);
if (!newL || oldL == newL)
break;
if (oldL->rightToLeft() == newL->rightToLeft() && !isMultiLingual()) {
changeLanguage(oldL, newL);
dr.forceBufferUpdate();
}
break;
}
default:
dispatched = false;
break;

View File

@ -1892,6 +1892,24 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
break;
}
// FIXME:
// The change of language of buffer belongs to the Buffer class.
// We have to do it here because we need a cursor for Undo.
// When Undo::recordUndoBufferParams() is implemented someday
// LFUN_BUFFER_LANGUAGE should be handled by the Buffer class.
case LFUN_BUFFER_LANGUAGE: {
Language const * oldL = buffer_.params().language;
Language const * newL = languages.getLanguage(argument);
if (!newL || oldL == newL)
break;
if (oldL->rightToLeft() == newL->rightToLeft() && !buffer_.isMultiLingual()) {
cur.recordUndoFullDocument();
buffer_.changeLanguage(oldL, newL);
dr.forceBufferUpdate();
}
break;
}
default:
// OK, so try the Buffer itself...
buffer_.dispatch(cmd, dr);