]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/text.cpp
* Added conversion of latex macros with optional parameters
[lyx.git] / src / tex2lyx / text.cpp
index 6c23768e602462259ef286cd7c4d0bc54a0141bf..f49012a55941e2760996d1f3ee760a593ce798e6 100644 (file)
 #include <config.h>
 
 #include "tex2lyx.h"
+
 #include "Context.h"
 #include "FloatList.h"
-#include "lengthcommon.h"
+#include "Layout.h"
+#include "Length.h"
+
 #include "support/lstrings.h"
 #include "support/convert.h"
 #include "support/filetools.h"
 
-#include <boost/filesystem/operations.hpp>
 #include <boost/tuple/tuple.hpp>
 
 #include <iostream>
 #include <sstream>
 #include <vector>
 
+using std::cerr;
+using std::endl;
+
+using std::map;
+using std::ostream;
+using std::ostringstream;
+using std::istringstream;
+using std::string;
+using std::vector;
 
 namespace lyx {
 
@@ -42,18 +53,6 @@ using support::suffixIs;
 using support::contains;
 using support::subst;
 
-using std::cerr;
-using std::endl;
-
-using std::map;
-using std::ostream;
-using std::ostringstream;
-using std::istringstream;
-using std::string;
-using std::vector;
-
-namespace fs = boost::filesystem;
-
 
 void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
                Context const & context)
@@ -105,8 +104,9 @@ string parse_text_snippet(Parser & p, unsigned flags, const bool outer,
 }
 
 
-char const * const known_latex_commands[] = { "ref", "cite", "label", "index",
-"printindex", "pageref", "url", "vref", "vpageref", "prettyref", "eqref", 0 };
+char const * const known_latex_commands[] = { "ref", "cite", "label", "href",
+ "index", "printindex", "pageref", "url", "vref", "vpageref", "prettyref",
+ "eqref", 0 };
 
 /*!
  * natbib commands.
@@ -359,7 +359,7 @@ string find_file(string const & name, string const & path,
        // expects utf8)
        for (char const * const * what = extensions; *what; ++what) {
                string const trial = addExtension(name, *what);
-               if (fs::exists(makeAbsPath(trial, path).toFilesystemEncoding()))
+               if (makeAbsPath(trial, path).exists())
                        return trial;
        }
        return string();
@@ -434,10 +434,10 @@ void handle_comment(ostream & os, string const & s, Context & context)
 }
 
 
-class isLayout : public std::unary_function<Layout_ptr, bool> {
+class isLayout : public std::unary_function<LayoutPtr, bool> {
 public:
        isLayout(string const name) : name_(name) {}
-       bool operator()(Layout_ptr const & ptr) const {
+       bool operator()(LayoutPtr const & ptr) const {
                return ptr->latexname() == name_;
        }
 private:
@@ -445,7 +445,7 @@ private:
 };
 
 
-Layout_ptr findLayout(TextClass const & textclass,
+LayoutPtr findLayout(TextClass const & textclass,
                         string const & name)
 {
        TextClass::const_iterator beg = textclass.begin();
@@ -454,7 +454,7 @@ Layout_ptr findLayout(TextClass const & textclass,
        TextClass::const_iterator
                it = std::find_if(beg, end, isLayout(name));
 
-       return (it == end) ? Layout_ptr() : *it;
+       return (it == end) ? LayoutPtr() : *it;
 }
 
 
@@ -463,7 +463,7 @@ void eat_whitespace(Parser &, ostream &, Context &, bool);
 
 void output_command_layout(ostream & os, Parser & p, bool outer,
                           Context & parent_context,
-                          Layout_ptr newlayout)
+                          LayoutPtr newlayout)
 {
        parent_context.check_end_layout(os);
        Context context(true, parent_context.textclass, newlayout,
@@ -719,7 +719,7 @@ void parse_unknown_environment(Parser & p, string const & name, ostream & os,
 void parse_environment(Parser & p, ostream & os, bool outer,
                       Context & parent_context)
 {
-       Layout_ptr newlayout;
+       LayoutPtr newlayout;
        string const name = p.getArg('{', '}');
        const bool is_starred = suffixIs(name, '*');
        string const unstarred_name = rtrim(name, "*");
@@ -1105,7 +1105,7 @@ void parse_noweb(Parser & p, ostream & os, Context & context)
 void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                Context & context)
 {
-       Layout_ptr newlayout;
+       LayoutPtr newlayout;
        // Store the latest bibliographystyle (needed for bibtex inset)
        string bibliographystyle;
        bool const use_natbib = used_packages.find("natbib") != used_packages.end();
@@ -1538,7 +1538,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        // therefore path is only used for testing
                        // FIXME UNICODE encoding of name and path may be
                        // wrong (makeAbsPath expects utf8)
-                       if (!fs::exists(makeAbsPath(name, path).toFilesystemEncoding())) {
+                       if (!makeAbsPath(name, path).exists()) {
                                // The file extension is probably missing.
                                // Now try to find it out.
                                string const dvips_name =
@@ -1570,7 +1570,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
 
                        // FIXME UNICODE encoding of name and path may be
                        // wrong (makeAbsPath expects utf8)
-                       if (fs::exists(makeAbsPath(name, path).toFilesystemEncoding()))
+                       if (makeAbsPath(name, path).exists())
                                fix_relative_filename(name);
                        else
                                cerr << "Warning: Could not find graphics file '"
@@ -2202,7 +2202,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        // FIXME UNICODE encoding of filename and path may be
                        // wrong (makeAbsPath expects utf8)
                        if ((t.cs() == "include" || t.cs() == "input") &&
-                           !fs::exists(makeAbsPath(filename, path).toFilesystemEncoding())) {
+                           !makeAbsPath(filename, path).exists()) {
                                // The file extension is probably missing.
                                // Now try to find it out.
                                string const tex_name =
@@ -2213,7 +2213,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        }
                        // FIXME UNICODE encoding of filename and path may be
                        // wrong (makeAbsPath expects utf8)
-                       if (fs::exists(makeAbsPath(filename, path).toFilesystemEncoding())) {
+                       if (makeAbsPath(filename, path).exists()) {
                                string const abstexname =
                                        makeAbsPath(filename, path).absFilename();
                                string const abslyxname =
@@ -2317,14 +2317,10 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                           opt1 + opt2 +
                                           '{' + p.verbatim_item() + '}';
 
-                       if (opt2.empty()) {
-                               context.check_layout(os);
-                               begin_inset(os, "FormulaMacro");
-                               os << "\n" << ert;
-                               end_inset(os);
-                       } else
-                               // we cannot handle optional argument, so only output ERT
-                               handle_ert(os, ert, context);
+                       context.check_layout(os);
+                       begin_inset(os, "FormulaMacro");
+                       os << "\n" << ert;
+                       end_inset(os);
                }
 
                else if (t.cs() == "vspace") {