3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
15 #include "funcrequest.h"
18 #include "LaTeXFeatures.h"
19 #include "frontends/LyXView.h"
20 #include "frontends/Dialogs.h"
21 #include "BufferView.h"
22 #include "support/lstrings.h"
26 InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf)
27 : InsetCommand(p), isLatex(buf.isLatex())
31 // InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf, bool)
32 // : InsetCommand(p, false), isLatex(buf.isLatex())
38 InsetCommandMailer("ref", *this).hideDialog();
42 dispatch_result InsetRef::localDispatch(FuncRequest const & cmd)
46 // Eventually trigger dialog with button 3 not 1
47 if (cmd.button() == mouse_button::button3)
49 dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
50 if (cmd.button() == mouse_button::button1)
51 InsetCommandMailer("ref", *this).showDialog(cmd.view());
55 return InsetCommand::localDispatch(cmd);
60 string const InsetRef::getScreenLabel(Buffer const *) const
63 for (int i = 0; !types[i].latex_name.empty(); ++ i)
64 if (getCmdName() == types[i].latex_name) {
65 temp = _(types[i].short_gui_name);
68 temp += getContents();
71 && !getOptions().empty()) {
79 int InsetRef::latex(Buffer const *, ostream & os,
80 LatexRunParams const &) const
82 if (getOptions().empty())
83 os << escape(getCommand());
85 InsetCommandParams p(getCmdName(), getContents(), "");
86 os << escape(p.getCommand());
92 int InsetRef::ascii(Buffer const *, ostream & os, int) const
94 os << '[' << getContents() << ']';
99 int InsetRef::linuxdoc(Buffer const *, ostream & os) const
101 os << "<ref id=\"" << getContents()
102 << "\" name=\"" << getOptions() << "\" >";
107 int InsetRef::docbook(Buffer const *, ostream & os, bool) const
109 if (getOptions().empty()) {
110 os << "<xref linkend=\"" << getContents() << "\">";
112 os << "<link linkend=\"" << getContents()
113 << "\">" << getOptions() << "</link>";
120 void InsetRef::validate(LaTeXFeatures & features) const
122 if (getCmdName() == "vref" || getCmdName() == "vpageref")
123 features.require("varioref");
124 else if (getCmdName() == "prettyref")
125 features.require("prettyref");
129 InsetRef::type_info InsetRef::types[] = {
130 { "ref", N_("Standard"), N_("Ref: ")},
131 { "eqref", N_("Equation"), N_("EqRef: ")},
132 { "pageref", N_("Page Number"), N_("Page: ")},
133 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
134 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
135 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},
140 int InsetRef::getType(string const & name)
142 for (int i = 0; !types[i].latex_name.empty(); ++i)
143 if (name == types[i].latex_name)
149 string const & InsetRef::getName(int type)
151 return types[type].latex_name;