]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph.C
Collapse all those LFUN_XYZ_APPLY to a single LFUN_INSET_APPLY.
[lyx.git] / src / paragraph.C
index 4e99c7318589bc58749bf4cc73c98868ab78324a..0f848a48df03eca04438be6f9784c0a615a93b1b 100644 (file)
@@ -26,7 +26,7 @@
 #include "gettext.h"
 #include "changes.h"
 
-#include "insets/insetbib.h"
+#include "insets/insetbibitem.h"
 #include "insets/insetoptarg.h"
 
 #include "support/filetools.h"
@@ -78,7 +78,6 @@ Paragraph::Paragraph()
 #endif
        enumdepth = 0;
        itemdepth = 0;
-       bibkey = 0; // ale970302
        params().clear();
 }
 
@@ -99,7 +98,6 @@ Paragraph::Paragraph(Paragraph * par)
        previous_->next_ = this;
        // end
 
-       bibkey = 0; // ale970302
        params().clear();
 }
 #endif
@@ -118,14 +116,6 @@ Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
        // follow footnotes
        layout_ = lp.layout();
 
-       // ale970302
-       if (lp.bibkey) {
-               bibkey = static_cast<InsetBibKey *>
-                       (lp.bibkey->clone(*current_view->buffer()));
-       } else {
-               bibkey = 0;
-       }
-
        // copy everything behind the break-position to the new paragraph
        insetlist = lp.insetlist;
        InsetList::iterator it = insetlist.begin();
@@ -149,9 +139,6 @@ Paragraph::~Paragraph()
                next_->previous_ = previous_;
 #endif
 
-       // ale970302
-       delete bibkey;
-
        delete pimpl_;
        //
        //lyxerr << "Paragraph::paragraph_id = "
@@ -234,10 +221,6 @@ void Paragraph::write(Buffer const * buf, ostream & os,
                os << "\\align " << string_align[h] << ' ';
        }
 
-       // bibitem  ale970302
-       if (bibkey)
-               bibkey->write(buf, os);
-
        LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
 
        Change running_change = Change(Change::UNCHANGED);
@@ -952,17 +935,21 @@ int Paragraph::getPositionOfInset(Inset const * inset) const
        // Find the entry.
        InsetList::iterator it = insetlist.begin();
        InsetList::iterator end = insetlist.end();
-       for (; it != end; ++it) {
-               if (it.getInset() == inset) {
+       for (; it != end; ++it)
+               if (it.getInset() == inset) 
                        return it.getPos();
-               }
-       }
-       if (inset == bibkey)
-               return 0;
-
        return -1;
 }
 
+
+InsetBibitem * Paragraph::bibitem()
+{
+       InsetList::iterator it = insetlist.begin();
+       if (it != insetlist.end() && it.getInset()->lyxCode() == Inset::BIBTEX_CODE)
+               return static_cast<InsetBibitem *>(it.getInset()); 
+       return 0;
+}
+
 namespace {
 
 InsetOptArg * optArgInset(Paragraph const & par)
@@ -1079,27 +1066,24 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
 
        switch (style->latextype) {
        case LATEX_COMMAND:
-               os << '\\'
-                  << style->latexname();
+               os << '\\' << style->latexname();
 
                // Separate handling of optional argument inset.
                if (style->optionalargs == 1) {
                        InsetOptArg * it = optArgInset(*this);
-                       if (it != 0)
+                       if (it)
                                it->latexOptional(buf, os, false, false);
                }
                else
                        os << style->latexparam();
                break;
        case LATEX_ITEM_ENVIRONMENT:
-               if (bibkey) {
-                       bibkey->latex(buf, os, false, false);
-               } else
-                       os << "\\item ";
-               break;
        case LATEX_LIST_ENVIRONMENT:
                os << "\\item ";
                break;
+       case LATEX_BIB_ENVIRONMENT:
+               // ignore this, the inset will write itself
+               break;
        default:
                break;
        }