]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inseturl.C
clear()->erase() ; lots of using directives for cxx
[lyx.git] / src / insets / inseturl.C
index d2fb64253128cc1c43f3e053c180d40c9e53ff7f..ae2c16a9fe1028ce8dfef62db6b4a6dfe2470875 100644 (file)
@@ -14,8 +14,7 @@
 #include "LaTeXFeatures.h"
 #include "lyx_gui_misc.h" // CancelCloseBoxCB
 
-extern BufferView * current_view;
-extern void UpdateInset(BufferView *, Inset * inset, bool mark_dirty = true);
+using std::ostream;
 
 InsetUrl::InsetUrl(string const & cmd)
        : fd_form_url(0)
@@ -67,7 +66,11 @@ InsetUrl::~InsetUrl()
 
 void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long)
 {
-       InsetUrl * inset = static_cast<InsetUrl*>(ob->u_vdata);
+       Holder * holder = static_cast<Holder*>(ob->u_vdata);
+       
+       InsetUrl * inset = holder->inset;
+       BufferView * bv = holder->view;
+       
        string url = fl_get_input(inset->fd_form_url->url_name);
        string name = fl_get_input(inset->fd_form_url->name_name);
        string cmdname;
@@ -76,7 +79,7 @@ void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long)
        else
                cmdname = "url";
        
-       Buffer * buffer = current_view->buffer();
+       Buffer * buffer = bv->buffer();
        
        if ((url != inset->getContents() ||
             name != inset->getOptions() ||
@@ -90,7 +93,7 @@ void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long)
                        inset->flag = InsetUrl::URL;
                else
                        inset->flag = InsetUrl::HTML_URL;
-               UpdateInset(current_view, inset);
+               bv->updateInset(inset, true);
        }
        
        if (inset->fd_form_url) {
@@ -107,19 +110,27 @@ extern "C" void C_InsetUrl_CloseUrlCB(FL_OBJECT * ob, long data)
 }
 
 
-void InsetUrl::Edit(int, int)
+char const * InsetUrl::EditMessage() const 
+{
+       return _("Opened Url");
+}
+
+
+void InsetUrl::Edit(BufferView * bv, int, int, unsigned int)
 {
        static int ow = -1, oh;
 
-       if(current_view->buffer()->isReadonly())
-               WarnReadonly(current_view->buffer()->fileName());
+       if(bv->buffer()->isReadonly())
+               WarnReadonly(bv->buffer()->fileName());
 
        if (!fd_form_url) {
                fd_form_url = create_form_form_url();
-               fd_form_url->button_close->u_vdata = this;
+               holder.inset = this;
+               fd_form_url->button_close->u_vdata = &holder;
                fl_set_form_atclose(fd_form_url->form_url,
                                    CancelCloseBoxCB, 0);
        }
+       holder.view = bv;
        fl_set_input(fd_form_url->url_name, getContents().c_str());
        fl_set_input(fd_form_url->name_name, getOptions().c_str());
        switch(flag) {
@@ -162,44 +173,42 @@ string InsetUrl::getScreenLabel() const
 }
 
 
-int InsetUrl::Latex(ostream & os, signed char fragile) const
-{
-       string latex_output;
-       int res = Latex(latex_output, fragile);
-       os << latex_output;
-
-       return res;
-}
-
-
-int InsetUrl::Latex(string & file, signed char fragile) const
+int InsetUrl::Latex(ostream & os,
+                   bool fragile, bool /*free_spc*/) const
 {
        if (!getOptions().empty())
-               file += getOptions() + ' ';
+               os << getOptions() + ' ';
        if (fragile)
-               file += "\\protect";
+               os << "\\protect";
+       os << "\\url{" << getContents() << '}';
+       return 0;
+}
 
-       file += "\\url{" + getContents() + '}';
 
+int InsetUrl::Ascii(ostream & os) const
+{
+       if (getOptions().empty())
+               os << "[" << getContents() << "]";
+       else
+               os << "[" << getContents() << "||" <<  getOptions() << "]";
        return 0;
 }
 
 
-int InsetUrl::Linuxdoc(string & file) const
+int InsetUrl::Linuxdoc(ostream & os) const
 {
-       file +=  "<"+ getCmdName() +
-                " url=\""  + getContents()+"\"" +
-                " name=\"" + getOptions() +"\">";
+       os << "<" << getCmdName()
+          << " url=\""  << getContents() << "\""
+          << " name=\"" << getOptions() << "\">";
 
        return 0;
 }
 
 
-int InsetUrl::DocBook(string & file) const
+int InsetUrl::DocBook(ostream & os) const
 {
-       file +=  "<ulink url=\""  + getContents() + "\">" +
-                getOptions() +"</ulink>";
-
+       os << "<ulink url=\"" << getContents() << "\">"
+          << getOptions() << "</ulink>";
        return 0;
 }