};
-} //namespace anon
+} // namespace
bool Format::formatSorter(Format const * lhs, Format const * rhs)
{
Format const * Formats::getFormat(string const & name) const
{
FormatList::const_iterator cit =
- find_if(formatlist.begin(), formatlist.end(),
+ find_if(formatlist_.begin(), formatlist_.end(),
FormatNamesEqual(name));
- if (cit != formatlist.end())
+ if (cit != formatlist_.end())
return &(*cit);
else
return 0;
static string const zipStamp = "PK";
// ZIP containers (koffice, openoffice.org etc).
- static string const nonzipStamp = "\008\0\0\0mimetypeapplication/";
+ static string const nonzipStamp = "\010\0\0\0mimetypeapplication/";
// compress
static string const compressStamp = "\037\235";
return string();
}
-}
+} // namespace
string Formats::getFormatFromFile(FileName const & filename) const
if (!mime.empty() && mime != "application/octet-stream" &&
mime != "text/plain") {
Formats::const_iterator cit =
- find_if(formatlist.begin(), formatlist.end(),
+ find_if(formatlist_.begin(), formatlist_.end(),
FormatMimeEqual(mime));
- if (cit != formatlist.end()) {
+ if (cit != formatlist_.end()) {
LYXERR(Debug::GRAPHICS, "\tgot format from MIME type: "
<< mime << " -> " << cit->name());
// See special eps/ps handling below
}
if (isZippedFileFormat(format) && !ext.empty()) {
- string const & fmt_name = formats.getFormatFromExtension(ext);
+ string const & fmt_name = getFormatFromExtension(ext);
if (!fmt_name.empty()) {
- Format const * p_format = formats.getFormat(fmt_name);
+ Format const * p_format = getFormat(fmt_name);
if (p_format && p_format->zippedNative())
return p_format->name();
}
// this is ambigous if two formats have the same extension,
// but better than nothing
Formats::const_iterator cit =
- find_if(formatlist.begin(), formatlist.end(),
+ find_if(formatlist_.begin(), formatlist_.end(),
FormatExtensionsEqual(ext));
- if (cit != formats.end()) {
+ if (cit != formatlist_.end()) {
LYXERR(Debug::GRAPHICS, "\twill guess format from file extension: "
<< ext << " -> " << cit->name());
return cit->name();
void Formats::setAutoOpen()
{
- FormatList::iterator fit = formatlist.begin();
- FormatList::iterator const fend = formatlist.end();
+ FormatList::iterator fit = formatlist_.begin();
+ FormatList::iterator const fend = formatlist_.end();
for ( ; fit != fend ; ++fit) {
fit->setViewer(fixCommand(fit->viewer(), fit->extension(), os::VIEW));
fit->setEditor(fixCommand(fit->editor(), fit->extension(), os::EDIT));
int Formats::getNumber(string const & name) const
{
FormatList::const_iterator cit =
- find_if(formatlist.begin(), formatlist.end(),
+ find_if(formatlist_.begin(), formatlist_.end(),
FormatNamesEqual(name));
- if (cit != formatlist.end())
- return distance(formatlist.begin(), cit);
+ if (cit != formatlist_.end())
+ return distance(formatlist_.begin(), cit);
else
return -1;
}
string const & mime, int flags)
{
FormatList::iterator it =
- find_if(formatlist.begin(), formatlist.end(),
+ find_if(formatlist_.begin(), formatlist_.end(),
FormatNamesEqual(name));
- if (it == formatlist.end())
- formatlist.push_back(Format(name, extensions, prettyname,
+ if (it == formatlist_.end())
+ formatlist_.push_back(Format(name, extensions, prettyname,
shortcut, viewer, editor, mime, flags));
else
*it = Format(name, extensions, prettyname, shortcut, viewer,
void Formats::erase(string const & name)
{
FormatList::iterator it =
- find_if(formatlist.begin(), formatlist.end(),
+ find_if(formatlist_.begin(), formatlist_.end(),
FormatNamesEqual(name));
- if (it != formatlist.end())
- formatlist.erase(it);
+ if (it != formatlist_.end())
+ formatlist_.erase(it);
}
void Formats::sort()
{
- std::sort(formatlist.begin(), formatlist.end());
+ std::sort(formatlist_.begin(), formatlist_.end());
}
{
add(name);
FormatList::iterator it =
- find_if(formatlist.begin(), formatlist.end(),
+ find_if(formatlist_.begin(), formatlist_.end(),
FormatNamesEqual(name));
- if (it != formatlist.end())
+ if (it != formatlist_.end())
it->setViewer(command);
}
{
add(name);
FormatList::iterator it =
- find_if(formatlist.begin(), formatlist.end(),
+ find_if(formatlist_.begin(), formatlist_.end(),
FormatNamesEqual(name));
- if (it != formatlist.end())
+ if (it != formatlist_.end())
it->setEditor(command);
}
// 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'
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);
// 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;
}
return translator;
}
-}
+} // namespace
std::string flavor2format(OutputParams::FLAVOR flavor)
return flavorTranslator().find(fmt);
} */
-Formats formats;
-
-Formats system_formats;
-
-
} // namespace lyx