diff --git a/src/ChangeLog b/src/ChangeLog index bbb93c56da..ba6045245a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2002-03-15 Juergen Vigna + + * CutAndPaste.C (SwitchLayoutsBetweenClasses): fix the wrong use of + inserting an Inset into the paragraph. I know this is not the best + fix but we already use current_view in CutAndPaste so we will remove + all of it's using at the same time. + + * buffer.C (sgmlError): deactivated function till it is rewritten in + the right mode, now it can create problems. + + * paragraph.C (isLineSeparator): check if getInset returns != 0, + before accessing it. + 2002-03-14 Juergen Vigna * undo_funcs.C (textHandleUndo): do the right thing when updating diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index df12c4de8d..a18806898a 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -19,6 +19,7 @@ #include "buffer.h" #include "paragraph.h" #include "ParagraphParameters.h" +#include "lyxtext.h" #include "lyxcursor.h" #include "gettext.h" #include "iterators.h" @@ -431,9 +432,12 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1, + textclasslist[c1].name() + _(" to ") + textclasslist[c2].name(); InsetError * new_inset = new InsetError(s); - par->insertInset(0, new_inset, - LyXFont(LyXFont::ALL_INHERIT, - bparams.language)); + LyXText * txt = current_view->getLyXText(); + LyXCursor cur = txt->cursor; + txt->setCursorIntern(current_view, par, 0); + txt->insertInset(current_view, new_inset); + txt->fullRebreak(current_view); + txt->setCursorIntern(current_view, cur.par(), cur.pos()); } } return ret; diff --git a/src/buffer.C b/src/buffer.C index 6c4f9e91b1..27b6e3d2fc 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1193,10 +1193,11 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, lex.eatLine(); string const s = _("Unknown token: ") + token + " " + lex.text() + "\n"; - + // we can do this here this way because we're actually reading + // the buffer and don't care about LyXText right now. InsetError * new_inset = new InsetError(s); par->insertInset(pos, new_inset, LyXFont(LyXFont::ALL_INHERIT, - params.language)); + params.language)); #ifndef NO_COMPABILITY } @@ -3078,12 +3079,20 @@ void Buffer::simpleLinuxDocOnePar(ostream & os, // Print an error message. void Buffer::sgmlError(Paragraph * par, int pos, - string const & message) const + string const & message) const { +#warning This is wrong we cannot insert an inset like this!!! + // I guess this was Jose' so I explain you more or less why this + // is wrong. This way you insert something in the paragraph and + // don't tell it to LyXText (row rebreaking and undo handling!!!) + // I deactivate this code, have a look at BufferView::insertErrors + // how you should do this correctly! (Jug 20020315) +#if 0 // insert an error marker in text InsetError * new_inset = new InsetError(message); par->insertInset(pos, new_inset, LyXFont(LyXFont::ALL_INHERIT, - params.language)); + params.language)); +#endif } diff --git a/src/paragraph.C b/src/paragraph.C index 29006e1dde..b2d361acd7 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1921,7 +1921,8 @@ bool Paragraph::isLineSeparator(pos_type pos) const { value_type const c = getChar(pos); return IsLineSeparatorChar(c) - || (IsInsetChar(c) && getInset(pos)->isLineSeparator()); + || (IsInsetChar(c) && getInset(pos) && + getInset(pos)->isLineSeparator()); } diff --git a/src/text2.C b/src/text2.C index ce3c27d570..7f8404d7c8 100644 --- a/src/text2.C +++ b/src/text2.C @@ -495,8 +495,7 @@ Paragraph * LyXText::setLayout(BufferView * bview, endpar = endpar->next(); // because of parindents etc. } - setUndo(bview, Undo::EDIT, - sstart_cur.par(), undoendpar); + setUndo(bview, Undo::EDIT, sstart_cur.par(), undoendpar); // ok we have a selection. This is always between sstart_cur // and sel_end cursor