X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBuffer.cpp;h=77ef949a5325715b8c5ee93cd5e683d04f951c68;hb=07dcb1c525435c6f22de4314ba31150c53502429;hp=12e3400f7c2ee402308bd17f9a81878e596c9a93;hpb=7aa6f972da50cab0588a76bc62a8c3216fa97107;p=lyx.git
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 12e3400f7c..77ef949a53 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -57,6 +57,7 @@
#include "PDFOptions.h"
#include "SpellChecker.h"
#include "sgml.h"
+#include "texstream.h"
#include "TexRow.h"
#include "Text.h"
#include "TextClass.h"
@@ -1684,7 +1685,7 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
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
@@ -1694,7 +1695,6 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
updateMacroInstances(OutputUpdate);
try {
- os.texrow().reset();
writeLaTeXSource(os, original_path, runparams, output);
}
catch (EncodingException const & e) {
@@ -1725,6 +1725,8 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
lyx_exit(1);
}
+ d->texrow = move(os.texrow());
+
ofs.close();
if (ofs.fail()) {
failed_export = true;
@@ -2150,7 +2152,7 @@ void Buffer::writeLyXHTMLSource(odocstream & os,
if (output_body) {
bool const output_body_tag = (output != IncludedFile);
if (output_body_tag)
- os << "
\n";
+ os << "\n";
XHTMLStream xs(os);
if (output != IncludedFile)
// if we're an included file, the counters are in the master.
@@ -2218,8 +2220,8 @@ void Buffer::validate(LaTeXFeatures & features) const
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();
@@ -3715,14 +3717,13 @@ unique_ptr Buffer::getSourceCode(odocstream & os, string const & format,
LaTeXFeatures features(*this, params(), runparams);
params().validate(features);
runparams.use_polyglossia = features.usePolyglossia();
- texrow = make_unique();
- 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
@@ -3758,13 +3759,13 @@ unique_ptr Buffer::getSourceCode(odocstream & os, string const & format,
writeDocBookSource(os, absFileName(), runparams, output);
} else {
// latex or literate
- texrow = make_unique();
- 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();
}
}
@@ -4314,26 +4315,22 @@ Buffer::ExportStatus Buffer::preview(string const & format, bool includeall) con
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;
}