X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBuffer.cpp;h=1ccb263014651595f417bb099d9ea820c8a4b522;hb=bea9d2f3f774d62aa48fe83ebbefdd0e7d5f85b9;hp=bfb0dbb33dfcf580f10864e223175af585d7c3ee;hpb=3883b85f49054c109cb8a9a293721a5e41edb68d;p=lyx.git diff --git a/src/Buffer.cpp b/src/Buffer.cpp index bfb0dbb33d..1ccb263014 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -664,7 +664,6 @@ void Buffer::cloneWithChildren(BufferMap & bufmap, CloneList_ptr clones) const buffer_clone->setChild(dit, child_clone); } buffer_clone->d->macro_lock = false; - return; } @@ -1357,7 +1356,7 @@ Buffer::ReadStatus Buffer::convertLyXFormat(FileName const & fn, LYXERR(Debug::INFO, "Running '" << command_str << '\''); cmd_ret const ret = runCommand(command_str); - if (ret.first != 0) { + if (!ret.valid) { if (from_format < LYX_FORMAT) { Alert::error(_("Conversion script failed"), bformat(_("%1$s is from an older version" @@ -1549,9 +1548,8 @@ bool Buffer::save() const // time stamp is invalidated by copying/moving saveCheckSum(); markClean(); - if (d->file_format != LYX_FORMAT) - // the file associated with this buffer is now in the current format - d->file_format = LYX_FORMAT; + // the file associated with this buffer is now in the current format + d->file_format = LYX_FORMAT; return true; } // else we saved the file, but failed to move it to the right location. @@ -1905,9 +1903,9 @@ Buffer::ExportStatus Buffer::writeLaTeXSource(otexstream & os, docstring uncodable_glyphs; Encoding const * const enc = runparams.encoding; if (enc) { - for (size_t n = 0; n < inputpath.size(); ++n) { - if (!enc->encodable(inputpath[n])) { - docstring const glyph(1, inputpath[n]); + for (char_type n : inputpath) { + if (!enc->encodable(n)) { + docstring const glyph(1, n); LYXERR0("Uncodable character '" << glyph << "' in input path!"); @@ -2140,40 +2138,39 @@ Buffer::ExportStatus Buffer::writeDocBookSource(odocstream & os, bool const output_body = output == FullSource || output == OnlyBody; - XMLStream xs(os); - if (output_preamble) { - // XML preamble, no doctype needed. + // XML preamble, no doctype needed. // Not using XMLStream for this, as the root tag would be in the tag stack and make troubles with the error // detection mechanisms (these are called before the end tag is output, and thus interact with the canary // parsep in output_docbook.cpp). - os << "\n" + os << "\n" << "\n"; // Directly output the root tag, based on the current type of document. - string languageCode = params().language->code(); + string languageCode = params().language->code(); string params = "xml:lang=\"" + languageCode + '"' + " xmlns=\"http://docbook.org/ns/docbook\"" + " xmlns:xlink=\"http://www.w3.org/1999/xlink\"" + " xmlns:m=\"http://www.w3.org/1998/Math/MathML\"" - + " xmlns:xi=\"http://www.w3.org/2001/XInclude\"" - + " version=\"5.2\""; + + " xmlns:xi=\"http://www.w3.org/2001/XInclude\"" + + " version=\"5.2\""; os << "<" << from_ascii(tclass.docbookroot()) << " " << from_ascii(params) << ">\n"; } if (output_body) { - params().documentClass().counters().reset(); - // Start to output the document. + XMLStream xs(os); docbookParagraphs(text(), *this, xs, runparams); } if (output_preamble) { - // Close the root element. - os << "\n"; + // Close the root element. No need for a line break, as free text is never allowed + // in a root element, it must always be wrapped in some container. + os << ""; } + return ExportSuccess; } @@ -2230,7 +2227,7 @@ Buffer::ExportStatus Buffer::writeLyXHTMLSource(odocstream & os, os << "" << (doctitle.empty() ? from_ascii("LyX Document") : - xml::xmlize(doctitle, XMLStream::ESCAPE_ALL)) + xml::escapeString(doctitle, XMLStream::ESCAPE_ALL)) << "\n"; docstring styles = features.getTClassHTMLPreamble(); @@ -4012,10 +4009,7 @@ InsetLabel const * Buffer::insetLabel(docstring const & label, bool Buffer::activeLabel(docstring const & label) const { - if (!insetLabel(label, true)) - return false; - - return true; + return insetLabel(label, true) != nullptr; } @@ -4414,7 +4408,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir // Only show this alert if this is an export to a non-temporary // file (not for previewing). docstring s = bformat(_("No information for exporting the format %1$s."), - theFormats().prettyName(format)); + translateIfPossible(theFormats().prettyName(format))); if (format == "pdf4") s += "\n" + bformat(_("Hint: use non-TeX fonts or set input encoding " @@ -4470,7 +4464,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir // DocBook backend else if (backend_format == "docbook5") { runparams.flavor = OutputParams::DOCBOOK5; - runparams.nice = !put_in_tempdir; + runparams.nice = false; if (makeDocBookFile(FileName(filename), runparams) == ExportKilled) return ExportKilled; } @@ -4612,13 +4606,13 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir } else { message(bformat(_("Document exported as %1$s " "to file `%2$s'"), - theFormats().prettyName(format), + translateIfPossible(theFormats().prettyName(format)), makeDisplayPath(result_file))); } } else { // This must be a dummy converter like fax (bug 1888) message(bformat(_("Document exported as %1$s"), - theFormats().prettyName(format))); + translateIfPossible(theFormats().prettyName(format)))); } return success ? ExportSuccess : ExportConverterError; @@ -5242,11 +5236,6 @@ void Buffer::updateBuffer(ParIterator & parit, UpdateType utype, bool const dele // to resolve macros in it. parit.text()->setMacrocontextPosition(parit); - // Reset bibitem counter in master (#8499) - Buffer const * const master = masterBuffer(); - if (master == this && !d->ignore_parent) - master->params().documentClass().counters().reset(from_ascii("bibitem")); - depth_type maxdepth = 0; pit_type const lastpit = parit.lastpit(); bool changed = false; @@ -5367,8 +5356,11 @@ void Buffer::Impl::updateStatistics(DocIterator & from, DocIterator & to, bool s ++word_count_; inword = true; } - if (ins && ins->isLetter()) - ++char_count_; + if (ins && ins->isLetter()) { + odocstringstream os; + ins->toString(os); + char_count_ += os.str().length(); + } else if (ins && ins->isSpace()) ++blank_count_; else {