]> git.lyx.org Git - lyx.git/commitdiff
Fix bug 2667
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 16 Jul 2006 13:04:59 +0000 (13:04 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 16 Jul 2006 13:04:59 +0000 (13:04 +0000)
* 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

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14469 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/context.C
src/tex2lyx/context.h
src/tex2lyx/tex2lyx.C

index a40cc3ad181adf2dea42c290ae8c6c4deda3ea66..800249fed439be8334ced75e4bce89cf5b7d1219 100644 (file)
@@ -77,6 +77,7 @@ void output_font_change(ostream & os, Font const & oldfont,
 
 
 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 9ea286f3740271ba32ca25317ddf866b20b9eecf..e60ae785a785feb9ad4f3b2f258dba9b2ba06fc1 100644 (file)
@@ -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;
index 06905f42c067e26d36dbe21d4b76694ea4efb76a..09dcf7cbbcf35c7678056ef9b73df038005e3d31 100644 (file)
@@ -413,6 +413,9 @@ void tex2lyx(std::istream &is, std::ostream &os)
        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();