add a ParagraphList::insert, adjust other funcs accordingly

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6345 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-03-04 21:40:36 +00:00
parent 30a9dd7f98
commit ebc4d99eaa
10 changed files with 49 additions and 11 deletions

View File

@ -1,5 +1,21 @@
2003-03-04 Lars Gullik Bjønnes <larsbj@gullik.net>
* text.C (breakParagraph): adjust
* paragraph_funcs.C (breakParagraph): take a Buffer* instead of a
BufferParams& as arg.
(breakParagraph): use ParagraphList::insert
(breakParagraphConservative): take a Buffer* instead of a
BufferParams& as arg.
(breakParagraphConservative): use ParagraphList::insert.
* buffer.C (insertStringAsLines): un-const it
(insertStringAsLines): adjust
* ParagraphList.C (insert): new function
* CutAndPaste.C (pasteSelection): adjust
* text.C (backspace): adjust
* tabular.C (SetMultiColumn): adjust

View File

@ -361,7 +361,7 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
// if necessary
if (((*par)->size() > pos) || !(*par)->next()) {
breakParagraphConservative(
current_view->buffer()->params, *par, pos);
current_view->buffer(), *par, pos);
paste_the_end = true;
}
// set the end for redoing later

View File

@ -85,6 +85,18 @@ ParagraphList::ParagraphList()
{}
ParagraphList::iterator
ParagraphList::insert(ParagraphList::iterator it, Paragraph * par)
{
Paragraph * prev = it->previous();
par->next(&*it);
par->previous(prev);
prev->next(par);
it->previous(par);
return iterator(par);
}
void ParagraphList::clear()
{
while (parlist) {

View File

@ -46,6 +46,8 @@ public:
///
ParagraphList();
///
iterator insert(iterator it, Paragraph * par);
///
void clear();
///
void erase(iterator it);

View File

@ -1015,7 +1015,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
// needed to insert the selection
void Buffer::insertStringAsLines(Paragraph *& par, pos_type & pos,
LyXFont const & fn,string const & str) const
LyXFont const & fn,string const & str)
{
LyXLayout_ptr const & layout = par->layout();
@ -1030,7 +1030,7 @@ void Buffer::insertStringAsLines(Paragraph *& par, pos_type & pos,
cit != str.end(); ++cit) {
if (*cit == '\n') {
if (autobreakrows && (!par->empty() || layout->keepempty)) {
breakParagraph(params, par, pos,
breakParagraph(this, par, pos,
layout->isEnvironment());
par = par->next();
pos = 0;

View File

@ -112,7 +112,7 @@ public:
LyXFont &);
///
void insertStringAsLines(Paragraph *&, lyx::pos_type &,
LyXFont const &, string const &) const;
LyXFont const &, string const &);
///
Paragraph * getParFromID(int id) const;
private:

View File

@ -80,6 +80,7 @@ Paragraph::Paragraph()
#ifndef NO_NEXT
// This constructor inserts the new paragraph in a list.
// It is placed after par.
Paragraph::Paragraph(Paragraph * par)
: pimpl_(new Paragraph::Pimpl(this))
{

View File

@ -29,13 +29,17 @@ using lyx::pos_type;
using std::endl;
using std::ostream;
void breakParagraph(BufferParams const & bparams,
void breakParagraph(Buffer * buf,
ParagraphList::iterator par,
pos_type pos,
int flag)
{
BufferParams const & bparams = buf->params;
// create a new paragraph, and insert into the list
Paragraph * tmp = new Paragraph(&*par);
ParagraphList::iterator tmp = buf->paragraphs.insert(boost::next(par),
new Paragraph);
// without doing that we get a crash when typing <Return> at the
// end of a paragraph
tmp->layout(bparams.getLyXTextClass().defaultLayout());
@ -126,12 +130,15 @@ void breakParagraph(BufferParams const & bparams,
}
void breakParagraphConservative(BufferParams const & bparams,
void breakParagraphConservative(Buffer * buf,
ParagraphList::iterator par,
pos_type pos)
{
BufferParams const & bparams = buf->params;
// create a new paragraph
Paragraph * tmp = new Paragraph(&*par);
ParagraphList::iterator tmp = buf->paragraphs.insert(boost::next(par),
new Paragraph);
tmp->makeSameLayout(&*par);
// When can pos > Last()?

View File

@ -21,13 +21,13 @@ class Paragraph;
class TexRow;
///
void breakParagraph(BufferParams const & bparams,
void breakParagraph(Buffer * buf,
ParagraphList::iterator par,
lyx::pos_type pos,
int flag);
///
void breakParagraphConservative(BufferParams const & bparams,
void breakParagraphConservative(Buffer * buf,
ParagraphList::iterator par,
lyx::pos_type pos);

View File

@ -1363,7 +1363,7 @@ void LyXText::breakParagraph(BufferView * bview, char keep_layout)
// paragraph before or behind and we should react on that one
// but we can fix this in 1.3.0 (Jug 20020509)
bool const isempty = (layout->keepempty && cursor.par()->empty());
::breakParagraph(bview->buffer()->params, cursor.par(), cursor.pos(),
::breakParagraph(bview->buffer(), cursor.par(), cursor.pos(),
keep_layout);
// well this is the caption hack since one caption is really enough