From 045dee3755dab51804dd8584462256a578f15149 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 22 Mar 2014 12:25:25 +0100 Subject: [PATCH] ulem commands can be nested. --- src/Font.cpp | 16 ++++++++-------- src/OutputParams.cpp | 2 +- src/OutputParams.h | 4 ++-- src/insets/InsetCitation.cpp | 2 +- src/insets/InsetRef.cpp | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Font.cpp b/src/Font.cpp index a155ec557a..7e8b3f4f2b 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -418,22 +418,22 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams, if (f.underbar() == FONT_ON) { os << "\\uline{"; count += 10; - runparams.inulemcmd = true; + ++runparams.inulemcmd; } if (f.strikeout() == FONT_ON) { os << "\\sout{"; count += 9; - runparams.inulemcmd = true; + ++runparams.inulemcmd; } if (f.uuline() == FONT_ON) { os << "\\uuline{"; count += 11; - runparams.inulemcmd = true; + ++runparams.inulemcmd; } if (f.uwave() == FONT_ON) { os << "\\uwave{"; count += 10; - runparams.inulemcmd = true; + ++runparams.inulemcmd; } return count; } @@ -497,22 +497,22 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams, if (f.underbar() == FONT_ON) { os << '}'; ++count; - runparams.inulemcmd = false; + --runparams.inulemcmd; } if (f.strikeout() == FONT_ON) { os << '}'; ++count; - runparams.inulemcmd = false; + --runparams.inulemcmd; } if (f.uuline() == FONT_ON) { os << '}'; ++count; - runparams.inulemcmd = false; + --runparams.inulemcmd; } if (f.uwave() == FONT_ON) { os << '}'; ++count; - runparams.inulemcmd = false; + --runparams.inulemcmd; } // If the current language is Hebrew, Arabic, or Farsi diff --git a/src/OutputParams.cpp b/src/OutputParams.cpp index df58ff4cad..e74eaa320e 100644 --- a/src/OutputParams.cpp +++ b/src/OutputParams.cpp @@ -20,7 +20,7 @@ namespace lyx { OutputParams::OutputParams(Encoding const * enc) : flavor(LATEX), math_flavor(NotApplicable), nice(false), is_child(false), - moving_arg(false), inulemcmd(false), local_font(0), master_language(0), + moving_arg(false), inulemcmd(0), local_font(0), master_language(0), encoding(enc), free_spacing(false), use_babel(false), use_polyglossia(false), use_indices(false), use_japanese(false), linelen(0), depth(0), exportdata(new ExportData), diff --git a/src/OutputParams.h b/src/OutputParams.h index f220b5e654..598b5753b8 100644 --- a/src/OutputParams.h +++ b/src/OutputParams.h @@ -99,13 +99,13 @@ public: */ bool intitle; - /** inulemcmd == true means that the environment in which the + /** inulemcmd > 0 means that the environment in which the inset is typeset is part of a ulem command (\uline, \uuline, \uwave, or \sout). Insets that output latex commands relying on local assignments (such as \cite) should enclose such commands in \mbox{} in order to avoid breakage. */ - mutable bool inulemcmd; + mutable int inulemcmd; /** the font at the point where the inset is */ diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index c0e61798a8..96620c1412 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -422,7 +422,7 @@ void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const // FIXME UNICODE docstring const cite_str = from_utf8(citationStyleToString(cs)); - if (runparams.inulemcmd) + if (runparams.inulemcmd > 0) os << "\\mbox{"; os << "\\" << cite_str; diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 9a2ddd8bd8..e7e458f477 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -143,7 +143,7 @@ void InsetRef::latex(otexstream & os, OutputParams const & rp) const string const cmd = getCmdName(); docstring const data = getEscapedLabel(rp); - if (rp.inulemcmd) + if (rp.inulemcmd > 0) os << "\\mbox{"; if (cmd == "eqref" && buffer().params().use_refstyle) { @@ -168,7 +168,7 @@ void InsetRef::latex(otexstream & os, OutputParams const & rp) const os << p.getCommand(rp); } - if (rp.inulemcmd) + if (rp.inulemcmd > 0) os << "}"; } -- 2.39.5