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 "dispatchresult.h"
16 #include "funcrequest.h"
17 #include "LaTeXFeatures.h"
19 #include "outputparams.h"
21 #include "support/lstrings.h"
23 #include "support/std_ostream.h"
25 using lyx::support::subst;
31 InsetUrl::InsetUrl(InsetCommandParams const & p)
32 : InsetCommand(p, "url")
36 string const InsetUrl::getScreenLabel(Buffer const &) const
40 if (getCmdName() == "url")
41 temp = lyx::to_utf8(_("Url: "));
43 temp = lyx::to_utf8(_("HtmlUrl: "));
47 if (!getOptions().empty())
53 if (url.length() > 30) {
54 url = url.substr(0, 10) + "..."
55 + url.substr(url.length() - 17, url.length());
61 int InsetUrl::latex(Buffer const &, ostream & os,
62 OutputParams const & runparams) const
64 if (!getOptions().empty())
65 os << getOptions() + ' ';
66 if (runparams.moving_arg)
68 os << "\\url{" << getContents() << '}';
73 int InsetUrl::plaintext(Buffer const &, ostream & os,
74 OutputParams const &) const
76 if (getOptions().empty())
77 os << '[' << getContents() << ']';
79 os << '[' << getContents() << "||" << getOptions() << ']';
84 int InsetUrl::docbook(Buffer const &, ostream & os,
85 OutputParams const &) const
87 os << "<ulink url=\"" << subst(getContents(),"&","&")
88 << "\">" << getOptions() << "</ulink>";
93 int InsetUrl::textString(Buffer const & buf, ostream & os,
94 OutputParams const & op) const
96 return plaintext(buf, os, op);
100 void InsetUrl::validate(LaTeXFeatures & features) const
102 features.require("url");