X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fparagraph_funcs.C;h=d9a2a41835d304f0d44c774281ce2e3e313135dc;hb=b99a5acc7f18c3f885856fa962c0f0a63a0ca5ad;hp=a203bf2d1f072726bb03ff1764f043bcc40389a2;hpb=38b325846cca955100f02b49456c3f6450ab73b6;p=lyx.git diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index a203bf2d1f..d9a2a41835 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -1,16 +1,17 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. +/** + * \file paragraph_funcs.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * ====================================================== */ + * \author Lars Gullik Bjønnes + * + * Full author contact details are available in file CREDITS + */ #include #include "paragraph_funcs.h" +#include "paragraph_pimpl.h" #include "buffer.h" #include "ParagraphParameters.h" #include "lyxtextclasslist.h" @@ -28,67 +29,91 @@ void breakParagraph(BufferParams const & bparams, { // create a new paragraph Paragraph * tmp = new Paragraph(par); + // without doing that we get a crash when typing at the + // end of a paragraph + tmp->layout(bparams.getLyXTextClass().defaultLayout()); // remember to set the inset_owner tmp->setInsetOwner(par->inInset()); - + + if (bparams.tracking_changes) + tmp->trackChanges(); + // 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()); tmp->setLabelWidthString(par->params().labelWidthString()); } - bool isempty = (par->layout()->keepempty && par->empty()); - + bool const 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 + +#ifdef WITH_WARNINGS +#warning this seems wrong +#endif + /* FIXME: if !keepempty, empty() == true, then we reach + * here with size() == 0. So pos_end becomes - 1. Why + * doesn't this cause problems ??? + */ pos_type pos_end = par->size() - 1; pos_type i = pos; pos_type j = pos; + for (; i <= pos_end; ++i) { + Change::Type change(par->lookupChange(i)); par->cutIntoMinibuffer(bparams, i); - if (tmp->insertFromMinibuffer(j - pos)) + if (tmp->insertFromMinibuffer(j - pos)) { + tmp->pimpl_->setChange(j - pos, change); ++j; + } } for (i = pos_end; i >= pos; --i) { - par->erase(i); + par->pimpl_->eraseIntern(i); } } - - // just an idea of me - if (!pos) { - tmp->params().lineTop(par->params().lineTop()); - tmp->params().pagebreakTop(par->params().pagebreakTop()); - tmp->params().spaceTop(par->params().spaceTop()); - tmp->bibkey = par->bibkey; - - par->bibkey = 0; - par->params().clear(); - - par->layout(bparams.getLyXTextClass().defaultLayout()); - - // layout stays the same with latex-environments - if (flag) { - par->layout(tmp->layout()); - par->setLabelWidthString(tmp->params().labelWidthString()); - par->params().depth(tmp->params().depth()); + + if (pos) + return; + + tmp->params().lineTop(par->params().lineTop()); + tmp->params().pagebreakTop(par->params().pagebreakTop()); + tmp->params().spaceTop(par->params().spaceTop()); + par->params().clear(); + + par->layout(bparams.getLyXTextClass().defaultLayout()); + + // layout stays the same with latex-environments + if (flag) { + par->layout(tmp->layout()); + par->setLabelWidthString(tmp->params().labelWidthString()); + par->params().depth(tmp->params().depth()); + } + + // subtle, but needed to get empty pars working right + if (bparams.tracking_changes) { + if (!par->size()) { + par->cleanChanges(); + } else if (!tmp->size()) { + tmp->cleanChanges(); } } } @@ -114,7 +139,7 @@ void breakParagraphConservative(BufferParams const & bparams, if (tmp->insertFromMinibuffer(j - pos)) ++j; } - + for (pos_type k = pos_end; k >= pos; --k) { par->erase(k); } @@ -122,14 +147,8 @@ 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) -void pasteParagraph(BufferParams const & bparams, - Paragraph * par) +void mergeParagraph(BufferParams const & bparams, Paragraph * par) { - // copy the next paragraph to this one Paragraph * the_next = par->next(); // first the DTP-stuff @@ -155,6 +174,7 @@ void pasteParagraph(BufferParams const & bparams, } +#if 0 Paragraph * depthHook(Paragraph * par, Paragraph::depth_type depth) { Paragraph * newpar = par; @@ -173,7 +193,7 @@ Paragraph * depthHook(Paragraph * par, Paragraph::depth_type depth) } -Paragraph * outerHook(Paragraph * par) +Paragraph * outerHook(Paragraph * par) { if (!par->getDepth()) return 0;