#include "pariterator.h"
#include "sgml.h"
#include "texrow.h"
+#include "TocBackend.h"
#include "undo.h"
#include "version.h"
namespace {
-int const LYX_FORMAT = 252;
+int const LYX_FORMAT = 254;
} // namespace anon
///
MacroTable macros;
+
+ ///
+ TocBackend toc_backend;
};
Buffer::Impl::Impl(Buffer & parent, string const & file, bool readonly_)
: lyx_clean(true), bak_clean(true), unnamed(false), read_only(readonly_),
- filename(file), file_fully_loaded(false),
- inset(params)
+ filename(file), file_fully_loaded(false), inset(params),
+ toc_backend(&parent)
{
inset.setAutoBreakRows(true);
lyxvc.buffer(&parent);
}
+TocBackend & Buffer::tocBackend()
+{
+ return pimpl_->toc_backend;
+}
+
+
+TocBackend const & Buffer::tocBackend() const
+{
+ return pimpl_->toc_backend;
+}
+
+
string const Buffer::getLatexName(bool const no_path) const
{
string const name = changeExtension(makeLatexName(fileName()), ".tex");
}
space_inserted = true;
}
-/* FIXME: not needed anymore?
} else if (!isPrintable(*cit)) {
// Ignore unprintables
continue;
-*/
} else {
// just insert the character
par.insertChar(pos, *cit, font, params().trackChanges);
}
-void Buffer::makeLaTeXFile(string const & fname,
+bool Buffer::makeLaTeXFile(string const & fname,
string const & original_path,
OutputParams const & runparams,
bool output_preamble, bool output_body)
{
- lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
+ string encoding;
+ if (params().inputenc == "auto")
+ encoding = params().language->encoding()->iconvName();
+ else {
+ Encoding const * enc = encodings.getFromLaTeXName(params().inputenc);
+ if (enc)
+ encoding = enc->iconvName();
+ else {
+ lyxerr << "Unknown inputenc value `"
+ << params().inputenc
+ << "'. Using `auto' instead." << endl;
+ encoding = params().language->encoding()->iconvName();
+ }
+ }
+ lyxerr[Debug::LATEX] << "makeLaTeXFile encoding: "
+ << encoding << "..." << endl;
- // FIXME UNICODE
- // This creates an utf8 encoded file, but the inputenc commands
- // specify other encodings
- odocfstream ofs;
+ odocfstream ofs(encoding);
if (!openFileWrite(ofs, fname))
- return;
+ return false;
- writeLaTeXSource(ofs, original_path,
+ try {
+ writeLaTeXSource(ofs, original_path,
runparams, output_preamble, output_body);
+ }
+ catch (iconv_codecvt_facet_exception &) {
+ Alert::error(_("Encoding error"),
+ _("Some characters of your document are not "
+ "representable in the chosen encoding.\n"
+ "Changing the document encoding to utf8 could help."));
+ return false;
+ }
ofs.close();
- if (ofs.fail())
+ if (ofs.fail()) {
lyxerr << "File '" << fname << "' was not closed properly." << endl;
+ Alert::error(_("Error closing file"),
+ _("The output file could not be closed properly.\n"
+ " Probably some characters of your document are not "
+ "representable in the chosen encoding.\n"
+ "Changing the document encoding to utf8 could help."));
+ return false;
+ }
+ return true;
}
features.require("dvipost");
// AMS Style is at document level
- if (params().use_amsmath == BufferParams::AMS_ON
+ if (params().use_amsmath == BufferParams::package_on
|| tclass.provides(LyXTextClass::amsmath))
features.require("amsmath");
+ if (params().use_esint == BufferParams::package_on)
+ features.require("esint");
for_each(paragraphs().begin(), paragraphs().end(),
boost::bind(&Paragraph::validate, _1, boost::ref(features)));
}
+docstring const Buffer::translateLabel(docstring const & label) const
+{
+ if (support::isAscii(label))
+ // Probably standard layout, try to translate
+ return B_(to_ascii(label));
+ else
+ // This must be a user defined layout. We can not translate
+ // this, since gettext accepts only ascii keys.
+ return label;
+}
+
+
bool Buffer::isClean() const
{
return pimpl_->lyx_clean;
} else
getLabelList(labels);
- // FIXME UNICODE
if (lyx::count(labels.begin(), labels.end(), from) > 1)
return;