]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inseturl.C
* In the process of fixing the math background color bug, this commit transfer backgr...
[lyx.git] / src / insets / inseturl.C
index 564e61a3aba189827692463cebae4dc4db024aeb..eb67e6e11775676ceec5706b602e2a0364651c58 100644 (file)
 
 #include "support/std_ostream.h"
 
-using lyx::docstring;
-using lyx::odocstream;
-using lyx::support::subst;
+
+namespace lyx {
+
+using support::subst;
 
 using std::string;
 using std::ostream;
@@ -40,25 +41,24 @@ docstring const InsetUrl::getScreenLabel(Buffer const &) const
        docstring const temp =
                (getCmdName() == "url") ? _("Url: ") : _("HtmlUrl: ");
 
-       string url;
+       docstring url;
 
-       if (!getOptions().empty())
-               url += getOptions();
+       if (!getParam("name").empty())
+               url += getParam("name");
        else
-               url += getContents();
+               url += getParam("target");
 
        // elide if long
        if (url.length() > 30) {
                url = url.substr(0, 10) + "..."
                        + url.substr(url.length() - 17, url.length());
        }
-       // FIXME UNICODE
-       return temp + lyx::from_utf8(url);
+       return temp + url;
 }
 
 
 int InsetUrl::latex(Buffer const &, odocstream & os,
-                   OutputParams const & runparams) const
+                    OutputParams const & runparams) const
 {
        docstring const & name = getParam("name");
        if (!name.empty())
@@ -71,28 +71,30 @@ int InsetUrl::latex(Buffer const &, odocstream & os,
 
 
 int InsetUrl::plaintext(Buffer const &, odocstream & os,
-                   OutputParams const &) const
+                        OutputParams const &) const
 {
-       // FIXME UNICODE
-       os << '[' << lyx::from_utf8(getContents());
-       if (getOptions().empty())
-               os << ']';
+       odocstringstream oss;
+
+       oss << '[' << getParam("target");
+       if (getParam("name").empty())
+               oss << ']';
        else
-               // FIXME UNICODE
-               os << "||" << lyx::from_utf8(getOptions()) << ']';
-       return 0;
+               oss << "||" << getParam("name") << ']';
+
+       docstring const str = oss.str();
+       os << str;
+       return str.size();
 }
 
 
 int InsetUrl::docbook(Buffer const &, odocstream & os,
-                     OutputParams const &) const
+                      OutputParams const &) const
 {
-        // FIXME UNICODE
-       os << "<ulink url=\""
-           << lyx::from_ascii(subst(getContents(), "&", "&amp;"))
-          << "\">"
-           << lyx::from_ascii(getOptions())
-           << "</ulink>";
+       os << "<ulink url=\"" 
+          << subst(getParam("target"), from_ascii("&"), from_ascii("&amp;"))
+          << "\">" 
+          << getParam("name")
+          << "</ulink>";
        return 0;
 }
 
@@ -108,3 +110,6 @@ void InsetUrl::validate(LaTeXFeatures & features) const
 {
        features.require("url");
 }
+
+
+} // namespace lyx