From 023fb5433c3028ec87042d9f2a7d2d4ed4d70eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Tue, 19 Sep 2006 09:39:17 +0000 Subject: [PATCH] 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 --- src/CutAndPaste.C | 31 ++++++++++++++++++++++--------- src/insets/insetbox.C | 7 ------- src/insets/insetcharstyle.C | 13 ++++--------- src/insets/insetert.C | 1 - src/insets/insettabular.C | 3 --- src/insets/insettext.C | 12 ------------ src/insets/insettext.h | 2 -- 7 files changed, 26 insertions(+), 43 deletions(-) diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 7a22cfc335..b98f10b025 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -123,11 +123,14 @@ bool checkPastePossible(int index) pair -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); diff --git a/src/insets/insetbox.C b/src/insets/insetbox.C index 9401ff3f4f..634c6b46b9 100644 --- a/src/insets/insetbox.C +++ b/src/insets/insetbox.C @@ -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); diff --git a/src/insets/insetcharstyle.C b/src/insets/insetcharstyle.C index e5543adc4f..1b5a5e418c 100644 --- a/src/insets/insetcharstyle.C +++ b/src/insets/insetcharstyle.C @@ -234,22 +234,17 @@ void InsetCharStyle::doDispatch(LCursor & cur, FuncRequest & cmd) { setInlined(); switch (cmd.action) { - case LFUN_MOUSE_PRESS: + + 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: { + + default: InsetCollapsable::doDispatch(cur, cmd); - forceParagraphsToDefault(cur); break; - } - default: - InsetCollapsable::doDispatch(cur, cmd); - break; } } diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 4b3a6f8f58..ce96f9ded7 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -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(); diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index f2725b6a55..2664f85633 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -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: diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 9604bd8ebe..2ff1fdb0c6 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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 diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 202dd7df1a..95c282a558 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -138,8 +138,6 @@ public: InsetText(InsetText const &); /// bool & Wide() const { return wide_inset_; } - /// - void forceParagraphsToDefault(LCursor & cur); protected: ///