From 4c6091b63f6ac4dae69ddcee26bf22e4f35a3cdf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Thu, 3 May 2001 14:31:33 +0000 Subject: [PATCH] remove !NEW_INSETS cruft git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1980 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.h | 10 - src/BufferView2.C | 178 +---- src/BufferView_pimpl.C | 93 +-- src/ChangeLog | 40 + src/CutAndPaste.C | 297 +------- src/ToolbarDefaults.C | 10 +- src/buffer.C | 374 +--------- src/buffer.h | 25 +- src/bufferview_funcs.C | 43 -- src/bufferview_funcs.h | 12 - src/figureForm.C | 19 - src/frontends/xforms/ChangeLog | 4 + src/frontends/xforms/FormParagraph.C | 288 +------- src/frontends/xforms/FormParagraph.h | 18 +- src/insets/ChangeLog | 10 + src/insets/insetbib.C | 8 - src/insets/insetcollapsable.h | 5 - src/insets/insettabular.C | 24 +- src/insets/insettext.C | 191 +---- src/lyx_cb.C | 30 +- src/lyxfind.C | 16 - src/lyxfunc.C | 70 +- src/lyxlex_pimpl.C | 26 - src/lyxtext.h | 36 +- src/spellchecker.C | 6 - src/support/ChangeLog | 4 + src/support/textutils.h | 18 - src/tabular.C | 48 +- src/text.C | 927 +---------------------- src/text2.C | 1024 +------------------------- src/undo.C | 12 - 31 files changed, 166 insertions(+), 3700 deletions(-) diff --git a/src/BufferView.h b/src/BufferView.h index ef0a4c90ed..2d6f36e88a 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -170,18 +170,8 @@ public: void menuUndo(); /// void menuRedo(); -#ifndef NEW_INSETS - /// - void toggleFloat(); - /// - void openStuff(); -#endif /// void insertNote(); -#ifndef NEW_INSETS - /// - void allFloats(char flag, char figmar); -#endif /// removes all autodeletable insets bool removeAutoInsets(); /// diff --git a/src/BufferView2.C b/src/BufferView2.C index 2e32c7cc78..aabf472270 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -106,26 +106,7 @@ bool BufferView::removeAutoInsets() LyXCursor cursor; bool a = false; -#ifndef NEW_INSETS - while (par) { - // this has to be done before the delete - if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) - text->SetCursor(this, cursor, par, 0); - if (par->AutoDeleteInsets()){ - a = true; - if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){ - text->RedoParagraphs(this, cursor, - cursor.par()->next()); - text->FullRebreak(this); - } - } - par = par->next_; - } - // avoid forbidden cursor positions caused by error removing - if (tmpcursor.pos() > tmpcursor.par()->Last()) - tmpcursor.pos(tmpcursor.par()->Last()); -#else while (par) { // this has to be done before the delete text->SetCursor(this, cursor, par, 0); @@ -141,7 +122,7 @@ bool BufferView::removeAutoInsets() // avoid forbidden cursor positions caused by error removing if (tmpcursor.pos() > tmpcursor.par()->size()) tmpcursor.pos(tmpcursor.par()->size()); -#endif + text->SetCursorIntern(this, tmpcursor.par(), tmpcursor.pos()); return a; @@ -153,12 +134,6 @@ void BufferView::insertErrors(TeXErrors & terr) // Save the cursor position LyXCursor cursor = text->cursor; -#ifndef NEW_INSETS - // This is drastic, but it's the only fix, I could find. (Asger) - allFloats(1, 0); - allFloats(1, 1); -#endif - for (TeXErrors::Errors::const_iterator cit = terr.begin(); cit != terr.end(); ++cit) { @@ -237,11 +212,7 @@ bool BufferView::insertInset(Inset * inset, string const & lout, text->BreakParagraph(this); update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); -#ifndef NEW_INSETS - if (text->cursor.par()->Last()) { -#else if (text->cursor.par()->size()) { -#endif text->CursorLeft(this); text->BreakParagraph(this); @@ -322,96 +293,6 @@ bool BufferView::gotoLabel(string const & label) } -#ifndef NEW_INSETS -void BufferView::allFloats(char flag, char figmar) -{ - if (!available()) return; - - LyXCursor cursor = text->cursor; - - if (!flag - && cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE - && ((figmar - && cursor.par()->footnotekind != LyXParagraph::FOOTNOTE - && cursor.par()->footnotekind != LyXParagraph::MARGIN - ) - || (!figmar - && cursor.par()->footnotekind != LyXParagraph::FIG - && cursor.par()->footnotekind != LyXParagraph::TAB - && cursor.par()->footnotekind != LyXParagraph::WIDE_FIG - && cursor.par()->footnotekind != LyXParagraph::WIDE_TAB - && cursor.par()->footnotekind != LyXParagraph::ALGORITHM))) - toggleFloat(); - else - beforeChange(text); - - LyXCursor tmpcursor = cursor; - cursor.par(tmpcursor.par()->ParFromPos(tmpcursor.pos())); - cursor.pos(tmpcursor.par()->PositionInParFromPos(tmpcursor.pos())); - - LyXParagraph *par = buffer()->paragraph; - while (par) { - if (flag) { - if (par->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE - && ((figmar - && par->footnotekind != LyXParagraph::FOOTNOTE - && par->footnotekind != LyXParagraph::MARGIN) - || (!figmar - && par->footnotekind != LyXParagraph::FIG - && par->footnotekind != LyXParagraph::TAB - && par->footnotekind != LyXParagraph::WIDE_FIG - && par->footnotekind != LyXParagraph::WIDE_TAB - && par->footnotekind != LyXParagraph::ALGORITHM - ) - ) - ) { - if (par->previous_ - && par->previous_->footnoteflag != - LyXParagraph::CLOSED_FOOTNOTE){ /* should be */ - text->SetCursorIntern(this, - par->previous_, - 0); - text->OpenFootnote(this); - } - } - } else { - if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE - && ( - (figmar - && - par->footnotekind != LyXParagraph::FOOTNOTE - && - par->footnotekind != LyXParagraph::MARGIN - ) - || - (!figmar - && - par->footnotekind != LyXParagraph::FIG - && - par->footnotekind != LyXParagraph::TAB - && - par->footnotekind != LyXParagraph::WIDE_FIG - && - par->footnotekind != LyXParagraph::WIDE_TAB - && - par->footnotekind != LyXParagraph::ALGORITHM - ) - ) - ) { - text->SetCursorIntern(this, par, 0); - text->CloseFootnote(this); - } - } - par = par->next_; - } - - text->SetCursorIntern(this, cursor.par(), cursor.pos()); - redraw(); - fitCursor(text); -} -#endif - - void BufferView::insertNote() { InsetInfo * new_inset = new InsetInfo(); @@ -420,35 +301,6 @@ void BufferView::insertNote() } -#ifndef NEW_INSETS -void BufferView::openStuff() -{ - if (available()) { - owner()->message(_("Open/Close...")); - hideCursor(); - beforeChange(text); - update(text, BufferView::SELECT|BufferView::FITCUR); - text->OpenStuff(this); - update(text, BufferView::SELECT|BufferView::FITCUR); - setState(); - } -} - - -void BufferView::toggleFloat() -{ - if (available()) { - owner()->message(_("Open/Close...")); - hideCursor(); - beforeChange(text); - update(text, BufferView::SELECT|BufferView::FITCUR); - text->ToggleFootnote(this); - update(text, BufferView::SELECT|BufferView::FITCUR); - setState(); - } -} -#endif - void BufferView::menuUndo() { if (available()) { @@ -841,17 +693,9 @@ 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; -#ifndef NEW_INSETS - text->SetUndo(buffer(), kind, - text->cursor.par()-> - ParFromPos(text->cursor.pos())->previous_, - text->cursor.par()-> - ParFromPos(text->cursor.pos())->next_); -#else text->SetUndo(buffer(), kind, text->cursor.par()->previous(), text->cursor.par()->next()); -#endif } @@ -905,13 +749,8 @@ bool BufferView::ChangeInsets(Inset::Code code, LyXParagraph * par = buffer()->paragraph; LyXCursor cursor = text->cursor; LyXCursor tmpcursor = cursor; -#ifndef NEW_INSETS - cursor.par(tmpcursor.par()->ParFromPos(tmpcursor.pos())); - cursor.pos(tmpcursor.par()->PositionInParFromPos(tmpcursor.pos())); -#else cursor.par(tmpcursor.par()); cursor.pos(tmpcursor.pos()); -#endif while (par) { bool flag2 = false; @@ -925,20 +764,6 @@ bool BufferView::ChangeInsets(Inset::Code code, } } } -#ifndef NEW_INSETS - if (flag2) { - flag = true; - if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){ - // 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_; -#else if (flag2) { flag = true; // this is possible now, since SetCursor takes @@ -949,7 +774,6 @@ bool BufferView::ChangeInsets(Inset::Code code, text->FullRebreak(this); } par = par->next(); -#endif } text->SetCursorIntern(this, cursor.par(), cursor.pos()); return flag; diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index de14a84718..017cd95f06 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -807,73 +807,6 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, return; } -#ifndef NEW_INSETS - // check whether we want to open a float - if (bv_->text) { - bool hit = false; - char c = ' '; - if (bv_->text->cursor.pos() < - bv_->text->cursor.par()->Last()) { - c = bv_->text->cursor.par()-> - GetChar(bv_->text->cursor.pos()); - } - if(!bv_->text->selection) - if (c == LyXParagraph::META_FOOTNOTE - || c == LyXParagraph::META_MARGIN - || c == LyXParagraph::META_FIG - || c == LyXParagraph::META_TAB - || c == LyXParagraph::META_WIDE_FIG - || c == LyXParagraph::META_WIDE_TAB - || c == LyXParagraph::META_ALGORITHM){ - hit = true; - } else - if (bv_->text->cursor.pos() - 1 >= 0) { - c = bv_->text->cursor.par()-> - GetChar(bv_->text->cursor.pos() - 1); - if (c == LyXParagraph::META_FOOTNOTE - || c == LyXParagraph::META_MARGIN - || c == LyXParagraph::META_FIG - || c == LyXParagraph::META_TAB - || c == LyXParagraph::META_WIDE_FIG - || c == LyXParagraph::META_WIDE_TAB - || c == LyXParagraph::META_ALGORITHM){ - // We are one step too far to the right - bv_->text->CursorLeft(bv_); - hit = true; - } - } - if (hit == true) { - bv_->toggleFloat(); - selection_possible = false; - return; - } - } - // Do we want to close a float? (click on the float-label) - if (bv_->text->cursor.row()->par()->footnoteflag == - LyXParagraph::OPEN_FOOTNOTE - && bv_->text->cursor.row()->previous() && - bv_->text->cursor.row()->previous()->par()-> - footnoteflag != LyXParagraph::OPEN_FOOTNOTE){ - LyXFont font(LyXFont::ALL_SANE); - font.setSize(LyXFont::SIZE_FOOTNOTE); - - int box_x = 20; // LYX_PAPER_MARGIN; - box_x += lyxfont::width(" wide-tab ", font); - - unsigned int screen_first = bv_->text->first; - - if (x < box_x - && y + screen_first > bv_->text->cursor.y() - - bv_->text->cursor.row()->baseline() - && y + screen_first < bv_->text->cursor.y() - - bv_->text->cursor.row()->baseline() - + lyxfont::maxAscent(font) * 1.2 + lyxfont::maxDescent(font) * 1.2) { - bv_->toggleFloat(); - selection_possible = false; - return; - } - } -#else // check whether we want to open a float if (bv_->text) { bool hit = false; @@ -892,7 +825,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, return; } } -#endif + // Maybe we want to edit a bibitem ale970302 if (bv_->text->cursor.par()->bibkey && x < 20 + bibitemMaxWidth(bv_, textclasslist. @@ -923,11 +856,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, text->SetCursor(bv_, cursor, cursor.par(),cursor.pos(),true); -#ifndef NEW_INSETS - if (cursor.pos() < cursor.par()->Last() -#else if (cursor.pos() < cursor.par()->size() -#endif && cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET && cursor.par()->GetInset(cursor.pos()) && cursor.par()->GetInset(cursor.pos())->Editable()) { @@ -1219,7 +1148,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i) if (i >= saved_positions_num) return; - string fname = saved_positions[i].filename; + string const fname = saved_positions[i].filename; beforeChange(bv_->text); @@ -1234,13 +1163,9 @@ void BufferView::Pimpl::restorePosition(unsigned int i) if (!par) return; -#ifndef NEW_INSETS - bv_->text->SetCursor(bv_, par, - min(par->Last(), saved_positions[i].par_pos)); -#else bv_->text->SetCursor(bv_, par, min(par->size(), saved_positions[i].par_pos)); -#endif + update(bv_->text, BufferView::SELECT|BufferView::FITCUR); if (i > 0) { string const str = _("Moved to bookmark") + ' ' + tostr(i); @@ -1838,11 +1763,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) update(TEXT(bv_), BufferView::SELECT|BufferView::FITCUR); if (is_rtl) TEXT(bv_)->CursorLeft(bv_, false); -#ifndef NEW_INSETS - if (TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->Last() -#else if (TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->size() -#endif && TEXT(bv_)->cursor.par()->GetChar(TEXT(bv_)->cursor.pos()) == LyXParagraph::META_INSET && TEXT(bv_)->cursor.par()->GetInset(TEXT(bv_)->cursor.pos()) @@ -1880,11 +1801,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) if (!is_rtl) TEXT(bv_)->CursorLeft(bv_, false); if ((is_rtl || cur != TEXT(bv_)->cursor) && // only if really moved! -#ifndef NEW_INSETS - TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->Last() && -#else TEXT(bv_)->cursor.pos() < TEXT(bv_)->cursor.par()->size() && -#endif (TEXT(bv_)->cursor.par()->GetChar(TEXT(bv_)->cursor.pos()) == LyXParagraph::META_INSET) && TEXT(bv_)->cursor.par()->GetInset(TEXT(bv_)->cursor.pos()) && @@ -2255,11 +2172,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) LyXCursor cursor = TEXT(bv_)->cursor; if (!TEXT(bv_)->selection) { -#ifndef NEW_INSETS - if (cursor.pos() == cursor.par()->Last()) { -#else if (cursor.pos() == cursor.par()->size()) { -#endif TEXT(bv_)->CursorRight(bv_); cursor = TEXT(bv_)->cursor; if (cursor.pos() == 0 diff --git a/src/ChangeLog b/src/ChangeLog index c64dcbc0be..10f5295c6c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,43 @@ +2001-05-03 Lars Gullik Bjønnes + + * undo.C: remove !NEW_INSETS cruft + +2001-04-28 Lars Gullik Bjønnes + + * text2.C: remove !NEW_INSETS cruft + + * text.C: remove !NEW_INSETS cruft + + * tabular.C: remove !NEW_INSETS cruft + + * spellchecker.C: remove !NEW_INSETS cruft + + * lyxtext.h: remove !NEW_INSETS cruft + + * lyxlex_pimpl.C: remove !NEW_INSETS cruft + + * lyxfunc.C: remove !NEW_INSETS cruft + + * lyxfind.C: remove !NEW_INSETS cruft + + * lyx_cb.C: remove !NEW_INSETS cruft + + * figureForm.C: remove !NEW_INSETS cruft + + * bufferview_funcs.[Ch]: remove !NEW_INSETS cruft + + * buffer.[Ch]: remove !NEW_INSETS cruft + + * ToolbarDefaults.C: remove !NEW_INSETS cruft + + * CutAndPaste.C: remove !NEW_INSETS cruft + + * BufferView_pimpl.C: remove !NEW_INSETS cruft + + * BufferView2.C: remove !NEW_INSETS cruft + + * BufferView.h: remove !NEW_INSETS cruft + 2001-05-03 Jean-Marc Lasgouttes * Lsstream.h: include LString.h before the sstream headers to diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index ed331f7291..1ac379811b 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -63,11 +63,7 @@ void DeleteBuffer() while (buf) { tmppar = buf; -#ifndef NEW_INSETS - buf = buf->next_; -#else buf = buf->next(); -#endif delete tmppar; } buf = 0; @@ -76,76 +72,6 @@ void DeleteBuffer() } // namespace anon -#ifndef NEW_INSETS -bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, - int start, int & end, char tc, bool doclear) -{ - if (!startpar || (start > startpar->Last())) - return false; - - DeleteBuffer(); - - textclass = tc; - - if (!(*endpar) || - (startpar->ParFromPos(start) == - (*endpar)->ParFromPos(end))) { - // only within one paragraph - buf = new LyXParagraph; - LyXParagraph::size_type i = start; - if (end > startpar->Last()) - end = startpar->Last(); - for (; i < end; ++i) { - startpar->CopyIntoMinibuffer(*current_view->buffer(), start); - startpar->Erase(start); - - buf->InsertFromMinibuffer(buf->Last()); - } - end = start - 1; - } else { - // more than one paragraph - (*endpar)->BreakParagraphConservative(current_view->buffer()->params, - end); - *endpar = (*endpar)->next(); - end = 0; - - startpar->BreakParagraphConservative(current_view->buffer()->params, - start); - - // store the selection - buf = startpar->ParFromPos(start)->next_; - buf->previous(0); - (*endpar)->previous()->next(0); - - // cut the selection - startpar->ParFromPos(start)->next(*endpar); - - (*endpar)->previous(startpar->ParFromPos(start)); - - // care about footnotes - if (buf->footnoteflag) { - LyXParagraph * tmppar = buf; - while (tmppar){ - tmppar->footnoteflag = LyXParagraph::NO_FOOTNOTE; - tmppar = tmppar->next_; - } - } - - // the cut selection should begin with standard layout - buf->Clear(); - - // paste the paragraphs again, if possible - if (doclear) - startpar->next()->StripLeadingSpaces(textclass); - if (startpar->FirstPhysicalPar()->HasSameLayout(startpar->next()) || - !startpar->next()->Last()) { - startpar->ParFromPos(start)->PasteParagraph(current_view->buffer()->params); - (*endpar) = startpar; // this because endpar gets deleted here! - } - } - return true; -} -#else bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, int start, int & end, char tc, bool doclear) { @@ -206,72 +132,8 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, } return true; } -#endif -#ifndef NEW_INSETS -bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar, - int start, int end, char tc) -{ - if (!startpar || (start > startpar->Last())) - return false; - - DeleteBuffer(); - - textclass = tc; - - if (!(endpar) || - (startpar->ParFromPos(start) == - (endpar)->ParFromPos(end))) { - // only within one paragraph - buf = new LyXParagraph; - LyXParagraph::size_type i = start; - if (end > startpar->Last()) - end = startpar->Last(); - for (; i < end; ++i) { - startpar->CopyIntoMinibuffer(*current_view->buffer(), - i); - buf->InsertFromMinibuffer(buf->Last()); - } - } else { - // copy more than one paragraph - // clone the paragraphs within the selection - LyXParagraph * tmppar = startpar->ParFromPos(start); - buf = tmppar->Clone(); - LyXParagraph * tmppar2 = buf; - - while (tmppar != endpar->ParFromPos(end) - && tmppar->next_) { - tmppar = tmppar->next_; - tmppar2->next(tmppar->Clone()); - tmppar2->next_->previous(tmppar2); - tmppar2 = tmppar2->next_; - } - tmppar2->next(0); - - // care about footnotes - if (buf->footnoteflag) { - tmppar = buf; - while (tmppar) { - tmppar->footnoteflag = LyXParagraph::NO_FOOTNOTE; - tmppar = tmppar->next_; - } - } - - // the buf paragraph is too big - LyXParagraph::size_type tmpi2 = startpar->PositionInParFromPos(start); - for (; tmpi2; --tmpi2) - buf->Erase(0); - - // now tmppar 2 is too big, delete all after end - tmpi2 = endpar->PositionInParFromPos(end); - while (tmppar2->size() > tmpi2) { - tmppar2->Erase(tmppar2->size() - 1); - } - } - return true; -} -#else bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar, int start, int end, char tc) { @@ -322,131 +184,8 @@ bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar, } return true; } -#endif -#ifndef NEW_INSETS -bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, - int & pos, char tc) -{ - if (!checkPastePossible(*par)) - return false; - - if (pos > (*par)->Last()) - pos = (*par)->Last(); - - LyXParagraph * tmpbuf; - LyXParagraph * tmppar = *par; - int tmppos = pos; - - // There are two cases: cutbuffer only one paragraph or many - if (!buf->next_) { - // only within a paragraph - tmpbuf = buf->Clone(); - // Some provisions should be done here for checking - // if we are inserting at the beginning of a - // paragraph. If there are a space at the beginning - // of the text to insert and we are inserting at - // the beginning of the paragraph the space should - // be removed. - while (buf->size()) { - // This is an attempt to fix the - // "never insert a space at the - // beginning of a paragraph" problem. - if (!tmppos && buf->IsLineSeparator(0)) { - buf->Erase(0); - } else { - buf->CutIntoMinibuffer(current_view->buffer()->params, 0); - buf->Erase(0); - if (tmppar->InsertFromMinibuffer(tmppos)) - ++tmppos; - } - } - delete buf; - buf = tmpbuf; - *endpar = tmppar->next(); - pos = tmppos; - } else { - // many paragraphs - - // make a copy of the simple cut_buffer - tmpbuf = buf; - LyXParagraph * simple_cut_clone = tmpbuf->Clone(); - LyXParagraph * tmpbuf2 = simple_cut_clone; - if ((*par)->footnoteflag) { - tmpbuf->footnoteflag = (*par)->footnoteflag; - tmpbuf->footnotekind = (*par)->footnotekind; - } - 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; - } - } - - // make sure there is no class difference - SwitchLayoutsBetweenClasses(textclass, tc, buf); - - // make the buf exactly the same layout than - // the cursor paragraph - buf->MakeSameLayout(*par); - - // find the end of the buffer - LyXParagraph * lastbuffer = buf; - 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()) { - (*par)->BreakParagraphConservative(current_view->buffer()->params, - pos); - paste_the_end = true; - } - // set the end for redoing later - *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())); - - (*par)->ParFromPos(pos)->next(buf); - buf->previous((*par)->ParFromPos(pos)); - - if ((*par)->ParFromPos(pos)->next() == lastbuffer) - lastbuffer = *par; - - (*par)->ParFromPos(pos)->PasteParagraph(current_view->buffer()->params); - // store the new cursor position - *par = lastbuffer; - pos = lastbuffer->Last(); - // maybe some pasting - if (lastbuffer->next() && paste_the_end) { - if (lastbuffer->next()->HasSameLayout(lastbuffer)) { - lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params); - } 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->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params); - } else - lastbuffer->next()->StripLeadingSpaces(tc); - } - // restore the simple cut buffer - buf = simple_cut_clone; - } - return true; -} -#else bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, int & pos, char tc) { @@ -558,7 +297,6 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, return true; } -#endif int CutAndPaste::nrOfParagraphs() @@ -568,17 +306,10 @@ int CutAndPaste::nrOfParagraphs() int n = 1; LyXParagraph * tmppar = buf; -#ifndef NEW_INSETS - while(tmppar->next_) { - ++n; - tmppar = tmppar->next_; - } -#else while(tmppar->next()) { ++n; tmppar = tmppar->next(); } -#endif return n; } @@ -590,9 +321,7 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1, int ret = 0; if (!par || c1 == c2) return ret; -#ifndef NEW_INSETS - par = par->FirstPhysicalPar(); -#endif + while (par) { string name = textclasslist.NameOfLayout(c1, par->layout); int lay = 0; @@ -617,39 +346,15 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1, InsetError * new_inset = new InsetError(s); par->InsertInset(0, new_inset); } -#ifndef NEW_INSETS - par = par->next_; -#else par = par->next(); -#endif } return ret; } -#ifndef NEW_INSETS -bool CutAndPaste::checkPastePossible(LyXParagraph * par) -#else bool CutAndPaste::checkPastePossible(LyXParagraph *) -#endif { if (!buf) return false; -#ifndef NEW_INSETS - // be carefull with footnotes in footnotes - if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE) { - // check whether the cut_buffer includes a footnote - LyXParagraph * tmppar = buf; - while (tmppar && tmppar->footnoteflag == LyXParagraph::NO_FOOTNOTE) - tmppar = tmppar->next_; - - if (tmppar) { - WriteAlert(_("Impossible operation"), - _("Can't paste float into float!"), - _("Sorry.")); - return false; - } - } -#endif return true; } diff --git a/src/ToolbarDefaults.C b/src/ToolbarDefaults.C index f6267fab4f..9e8cc03a78 100644 --- a/src/ToolbarDefaults.C +++ b/src/ToolbarDefaults.C @@ -20,10 +20,6 @@ #include "lyxlex.h" #include "debug.h" #include "lyxlex.h" -#if 1 -// only until we don't need access to the NEW_INSETS anymore -#include "lyxparagraph.h" -#endif using std::endl; @@ -62,13 +58,9 @@ void ToolbarDefaults::init() add(LFUN_FREE); add(SEPARATOR); -#ifndef NEW_INSETS - add(LFUN_FOOTMELT); - add(LFUN_MARGINMELT); -#else add(LFUN_INSET_FOOTNOTE); add(LFUN_INSET_MARGINAL); -#endif + add(LFUN_DEPTH); add(SEPARATOR); diff --git a/src/buffer.C b/src/buffer.C index 5de92cfbcb..b5ff03380e 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -33,7 +33,7 @@ #endif #ifdef __GNUG__ -#pragma implementation "buffer.h" +#pragma implementation #endif #include "buffer.h" @@ -165,19 +165,11 @@ 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(); delete par; par = tmppar; } -#endif paragraph = 0; } @@ -294,10 +286,6 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par) { int pos = 0; char depth = 0; // signed or unsigned? -#ifndef NEW_INSETS - LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE; - LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE; -#endif bool the_end_read = false; LyXParagraph * return_par = 0; @@ -341,10 +329,6 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par) parseSingleLyXformat2Token(lex, par, return_par, pretoken, pos, depth, font -#ifndef NEW_INSETS - , footnoteflag, - footnotekind -#endif ); } @@ -370,20 +354,14 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, LyXParagraph *& return_par, string const & token, int & pos, char & depth, LyXFont & font -#ifndef NEW_INSETS - , LyXParagraph::footnote_flag & footnoteflag, - LyXParagraph::footnote_kind & footnotekind -#endif ) { bool the_end_read = false; #ifndef NO_PEXTRA_REALLY -#ifdef NEW_INSETS // This is super temporary but is needed to get the compability // mode for minipages work correctly together with new tabulars. static int call_depth = 0; ++call_depth; -#endif bool checkminipage = false; static LyXParagraph * minipar = 0; static LyXParagraph * parBeforeMinipage = 0; @@ -403,40 +381,6 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, par->InsertInset(pos, inset, font); ++pos; } else if (token == "\\layout") { -#ifndef NEW_INSETS - if (!return_par) - return_par = par; - else { - par->fitToSize(); - par = new LyXParagraph(par); - } - pos = 0; - lex.EatLine(); - string const layoutname = lex.GetString(); - pair pp - = textclasslist.NumberOfLayout(params.textclass, - layoutname); - if (pp.first) { - par->layout = pp.second; - } else { // layout not found - // use default layout "Standard" (0) - par->layout = 0; - } - // Test whether the layout is obsolete. - LyXLayout const & layout = - textclasslist.Style(params.textclass, - par->layout); - if (!layout.obsoleted_by().empty()) - par->layout = - textclasslist.NumberOfLayout(params.textclass, - layout.obsoleted_by()).second; - par->footnoteflag = footnoteflag; - par->footnotekind = footnotekind; - par->params.depth(depth); - font = LyXFont(LyXFont::ALL_INHERIT, params.language); - if (file_format < 216 && params.language->lang() == "hebrew") - font.setLanguage(default_language); -#else lex.EatLine(); string const layoutname = lex.GetString(); pair pp @@ -527,34 +471,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, #if USE_CAPTION } #endif -#endif -#ifndef NEW_INSETS - } else if (token == "\\end_float") { - if (!return_par) - return_par = par; - else { - par->fitToSize(); - par = new LyXParagraph(par); - } - footnotekind = LyXParagraph::FOOTNOTE; - footnoteflag = LyXParagraph::NO_FOOTNOTE; - pos = 0; - lex.EatLine(); - par->layout = LYX_DUMMY_LAYOUT; - font = LyXFont(LyXFont::ALL_INHERIT, params.language); - if (file_format < 216 && params.language->lang() == "hebrew") - font.setLanguage(default_language); - } else if (token == "\\begin_float") { - int tmpret = lex.FindToken(string_footnotekinds); - if (tmpret == -1) ++tmpret; - if (tmpret != LYX_LAYOUT_DEFAULT) - footnotekind = static_cast(tmpret); // bad - if (footnotekind == LyXParagraph::FOOTNOTE - || footnotekind == LyXParagraph::MARGIN) - footnoteflag = LyXParagraph::CLOSED_FOOTNOTE; - else - footnoteflag = LyXParagraph::OPEN_FOOTNOTE; -#else + } else if (token == "\\begin_float") { // This is the compability reader. It can be removed in // LyX version 1.3.0. (Lgb) @@ -628,7 +545,6 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, inset->Read(this, nylex); par->InsertInset(pos, inset, font); ++pos; -#endif } else if (token == "\\begin_deeper") { ++depth; } else if (token == "\\end_deeper") { @@ -1586,9 +1502,6 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, LyXFont font2; Inset const * inset; char c; -#ifndef NEW_INSETS - LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE; -#endif char depth = 0; int ltype = 0; int ltype_depth = 0; @@ -1597,29 +1510,7 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, int noparbreak = 0; int islatex = 0; -#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; - if (footnoteflag) { - size_t const j = strlen(string_footnotekinds[par->footnotekind]) + 4; - if ((linelen > 0) && - ((currlinelen + j) > linelen)) { - buffer << "\n"; - currlinelen = 0; - } - buffer << "([" - << string_footnotekinds[par->footnotekind] - << "] "; - currlinelen += j; - } - } -#else - if (!par->previous()) { -#endif + if (!par->previous()) { /* begins or ends a deeper area ?*/ if (depth != par->params.depth()) { if (par->params.depth() > depth) { @@ -1673,23 +1564,12 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, /* what about the alignment */ } else { -#ifndef NEW_INSETS - /* dummy layout, that means a footnote ended */ - footnoteflag = LyXParagraph::NO_FOOTNOTE; - buffer << ") "; - noparbreak = 1; -#else lyxerr << "Should this ever happen?" << endl; -#endif } font1 = LyXFont(LyXFont::ALL_INHERIT, params.language); for (LyXParagraph::size_type i = 0; i < par->size(); ++i) { - if (!i && -#ifndef NEW_INSETS - !footnoteflag && -#endif - !noparbreak) { + if (!i && !noparbreak) { if (linelen > 0) buffer << "\n\n"; for (char j = 0; j < depth; ++j) @@ -2338,11 +2218,6 @@ void Buffer::latexParagraphs(ostream & ofs, LyXParagraph * par, // if only_body while (par != endpar) { -#ifndef NEW_INSETS - if (par->IsDummy()) - lyxerr[Debug::LATEX] << "Error in latexParagraphs." - << endl; -#endif LyXLayout const & layout = textclasslist.Style(params.textclass, par->layout); @@ -2364,23 +2239,10 @@ void Buffer::latexParagraphs(ostream & ofs, LyXParagraph * par, // ordinary \footnote{} generation // flag this with ftcount ftcount = -1; - if (layout.isEnvironment() -#ifndef NEW_INSETS - || par->params.pextraType() != LyXParagraph::PEXTRA_NONE -#endif - ) { - par = par->TeXEnvironment(this, params, ofs, texrow -#ifndef NEW_INSETS - ,ftnote, ft_texrow, ftcount -#endif - ); + if (layout.isEnvironment()) { + par = par->TeXEnvironment(this, params, ofs, texrow); } else { - par = par->TeXOnePar(this, params, ofs, texrow, false -#ifndef NEW_INSETS - , - ftnote, ft_texrow, ftcount -#endif - ); + par = par->TeXOnePar(this, params, ofs, texrow, false); } // Write out what we've generated... @@ -2518,12 +2380,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) string const temp = "toc"; sgmlOpenTag(ofs, depth, temp); -#ifndef NEW_INSETS - par = par->next_; - linuxDocHandleFootnote(ofs, par, depth); -#else par = par->next(); -#endif continue; } } @@ -2605,19 +2462,9 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) break; } -#ifndef NEW_INSETS - do { - SimpleLinuxDocOnePar(ofs, par, depth); - - par = par->next_; - linuxDocHandleFootnote(ofs, par, depth); - } - while(par && par->IsDummy()); -#else SimpleLinuxDocOnePar(ofs, par, depth); par = par->next(); -#endif ofs << "\n"; // write closing SGML tags @@ -2649,39 +2496,16 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) } -#ifndef NEW_INSETS -void Buffer::linuxDocHandleFootnote(ostream & os, LyXParagraph * & par, - int depth) -{ - string const tag = "footnote"; - - while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE) { - sgmlOpenTag(os, depth + 1, tag); - SimpleLinuxDocOnePar(os, par, 0, depth + 1); - sgmlCloseTag(os, depth + 1, tag); - par = par->next_; - } -} -#endif - - void Buffer::DocBookHandleCaption(ostream & os, string & inner_tag, int depth, int desc_on, LyXParagraph * & par) { LyXParagraph * tpar = par; -#ifndef NEW_INSETS - while (tpar - && (tpar->footnoteflag != LyXParagraph::NO_FOOTNOTE) - && (tpar->layout != textclasslist.NumberOfLayout(params.textclass, - "Caption").second)) - 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) { @@ -2696,106 +2520,6 @@ void Buffer::DocBookHandleCaption(ostream & os, string & inner_tag, } -#ifndef NEW_INSETS -void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par, - int depth) -{ - string tag, inner_tag; - string tmp_par, extra_par; - bool inner_span = false; - int desc_on = 4; - - // Someone should give this enum a proper name (Lgb) - enum SOME_ENUM { - NO_ONE, - FOOTNOTE_LIKE, - MARGIN_LIKE, - FIG_LIKE, - TAB_LIKE - }; - SOME_ENUM last = NO_ONE; - SOME_ENUM present = FOOTNOTE_LIKE; - - while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE) { - if (last == present) { - if (inner_span) { - if (!tmp_par.empty()) { - os << tmp_par; - tmp_par.erase(); - sgmlCloseTag(os, depth + 1, inner_tag); - sgmlOpenTag(os, depth + 1, inner_tag); - } - } else { - os << "\n"; - } - } else { - os << tmp_par; - if (!inner_tag.empty()) sgmlCloseTag(os, depth + 1, - inner_tag); - if (!extra_par.empty()) os << extra_par; - if (!tag.empty()) sgmlCloseTag(os, depth, tag); - extra_par.erase(); - - switch (par->footnotekind) { - case LyXParagraph::FOOTNOTE: - case LyXParagraph::ALGORITHM: - tag = "footnote"; - inner_tag = "para"; - present = FOOTNOTE_LIKE; - inner_span = true; - break; - case LyXParagraph::MARGIN: - tag = "sidebar"; - inner_tag = "para"; - present = MARGIN_LIKE; - inner_span = true; - break; - case LyXParagraph::FIG: - case LyXParagraph::WIDE_FIG: - tag = "figure"; - inner_tag = "title"; - present = FIG_LIKE; - inner_span = false; - break; - case LyXParagraph::TAB: - case LyXParagraph::WIDE_TAB: - tag = "table"; - inner_tag = "title"; - present = TAB_LIKE; - inner_span = false; - break; - } - sgmlOpenTag(os, depth, tag); - if ((present == TAB_LIKE) || (present == FIG_LIKE)) { - DocBookHandleCaption(os, inner_tag, depth, - desc_on, par); - inner_tag.erase(); - } else { - sgmlOpenTag(os, depth + 1, inner_tag); - } - } - // ignore all caption here, we processed them above!!! - if (par->layout != textclasslist - .NumberOfLayout(params.textclass, - "Caption").second) { - std::ostringstream ost; - SimpleDocBookOnePar(ost, extra_par, par, - desc_on, depth + 2); - tmp_par += ost.str().c_str(); - } - tmp_par = frontStrip(strip(tmp_par)); - - last = present; - par = par->next_; - } - os << tmp_par; - if (!inner_tag.empty()) sgmlCloseTag(os, depth + 1, inner_tag); - if (!extra_par.empty()) os << extra_par; - if (!tag.empty()) sgmlCloseTag(os, depth, tag); -} -#endif - - // checks, if newcol chars should be put into this line // writes newline, if necessary. namespace { @@ -3289,21 +3013,11 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) break; } -#ifndef NEW_INSETS - do { - string extra_par; - SimpleDocBookOnePar(ofs, extra_par, par, desc_on, - depth + 1 + command_depth); - par = par->next_; - DocBookHandleFootnote(ofs, par, - depth + 1 + command_depth); - } 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 switch (style.latextype) { @@ -3536,11 +3250,7 @@ void Buffer::validate(LaTeXFeatures & features) const par->validate(features); // and then the next paragraph -#ifndef NEW_INSETS - par = par->next_; -#else par = par->next(); -#endif } // the bullet shapes are buffer level not paragraph level @@ -3646,45 +3356,12 @@ Buffer::Lists const Buffer::getLists() const { Lists l; LyXParagraph * par = paragraph; -#ifdef NEW_INSETS bool found; LyXTextClassList::size_type cap; boost::tie(found, cap) = textclasslist .NumberOfLayout(params.textclass, "Caption"); -#endif while (par) { -#ifndef NEW_INSETS - if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE) { - if (textclasslist.Style(params.textclass, - par->GetLayout()).labeltype - == LABEL_SENSITIVE) { - string type; - switch (par->footnotekind) { - case LyXParagraph::FIG: - case LyXParagraph::WIDE_FIG: - type = "LOF"; - break; - case LyXParagraph::TAB: - case LyXParagraph::WIDE_TAB: - type = "LOT"; - break; - case LyXParagraph::ALGORITHM: - type = "LOA"; - break; - case LyXParagraph::FOOTNOTE: - case LyXParagraph::MARGIN: - break; - } - if (!type.empty()) { - SingleList & item = l[type]; - string const str = - tostr(item.size()+1) + ". " + par->String(this, false); - item.push_back(TocItem(par, 0, str)); - } - } - } else if (!par->IsDummy()) { -#endif char const labeltype = textclasslist.Style(params.textclass, par->GetLayout()).labeltype; @@ -3698,7 +3375,6 @@ Buffer::Lists const Buffer::getLists() const textclasslist.TextClass(params.textclass).maxcounter()); item.push_back(TocItem(par, depth, par->String(this, true))); } -#ifdef NEW_INSETS // For each paragrph, traverse its insets and look for // FLOAT_CODE @@ -3734,13 +3410,7 @@ Buffer::Lists const Buffer::getLists() const lyxerr << "caption not found" << endl; } -#endif -#ifndef NEW_INSETS - } - par = par->next_; -#else par = par->next(); -#endif } return l; } @@ -3763,11 +3433,7 @@ vector > const Buffer::getBibkeyList() if (par->bibkey) keys.push_back(pair(par->bibkey->getContents(), par->String(this, false))); -#ifndef NEW_INSETS - par = par->next_; -#else par = par->next(); -#endif } // Might be either using bibtex or a child has bibliography @@ -3862,15 +3528,9 @@ void Buffer::resizeInsets(BufferView * bv) { /// then remove all LyXText in text-insets LyXParagraph * par = paragraph; -#ifndef NEW_INSETS - for (; par; par = par->next_) { - par->resizeInsetsLyXText(bv); - } -#else for (; par; par = par->next()) { par->resizeInsetsLyXText(bv); } -#endif } @@ -3880,11 +3540,7 @@ void Buffer::ChangeLanguage(Language const * from, Language const * to) LyXParagraph * par = paragraph; while (par) { par->ChangeLanguage(params, from, to); -#ifndef NEW_INSETS - par = par->next_; -#else par = par->next(); -#endif } } @@ -3895,11 +3551,7 @@ bool Buffer::isMultiLingual() while (par) { if (par->isMultiLingual(params)) return true; -#ifndef NEW_INSETS - par = par->next_; -#else par = par->next(); -#endif } return false; } @@ -3911,11 +3563,7 @@ Buffer::inset_iterator::inset_iterator(LyXParagraph * paragraph, { it = par->InsetIterator(pos); if (it == par->inset_iterator_end()) { -#ifndef NEW_INSETS - par = par->next_; -#else par = par->next(); -#endif SetParagraph(); } } @@ -3927,11 +3575,7 @@ void Buffer::inset_iterator::SetParagraph() it = par->inset_iterator_begin(); if (it != par->inset_iterator_end()) return; -#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 2d58f33769..4e6db6dc84 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -132,12 +132,7 @@ public: bool parseSingleLyXformat2Token(LyXLex &, LyXParagraph *& par, LyXParagraph *& return_par, string const & token, int & pos, - char & depth, LyXFont & -#ifndef NEW_INSETS - ,LyXParagraph::footnote_flag &, - LyXParagraph::footnote_kind & -#endif - ); + char & depth, LyXFont &); private: /// Parse a single inset. void readInset(LyXLex &, LyXParagraph *& par, int & pos, LyXFont &); @@ -324,20 +319,10 @@ public: /// Used when typesetting to place errorboxes. TexRow texrow; private: -#ifndef NEW_INSETS - /// - void linuxDocHandleFootnote(std::ostream & os, - LyXParagraph * & par, int depth); -#endif /// void DocBookHandleCaption(std::ostream & os, string & inner_tag, int depth, int desc_on, LyXParagraph * & par); -#ifndef NEW_INSETS - /// - void DocBookHandleFootnote(std::ostream & os, - LyXParagraph * & par, int depth); -#endif /// Open SGML/XML tag. void sgmlOpenTag(std::ostream & os, int depth, string const & latexname) const; @@ -404,11 +389,7 @@ public: if (par) { ++it; if (it == par->inset_iterator_end()) { -#ifndef NEW_INSETS - par = par->next_; -#else par = par->next(); -#endif SetParagraph(); } } @@ -420,11 +401,7 @@ public: if (par) { ++it; if (it == par->inset_iterator_end()) { -#ifndef NEW_INSETS - par = par->next_; -#else par = par->next(); -#endif SetParagraph(); } } diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 10fb795b21..56ddcad68d 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -27,21 +27,6 @@ #include "language.h" #include "gettext.h" -#ifndef NEW_INSETS -void Foot(BufferView * bv) -{ - if (!bv->available()) - return; - - bv->owner()->getMiniBuffer() - ->Set(_("Inserting Footnote...")); - bv->hideCursor(); - bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR); - bv->text->InsertFootnoteEnvironment(bv, LyXParagraph::FOOTNOTE); - bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); -} -#endif - void Emph(BufferView * bv) { @@ -67,19 +52,6 @@ void Noun(BufferView * bv) } -#ifndef NEW_INSETS -void Margin(BufferView * bv) -{ - if (bv->available()) { - bv->owner()->message(_("Inserting margin note..."); - bv->hideCursor(); - bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR); - bv->text->InsertFootnoteEnvironment(bv, LyXParagraph::MARGIN); - bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - } -} -#endif - void Number(BufferView * bv) { LyXFont font(LyXFont::ALL_IGNORE); @@ -99,21 +71,6 @@ void Lang(BufferView * bv, string const & l) } -#ifndef NEW_INSETS -void Melt(BufferView * bv) -{ - if (!bv->available()) return; - - bv->owner()->message(_("Melt")); - bv->hideCursor(); - bv->beforeChange(bv->text); - bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR); - bv->text->MeltFootnoteEnvironment(bv); - bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); -} -#endif - - void Tex(BufferView * bv) { LyXFont font(LyXFont::ALL_IGNORE); diff --git a/src/bufferview_funcs.h b/src/bufferview_funcs.h index ad1b174c5d..368549f624 100644 --- a/src/bufferview_funcs.h +++ b/src/bufferview_funcs.h @@ -22,20 +22,12 @@ class BufferView; class LyXFont; class LyXText; -#ifndef NEW_INSETS -/// -extern void Foot(BufferView *); -#endif /// extern void Emph(BufferView *); /// extern void Bold(BufferView *); /// extern void Noun(BufferView *); -#ifndef NEW_INSETS -/// -extern void Margin(BufferView *); -#endif /// extern void Figure(); /// @@ -44,10 +36,6 @@ extern void Table(); extern void Lang(BufferView *, string const &); /// extern void Number(BufferView *); -#ifndef NEW_INSETS -/// -extern void Melt(BufferView *); -#endif /// extern void Tex(BufferView *); /// diff --git a/src/figureForm.C b/src/figureForm.C index 4f6cd05759..f068c3c581 100644 --- a/src/figureForm.C +++ b/src/figureForm.C @@ -69,11 +69,7 @@ void FigureApplyCB(FL_OBJECT *, long) current_view->text->BreakParagraph(current_view); current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); -#ifndef NEW_INSETS - if (current_view->text->cursor.par()->Last()) { -#else if (current_view->text->cursor.par()->size()) { -#endif current_view->text->CursorLeft(current_view); current_view->text->BreakParagraph(current_view); @@ -83,10 +79,6 @@ void FigureApplyCB(FL_OBJECT *, long) // The standard layout should always be numer 0; current_view->text->SetLayout(current_view, 0); -#ifndef NEW_INSETS - if (current_view->text->cursor.par()->footnoteflag == - LyXParagraph::NO_FOOTNOTE) { -#endif current_view->text-> SetParagraph(current_view, 0, 0, 0, 0, @@ -96,17 +88,6 @@ void FigureApplyCB(FL_OBJECT *, long) buffer->params.spacing.getValue(), LyXLength::CM), LYX_ALIGN_CENTER, string(), 0); -#ifndef NEW_INSETS - } else { - current_view->text->SetParagraph(current_view, 0, 0, - 0, 0, - VSpace(VSpace::NONE), - VSpace(VSpace::NONE), - LYX_ALIGN_CENTER, - string(), - 0); - } -#endif current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index ca33ed81f7..5d288647ad 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2001-05-03 Lars Gullik Bjønnes + + * FormParagraph.[Ch]: remove !NO_PEXTRA and !NEW_INSETS cruft + 2001-04-26 Angus Leeming * Dialogs.C: included insetgraphicsParams.h diff --git a/src/frontends/xforms/FormParagraph.C b/src/frontends/xforms/FormParagraph.C index 7a59f86343..adb84b116d 100644 --- a/src/frontends/xforms/FormParagraph.C +++ b/src/frontends/xforms/FormParagraph.C @@ -25,13 +25,11 @@ #include "buffer.h" #include "lyxtext.h" #include "xforms_helpers.h" -#if 1 -#include "lyxparagraph.h" -#endif using Liason::setMinibuffer; using SigC::slot; + FormParagraph::FormParagraph(LyXView * lv, Dialogs * d) : FormBaseBD(lv, d, _("Paragraph Layout")) { @@ -104,25 +102,8 @@ void FormParagraph::build() bc_.addReadOnly (general_->check_noindent); bc_.addReadOnly (general_->input_labelwidth); -#ifndef NO_PEXTRA - // the document class form - extra_.reset(build_paragraph_extra()); - - fl_set_input_return(extra_->input_pextra_width, FL_RETURN_CHANGED); - fl_set_input_return(extra_->input_pextra_widthp, FL_RETURN_CHANGED); - - bc_.addReadOnly (extra_->radio_pextra_indent); - bc_.addReadOnly (extra_->radio_pextra_minipage); - bc_.addReadOnly (extra_->radio_pextra_floatflt); - bc_.addReadOnly (extra_->radio_pextra_hfill); - bc_.addReadOnly (extra_->radio_pextra_startmp); -#endif - // now make them fit together fl_addto_tabfolder(dialog_->tabbed_folder,_("General"), general_->form); -#ifndef NO_PEXTRA - fl_addto_tabfolder(dialog_->tabbed_folder,_("Extra"), extra_->form); -#endif } @@ -132,9 +113,6 @@ void FormParagraph::apply() return; general_apply(); -#ifndef NO_PEXTRA - extra_apply(); -#endif lv_->view()->update(lv_->view()->text, BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); @@ -149,9 +127,7 @@ void FormParagraph::update() return; general_update(); -#ifndef NO_PEXTRA - extra_update(); -#endif + bc_.readOnly(lv_->buffer()->isReadonly()); } @@ -257,40 +233,6 @@ void FormParagraph::general_apply() } -#ifndef NO_PEXTRA -void FormParagraph::extra_apply() -{ - char const * width = fl_get_input(extra_->input_pextra_width); - char const * widthp = fl_get_input(extra_->input_pextra_widthp); - LyXText * text = lv_->view()->text; - int type = LyXParagraph::PEXTRA_NONE; - LyXParagraph::MINIPAGE_ALIGNMENT - alignment = LyXParagraph::MINIPAGE_ALIGN_TOP; - bool - hfill = false, - start_minipage = false; - - if (fl_get_button(extra_->radio_pextra_indent)) { - type = LyXParagraph::PEXTRA_INDENT; - } else if (fl_get_button(extra_->radio_pextra_minipage)) { - type = LyXParagraph::PEXTRA_MINIPAGE; - hfill = fl_get_button(extra_->radio_pextra_hfill); - start_minipage = fl_get_button(extra_->radio_pextra_startmp); - if (fl_get_button(extra_->radio_pextra_top)) - alignment = LyXParagraph::MINIPAGE_ALIGN_TOP; - else if (fl_get_button(extra_->radio_pextra_middle)) - alignment = LyXParagraph::MINIPAGE_ALIGN_MIDDLE; - else if (fl_get_button(extra_->radio_pextra_bottom)) - alignment = LyXParagraph::MINIPAGE_ALIGN_BOTTOM; - } else if (fl_get_button(extra_->radio_pextra_floatflt)) { - type = LyXParagraph::PEXTRA_FLOATFLT; - } - text->SetParagraphExtraOpt(lv_->view(), type, width, widthp, alignment, - hfill, start_minipage); -} -#endif - - void FormParagraph::general_update() { if (!general_.get()) @@ -331,21 +273,6 @@ void FormParagraph::general_update() break; } -#ifndef NEW_INSETS - fl_set_button(general_->check_lines_top, - text->cursor.par()->FirstPhysicalPar()->params.lineTop()); - - fl_set_button(general_->check_lines_bottom, - text->cursor.par()->FirstPhysicalPar()->params.lineBottom()); - - fl_set_button(general_->check_pagebreaks_top, - text->cursor.par()->FirstPhysicalPar()->params.pagebreakTop()); - - fl_set_button(general_->check_pagebreaks_bottom, - text->cursor.par()->FirstPhysicalPar()->params.pagebreakBottom()); - fl_set_button(general_->check_noindent, - text->cursor.par()->FirstPhysicalPar()->params.noindent()); -#else fl_set_button(general_->check_lines_top, text->cursor.par()->params.lineTop()); fl_set_button(general_->check_lines_bottom, @@ -356,15 +283,10 @@ void FormParagraph::general_update() text->cursor.par()->params.pagebreakBottom()); fl_set_button(general_->check_noindent, text->cursor.par()->params.noindent()); -#endif + fl_set_input (general_->input_space_above, ""); -#ifndef NEW_INSETS - switch (text->cursor.par()->FirstPhysicalPar()->params.spaceTop().kind()) { -#else switch (text->cursor.par()->params.spaceTop().kind()) { -#endif - case VSpace::NONE: fl_set_choice (general_->choice_space_above, 1); break; @@ -385,29 +307,16 @@ void FormParagraph::general_update() break; case VSpace::LENGTH: fl_set_choice (general_->choice_space_above, 7); -#ifndef NEW_INSETS - fl_set_input(general_->input_space_above, - text->cursor.par()->FirstPhysicalPar()-> - params.spaceTop().length().asString().c_str()); -#else fl_set_input(general_->input_space_above, text->cursor.par()-> params.spaceTop().length().asString().c_str()); -#endif break; } -#ifndef NEW_INSETS - fl_set_button(general_->check_space_above, - text->cursor.par()->FirstPhysicalPar()-> - params.spaceTop().keep()); - fl_set_input(general_->input_space_below, ""); - switch (text->cursor.par()->FirstPhysicalPar()-> - params.spaceBottom().kind()) { -#else + fl_set_button (general_->check_space_above, text->cursor.par()->params.spaceTop().keep()); fl_set_input (general_->input_space_below, ""); + switch (text->cursor.par()->params.spaceBottom().kind()) { -#endif case VSpace::NONE: fl_set_choice (general_->choice_space_below, 1); break; @@ -428,29 +337,6 @@ void FormParagraph::general_update() break; case VSpace::LENGTH: fl_set_choice (general_->choice_space_below, 7); -#ifndef NEW_INSETS - fl_set_input(general_->input_space_below, - text->cursor.par()->FirstPhysicalPar()-> - params.spaceBottom().length().asString().c_str()); - break; - } - fl_set_button(general_->check_space_below, - text->cursor.par()->FirstPhysicalPar()-> - params.spaceBottom().keep()); - fl_set_button(general_->check_noindent, - text->cursor.par()->FirstPhysicalPar()->params.noindent()); - - bool const enable = (!text->cursor.par()->FirstPhysicalPar()->InInset()); - - setEnabled(general_->check_pagebreaks_top, enable); - setEnabled(general_->check_pagebreaks_bottom, enable); - - if (!enable) { - fl_set_button(general_->check_pagebreaks_top, 0); - fl_set_button(general_->check_pagebreaks_bottom, 0); - } - -#else fl_set_input(general_->input_space_below, text->cursor.par()-> params.spaceBottom().length().asString().c_str()); break; @@ -459,78 +345,7 @@ void FormParagraph::general_update() text->cursor.par()->params.spaceBottom().keep()); fl_set_button(general_->check_noindent, text->cursor.par()->params.noindent()); -#endif -} - - -#ifndef NO_PEXTRA -void FormParagraph::extra_update() -{ - if (!lv_->view()->available() || !extra_.get()) - return; - - LyXParagraph * par = lv_->view()->text->cursor.par(); - - setEnabled(extra_->input_pextra_width, true); - setEnabled(extra_->input_pextra_widthp, true); - - fl_set_input(extra_->input_pextra_width, - par->params.pextraWidth().c_str()); - fl_set_input(extra_->input_pextra_widthp, - par->params.pextraWidthp().c_str()); - switch (par->params.pextraAlignment()) { - case LyXParagraph::MINIPAGE_ALIGN_TOP: - fl_set_button(extra_->radio_pextra_top, 1); - break; - case LyXParagraph::MINIPAGE_ALIGN_MIDDLE: - fl_set_button(extra_->radio_pextra_middle, 1); - break; - case LyXParagraph::MINIPAGE_ALIGN_BOTTOM: - fl_set_button(extra_->radio_pextra_bottom, 1); - break; - } - fl_set_button(extra_->radio_pextra_hfill, - par->params.pextraHfill()); - fl_set_button(extra_->radio_pextra_startmp, - par->params.pextraStartMinipage()); - if (par->params.pextraType() == LyXParagraph::PEXTRA_INDENT) { - fl_set_button(extra_->radio_pextra_indent, 1); - fl_set_button(extra_->radio_pextra_minipage, 0); - fl_set_button(extra_->radio_pextra_floatflt, 0); - setEnabled(extra_->radio_pextra_top, false); - setEnabled(extra_->radio_pextra_middle, false); - setEnabled(extra_->radio_pextra_bottom, false); - input(extra_->radio_pextra_indent, 0); - } else if (par->params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE) { - fl_set_button(extra_->radio_pextra_indent, 0); - fl_set_button(extra_->radio_pextra_minipage, 1); - fl_set_button(extra_->radio_pextra_floatflt, 0); - setEnabled(extra_->radio_pextra_top, true); - setEnabled(extra_->radio_pextra_middle, true); - setEnabled(extra_->radio_pextra_bottom, true); - input(extra_->radio_pextra_minipage, 0); - } else if (par->params.pextraType() == LyXParagraph::PEXTRA_FLOATFLT) { - fl_set_button(extra_->radio_pextra_indent, 0); - fl_set_button(extra_->radio_pextra_minipage, 0); - fl_set_button(extra_->radio_pextra_floatflt, 1); - setEnabled(extra_->radio_pextra_top, false); - setEnabled(extra_->radio_pextra_middle, false); - setEnabled(extra_->radio_pextra_bottom, false); - input(extra_->radio_pextra_floatflt, 0); - } else { - fl_set_button(extra_->radio_pextra_indent, 0); - fl_set_button(extra_->radio_pextra_minipage, 0); - fl_set_button(extra_->radio_pextra_floatflt, 0); - setEnabled(extra_->input_pextra_width, false); - setEnabled(extra_->input_pextra_widthp, false); - setEnabled(extra_->radio_pextra_top, false); - setEnabled(extra_->radio_pextra_middle, false); - setEnabled(extra_->radio_pextra_bottom, false); - input(0, 0); - } - fl_hide_object(dialog_->text_warning); } -#endif bool FormParagraph::input(FL_OBJECT * ob, long) @@ -553,61 +368,6 @@ bool FormParagraph::input(FL_OBJECT * ob, long) if (fl_get_choice (general_->choice_space_below) != 7) fl_set_input (general_->input_space_below, ""); -#ifndef NO_PEXTRA - // - // then the extra form - // - if (ob == extra_->radio_pextra_indent) { - bool const enable = (fl_get_button(extra_->radio_pextra_indent) != 0); - - if (enable) { - fl_set_button(extra_->radio_pextra_minipage, 0); - fl_set_button(extra_->radio_pextra_floatflt, 0); - } - - setEnabled(extra_->input_pextra_width, enable); - setEnabled(extra_->input_pextra_widthp, enable); - - setEnabled(extra_->radio_pextra_top, false); - setEnabled(extra_->radio_pextra_middle, false); - setEnabled(extra_->radio_pextra_bottom, false); - setEnabled(extra_->radio_pextra_hfill, false); - setEnabled(extra_->radio_pextra_startmp, false); - - } else if (ob == extra_->radio_pextra_minipage) { - bool const enable = (fl_get_button(extra_->radio_pextra_minipage) != 0); - - if (enable) { - fl_set_button(extra_->radio_pextra_indent, 0); - fl_set_button(extra_->radio_pextra_floatflt, 0); - } - - setEnabled(extra_->input_pextra_width, enable); - setEnabled(extra_->input_pextra_widthp, enable); - setEnabled(extra_->radio_pextra_top, enable); - setEnabled(extra_->radio_pextra_middle, enable); - setEnabled(extra_->radio_pextra_bottom, enable); - setEnabled(extra_->radio_pextra_hfill, enable); - setEnabled(extra_->radio_pextra_startmp, enable); - } else if (ob == extra_->radio_pextra_floatflt) { - bool const enable = (fl_get_button(extra_->radio_pextra_floatflt) != 0); - - if (enable) { - fl_set_button(extra_->radio_pextra_indent, 0); - fl_set_button(extra_->radio_pextra_minipage, 0); - } - - setEnabled(extra_->input_pextra_width, enable); - setEnabled(extra_->input_pextra_widthp, enable); - - setEnabled(extra_->radio_pextra_top, false); - setEnabled(extra_->radio_pextra_middle, false); - setEnabled(extra_->radio_pextra_bottom, false); - setEnabled(extra_->radio_pextra_hfill, false); - setEnabled(extra_->radio_pextra_startmp, false); - } -#endif - // // first the general form // @@ -634,44 +394,6 @@ bool FormParagraph::input(FL_OBJECT * ob, long) } } -#ifndef NO_PEXTRA - // - // then the extra form - // - int n = fl_get_button(extra_->radio_pextra_indent) + - fl_get_button(extra_->radio_pextra_minipage) + - fl_get_button(extra_->radio_pextra_floatflt); - string s1 = fl_get_input(extra_->input_pextra_width); - string s2 = fl_get_input(extra_->input_pextra_widthp); - if (!n) { // no button pressed both should be deactivated now - setEnabled(extra_->input_pextra_width, false); - setEnabled(extra_->input_pextra_widthp, false); - fl_hide_object(dialog_->text_warning); - } else if (s1.empty() && s2.empty()) { - setEnabled(extra_->input_pextra_width, true); - setEnabled(extra_->input_pextra_widthp, true); - fl_hide_object(dialog_->text_warning); - ret = false; - } else if (!s1.empty()) { // LyXLength parameter - setEnabled(extra_->input_pextra_width, true); - setEnabled(extra_->input_pextra_widthp, false); - if (!isValidLength(s1)) { - fl_set_object_label(dialog_->text_warning, - _("Warning: Invalid Length (valid example: 10mm)")); - fl_show_object(dialog_->text_warning); - ret = false; - } - } else { // !s2.empty() % parameter - setEnabled(extra_->input_pextra_width, false); - setEnabled(extra_->input_pextra_widthp, true); - if ((lyx::atoi(s2) < 0 ) || (lyx::atoi(s2) > 100)) { - ret = false; - fl_set_object_label(dialog_->text_warning, - _("Warning: Invalid percent value (0-100)")); - fl_show_object(dialog_->text_warning); - } - } -#endif return ret; } diff --git a/src/frontends/xforms/FormParagraph.h b/src/frontends/xforms/FormParagraph.h index d72fac11b7..9470355f38 100644 --- a/src/frontends/xforms/FormParagraph.h +++ b/src/frontends/xforms/FormParagraph.h @@ -20,9 +20,6 @@ #endif #include "FormBaseDeprecated.h" -#if 1 -#include "lyxparagraph.h" -#endif struct FD_form_tabbed_paragraph; struct FD_form_paragraph_general; @@ -55,32 +52,19 @@ private: /// void general_update(); -#ifndef NO_PEXTRA - /// - void extra_update(); -#endif /// void general_apply(); -#ifndef NO_PEXTRA - /// - void extra_apply(); -#endif + /// Fdesign generated methods FD_form_tabbed_paragraph * build_tabbed_paragraph(); /// FD_form_paragraph_general * build_paragraph_general(); -//#ifndef NO_PEXTRA /// FD_form_paragraph_extra * build_paragraph_extra(); -//#endif /// Real GUI implementation. boost::scoped_ptr dialog_; /// boost::scoped_ptr general_; -#ifndef NO_PEXTRA - /// - boost::scoped_ptr extra_; -#endif /// The ButtonController ButtonController bc_; }; diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 030545f676..d2431d494e 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,13 @@ +2001-05-03 Lars Gullik Bjønnes + + * insettext.C: remvoe !NEW_INSETS cruft + + * insettabular.C: remove !NEW_INSETS cruft + + * insetcollapsable.h: remove !NEW_INSETS cruft + + * insetbib.C: remove !NEW_INSETS cruft + 2001-04-27 Lars Gullik Bjønnes * insettoc.C: hack to make listof algorithm work diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index 3696dbbdf2..6db97e73a2 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -261,11 +261,7 @@ int bibitemMaxWidth(BufferView * bv, LyXFont const & font) int const wx = par->bibkey->width(bv, font); if (wx > w) w = wx; } -#ifndef NEW_INSETS - par = par->next_; -#else par = par->next(); -#endif } return w; } @@ -290,11 +286,7 @@ string const bibitemWidest(Buffer const * buffer) bkey = par->bibkey; } } -#ifndef NEW_INSETS - par = par->next_; -#else par = par->next(); -#endif } if (bkey && !bkey->getBibLabel().empty()) diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 5b89661942..47100ac6a4 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -21,9 +21,6 @@ #include "insettext.h" #include "lyxfont.h" #include "LColor.h" -#if 1 // NEW_INSETS -#include "lyxparagraph.h" -#endif class Painter; class LyXText; @@ -160,9 +157,7 @@ protected: LColor::color framecolor; /// LyXFont labelfont; -#ifdef NEW_INSETS public: -#endif /// InsetText inset; protected: diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 679698de1e..a3bced2cd7 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -941,14 +941,8 @@ InsetTabular::LocalDispatch(BufferView * bv, if (!copySelection(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_ -#else bv->text->cursor.par()->previous(), - bv->text->cursor.par()->next() -#endif - ); + bv->text->cursor.par()->next()); cutSelection(); UpdateLocal(bv, INIT, true); break; @@ -1027,14 +1021,8 @@ InsetTabular::LocalDispatch(BufferView * bv, case LFUN_PASTE: 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_ -#else bv->text->cursor.par()->previous(), - bv->text->cursor.par()->next() -#endif - ); + bv->text->cursor.par()->next()); pasteSelection(bv); UpdateLocal(bv, INIT, true); break; @@ -1558,14 +1546,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, sel_row_start = sel_row_end = tabular->row_of_cell(actcell); } 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_ -#else bv->text->cursor.par()->previous(), - bv->text->cursor.par()->next() -#endif - ); + bv->text->cursor.par()->next()); int row = tabular->row_of_cell(actcell); int column = tabular->column_of_cell(actcell); diff --git a/src/insets/insettext.C b/src/insets/insettext.C index b693257621..fa69c36dda 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -122,21 +122,12 @@ InsetText::~InsetText() delete (*cit).second; (*cit).second = 0; } -#ifndef NEW_INSETS - LyXParagraph * p = par->next_; - delete par; - while(p) { - par = p; - p = p->next_; - delete par; - } -#else + while (par) { LyXParagraph * tmp = par->next(); delete par; par = tmp; } -#endif } @@ -148,21 +139,12 @@ void InsetText::clear() delete (*cit).second; (*cit).second = 0; } -#ifndef NEW_INSETS - LyXParagraph * p = par->next_; - delete par; - while(p) { - par = p; - p = p->next_; - delete par; - } -#else + while (par) { LyXParagraph * tmp = par->next(); delete par; par = tmp; } -#endif par = new LyXParagraph; } @@ -193,10 +175,6 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex) int pos = 0; LyXParagraph * return_par = 0; char depth = 0; // signed or unsigned? -#ifndef NEW_INSETS - LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE; - LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE; -#endif LyXFont font(LyXFont::ALL_INHERIT); // delete all instances of LyXText before deleting the paragraps used @@ -206,21 +184,12 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex) (*cit).second = 0; } -#ifndef NEW_INSETS - LyXParagraph * p = par->next_; - delete par; - while(p) { - par = p; - p = p->next_; - delete par; - } -#else while (par) { LyXParagraph * tmp = par->next(); delete par; par = tmp; } -#endif + par = new LyXParagraph; while (lex.IsOK()) { lex.nextToken(); @@ -231,12 +200,7 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex) break; if (const_cast(buf)-> parseSingleLyXformat2Token(lex, par, return_par, - token, pos, depth, font -#ifndef NEW_INSETS - , footnoteflag, footnotekind -#endif - )) - { + token, pos, depth, font)) { // the_end read this should NEVER happen lex.printError("\\the_end read in inset! Error in document!"); return; @@ -247,11 +211,7 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex) par = return_par; while(return_par) { return_par->SetInsetOwner(this); -#ifndef NEW_INSETS - return_par = return_par->next_; -#else return_par = return_par->next(); -#endif } if (token != "\\end_inset") { @@ -578,12 +538,7 @@ 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. -#ifndef NEW_INSETS - if (par->Last() == 0 && !par->next_) -#else - if (par->size() == 0 && !par->next()) -#endif - { + if (par->size() == 0 && !par->next()) { LyXFont font(LyXFont::ALL_IGNORE); font.setLanguage(bv->getParentLanguage(this)); SetFont(bv, font, false); @@ -891,14 +846,8 @@ InsetText::LocalDispatch(BufferView * bv, * true (on). */ 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_ -#else bv->text->cursor.par()->previous(), - bv->text->cursor.par()->next() -#endif - ); + bv->text->cursor.par()->next()); bv->setState(); if (lyxrc.auto_region_delete) { if (TEXT(bv)->selection){ @@ -978,14 +927,8 @@ InsetText::LocalDispatch(BufferView * bv, break; 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_ -#else bv->text->cursor.par()->previous(), - bv->text->cursor.par()->next() -#endif - ); + bv->text->cursor.par()->next()); if (TEXT(bv)->selection) TEXT(bv)->CutSelection(bv); else @@ -994,14 +937,8 @@ InsetText::LocalDispatch(BufferView * bv, break; 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_ -#else bv->text->cursor.par()->previous(), - bv->text->cursor.par()->next() -#endif - ); + bv->text->cursor.par()->next()); if (TEXT(bv)->selection) TEXT(bv)->CutSelection(bv); else @@ -1010,14 +947,8 @@ InsetText::LocalDispatch(BufferView * bv, break; 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_ -#else bv->text->cursor.par()->previous(), - bv->text->cursor.par()->next() -#endif - ); + bv->text->cursor.par()->next()); TEXT(bv)->CutSelection(bv); UpdateLocal(bv, CURSOR_PAR, true); break; @@ -1052,14 +983,8 @@ 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_ -#else bv->text->cursor.par()->previous(), - bv->text->cursor.par()->next() -#endif - ); + bv->text->cursor.par()->next()); TEXT(bv)->PasteSelection(bv); UpdateLocal(bv, CURSOR_PAR, true); break; @@ -1079,14 +1004,8 @@ InsetText::LocalDispatch(BufferView * bv, if (!autoBreakRows) 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_ -#else bv->text->cursor.par()->previous(), - bv->text->cursor.par()->next() -#endif - ); + bv->text->cursor.par()->next()); TEXT(bv)->InsertChar(bv, LyXParagraph::META_NEWLINE); UpdateLocal(bv, CURSOR_PAR, true); break; @@ -1184,12 +1103,7 @@ 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. -#ifndef NEW_INSETS - if (par->Last() == 0 && !par->next_) -#else - if (par->size() == 0 && !par->next()) -#endif - { + if (par->size() == 0 && !par->next()) { LyXFont font(LyXFont::ALL_IGNORE); font.setLanguage(bv->getParentLanguage(this)); SetFont(bv, font, false); @@ -1221,11 +1135,7 @@ int InsetText::Ascii(Buffer const * buf, ostream & os, int linelen) const tmp = buf->asciiParagraph(p, linelen); lines += countChar(tmp, '\n'); os << tmp; -#ifndef NEW_INSETS - p = p->next(); -#else p = p->next(); -#endif } return lines; } @@ -1240,11 +1150,7 @@ int InsetText::DocBook(Buffer const * buf, ostream & os) const string tmp; while (p) { buf->SimpleDocBookOnePar(os,tmp,p,desc,0); -#ifndef NEW_INSETS - p = p->next_; -#else p = p->next(); -#endif } return lines; @@ -1256,11 +1162,7 @@ void InsetText::Validate(LaTeXFeatures & features) const LyXParagraph * p = par; while(p) { p->validate(features); -#ifndef NEW_INSETS - p = p->next_; -#else p = p->next(); -#endif } } @@ -1367,11 +1269,7 @@ UpdatableInset::RESULT InsetText::moveRightIntern(BufferView * bv, bool behind, bool activate_inset, bool selecting) { -#ifndef NEW_INSETS - if (!cpar(bv)->next_ && (cpos(bv) >= cpar(bv)->Last())) -#else if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size())) -#endif return FINISHED; if (activate_inset && checkAndActivateInset(bv, behind)) return DISPATCHED; @@ -1386,11 +1284,7 @@ UpdatableInset::RESULT InsetText::moveLeftIntern(BufferView * bv, bool behind, bool activate_inset, bool selecting) { -#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) @@ -1429,14 +1323,8 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset) return false; } 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_ -#else bv->text->cursor.par()->previous(), - bv->text->cursor.par()->next() -#endif - ); + bv->text->cursor.par()->next()); inset->setOwner(this); HideInsetCursor(bv); TEXT(bv)->InsertInset(bv, inset); @@ -1498,14 +1386,8 @@ 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_ -#else bv->text->cursor.par()->previous(), - bv->text->cursor.par()->next() -#endif - ); + bv->text->cursor.par()->next()); } TEXT(bv)->SetFont(bv, font, toggleall); bv->fitCursor(TEXT(bv)); @@ -1594,28 +1476,6 @@ void InsetText::SetParagraphData(LyXParagraph * p) (*cit).second = 0; } -#ifndef NEW_INSETS - LyXParagraph * np; - if (par) { - 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 while (par) { LyXParagraph * tmp = par->next(); delete par; @@ -1632,7 +1492,7 @@ void InsetText::SetParagraphData(LyXParagraph * p) np = np->next(); np->SetInsetOwner(this); } -#endif + need_update = INIT; } @@ -1754,26 +1614,16 @@ void InsetText::deleteLyXText(BufferView * bv, bool recursive) const if (recursive) { /// then remove all LyXText in text-insets LyXParagraph * p = par; -#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 { -#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; @@ -1835,15 +1685,9 @@ 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; -#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; } @@ -1851,13 +1695,8 @@ void InsetText::resizeLyXText(BufferView * bv) const void InsetText::removeNewlines() { -#ifndef NEW_INSETS - for (LyXParagraph * p = par; p; p = p->next_) { - for (int i = 0; i < p->Last(); ++i) { -#else for (LyXParagraph * p = par; p; p = p->next()) { for (int i = 0; i < p->size(); ++i) { -#endif if (p->GetChar(i) == LyXParagraph::META_NEWLINE) p->Erase(i); } diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 9f4c5e04de..b333558895 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -473,23 +473,13 @@ void MenuInsertLabel(BufferView * bv, string const & arg) string label(arg); ProhibitInput(bv); if (label.empty()) { -#ifndef NEW_INSETS - LyXParagraph * par = - bv->text->cursor.par()->FirstPhysicalPar(); -#else LyXParagraph * par = bv->text->cursor.par(); -#endif LyXLayout const * layout = &textclasslist.Style(bv->buffer()->params.textclass, par->GetLayout()); -#ifndef NEW_INSETS - if (layout->latextype == LATEX_PARAGRAPH && par->previous_) { - LyXParagraph * par2 = par->previous_->FirstPhysicalPar(); -#else if (layout->latextype == LATEX_PARAGRAPH && par->previous()) { LyXParagraph * par2 = par->previous(); -#endif LyXLayout const * layout2 = &textclasslist.Style(bv->buffer()->params.textclass, par2->GetLayout()); @@ -501,25 +491,7 @@ void MenuInsertLabel(BufferView * bv, string const & arg) string text = layout->latexname().substr(0, 3); if (layout->latexname() == "theorem") text = "thm"; // Create a correct prefix for prettyref -#ifndef NEW_INSETS - if (par->footnoteflag==LyXParagraph::OPEN_FOOTNOTE) - switch (par->footnotekind) { - case LyXParagraph::FIG: - case LyXParagraph::WIDE_FIG: - text = "fig"; - break; - case LyXParagraph::TAB: - case LyXParagraph::WIDE_TAB: - text = "tab"; - break; - case LyXParagraph::ALGORITHM: - text = "alg"; - break; - case LyXParagraph::FOOTNOTE: - case LyXParagraph::MARGIN: - break; - } -#endif + text += ":"; if (layout->latextype == LATEX_PARAGRAPH || lyxrc.label_init_length < 0) diff --git a/src/lyxfind.C b/src/lyxfind.C index 21065b6115..21d834eab1 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -118,11 +118,7 @@ bool IsStringInText(LyXParagraph * par, LyXParagraph::size_type pos, string::size_type size = str.length(); LyXParagraph::size_type i = 0; -#ifndef NEW_INSETS - while (((pos + i) < par->Last()) -#else while (((pos + i) < par->size()) -#endif && (string::size_type(i) < size) && (cs ? (str[i] == par->GetChar(pos + i)) : (toupper(str[i]) == toupper(par->GetChar(pos + i))))) @@ -133,11 +129,7 @@ bool IsStringInText(LyXParagraph * par, LyXParagraph::size_type pos, // if necessary, check whether string matches word if (!mw || (mw && ((pos <= 0 || !IsLetterCharOrDigit(par->GetChar(pos - 1))) -#ifndef NEW_INSETS - && (pos + size >= par->Last() -#else && (pos + size >= par->size() -#endif || !IsLetterCharOrDigit(par->GetChar(pos + size)))) ) ) @@ -156,11 +148,7 @@ bool SearchForward(BufferView * bv, string const & str, LyXParagraph::size_type pos = bv->text->cursor.pos(); while (par && !IsStringInText(par, pos, str, cs, mw)) { -#ifndef NEW_INSETS - if (pos < par->Last() - 1) -#else if (pos < par->size() - 1) -#endif ++pos; else { pos = 0; @@ -193,11 +181,7 @@ bool SearchBackward(BufferView * bv, string const & str, do { par = par->previous(); if (par) -#ifndef NEW_INSETS - pos = par->Last() - 1; -#else pos = par->size() - 1; -#endif } while (par && pos < 0); } } while (par && !IsStringInText(par, pos, str, cs, mw)); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 9cf3a6ae2b..2cc377cde6 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -968,12 +968,6 @@ string const LyXFunc::Dispatch(int ac, } break; -#ifndef NEW_INSETS - case LFUN_OPENSTUFF: - owner->view()->openStuff(); - break; -#endif - case LFUN_HYPHENATION: owner->view()->hyphenationPoint(); break; @@ -1015,43 +1009,12 @@ string const LyXFunc::Dispatch(int ac, owner->view()->setState(); owner->showState(); break; -#ifndef NEW_INSETS - case LFUN_MELT: - Melt(owner->view()); - break; -#endif + case LFUN_RECONFIGURE: Reconfigure(owner->view()); break; -#ifndef NEW_INSETS - case LFUN_FOOTMELT: - if (owner->view()->available() - && !TEXT()->selection - && TEXT()->cursor.par()->footnoteflag - != LyXParagraph::NO_FOOTNOTE) - { // only melt footnotes with FOOTMELT, not margins etc - if (TEXT()->cursor.par()->footnotekind == LyXParagraph::FOOTNOTE) - Melt(owner->view()); - } - else - Foot(owner->view()); - owner->view()->setState(); - break; - case LFUN_MARGINMELT: - if (owner->view()->available() - && !TEXT()->selection - && TEXT()->cursor.par()->footnoteflag - != LyXParagraph::NO_FOOTNOTE) { - // only melt margins - if (TEXT()->cursor.par()->footnotekind == LyXParagraph::MARGIN) - Melt(owner->view()); - } else - Margin(owner->view()); - owner->view()->setState(); - break; -#endif -#ifndef NEW_INSETS +#if 0 case LFUN_FLOATSOPERATE: if (argument == "openfoot") owner->view()->allFloats(1,0); @@ -1422,35 +1385,6 @@ string const LyXFunc::Dispatch(int ac, } break; -#ifndef NEW_INSETS - case LFUN_INSERTFOOTNOTE: - { - LyXParagraph::footnote_kind kind; - if (argument == "footnote") { - kind = LyXParagraph::FOOTNOTE; - } else if (argument == "margin") { - kind = LyXParagraph::MARGIN; - } else if (argument == "figure") { - kind = LyXParagraph::FIG; - } else if (argument == "table") { - kind = LyXParagraph::TAB; - } else if (argument == "wide-fig") { - kind = LyXParagraph::WIDE_FIG; - } else if (argument == "wide-tab") { - kind = LyXParagraph::WIDE_TAB; - } else if (argument == "algorithm") { - kind = LyXParagraph::ALGORITHM; - } else { - setErrorMessage(N_("Unknown kind of footnote")); - break; - } - TEXT()->InsertFootnoteEnvironment(owner->view(), kind); - owner->view()->update(TEXT(), - BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - owner->view()->setState(); - } - break; -#endif case LFUN_TOGGLECURSORFOLLOW: lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar; break; diff --git a/src/lyxlex_pimpl.C b/src/lyxlex_pimpl.C index b0587400df..173d542cee 100644 --- a/src/lyxlex_pimpl.C +++ b/src/lyxlex_pimpl.C @@ -9,9 +9,6 @@ #include "support/lyxalgo.h" #include "support/filetools.h" #include "debug.h" -#if 1 // to get NEW_INSETS -#include "lyxparagraph.h" -#endif using std::sort; using std::ostream; @@ -142,12 +139,6 @@ void LyXLex::Pimpl::setCommentChar(char c) bool LyXLex::Pimpl::next(bool esc /* = false */) { if (!pushTok.empty()) { -#ifndef NEW_INSETS - pushTok.copy(buff, string::npos); - buff[pushTok.length()] = '\0'; - pushTok.erase(); - return true; -#else // There can have been a whole line pushed so // we extract the first word and leaves the rest // in pushTok. (Lgb) @@ -163,7 +154,6 @@ bool LyXLex::Pimpl::next(bool esc /* = false */) pushTok.erase(); return true; } -#endif } if (!esc) { unsigned char c = 0; // getc() returns an int @@ -401,15 +391,6 @@ int LyXLex::Pimpl::lex() bool LyXLex::Pimpl::EatLine() { -#ifndef NEW_INSETS - // This is not handling the pushed token - if (!pushTok.empty()) { - pushTok.copy(buff, string::npos); - buff[pushTok.length()] = '\0'; - pushTok.erase(); - return true; - } -#endif int i = 0; unsigned char c = '\0'; char cc = 0; @@ -442,12 +423,6 @@ bool LyXLex::Pimpl::EatLine() bool LyXLex::Pimpl::nextToken() { if (!pushTok.empty()) { -#ifndef NEW_INSETS - pushTok.copy(buff, string::npos); - buff[pushTok.length()] = '\0'; - pushTok.erase(); - return true; -#else // There can have been a whole line pushed so // we extract the first word and leaves the rest // in pushTok. (Lgb) @@ -463,7 +438,6 @@ bool LyXLex::Pimpl::nextToken() pushTok.erase(); return true; } -#endif } status = 0; diff --git a/src/lyxtext.h b/src/lyxtext.h index 1c3ec4d6fc..d651cf154c 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -156,10 +156,6 @@ public: Returns true if something was broken. */ bool FullRebreak(BufferView *); -#ifndef NEW_INSETS - /// - LyXParagraph::footnote_flag GetFootnoteFlag(int row); -#endif /// Row * need_break_row; /// @@ -338,29 +334,6 @@ public: void GetVisibleRow(BufferView *, int y_offset, int x_offset, Row * row_ptr, int y, bool cleared=false); -#ifndef NEW_INSETS - /* footnotes: */ - /// - void ToggleFootnote(BufferView *); - /// - void OpenStuff(BufferView *); - /// - void OpenFootnotes(); - /// - void OpenFootnote(BufferView *); - /// - void CloseFootnotes(); - /// - void CloseFootnote(BufferView *); - - /** turn the selection into a new environment. If there is no - selection, create an empty environment - */ - void InsertFootnoteEnvironment(BufferView *, - LyXParagraph::footnote_kind kind); - /// - void MeltFootnoteEnvironment(BufferView *); -#endif /// void CutSelection(BufferView *, bool = true); /// @@ -394,14 +367,7 @@ public: LyXAlignment align, string labelwidthstring, bool noindent); -#ifndef NO_PEXTRA - /// - void SetParagraphExtraOpt(BufferView *, int type, - string const & width, - string const & widthp, - int alignment, bool hfill, - bool start_minipage); -#endif + /* these things are for search and replace */ /** sets the selection over the number of characters of string, diff --git a/src/spellchecker.C b/src/spellchecker.C index 34c097884d..030cbc4aca 100644 --- a/src/spellchecker.C +++ b/src/spellchecker.C @@ -811,12 +811,6 @@ bool RunSpellChecker(BufferView * bv) int newvalue; FL_OBJECT * obj; -#ifndef NEW_INSETS - // Open all floats - bv->allFloats(1, 0); - bv->allFloats(1, 1); -#endif - #ifdef USE_PSPELL string tmp = (lyxrc.isp_use_alt_lang) ? lyxrc.isp_alt_lang : bv->buffer()->params.language->code(); diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 084424bf3b..1a66882283 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,7 @@ +2001-05-03 Lars Gullik Bjønnes + + * textutils.h: remvoe !NEW_INSETS cruft + 2001-05-02 Jean-Marc Lasgouttes * fmt.C: diff --git a/src/support/textutils.h b/src/support/textutils.h index 20dd4d7751..754a27f0b5 100644 --- a/src/support/textutils.h +++ b/src/support/textutils.h @@ -42,21 +42,6 @@ bool IsInsetChar(char c) { } -#ifndef NEW_INSETS -/// -inline -bool IsFloatChar(char c) { - return (c == LyXParagraph::META_FOOTNOTE - || c == LyXParagraph::META_MARGIN - || c == LyXParagraph::META_FIG - || c == LyXParagraph::META_TAB - || c == LyXParagraph::META_ALGORITHM - || c == LyXParagraph::META_WIDE_FIG - || c == LyXParagraph::META_WIDE_TAB); -} -#endif - - /// inline bool IsLineSeparatorChar(char c) { @@ -124,9 +109,6 @@ bool IsWordChar(unsigned char c) { return !( IsSeparatorChar( c ) || IsKommaChar( c ) || IsHfillChar( c ) -#ifndef NEW_INSETS - || IsFloatChar( c ) -#endif || IsInsetChar( c )); } diff --git a/src/tabular.C b/src/tabular.C index f0c61ed8b8..3d68635b21 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -1475,10 +1475,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl) LyXParagraph * par = new LyXParagraph; LyXParagraph * return_par = 0; -#ifndef NEW_INSETS - LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE; - LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE; -#endif + string tmptok; int pos = 0; char depth = 0; @@ -1499,14 +1496,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl) if (owner_->BufferOwner()->parseSingleLyXformat2Token(lex, par, return_par, token, pos, - depth, font -#ifndef NEW_INSETS - , - footnoteflag, - footnotekind -#endif - )) - { + depth, font)) { // the_end read lex.pushToken(token); break; @@ -1524,12 +1514,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl) InsetText * inset = GetCellInset(cell); int row; -#ifndef NEW_INSETS - for (int i = 0; i < par->Last(); ++i) -#else - for (int i = 0; i < par->size(); ++i) -#endif - { + for (int i = 0; i < par->size(); ++i) { if (par->IsNewline(i)) { ++cell; if (cell > GetNumberOfCells()) { @@ -1558,11 +1543,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl) } } par->CopyIntoMinibuffer(*owner_->BufferOwner(), i); -#ifndef NEW_INSETS - inset->par->InsertFromMinibuffer(inset->par->Last()); -#else inset->par->InsertFromMinibuffer(inset->par->size()); -#endif } delete par; Reinit(); @@ -2165,11 +2146,8 @@ int LyXTabular::Latex(Buffer const * buf, InsetText * inset = GetCellInset(cell); bool rtl = inset->par->isRightToLeftPar(buf->params) && -#ifndef NEW_INSETS - inset->par->Last() > 0 && GetPWidth(cell).empty(); -#else - inset->par->size() > 0 && GetPWidth(cell).empty(); -#endif + inset->par->size() > 0 && GetPWidth(cell).empty(); + if (rtl) os << "\\R{"; ret += inset->Latex(buf, os, fragile, fp); @@ -2565,20 +2543,6 @@ std::vector const LyXTabular::getLabelList() 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; @@ -2591,7 +2555,7 @@ LyXTabular::BoxType LyXTabular::UseParbox(int cell) const } return BOX_NONE; } -#endif + /* Emacs: * Local variables: * tab-width: 4 diff --git a/src/text.C b/src/text.C index 68e26adf41..f86a5b6874 100644 --- a/src/text.C +++ b/src/text.C @@ -77,11 +77,8 @@ unsigned char LyXText::TransformChar(unsigned char c, LyXParagraph * par, unsigned char const prev_char = pos > 0 ? par->GetChar(pos-1) : ' '; unsigned char next_char = ' '; -#ifndef NEW_INSETS - for (LyXParagraph::size_type i = pos+1; i < par->Last(); ++i) -#else + for (LyXParagraph::size_type i = pos+1; i < par->size(); ++i) -#endif if (!Encodings::IsComposeChar_arabic(par->GetChar(i))) { next_char = par->GetChar(i); break; @@ -157,42 +154,6 @@ int LyXText::SingleWidth(BufferView * bview, LyXParagraph * par, } else if (IsHfillChar(c)) { return 3; /* Because of the representation * as vertical lines */ -#ifndef NEW_INSETS - } else if (c == LyXParagraph::META_FOOTNOTE || - c == LyXParagraph::META_MARGIN || - c == LyXParagraph::META_FIG || - c == LyXParagraph::META_TAB || - c == LyXParagraph::META_WIDE_FIG || - c == LyXParagraph::META_WIDE_TAB || - c == LyXParagraph::META_ALGORITHM) { - string fs; - switch (c) { - case LyXParagraph::META_MARGIN: - fs = "margin"; - break; - case LyXParagraph::META_FIG: - fs = "fig"; - break; - case LyXParagraph::META_TAB: - fs = "tab"; - break; - case LyXParagraph::META_ALGORITHM: - fs = "alg"; - break; - case LyXParagraph::META_WIDE_FIG: - fs = "wide-fig"; - break; - case LyXParagraph::META_WIDE_TAB: - fs = "wide-tab"; - break; - case LyXParagraph::META_FOOTNOTE: - fs = "foot"; - break; - } - font.decSize(); - font.decSize(); - return lyxfont::width(fs, font); -#endif } else if (c == LyXParagraph::META_INSET) { Inset * tmpinset = par->GetInset(pos); if (tmpinset) { @@ -212,21 +173,12 @@ int LyXText::SingleWidth(BufferView * bview, LyXParagraph * par, // Returns the paragraph position of the last character in the specified row LyXParagraph::size_type LyXText::RowLast(Row const * row) const { -#ifndef NEW_INSETS - if (row->next() == 0) - return row->par()->Last() - 1; - else if (row->next()->par() != row->par()) - return row->par()->Last() - 1; - else - return row->next()->pos() - 1; -#else if (row->next() == 0) return row->par()->size() - 1; else if (row->next()->par() != row->par()) return row->par()->size() - 1; else return row->next()->pos() - 1; -#endif } @@ -472,60 +424,8 @@ void LyXText::draw(BufferView * bview, Row const * row, LyXFont font = GetFont(bview->buffer(), row->par(), pos); LyXFont font2 = font; -#ifndef NEW_INSETS - if (c == LyXParagraph::META_FOOTNOTE - || c == LyXParagraph::META_MARGIN - || c == LyXParagraph::META_FIG - || c == LyXParagraph::META_TAB - || c == LyXParagraph::META_WIDE_FIG - || c == LyXParagraph::META_WIDE_TAB - || c == LyXParagraph::META_ALGORITHM) { - string fs; - switch (c) { - case LyXParagraph::META_MARGIN: - fs = "margin"; - break; - case LyXParagraph::META_FIG: - fs = "fig"; - break; - case LyXParagraph::META_TAB: - fs = "tab"; - break; - case LyXParagraph::META_ALGORITHM: - fs = "alg"; - break; - case LyXParagraph::META_WIDE_FIG: - fs = "wide-fig"; - break; - case LyXParagraph::META_WIDE_TAB: - fs = "wide-tab"; - break; - case LyXParagraph::META_FOOTNOTE: - fs = "foot"; - break; - } - font.decSize(); - font.decSize(); - - // calculate the position of the footnotemark - int const y = (row->baseline() - lyxfont::maxAscent(font2) - + lyxfont::maxAscent(font)); - - font.setColor(LColor::footnote); - // draw it and set new x position - - pain.text(int(x), offset + y, fs, font); - x += lyxfont::width(fs, font); - pain.line(int(tmpx), offset + row->baseline(), - int(x), offset + row->baseline(), - LColor::footnote); - - ++vpos; - return; - } else -#endif - if (c == LyXParagraph::META_INSET) { + if (c == LyXParagraph::META_INSET) { Inset * tmpinset = row->par()->GetInset(pos); if (tmpinset) { // tmpinset->update(bview, font, false); @@ -690,25 +590,14 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const textclasslist .TextClass(bview->buffer()->params.textclass) .defaultfont()); -#ifndef NEW_INSETS - if (row->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) { - LyXFont font(LyXFont::ALL_SANE); - font.setSize(LyXFont::SIZE_SMALL); - x += lyxfont::width("Mwide-figM", font) - + LYX_PAPER_MARGIN/2; - } -#endif + // this is the way, LyX handles the LaTeX-Environments. // I have had this idea very late, so it seems to be a // later added hack and this is true if (!row->par()->GetDepth()) { if (!row->par()->GetLayout()) { // find the previous same level paragraph -#ifndef NEW_INSETS - if (row->par()->FirstPhysicalPar()->previous()) { -#else if (row->par()->previous()) { -#endif LyXParagraph * newpar = row->par() ->DepthHook(row->par()->GetDepth()); if (newpar && @@ -728,38 +617,23 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const // check wether it is a sufficent paragraph if (newpar -#ifndef NEW_INSETS - && newpar->footnoteflag == row->par()->footnoteflag -#endif && textclasslist .Style(bview->buffer()->params.textclass, newpar->GetLayout()).isEnvironment()) { Row dummyrow; dummyrow.par(newpar); -#ifndef NEW_INSETS - dummyrow.pos(newpar->Last()); -#else dummyrow.pos(newpar->size()); -#endif x = LeftMargin(bview, &dummyrow); } else { // this is no longer an error, because this function // is used to clear impossible depths after changing // a layout. Since there is always a redo, // LeftMargin() is always called -#ifndef NEW_INSETS - row->par()->FirstPhysicalPar()->params.depth(0); -#else row->par()->params.depth(0); -#endif } if (newpar && !row->par()->GetLayout()) { -#ifndef NEW_INSETS - if (newpar->FirstPhysicalPar()->params.noindent()) -#else if (newpar->params.noindent()) -#endif parindent.erase(); else parindent = textclasslist @@ -857,36 +731,14 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const } break; } -#ifndef NO_PEXTRA - if ((workWidth(bview) > 0) && - (row->par()->params.pextraType() == LyXParagraph::PEXTRA_INDENT)) { - if (!row->par()->params.pextraWidthp().empty()) { - x += workWidth(bview) * - lyx::atoi(row->par()->params.pextraWidthp()) / 100; - } else if (!row->par()->params.pextraWidth().empty()) { - int xx = VSpace(row->par()->params.pextraWidth()).inPixels(bview); - if (xx > workWidth(bview)) - xx = workWidth(bview) * 80 / 100; - x += xx; - } else { // should not happen - LyXFont font(LyXFont::ALL_SANE); - x += lyxfont::width("XXXXXX", font); - } - } -#endif int align; // wrong type -#ifndef NEW_INSETS - if (row->par()->FirstPhysicalPar()->params.align() == LYX_ALIGN_LAYOUT) - align = layout.align; - else - align = row->par()->FirstPhysicalPar()->params.align(); -#else + if (row->par()->params.align() == LYX_ALIGN_LAYOUT) align = layout.align; else align = row->par()->params.align(); -#endif + // set the correct parindent if (row->pos() == 0) { if ((layout.labeltype == LABEL_NO_LABEL @@ -895,9 +747,6 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const || (layout.labeltype == LABEL_STATIC && layout.latextype == LATEX_ENVIRONMENT && ! row->par()->IsFirstInSequence())) -#ifndef NEW_INSETS - && row->par() == row->par()->FirstPhysicalPar() -#endif && align == LYX_ALIGN_BLOCK && !row->par()->params.noindent() && (row->par()->layout || @@ -934,11 +783,6 @@ int LyXText::RightMargin(Buffer const * buf, Row const * row) const .TextClass(buf->params.textclass) .defaultfont()); -#ifndef NEW_INSETS - if (row->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) { - x += LYX_PAPER_MARGIN / 2; - } -#endif // this is the way, LyX handles the LaTeX-Environments. // I have had this idea very late, so it seems to be a // later added hack and this is true @@ -947,27 +791,15 @@ int LyXText::RightMargin(Buffer const * buf, Row const * row) const LyXParagraph * newpar = row->par(); -#ifndef NEW_INSETS - do { - 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(); } while (newpar && newpar->GetDepth() >= row->par()->GetDepth()); -#endif // make a corresponding row. Needed to call LeftMargin() // check wether it is a sufficent paragraph if (newpar -#ifndef NEW_INSETS - && newpar->footnoteflag == row->par()->footnoteflag -#endif && textclasslist.Style(buf->params.textclass, newpar->GetLayout()) .isEnvironment()) { @@ -980,11 +812,7 @@ int LyXText::RightMargin(Buffer const * buf, Row const * row) const // is used to clear impossible depths after changing // a layout. Since there is always a redo, // LeftMargin() is always called -#ifndef NEW_INSETS - row->par()->FirstPhysicalPar()->params.depth(0); -#else row->par()->params.depth(0); -#endif } } @@ -1004,11 +832,7 @@ int LyXText::LabelEnd(BufferView * bview, Row const * row) const == MARGIN_MANUAL) { Row tmprow; tmprow = *row; -#ifndef NEW_INSETS - tmprow.pos(row->par()->Last()); -#else tmprow.pos(row->par()->size()); -#endif return LeftMargin(bview, &tmprow); /* just the beginning of the main body */ } else @@ -1025,11 +849,7 @@ LyXText::NextBreakPoint(BufferView * bview, Row const * row, int width) const LyXParagraph * par = row->par(); if (width < 0) -#ifndef NEW_INSETS - return par->Last(); -#else return par->size(); -#endif LyXParagraph::size_type const pos = row->pos(); @@ -1047,18 +867,10 @@ LyXText::NextBreakPoint(BufferView * bview, Row const * row, int width) const if (layout.margintype == MARGIN_RIGHT_ADDRESS_BOX) { /* special code for right address boxes, only newlines count */ -#ifndef NEW_INSETS - while (i < par->Last()) { -#else while (i < par->size()) { -#endif if (par->IsNewline(i)) { last_separator = i; -#ifndef NEW_INSETS - i = par->Last() - 1; // this means break -#else i = par->size() - 1; // this means break -#endif //x = width; } else if (par->GetChar(i) == LyXParagraph::META_INSET && par->GetInset(i) && par->GetInset(i)->display()){ @@ -1068,13 +880,8 @@ LyXText::NextBreakPoint(BufferView * bview, Row const * row, int width) const } } else { // Last position is an invariant -#ifndef NEW_INSETS - LyXParagraph::size_type const last = - par->Last(); -#else LyXParagraph::size_type const last = par->size(); -#endif // this is the usual handling int x = LeftMargin(bview, row); bool doitonetime = true; @@ -1373,22 +1180,13 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const /* Correction: only the fontsize count. The other properties are taken from the layoutfont. Nicer on the screen :) */ -#ifndef NEW_INSETS - LyXParagraph * par = row_ptr->par()->LastPhysicalPar(); - LyXParagraph * firstpar = row_ptr->par()->FirstPhysicalPar(); -#else LyXParagraph * par = row_ptr->par(); LyXParagraph * firstpar = row_ptr->par(); -#endif LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass, firstpar->GetLayout()); -#ifndef NEW_INSETS - LyXFont font = GetFont(bview->buffer(), par, par->Last() - 1); -#else LyXFont font = GetFont(bview->buffer(), par, par->size() - 1); -#endif LyXFont::FONT_SIZE const size = font.size(); font = GetFont(bview->buffer(), par, -1); font.setSize(size); @@ -1473,13 +1271,8 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const } // 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) @@ -1588,22 +1381,12 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const } // is it a bottom line? - if ( -#ifndef NEW_INSETS - row_ptr->par()->ParFromPos(RowLast(row_ptr) + 1) == par -#else - row_ptr->par() == par -#endif + if (row_ptr->par() == par && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par())) { // 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) @@ -1611,16 +1394,10 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const // do not forget the DTP-lines! // there height depends on the font of the nearest character -#ifndef NEW_INSETS - if (firstpar->params.lineBottom()) - maxdesc += 2 * lyxfont::ascent('x', GetFont(bview->buffer(), - par, par->Last() - 1)); -#else if (firstpar->params.lineBottom()) maxdesc += 2 * lyxfont::ascent('x', GetFont(bview->buffer(), par, par->size() - 1)); -#endif // and now the pagebreaks if (firstpar->params.pagebreakBottom()) @@ -1693,11 +1470,7 @@ void LyXText::AppendParagraph(BufferView * bview, Row * row) const // The last character position of a paragraph is an invariant so we can // safely get it here. (Asger) -#ifndef NEW_INSETS - int const lastposition = row->par()->Last(); -#else int const lastposition = row->par()->size(); -#endif do { // Get the next breakpoint int z = NextBreakPoint(bview, row, workWidth(bview)); @@ -1731,11 +1504,7 @@ void LyXText::BreakAgain(BufferView * bview, Row * row) const LyXParagraph::size_type z = NextBreakPoint(bview, row, workWidth(bview)); Row * tmprow = row; -#ifndef NEW_INSETS - if (z < row->par()->Last()) { -#else if (z < row->par()->size()) { -#endif if (!row->next() || (row->next() && row->next()->par() != row->par())) { // insert a new row ++z; @@ -1779,11 +1548,7 @@ void LyXText::BreakAgainOneRow(BufferView * bview, Row * row) LyXParagraph::size_type z = NextBreakPoint(bview, row, workWidth(bview)); Row * tmprow = row; -#ifndef NEW_INSETS - if (z < row->par()->Last()) { -#else if (z < row->par()->size()) { -#endif if (!row->next() || (row->next() && row->next()->par() != row->par())) { /* insert a new row */ @@ -1824,16 +1589,6 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) cursor.par()->GetLayout()); // this is only allowed, if the current paragraph is not empty or caption -#ifndef NEW_INSETS - if ((cursor.par()->Last() <= 0 - && !cursor.par()->IsDummy()) - && layout.labeltype!= LABEL_SENSITIVE) - return; - - SetUndo(bview->buffer(), Undo::INSERT, - cursor.par()->ParFromPos(cursor.pos())->previous_, - cursor.par()->ParFromPos(cursor.pos())->next_); -#else if ((cursor.par()->size() <= 0) && layout.labeltype!= LABEL_SENSITIVE) return; @@ -1841,16 +1596,11 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) SetUndo(bview->buffer(), Undo::INSERT, cursor.par()->previous(), cursor.par()->next()); -#endif // Always break behind a space // // It is better to erase the space (Dekel) -#ifndef NEW_INSETS - if (cursor.pos() < cursor.par()->Last() -#else if (cursor.pos() < cursor.par()->size() -#endif && cursor.par()->IsLineSeparator(cursor.pos())) cursor.par()->Erase(cursor.pos()); // cursor.pos(cursor.pos() + 1); @@ -1867,18 +1617,10 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) if (layout.labeltype == LABEL_SENSITIVE) { if (!cursor.pos()) // set to standard-layout -#ifndef NEW_INSETS - cursor.par()->SetLayout(bview->buffer()->params, 0); -#else cursor.par()->SetLayout(0); -#endif else // set to standard-layout -#ifndef NEW_INSETS - cursor.par()->next()->SetLayout(bview->buffer()->params, 0); -#else cursor.par()->next()->SetLayout(0); -#endif } /* if the cursor is at the beginning of a row without prior newline, @@ -1909,11 +1651,7 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) SetHeightOfRow(bview, cursor.row()); -#ifndef NEW_INSETS - while (cursor.par()->next()->Last() -#else while (cursor.par()->next()->size() -#endif && cursor.par()->next()->IsNewline(0)) cursor.par()->next()->Erase(0); @@ -1935,64 +1673,6 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) } -#ifndef NEW_INSETS -void LyXText::OpenFootnote(BufferView * bview) -{ - LyXParagraph * endpar,* tmppar; - Row * row; - - 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) - return; - - /* ok, move the cursor right before the footnote */ - - /* just a little faster than using CursorRight() */ - for (cursor.pos(0); - cursor.par()->ParFromPos(cursor.pos()) != par;) { - cursor.pos(cursor.pos() + 1); - } - - /* now the cursor is at the beginning of the physical par */ - SetCursor(bview, cursor.par(), - cursor.pos() + cursor.par()->ParFromPos(cursor.pos())->size()); - - /* the cursor must be exactly before the footnote */ - par = cursor.par()->ParFromPos(cursor.pos()); - - status = LyXText::NEED_MORE_REFRESH; - refresh_row = cursor.row(); - refresh_y = cursor.y() - cursor.row()->baseline(); - - tmppar = cursor.par(); - endpar = cursor.par()->next(); - row = cursor.row(); - - tmppar->OpenFootnote(cursor.pos()); - RemoveParagraph(row); - /* set the dimensions of the cursor row */ - row->fill(Fill(bview, row, workWidth(bview))); - SetHeightOfRow(bview, row); - // CHECK See comment on top of text.C - 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(); - } - } - SetCursor(bview, par->next_, 0); - sel_cursor = cursor; -} -#endif - - // Just a macro to make some thing easier. void LyXText::RedoParagraph(BufferView * bview) const { @@ -2007,14 +1687,8 @@ void LyXText::RedoParagraph(BufferView * bview) const 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_ -#else cursor.par()->previous(), - cursor.par()->next() -#endif - ); + cursor.par()->next()); // When the free-spacing option is set for the current layout, // disable the double-space checking @@ -2091,13 +1765,10 @@ void LyXText::InsertChar(BufferView * bview, char c) * current font */ // Get the font that is used to calculate the baselineskip -#ifndef NEW_INSETS - LyXParagraph::size_type const lastpos = cursor.par()->Last(); -#else LyXParagraph::size_type const lastpos = cursor.par()->size(); -#endif - LyXFont rawparfont = cursor.par()->GetFontSettings(bview->buffer()->params, - lastpos - 1); + LyXFont rawparfont = + cursor.par()->GetFontSettings(bview->buffer()->params, + lastpos - 1); bool jumped_over_space = false; @@ -2106,13 +1777,7 @@ void LyXText::InsertChar(BufferView * bview, char c) && cursor.par()->IsLineSeparator(cursor.pos() - 1)) || (cursor.pos() > 0 && cursor.par()->IsNewline(cursor.pos() - 1)) - || (cursor.pos() == 0 -#ifndef NEW_INSETS - && !(cursor.par()->previous() - && cursor.par()->previous()->footnoteflag - == LyXParagraph::OPEN_FOOTNOTE) -#endif - )) { + || (cursor.pos() == 0)) { if (cursor.pos() == 0 ) bview->owner()->message(_("You cannot insert a space at the beginning of a paragraph. Please read the Tutorial.")); else @@ -2121,11 +1786,7 @@ void LyXText::InsertChar(BufferView * bview, char c) return; } } else if (IsNewlineChar(c)) { -#ifndef NEW_INSETS - if (cursor.par()->FirstPhysicalPar() == cursor.par() -#else if (cursor.par() == cursor.par() -#endif && cursor.pos() <= BeginningOfMainBody(bview->buffer(), cursor.par())) { charInserted(); return; @@ -2134,11 +1795,7 @@ void LyXText::InsertChar(BufferView * bview, char c) * of a paragraph or behind labels. * TeX does not allow that. */ -#ifndef NEW_INSETS - if (cursor.pos() < cursor.par()->Last() && -#else if (cursor.pos() < cursor.par()->size() && -#endif cursor.par()->IsLineSeparator(cursor.pos())) // newline always after a blank! CursorRight(bview); @@ -2206,11 +1863,7 @@ void LyXText::InsertChar(BufferView * bview, char c) need_break_row = 0; // check, wether the last characters font has changed. -#ifndef NEW_INSETS - if (cursor.pos() && cursor.pos() == cursor.par()->Last() -#else if (cursor.pos() && cursor.pos() == cursor.par()->size() -#endif && rawparfont != rawtmpfont) RedoHeightOfParagraph(bview, cursor); @@ -2271,11 +1924,7 @@ void LyXText::InsertChar(BufferView * bview, char c) } // check, wether the last characters font has changed. -#ifndef NEW_INSETS - if (cursor.pos() && cursor.pos() == cursor.par()->Last() -#else if (cursor.pos() && cursor.pos() == cursor.par()->size() -#endif && rawparfont != rawtmpfont) { RedoHeightOfParagraph(bview, cursor); } else { @@ -2325,13 +1974,6 @@ void LyXText::PrepareToPrint(BufferView * bview, if (is_rtl) { x = (workWidth(bview) > 0) ? RightMargin(bview->buffer(), row) : 0; -#ifndef NEW_INSETS - if (row->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) { - LyXFont font(LyXFont::ALL_SANE); - font.setSize(LyXFont::SIZE_SMALL); - x += lyxfont::width("Mwide-figM", font); - } -#endif } else x = (workWidth(bview) > 0) ? LeftMargin(bview, row) : 0; @@ -2357,17 +1999,10 @@ void LyXText::PrepareToPrint(BufferView * bview, // is it block, flushleft or flushright? // set x how you need it int align; -#ifndef NEW_INSETS - if (row->par()->FirstPhysicalPar()->params.align() == LYX_ALIGN_LAYOUT) - align = textclasslist.Style(bview->buffer()->params.textclass, row->par()->GetLayout()).align; - else - align = row->par()->FirstPhysicalPar()->params.align(); -#else if (row->par()->params.align() == LYX_ALIGN_LAYOUT) align = textclasslist.Style(bview->buffer()->params.textclass, row->par()->GetLayout()).align; else align = row->par()->params.align(); -#endif // center displayed insets Inset * inset; @@ -2434,11 +2069,7 @@ void LyXText::CursorRightOneWord(BufferView * bview) const LyXCursor tmpcursor = cursor; // CHECK See comment on top of text.C -#ifndef NEW_INSETS - if (tmpcursor.pos() == tmpcursor.par()->Last() -#else if (tmpcursor.pos() == tmpcursor.par()->size() -#endif && tmpcursor.par()->next()) { tmpcursor.par(tmpcursor.par()->next()); tmpcursor.pos(0); @@ -2446,25 +2077,15 @@ void LyXText::CursorRightOneWord(BufferView * bview) const int steps = 0; // Skip through initial nonword stuff. -#ifndef NEW_INSETS - while (tmpcursor.pos() < tmpcursor.par()->Last() && -#else while (tmpcursor.pos() < tmpcursor.par()->size() && -#endif - ! tmpcursor.par()->IsWord( tmpcursor.pos() ) ) - { + ! tmpcursor.par()->IsWord( tmpcursor.pos())) { // printf("Current pos1 %d", tmpcursor.pos()) ; tmpcursor.pos(tmpcursor.pos() + 1); ++steps; } // Advance through word. -#ifndef NEW_INSETS - while (tmpcursor.pos() < tmpcursor.par()->Last() && -#else while (tmpcursor.pos() < tmpcursor.par()->size() && -#endif - tmpcursor.par()->IsWord( tmpcursor.pos() ) ) - { + tmpcursor.par()->IsWord( tmpcursor.pos())) { // printf("Current pos2 %d", tmpcursor.pos()) ; tmpcursor.pos(tmpcursor.pos() + 1); ++steps; @@ -2477,19 +2098,11 @@ void LyXText::CursorRightOneWord(BufferView * bview) const void LyXText::CursorTab(BufferView * bview) const { LyXCursor tmpcursor = cursor; -#ifndef NEW_INSETS - while (tmpcursor.pos() < tmpcursor.par()->Last() -#else while (tmpcursor.pos() < tmpcursor.par()->size() -#endif && !tmpcursor.par()->IsNewline(tmpcursor.pos())) tmpcursor.pos(tmpcursor.pos() + 1); -#ifndef NEW_INSETS - if (tmpcursor.pos() == tmpcursor.par()->Last()){ -#else if (tmpcursor.pos() == tmpcursor.par()->size()){ -#endif if (tmpcursor.par()->next()) { tmpcursor.par(tmpcursor.par()->next()); tmpcursor.pos(0); @@ -2511,27 +2124,17 @@ void LyXText::CursorLeftOneWord(BufferView * bview) const && (tmpcursor.par()->IsSeparator(tmpcursor.pos() - 1) || tmpcursor.par()->IsKomma(tmpcursor.pos() - 1)) && !(tmpcursor.par()->IsHfill(tmpcursor.pos() - 1) -#ifndef NEW_INSETS - || tmpcursor.par()->IsFloat(tmpcursor.pos() - 1) -#endif || tmpcursor.par()->IsInset(tmpcursor.pos() - 1))) tmpcursor.pos(tmpcursor.pos() - 1); if (tmpcursor.pos() && (tmpcursor.par()->IsInset(tmpcursor.pos() - 1) -#ifndef NEW_INSETS - || tmpcursor.par()->IsFloat(tmpcursor.pos() - 1) -#endif || tmpcursor.par()->IsHfill(tmpcursor.pos() - 1))) { tmpcursor.pos(tmpcursor.pos() - 1); } else if (!tmpcursor.pos()) { if (tmpcursor.par()->previous()){ tmpcursor.par(tmpcursor.par()->previous()); -#ifndef NEW_INSETS - tmpcursor.pos(tmpcursor.par()->Last()); -#else tmpcursor.pos(tmpcursor.par()->size()); -#endif } } else { // Here, tmpcursor != 0 while (tmpcursor.pos() > 0 && @@ -2555,11 +2158,7 @@ void LyXText::SelectWord(BufferView * bview) // set the sel cursor sel_cursor = cursor; -#ifndef NEW_INSETS - while (cursor.pos() < cursor.par()->Last() -#else while (cursor.pos() < cursor.par()->size() -#endif && !cursor.par()->IsSeparator(cursor.pos()) && !cursor.par()->IsKomma(cursor.pos()) ) cursor.pos(cursor.pos() + 1); @@ -2577,11 +2176,7 @@ void LyXText::SelectWord(BufferView * bview) bool LyXText::SelectWordWhenUnderCursor(BufferView * bview) { if (!selection && -#ifndef NEW_INSETS - cursor.pos() > 0 && cursor.pos() < cursor.par()->Last() -#else cursor.pos() > 0 && cursor.pos() < cursor.par()->size() -#endif && !cursor.par()->IsSeparator(cursor.pos()) && !cursor.par()->IsKomma(cursor.pos()) && !cursor.par()->IsSeparator(cursor.pos() -1) @@ -2603,40 +2198,20 @@ 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. -#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()->size() && cursor.par()->IsLetter(cursor.pos())) cursor.pos(cursor.pos() + 1); } -#endif // Now, skip until we have real text (will jump paragraphs) -#ifndef NEW_INSETS - while ((cursor.par()->Last() > cursor.pos() -#else while ((cursor.par()->size() > cursor.pos() -#endif && (!cursor.par()->IsLetter(cursor.pos()) || cursor.par()->getFont(bview->buffer()->params, cursor.pos()) .latex() == LyXFont::ON)) -#ifndef NEW_INSETS - || (cursor.par()->Last() == cursor.pos() -#else || (cursor.par()->size() == cursor.pos() -#endif && cursor.par()->next())){ -#ifndef NEW_INSETS - if (cursor.pos() == cursor.par()->Last()) { -#else if (cursor.pos() == cursor.par()->size()) { -#endif cursor.par(cursor.par()->next()); cursor.pos(0); } else @@ -2656,11 +2231,7 @@ string const LyXText::SelectNextWord(BufferView * bview, // and find the end of the word // (optional hyphens are part of a word) -#ifndef NEW_INSETS - while (cursor.pos() < cursor.par()->Last() -#else while (cursor.pos() < cursor.par()->size() -#endif && (cursor.par()->IsLetter(cursor.pos())) || (cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET && cursor.par()->GetInset(cursor.pos()) != 0 @@ -2694,11 +2265,7 @@ void LyXText::SelectSelectedWord(BufferView * bview) std::ostringstream latex; // now find the end of the word -#ifndef NEW_INSETS - while (cursor.pos() < cursor.par()->Last() -#else while (cursor.pos() < cursor.par()->size() -#endif && (cursor.par()->IsLetter(cursor.pos()) || (cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET && cursor.par()->GetInset(cursor.pos()) != 0 @@ -2717,11 +2284,7 @@ void LyXText::SelectSelectedWord(BufferView * bview) /* -------> Delete from cursor up to the end of the current or next word. */ void LyXText::DeleteWordForward(BufferView * bview) { -#ifndef NEW_INSETS - if (!cursor.par()->Last()) -#else if (!cursor.par()->size()) -#endif CursorRight(bview); else { LyXCursor tmpcursor = cursor; @@ -2742,11 +2305,7 @@ void LyXText::DeleteWordForward(BufferView * bview) /* -------> Delete from cursor to start of current or prior word. */ void LyXText::DeleteWordBackward(BufferView * bview) { -#ifndef NEW_INSETS - if (!cursor.par()->Last()) -#else if (!cursor.par()->size()) -#endif CursorLeft(bview); else { LyXCursor tmpcursor = cursor; @@ -2765,11 +2324,7 @@ void LyXText::DeleteWordBackward(BufferView * bview) /* -------> Kill to end of line. */ void LyXText::DeleteLineForward(BufferView * bview) { -#ifndef NEW_INSETS - if (!cursor.par()->Last()) -#else if (!cursor.par()->size()) -#endif // Paragraph is empty, so we just go to the right CursorRight(bview); else { @@ -2802,22 +2357,12 @@ void LyXText::DeleteLineForward(BufferView * bview) // version did. (JMarc) void LyXText::ChangeWordCase(BufferView * bview, LyXText::TextCase action) { -#ifndef NEW_INSETS - LyXParagraph * tmppar = cursor.par()->ParFromPos(cursor.pos()); - - SetUndo(bview->buffer(),Undo::FINISH, - tmppar->previous_, tmppar->next_); - - 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); @@ -2884,13 +2429,8 @@ void LyXText::Delete(BufferView * bview) LyXCursor old_cursor = cursor; int const old_cur_par_id = old_cursor.par()->id(); -#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); @@ -2901,12 +2441,7 @@ 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 ( -#ifndef NEW_INSETS - (cursor.par()->previous_ ? cursor.par()->previous_->id() : 0) -#else - (cursor.par()->previous() ? cursor.par()->previous()->id() : 0) -#endif + if ((cursor.par()->previous() ? cursor.par()->previous()->id() : 0) == old_cur_par_prev_id && cursor.par()->id() != old_cur_par_id) return; // delete-empty-paragraph-mechanism has done it @@ -2916,14 +2451,8 @@ void LyXText::Delete(BufferView * bview) LyXCursor tmpcursor = cursor; 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_ -#else cursor.par()->previous(), - cursor.par()->next() -#endif - ); + cursor.par()->next()); cursor = tmpcursor; Backspace(bview); } @@ -2933,13 +2462,10 @@ void LyXText::Delete(BufferView * bview) void LyXText::Backspace(BufferView * bview) { // Get the font that is used to calculate the baselineskip -#ifndef NEW_INSETS - LyXParagraph::size_type lastpos = cursor.par()->Last(); -#else LyXParagraph::size_type lastpos = cursor.par()->size(); -#endif - LyXFont rawparfont = cursor.par()->GetFontSettings(bview->buffer()->params, - lastpos - 1); + LyXFont rawparfont = + cursor.par()->GetFontSettings(bview->buffer()->params, + lastpos - 1); if (cursor.pos() == 0) { // The cursor is at the beginning of a paragraph, @@ -2950,27 +2476,14 @@ void LyXText::Backspace(BufferView * bview) // is it an empty paragraph? if ((lastpos == 0 - || (lastpos == 1 && cursor.par()->IsSeparator(0))) -#ifndef NEW_INSETS - && !(cursor.par()->next() - && cursor.par()->footnoteflag == LyXParagraph::NO_FOOTNOTE - && cursor.par()->next()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) -#endif - ) { + || (lastpos == 1 && cursor.par()->IsSeparator(0)))) { // 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. -#ifndef NEW_INSETS - if (cursor.par()->previous_) { - LyXParagraph * tmppar = cursor.par()->previous_->FirstPhysicalPar(); - if (cursor.par()->GetLayout() == tmppar->GetLayout() - && 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. // (the one we are deleting) @@ -2993,19 +2506,11 @@ void LyXText::Backspace(BufferView * bview) } } -#ifndef NEW_INSETS - 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_); - } -#else if (cursor.par()->previous()) { SetUndo(bview->buffer(), Undo::DELETE, cursor.par()->previous()->previous(), cursor.par()->next()); } -#endif LyXParagraph * tmppar = cursor.par(); Row * tmprow = cursor.row(); @@ -3016,14 +2521,9 @@ void LyXText::Backspace(BufferView * bview) // without the dreaded mechanism. (JMarc) if (cursor.par()->previous()) { // steps into the above paragraph. -#ifndef NEW_INSETS - SetCursorIntern(bview, cursor.par()->previous(), - cursor.par()->previous()->Last(), false); -#else SetCursorIntern(bview, cursor.par()->previous(), cursor.par()->previous()->size(), false); -#endif } /* Pasting is not allowed, if the paragraphs have different @@ -3039,9 +2539,6 @@ void LyXText::Backspace(BufferView * bview) if (cursor.par() != tmppar && (cursor.par()->GetLayout() == tmppar->GetLayout() || tmppar->GetLayout() == 0 /*standard*/) -#ifndef NEW_INSETS - && cursor.par()->footnoteflag == tmppar->footnoteflag -#endif && cursor.par()->GetAlign() == tmppar->GetAlign()) { RemoveParagraph(tmprow); @@ -3080,14 +2577,8 @@ void LyXText::Backspace(BufferView * bview) /* this is the code for a normal backspace, not pasting * any paragraphs */ SetUndo(bview->buffer(), Undo::DELETE, -#ifndef NEW_INSETS - cursor.par()->ParFromPos(cursor.pos())->previous_, - cursor.par()->ParFromPos(cursor.pos())->next_ -#else cursor.par()->previous(), - cursor.par()->next() -#endif - ); + cursor.par()->next()); // We used to do CursorLeftIntern() here, but it is // not a good idea since it triggers the auto-delete // mechanism. So we do a CursorLeftIntern()-lite, @@ -3134,13 +2625,8 @@ void LyXText::Backspace(BufferView * bview) if (cursor.par()->IsLineSeparator(cursor.pos() - 1)) cursor.pos(cursor.pos() - 1); -#ifndef NEW_INSETS - if (cursor.pos() < cursor.par()->Last() - && !cursor.par()->IsSeparator(cursor.pos())) { -#else if (cursor.pos() < cursor.par()->size() && !cursor.par()->IsSeparator(cursor.pos())) { -#endif cursor.par()->InsertChar(cursor.pos(), ' '); SetCharFont(bview->buffer(), cursor.par(), cursor.pos(), current_font); @@ -3163,11 +2649,7 @@ void LyXText::Backspace(BufferView * bview) } // delete newlines at the beginning of paragraphs -#ifndef NEW_INSETS - while (cursor.par()->Last() && -#else while (cursor.par()->size() && -#endif cursor.par()->IsNewline(cursor.pos()) && cursor.pos() == BeginningOfMainBody(bview->buffer(), cursor.par())) { @@ -3192,11 +2674,7 @@ void LyXText::Backspace(BufferView * bview) Row * tmprow = row->previous(); // maybe the current row is now empty -#ifndef NEW_INSETS - if (row->pos() >= row->par()->Last()) { -#else if (row->pos() >= row->par()->size()) { -#endif // remove it RemoveRow(row); need_break_row = 0; @@ -3222,15 +2700,9 @@ void LyXText::Backspace(BufferView * bview) //current_font = rawtmpfont; //real_current_font = realtmpfont; // check, whether the last character's font has changed. -#ifndef NEW_INSETS - if (rawparfont != - cursor.par()->GetFontSettings(bview->buffer()->params, - cursor.par()->Last() - 1)) -#else if (rawparfont != cursor.par()->GetFontSettings(bview->buffer()->params, cursor.par()->size() - 1)) -#endif RedoHeightOfParagraph(bview, cursor); return; } @@ -3238,22 +2710,14 @@ void LyXText::Backspace(BufferView * bview) // break the cursor row again if (row->next() && row->next()->par() == row->par() && -#ifndef NEW_INSETS - (RowLast(row) == row->par()->Last() - 1 || -#else (RowLast(row) == row->par()->size() - 1 || -#endif NextBreakPoint(bview, row, workWidth(bview)) != RowLast(row))) { /* it can happen that a paragraph loses one row * without a real breakup. This is when a word * is to long to be broken. Well, I don t care this * hack ;-) */ -#ifndef NEW_INSETS - if (RowLast(row) == row->par()->Last() - 1) -#else if (RowLast(row) == row->par()->size() - 1) -#endif RemoveRow(row->next()); refresh_y = y; @@ -3297,11 +2761,7 @@ void LyXText::Backspace(BufferView * bview) SetCursor(bview, cursor.par(), cursor.pos(), false, !cursor.boundary()); -#ifndef NEW_INSETS - lastpos = cursor.par()->Last(); -#else lastpos = cursor.par()->size(); -#endif if (cursor.pos() == lastpos) SetCurrentFont(bview); @@ -3519,134 +2979,10 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, } int box_x = 0; -#ifndef NEW_INSETS - if (row_ptr->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) { - LyXFont font(LyXFont::ALL_SANE); - font.setSize(LyXFont::SIZE_FOOTNOTE); - font.setColor(LColor::footnote); - - box_x = LYX_PAPER_MARGIN + lyxfont::width(" wide-tab ", font); - if (row_ptr->previous() && - row_ptr->previous()->par()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE){ - string fs; - switch (row_ptr->par()->footnotekind) { - case LyXParagraph::MARGIN: - fs = " margin"; - break; - case LyXParagraph::FIG: - fs = " fig"; - break; - case LyXParagraph::TAB: - fs = " tab"; - break; - case LyXParagraph::WIDE_FIG: - fs = " wide-fig"; - break; - case LyXParagraph::WIDE_TAB: - fs = " wide-tab"; - break; - case LyXParagraph::ALGORITHM: - fs = " alg"; - break; - case LyXParagraph::FOOTNOTE: - fs = " foot"; - break; - } - - pain.fillRectangle(LYX_PAPER_MARGIN, - y_offset + 1, - box_x - LYX_PAPER_MARGIN, - int(lyxfont::maxAscent(font) - + lyxfont::maxDescent(font)), - LColor::footnotebg); - - pain.line(LYX_PAPER_MARGIN, y_offset, - workWidth(bview) - LYX_PAPER_MARGIN, y_offset, - LColor::footnoteframe); - - pain.text(LYX_PAPER_MARGIN, - y_offset + int(lyxfont::maxAscent(font)) + 1, - fs, font); - - pain.line(LYX_PAPER_MARGIN, y_offset, - LYX_PAPER_MARGIN, - y_offset + int(lyxfont::maxAscent(font) - + lyxfont::maxDescent(font)), - LColor::footnoteframe); - - pain.line(LYX_PAPER_MARGIN, - y_offset + int(lyxfont::maxAscent(font) - + lyxfont::maxDescent(font)) + 1, - box_x, - y_offset + int(lyxfont::maxAscent(font) - + lyxfont::maxDescent(font)) + 1, - LColor::footnoteframe); - - } - - /* draw the open floats in a red box */ - pain.line(box_x, y_offset, - box_x, y_offset + row_ptr->height(), - LColor::footnoteframe); - - pain.line(workWidth(bview) - LYX_PAPER_MARGIN, - y_offset, - workWidth(bview) - LYX_PAPER_MARGIN, - y_offset + row_ptr->height(), - LColor::footnoteframe); - - // Draw appendix lines - LyXParagraph * p = row_ptr->par()->PreviousBeforeFootnote()->FirstPhysicalPar(); - if (p->params.appendix()) { - pain.line(1, y_offset, - 1, y_offset + row_ptr->height(), - LColor::appendixline); - pain.line(workWidth(bview) - 2, y_offset, - workWidth(bview) - 2, - y_offset + row_ptr->height(), - LColor::appendixline); - } - -#ifndef NO_PEXTRA - // Draw minipage line - bool const minipage = - (p->params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE); - if (minipage) - pain.line(LYX_PAPER_MARGIN/5, y_offset, - LYX_PAPER_MARGIN/5, - y_offset + row_ptr->height() - 1, - LColor::minipageline); -#endif - // Draw depth lines - int const depth = p->GetDepth(); - for (int i = 1; i <= depth; ++i) { - int const line_x = (LYX_PAPER_MARGIN / 5) * - (i + minipage); - pain.line(line_x, y_offset, line_x, - y_offset + row_ptr->height() - 1, - LColor::depthbar); - } - } else if (row_ptr->previous() && - row_ptr->previous()->par()->footnoteflag - == LyXParagraph::OPEN_FOOTNOTE) { - LyXFont font(LyXFont::ALL_SANE); - font.setSize(LyXFont::SIZE_FOOTNOTE); - - int const box_x = LYX_PAPER_MARGIN - + lyxfont::width(" wide-tab ", font); - - pain.line(box_x, y_offset, - workWidth(bview) - LYX_PAPER_MARGIN, - y_offset, LColor::footnote); - } -#endif // Draw appendix lines -#ifndef NEW_INSETS - LyXParagraph * firstpar = row_ptr->par()->FirstPhysicalPar(); -#else LyXParagraph * firstpar = row_ptr->par(); -#endif + if (firstpar->params.appendix()) { pain.line(1, y_offset, 1, y_offset + row_ptr->height(), @@ -3655,49 +2991,20 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, ww - 2, y_offset + row_ptr->height(), LColor::appendixline); } -#ifndef NO_PEXTRA - // Draw minipage line - bool const minipage = - (firstpar->params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE); - if (minipage) - pain.line(LYX_PAPER_MARGIN/5 + box_x, y_offset, - LYX_PAPER_MARGIN/5 + box_x, - y_offset + row_ptr->height() - 1, - LColor::minipageline); -#endif + // Draw depth lines int const depth = firstpar->GetDepth(); if (depth > 0) { int next_depth = 0; int prev_depth = 0; if (row_ptr->next()) -#ifndef NEW_INSETS - if (row_ptr->par()->footnoteflag == - row_ptr->next()->par()->footnoteflag) - next_depth = row_ptr->next()->par()->GetDepth(); - else if (row_ptr->par()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) - next_depth = depth; -#else next_depth = row_ptr->next()->par()->GetDepth(); -#endif if (row_ptr->previous()) -#ifndef NEW_INSETS - if (row_ptr->par()->footnoteflag == - row_ptr->previous()->par()->footnoteflag) - prev_depth = row_ptr->previous()->par()->GetDepth(); - else if (row_ptr->par()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) - prev_depth = depth; -#else prev_depth = row_ptr->previous()->par()->GetDepth(); -#endif for (int i = 1; i <= depth; ++i) { int const line_x = (LYX_PAPER_MARGIN / 5) * - (i -#ifndef NO_PEXTRA - + minipage -#endif - ) + box_x + x_offset; + i + box_x + x_offset; pain.line(line_x, y_offset, line_x, y_offset + row_ptr->height() - 1 - (i - next_depth - 1) * 3, LColor::depthbar); @@ -3855,13 +3162,6 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, if (is_rtl) { tmpx = ww - LeftMargin(bview, row_ptr) + lyxfont::width(layout.labelsep, font); -#ifndef NEW_INSETS - if (row_ptr->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) { - LyXFont font(LyXFont::ALL_SANE); - font.setSize(LyXFont::SIZE_SMALL); - tmpx += lyxfont::width("Mwide-fixM", font); - } -#endif } else tmpx = x - lyxfont::width(layout.labelsep, font) - lyxfont::width(tmpstring, font); @@ -3924,20 +3224,10 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, } // is it a last row? -#ifndef NEW_INSETS - LyXParagraph * par = row_ptr->par()->LastPhysicalPar(); -#else LyXParagraph * par = row_ptr->par(); -#endif - if ( -#ifndef NEW_INSETS - row_ptr->par()->ParFromPos(last + 1) == par -#else - row_ptr->par() == par -#endif - && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par())) - { - // think about the margins + if (row_ptr->par() == par + && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par())) { + // think about the margins if (!row_ptr->next() && bv_owner) y_bottom -= LYX_PAPER_MARGIN; @@ -3993,17 +3283,10 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, if (firstpar->params.lineBottom()) { // draw a bottom line -#ifndef NEW_INSETS - y_bottom -= lyxfont::ascent('x', - GetFont(bview->buffer(), - par, - par->Last() - 1)); -#else y_bottom -= lyxfont::ascent('x', GetFont(bview->buffer(), par, par->size() - 1)); -#endif int const w = (inset_owner ? inset_owner->width(bview, font) : ww); int const xp = static_cast(inset_owner ? x : 0); @@ -4011,17 +3294,10 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, w, y_offset + y_bottom, LColor::topline, Painter::line_solid, Painter::line_thick); -#ifndef NEW_INSETS - y_bottom -= lyxfont::ascent('x', - GetFont(bview->buffer(), - par, - par->Last() - 1)); -#else y_bottom -= lyxfont::ascent('x', GetFont(bview->buffer(), par, par->size() - 1)); -#endif } // draw an endlabel @@ -4037,15 +3313,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, int const y = (y_offset + row_ptr->baseline()) - size; int x = is_rtl ? LYX_PAPER_MARGIN : ww - LYX_PAPER_MARGIN - size; -#ifndef NEW_INSETS - if (row_ptr->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) - if (is_rtl) { - LyXFont font(LyXFont::ALL_SANE); - font.setSize(LyXFont::SIZE_SMALL); - x += lyxfont::width("Mwide-figM", font); - } else - x -= LYX_PAPER_MARGIN/2; -#endif + if (row_ptr->fill() <= size) x += (size - row_ptr->fill() + 1) * (is_rtl ? -1 : 1); if (endlabel == END_LABEL_BOX) { @@ -4264,147 +3532,6 @@ int LyXText::GetColumnNearX(BufferView * bview, Row * row, int & x, } -#ifndef NEW_INSETS -/* turn the selection into a new environment. If there is no selection, -* create an empty environment */ -void LyXText::InsertFootnoteEnvironment(BufferView * bview, - LyXParagraph::footnote_kind kind) -{ - /* no footnoteenvironment in a footnoteenvironment */ - if (cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) { - WriteAlert(_("Impossible operation"), - _("You can't insert a float in a float!"), - _("Sorry.")); - return; - } -#ifndef NO_PEXTRA - /* no marginpars in minipages */ - if (kind == LyXParagraph::MARGIN - && cursor.par()->params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE) { - WriteAlert(_("Impossible operation"), - _("You can't insert a marginpar in a minipage!"), - _("Sorry.")); - return; - } -#endif - /* this doesnt make sense, if there is no selection */ - bool dummy_selection = false; - if (!selection) { - sel_start_cursor = cursor; /* dummy selection */ - sel_end_cursor = cursor; - dummy_selection = true; - } - - LyXParagraph * tmppar; - - /* a test to make sure there is not already a footnote - * in the selection. */ - - tmppar = sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos()); - - while (tmppar != sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos()) && - tmppar->footnoteflag == LyXParagraph::NO_FOOTNOTE) - tmppar = tmppar->next_; - - if (tmppar != sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos()) - || tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE) { - WriteAlert(_("Impossible operation"), - _("Float would include float!"), - _("Sorry.")); - return; - } - - /* ok we have a selection. This is always between sel_start_cursor - * 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_); - - if (sel_end_cursor.pos() > 0 - && sel_end_cursor.par()->IsLineSeparator(sel_end_cursor.pos() - 1)) - sel_end_cursor.pos(sel_end_cursor.pos() - 1); - /* please break before a space at the end */ - if (sel_start_cursor.par() == sel_end_cursor.par() - && sel_start_cursor.pos() > sel_end_cursor.pos()) - sel_start_cursor.pos(sel_start_cursor.pos() - 1); - - sel_end_cursor.par()->BreakParagraphConservative(bview->buffer()->params, sel_end_cursor.pos()); - - 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_); - } - else - sel_end_cursor.par()->layout = LYX_DUMMY_LAYOUT; - - cursor = sel_end_cursor; - - /* please break behind a space, if there is one. The space should - * be erased too */ - if (sel_start_cursor.pos() > 0 - && sel_start_cursor.par()->IsLineSeparator(sel_start_cursor.pos() - 1)) - sel_start_cursor.pos(sel_start_cursor.pos() - 1); - if (sel_start_cursor.par()->IsLineSeparator(sel_start_cursor.pos())) { - sel_start_cursor.par()->Erase(sel_start_cursor.pos()); - } - - sel_start_cursor.par()->BreakParagraphConservative(bview->buffer()->params, - sel_start_cursor.pos()); - tmppar = sel_start_cursor.par()->next(); - - if (dummy_selection) { - tmppar->Clear(); - if (kind == LyXParagraph::TAB - || kind == LyXParagraph::FIG - || kind == LyXParagraph::WIDE_TAB - || kind == LyXParagraph::WIDE_FIG - || kind == LyXParagraph::ALGORITHM) { - pair lres = - textclasslist.NumberOfLayout(bview->buffer()->params.textclass, - "Caption"); - LyXTextClass::size_type lay; - if (lres.first) { - // layout fount - lay = lres.second; - } else { - // layout not found - lay = 0; // use default layout "Standard" (0) - } - tmppar->SetLayout(bview->buffer()->params, lay); - } - } else { - if (sel_start_cursor.pos() > 0) { - /* the footnote-environment should begin with a standard layout. - * Imagine you insert a footnote within an enumeration, you - * certainly do not want an enumerated footnote! */ - tmppar->Clear(); - } else { - /* this is a exception the user would sometimes expect, I hope */ - sel_start_cursor.par()->Clear(); - } - } - - while (tmppar != sel_end_cursor.par()) { - tmppar->footnoteflag = LyXParagraph::OPEN_FOOTNOTE; - tmppar->footnotekind = kind; - tmppar = tmppar->next(); - } - - RedoParagraphs(bview, sel_start_cursor, sel_end_cursor.par()->next()); - - SetCursor(bview, sel_start_cursor.par()->next(), 0); - - ClearSelection(bview); -} -#endif - - // returns pointer to a specified row Row * LyXText::GetRow(LyXParagraph * par, LyXParagraph::size_type pos, int & y) const diff --git a/src/text2.C b/src/text2.C index c8bb54bd07..d1ec3e1612 100644 --- a/src/text2.C +++ b/src/text2.C @@ -182,11 +182,7 @@ LyXFont const LyXText::GetFont(Buffer const * buf, LyXParagraph * par, char par_depth = par->GetDepth(); // We specialize the 95% common case: - if ( -#ifndef NEW_INSETS - par->footnoteflag == LyXParagraph::NO_FOOTNOTE && -#endif - !par_depth) { + if (!par_depth) { if (pos >= 0){ // 95% goes here if (layout.labeltype == LABEL_MANUAL @@ -247,14 +243,6 @@ LyXFont const LyXText::GetFont(Buffer const * buf, LyXParagraph * par, tmpfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont()); -#ifndef NEW_INSETS - // Cosmetic improvement: If this is an open footnote, make the font - // smaller. - if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE - && par->footnotekind == LyXParagraph::FOOTNOTE) { - tmpfont.decSize(); - } -#endif return tmpfont; } @@ -296,12 +284,6 @@ void LyXText::SetCharFont(Buffer const * buf, LyXParagraph * par, layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont()); -#ifndef NEW_INSETS - if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE - && par->footnotekind == LyXParagraph::FOOTNOTE) { - layoutfont.decSize(); - } -#endif // Now, reduce font against full layout font font.reduce(layoutfont); @@ -402,118 +384,6 @@ void LyXText::InsertParagraph(BufferView * bview, LyXParagraph * par, } -#ifndef NEW_INSETS -void LyXText::ToggleFootnote(BufferView * bview) -{ - LyXParagraph * par = cursor.par()->ParFromPos(cursor.pos()); - if (par->next_ - && par->next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) { - OpenFootnote(bview); - bview->owner()->getMiniBuffer()->Set(_("Opened float")); - } else { - bview->owner()->getMiniBuffer()->Set(_("Closed float")); - CloseFootnote(bview); - } -} -#endif - - -#ifndef NEW_INSETS -void LyXText::OpenStuff(BufferView * bview) -{ - if (cursor.pos() == 0 && cursor.par()->bibkey){ - cursor.par()->bibkey->Edit(bview, 0, 0, 0); - } else if (cursor.pos() < cursor.par()->Last() - && cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET - && cursor.par()->GetInset(cursor.pos())->Editable()) { - bview->owner()->getMiniBuffer() - ->Set(cursor.par()->GetInset(cursor.pos())->EditMessage()); - if (cursor.par()->GetInset(cursor.pos())->Editable() != Inset::HIGHLY_EDITABLE) - SetCursorParUndo(bview->buffer()); - cursor.par()->GetInset(cursor.pos())->Edit(bview, 0, 0, 0); - } -#ifndef NEW_INSETS - else { - ToggleFootnote(bview); - } -#endif -} -#endif - - -#ifndef NEW_INSETS -void LyXText::CloseFootnote(BufferView * bview) -{ - LyXParagraph * tmppar; - LyXParagraph * par = cursor.par()->ParFromPos(cursor.pos()); - - // if the cursor is not in an open footnote, or - // 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) { - bview->owner()->getMiniBuffer() - ->Set(_("Nothing to do")); - return; - } - - // ok, move the cursor right before the footnote - // just a little faster than using CursorRight() - for (cursor.pos(0); - cursor.par()->ParFromPos(cursor.pos()) != par;) { - cursor.pos(cursor.pos() + 1); - } - - // now the cursor is at the beginning of the physical par - SetCursor(bview, cursor.par(), - cursor.pos() + - cursor.par()->ParFromPos(cursor.pos())->size()); - } else { - /* we are in a footnote, so let us move at the beginning */ - /* this is just faster than using just CursorLeft() */ - - tmppar = cursor.par(); - while (tmppar->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) { - // just a little bit faster than movin the cursor - tmppar = tmppar->previous(); - } - SetCursor(bview, tmppar, tmppar->Last()); - } - - // the cursor must be exactly before the footnote - par = cursor.par()->ParFromPos(cursor.pos()); - - status = LyXText::NEED_MORE_REFRESH; - refresh_row = cursor.row(); - refresh_y = cursor.y() - cursor.row()->baseline(); - - tmppar = cursor.par(); - LyXParagraph * endpar = par->NextAfterFootnote()->next(); - Row * row = cursor.row(); - - tmppar->CloseFootnote(cursor.pos()); - - while (tmppar != endpar) { - RemoveRow(row->next()); - if (row->next()) - tmppar = row->next()->par(); - else - tmppar = 0; - } - - AppendParagraph(bview, cursor.row()); - - SetCursor(bview, cursor.par(), cursor.pos()); - sel_cursor = cursor; - - // just necessary - if (cursor.row()->next()) - SetHeightOfRow(bview, cursor.row()->next()); -} -#endif - - /* used in setlayout */ // Asger is not sure we want to do this... void LyXText::MakeFontEntriesLayoutSpecific(Buffer const * buf, @@ -525,11 +395,7 @@ void LyXText::MakeFontEntriesLayoutSpecific(Buffer const * buf, LyXFont layoutfont, tmpfont; for (LyXParagraph::size_type pos = 0; -#ifndef NEW_INSETS - pos < par->Last(); ++pos) { -#else pos < par->size(); ++pos) { -#endif if (pos < BeginningOfMainBody(buf, par)) layoutfont = layout.labelfont; else @@ -542,73 +408,6 @@ void LyXText::MakeFontEntriesLayoutSpecific(Buffer const * buf, } -#ifndef NEW_INSETS -LyXParagraph * LyXText::SetLayout(BufferView * bview, - LyXCursor & cur, LyXCursor & sstart_cur, - LyXCursor & send_cur, - LyXTextClass::size_type layout) -{ - LyXParagraph * endpar = send_cur.par()->LastPhysicalPar()->next(); - LyXParagraph * undoendpar = endpar; - - if (endpar && endpar->GetDepth()) { - while (endpar && endpar->GetDepth()) { - endpar = endpar->LastPhysicalPar()->next(); - undoendpar = endpar; - } - } else if (endpar) { - endpar = endpar->next(); // because of parindents etc. - } - - SetUndo(bview->buffer(), Undo::EDIT, - sstart_cur.par()->ParFromPos(sstart_cur.pos())->previous_, - undoendpar); - - /* ok we have a selection. This is always between sstart_cur - * and sel_end cursor */ - cur = sstart_cur; - - LyXLayout const & lyxlayout = - textclasslist.Style(bview->buffer()->params.textclass, layout); - - while (cur.par() != send_cur.par()) { - if (cur.par()->footnoteflag == sstart_cur.par()->footnoteflag) { - cur.par()->SetLayout(bview->buffer()->params, layout); - MakeFontEntriesLayoutSpecific(bview->buffer(), cur.par()); - LyXParagraph * fppar = cur.par()->FirstPhysicalPar(); - fppar->params.spaceTop(lyxlayout.fill_top ? - VSpace(VSpace::VFILL) : VSpace(VSpace::NONE)); - fppar->params.spaceBottom(lyxlayout.fill_bottom ? - VSpace(VSpace::VFILL) : VSpace(VSpace::NONE)); - if (lyxlayout.margintype == MARGIN_MANUAL) - cur.par()->SetLabelWidthString(lyxlayout.labelstring()); - if (lyxlayout.labeltype != LABEL_BIBLIO - && fppar->bibkey) { - delete fppar->bibkey; - fppar->bibkey = 0; - } - } - cur.par(cur.par()->next()); - } - if (cur.par()->footnoteflag == sstart_cur.par()->footnoteflag) { - cur.par()->SetLayout(bview->buffer()->params, layout); - MakeFontEntriesLayoutSpecific(bview->buffer(), cur.par()); - LyXParagraph * fppar = cur.par()->FirstPhysicalPar(); - fppar->params.spaceTop(lyxlayout.fill_top ? - VSpace(VSpace::VFILL) : VSpace(VSpace::NONE)); - fppar->params.spaceBottom(lyxlayout.fill_bottom ? - VSpace(VSpace::VFILL) : VSpace(VSpace::NONE)); - if (lyxlayout.margintype == MARGIN_MANUAL) - cur.par()->SetLabelWidthString(lyxlayout.labelstring()); - if (lyxlayout.labeltype != LABEL_BIBLIO - && fppar->bibkey) { - delete fppar->bibkey; - fppar->bibkey = 0; - } - } - return endpar; -} -#else LyXParagraph * LyXText::SetLayout(BufferView * bview, LyXCursor & cur, LyXCursor & sstart_cur, LyXCursor & send_cur, @@ -672,7 +471,6 @@ LyXParagraph * LyXText::SetLayout(BufferView * bview, } return endpar; } -#endif // set layout over selection and make a total rebreak of those paragraphs @@ -716,21 +514,13 @@ 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(); -#else - sel_end_cursor.par()->next(); -#endif + LyXParagraph * endpar = sel_end_cursor.par()->next(); + LyXParagraph * undoendpar = endpar; if (endpar && endpar->GetDepth()) { while (endpar && endpar->GetDepth()) { -#ifndef NEW_INSETS - endpar = endpar->LastPhysicalPar()->next(); -#else endpar = endpar->next(); -#endif undoendpar = endpar; } } @@ -739,12 +529,7 @@ void LyXText::IncDepth(BufferView * bview) } SetUndo(bview->buffer(), Undo::EDIT, -#ifndef NEW_INSETS - sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous_, -#else sel_start_cursor.par()->previous(), -#endif undoendpar); LyXCursor tmpcursor = cursor; // store the current cursor @@ -758,29 +543,17 @@ void LyXText::IncDepth(BufferView * bview) while (true) { // NOTE: you can't change the depth of a bibliography entry if ( -#ifndef NEW_INSETS - cursor.par()->footnoteflag == - sel_start_cursor.par()->footnoteflag && -#endif textclasslist.Style(bview->buffer()->params.textclass, cursor.par()->GetLayout() ).labeltype != LABEL_BIBLIO) { - LyXParagraph * prev = -#ifndef NEW_INSETS - cursor.par()->FirstPhysicalPar()->previous(); -#else - cursor.par()->previous(); -#endif + LyXParagraph * prev = cursor.par()->previous(); + if (prev && (prev->GetDepth() - cursor.par()->GetDepth() > 0 || (prev->GetDepth() == cursor.par()->GetDepth() && textclasslist.Style(bview->buffer()->params.textclass, prev->GetLayout()).isEnvironment()))) { -#ifndef NEW_INSETS - cursor.par()->FirstPhysicalPar()->params.depth(cursor.par()->FirstPhysicalPar()->params.depth() + 1); -#else cursor.par()->params.depth(cursor.par()->params.depth() + 1); -#endif anything_changed = true; } } @@ -793,19 +566,10 @@ void LyXText::IncDepth(BufferView * bview) if (!anything_changed) { cursor = sel_start_cursor; while (cursor.par() != sel_end_cursor.par()) { -#ifndef NEW_INSETS - cursor.par()->FirstPhysicalPar()->params.depth(0); -#else cursor.par()->params.depth(0); -#endif cursor.par(cursor.par()->next()); } -#ifndef NEW_INSETS - if (cursor.par()->footnoteflag == sel_start_cursor.par()->footnoteflag) - cursor.par()->FirstPhysicalPar()->params.depth(0); -#else - cursor.par()->params.depth(0); -#endif + cursor.par()->params.depth(0); } RedoParagraphs(bview, sel_start_cursor, endpar); @@ -833,20 +597,12 @@ void LyXText::DecDepth(BufferView * bview) sel_start_cursor = cursor; // dummy selection sel_end_cursor = cursor; } -#ifndef NEW_INSETS - LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->next(); -#else 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(); -#else endpar = endpar->next(); -#endif undoendpar = endpar; } } @@ -855,12 +611,7 @@ void LyXText::DecDepth(BufferView * bview) } SetUndo(bview->buffer(), Undo::EDIT, -#ifndef NEW_INSETS - sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous_, -#else sel_start_cursor.par()->previous(), -#endif undoendpar); LyXCursor tmpcursor = cursor; // store the current cursor @@ -870,16 +621,8 @@ void LyXText::DecDepth(BufferView * bview) cursor = sel_start_cursor; while (true) { -#ifndef NEW_INSETS - if (cursor.par()->footnoteflag == - sel_start_cursor.par()->footnoteflag) { - if (cursor.par()->FirstPhysicalPar()->params.depth()) - cursor.par()->FirstPhysicalPar()->params.depth(cursor.par()->FirstPhysicalPar()->params.depth() - 1); - } -#else - if (cursor.par()->params.depth()) - cursor.par()->params.depth(cursor.par()->params.depth() - 1); -#endif + if (cursor.par()->params.depth()) + cursor.par()->params.depth(cursor.par()->params.depth() - 1); if (cursor.par() == sel_end_cursor.par()) break; cursor.par(cursor.par()->next()); @@ -931,30 +674,12 @@ void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall) // and sel_end cursor 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_ -#else sel_start_cursor.par()->previous(), - sel_end_cursor.par()->next() -#endif - ); + sel_end_cursor.par()->next()); cursor = sel_start_cursor; while (cursor.par() != sel_end_cursor.par() || - ( -#ifndef NEW_INSETS - cursor.par()->footnoteflag == sel_start_cursor.par()->footnoteflag && -#endif - cursor.pos() < sel_end_cursor.pos())) - { -#ifndef NEW_INSETS - if (cursor.pos() < cursor.par()->Last() - && cursor.par()->footnoteflag - == sel_start_cursor.par()->footnoteflag -#else - if (cursor.pos() < cursor.par()->size() -#endif - ) { + (cursor.pos() < sel_end_cursor.pos())) { + if (cursor.pos() < cursor.par()->size()) { // an open footnote should behave // like a closed one LyXFont newfont = GetFont(bview->buffer(), @@ -991,11 +716,8 @@ void LyXText::RedoHeightOfParagraph(BufferView * bview, LyXCursor const & cur) int y = cur.y() - tmprow->baseline(); SetHeightOfRow(bview, tmprow); -#ifndef NEW_INSETS - LyXParagraph * first_phys_par = tmprow->par()->FirstPhysicalPar(); -#else LyXParagraph * first_phys_par = tmprow->par(); -#endif + // find the first row of the paragraph if (first_phys_par != tmprow->par()) while (tmprow->previous() @@ -1024,11 +746,8 @@ void LyXText::RedoDrawingOfParagraph(BufferView * bview, LyXCursor const & cur) int y = cur.y() - tmprow->baseline(); SetHeightOfRow(bview, tmprow); -#ifndef NEW_INSETS - LyXParagraph * first_phys_par = tmprow->par()->FirstPhysicalPar(); -#else LyXParagraph * first_phys_par = tmprow->par(); -#endif + // find the first row of the paragraph if (first_phys_par != tmprow->par()) while (tmprow->previous() && tmprow->previous()->par() != first_phys_par) { @@ -1066,11 +785,7 @@ void LyXText::RedoParagraphs(BufferView * bview, LyXCursor const & cur, if (!tmprow->previous()){ first_phys_par = FirstParagraph(); // a trick/hack for UNDO } else { -#ifndef NEW_INSETS - first_phys_par = tmprow->par()->FirstPhysicalPar(); -#else first_phys_par = tmprow->par(); -#endif // find the first row of the paragraph if (first_phys_par != tmprow->par()) while (tmprow->previous() && @@ -1232,27 +947,16 @@ string const LyXText::selectionAsString(Buffer const * buffer) const // The selection spans more than one paragraph // First paragraph in selection -#ifndef NEW_INSETS - result += sel_start_cursor.par()->String(buffer, - sel_start_cursor.pos(), - sel_start_cursor.par()->Last()) - + "\n\n"; -#else result += sel_start_cursor.par()->String(buffer, sel_start_cursor.pos(), sel_start_cursor.par()->size()) + "\n\n"; -#endif // The paragraphs in between (if any) LyXCursor tmpcur(sel_start_cursor); tmpcur.par(tmpcur.par()->next()); while (tmpcur.par() != sel_end_cursor.par()) { -#ifndef NEW_INSETS - result += tmpcur.par()->String(buffer, 0, tmpcur.par()->Last()) + "\n\n"; -#else result += tmpcur.par()->String(buffer, 0, tmpcur.par()->size()) + "\n\n"; -#endif tmpcur.par(tmpcur.par()->next()); // Or NextAfterFootnote?? } @@ -1281,11 +985,7 @@ void LyXText::CursorEnd(BufferView * bview) const if (!cursor.row()->next() || cursor.row()->next()->par() != cursor.row()->par()) SetCursor(bview, cursor.par(), RowLast(cursor.row()) + 1); else { -#ifndef NEW_INSETS - if (cursor.par()->Last() && -#else if (cursor.par()->size() && -#endif (cursor.par()->GetChar(RowLast(cursor.row())) == ' ' || cursor.par()->IsNewline(RowLast(cursor.row())))) SetCursor(bview, cursor.par(), RowLast(cursor.row())); @@ -1295,7 +995,7 @@ void LyXText::CursorEnd(BufferView * bview) const } -void LyXText::CursorTop(BufferView * bview) const +void LyXText::CursorTop(BufferView * bview) const { while (cursor.par()->previous()) cursor.par(cursor.par()->previous()); @@ -1303,15 +1003,11 @@ void LyXText::CursorTop(BufferView * bview) const } -void LyXText::CursorBottom(BufferView * bview) const +void LyXText::CursorBottom(BufferView * bview) const { while (cursor.par()->next()) cursor.par(cursor.par()->next()); -#ifndef NEW_INSETS - SetCursor(bview, cursor.par(), cursor.par()->Last()); -#else SetCursor(bview, cursor.par(), cursor.par()->size()); -#endif } @@ -1361,104 +1057,6 @@ LyXText::BeginningOfMainBody(Buffer const * buf, } -#ifndef NEW_INSETS -/* if there is a selection, reset every environment you can find -* in the selection, otherwise just the environment you are in */ -void LyXText::MeltFootnoteEnvironment(BufferView * bview) -{ - LyXParagraph * tmppar, * firsttmppar; - - ClearSelection(bview); - - /* is is only allowed, if the cursor is IN an open footnote. - * Otherwise it is too dangerous */ - if (cursor.par()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE) - return; - - SetUndo(bview->buffer(), Undo::FINISH, - 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()); - - SetCursor(bview, cursor.par(), cursor.par()->Last()); - /* this is just faster than using CursorLeft(); */ - - firsttmppar = cursor.par()->ParFromPos(cursor.pos()); - tmppar = firsttmppar; - /* tmppar is now the paragraph right before the footnote */ - - 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(), - * because there cannot be any - * footnotes in a footnote - * environment */ - tmppar->footnoteflag = LyXParagraph::NO_FOOTNOTE; - - /* remember the captions and empty paragraphs */ - if ((textclasslist.Style(bview->buffer()->params.textclass, - tmppar->GetLayout()) - .labeltype == LABEL_SENSITIVE) - || !tmppar->Last()) - tmppar->SetLayout(bview->buffer()->params, 0); - } - - // 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()); - - // 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->PasteParagraph(bview->buffer()->params); - } - - 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->size() - && !firsttmppar->IsSeparator(firsttmppar->size() - 1) - && first_footnote_par_is_not_empty) { - firsttmppar->next_->InsertChar(0, ' '); - } - firsttmppar->PasteParagraph(bview->buffer()->params); - } - - /* now redo the paragaphs */ - RedoParagraphs(bview, cursor, tmppar); - - SetCursor(bview, cursor.par(), cursor.pos()); - - /* sometimes it can happen, that there is a counter change */ - Row * row = cursor.row(); - while (row->next() && row->par() != tmppar && row->next()->par() != tmppar) - row = row->next(); - UpdateCounters(bview, row); - - - ClearSelection(bview); -} -#endif - - /* the DTP switches for paragraphs. LyX will store them in the * first physicla paragraph. When a paragraph is broken, the top settings * rest, the bottom settings are given to the new one. So I can make shure, @@ -1481,20 +1079,12 @@ 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(); -#else 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(); -#else endpar = endpar->next(); -#endif undoendpar = endpar; } } @@ -1503,30 +1093,16 @@ void LyXText::SetParagraph(BufferView * bview, } SetUndo(bview->buffer(), Undo::EDIT, -#ifndef NEW_INSETS - sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous_, -#else sel_start_cursor.par()->previous(), -#endif undoendpar); LyXParagraph * tmppar = sel_end_cursor.par(); -#ifndef NEW_INSETS - while (tmppar != sel_start_cursor.par()->FirstPhysicalPar()->previous()) { - SetCursor(bview, tmppar->FirstPhysicalPar(), 0); -#else while (tmppar != sel_start_cursor.par()->previous()) { SetCursor(bview, tmppar, 0); -#endif status = LyXText::NEED_MORE_REFRESH; refresh_row = cursor.row(); refresh_y = cursor.y() - cursor.row()->baseline(); -#ifndef NEW_INSETS - if (cursor.par()->footnoteflag == - sel_start_cursor.par()->footnoteflag) { -#endif cursor.par()->params.lineTop(line_top); cursor.par()->params.lineBottom(line_bottom); cursor.par()->params.pagebreakTop(pagebreak_top); @@ -1550,13 +1126,7 @@ void LyXText::SetParagraph(BufferView * bview, } cursor.par()->SetLabelWidthString(labelwidthstring); cursor.par()->params.noindent(noindent); -#ifndef NEW_INSETS - } - - tmppar = cursor.par()->FirstPhysicalPar()->previous(); -#else tmppar = cursor.par()->previous(); -#endif } RedoParagraphs(bview, sel_start_cursor, endpar); @@ -1572,98 +1142,6 @@ void LyXText::SetParagraph(BufferView * bview, } -#ifndef NO_PEXTRA -void LyXText::SetParagraphExtraOpt(BufferView * bview, int type, - string const & width, - string const & widthp, - int alignment, bool hfill, - bool start_minipage) -{ - LyXCursor tmpcursor = cursor; - LyXParagraph * tmppar; - if (!selection) { - sel_start_cursor = cursor; - sel_end_cursor = cursor; - } - - // make sure that the depth behind the selection are restored, too -#ifndef NEW_INSETS - LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->next(); -#else - 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(); -#else - endpar = endpar->next(); -#endif - undoendpar = endpar; - } - } - else if (endpar) { - 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_, -#else - sel_start_cursor.par()->previous(), -#endif - undoendpar); - - tmppar = sel_end_cursor.par(); -#ifndef NEW_INSETS - while(tmppar != sel_start_cursor.par()->FirstPhysicalPar()->previous()) { - SetCursor(bview, tmppar->FirstPhysicalPar(), 0); -#else - while(tmppar != sel_start_cursor.par()->previous()) { - SetCursor(bview, tmppar, 0); -#endif - status = LyXText::NEED_MORE_REFRESH; - refresh_row = cursor.row(); - refresh_y = cursor.y() - cursor.row()->baseline(); -#ifndef NEW_INSETS - if (cursor.par()->footnoteflag == - sel_start_cursor.par()->footnoteflag) { -#endif -#ifndef NO_PEXTRA - if (type == LyXParagraph::PEXTRA_NONE) { - if (cursor.par()->params.pextraType() != LyXParagraph::PEXTRA_NONE) { - cursor.par()->UnsetPExtraType(bview->buffer()->params); - cursor.par()->params.pextraType(LyXParagraph::PEXTRA_NONE); - } - } else { - cursor.par()->SetPExtraType(bview->buffer()->params, - type, width, widthp); - cursor.par()->params.pextraHfill(hfill); - cursor.par()->params.pextraStartMinipage(start_minipage); - cursor.par()->params.pextraAlignment(alignment); - } -#endif -#ifndef NEW_INSETS - } - tmppar = cursor.par()->FirstPhysicalPar()->previous(); -#else - tmppar = cursor.par()->previous(); -#endif - } - RedoParagraphs(bview, sel_start_cursor, endpar); - ClearSelection(bview); - SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos()); - sel_cursor = cursor; - SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos()); - SetSelection(bview); - SetCursor(bview, tmpcursor.par(), tmpcursor.pos()); -} -#endif - - char loweralphaCounter(int n) { if (n < 1 || n > 26) @@ -1721,10 +1199,6 @@ string const romanCounter(int n) // set the counter of a paragraph. This includes the labels void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const { -#ifndef NEW_INSETS - // this is only relevant for the beginning of paragraph - par = par->FirstPhysicalPar(); -#endif LyXLayout const & layout = textclasslist.Style(buf->params.textclass, par->GetLayout()); @@ -1735,11 +1209,6 @@ 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() -#ifndef NEW_INSETS - && !(par->previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE - && par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE - && par->footnotekind == LyXParagraph::FOOTNOTE) -#endif && !(textclasslist.Style(buf->params.textclass, par->previous()->GetLayout() ).labeltype != LABEL_BIBLIO @@ -1747,24 +1216,15 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const for (int i = 0; i < 10; ++i) { par->setCounter(i, par->previous()->GetFirstCounter(i)); } -#ifndef NEW_INSETS - par->params.appendix(par->previous()->FirstPhysicalPar()->params.appendix()); -#else par->params.appendix(par->previous()->params.appendix()); -#endif if (!par->params.appendix() && par->params.startOfAppendix()) { par->params.appendix(true); for (int i = 0; i < 10; ++i) { par->setCounter(i, 0); } } -#ifndef NEW_INSETS - par->enumdepth = par->previous()->FirstPhysicalPar()->enumdepth; - par->itemdepth = par->previous()->FirstPhysicalPar()->itemdepth; -#else par->enumdepth = par->previous()->enumdepth; par->itemdepth = par->previous()->itemdepth; -#endif } else { for (int i = 0; i < 10; ++i) { par->setCounter(i, 0); @@ -1774,29 +1234,6 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const par->itemdepth = 0; } -#ifndef NEW_INSETS - // if this is an open marginnote and this is the first - // entry in the marginnote and the enclosing - // environment is an enum/item then correct for the - // LaTeX behaviour (ARRae) - if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE - && par->footnotekind == LyXParagraph::MARGIN - && par->previous() - && par->previous()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE - && (par->PreviousBeforeFootnote() - && textclasslist.Style(buf->params.textclass, - par->PreviousBeforeFootnote()->GetLayout() - ).labeltype >= LABEL_COUNTER_ENUMI)) { - // Any itemize or enumerate environment in a marginnote - // that is embedded in an itemize or enumerate - // paragraph is seen by LaTeX as being at a deeper - // level within that enclosing itemization/enumeration - // even if there is a "standard" layout at the start of - // the marginnote. - par->enumdepth++; - par->itemdepth++; - } -#endif /* Maybe we have to increment the enumeration depth. * BUT, enumeration in a footnote is considered in isolation from its * surrounding paragraph so don't increment if this is the @@ -1810,11 +1247,6 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const par->previous()->GetLayout() ).labeltype == LABEL_COUNTER_ENUMI && par->enumdepth < 3 -#ifndef NEW_INSETS - && !(par->previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE - && par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE - && par->footnotekind == LyXParagraph::FOOTNOTE) -#endif && layout.labeltype != LABEL_BIBLIO) { par->enumdepth++; } @@ -1822,11 +1254,6 @@ 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() -#ifndef NEW_INSETS - && !(par->previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE - && par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE - && par->footnotekind == LyXParagraph::FOOTNOTE) -#endif && layout.labeltype != LABEL_BIBLIO) { par->enumdepth = par->DepthHook(par->GetDepth())->enumdepth; par->setCounter(6 + par->enumdepth, @@ -2073,23 +1500,6 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const if (layout.labeltype == LABEL_SENSITIVE) { bool isOK (par->InInset() && par->InInset()->owner() && (par->InInset()->owner()->LyxCode() == Inset::FLOAT_CODE)); -#ifndef NEW_INSETS - if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE - && (par->footnotekind == LyXParagraph::FIG - || par->footnotekind == LyXParagraph::WIDE_FIG)) { - s = (par->getParLanguage(buf->params)->lang() == "hebrew") - ? ":øåéà" : "Figure:"; - } else if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE - && (par->footnotekind == LyXParagraph::TAB - || par->footnotekind == LyXParagraph::WIDE_TAB)) { - s = (par->getParLanguage(buf->params)->lang() == "hebrew") - ? ":äìáè" : "Table:"; - } else if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE - && par->footnotekind == LyXParagraph::ALGORITHM) { - s = (par->getParLanguage(buf->params)->lang() == "hebrew") - ? ":íúéøåâìà" : "Algorithm:"; - } else -#endif if (isOK) { InsetFloat * tmp = static_cast(par->InInset()->owner()); Floating const & fl @@ -2118,24 +1528,13 @@ 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 { - par = row->par()->next_; - } -#else + if (!row) { row = firstrow; par = row->par(); } else { par = row->par()->next(); } -#endif while (par) { while (row->par() != par) @@ -2145,41 +1544,16 @@ void LyXText::UpdateCounters(BufferView * bview, Row * row) const /* now check for the headline layouts. remember that they * have a dynamic left margin */ - if ( -#ifndef NEW_INSETS - !par->IsDummy() && -#endif - ( textclasslist.Style(bview->buffer()->params.textclass, - par->layout).margintype == MARGIN_DYNAMIC - || textclasslist.Style(bview->buffer()->params.textclass, - par->layout).labeltype == LABEL_SENSITIVE) - ) { - + if ((textclasslist.Style(bview->buffer()->params.textclass, + par->layout).margintype == MARGIN_DYNAMIC + || textclasslist.Style(bview->buffer()->params.textclass, + par->layout).labeltype == LABEL_SENSITIVE)) { + /* Rebreak the paragraph */ RemoveParagraph(row); AppendParagraph(bview, row); - -#ifndef NEW_INSETS - /* think about the damned open footnotes! */ - 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(); - RemoveParagraph(row); - AppendParagraph(bview, row); - } - } -#endif } -#ifndef NEW_INSETS - par = par->LastPhysicalPar()->next(); -#else par = par->next(); -#endif - } } @@ -2190,14 +1564,8 @@ void LyXText::InsertInset(BufferView * bview, Inset * inset) if (!cursor.par()->InsertInsetAllowed(inset)) return; SetUndo(bview->buffer(), Undo::INSERT, -#ifndef NEW_INSETS - cursor.par()->ParFromPos(cursor.pos())->previous_, - cursor.par()->ParFromPos(cursor.pos())->next_ -#else cursor.par()->previous(), - cursor.par()->next() -#endif - ); + cursor.par()->next()); cursor.par()->InsertInset(cursor.pos(), inset); InsertChar(bview, LyXParagraph::META_INSET); /* just to rebreak and refresh correctly. * The character will not be inserted a @@ -2245,38 +1613,14 @@ void LyXText::CutSelection(BufferView * bview, bool doclear) // OK, we have a selection. This is always between sel_start_cursor // and sel_end_cursor -#ifndef NEW_INSETS - // Check whether there are half footnotes in the selection - if (sel_start_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE - || sel_end_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) { - LyXParagraph * tmppar = sel_start_cursor.par(); - while (tmppar != sel_end_cursor.par()){ - if (tmppar->footnoteflag != sel_end_cursor.par()->footnoteflag) { - WriteAlert(_("Impossible operation"), - _("Don't know what to do with half floats."), - _("sorry.")); - return; - } - 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(); -#else 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(); -#else endpar = endpar->next(); -#endif undoendpar = endpar; } } else if (endpar) { @@ -2284,25 +1628,14 @@ void LyXText::CutSelection(BufferView * bview, bool doclear) } SetUndo(bview->buffer(), Undo::DELETE, -#ifndef NEW_INSETS - sel_start_cursor - .par()->ParFromPos(sel_start_cursor.pos())->previous_, -#else sel_start_cursor.par()->previous(), -#endif undoendpar); CutAndPaste cap; // there are two cases: cut only within one paragraph or // more than one paragraph -#ifndef NEW_INSETS - if (sel_start_cursor.par()->ParFromPos(sel_start_cursor.pos()) - == sel_end_cursor.par()->ParFromPos(sel_end_cursor.pos())) -#else - if (sel_start_cursor.par() == sel_end_cursor.par()) -#endif - { + if (sel_start_cursor.par() == sel_end_cursor.par()) { // only within one paragraph endpar = sel_start_cursor.par(); int pos = sel_end_cursor.pos(); @@ -2357,31 +1690,8 @@ void LyXText::CopySelection(BufferView * bview) // ok we have a selection. This is always between sel_start_cursor // and sel_end cursor -#ifndef NEW_INSETS - /* check wether there are half footnotes in the selection */ - if (sel_start_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE - || sel_end_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) { - LyXParagraph * tmppar = sel_start_cursor.par(); - while (tmppar != sel_end_cursor.par()) { - if (tmppar->footnoteflag != - sel_end_cursor.par()->footnoteflag) { - WriteAlert(_("Impossible operation"), - _("Don't know what to do" - " with half floats."), - _("sorry.")); - return; - } - tmppar = tmppar->next(); - } - } -#endif - // copy behind a space if there is one -#ifndef NEW_INSETS - while (sel_start_cursor.par()->Last() > sel_start_cursor.pos() -#else while (sel_start_cursor.par()->size() > sel_start_cursor.pos() -#endif && sel_start_cursor.par()->IsLineSeparator(sel_start_cursor.pos()) && (sel_start_cursor.par() != sel_end_cursor.par() || sel_start_cursor.pos() < sel_end_cursor.pos())) @@ -2404,20 +1714,15 @@ void LyXText::PasteSelection(BufferView * bview) return; SetUndo(bview->buffer(), Undo::INSERT, -#ifndef NEW_INSETS - cursor.par()->ParFromPos(cursor.pos())->previous_, - cursor.par()->ParFromPos(cursor.pos())->next_ -#else cursor.par()->previous(), - cursor.par()->next() -#endif - ); + cursor.par()->next()); LyXParagraph * endpar; LyXParagraph * actpar = cursor.par(); int pos = cursor.pos(); - cap.pasteSelection(&actpar, &endpar, pos, bview->buffer()->params.textclass); + cap.pasteSelection(&actpar, &endpar, pos, + bview->buffer()->params.textclass); RedoParagraphs(bview, cursor, endpar); @@ -2602,11 +1907,7 @@ bool LyXText::GotoNextInset(BufferView * bview, LyXCursor res = cursor; Inset * inset; do { -#ifndef NEW_INSETS - if (res.pos() < res.par()->Last() - 1) { -#else if (res.pos() < res.par()->size() - 1) { -#endif res.pos(res.pos() + 1); } else { res.par(res.par()->next()); @@ -2725,18 +2026,11 @@ bool LyXText::UpdateInset(BufferView * bview, Inset * inset) LyXParagraph * par = FirstParagraph(); do { -#ifndef NEW_INSETS - // make sure the paragraph is open - if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){ -#endif pos = par->GetPositionOfInset(inset); if (pos != -1){ CheckParagraph(bview, par, pos); return true; } -#ifndef NEW_INSETS - } -#endif par = par->next(); } while (par); @@ -2757,33 +2051,6 @@ void LyXText::SetCursor(BufferView * bview, LyXParagraph * par, void LyXText::SetCursor(BufferView *bview, LyXCursor & cur, LyXParagraph * par, LyXParagraph::size_type pos, bool boundary) const { -#ifndef NEW_INSETS - // correct the cursor position if impossible - if (pos > par->Last()){ - LyXParagraph * tmppar = par->ParFromPos(pos); - 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 == - LyXParagraph::CLOSED_FOOTNOTE)) || - (par->previous_->footnoteflag == - LyXParagraph::CLOSED_FOOTNOTE))) { - par = par->previous_; - if (par->IsDummy() && - (par->previous_->footnoteflag == - LyXParagraph::CLOSED_FOOTNOTE)) - pos += par->size() + 1; - } - if (par->previous_) { - par = par->previous_; - } - pos += par->size() + 1; - } -#endif cur.par(par); cur.pos(pos); cur.boundary(boundary); @@ -2881,22 +2148,14 @@ void LyXText::SetCurrentFont(BufferView * bview) const --pos; if (pos > 0) { -#ifndef NEW_INSETS - if (pos == cursor.par()->Last()) -#else if (pos == cursor.par()->size()) -#endif --pos; else if (cursor.par()->IsSeparator(pos)) { if (pos > cursor.row()->pos() && bidi_level(pos) % 2 == bidi_level(pos - 1) % 2) --pos; -#ifndef NEW_INSETS - else if (pos + 1 < cursor.par()->Last()) -#else else if (pos + 1 < cursor.par()->size()) -#endif ++pos; } } @@ -2905,11 +2164,7 @@ void LyXText::SetCurrentFont(BufferView * bview) const cursor.par()->GetFontSettings(bview->buffer()->params, pos); real_current_font = GetFont(bview->buffer(), cursor.par(), pos); -#ifndef NEW_INSETS - if (cursor.pos() == cursor.par()->Last() && -#else if (cursor.pos() == cursor.par()->size() && -#endif IsBoundary(bview->buffer(), cursor.par(), cursor.pos()) && !cursor.boundary()) { Language const * lang = @@ -2971,11 +2226,7 @@ void LyXText::CursorLeft(BufferView * bview, bool internal) const SetCursor(bview, cursor.par(), cursor.pos() + 1, true, true); } else if (cursor.par()->previous()) { // steps into the above paragraph. LyXParagraph * par = cursor.par()->previous(); -#ifndef NEW_INSETS - SetCursor(bview, par, par->Last()); -#else SetCursor(bview, par, par->size()); -#endif } } @@ -2985,11 +2236,7 @@ void LyXText::CursorRight(BufferView * bview, bool internal) const if (!internal && cursor.boundary() && !cursor.par()->IsNewline(cursor.pos())) SetCursor(bview, cursor.par(), cursor.pos(), true, false); -#ifndef NEW_INSETS - else if (cursor.pos() < cursor.par()->Last()) { -#else else if (cursor.pos() < cursor.par()->size()) { -#endif SetCursor(bview, cursor.par(), cursor.pos() + 1, true, false); if (!internal && IsBoundary(bview->buffer(), cursor.par(), cursor.pos())) @@ -3030,11 +2277,7 @@ void LyXText::CursorDownParagraph(BufferView * bview) const if (cursor.par()->next()) { SetCursor(bview, cursor.par()->next(), 0); } else { -#ifndef NEW_INSETS - SetCursor(bview, cursor.par(), cursor.par()->Last()); -#else SetCursor(bview, cursor.par(), cursor.par()->size()); -#endif } } @@ -3080,11 +2323,7 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, // Only if the cursor has really moved if (old_cursor.pos() > 0 -#ifndef NEW_INSETS - && old_cursor.pos() < old_cursor.par()->Last() -#else && old_cursor.pos() < old_cursor.par()->size() -#endif && old_cursor.par()->IsLineSeparator(old_cursor.pos()) && old_cursor.par()->IsLineSeparator(old_cursor.pos() - 1)) { old_cursor.par()->Erase(old_cursor.pos() - 1); @@ -3108,37 +2347,13 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, LyXCursor tmpcursor; -#ifndef NEW_INSETS - if (old_cursor.par() != cursor.par()) { - if ((old_cursor.par()->Last() == 0 - || (old_cursor.par()->Last() == 1 - && old_cursor.par()->IsLineSeparator(0))) - && old_cursor.par()->FirstPhysicalPar() - == old_cursor.par()->LastPhysicalPar() -#else if (old_cursor.par() != cursor.par()) { if ((old_cursor.par()->size() == 0 || (old_cursor.par()->size() == 1 - && old_cursor.par()->IsLineSeparator(0))) -#endif - ) { + && old_cursor.par()->IsLineSeparator(0)))) { // ok, we will delete anything // make sure that you do not delete any environments -#ifndef NEW_INSETS - if (( - old_cursor.par()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE && - !(old_cursor.row()->previous() - && old_cursor.row()->previous()->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) - && !(old_cursor.row()->next() - && old_cursor.row()->next()->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)) - || (old_cursor.par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE - && ((old_cursor.row()->previous() - && old_cursor.row()->previous()->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) - || (old_cursor.row()->next() - && old_cursor.row()->next()->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)) - )) { -#endif status = LyXText::NEED_MORE_REFRESH; deleted = true; @@ -3147,24 +2362,6 @@ 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 -#ifndef NEW_INSETS - LyXParagraph * endpar = old_cursor.par()->next_; - if (endpar && endpar->GetDepth()) { - while (endpar && endpar->GetDepth()) { - 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 LyXParagraph * endpar = old_cursor.par()->next(); if (endpar && endpar->GetDepth()) { while (endpar && endpar->GetDepth()) { @@ -3181,7 +2378,6 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, if (OwnerParagraph() == old_cursor.par()) { OwnerParagraph(OwnerParagraph()->next()); } -#endif // delete old par delete old_cursor.par(); @@ -3201,25 +2397,6 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, tmpcursor = cursor; cursor = old_cursor; // that undo can restore the right cursor position -#ifndef NEW_INSETS - LyXParagraph * endpar = old_cursor.par()->next_; - if (endpar && endpar->GetDepth()) { - while (endpar && endpar->GetDepth()) { - 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 LyXParagraph * endpar = old_cursor.par()->next(); if (endpar && endpar->GetDepth()) { while (endpar && endpar->GetDepth()) { @@ -3237,7 +2414,7 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, if (OwnerParagraph() == old_cursor.par()) { OwnerParagraph(OwnerParagraph()->next()); } -#endif + delete old_cursor.par(); /* Breakagain the next par. Needed @@ -3261,9 +2438,6 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, // correct selection sel_cursor = cursor; } -#ifndef NEW_INSETS - } -#endif } if (!deleted) { if (old_cursor.par()->StripLeadingSpaces(bview->buffer()->params.textclass)) { @@ -3277,15 +2451,6 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, } -#ifndef NEW_INSETS -LyXParagraph * LyXText::GetParFromID(int id) -{ - LyXParagraph * result = FirstParagraph(); - while (result && result->id() != id) - result = result->next_; - return result; -} -#else LyXParagraph * LyXText::GetParFromID(int id) { LyXParagraph * result = FirstParagraph(); @@ -3293,7 +2458,6 @@ LyXParagraph * LyXText::GetParFromID(int id) result = result->next(); return result; } -#endif // undo functions @@ -3359,33 +2523,7 @@ 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; -#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(); @@ -3411,7 +2549,6 @@ bool LyXText::TextHandleUndo(BufferView * bview, Undo * undo) } } -#endif // put the new stuff in the list if there is one if (tmppar3){ if (before) @@ -3432,49 +2569,12 @@ bool LyXText::TextHandleUndo(BufferView * bview, Undo * undo) // Set the cursor for redoing if (before) { -#ifndef NEW_INSETS - SetCursorIntern(bview, before->FirstSelfrowPar(), 0); -#else SetCursorIntern(bview, before, 0); -#endif -#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){ - tmppar4 = before; - 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_; - } - } -#endif } -#ifndef NEW_INSETS - // open a cosed footnote at the end if necessary - 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_; - } - } -#endif - // calculate the endpar for redoing the paragraphs. if (behind) { -#ifndef NEW_INSETS - if (behind->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) - endpar = behind->LastPhysicalPar()->next(); - else - endpar = behind->NextAfterFootnote()->LastPhysicalPar()->next(); -#else endpar = behind->next(); -#endif } else endpar = behind; @@ -3578,53 +2678,6 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind, LyXParagraph * start = 0; LyXParagraph * end = 0; -#ifndef NEW_INSETS - if (before) - start = before->next_; - else - start = FirstParagraph(); - if (behind) - end = 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()->ParFromPos(cursor.pos())->id(); - int cursor_pos = cursor.par()->PositionInParFromPos(cursor.pos()); -#else if (before) start = const_cast(before->next()); else @@ -3670,7 +2723,6 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind, int cursor_par = cursor.par()->id(); int cursor_pos = cursor.pos(); -#endif Undo * undo = new Undo(kind, before_number, behind_number, @@ -3687,35 +2739,21 @@ void LyXText::SetCursorParUndo(Buffer * buf) if (inset_owner) return; SetUndo(buf, Undo::FINISH, -#ifndef NEW_INSETS - cursor.par()->ParFromPos(cursor.pos())->previous_, - cursor.par()->ParFromPos(cursor.pos())->next_ -#else cursor.par()->previous(), - cursor.par()->next() -#endif - ); + cursor.par()->next()); } void LyXText::toggleAppendix(BufferView * bview) { -#ifndef NEW_INSETS - LyXParagraph * par = cursor.par()->FirstPhysicalPar(); -#else LyXParagraph * par = cursor.par(); -#endif bool start = !par->params.startOfAppendix(); // ensure that we have only one start_of_appendix in this document LyXParagraph * tmp = FirstParagraph(); -#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 b35ab68a57..793df3b079 100644 --- a/src/undo.C +++ b/src/undo.C @@ -31,17 +31,6 @@ Undo::Undo(undo_kind kind_arg, } -#ifndef NEW_INSETS -Undo::~Undo() -{ - LyXParagraph * tmppar; - while (par) { - tmppar = par; - par = par->next_; - delete tmppar; - } -} -#else Undo::~Undo() { LyXParagraph * tmppar; @@ -51,7 +40,6 @@ Undo::~Undo() delete tmppar; } } -#endif UndoStack::UndoStack() -- 2.39.2