]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBibitem.cpp
InsetBox.cpp: add important note
[lyx.git] / src / insets / InsetBibitem.cpp
index 0f10693f3301995001329f4d79b4435708279f2b..d3a10ae63c645bb653a161109434dc75047e42ac 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "BiblioInfo.h"
 #include "Buffer.h"
+#include "Cursor.h"
 #include "buffer_funcs.h"
 #include "BufferParams.h"
 #include "BufferView.h"
@@ -52,7 +53,7 @@ docstring const key_prefix = from_ascii("key-");
 
 
 InsetBibitem::InsetBibitem(Buffer * buf, InsetCommandParams const & p)
-       : InsetCommand(buf, p, "bibitem")
+       : InsetCommand(buf, p)
 {
        buffer().invalidateBibinfoCache();
        if (getParam("key").empty())
@@ -116,11 +117,14 @@ void InsetBibitem::doDispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_INSET_MODIFY: {
                InsetCommandParams p(BIBITEM_CODE);
-               InsetCommand::string2params("bibitem", to_utf8(cmd.argument()), p);
+               InsetCommand::string2params(to_utf8(cmd.argument()), p);
                if (p.getCmdName().empty()) {
                        cur.noScreenUpdate();
                        break;
                }
+
+               cur.recordUndo();
+
                docstring const & old_key = params()["key"];
                docstring const & old_label = params()["label"];
                docstring label = p["label"];
@@ -307,7 +311,7 @@ docstring bibitemWidest(Buffer const & buffer, OutputParams const & runparams)
 }
 
 
-void InsetBibitem::fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it) const
+void InsetBibitem::collectBibKeys(InsetIterator const & it) const
 {
        docstring const key = getParam("key");
        BibTeXInfo keyvalmap(false);
@@ -315,7 +319,7 @@ void InsetBibitem::fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it)
        DocIterator doc_it(it); 
        doc_it.forwardPos();
        keyvalmap[from_ascii("ref")] = doc_it.paragraph().asString();
-       keys[key] = keyvalmap;
+       buffer().addBibTeXInfo(key, keyvalmap);
 }
 
 
@@ -325,8 +329,9 @@ void InsetBibitem::updateBuffer(ParIterator const & it, UpdateType utype)
        BufferParams const & bp = buffer().masterBuffer()->params();
        Counters & counters = bp.documentClass().counters();
        docstring const bibitem = from_ascii("bibitem");
-       if (counters.hasCounter(bibitem) && getParam("label").empty()) {
-               counters.step(bibitem, utype);
+       if (getParam("label").empty()) {
+               if (counters.hasCounter(bibitem))
+                       counters.step(bibitem, utype);
                string const & lang = it.paragraph().getParLanguage(bp)->code();
                autolabel_ = counters.theCounter(bibitem, lang);
        } else {