X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FFormat.cpp;h=b605c4ee4a286200771b2dd9065e18efd68afc19;hb=2de30c62f8d671a8c8d4d52a6a7310e2c5ca84de;hp=bf3102653c37658c838c6e67704d33f4d936a07f;hpb=a180414975f45dc3387d6ca71912509fbb03e3e5;p=lyx.git diff --git a/src/Format.cpp b/src/Format.cpp index bf3102653c..b605c4ee4a 100644 --- a/src/Format.cpp +++ b/src/Format.cpp @@ -23,6 +23,7 @@ #include "support/gettext.h" #include "support/lstrings.h" #include "support/mutex.h" +#include "support/docstream.h" #include "support/os.h" #include "support/PathChanger.h" #include "support/Systemcall.h" @@ -105,16 +106,18 @@ private: bool Format::formatSorter(Format const * lhs, Format const * rhs) { - return compare_locale(_(lhs->prettyname()), _(rhs->prettyname())) < 0; + return compare_locale(translateIfPossible(lhs->prettyname()), + translateIfPossible(rhs->prettyname())) < 0; } bool operator<(Format const & a, Format const & b) { - return compare_locale(_(a.prettyname()), _(b.prettyname())) < 0; + return compare_locale(translateIfPossible(a.prettyname()), + translateIfPossible(b.prettyname())) < 0; } -Format::Format(string const & n, string const & e, string const & p, +Format::Format(string const & n, string const & e, docstring const & p, string const & s, string const & v, string const & ed, string const & m, int flags) : name_(n), prettyname_(p), shortcut_(s), viewer_(v), @@ -530,6 +533,10 @@ bool Formats::isZippedFile(support::FileName const & filename) const { map::iterator it = zipped_.find(fname); if (it != zipped_.end() && it->second.timestamp == timestamp) return it->second.zipped; + // FIXME perf: This very expensive function is called on startup on each + // file whic is going to be parsed, and also on svgz icons. Maybe there is a + // quicker way to check whether a file is zipped? I.e. for icons we + // probably just need to check the extension (svgz vs svg). string const & format = getFormatFromFile(filename); bool zipped = (format == "gzip" || format == "zip"); zipped_.insert(make_pair(fname, ZippedInfo(zipped, timestamp))); @@ -594,13 +601,13 @@ 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, from_utf8(name), string(), string(), string(), string(), Format::document); } void Formats::add(string const & name, string const & extensions, - string const & prettyname, string const & shortcut, + docstring const & prettyname, string const & shortcut, string const & viewer, string const & editor, string const & mime, int flags) { @@ -716,7 +723,8 @@ bool Formats::view(Buffer const & buffer, FileName const & filename, PathChanger p(filename.onlyPath()); Systemcall one; - one.startscript(Systemcall::DontWait, command, buffer.filePath()); + one.startscript(Systemcall::DontWait, command, + buffer.filePath(), buffer.layoutPos()); // we can't report any sort of error, since we aren't waiting return true; @@ -785,7 +793,8 @@ bool Formats::edit(Buffer const & buffer, FileName const & filename, buffer.message(_("Executing command: ") + from_utf8(command)); Systemcall one; - one.startscript(Systemcall::DontWait, command, buffer.filePath()); + one.startscript(Systemcall::DontWait, command, + buffer.filePath(), buffer.layoutPos()); // we can't report any sort of error, since we aren't waiting return true; @@ -796,7 +805,7 @@ docstring const Formats::prettyName(string const & name) const { Format const * format = getFormat(name); if (format) - return from_utf8(format->prettyname()); + return format->prettyname(); else return from_utf8(name); } @@ -837,6 +846,7 @@ FlavorTranslator initFlavorTranslator() f.addPair(OutputParams::XML, "docbook-xml"); f.addPair(OutputParams::HTML, "xhtml"); f.addPair(OutputParams::TEXT, "text"); + f.addPair(OutputParams::LYX, "lyx"); return f; }