X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetRef.cpp;h=31c0187cc1cadfeb01035c69f69a777d7ce7782f;hb=239b9919ffe28338d789e6dc9122228f77ab77a7;hp=81229cc6a308cffc8325ed359506de385faabc43;hpb=73f59e87bd62e00bbfbceee59b8876aa59e75f58;p=lyx.git diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 81229cc6a3..31c0187cc1 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -71,6 +71,7 @@ ParamInfo const & InsetRef::findInfo(string const & /* cmdName */) ParamInfo::HANDLING_ESCAPE); param_info_.add("plural", ParamInfo::LYX_INTERNAL); param_info_.add("caps", ParamInfo::LYX_INTERNAL); + param_info_.add("noprefix", ParamInfo::LYX_INTERNAL); } return param_info_; } @@ -110,7 +111,7 @@ docstring InsetRef::getFormattedCmd(docstring const & ref, // we have to have xxx:xxxxx... if (label.empty()) { - LYXERR0("Label `" << ref << "' contains no prefix."); + LYXERR0("Label `" << ref << "' contains no `:' separator."); label = ref; prefix = from_ascii(""); return defcmd; @@ -181,7 +182,19 @@ void InsetRef::latex(otexstream & os, OutputParams const & rp) const os << '{' << label << '}'; } else if (cmd == "labelonly") { - os << getParam("reference"); + docstring const & ref = getParam("reference"); + if (getParam("noprefix") != "true") + os << ref; + else { + docstring prefix; + docstring suffix = split(ref, prefix, ':'); + if (suffix.empty()) { + LYXERR0("Label `" << ref << "' contains no `:' separator."); + os << ref; + } else { + os << suffix; + } + } } else { // We don't want to output p_["name"], since that is only used @@ -303,13 +316,29 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType) buffer().addReference(ref, this, it); docstring label; + string const & cmd = getCmdName(); for (int i = 0; !types[i].latex_name.empty(); ++i) { - if (getCmdName() == types[i].latex_name) { + if (cmd == types[i].latex_name) { label = _(types[i].short_gui_name); break; } } - label += ref; + + if (cmd != "labelonly") + label += ref; + else { + if (getParam("noprefix") != "true") + label += ref; + else { + docstring prefix; + docstring suffix = split(ref, prefix, ':'); + if (suffix.empty()) { + label += ref; + } else { + label += suffix; + } + } + } if (!buffer().params().isLatex() && !getParam("name").empty()) { label += "||";