This patch fixes bug 2667 (see http://bugzilla.lyx.org/show_bug.cgi?id=2667). It will go in trunk tomorrow if nobody objects. I will then also set the target to 1.4.3 and attach a patch for 1.4 in bugzilla. I propose to do that with all 1.4 bugs that get fixed during Jean-Marcs vacation.
Georg Log: Fix bug 2667 * src/tex2lyx/tex2lyx.C (tex2lyx): output an empty paragraph if the document is empty * src/tex2lyx/context.C (Context::check_layout): set empty to false * src/tex2lyx/context.[Ch] (empty): new flag, tells whether all contexts are empty
Index: src/tex2lyx/tex2lyx.C =================================================================== --- src/tex2lyx/tex2lyx.C (Revision 14461) +++ src/tex2lyx/tex2lyx.C (Arbeitskopie) @@ -413,6 +413,9 @@ void tex2lyx(std::istream &is, std::ostr active_environments.push_back("document"); Context context(true, textclass); parse_text(p, ss, FLAG_END, true, context); + if (Context::empty) + // Empty document body. LyX needs at least one paragraph. + context.check_layout(ss); context.check_end_layout(ss); ss << "\n\\end_body\n\\end_document\n"; active_environments.pop_back(); Index: src/tex2lyx/context.C =================================================================== --- src/tex2lyx/context.C (Revision 14461) +++ src/tex2lyx/context.C (Arbeitskopie) @@ -77,6 +77,7 @@ void output_font_change(ostream & os, Fo Font Context::normalfont; +bool Context::empty = true; Context::Context(bool need_layout_, @@ -145,6 +146,7 @@ void Context::check_layout(ostream & os) extra_stuff.erase(); } os << "\n"; + empty = false; } } Index: src/tex2lyx/context.h =================================================================== --- src/tex2lyx/context.h (Revision 14461) +++ src/tex2lyx/context.h (Arbeitskopie) @@ -133,6 +133,8 @@ public: * would not work. */ bool new_layout_allowed; + /// Did we output anything yet in any context? + static bool empty; /// The textclass of the document. Could actually be a global variable LyXTextClass const & textclass;