]> git.lyx.org Git - features.git/commitdiff
add ParagraphList::erase, make mergeParagraph take a Buffer* arg, adjust other funcs...
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 4 Mar 2003 20:45:02 +0000 (20:45 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 4 Mar 2003 20:45:02 +0000 (20:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6344 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
src/ChangeLog
src/CutAndPaste.C
src/ParagraphList.C
src/ParagraphList.h
src/insets/ChangeLog
src/insets/insettext.C
src/insets/insettext.h
src/paragraph_funcs.C
src/paragraph_funcs.h
src/tabular.C
src/tabular.h
src/text.C

index 9b7e289a15c6f6ca3d34455f39b70b4d26387bfa..c749add78ac86f1ee1c45244bec4dc5a8b708a46 100644 (file)
@@ -1,5 +1,20 @@
 2003-03-04  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
+       * text.C (backspace): adjust
+
+       * tabular.C (SetMultiColumn): adjust
+
+       * CutAndPaste.C (cutSelection): adjust
+       (pasteSelection): adjust
+
+       * tabular.C (SetMultiColumn): make it take a Buffer* instead of a
+       Buffer const * as arg
+
+       * ParagraphList.C (erase): new function
+       * paragraph_funcs.C (mergeParagraph): use it
+       (mergeParagraph): make it take a Buffer* instead of a
+       BufferParams* as arg
+
        * paragraph_funcs.C (breakParagraph): take ParagraphList::iterator
        as arg
        (breakParagraphConservative): ditto
index 78dddda1286042063ef87a4bd6ae1ce21d2d0f5e..f019f906d09c1e9d2f04c342129e06efd87d4e67 100644 (file)
@@ -165,7 +165,7 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
        // paste the paragraphs again, if possible
        if (startpar->hasSameLayout(startpar->next()) ||
            startpar->next()->empty()) {
-               mergeParagraph(buffer->params, startpar);
+               mergeParagraph(buffer, startpar);
                // this because endpar gets deleted here!
                (*endpar) = startpar;
        }
@@ -377,20 +377,20 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
                if ((*par)->next() == lastbuffer)
                        lastbuffer = *par;
 
-               mergeParagraph(current_view->buffer()->params, *par);
+               mergeParagraph(current_view->buffer(), *par);
                // store the new cursor position
                *par = lastbuffer;
                pos = lastbuffer->size();
                // maybe some pasting
                if (lastbuffer->next() && paste_the_end) {
                        if (lastbuffer->next()->hasSameLayout(lastbuffer)) {
-                               mergeParagraph(current_view->buffer()->params, lastbuffer);
+                               mergeParagraph(current_view->buffer(), lastbuffer);
                        } else if (!lastbuffer->next()->size()) {
                                lastbuffer->next()->makeSameLayout(lastbuffer);
-                               mergeParagraph(current_view->buffer()->params, lastbuffer);
+                               mergeParagraph(current_view->buffer(), lastbuffer);
                        } else if (!lastbuffer->size()) {
                                lastbuffer->makeSameLayout(lastbuffer->next());
-                               mergeParagraph(current_view->buffer()->params, lastbuffer);
+                               mergeParagraph(current_view->buffer(), lastbuffer);
                        } else
                                lastbuffer->next()->stripLeadingSpaces();
                }
index 131380d6442e9b75a26101667389b369b4c3a4f9..136071aa7a471375c669ba203ab72ddfbf863357 100644 (file)
@@ -95,6 +95,18 @@ void ParagraphList::clear()
 }
 
 
+void ParagraphList::erase(ParagraphList::iterator it)
+{
+       Paragraph * prev = it->previous();
+       Paragraph * next = it->next();
+
+       prev->next(next);
+       next->previous(prev);
+
+       delete &*it;
+}
+
+
 ParagraphList::iterator ParagraphList::begin()
 {
        return iterator(parlist);
index b56dacdc724c4065818f4f7b2d57c5b52c55689d..b81ac00690dda63d87e89a6b81103efd73aff5a3 100644 (file)
@@ -48,6 +48,8 @@ public:
        ///
        void clear();
        ///
+       void erase(iterator it);
+       ///
        iterator begin();
        ///
        iterator begin() const;
index 9e65924dc3bce37adff7aa75cd012d4e4db93176..849c49cf09013dc7e565339d8657c8b78b12f8c7 100644 (file)
@@ -1,3 +1,10 @@
+2003-03-04  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * insettext.C (collapseParagraphs): adjust
+       (appendParagraphs): make it take a Buffer* instead of a
+       BufferParams& as arg.
+       (appendParagraphs): adjust
+
 2003-03-04  Angus Leeming  <leeming@lyx.org>
 
        * insetbibitem.C (localDispatch):
index 84ae7667fb8ae18a8229e3299fa615e7adc49e3e..df7a181653685d6001b87f56c5cc975987120191 100644 (file)
@@ -2770,7 +2770,6 @@ bool InsetText::checkInsertChar(LyXFont & font)
 
 void InsetText::collapseParagraphs(BufferView * bv) const
 {
-       BufferParams const & bparams = bv->buffer()->params;
        LyXText * llt = getLyXText(bv);
 
        while (paragraphs.begin()->next()) {
@@ -2791,7 +2790,7 @@ void InsetText::collapseParagraphs(BufferView * bv) const
                                        llt->selection.end.pos() + paragraphs.begin()->size());
                        }
                }
-               mergeParagraph(bparams, &*paragraphs.begin());
+               mergeParagraph(bv->buffer(), paragraphs.begin());
        }
        reinitLyXText();
 }
@@ -2805,9 +2804,10 @@ void InsetText::getDrawFont(LyXFont & font) const
 }
 
 
-void InsetText::appendParagraphs(BufferParams const & bparams,
+void InsetText::appendParagraphs(Buffer * buffer,
                                 Paragraph * newpar)
 {
+       BufferParams const & bparams = buffer->params;
        Paragraph * buf;
        Paragraph * tmpbuf = newpar;
        Paragraph * lastbuffer = buf = new Paragraph(*tmpbuf, false);
@@ -2837,7 +2837,7 @@ void InsetText::appendParagraphs(BufferParams const & bparams,
        // paste it!
        lastbuffer->next(buf);
        buf->previous(lastbuffer);
-       mergeParagraph(bparams, lastbuffer);
+       mergeParagraph(buffer, lastbuffer);
 
        reinitLyXText();
 }
index 33c7d5c363a439c6ef47c351f71763c93858f873..5919ab48b704151e4517233224bd2407ab8cc2a4 100644 (file)
@@ -248,7 +248,7 @@ public:
        ///
        void getDrawFont(LyXFont &) const;
        /// append text onto the existing text
-       void appendParagraphs(BufferParams const & bp, Paragraph *);
+       void appendParagraphs(Buffer * bp, Paragraph *);
 
        ///
        void addPreview(grfx::PreviewLoader &) const;
index 2bc417722464ac5af9947a4e3e05a304f7b39e98..77462f1e936dcc2c5e0fe2e4f7f151297edd5893 100644 (file)
@@ -154,8 +154,10 @@ void breakParagraphConservative(BufferParams const & bparams,
 }
 
 
-void mergeParagraph(BufferParams const & bparams, ParagraphList::iterator par)
+void mergeParagraph(Buffer * buf, ParagraphList::iterator par)
 {
+       BufferParams const & bparams = buf->params;
+
        ParagraphList::iterator the_next = boost::next(par);
 
        // first the DTP-stuff
@@ -173,13 +175,7 @@ void mergeParagraph(BufferParams const & bparams, ParagraphList::iterator par)
                        ++j;
        }
 
-       // delete the next paragraph
-#warning a ParagraphList::erase is needed. (Lgb)
-       // Isn't this really just par?
-       ParagraphList::iterator ppar = boost::prior(the_next);
-       ParagraphList::iterator npar = boost::next(the_next);
-       delete &*the_next;
-       ppar->next(&*npar);
+       buf->paragraphs.erase(the_next);
 }
 
 
index 56054c8f2acb5d16aa0517d0e9e7efe9f418e7fd..fa7d69419fb253c5f472a934822571406732819c 100644 (file)
@@ -35,7 +35,7 @@ void breakParagraphConservative(BufferParams const & bparams,
  * Append the next paragraph onto the tail of this one.
  * Be careful, this doesent make any check at all.
  */
-void mergeParagraph(BufferParams const & bparams,
+void mergeParagraph(Buffer * buf,
                    ParagraphList::iterator par);
 
 
index 97877140264fe4ddd9b876aa35bd13b75b34a70a..dcf10bba2a5abaaf36db45c8840fac480c623a16 100644 (file)
@@ -1542,7 +1542,7 @@ LyXTabular::cellstruct * LyXTabular::cellinfo_of_cell(int cell) const
 }
 
 
-void LyXTabular::SetMultiColumn(Buffer const * buffer, int cell, int number)
+void LyXTabular::SetMultiColumn(Buffer * buffer, int cell, int number)
 {
        cellinfo_of_cell(cell)->multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
        cellinfo_of_cell(cell)->alignment = column_info[column_of_cell(cell)].alignment;
@@ -1552,7 +1552,7 @@ void LyXTabular::SetMultiColumn(Buffer const * buffer, int cell, int number)
 #if 1
        for (int i = 1; i < number; ++i) {
                cellinfo_of_cell(cell+i)->multicolumn = CELL_PART_OF_MULTICOLUMN;
-               cellinfo_of_cell(cell)->inset.appendParagraphs(buffer->params,
+               cellinfo_of_cell(cell)->inset.appendParagraphs(buffer,
                        cellinfo_of_cell(cell+i)->inset.paragraph());
                cellinfo_of_cell(cell+i)->inset.clear(false);
        }
index bac0c068ea72d7b162730017f65922c8ae3cc752..6ed2cefe575f2be17f45aa64c514f1c2ff853f5c 100644 (file)
@@ -301,7 +301,7 @@ public:
        ///
        bool IsMultiColumn(int cell, bool real = false) const;
        ///
-       void SetMultiColumn(Buffer const *, int cell, int number);
+       void SetMultiColumn(Buffer *, int cell, int number);
        ///
        int UnsetMultiColumn(int cell); // returns number of new cells
        ///
index 2b251da2538cc2aa11f400df4ef984cec69ed6ed..2925ee7f68cb92be1e46fb6d068ce983243e7bc3 100644 (file)
@@ -2440,7 +2440,7 @@ void LyXText::backspace(BufferView * bview)
                    && cursor.par()->getAlign() == tmppar->getAlign()) {
                        removeParagraph(tmprow);
                        removeRow(tmprow);
-                       mergeParagraph(bview->buffer()->params, cursor.par());
+                       mergeParagraph(bview->buffer(), cursor.par());
 
                        if (!cursor.pos() || !cursor.par()->isSeparator(cursor.pos() - 1))
                                ; //cursor.par()->insertChar(cursor.pos(), ' ');