Backport fix for #7652, so that we show backends, not formats, in the

View>Source combo.
This commit is contained in:
Richard Heck 2012-06-29 10:37:02 -04:00
parent 0c8ac6444e
commit 7e4a2ae1e8
6 changed files with 45 additions and 18 deletions

View File

@ -33,6 +33,12 @@ http://www.lyx.org
What's new in LyX 2.0.5 What's new in LyX 2.0.5
======================= =======================
The View>Source widget now allows you to select the backend to display,
e.g., LaTeX or XHTML, rather than the output format. The previous choice
really made no sense: You didn't see a PDF there if you chose one of the
PDF output formats, but rather LaTeX. This solves some long-standing issues
with View>Source.
What's new What's new
========== ==========

View File

@ -3225,6 +3225,12 @@ void Buffer::getSourceCode(odocstream & os, string const format,
else if (runparams.flavor == OutputParams::HTML) { else if (runparams.flavor == OutputParams::HTML) {
XHTMLStream xs(os); XHTMLStream xs(os);
xhtmlParagraphs(text(), *this, xs, runparams); xhtmlParagraphs(text(), *this, xs, runparams);
} else if (runparams.flavor == OutputParams::TEXT) {
bool dummy;
// FIXME Handles only one paragraph, unlike the others.
// Probably should have some routine with a signature like them.
writePlaintextParagraph(*this,
text().paragraphs()[par_begin], os, runparams, dummy);
} else { } else {
// latex or literate // latex or literate
otexstream ots(os, texrow); otexstream ots(os, texrow);

View File

@ -2130,17 +2130,24 @@ bool BufferParams::isExportableFormat(string const & format) const
vector<string> BufferParams::backends() const vector<string> BufferParams::backends() const
{ {
vector<string> v; vector<string> v;
v.push_back(bufferFormat()); string const buffmt = bufferFormat();
// FIXME: Don't hardcode format names here, but use a flag // FIXME: Don't hardcode format names here, but use a flag
if (v.back() == "latex") { if (buffmt == "latex") {
v.push_back("pdflatex"); if (!useNonTeXFonts) {
v.push_back("pdflatex");
v.push_back("latex");
}
v.push_back("luatex"); v.push_back("luatex");
v.push_back("dviluatex"); v.push_back("dviluatex");
v.push_back("xetex"); v.push_back("xetex");
} else if (v.back() == "xetex") { } else if (buffmt == "xetex") {
v.push_back("xetex");
v.push_back("luatex"); v.push_back("luatex");
v.push_back("dviluatex"); v.push_back("dviluatex");
} } else
v.push_back(buffmt);
v.push_back("xhtml"); v.push_back("xhtml");
v.push_back("text"); v.push_back("text");
v.push_back("lyx"); v.push_back("lyx");
@ -2162,6 +2169,8 @@ OutputParams::FLAVOR BufferParams::getOutputFlavor(string const format) const
if (dformat == "xhtml") if (dformat == "xhtml")
result = OutputParams::HTML; result = OutputParams::HTML;
else if (dformat == "text")
result = OutputParams::TEXT;
else { else {
// Try to determine flavor of default output format // Try to determine flavor of default output format
vector<string> backs = backends(); vector<string> backs = backends();

View File

@ -176,7 +176,8 @@ public:
std::vector<Format const *> exportableFormats(bool only_viewable) const; std::vector<Format const *> exportableFormats(bool only_viewable) const;
/// ///
bool isExportableFormat(std::string const & format) const; bool isExportableFormat(std::string const & format) const;
/// /// the backends appropriate for use with this document.
/// so, e.g., latex is excluded , if we're using non-TeX fonts
std::vector<std::string> backends() const; std::vector<std::string> backends() const;
/// List of included children (for includeonly) /// List of included children (for includeonly)

View File

@ -197,19 +197,23 @@ void ViewSourceWidget::updateDefaultFormat()
outputFormatCO->addItem(qt_("Default"), outputFormatCO->addItem(qt_("Default"),
QVariant(QString("default"))); QVariant(QString("default")));
int index = 0; vector<string> tmp = bv_->buffer().params().backends();
typedef vector<Format const *> Formats; vector<string>::const_iterator it = tmp.begin();
Formats formats = bv_->buffer().params().exportableFormats(true); vector<string>::const_iterator en = tmp.end();
Formats::const_iterator cit = formats.begin(); for (; it != en; ++it) {
Formats::const_iterator end = formats.end(); string const format = *it;
for (; cit != end; ++cit) { Format const * fmt = formats.getFormat(format);
QString const fname = toqstr((*cit)->name()); if (!fmt)
outputFormatCO->addItem(qt_((*cit)->prettyname()), LYXERR0("Can't find format for backend " << format << "!");
QVariant(fname)); else if (fmt->name() == "lyx")
if (fname == view_format_) // we can't presently display the LyX format itself
index = outputFormatCO->count() -1; continue;
QString const pretty =
fmt ? qt_(fmt->prettyname()) : toqstr(format);
outputFormatCO->addItem(pretty, QVariant(toqstr(format)));
} }
outputFormatCO->setCurrentIndex(index);
outputFormatCO->blockSignals(false); outputFormatCO->blockSignals(false);
} }

View File

@ -36,6 +36,7 @@ What's new
* USER INTERFACE * USER INTERFACE
- Show backends, not formats, in View>Source (bug #7652).
* DOCUMENTATION AND LOCALIZATION * DOCUMENTATION AND LOCALIZATION