]> git.lyx.org Git - features.git/blobdiff - src/insets/insetexternal.C
Replace LString.h with support/std_string.h,
[features.git] / src / insets / insetexternal.C
index 11c0eaec2ca1ce2acb34cd8f6b0d79cd34b3fc27..664d1a8035c0fcdf22263d0bf3269d2bf933ef8e 100644 (file)
 #include "funcrequest.h"
 #include "gettext.h"
 #include "LaTeXFeatures.h"
-#include "latexrunparams.h"
-#include "lyx_main.h"
 #include "lyxlex.h"
 #include "lyxrc.h"
-#include "Lsstream.h"
+#include "support/std_sstream.h"
 
 #include "frontends/lyx_gui.h"
-#include "frontends/LyXView.h"
-#include "frontends/Dialogs.h"
 
-#include "support/FileInfo.h"
 #include "support/filetools.h"
 #include "support/forkedcall.h"
 #include "support/lstrings.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>
 
-#include <cstdio>
-#include <utility>
-
 namespace support = lyx::support;
 
-using std::ostream;
 using std::endl;
 using std::auto_ptr;
+using std::ostream;
+
 
 namespace lyx {
 namespace graphics {
@@ -367,12 +359,13 @@ void InsetExternal::read(Buffer const & buffer, LyXLex & lex)
        // Replace the inset's store
        setParams(params, buffer);
 
-       lyxerr[Debug::INFO] << "InsetExternal::Read: "
-                           << "template: '" << params_.templatename
-                           << "' filename: '" << params_.filename.absFilename()
-                           << "' display: '" << params_.display
-                           << "' scale: '" << params_.lyxscale
-                           << '\'' << endl;
+       lyxerr[Debug::EXTERNAL]
+               << "InsetExternal::Read: "
+               << "template: '" << params_.templatename
+               << "' filename: '" << params_.filename.absFilename()
+               << "' display: '" << params_.display
+               << "' scale: '" << params_.lyxscale
+               << '\'' << endl;
 }
 
 
@@ -388,9 +381,10 @@ int InsetExternal::write(string const & format,
        ExternalTemplate::Formats::const_iterator cit =
                et.formats.find(format);
        if (cit == et.formats.end()) {
-               lyxerr << "External template format '" << format
-                      << "' not specified in template "
-                      << params_.templatename << endl;
+               lyxerr[Debug::EXTERNAL]
+                       << "External template format '" << format
+                       << "' not specified in template "
+                       << params_.templatename << endl;
                return 0;
        }
 
@@ -454,18 +448,17 @@ void InsetExternal::validate(LaTeXFeatures & features) const
                return;
        ExternalTemplate const & et = *et_ptr;
 
-       ExternalTemplate::Formats::const_iterator cit =
-               et.formats.find("LaTeX");
-
+       ExternalTemplate::Formats::const_iterator cit = et.formats.find("LaTeX");
        if (cit == et.formats.end())
                return;
 
-       if (!cit->second.requirement.empty()) {
+       if (!cit->second.requirement.empty())
                features.require(cit->second.requirement);
-       }
-       if (!cit->second.preamble.empty()) {
-               features.addExternalPreamble(cit->second.preamble);
-       }
+
+       ExternalTemplateManager & etm = ExternalTemplateManager::get();
+       string const preamble = etm.getPreambleDefByName(cit->second.preambleName);
+       if (!preamble.empty())
+               features.addExternalPreamble(preamble);
 }
 
 
@@ -511,9 +504,10 @@ void InsetExternal::updateExternal(string const & format,
                return;
 
        if (!converters.isReachable(from_format, to_format)) {
-               lyxerr << "InsetExternal::updateExternal. "
-                       "Unable to convert from "
-                      << from_format << " to " << to_format << endl;
+               lyxerr[Debug::EXTERNAL]
+                       << "InsetExternal::updateExternal. "
+                       << "Unable to convert from "
+                       << from_format << " to " << to_format << endl;
                return;
        }
 
@@ -605,7 +599,7 @@ void editExternal(InsetExternal::Params const & params, Buffer const & buffer)
 
        support::Path p(buffer.filePath());
        support::Forkedcall call;
-       if (lyxerr.debugging()) {
+       if (lyxerr.debugging(Debug::EXTERNAL)) {
                lyxerr << "Executing '" << command << "' in '"
                       << buffer.filePath() << '\'' << endl;
        }