2 * \file InsetHyperlink.cpp
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.
13 #include "InsetHyperlink.h"
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 InsetHyperlink::InsetHyperlink(InsetCommandParams const & p)
35 : InsetCommand(p, "href")
39 docstring const InsetHyperlink::getScreenLabel(Buffer const &) const
41 docstring const temp = from_ascii("Hyperlink: ");
45 url += getParam("name");
47 url += getParam("target");
50 if (url.length() > 30) {
51 url = url.substr(0, 10) + "..."
52 + url.substr(url.length() - 17, url.length());
58 int InsetHyperlink::latex(Buffer const &, odocstream & os,
59 OutputParams const & runparams) const
61 docstring const & name = getParam("name");
62 if (runparams.moving_arg)
64 //set the target for the name when no name is given
65 if (!getParam("name").empty())
66 os << "\\href{" << getParam("target") << "}{" << getParam("name") << '}';
68 os << "\\href{" << getParam("target") << "}{" << getParam("target") << '}';
73 int InsetHyperlink::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 InsetHyperlink::docbook(Buffer const &, odocstream & os,
91 OutputParams const &) const
94 << subst(getParam("target"), from_ascii("&"), from_ascii("&"))
102 int InsetHyperlink::textString(Buffer const & buf, odocstream & os,
103 OutputParams const & op) const
105 return plaintext(buf, os, op);
109 void InsetHyperlink::validate(LaTeXFeatures & features) const
111 features.require("hyperref");