Martin Vermeer wrote:
> Fair enough... but could you put a link to this discussion
> on bugzilla?

Finally, I couldn't resist. See attached patch (against trunk). Please test 
someone.
BTW this bug is a consequence of the fix for bug 1332.

Jürgen
Index: src/CutAndPaste.C
===================================================================
--- src/CutAndPaste.C	(Revision 14866)
+++ src/CutAndPaste.C	(Arbeitskopie)
@@ -126,7 +126,7 @@ pair<PitPosPair, pit_type>
 pasteSelectionHelper(Buffer const & buffer,
 		     ParagraphList & pars, pit_type pit, int pos,
 		     ParagraphList const & parlist, textclass_type textclass,
-		     ErrorList & errorlist)
+		     ErrorList & errorlist, bool targetlayout)
 {
 	if (parlist.empty())
 		return make_pair(PitPosPair(pit, pos), pit);
@@ -206,7 +206,7 @@ pasteSelectionHelper(Buffer const & buff
 	}
 
 	bool const empty = pars[pit].empty();
-	if (!empty) {
+	if (!empty || targetlayout) {
 		// Make the buf exactly the same layout as the cursor
 		// paragraph.
 		insertion.begin()->makeSameLayout(pars[pit]);
@@ -612,7 +612,8 @@ std::string getSelection(Buffer const & 
 
 
 void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
-			textclass_type textclass, ErrorList & errorList)
+			textclass_type textclass, ErrorList & errorList,
+			bool targetlayout)
 {
 	if (cur.inTexted()) {
 		LyXText * text = cur.text();
@@ -628,7 +629,7 @@ void pasteParagraphList(LCursor & cur, P
 					     text->paragraphs(),
 					     cur.pit(), cur.pos(),
 					     parlist, textclass,
-					     errorList);
+					     errorList, targetlayout);
 		updateLabels(cur.buffer());
 		cur.clearSelection();
 		text->setCursor(cur, ppp.first, ppp.second);
@@ -639,14 +640,14 @@ void pasteParagraphList(LCursor & cur, P
 }
 
 
-void pasteSelection(LCursor & cur, ErrorList & errorList, size_t sel_index)
+void pasteSelection(LCursor & cur, ErrorList & errorList, size_t sel_index, bool targetlayout)
 {
 	// this does not make sense, if there is nothing to paste
 	if (!checkPastePossible(sel_index))
 		return;
 
 	pasteParagraphList(cur, theCuts[sel_index].first,
-			   theCuts[sel_index].second, errorList);
+			   theCuts[sel_index].second, errorList, targetlayout);
 	cur.setSelection();
 }
 
Index: src/CutAndPaste.h
===================================================================
--- src/CutAndPaste.h	(Revision 14866)
+++ src/CutAndPaste.h	(Arbeitskopie)
@@ -55,11 +55,13 @@ void cutSelection(LCursor & cur, bool do
 ///
 void copySelection(LCursor & cur);
 ///
-void pasteSelection(LCursor & cur, ErrorList &, size_t sel_index = 0);
+void pasteSelection(LCursor & cur, ErrorList &, size_t sel_index = 0,
+			bool targetlayout = false);
 
 ///
 void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
-			textclass_type textclass, ErrorList & errorList);
+			textclass_type textclass, ErrorList & errorList,
+			bool targetlayout = false);
 
 
 /** Needed to switch between different classes. This works
Index: src/text3.C
===================================================================
--- src/text3.C	(Revision 14866)
+++ src/text3.C	(Arbeitskopie)
@@ -278,8 +278,12 @@ bool doInsertInset(LCursor & cur, LyXTex
 	if (edit)
 		inset->edit(cur, true);
 
-	if (gotsel && pastesel)
-		cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
+	if (gotsel && pastesel) {
+		// paste, but use the standard layout in the first par.
+		pasteSelection(cur, cur.bv().buffer()->errorList("Paste"),
+			0, true);
+		cur.clearSelection();
+	}
 	return true;
 }
 

Reply via email to