]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetHyperlink.cpp
pimpl not needed here
[lyx.git] / src / insets / InsetHyperlink.cpp
index 1b880add78102c5ebd5f52b0c55d3ad4ca7b6a91..509fedfe7e3b20583040235f95e11f67c93ef4d5 100644 (file)
 #include "support/lstrings.h"
 #include "support/docstream.h"
 
+using std::string;
+using std::find;
+using std::replace;
 
 namespace lyx {
 
 using support::subst;
 
-using std::string;
-using std::find;
-using std::replace;
-
 
 InsetHyperlink::InsetHyperlink(InsetCommandParams const & p)
        : InsetCommand(p, "href")
@@ -101,7 +100,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 +113,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;
 }