From 72ad0bdfbf380743c9c5705f29ba62042e4360b1 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Sat, 19 Mar 2011 10:37:24 +0000 Subject: [PATCH] Simplify logic in InsetRef::latex(). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37960 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetRef.cpp | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 17184e51f6..4bbb38d466 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -140,34 +140,25 @@ docstring InsetRef::getEscapedLabel(OutputParams const & rp) const void InsetRef::latex(otexstream & os, OutputParams const & rp) const { string const cmd = getCmdName(); + docstring const data = getEscapedLabel(rp); - // refstyle defines its own version of \eqref - if (cmd != "formatted" && - !(cmd == "eqref" && buffer().params().use_refstyle) - ) { + if (cmd == "eqref" && buffer().params().use_refstyle) { + os << '(' << from_ascii("\\ref{") << data << from_ascii("})"); + } + else if (cmd == "formatted") { + docstring label; + docstring prefix; + docstring const fcmd = getFormattedCmd(data, label, prefix); + os << fcmd << '{' << label << '}'; + } + else { // We don't want to output p_["name"], since that is only used // in docbook. So we construct new params, without it, and use that. InsetCommandParams p(REF_CODE, cmd); docstring const ref = getParam("reference"); p["reference"] = ref; os << p.getCommand(rp); - return; - } - - // so we're doing a formatted reference of some kind. - docstring const data = getEscapedLabel(rp); - - // what we say in the UI is that an "eqref" is supposed to surround the - // reference with parentheses, so let's do that. - if (cmd == "eqref" /* && buffer().params().use_refstyle */) { - os << '(' << from_ascii("\\ref{") << data << from_ascii("})"); - return; } - - docstring label; - docstring prefix; - docstring const fcmd = getFormattedCmd(data, label, prefix); - os << fcmd << '{' << label << '}'; } -- 2.39.2