]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetexternal.C
prevent crash when inserting minipage in table cell,
[lyx.git] / src / insets / insetexternal.C
index 1ac3deaad71b8e692148b802cde4481bc0ae3254..d8f4c83af2c889fa4fa8423d7af0a751eaea5f5e 100644 (file)
 #include "support/lstrings.h"
 #include "support/lyxalgo.h"
 #include "support/path.h"
+#include "support/path_defines.h"
 #include "support/tostr.h"
+#include "support/LAssert.h"
+#include "support/translator.h"
 
 #include <boost/bind.hpp>
 
@@ -48,6 +51,14 @@ using namespace lyx::support;
 
 using std::ostream;
 using std::endl;
+using std::auto_ptr;
+
+namespace lyx {
+namespace graphics {
+/// The translator between the DisplayType and the corresponding lyx string.
+extern Translator<DisplayType, string> displayTranslator;
+}
+}
 
 namespace {
 
@@ -88,7 +99,7 @@ InsetExternal::InsetExternal()
 
 
 InsetExternal::InsetExternal(InsetExternal const & other)
-       : Inset(other),
+       : InsetOld(other),
          boost::signals::trackable(),
          params_(other.params_),
          renderer_(other.renderer_->clone())
@@ -100,10 +111,9 @@ InsetExternal::InsetExternal(InsetExternal const & other)
 }
 
 
-InsetBase * InsetExternal::clone() const
+auto_ptr<InsetBase> InsetExternal::clone() const
 {
-       InsetExternal * inset = new InsetExternal(*this);
-       return inset;
+       return auto_ptr<InsetBase>(new InsetExternal(*this));
 }
 
 
@@ -299,7 +309,7 @@ void InsetExternal::read(Buffer const * buffer, LyXLex & lex)
                { "template", EX_TEMPLATE }
        };
 
-       lex.pushTable(external_tags, EX_END);
+       pushpophelper pph(lex, external_tags, EX_END);
 
        bool found_end  = false;
        bool read_error = false;
@@ -353,8 +363,6 @@ void InsetExternal::read(Buffer const * buffer, LyXLex & lex)
                               "Missing \\end_inset.");
        }
 
-       lex.popTable();
-
        // Replace the inset's store
        setParams(params, buffer);
 
@@ -550,7 +558,7 @@ string const doSubstitution(InsetExternal::Params const & params,
        result = subst(result, "$$Basename", basename);
        result = subst(result, "$$FPath", filepath);
        result = subst(result, "$$Tempname", params.tempname);
-       result = subst(result, "$$Sysdir", system_lyxdir);
+       result = subst(result, "$$Sysdir", system_lyxdir());
 
        // Handle the $$Contents(filename) syntax
        if (contains(result, "$$Contents(\"")) {