X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finseturl.C;h=4bd7f5765a8d581e512c828af431d7aafdd426ab;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=0c1c1f17aac7bc9d86c6b4ea156d1c219054ad3b;hpb=7ac850e36d4dba4007ca2c0949f8062cc207eaa3;p=lyx.git diff --git a/src/insets/inseturl.C b/src/insets/inseturl.C index 0c1c1f17aa..4bd7f5765a 100644 --- a/src/insets/inseturl.C +++ b/src/insets/inseturl.C @@ -5,62 +5,48 @@ * * \author José Matos * - * Full author contact details are available in file CREDITS + * Full author contact details are available in file CREDITS. */ -#include +#include #include "inseturl.h" -#include "BufferView.h" + +#include "dispatchresult.h" +#include "funcrequest.h" #include "LaTeXFeatures.h" -#include "frontends/LyXView.h" -#include "debug.h" -#include "frontends/Dialogs.h" -#include "support/lstrings.h" #include "gettext.h" +#include "outputparams.h" -using std::ostream; - +#include "support/lstrings.h" -InsetUrl::InsetUrl(InsetCommandParams const & p, bool) - : InsetCommand(p) -{} +#include "support/std_ostream.h" -InsetUrl::~InsetUrl() -{ - InsetCommandMailer mailer("url", *this); - mailer.hideDialog(); -} +namespace lyx { +using support::subst; -void InsetUrl::edit(BufferView * bv, int, int, mouse_button::state) -{ - InsetCommandMailer mailer("url", *this); - mailer.showDialog(bv); -} +using std::string; +using std::ostream; -void InsetUrl::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); -} +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) { @@ -71,43 +57,47 @@ string const InsetUrl::getScreenLabel(Buffer const *) const } -int InsetUrl::latex(Buffer const *, ostream & os, - bool fragile, bool /*free_spc*/) const +int InsetUrl::latex(Buffer const &, odocstream & os, + OutputParams const & runparams) const { - if (!getOptions().empty()) - os << getOptions() + ' '; - if (fragile) + 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 << "" + << getParam("name") + << ""; return 0; } -int InsetUrl::docbook(Buffer const *, ostream & os, bool) const +int InsetUrl::textString(Buffer const & buf, odocstream & os, + OutputParams const & op) const { - os << "" << getOptions() << ""; - return 0; + return plaintext(buf, os, op); } @@ -115,3 +105,6 @@ void InsetUrl::validate(LaTeXFeatures & features) const { features.require("url"); } + + +} // namespace lyx