#include "PDFOptions.h"
#include "SpellChecker.h"
#include "sgml.h"
+#include "texstream.h"
#include "TexRow.h"
#include "Text.h"
#include "TextClass.h"
#include "support/types.h"
#include "support/bind.h"
-#include "support/shared_ptr.h"
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <map>
+#include <memory>
#include <set>
#include <sstream>
#include <vector>
/// positions of child buffers in the buffer
typedef map<Buffer const * const, DocIterator> BufferPositionMap;
struct ScopeBuffer {
- ScopeBuffer() {}
- ScopeBuffer(DocIterator const & s,Buffer const * b)
+ ScopeBuffer() : buffer(0) {}
+ ScopeBuffer(DocIterator const & s, Buffer const * b)
: scope(s), buffer(b) {}
DocIterator scope;
Buffer const * buffer;
{
OutputParams runparams = runparams_in;
- // XeTeX with TeX fonts is only safe with ASCII encoding,
- // but the "flavor" is not known in BufferParams::encoding().
- if (!params().useNonTeXFonts && (runparams.flavor == OutputParams::XETEX))
+ // XeTeX with TeX fonts is only safe with ASCII encoding (see also #9740),
+ // Check here, because the "flavor" is not known in BufferParams::encoding()
+ // (power users can override this safety measure selecting "utf8-plain").
+ if (!params().useNonTeXFonts && (runparams.flavor == OutputParams::XETEX)
+ && (runparams.encoding->name() != "utf8-plain"))
runparams.encoding = encodings.fromLyXName("ascii");
string const encoding = runparams.encoding->iconvName();
ErrorList & errorList = d->errorLists["Export"];
errorList.clear();
bool failed_export = false;
- otexstream os(ofs, d->texrow);
+ otexstream os(ofs);
// make sure we are ready to export
// this needs to be done before we validate
updateMacroInstances(OutputUpdate);
try {
- os.texrow().reset();
writeLaTeXSource(os, original_path, runparams, output);
}
catch (EncodingException const & e) {
lyx_exit(1);
}
+ d->texrow = move(os.texrow());
+
ofs.close();
if (ofs.fail()) {
failed_export = true;
OutputParams runparams = runparams_in;
// XeTeX with TeX fonts is only safe with ASCII encoding,
- // but the "flavor" is not known in BufferParams::encoding().
- if (!params().useNonTeXFonts && (runparams.flavor == OutputParams::XETEX))
+ // Check here, because the "flavor" is not known in BufferParams::encoding()
+ // (power users can override this safety measure selecting "utf8-plain").
+ if (!params().useNonTeXFonts && (runparams.flavor == OutputParams::XETEX)
+ && (runparams.encoding->name() != "utf8-plain"))
runparams.encoding = encodings.fromLyXName("ascii");
// FIXME: when only the current paragraph is shown, this is ignored
// (or not reached) and characters encodable in the current
if (output_body) {
bool const output_body_tag = (output != IncludedFile);
if (output_body_tag)
- os << "<body>\n";
+ os << "<body dir=\"auto\">\n";
XHTMLStream xs(os);
if (output != IncludedFile)
// if we're an included file, the counters are in the master.
if (!features.runparams().is_child)
params().validate(features);
- for_each(paragraphs().begin(), paragraphs().end(),
- bind(&Paragraph::validate, _1, ref(features)));
+ for (Paragraph const & p : paragraphs())
+ p.validate(features);
if (lyxerr.debugging(Debug::LATEX)) {
features.showStruct();
LaTeXFeatures features(*this, params(), runparams);
params().validate(features);
runparams.use_polyglossia = features.usePolyglossia();
- texrow = make_unique<TexRow>();
- texrow->newline();
- texrow->newline();
// latex or literate
- otexstream ots(os, *texrow);
-
+ otexstream ots(os);
+ // output above
+ ots.texrow().newlines(2);
// the real stuff
latexParagraphs(*this, text(), ots, runparams);
+ texrow = ots.releaseTexRow();
texrow->finalize();
// Restore the parenthood
writeDocBookSource(os, absFileName(), runparams, output);
} else {
// latex or literate
- texrow = make_unique<TexRow>();
- texrow->newline();
- texrow->newline();
- otexstream ots(os, *texrow);
+ otexstream ots(os);
+ // output above
+ ots.texrow().newlines(2);
if (master)
runparams.is_child = true;
writeLaTeXSource(ots, string(), runparams, output);
+ texrow = ots.releaseTexRow();
texrow->finalize();
}
}
///
virtual shared_ptr<ForkedProcess> clone() const
{
- return shared_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
+ return make_shared<AutoSaveBuffer>(*this);
}
///
int start()
ExportStatus const status = doExport(format, true, false, result_file);
FileName const previewFile(result_file);
- LATTEST (isClone());
- d->cloned_buffer_->d->preview_file_ = previewFile;
- d->cloned_buffer_->d->preview_format_ = format;
- d->cloned_buffer_->d->preview_error_ = (status != ExportSuccess);
+ Impl * theimpl = isClone() ? d->cloned_buffer_->d : d;
+ theimpl->preview_file_ = previewFile;
+ theimpl->preview_format_ = format;
+ theimpl->preview_error_ = (status != ExportSuccess);
if (status != ExportSuccess)
return status;
- if (previewFile.exists()) {
- if (!formats.view(*this, previewFile, format))
- return PreviewError;
- else
- return PreviewSuccess;
- }
- else {
- // Successful export but no output file?
- // Probably a bug in error detection.
- LATTEST (status != ExportSuccess);
- return status;
- }
+ if (previewFile.exists())
+ return formats.view(*this, previewFile, format) ?
+ PreviewSuccess : PreviewError;
+
+ // Successful export but no output file?
+ // Probably a bug in error detection.
+ LATTEST(status != ExportSuccess);
+ return status;
}
if (!it[i].inset().inMathed())
depth += it[i].paragraph().getDepth() + 1;
// remove 1 since the outer inset does not count
+ // we should have at least one non-math inset, so
+ // depth should nevery be 0. but maybe it is worth
+ // marking this, just in case.
+ LATTEST(depth > 0);
+ // coverity[INTEGER_OVERFLOW]
return depth - 1;
}