9 #include "commandtags.h"
12 #include "LaTeXFeatures.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, unsigned int button)
27 // Eventually trigger dialog with button 3 not 1
29 bv->owner()->getLyXFunc()->
30 dispatch(LFUN_REF_GOTO, getContents());
31 else if (button == 1 )
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) 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.varioref = true;
105 else if (getCmdName() == "prettyref")
106 features.prettyref = true;
109 InsetRef::type_info InsetRef::types[] = {
110 { "ref", N_("Standard"), N_("Ref: ")},
111 { "pageref", N_("Page Number"), N_("Page: ")},
112 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
113 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
114 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},
119 int InsetRef::getType(string const & name)
121 for (int i = 0; !types[i].latex_name.empty(); ++i)
122 if (name == types[i].latex_name)
128 string const & InsetRef::getName(int type)
130 return types[type].latex_name;