X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxtextclass.C;h=cdda271a71d942a40660e246fcc891867197cc9d;hb=52eb91c94fb70d58dceef430659c8781de2eccda;hp=48d602a07e3e3feb4cb30d18d692135408c393e6;hpb=ef2fda75001fdb13689cb3071d3dec2c96063429;p=lyx.git diff --git a/src/lyxtextclass.C b/src/lyxtextclass.C index 48d602a07e..cdda271a71 100644 --- a/src/lyxtextclass.C +++ b/src/lyxtextclass.C @@ -34,6 +34,7 @@ namespace fs = boost::filesystem; namespace lyx { +using support::FileName; using support::libFileSearch; using support::makeDisplayPath; using support::quoteName; @@ -64,12 +65,12 @@ private: }; -int const FORMAT = 2; +int const FORMAT = 3; -bool layout2layout(string const & filename, string const & tempfile) +bool layout2layout(FileName const & filename, FileName const & tempfile) { - string const script = libFileSearch("scripts", "layout2layout.py"); + FileName const script = libFileSearch("scripts", "layout2layout.py"); if (script.empty()) { lyxerr << "Could not find layout conversion " "script layout2layout.py." << endl; @@ -77,9 +78,9 @@ bool layout2layout(string const & filename, string const & tempfile) } std::ostringstream command; - command << support::os::python() << ' ' << quoteName(script) - << ' ' << quoteName(filename) - << ' ' << quoteName(tempfile); + command << support::os::python() << ' ' << quoteName(script.toFilesystemEncoding()) + << ' ' << quoteName(filename.toFilesystemEncoding()) + << ' ' << quoteName(tempfile.toFilesystemEncoding()); string const command_str = command.str(); lyxerr[Debug::TCLASS] << "Running `" << command_str << '\'' << endl; @@ -173,7 +174,7 @@ enum TextClassTags { // Reads a textclass structure from file. -bool LyXTextClass::read(string const & filename, bool merge) +bool LyXTextClass::read(FileName const & filename, bool merge) { if (!support::isFileReadable(filename)) { lyxerr << "Cannot read layout file `" << filename << "'." @@ -213,11 +214,11 @@ bool LyXTextClass::read(string const & filename, bool merge) if (!merge) lyxerr[Debug::TCLASS] << "Reading textclass " - << to_utf8(makeDisplayPath(filename)) + << to_utf8(makeDisplayPath(filename.absFilename())) << endl; else lyxerr[Debug::TCLASS] << "Reading input file " - << to_utf8(makeDisplayPath(filename)) + << to_utf8(makeDisplayPath(filename.absFilename())) << endl; LyXLex lexrc(textClassTags, @@ -260,7 +261,7 @@ bool LyXTextClass::read(string const & filename, bool merge) case TC_INPUT: // Include file if (lexrc.next()) { string const inc = lexrc.getString(); - string tmp = libFileSearch("layouts", inc, + FileName tmp = libFileSearch("layouts", inc, "layout"); if (tmp.empty()) { @@ -269,7 +270,7 @@ bool LyXTextClass::read(string const & filename, bool merge) error = true; } else if (read(tmp, true)) { lexrc.printError("Error reading input" - "file: "+tmp); + "file: " + tmp.absFilename()); error = true; } } @@ -444,7 +445,7 @@ bool LyXTextClass::read(string const & filename, bool merge) if (format != FORMAT) { lyxerr[Debug::TCLASS] << "Converting layout file from format " << format << " to " << FORMAT << endl; - string const tempfile = support::tempName(); + FileName const tempfile(support::tempName()); error = !layout2layout(filename, tempfile); if (!error) error = read(tempfile, merge); @@ -454,7 +455,7 @@ bool LyXTextClass::read(string const & filename, bool merge) if (!merge) { // we are at top level here. lyxerr[Debug::TCLASS] << "Finished reading textclass " - << to_utf8(makeDisplayPath(filename)) + << to_utf8(makeDisplayPath(filename.absFilename())) << endl; if (defaultlayout_.empty()) { lyxerr << "Error: Textclass '" << name_ @@ -484,7 +485,7 @@ bool LyXTextClass::read(string const & filename, bool merge) } else lyxerr[Debug::TCLASS] << "Finished reading input file " - << to_utf8(makeDisplayPath(filename)) + << to_utf8(makeDisplayPath(filename.absFilename())) << endl; return error; @@ -821,12 +822,12 @@ void LyXTextClass::readCounter(LyXLex & lexrc) switch (static_cast(le)) { case CT_NAME: lexrc.next(); - name = lyx::from_ascii(lexrc.getString()); + name = from_ascii(lexrc.getString()); break; case CT_WITHIN: lexrc.next(); - within = lyx::from_ascii(lexrc.getString()); - if (within == lyx::from_ascii("none")) + within = from_ascii(lexrc.getString()); + if (within == "none") within.erase(); break; case CT_END: @@ -925,16 +926,16 @@ bool LyXTextClass::load(string const & path) const return true; // Read style-file, provided path is searched before the system ones - string layout_file; + FileName layout_file; if (!path.empty()) - layout_file = addName(path, name_ + ".layout"); - if (layout_file.empty() || !fs::exists(layout_file)) + layout_file = FileName(addName(path, name_ + ".layout")); + if (layout_file.empty() || !fs::exists(layout_file.toFilesystemEncoding())) layout_file = libFileSearch("layouts", name_, "layout"); loaded_ = const_cast(this)->read(layout_file) == 0; if (!loaded_) { lyxerr << "Error reading `" - << to_utf8(makeDisplayPath(layout_file)) + << to_utf8(makeDisplayPath(layout_file.absFilename())) << "'\n(Check `" << name_ << "')\nCheck your installation and " "try Options/Reconfigure..." << endl;