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 (!getParam("name").empty())
46 url += getParam("name");
48 url += getParam("target");
51 if (url.length() > 30) {
52 url = url.substr(0, 10) + "..."
53 + url.substr(url.length() - 17, url.length());
59 int InsetUrl::latex(Buffer const &, odocstream & os,
60 OutputParams const & runparams) const
62 docstring const & name = getParam("name");
65 if (runparams.moving_arg)
67 os << "\\url{" << getParam("target") << '}';
72 int InsetUrl::plaintext(Buffer const &, odocstream & os,
73 OutputParams const &) const
75 os << '[' << getParam("target");
76 if (getParam("name").empty())
79 os << "||" << getParam("name") << ']';
84 int InsetUrl::docbook(Buffer const &, odocstream & os,
85 OutputParams const &) const
88 << subst(getParam("target"), lyx::from_ascii("&"), lyx::from_ascii("&"))
96 int InsetUrl::textString(Buffer const & buf, odocstream & os,
97 OutputParams const & op) const
99 return plaintext(buf, os, op);
103 void InsetUrl::validate(LaTeXFeatures & features) const
105 features.require("url");