]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetbib.C
clear()->erase() ; lots of using directives for cxx
[lyx.git] / src / insets / insetbib.C
index d8e5c8b15a053ea8400723b7e90cbeee5d10ae10..7bebfb9d1fba3028f8881902b815f4a3227d342d 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <fstream>
 using std::ifstream;
+using std::getline;
 
 #include <cstdlib>
 
@@ -21,13 +22,15 @@ using std::ifstream;
 #include "lyxtext.h"
 #include "support/filetools.h"
 
+using std::ostream;
+using std::endl;
+
 extern BufferView * current_view;
 
 FD_citation_form * citation_form = 0;
 FD_bibitem_form * bibitem_form = 0;
 static Combox * bibcombox = 0;
 
-extern void UpdateInset(BufferView *, Inset * inset, bool mark_dirty = true);
 void BibitemUpdate(Combox *);
 FD_citation_form * create_form_citation_form(void);
 FD_bibitem_form * create_form_bibitem_form(void);
@@ -49,7 +52,7 @@ extern "C" void bibitem_cb(FL_OBJECT *, long data)
                        fl_hide_form(citation_form->citation_form);
                        // shouldn't mark the buffer dirty unless something
                        // was actually altered
-                       UpdateInset(holder->view, inset);
+                       holder->view->updateInset(inset, true);
                        break;
                }
                // fall through to Cancel on RO-mode
@@ -157,7 +160,7 @@ InsetCitation::~InsetCitation()
 }
 
 
-void InsetCitation::Edit(BufferView * bv, int, int)
+void InsetCitation::Edit(BufferView * bv, int, int, unsigned int)
 {
        if(bv->buffer()->isReadonly())
                WarnReadonly(bv->buffer()->fileName());
@@ -221,7 +224,8 @@ InsetBibKey::InsetBibKey(InsetBibKey const * b):
 InsetBibKey::~InsetBibKey()
 {
        if(bibitem_form && bibitem_form->bibitem_form
-          && bibitem_form->bibitem_form->visible)
+          && bibitem_form->bibitem_form->visible
+          && bibitem_form->bibitem_form->u_vdata == &holder)
                fl_hide_form(bibitem_form->bibitem_form);
 }
 
@@ -240,14 +244,13 @@ void InsetBibKey::setCounter(int c)
 // of time cause LyX3 won't use lyxlex anyway.  (ale)
 void InsetBibKey::Write(ostream & os) const
 {
-       string s;
+       os << "\\bibitem ";
        if (!options.empty()) {
-               s += '[';
-               s += options + ']';
+               os << '['
+                  << options << ']';
        }
-       s += '{';
-       s += contents + '}';
-       os << "\\bibitem " << s << "\n";
+       os << '{'
+          << contents << "}\n";
 }
 
 
@@ -266,7 +269,7 @@ string InsetBibKey::getScreenLabel() const
   upwards?
   (Joacim 1998-03-04)
 */
-void InsetBibKey::Edit(BufferView * bv, int, int)
+void InsetBibKey::Edit(BufferView * bv, int, int, unsigned int)
 {
        if(bv->buffer()->isReadonly())
                WarnReadonly(bv->buffer()->fileName());
@@ -305,24 +308,23 @@ InsetBibtex::InsetBibtex(string const & dbase, string const & style,
 {
 }
 
-
-string InsetBibtex::getScreenLabel() const
+InsetBibtex::~InsetBibtex()
 {
-       return _("BibTeX Generated References");
+       if(bibitem_form && bibitem_form->bibitem_form
+          && bibitem_form->bibitem_form->visible
+          && bibitem_form->bibitem_form->u_vdata == &holder)
+               fl_hide_form(bibitem_form->bibitem_form);
 }
 
 
-int InsetBibtex::Latex(ostream & os, signed char /*fragile*/) const
+string InsetBibtex::getScreenLabel() const
 {
-       string bib;
-       signed char dummy = 0;
-       int result = Latex(bib, dummy);
-       os << bib;
-       return result;
+       return _("BibTeX Generated References");
 }
 
 
-int InsetBibtex::Latex(string & file, signed char /*fragile*/) const
+int InsetBibtex::Latex(ostream & os,
+                      bool /*fragile*/, bool/*fs*/) const
 {
        // this looks like an horrible hack and it is :) The problem
        // is that owner is not initialized correctly when the bib
@@ -355,12 +357,8 @@ int InsetBibtex::Latex(string & file, signed char /*fragile*/) const
        else
                style = getOptions();
 
-       file += "\\bibliographystyle{";
-       file += style;
-       file += "}\n";
-       file += "\\bibliography{";
-       file += db_out;
-       file += "}\n";
+       os << "\\bibliographystyle{" << style << "}\n"
+          << "\\bibliography{" << db_out << "}\n";
        return 2;
 }
 
@@ -420,7 +418,7 @@ string InsetBibtex::getKeys(char delim)
 
 
 // BibTeX should have its own dialog. This is provisional.
-void InsetBibtex::Edit(BufferView *, int, int)
+void InsetBibtex::Edit(BufferView * bv, int, int, unsigned int)
 {
        if (!bibitem_form) {
                bibitem_form = create_form_bibitem_form();
@@ -428,7 +426,10 @@ void InsetBibtex::Edit(BufferView *, int, int)
                                    CancelCloseBoxCB, 0);
        }
 
-       bibitem_form->bibitem_form->u_vdata = this;
+       holder.inset = this;
+       holder.view = bv;
+       bibitem_form->bibitem_form->u_vdata = &holder;
+
        fl_set_object_label(bibitem_form->key, _("Database:"));
        fl_set_object_label(bibitem_form->label, _("Style:  "));
        fl_set_input(bibitem_form->key, getContents().c_str());