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, bool)
27 : InsetCommand(p), isLatex(buf.isLatex())
33 InsetCommandMailer("ref", *this).hideDialog();
37 dispatch_result InsetRef::localDispatch(FuncRequest const & cmd)
41 // Eventually trigger dialog with button 3 not 1
42 if (cmd.button() == mouse_button::button3)
44 dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
45 if (cmd.button() == mouse_button::button1)
46 InsetCommandMailer("ref", *this).showDialog(cmd.view());
55 string const InsetRef::getScreenLabel(Buffer const *) const
58 for (int i = 0; !types[i].latex_name.empty(); ++ i)
59 if (getCmdName() == types[i].latex_name) {
60 temp = _(types[i].short_gui_name);
63 temp += getContents();
66 && !getOptions().empty()) {
74 int InsetRef::latex(Buffer const *, ostream & os, LatexRunParams const &,
77 if (getOptions().empty())
78 os << escape(getCommand());
80 InsetCommandParams p(getCmdName(), getContents(), "");
81 os << escape(p.getCommand());
87 int InsetRef::ascii(Buffer const *, ostream & os, int) const
89 os << '[' << getContents() << ']';
94 int InsetRef::linuxdoc(Buffer const *, ostream & os) const
96 os << "<ref id=\"" << getContents()
97 << "\" name=\"" << getOptions() << "\" >";
102 int InsetRef::docbook(Buffer const *, ostream & os, bool) const
104 if (getOptions().empty()) {
105 os << "<xref linkend=\"" << getContents() << "\">";
107 os << "<link linkend=\"" << getContents()
108 << "\">" << getOptions() << "</link>";
115 void InsetRef::validate(LaTeXFeatures & features) const
117 if (getCmdName() == "vref" || getCmdName() == "vpageref")
118 features.require("varioref");
119 else if (getCmdName() == "prettyref")
120 features.require("prettyref");
124 InsetRef::type_info InsetRef::types[] = {
125 { "ref", N_("Standard"), N_("Ref: ")},
126 { "eqref", N_("Equation"), N_("EqRef: ")},
127 { "pageref", N_("Page Number"), N_("Page: ")},
128 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
129 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
130 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},
135 int InsetRef::getType(string const & name)
137 for (int i = 0; !types[i].latex_name.empty(); ++i)
138 if (name == types[i].latex_name)
144 string const & InsetRef::getName(int type)
146 return types[type].latex_name;