Cleanup fix for bug 2382:

* src/CutAndPaste.C (pasteSelectionHelper): pass Cursor 
	as argument, remove cursor-dependent arguments, 	
	implement method to reset layout in insets which
	forceParagraphsToDefault.

	* src/CutAndPaste.C (pasteParagraphList): adapt call of 
	pasteSelectionHelper.

	* insets/insetbox.C (doDispatch):
	* insets/insetert.C (doDispatch):
	* insets/insetcharstyle.C (doDispatch):
	* insettext.[Ch] (forceParagraphsToDefault):
		remove ad-hoc-Code to 
		reset paragraph layout. 
		This is now done generally in CutAndPaste.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15062 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2006-09-19 09:39:17 +00:00
parent 513b57cfaa
commit 023fb5433c
7 changed files with 26 additions and 43 deletions

View File

@ -123,11 +123,14 @@ bool checkPastePossible(int index)
pair<PitPosPair, pit_type> pair<PitPosPair, pit_type>
pasteSelectionHelper(Buffer const & buffer, pasteSelectionHelper(LCursor & cur, ParagraphList const & parlist,
ParagraphList & pars, pit_type pit, int pos, textclass_type textclass, ErrorList & errorlist)
ParagraphList const & parlist, textclass_type textclass,
ErrorList & errorlist)
{ {
Buffer const & buffer = cur.buffer();
pit_type pit = cur.pit();
pos_type pos = cur.pos();
ParagraphList & pars = cur.text()->paragraphs();
if (parlist.empty()) if (parlist.empty())
return make_pair(PitPosPair(pit, pos), pit); return make_pair(PitPosPair(pit, pos), pit);
@ -156,6 +159,19 @@ pasteSelectionHelper(Buffer const & buffer,
} }
} }
// If we are in an inset which returns forceDefaultParagraphs,
// set the paragraphs to default
// FIXME: pars[pit].forceDefaultParagraphs() should be enough,
// but returns the wrong values for tabular cells!
if (cur.inset().forceDefaultParagraphs(cur.idx())) {
LyXLayout_ptr const layout =
buffer.params().getLyXTextClass().defaultLayout();
ParagraphList::iterator const end = insertion.end();
for (ParagraphList::iterator par = insertion.begin();
par != end; ++par)
par->layout(layout);
}
// Make sure there is no class difference. // Make sure there is no class difference.
InsetText in; InsetText in;
// This works without copying any paragraph data because we have // This works without copying any paragraph data because we have
@ -625,11 +641,8 @@ void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
PitPosPair ppp; PitPosPair ppp;
boost::tie(ppp, endpit) = boost::tie(ppp, endpit) =
pasteSelectionHelper(cur.buffer(), pasteSelectionHelper(cur, parlist,
text->paragraphs(), textclass, errorList);
cur.pit(), cur.pos(),
parlist, textclass,
errorList);
updateLabels(cur.buffer()); updateLabels(cur.buffer());
cur.clearSelection(); cur.clearSelection();
text->setCursor(cur, ppp.first, ppp.second); text->setCursor(cur, ppp.first, ppp.second);

View File

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

View File

@ -234,22 +234,17 @@ void InsetCharStyle::doDispatch(LCursor & cur, FuncRequest & cmd)
{ {
setInlined(); setInlined();
switch (cmd.action) { switch (cmd.action) {
case LFUN_MOUSE_PRESS:
case LFUN_MOUSE_PRESS:
if (cmd.button() == mouse_button::button3) if (cmd.button() == mouse_button::button3)
has_label_ = !has_label_; has_label_ = !has_label_;
else else
InsetText::doDispatch(cur, cmd); InsetText::doDispatch(cur, cmd);
break; break;
case LFUN_PASTE:
case LFUN_CLIPBOARD_PASTE: default:
case LFUN_PRIMARY_SELECTION_PASTE: {
InsetCollapsable::doDispatch(cur, cmd); InsetCollapsable::doDispatch(cur, cmd);
forceParagraphsToDefault(cur);
break; break;
}
default:
InsetCollapsable::doDispatch(cur, cmd);
break;
} }
} }

View File

@ -224,7 +224,6 @@ void InsetERT::doDispatch(LCursor & cur, FuncRequest & cmd)
// Since we can only store plain text, we must reset all // Since we can only store plain text, we must reset all
// attributes. // attributes.
forceParagraphsToDefault(cur);
// FIXME: Change only the pasted paragraphs // FIXME: Change only the pasted paragraphs
BufferParams const & bp = cur.buffer().params(); BufferParams const & bp = cur.buffer().params();

View File

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

View File

@ -251,18 +251,6 @@ InsetBase * InsetText::editXY(LCursor & cur, int x, int y)
} }
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) void InsetText::doDispatch(LCursor & cur, FuncRequest & cmd)
{ {
lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION

View File

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