#include "gettext.h"
#include "iterators.h"
#include "lyxtextclasslist.h"
+#include "undo_funcs.h"
+#include "paragraph_funcs.h"
#include "insets/inseterror.h"
+#include "BoostFormat.h"
+
using std::pair;
using lyx::pos_type;
using lyx::textclass_type;
end = start - 1;
} else {
// more than one paragraph
- (*endpar)->breakParagraphConservative(current_view->buffer()->params,
- end);
+ breakParagraphConservative(current_view->buffer()->params,
+ *endpar,
+ end);
*endpar = (*endpar)->next();
end = 0;
- startpar->breakParagraphConservative(current_view->buffer()->params,
- start);
+ breakParagraphConservative(current_view->buffer()->params,
+ startpar,
+ start);
// store the selection
if (realcut) {
startpar->next()->stripLeadingSpaces();
if (startpar->hasSameLayout(startpar->next()) ||
startpar->next()->empty()) {
- startpar->pasteParagraph(current_view->buffer()->params);
+ mergeParagraph(current_view->buffer()->params, startpar);
(*endpar) = startpar; // this because endpar gets deleted here!
}
// this paragraph's are of noone's owner!
// open the paragraph for inserting the buf
// if necessary
if (((*par)->size() > pos) || !(*par)->next()) {
- (*par)->breakParagraphConservative(current_view->buffer()->params,
- pos);
+ breakParagraphConservative(
+ current_view->buffer()->params,
+ *par,
+ pos);
paste_the_end = true;
}
// set the end for redoing later
if ((*par)->next() == lastbuffer)
lastbuffer = *par;
- (*par)->pasteParagraph(current_view->buffer()->params);
+ mergeParagraph(current_view->buffer()->params, *par);
// store the new cursor position
*par = lastbuffer;
pos = lastbuffer->size();
// maybe some pasting
if (lastbuffer->next() && paste_the_end) {
if (lastbuffer->next()->hasSameLayout(lastbuffer)) {
- lastbuffer->pasteParagraph(current_view->buffer()->params);
+ mergeParagraph(current_view->buffer()->params, lastbuffer);
} else if (lastbuffer->next()->empty()) {
lastbuffer->next()->makeSameLayout(lastbuffer);
- lastbuffer->pasteParagraph(current_view->buffer()->params);
+ mergeParagraph(current_view->buffer()->params, lastbuffer);
} else if (lastbuffer->empty()) {
lastbuffer->makeSameLayout(lastbuffer->next());
- lastbuffer->pasteParagraph(current_view->buffer()->params);
+ mergeParagraph(current_view->buffer()->params, lastbuffer);
} else
lastbuffer->next()->stripLeadingSpaces();
}
string const name = par->layout()->name();
bool hasLayout = tclass2.hasLayout(name);
- if (!hasLayout)
+ if (hasLayout)
+ par->layout(tclass2[name]);
+ else
par->layout(tclass2.defaultLayout());
if (!hasLayout && name != tclass1.defaultLayoutName()) {
++ret;
+#if USE_BOOST_FORMAT
+ boost::format fmt(_("Layout had to be changed from\n"
+ "%1$s to %2$s\n"
+ "because of class conversion from\n"
+ "%3$s to %4$s"));
+ fmt % name
+ % par->layout()->name()
+ % tclass1.name()
+ % tclass2.name();
+
+ string const s = fmt.str();
+#else
string const s = _("Layout had to be changed from\n")
+ name + _(" to ")
+ par->layout()->name()
+ _("\nbecause of class conversion from\n")
+ tclass1.name() + _(" to ")
+ tclass2.name();
+#endif
+ freezeUndo();
InsetError * new_inset = new InsetError(s);
LyXText * txt = current_view->getLyXText();
LyXCursor cur = txt->cursor;
txt->insertInset(current_view, new_inset);
txt->fullRebreak(current_view);
txt->setCursorIntern(current_view, cur.par(), cur.pos());
+ unFreezeUndo();
}
}
return ret;