The following patch gets rid of Paragraph::autoBreakRows(), one of the two
users of Paragraph::inInset(). Getting rid of inInset() is a worthy goal in
itself, and would even solve some reported crashes.

I've moved the autoBreakRows_ bool from InsetText to LyXText to make it
available to some LyXText member functions, but otherwise the patch is
straightforward. Ok?

Regards, Alfredo

? alldevel.diff
? output_latex.C-save
? output_latex.h-save
Index: buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.595
diff -u -p -r1.595 buffer.C
--- buffer.C	3 Dec 2004 18:39:49 -0000	1.595
+++ buffer.C	17 Dec 2004 14:55:09 -0000
@@ -474,7 +474,7 @@ bool Buffer::readDocument(LyXLex & lex)
 // needed to insert the selection
 void Buffer::insertStringAsLines(ParagraphList & pars,
 	pit_type & par, pos_type & pos,
-	LyXFont const & fn, string const & str)
+	LyXFont const & fn, string const & str, bool autobreakrows)
 {
 	LyXLayout_ptr const & layout = pars[par].layout();
 
@@ -483,7 +483,6 @@ void Buffer::insertStringAsLines(Paragra
 	pars[par].checkInsertChar(font);
 	// insert the string, don't insert doublespace
 	bool space_inserted = true;
-	bool autobreakrows = pars[par].autoBreakRows();
 	for (string::const_iterator cit = str.begin();
 	    cit != str.end(); ++cit) {
 		if (*cit == '\n') {
Index: buffer.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.h,v
retrieving revision 1.188
diff -u -p -r1.188 buffer.h
--- buffer.h	24 Nov 2004 21:53:37 -0000	1.188
+++ buffer.h	17 Dec 2004 14:55:09 -0000
@@ -99,7 +99,7 @@ public:
 	///
 	void insertStringAsLines(ParagraphList & plist,
 		lyx::pit_type &, lyx::pos_type &,
-		LyXFont const &, std::string const &);
+		LyXFont const &, std::string const &, bool);
 	///
 	ParIterator getParFromID(int id) const;
 	/// do we have a paragraph with this id?
Index: lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.315
diff -u -p -r1.315 lyxtext.h
--- lyxtext.h	30 Nov 2004 01:59:34 -0000	1.315
+++ lyxtext.h	17 Dec 2004 14:55:09 -0000
@@ -352,6 +352,8 @@ public:
 	/// our 'outermost' Font
 	LyXFont font_;
 
+	///
+	bool autoBreakRows_;
 private:
 	/// return past-the-last paragraph influenced by a layout
 	/// change on pit
Index: paragraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
retrieving revision 1.394
diff -u -p -r1.394 paragraph.C
--- paragraph.C	30 Nov 2004 01:59:34 -0000	1.394
+++ paragraph.C	17 Dec 2004 14:55:10 -0000
@@ -716,12 +716,6 @@ bool Paragraph::forceDefaultParagraphs()
 }
 
 
-bool Paragraph::autoBreakRows() const
-{
-	return inInset() && static_cast<InsetText *>(inInset())->getAutoBreakRows();
-}
-
-
 namespace {
 
 // paragraphs inside floats need different alignment tags to avoid
Index: paragraph.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.h,v
retrieving revision 1.144
diff -u -p -r1.144 paragraph.h
--- paragraph.h	30 Nov 2004 01:59:35 -0000	1.144
+++ paragraph.h	17 Dec 2004 14:55:10 -0000
@@ -169,8 +169,6 @@ public:
 	///
 	InsetBase::Code ownerCode() const;
 	///
-	bool autoBreakRows() const;
-	///
 	bool forceDefaultParagraphs() const;
 
 	///
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.590
diff -u -p -r1.590 text2.C
--- text2.C	6 Dec 2004 12:55:03 -0000	1.590
+++ text2.C	17 Dec 2004 14:55:10 -0000
@@ -74,7 +74,8 @@ using std::string;
 LyXText::LyXText(BufferView * bv)
 	: maxwidth_(bv ? bv->workWidth() : 100),
 	  background_color_(LColor::background),
-	  bv_owner(bv)
+	  bv_owner(bv),
+	  autoBreakRows_(false)
 {}
 
 
@@ -893,7 +894,8 @@ void LyXText::insertStringAsLines(LCurso
 
 	// only to be sure, should not be neccessary
 	cur.clearSelection();
-	cur.buffer().insertStringAsLines(pars_, pit, pos, current_font, str);
+	cur.buffer().insertStringAsLines(pars_, pit, pos, current_font, str,
+		autoBreakRows_);
 
 	cur.resetAnchor();
 	setCursor(cur, cur.pit(), pos);
Index: insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.602
diff -u -p -r1.602 insettext.C
--- insets/insettext.C	30 Nov 2004 01:59:47 -0000	1.602
+++ insets/insettext.C	17 Dec 2004 14:55:11 -0000
@@ -72,8 +72,7 @@ using std::vector;
 
 
 InsetText::InsetText(BufferParams const & bp)
-	: autoBreakRows_(false), drawFrame_(false),
-	  frame_color_(LColor::insetframe), text_(0)
+	: drawFrame_(false), frame_color_(LColor::insetframe), text_(0)
 {
 	paragraphs().push_back(Paragraph());
 	paragraphs().back().layout(bp.getLyXTextClass().defaultLayout());
@@ -86,7 +85,7 @@ InsetText::InsetText(BufferParams const 
 InsetText::InsetText(InsetText const & in)
 	: UpdatableInset(in), text_(in.text_.bv_owner)
 {
-	autoBreakRows_ = in.autoBreakRows_;
+	text_.autoBreakRows_ = in.text_.autoBreakRows_;
 	drawFrame_ = in.drawFrame_;
 	frame_color_ = in.frame_color_;
 	text_.paragraphs() = in.text_.paragraphs();
@@ -226,7 +225,7 @@ void InsetText::clearInset(Painter & pai
 
 void InsetText::updateLocal(LCursor & cur)
 {
-	if (!autoBreakRows_ && paragraphs().size() > 1) {
+	if (!text_.autoBreakRows_ && paragraphs().size() > 1) {
 		// collapse paragraphs
 		while (paragraphs().size() > 1) {
 			ParagraphList::iterator const first = paragraphs().begin();
@@ -409,8 +408,8 @@ void InsetText::setText(string const & d
 
 void InsetText::setAutoBreakRows(bool flag)
 {
-	if (flag != autoBreakRows_) {
-		autoBreakRows_ = flag;
+	if (flag != text_.autoBreakRows_) {
+		text_.autoBreakRows_ = flag;
 		if (!flag)
 			removeNewlines();
 	}
Index: insets/insettext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.h,v
retrieving revision 1.266
diff -u -p -r1.266 insettext.h
--- insets/insettext.h	30 Nov 2004 01:59:48 -0000	1.266
+++ insets/insettext.h	17 Dec 2004 14:55:11 -0000
@@ -86,7 +86,7 @@ public:
 	///
 	void setAutoBreakRows(bool);
 	///
-	bool getAutoBreakRows() const { return autoBreakRows_; }
+	bool getAutoBreakRows() const { return text_.autoBreakRows_; }
 	///
 	void setDrawFrame(bool);
 	///
@@ -157,8 +157,6 @@ private:
 	///
 	void clearInset(Painter &, int x, int y) const;
 
-	///
-	bool autoBreakRows_;
 	///
 	bool drawFrame_;
 	/** We store the LColor::color value as an int to get LColor.h out

Reply via email to