diff --git a/src/ChangeLog b/src/ChangeLog index 7986fda635..111f4b33bd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ 2003-05-24 Lars Gullik Bjønnes + * paragraph_funcs.C (breakParagraph): adjust + (breakParagraphConservative): adjust + + * buffer.C (readParagraph): adjust + + * ParagraphList.C (insert): take a reference instead of a pointer + (insert): adjust + * paragraph.[Ch] (id): new function * bufferlist.C (newFile): adjust diff --git a/src/ParagraphList.C b/src/ParagraphList.C index 9ebcdebe61..4b3f5bb434 100644 --- a/src/ParagraphList.C +++ b/src/ParagraphList.C @@ -110,8 +110,10 @@ ParagraphList & ParagraphList::operator=(ParagraphList const & rhs) ParagraphList::iterator -ParagraphList::insert(ParagraphList::iterator it, Paragraph * par) +ParagraphList::insert(ParagraphList::iterator it, Paragraph const & p) { + Paragraph * par = new Paragraph(p, false); + if (it != end()) { Paragraph * prev = it->prev_par_; par->next_par_ = &*it; @@ -136,7 +138,7 @@ ParagraphList::insert(ParagraphList::iterator it, Paragraph * par) void ParagraphList::insert(iterator pos, iterator beg, iterator end) { for (; beg != end; ++beg) { - insert(pos, new Paragraph(*beg, false)); + insert(pos, *beg); } } diff --git a/src/ParagraphList.h b/src/ParagraphList.h index 2251875ac9..688d551465 100644 --- a/src/ParagraphList.h +++ b/src/ParagraphList.h @@ -63,7 +63,7 @@ public: /// ParagraphList & operator=(ParagraphList const &); /// - iterator insert(iterator it, Paragraph * par); + iterator insert(iterator it, Paragraph const & par); /// void insert(iterator pos, iterator beg, iterator end); /// diff --git a/src/buffer.C b/src/buffer.C index 22314c3f9a..ea8485e066 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -368,16 +368,16 @@ int Buffer::readParagraph(LyXLex & lex, string const & token, if (token == "\\layout") { lex.pushToken(token); - Paragraph * par = new Paragraph(); - par->params().depth(depth); + Paragraph par; + par.params().depth(depth); if (params.tracking_changes) - par->trackChanges(); + par.trackChanges(); LyXFont f(LyXFont::ALL_INHERIT, params.language); - par->setFont(0, f); + par.setFont(0, f); // FIXME: goddamn InsetTabular makes us pass a Buffer // not BufferParams - unknown += ::readParagraph(*this, *par, lex); + unknown += ::readParagraph(*this, par, lex); // insert after if (pit != pars.end()) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 807ade6e34..dbc0cbb056 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -4,6 +4,7 @@ (clear): adjust (setParagraphData): separate same_id cases, adjust (appendParagraphs): adjust + (appendParagraphs): adjust 2003-05-23 André Pönitz diff --git a/src/insets/insettext.C b/src/insets/insettext.C index d74aea11de..20599f503e 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -2649,8 +2649,7 @@ void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist) mergeParagraph(buffer->params, paragraphs, lastbuffer); #else ParagraphList::iterator pit = plist.begin(); - ParagraphList::iterator ins = paragraphs.insert(paragraphs.end(), - new Paragraph(*pit, false)); + ParagraphList::iterator ins = paragraphs.insert(paragraphs.end(), *pit); ++pit; mergeParagraph(buffer->params, paragraphs, boost::prior(ins)); diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index c6b92bb839..694c3a9a2b 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -51,7 +51,7 @@ void breakParagraph(BufferParams const & bparams, { // create a new paragraph, and insert into the list ParagraphList::iterator tmp = paragraphs.insert(boost::next(par), - new Paragraph); + Paragraph()); // without doing that we get a crash when typing at the // end of a paragraph @@ -150,7 +150,7 @@ void breakParagraphConservative(BufferParams const & bparams, { // create a new paragraph ParagraphList::iterator tmp = paragraphs.insert(boost::next(par), - new Paragraph); + Paragraph()); tmp->makeSameLayout(*par); // When can pos > size()?