]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetexternal.C
Make it compile when USE_BOOST_FORMAT is unset
[lyx.git] / src / insets / insetexternal.C
index ec9047185275278363040ce066eaf3b49adf159f..ed22c53cdff5a5b10c2cea610b1ad35c4114ce7e 100644 (file)
@@ -1,12 +1,12 @@
-/* This file is part of
- * ======================================================
+/**
+ * \file insetexternal.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
- *     
- *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-2001 The LyX Team.
+ * \author Asger Alstrup Nielsen
  *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS
+ */
 
 #include <config.h>
 
 #include "ExternalTemplate.h"
 #include "BufferView.h"
 #include "buffer.h"
-#include "LyXView.h"
+#include "frontends/LyXView.h"
 #include "lyx_main.h"
 #include "LaTeXFeatures.h"
 #include "gettext.h"
 #include "debug.h"
+#include "lyxlex.h"
 
 #include "frontends/Dialogs.h"
 
@@ -40,7 +41,7 @@ using std::ostream;
 using std::endl;
 
 
-InsetExternal::InsetExternal() 
+InsetExternal::InsetExternal()
        : view_(0)
 {
        tempname_ = lyx::tempName(string(), "lyxext");
@@ -60,14 +61,14 @@ InsetExternal::Params InsetExternal::params() const
 {
        return params_;
 }
+
+
 void InsetExternal::setFromParams(Params const & p)
 {
        params_.filename = p.filename;
        params_.parameters = p.parameters;
        params_.templ = p.templ;
-}      
+}
 
 
 string const InsetExternal::editMessage() const
@@ -77,16 +78,16 @@ string const InsetExternal::editMessage() const
 
 
 void InsetExternal::edit(BufferView * bv,
-                        int /*x*/, int /*y*/, unsigned int /*button*/)
+                        int /*x*/, int /*y*/, mouse_button::state)
 {
        view_ = bv;
-       view_->owner()->getDialogs()->showExternal(this);
+       view_->owner()->getDialogs().showExternal(this);
 }
 
 
 void InsetExternal::edit(BufferView * bv, bool)
 {
-       edit(bv, 0, 0, 0);
+       edit(bv, 0, 0, mouse_button::none);
 }
 
 
@@ -108,7 +109,7 @@ void InsetExternal::read(Buffer const *, LyXLex & lex)
        } else {
                lex.printError("InsetExternal: Parse error: `$$Token'");
        }
-       
+
        while (lex.isOK()) {
                lex.nextToken();
                token = lex.getString();
@@ -145,7 +146,7 @@ int InsetExternal::write(string const & format,
                       << params_.templ.lyxName << endl;
                return 0;
        }
-       
+
        updateExternal(format, buf);
        os << doSubstitution(buf, cit->second.product);
        return 0; // CHECK  (FIXME check what ? - jbl)
@@ -171,7 +172,7 @@ int InsetExternal::linuxdoc(Buffer const * buf, ostream & os) const
 }
 
 
-int InsetExternal::docbook(Buffer const * buf, ostream & os) const
+int InsetExternal::docbook(Buffer const * buf, ostream & os, bool) const
 {
        return write("DocBook", buf, os);
 }
@@ -185,7 +186,7 @@ void InsetExternal::validate(LaTeXFeatures & features) const
 
        if (cit == et.formats.end())
                return;
-       
+
        if (!cit->second.requirement.empty()) {
                features.require(cit->second.requirement);
        }
@@ -197,7 +198,7 @@ void InsetExternal::validate(LaTeXFeatures & features) const
 
 Inset * InsetExternal::clone(Buffer const &, bool same_id) const
 {
-       InsetExternal * inset = new InsetExternal();
+       InsetExternal * inset = new InsetExternal;
        inset->params_ = params_;
        inset->view_ = view_;
        if (same_id)
@@ -235,17 +236,16 @@ string const InsetExternal::doSubstitution(Buffer const * buffer,
        string result;
        string const basename = ChangeExtension(params_.filename, string());
        string filepath;
-       if (buffer && (!buffer->niceFile)) {
+       if (buffer && !buffer->tmppath.empty() && !buffer->niceFile) {
                filepath = buffer->filePath();
        }
        result = subst(s, "$$FName", params_.filename);
        result = subst(result, "$$Basename", basename);
        result = subst(result, "$$Parameters", params_.parameters);
        result = subst(result, "$$FPath", filepath);
-       result = ReplaceEnvironmentPath(result);
        result = subst(result, "$$Tempname", tempname_);
        result = subst(result, "$$Sysdir", system_lyxdir);
-       
+
        // Handle the $$Contents(filename) syntax
        if (contains(result, "$$Contents(\"")) {
 
@@ -271,7 +271,7 @@ string const InsetExternal::doSubstitution(Buffer const * buffer,
 
 void InsetExternal::updateExternal() const
 {
-       updateExternal("LaTeX", view_->buffer());       
+       updateExternal("LaTeX", view_->buffer());
 }
 
 void InsetExternal::updateExternal(string const & format,
@@ -285,16 +285,16 @@ void InsetExternal::updateExternal(string const & format,
            cit->second.updateCommand.empty() ||
            !et.automaticProduction)
                return;
-       
+
        if (!cit->second.updateResult.empty()) {
                string const resultfile = doSubstitution(buf,
                                                         cit->second.updateResult);
                FileInfo fi(params_.filename);
                FileInfo fi2(resultfile);
                if (fi2.exist() && fi.exist() &&
-                   ::difftime(fi2.getModificationTime(),
-                              fi.getModificationTime()) >= 0) {
-                       lyxerr[Debug::FILES] << resultfile 
+                   difftime(fi2.getModificationTime(),
+                            fi.getModificationTime()) >= 0) {
+                       lyxerr[Debug::FILES] << resultfile
                                             << " is up to date" << endl;
                        return;
                }
@@ -342,6 +342,5 @@ bool operator==(InsetExternal::Params const & left,
 bool operator!=(InsetExternal::Params const & left,
                InsetExternal::Params const & right)
 {
-       return  !(left == right);
+       return  !(left == right);
 }
-