Jean-Marc Lasgouttes wrote:
> So the test only works by chance, because a tabular cell is the only
> insettext that is not subclassed, right? 

Let's say the test "sort of" works. I think the reason for bug 1952 is that 
isMainText() returns true _inside_ a tabular cell after undo. I don't know 
why (and I also haven't verified that completely). 

> The right solution, then, 
> could be to create an InsetCell, which is a child of insettext and
> returns CELL_CODE. But this is not something we want to do now.

Yes and yes.

> We could move the test lyxCode == TEXT_CODE inside
> InsetText::neverIndent, but this does not handle the isMainText()
> case.
>
> What about
>
> bool InsetText::neverIndent{} const
> {
>         // only a tabular cell does that.
>         return lyxCode() == TEXT_CODE;
> }
>
> and then in the patch, test for
>
> +           // in some insets, paragraphs are never indented
> +           && (isMainText() || !par.inInset()->neverIndent())
>
> [inInset is always tru AFAICS]
>
> Would that work?

Yes, but then I'd prefer the attached (which works as well).

Jürgen

> JMarc
Index: text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.625
diff -u -r1.625 text.C
--- text.C	7 Sep 2005 10:37:01 -0000	1.625
+++ text.C	8 Sep 2005 18:07:06 -0000
@@ -591,14 +591,12 @@
 	           && !isFirstInSequence(pit, pars_)))
 	    && align == LYX_ALIGN_BLOCK
 	    && !par.params().noindent()
+	    // in some insets, paragraphs are never indented
+	    && !par.inInset()->neverIndent()
 	    // display style insets are always centered, omit indentation
 	    && !(!par.empty()
 		    && par.isInset(pos)
 		    && par.getInset(pos)->display())
-	    // in charstyles, tabulars and ert paragraphs are never indented!
-	    && ((par.ownerCode() != InsetBase::TEXT_CODE || isMainText())
-	            && par.ownerCode() != InsetBase::ERT_CODE
-		    && par.ownerCode() != InsetBase::CHARSTYLE_CODE)
 	    && (par.layout() != tclass.defaultLayout()
 	        || bv()->buffer()->params().paragraph_separation ==
 	           BufferParams::PARSEP_INDENT))
Index: insets/insetbase.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbase.h,v
retrieving revision 1.58
diff -u -r1.58 insetbase.h
--- insets/insetbase.h	7 Sep 2005 10:37:03 -0000	1.58
+++ insets/insetbase.h	8 Sep 2005 18:07:10 -0000
@@ -338,6 +338,8 @@
 	virtual bool display() const { return false; }
 	/// should we break lines after this inset?
 	virtual bool isLineSeparator() const { return false; }
+	/// should paragraph indendation be ommitted in any case?
+	virtual bool neverIndent() const { return false; }
 	/// dumps content to lyxerr
 	virtual void dump() const;
 	/// write inset in .lyx format
Index: insets/insetcharstyle.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcharstyle.h,v
retrieving revision 1.14
diff -u -r1.14 insetcharstyle.h
--- insets/insetcharstyle.h	4 May 2005 11:21:14 -0000	1.14
+++ insets/insetcharstyle.h	8 Sep 2005 18:07:11 -0000
@@ -86,6 +86,9 @@
 	///
 	InsetCharStyleParams const & params() const { return params_; }
 
+	/// should paragraph indendation be ommitted in any case?
+	bool neverIndent() const { return true; }
+
 protected:
 	InsetCharStyle(InsetCharStyle const &);
 	virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
Index: insets/insetert.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.h,v
retrieving revision 1.111
diff -u -r1.111 insetert.h
--- insets/insetert.h	25 Nov 2004 19:13:04 -0000	1.111
+++ insets/insetert.h	8 Sep 2005 18:07:11 -0000
@@ -68,6 +68,8 @@
 	void getDrawFont(LyXFont &) const;
 	///
 	bool forceDefaultParagraphs(InsetBase const *) const { return true; }
+	/// should paragraph indendation be ommitted in any case?
+	bool neverIndent() const { return true; }
 protected:
 	InsetERT(InsetERT const &);
 	///
Index: insets/insetoptarg.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetoptarg.h,v
retrieving revision 1.25
diff -u -r1.25 insetoptarg.h
--- insets/insetoptarg.h	11 May 2005 09:47:54 -0000	1.25
+++ insets/insetoptarg.h	8 Sep 2005 18:07:11 -0000
@@ -48,6 +48,9 @@
 			  OutputParams const &) const;
 	/// Write out tothe .lyx file
 	void write(Buffer const & buf, std::ostream & os) const;
+
+	/// should paragraph indendation be ommitted in any case?
+	virtual bool neverIndent() const { return true; }
 protected:
 	InsetOptArg(InsetOptArg const &);
 private:
Index: insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.620
diff -u -r1.620 insettext.C
--- insets/insettext.C	7 Sep 2005 10:37:04 -0000	1.620
+++ insets/insettext.C	8 Sep 2005 18:07:12 -0000
@@ -442,6 +442,13 @@
 }
 
 
+bool InsetText::neverIndent() const
+{
+	// this is only true for tabular cells
+	return !text_.isMainText() && lyxCode() == TEXT_CODE;
+}
+
+
 ParagraphList const & InsetText::paragraphs() const
 {
 	return text_.paragraphs();
Index: insets/insettext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.h,v
retrieving revision 1.276
diff -u -r1.276 insettext.h
--- insets/insettext.h	7 Sep 2005 10:37:05 -0000	1.276
+++ insets/insettext.h	8 Sep 2005 18:07:12 -0000
@@ -139,6 +139,8 @@
 	bool insetAllowed(Code) const { return true; }
 	///
 	bool allowSpellCheck() const { return true; }
+	/// should paragraph indendation be ommitted in any case?
+	bool neverIndent() const;
 	///
 	InsetText(InsetText const &);
 

Reply via email to