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"
24 using namespace lyx::support;
28 InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf)
29 : InsetCommand(p), isLatex(buf.isLatex())
33 InsetRef::InsetRef(InsetRef const & ir)
34 : InsetCommand(ir), isLatex(ir.isLatex)
41 InsetCommandMailer("ref", *this).hideDialog();
45 dispatch_result InsetRef::localDispatch(FuncRequest const & cmd)
49 // Eventually trigger dialog with button 3 not 1
50 if (cmd.button() == mouse_button::button3)
52 dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
54 InsetCommandMailer("ref", *this).showDialog(cmd.view());
58 return InsetCommand::localDispatch(cmd);
63 string const InsetRef::getScreenLabel(Buffer const *) const
66 for (int i = 0; !types[i].latex_name.empty(); ++ i)
67 if (getCmdName() == types[i].latex_name) {
68 temp = _(types[i].short_gui_name);
71 temp += getContents();
74 && !getOptions().empty()) {
82 int InsetRef::latex(Buffer const *, ostream & os,
83 LatexRunParams const &) const
85 if (getOptions().empty())
86 os << escape(getCommand());
88 InsetCommandParams p(getCmdName(), getContents(), "");
89 os << escape(p.getCommand());
95 int InsetRef::ascii(Buffer const *, ostream & os, int) const
97 os << '[' << getContents() << ']';
102 int InsetRef::linuxdoc(Buffer const *, ostream & os) const
104 os << "<ref id=\"" << getContents()
105 << "\" name=\"" << getOptions() << "\" >";
110 int InsetRef::docbook(Buffer const *, ostream & os, bool) const
112 if (getOptions().empty()) {
113 os << "<xref linkend=\"" << getContents() << "\">";
115 os << "<link linkend=\"" << getContents()
116 << "\">" << getOptions() << "</link>";
123 void InsetRef::validate(LaTeXFeatures & features) const
125 if (getCmdName() == "vref" || getCmdName() == "vpageref")
126 features.require("varioref");
127 else if (getCmdName() == "prettyref")
128 features.require("prettyref");
132 InsetRef::type_info InsetRef::types[] = {
133 { "ref", N_("Standard"), N_("Ref: ")},
134 { "eqref", N_("Equation"), N_("EqRef: ")},
135 { "pageref", N_("Page Number"), N_("Page: ")},
136 { "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
137 { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
138 { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},
143 int InsetRef::getType(string const & name)
145 for (int i = 0; !types[i].latex_name.empty(); ++i)
146 if (name == types[i].latex_name)
152 string const & InsetRef::getName(int type)
154 return types[type].latex_name;