On Tue, Apr 30, 2002 at 11:56:07AM +0200, Juergen Vigna wrote:
> 
> On 29-Apr-2002 Dekel Tsur wrote:
> > On Mon, Apr 29, 2002 at 06:01:27PM +0200, Lars Gullik Bjønnes wrote:
> >> Why do you say that 1.2.0cvs is not able to read files with the latex
> >> layout? Hmm it seems that we test for a valid layout a bit early in
> >> buffer.C... so that the compability reading does not kick in before we
> >> have already changed to using defaultLayoutName...
> >> 
> >> Do anyone have a test file for me? That is f.ex two plain paragraphs
> >> and a latex paragraph in between?
> > 
> > Attached.
> 
> Well it seems to me this is perfectly read!

When I read it, the text in the latex layout is not inserted into ERT inset.
Looking at the code, I see that by the time we reach the line
 if (compare_no_case(layoutname, "latex") == 0) 
the layout was already changed to the default layout.
The following patch seems like the fix for it.
Index: buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.330
diff -u -p -r1.330 buffer.C
--- buffer.C    30 Apr 2002 10:58:10 -0000      1.330
+++ buffer.C    30 Apr 2002 13:09:38 -0000
@@ -463,6 +463,13 @@ Buffer::parseSingleLyXformat2Token(LyXLe
                // Do the insetert.
                insertErtContents(par, pos);
 #endif
+               // reset the font as we start a new layout and if the font is
+               // not ALL_INHERIT,document_language then it will be set to the
+               // right values after this tag (Jug 20020420)
+               font = LyXFont(LyXFont::ALL_INHERIT, params.language);
+               if (file_format < 216 && params.language->lang() == "hebrew")
+                       font.setLanguage(default_language);
+
                lex.eatLine();
                string layoutname = lex.getString();
 
@@ -472,6 +479,12 @@ Buffer::parseSingleLyXformat2Token(LyXLe
                        layoutname = tclass.defaultLayoutName();
                }
 
+#ifndef NO_COMPABILITY
+               if (compare_no_case(layoutname, "latex") == 0) {
+                       ert_comp.active = true;
+                       ert_comp.font = font;
+               }
+#endif
                bool hasLayout = tclass.hasLayout(layoutname);
                if (!hasLayout) {
                        lyxerr << "Layout '" << layoutname << "' does not"
@@ -481,20 +494,7 @@ Buffer::parseSingleLyXformat2Token(LyXLe
                               << endl;
                        layoutname = tclass.defaultLayoutName();
                }
-
-               // reset the font as we start a new layout and if the font is
-               // not ALL_INHERIT,document_language then it will be set to the
-               // right values after this tag (Jug 20020420)
-               font = LyXFont(LyXFont::ALL_INHERIT, params.language);
-               if (file_format < 216 && params.language->lang() == "hebrew")
-                       font.setLanguage(default_language);
                
-#ifndef NO_COMPABILITY
-               if (compare_no_case(layoutname, "latex") == 0) {
-                       ert_comp.active = true;
-                       ert_comp.font = font;
-               }
-#endif
 #ifdef USE_CAPTION
                // The is the compability reading of layout caption.
                // It can be removed in LyX version 1.3.0. (Lgb)

Reply via email to