mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-12 22:14:35 +00:00
Move the global formats and system_formats variables into the
LyX singleton. Mostly, this is very boring, but it might be good if someone would check what I did about the dummy implementation in tex2lyx.
This commit is contained in:
parent
591f5780e4
commit
50060053e3
@ -834,7 +834,7 @@ string Buffer::logName(LogType * type) const
|
|||||||
FileName const bname(
|
FileName const bname(
|
||||||
addName(path, onlyFileName(
|
addName(path, onlyFileName(
|
||||||
changeExtension(filename,
|
changeExtension(filename,
|
||||||
formats.extension(params().bufferFormat()) + ".out"))));
|
theFormats().extension(params().bufferFormat()) + ".out"))));
|
||||||
|
|
||||||
// Also consider the master buffer log file
|
// Also consider the master buffer log file
|
||||||
FileName masterfname = fname;
|
FileName masterfname = fname;
|
||||||
@ -1085,7 +1085,7 @@ bool Buffer::readDocument(Lexer & lex)
|
|||||||
|
|
||||||
bool Buffer::importString(string const & format, docstring const & contents, ErrorList & errorList)
|
bool Buffer::importString(string const & format, docstring const & contents, ErrorList & errorList)
|
||||||
{
|
{
|
||||||
Format const * fmt = formats.getFormat(format);
|
Format const * fmt = theFormats().getFormat(format);
|
||||||
if (!fmt)
|
if (!fmt)
|
||||||
return false;
|
return false;
|
||||||
// It is important to use the correct extension here, since some
|
// It is important to use the correct extension here, since some
|
||||||
@ -1199,7 +1199,7 @@ Buffer::ReadStatus Buffer::readFile(FileName const & fn)
|
|||||||
|
|
||||||
d->file_fully_loaded = true;
|
d->file_fully_loaded = true;
|
||||||
d->read_only = !d->filename.isWritable();
|
d->read_only = !d->filename.isWritable();
|
||||||
params().compressed = formats.isZippedFile(d->filename);
|
params().compressed = theFormats().isZippedFile(d->filename);
|
||||||
saveCheckSum();
|
saveCheckSum();
|
||||||
return ReadSuccess;
|
return ReadSuccess;
|
||||||
}
|
}
|
||||||
@ -2689,7 +2689,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
|||||||
case LFUN_BUFFER_EXPORT_CUSTOM: {
|
case LFUN_BUFFER_EXPORT_CUSTOM: {
|
||||||
string format_name;
|
string format_name;
|
||||||
string command = split(argument, format_name, ' ');
|
string command = split(argument, format_name, ' ');
|
||||||
Format const * format = formats.getFormat(format_name);
|
Format const * format = theFormats().getFormat(format_name);
|
||||||
if (!format) {
|
if (!format) {
|
||||||
lyxerr << "Format \"" << format_name
|
lyxerr << "Format \"" << format_name
|
||||||
<< "\" not recognized!"
|
<< "\" not recognized!"
|
||||||
@ -2848,7 +2848,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_BUFFER_VIEW_CACHE:
|
case LFUN_BUFFER_VIEW_CACHE:
|
||||||
if (!formats.view(*this, d->preview_file_,
|
if (!theFormats().view(*this, d->preview_file_,
|
||||||
d->preview_format_))
|
d->preview_format_))
|
||||||
dr.setMessage(_("Error viewing the output file."));
|
dr.setMessage(_("Error viewing the output file."));
|
||||||
break;
|
break;
|
||||||
@ -4281,7 +4281,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
|
|||||||
// file (not for previewing).
|
// file (not for previewing).
|
||||||
Alert::error(_("Couldn't export file"), bformat(
|
Alert::error(_("Couldn't export file"), bformat(
|
||||||
_("No information for exporting the format %1$s."),
|
_("No information for exporting the format %1$s."),
|
||||||
formats.prettyName(format)));
|
theFormats().prettyName(format)));
|
||||||
}
|
}
|
||||||
return ExportNoPathToFormat;
|
return ExportNoPathToFormat;
|
||||||
}
|
}
|
||||||
@ -4311,7 +4311,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
|
|||||||
string filename = latexName(false);
|
string filename = latexName(false);
|
||||||
filename = addName(temppath(), filename);
|
filename = addName(temppath(), filename);
|
||||||
filename = changeExtension(filename,
|
filename = changeExtension(filename,
|
||||||
formats.extension(backend_format));
|
theFormats().extension(backend_format));
|
||||||
LYXERR(Debug::FILES, "filename=" << filename);
|
LYXERR(Debug::FILES, "filename=" << filename);
|
||||||
|
|
||||||
// Plain text backend
|
// Plain text backend
|
||||||
@ -4357,7 +4357,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
|
|||||||
string const error_type = (format == "program")
|
string const error_type = (format == "program")
|
||||||
? "Build" : params().bufferFormat();
|
? "Build" : params().bufferFormat();
|
||||||
ErrorList & error_list = d->errorLists[error_type];
|
ErrorList & error_list = d->errorLists[error_type];
|
||||||
string const ext = formats.extension(format);
|
string const ext = theFormats().extension(format);
|
||||||
FileName const tmp_result_file(changeExtension(filename, ext));
|
FileName const tmp_result_file(changeExtension(filename, ext));
|
||||||
bool const success = converters.convert(this, FileName(filename),
|
bool const success = converters.convert(this, FileName(filename),
|
||||||
tmp_result_file, FileName(absFileName()), backend_format, format,
|
tmp_result_file, FileName(absFileName()), backend_format, format,
|
||||||
@ -4425,7 +4425,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
|
|||||||
vector<ExportedFile>::const_iterator it = files.begin();
|
vector<ExportedFile>::const_iterator it = files.begin();
|
||||||
vector<ExportedFile>::const_iterator const en = files.end();
|
vector<ExportedFile>::const_iterator const en = files.end();
|
||||||
for (; it != en && status != CANCEL; ++it) {
|
for (; it != en && status != CANCEL; ++it) {
|
||||||
string const fmt = formats.getFormatFromFile(it->sourceName);
|
string const fmt = theFormats().getFormatFromFile(it->sourceName);
|
||||||
string fixedName = it->exportName;
|
string fixedName = it->exportName;
|
||||||
if (!runparams.export_folder.empty()) {
|
if (!runparams.export_folder.empty()) {
|
||||||
// Relative pathnames starting with ../ will be sanitized
|
// Relative pathnames starting with ../ will be sanitized
|
||||||
@ -4461,13 +4461,13 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
|
|||||||
} else {
|
} else {
|
||||||
message(bformat(_("Document exported as %1$s "
|
message(bformat(_("Document exported as %1$s "
|
||||||
"to file `%2$s'"),
|
"to file `%2$s'"),
|
||||||
formats.prettyName(format),
|
theFormats().prettyName(format),
|
||||||
makeDisplayPath(result_file)));
|
makeDisplayPath(result_file)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// This must be a dummy converter like fax (bug 1888)
|
// This must be a dummy converter like fax (bug 1888)
|
||||||
message(bformat(_("Document exported as %1$s"),
|
message(bformat(_("Document exported as %1$s"),
|
||||||
formats.prettyName(format)));
|
theFormats().prettyName(format)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return success ? ExportSuccess : ExportConverterError;
|
return success ? ExportSuccess : ExportConverterError;
|
||||||
@ -4506,7 +4506,7 @@ Buffer::ExportStatus Buffer::preview(string const & format, bool includeall) con
|
|||||||
return status;
|
return status;
|
||||||
|
|
||||||
if (previewFile.exists())
|
if (previewFile.exists())
|
||||||
return formats.view(*this, previewFile, format) ?
|
return theFormats().view(*this, previewFile, format) ?
|
||||||
PreviewSuccess : PreviewError;
|
PreviewSuccess : PreviewError;
|
||||||
|
|
||||||
// Successful export but no output file?
|
// Successful export but no output file?
|
||||||
|
@ -134,7 +134,7 @@ void Converter::readFlags()
|
|||||||
need_auth_ = true;
|
need_auth_ = true;
|
||||||
}
|
}
|
||||||
if (!result_dir_.empty() && result_file_.empty())
|
if (!result_dir_.empty() && result_file_.empty())
|
||||||
result_file_ = "index." + formats.extension(to_);
|
result_file_ = "index." + theFormats().extension(to_);
|
||||||
//if (!contains(command, token_from))
|
//if (!contains(command, token_from))
|
||||||
// latex = true;
|
// latex = true;
|
||||||
}
|
}
|
||||||
@ -168,8 +168,8 @@ int Converters::getNumber(string const & from, string const & to) const
|
|||||||
void Converters::add(string const & from, string const & to,
|
void Converters::add(string const & from, string const & to,
|
||||||
string const & command, string const & flags)
|
string const & command, string const & flags)
|
||||||
{
|
{
|
||||||
formats.add(from);
|
theFormats().add(from);
|
||||||
formats.add(to);
|
theFormats().add(to);
|
||||||
ConverterList::iterator it = find_if(converterlist_.begin(),
|
ConverterList::iterator it = find_if(converterlist_.begin(),
|
||||||
converterlist_.end(),
|
converterlist_.end(),
|
||||||
ConverterEqual(from , to));
|
ConverterEqual(from , to));
|
||||||
@ -235,8 +235,8 @@ void Converters::update(Formats const & formats)
|
|||||||
ConverterList::iterator it = converterlist_.begin();
|
ConverterList::iterator it = converterlist_.begin();
|
||||||
ConverterList::iterator end = converterlist_.end();
|
ConverterList::iterator end = converterlist_.end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
it->setFrom(formats.getFormat(it->from()));
|
it->setFrom(theFormats().getFormat(it->from()));
|
||||||
it->setTo(formats.getFormat(it->to()));
|
it->setTo(theFormats().getFormat(it->to()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,8 +247,8 @@ void Converters::updateLast(Formats const & formats)
|
|||||||
{
|
{
|
||||||
if (converterlist_.begin() != converterlist_.end()) {
|
if (converterlist_.begin() != converterlist_.end()) {
|
||||||
ConverterList::iterator it = converterlist_.end() - 1;
|
ConverterList::iterator it = converterlist_.end() - 1;
|
||||||
it->setFrom(formats.getFormat(it->from()));
|
it->setFrom(theFormats().getFormat(it->from()));
|
||||||
it->setTo(formats.getFormat(it->to()));
|
it->setTo(theFormats().getFormat(it->to()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,8 +350,8 @@ bool Converters::convert(Buffer const * buffer,
|
|||||||
// default one from ImageMagic.
|
// default one from ImageMagic.
|
||||||
string const from_ext = from_format.empty() ?
|
string const from_ext = from_format.empty() ?
|
||||||
getExtension(from_file.absFileName()) :
|
getExtension(from_file.absFileName()) :
|
||||||
formats.extension(from_format);
|
theFormats().extension(from_format);
|
||||||
string const to_ext = formats.extension(to_format);
|
string const to_ext = theFormats().extension(to_format);
|
||||||
string const command =
|
string const command =
|
||||||
os::python() + ' ' +
|
os::python() + ' ' +
|
||||||
quoteName(libFileSearch("scripts", "convertDefault.py").toFilesystemEncoding()) +
|
quoteName(libFileSearch("scripts", "convertDefault.py").toFilesystemEncoding()) +
|
||||||
@ -761,15 +761,15 @@ bool Converters::runLaTeX(Buffer const & buffer, string const & command,
|
|||||||
void Converters::buildGraph()
|
void Converters::buildGraph()
|
||||||
{
|
{
|
||||||
// clear graph's data structures
|
// clear graph's data structures
|
||||||
G_.init(formats.size());
|
G_.init(theFormats().size());
|
||||||
// each of the converters knows how to convert one format to another
|
// each of the converters knows how to convert one format to another
|
||||||
// so, for each of them, we create an arrow on the graph, going from
|
// so, for each of them, we create an arrow on the graph, going from
|
||||||
// the one to the other
|
// the one to the other
|
||||||
ConverterList::iterator it = converterlist_.begin();
|
ConverterList::iterator it = converterlist_.begin();
|
||||||
ConverterList::iterator const end = converterlist_.end();
|
ConverterList::iterator const end = converterlist_.end();
|
||||||
for (; it != end ; ++it) {
|
for (; it != end ; ++it) {
|
||||||
int const from = formats.getNumber(it->from());
|
int const from = theFormats().getNumber(it->from());
|
||||||
int const to = formats.getNumber(it->to());
|
int const to = theFormats().getNumber(it->to());
|
||||||
LASSERT(from >= 0, continue);
|
LASSERT(from >= 0, continue);
|
||||||
LASSERT(to >= 0, continue);
|
LASSERT(to >= 0, continue);
|
||||||
G_.addEdge(from, to);
|
G_.addEdge(from, to);
|
||||||
@ -785,7 +785,7 @@ FormatList const Converters::intToFormat(vector<int> const & input)
|
|||||||
vector<int>::const_iterator const end = input.end();
|
vector<int>::const_iterator const end = input.end();
|
||||||
FormatList::iterator rit = result.begin();
|
FormatList::iterator rit = result.begin();
|
||||||
for ( ; it != end; ++it, ++rit) {
|
for ( ; it != end; ++it, ++rit) {
|
||||||
*rit = &formats.get(*it);
|
*rit = &theFormats().get(*it);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -795,7 +795,7 @@ FormatList const Converters::getReachableTo(string const & target,
|
|||||||
bool const clear_visited)
|
bool const clear_visited)
|
||||||
{
|
{
|
||||||
vector<int> const & reachablesto =
|
vector<int> const & reachablesto =
|
||||||
G_.getReachableTo(formats.getNumber(target), clear_visited);
|
G_.getReachableTo(theFormats().getNumber(target), clear_visited);
|
||||||
|
|
||||||
return intToFormat(reachablesto);
|
return intToFormat(reachablesto);
|
||||||
}
|
}
|
||||||
@ -810,10 +810,10 @@ FormatList const Converters::getReachable(string const & from,
|
|||||||
set<string>::const_iterator sit = excludes.begin();
|
set<string>::const_iterator sit = excludes.begin();
|
||||||
set<string>::const_iterator const end = excludes.end();
|
set<string>::const_iterator const end = excludes.end();
|
||||||
for (; sit != end; ++sit)
|
for (; sit != end; ++sit)
|
||||||
excluded_numbers.insert(formats.getNumber(*sit));
|
excluded_numbers.insert(theFormats().getNumber(*sit));
|
||||||
|
|
||||||
vector<int> const & reachables =
|
vector<int> const & reachables =
|
||||||
G_.getReachable(formats.getNumber(from),
|
G_.getReachable(theFormats().getNumber(from),
|
||||||
only_viewable,
|
only_viewable,
|
||||||
clear_visited,
|
clear_visited,
|
||||||
excluded_numbers);
|
excluded_numbers);
|
||||||
@ -824,15 +824,15 @@ FormatList const Converters::getReachable(string const & from,
|
|||||||
|
|
||||||
bool Converters::isReachable(string const & from, string const & to)
|
bool Converters::isReachable(string const & from, string const & to)
|
||||||
{
|
{
|
||||||
return G_.isReachable(formats.getNumber(from),
|
return G_.isReachable(theFormats().getNumber(from),
|
||||||
formats.getNumber(to));
|
theFormats().getNumber(to));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Graph::EdgePath Converters::getPath(string const & from, string const & to)
|
Graph::EdgePath Converters::getPath(string const & from, string const & to)
|
||||||
{
|
{
|
||||||
return G_.getPath(formats.getNumber(from),
|
return G_.getPath(theFormats().getNumber(from),
|
||||||
formats.getNumber(to));
|
theFormats().getNumber(to));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ void ConverterCache::Impl::readIndex()
|
|||||||
// cached files on opening. This slows LyX startup a lot. It
|
// cached files on opening. This slows LyX startup a lot. It
|
||||||
// would be better if this information was retrieved in a
|
// would be better if this information was retrieved in a
|
||||||
// delayed fashion.
|
// delayed fashion.
|
||||||
formats.getFormatFromFile(orig_from_name);
|
theFormats().getFormatFromFile(orig_from_name);
|
||||||
format_cache.cache[to_format] = item;
|
format_cache.cache[to_format] = item;
|
||||||
}
|
}
|
||||||
is.close();
|
is.close();
|
||||||
@ -320,7 +320,7 @@ void ConverterCache::add(FileName const & orig_from, string const & to_format,
|
|||||||
FormatCache & format_cache = pimpl_->cache[orig_from];
|
FormatCache & format_cache = pimpl_->cache[orig_from];
|
||||||
if (format_cache.from_format.empty())
|
if (format_cache.from_format.empty())
|
||||||
format_cache.from_format =
|
format_cache.from_format =
|
||||||
formats.getFormatFromFile(orig_from);
|
theFormats().getFormatFromFile(orig_from);
|
||||||
format_cache.cache[to_format] = new_item;
|
format_cache.cache[to_format] = new_item;
|
||||||
} else
|
} else
|
||||||
LYXERR(Debug::FILES, "ConverterCache::add(" << orig_from << "):\n"
|
LYXERR(Debug::FILES, "ConverterCache::add(" << orig_from << "):\n"
|
||||||
|
@ -872,9 +872,4 @@ OutputParams::FLAVOR format2flavor(std::string fmt)
|
|||||||
return flavorTranslator().find(fmt);
|
return flavorTranslator().find(fmt);
|
||||||
} */
|
} */
|
||||||
|
|
||||||
Formats formats;
|
|
||||||
|
|
||||||
Formats system_formats;
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -217,10 +217,13 @@ std::string flavor2format(OutputParams::FLAVOR flavor);
|
|||||||
// Not currently used.
|
// Not currently used.
|
||||||
// OutputParams::FLAVOR format2flavor(std::string fmt);
|
// OutputParams::FLAVOR format2flavor(std::string fmt);
|
||||||
|
|
||||||
extern Formats formats;
|
/// The global instance.
|
||||||
|
/// Implementation is in LyX.cpp.
|
||||||
extern Formats system_formats;
|
extern Formats & theFormats();
|
||||||
|
|
||||||
|
/// The global copy after reading lyxrc.defaults.
|
||||||
|
/// Implementation is in LyX.cpp.
|
||||||
|
extern Formats & theSystemFormats();
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ Graph::EdgePath const
|
|||||||
while (!Q.empty()) {
|
while (!Q.empty()) {
|
||||||
int const current = Q.front();
|
int const current = Q.front();
|
||||||
Q.pop();
|
Q.pop();
|
||||||
if (current != target || formats.get(target).name() != "lyx")
|
if (current != target || theFormats().get(target).name() != "lyx")
|
||||||
result.push_back(current);
|
result.push_back(current);
|
||||||
|
|
||||||
vector<Arrow *>::iterator it = vertices_[current].in_arrows.begin();
|
vector<Arrow *>::iterator it = vertices_[current].in_arrows.begin();
|
||||||
@ -93,12 +93,12 @@ Graph::EdgePath const
|
|||||||
while (!Q.empty()) {
|
while (!Q.empty()) {
|
||||||
int const current = Q.front();
|
int const current = Q.front();
|
||||||
Q.pop();
|
Q.pop();
|
||||||
Format const & format = formats.get(current);
|
Format const & format = theFormats().get(current);
|
||||||
if (!only_viewable || !format.viewer().empty())
|
if (!only_viewable || !format.viewer().empty())
|
||||||
result.push_back(current);
|
result.push_back(current);
|
||||||
else if (format.isChildFormat()) {
|
else if (format.isChildFormat()) {
|
||||||
Format const * const parent =
|
Format const * const parent =
|
||||||
formats.getFormat(format.parentFormat());
|
theFormats().getFormat(format.parentFormat());
|
||||||
if (parent && !parent->viewer().empty())
|
if (parent && !parent->viewer().empty())
|
||||||
result.push_back(current);
|
result.push_back(current);
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ void Lexer::Pimpl::popTable()
|
|||||||
bool Lexer::Pimpl::setFile(FileName const & filename)
|
bool Lexer::Pimpl::setFile(FileName const & filename)
|
||||||
{
|
{
|
||||||
// Check the format of the file.
|
// Check the format of the file.
|
||||||
if (formats.isZippedFile(filename)) {
|
if (theFormats().isZippedFile(filename)) {
|
||||||
LYXERR(Debug::LYXLEX, "lyxlex: compressed");
|
LYXERR(Debug::LYXLEX, "lyxlex: compressed");
|
||||||
// The check only outputs a debug message, because it triggers
|
// The check only outputs a debug message, because it triggers
|
||||||
// a bug in compaq cxx 6.2, where is_open() returns 'true' for
|
// a bug in compaq cxx 6.2, where is_open() returns 'true' for
|
||||||
|
31
src/LyX.cpp
31
src/LyX.cpp
@ -190,9 +190,14 @@ struct LyX::Impl {
|
|||||||
|
|
||||||
/// The file converters.
|
/// The file converters.
|
||||||
Converters converters_;
|
Converters converters_;
|
||||||
|
/// The system converters after reading lyxrc.defaults.
|
||||||
// The system converters copy after reading lyxrc.defaults.
|
|
||||||
Converters system_converters_;
|
Converters system_converters_;
|
||||||
|
|
||||||
|
/// Global format information
|
||||||
|
Formats formats_;
|
||||||
|
/// The system formats after reading lyxrc.defaults.
|
||||||
|
Formats system_formats_;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
Movers movers_;
|
Movers movers_;
|
||||||
@ -938,13 +943,13 @@ bool LyX::init()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Query the OS to know what formats are viewed natively
|
// Query the OS to know what formats are viewed natively
|
||||||
formats.setAutoOpen();
|
theFormats().setAutoOpen();
|
||||||
|
|
||||||
// Read lyxrc.dist again to be able to override viewer auto-detection.
|
// Read lyxrc.dist again to be able to override viewer auto-detection.
|
||||||
readRcFile("lyxrc.dist");
|
readRcFile("lyxrc.dist");
|
||||||
|
|
||||||
system_lyxrc = lyxrc;
|
system_lyxrc = lyxrc;
|
||||||
system_formats = formats;
|
theSystemFormats() = theFormats();
|
||||||
pimpl_->system_converters_ = pimpl_->converters_;
|
pimpl_->system_converters_ = pimpl_->converters_;
|
||||||
pimpl_->system_movers_ = pimpl_->movers_;
|
pimpl_->system_movers_ = pimpl_->movers_;
|
||||||
system_lcolor = lcolor;
|
system_lcolor = lcolor;
|
||||||
@ -1499,17 +1504,31 @@ KeyMap & theTopLevelKeymap()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Formats & theFormats()
|
||||||
|
{
|
||||||
|
LAPPERR(singleton_);
|
||||||
|
return singleton_->pimpl_->formats_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Formats & theSystemFormats()
|
||||||
|
{
|
||||||
|
LAPPERR(singleton_);
|
||||||
|
return singleton_->pimpl_->system_formats_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Converters & theConverters()
|
Converters & theConverters()
|
||||||
{
|
{
|
||||||
LAPPERR(singleton_);
|
LAPPERR(singleton_);
|
||||||
return singleton_->pimpl_->converters_;
|
return singleton_->pimpl_->converters_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Converters & theSystemConverters()
|
Converters & theSystemConverters()
|
||||||
{
|
{
|
||||||
LAPPERR(singleton_);
|
LAPPERR(singleton_);
|
||||||
return singleton_->pimpl_->system_converters_;
|
return singleton_->pimpl_->system_converters_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ class CmdDef;
|
|||||||
class Converters;
|
class Converters;
|
||||||
class DispatchResult;
|
class DispatchResult;
|
||||||
class ErrorItem;
|
class ErrorItem;
|
||||||
|
class Formats;
|
||||||
class FuncRequest;
|
class FuncRequest;
|
||||||
class FuncStatus;
|
class FuncStatus;
|
||||||
class KeyMap;
|
class KeyMap;
|
||||||
@ -139,6 +140,8 @@ private:
|
|||||||
friend ServerSocket & theServerSocket();
|
friend ServerSocket & theServerSocket();
|
||||||
friend Converters & theConverters();
|
friend Converters & theConverters();
|
||||||
friend Converters & theSystemConverters();
|
friend Converters & theSystemConverters();
|
||||||
|
friend Formats & theFormats();
|
||||||
|
friend Formats & theSystemFormats();
|
||||||
friend Messages const & getMessages(std::string const & language);
|
friend Messages const & getMessages(std::string const & language);
|
||||||
friend Messages const & getGuiMessages();
|
friend Messages const & getGuiMessages();
|
||||||
friend KeyMap & theTopLevelKeymap();
|
friend KeyMap & theTopLevelKeymap();
|
||||||
|
@ -994,7 +994,7 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
|
|||||||
case RC_VIEWER: {
|
case RC_VIEWER: {
|
||||||
string format, command;
|
string format, command;
|
||||||
lexrc >> format >> command;
|
lexrc >> format >> command;
|
||||||
formats.setViewer(format, command);
|
theFormats().setViewer(format, command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RC_FILEFORMAT: {
|
case RC_FILEFORMAT: {
|
||||||
@ -1045,9 +1045,9 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
|
|||||||
if (theConverters().formatIsUsed(format))
|
if (theConverters().formatIsUsed(format))
|
||||||
LYXERR0("Can't delete format " << format);
|
LYXERR0("Can't delete format " << format);
|
||||||
else
|
else
|
||||||
formats.erase(format);
|
theFormats().erase(format);
|
||||||
} else {
|
} else {
|
||||||
formats.add(format, extensions, prettyname,
|
theFormats().add(format, extensions, prettyname,
|
||||||
shortcut, viewer, editor, mime, flgs);
|
shortcut, viewer, editor, mime, flgs);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1227,7 +1227,7 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update converters data-structures
|
/// Update converters data-structures
|
||||||
theConverters().update(formats);
|
theConverters().update(theFormats());
|
||||||
theConverters().buildGraph();
|
theConverters().buildGraph();
|
||||||
theBufferList().invalidateConverterCache();
|
theBufferList().invalidateConverterCache();
|
||||||
|
|
||||||
@ -2558,10 +2558,10 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
|||||||
|
|
||||||
case RC_FILEFORMAT:
|
case RC_FILEFORMAT:
|
||||||
// New/modified formats
|
// New/modified formats
|
||||||
for (Formats::const_iterator cit = formats.begin();
|
for (Formats::const_iterator cit = theFormats().begin();
|
||||||
cit != formats.end(); ++cit) {
|
cit != theFormats().end(); ++cit) {
|
||||||
Format const * format =
|
Format const * format =
|
||||||
system_formats.getFormat(cit->name());
|
theSystemFormats().getFormat(cit->name());
|
||||||
if (!format ||
|
if (!format ||
|
||||||
format->extensions() != cit->extensions() ||
|
format->extensions() != cit->extensions() ||
|
||||||
format->prettyname() != cit->prettyname() ||
|
format->prettyname() != cit->prettyname() ||
|
||||||
@ -2594,9 +2594,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Look for deleted formats
|
// Look for deleted formats
|
||||||
for (Formats::const_iterator cit = system_formats.begin();
|
for (Formats::const_iterator cit = theSystemFormats().begin();
|
||||||
cit != system_formats.end(); ++cit)
|
cit != theSystemFormats().end(); ++cit)
|
||||||
if (!formats.getFormat(cit->name()))
|
if (!theFormats().getFormat(cit->name()))
|
||||||
os << "\\format \"" << cit->name()
|
os << "\\format \"" << cit->name()
|
||||||
<< "\" \"\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
|
<< "\" \"\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
|
||||||
if (tag != RC_LAST)
|
if (tag != RC_LAST)
|
||||||
|
@ -3491,7 +3491,7 @@ void GuiPreferences::applyView()
|
|||||||
bool GuiPreferences::initialiseParams(string const &)
|
bool GuiPreferences::initialiseParams(string const &)
|
||||||
{
|
{
|
||||||
rc_ = lyxrc;
|
rc_ = lyxrc;
|
||||||
formats_ = lyx::formats;
|
formats_ = theFormats();
|
||||||
converters_ = theConverters();
|
converters_ = theConverters();
|
||||||
converters_.update(formats_);
|
converters_.update(formats_);
|
||||||
movers_ = theMovers();
|
movers_ = theMovers();
|
||||||
@ -3522,10 +3522,10 @@ void GuiPreferences::dispatchParams()
|
|||||||
Author(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
|
Author(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
|
||||||
theBufferList().recordCurrentAuthor(author);
|
theBufferList().recordCurrentAuthor(author);
|
||||||
|
|
||||||
lyx::formats = formats_;
|
theFormats() = formats_;
|
||||||
|
|
||||||
theConverters() = converters_;
|
theConverters() = converters_;
|
||||||
theConverters().update(lyx::formats);
|
theConverters().update(formats_);
|
||||||
theConverters().buildGraph();
|
theConverters().buildGraph();
|
||||||
theBufferList().invalidateConverterCache();
|
theBufferList().invalidateConverterCache();
|
||||||
|
|
||||||
|
@ -652,7 +652,7 @@ QVector<GuiWorkArea*> GuiView::GuiViewPrivate::guiWorkAreas()
|
|||||||
static void handleExportStatus(GuiView * view, Buffer::ExportStatus status,
|
static void handleExportStatus(GuiView * view, Buffer::ExportStatus status,
|
||||||
string const & format)
|
string const & format)
|
||||||
{
|
{
|
||||||
docstring const fmt = formats.prettyName(format);
|
docstring const fmt = theFormats().prettyName(format);
|
||||||
docstring msg;
|
docstring msg;
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case Buffer::ExportSuccess:
|
case Buffer::ExportSuccess:
|
||||||
@ -2231,7 +2231,7 @@ static bool import(GuiView * lv, FileName const & filename,
|
|||||||
|
|
||||||
string const tofile =
|
string const tofile =
|
||||||
support::changeExtension(filename.absFileName(),
|
support::changeExtension(filename.absFileName(),
|
||||||
formats.extension(*it));
|
theFormats().extension(*it));
|
||||||
if (!theConverters().convert(0, filename, FileName(tofile),
|
if (!theConverters().convert(0, filename, FileName(tofile),
|
||||||
filename, format, *it, errorList))
|
filename, format, *it, errorList))
|
||||||
return false;
|
return false;
|
||||||
@ -2241,7 +2241,7 @@ static bool import(GuiView * lv, FileName const & filename,
|
|||||||
if (loader_format.empty()) {
|
if (loader_format.empty()) {
|
||||||
frontend::Alert::error(_("Couldn't import file"),
|
frontend::Alert::error(_("Couldn't import file"),
|
||||||
bformat(_("No information for importing the format %1$s."),
|
bformat(_("No information for importing the format %1$s."),
|
||||||
formats.prettyName(format)));
|
theFormats().prettyName(format)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -2259,7 +2259,7 @@ static bool import(GuiView * lv, FileName const & filename,
|
|||||||
bool as_paragraphs = loader_format == "textparagraph";
|
bool as_paragraphs = loader_format == "textparagraph";
|
||||||
string filename2 = (loader_format == format) ? filename.absFileName()
|
string filename2 = (loader_format == format) ? filename.absFileName()
|
||||||
: support::changeExtension(filename.absFileName(),
|
: support::changeExtension(filename.absFileName(),
|
||||||
formats.extension(loader_format));
|
theFormats().extension(loader_format));
|
||||||
lv->currentBufferView()->insertPlaintextFile(FileName(filename2),
|
lv->currentBufferView()->insertPlaintextFile(FileName(filename2),
|
||||||
as_paragraphs);
|
as_paragraphs);
|
||||||
guiApp->setCurrentView(lv);
|
guiApp->setCurrentView(lv);
|
||||||
@ -2288,17 +2288,17 @@ void GuiView::importDocument(string const & argument)
|
|||||||
}
|
}
|
||||||
|
|
||||||
docstring const text = bformat(_("Select %1$s file to import"),
|
docstring const text = bformat(_("Select %1$s file to import"),
|
||||||
formats.prettyName(format));
|
theFormats().prettyName(format));
|
||||||
|
|
||||||
FileDialog dlg(toqstr(text));
|
FileDialog dlg(toqstr(text));
|
||||||
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
||||||
dlg.setButton2(qt_("Examples|#E#e"),
|
dlg.setButton2(qt_("Examples|#E#e"),
|
||||||
toqstr(addPath(package().system_support().absFileName(), "examples")));
|
toqstr(addPath(package().system_support().absFileName(), "examples")));
|
||||||
|
|
||||||
docstring filter = formats.prettyName(format);
|
docstring filter = theFormats().prettyName(format);
|
||||||
filter += " (*.{";
|
filter += " (*.{";
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
filter += from_utf8(formats.extensions(format));
|
filter += from_utf8(theFormats().extensions(format));
|
||||||
filter += "})";
|
filter += "})";
|
||||||
|
|
||||||
FileDialog::Result result =
|
FileDialog::Result result =
|
||||||
@ -2592,7 +2592,7 @@ bool GuiView::exportBufferAs(Buffer & b, docstring const & iformat)
|
|||||||
types << anyformat;
|
types << anyformat;
|
||||||
|
|
||||||
vector<Format const *> export_formats;
|
vector<Format const *> export_formats;
|
||||||
for (Format const & f : formats)
|
for (Format const & f : theFormats())
|
||||||
if (f.documentFormat())
|
if (f.documentFormat())
|
||||||
export_formats.push_back(&f);
|
export_formats.push_back(&f);
|
||||||
sort(export_formats.begin(), export_formats.end(), Format::formatSorter);
|
sort(export_formats.begin(), export_formats.end(), Format::formatSorter);
|
||||||
@ -2625,7 +2625,7 @@ bool GuiView::exportBufferAs(Buffer & b, docstring const & iformat)
|
|||||||
string fmt_name;
|
string fmt_name;
|
||||||
fname.set(fromqstr(result.second));
|
fname.set(fromqstr(result.second));
|
||||||
if (filter == anyformat)
|
if (filter == anyformat)
|
||||||
fmt_name = formats.getFormatFromExtension(fname.extension());
|
fmt_name = theFormats().getFormatFromExtension(fname.extension());
|
||||||
else
|
else
|
||||||
fmt_name = fmap[filter];
|
fmt_name = fmap[filter];
|
||||||
LYXERR(Debug::FILES, "filter=" << fromqstr(filter)
|
LYXERR(Debug::FILES, "filter=" << fromqstr(filter)
|
||||||
|
@ -303,7 +303,7 @@ docstring ViewSourceWidget::currentFormatName(BufferView const * bv) const
|
|||||||
// Compute the actual format used
|
// Compute the actual format used
|
||||||
string const format = !bv ? ""
|
string const format = !bv ? ""
|
||||||
: flavor2format(bv->buffer().params().getOutputFlavor(view_format_));
|
: flavor2format(bv->buffer().params().getOutputFlavor(view_format_));
|
||||||
Format const * f = formats.getFormat(format.empty() ? view_format_ : format);
|
Format const * f = theFormats().getFormat(format.empty() ? view_format_ : format);
|
||||||
return f ? f->prettyname() : from_utf8(view_format_);
|
return f ? f->prettyname() : from_utf8(view_format_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ void ViewSourceWidget::updateDefaultFormat(BufferView const & bv)
|
|||||||
vector<string>::const_iterator en = tmp.end();
|
vector<string>::const_iterator en = tmp.end();
|
||||||
for (; it != en; ++it) {
|
for (; it != en; ++it) {
|
||||||
string const format = *it;
|
string const format = *it;
|
||||||
Format const * fmt = formats.getFormat(format);
|
Format const * fmt = theFormats().getFormat(format);
|
||||||
if (!fmt) {
|
if (!fmt) {
|
||||||
LYXERR0("Can't find format for backend " << format << "!");
|
LYXERR0("Can't find format for backend " << format << "!");
|
||||||
continue;
|
continue;
|
||||||
|
@ -2192,7 +2192,7 @@ void Menus::Impl::expand(MenuDefinition const & frommenu,
|
|||||||
if (!buf)
|
if (!buf)
|
||||||
break;
|
break;
|
||||||
string const format = buf->params().getDefaultOutputFormat();
|
string const format = buf->params().getDefaultOutputFormat();
|
||||||
Format const * f = formats.getFormat(format);
|
Format const * f = theFormats().getFormat(format);
|
||||||
docstring const name = f ? f->prettyname() : from_utf8(format);
|
docstring const name = f ? f->prettyname() : from_utf8(format);
|
||||||
docstring const label = bformat(_("Export [%1$s]|E"), name);
|
docstring const label = bformat(_("Export [%1$s]|E"), name);
|
||||||
MenuItem item(MenuItem::Command, toqstr(label),
|
MenuItem item(MenuItem::Command, toqstr(label),
|
||||||
|
@ -71,8 +71,8 @@ vector<string> const & Cache::loadableFormats() const
|
|||||||
return fmts;
|
return fmts;
|
||||||
|
|
||||||
// The formats recognised by LyX
|
// The formats recognised by LyX
|
||||||
Formats::const_iterator begin = formats.begin();
|
Formats::const_iterator begin = theFormats().begin();
|
||||||
Formats::const_iterator end = formats.end();
|
Formats::const_iterator end = theFormats().end();
|
||||||
|
|
||||||
// The formats natively loadable.
|
// The formats natively loadable.
|
||||||
vector<string> nformat = frontend::loadableImageFormats();
|
vector<string> nformat = frontend::loadableImageFormats();
|
||||||
|
@ -318,10 +318,10 @@ bool CacheItem::Impl::loadImage()
|
|||||||
|
|
||||||
typedef vector<string> FormatList;
|
typedef vector<string> FormatList;
|
||||||
|
|
||||||
static string const findTargetFormat(FormatList const & formats, string const & from)
|
static string const findTargetFormat(FormatList const & format_list, string const & from)
|
||||||
{
|
{
|
||||||
// There must be a format to load from.
|
// There must be a format to load from.
|
||||||
LASSERT(!formats.empty(), return string());
|
LASSERT(!theFormats().empty(), return string());
|
||||||
|
|
||||||
// Use the standard converter if we don't know the format to load
|
// Use the standard converter if we don't know the format to load
|
||||||
// from.
|
// from.
|
||||||
@ -329,15 +329,15 @@ static string const findTargetFormat(FormatList const & formats, string const &
|
|||||||
return string("ppm");
|
return string("ppm");
|
||||||
|
|
||||||
// First ascertain if we can load directly with no conversion
|
// First ascertain if we can load directly with no conversion
|
||||||
FormatList::const_iterator it = formats.begin();
|
FormatList::const_iterator it = format_list.begin();
|
||||||
FormatList::const_iterator end = formats.end();
|
FormatList::const_iterator end = format_list.end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
if (from == *it)
|
if (from == *it)
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
// So, we have to convert to a loadable format. Can we?
|
// So, we have to convert to a loadable format. Can we?
|
||||||
it = formats.begin();
|
it = format_list.begin();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
if (lyx::graphics::Converter::isReachable(from, *it))
|
if (lyx::graphics::Converter::isReachable(from, *it))
|
||||||
return *it;
|
return *it;
|
||||||
@ -364,7 +364,7 @@ bool CacheItem::Impl::tryDisplayFormat(FileName & filename, string & from)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
zipped_ = formats.isZippedFile(filename_);
|
zipped_ = theFormats().isZippedFile(filename_);
|
||||||
if (zipped_) {
|
if (zipped_) {
|
||||||
string tempname = unzippedFileName(filename_.toFilesystemEncoding());
|
string tempname = unzippedFileName(filename_.toFilesystemEncoding());
|
||||||
string const ext = getExtension(tempname);
|
string const ext = getExtension(tempname);
|
||||||
@ -389,7 +389,7 @@ bool CacheItem::Impl::tryDisplayFormat(FileName & filename, string & from)
|
|||||||
<< "\tAttempting to convert image file: " << filename
|
<< "\tAttempting to convert image file: " << filename
|
||||||
<< "\n\twith displayed filename: " << to_utf8(displayed_filename));
|
<< "\n\twith displayed filename: " << to_utf8(displayed_filename));
|
||||||
|
|
||||||
from = formats.getFormatFromFile(filename);
|
from = theFormats().getFormatFromFile(filename);
|
||||||
if (from.empty()) {
|
if (from.empty()) {
|
||||||
status_ = ErrorConverting;
|
status_ = ErrorConverting;
|
||||||
LYXERR(Debug::GRAPHICS, "\tCould not determine file format.");
|
LYXERR(Debug::GRAPHICS, "\tCould not determine file format.");
|
||||||
|
@ -139,7 +139,7 @@ Converter::Impl::Impl(FileName const & doc_fname,
|
|||||||
// The converted image is to be stored in this file (we do not
|
// The converted image is to be stored in this file (we do not
|
||||||
// use ChangeExtension because this is a basename which may
|
// use ChangeExtension because this is a basename which may
|
||||||
// nevertheless contain a '.')
|
// nevertheless contain a '.')
|
||||||
to_file_ = FileName(to_file_base + '.' + formats.extension(to_format));
|
to_file_ = FileName(to_file_base + '.' + theFormats().extension(to_format));
|
||||||
|
|
||||||
// The conversion commands are stored in a stringstream
|
// The conversion commands are stored in a stringstream
|
||||||
ostringstream script;
|
ostringstream script;
|
||||||
|
@ -47,9 +47,9 @@ string const readBB_from_PSFile(FileName const & file)
|
|||||||
// end of the file. Than we have in the header:
|
// end of the file. Than we have in the header:
|
||||||
// %%BoundingBox: (atend)
|
// %%BoundingBox: (atend)
|
||||||
// In this case we must check the end.
|
// In this case we must check the end.
|
||||||
bool const zipped = formats.isZippedFile(file);
|
bool const zipped = theFormats().isZippedFile(file);
|
||||||
FileName const file_ = zipped ? unzipFile(file) : file;
|
FileName const file_ = zipped ? unzipFile(file) : file;
|
||||||
string const format = formats.getFormatFromFile(file_);
|
string const format = theFormats().getFormatFromFile(file_);
|
||||||
|
|
||||||
if (!Formats::isPostScriptFileFormat(format)) {
|
if (!Formats::isPostScriptFileFormat(format)) {
|
||||||
LYXERR(Debug::GRAPHICS, "[readBB_from_PSFile] no(e)ps-format");
|
LYXERR(Debug::GRAPHICS, "[readBB_from_PSFile] no(e)ps-format");
|
||||||
|
@ -51,8 +51,8 @@ Template const * getTemplatePtr(InsetExternalParams const & params)
|
|||||||
|
|
||||||
void editExternal(InsetExternalParams const & params, Buffer const & buffer)
|
void editExternal(InsetExternalParams const & params, Buffer const & buffer)
|
||||||
{
|
{
|
||||||
formats.edit(buffer, params.filename,
|
theFormats().edit(buffer, params.filename,
|
||||||
formats.getFormatFromFile(params.filename));
|
theFormats().getFormatFromFile(params.filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ string const doSubstitution(InsetExternalParams const & params,
|
|||||||
// This is for raster images and pdflatex:
|
// This is for raster images and pdflatex:
|
||||||
// Since pdflatex supports both jpg and png, we choose the best format:
|
// Since pdflatex supports both jpg and png, we choose the best format:
|
||||||
// jpg if the original file is jpg to retain the compression, else png.
|
// jpg if the original file is jpg to retain the compression, else png.
|
||||||
string format = formats.getFormatFromFile(params.filename);
|
string format = theFormats().getFormatFromFile(params.filename);
|
||||||
if (format == "jpg")
|
if (format == "jpg")
|
||||||
result = subst(result, "$$pngOrjpg", "jpg");
|
result = subst(result, "$$pngOrjpg", "jpg");
|
||||||
else
|
else
|
||||||
@ -245,7 +245,7 @@ void updateExternal(InsetExternalParams const & params,
|
|||||||
return; // NOT_NEEDED
|
return; // NOT_NEEDED
|
||||||
|
|
||||||
// Try and ascertain the file format from its contents.
|
// Try and ascertain the file format from its contents.
|
||||||
from_format = formats.getFormatFromFile(params.filename);
|
from_format = theFormats().getFormatFromFile(params.filename);
|
||||||
if (from_format.empty())
|
if (from_format.empty())
|
||||||
return; // FAILURE
|
return; // FAILURE
|
||||||
}
|
}
|
||||||
|
@ -164,8 +164,8 @@ void InsetBibtex::editDatabases() const
|
|||||||
vector<docstring>::const_iterator en = bibfilelist.end();
|
vector<docstring>::const_iterator en = bibfilelist.end();
|
||||||
for (; it != en; ++it) {
|
for (; it != en; ++it) {
|
||||||
FileName const bibfile = getBibTeXPath(*it, buffer());
|
FileName const bibfile = getBibTeXPath(*it, buffer());
|
||||||
formats.edit(buffer(), bibfile,
|
theFormats().edit(buffer(), bibfile,
|
||||||
formats.getFormatFromFile(bibfile));
|
theFormats().getFormatFromFile(bibfile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ string findTargetFormat(string const & format, OutputParams const & runparams)
|
|||||||
|| runparams.flavor == OutputParams::XETEX
|
|| runparams.flavor == OutputParams::XETEX
|
||||||
|| runparams.flavor == OutputParams::LUATEX) {
|
|| runparams.flavor == OutputParams::LUATEX) {
|
||||||
LYXERR(Debug::GRAPHICS, "findTargetFormat: PDF mode");
|
LYXERR(Debug::GRAPHICS, "findTargetFormat: PDF mode");
|
||||||
Format const * const f = formats.getFormat(format);
|
Format const * const f = theFormats().getFormat(format);
|
||||||
// Convert vector graphics to pdf
|
// Convert vector graphics to pdf
|
||||||
if (f && f->vectorFormat())
|
if (f && f->vectorFormat())
|
||||||
return "pdf6";
|
return "pdf6";
|
||||||
@ -119,7 +119,7 @@ string findTargetFormat(string const & format, OutputParams const & runparams)
|
|||||||
}
|
}
|
||||||
// for HTML, we leave the known formats and otherwise convert to png
|
// for HTML, we leave the known formats and otherwise convert to png
|
||||||
if (runparams.flavor == OutputParams::HTML) {
|
if (runparams.flavor == OutputParams::HTML) {
|
||||||
Format const * const f = formats.getFormat(format);
|
Format const * const f = theFormats().getFormat(format);
|
||||||
// Convert vector graphics to svg
|
// Convert vector graphics to svg
|
||||||
if (f && f->vectorFormat() && theConverters().isReachable(format, "svg"))
|
if (f && f->vectorFormat() && theConverters().isReachable(format, "svg"))
|
||||||
return "svg";
|
return "svg";
|
||||||
@ -483,7 +483,7 @@ copyFileIfNeeded(FileName const & file_in, FileName const & file_out)
|
|||||||
// Nothing to do...
|
// Nothing to do...
|
||||||
return make_pair(IDENTICAL_CONTENTS, file_out);
|
return make_pair(IDENTICAL_CONTENTS, file_out);
|
||||||
|
|
||||||
Mover const & mover = getMover(formats.getFormatFromFile(file_in));
|
Mover const & mover = getMover(theFormats().getFormatFromFile(file_in));
|
||||||
bool const success = mover.copy(file_in, file_out);
|
bool const success = mover.copy(file_in, file_out);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
@ -507,7 +507,7 @@ copyToDirIfNeeded(DocFileName const & file, string const & dir)
|
|||||||
return make_pair(IDENTICAL_PATHS, FileName(file_in));
|
return make_pair(IDENTICAL_PATHS, FileName(file_in));
|
||||||
|
|
||||||
string mangled = file.mangledFileName();
|
string mangled = file.mangledFileName();
|
||||||
if (formats.isZippedFile(file)) {
|
if (theFormats().isZippedFile(file)) {
|
||||||
// We need to change _eps.gz to .eps.gz. The mangled name is
|
// We need to change _eps.gz to .eps.gz. The mangled name is
|
||||||
// still unique because of the counter in mangledFileName().
|
// still unique because of the counter in mangledFileName().
|
||||||
// We can't just call mangledFileName() with the zip
|
// We can't just call mangledFileName() with the zip
|
||||||
@ -548,7 +548,7 @@ string const stripExtensionIfPossible(string const & file, string const & to, bo
|
|||||||
{
|
{
|
||||||
// No conversion is needed. LaTeX can handle the graphic file as is.
|
// No conversion is needed. LaTeX can handle the graphic file as is.
|
||||||
// This is true even if the orig_file is compressed.
|
// This is true even if the orig_file is compressed.
|
||||||
string const to_format = formats.getFormat(to)->extension();
|
string const to_format = theFormats().getFormat(to)->extension();
|
||||||
string const file_format = getExtension(file);
|
string const file_format = getExtension(file);
|
||||||
// for latex .ps == .eps
|
// for latex .ps == .eps
|
||||||
if (to_format == file_format ||
|
if (to_format == file_format ||
|
||||||
@ -629,7 +629,7 @@ string InsetGraphics::prepareFile(OutputParams const & runparams) const
|
|||||||
// determine the export format
|
// determine the export format
|
||||||
string const tex_format = flavor2format(runparams.flavor);
|
string const tex_format = flavor2format(runparams.flavor);
|
||||||
|
|
||||||
if (formats.isZippedFile(params().filename)) {
|
if (theFormats().isZippedFile(params().filename)) {
|
||||||
FileName const unzipped_temp_file =
|
FileName const unzipped_temp_file =
|
||||||
FileName(unzippedFileName(temp_file.absFileName()));
|
FileName(unzippedFileName(temp_file.absFileName()));
|
||||||
output_file = unzippedFileName(output_file);
|
output_file = unzippedFileName(output_file);
|
||||||
@ -646,12 +646,12 @@ string InsetGraphics::prepareFile(OutputParams const & runparams) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string const from = formats.getFormatFromFile(temp_file);
|
string const from = theFormats().getFormatFromFile(temp_file);
|
||||||
if (from.empty())
|
if (from.empty())
|
||||||
LYXERR(Debug::GRAPHICS, "\tCould not get file format.");
|
LYXERR(Debug::GRAPHICS, "\tCould not get file format.");
|
||||||
|
|
||||||
string const to = findTargetFormat(from, runparams);
|
string const to = findTargetFormat(from, runparams);
|
||||||
string const ext = formats.extension(to);
|
string const ext = theFormats().extension(to);
|
||||||
LYXERR(Debug::GRAPHICS, "\t we have: from " << from << " to " << to);
|
LYXERR(Debug::GRAPHICS, "\t we have: from " << from << " to " << to);
|
||||||
|
|
||||||
// We're going to be running the exported buffer through the LaTeX
|
// We're going to be running the exported buffer through the LaTeX
|
||||||
@ -893,14 +893,14 @@ string InsetGraphics::prepareHTMLFile(OutputParams const & runparams) const
|
|||||||
if (status == FAILURE)
|
if (status == FAILURE)
|
||||||
return string();
|
return string();
|
||||||
|
|
||||||
string const from = formats.getFormatFromFile(temp_file);
|
string const from = theFormats().getFormatFromFile(temp_file);
|
||||||
if (from.empty()) {
|
if (from.empty()) {
|
||||||
LYXERR(Debug::GRAPHICS, "\tCould not get file format.");
|
LYXERR(Debug::GRAPHICS, "\tCould not get file format.");
|
||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
|
|
||||||
string const to = findTargetFormat(from, runparams);
|
string const to = findTargetFormat(from, runparams);
|
||||||
string const ext = formats.extension(to);
|
string const ext = theFormats().extension(to);
|
||||||
string const orig_file = params().filename.absFileName();
|
string const orig_file = params().filename.absFileName();
|
||||||
string output_file = onlyFileName(temp_file.absFileName());
|
string output_file = onlyFileName(temp_file.absFileName());
|
||||||
LYXERR(Debug::GRAPHICS, "\t we have: from " << from << " to " << to);
|
LYXERR(Debug::GRAPHICS, "\t we have: from " << from << " to " << to);
|
||||||
@ -1030,8 +1030,8 @@ InsetGraphicsParams const & InsetGraphics::params() const
|
|||||||
|
|
||||||
void InsetGraphics::editGraphics(InsetGraphicsParams const & p) const
|
void InsetGraphics::editGraphics(InsetGraphicsParams const & p) const
|
||||||
{
|
{
|
||||||
formats.edit(buffer(), p.filename,
|
theFormats().edit(buffer(), p.filename,
|
||||||
formats.getFormatFromFile(p.filename));
|
theFormats().getFormatFromFile(p.filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,8 +110,8 @@ void InsetHyperlink::viewTarget() const
|
|||||||
{
|
{
|
||||||
if (getParam("type") == "file:") {
|
if (getParam("type") == "file:") {
|
||||||
FileName url = makeAbsPath(to_utf8(getParam("target")), buffer().filePath());
|
FileName url = makeAbsPath(to_utf8(getParam("target")), buffer().filePath());
|
||||||
string const format = formats.getFormatFromFile(url);
|
string const format = theFormats().getFormatFromFile(url);
|
||||||
formats.view(buffer(), url, format);
|
theFormats().view(buffer(), url, format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ void InsetInclude::editIncluded(string const & file)
|
|||||||
lyx::dispatch(fr);
|
lyx::dispatch(fr);
|
||||||
} else
|
} else
|
||||||
// tex file or other text file in verbatim mode
|
// tex file or other text file in verbatim mode
|
||||||
formats.edit(buffer(),
|
theFormats().edit(buffer(),
|
||||||
support::makeAbsPath(file, support::onlyPath(buffer().absFileName())),
|
support::makeAbsPath(file, support::onlyPath(buffer().absFileName())),
|
||||||
"text");
|
"text");
|
||||||
}
|
}
|
||||||
@ -696,7 +696,7 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
|
|||||||
// Don't assume the child's format is latex
|
// Don't assume the child's format is latex
|
||||||
string const inc_format = tmp->params().bufferFormat();
|
string const inc_format = tmp->params().bufferFormat();
|
||||||
FileName const tmpwritefile(changeExtension(writefile.absFileName(),
|
FileName const tmpwritefile(changeExtension(writefile.absFileName(),
|
||||||
formats.extension(inc_format)));
|
theFormats().extension(inc_format)));
|
||||||
|
|
||||||
// FIXME: handle non existing files
|
// FIXME: handle non existing files
|
||||||
// The included file might be written in a different encoding
|
// The included file might be written in a different encoding
|
||||||
|
@ -83,7 +83,12 @@ Messages const & getGuiMessages()
|
|||||||
// Dummy formats support (needed by Lexer)
|
// Dummy formats support (needed by Lexer)
|
||||||
//
|
//
|
||||||
|
|
||||||
Formats formats;
|
|
||||||
|
Formats & theFormats()
|
||||||
|
{
|
||||||
|
static Formats dummy_formats;
|
||||||
|
return dummy_formats;
|
||||||
|
}
|
||||||
|
|
||||||
bool Formats::isZippedFile(support::FileName const&) const
|
bool Formats::isZippedFile(support::FileName const&) const
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user