Fixed/Disabled code inserting InsetError in the wrong way (fix #129)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3758 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2002-03-15 15:28:25 +00:00
parent c90ae47255
commit e81a703cdc
5 changed files with 36 additions and 10 deletions

View File

@ -1,3 +1,16 @@
2002-03-15 Juergen Vigna <jug@sad.it>
* 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 <jug@sad.it>
* undo_funcs.C (textHandleUndo): do the right thing when updating

View File

@ -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;

View File

@ -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
}

View File

@ -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());
}

View File

@ -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