]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inseturl.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[lyx.git] / src / insets / inseturl.C
index b6f5e82d78b7d8a6588d7de83f74cfe987a9e551..4bd7f5765a8d581e512c828af431d7aafdd426ab 100644 (file)
 
 #include "support/std_ostream.h"
 
-using lyx::support::subst;
+
+namespace lyx {
+
+using support::subst;
 
 using std::string;
 using std::ostream;
@@ -33,21 +36,17 @@ InsetUrl::InsetUrl(InsetCommandParams const & p)
 {}
 
 
-string const InsetUrl::getScreenLabel(Buffer const &) const
+docstring const InsetUrl::getScreenLabel(Buffer const &) const
 {
-       string temp;
-       // FIXME UNICODE
-       if (getCmdName() == "url")
-               temp = lyx::to_utf8(_("Url: "));
-       else
-               temp = lyx::to_utf8(_("HtmlUrl: "));
+       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) {
@@ -58,39 +57,44 @@ string const InsetUrl::getScreenLabel(Buffer const &) const
 }
 
 
-int InsetUrl::latex(Buffer const &, ostream & os,
+int InsetUrl::latex(Buffer const &, odocstream & os,
                    OutputParams const & runparams) const
 {
-       if (!getOptions().empty())
-               os << getOptions() + ' ';
+       docstring const & name = getParam("name");
+       if (!name.empty())
+               os << name + ' ';
        if (runparams.moving_arg)
                os << "\\protect";
-       os << "\\url{" << getContents() << '}';
+       os << "\\url{" << getParam("target") << '}';
        return 0;
 }
 
 
-int InsetUrl::plaintext(Buffer const &, ostream & os,
+int InsetUrl::plaintext(Buffer const &, odocstream & os,
                    OutputParams const &) const
 {
-       if (getOptions().empty())
-               os << '[' << getContents() << ']';
+       os << '[' << getParam("target");
+       if (getParam("name").empty())
+               os << ']';
        else
-               os << '[' << getContents() << "||" <<  getOptions() << ']';
+               os << "||" << getParam("name") << ']';
        return 0;
 }
 
 
-int InsetUrl::docbook(Buffer const &, ostream & os,
+int InsetUrl::docbook(Buffer const &, odocstream & os,
                      OutputParams const &) const
 {
-       os << "<ulink url=\"" << subst(getContents(),"&","&amp;")
-          << "\">" << getOptions() << "</ulink>";
+       os << "<ulink url=\"" 
+          << subst(getParam("target"), from_ascii("&"), from_ascii("&amp;"))
+          << "\">" 
+          << getParam("name")
+          << "</ulink>";
        return 0;
 }
 
 
-int InsetUrl::textString(Buffer const & buf, ostream & os,
+int InsetUrl::textString(Buffer const & buf, odocstream & os,
                       OutputParams const & op) const
 {
        return plaintext(buf, os, op);
@@ -101,3 +105,6 @@ void InsetUrl::validate(LaTeXFeatures & features) const
 {
        features.require("url");
 }
+
+
+} // namespace lyx