From e2309ca098ced6048429d511e726dc45e3147d09 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sun, 28 Nov 2010 12:27:52 +0000 Subject: [PATCH] Fix bug #6853 (Short titles ignored when InPreamble is set to 1 in layout file) The fix includes required arguments and LaTeXParam, too. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36552 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Paragraph.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 859a01835d..3eb13ec0d1 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1332,16 +1332,27 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const BufferParams const & bp = buf.params(); Font f; TexRow tr; + // Using a string stream here circumvents the encoding + // switching machinery of odocstream. Therefore the + // output is wrong if this paragraph contains content + // that needs to switch encoding. odocstringstream ods; + ods << '\\' << from_ascii(layout_->latexname()); // we have to provide all the optional arguments here, even though // the last one is the only one we care about. + // Separate handling of optional argument inset. + if (layout_->optargs != 0 || layout_->reqargs != 0) + latexArgInsets(*owner_, ods, features.runparams(), + layout_->reqargs, layout_->optargs); + else + ods << from_ascii(layout_->latexparam()); + docstring::size_type const length = ods.str().length(); + // this will output "{" at the beginning, but not at the end owner_->latex(bp, f, ods, tr, features.runparams(), 0, -1, true); - docstring const d = ods.str(); - if (!d.empty()) { - // this will have "{" at the beginning, but not at the end - string const content = to_utf8(d); - string const cmd = layout_->latexname(); - features.addPreambleSnippet("\\" + cmd + content + "}"); + if (ods.str().length() > length) { + ods << '}'; + string const snippet = to_utf8(ods.str()); + features.addPreambleSnippet(snippet); } } -- 2.39.2