]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/preamble.C
Removed all redundant using directives from the source.
[lyx.git] / src / tex2lyx / preamble.C
index 897bb4b8bb7ba5b1a24737fa683ebddde9deadec..777aec4695853857ba32ef7ca280253c63b52537 100644 (file)
@@ -1,5 +1,11 @@
-/** The .tex to .lyx converter
-    \author André Pönitz (2003)
+/**
+ * \file preamble.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 // {[(
@@ -8,6 +14,11 @@
 
 #include "tex2lyx.h"
 
+#include "layout.h"
+#include "lyxtextclass.h"
+#include "lyxlex.h"
+#include "support/filetools.h"
+
 #include <algorithm>
 #include <iostream>
 #include <sstream>
 #include <vector>
 #include <map>
 
-using std::cerr;
-using std::endl;
-using std::getline;
-using std::istream;
 using std::istringstream;
 using std::ostream;
 using std::ostringstream;
 using std::string;
 using std::vector;
 
+using lyx::support::LibFileSearch;
+
 // special columntypes
 extern std::map<char, int> special_columns;
 
@@ -128,10 +137,10 @@ void handle_package(string const & name, string const & options)
 
 
 
-void end_preamble(ostream & os)
+void end_preamble(ostream & os, LyXTextClass const & /*textclass*/)
 {
-       os << "# tex2lyx 0.0.3 created this file\n"
-          << "\\lyxformat 224\n"
+       os << "#LyX file created by  tex2lyx 0.1.2 \n"
+          << "\\lyxformat 225\n"
           << "\\textclass " << h_textclass << "\n"
           << "\\begin_preamble\n" << h_preamble.str() << "\n\\end_preamble\n";
        if (h_options.size())
@@ -159,13 +168,12 @@ void end_preamble(ostream & os)
           << "\\papersides " << h_papersides << "\n"
           << "\\paperpagestyle " << h_paperpagestyle << "\n"
           << "\\tracking_changes " << h_tracking_changes << "\n"
-          << "\\end_header\n\n\\layout Standard\n";
+          << "\\end_header\n";
 }
 
-
 } // anonymous namespace
 
-void parse_preamble(Parser & p, ostream & os)
+LyXTextClass const parse_preamble(Parser & p, ostream & os)
 {
        // initialize fixed types
        special_columns['D'] = 3;
@@ -334,17 +342,19 @@ void parse_preamble(Parser & p, ostream & os)
 
                else if (t.cs() == "begin") {
                        string const name = p.getArg('{', '}');
-                       if (name == "document") {
-                               end_preamble(os);
-                               return;
-                       }
+                       if (name == "document")
+                               break;
                        h_preamble << "\\begin{" << name << "}";
                }
 
                else if (t.cs().size())
                        h_preamble << '\\' << t.cs() << ' ';
        }
-}
 
+       LyXTextClass textclass;
+       textclass.Read(LibFileSearch("layouts", h_textclass, "layout"));
+       end_preamble(os, textclass);
+       return textclass;
+}
 
 // }])