]> git.lyx.org Git - features.git/commitdiff
fix preamble output in case child docs are present
authorGeorg Baum <georg.baum@post.rwth-aachen.de>
Sun, 4 Dec 2011 15:35:59 +0000 (15:35 +0000)
committerGeorg Baum <georg.baum@post.rwth-aachen.de>
Sun, 4 Dec 2011 15:35:59 +0000 (15:35 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40362 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/Preamble.cpp
src/tex2lyx/Preamble.h
src/tex2lyx/tex2lyx.cpp

index f91f8e8649bff2798cfd281359b452a3dec2ef9d..066da83c809d080628827e037ad1a6f731f3b63f 100644 (file)
@@ -815,7 +815,7 @@ void Preamble::handle_if(Parser & p, bool in_lyx_preamble)
 }
 
 
-bool Preamble::writeLyXHeader(ostream & os)
+bool Preamble::writeLyXHeader(ostream & os, bool subdoc)
 {
        // translate from babel to LyX names
        h_language = babel2lyx(h_language);
@@ -858,7 +858,7 @@ bool Preamble::writeLyXHeader(ostream & os)
           << "\\begin_document\n"
           << "\\begin_header\n"
           << "\\textclass " << h_textclass << "\n";
-       string const raw = h_preamble.str();
+       string const raw = subdoc ? empty_string() : h_preamble.str();
        if (!raw.empty()) {
                os << "\\begin_preamble\n";
                for (string::size_type i = 0; i < raw.size(); ++i) {
@@ -977,8 +977,6 @@ bool Preamble::writeLyXHeader(ostream & os)
           << authors_
           << "\\end_header\n\n"
           << "\\begin_body\n";
-       // clear preamble for subdocuments
-       h_preamble.str("");
        return true;
 }
 
index 31e4d34998f35d2761d1644f69cb11005568799d..82d4891ee46e322bb9320d655f4bde06793e3e33 100644 (file)
@@ -65,7 +65,7 @@ public:
        void parse(Parser & p, std::string const & forceclass,
                   TeX2LyXDocClass & tc);
        /// Writes the LyX file header from internal data
-       bool writeLyXHeader(std::ostream & os);
+       bool writeLyXHeader(std::ostream & os, bool subdoc);
 
 private:
        ///
index 49892b0a959da23d694b3c70399073c0bb47b456..9a4ca4f4108016ac873d3f1d20464f463d3048dc 100644 (file)
@@ -685,7 +685,7 @@ bool tex2lyx(idocstream & is, ostream & os, string encoding)
                for (; it != end; it++)
                        preamble.addModule(*it);
        }
-       if (!preamble.writeLyXHeader(os)) {
+       if (!preamble.writeLyXHeader(os, !active_environments.empty())) {
                cerr << "Could write LyX file header." << endl;
                return false;
        }