]> 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 c60b5f620bbf10421ddc6b2c6df4dd64a3657239..4bd7f5765a8d581e512c828af431d7aafdd426ab 100644 (file)
 #include <config.h>
 
 #include "inseturl.h"
+
+#include "dispatchresult.h"
 #include "funcrequest.h"
-#include "BufferView.h"
 #include "LaTeXFeatures.h"
-#include "latexrunparams.h"
-#include "frontends/LyXView.h"
-#include "debug.h"
-#include "frontends/Dialogs.h"
-#include "support/lstrings.h"
 #include "gettext.h"
+#include "outputparams.h"
 
-using namespace lyx::support;
+#include "support/lstrings.h"
 
-using std::ostream;
+#include "support/std_ostream.h"
 
 
-InsetUrl::InsetUrl(InsetCommandParams const & p)
-               : InsetCommand(p)
-{}
+namespace lyx {
 
+using support::subst;
 
-// InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
-//             : InsetCommand(p, false)
-// {}
-
-
-InsetUrl::~InsetUrl()
-{
-       InsetCommandMailer("url", *this).hideDialog();
-}
+using std::string;
+using std::ostream;
 
 
-dispatch_result InsetUrl::localDispatch(FuncRequest const & cmd)
-{
-       switch (cmd.action) {
-               case LFUN_INSET_EDIT:
-                       InsetCommandMailer("url", *this).showDialog(cmd.view());
-                       return DISPATCHED;
-               default:
-                       return InsetCommand::localDispatch(cmd);
-       }
-}
+InsetUrl::InsetUrl(InsetCommandParams const & p)
+       : InsetCommand(p, "url")
+{}
 
 
-string const InsetUrl::getScreenLabel(Buffer const &) const
+docstring const InsetUrl::getScreenLabel(Buffer const &) const
 {
-       string temp;
-       if (getCmdName() == "url")
-               temp = _("Url: ");
-       else
-               temp = _("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) {
@@ -78,43 +57,47 @@ string const InsetUrl::getScreenLabel(Buffer const &) const
 }
 
 
-int InsetUrl::latex(Buffer const &, ostream & os,
-                   LatexRunParams const & runparams) const
+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::ascii(Buffer const &, ostream & os, int) const
+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::linuxdoc(Buffer const &, ostream & os) const
+int InsetUrl::docbook(Buffer const &, odocstream & os,
+                     OutputParams const &) const
 {
-       os << '<' << getCmdName()
-          << " url=\""  << getContents() << "\""
-          << " name=\"" << getOptions() << "\">";
-
+       os << "<ulink url=\"" 
+          << subst(getParam("target"), from_ascii("&"), from_ascii("&amp;"))
+          << "\">" 
+          << getParam("name")
+          << "</ulink>";
        return 0;
 }
 
 
-int InsetUrl::docbook(Buffer const &, ostream & os, bool) const
+int InsetUrl::textString(Buffer const & buf, odocstream & os,
+                      OutputParams const & op) const
 {
-       os << "<ulink url=\"" << subst(getContents(),"&","&amp;")
-          << "\">" << getOptions() << "</ulink>";
-       return 0;
+       return plaintext(buf, os, op);
 }
 
 
@@ -122,3 +105,6 @@ void InsetUrl::validate(LaTeXFeatures & features) const
 {
        features.require("url");
 }
+
+
+} // namespace lyx