A more general way of setting paragraphs in an inset to standard

layout upon paste.

	* insettext.[Ch]: add forceParagraphsToDefault method

	* insettabular.C
	(InsetTabular::doDispatch): use it for cell

	* insetbox.C
	(InsetBox::doDispatch): use it

	* insetert.C
	(InsetERT::doDispatch): use it

	* insetcharstyle.C
	(InsetCharStyle::doDispatch): use it



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13535 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Martin Vermeer 2006-03-30 12:43:32 +00:00
parent ce1170d887
commit 726637fc29
6 changed files with 25 additions and 8 deletions

View File

@ -198,6 +198,12 @@ void InsetBox::doDispatch(LCursor & cur, FuncRequest & cmd)
}
InsetCollapsable::doDispatch(cur, cmd);
break;
case LFUN_PASTE:
case LFUN_PASTESELECTION:
InsetCollapsable::doDispatch(cur, cmd);
if (!params_.inner_box)
forceParagraphsToDefault(cur);
break;
default:
InsetCollapsable::doDispatch(cur, cmd);

View File

@ -238,13 +238,7 @@ void InsetCharStyle::doDispatch(LCursor & cur, FuncRequest & cmd)
case LFUN_PASTE:
case LFUN_PASTESELECTION: {
InsetCollapsable::doDispatch(cur, cmd);
BufferParams const & bp = cur.buffer().params();
LyXLayout_ptr const layout =
bp.getLyXTextClass().defaultLayout();
ParagraphList::iterator const end = paragraphs().end();
for (ParagraphList::iterator par = paragraphs().begin();
par != end; ++par)
par->layout(layout);
forceParagraphsToDefault(cur);
break;
}
default:

View File

@ -244,6 +244,7 @@ void InsetERT::doDispatch(LCursor & cur, FuncRequest & cmd)
// Since we can only store plain text, we must reset all
// attributes.
forceParagraphsToDefault(cur);
// FIXME: Change only the pasted paragraphs
BufferParams const & bp = cur.buffer().params();
@ -255,7 +256,6 @@ void InsetERT::doDispatch(LCursor & cur, FuncRequest & cmd)
ParagraphList::iterator const end = paragraphs().end();
for (ParagraphList::iterator par = paragraphs().begin();
par != end; ++par) {
par->layout(layout);
// in case par had a manual label
par->setBeginOfBody();
pos_type const siz = par->size();

View File

@ -745,6 +745,9 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
break;
}
cell(cur.idx())->dispatch(cur, cmd);
// Reset pasted paragraphs:
if (tabular.getPWidth(cur.idx()).zero())
cell(cur.idx())->forceParagraphsToDefault(cur);
break;
case LFUN_EMPH:

View File

@ -264,6 +264,18 @@ bool const InsetText::Tall() const
}
void InsetText::forceParagraphsToDefault(LCursor & cur)
{
BufferParams const & bp = cur.buffer().params();
LyXLayout_ptr const layout =
bp.getLyXTextClass().defaultLayout();
ParagraphList::iterator const end = paragraphs().end();
for (ParagraphList::iterator par = paragraphs().begin();
par != end; ++par)
par->layout(layout);
}
void InsetText::doDispatch(LCursor & cur, FuncRequest & cmd)
{
lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION

View File

@ -143,6 +143,8 @@ public:
bool & Wide() const { return wide_inset_; }
///
bool const Tall() const;
///
void forceParagraphsToDefault(LCursor & cur);
protected:
///