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"
26 using lyx::odocstream;
27 using lyx::support::subst;
33 InsetUrl::InsetUrl(InsetCommandParams const & p)
34 : InsetCommand(p, "url")
38 docstring const InsetUrl::getScreenLabel(Buffer const &) const
40 docstring const temp =
41 (getCmdName() == "url") ? _("Url: ") : _("HtmlUrl: ");
45 if (!getOptions().empty())
51 if (url.length() > 30) {
52 url = url.substr(0, 10) + "..."
53 + url.substr(url.length() - 17, url.length());
56 return temp + lyx::from_utf8(url);
60 int InsetUrl::latex(Buffer const &, odocstream & os,
61 OutputParams const & runparams) const
63 docstring const & name = getParam("name");
66 if (runparams.moving_arg)
68 os << "\\url{" << getParam("target") << '}';
73 int InsetUrl::plaintext(Buffer const &, odocstream & os,
74 OutputParams const &) const
77 os << '[' << lyx::from_utf8(getContents());
78 if (getOptions().empty())
82 os << "||" << lyx::from_utf8(getOptions()) << ']';
87 int InsetUrl::docbook(Buffer const &, odocstream & os,
88 OutputParams const &) const
92 << lyx::from_ascii(subst(getContents(), "&", "&"))
94 << lyx::from_ascii(getOptions())
100 int InsetUrl::textString(Buffer const & buf, odocstream & os,
101 OutputParams const & op) const
103 return plaintext(buf, os, op);
107 void InsetUrl::validate(LaTeXFeatures & features) const
109 features.require("url");