]> git.lyx.org Git - features.git/commitdiff
Fixed/Disabled code inserting InsetError in the wrong way (fix #129)
authorJürgen Vigna <jug@sad.it>
Fri, 15 Mar 2002 15:28:25 +0000 (15:28 +0000)
committerJürgen Vigna <jug@sad.it>
Fri, 15 Mar 2002 15:28:25 +0000 (15:28 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3758 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/CutAndPaste.C
src/buffer.C
src/paragraph.C
src/text2.C

index bbb93c56da6a48cfbf4d16e39587608041ee9f1c..ba6045245aa6579f9370511e0a628f7be94fb9f8 100644 (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
index df12c4de8d81a241a7044b0a11df46c232bb1ba8..a18806898accac594be9c72187f0d8b9c29b11e7 100644 (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;
index 6c4f9e91b148b96a246e1e8944fad86e4b641736..27b6e3d2fcc557104cfd698afc843dc870b113f7 100644 (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
 }
 
 
index 29006e1dde6734502fde9bb7566fec5d0c955b33..b2d361acd794dcb420fe75a2b734dbf2a0f3360c 100644 (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());
 }
 
 
index ce3c27d570d3bc099775f48c1a1c24ecf527413b..7f8404d7c8ed3bddf163fb623382e16f5acba80a 100644 (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