X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FFormat.cpp;h=a6727a2d8128a8c67e670912ad559b0d66b901f8;hb=c57d04908f9746a3923c36c0f41e1e23c6043550;hp=feefd1e0dcfa3b781d5e97758f28f18977d6cce2;hpb=4c6a341ab592b2389083579dba08d1961a0380b7;p=lyx.git diff --git a/src/Format.cpp b/src/Format.cpp index feefd1e0dc..a6727a2d81 100644 --- a/src/Format.cpp +++ b/src/Format.cpp @@ -23,7 +23,7 @@ #include "support/filetools.h" #include "support/gettext.h" #include "support/lstrings.h" -#include "support/Magic.h" +#include "support/lyxmagic.h" #include "support/mutex.h" #include "support/os.h" #include "support/PathChanger.h" @@ -337,6 +337,9 @@ string guessFormatFromContents(FileName const & fn) // autodetect pdf format for graphics inclusion format = "pdf6"; + else if (contains(str, " EMF")) + format = "emf"; + else if (contains(str, "PNG")) format = "png"; @@ -679,6 +682,28 @@ bool Formats::view(Buffer const & buffer, FileName const & filename, string command = format->viewer(); + // Escape backslashes if not already in double or single quotes. + // We cannot simply quote the whole command as there may be arguments. + if (contains(command, '\\')) { + bool inquote1 = false; + bool inquote2 = false; + string::iterator cit = command.begin(); + for (; cit != command.end(); ++cit) { + switch (*cit) { + case '"': + inquote1 = !inquote1; + break; + case '\'': + inquote2 = !inquote2; + break; + case '\\': + if (!inquote1 && !inquote2) + cit = ++command.insert(cit, '\\'); + break; + } + } + } + if (format_name == "dvi" && !lyxrc.view_dvi_paper_option.empty()) { string paper_size = buffer.params().paperSizeName(BufferParams::XDVI);