mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
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:
parent
513b57cfaa
commit
023fb5433c
@ -123,11 +123,14 @@ bool checkPastePossible(int index)
|
||||
|
||||
|
||||
pair<PitPosPair, pit_type>
|
||||
pasteSelectionHelper(Buffer const & buffer,
|
||||
ParagraphList & pars, pit_type pit, int pos,
|
||||
ParagraphList const & parlist, textclass_type textclass,
|
||||
ErrorList & errorlist)
|
||||
pasteSelectionHelper(LCursor & cur, 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())
|
||||
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.
|
||||
InsetText in;
|
||||
// This works without copying any paragraph data because we have
|
||||
@ -625,11 +641,8 @@ void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
|
||||
PitPosPair ppp;
|
||||
|
||||
boost::tie(ppp, endpit) =
|
||||
pasteSelectionHelper(cur.buffer(),
|
||||
text->paragraphs(),
|
||||
cur.pit(), cur.pos(),
|
||||
parlist, textclass,
|
||||
errorList);
|
||||
pasteSelectionHelper(cur, parlist,
|
||||
textclass, errorList);
|
||||
updateLabels(cur.buffer());
|
||||
cur.clearSelection();
|
||||
text->setCursor(cur, ppp.first, ppp.second);
|
||||
|
@ -213,13 +213,6 @@ void InsetBox::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
InsetCollapsable::doDispatch(cur, cmd);
|
||||
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:
|
||||
InsetCollapsable::doDispatch(cur, cmd);
|
||||
|
@ -234,19 +234,14 @@ void InsetCharStyle::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
{
|
||||
setInlined();
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
if (cmd.button() == mouse_button::button3)
|
||||
has_label_ = !has_label_;
|
||||
else
|
||||
InsetText::doDispatch(cur, cmd);
|
||||
break;
|
||||
case LFUN_PASTE:
|
||||
case LFUN_CLIPBOARD_PASTE:
|
||||
case LFUN_PRIMARY_SELECTION_PASTE: {
|
||||
InsetCollapsable::doDispatch(cur, cmd);
|
||||
forceParagraphsToDefault(cur);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
InsetCollapsable::doDispatch(cur, cmd);
|
||||
break;
|
||||
|
@ -224,7 +224,6 @@ 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();
|
||||
|
@ -731,9 +731,6 @@ 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_FONT_EMPH:
|
||||
|
@ -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)
|
||||
{
|
||||
lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
|
||||
|
@ -138,8 +138,6 @@ public:
|
||||
InsetText(InsetText const &);
|
||||
///
|
||||
bool & Wide() const { return wide_inset_; }
|
||||
///
|
||||
void forceParagraphsToDefault(LCursor & cur);
|
||||
|
||||
protected:
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user