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"
34 InsetUrl::InsetUrl(InsetCommandParams const & p)
35 : InsetCommand(p, "url")
39 docstring const InsetUrl::getScreenLabel(Buffer const &) const
41 docstring const temp =
42 (getCmdName() == "url") ? _("Url: ") : _("HtmlUrl: ");
46 if (!getParam("name").empty())
47 url += getParam("name");
49 url += getParam("target");
52 if (url.length() > 30) {
53 url = url.substr(0, 10) + "..."
54 + url.substr(url.length() - 17, url.length());
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
76 os << '[' << getParam("target");
77 if (getParam("name").empty())
80 os << "||" << getParam("name") << ']';
85 int InsetUrl::docbook(Buffer const &, odocstream & os,
86 OutputParams const &) const
89 << subst(getParam("target"), from_ascii("&"), from_ascii("&"))
97 int InsetUrl::textString(Buffer const & buf, odocstream & os,
98 OutputParams const & op) const
100 return plaintext(buf, os, op);
104 void InsetUrl::validate(LaTeXFeatures & features) const
106 features.require("url");