X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetHyperlink.cpp;h=e87103ac13a757efb1a5d32a5dab69c1d6243350;hb=bfddee97e191a853f0576f4fab3f095c4e9ce0de;hp=29ce2ddca75585bc141c6eb11fa8c8bfcef0e9a1;hpb=455ac11cfc239621c2603f56257a24abece4373a;p=lyx.git diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp index 29ce2ddca7..e87103ac13 100644 --- a/src/insets/InsetHyperlink.cpp +++ b/src/insets/InsetHyperlink.cpp @@ -100,10 +100,7 @@ bool InsetHyperlink::getStatus(Cursor & cur, FuncRequest const & cmd, void InsetHyperlink::viewTarget() const { - if (getParam("type").empty()) - formats.viewURL(getParam("target")); - - else if (getParam("type") == "file:") { + if (getParam("type") == "file:") { FileName url = makeAbsPath(to_utf8(getParam("target")), buffer().filePath()); string const format = formats.getFormatFromFile(url); formats.view(buffer(), url, format); @@ -111,8 +108,8 @@ void InsetHyperlink::viewTarget() const } -int InsetHyperlink::latex(odocstream & os, - OutputParams const & runparams) const +void InsetHyperlink::latex(otexstream & os, + OutputParams const & runparams) const { docstring url = getParam("target"); docstring name = getParam("name"); @@ -196,8 +193,6 @@ int InsetHyperlink::latex(odocstream & os, // output the ready \href command os << "\\href{" << getParam("type") << url << "}{" << name << '}'; - - return 0; } @@ -230,7 +225,8 @@ int InsetHyperlink::docbook(odocstream & os, OutputParams const &) const docstring InsetHyperlink::xhtml(XHTMLStream & xs, OutputParams const &) const { - docstring const & target = getParam("target"); + docstring const & target = + html::htmlize(getParam("target"), XHTMLStream::ESCAPE_AND); docstring const & name = getParam("name"); xs << html::StartTag("a", to_utf8("href=\"" + target + "\"")); xs << (name.empty() ? target : name); @@ -239,12 +235,23 @@ docstring InsetHyperlink::xhtml(XHTMLStream & xs, OutputParams const &) const } -void InsetHyperlink::tocString(odocstream & os) const +void InsetHyperlink::toString(odocstream & os) const { plaintext(os, OutputParams(0)); } +void InsetHyperlink::forToc(docstring & os, size_t) const +{ + docstring const & n = getParam("name"); + if (!n.empty()) { + os += n; + return; + } + os += getParam("target"); +} + + docstring InsetHyperlink::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*/) const { docstring url = getParam("target"); @@ -264,7 +271,7 @@ void InsetHyperlink::validate(LaTeXFeatures & features) const } -docstring InsetHyperlink::contextMenu(BufferView const &, int, int) const +docstring InsetHyperlink::contextMenuName() const { return from_ascii("context-hyperlink"); }