]> git.lyx.org Git - lyx.git/blobdiff - src/lyxtextclass.C
cleanup after svn hang-up, #undef CursorShape. Should be compilable ganin now.
[lyx.git] / src / lyxtextclass.C
index 0e2e964501edd1f4bf6ae3b97c0f46f2ddce535f..7eae766cff10c94623f2a20c2b64171a842ee238 100644 (file)
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
 #include "support/filetools.h"
+#include "support/os.h"
+
+#include <boost/filesystem/operations.hpp>
+namespace fs = boost::filesystem;
 
 #include <sstream>
 
+using lyx::docstring;
 using lyx::support::libFileSearch;
 using lyx::support::makeDisplayPath;
 using lyx::support::quoteName;
 using lyx::support::rtrim;
 using lyx::support::subst;
+using lyx::support::addName;
 
 using std::endl;
 using std::find_if;
@@ -69,7 +75,7 @@ bool layout2layout(string const & filename, string const & tempfile)
        }
 
        std::ostringstream command;
-       command << "python " << quoteName(script)
+       command << lyx::support::os::python() << ' ' << quoteName(script)
                << ' ' << quoteName(filename)
                << ' ' << quoteName(tempfile);
        string const command_str = command.str();
@@ -205,11 +211,11 @@ bool LyXTextClass::read(string const & filename, bool merge)
 
        if (!merge)
                lyxerr[Debug::TCLASS] << "Reading textclass "
-                                     << makeDisplayPath(filename)
-                                     << endl;
+                                       << lyx::to_utf8(makeDisplayPath(filename))
+                                       << endl;
        else
                lyxerr[Debug::TCLASS] << "Reading input file "
-                                    << makeDisplayPath(filename)
+                                    << lyx::to_utf8(makeDisplayPath(filename))
                                     << endl;
 
        LyXLex lexrc(textClassTags,
@@ -442,7 +448,7 @@ bool LyXTextClass::read(string const & filename, bool merge)
 
        if (!merge) { // we are at top level here.
                lyxerr[Debug::TCLASS] << "Finished reading textclass "
-                                     << makeDisplayPath(filename)
+                                     << lyx::to_utf8(makeDisplayPath(filename))
                                      << endl;
                if (defaultlayout_.empty()) {
                        lyxerr << "Error: Textclass '" << name_
@@ -472,7 +478,7 @@ bool LyXTextClass::read(string const & filename, bool merge)
 
        } else
                lyxerr[Debug::TCLASS] << "Finished reading input file "
-                                     << makeDisplayPath(filename)
+                                     << lyx::to_utf8(makeDisplayPath(filename))
                                      << endl;
 
        return error;
@@ -511,7 +517,6 @@ void LyXTextClass::readOutputType(LyXLex & lexrc)
        keyword_item outputTypeTags[] = {
                { "docbook", DOCBOOK },
                { "latex", LATEX },
-               { "linuxdoc", LINUXDOC },
                { "literate", LITERATE }
        };
 
@@ -523,7 +528,6 @@ void LyXTextClass::readOutputType(LyXLex & lexrc)
                lexrc.printError("Unknown output type `$$Token'");
                return;
        case LATEX:
-       case LINUXDOC:
        case DOCBOOK:
        case LITERATE:
                outputType_ = static_cast<OutputType>(le);
@@ -910,18 +914,22 @@ bool LyXTextClass::delete_layout(string const & name)
 
 
 // Load textclass info if not loaded yet
-bool LyXTextClass::load() const
+bool LyXTextClass::load(string const & path) const
 {
        if (loaded_)
                return true;
 
-       // Read style-file
-       string const real_file = libFileSearch("layouts", name_, "layout");
-       loaded_ = const_cast<LyXTextClass*>(this)->read(real_file) == 0;
+       // Read style-file, provided path is searched before the system ones
+       string layout_file;
+       if (!path.empty())
+               layout_file = addName(path, name_ + ".layout");
+       if (layout_file.empty() || !fs::exists(layout_file))
+               layout_file = libFileSearch("layouts", name_, "layout");
+       loaded_ = const_cast<LyXTextClass*>(this)->read(layout_file) == 0;
 
        if (!loaded_) {
                lyxerr << "Error reading `"
-                      << makeDisplayPath(real_file)
+                      << lyx::to_utf8(makeDisplayPath(layout_file))
                       << "'\n(Check `" << name_
                       << "')\nCheck your installation and "
                        "try Options/Reconfigure..." << endl;