#include "PDFOptions.h"
#include "SpellChecker.h"
#include "sgml.h"
+#include "texstream.h"
#include "TexRow.h"
#include "Text.h"
#include "TextClass.h"
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;
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();
}
}
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;
}