X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fformat.C;h=29ebe338c2f4edcae906f7ae502651f816c5560a;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=7de79556ff9eb90400e0f5273ebd1a203480f712;hpb=6104eebe0dfe744adcc01c73c16154d5a7d0b8e1;p=lyx.git diff --git a/src/format.C b/src/format.C index 7de79556ff..29ebe338c2 100644 --- a/src/format.C +++ b/src/format.C @@ -16,6 +16,7 @@ #include "lyxrc.h" #include "debug.h" #include "gettext.h" +#include "lyxsocket.h" #include "frontends/Application.h" #include "frontends/Alert.h" //to be removed? @@ -27,24 +28,27 @@ #include -using lyx::docstring; -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::onlyPath; -using lyx::support::quoteName; -using lyx::support::subst; -using lyx::support::Systemcall; -using lyx::support::token; + +namespace lyx { + +using support::absolutePath; +using support::bformat; +using support::compare_ascii_no_case; +using support::contains; +using support::libScriptSearch; +using support::makeDisplayPath; +using support::onlyPath; +using support::quoteName; +using support::subst; +using support::Systemcall; +using support::token; using std::string; using std::distance; +namespace Alert = frontend::Alert; namespace fs = boost::filesystem; -namespace os = lyx::support::os; +namespace os = support::os; namespace { @@ -92,9 +96,9 @@ bool operator<(Format const & a, Format const & b) Format::Format(string const & n, string const & e, string const & p, string const & s, string const & v, string const & ed, - bool d) + int flags) : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), - editor_(ed), document_(d) + editor_(ed), flags_(flags) {} @@ -137,12 +141,12 @@ string Formats::getFormatFromFile(string const & filename) const if (filename.empty()) return string(); - string const format = lyx::support::getFormatFromContents(filename); + string const format = support::getFormatFromContents(filename); if (!format.empty()) return format; // try to find a format from the file extension. - string const ext(lyx::support::getExtension(filename)); + string const ext(support::getExtension(filename)); if (!ext.empty()) { // this is ambigous if two formats have the same extension, // but better than nothing @@ -208,24 +212,25 @@ int Formats::getNumber(string const & name) const void Formats::add(string const & name) { if (!getFormat(name)) - add(name, name, name, string(), string(), string(), true); + add(name, name, name, string(), string(), string(), + Format::document); } void Formats::add(string const & name, string const & extension, string const & prettyname, string const & shortcut, - string const & viewer, string const & editor, bool document) + string const & viewer, string const & editor, + int flags) { 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, - document)); + shortcut, viewer, editor, flags)); else *it = Format(name, extension, prettyname, shortcut, viewer, - editor, document); + editor, flags); } @@ -263,7 +268,7 @@ bool Formats::view(Buffer const & buffer, string const & filename, if (filename.empty() || !fs::exists(filename)) { Alert::error(_("Cannot view file"), bformat(_("File does not exist: %1$s"), - lyx::from_utf8(filename))); + from_utf8(filename))); return false; } @@ -286,7 +291,7 @@ bool Formats::view(Buffer const & buffer, string const & filename, else { Alert::error(_("Cannot view file"), bformat(_("Auto-view file %1$s failed"), - lyx::from_utf8(filename))); + from_utf8(filename))); return false; } } @@ -309,9 +314,9 @@ bool Formats::view(Buffer const & buffer, string const & filename, command = subst(command, token_from, quoteName(filename)); command = subst(command, token_path, quoteName(onlyPath(filename))); - command = subst(command, token_socket, quoteName(theApp->socket().address())); + command = subst(command, token_socket, quoteName(theLyXServerSocket().address())); lyxerr[Debug::FILES] << "Executing command: " << command << std::endl; - buffer.message(_("Executing command: ") + lyx::from_utf8(command)); + buffer.message(_("Executing command: ") + from_utf8(command)); Systemcall one; int const res = one.startscript(Systemcall::DontWait, command); @@ -333,7 +338,7 @@ bool Formats::edit(Buffer const & buffer, string const & filename, if (filename.empty() || !fs::exists(filename)) { Alert::error(_("Cannot edit file"), bformat(_("File does not exist: %1$s"), - lyx::from_utf8(filename))); + from_utf8(filename))); return false; } @@ -356,7 +361,7 @@ bool Formats::edit(Buffer const & buffer, string const & filename, else { Alert::error(_("Cannot edit file"), bformat(_("Auto-edit file %1$s failed"), - lyx::from_utf8(filename))); + from_utf8(filename))); return false; } } @@ -368,9 +373,9 @@ bool Formats::edit(Buffer const & buffer, string const & filename, command = subst(command, token_from, quoteName(filename)); command = subst(command, token_path, quoteName(onlyPath(filename))); - command = subst(command, token_socket, quoteName(theApp->socket().address())); + command = subst(command, token_socket, quoteName(theLyXServerSocket().address())); lyxerr[Debug::FILES] << "Executing command: " << command << std::endl; - buffer.message(_("Executing command: ") + lyx::from_utf8(command)); + buffer.message(_("Executing command: ") + from_utf8(command)); Systemcall one; int const res = one.startscript(Systemcall::DontWait, command); @@ -389,9 +394,9 @@ docstring const Formats::prettyName(string const & name) const { Format const * format = getFormat(name); if (format) - return lyx::from_utf8(format->prettyname()); + return from_utf8(format->prettyname()); else - return lyx::from_utf8(name); + return from_utf8(name); } @@ -410,3 +415,6 @@ string const Formats::extension(string const & name) const Formats formats; Formats system_formats; + + +} // namespace lyx