From fd1a4f75e897c8d0894d7c3247fafa964eb44b6d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Wed, 21 Aug 2002 17:35:24 +0000 Subject: [PATCH] move pasteParagraph to global scope git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5062 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 11 ++++++++++- src/CutAndPaste.C | 10 +++++----- src/insets/ChangeLog | 6 ++++++ src/insets/insettext.C | 5 +++-- src/paragraph.C | 31 ------------------------------- src/paragraph.h | 5 ----- src/paragraph_funcs.C | 30 +++++++++++++++--------------- src/paragraph_funcs.h | 12 ++++++------ src/text.C | 2 +- src/text2.C | 8 ++++---- 10 files changed, 50 insertions(+), 70 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 3bf8e880aa..c56303b2a8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2002-08-21 Lars Gullik Bjønnes + + * text.C (backspace): pasteParagraph now in global scipe + + * CutAndPaste.C (cutSelection): pasteParagraph now in global scope + (pasteSelection): ditto + + * paragraph.[Ch] (pasteParagraph): move function to global scope ... + * paragraph_funcs.C (pasteParagraph): ... here 2002-08-20 André Pönitz @@ -8,7 +17,7 @@ 2002-08-21 Lars Gullik Bjønnes - * tabular.C: + * tabular.C: * buffer.[Ch]: remove NO_COMPABILITY stuff 2002-08-20 Lars Gullik Bjønnes diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 230648add5..91601f2934 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -149,7 +149,7 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar, startpar->next()->stripLeadingSpaces(); if (startpar->hasSameLayout(startpar->next()) || startpar->next()->empty()) { - startpar->pasteParagraph(current_view->buffer()->params); + pasteParagraph(current_view->buffer()->params, startpar); (*endpar) = startpar; // this because endpar gets deleted here! } // this paragraph's are of noone's owner! @@ -365,20 +365,20 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, if ((*par)->next() == lastbuffer) lastbuffer = *par; - (*par)->pasteParagraph(current_view->buffer()->params); + pasteParagraph(current_view->buffer()->params, *par); // store the new cursor position *par = lastbuffer; pos = lastbuffer->size(); // maybe some pasting if (lastbuffer->next() && paste_the_end) { if (lastbuffer->next()->hasSameLayout(lastbuffer)) { - lastbuffer->pasteParagraph(current_view->buffer()->params); + pasteParagraph(current_view->buffer()->params, lastbuffer); } else if (lastbuffer->next()->empty()) { lastbuffer->next()->makeSameLayout(lastbuffer); - lastbuffer->pasteParagraph(current_view->buffer()->params); + pasteParagraph(current_view->buffer()->params, lastbuffer); } else if (lastbuffer->empty()) { lastbuffer->makeSameLayout(lastbuffer->next()); - lastbuffer->pasteParagraph(current_view->buffer()->params); + pasteParagraph(current_view->buffer()->params, lastbuffer); } else lastbuffer->next()->stripLeadingSpaces(); } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 73bd5ad5df..1bd2e210f1 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2002-08-21 Lars Gullik Bjønnes + + * insettext.C (collapseParagraphs): pasteParagraph now in global + scope + (appendParagraphs): ditto + 2002-08-21 Dekel Tsur * insetcite.C (latex): Remove spaces only after commmas. diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 27dcbc7dfc..88a4638121 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -37,6 +37,7 @@ #include "trans_mgr.h" #include "undo_funcs.h" #include "WordLangTuple.h" +#include "paragraph_funcs.h" #include "frontends/Alert.h" #include "frontends/Dialogs.h" @@ -2729,7 +2730,7 @@ void InsetText::collapseParagraphs(BufferView * bv) const llt->selection.end.pos() + paragraphs.begin()->size()); } } - paragraphs.begin()->pasteParagraph(bparams); + pasteParagraph(bparams, &*paragraphs.begin()); } reinitLyXText(); } @@ -2771,7 +2772,7 @@ void InsetText::appendParagraphs(BufferParams const & bparams, // paste it! lastbuffer->next(buf); buf->previous(lastbuffer); - lastbuffer->pasteParagraph(bparams); + pasteParagraph(bparams, lastbuffer); reinitLyXText(); } diff --git a/src/paragraph.C b/src/paragraph.C index 6695bb3844..01f2f542fd 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -765,37 +765,6 @@ bool Paragraph::hasSameLayout(Paragraph const * par) const } -// Be carefull, this does not make any check at all. -// This method has wrong name, it combined this par with the next par. -// In that sense it is the reverse of break paragraph. (Lgb) -void Paragraph::pasteParagraph(BufferParams const & bparams) -{ - // copy the next paragraph to this one - Paragraph * the_next = next(); - - // first the DTP-stuff - params().lineBottom(the_next->params().lineBottom()); - params().spaceBottom(the_next->params().spaceBottom()); - params().pagebreakBottom(the_next->params().pagebreakBottom()); - - pos_type pos_end = the_next->pimpl_->size() - 1; - pos_type pos_insert = size(); - - // ok, now copy the paragraph - for (pos_type i = 0, j = 0; i <= pos_end; ++i) { - the_next->cutIntoMinibuffer(bparams, i); - if (insertFromMinibuffer(pos_insert + j)) - ++j; - } - - // delete the next paragraph - Paragraph * ppar = the_next->previous_; - Paragraph * npar = the_next->next_; - delete the_next; - ppar->next(npar); -} - - int Paragraph::getEndLabel() const { Paragraph const * par = this; diff --git a/src/paragraph.h b/src/paragraph.h index d68e9a5e2e..0b55d03cfa 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -273,11 +273,6 @@ public: /// bool isWord(lyx::pos_type pos) const; - /** paste this paragraph with the next one - be carefull, this doesent make any check at all - */ - void pasteParagraph(BufferParams const &); - /// returns -1 if inset not found int getPositionOfInset(Inset const * inset) const; diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index 4486bae1b4..597444fa1e 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -1,10 +1,10 @@ /* This file is part of - * ====================================================== - * + * ====================================================== + * * LyX, The Document Processor - * + * * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. + * Copyright 1995-2001 The LyX Team. * * ====================================================== */ @@ -33,10 +33,10 @@ void breakParagraph(BufferParams const & bparams, tmp->layout(bparams.getLyXTextClass().defaultLayout()); // remember to set the inset_owner tmp->setInsetOwner(par->inInset()); - + // this is an idea for a more userfriendly layout handling, I will // see what the users say - + // layout stays the same with latex-environments if (flag) { tmp->layout(par->layout()); @@ -44,22 +44,22 @@ void breakParagraph(BufferParams const & bparams, } bool isempty = (par->layout()->keepempty && par->empty()); - + if (!isempty && (par->size() > pos || par->empty() || flag == 2)) { tmp->layout(par->layout()); tmp->params().align(par->params().align()); tmp->setLabelWidthString(par->params().labelWidthString()); - + tmp->params().lineBottom(par->params().lineBottom()); par->params().lineBottom(false); tmp->params().pagebreakBottom(par->params().pagebreakBottom()); par->params().pagebreakBottom(false); tmp->params().spaceBottom(par->params().spaceBottom()); par->params().spaceBottom(VSpace(VSpace::NONE)); - + tmp->params().depth(par->params().depth()); tmp->params().noindent(par->params().noindent()); - + // copy everything behind the break-position // to the new paragraph pos_type pos_end = par->size() - 1; @@ -74,7 +74,7 @@ void breakParagraph(BufferParams const & bparams, par->erase(i); } } - + // just an idea of me if (!pos) { tmp->params().lineTop(par->params().lineTop()); @@ -86,7 +86,7 @@ void breakParagraph(BufferParams const & bparams, par->params().clear(); par->layout(bparams.getLyXTextClass().defaultLayout()); - + // layout stays the same with latex-environments if (flag) { par->layout(tmp->layout()); @@ -117,7 +117,7 @@ void breakParagraphConservative(BufferParams const & bparams, if (tmp->insertFromMinibuffer(j - pos)) ++j; } - + for (pos_type k = pos_end; k >= pos; --k) { par->erase(k); } @@ -125,7 +125,6 @@ void breakParagraphConservative(BufferParams const & bparams, } -#if 0 // Be carefull, this does not make any check at all. // This method has wrong name, it combined this par with the next par. // In that sense it is the reverse of break paragraph. (Lgb) @@ -158,6 +157,7 @@ void pasteParagraph(BufferParams const & bparams, } +#if 0 Paragraph * depthHook(Paragraph * par, Paragraph::depth_type depth) { Paragraph * newpar = par; @@ -176,7 +176,7 @@ Paragraph * depthHook(Paragraph * par, Paragraph::depth_type depth) } -Paragraph * outerHook(Paragraph * par) +Paragraph * outerHook(Paragraph * par) { if (!par->getDepth()) return 0; diff --git a/src/paragraph_funcs.h b/src/paragraph_funcs.h index 5d2a051384..c02a33006c 100644 --- a/src/paragraph_funcs.h +++ b/src/paragraph_funcs.h @@ -1,11 +1,11 @@ // -*- C++ -*- /* This file is part of - * ====================================================== - * + * ====================================================== + * * LyX, The Document Processor - * + * * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. + * Copyright 1995-2001 The LyX Team. * * ====================================================== */ @@ -30,14 +30,14 @@ void breakParagraphConservative(BufferParams const & bparams, Paragraph *, lyx::pos_type pos); -#if 0 /** Paste this paragraph with the next one. Be carefull, this doesent make any check at all. -*/ +*/ void pasteParagraph(BufferParams const & bparams, Paragraph *); +#if 0 /// for the environments Paragraph * depthHook(Paragraph * par, Paragraph::depth_type depth); diff --git a/src/text.C b/src/text.C index ed074c4330..3b637993d2 100644 --- a/src/text.C +++ b/src/text.C @@ -2796,7 +2796,7 @@ void LyXText::backspace(BufferView * bview) && cursor.par()->getAlign() == tmppar->getAlign()) { removeParagraph(tmprow); removeRow(tmprow); - cursor.par()->pasteParagraph(bview->buffer()->params); + pasteParagraph(bview->buffer()->params, cursor.par()); if (!cursor.pos() || !cursor.par()->isSeparator(cursor.pos() - 1)) ; //cursor.par()->insertChar(cursor.pos(), ' '); diff --git a/src/text2.C b/src/text2.C index 12e0bd5590..7268ca2e3a 100644 --- a/src/text2.C +++ b/src/text2.C @@ -382,8 +382,8 @@ void LyXText::removeParagraph(Row * row) const void LyXText::insertParagraph(BufferView * bview, Paragraph * par, Row * row) const { - // insert a new row, starting at position 0 - insertRow(row, par, 0); + // insert a new row, starting at position 0 + insertRow(row, par, 0); // set the counters setCounter(bview->buffer(), par); @@ -1362,7 +1362,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const s = o.str(); } else { // par->SetLayout(0); - // s = layout->labelstring; + // s = layout->labelstring; s = (par->getParLanguage(buf->params)->lang() == "hebrew") ? " :úåòîùî øñç" : "Senseless: "; } @@ -1370,7 +1370,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const par->params().labelString(s); // reset the enumeration counter. They are always resetted - // when there is any other layout between + // when there is any other layout between for (int i = par->enumdepth + 1; i < 4; i++) { buf->counters().set(buf->counters().enums[i], 0); } -- 2.39.2