]> git.lyx.org Git - lyx.git/blobdiff - src/format.C
* remove various xforms relicts, in particular:
[lyx.git] / src / format.C
index e51358df6dafb42da824ce405b231c1a1c952a57..a8fd1f2828bb1923f7050c5701d6f162500e84fa 100644 (file)
 #include "support/filetools.h"
 #include "support/lstrings.h"
 #include "support/os.h"
-#include "support/path.h"
 #include "support/systemcall.h"
 
 #include <boost/filesystem/operations.hpp>
 
+using lyx::support::absolutePath;
 using lyx::support::bformat;
 using lyx::support::compare_ascii_no_case;
 using lyx::support::contains;
 using lyx::support::libScriptSearch;
 using lyx::support::makeDisplayPath;
-using lyx::support::onlyFilename;
 using lyx::support::onlyPath;
-using lyx::support::Path;
 using lyx::support::quoteName;
 using lyx::support::subst;
 using lyx::support::Systemcall;
@@ -92,9 +90,12 @@ bool operator<(Format const & a, Format const & b)
        return compare_ascii_no_case(a.prettyname(), b.prettyname()) < 0;
 }
 
+
 Format::Format(string const & n, string const & e, string const & p,
-              string const & s, string const & v, string const & ed)
-       : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), editor_(ed)
+              string const & s, string const & v, string const & ed,
+               bool d)
+       : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v),
+         editor_(ed), document_(d)
 {}
 
 
@@ -173,7 +174,7 @@ string fixCommand(string const & cmd, string const & ext,
                return "auto";
 
        // if configure.py found nothing, clear the command
-       if (token(cmd, ' ', 0) == "none")
+       if (token(cmd, ' ', 0) == "auto")
                return string();
 
        // use the command found by configure.py
@@ -208,22 +209,24 @@ int Formats::getNumber(string const & name) const
 void Formats::add(string const & name)
 {
        if (!getFormat(name))
-               add(name, name, name, string(), string(), string());
+               add(name, name, name, string(), string(), string(), true);
 }
 
 
 void Formats::add(string const & name, string const & extension,
                  string const & prettyname, string const & shortcut,
-                 string const & viewer, string const & editor)
+                 string const & viewer, string const & editor, bool document)
 {
        FormatList::iterator it =
                find_if(formatlist.begin(), formatlist.end(),
                        FormatNamesEqual(name));
        if (it == formatlist.end())
                formatlist.push_back(Format(name, extension, prettyname,
-                                           shortcut, viewer, editor));
+                                           shortcut, viewer, editor,
+                                           document));
        else
-               *it = Format(name, extension, prettyname, shortcut, viewer, editor);
+               *it = Format(name, extension, prettyname, shortcut, viewer,
+                            editor, document);
 }
 
 
@@ -257,6 +260,7 @@ void Formats::setViewer(string const & name, string const & command)
 bool Formats::view(Buffer const & buffer, string const & filename,
                   string const & format_name) const
 {
+       BOOST_ASSERT(absolutePath(filename));
        if (filename.empty() || !fs::exists(filename)) {
                Alert::error(_("Cannot view file"),
                        bformat(_("File does not exist: %1$s"),
@@ -304,14 +308,12 @@ bool Formats::view(Buffer const & buffer, string const & filename,
        if (!contains(command, token_from))
                command += ' ' + token_from;
 
-       command = subst(command, token_from,
-                       quoteName(onlyFilename(filename)));
+       command = subst(command, token_from, quoteName(filename));
        command = subst(command, token_path, quoteName(onlyPath(filename)));
        command = subst(command, token_socket, quoteName(lyxsocket->address()));
        lyxerr[Debug::FILES] << "Executing command: " << command << std::endl;
        buffer.message(_("Executing command: ") + command);
 
-       Path p(onlyPath(filename));
        Systemcall one;
        int const res = one.startscript(Systemcall::DontWait, command);
 
@@ -328,6 +330,7 @@ bool Formats::view(Buffer const & buffer, string const & filename,
 bool Formats::edit(Buffer const & buffer, string const & filename,
                         string const & format_name) const
 {
+       BOOST_ASSERT(absolutePath(filename));
        if (filename.empty() || !fs::exists(filename)) {
                Alert::error(_("Cannot edit file"),
                        bformat(_("File does not exist: %1$s"),
@@ -364,14 +367,12 @@ bool Formats::edit(Buffer const & buffer, string const & filename,
        if (!contains(command, token_from))
                command += ' ' + token_from;
 
-       command = subst(command, token_from,
-                       quoteName(onlyFilename(filename)));
+       command = subst(command, token_from, quoteName(filename));
        command = subst(command, token_path, quoteName(onlyPath(filename)));
        command = subst(command, token_socket, quoteName(lyxsocket->address()));
        lyxerr[Debug::FILES] << "Executing command: " << command << std::endl;
        buffer.message(_("Executing command: ") + command);
 
-       Path p(onlyPath(filename));
        Systemcall one;
        int const res = one.startscript(Systemcall::DontWait, command);