#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"
// autodetect pdf format for graphics inclusion
format = "pdf6";
+ else if (contains(str, " EMF"))
+ format = "emf";
+
else if (contains(str, "PNG"))
format = "png";
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);