On Wed, Oct 10, 2007 at 11:26:54AM +0200, Jean-Marc Lasgouttes wrote:
> Martin Vermeer <[EMAIL PROTECTED]> writes:
> 
> >> OTOH if the surrounding text para becomes empty after the cut, I think
> >> resetting _that_ to default makes sense. Think enclosing a section
> >> header plus text into a (branch) inset. Or a numbered/bullet list.
> 
> Yes! This has annoyed me for ages!
> 
> > The attached patch implements this (IMHO saner) behaviour.
> 
> I cannot test here (other compilation problems), but it looks good, as
> long as the behaviour is only when selecting the whole paragraph.
> 
> > BTW the FIXME has been broken forever. As a fix, merging the paragraphs may
> > produce minimum information loss for the user.
> 
> It would be nice to do this directly at paste level. BTW, what about
> adding a allowMultipar() property directly to InsetText, which would
> be set from multipar in InsetFlex, and move as much code as possible
> to InsetText itself?

The attached adds and uses an allowMultiPar() method, and everything
still works (I also made Box insetlayoutable, as it wouldn't work right
without). 

 From there on I am lost as to what you precisely have in mind ;-)

- Martin
 
Index: src/Text3.cpp
===================================================================
--- src/Text3.cpp	(revision 20889)
+++ src/Text3.cpp	(working copy)
@@ -209,8 +209,8 @@
 
 		if (gotsel && pastesel) {
 			lyx::dispatch(FuncRequest(LFUN_PASTE, "0"));
-			InsetLayout il = inset->getLayout(cur.buffer().params());
-			if (!il.multipar || cur.lastpit() == 0) {
+			if (!static_cast<InsetText *>(inset)->allowMultiPar() 
+			    || cur.lastpit() == 0) {
 				// reset first par to default
 				LayoutPtr const layout =
 					cur.buffer().params().getTextClass().defaultLayout();
Index: src/insets/InsetBox.cpp
===================================================================
--- src/insets/InsetBox.cpp	(revision 20732)
+++ src/insets/InsetBox.cpp	(working copy)
@@ -14,6 +14,7 @@
 
 #include "InsetBox.h"
 
+#include "Buffer.h"
 #include "BufferView.h"
 #include "Cursor.h"
 #include "DispatchResult.h"
@@ -94,6 +95,7 @@
 InsetBox::InsetBox(BufferParams const & bp, string const & label)
 	: InsetCollapsable(bp), params_(label)
 {
+	setLayout(bp);
 	init();
 }
 
@@ -134,6 +136,7 @@
 {
 	params_.read(lex);
 	InsetCollapsable::read(buf, lex);
+	setLayout(buf.params());
 	setButtonLabel();
 }
 
@@ -203,6 +206,7 @@
 	case LFUN_INSET_MODIFY: {
 		//lyxerr << "InsetBox::dispatch MODIFY" << endl;
 		InsetBoxMailer::string2params(to_utf8(cmd.argument()), params_);
+		setLayout(cur.buffer().params());
 		setButtonLabel();
 		break;
 	}
Index: src/insets/InsetCollapsable.cpp
===================================================================
--- src/insets/InsetCollapsable.cpp	(revision 20769)
+++ src/insets/InsetCollapsable.cpp	(working copy)
@@ -546,6 +546,12 @@
 }
 
 
+bool InsetCollapsable::allowMultiPar() const
+{
+	return layout_.multipar;
+}
+
+
 bool InsetCollapsable::getStatus(Cursor & cur, FuncRequest const & cmd,
 		FuncStatus & flag) const
 {
Index: src/insets/InsetText.h
===================================================================
--- src/insets/InsetText.h	(revision 20732)
+++ src/insets/InsetText.h	(working copy)
@@ -130,6 +130,8 @@
 	/// should paragraph indendation be ommitted in any case?
 	bool neverIndent(Buffer const &) const;
 	///
+	virtual bool allowMultiPar() const { return true; }
+	///
 	InsetText(InsetText const &);
 
 	// Update the counters of this inset and of its contents
Index: src/insets/InsetCollapsable.h
===================================================================
--- src/insets/InsetCollapsable.h	(revision 20732)
+++ src/insets/InsetCollapsable.h	(working copy)
@@ -122,6 +122,8 @@
 	///
 	bool allowSpellCheck() const { return true; }
 	///
+	bool allowMultiPar() const;
+	///
 	bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
 	///
 	void setStatus(Cursor & cur, CollapseStatus st);

Reply via email to