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
78 oss << '[' << getParam("target");
79 if (getParam("name").empty())
82 oss << "||" << getParam("name") << ']';
84 docstring const str = oss.str();
90 int InsetUrl::docbook(Buffer const &, odocstream & os,
91 OutputParams const &) const
94 << subst(getParam("target"), from_ascii("&"), from_ascii("&"))
102 int InsetUrl::textString(Buffer const & buf, odocstream & os,
103 OutputParams const & op) const
105 return plaintext(buf, os, op);
109 void InsetUrl::validate(LaTeXFeatures & features) const
111 features.require("url");