From 8a3b0939d5fdf0f561e608af9c706b22303e04a9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Wed, 5 Dec 2001 15:34:41 +0000 Subject: [PATCH] Fixed insetAllowd for InsetText and Pasting multiple paragraphs inside Insets with particular restrictions. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3151 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 +++++ src/CutAndPaste.C | 23 +++++++++++++++++++++++ src/insets/ChangeLog | 5 +++++ src/insets/insettext.C | 12 ++++++++++-- src/insets/insettext.h | 1 + 5 files changed, 44 insertions(+), 2 deletions(-) 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 -- 2.39.5