]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph.C
Make lyx2lyx output the new external inset format.
[lyx.git] / src / paragraph.C
index 0d12383a6cbc92ce68d0db116602fde1203ebfea..0da1d96d2c9906988607378d5b948512546a891c 100644 (file)
@@ -70,42 +70,59 @@ Inset * minibuffer_inset;
 Paragraph::Paragraph()
        : pimpl_(new Paragraph::Pimpl(this))
 {
-#ifdef NO_STD_LIST
-       next_par_ = 0;
-       prev_par_ = 0;
-#endif
        enumdepth = 0;
        itemdepth = 0;
        params().clear();
 }
 
 
-Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
-       : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
+Paragraph::Paragraph(Paragraph const & lp)
+       : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this))
 {
        enumdepth = 0;
        itemdepth = 0;
-#ifdef NO_STD_LIST
-       next_par_ = 0;
-       prev_par_ = 0;
-#endif
        // this is because of the dummy layout of the paragraphs that
        // follow footnotes
        layout_ = lp.layout();
-       buffer_ = lp.buffer_;
-       
+
        // copy everything behind the break-position to the new paragraph
        insetlist = lp.insetlist;
        InsetList::iterator it = insetlist.begin();
        InsetList::iterator end = insetlist.end();
        for (; it != end; ++it) {
-               it.setInset(it.getInset()->clone(**buffer_, same_ids));
+               it->inset = it->inset->clone();
                // tell the new inset who is the boss now
-               it.getInset()->parOwner(this);
+               it->inset->parOwner(this);
        }
 }
 
 
+void Paragraph::operator=(Paragraph const & lp)
+{
+       // needed as we will destroy the pimpl_ before copying it
+       if (&lp != this)
+               return;
+       lyxerr << "Paragraph::operator=()\n";
+       delete pimpl_;
+       pimpl_ = new Pimpl(*lp.pimpl_, this);
+
+       enumdepth = lp.enumdepth;
+       itemdepth = lp.itemdepth;
+       // this is because of the dummy layout of the paragraphs that
+       // follow footnotes
+       layout_ = lp.layout();
+
+       // copy everything behind the break-position to the new paragraph
+       insetlist = lp.insetlist;
+       InsetList::iterator it = insetlist.begin();
+       InsetList::iterator end = insetlist.end();
+       for (; it != end; ++it) {
+               it->inset = it->inset->clone();
+               // tell the new inset who is the boss now
+               it->inset->parOwner(this);
+       }
+}
+
 // the destructor removes the new paragraph from the list
 Paragraph::~Paragraph()
 {
@@ -239,7 +256,7 @@ void Paragraph::copyIntoMinibuffer(Buffer const & buffer, pos_type pos) const
        minibuffer_inset = 0;
        if (minibuffer_char == Paragraph::META_INSET) {
                if (getInset(pos)) {
-                       minibuffer_inset = getInset(pos)->clone(buffer);
+                       minibuffer_inset = getInset(pos)->clone();
                } else {
                        minibuffer_inset = 0;
                        minibuffer_char = ' ';
@@ -718,20 +735,20 @@ int Paragraph::beginningOfBody() const
 int Paragraph::getPositionOfInset(Inset const * inset) const
 {
        // Find the entry.
-       InsetList::iterator it = insetlist.begin();
-       InsetList::iterator end = insetlist.end();
+       InsetList::const_iterator it = insetlist.begin();
+       InsetList::const_iterator end = insetlist.end();
        for (; it != end; ++it)
-               if (it.getInset() == inset)
-                       return it.getPos();
+               if (it->inset == inset)
+                       return it->pos;
        return -1;
 }
 
 
-InsetBibitem * Paragraph::bibitem()
+InsetBibitem * Paragraph::bibitem() const
 {
-       InsetList::iterator it = insetlist.begin();
-       if (it != insetlist.end() && it.getInset()->lyxCode() == Inset::BIBTEX_CODE)
-               return static_cast<InsetBibitem *>(it.getInset());
+       InsetList::const_iterator it = insetlist.begin();
+       if (it != insetlist.end() && it->inset->lyxCode() == Inset::BIBTEX_CODE)
+               return static_cast<InsetBibitem *>(it->inset);
        return 0;
 }
 
@@ -1214,14 +1231,14 @@ string const Paragraph::asString(Buffer const * buffer,
 }
 
 
-void Paragraph::setInsetOwner(Inset * i)
+void Paragraph::setInsetOwner(UpdatableInset * inset)
 {
-       pimpl_->inset_owner = i;
+       pimpl_->inset_owner = inset;
        InsetList::iterator it = insetlist.begin();
        InsetList::iterator end = insetlist.end();
        for (; it != end; ++it)
-               if (it.getInset())
-                       it.getInset()->setOwner(i);
+               if (it->inset)
+                       it->inset->setOwner(inset);
 }
 
 
@@ -1346,9 +1363,11 @@ void Paragraph::id(int i)
 
 LyXLayout_ptr const & Paragraph::layout() const
 {
+/*
        Inset * inset = inInset();
        if (inset && inset->lyxCode() == Inset::ENVIRONMENT_CODE)
                return static_cast<InsetEnvironment*>(inset)->layout();
+*/
        return layout_;
 }
 
@@ -1359,7 +1378,7 @@ void Paragraph::layout(LyXLayout_ptr const & new_layout)
 }
 
 
-Inset * Paragraph::inInset() const
+UpdatableInset * Paragraph::inInset() const
 {
        return pimpl_->inset_owner;
 }
@@ -1396,3 +1415,10 @@ bool Paragraph::isFreeSpacing() const
                return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);
        return false;
 }
+
+
+bool operator==(Paragraph const & lhs, Paragraph const & rhs)
+{
+#warning FIXME this implementatoin must be completely wrong...
+       return &lhs == &rhs;
+}