9 #include "commandtags.h"
12 #include "LaTeXFeatures.h"
13 #include "frontends/LyXView.h"
14 #include "frontends/Dialogs.h"
16 #include "BufferView.h"
17 #include "support/lstrings.h"
21 InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf, bool)
22 : InsetCommand(p), isLatex(buf.isLatex())
25 void InsetRef::edit(BufferView * bv, int, int, mouse_button::state button)
27 // Eventually trigger dialog with button 3 not 1
28 if (button == mouse_button::button3)
29 bv->owner()->getLyXFunc()->
30 dispatch(LFUN_REF_GOTO, getContents());
31 else if (button == mouse_button::button1)
32 bv->owner()->getDialogs()->showRef(this);
36 void InsetRef::edit(BufferView *, bool)
41 string const InsetRef::getScreenLabel(Buffer const *) const
44 for (int i = 0; !types[i].latex_name.empty(); ++ i)
45 if (getCmdName() == types[i].latex_name) {
46 temp = _(types[i].short_gui_name);
49 temp += getContents();
52 && !getOptions().empty()) {
60 int InsetRef::latex(Buffer const *, ostream & os,
61 bool /*fragile*/, bool /*fs*/) const
63 if (getOptions().empty())
64 os << escape(getCommand());
66 InsetCommandParams p(getCmdName(), getContents(), "");
67 os << escape(p.getCommand());
73 int InsetRef::ascii(Buffer const *, ostream & os, int) const
75 os << "[" << getContents() << "]";
80 int InsetRef::linuxdoc(Buffer const *, ostream & os) const
82 os << "<ref id=\"" << getContents()
83 << "\" name=\"" << getOptions() << "\" >";
88 int InsetRef::docbook(Buffer const *, ostream & os, bool) const
90 if (getOptions().empty()) {
91 os << "<xref linkend=\"" << getContents() << "\">";
93 os << "<link linkend=\"" << getContents()
94 << "\">" << getOptions() << "</link>";
101 void InsetRef::validate(LaTeXFeatures & features) const
103 if (getCmdName() == "vref" || getCmdName() == "vpageref")
104 features.require("varioref");
105 else if (getCmdName() == "prettyref")
106 features.require("prettyref");
110 InsetRef::type_info InsetRef::types[] = {
111 { "ref", N_("Standard"), N_("Ref: ")},
112 { "pageref", N_("Page Number"), N_("Page: ")},
113 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
114 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
115 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},
120 int InsetRef::getType(string const & name)
122 for (int i = 0; !types[i].latex_name.empty(); ++i)
123 if (name == types[i].latex_name)
129 string const & InsetRef::getName(int type)
131 return types[type].latex_name;