]> git.lyx.org Git - lyx.git/blobdiff - src/Format.cpp
Amend 3093789e for cmake build
[lyx.git] / src / Format.cpp
index a747f0071b4c1325da4005928d20d96b8cb7fd64..62c09d0fa4cb2245fb428d9e31c67701a9a17329 100644 (file)
@@ -94,9 +94,9 @@ string const Format::extensions() const
 }
 
 
-bool Format::hasExtension(string const & e) const
+bool Format::hasExtension(string const & ext) const
 {
-       return (find(extension_list_.begin(), extension_list_.end(), e)
+       return (find(extension_list_.begin(), extension_list_.end(), ext)
                != extension_list_.end());
 }
 
@@ -123,7 +123,7 @@ void Format::setExtensions(string const & e)
 
 namespace {
 
-std::function<bool (Format const &)> FormatNamesEqual(string const & name)
+std::function<bool (Format const &)> FormatNameIs(string const & name)
 {
        return [name](Format const & f){ return f.name() == name; };
 }
@@ -136,7 +136,7 @@ Format const * Formats::getFormat(string const & name) const
 {
        FormatList::const_iterator cit =
                find_if(formatlist_.begin(), formatlist_.end(),
-                       FormatNamesEqual(name));
+                       FormatNameIs(name));
        if (cit != formatlist_.end())
                return &(*cit);
        else
@@ -148,7 +148,7 @@ Format * Formats::getFormat(string const & name)
 {
        FormatList::iterator it =
                find_if(formatlist_.begin(), formatlist_.end(),
-                               FormatNamesEqual(name));
+                               FormatNameIs(name));
 
        if (it != formatlist_.end())
                return &(*it);
@@ -255,8 +255,12 @@ string guessFormatFromContents(FileName const & fn)
                        } else if (stamp == "\377\330") {
                                format =  "jpg";
 
+                       } else if (prefixIs(str, "\x89PNG")) {
+                               format =  "png";
+
                        } else if (stamp == "\001\332") {
                                format =  "sgi";
+
                        } else if (prefixIs(str, binEPSStamp)) {
                                format =  "eps";
 
@@ -319,9 +323,6 @@ string guessFormatFromContents(FileName const & fn)
                else if (contains(str, " EMF"))
                        format = "emf";
 
-               else if (contains(str, "PNG"))
-                       format = "png";
-
                else if (contains(str, "%!PS-Adobe")) {
                        // eps or ps
                        ifs >> str;
@@ -554,7 +555,7 @@ int Formats::getNumber(string const & name) const
 {
        FormatList::const_iterator cit =
                find_if(formatlist_.begin(), formatlist_.end(),
-                       FormatNamesEqual(name));
+                       FormatNameIs(name));
        if (cit == formatlist_.end())
                return -1;
 
@@ -589,7 +590,7 @@ void Formats::erase(string const & name)
 {
        FormatList::iterator it =
                find_if(formatlist_.begin(), formatlist_.end(),
-                       FormatNamesEqual(name));
+                       FormatNameIs(name));
        if (it != formatlist_.end())
                formatlist_.erase(it);
 }
@@ -642,7 +643,7 @@ bool Formats::view(Buffer const & buffer, FileName const & filename,
 // by the caller (this should be "utility" code)
                Alert::error(_("Cannot view file"),
                        bformat(_("No information for viewing %1$s"),
-                               prettyName(format_name)));
+                               translateIfPossible(prettyName(format_name))));
                return false;
        }
        // viewer is 'auto'
@@ -746,7 +747,7 @@ bool Formats::edit(Buffer const & buffer, FileName const & filename,
 // be done by the caller (this should be "utility" code)
                Alert::error(_("Cannot edit file"),
                        bformat(_("No information for editing %1$s"),
-                               prettyName(format_name)));
+                               translateIfPossible(prettyName(format_name))));
                return false;
        }
 
@@ -827,7 +828,7 @@ FlavorTranslator initFlavorTranslator()
        f.addPair(OutputParams::LUATEX, "luatex");
        f.addPair(OutputParams::PDFLATEX, "pdflatex");
        f.addPair(OutputParams::XETEX, "xetex");
-       f.addPair(OutputParams::XML, "docbook-xml");
+       f.addPair(OutputParams::DOCBOOK5, "docbook-xml");
        f.addPair(OutputParams::HTML, "xhtml");
        f.addPair(OutputParams::TEXT, "text");
        f.addPair(OutputParams::LYX, "lyx");