2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file ref_inset.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
#include <config.h>
|
2002-06-24 15:51:35 +00:00
|
|
|
|
|
|
|
|
|
#include "ref_inset.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "math_data.h"
|
2003-03-04 16:39:13 +00:00
|
|
|
|
#include "math_factory.h"
|
|
|
|
|
|
2002-06-24 15:51:35 +00:00
|
|
|
|
#include "BufferView.h"
|
2004-01-20 14:25:24 +00:00
|
|
|
|
#include "cursor.h"
|
2003-03-04 16:39:13 +00:00
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "funcrequest.h"
|
2003-06-02 10:03:27 +00:00
|
|
|
|
#include "math_support.h"
|
2002-06-24 15:51:35 +00:00
|
|
|
|
#include "gettext.h"
|
|
|
|
|
#include "LaTeXFeatures.h"
|
2003-03-04 16:39:13 +00:00
|
|
|
|
|
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
#include "frontends/Dialogs.h"
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2003-08-02 11:30:30 +00:00
|
|
|
|
using std::endl;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
|
2002-06-24 15:51:35 +00:00
|
|
|
|
|
2004-01-20 14:25:24 +00:00
|
|
|
|
|
2002-06-24 15:51:35 +00:00
|
|
|
|
RefInset::RefInset()
|
|
|
|
|
: CommandInset("ref")
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RefInset::RefInset(string const & data)
|
|
|
|
|
: CommandInset(data)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
auto_ptr<InsetBase> RefInset::clone() const
|
2002-06-24 15:51:35 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new RefInset(*this));
|
2002-06-24 15:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RefInset::infoize(std::ostream & os) const
|
|
|
|
|
{
|
|
|
|
|
os << "Ref: " << cell(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-02-16 11:58:51 +00:00
|
|
|
|
void RefInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
2002-06-24 15:51:35 +00:00
|
|
|
|
{
|
2002-08-12 09:53:04 +00:00
|
|
|
|
switch (cmd.action) {
|
2003-10-17 18:01:15 +00:00
|
|
|
|
case LFUN_INSET_MODIFY:
|
|
|
|
|
if (cmd.getArg(0) == "ref") {
|
|
|
|
|
MathArray ar;
|
2004-02-16 11:58:51 +00:00
|
|
|
|
if (createMathInset_fromDialogStr(cmd.argument, ar)) {
|
|
|
|
|
*this = *ar[0].nucleus()->asRefInset();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-10-17 18:01:15 +00:00
|
|
|
|
}
|
2004-02-16 11:58:51 +00:00
|
|
|
|
cur.notdispatched();
|
|
|
|
|
return;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
|
2003-10-17 18:01:15 +00:00
|
|
|
|
case LFUN_MOUSE_RELEASE:
|
|
|
|
|
if (cmd.button() == mouse_button::button3) {
|
|
|
|
|
lyxerr << "trying to goto ref" << cell(0) << endl;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.bv().dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
|
2004-02-16 11:58:51 +00:00
|
|
|
|
return;
|
2003-10-17 18:01:15 +00:00
|
|
|
|
}
|
|
|
|
|
if (cmd.button() == mouse_button::button1) {
|
|
|
|
|
// Eventually trigger dialog with button 3
|
|
|
|
|
// not 1
|
|
|
|
|
string const data = createDialogStr("ref");
|
2004-01-20 14:25:24 +00:00
|
|
|
|
cur.bv().owner()->getDialogs().show("ref", data, this);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
return;
|
2003-10-17 18:01:15 +00:00
|
|
|
|
}
|
2004-02-16 11:58:51 +00:00
|
|
|
|
cur.notdispatched();
|
|
|
|
|
return;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
|
2003-10-17 18:01:15 +00:00
|
|
|
|
case LFUN_MOUSE_PRESS:
|
|
|
|
|
case LFUN_MOUSE_MOTION:
|
|
|
|
|
// eat other mouse commands
|
2004-02-16 11:58:51 +00:00
|
|
|
|
return;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
|
2003-10-17 18:01:15 +00:00
|
|
|
|
default:
|
2004-02-16 11:58:51 +00:00
|
|
|
|
CommandInset::priv_dispatch(cur, cmd);
|
|
|
|
|
return;
|
2002-06-24 15:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-12 08:52:36 +00:00
|
|
|
|
string const RefInset::screenLabel() const
|
2002-06-24 15:51:35 +00:00
|
|
|
|
{
|
|
|
|
|
string str;
|
|
|
|
|
for (int i = 0; !types[i].latex_name.empty(); ++i)
|
2003-06-12 08:52:36 +00:00
|
|
|
|
if (commandname() == types[i].latex_name) {
|
2002-06-24 15:51:35 +00:00
|
|
|
|
str = _(types[i].short_gui_name);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
str += asString(cell(0));
|
|
|
|
|
|
|
|
|
|
//if (/* !isLatex && */ !cell(0).empty()) {
|
|
|
|
|
// str += "||";
|
|
|
|
|
// str += asString(cell(1));
|
|
|
|
|
//}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void RefInset::validate(LaTeXFeatures & features) const
|
|
|
|
|
{
|
2003-06-12 08:52:36 +00:00
|
|
|
|
if (commandname() == "vref" || commandname() == "vpageref")
|
2002-06-24 15:51:35 +00:00
|
|
|
|
features.require("varioref");
|
2003-06-12 08:52:36 +00:00
|
|
|
|
else if (commandname() == "prettyref")
|
2002-06-24 15:51:35 +00:00
|
|
|
|
features.require("prettyref");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
int RefInset::plaintext(std::ostream & os, OutputParams const &) const
|
2002-06-24 15:51:35 +00:00
|
|
|
|
{
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '[' << asString(cell(0)) << ']';
|
2002-06-24 15:51:35 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
int RefInset::linuxdoc(std::ostream & os, OutputParams const &) const
|
2002-06-24 15:51:35 +00:00
|
|
|
|
{
|
|
|
|
|
os << "<ref id=\"" << asString(cell(0))
|
|
|
|
|
<< "\" name=\"" << asString(cell(1)) << "\" >";
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
int RefInset::docbook(std::ostream & os, OutputParams const &) const
|
2002-06-24 15:51:35 +00:00
|
|
|
|
{
|
|
|
|
|
if (cell(1).empty()) {
|
|
|
|
|
os << "<xref linkend=\"" << asString(cell(0)) << "\">";
|
|
|
|
|
} else {
|
|
|
|
|
os << "<link linkend=\"" << asString(cell(0))
|
|
|
|
|
<< "\">" << asString(cell(1)) << "</link>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
2003-02-26 11:37:53 +00:00
|
|
|
|
|
|
|
|
|
|
2003-02-13 08:12:51 +00:00
|
|
|
|
RefInset::ref_type_info RefInset::types[] = {
|
2003-04-24 12:16:56 +00:00
|
|
|
|
{ "ref", N_("Standard"), N_("Ref: ")},
|
|
|
|
|
{ "eqref", N_("Equation"), N_("EqRef: ")},
|
|
|
|
|
{ "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: ")},
|
2002-06-24 15:51:35 +00:00
|
|
|
|
{ "", "", "" }
|
|
|
|
|
};
|