diff --git a/src/ChangeLog b/src/ChangeLog index b0aa51df7b..05f7a33474 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-12-05 Juergen Vigna + + * CutAndPaste.C (pasteSelection): remove not allowed insets/chars and + set the right font on the "multi" paragraph paste! + 2001-12-05 Lars Gullik Bjønnes * trans_decl.h: diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index f7117cb8e0..8e9c574c4f 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -262,6 +262,29 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, tmpbuf2->next()->previous(tmpbuf2); tmpbuf2 = tmpbuf2->next(); } + + // now remove all out of the buffer which is NOT allowed in the + // new environment and set also another font if that is required + tmpbuf = buf; + while(tmpbuf) { + for(pos_type i = 0; i < tmpbuf->size(); ++i) { + if (tmpbuf->getChar(i) == Paragraph::META_INSET) { + if (!(*par)->insetAllowed(tmpbuf->getInset(i)->lyxCode())) + { + tmpbuf->erase(i--); + } + } else { + LyXFont f1 = tmpbuf->getFont(current_view->buffer()->params,i); + LyXFont f2 = f1; + if (!(*par)->checkInsertChar(f1)) { + tmpbuf->erase(i--); + } else if (f1 != f2) { + tmpbuf->setFont(i, f1); + } + } + } + tmpbuf = tmpbuf->next(); + } // make sure there is no class difference SwitchLayoutsBetweenClasses(textclass, tc, buf); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index a6ee9e4038..df0cad75bf 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2001-12-05 Juergen Vigna + + * insettext.C (insetAllowed): fixed for the case that we directly + ask the insettext from it's LyXText. + 2001-12-05 Lars Gullik Bjønnes * insetbib.C: diff --git a/src/insets/insettext.C b/src/insets/insettext.C index e10eea1b90..5775594a9b 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -196,6 +196,7 @@ void InsetText::init(InsetText const * ins, bool same_id) frame_is_visible = false; cached_bview = 0; sstate.lpar = 0; + in_insetAllowed = false; } @@ -1799,9 +1800,16 @@ bool InsetText::insertInset(BufferView * bv, Inset * inset) bool InsetText::insetAllowed(Inset::Code code) const { + bool ret = true; + if (in_insetAllowed) + return ret; + in_insetAllowed = true; if (the_locking_inset) - return the_locking_inset->insetAllowed(code); - return true; + ret = the_locking_inset->insetAllowed(code); + else if (owner()) + ret = owner()->insetAllowed(code); + in_insetAllowed = false; + return ret; } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index ab981c6a63..0a7a0f99dd 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -404,5 +404,6 @@ private: bool in_update; /* as update is not reentrant! */ mutable BufferView * do_resize; mutable bool do_reinit; + mutable bool in_insetAllowed; }; #endif