]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
Collapse all those LFUN_XYZ_APPLY to a single LFUN_INSET_APPLY.
[lyx.git] / src / buffer.C
index 53113abb48d4b251053526eee8bbe439faee4e9a..24f0dbaa4468e8cf56394cf27036c497931f9f3f 100644 (file)
@@ -55,7 +55,8 @@
 #include "insets/insetnote.h"
 #include "insets/insetquotes.h"
 #include "insets/insetlatexaccent.h"
-#include "insets/insetbib.h"
+#include "insets/insetbibitem.h"
+#include "insets/insetbibtex.h"
 #include "insets/insetcite.h"
 #include "insets/insetexternal.h"
 #include "insets/insetindex.h"
@@ -130,7 +131,6 @@ using std::pair;
 using std::make_pair;
 using std::vector;
 using std::map;
-using std::max;
 using std::stack;
 using std::list;
 using std::for_each;
@@ -923,7 +923,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                params.float_placement = lex.getString();
        } else if (token == "\\align") {
                int tmpret = lex.findToken(string_align);
-               if (tmpret == -1) ++tmpret;
+               if (tmpret == -1)
+                       ++tmpret;
                int const tmpret2 = int(pow(2.0, tmpret));
                par->params().align(LyXAlignment(tmpret2));
        } else if (token == "\\added_space_top") {
@@ -958,7 +959,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                ++pos;
        } else if (token == "\\bibitem") {  // ale970302
                InsetCommandParams p("bibitem", "dummy");
-               InsetBibKey * inset = new InsetBibKey(p);
+               InsetBibitem * inset = new InsetBibitem(p);
                inset->read(this, lex);
                par->insertInset(pos, inset, font, current_change);
                ++pos;
@@ -1099,7 +1100,7 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
                        inset = new InsetCitation(inscmd);
                } else if (cmdName == "bibitem") {
                        lex.printError("Wrong place for bibitem");
-                       inset = new InsetBibKey(inscmd);
+                       inset = new InsetBibitem(inscmd);
                } else if (cmdName == "BibTeX") {
                        inset = new InsetBibtex(inscmd);
                } else if (cmdName == "index") {
@@ -1586,7 +1587,7 @@ string const Buffer::asciiParagraph(Paragraph const & par,
 
        // this is to change the linebreak to do it by word a bit more
        // intelligent hopefully! (only in the case where we have a
-       // max linelenght!) (Jug)
+       // max linelength!) (Jug)
 
        string word;
 
@@ -2872,51 +2873,33 @@ vector<string> const Buffer::getLabelList() const
 
 
 // This is also a buffer property (ale)
-vector<pair<string, string> > const Buffer::getBibkeyList() const
+void Buffer::fillWithBibKeys(vector<pair<string, string> > & keys) const
 {
-       typedef pair<string, string> StringPair;
        /// if this is a child document and the parent is already loaded
-       /// Use the parent's list instead  [ale990412]
+       /// use the parent's list instead  [ale990412]
        if (!params.parentname.empty() && bufferlist.exists(params.parentname)) {
                Buffer const * tmp = bufferlist.getBuffer(params.parentname);
-               if (tmp)
-                       return tmp->getBibkeyList();
-       }
-
-       vector<StringPair> keys;
-       ParagraphList::iterator pit = paragraphs.begin();
-       ParagraphList::iterator pend = paragraphs.end();
-       for (; pit != pend; ++pit) {
-               InsetBibKey * bib = pit->bibkey();
-               if (bib) {
-                       string const key = bib->getContents();
-                       string const opt = bib->getOptions();
-                       string const ref = pit->asString(this, false);
-                       string const info = opt + "TheBibliographyRef" + ref;
-
-                       keys.push_back(StringPair(key, info));
+               if (tmp) {
+                       tmp->fillWithBibKeys(keys);
+                       return;
                }
        }
 
-       if (!keys.empty())
-               return keys;
-
-       // Might be either using bibtex or a child has bibliography
        for (inset_iterator it = inset_const_iterator_begin();
                it != inset_const_iterator_end(); ++it) {
-               // Search for Bibtex or Include inset
-               if (it->lyxCode() == Inset::BIBTEX_CODE) {
-                       vector<StringPair> tmp =
-                               static_cast<InsetBibtex &>(*it).getKeys(this);
-                       keys.insert(keys.end(), tmp.begin(), tmp.end());
-               } else if (it->lyxCode() == Inset::INCLUDE_CODE) {
-                       vector<StringPair> const tmp =
-                               static_cast<InsetInclude &>(*it).getKeys();
-                       keys.insert(keys.end(), tmp.begin(), tmp.end());
+               if (it->lyxCode() == Inset::BIBTEX_CODE)
+                       static_cast<InsetBibtex &>(*it).fillWithBibKeys(this, keys);
+               else if (it->lyxCode() == Inset::INCLUDE_CODE)
+                       static_cast<InsetInclude &>(*it).fillWithBibKeys(keys);
+               else if (it->lyxCode() == Inset::BIBITEM_CODE) {
+                       InsetBibitem & bib = static_cast<InsetBibitem &>(*it);
+                       string const key = bib.getContents();
+                       string const opt = bib.getOptions();
+                       string const ref; // = pit->asString(this, false);
+                       string const info = opt + "TheBibliographyRef" + ref;
+                       keys.push_back(pair<string, string>(key, info));
                }
        }
-
-       return keys;
 }