1999-09-27 18:44:28 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "inseturl.h"
|
2000-07-27 08:55:59 +00:00
|
|
|
#include "BufferView.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2000-07-27 08:55:59 +00:00
|
|
|
#include "LyXView.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "frontends/Dialogs.h"
|
2001-04-05 12:26:41 +00:00
|
|
|
#include "gettext.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::ostream;
|
2000-02-22 00:36:17 +00:00
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
|
2000-07-27 08:55:59 +00:00
|
|
|
: InsetCommand(p)
|
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2001-06-29 06:30:53 +00:00
|
|
|
void InsetUrl::edit(BufferView * bv, int, int, unsigned int)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-07-27 08:55:59 +00:00
|
|
|
bv->owner()->getDialogs()->showUrl( this );
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-20 14:18:48 +00:00
|
|
|
void InsetUrl::edit(BufferView * bv, bool)
|
|
|
|
{
|
|
|
|
edit(bv, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-28 12:24:16 +00:00
|
|
|
string const InsetUrl::getScreenLabel(Buffer const *) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string temp;
|
2000-11-04 10:00:12 +00:00
|
|
|
if (getCmdName() == "url" )
|
2000-07-27 08:55:59 +00:00
|
|
|
temp = _("Url: ");
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
2000-07-27 08:55:59 +00:00
|
|
|
temp = _("HtmlUrl: ");
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
if (!getOptions().empty())
|
1999-09-27 18:44:28 +00:00
|
|
|
temp += getOptions();
|
2000-07-27 08:55:59 +00:00
|
|
|
else
|
|
|
|
temp += getContents();
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-29 06:30:53 +00:00
|
|
|
int InsetUrl::latex(Buffer const *, ostream & os,
|
2000-04-19 01:42:55 +00:00
|
|
|
bool fragile, bool /*free_spc*/) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-02 02:19:43 +00:00
|
|
|
if (!getOptions().empty())
|
|
|
|
os << getOptions() + ' ';
|
|
|
|
if (fragile)
|
|
|
|
os << "\\protect";
|
|
|
|
os << "\\url{" << getContents() << '}';
|
|
|
|
return 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-03-06 02:42:40 +00:00
|
|
|
|
2001-06-29 06:30:53 +00:00
|
|
|
int InsetUrl::ascii(Buffer const *, ostream & os, int) const
|
2000-04-24 20:58:23 +00:00
|
|
|
{
|
|
|
|
if (getOptions().empty())
|
|
|
|
os << "[" << getContents() << "]";
|
|
|
|
else
|
|
|
|
os << "[" << getContents() << "||" << getOptions() << "]";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-29 06:30:53 +00:00
|
|
|
int InsetUrl::linuxdoc(Buffer const *, ostream & os) const
|
2000-03-06 02:42:40 +00:00
|
|
|
{
|
|
|
|
os << "<" << getCmdName()
|
|
|
|
<< " url=\"" << getContents() << "\""
|
|
|
|
<< " name=\"" << getOptions() << "\">";
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-30 11:56:04 +00:00
|
|
|
int InsetUrl::docbook(Buffer const *, ostream & os) const
|
2000-03-06 02:42:40 +00:00
|
|
|
{
|
|
|
|
os << "<ulink url=\"" << getContents() << "\">"
|
|
|
|
<< getOptions() << "</ulink>";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-06-29 06:30:53 +00:00
|
|
|
void InsetUrl::validate(LaTeXFeatures & features) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-11-19 15:34:11 +00:00
|
|
|
features.require("url");
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|