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 string const InsetRef::getScreenLabel() const
39 for (int i = 0; !types[i].latex_name.empty(); ++ i)
40 if (getCmdName() == types[i].latex_name) {
41 temp = _(types[i].short_gui_name);
44 temp += getContents();
47 && !getOptions().empty()) {
55 int InsetRef::latex(Buffer const *, ostream & os,
56 bool /*fragile*/, bool /*fs*/) const
58 if (getOptions().empty())
59 os << escape(getCommand());
61 InsetCommandParams p( getCmdName(), getContents(), "" );
62 os << escape(p.getCommand());
68 int InsetRef::ascii(Buffer const *, ostream & os, int) const
70 os << "[" << getContents() << "]";
75 int InsetRef::linuxdoc(Buffer const *, ostream & os) const
77 os << "<ref id=\"" << getContents()
78 << "\" name=\"" << getOptions() << "\" >";
83 int InsetRef::docBook(Buffer const *, ostream & os) const
85 if (getOptions().empty()) {
86 os << "<xref linkend=\"" << getContents() << "\"/>";
88 os << "<link linkend=\"" << getContents()
89 << "\">" << getOptions() << "</link>";
96 void InsetRef::validate(LaTeXFeatures & features) const
98 if (getCmdName() == "vref" || getCmdName() == "vpageref")
99 features.varioref = true;
100 else if (getCmdName() == "prettyref")
101 features.prettyref = true;
104 InsetRef::type_info InsetRef::types[] = {
105 { "ref", N_("Standard"), N_("Ref: ")},
106 { "pageref", N_("Page Number"), N_("Page: ")},
107 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
108 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
109 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},
114 int InsetRef::getType(string const & name)
116 for (int i = 0; !types[i].latex_name.empty(); ++i)
117 if (name == types[i].latex_name)
123 string const & InsetRef::getName(int type)
125 return types[type].latex_name;