1999-09-27 18:44:28 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insetref.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "commandtags.h"
|
2000-08-08 13:55:26 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "gettext.h"
|
2000-05-19 16:46:01 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2000-08-08 13:55:26 +00:00
|
|
|
#include "LyXView.h"
|
|
|
|
#include "frontends/Dialogs.h"
|
2001-04-24 17:33:01 +00:00
|
|
|
#include "lyxfunc.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "BufferView.h"
|
2001-06-27 14:10:35 +00:00
|
|
|
#include "support/lstrings.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::ostream;
|
|
|
|
|
2000-10-10 11:50:43 +00:00
|
|
|
InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf)
|
|
|
|
: InsetCommand(p), isLatex(buf.isLatex())
|
2000-08-08 13:55:26 +00:00
|
|
|
{}
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetRef::edit(BufferView * bv, int, int, unsigned int button)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-08-08 13:55:26 +00:00
|
|
|
// Eventually trigger dialog with button 3 not 1
|
2000-11-04 10:00:12 +00:00
|
|
|
if (button == 3 )
|
2000-08-08 13:55:26 +00:00
|
|
|
bv->owner()->getLyXFunc()->
|
2000-09-19 11:18:35 +00:00
|
|
|
Dispatch(LFUN_REF_GOTO, getContents());
|
2000-11-04 10:00:12 +00:00
|
|
|
else if (button == 1 )
|
2000-08-08 13:55:26 +00:00
|
|
|
bv->owner()->getDialogs()->showRef( this );
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-08-08 13:55:26 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
string const InsetRef::getScreenLabel() const
|
2000-05-19 16:46:01 +00:00
|
|
|
{
|
2000-08-08 13:55:26 +00:00
|
|
|
string temp;
|
2001-01-21 21:41:35 +00:00
|
|
|
for (int i = 0; !types[i].latex_name.empty(); ++ i)
|
|
|
|
if (getCmdName() == types[i].latex_name) {
|
|
|
|
temp = _(types[i].short_gui_name);
|
|
|
|
break;
|
|
|
|
}
|
2000-08-08 13:55:26 +00:00
|
|
|
temp += getContents();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
if (!isLatex
|
1999-11-04 01:40:20 +00:00
|
|
|
&& !getOptions().empty()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
temp += "||";
|
|
|
|
temp += getOptions();
|
|
|
|
}
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetRef::latex(Buffer const *, ostream & os,
|
2000-04-19 01:42:55 +00:00
|
|
|
bool /*fragile*/, bool /*fs*/) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-11-04 10:00:12 +00:00
|
|
|
if (getOptions().empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
os << escape(getCommand());
|
1999-09-27 18:44:28 +00:00
|
|
|
else {
|
2000-08-04 13:12:30 +00:00
|
|
|
InsetCommandParams p( getCmdName(), getContents(), "" );
|
|
|
|
os << escape(p.getCommand());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetRef::ascii(Buffer const *, ostream & os, int) const
|
2000-04-24 20:58:23 +00:00
|
|
|
{
|
|
|
|
os << "[" << getContents() << "]";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetRef::linuxdoc(Buffer const *, ostream & os) const
|
2000-03-06 02:42:40 +00:00
|
|
|
{
|
|
|
|
os << "<ref id=\"" << getContents()
|
|
|
|
<< "\" name=\"" << getOptions() << "\" >";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetRef::docBook(Buffer const *, ostream & os) const
|
2000-03-06 02:42:40 +00:00
|
|
|
{
|
2001-06-27 14:10:35 +00:00
|
|
|
if (getOptions().empty()) {
|
|
|
|
os << "<xref linkend=\"" << getContents() << "\"/>";
|
|
|
|
} else {
|
|
|
|
os << "<link linkend=\"" << getContents()
|
|
|
|
<< "\">" << getOptions() << "</link>";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2001-06-27 14:10:35 +00:00
|
|
|
|
|
|
|
return 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-05-19 16:46:01 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetRef::validate(LaTeXFeatures & features) const
|
2000-05-19 16:46:01 +00:00
|
|
|
{
|
2000-08-08 13:55:26 +00:00
|
|
|
if (getCmdName() == "vref" || getCmdName() == "vpageref")
|
2000-05-19 16:46:01 +00:00
|
|
|
features.varioref = true;
|
2000-11-04 10:00:12 +00:00
|
|
|
else if (getCmdName() == "prettyref")
|
2000-05-19 16:46:01 +00:00
|
|
|
features.prettyref = true;
|
2000-08-04 13:12:30 +00:00
|
|
|
}
|
2001-01-21 21:41:35 +00:00
|
|
|
|
|
|
|
InsetRef::type_info InsetRef::types[] = {
|
|
|
|
{ "ref", N_("Standard"), N_("Ref: ")},
|
|
|
|
{ "pageref", N_("Page Number"), N_("Page: ")},
|
|
|
|
{ "vpageref", N_("Textual Page Number"), N_("TextPage: ")},
|
|
|
|
{ "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")},
|
|
|
|
{ "prettyref", N_("PrettyRef"), N_("PrettyRef: ")},
|
|
|
|
{ "", "", "" }
|
|
|
|
};
|
2001-01-26 17:11:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
int InsetRef::getType(string const & name)
|
|
|
|
{
|
|
|
|
for (int i = 0; !types[i].latex_name.empty(); ++i)
|
|
|
|
if (name == types[i].latex_name)
|
|
|
|
return i;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const & InsetRef::getName(int type)
|
|
|
|
{
|
|
|
|
return types[type].latex_name;
|
|
|
|
}
|