9 #include "funcrequest.h"
12 #include "LaTeXFeatures.h"
13 #include "frontends/LyXView.h"
14 #include "frontends/Dialogs.h"
15 #include "BufferView.h"
16 #include "support/lstrings.h"
20 InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf, bool)
21 : InsetCommand(p), isLatex(buf.isLatex())
25 void InsetRef::edit(BufferView * bv, int, int, mouse_button::state button)
27 // FuncRequestually trigger dialog with button 3 not 1
28 if (button == mouse_button::button3)
29 bv->owner()->dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
30 else if (button == mouse_button::button1)
31 bv->owner()->getDialogs().showRef(this);
35 void InsetRef::edit(BufferView *, bool)
39 string const InsetRef::getScreenLabel(Buffer const *) const
42 for (int i = 0; !types[i].latex_name.empty(); ++ i)
43 if (getCmdName() == types[i].latex_name) {
44 temp = _(types[i].short_gui_name);
47 temp += getContents();
50 && !getOptions().empty()) {
58 int InsetRef::latex(Buffer const *, ostream & os,
59 bool /*fragile*/, bool /*fs*/) const
61 if (getOptions().empty())
62 os << escape(getCommand());
64 InsetCommandParams p(getCmdName(), getContents(), "");
65 os << escape(p.getCommand());
71 int InsetRef::ascii(Buffer const *, ostream & os, int) const
73 os << "[" << getContents() << "]";
78 int InsetRef::linuxdoc(Buffer const *, ostream & os) const
80 os << "<ref id=\"" << getContents()
81 << "\" name=\"" << getOptions() << "\" >";
86 int InsetRef::docbook(Buffer const *, ostream & os, bool) const
88 if (getOptions().empty()) {
89 os << "<xref linkend=\"" << getContents() << "\">";
91 os << "<link linkend=\"" << getContents()
92 << "\">" << getOptions() << "</link>";
99 void InsetRef::validate(LaTeXFeatures & features) const
101 if (getCmdName() == "vref" || getCmdName() == "vpageref")
102 features.require("varioref");
103 else if (getCmdName() == "prettyref")
104 features.require("prettyref");
108 InsetRef::type_info InsetRef::types[] = {
109 { "ref", N_("Standard"), N_("Ref: ")},
110 { "pageref", N_("Page Number"), N_("Page: ")},
111 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
112 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
113 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},
118 int InsetRef::getType(string const & name)
120 for (int i = 0; !types[i].latex_name.empty(); ++i)
121 if (name == types[i].latex_name)
127 string const & InsetRef::getName(int type)
129 return types[type].latex_name;