On Wed, Nov 13, 2002 at 03:53:18PM +0100, Jean-Marc Lasgouttes wrote:

> bug and explain what arguments should be passed to beforeChange(),
> what is the exact difference between text and getLyxText(), and so
> on...

See below. The big problem is inserting the new paragraphs properly.
I've only looked at this /extremely/ briefly, if I find time I might do
a more proper investigation.

beforeChange() does nothing but clear the selection, so it's not
interesting.

Difference between bv_->text and bv_->getLyXText is a PITA. As I'm sure
you know bv_->text is the lyxtext object for the top level of the
document, and getLyXText() returns the lyxtext for the locking inset if
there is one. This is complicated by the fact that some operations
aren't inset-dependent and should only be done on bv_->text (one thing
I'd like to clean up !!).

But it's managing the paragraph list that's killing us here

regards
john


Index: buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.391
diff -u -r1.391 buffer.C
--- buffer.C    8 Nov 2002 01:08:26 -0000       1.391
+++ buffer.C    13 Nov 2002 19:59:09 -0000
@@ -305,18 +305,15 @@
        Paragraph * first_par = 0;
        LyXFont font(LyXFont::ALL_INHERIT, params.language);
 
-#if 0
-       if (file_format < 216 && params.language->lang() == "hebrew")
-               font.setLanguage(default_language);
-#endif
-
+       LyXText * t(users->getLyXText());
+ 
        if (!par) {
                par = new Paragraph;
                par->layout(params.getLyXTextClass().defaultLayout());
        } else {
                // We are inserting into an existing document
-               users->text->breakParagraph(users);
-               first_par = users->text->ownerParagraph();
+               t->breakParagraph(users);
+               first_par = t->ownerParagraph();
                pos = 0;
                markDirty();
                // We don't want to adopt the parameters from the
@@ -349,6 +346,9 @@
        if (!first_par)
                first_par = par;
 
+       // FIXME: JMarc, this is where we have problems, we need
+       // to set the start of the relevant par list to the start
+       // if we insert at the top ...
        paragraphs.set(first_par);
 
        if (unknown_layouts > 0) {
Index: BufferView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v
retrieving revision 1.113
diff -u -r1.113 BufferView.C
--- BufferView.C        21 Oct 2002 16:21:51 -0000      1.113
+++ BufferView.C        13 Nov 2002 19:59:15 -0000
@@ -296,7 +296,9 @@
                return false;
        }
 
-       beforeChange(text);
+       LyXText * t(getLyXText());
+ 
+       beforeChange(t);
 
        ifstream ifs(fname.c_str());
        if (!ifs) {
@@ -315,11 +317,11 @@
 
        if (c == '#') {
                lyxerr[Debug::INFO] << "Will insert file with header" << endl;
-               res = buffer()->readFile(lex, fname, text->cursor.par());
+               res = buffer()->readFile(lex, fname, t->cursor.par());
        } else {
                lyxerr[Debug::INFO] << "Will insert file without header"
                                    << endl;
-               res = buffer()->readLyXformat2(lex, text->cursor.par());
+               res = buffer()->readLyXformat2(lex, t->cursor.par());
        }
 
        resize();
-- 
Khendon's Law: If the same point is made twice by the same person,
the thread is over.

Reply via email to