X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetHyperlink.cpp;h=908ddd1337c099e35bfc2b97cb58a427ebf0e4e5;hb=c3a8b3a566e9e90f9ade72acbc723232d721d0b1;hp=1b880add78102c5ebd5f52b0c55d3ad4ca7b6a91;hpb=52d0e138090184c6ac6bce41cd47c3053053233f;p=lyx.git diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp index 1b880add78..908ddd1337 100644 --- a/src/insets/InsetHyperlink.cpp +++ b/src/insets/InsetHyperlink.cpp @@ -16,21 +16,17 @@ #include "DispatchResult.h" #include "FuncRequest.h" #include "LaTeXFeatures.h" -#include "gettext.h" +#include "support/gettext.h" #include "OutputParams.h" #include "support/lstrings.h" #include "support/docstream.h" +using namespace std; +using namespace lyx::support; namespace lyx { -using support::subst; - -using std::string; -using std::find; -using std::replace; - InsetHyperlink::InsetHyperlink(InsetCommandParams const & p) : InsetCommand(p, "href") @@ -101,7 +97,7 @@ int InsetHyperlink::latex(Buffer const &, odocstream & os, for (size_t i = 0, pos; (pos = name.find('\\', i)) != string::npos; i = pos + 2) { - if (name[pos + 1] != '\\') + if (name[pos + 1] != '\\') name.replace(pos, 1, textbackslash); } for (int k = 0; k < 6; k++) { @@ -114,25 +110,20 @@ int InsetHyperlink::latex(Buffer const &, odocstream & os, // replace the tilde by the \sim character as suggested in the LaTeX FAQ // for URLs docstring const sim = from_ascii("$\\sim$"); - for (int i = 0, pos; + for (size_t i = 0, pos; (pos = name.find('~', i)) != string::npos; i = pos + 1) name.replace(pos, 1, sim); } // end if (!name.empty()) - //for the case there is no name given, the target is set as name - docstring const urlname = url; - // set the hyperlink type - url += getParam("type"); - if (runparams.moving_arg) os << "\\protect"; - //set the target for the name when no name is given - if (!name.empty()) - os << "\\href{" << url << "}{" << name << '}'; - else - os << "\\href{" << url << "}{" << urlname << '}'; + + //for the case there is no name given, the target is set as name + os << "\\href{" << getParam("type") << url << "}{" + << (name.empty()? url : name) << '}'; + return 0; } @@ -166,10 +157,9 @@ int InsetHyperlink::docbook(Buffer const &, odocstream & os, } -int InsetHyperlink::textString(Buffer const & buf, odocstream & os, - OutputParams const & op) const +void InsetHyperlink::textString(Buffer const & buf, odocstream & os) const { - return plaintext(buf, os, op); + plaintext(buf, os, OutputParams(0)); }