On Fri, Mar 24, 2006 at 03:49:10PM +0100, Jean-Marc Lasgouttes wrote:
> >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:

... 
 
> >> What I propose is to run resetParagraphStyle on the whole LyXText
> >> after pasting. This cannot really hurt :)
> 
> Martin> That's precisely what the insertert FIXME complained about ;-)
> 
> I see that now. But I do not think it matters much. 
> 
> Martin> Sure I can do it. Where do you want resetParagraphStyles to be
> Martin> relocated?
> 
> Good question. What about putting it in anonymous namespace in
> text3.C?

That would be this patch.

Unless anyone sees a problem, this goes in soon.

- Martin 

Index: text3.C
===================================================================
--- text3.C     (revision 13473)
+++ text3.C     (working copy)
@@ -250,6 +250,22 @@ void specialChar(LCursor & cur, InsetSpe
 }
 
 
+void resetParagraphStyles(LyXTextClass const & textclass, ParagraphList &
+               plist)
+{
+       ParagraphList::const_iterator const beg = plist.begin();
+       ParagraphList::const_iterator const end = plist.end();
+       ParagraphList::const_iterator it = beg;
+       for (; it != end; ++it) {
+               LyXLayout_ptr const & p = textclass.defaultLayout();
+               lyx::pit_type pit = std::distance(beg, it);
+               plist[pit].layout(p);
+               plist[pit].setBeginOfBody();
+               plist[pit].params().clear();
+       }
+}
+
+
 bool doInsertInset(LCursor & cur, LyXText * text,
        FuncRequest const & cmd, bool edit, bool pastesel)
 {
@@ -268,8 +284,15 @@ bool doInsertInset(LCursor & cur, LyXTex
        if (edit)
                inset->edit(cur, true);
 
-       if (gotsel && pastesel)
+       if (gotsel && pastesel) {
                cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
+               if (inset->forceDefaultParagraphs(cur.idx()) &&
+                   inset->asTextInset()) {
+                       resetParagraphStyles(
+                               cur.buffer().params().getLyXTextClass(),
+                               static_cast<InsetText *>(inset)->paragraphs());
+               }
+       }
        return true;
 }
 
Index: insets/insetert.C
===================================================================
--- insets/insetert.C   (revision 13473)
+++ insets/insetert.C   (working copy)
@@ -249,14 +249,10 @@ void InsetERT::doDispatch(LCursor & cur,
                ParagraphList::iterator const end = paragraphs().end();
                for (ParagraphList::iterator par = paragraphs().begin();
                     par != end; ++par) {
-                       par->layout(layout);
-                       // in case par had a manual label
-                       par->setBeginOfBody();
                        pos_type const siz = par->size();
                        for (pos_type i = 0; i < siz; ++i) {
                                par->setFont(i, font);
                        }
-                       par->params().clear();
                }
                break;
        }

Attachment: pgpzzQGekW2L2.pgp
Description: PGP signature

Reply via email to