void Buffer::getSourceCode(odocstream & os, pit_type par_begin,
- pit_type par_end, bool full_source) const
+ pit_type par_end, bool full_source)
{
OutputParams runparams(¶ms().encoding());
runparams.nice = true;
- runparams.flavor = params().useNonTeXFonts ?
- OutputParams::XETEX : OutputParams::LATEX;
+ runparams.flavor = getDefaultOutputFlavor();
runparams.linelen = lyxrc.plaintext_linelen;
// No side effect of file copying and image conversion
runparams.dryrun = true;
d->texrow.newline();
if (isDocBook())
writeDocBookSource(os, absFileName(), runparams, false);
+ else if (runparams.flavor == OutputParams::HTML)
+ writeLyXHTMLSource(os, runparams, false);
else
// latex or literate
writeLaTeXSource(os, string(), runparams, true, true);
// output paragraphs
if (isDocBook())
docbookParagraphs(text(), *this, os, runparams);
- else
+ else if (runparams.flavor == OutputParams::HTML) {
+ XHTMLStream xs(os);
+ xhtmlParagraphs(text(), *this, xs, runparams);
+ } else
// latex or literate
latexParagraphs(*this, text(), os, texrow, runparams);
}
}
+OutputParams::FLAVOR Buffer::getDefaultOutputFlavor()
+{
+ string const dformat = getDefaultOutputFormat();
+ DefaultFlavorCache::const_iterator it =
+ default_flavors_.find(dformat);
+
+ if (it != default_flavors_.end())
+ return it->second;
+
+ OutputParams::FLAVOR result = OutputParams::LATEX;
+
+ if (dformat == "xhtml")
+ result = OutputParams::HTML;
+ else {
+ // Try to determine flavor of default output format
+ vector<string> backs = backends();
+ if (find(backs.begin(), backs.end(), dformat) == backs.end()) {
+ // Get shortest path to format
+ Graph::EdgePath path;
+ for (vector<string>::const_iterator it = backs.begin();
+ it != backs.end(); ++it) {
+ Graph::EdgePath p = theConverters().getPath(*it, dformat);
+ if (!p.empty() && (path.empty() || p.size() < path.size())) {
+ path = p;
+ }
+ }
+ if (!path.empty())
+ result = theConverters().getFlavor(path);
+ }
+ }
+ // cache this flavor
+ default_flavors_[dformat] = result;
+ return result;
+}
+
+
namespace {
// helper class, to guarantee this gets reset properly
class MarkAsExporting {
#define BUFFER_H
#include "OutputEnums.h"
+#include "OutputParams.h"
#include "insets/InsetCode.h"
#include "support/strfwd.h"
#include "support/types.h"
+#include <map>
#include <list>
#include <set>
#include <string>
/// get source code (latex/docbook) for some paragraphs, or all paragraphs
/// including preamble
void getSourceCode(odocstream & os, pit_type par_begin, pit_type par_end,
- bool full_source) const;
+ bool full_source);
/// Access to error list.
/// This method is used only for GUI visualisation of Buffer related
std::string bufferFormat() const;
/// return the default output format of the current backend
std::string getDefaultOutputFormat() const;
+ /// return the default output flavor
+ OutputParams::FLAVOR getDefaultOutputFlavor();
///
bool doExport(std::string const & format, bool put_in_tempdir,
void setFileName(support::FileName const & fname);
///
std::vector<std::string> backends() const;
+ /// A cache for the default flavors
+ typedef std::map<std::string, OutputParams::FLAVOR> DefaultFlavorCache;
+ ///
+ DefaultFlavorCache default_flavors_;
///
void getLanguages(std::set<Language const *> &) const;
/// Checks whether any of the referenced bibfiles have changed since the