From: Lars Gullik Bjønnes Date: Fri, 9 Mar 2001 00:56:42 +0000 (+0000) Subject: some cascading name changes X-Git-Tag: 1.6.10~21493 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=b95e8f250dca6264900d8aedf98e8a24411c36d4;p=features.git some cascading name changes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1720 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/po/POTFILES.in b/po/POTFILES.in index 6b0bf59fe8..0c414a861f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -72,54 +72,54 @@ src/frontends/qt2/paragraphdlgimpl.C src/frontends/qt2/tabularcreatedlgimpl.C src/frontends/xforms/FileDialog.C src/frontends/xforms/FormBase.h -src/frontends/xforms/FormBibitem.C src/frontends/xforms/form_bibitem.C -src/frontends/xforms/FormBibtex.C +src/frontends/xforms/FormBibitem.C src/frontends/xforms/form_bibtex.C +src/frontends/xforms/FormBibtex.C src/frontends/xforms/form_browser.C -src/frontends/xforms/FormCharacter.C src/frontends/xforms/form_character.C -src/frontends/xforms/FormCitation.C +src/frontends/xforms/FormCharacter.C src/frontends/xforms/form_citation.C -src/frontends/xforms/FormCopyright.C +src/frontends/xforms/FormCitation.C src/frontends/xforms/form_copyright.C -src/frontends/xforms/FormCredits.C +src/frontends/xforms/FormCopyright.C src/frontends/xforms/form_credits.C -src/frontends/xforms/FormDocument.C +src/frontends/xforms/FormCredits.C src/frontends/xforms/form_document.C -src/frontends/xforms/FormError.C +src/frontends/xforms/FormDocument.C src/frontends/xforms/form_error.C -src/frontends/xforms/FormFiledialog.C +src/frontends/xforms/FormError.C src/frontends/xforms/form_filedialog.C -src/frontends/xforms/FormGraphics.C +src/frontends/xforms/FormFiledialog.C src/frontends/xforms/form_graphics.C -src/frontends/xforms/FormInclude.C +src/frontends/xforms/FormGraphics.C src/frontends/xforms/form_include.C -src/frontends/xforms/FormIndex.C +src/frontends/xforms/FormInclude.C src/frontends/xforms/form_index.C +src/frontends/xforms/FormIndex.C src/frontends/xforms/FormInset.h src/frontends/xforms/FormLog.C -src/frontends/xforms/FormParagraph.C src/frontends/xforms/form_paragraph.C -src/frontends/xforms/FormPreamble.C +src/frontends/xforms/FormParagraph.C src/frontends/xforms/form_preamble.C -src/frontends/xforms/FormPreferences.C +src/frontends/xforms/FormPreamble.C src/frontends/xforms/form_preferences.C -src/frontends/xforms/FormPrint.C +src/frontends/xforms/FormPreferences.C src/frontends/xforms/form_print.C -src/frontends/xforms/FormRef.C +src/frontends/xforms/FormPrint.C src/frontends/xforms/form_ref.C -src/frontends/xforms/FormSearch.C +src/frontends/xforms/FormRef.C src/frontends/xforms/form_search.C +src/frontends/xforms/FormSearch.C src/frontends/xforms/FormSplash.C -src/frontends/xforms/FormTabular.C src/frontends/xforms/form_tabular.C -src/frontends/xforms/FormTabularCreate.C +src/frontends/xforms/FormTabular.C src/frontends/xforms/form_tabular_create.C -src/frontends/xforms/FormToc.C +src/frontends/xforms/FormTabularCreate.C src/frontends/xforms/form_toc.C -src/frontends/xforms/FormUrl.C +src/frontends/xforms/FormToc.C src/frontends/xforms/form_url.C +src/frontends/xforms/FormUrl.C src/frontends/xforms/FormVCLog.C src/frontends/xforms/input_validators.C src/frontends/xforms/Menubar_pimpl.C diff --git a/src/BufferView2.C b/src/BufferView2.C index 010be99a79..710b034ec3 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -105,26 +105,35 @@ bool BufferView::removeAutoInsets() LyXCursor cursor; bool a = false; +#ifndef NEW_INSETS while (par) { // this has to be done before the delete -#ifndef NEW_INSETS if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) -#endif text->SetCursor(this, cursor, par, 0); if (par->AutoDeleteInsets()){ a = true; -#ifndef NEW_INSETS if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){ -#endif text->RedoParagraphs(this, cursor, - cursor.par()->Next()); + cursor.par()->next()); text->FullRebreak(this); -#ifndef NEW_INSETS } -#endif } - par = par->next; + par = par->next_; } +#else + while (par) { + // this has to be done before the delete + text->SetCursor(this, cursor, par, 0); + if (par->AutoDeleteInsets()){ + a = true; + text->RedoParagraphs(this, cursor, + cursor.par()->next()); + text->FullRebreak(this); + } + par = par->next(); + } +#endif + // avoid forbidden cursor positions caused by error removing if (tmpcursor.pos() > tmpcursor.par()->Last()) tmpcursor.pos(tmpcursor.par()->Last()); @@ -347,11 +356,11 @@ void BufferView::allFloats(char flag, char figmar) ) ) ) { - if (par->previous - && par->previous->footnoteflag != + if (par->previous_ + && par->previous_->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){ /* should be */ text->SetCursorIntern(this, - par->previous, + par->previous_, 0); text->OpenFootnote(this); } @@ -384,7 +393,7 @@ void BufferView::allFloats(char flag, char figmar) text->CloseFootnote(this); } } - par = par->next; + par = par->next_; } text->SetCursorIntern(this, cursor.par(), cursor.pos()); @@ -821,17 +830,17 @@ void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind) return; // shouldn't happen if (kind == Undo::EDIT) // in this case insets would not be stored! kind = Undo::FINISH; - text->SetUndo(buffer(), kind, #ifndef NEW_INSETS + text->SetUndo(buffer(), kind, text->cursor.par()-> - ParFromPos(text->cursor.pos())->previous, + ParFromPos(text->cursor.pos())->previous_, text->cursor.par()-> - ParFromPos(text->cursor.pos())->next + ParFromPos(text->cursor.pos())->next_); #else - text->cursor.par()->previous, - text->cursor.par()->next + text->SetUndo(buffer(), kind, + text->cursor.par()->previous(), + text->cursor.par()->next()); #endif - ); } @@ -910,22 +919,31 @@ bool BufferView::ChangeInsets(Inset::Code code, string const & from, string cons } } } +#ifndef NEW_INSETS if (flag2) { flag = true; -#ifndef NEW_INSETS if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){ -#endif // this is possible now, since SetCursor takes // care about footnotes text->SetCursorIntern(this, par, 0); text->RedoParagraphs(this, text->cursor, - text->cursor.par()->Next()); + text->cursor.par()->next()); text->FullRebreak(this); -#ifndef NEW_INSETS } -#endif } - par = par->next; + par = par->next_; +#else + if (flag2) { + flag = true; + // this is possible now, since SetCursor takes + // care about footnotes + text->SetCursorIntern(this, par, 0); + text->RedoParagraphs(this, text->cursor, + text->cursor.par()->next()); + text->FullRebreak(this); + } + par = par->next(); +#endif } text->SetCursorIntern(this, cursor.par(), cursor.pos()); return flag; diff --git a/src/ChangeLog b/src/ChangeLog index 21fbce4426..61217f9ed7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2001-03-09 Lars Gullik Bjønnes + + * lyxparagraph.h: rename next to next_, previous to previous_, + make them private for NEW_INSETS. Rename Next() to next(), + Previous() to previous(). + + * other files: changes because of the above. + 2001-03-08 Dekel Tsur * BufferView.h: diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index ef04824c56..75e89105f6 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -61,7 +61,11 @@ void DeleteBuffer() while (buf) { tmppar = buf; - buf = buf->next; +#ifndef NEW_INSETS + buf = buf->next_; +#else + buf = buf->next(); +#endif delete tmppar; } buf = 0; @@ -102,7 +106,7 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, // more than one paragraph (*endpar)->BreakParagraphConservative(current_view->buffer()->params, end); - *endpar = (*endpar)->Next(); + *endpar = (*endpar)->next(); end = 0; startpar->BreakParagraphConservative(current_view->buffer()->params, @@ -110,22 +114,22 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, // store the selection #ifndef NEW_INSETS - buf = startpar->ParFromPos(start)->next; + buf = startpar->ParFromPos(start)->next_; #else - buf = startpar->next; + buf = startpar->next(); #endif - buf->previous = 0; - (*endpar)->previous->next = 0; + buf->previous(0); + (*endpar)->previous()->next(0); // cut the selection #ifndef NEW_INSETS - startpar->ParFromPos(start)->next = (*endpar); + startpar->ParFromPos(start)->next(*endpar); - (*endpar)->previous = startpar->ParFromPos(start); + (*endpar)->previous(startpar->ParFromPos(start)); #else - startpar->next = (*endpar); + startpar->next(*endpar); - (*endpar)->previous = startpar; + (*endpar)->previous(startpar); #endif #ifndef NEW_INSETS @@ -134,7 +138,7 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, LyXParagraph * tmppar = buf; while (tmppar){ tmppar->footnoteflag = LyXParagraph::NO_FOOTNOTE; - tmppar = tmppar->next; + tmppar = tmppar->next_; } } #endif @@ -144,13 +148,13 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, // paste the paragraphs again, if possible if (doclear) - startpar->Next()->StripLeadingSpaces(textclass); + startpar->next()->StripLeadingSpaces(textclass); #ifndef NEW_INSETS - if (startpar->FirstPhysicalPar()->HasSameLayout(startpar->Next()) || + if (startpar->FirstPhysicalPar()->HasSameLayout(startpar->next()) || #else - if (startpar->HasSameLayout(startpar->Next()) || + if (startpar->HasSameLayout(startpar->next()) || #endif - !startpar->Next()->Last()) { + !startpar->next()->Last()) { #ifndef NEW_INSETS startpar->ParFromPos(start)->PasteParagraph(current_view->buffer()->params); #else @@ -201,19 +205,25 @@ bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar, buf = tmppar->Clone(); LyXParagraph * tmppar2 = buf; - while ( #ifndef NEW_INSETS - tmppar != endpar->ParFromPos(end) + while (tmppar != endpar->ParFromPos(end) + && tmppar->next_) { + tmppar = tmppar->next_; + tmppar2->next(tmppar->Clone()); + tmppar2->next_->previous(tmppar2); + tmppar2 = tmppar2->next_; + } + tmppar2->next(0); #else - tmppar != endpar -#endif - && tmppar->next) { - tmppar = tmppar->next; - tmppar2->next = tmppar->Clone(); - tmppar2->next->previous = tmppar2; - tmppar2 = tmppar2->next; + while (tmppar != endpar + && tmppar->next()) { + tmppar = tmppar->next(); + tmppar2->next(tmppar->Clone()); + tmppar2->next()->previous(tmppar2); + tmppar2 = tmppar2->next(); } - tmppar2->next = 0; + tmppar2->next(0); +#endif #ifndef NEW_INSETS // care about footnotes @@ -221,7 +231,7 @@ bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar, tmppar = buf; while (tmppar) { tmppar->footnoteflag = LyXParagraph::NO_FOOTNOTE; - tmppar = tmppar->next; + tmppar = tmppar->next_; } } #endif @@ -263,7 +273,11 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, int tmppos = pos; // There are two cases: cutbuffer only one paragraph or many - if (!buf->next) { +#ifndef NEW_INSETS + if (!buf->next_) { +#else + if (!buf->next()) { +#endif // only within a paragraph tmpbuf = buf->Clone(); // Some provisions should be done here for checking @@ -287,7 +301,7 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, } delete buf; buf = tmpbuf; - *endpar = tmppar->Next(); + *endpar = tmppar->next(); pos = tmppos; } else { // many paragraphs @@ -297,23 +311,28 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, LyXParagraph * simple_cut_clone = tmpbuf->Clone(); LyXParagraph * tmpbuf2 = simple_cut_clone; #ifndef NEW_INSETS - if ((*par)->footnoteflag){ - tmpbuf->footnoteflag = (*par)->footnoteflag; - tmpbuf->footnotekind = (*par)->footnotekind; - } -#endif - while (tmpbuf->next) { - tmpbuf = tmpbuf->next; - tmpbuf2->next = tmpbuf->Clone(); - tmpbuf2->next->previous = tmpbuf2; - tmpbuf2 = tmpbuf2->next; -#ifndef NEW_INSETS - if ((*par)->footnoteflag){ + if ((*par)->footnoteflag) { tmpbuf->footnoteflag = (*par)->footnoteflag; tmpbuf->footnotekind = (*par)->footnotekind; - } -#endif } + while (tmpbuf->next_) { + tmpbuf = tmpbuf->next_; + tmpbuf2->next(tmpbuf->Clone()); + tmpbuf2->next_->previous(tmpbuf2); + tmpbuf2 = tmpbuf2->next_; + if ((*par)->footnoteflag){ + tmpbuf->footnoteflag = (*par)->footnoteflag; + tmpbuf->footnotekind = (*par)->footnotekind; + } + } +#else + while (tmpbuf->next()) { + tmpbuf = tmpbuf->next(); + tmpbuf2->next(tmpbuf->Clone()); + tmpbuf2->next()->previous(tmpbuf2); + tmpbuf2 = tmpbuf2->next(); + } +#endif // make sure there is no class difference SwitchLayoutsBetweenClasses(textclass, tc, buf); @@ -324,14 +343,14 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, // find the end of the buffer LyXParagraph * lastbuffer = buf; - while (lastbuffer->Next()) - lastbuffer = lastbuffer->Next(); + while (lastbuffer->next()) + lastbuffer = lastbuffer->next(); bool paste_the_end = false; // open the paragraph for inserting the buf // if necessary - if (((*par)->Last() > pos) || !(*par)->Next()) { + if (((*par)->Last() > pos) || !(*par)->next()) { (*par)->BreakParagraphConservative(current_view->buffer()->params, pos); paste_the_end = true; @@ -339,32 +358,32 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, // set the end for redoing later #ifndef NEW_INSETS - *endpar = (*par)->ParFromPos(pos)->next->Next(); + *endpar = (*par)->ParFromPos(pos)->next_->next(); // paste it! - lastbuffer->ParFromPos(lastbuffer->Last())->next = - (*par)->ParFromPos(pos)->next; - (*par)->ParFromPos(pos)->next->previous = - lastbuffer->ParFromPos(lastbuffer->Last()); + lastbuffer->ParFromPos(lastbuffer->Last())->next( + (*par)->ParFromPos(pos)->next_); + (*par)->ParFromPos(pos)->next()->previous( + lastbuffer->ParFromPos(lastbuffer->Last())); - (*par)->ParFromPos(pos)->next = buf; - buf->previous = (*par)->ParFromPos(pos); + (*par)->ParFromPos(pos)->next(buf); + buf->previous((*par)->ParFromPos(pos)); - if ((*par)->ParFromPos(pos)->Next() == lastbuffer) + if ((*par)->ParFromPos(pos)->next() == lastbuffer) lastbuffer = *par; (*par)->ParFromPos(pos)->PasteParagraph(current_view->buffer()->params); #else - *endpar = (*par)->next->Next(); + *endpar = (*par)->next()->next(); // paste it! - lastbuffer->next = (*par)->next; - (*par)->next->previous = lastbuffer; + lastbuffer->next((*par)->next()); + (*par)->next()->previous(lastbuffer); - (*par)->next = buf; - buf->previous = (*par); + (*par)->next(buf); + buf->previous(*par); - if ((*par)->Next() == lastbuffer) + if ((*par)->next() == lastbuffer) lastbuffer = *par; (*par)->PasteParagraph(current_view->buffer()->params); @@ -374,28 +393,28 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, pos = lastbuffer->Last(); // maybe some pasting - if (lastbuffer->Next() && paste_the_end) { + if (lastbuffer->next() && paste_the_end) { #ifndef NEW_INSETS - if (lastbuffer->Next()->HasSameLayout(lastbuffer)) { + if (lastbuffer->next()->HasSameLayout(lastbuffer)) { lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params); - } else if (!lastbuffer->Next()->Last()) { - lastbuffer->Next()->MakeSameLayout(lastbuffer); + } else if (!lastbuffer->next()->Last()) { + lastbuffer->next()->MakeSameLayout(lastbuffer); lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params); } else if (!lastbuffer->Last()) { - lastbuffer->MakeSameLayout(lastbuffer->next); + lastbuffer->MakeSameLayout(lastbuffer->next_); lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params); #else - if (lastbuffer->Next()->HasSameLayout(lastbuffer)) { + if (lastbuffer->next()->HasSameLayout(lastbuffer)) { lastbuffer->PasteParagraph(current_view->buffer()->params); - } else if (!lastbuffer->Next()->Last()) { - lastbuffer->Next()->MakeSameLayout(lastbuffer); + } else if (!lastbuffer->next()->Last()) { + lastbuffer->next()->MakeSameLayout(lastbuffer); lastbuffer->PasteParagraph(current_view->buffer()->params); } else if (!lastbuffer->Last()) { - lastbuffer->MakeSameLayout(lastbuffer->next); + lastbuffer->MakeSameLayout(lastbuffer->next()); lastbuffer->PasteParagraph(current_view->buffer()->params); #endif } else - lastbuffer->Next()->StripLeadingSpaces(tc); + lastbuffer->next()->StripLeadingSpaces(tc); } // restore the simple cut buffer buf = simple_cut_clone; @@ -411,10 +430,17 @@ int CutAndPaste::nrOfParagraphs() int n = 1; LyXParagraph * tmppar = buf; - while(tmppar->next) { +#ifndef NEW_INSETS + while(tmppar->next_) { + ++n; + tmppar = tmppar->next_; + } +#else + while(tmppar->next()) { ++n; - tmppar = tmppar->next; + tmppar = tmppar->next(); } +#endif return n; } @@ -453,8 +479,11 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1, InsetError * new_inset = new InsetError(s); par->InsertInset(0, new_inset); } - - par = par->next; +#ifndef NEW_INSETS + par = par->next_; +#else + par = par->next(); +#endif } return ret; } @@ -470,7 +499,7 @@ bool CutAndPaste::checkPastePossible(LyXParagraph * par, int) // check whether the cut_buffer includes a footnote LyXParagraph * tmppar = buf; while (tmppar && tmppar->footnoteflag == LyXParagraph::NO_FOOTNOTE) - tmppar = tmppar->next; + tmppar = tmppar->next_; if (tmppar) { WriteAlert(_("Impossible operation"), diff --git a/src/buffer.C b/src/buffer.C index 65586dc091..4612c01333 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -156,11 +156,19 @@ Buffer::~Buffer() LyXParagraph * par = paragraph; LyXParagraph * tmppar; +#ifndef NEW_INSETS + while (par) { + tmppar = par->next_; + delete par; + par = tmppar; + } +#else while (par) { - tmppar = par->next; + tmppar = par->next(); delete par; par = tmppar; } +#endif paragraph = 0; } @@ -1315,16 +1323,10 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, int noparbreak = 0; int islatex = 0; - if ( -#ifndef NEW_INSETS - par->footnoteflag != LyXParagraph::NO_FOOTNOTE || -#endif - !par->previous -#ifndef NEW_INSETS - || par->previous->footnoteflag == LyXParagraph::NO_FOOTNOTE -#endif - ){ #ifndef NEW_INSETS + if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE || + !par->previous_ + || par->previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE) { /* begins a footnote environment ? */ if (footnoteflag != par->footnoteflag) { footnoteflag = par->footnoteflag; @@ -1341,6 +1343,8 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, currlinelen += j; } } +#else + if (!par->previous()) { #endif /* begins or ends a deeper area ?*/ if (depth != par->params.depth()) { @@ -1359,19 +1363,19 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, string const tmp = textclasslist.NameOfLayout(params.textclass, par->layout); if (tmp == "Itemize") { ltype = 1; - ltype_depth = depth+1; + ltype_depth = depth + 1; } else if (tmp == "Enumerate") { ltype = 2; - ltype_depth = depth+1; + ltype_depth = depth + 1; } else if (strstr(tmp.c_str(), "ection")) { ltype = 3; - ltype_depth = depth+1; + ltype_depth = depth + 1; } else if (strstr(tmp.c_str(), "aragraph")) { ltype = 4; - ltype_depth = depth+1; + ltype_depth = depth + 1; } else if (tmp == "Description") { ltype = 5; - ltype_depth = depth+1; + ltype_depth = depth + 1; } else if (tmp == "Abstract") { ltype = 6; ltype_depth = 0; @@ -1535,7 +1539,7 @@ void Buffer::writeFileAscii(ostream & ofs, int linelen) LyXParagraph * par = paragraph; while (par) { ofs << asciiParagraph(par, linelen); - par = par->next; + par = par->next(); } ofs << "\n"; } @@ -2244,9 +2248,11 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) string const temp = "toc"; sgmlOpenTag(ofs, depth, temp); - par = par->next; #ifndef NEW_INSETS + par = par->next_; linuxDocHandleFootnote(ofs, par, depth); +#else + par = par->next(); #endif continue; } @@ -2330,14 +2336,16 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) #ifndef NEW_INSETS do { -#endif SimpleLinuxDocOnePar(ofs, par, desc_on, depth); - - par = par->next; -#ifndef NEW_INSETS + + par = par->next_; linuxDocHandleFootnote(ofs, par, depth); } while(par && par->IsDummy()); +#else + SimpleLinuxDocOnePar(ofs, par, desc_on, depth); + + par = par->next(); #endif ofs << "\n"; @@ -2380,7 +2388,7 @@ void Buffer::linuxDocHandleFootnote(ostream & os, LyXParagraph * & par, sgmlOpenTag(os, depth + 1, tag); SimpleLinuxDocOnePar(os, par, 0, depth + 1); sgmlCloseTag(os, depth + 1, tag); - par = par->next; + par = par->next_; } } #endif @@ -2391,13 +2399,18 @@ void Buffer::DocBookHandleCaption(ostream & os, string & inner_tag, LyXParagraph * & par) { LyXParagraph * tpar = par; - while (tpar #ifndef NEW_INSETS + while (tpar && (tpar->footnoteflag != LyXParagraph::NO_FOOTNOTE) -#endif && (tpar->layout != textclasslist.NumberOfLayout(params.textclass, "Caption").second)) - tpar = tpar->next; + tpar = tpar->next_; +#else + while (tpar + && (tpar->layout != textclasslist.NumberOfLayout(params.textclass, + "Caption").second)) + tpar = tpar->next(); +#endif if (tpar && tpar->layout == textclasslist.NumberOfLayout(params.textclass, "Caption").second) { @@ -2502,7 +2515,7 @@ void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par, tmp_par = frontStrip(strip(tmp_par)); last = present; - par = par->next; + par = par->next_; } os << tmp_par; if (!inner_tag.empty()) sgmlCloseTag(os, depth + 1, inner_tag); @@ -3039,16 +3052,18 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) #ifndef NEW_INSETS do { -#endif string extra_par; SimpleDocBookOnePar(ofs, extra_par, par, desc_on, depth + 1 + command_depth); - par = par->next; -#ifndef NEW_INSETS + par = par->next_; DocBookHandleFootnote(ofs, par, depth + 1 + command_depth); - } - while(par && par->IsDummy()); + } while(par && par->IsDummy()); +#else + string extra_par; + SimpleDocBookOnePar(ofs, extra_par, par, desc_on, + depth + 1 + command_depth); + par = par->next(); #endif string end_tag; // write closing SGML tags @@ -3296,7 +3311,11 @@ void Buffer::validate(LaTeXFeatures & features) const par->validate(features); // and then the next paragraph - par = par->next; +#ifndef NEW_INSETS + par = par->next_; +#else + par = par->next(); +#endif } // the bullet shapes are buffer level not paragraph level @@ -3458,8 +3477,10 @@ vector > const Buffer::getTocList() const } #ifndef NEW_INSETS } + par = par->next_; +#else + par = par->next(); #endif - par = par->next; } return l; } @@ -3482,7 +3503,11 @@ vector > const Buffer::getBibkeyList() if (par->bibkey) keys.push_back(pair(par->bibkey->getContents(), par->String(this, false))); - par = par->next; +#ifndef NEW_INSETS + par = par->next_; +#else + par = par->next(); +#endif } // Might be either using bibtex or a child has bibliography @@ -3577,18 +3602,29 @@ void Buffer::resizeInsets(BufferView * bv) { /// then remove all LyXText in text-insets LyXParagraph * par = paragraph; - for (; par; par = par->next) { +#ifndef NEW_INSETS + for (; par; par = par->next_) { + par->resizeInsetsLyXText(bv); + } +#else + for (; par; par = par->next()) { par->resizeInsetsLyXText(bv); } +#endif } + void Buffer::ChangeLanguage(Language const * from, Language const * to) { LyXParagraph * par = paragraph; while (par) { par->ChangeLanguage(params, from, to); - par = par->next; +#ifndef NEW_INSETS + par = par->next_; +#else + par = par->next(); +#endif } } @@ -3599,7 +3635,11 @@ bool Buffer::isMultiLingual() while (par) { if (par->isMultiLingual(params)) return true; - par = par->next; +#ifndef NEW_INSETS + par = par->next_; +#else + par = par->next(); +#endif } return false; } @@ -3611,7 +3651,11 @@ Buffer::inset_iterator::inset_iterator(LyXParagraph * paragraph, { it = par->InsetIterator(pos); if (it == par->inset_iterator_end()) { - par = par->next; +#ifndef NEW_INSETS + par = par->next_; +#else + par = par->next(); +#endif SetParagraph(); } } @@ -3623,7 +3667,11 @@ void Buffer::inset_iterator::SetParagraph() it = par->inset_iterator_begin(); if (it != par->inset_iterator_end()) return; - par = par->next; +#ifndef NEW_INSETS + par = par->next_; +#else + par = par->next(); +#endif } //it = 0; // We maintain an invariant that whenever par = 0 then it = 0 diff --git a/src/buffer.h b/src/buffer.h index 9508b1a3bb..9d2a7cbd87 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -414,7 +414,11 @@ public: if (par) { ++it; if (it == par->inset_iterator_end()) { - par = par->next; +#ifndef NEW_INSETS + par = par->next_; +#else + par = par->next(); +#endif SetParagraph(); } } @@ -426,7 +430,11 @@ public: if (par) { ++it; if (it == par->inset_iterator_end()) { - par = par->next; +#ifndef NEW_INSETS + par = par->next_; +#else + par = par->next(); +#endif SetParagraph(); } } diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index 06ab28f976..7f396772fd 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -261,7 +261,11 @@ int bibitemMaxWidth(BufferView * bv, LyXFont const & font) int const wx = par->bibkey->width(bv, font); if (wx > w) w = wx; } - par = par->next; +#ifndef NEW_INSETS + par = par->next_; +#else + par = par->next(); +#endif } return w; } @@ -286,7 +290,11 @@ string const bibitemWidest(Buffer const * buffer) bkey = par->bibkey; } } - par = par->next; +#ifndef NEW_INSETS# + par = par->next_; +#else + par = par->next(); +#endif } if (bkey && !bkey->getBibLabel().empty()) diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index d31318d42b..e77fbe3bfe 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -896,11 +896,11 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, break; bv->text->SetUndo(bv->buffer(), Undo::DELETE, #ifndef NEW_INSETS - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_, + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_ #else - bv->text->cursor.par()->previous, - bv->text->cursor.par()->next + bv->text->cursor.par()->previous(), + bv->text->cursor.par()->next() #endif ); cutSelection(); @@ -983,11 +983,11 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, if (hasPasteBuffer()) { bv->text->SetUndo(bv->buffer(), Undo::INSERT, #ifndef NEW_INSETS - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_, + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_ #else - bv->text->cursor.par()->previous, - bv->text->cursor.par()->next + bv->text->cursor.par()->previous(), + bv->text->cursor.par()->next() #endif ); pasteSelection(bv); @@ -1511,11 +1511,11 @@ void InsetTabular::TabularFeatures(BufferView * bv, } bv->text->SetUndo(bv->buffer(), Undo::FINISH, #ifndef NEW_INSETS - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_, + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_ #else - bv->text->cursor.par()->previous, - bv->text->cursor.par()->next + bv->text->cursor.par()->previous(), + bv->text->cursor.par()->next() #endif ); diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 4e881834e8..9d414218ba 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -120,13 +120,23 @@ InsetText::~InsetText() delete (*cit).second; (*cit).second = 0; } - LyXParagraph * p = par->next; +#ifndef NEW_INSETS + LyXParagraph * p = par->next_; + delete par; + while(p) { + par = p; + p = p->next_; + delete par; + } +#else + LyXParagraph * p = par->next(); delete par; while(p) { par = p; - p = p->next; + p = p->next(); delete par; } +#endif } @@ -138,13 +148,23 @@ void InsetText::clear() delete (*cit).second; (*cit).second = 0; } - LyXParagraph * p = par->next; +#ifndef NEW_INSETS + LyXParagraph * p = par->next_; + delete par; + while(p) { + par = p; + p = p->next_; + delete par; + } +#else + LyXParagraph * p = par->next(); delete par; while(p) { par = p; - p = p->next; + p = p->next(); delete par; } +#endif par = new LyXParagraph(); } @@ -188,13 +208,23 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex) (*cit).second = 0; } - LyXParagraph * p = par->next; +#ifndef NEW_INSETS + LyXParagraph * p = par->next_; delete par; while(p) { par = p; - p = p->next; + p = p->next_; delete par; } +#else + LyXParagraph * p = par->next(); + delete par; + while(p) { + par = p; + p = p->next(); + delete par; + } +#endif par = new LyXParagraph; while (lex.IsOK()) { lex.nextToken(); @@ -221,7 +251,11 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex) par = return_par; while(return_par) { return_par->SetInsetOwner(this); - return_par = return_par->next; +#ifndef NEW_INSETS + return_par = return_par->next_; +#else + return_par = return_par->next(); +#endif } if (token != "\\end_inset") { @@ -512,7 +546,11 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button) // If the inset is empty set the language of the current font to the // language to the surronding text. - if (par->Last() == 0 && !par->next) { +#ifndef NEW_INSETS + if (par->Last() == 0 && !par->next_) { +#else# + if (par->Last() == 0 && !par->next()) { +#endif LyXFont font(LyXFont::ALL_IGNORE); font.setLanguage(bv->getParentLanguage(this)); SetFont(bv, font, false); @@ -810,11 +848,11 @@ InsetText::LocalDispatch(BufferView * bv, bv->text->SetUndo(bv->buffer(), Undo::INSERT, #ifndef NEW_INSETS - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_, + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_ #else - bv->text->cursor.par()->previous, - bv->text->cursor.par()->next + bv->text->cursor.par()->previous(), + bv->text->cursor.par()->next() #endif ); bv->setState(); @@ -897,11 +935,11 @@ InsetText::LocalDispatch(BufferView * bv, case LFUN_BACKSPACE: bv->text->SetUndo(bv->buffer(), Undo::DELETE, #ifndef NEW_INSETS - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_, + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_ #else - bv->text->cursor.par()->previous, - bv->text->cursor.par()->next + bv->text->cursor.par()->previous(), + bv->text->cursor.par()->next() #endif ); if (TEXT(bv)->selection) @@ -913,11 +951,11 @@ InsetText::LocalDispatch(BufferView * bv, case LFUN_DELETE: bv->text->SetUndo(bv->buffer(), Undo::DELETE, #ifndef NEW_INSETS - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_, + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_ #else - bv->text->cursor.par()->previous, - bv->text->cursor.par()->next + bv->text->cursor.par()->previous(), + bv->text->cursor.par()->next() #endif ); if (TEXT(bv)->selection) @@ -929,11 +967,11 @@ InsetText::LocalDispatch(BufferView * bv, case LFUN_CUT: bv->text->SetUndo(bv->buffer(), Undo::DELETE, #ifndef NEW_INSETS - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_, + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_ #else - bv->text->cursor.par()->previous, - bv->text->cursor.par()->next + bv->text->cursor.par()->previous(), + bv->text->cursor.par()->next() #endif ); TEXT(bv)->CutSelection(bv); @@ -971,11 +1009,11 @@ InsetText::LocalDispatch(BufferView * bv, } bv->text->SetUndo(bv->buffer(), Undo::INSERT, #ifndef NEW_INSETS - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_, + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_ #else - bv->text->cursor.par()->previous, - bv->text->cursor.par()->next + bv->text->cursor.par()->previous(), + bv->text->cursor.par()->next() #endif ); TEXT(bv)->PasteSelection(bv); @@ -998,11 +1036,11 @@ InsetText::LocalDispatch(BufferView * bv, return DISPATCHED; bv->text->SetUndo(bv->buffer(), Undo::INSERT, #ifndef NEW_INSETS - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_, + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_ #else - bv->text->cursor.par()->previous, - bv->text->cursor.par()->next + bv->text->cursor.par()->previous(), + bv->text->cursor.par()->next() #endif ); TEXT(bv)->InsertChar(bv, LyXParagraph::META_NEWLINE); @@ -1103,7 +1141,11 @@ InsetText::LocalDispatch(BufferView * bv, /// If the action has deleted all text in the inset, we need to change the // language to the language to the surronding text. - if (par->Last() == 0 && !par->next) { +#ifndef NEW_INSETS + if (par->Last() == 0 && !par->next_) { +#else + if (par->Last() == 0 && !par->next()) { +#endif LyXFont font(LyXFont::ALL_IGNORE); font.setLanguage(bv->getParentLanguage(this)); SetFont(bv, font, false); @@ -1135,7 +1177,11 @@ int InsetText::Ascii(Buffer const * buf, ostream & os, int linelen) const tmp = buf->asciiParagraph(p, linelen); lines += countChar(tmp, '\n'); os << tmp; - p = p->next; +#ifndef NEW_INSETS + p = p->next(); +#else + p = p->next(); +#endif } return lines; } @@ -1150,7 +1196,11 @@ int InsetText::DocBook(Buffer const * buf, ostream & os) const string tmp; while (p) { buf->SimpleDocBookOnePar(os,tmp,p,desc,0); - p = p->next; +#ifndef NEW_INSETS + p = p->next_; +#else + p = p->next(); +#endif } return lines; @@ -1162,7 +1212,11 @@ void InsetText::Validate(LaTeXFeatures & features) const LyXParagraph * p = par; while(p) { p->validate(features); - p = p->next; +#ifndef NEW_INSETS + p = p->next_; +#else + p = p->next(); +#endif } } @@ -1268,7 +1322,11 @@ UpdatableInset::RESULT InsetText::moveRightIntern(BufferView * bv, bool behind, bool activate_inset, bool selecting) { - if (!cpar(bv)->next && (cpos(bv) >= cpar(bv)->Last())) +#ifndef NEW_INSETS + if (!cpar(bv)->next_ && (cpos(bv) >= cpar(bv)->Last())) +#else + if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->Last())) +#endif return FINISHED; if (activate_inset && checkAndActivateInset(bv, behind)) return DISPATCHED; @@ -1283,7 +1341,11 @@ UpdatableInset::RESULT InsetText::moveLeftIntern(BufferView * bv, bool behind, bool activate_inset, bool selecting) { - if (!cpar(bv)->previous && (cpos(bv) <= 0)) +#ifndef NEW_INSETS + if (!cpar(bv)->previous_ && (cpos(bv) <= 0)) +#else + if (!cpar(bv)->previous() && (cpos(bv) <= 0)) +#endif return FINISHED; TEXT(bv)->CursorLeft(bv); if (!selecting) @@ -1323,11 +1385,11 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset) } bv->text->SetUndo(bv->buffer(), Undo::INSERT, #ifndef NEW_INSETS - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_, + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_ #else - bv->text->cursor.par()->previous, - bv->text->cursor.par()->next + bv->text->cursor.par()->previous(), + bv->text->cursor.par()->next() #endif ); inset->setOwner(this); @@ -1366,11 +1428,11 @@ void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall) if (TEXT(bv)->selection) { bv->text->SetUndo(bv->buffer(), Undo::EDIT, #ifndef NEW_INSETS - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous, - bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous_, + bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next_ #else - bv->text->cursor.par()->previous, - bv->text->cursor.par()->next + bv->text->cursor.par()->previous(), + bv->text->cursor.par()->next() #endif ); } @@ -1450,7 +1512,7 @@ int InsetText::getMaxWidth(Painter & pain, UpdatableInset const * inset) const } -void InsetText::SetParagraphData(LyXParagraph *p) +void InsetText::SetParagraphData(LyXParagraph * p) { // delete all instances of LyXText before deleting the paragraps used // by it. @@ -1459,26 +1521,49 @@ void InsetText::SetParagraphData(LyXParagraph *p) (*cit).second = 0; } +#ifndef NEW_INSETS LyXParagraph * np; if (par) { - np = par->next; + np = par->next_; + delete par; + while (np) { + par = np; + np = np->next_; + delete par; + } + } + par = p->Clone(); + par->SetInsetOwner(this); + np = par; + while (p->next_) { + p = p->next_; + np->next(p->Clone()); + np->next_->previous(np); + np = np->next_; + np->SetInsetOwner(this); + } +#else + LyXParagraph * np; + if (par) { + np = par->next(); delete par; while(np) { par = np; - np = np->next; + np = np->next(); delete par; } } par = p->Clone(); par->SetInsetOwner(this); np = par; - while(p->next) { - p = p->next; - np->next = p->Clone(); - np->next->previous = np; - np = np->next; + while(p->next()) { + p = p->next(); + np->next(p->Clone()); + np->next()->previous(np); + np = np->next(); np->SetInsetOwner(this); } +#endif need_update = INIT; } @@ -1605,16 +1690,26 @@ void InsetText::deleteLyXText(BufferView * bv, bool recursive) const if (recursive) { /// then remove all LyXText in text-insets LyXParagraph * p = par; - for (;p;p = p->next) { +#ifndef NEW_INSETS + for (; p; p = p->next_) { + p->deleteInsetsLyXText(bv); + } +#else + for (; p; p = p->next()) { p->deleteInsetsLyXText(bv); } +#endif } } void InsetText::resizeLyXText(BufferView * bv) const { - if (!par->next && !par->size()) // resize not neccessary! +#ifndef NEW_INSETS + if (!par->next_ && !par->size()) // resize not neccessary! +#else + if (!par->next() && !par->size()) // resize not neccessary! +#endif return; if ((cache.find(bv) == cache.end()) || !cache[bv]) return; @@ -1675,9 +1770,15 @@ void InsetText::resizeLyXText(BufferView * bv) const /// then resize all LyXText in text-insets inset_x = cx(bv) - top_x + drawTextXOffset; inset_y = cy(bv) + drawTextYOffset; - for (LyXParagraph * p = par; p; p = p->next) { +#ifndef NEW_INSETS + for (LyXParagraph * p = par; p; p = p->next_) { + p->resizeInsetsLyXText(bv); + } +#else + for (LyXParagraph * p = par; p; p = p->next()) { p->resizeInsetsLyXText(bv); } +#endif } need_update = FULL; } @@ -1685,7 +1786,11 @@ void InsetText::resizeLyXText(BufferView * bv) const void InsetText::removeNewlines() { - for (LyXParagraph * p = par; p; p = p->next) { +#ifndef NEW_INSETS + for (LyXParagraph * p = par; p; p = p->next_) { +#else + for (LyXParagraph * p = par; p; p = p->next()) { +#endif for (int i = 0; i < p->Last(); ++i) { if (p->GetChar(i) == LyXParagraph::META_NEWLINE) p->Erase(i); diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 1763bb328c..24561bb68f 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -497,11 +497,12 @@ void MenuInsertLabel(BufferView * bv, string const & arg) &textclasslist.Style(bv->buffer()->params.textclass, par->GetLayout()); - if (layout->latextype == LATEX_PARAGRAPH && par->previous) { #ifndef NEW_INSETS - LyXParagraph * par2 = par->previous->FirstPhysicalPar(); + if (layout->latextype == LATEX_PARAGRAPH && par->previous_) { + LyXParagraph * par2 = par->previous_->FirstPhysicalPar(); #else - LyXParagraph * par2 = par->previous; + if (layout->latextype == LATEX_PARAGRAPH && par->previous()) { + LyXParagraph * par2 = par->previous(); #endif LyXLayout const * layout2 = &textclasslist.Style(bv->buffer()->params.textclass, diff --git a/src/lyxfind.C b/src/lyxfind.C index 183cb7b3c0..27b9a6a388 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -152,7 +152,7 @@ bool SearchForward(BufferView * bv, string const & str, ++pos; else { pos = 0; - par = par->Next(); + par = par->next(); } } if (par) { @@ -179,7 +179,7 @@ bool SearchBackward(BufferView * bv, string const & str, else { // We skip empty paragraphs (Asger) do { - par = par->Previous(); + par = par->previous(); if (par) pos = par->Last() - 1; } while (par && pos < 0); diff --git a/src/lyxparagraph.h b/src/lyxparagraph.h index 1b4a6ce28f..77df7ac4e9 100644 --- a/src/lyxparagraph.h +++ b/src/lyxparagraph.h @@ -261,23 +261,31 @@ public: /// char itemdepth; - +#ifdef NEW_INSETS +private: +#endif /// - LyXParagraph * next; + LyXParagraph * next_; /// - LyXParagraph * previous; - + LyXParagraph * previous_; +public: /// InsetBibKey * bibkey; // ale970302 + /// + void next(LyXParagraph *); /** these function are able to hide closed footnotes */ - LyXParagraph * Next(); - + LyXParagraph * next(); + /// + LyXParagraph const * next() const; + + /// + void previous(LyXParagraph *); /// - LyXParagraph * Previous(); + LyXParagraph * previous(); /// - LyXParagraph const * Previous() const; + LyXParagraph const * previous() const; #ifndef NEW_INSETS /** these function are able to hide open and closed footnotes diff --git a/src/paragraph.C b/src/paragraph.C index 2862334884..b342451b87 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -76,8 +76,8 @@ LyXParagraph::LyXParagraph() for (int i = 0; i < 10; ++i) setCounter(i , 0); enumdepth = 0; itemdepth = 0; - next = 0; - previous = 0; + next_ = 0; + previous_ = 0; #ifndef NEW_INSETS footnoteflag = LyXParagraph::NO_FOOTNOTE; footnotekind = LyXParagraph::FOOTNOTE; // should not be needed @@ -100,11 +100,11 @@ LyXParagraph::LyXParagraph(LyXParagraph * par) enumdepth = 0; itemdepth = 0; // double linked list begin - next = par->next; - if (next) - next->previous = this; - previous = par; - previous->next = this; + next_ = par->next_; + if (next_) + next_->previous_ = this; + previous_ = par; + previous_->next_ = this; // end #ifndef NEW_INSETS footnoteflag = LyXParagraph::NO_FOOTNOTE; @@ -126,8 +126,8 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os, #ifndef NEW_INSETS if ( footnoteflag != LyXParagraph::NO_FOOTNOTE || - !previous - || previous->footnoteflag == LyXParagraph::NO_FOOTNOTE + !previous_ + || previous_->footnoteflag == LyXParagraph::NO_FOOTNOTE ) { #endif @@ -318,8 +318,8 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os, } // now write the next paragraph - if (next) - next->writeFile(buf, os, bparams, footflag, dth); + if (next_) + next_->writeFile(buf, os, bparams, footflag, dth); } @@ -390,7 +390,7 @@ void LyXParagraph::validate(LaTeXFeatures & features) const features.floatflt = true; #ifndef NEW_INSETS if (layout.needprotect - && next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) + && next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE) features.NeedLyXFootnoteCode = true; #endif if (bparams.paragraph_separation == BufferParams::PARSEP_INDENT @@ -484,10 +484,10 @@ void LyXParagraph::Clear() // the destructor removes the new paragraph from the list LyXParagraph::~LyXParagraph() { - if (previous) - previous->next = next; - if (next) - next->previous = previous; + if (previous_) + previous_->next_ = next_; + if (next_) + next_->previous_ = previous_; for (InsetList::iterator it = insetlist.begin(); it != insetlist.end(); ++it) { @@ -508,7 +508,7 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos) // > because last is the next unused position, and you can // use it if you want if (pos > size()) { - if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) + if (next_ && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) NextAfterFootnote()->Erase(pos - text.size() - 1); else lyxerr.debug() << "ERROR (LyXParagraph::Erase): " @@ -600,8 +600,8 @@ void LyXParagraph::InsertChar(LyXParagraph::size_type pos, // > because last is the next unused position, and you can // use it if you want if (pos > size()) { - if (next - && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) + if (next_ + && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) NextAfterFootnote()->InsertChar(pos - text.size() - 1, c); else @@ -651,8 +651,8 @@ void LyXParagraph::InsertInset(LyXParagraph::size_type pos, // > because last is the next unused position, and you can // use it if you want if (pos > size()) { - if (next - && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) + if (next_ + && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) NextAfterFootnote() ->InsertInset(pos - text.size() - 1, inset, font); @@ -697,8 +697,8 @@ Inset * LyXParagraph::GetInset(LyXParagraph::size_type pos) { #ifndef NEW_INSETS if (pos >= size()) { - if (next - && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) + if (next_ + && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) return NextAfterFootnote() ->GetInset(pos - text.size() - 1); else @@ -736,8 +736,8 @@ Inset const * LyXParagraph::GetInset(LyXParagraph::size_type pos) const { #ifndef NEW_INSETS if (pos >= size()) { - if (next - && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) + if (next_ + && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) return NextAfterFootnote() ->GetInset(pos - text.size() - 1); else @@ -794,8 +794,8 @@ LyXFont const LyXParagraph::GetFontSettings(BufferParams const & bparams, // > because last is the next unused position, and you can // use it if you want else if (pos > size()) { - if (next - && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) + if (next_ + && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) return NextAfterFootnote() ->GetFontSettings(bparams, pos - text.size() - 1); @@ -833,7 +833,7 @@ LyXFont const LyXParagraph::GetFirstFontSettings() const } #ifndef NEW_INSETS - else if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) + else if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE) return NextAfterFootnote()->GetFirstFontSettings(); #endif return LyXFont(LyXFont::ALL_INHERIT); @@ -946,7 +946,7 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const // > because last is the next unused position, and you can // use it if you want else if (pos > size()) { - if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) + if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE) return NextAfterFootnote() ->GetChar(pos - text.size() - 1); else @@ -960,14 +960,14 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const return '\0'; } else { // We should have a footnote environment. - if (!next || next->footnoteflag == LyXParagraph::NO_FOOTNOTE) { + if (!next_ || next_->footnoteflag == LyXParagraph::NO_FOOTNOTE) { // Notice that LyX does request the // last char from time to time. (Asger) //lyxerr << "ERROR (LyXParagraph::GetChar): " // "expected footnote." << endl; return '\0'; } - switch (next->footnotekind) { + switch (next_->footnotekind) { case LyXParagraph::FOOTNOTE: return LyXParagraph::META_FOOTNOTE; case LyXParagraph::MARGIN: @@ -1081,7 +1081,7 @@ string const LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const LyXParagraph::size_type LyXParagraph::Last() const { #ifndef NEW_INSETS - if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) + if (next_ && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) return text.size() + NextAfterFootnote()->Last() + 1; // the 1 is the symbol // for the footnote @@ -1097,8 +1097,8 @@ LyXParagraph * LyXParagraph::ParFromPos(LyXParagraph::size_type pos) // > because last is the next unused position, and you can // use it if you want if (pos > size()) { - if (next - && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) + if (next_ + && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) return NextAfterFootnote() ->ParFromPos(pos - text.size() - 1); else @@ -1117,8 +1117,8 @@ int LyXParagraph::PositionInParFromPos(LyXParagraph::size_type pos) const // > because last is the next unused position, and you can // use it if you want if (pos > size()) { - if (next - && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) + if (next_ + && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) return NextAfterFootnote() ->PositionInParFromPos(pos - text.size() - 1); else @@ -1140,8 +1140,8 @@ void LyXParagraph::SetFont(LyXParagraph::size_type pos, // > because last is the next unused position, and you can // use it if you want if (pos > size()) { - if (next && - next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { + if (next_ && + next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { NextAfterFootnote()->SetFont(pos - text.size() - 1, font); } else @@ -1209,42 +1209,69 @@ void LyXParagraph::SetFont(LyXParagraph::size_type pos, } } - + + +void LyXParagraph::next(LyXParagraph * p) +{ + next_ = p; +} + + // This function is able to hide closed footnotes. -LyXParagraph * LyXParagraph::Next() +LyXParagraph * LyXParagraph::next() +{ +#ifndef NEW_INSETS + if (next_ && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { + LyXParagraph * tmp = next_; + while (tmp + && tmp->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) + tmp = tmp->next_; + if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) + return tmp->next(); /* there can be more than one + footnote in a logical + paragraph */ + else + return next_; // This should never happen! + } else +#endif + return next_; +} + + +LyXParagraph const * LyXParagraph::next() const { #ifndef NEW_INSETS - if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { - LyXParagraph * tmp = next; + if (next_ && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { + LyXParagraph * tmp = next_; while (tmp && tmp->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) - tmp = tmp->next; + tmp = tmp->next_; if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) - return tmp->Next(); /* there can be more than one + return tmp->next(); /* there can be more than one footnote in a logical paragraph */ else - return next; // This should never happen! + return next_; // This should never happen! } else #endif - return next; + return next_; } #ifndef NEW_INSETS LyXParagraph * LyXParagraph::NextAfterFootnote() { - if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) { - LyXParagraph * tmp = next; + if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE) { + LyXParagraph * tmp = next_; while (tmp && tmp->footnoteflag != LyXParagraph::NO_FOOTNOTE) - tmp = tmp->next; + tmp = tmp->next_; if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) return tmp; /* there can be more than one footnote in a logical paragraph */ else - return next; // This should never happen! + return next_; // This should never happen! } else - return next; + return next_; } #endif @@ -1252,17 +1279,17 @@ LyXParagraph * LyXParagraph::NextAfterFootnote() #ifndef NEW_INSETS LyXParagraph const * LyXParagraph::NextAfterFootnote() const { - if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) { - LyXParagraph * tmp = next; + if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE) { + LyXParagraph * tmp = next_; while (tmp && tmp->footnoteflag != LyXParagraph::NO_FOOTNOTE) - tmp = tmp->next; + tmp = tmp->next_; if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) return tmp; /* there can be more than one footnote in a logical paragraph */ else - return next; // This should never happen! + return next_; // This should never happen! } else - return next; + return next_; } #endif @@ -1271,17 +1298,17 @@ LyXParagraph const * LyXParagraph::NextAfterFootnote() const LyXParagraph * LyXParagraph::PreviousBeforeFootnote() { LyXParagraph * tmp; - if (previous && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE) { - tmp = previous; + if (previous_ && previous_->footnoteflag != LyXParagraph::NO_FOOTNOTE) { + tmp = previous_; while (tmp && tmp->footnoteflag != LyXParagraph::NO_FOOTNOTE) - tmp = tmp->previous; + tmp = tmp->previous_; if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) return tmp; /* there can be more than one footnote in a logical paragraph */ else - return previous; // This should never happen! + return previous_; // This should never happen! } else - return previous; + return previous_; } #endif @@ -1293,8 +1320,8 @@ LyXParagraph * LyXParagraph::LastPhysicalPar() return this; LyXParagraph * tmp = this; - while (tmp->next - && tmp->next->footnoteflag != LyXParagraph::NO_FOOTNOTE) + while (tmp->next_ + && tmp->next_->footnoteflag != LyXParagraph::NO_FOOTNOTE) tmp = tmp->NextAfterFootnote(); return tmp; @@ -1309,8 +1336,8 @@ LyXParagraph const * LyXParagraph::LastPhysicalPar() const return this; LyXParagraph const * tmp = this; - while (tmp->next - && tmp->next->footnoteflag != LyXParagraph::NO_FOOTNOTE) + while (tmp->next_ + && tmp->next_->footnoteflag != LyXParagraph::NO_FOOTNOTE) tmp = tmp->NextAfterFootnote(); return tmp; @@ -1328,7 +1355,7 @@ LyXParagraph * LyXParagraph::FirstPhysicalPar() while (tmppar && (tmppar->IsDummy() || tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE)) - tmppar = tmppar->previous; + tmppar = tmppar->previous_; if (!tmppar) { return this; @@ -1348,7 +1375,7 @@ LyXParagraph const * LyXParagraph::FirstPhysicalPar() const while (tmppar && (tmppar->IsDummy() || tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE)) - tmppar = tmppar->previous; + tmppar = tmppar->previous_; if (!tmppar) { return this; @@ -1358,52 +1385,58 @@ LyXParagraph const * LyXParagraph::FirstPhysicalPar() const #endif +void LyXParagraph::previous(LyXParagraph * p) +{ + previous_ = p; +} + + // This function is able to hide closed footnotes. -LyXParagraph * LyXParagraph::Previous() +LyXParagraph * LyXParagraph::previous() { #ifndef NEW_INSETS - LyXParagraph * tmp = previous; + LyXParagraph * tmp = previous_; if (!tmp) return tmp; - if (tmp->previous - && tmp->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { - tmp = tmp->previous; + if (tmp->previous_ + && tmp->previous_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { + tmp = tmp->previous_; while (tmp && tmp->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) - tmp = tmp->previous; + tmp = tmp->previous_; if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) - return tmp->next->Previous(); + return tmp->next_->previous(); else - return previous; + return previous_; } else #endif - return previous; + return previous_; } // This function is able to hide closed footnotes. -LyXParagraph const * LyXParagraph::Previous() const +LyXParagraph const * LyXParagraph::previous() const { #ifndef NEW_INSETS - LyXParagraph * tmp = previous; + LyXParagraph * tmp = previous_; if (!tmp) return tmp; - if (tmp->previous - && tmp->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { - tmp = tmp->previous; + if (tmp->previous_ + && tmp->previous_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { + tmp = tmp->previous_; while (tmp && tmp->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) - tmp = tmp->previous; + tmp = tmp->previous_; if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) - return tmp->next->Previous(); + return tmp->next_->previous(); else - return previous; + return previous_; } else #endif - return previous; + return previous_; } @@ -1570,10 +1603,10 @@ LyXParagraph * LyXParagraph::FirstSelfrowPar() LyXParagraph * tmppar = this; while (tmppar && ( (tmppar->IsDummy() - && tmppar->previous->footnoteflag == + && tmppar->previous_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) || tmppar->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)) - tmppar = tmppar->previous; + tmppar = tmppar->previous_; if (!tmppar) return this; // This should never happen! @@ -1723,7 +1756,7 @@ void LyXParagraph::BreakParagraphConservative(BufferParams const & bparams, void LyXParagraph::PasteParagraph(BufferParams const & bparams) { // copy the next paragraph to this one - LyXParagraph * the_next = Next(); + LyXParagraph * the_next = next(); #ifndef NEW_INSETS LyXParagraph * firstpar = FirstPhysicalPar(); #endif @@ -1751,10 +1784,10 @@ void LyXParagraph::PasteParagraph(BufferParams const & bparams) } // delete the next paragraph - LyXParagraph * ppar = the_next->previous; - LyXParagraph * npar = the_next->next; + LyXParagraph * ppar = the_next->previous_; + LyXParagraph * npar = the_next->next_; delete the_next; - ppar->next = npar; + ppar->next(npar); } @@ -1762,10 +1795,10 @@ void LyXParagraph::PasteParagraph(BufferParams const & bparams) void LyXParagraph::OpenFootnote(LyXParagraph::size_type pos) { LyXParagraph * par = ParFromPos(pos); - par = par->next; + par = par->next_; while (par && par->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { par->footnoteflag = LyXParagraph::OPEN_FOOTNOTE; - par = par->next; + par = par->next_; } } @@ -1773,10 +1806,10 @@ void LyXParagraph::OpenFootnote(LyXParagraph::size_type pos) void LyXParagraph::CloseFootnote(LyXParagraph::size_type pos) { LyXParagraph * par = ParFromPos(pos); - par = par->next; + par = par->next_; while (par && par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) { par->footnoteflag = LyXParagraph::CLOSED_FOOTNOTE; - par = par->next; + par = par->next_; } } #endif @@ -1796,18 +1829,18 @@ int LyXParagraph::GetEndLabel(BufferParams const & bparams) const #ifndef NEW_INSETS if (footnoteflag == NO_FOOTNOTE) last = LastPhysicalPar(); - else if (next->footnoteflag == NO_FOOTNOTE) + else if (next_->footnoteflag == NO_FOOTNOTE) return endlabeltype; #else last = this; #endif - if (!last || !last->next) + if (!last || !last->next_) return endlabeltype; - int next_depth = last->next->GetDepth(); + int next_depth = last->next_->GetDepth(); if (par_depth > next_depth || - (par_depth == next_depth && layout != last->next->GetLayout() )) + (par_depth == next_depth && layout != last->next_->GetLayout() )) return endlabeltype; break; } @@ -1912,34 +1945,34 @@ void LyXParagraph::SetOnlyLayout(BufferParams const & bparams, par->layout = new_layout; if (par->params.pextraType() == PEXTRA_NONE) { - if (par->Previous()) { + if (par->previous()) { #ifndef NEW_INSETS - ppar = par->Previous()->FirstPhysicalPar(); + ppar = par->previous()->FirstPhysicalPar(); #else - ppar = par->Previous(); + ppar = par->previous(); #endif while(ppar - && ppar->Previous() + && ppar->previous() && (ppar->params.depth() > par->params.depth())) #ifndef NEW_INSETS - ppar = ppar->Previous()->FirstPhysicalPar(); + ppar = ppar->previous()->FirstPhysicalPar(); #else - ppar = ppar->Previous(); + ppar = ppar->previous(); #endif } - if (par->Next()) { + if (par->next()) { #ifndef NEW_INSETS - npar = par->Next()->NextAfterFootnote(); + npar = par->next()->NextAfterFootnote(); #else - npar = par->Next(); + npar = par->next(); #endif while(npar - && npar->Next() + && npar->next() && (npar->params.depth() > par->params.depth())) #ifndef NEW_INSETS - npar = npar->Next()->NextAfterFootnote(); + npar = npar->next()->NextAfterFootnote(); #else - npar = npar->Next(); + npar = npar->next(); #endif } if (ppar && (ppar->params.pextraType() != PEXTRA_NONE)) { @@ -1980,34 +2013,34 @@ void LyXParagraph::SetLayout(BufferParams const & bparams, par->params.spacing(Spacing(Spacing::Default)); if (par->params.pextraType() == PEXTRA_NONE) { - if (par->Previous()) { + if (par->previous()) { #ifndef NEW_INSETS - ppar = par->Previous()->FirstPhysicalPar(); + ppar = par->previous()->FirstPhysicalPar(); #else - ppar = par->Previous(); + ppar = par->previous(); #endif while(ppar - && ppar->Previous() + && ppar->previous() && (ppar->params.depth() > par->params.depth())) #ifndef NEW_INSETS - ppar = ppar->Previous()->FirstPhysicalPar(); + ppar = ppar->previous()->FirstPhysicalPar(); #else - ppar = ppar->Previous(); + ppar = ppar->previous(); #endif } - if (par->Next()) { + if (par->next()) { #ifndef NEW_INSETS - npar = par->Next()->NextAfterFootnote(); + npar = par->next()->NextAfterFootnote(); #else - npar = par->Next(); + npar = par->next(); #endif while(npar - && npar->Next() + && npar->next() && (npar->params.depth() > par->params.depth())) #ifndef NEW_INSETS - npar = npar->Next()->NextAfterFootnote(); + npar = npar->next()->NextAfterFootnote(); #else - npar = npar->Next(); + npar = npar->next(); #endif } if (ppar && (ppar->params.pextraType() != PEXTRA_NONE)) { @@ -2066,7 +2099,7 @@ int LyXParagraph::BeginningOfMainBody() const #ifndef NEW_INSETS if (i == 0 && i == size() && !(footnoteflag == LyXParagraph::NO_FOOTNOTE - && next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)) + && next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE)) ++i; /* the cursor should not jump * to the main body if there * is nothing in! */ @@ -2083,9 +2116,9 @@ LyXParagraph * LyXParagraph::DepthHook(int deth) do { #ifndef NEW_INSETS - newpar = newpar->FirstPhysicalPar()->Previous(); + newpar = newpar->FirstPhysicalPar()->previous(); #else - newpar = newpar->Previous(); + newpar = newpar->previous(); #endif } while (newpar && newpar->GetDepth() > deth #ifndef NEW_INSETS @@ -2094,7 +2127,7 @@ LyXParagraph * LyXParagraph::DepthHook(int deth) ); if (!newpar) { - if (Previous() || GetDepth()) + if (previous() || GetDepth()) lyxerr << "ERROR (LyXParagraph::DepthHook): " "no hook." << endl; newpar = this; @@ -2115,9 +2148,9 @@ LyXParagraph const * LyXParagraph::DepthHook(int deth) const do { #ifndef NEW_INSETS - newpar = newpar->FirstPhysicalPar()->Previous(); + newpar = newpar->FirstPhysicalPar()->previous(); #else - newpar = newpar->Previous(); + newpar = newpar->previous(); #endif } while (newpar && newpar->GetDepth() > deth #ifndef NEW_INSETS @@ -2126,7 +2159,7 @@ LyXParagraph const * LyXParagraph::DepthHook(int deth) const ); if (!newpar) { - if (Previous() || GetDepth()) + if (previous() || GetDepth()) lyxerr << "ERROR (LyXParagraph::DepthHook): " "no hook." << endl; newpar = this; @@ -2183,7 +2216,7 @@ int LyXParagraph::GetPositionOfInset(Inset * inset) const #ifndef NEW_INSETS // Think about footnotes. if (footnoteflag == LyXParagraph::NO_FOOTNOTE - && next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { + && next_ && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { int const further = NextAfterFootnote()->GetPositionOfInset(inset); if (further != -1) @@ -2223,7 +2256,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, } if (!params.spacing().isDefault() - && (!Previous() || !Previous()->HasSameLayout(this))) { + && (!previous() || !previous()->HasSameLayout(this))) { os << params.spacing().writeEnvirBegin() << "\n"; texrow.newline(); } @@ -2255,8 +2288,8 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, Language const * language = getParLanguage(bparams); Language const * doc_language = bparams.language; - Language const * previous_language = previous - ? previous->getParLanguage(bparams) : doc_language; + Language const * previous_language = previous_ + ? previous_->getParLanguage(bparams) : doc_language; if (language->babel() != doc_language->babel() && language->babel() != previous_language->babel()) { os << subst(lyxrc.language_command_begin, "$$lang", @@ -2294,12 +2327,12 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, bool need_par = SimpleTeXOnePar(buf, bparams, os, texrow, moving_arg); - LyXParagraph * par = next; + LyXParagraph * par = next_; #ifndef NEW_INSETS // Spit out footnotes if (lyxrc.rtl_support) { - if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE - && next->footnoteflag != footnoteflag) { + if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE + && next_->footnoteflag != footnoteflag) { LyXParagraph * p = 0; bool is_rtl = (size() > 0) ? GetFontSettings(bparams, @@ -2321,13 +2354,13 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, ? par->GetFontSettings(bparams, par->size()-1).isRightToLeft() : language->RightToLeft(); - if (par->next && - par->next->footnoteflag != LyXParagraph::NO_FOOTNOTE && + if (par->next_ && + par->next_->footnoteflag != LyXParagraph::NO_FOOTNOTE && (p = par->NextAfterFootnote()) != 0 && p->size() > 0 && p->GetFontSettings(bparams, 0).isRightToLeft() != is_rtl) is_rtl = language->RightToLeft(); - par = par->next; + par = par->next_; } } } else { @@ -2338,7 +2371,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, foot, foot_texrow, foot_count, false); par->SimpleTeXOnePar(buf, bparams, os, texrow, moving_arg); - par = par->next; + par = par->next_; } } #endif @@ -2355,7 +2388,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, LyXFont font = getFont(bparams, Last() - 1); bool is_command = textclasslist.Style(bparams.textclass, GetLayout()).isCommand(); - if (style.resfont.size() != font.size() && next && !is_command) { + if (style.resfont.size() != font.size() && next_ && !is_command) { if (!need_par) os << "{"; os << "\\" << font.latexSize() << " \\par}"; @@ -2396,7 +2429,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, // or for tables in floats // -- effectively creates a \par where there isn't one which // breaks a \subfigure or \subtable. - if (next) { + if (next_) { // && footnoteflag == LyXParagraph::NO_FOOTNOTE) { os << '\n'; texrow.newline(); @@ -2431,7 +2464,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, } // we don't need it for the last paragraph!!! - if (next + if (next_ #ifndef NEW_INSETS && !(footnoteflag != LyXParagraph::NO_FOOTNOTE && par && par->footnoteflag == LyXParagraph::NO_FOOTNOTE) @@ -2523,7 +2556,7 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf, if (style.isCommand()) { os << '{'; ++column; - } else if (params.align() != LYX_ALIGN_LAYOUT && next) { + } else if (params.align() != LYX_ALIGN_LAYOUT && next_) { // We do not need \par here (Dekel) // os << "{\\par"; os << "{"; @@ -2579,8 +2612,8 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf, #ifndef NEW_INSETS LyXParagraph * p = 0; if (i == 0 - && previous && - previous->footnoteflag != LyXParagraph::NO_FOOTNOTE && + && previous_ && + previous_->footnoteflag != LyXParagraph::NO_FOOTNOTE && (p = PreviousBeforeFootnote()) != 0) last_font = p->getFont(bparams, p->size() - 1); else @@ -2657,12 +2690,12 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf, // If we have an open font definition, we have to close it if (open_font) { LyXParagraph * p = 0; - if (next + if (next_ #ifndef NEW_INSETS - && next->footnoteflag != LyXParagraph::NO_FOOTNOTE + && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE && (p = NextAfterFootnote()) != 0 #else - && (p = next) + && (p = next_) #endif ) running_font.latexWriteEndChanges(os, basefont, @@ -3158,8 +3191,8 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, eindent_open = true; } if ((params.pextraType() == PEXTRA_MINIPAGE) && !minipage_open) { - if (params.pextraHfill() && Previous() && - (Previous()->params.pextraType() == PEXTRA_MINIPAGE)) { + if (params.pextraHfill() && previous() && + (previous()->params.pextraType() == PEXTRA_MINIPAGE)) { os << "\\hfill{}\n"; texrow.newline(); } @@ -3297,8 +3330,8 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, } if (par && par->layout == layout && par->params.depth() == params.depth() && (par->params.pextraType() == PEXTRA_MINIPAGE) && !minipage_open) { - if (par->params.pextraHfill() && par->Previous() && - (par->Previous()->params.pextraType() == PEXTRA_MINIPAGE)){ + if (par->params.pextraHfill() && par->previous() && + (par->previous()->params.pextraType() == PEXTRA_MINIPAGE)){ os << "\\hfill{}\n"; texrow.newline(); } @@ -3421,7 +3454,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf, LyXParagraph * par = this; LyXLayout const & style = textclasslist.Style(bparams.textclass, - previous->GetLayout()); + previous_->GetLayout()); if (style.needprotect && footnotekind != LyXParagraph::FOOTNOTE){ lyxerr << "ERROR (LyXParagraph::TeXFootnote): " @@ -3668,15 +3701,15 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf, texrow.newline(); } - lyxerr[Debug::LATEX] << "TeXFootnote...done " << par->next << endl; + lyxerr[Debug::LATEX] << "TeXFootnote...done " << par->next_ << endl; return par; } bool LyXParagraph::IsDummy() const { - return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous - && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE); + return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous_ + && previous_->footnoteflag != LyXParagraph::NO_FOOTNOTE); } #endif @@ -3696,13 +3729,13 @@ void LyXParagraph::SetPExtraType(BufferParams const & bparams, while (par && (par->layout == layout) && (par->params.depth() == params.depth())) { ppar = par; - par = par->Previous(); + par = par->previous(); #ifndef NEW_INSETS if (par) par = par->FirstPhysicalPar(); #endif while (par && par->params.depth() > params.depth()) { - par = par->Previous(); + par = par->previous(); #ifndef NEW_INSETS if (par) par = par->FirstPhysicalPar(); @@ -3718,7 +3751,7 @@ void LyXParagraph::SetPExtraType(BufferParams const & bparams, #ifndef NEW_INSETS par = par->NextAfterFootnote(); #else - par = par->Next(); + par = par->next(); #endif if (par && (par->params.depth() > params.depth())) par->SetPExtraType(bparams, @@ -3728,7 +3761,7 @@ void LyXParagraph::SetPExtraType(BufferParams const & bparams, par = par->NextAfterFootnote(); #else while (par && par->params.depth() > params.depth()) - par = par->Next(); + par = par->next(); #endif } } @@ -3752,13 +3785,13 @@ void LyXParagraph::UnsetPExtraType(BufferParams const & bparams) while (par && (par->layout == layout) && (par->params.depth() == params.depth())) { ppar = par; - par = par->Previous(); + par = par->previous(); #ifndef NEW_INSETS if (par) par = par->FirstPhysicalPar(); #endif while (par && par->params.depth() > params.depth()) { - par = par->Previous(); + par = par->previous(); #ifndef NEW_INSETS if (par) par = par->FirstPhysicalPar(); @@ -3774,7 +3807,7 @@ void LyXParagraph::UnsetPExtraType(BufferParams const & bparams) #ifndef NEW_INSETS par = par->NextAfterFootnote(); #else - par = par->Next(); + par = par->next(); #endif if (par && (par->params.depth() > params.depth())) par->UnsetPExtraType(bparams); @@ -3783,7 +3816,7 @@ void LyXParagraph::UnsetPExtraType(BufferParams const & bparams) par = par->NextAfterFootnote(); #else while (par && par->params.depth() > params.depth()) - par = par->Next(); + par = par->next(); #endif } } @@ -3866,8 +3899,8 @@ LyXParagraph::getParLanguage(BufferParams const & bparams) const #endif if (size() > 0) return GetFirstFontSettings().language(); - else if (previous) - return previous->getParLanguage(bparams); + else if (previous_) + return previous_->getParLanguage(bparams); else return bparams.language; } @@ -3931,7 +3964,7 @@ string const LyXParagraph::String(Buffer const * buffer, bool label) } #ifndef NEW_INSETS - if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE + if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE && footnoteflag == LyXParagraph::NO_FOOTNOTE) s += NextAfterFootnote()->String(buffer, false); diff --git a/src/tabular.C b/src/tabular.C index 5744600ad5..02cbc7544a 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -2541,11 +2541,25 @@ void LyXTabular::Validate(LaTeXFeatures & features) const } +#ifndef NEW_INSETS +LyXTabular::BoxType LyXTabular::UseParbox(int cell) const +{ + LyXParagraph * par = GetCellInset(cell)->par; + + for (; par; par = par->next_) { + for (int i = 0; i < par->Last(); ++i) { + if (par->GetChar(i) == LyXParagraph::META_NEWLINE) + return BOX_PARBOX; + } + } + return BOX_NONE; +} +#else LyXTabular::BoxType LyXTabular::UseParbox(int cell) const { LyXParagraph * par = GetCellInset(cell)->par; - for (; par; par = par->next) { + for (; par; par = par->next()) { for (int i = 0; i < par->Last(); ++i) { if (par->GetChar(i) == LyXParagraph::META_NEWLINE) return BOX_PARBOX; @@ -2553,3 +2567,4 @@ LyXTabular::BoxType LyXTabular::UseParbox(int cell) const } return BOX_NONE; } +#endif diff --git a/src/text.C b/src/text.C index 590dd65429..cedf1085b0 100644 --- a/src/text.C +++ b/src/text.C @@ -688,9 +688,9 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const if (!row->par()->GetLayout()) { // find the previous same level paragraph #ifndef NEW_INSETS - if (row->par()->FirstPhysicalPar()->Previous()) { + if (row->par()->FirstPhysicalPar()->previous()) { #else - if (row->par()->Previous()) { + if (row->par()->previous()) { #endif LyXParagraph * newpar = row->par() ->DepthHook(row->par()->GetDepth()); @@ -926,14 +926,14 @@ int LyXText::RightMargin(Buffer const * buf, Row const * row) const #ifndef NEW_INSETS do { - newpar = newpar->FirstPhysicalPar()->Previous(); + newpar = newpar->FirstPhysicalPar()->previous(); if (newpar) newpar = newpar->FirstPhysicalPar(); } while (newpar && newpar->GetDepth() >= row->par()->GetDepth() && newpar->footnoteflag == row->par()->footnoteflag); #else do { - newpar = newpar->Previous(); + newpar = newpar->previous(); } while (newpar && newpar->GetDepth() >= row->par()->GetDepth()); #endif @@ -1407,19 +1407,24 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const BufferParams::PARSEP_SKIP) { if (layout.isParagraph() && firstpar->GetDepth() == 0 - && firstpar->Previous()) + && firstpar->previous()) maxasc += bview->buffer()->params.getDefSkip().inPixels(bview); - else if (firstpar->Previous() + else if (firstpar->previous() && textclasslist.Style(bview->buffer()->params.textclass, - firstpar->Previous()->GetLayout()).isParagraph() - && firstpar->Previous()->GetDepth() == 0) + firstpar->previous()->GetLayout()).isParagraph() + && firstpar->previous()->GetDepth() == 0) // is it right to use defskip here too? (AS) maxasc += bview->buffer()->params.getDefSkip().inPixels(bview); } - /* the paper margins */ - if (!row_ptr->par()->previous && bv_owner) + /* the paper margins */ +#ifndef NEW_INSETS + if (!row_ptr->par()->previous_ && bv_owner) + maxasc += LYX_PAPER_MARGIN; +#else + if (!row_ptr->par()->previous() && bv_owner) maxasc += LYX_PAPER_MARGIN; +#endif /* add the vertical spaces, that the user added */ if (firstpar->params.spaceTop().kind() != VSpace::NONE) @@ -1482,7 +1487,7 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const * or between the items of a itemize or enumerate environment */ if (!firstpar->params.pagebreakTop()) { - LyXParagraph * prev = row_ptr->par()->Previous(); + LyXParagraph * prev = row_ptr->par()->previous(); if (prev) prev = row_ptr->par()->DepthHook(row_ptr->par()->GetDepth()); if (prev && prev->GetLayout() == firstpar->GetLayout() @@ -1515,12 +1520,12 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const prev->GetLayout()).parsep * DefaultHeight()); } else { - if (firstpar->Previous() - && firstpar->Previous()->GetDepth() == 0 - && firstpar->Previous()->GetLayout() != firstpar->GetLayout()) { + if (firstpar->previous() + && firstpar->previous()->GetDepth() == 0 + && firstpar->previous()->GetLayout() != firstpar->GetLayout()) { /* avoid parsep */ } - else if (firstpar->Previous()){ + else if (firstpar->previous()){ maxasc += int(layout.parsep * DefaultHeight()); } } @@ -1534,12 +1539,17 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const #else row_ptr->par() == par #endif - && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par())) { + && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par())) { - /* the paper margins */ - if (!par->next && bv_owner) + /* the paper margins */ +#ifndef NEW_INSETS + if (!par->next_ && bv_owner) maxdesc += LYX_PAPER_MARGIN; - +#else + if (!par->next() && bv_owner) + maxdesc += LYX_PAPER_MARGIN; +#endif + /* add the vertical spaces, that the user added */ if (firstpar->params.spaceBottom().kind() != VSpace::NONE) maxdesc += int(firstpar->params.spaceBottom().inPixels(bview)); @@ -1556,8 +1566,8 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const /* and now the layout spaces, for example before and after a section, * or between the items of a itemize or enumerate environment */ - if (!firstpar->params.pagebreakBottom() && row_ptr->par()->Next()) { - LyXParagraph * nextpar = row_ptr->par()->Next(); + if (!firstpar->params.pagebreakBottom() && row_ptr->par()->next()) { + LyXParagraph * nextpar = row_ptr->par()->next(); LyXParagraph * comparepar = row_ptr->par(); float usual = 0; float unusual = 0; @@ -1750,11 +1760,11 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) SetUndo(bview->buffer(), Undo::INSERT, #ifndef NEW_INSETS - cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next + cursor.par()->ParFromPos(cursor.pos())->previous_, + cursor.par()->ParFromPos(cursor.pos())->next_ #else - cursor.par()->previous, - cursor.par()->next + cursor.par()->previous(), + cursor.par()->next() #endif ); @@ -1781,7 +1791,7 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) cursor.par()->SetLayout(bview->buffer()->params, 0); else // set to standard-layout - cursor.par()->Next()->SetLayout(bview->buffer()->params, 0); + cursor.par()->next()->SetLayout(bview->buffer()->params, 0); } /* if the cursor is at the beginning of a row without prior newline, @@ -1812,18 +1822,18 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) SetHeightOfRow(bview, cursor.row()); - while (cursor.par()->Next()->Last() - && cursor.par()->Next()->IsNewline(0)) - cursor.par()->Next()->Erase(0); + while (cursor.par()->next()->Last() + && cursor.par()->next()->IsNewline(0)) + cursor.par()->next()->Erase(0); - InsertParagraph(bview, cursor.par()->Next(), cursor.row()); + InsertParagraph(bview, cursor.par()->next(), cursor.row()); UpdateCounters(bview, cursor.row()->previous()); /* This check is necessary. Otherwise the new empty paragraph will * be deleted automatically. And it is more friendly for the user! */ if (cursor.pos()) - SetCursor(bview, cursor.par()->Next(), 0); + SetCursor(bview, cursor.par()->next(), 0); else SetCursor(bview, cursor.par(), 0); @@ -1843,8 +1853,8 @@ void LyXText::OpenFootnote(BufferView * bview) LyXParagraph * par = cursor.par()->ParFromPos(cursor.pos()); /* if there is no footnote in this paragraph, just return. */ - if (!par->next - || par->next->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) + if (!par->next_ + || par->next_->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) return; /* ok, move the cursor right before the footnote */ @@ -1867,7 +1877,7 @@ void LyXText::OpenFootnote(BufferView * bview) refresh_y = cursor.y() - cursor.row()->baseline(); tmppar = cursor.par(); - endpar = cursor.par()->Next(); + endpar = cursor.par()->next(); row = cursor.row(); tmppar->OpenFootnote(cursor.pos()); @@ -1876,17 +1886,17 @@ void LyXText::OpenFootnote(BufferView * bview) row->fill(Fill(bview, row, workWidth(bview))); SetHeightOfRow(bview, row); // CHECK See comment on top of text.C - tmppar = tmppar->Next(); + tmppar = tmppar->next(); while (tmppar != endpar) { if (tmppar) { InsertParagraph(bview, tmppar, row); while (row->next() && row->next()->par() == tmppar) row = row->next(); - tmppar = tmppar->Next(); + tmppar = tmppar->next(); } } - SetCursor(bview, par->next, 0); + SetCursor(bview, par->next_, 0); sel_cursor = cursor; } #endif @@ -1896,7 +1906,7 @@ void LyXText::OpenFootnote(BufferView * bview) void LyXText::RedoParagraph(BufferView * bview) const { ClearSelection(bview); - RedoParagraphs(bview, cursor, cursor.par()->Next()); + RedoParagraphs(bview, cursor, cursor.par()->next()); SetCursorIntern(bview, cursor.par(), cursor.pos()); } @@ -1907,11 +1917,11 @@ void LyXText::InsertChar(BufferView * bview, char c) { SetUndo(bview->buffer(), Undo::INSERT, #ifndef NEW_INSETS - cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next + cursor.par()->ParFromPos(cursor.pos())->previous_, + cursor.par()->ParFromPos(cursor.pos())->next_ #else - cursor.par()->previous, - cursor.par()->next + cursor.par()->previous(), + cursor.par()->next() #endif ); @@ -2003,8 +2013,8 @@ void LyXText::InsertChar(BufferView * bview, char c) && cursor.par()->IsNewline(cursor.pos() - 1)) || (cursor.pos() == 0 #ifndef NEW_INSETS - && !(cursor.par()->Previous() - && cursor.par()->Previous()->footnoteflag + && !(cursor.par()->previous() + && cursor.par()->previous()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) #endif )) { @@ -2318,8 +2328,8 @@ void LyXText::CursorRightOneWord(BufferView * bview) const // CHECK See comment on top of text.C if (tmpcursor.pos() == tmpcursor.par()->Last() - && tmpcursor.par()->Next()) { - tmpcursor.par(tmpcursor.par()->Next()); + && tmpcursor.par()->next()) { + tmpcursor.par(tmpcursor.par()->next()); tmpcursor.pos(0); } else { int steps = 0; @@ -2353,8 +2363,8 @@ void LyXText::CursorTab(BufferView * bview) const tmpcursor.pos(tmpcursor.pos() + 1); if (tmpcursor.pos() == tmpcursor.par()->Last()){ - if (tmpcursor.par()->Next()) { - tmpcursor.par(tmpcursor.par()->Next()); + if (tmpcursor.par()->next()) { + tmpcursor.par(tmpcursor.par()->next()); tmpcursor.pos(0); } } else @@ -2388,8 +2398,8 @@ void LyXText::CursorLeftOneWord(BufferView * bview) const || tmpcursor.par()->IsHfill(tmpcursor.pos() - 1))) { tmpcursor.pos(tmpcursor.pos() - 1); } else if (!tmpcursor.pos()) { - if (tmpcursor.par()->Previous()){ - tmpcursor.par(tmpcursor.par()->Previous()); + if (tmpcursor.par()->previous()){ + tmpcursor.par(tmpcursor.par()->previous()); tmpcursor.pos(tmpcursor.par()->Last()); } } else { // Here, tmpcursor != 0 @@ -2454,20 +2464,29 @@ string const LyXText::SelectNextWord(BufferView * bview, // If this is not the very first word, skip rest of // current word because we are probably in the middle // of a word if there is text here. - if (cursor.pos() || cursor.par()->previous) { +#ifndef NEW_INSETS + if (cursor.pos() || cursor.par()->previous_) { while (cursor.pos() < cursor.par()->Last() && cursor.par()->IsLetter(cursor.pos())) cursor.pos(cursor.pos() + 1); } +#else + if (cursor.pos() || cursor.par()->previous()) { + while (cursor.pos() < cursor.par()->Last() + && cursor.par()->IsLetter(cursor.pos())) + cursor.pos(cursor.pos() + 1); + } +#endif + // Now, skip until we have real text (will jump paragraphs) while ((cursor.par()->Last() > cursor.pos() && (!cursor.par()->IsLetter(cursor.pos()) || cursor.par()->getFont(bview->buffer()->params, cursor.pos()) .latex() == LyXFont::ON)) || (cursor.par()->Last() == cursor.pos() - && cursor.par()->Next())){ + && cursor.par()->next())){ if (cursor.pos() == cursor.par()->Last()) { - cursor.par(cursor.par()->Next()); + cursor.par(cursor.par()->next()); cursor.pos(0); } else cursor.pos(cursor.pos() + 1); @@ -2614,18 +2633,21 @@ void LyXText::ChangeWordCase(BufferView * bview, LyXText::TextCase action) { #ifndef NEW_INSETS LyXParagraph * tmppar = cursor.par()->ParFromPos(cursor.pos()); -#else - LyXParagraph * tmppar = cursor.par(); -#endif - SetUndo(bview->buffer(),Undo::FINISH, tmppar->previous, tmppar->next); + SetUndo(bview->buffer(),Undo::FINISH, + tmppar->previous_, tmppar->next_); -#ifndef NEW_INSETS LyXParagraph::size_type tmppos = cursor.par()->PositionInParFromPos(cursor.pos()); #else + LyXParagraph * tmppar = cursor.par(); + + SetUndo(bview->buffer(),Undo::FINISH, + tmppar->previous(), tmppar->next()); + LyXParagraph::size_type tmppos = cursor.pos(); #endif + while (tmppos < tmppar->size()) { unsigned char c = tmppar->GetChar(tmppos); if (IsKommaChar(c) || IsLineSeparatorChar(c)) @@ -2660,8 +2682,13 @@ void LyXText::Delete(BufferView * bview) LyXCursor old_cursor = cursor; int const old_cur_par_id = old_cursor.par()->id(); - int const old_cur_par_prev_id = old_cursor.par()->previous ? - old_cursor.par()->previous->id() : 0; +#ifndef NEW_INSETS + int const old_cur_par_prev_id = old_cursor.par()->previous_ ? + old_cursor.par()->previous_->id() : 0; +#else + int const old_cur_par_prev_id = old_cursor.par()->previous() ? + old_cursor.par()->previous()->id() : 0; +#endif // just move to the right CursorRight(bview); @@ -2672,7 +2699,12 @@ void LyXText::Delete(BufferView * bview) // and that can very well delete the par or par->previous in // old_cursor. Will a solution where we compare paragraph id's //work better? - if ((cursor.par()->previous ? cursor.par()->previous->id() : 0) + if ( +#ifndef NEW_INSETS + (cursor.par()->previous_ ? cursor.par()->previous_->id() : 0) +#else + (cursor.par()->previous() ? cursor.par()->previous()->id() : 0) +#endif == old_cur_par_prev_id && cursor.par()->id() != old_cur_par_id) return; // delete-empty-paragraph-mechanism has done it @@ -2683,11 +2715,11 @@ void LyXText::Delete(BufferView * bview) cursor = old_cursor; // to make sure undo gets the right cursor position SetUndo(bview->buffer(), Undo::DELETE, #ifndef NEW_INSETS - cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next + cursor.par()->ParFromPos(cursor.pos())->previous_, + cursor.par()->ParFromPos(cursor.pos())->next_ #else - cursor.par()->previous, - cursor.par()->next + cursor.par()->previous(), + cursor.par()->next() #endif ); cursor = tmpcursor; @@ -2714,24 +2746,24 @@ void LyXText::Backspace(BufferView * bview) if ((lastpos == 0 || (lastpos == 1 && cursor.par()->IsSeparator(0))) #ifndef NEW_INSETS - && !(cursor.par()->Next() + && !(cursor.par()->next() && cursor.par()->footnoteflag == LyXParagraph::NO_FOOTNOTE - && cursor.par()->Next()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) + && cursor.par()->next()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) #endif ) { // This is an empty paragraph and we delete it just by moving the cursor one step // left and let the DeleteEmptyParagraphMechanism handle the actual deletion // of the paragraph. - if (cursor.par()->previous) { #ifndef NEW_INSETS - LyXParagraph * tmppar = cursor.par()->previous->FirstPhysicalPar(); -#else - LyXParagraph * tmppar = cursor.par()->previous; -#endif + if (cursor.par()->previous_) { + LyXParagraph * tmppar = cursor.par()->previous_->FirstPhysicalPar(); if (cursor.par()->GetLayout() == tmppar->GetLayout() -#ifndef NEW_INSETS && cursor.par()->footnoteflag == tmppar->footnoteflag +#else + if (cursor.par()->previous()) { + LyXParagraph * tmppar = cursor.par()->previous(); + if (cursor.par()->GetLayout() == tmppar->GetLayout() #endif && cursor.par()->GetAlign() == tmppar->GetAlign()) { // Inherit bottom DTD from the paragraph below. @@ -2756,16 +2788,16 @@ void LyXText::Backspace(BufferView * bview) } #ifndef NEW_INSETS - if (cursor.par()->ParFromPos(cursor.pos())->previous){ + if (cursor.par()->ParFromPos(cursor.pos())->previous_) { SetUndo(bview->buffer(), Undo::DELETE, - cursor.par()->ParFromPos(cursor.pos())->previous->previous, - cursor.par()->ParFromPos(cursor.pos())->next); + cursor.par()->ParFromPos(cursor.pos())->previous_->previous_, + cursor.par()->ParFromPos(cursor.pos())->next_); } #else - if (cursor.par()->previous) { + if (cursor.par()->previous()) { SetUndo(bview->buffer(), Undo::DELETE, - cursor.par()->previous->previous, - cursor.par()->next); + cursor.par()->previous()->previous(), + cursor.par()->next()); } #endif @@ -2776,10 +2808,10 @@ void LyXText::Backspace(BufferView * bview) // not a good idea since it triggers the auto-delete // mechanism. So we do a CursorLeftIntern()-lite, // without the dreaded mechanism. (JMarc) - if (cursor.par()->Previous()) { + if (cursor.par()->previous()) { // steps into the above paragraph. - SetCursorIntern(bview, cursor.par()->Previous(), - cursor.par()->Previous()->Last(), false); + SetCursorIntern(bview, cursor.par()->previous(), + cursor.par()->previous()->Last(), false); } /* Pasting is not allowed, if the paragraphs have different @@ -2837,11 +2869,11 @@ void LyXText::Backspace(BufferView * bview) * any paragraphs */ SetUndo(bview->buffer(), Undo::DELETE, #ifndef NEW_INSETS - cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next + cursor.par()->ParFromPos(cursor.pos())->previous_, + cursor.par()->ParFromPos(cursor.pos())->next_ #else - cursor.par()->previous, - cursor.par()->next + cursor.par()->previous(), + cursor.par()->next() #endif ); // We used to do CursorLeftIntern() here, but it is @@ -3506,12 +3538,12 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, if (bview->buffer()->params.paragraph_separation == BufferParams::PARSEP_SKIP) { if (layout.latextype == LATEX_PARAGRAPH && firstpar->GetDepth() == 0 - && firstpar->Previous()) + && firstpar->previous()) y_top += bview->buffer()->params.getDefSkip().inPixels(bview); - else if (firstpar->Previous() + else if (firstpar->previous() && textclasslist.Style(bview->buffer()->params.textclass, - firstpar->Previous()->GetLayout()).latextype == LATEX_PARAGRAPH - && firstpar->Previous()->GetDepth() == 0) + firstpar->previous()->GetLayout()).latextype == LATEX_PARAGRAPH + && firstpar->previous()->GetDepth() == 0) // is it right to use defskip here, too? (AS) y_top += bview->buffer()->params.getDefSkip().inPixels(bview); } @@ -3996,7 +4028,7 @@ void LyXText::InsertFootnoteEnvironment(BufferView * bview, while (tmppar != sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos()) && tmppar->footnoteflag == LyXParagraph::NO_FOOTNOTE) - tmppar = tmppar->next; + tmppar = tmppar->next_; if (tmppar != sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos()) || tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE) { @@ -4010,8 +4042,8 @@ void LyXText::InsertFootnoteEnvironment(BufferView * bview, * and sel_end cursor */ SetUndo(bview->buffer(), Undo::FINISH, - sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())->previous, - sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())->next); + sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())->previous_, + sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())->next_); if (sel_end_cursor.pos() > 0 && sel_end_cursor.par()->IsLineSeparator(sel_end_cursor.pos() - 1)) @@ -4023,14 +4055,14 @@ void LyXText::InsertFootnoteEnvironment(BufferView * bview, sel_end_cursor.par()->BreakParagraphConservative(bview->buffer()->params, sel_end_cursor.pos()); - sel_end_cursor.par(sel_end_cursor.par()->Next()); + sel_end_cursor.par(sel_end_cursor.par()->next()); sel_end_cursor.pos(0); // don't forget to insert a dummy layout paragraph if necessary if (sel_start_cursor.par()->GetLayout() != sel_end_cursor.par()->layout){ sel_end_cursor.par()->BreakParagraphConservative(bview->buffer()->params, 0); sel_end_cursor.par()->layout = LYX_DUMMY_LAYOUT; - sel_end_cursor.par(sel_end_cursor.par()->next); + sel_end_cursor.par(sel_end_cursor.par()->next_); } else sel_end_cursor.par()->layout = LYX_DUMMY_LAYOUT; @@ -4048,7 +4080,7 @@ void LyXText::InsertFootnoteEnvironment(BufferView * bview, sel_start_cursor.par()->BreakParagraphConservative(bview->buffer()->params, sel_start_cursor.pos()); - tmppar = sel_start_cursor.par()->Next(); + tmppar = sel_start_cursor.par()->next(); if (dummy_selection) { tmppar->Clear(); @@ -4085,12 +4117,12 @@ void LyXText::InsertFootnoteEnvironment(BufferView * bview, while (tmppar != sel_end_cursor.par()) { tmppar->footnoteflag = LyXParagraph::OPEN_FOOTNOTE; tmppar->footnotekind = kind; - tmppar = tmppar->Next(); + tmppar = tmppar->next(); } - RedoParagraphs(bview, sel_start_cursor, sel_end_cursor.par()->Next()); + RedoParagraphs(bview, sel_start_cursor, sel_end_cursor.par()->next()); - SetCursor(bview, sel_start_cursor.par()->Next(), 0); + SetCursor(bview, sel_start_cursor.par()->next(), 0); ClearSelection(bview); } diff --git a/src/text2.C b/src/text2.C index 6dac6a12ba..77287dd1b2 100644 --- a/src/text2.C +++ b/src/text2.C @@ -88,7 +88,7 @@ void LyXText::init() current_font = GetFont(bv_owner->buffer(), par, 0); while (par) { InsertParagraph(bv_owner, par, lastrow); - par = par->Next(); + par = par->next(); } SetCursor(bv_owner, firstrow->par(), 0); } else @@ -134,7 +134,7 @@ void LyXText::init(BufferView * bview) current_font = GetFont(bview->buffer(), par, 0); while (par) { InsertParagraph(bview, par, lastrow); - par = par->Next(); + par = par->next(); } SetCursorIntern(bview, firstrow->par(), 0); sel_cursor = cursor; @@ -407,8 +407,8 @@ void LyXText::InsertParagraph(BufferView * bview, LyXParagraph * par, void LyXText::ToggleFootnote(BufferView * bview) { LyXParagraph * par = cursor.par()->ParFromPos(cursor.pos()); - if (par->next - && par->next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { + if (par->next_ + && par->next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { OpenFootnote(bview); bview->owner()->getMiniBuffer()->Set(_("Opened float")); } else { @@ -452,8 +452,8 @@ void LyXText::CloseFootnote(BufferView * bview) // there is no open footnote in this paragraph, just return. if (cursor.par()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) { - if (!par->next || - par->next->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) { + if (!par->next_ || + par->next_->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) { bview->owner()->getMiniBuffer() ->Set(_("Nothing to do")); return; @@ -477,7 +477,7 @@ void LyXText::CloseFootnote(BufferView * bview) tmppar = cursor.par(); while (tmppar->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) { // just a little bit faster than movin the cursor - tmppar = tmppar->Previous(); + tmppar = tmppar->previous(); } SetCursor(bview, tmppar, tmppar->Last()); } @@ -490,7 +490,7 @@ void LyXText::CloseFootnote(BufferView * bview) refresh_y = cursor.y() - cursor.row()->baseline(); tmppar = cursor.par(); - LyXParagraph * endpar = par->NextAfterFootnote()->Next(); + LyXParagraph * endpar = par->NextAfterFootnote()->next(); Row * row = cursor.row(); tmppar->CloseFootnote(cursor.pos()); @@ -545,30 +545,30 @@ LyXParagraph * LyXText::SetLayout(BufferView * bview, LyXTextClass::size_type layout) { #ifndef NEW_INSETS - LyXParagraph * endpar = send_cur.par()->LastPhysicalPar()->Next(); + LyXParagraph * endpar = send_cur.par()->LastPhysicalPar()->next(); #else - LyXParagraph * endpar = send_cur.par()->Next(); + LyXParagraph * endpar = send_cur.par()->next(); #endif LyXParagraph * undoendpar = endpar; if (endpar && endpar->GetDepth()) { while (endpar && endpar->GetDepth()) { #ifndef NEW_INSETS - endpar = endpar->LastPhysicalPar()->Next(); + endpar = endpar->LastPhysicalPar()->next(); #else - endpar = endpar->Next(); + endpar = endpar->next(); #endif undoendpar = endpar; } } else if (endpar) { - endpar = endpar->Next(); // because of parindents etc. + endpar = endpar->next(); // because of parindents etc. } SetUndo(bview->buffer(), Undo::EDIT, #ifndef NEW_INSETS - sstart_cur.par()->ParFromPos(sstart_cur.pos())->previous, + sstart_cur.par()->ParFromPos(sstart_cur.pos())->previous_, #else - sstart_cur.par()->previous, + sstart_cur.par()->previous(), #endif undoendpar); @@ -604,7 +604,7 @@ LyXParagraph * LyXText::SetLayout(BufferView * bview, #ifndef NEW_INSETS } #endif - cur.par(cur.par()->Next()); + cur.par(cur.par()->next()); } #ifndef NEW_INSETS if (cur.par()->footnoteflag == sstart_cur.par()->footnoteflag) { @@ -676,32 +676,32 @@ void LyXText::IncDepth(BufferView * bview) // We end at the next paragraph with depth 0 LyXParagraph * endpar = #ifndef NEW_INSETS - sel_end_cursor.par()->LastPhysicalPar()->Next(); + sel_end_cursor.par()->LastPhysicalPar()->next(); #else - sel_end_cursor.par()->Next(); + sel_end_cursor.par()->next(); #endif LyXParagraph * undoendpar = endpar; if (endpar && endpar->GetDepth()) { while (endpar && endpar->GetDepth()) { #ifndef NEW_INSETS - endpar = endpar->LastPhysicalPar()->Next(); + endpar = endpar->LastPhysicalPar()->next(); #else - endpar = endpar->Next(); + endpar = endpar->next(); #endif undoendpar = endpar; } } else if (endpar) { - endpar = endpar->Next(); // because of parindents etc. + endpar = endpar->next(); // because of parindents etc. } SetUndo(bview->buffer(), Undo::EDIT, #ifndef NEW_INSETS sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous, + .par()->ParFromPos(sel_start_cursor.pos())->previous_, #else - sel_start_cursor.par()->previous, + sel_start_cursor.par()->previous(), #endif undoendpar); @@ -725,9 +725,9 @@ void LyXText::IncDepth(BufferView * bview) ).labeltype != LABEL_BIBLIO) { LyXParagraph * prev = #ifndef NEW_INSETS - cursor.par()->FirstPhysicalPar()->Previous(); + cursor.par()->FirstPhysicalPar()->previous(); #else - cursor.par()->Previous(); + cursor.par()->previous(); #endif if (prev && (prev->GetDepth() - cursor.par()->GetDepth() > 0 @@ -744,7 +744,7 @@ void LyXText::IncDepth(BufferView * bview) } if (cursor.par() == sel_end_cursor.par()) break; - cursor.par(cursor.par()->Next()); + cursor.par(cursor.par()->next()); } // if nothing changed set all depth to 0 @@ -756,7 +756,7 @@ void LyXText::IncDepth(BufferView * bview) #else cursor.par()->params.depth(0); #endif - cursor.par(cursor.par()->Next()); + cursor.par(cursor.par()->next()); } #ifndef NEW_INSETS if (cursor.par()->footnoteflag == sel_start_cursor.par()->footnoteflag) @@ -792,32 +792,32 @@ void LyXText::DecDepth(BufferView * bview) sel_end_cursor = cursor; } #ifndef NEW_INSETS - LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next(); + LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->next(); #else - LyXParagraph * endpar = sel_end_cursor.par()->Next(); + LyXParagraph * endpar = sel_end_cursor.par()->next(); #endif LyXParagraph * undoendpar = endpar; if (endpar && endpar->GetDepth()) { while (endpar && endpar->GetDepth()) { #ifndef NEW_INSETS - endpar = endpar->LastPhysicalPar()->Next(); + endpar = endpar->LastPhysicalPar()->next(); #else - endpar = endpar->Next(); + endpar = endpar->next(); #endif undoendpar = endpar; } } else if (endpar) { - endpar = endpar->Next(); // because of parindents etc. + endpar = endpar->next(); // because of parindents etc. } SetUndo(bview->buffer(), Undo::EDIT, #ifndef NEW_INSETS sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous, + .par()->ParFromPos(sel_start_cursor.pos())->previous_, #else - sel_start_cursor.par()->previous, + sel_start_cursor.par()->previous(), #endif undoendpar); @@ -840,7 +840,7 @@ void LyXText::DecDepth(BufferView * bview) #endif if (cursor.par() == sel_end_cursor.par()) break; - cursor.par(cursor.par()->Next()); + cursor.par(cursor.par()->next()); } RedoParagraphs(bview, sel_start_cursor, endpar); @@ -890,11 +890,11 @@ void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall) SetUndo(bview->buffer(), Undo::EDIT, #ifndef NEW_INSETS - sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())->previous, - sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())->next + sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos())->previous_, + sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())->next_ #else - sel_start_cursor.par()->previous, - sel_end_cursor.par()->next + sel_start_cursor.par()->previous(), + sel_end_cursor.par()->next() #endif ); cursor = sel_start_cursor; @@ -923,11 +923,11 @@ void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall) cursor.pos(cursor.pos() + 1); } else { cursor.pos(0); - cursor.par(cursor.par()->Next()); + cursor.par(cursor.par()->next()); } } - RedoParagraphs(bview, sel_start_cursor, sel_end_cursor.par()->Next()); + RedoParagraphs(bview, sel_start_cursor, sel_end_cursor.par()->next()); // we have to reset the selection, because the // geometry could have changed @@ -1075,7 +1075,7 @@ void LyXText::RedoParagraphs(BufferView * bview, LyXCursor const & cur, tmprow = firstrow; while (tmprow->next() && tmprow->next()->par() == tmppar) tmprow = tmprow->next(); - tmppar = tmppar->Next(); + tmppar = tmppar->next(); } } while (tmppar != endpar); @@ -1195,10 +1195,10 @@ string const LyXText::selectionAsString(Buffer const * buffer) const // The paragraphs in between (if any) LyXCursor tmpcur(sel_start_cursor); - tmpcur.par(tmpcur.par()->Next()); + tmpcur.par(tmpcur.par()->next()); while (tmpcur.par() != sel_end_cursor.par()) { result += tmpcur.par()->String(buffer, 0, tmpcur.par()->Last()) + "\n\n"; - tmpcur.par(tmpcur.par()->Next()); // Or NextAfterFootnote?? + tmpcur.par(tmpcur.par()->next()); // Or NextAfterFootnote?? } // Last paragraph in selection @@ -1238,16 +1238,16 @@ void LyXText::CursorEnd(BufferView * bview) const void LyXText::CursorTop(BufferView * bview) const { - while (cursor.par()->Previous()) - cursor.par(cursor.par()->Previous()); + while (cursor.par()->previous()) + cursor.par(cursor.par()->previous()); SetCursor(bview, cursor.par(), 0); } void LyXText::CursorBottom(BufferView * bview) const { - while (cursor.par()->Next()) - cursor.par(cursor.par()->Next()); + while (cursor.par()->next()) + cursor.par(cursor.par()->next()); SetCursor(bview, cursor.par(), cursor.par()->Last()); } @@ -1333,12 +1333,12 @@ void LyXText::MeltFootnoteEnvironment(BufferView * bview) return; SetUndo(bview->buffer(), Undo::FINISH, - cursor.par()->PreviousBeforeFootnote()->previous, - cursor.par()->NextAfterFootnote()->next); + cursor.par()->PreviousBeforeFootnote()->previous_, + cursor.par()->NextAfterFootnote()->next_); /* ok, move to the beginning of the footnote. */ while (cursor.par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) - cursor.par(cursor.par()->Previous()); + cursor.par(cursor.par()->previous()); SetCursor(bview, cursor.par(), cursor.par()->Last()); /* this is just faster than using CursorLeft(); */ @@ -1347,11 +1347,11 @@ void LyXText::MeltFootnoteEnvironment(BufferView * bview) tmppar = firsttmppar; /* tmppar is now the paragraph right before the footnote */ - bool first_footnote_par_is_not_empty = tmppar->next->size(); + bool first_footnote_par_is_not_empty = tmppar->next_->size(); - while (tmppar->next - && tmppar->next->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) { - tmppar = tmppar->next; /* I use next instead of Next(), + while (tmppar->next_ + && tmppar->next_->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) { + tmppar = tmppar->next_; /* I use next instead of Next(), * because there cannot be any * footnotes in a footnote * environment */ @@ -1368,33 +1368,33 @@ void LyXText::MeltFootnoteEnvironment(BufferView * bview) // now we will paste the ex-footnote, if the layouts allow it // first restore the layout of the paragraph right behind // the footnote - if (tmppar->next) - tmppar->next->MakeSameLayout(cursor.par()); + if (tmppar->next_) + tmppar->next_->MakeSameLayout(cursor.par()); // first the end if (!tmppar->GetLayout() - || (tmppar->Next() - && (!tmppar->Next()->Last() - || tmppar->Next()->HasSameLayout(tmppar)))) { - if (tmppar->Next()->Last() - && tmppar->Next()->IsLineSeparator(0)) - tmppar->Next()->Erase(0); + || (tmppar->next() + && (!tmppar->next()->Last() + || tmppar->next()->HasSameLayout(tmppar)))) { + if (tmppar->next()->Last() + && tmppar->next()->IsLineSeparator(0)) + tmppar->next()->Erase(0); tmppar->PasteParagraph(bview->buffer()->params); } - tmppar = tmppar->Next(); /* make sure tmppar cannot be touched + tmppar = tmppar->next(); /* make sure tmppar cannot be touched * by the pasting of the beginning */ /* then the beginning */ /* if there is no space between the text and the footnote, so we insert * a blank * (only if the previous par and the footnotepar are not empty!) */ - if (!firsttmppar->next->GetLayout() - || firsttmppar->HasSameLayout(firsttmppar->next)) { + if (!firsttmppar->next_->GetLayout() + || firsttmppar->HasSameLayout(firsttmppar->next_)) { if (firsttmppar->size() && !firsttmppar->IsSeparator(firsttmppar->size() - 1) && first_footnote_par_is_not_empty) { - firsttmppar->next->InsertChar(0, ' '); + firsttmppar->next_->InsertChar(0, ' '); } firsttmppar->PasteParagraph(bview->buffer()->params); } @@ -1439,42 +1439,42 @@ void LyXText::SetParagraph(BufferView * bview, // make sure that the depth behind the selection are restored, too #ifndef NEW_INSETS - LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next(); + LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->next(); #else - LyXParagraph * endpar = sel_end_cursor.par()->Next(); + LyXParagraph * endpar = sel_end_cursor.par()->next(); #endif LyXParagraph * undoendpar = endpar; if (endpar && endpar->GetDepth()) { while (endpar && endpar->GetDepth()) { #ifndef NEW_INSETS - endpar = endpar->LastPhysicalPar()->Next(); + endpar = endpar->LastPhysicalPar()->next(); #else - endpar = endpar->Next(); + endpar = endpar->next(); #endif undoendpar = endpar; } } else if (endpar) { - endpar = endpar->Next(); // because of parindents etc. + endpar = endpar->next(); // because of parindents etc. } SetUndo(bview->buffer(), Undo::EDIT, #ifndef NEW_INSETS sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous, + .par()->ParFromPos(sel_start_cursor.pos())->previous_, #else - sel_start_cursor.par()->previous, + sel_start_cursor.par()->previous(), #endif undoendpar); LyXParagraph * tmppar = sel_end_cursor.par(); #ifndef NEW_INSETS - while (tmppar != sel_start_cursor.par()->FirstPhysicalPar()->Previous()) { + while (tmppar != sel_start_cursor.par()->FirstPhysicalPar()->previous()) { SetCursor(bview, tmppar->FirstPhysicalPar(), 0); #else - while (tmppar != sel_start_cursor.par()->Previous()) { + while (tmppar != sel_start_cursor.par()->previous()) { SetCursor(bview, tmppar, 0); #endif status = LyXText::NEED_MORE_REFRESH; @@ -1510,9 +1510,9 @@ void LyXText::SetParagraph(BufferView * bview, #ifndef NEW_INSETS } - tmppar = cursor.par()->FirstPhysicalPar()->Previous(); + tmppar = cursor.par()->FirstPhysicalPar()->previous(); #else - tmppar = cursor.par()->Previous(); + tmppar = cursor.par()->previous(); #endif } @@ -1544,41 +1544,41 @@ void LyXText::SetParagraphExtraOpt(BufferView * bview, int type, // make sure that the depth behind the selection are restored, too #ifndef NEW_INSETS - LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next(); + LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->next(); #else - LyXParagraph * endpar = sel_end_cursor.par()->Next(); + LyXParagraph * endpar = sel_end_cursor.par()->next(); #endif LyXParagraph * undoendpar = endpar; if (endpar && endpar->GetDepth()) { while (endpar && endpar->GetDepth()) { #ifndef NEW_INSETS - endpar = endpar->LastPhysicalPar()->Next(); + endpar = endpar->LastPhysicalPar()->next(); #else - endpar = endpar->Next(); + endpar = endpar->next(); #endif undoendpar = endpar; } } else if (endpar) { - endpar = endpar->Next(); // because of parindents etc. + endpar = endpar->next(); // because of parindents etc. } SetUndo(bview->buffer(), Undo::EDIT, #ifndef NEW_INSETS sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous, + .par()->ParFromPos(sel_start_cursor.pos())->previous_, #else - sel_start_cursor.par()->previous, + sel_start_cursor.par()->previous(), #endif undoendpar); tmppar = sel_end_cursor.par(); #ifndef NEW_INSETS - while(tmppar != sel_start_cursor.par()->FirstPhysicalPar()->Previous()) { + while(tmppar != sel_start_cursor.par()->FirstPhysicalPar()->previous()) { SetCursor(bview, tmppar->FirstPhysicalPar(), 0); #else - while(tmppar != sel_start_cursor.par()->Previous()) { + while(tmppar != sel_start_cursor.par()->previous()) { SetCursor(bview, tmppar, 0); #endif status = LyXText::NEED_MORE_REFRESH; @@ -1602,9 +1602,9 @@ void LyXText::SetParagraphExtraOpt(BufferView * bview, int type, } #ifndef NEW_INSETS } - tmppar = cursor.par()->FirstPhysicalPar()->Previous(); + tmppar = cursor.par()->FirstPhysicalPar()->previous(); #else - tmppar = cursor.par()->Previous(); + tmppar = cursor.par()->previous(); #endif } RedoParagraphs(bview, sel_start_cursor, endpar); @@ -1683,23 +1683,23 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const /* copy the prev-counters to this one, unless this is the start of a footnote or of a bibliography or the very first paragraph */ - if (par->Previous() + if (par->previous() #ifndef NEW_INSETS - && !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE + && !(par->previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE && par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE && par->footnotekind == LyXParagraph::FOOTNOTE) #endif && !(textclasslist.Style(buf->params.textclass, - par->Previous()->GetLayout() + par->previous()->GetLayout() ).labeltype != LABEL_BIBLIO && layout.labeltype == LABEL_BIBLIO)) { for (int i = 0; i < 10; ++i) { - par->setCounter(i, par->Previous()->GetFirstCounter(i)); + par->setCounter(i, par->previous()->GetFirstCounter(i)); } #ifndef NEW_INSETS - par->params.appendix(par->Previous()->FirstPhysicalPar()->params.appendix()); + par->params.appendix(par->previous()->FirstPhysicalPar()->params.appendix()); #else - par->params.appendix(par->Previous()->params.appendix()); + par->params.appendix(par->previous()->params.appendix()); #endif if (!par->params.appendix() && par->params.startOfAppendix()) { par->params.appendix(true); @@ -1708,11 +1708,11 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const } } #ifndef NEW_INSETS - par->enumdepth = par->Previous()->FirstPhysicalPar()->enumdepth; - par->itemdepth = par->Previous()->FirstPhysicalPar()->itemdepth; + par->enumdepth = par->previous()->FirstPhysicalPar()->enumdepth; + par->itemdepth = par->previous()->FirstPhysicalPar()->itemdepth; #else - par->enumdepth = par->Previous()->enumdepth; - par->itemdepth = par->Previous()->itemdepth; + par->enumdepth = par->previous()->enumdepth; + par->itemdepth = par->previous()->itemdepth; #endif } else { for (int i = 0; i < 10; ++i) { @@ -1730,8 +1730,8 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const // LaTeX behaviour (ARRae) if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE && par->footnotekind == LyXParagraph::MARGIN - && par->Previous() - && par->Previous()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE + && par->previous() + && par->previous()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE && (par->PreviousBeforeFootnote() && textclasslist.Style(buf->params.textclass, par->PreviousBeforeFootnote()->GetLayout() @@ -1753,14 +1753,14 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const * AND, bibliographies can't have their depth changed ie. they * are always of depth 0 */ - if (par->Previous() - && par->Previous()->GetDepth() < par->GetDepth() + if (par->previous() + && par->previous()->GetDepth() < par->GetDepth() && textclasslist.Style(buf->params.textclass, - par->Previous()->GetLayout() + par->previous()->GetLayout() ).labeltype == LABEL_COUNTER_ENUMI && par->enumdepth < 3 #ifndef NEW_INSETS - && !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE + && !(par->previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE && par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE && par->footnotekind == LyXParagraph::FOOTNOTE) #endif @@ -1769,10 +1769,10 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const } /* Maybe we have to decrement the enumeration depth, see note above */ - if (par->Previous() - && par->Previous()->GetDepth() > par->GetDepth() + if (par->previous() + && par->previous()->GetDepth() > par->GetDepth() #ifndef NEW_INSETS - && !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE + && !(par->previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE && par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE && par->footnotekind == LyXParagraph::FOOTNOTE) #endif @@ -2067,24 +2067,24 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const void LyXText::UpdateCounters(BufferView * bview, Row * row) const { LyXParagraph * par; +#ifndef NEW_INSETS if (!row) { row = firstrow; par = row->par(); + } else if (row->par()->next_ + && row->par()->next_->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) { + par = row->par()->LastPhysicalPar()->next(); } else { - if (row->par()->next -#ifndef NEW_INSETS - && row->par()->next->footnoteflag != LyXParagraph::OPEN_FOOTNOTE -#endif - ) { -#ifndef NEW_INSETS - par = row->par()->LastPhysicalPar()->Next(); + par = row->par()->next_; + } #else - par = row->par()->Next(); -#endif - } else { - par = row->par()->next; - } + if (!row) { + row = firstrow; + par = row->par(); + } else { + par = row->par()->next(); } +#endif while (par) { while (row->par() != par) @@ -2110,10 +2110,10 @@ void LyXText::UpdateCounters(BufferView * bview, Row * row) const #ifndef NEW_INSETS /* think about the damned open footnotes! */ - while (par->Next() && - (par->Next()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE - || par->Next()->IsDummy())){ - par = par->Next(); + while (par->next() && + (par->next()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE + || par->next()->IsDummy())){ + par = par->next(); if (par->IsDummy()) { while (row->par() != par) row = row->next(); @@ -2124,9 +2124,9 @@ void LyXText::UpdateCounters(BufferView * bview, Row * row) const #endif } #ifndef NEW_INSETS - par = par->LastPhysicalPar()->Next(); + par = par->LastPhysicalPar()->next(); #else - par = par->Next(); + par = par->next(); #endif } @@ -2140,11 +2140,11 @@ void LyXText::InsertInset(BufferView * bview, Inset * inset) return; SetUndo(bview->buffer(), Undo::INSERT, #ifndef NEW_INSETS - cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next + cursor.par()->ParFromPos(cursor.pos())->previous_, + cursor.par()->ParFromPos(cursor.pos())->next_ #else - cursor.par()->previous, - cursor.par()->next + cursor.par()->previous(), + cursor.par()->next() #endif ); cursor.par()->InsertInset(cursor.pos(), inset); @@ -2206,38 +2206,38 @@ void LyXText::CutSelection(BufferView * bview, bool doclear) _("sorry.")); return; } - tmppar = tmppar->Next(); + tmppar = tmppar->next(); } } #endif // make sure that the depth behind the selection are restored, too #ifndef NEW_INSETS - LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next(); + LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->next(); #else - LyXParagraph * endpar = sel_end_cursor.par()->Next(); + LyXParagraph * endpar = sel_end_cursor.par()->next(); #endif LyXParagraph * undoendpar = endpar; if (endpar && endpar->GetDepth()) { while (endpar && endpar->GetDepth()) { #ifndef NEW_INSETS - endpar = endpar->LastPhysicalPar()->Next(); + endpar = endpar->LastPhysicalPar()->next(); #else - endpar = endpar->Next(); + endpar = endpar->next(); #endif undoendpar = endpar; } } else if (endpar) { - endpar = endpar->Next(); // because of parindents etc. + endpar = endpar->next(); // because of parindents etc. } SetUndo(bview->buffer(), Undo::DELETE, #ifndef NEW_INSETS sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous, + .par()->ParFromPos(sel_start_cursor.pos())->previous_, #else - sel_start_cursor.par()->previous, + sel_start_cursor.par()->previous(), #endif undoendpar); @@ -2271,7 +2271,7 @@ void LyXText::CutSelection(BufferView * bview, bool doclear) sel_end_cursor.pos(pos); cursor.pos(sel_end_cursor.pos()); } - endpar = endpar->Next(); + endpar = endpar->next(); // sometimes necessary if (doclear) @@ -2320,7 +2320,7 @@ void LyXText::CopySelection(BufferView * bview) _("sorry.")); return; } - tmppar = tmppar->Next(); + tmppar = tmppar->next(); } } #endif @@ -2350,11 +2350,11 @@ void LyXText::PasteSelection(BufferView * bview) SetUndo(bview->buffer(), Undo::INSERT, #ifndef NEW_INSETS - cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next + cursor.par()->ParFromPos(cursor.pos())->previous_, + cursor.par()->ParFromPos(cursor.pos())->next_ #else - cursor.par()->previous, - cursor.par()->next + cursor.par()->previous(), + cursor.par()->next() #endif ); @@ -2430,7 +2430,7 @@ void LyXText::InsertStringA(BufferView * bview, string const & str) LyXParagraph * par = cursor.par(); LyXParagraph::size_type pos = cursor.pos(); LyXParagraph::size_type a = 0; - LyXParagraph * endpar = cursor.par()->Next(); + LyXParagraph * endpar = cursor.par()->next(); SetCursorParUndo(bview->buffer()); @@ -2491,7 +2491,7 @@ void LyXText::InsertStringA(BufferView * bview, string const & str) ++pos; } par->BreakParagraph(bview->buffer()->params, pos, flag); - par = par->Next(); + par = par->next(); pos = 0; } ++i; @@ -2550,7 +2550,7 @@ bool LyXText::GotoNextInset(BufferView * bview, if (res.pos() < res.par()->Last() - 1) { res.pos(res.pos() + 1); } else { - res.par(res.par()->Next()); + res.par(res.par()->next()); res.pos(0); } @@ -2678,7 +2678,7 @@ bool LyXText::UpdateInset(BufferView * bview, Inset * inset) #ifndef NEW_INSETS } #endif - par = par->Next(); + par = par->next(); } while (par); return false; @@ -2705,22 +2705,22 @@ void LyXText::SetCursor(BufferView *bview, LyXCursor & cur, LyXParagraph * par, pos = par->PositionInParFromPos(pos); par = tmppar; } - if (par->IsDummy() && par->previous && - par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { - while (par->previous && - ((par->previous->IsDummy() && - (par->previous->previous->footnoteflag == + if (par->IsDummy() && par->previous_ && + par->previous_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { + while (par->previous_ && + ((par->previous_->IsDummy() && + (par->previous_->previous_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)) || - (par->previous->footnoteflag == + (par->previous_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE))) { - par = par->previous ; + par = par->previous_; if (par->IsDummy() && - (par->previous->footnoteflag == + (par->previous_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)) pos += par->size() + 1; } - if (par->previous) { - par = par->previous; + if (par->previous_) { + par = par->previous_; } pos += par->size() + 1; } @@ -2898,8 +2898,8 @@ void LyXText::CursorLeft(BufferView * bview, bool internal) const if (!internal && !boundary && IsBoundary(bview->buffer(), cursor.par(), cursor.pos() + 1)) SetCursor(bview, cursor.par(), cursor.pos() + 1, true, true); - } else if (cursor.par()->Previous()) { // steps into the above paragraph. - LyXParagraph * par = cursor.par()->Previous(); + } else if (cursor.par()->previous()) { // steps into the above paragraph. + LyXParagraph * par = cursor.par()->previous(); SetCursor(bview, par, par->Last()); } } @@ -2915,8 +2915,8 @@ void LyXText::CursorRight(BufferView * bview, bool internal) const if (!internal && IsBoundary(bview->buffer(), cursor.par(), cursor.pos())) SetCursor(bview, cursor.par(), cursor.pos(), true, true); - } else if (cursor.par()->Next()) - SetCursor(bview, cursor.par()->Next(), 0); + } else if (cursor.par()->next()) + SetCursor(bview, cursor.par()->next(), 0); } @@ -2940,16 +2940,16 @@ void LyXText::CursorUpParagraph(BufferView * bview) const if (cursor.pos() > 0) { SetCursor(bview, cursor.par(), 0); } - else if (cursor.par()->Previous()) { - SetCursor(bview, cursor.par()->Previous(), 0); + else if (cursor.par()->previous()) { + SetCursor(bview, cursor.par()->previous(), 0); } } void LyXText::CursorDownParagraph(BufferView * bview) const { - if (cursor.par()->Next()) { - SetCursor(bview, cursor.par()->Next(), 0); + if (cursor.par()->next()) { + SetCursor(bview, cursor.par()->next(), 0); } else { SetCursor(bview, cursor.par(), cursor.par()->Last()); } @@ -3001,7 +3001,7 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, && old_cursor.par()->IsLineSeparator(old_cursor.pos()) && old_cursor.par()->IsLineSeparator(old_cursor.pos() - 1)) { old_cursor.par()->Erase(old_cursor.pos() - 1); - RedoParagraphs(bview, old_cursor, old_cursor.par()->Next()); + RedoParagraphs(bview, old_cursor, old_cursor.par()->next()); // correct cursor if (old_cursor.par() == cursor.par() && cursor.pos() > old_cursor.pos()) { @@ -3055,26 +3055,41 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, refresh_y = old_cursor.y() - old_cursor.row()->baseline() - refresh_row->height(); tmpcursor = cursor; cursor = old_cursor; // that undo can restore the right cursor position - LyXParagraph * endpar = old_cursor.par()->next; +#ifndef NEW_INSETS + LyXParagraph * endpar = old_cursor.par()->next_; if (endpar && endpar->GetDepth()) { while (endpar && endpar->GetDepth()) { -#ifndef NEW_INSETS - endpar = endpar->LastPhysicalPar()->Next(); + endpar = endpar->LastPhysicalPar()->next(); + } + } + SetUndo(bview->buffer(), Undo::DELETE, + old_cursor.par()->previous_, + endpar); + cursor = tmpcursor; + + // delete old row + RemoveRow(old_cursor.row()); + if (OwnerParagraph() == old_cursor.par()) { + OwnerParagraph(OwnerParagraph()->next_); + } #else - endpar = endpar->Next(); -#endif + LyXParagraph * endpar = old_cursor.par()->next(); + if (endpar && endpar->GetDepth()) { + while (endpar && endpar->GetDepth()) { + endpar = endpar->next(); } } SetUndo(bview->buffer(), Undo::DELETE, - old_cursor.par()->previous, + old_cursor.par()->previous(), endpar); cursor = tmpcursor; // delete old row RemoveRow(old_cursor.row()); if (OwnerParagraph() == old_cursor.par()) { - OwnerParagraph(OwnerParagraph()->next); + OwnerParagraph(OwnerParagraph()->next()); } +#endif // delete old par delete old_cursor.par(); @@ -3094,18 +3109,33 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, tmpcursor = cursor; cursor = old_cursor; // that undo can restore the right cursor position - LyXParagraph * endpar = old_cursor.par()->next; +#ifndef NEW_INSETS + LyXParagraph * endpar = old_cursor.par()->next_; if (endpar && endpar->GetDepth()) { while (endpar && endpar->GetDepth()) { -#ifndef NEW_INSETS - endpar = endpar->LastPhysicalPar()->Next(); + endpar = endpar->LastPhysicalPar()->next(); + } + } + SetUndo(bview->buffer(), Undo::DELETE, + old_cursor.par()->previous_, + endpar); + cursor = tmpcursor; + + // delete old row + RemoveRow(old_cursor.row()); + // delete old par + if (OwnerParagraph() == old_cursor.par()) { + OwnerParagraph(OwnerParagraph()->next_); + } #else - endpar = endpar->Next(); -#endif + LyXParagraph * endpar = old_cursor.par()->next(); + if (endpar && endpar->GetDepth()) { + while (endpar && endpar->GetDepth()) { + endpar = endpar->next(); } } SetUndo(bview->buffer(), Undo::DELETE, - old_cursor.par()->previous, + old_cursor.par()->previous(), endpar); cursor = tmpcursor; @@ -3113,8 +3143,9 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, RemoveRow(old_cursor.row()); // delete old par if (OwnerParagraph() == old_cursor.par()) { - OwnerParagraph(OwnerParagraph()->next); + OwnerParagraph(OwnerParagraph()->next()); } +#endif delete old_cursor.par(); /* Breakagain the next par. Needed @@ -3144,7 +3175,7 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, } if (!deleted) { if (old_cursor.par()->StripLeadingSpaces(bview->buffer()->params.textclass)) { - RedoParagraphs(bview, old_cursor, old_cursor.par()->Next()); + RedoParagraphs(bview, old_cursor, old_cursor.par()->next()); // correct cursor y SetCursorIntern(bview, cursor.par(), cursor.pos()); sel_cursor = cursor; @@ -3154,13 +3185,23 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, } +#ifndef NEW_INSETS LyXParagraph * LyXText::GetParFromID(int id) { LyXParagraph * result = FirstParagraph(); while (result && result->id() != id) - result = result->next; + result = result->next_; return result; } +#else +LyXParagraph * LyXText::GetParFromID(int id) +{ + LyXParagraph * result = FirstParagraph(); + while (result && result->id() != id) + result = result->next(); + return result; +} +#endif // undo functions @@ -3226,46 +3267,74 @@ bool LyXText::TextHandleUndo(BufferView * bview, Undo * undo) LyXParagraph * tmppar3 = undo->par; undo->par = 0; // otherwise the undo destructor would delete the paragraph LyXParagraph * tmppar4 = tmppar3; - if (tmppar4){ - while (tmppar4->next) - tmppar4 = tmppar4->next; +#ifndef NEW_INSETS + if (tmppar4) { + while (tmppar4->next_) + tmppar4 = tmppar4->next_; + } // get last undo par + + // now remove the old text if there is any + if (before != behind || (!behind && !before)) { + if (before) + tmppar5 = before->next(); + else + tmppar5 = OwnerParagraph(); + tmppar2 = tmppar3; + while (tmppar5 && tmppar5 != behind) { + tmppar = tmppar5; + tmppar5 = tmppar5->next(); + // a memory optimization for edit: Only layout information + // is stored in the undo. So restore the text informations. + if (undo->kind == Undo::EDIT) { + tmppar2->setContentsFromPar(tmppar); + tmppar->clearContents(); + tmppar2 = tmppar2->next(); + } + } + } + +#else + if (tmppar4) { + while (tmppar4->next()) + tmppar4 = tmppar4->next(); } // get last undo par // now remove the old text if there is any - if (before != behind || (!behind && !before)){ + if (before != behind || (!behind && !before)) { if (before) - tmppar5 = before->next; + tmppar5 = before->next(); else tmppar5 = OwnerParagraph(); tmppar2 = tmppar3; - while (tmppar5 && tmppar5 != behind){ + while (tmppar5 && tmppar5 != behind) { tmppar = tmppar5; - tmppar5 = tmppar5->next; + tmppar5 = tmppar5->next(); // a memory optimization for edit: Only layout information // is stored in the undo. So restore the text informations. if (undo->kind == Undo::EDIT) { tmppar2->setContentsFromPar(tmppar); tmppar->clearContents(); - tmppar2 = tmppar2->next; + tmppar2 = tmppar2->next(); } } } +#endif // put the new stuff in the list if there is one if (tmppar3){ if (before) - before->next = tmppar3; + before->next(tmppar3); else OwnerParagraph(tmppar3); - tmppar3->previous = before; + tmppar3->previous(before); } else { if (!before) OwnerParagraph(behind); } if (tmppar4) { - tmppar4->next = behind; + tmppar4->next(behind); if (behind) - behind->previous = tmppar4; + behind->previous(tmppar4); } @@ -3279,14 +3348,14 @@ bool LyXText::TextHandleUndo(BufferView * bview, Undo * undo) #ifndef NEW_INSETS // check wether before points to a closed float and open it if necessary if (before && before->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE - && before->next && before->next->footnoteflag != LyXParagraph::NO_FOOTNOTE){ + && before->next_ && before->next_->footnoteflag != LyXParagraph::NO_FOOTNOTE){ tmppar4 = before; - while (tmppar4->previous && - tmppar4->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) - tmppar4 = tmppar4->previous; + while (tmppar4->previous_ && + tmppar4->previous_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) + tmppar4 = tmppar4->previous_; while (tmppar4 && tmppar4->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE){ tmppar4->footnoteflag = LyXParagraph::OPEN_FOOTNOTE; - tmppar4 = tmppar4->next; + tmppar4 = tmppar4->next_; } } #endif @@ -3294,12 +3363,12 @@ bool LyXText::TextHandleUndo(BufferView * bview, Undo * undo) #ifndef NEW_INSETS // open a cosed footnote at the end if necessary - if (behind && behind->previous && - behind->previous->footnoteflag != LyXParagraph::NO_FOOTNOTE && + if (behind && behind->previous_ && + behind->previous_->footnoteflag != LyXParagraph::NO_FOOTNOTE && behind->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE){ while (behind && behind->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE){ behind->footnoteflag = LyXParagraph::OPEN_FOOTNOTE; - behind = behind->next; + behind = behind->next_; } } #endif @@ -3308,11 +3377,11 @@ bool LyXText::TextHandleUndo(BufferView * bview, Undo * undo) if (behind) { #ifndef NEW_INSETS if (behind->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) - endpar = behind->LastPhysicalPar()->Next(); + endpar = behind->LastPhysicalPar()->next(); else - endpar = behind->NextAfterFootnote()->LastPhysicalPar()->Next(); + endpar = behind->NextAfterFootnote()->LastPhysicalPar()->next(); #else - endpar = behind->Next(); + endpar = behind->next(); #endif } else endpar = behind; @@ -3416,22 +3485,21 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind, LyXParagraph * start = 0; LyXParagraph * end = 0; - + +#ifndef NEW_INSETS if (before) - start = before->next; + start = before->next_; else start = FirstParagraph(); if (behind) - end = behind->previous; + end = behind->previous_; else { end = FirstParagraph(); - while (end->next) - end = end->next; + while (end->next_) + end = end->next_; } - - if (start && end && (start != end->next) && - ((before != behind) || (!before && !behind))) - { + if (start && end && (start != end->next_) && + ((before != behind) || (!before && !behind))) { tmppar = start; tmppar2 = tmppar->Clone(); tmppar2->id(tmppar->id()); @@ -3445,31 +3513,73 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind, undopar = tmppar2; - while (tmppar != end && tmppar->next) { - tmppar = tmppar->next; - tmppar2->next = tmppar->Clone(); - tmppar2->next->id(tmppar->id()); + while (tmppar != end && tmppar->next_) { + tmppar = tmppar->next_; + tmppar2->next(tmppar->Clone()); + tmppar2->next_->id(tmppar->id()); // a memory optimization: Just store the layout // information when only edit if (kind == Undo::EDIT){ //tmppar2->next->text.clear(); tmppar2->clearContents(); } - tmppar2->next->previous = tmppar2; - tmppar2 = tmppar2->next; + tmppar2->next_->previous(tmppar2); + tmppar2 = tmppar2->next_; } - tmppar2->next = 0; + tmppar2->next(0); } else undopar = 0; // nothing to replace (undo of delete maybe) -#ifndef NEW_INSETS int cursor_par = cursor.par()->ParFromPos(cursor.pos())->id(); int cursor_pos = cursor.par()->PositionInParFromPos(cursor.pos()); #else + if (before) + start = const_cast(before->next()); + else + start = FirstParagraph(); + if (behind) + end = const_cast(behind->previous()); + else { + end = FirstParagraph(); + while (end->next()) + end = end->next(); + } + if (start && end && (start != end->next()) && + ((before != behind) || (!before && !behind))) { + tmppar = start; + tmppar2 = tmppar->Clone(); + tmppar2->id(tmppar->id()); + + // a memory optimization: Just store the layout information + // when only edit + if (kind == Undo::EDIT){ + //tmppar2->text.clear(); + tmppar2->clearContents(); + } + + undopar = tmppar2; + + while (tmppar != end && tmppar->next()) { + tmppar = tmppar->next(); + tmppar2->next(tmppar->Clone()); + tmppar2->next()->id(tmppar->id()); + // a memory optimization: Just store the layout + // information when only edit + if (kind == Undo::EDIT){ + //tmppar2->next->text.clear(); + tmppar2->clearContents(); + } + tmppar2->next()->previous(tmppar2); + tmppar2 = tmppar2->next(); + } + tmppar2->next(0); + } else + undopar = 0; // nothing to replace (undo of delete maybe) + int cursor_par = cursor.par()->id(); int cursor_pos = cursor.pos(); #endif - + Undo * undo = new Undo(kind, before_number, behind_number, cursor_par, cursor_pos, @@ -3486,11 +3596,11 @@ void LyXText::SetCursorParUndo(Buffer * buf) return; SetUndo(buf, Undo::FINISH, #ifndef NEW_INSETS - cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next + cursor.par()->ParFromPos(cursor.pos())->previous_, + cursor.par()->ParFromPos(cursor.pos())->next_ #else - cursor.par()->previous, - cursor.par()->next + cursor.par()->previous(), + cursor.par()->next() #endif ); } @@ -3507,8 +3617,13 @@ void LyXText::toggleAppendix(BufferView * bview) // ensure that we have only one start_of_appendix in this document LyXParagraph * tmp = FirstParagraph(); - for (; tmp; tmp = tmp->next) +#ifndef NEW_INSETS + for (; tmp; tmp = tmp->next_) tmp->params.startOfAppendix(false); +#else + for (; tmp; tmp = tmp->next()) + tmp->params.startOfAppendix(false); +#endif par->params.startOfAppendix(start); // we can set the refreshing parameters now diff --git a/src/undo.C b/src/undo.C index b177deb8d4..b35ab68a57 100644 --- a/src/undo.C +++ b/src/undo.C @@ -31,15 +31,27 @@ Undo::Undo(undo_kind kind_arg, } +#ifndef NEW_INSETS Undo::~Undo() { LyXParagraph * tmppar; while (par) { tmppar = par; - par = par->next; + par = par->next_; delete tmppar; } } +#else +Undo::~Undo() +{ + LyXParagraph * tmppar; + while (par) { + tmppar = par; + par = par->next(); + delete tmppar; + } +} +#endif UndoStack::UndoStack()