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
This commit is contained in:
Jürgen Vigna 2001-12-05 15:34:41 +00:00
parent c80187fbfc
commit 8a3b0939d5
5 changed files with 44 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2001-12-05 Juergen Vigna <jug@sad.it>
* 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 <larsbj@birdstep.com>
* trans_decl.h:

View File

@ -263,6 +263,29 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
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);

View File

@ -1,3 +1,8 @@
2001-12-05 Juergen Vigna <jug@sad.it>
* insettext.C (insetAllowed): fixed for the case that we directly
ask the insettext from it's LyXText.
2001-12-05 Lars Gullik Bjønnes <larsbj@birdstep.com>
* insetbib.C:

View File

@ -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;
}

View File

@ -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