Jean-Marc Lasgouttes wrote:
> It look very nice. I'll try it out a bit.

FYI, attached is the corresponding patch for trunk.

Jürgen
Index: src/insets/insettext.h
===================================================================
--- src/insets/insettext.h	(Revision 15012)
+++ src/insets/insettext.h	(Arbeitskopie)
@@ -138,8 +138,6 @@ public:
 	InsetText(InsetText const &);
 	///
 	bool & Wide() const { return wide_inset_; }
-	///
-	void forceParagraphsToDefault(LCursor & cur);
 
 protected:
 	///
Index: src/insets/insettabular.C
===================================================================
--- src/insets/insettabular.C	(Revision 15012)
+++ src/insets/insettabular.C	(Arbeitskopie)
@@ -731,9 +731,6 @@ void InsetTabular::doDispatch(LCursor & 
 			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:
Index: src/insets/insetbox.C
===================================================================
--- src/insets/insetbox.C	(Revision 15012)
+++ src/insets/insetbox.C	(Arbeitskopie)
@@ -213,13 +213,6 @@ void InsetBox::doDispatch(LCursor & cur,
 		}
 		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);
Index: src/insets/insetert.C
===================================================================
--- src/insets/insetert.C	(Revision 15012)
+++ src/insets/insetert.C	(Arbeitskopie)
@@ -224,7 +224,6 @@ void InsetERT::doDispatch(LCursor & cur,
 
 		// 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();
Index: src/insets/insetcharstyle.C
===================================================================
--- src/insets/insetcharstyle.C	(Revision 15012)
+++ src/insets/insetcharstyle.C	(Arbeitskopie)
@@ -234,22 +234,17 @@ void InsetCharStyle::doDispatch(LCursor 
 {
 	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;
 	}
 }
 
Index: src/insets/insettext.C
===================================================================
--- src/insets/insettext.C	(Revision 15012)
+++ src/insets/insettext.C	(Arbeitskopie)
@@ -251,18 +251,6 @@ InsetBase * InsetText::editXY(LCursor & 
 }
 
 
-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
Index: src/CutAndPaste.C
===================================================================
--- src/CutAndPaste.C	(Revision 15012)
+++ src/CutAndPaste.C	(Arbeitskopie)
@@ -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 & buff
 		}
 	}
 
+	// 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, P
 		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);

Reply via email to