2002-09-25 14:26:13 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetRef.cpp
|
2002-09-25 14:26:13 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author José Matos
|
2002-09-25 14:26:13 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "InsetRef.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Buffer.h"
|
2010-10-13 12:36:53 +00:00
|
|
|
#include "BufferParams.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
#include "Cursor.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "DispatchResult.h"
|
2010-01-20 19:03:17 +00:00
|
|
|
#include "InsetLabel.h"
|
2000-05-19 16:46:01 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2010-02-09 16:11:13 +00:00
|
|
|
#include "LyX.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "OutputParams.h"
|
2009-11-14 14:12:37 +00:00
|
|
|
#include "output_xhtml.h"
|
2008-02-27 16:23:27 +00:00
|
|
|
#include "ParIterator.h"
|
2004-10-29 23:08:04 +00:00
|
|
|
#include "sgml.h"
|
2008-02-27 16:23:27 +00:00
|
|
|
#include "TocBackend.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
2010-10-28 15:15:14 +00:00
|
|
|
#include "support/debug.h"
|
2007-11-01 22:17:22 +00:00
|
|
|
#include "support/docstream.h"
|
2008-02-27 16:23:27 +00:00
|
|
|
#include "support/gettext.h"
|
2001-06-27 14:10:35 +00:00
|
|
|
#include "support/lstrings.h"
|
2010-11-17 22:17:53 +00:00
|
|
|
#include "support/textutils.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-12-12 18:57:56 +00:00
|
|
|
using namespace lyx::support;
|
2008-03-02 15:27:35 +00:00
|
|
|
using namespace std;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2003-09-05 09:01:27 +00:00
|
|
|
|
2009-11-08 15:53:21 +00:00
|
|
|
InsetRef::InsetRef(Buffer * buf, InsetCommandParams const & p)
|
2010-10-29 00:46:21 +00:00
|
|
|
: InsetCommand(buf, p)
|
2000-08-08 13:55:26 +00:00
|
|
|
{}
|
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
|
2003-06-03 15:10:14 +00:00
|
|
|
InsetRef::InsetRef(InsetRef const & ir)
|
2010-10-27 22:34:18 +00:00
|
|
|
: InsetCommand(ir)
|
2003-12-11 15:23:15 +00:00
|
|
|
{}
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
bool InsetRef::isCompatibleCommand(string const & s) {
|
2007-10-25 04:13:56 +00:00
|
|
|
//FIXME This is likely not the best way to handle this.
|
|
|
|
//But this stuff is hardcoded elsewhere already.
|
|
|
|
return s == "ref"
|
|
|
|
|| s == "pageref"
|
|
|
|
|| s == "vref"
|
|
|
|
|| s == "vpageref"
|
2010-10-13 12:36:53 +00:00
|
|
|
|| s == "formatted"
|
2010-07-13 03:23:29 +00:00
|
|
|
|| s == "eqref"
|
2010-07-16 15:19:04 +00:00
|
|
|
|| s == "nameref";
|
2007-10-25 04:13:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-23 22:01:02 +00:00
|
|
|
ParamInfo const & InsetRef::findInfo(string const & /* cmdName */)
|
2007-10-25 04:13:56 +00:00
|
|
|
{
|
2008-02-23 22:01:02 +00:00
|
|
|
static ParamInfo param_info_;
|
|
|
|
if (param_info_.empty()) {
|
Per Abdel's suggestion that we focus on bug-fixing at this point, this will be the last patch in this series for a bit. But I wanted to get this done before I forget what it is I was doing, so here it is.
The idea behind this patch is to make real key-value support for InsetCommand parameters possible. This should be particularly useful for the listings version of InsetInclude, though we would need some kind of UI for it before it would really be helpful. (See below for some thoughts.) This doesn't substantially change anything else, though some things do get re-arranged a bit.
Basically, the idea is this. First, we introduce a whole range of parameter types: Normal LaTeX optional and required parameters; ones for LyX's internal use (like embed); and finally, in connection with keyval, ones that represent keys and ones that represent optional and required arguments where the keyval stuff will appear. (I'm assuming here that there will always be exactly one of those, and that it will accept only keyval-type material.) The parameters themselves are stored in a map, so it's really only the output routines that need to care about the different types of parameters.
Regarding the frontend, it seems to me that something like the following would work:
(i) scan the parameter list for LATEX_KEY type parameters
(ii) the dialog will have a series of lines, each of which has a combo box listing the acceptable keys and a QLineEdit for entering its value, as well as a "delete" button of some sort for removing this key and its value
(iii) there should be an "add line" button to add a new line, activated only when all other lines are filled with values
Probably not even too hard.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23235 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-25 22:13:45 +00:00
|
|
|
param_info_.add("name", ParamInfo::LATEX_OPTIONAL);
|
2010-02-13 13:08:32 +00:00
|
|
|
param_info_.add("reference", ParamInfo::LATEX_REQUIRED,
|
|
|
|
ParamInfo::HANDLING_ESCAPE);
|
2008-02-23 22:01:02 +00:00
|
|
|
}
|
|
|
|
return param_info_;
|
2007-10-25 04:13:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-08 17:50:02 +00:00
|
|
|
// the ref argument is the label name we are referencing.
|
|
|
|
// we expect ref to be in the form: pfx:suffix.
|
|
|
|
//
|
|
|
|
// if it isn't, then we can't produce a formatted reference,
|
|
|
|
// so we return "\ref" and put ref into label.
|
|
|
|
//
|
|
|
|
// for refstyle, we return "\pfxcmd", and put suffix into
|
|
|
|
// label and pfx into prefix. this is because refstyle expects
|
|
|
|
// the command: \pfxcmd{suffix}.
|
|
|
|
//
|
|
|
|
// for prettyref, we return "\prettyref" and put ref into label
|
2011-03-13 20:29:52 +00:00
|
|
|
// and pfx into prefix. this is because prettyref uses the whole
|
|
|
|
// label, thus: \prettyref{pfx:suffix}.
|
2010-11-08 17:50:02 +00:00
|
|
|
//
|
|
|
|
docstring InsetRef::getFormattedCmd(docstring const & ref,
|
|
|
|
docstring & label, docstring & prefix) const
|
2010-10-28 15:15:14 +00:00
|
|
|
{
|
|
|
|
static docstring const defcmd = from_ascii("\\ref");
|
2010-11-01 21:54:20 +00:00
|
|
|
static docstring const prtcmd = from_ascii("\\prettyref");
|
|
|
|
|
2010-10-28 15:15:14 +00:00
|
|
|
label = split(ref, prefix, ':');
|
2010-11-01 21:54:20 +00:00
|
|
|
|
|
|
|
// we have to have xxx:xxxxx...
|
2010-11-10 16:45:55 +00:00
|
|
|
if (label.empty()) {
|
|
|
|
LYXERR0("Label `" << ref << "' contains no prefix.");
|
|
|
|
label = ref;
|
|
|
|
prefix = from_ascii("");
|
|
|
|
return defcmd;
|
|
|
|
}
|
|
|
|
|
2010-10-28 15:15:14 +00:00
|
|
|
if (prefix.empty()) {
|
2010-11-10 16:45:55 +00:00
|
|
|
// we have ":xxxx"
|
2010-10-29 13:07:05 +00:00
|
|
|
label = ref;
|
2010-10-28 15:15:14 +00:00
|
|
|
return defcmd;
|
|
|
|
}
|
|
|
|
|
2010-11-01 21:54:20 +00:00
|
|
|
if (!buffer().params().use_refstyle) {
|
|
|
|
// \prettyref uses the whole label
|
|
|
|
label = ref;
|
|
|
|
return prtcmd;
|
|
|
|
}
|
|
|
|
|
2010-10-28 15:15:14 +00:00
|
|
|
// make sure the prefix is legal for a latex command
|
|
|
|
int const len = prefix.size();
|
|
|
|
for (int i = 0; i < len; i++) {
|
2010-11-17 22:17:53 +00:00
|
|
|
char_type const c = prefix[i];
|
|
|
|
if (!isAlphaASCII(c)) {
|
2010-11-17 21:19:01 +00:00
|
|
|
LYXERR0("Prefix `" << prefix << "' is invalid for LaTeX.");
|
2010-10-28 15:15:14 +00:00
|
|
|
// restore the label
|
|
|
|
label = ref;
|
|
|
|
return defcmd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return from_ascii("\\") + prefix + from_ascii("ref");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
docstring InsetRef::getEscapedLabel(OutputParams const & rp) const
|
|
|
|
{
|
|
|
|
InsetCommandParams const & p = params();
|
|
|
|
ParamInfo const & pi = p.info();
|
|
|
|
ParamInfo::ParamData const & pd = pi["reference"];
|
|
|
|
return p.prepareCommand(rp, getParam("reference"), pd.handling());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-10 20:02:48 +00:00
|
|
|
void InsetRef::latex(otexstream & os, OutputParams const & rp) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2010-10-13 12:36:53 +00:00
|
|
|
string const cmd = getCmdName();
|
2011-03-19 10:37:24 +00:00
|
|
|
docstring const data = getEscapedLabel(rp);
|
2011-03-13 20:29:52 +00:00
|
|
|
|
2011-03-19 10:37:24 +00:00
|
|
|
if (cmd == "eqref" && buffer().params().use_refstyle) {
|
2011-12-03 23:15:04 +00:00
|
|
|
// we advertise this as printing "(n)", so we'll do that, at least
|
|
|
|
// for refstyle, since refstlye's own \eqref prints, by default,
|
|
|
|
// "equation n". if one wants \eqref, one can get it by using a
|
|
|
|
// formatted label in this case.
|
2011-03-19 10:37:24 +00:00
|
|
|
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 {
|
2010-10-13 12:36:53 +00:00
|
|
|
// 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);
|
2010-10-28 15:15:14 +00:00
|
|
|
docstring const ref = getParam("reference");
|
2010-10-13 12:36:53 +00:00
|
|
|
p["reference"] = ref;
|
2010-10-28 15:15:14 +00:00
|
|
|
os << p.getCommand(rp);
|
2011-03-13 20:29:52 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
int InsetRef::plaintext(odocstream & os, OutputParams const &) const
|
2000-04-24 20:58:23 +00:00
|
|
|
{
|
2007-02-24 14:35:38 +00:00
|
|
|
docstring const str = getParam("reference");
|
2007-02-15 23:28:31 +00:00
|
|
|
os << '[' << str << ']';
|
|
|
|
return 2 + str.size();
|
2000-04-24 20:58:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
int InsetRef::docbook(odocstream & os, OutputParams const & runparams) const
|
2000-03-06 02:42:40 +00:00
|
|
|
{
|
2006-10-20 16:12:49 +00:00
|
|
|
docstring const & name = getParam("name");
|
|
|
|
if (name.empty()) {
|
|
|
|
if (runparams.flavor == OutputParams::XML) {
|
2007-05-28 22:27:45 +00:00
|
|
|
os << "<xref linkend=\""
|
2008-02-27 20:43:16 +00:00
|
|
|
<< sgml::cleanID(buffer(), runparams, getParam("reference"))
|
2006-10-20 16:12:49 +00:00
|
|
|
<< "\" />";
|
|
|
|
} else {
|
2007-05-28 22:27:45 +00:00
|
|
|
os << "<xref linkend=\""
|
2008-02-27 20:43:16 +00:00
|
|
|
<< sgml::cleanID(buffer(), runparams, getParam("reference"))
|
2006-10-20 16:12:49 +00:00
|
|
|
<< "\">";
|
|
|
|
}
|
2001-06-27 14:10:35 +00:00
|
|
|
} else {
|
2007-05-28 22:27:45 +00:00
|
|
|
os << "<link linkend=\""
|
2008-02-27 20:43:16 +00:00
|
|
|
<< sgml::cleanID(buffer(), runparams, getParam("reference"))
|
2007-05-28 22:27:45 +00:00
|
|
|
<< "\">"
|
2006-10-20 16:12:49 +00:00
|
|
|
<< getParam("name")
|
|
|
|
<< "</link>";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2001-06-27 14:10:35 +00:00
|
|
|
|
|
|
|
return 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-05-19 16:46:01 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
2009-11-28 21:37:47 +00:00
|
|
|
docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const &) const
|
2009-11-14 14:12:37 +00:00
|
|
|
{
|
2010-01-20 19:03:17 +00:00
|
|
|
docstring const & ref = getParam("reference");
|
|
|
|
InsetLabel const * il = buffer().insetLabel(ref);
|
|
|
|
string const & cmd = params().getCmdName();
|
|
|
|
docstring display_string;
|
|
|
|
|
|
|
|
if (il && !il->counterValue().empty()) {
|
|
|
|
// Try to construct a label from the InsetLabel we reference.
|
|
|
|
docstring const & value = il->counterValue();
|
|
|
|
if (cmd == "ref")
|
|
|
|
display_string = value;
|
|
|
|
else if (cmd == "vref")
|
2010-01-20 20:33:36 +00:00
|
|
|
// normally, would be "ref on page #", but we have no pages
|
|
|
|
display_string = value;
|
2010-01-20 19:03:17 +00:00
|
|
|
else if (cmd == "pageref" || cmd == "vpageref")
|
2010-01-20 20:33:36 +00:00
|
|
|
// normally would be "on page #", but we have no pages
|
|
|
|
display_string = _("elsewhere");
|
2010-01-20 19:03:17 +00:00
|
|
|
else if (cmd == "eqref")
|
|
|
|
display_string = bformat(from_ascii("equation (%1$s)"), value);
|
2011-04-15 11:28:56 +00:00
|
|
|
else if (cmd == "formatted"
|
2010-07-13 03:23:29 +00:00
|
|
|
// we don't really have the ability to handle these
|
|
|
|
// properly in XHTML output
|
2010-07-16 15:19:04 +00:00
|
|
|
|| cmd == "nameref")
|
2010-01-20 20:33:36 +00:00
|
|
|
display_string = il->prettyCounter();
|
2010-01-20 19:03:17 +00:00
|
|
|
} else
|
|
|
|
display_string = ref;
|
|
|
|
|
2009-11-14 14:12:37 +00:00
|
|
|
// FIXME What we'd really like to do is to be able to output some
|
|
|
|
// appropriate sort of text here. But to do that, we need to associate
|
|
|
|
// some sort of counter with the label, and we don't have that yet.
|
2010-01-20 19:03:17 +00:00
|
|
|
string const attr = "href=\"#" + html::cleanAttr(to_utf8(ref)) + "\"";
|
2010-01-19 22:08:04 +00:00
|
|
|
xs << html::StartTag("a", attr);
|
2010-01-20 19:03:17 +00:00
|
|
|
xs << display_string;
|
2010-01-19 22:08:04 +00:00
|
|
|
xs << html::EndTag("a");
|
2009-11-14 14:12:37 +00:00
|
|
|
return docstring();
|
|
|
|
}
|
|
|
|
|
2009-12-31 15:52:16 +00:00
|
|
|
|
2010-12-15 01:34:04 +00:00
|
|
|
void InsetRef::toString(odocstream & os) const
|
2005-11-25 14:40:34 +00:00
|
|
|
{
|
2008-02-27 20:43:16 +00:00
|
|
|
plaintext(os, OutputParams(0));
|
2005-11-25 14:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-20 21:55:09 +00:00
|
|
|
void InsetRef::forToc(docstring & os, size_t) const
|
|
|
|
{
|
2010-12-20 22:47:09 +00:00
|
|
|
// There's no need for details in the TOC, and a long label
|
|
|
|
// will just get in the way.
|
|
|
|
os += '#';
|
2010-12-20 21:55:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-03 22:13:45 +00:00
|
|
|
void InsetRef::updateBuffer(ParIterator const & it, UpdateType)
|
2008-02-27 16:23:27 +00:00
|
|
|
{
|
2010-02-26 20:16:12 +00:00
|
|
|
docstring const & ref = getParam("reference");
|
2008-03-03 17:58:26 +00:00
|
|
|
// register this inset into the buffer reference cache.
|
2010-02-26 20:16:12 +00:00
|
|
|
buffer().references(ref).push_back(make_pair(this, it));
|
2008-03-03 17:58:26 +00:00
|
|
|
|
2010-02-26 20:16:12 +00:00
|
|
|
docstring label;
|
2008-03-03 17:58:26 +00:00
|
|
|
for (int i = 0; !types[i].latex_name.empty(); ++i) {
|
|
|
|
if (getCmdName() == types[i].latex_name) {
|
2010-02-26 20:16:12 +00:00
|
|
|
label = _(types[i].short_gui_name);
|
2008-03-03 17:58:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-02-26 20:16:12 +00:00
|
|
|
label += ref;
|
2010-10-27 22:34:18 +00:00
|
|
|
|
2011-05-13 19:39:56 +00:00
|
|
|
if (!buffer().params().isLatex() && !getParam("name").empty()) {
|
2010-02-26 20:16:12 +00:00
|
|
|
label += "||";
|
|
|
|
label += getParam("name");
|
|
|
|
}
|
|
|
|
|
|
|
|
screen_label_ = label;
|
|
|
|
bool shortened = false;
|
|
|
|
unsigned int const maxLabelChars = 24;
|
|
|
|
if (screen_label_.size() > maxLabelChars) {
|
|
|
|
screen_label_.erase(maxLabelChars - 3);
|
|
|
|
screen_label_ += "...";
|
|
|
|
shortened = true;
|
2008-03-03 17:58:26 +00:00
|
|
|
}
|
2010-02-26 20:16:12 +00:00
|
|
|
if (shortened)
|
|
|
|
tooltip_ = label;
|
|
|
|
else
|
|
|
|
tooltip_ = from_ascii("");
|
2008-03-02 15:27:35 +00:00
|
|
|
}
|
2008-02-27 16:44:57 +00:00
|
|
|
|
2008-03-02 15:27:35 +00:00
|
|
|
|
2011-01-12 22:23:27 +00:00
|
|
|
void InsetRef::addToToc(DocIterator const & cpit) const
|
2008-03-02 15:27:35 +00:00
|
|
|
{
|
|
|
|
docstring const & label = getParam("reference");
|
|
|
|
if (buffer().insetLabel(label))
|
|
|
|
// This InsetRef has already been taken care of in InsetLabel::addToToc().
|
2008-02-27 16:44:57 +00:00
|
|
|
return;
|
|
|
|
|
2008-03-03 17:58:26 +00:00
|
|
|
// It seems that this reference does not point to any valid label.
|
|
|
|
screen_label_ = _("BROKEN: ") + screen_label_;
|
2008-03-02 15:27:35 +00:00
|
|
|
Toc & toc = buffer().tocBackend().toc("label");
|
2008-03-03 17:58:26 +00:00
|
|
|
toc.push_back(TocItem(cpit, 0, screen_label_));
|
2008-02-27 16:23:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetRef::validate(LaTeXFeatures & features) const
|
2000-05-19 16:46:01 +00:00
|
|
|
{
|
2010-07-13 03:23:29 +00:00
|
|
|
string const cmd = getCmdName();
|
|
|
|
if (cmd == "vref" || cmd == "vpageref")
|
2001-11-19 15:34:11 +00:00
|
|
|
features.require("varioref");
|
2011-07-13 15:18:29 +00:00
|
|
|
else if (cmd == "formatted") {
|
2010-11-10 16:45:55 +00:00
|
|
|
docstring const data = getEscapedLabel(features.runparams());
|
|
|
|
docstring label;
|
|
|
|
docstring prefix;
|
2011-07-13 15:18:29 +00:00
|
|
|
string const fcmd = to_utf8(getFormattedCmd(data, label, prefix));
|
2010-10-13 12:36:53 +00:00
|
|
|
if (buffer().params().use_refstyle) {
|
|
|
|
features.require("refstyle");
|
2010-11-08 17:50:02 +00:00
|
|
|
if (!prefix.empty()) {
|
|
|
|
string lcmd = "\\AtBeginDocument{\\providecommand" +
|
|
|
|
fcmd + "[1]{\\ref{" + to_utf8(prefix) + ":#1}}}";
|
2010-10-28 15:15:14 +00:00
|
|
|
features.addPreambleSnippet(lcmd);
|
2010-11-10 16:45:55 +00:00
|
|
|
} else if (prefix == "cha")
|
|
|
|
features.addPreambleSnippet("\\let\\charef=\\chapref");
|
|
|
|
} else {
|
2010-10-13 12:36:53 +00:00
|
|
|
features.require("prettyref");
|
2010-11-10 16:45:55 +00:00
|
|
|
// prettyref uses "cha" for chapters, so we provide a kind of
|
|
|
|
// translation.
|
|
|
|
if (prefix == "chap")
|
|
|
|
features.addPreambleSnippet("\\let\\pr@chap=\\pr@cha");
|
|
|
|
}
|
2011-07-13 15:18:29 +00:00
|
|
|
} else if (cmd == "eqref" && !buffer().params().use_refstyle)
|
2011-12-03 23:15:04 +00:00
|
|
|
// with refstyle, we simply output "(\ref{label})"
|
2003-08-18 17:41:30 +00:00
|
|
|
features.require("amsmath");
|
2010-07-16 15:19:04 +00:00
|
|
|
else if (cmd == "nameref")
|
2010-07-13 03:23:29 +00:00
|
|
|
features.require("nameref");
|
2000-08-04 13:12:30 +00:00
|
|
|
}
|
2001-01-21 21:41:35 +00:00
|
|
|
|
2002-06-24 17:26:15 +00:00
|
|
|
|
2001-01-21 21:41:35 +00:00
|
|
|
InsetRef::type_info InsetRef::types[] = {
|
2003-04-24 12:16:56 +00:00
|
|
|
{ "ref", N_("Standard"), N_("Ref: ")},
|
|
|
|
{ "eqref", N_("Equation"), N_("EqRef: ")},
|
|
|
|
{ "pageref", N_("Page Number"), N_("Page: ")},
|
|
|
|
{ "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
|
|
|
|
{ "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
|
2010-10-13 12:36:53 +00:00
|
|
|
{ "formatted", N_("Formatted"), N_("Format: ")},
|
2010-07-13 03:23:29 +00:00
|
|
|
{ "nameref", N_("Reference to Name"), N_("NameRef:")},
|
2001-01-21 21:41:35 +00:00
|
|
|
{ "", "", "" }
|
|
|
|
};
|
2001-01-26 17:11:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
int InsetRef::getType(string const & name)
|
|
|
|
{
|
|
|
|
for (int i = 0; !types[i].latex_name.empty(); ++i)
|
|
|
|
if (name == types[i].latex_name)
|
|
|
|
return i;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const & InsetRef::getName(int type)
|
|
|
|
{
|
|
|
|
return types[type].latex_name;
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|