please tell me what I need to fix with the attached. It is supposed to
fix :

1) errors should be inserted inside minipages etc., and converted to Standard
2) all errors should be removed

The first one works fine, except there is a need to do a proper update (as the
size changed), and I don't know the right incantation. 
Is it bv->updateInset(par->inset_owner) ?

The second one is crashing at some code I don't really follow in redoParagraphs.
Can someone tell me why and what needs to be fixed ?

The first bug is really serious as it can crash !

thanks for any help
john

-- 
"Faced with the prospect of rereading this book, I would rather have 
 my brains ripped out by a plastic fork."
        - Charles Cooper on "Business at the Speed of Thought" 
Index: src/BufferView2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView2.C,v
retrieving revision 1.100
diff -u -r1.100 BufferView2.C
--- src/BufferView2.C   2001/11/29 12:58:57     1.100
+++ src/BufferView2.C   2001/12/04 01:27:51
@@ -102,23 +102,22 @@
 
 bool BufferView::removeAutoInsets()
 {
-       Paragraph * par = buffer()->paragraph;
-
        LyXCursor tmpcursor = text->cursor;
        LyXCursor cursor;
-
-       bool a = false;
+       bool found = false;
 
-       while (par) {
+       ParIterator end = buffer()->par_iterator_end();
+       for (ParIterator it = buffer()->par_iterator_begin();
+            it != end; ++it) {
+               Paragraph * par = *it;
                // this has to be done before the delete
                text->setCursor(this, cursor, par, 0);
-               if (par->autoDeleteInsets()){
-                       a = true;
+               if (par->autoDeleteInsets()) {
+                       found = true;
                        text->redoParagraphs(this, cursor,
                                             cursor.par()->next());
                        text->fullRebreak(this);
                }
-               par = par->next();
        }
 
        // avoid forbidden cursor positions caused by error removing
@@ -127,7 +126,7 @@
 
        text->setCursorIntern(this, tmpcursor.par(), tmpcursor.pos());
 
-       return a;
+       return found;
 }
 
 
Index: src/CutAndPaste.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/CutAndPaste.C,v
retrieving revision 1.39
diff -u -r1.39 CutAndPaste.C
--- src/CutAndPaste.C   2001/11/29 17:12:17     1.39
+++ src/CutAndPaste.C   2001/12/04 01:28:10
@@ -17,6 +17,7 @@
 #include "lyx_gui_misc.h"
 #include "lyxcursor.h"
 #include "gettext.h"
+#include "iterators.h"
 
 #ifdef __GNUG__
 #pragma implementation
@@ -264,7 +265,7 @@
                }
                
                // make sure there is no class difference
-               SwitchLayoutsBetweenClasses(textclass, tc, buf);
+               SwitchLayoutsBetweenClasses(textclass, tc, *current_view->buffer());
                
                // make the buf exactly the same layout than
                // the cursor paragraph
@@ -338,21 +339,25 @@
 
 
 int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
-                                            textclass_type c2, Paragraph * par)
+                                            textclass_type c2, Buffer & buf)
 {
        int ret = 0;
-       if (!par || c1 == c2)
+       if (c1 == c2)
                return ret;
        
-       while (par) {
+       ParIterator end(buf.par_iterator_end());
+       for (ParIterator it = buf.par_iterator_begin();
+               it != end; ++it) { 
+               Paragraph * par = *it; 
                string const name = textclasslist.NameOfLayout(c1, par->layout);
                int lay = 0;
+ 
                pair<bool, layout_type> pp =
                        textclasslist.NumberOfLayout(c2, name);
                if (pp.first) {
                        lay = pp.second;
-               } else { // layout not found
-                       // use default layout "Standard" (0)
+               } else {
+                       // not found: use default layout "Standard" (0)
                        lay = 0;
                }
                par->layout = lay;
@@ -367,8 +372,10 @@
                                + textclasslist.NameOfClass(c2);
                        InsetError * new_inset = new InsetError(s);
                        par->insertInset(0, new_inset);
+                       // FIXME: here we need to update e.g. containing minipage
+                       // size
+                       it = ParIterator(par);
                }
-               par = par->next();
        }
        return ret;
 }
Index: src/CutAndPaste.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/CutAndPaste.h,v
retrieving revision 1.12
diff -u -r1.12 CutAndPaste.h
--- src/CutAndPaste.h   2001/11/29 17:12:17     1.12
+++ src/CutAndPaste.h   2001/12/04 01:28:10
@@ -18,6 +18,7 @@
 #include "layout.h"
 
 class Paragraph;
+class Buffer;
 
 ///
 class CutAndPaste {
@@ -45,7 +46,7 @@
        static
        int SwitchLayoutsBetweenClasses(lyx::textclass_type class1,
                                        lyx::textclass_type class2,
-                                       Paragraph * par);
+                                       Buffer & buf);
        ///
        static
        bool checkPastePossible(Paragraph *);
Index: src/frontends/xforms/FormDocument.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormDocument.C,v
retrieving revision 1.77
diff -u -r1.77 FormDocument.C
--- src/frontends/xforms/FormDocument.C 2001/11/26 10:19:52     1.77
+++ src/frontends/xforms/FormDocument.C 2001/12/04 01:28:33
@@ -745,7 +745,7 @@
                        setMinibuffer(lv_, _("Converting document to new document 
class..."));
                        int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
                                old_class, params.textclass,
-                               lv_->buffer()->paragraph);
+                               *lv_->buffer());
                        if (ret) {
                                string s;
                                if (ret==1) {

Reply via email to