formats.getNumber(to));
}
-
-/// The global instance
-Converters converters;
-
-// The global copy after reading lyxrc.defaults
-Converters system_converters;
-
-
} // namespace lyx
Graph G_;
};
-extern Converters converters;
-
-extern Converters system_converters;
+/// The global instance.
+/// Implementation is in lyx_main.C.
+extern Converters & theConverters();
+/// The global copy after reading lyxrc.defaults.
+/// Implementation is in lyx_main.C.
+extern Converters & theSystemConverters();
} // namespace lyx
// which returns the shortest path from one of the formats in 'from'
// to 'to'.
if ((format == "lyx13x" || format == "lyx14x") &&
- !converters.getPath("lyx", format).empty())
+ !theConverters().getPath("lyx", format).empty())
backend_format = "lyx";
else if (find(backends.begin(), backends.end(), format) == backends.end()) {
for (vector<string>::const_iterator it = backends.begin();
it != backends.end(); ++it) {
- Graph::EdgePath p = converters.getPath(*it, format);
+ Graph::EdgePath p = theConverters().getPath(*it, format);
if (!p.empty()) {
- runparams.flavor = converters.getFlavor(p);
+ runparams.flavor = theConverters().getFlavor(p);
backend_format = *it;
break;
}
string const error_type = (format == "program")? "Build" : bufferFormat(*buffer);
string const ext = formats.extension(format);
FileName const tmp_result_file(changeExtension(filename, ext));
- bool const success = converters.convert(buffer, FileName(filename),
+ bool const success = theConverters().convert(buffer, FileName(filename),
tmp_result_file, FileName(buffer->fileName()), backend_format, format,
buffer->errorList(error_type));
// Emit the signal to show the error list.
vector<string> backends = Backends(buffer);
for (vector<string>::const_iterator it = backends.begin();
it != backends.end(); ++it)
- if (converters.isReachable(*it, format))
+ if (theConverters().isReachable(*it, format))
return true;
return false;
}
{
vector<string> backends = Backends(buffer);
vector<Format const *> result =
- converters.getReachable(backends[0], only_viewable, true);
+ theConverters().getReachable(backends[0], only_viewable, true);
for (vector<string>::const_iterator it = backends.begin() + 1;
it != backends.end(); ++it) {
vector<Format const *> r =
- converters.getReachable(*it, only_viewable, false);
+ theConverters().getReachable(*it, only_viewable, false);
result.insert(result.end(), r.begin(), r.end());
}
return result;
{
rc_ = lyxrc;
formats_ = lyx::formats;
- converters_ = lyx::converters;
+ converters_ = theConverters();
converters_.update(formats_);
movers_ = lyx::movers;
colors_.clear();
lyx::formats = formats_;
- lyx::converters = converters_;
- lyx::converters.update(lyx::formats);
- lyx::converters.buildGraph();
+ theConverters() = converters_;
+ theConverters().update(lyx::formats);
+ theConverters().buildGraph();
lyx::movers = movers_;
// for the internal lyx-view and external latex run
string const name = fo_it->name();
if (name != "eps" && name != "xpm" && name != "png" &&
- converters.isReachable(*ex_it, name))
+ theConverters().isReachable(*ex_it, name))
to.push_back(&(*fo_it));
}
}
bool Converter::isReachable(string const & from_format_name,
string const & to_format_name)
{
- return converters.isReachable(from_format_name, to_format_name);
+ return theConverters().isReachable(from_format_name, to_format_name);
}
EdgePath const edgepath = from_format.empty() ?
EdgePath() :
- converters.getPath(from_format, to_format);
+ theConverters().getPath(from_format, to_format);
// Create a temporary base file-name for all intermediate steps.
// Remember to remove the temp file because we only want the name...
EdgePath::const_iterator end = edgepath.end();
for (; it != end; ++it) {
- lyx::Converter const & conv = converters.get(*it);
+ lyx::Converter const & conv = theConverters().get(*it);
// Build the conversion command
string const infile = outfile;
if (from == to)
continue;
- lyx::Converter const * ptr = lyx::converters.getConverter(from, to);
+ lyx::Converter const * ptr = lyx::theConverters().getConverter(from, to);
if (ptr)
return ptr;
}
if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
for (vector<string>::const_iterator it = loaders.begin();
it != loaders.end(); ++it) {
- if (converters.isReachable(format, *it)) {
+ if (theConverters().isReachable(format, *it)) {
string const tofile =
changeExtension(filename.absFilename(),
formats.extension(*it));
- if (!converters.convert(0, filename, FileName(tofile),
+ if (!theConverters().convert(0, filename, FileName(tofile),
filename, format, *it, errorList))
return false;
loader_format = *it;
{
vector<string> loaders = Loaders();
vector<Format const *> result =
- converters.getReachableTo(loaders[0], true);
+ theConverters().getReachableTo(loaders[0], true);
for (vector<string>::const_iterator it = loaders.begin() + 1;
it != loaders.end(); ++it) {
vector<Format const *> r =
- converters.getReachableTo(*it, false);
+ theConverters().getReachableTo(*it, false);
result.insert(result.end(), r.begin(), r.end());
}
return result;
if (to_format.empty())
return; // NOT_NEEDED
- if (!converters.isReachable(from_format, to_format)) {
+ if (!theConverters().isReachable(from_format, to_format)) {
lyxerr[Debug::EXTERNAL]
<< "external::updateExternal. "
<< "Unable to convert from "
// FIXME (Abdel 12/08/06): Is there a need to show these errors?
ErrorList el;
/* bool const success = */
- converters.convert(&buffer, temp_file, abs_to_file,
+ theConverters().convert(&buffer, temp_file, abs_to_file,
params.filename, from_format, to_format, el,
Converters::try_default | Converters::try_cache);
// return success
// FIXME (Abdel 12/08/06): Is there a need to show these errors?
ErrorList el;
- if (converters.convert(&buf, temp_file, to_file, params().filename,
+ if (theConverters().convert(&buf, temp_file, to_file, params().filename,
from, to, el,
Converters::try_default | Converters::try_cache)) {
runparams.exportdata->addExternalFile(tex_format,
{
Singletons(): iconv(ucs4_codeset, "UTF-8")
{
+ // Set the default User Interface language as soon as possible.
+ // The language used will be derived from the environment
+ // variables.
+ messages_["GUI"] = Messages();
}
/// our function handler
LyXFunc lyxfunc_;
/// Files to load at start.
vector<FileName> files_to_load_;
- ///
+ /// The messages translators.
map<string, Messages> messages_;
+
+ /// The file converters.
+ Converters converters_;
+
+ // The system converters copy after reading lyxrc.defaults.
+ Converters system_converters_;
};
///
}
+Converters & LyX::converters()
+{
+ return pimpl_->converters_;
+}
+
+
+Converters & LyX::systemConverters()
+{
+ return pimpl_->system_converters_;
+}
+
+
IconvProcessor & LyX::iconvProcessor()
{
return pimpl_->iconv;
if (!readRcFile("lyxrc.dist"))
return false;
- // Set the User Interface language.
- pimpl_->messages_["GUI"] = Messages();
+ // Set the language defined by the distributor.
+ //setGuiLanguage(lyxrc.gui_language);
// Set the PATH correctly.
#if !defined (USE_POSIX_PACKAGING)
system_lyxrc = lyxrc;
system_formats = formats;
- system_converters = converters;
+ pimpl_->system_converters_ = pimpl_->converters_;
system_movers = movers;
system_lcolor = lcolor;
return false;
if (use_gui) {
+ // Set the language defined by the user.
+ //setGuiLanguage(lyxrc.gui_language);
+
// Set up bindings
pimpl_->toplevel_keymap_.reset(new kb_keymap);
defaultKeyBindings(pimpl_->toplevel_keymap_.get());
}
+Converters & theConverters()
+{
+ return LyX::ref().converters();
+}
+
+
+Converters & theSystemConverters()
+{
+ return LyX::ref().systemConverters();
+}
+
+
IconvProcessor & utf8ToUcs4()
{
return LyX::ref().iconvProcessor();
class Buffer;
class BufferList;
+class Converters;
class ErrorItem;
class IconvProcessor;
class InsetBase;
///
kb_keymap & topLevelKeymap();
kb_keymap const & topLevelKeymap() const;
+
+ ///
+ Converters & converters();
+ Converters & systemConverters();
///
Messages & getMessages(std::string const & language);
flags = lexrc.getString();
}
if (command.empty()) {
- converters.erase(from, to);
+ theConverters().erase(from, to);
} else {
- converters.add(from, to, command, flags);
+ theConverters().add(from, to, command, flags);
}
break;
}
<< format << "'." << endl;
}
if (prettyname.empty()) {
- if (converters.formatIsUsed(format)) {
+ if (theConverters().formatIsUsed(format)) {
lyxerr << "Can't delete format "
<< format << endl;
} else {
}
/// Update converters data-structures
- converters.update(formats);
- converters.buildGraph();
+ theConverters().update(formats);
+ theConverters().buildGraph();
return 0;
}
case RC_CONVERTER:
// Look for new converters
- for (Converters::const_iterator cit = converters.begin();
- cit != converters.end(); ++cit) {
+ for (Converters::const_iterator cit = theConverters().begin();
+ cit != theConverters().end(); ++cit) {
Converter const * converter =
- system_converters.getConverter(cit->from,
+ theSystemConverters().getConverter(cit->from,
cit->to);
if (!converter ||
converter->command != cit->command ||
}
// New/modifed converters
- for (Converters::const_iterator cit = system_converters.begin();
- cit != system_converters.end(); ++cit)
- if (!converters.getConverter(cit->from, cit->to))
+ for (Converters::const_iterator cit = theSystemConverters().begin();
+ cit != theSystemConverters().end(); ++cit)
+ if (!theConverters().getConverter(cit->from, cit->to))
os << "\\converter \"" << cit->from
<< "\" \"" << cit->to << "\" \"\" \"\"\n";