2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file inseturl.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Jos<EFBFBD> Matos
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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"
|
2002-05-23 12:08:47 +00:00
|
|
|
|
#include "frontends/LyXView.h"
|
2000-07-27 08:55:59 +00:00
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "frontends/Dialogs.h"
|
2002-02-13 14:34:23 +00:00
|
|
|
|
#include "support/lstrings.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
|
|
|
|
|
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
|
InsetUrl::~InsetUrl()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-02-25 14:51:38 +00:00
|
|
|
|
InsetCommandMailer mailer("url", *this);
|
|
|
|
|
mailer.hideDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-10 22:12:07 +00:00
|
|
|
|
void InsetUrl::edit(BufferView * bv, int, int, mouse_button::state)
|
2003-02-25 14:51:38 +00:00
|
|
|
|
{
|
|
|
|
|
InsetCommandMailer mailer("url", *this);
|
2003-03-10 22:12:07 +00:00
|
|
|
|
mailer.showDialog(bv);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-20 14:18:48 +00:00
|
|
|
|
void InsetUrl::edit(BufferView * bv, bool)
|
|
|
|
|
{
|
2002-05-26 17:33:14 +00:00
|
|
|
|
edit(bv, 0, 0, mouse_button::none);
|
2001-07-20 14:18:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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;
|
2002-02-16 15:59:55 +00:00
|
|
|
|
if (getCmdName() == "url")
|
2000-07-27 08:55:59 +00:00
|
|
|
|
temp = _("Url: ");
|
2002-03-21 17:09:55 +00:00
|
|
|
|
else
|
2000-07-27 08:55:59 +00:00
|
|
|
|
temp = _("HtmlUrl: ");
|
|
|
|
|
|
2002-08-25 01:15:01 +00:00
|
|
|
|
string url;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (!getOptions().empty())
|
2002-08-25 01:15:01 +00:00
|
|
|
|
url += getOptions();
|
2000-07-27 08:55:59 +00:00
|
|
|
|
else
|
2002-08-25 01:15:01 +00:00
|
|
|
|
url += getContents();
|
|
|
|
|
|
|
|
|
|
// elide if long
|
|
|
|
|
if (url.length() > 30) {
|
|
|
|
|
url = url.substr(0, 10) + "..."
|
|
|
|
|
+ url.substr(url.length() - 17, url.length());
|
|
|
|
|
}
|
|
|
|
|
return temp + url;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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())
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '[' << getContents() << ']';
|
2000-04-24 20:58:23 +00:00
|
|
|
|
else
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '[' << getContents() << "||" << getOptions() << ']';
|
2000-04-24 20:58:23 +00:00
|
|
|
|
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
|
|
|
|
{
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '<' << getCmdName()
|
2000-03-06 02:42:40 +00:00
|
|
|
|
<< " url=\"" << getContents() << "\""
|
|
|
|
|
<< " name=\"" << getOptions() << "\">";
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
int InsetUrl::docbook(Buffer const *, ostream & os, bool) const
|
2000-03-06 02:42:40 +00:00
|
|
|
|
{
|
2002-02-13 14:34:23 +00:00
|
|
|
|
os << "<ulink url=\"" << subst(getContents(),"&","&")
|
|
|
|
|
<< "\">" << getOptions() << "</ulink>";
|
2000-03-06 02:42:40 +00:00
|
|
|
|
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
|
|
|
|
}
|