#include "OutputParams.h"
#include "sgml.h"
+#include "support/docstream.h"
#include "support/lstrings.h"
{}
+bool InsetRef::isCompatibleCommand(std::string const & s) {
+ //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"
+ || s == "prettyref"
+ || s == "eqref";
+}
+
+
+CommandInfo const * InsetRef::findInfo(std::string const & /* cmdName */)
+{
+ static const char * const paramnames[] = {"name", "reference", ""};
+ static const bool isoptional[] = {true, false};
+ static const CommandInfo info = {2, paramnames, isoptional};
+ return &info;
+}
+
+
void InsetRef::doDispatch(Cursor & cur, FuncRequest & cmd)
{
switch (cmd.action) {
case LFUN_MOUSE_RELEASE:
// Eventually trigger dialog with button 3 not 1
if (cmd.button() == mouse_button::button3)
- lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO,
+ lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO,
getParam("reference")));
- else
+ else
InsetCommand::doDispatch(cur, cmd);
break;
int InsetRef::latex(Buffer const &, odocstream & os,
- OutputParams const &) const
+ OutputParams const &) const
{
- // Don't output p_["name"], this is only used in docbook
- InsetCommandParams p(getCmdName());
+ // 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, getCmdName());
p["reference"] = getParam("reference");
os << escape(p.getCommand());
return 0;
int InsetRef::plaintext(Buffer const &, odocstream & os,
- OutputParams const &) const
+ OutputParams const &) const
{
docstring const str = getParam("reference");
os << '[' << str << ']';
int InsetRef::docbook(Buffer const & buf, odocstream & os,
- OutputParams const & runparams) const
+ OutputParams const & runparams) const
{
docstring const & name = getParam("name");
if (name.empty()) {
if (runparams.flavor == OutputParams::XML) {
- os << "<xref linkend=\""
- << sgml::cleanID(buf, runparams, getParam("reference"))
+ os << "<xref linkend=\""
+ << sgml::cleanID(buf, runparams, getParam("reference"))
<< "\" />";
} else {
- os << "<xref linkend=\""
- << sgml::cleanID(buf, runparams, getParam("reference"))
+ os << "<xref linkend=\""
+ << sgml::cleanID(buf, runparams, getParam("reference"))
<< "\">";
}
} else {
- os << "<link linkend=\""
+ os << "<link linkend=\""
<< sgml::cleanID(buf, runparams, getParam("reference"))
- << "\">"
+ << "\">"
<< getParam("name")
<< "</link>";
}