]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/text.cpp
* src/insets/InsetNote.h:
[lyx.git] / src / tex2lyx / text.cpp
index fbc89d3f0bb731781048afce155141611c8a65fa..43f6dd64b6bd708d7142f38ebbb39ee4e01f60a3 100644 (file)
@@ -26,6 +26,9 @@
 #include "support/filetools.h"
 #include "support/lstrings.h"
 
+#include <boost/assert.hpp>
+
+#include <algorithm>
 #include <iostream>
 #include <map>
 #include <sstream>
@@ -421,27 +424,14 @@ void handle_comment(ostream & os, string const & s, Context & context)
 }
 
 
-class isLayout : public unary_function<LayoutPtr, bool> {
-public:
-       isLayout(string const name) : name_(name) {}
-       bool operator()(LayoutPtr const & ptr) const {
-               return ptr->latexname() == name_;
-       }
-private:
-       string const name_;
-};
-
-
-LayoutPtr findLayout(TextClass const & textclass,
-                        string const & name)
+LayoutPtr findLayout(TextClass const & textclass, string const & name)
 {
-       TextClass::const_iterator beg = textclass.begin();
-       TextClass::const_iterator end = textclass.end();
-
-       TextClass::const_iterator
-               it = find_if(beg, end, isLayout(name));
-
-       return (it == end) ? LayoutPtr() : *it;
+       DocumentClass::const_iterator lit = textclass.begin();
+       DocumentClass::const_iterator len = textclass.end();
+       for (; lit != len; ++lit)
+               if (lit->latexname() == name)
+                       return &*lit;
+       return LayoutPtr();
 }
 
 
@@ -822,7 +812,7 @@ void parse_environment(Parser & p, ostream & os, bool outer,
        }
 
        // The single '=' is meant here.
-       else if ((newlayout = findLayout(parent_context.textclass, name)).get() &&
+       else if ((newlayout = findLayout(parent_context.textclass, name)) &&
                  newlayout->isEnvironment()) {
                eat_whitespace(p, os, parent_context, false);
                Context context(true, parent_context.textclass, newlayout,
@@ -1075,7 +1065,7 @@ void parse_noweb(Parser & p, ostream & os, Context & context)
        // always must be in an own paragraph.
        context.new_paragraph(os);
        Context newcontext(true, context.textclass,
-               context.textclass[from_ascii("Scrap")]);
+               &context.textclass[from_ascii("Scrap")]);
        newcontext.check_layout(os);
        os << name;
        while (p.good()) {
@@ -1527,9 +1517,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                else if ((p.next_token().asInput() == "*") &&
                         context.new_layout_allowed &&
                         // The single '=' is meant here.
-                        (newlayout = findLayout(context.textclass,
-                                                t.cs() + '*')).get() &&
-                        newlayout->isCommand()) {
+                        (newlayout = findLayout(context.textclass, t.cs() + '*')) &&
+                         newlayout->isCommand()) {
                        p.get_token();
                        output_command_layout(os, p, outer, context, newlayout);
                        p.skip_spaces();
@@ -1537,7 +1526,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
 
                // The single '=' is meant here.
                else if (context.new_layout_allowed &&
-                        (newlayout = findLayout(context.textclass, t.cs())).get() &&
+                        (newlayout = findLayout(context.textclass, t.cs())) &&
                         newlayout->isCommand()) {
                        output_command_layout(os, p, outer, context, newlayout);
                        p.skip_spaces();