>>>>> "Jose'" == Jose' Matos <[EMAIL PROTECTED]> writes:

Jose'> On Thursday 27 January 2005 13:56, Jean-Marc Lasgouttes wrote:
>> This patch does the following:
Jose'> ...
>> Comments welcome.

Jose'>   It is amazing what a zero size patch can do, isn't it? ;-)

Grr.

Index: src/BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.568
diff -u -p -r1.568 BufferView_pimpl.C
--- src/BufferView_pimpl.C	24 Jan 2005 17:12:16 -0000	1.568
+++ src/BufferView_pimpl.C	27 Jan 2005 13:49:25 -0000
@@ -807,7 +807,7 @@ void BufferView::Pimpl::MenuInsertLyXFil
 	owner_->message(bformat(_("Inserting document %1$s..."), disp_fn));
 
 	bv_->cursor().clearSelection();
-	bv_->text()->breakParagraph(bv_->cursor());
+	bv_->getLyXText()->breakParagraph(bv_->cursor());
 
 	BOOST_ASSERT(bv_->cursor().inTexted());
 
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2100
diff -u -p -r1.2100 ChangeLog
--- src/ChangeLog	24 Jan 2005 17:12:17 -0000	1.2100
+++ src/ChangeLog	27 Jan 2005 13:49:27 -0000
@@ -1,7 +1,19 @@
+2005-01-27  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* BufferView_pimpl.C (MenuInsertLyXFile): do breakParagraph on the
+	LyXText containing the cursor, not the top-level one.
+
+	* buffer.C (Impl): make sure the toplevel insettext has AutoBreak_
+	true. 
+	(insertStringAsLines): rename par to pit; use temporary variable
+	par to hold a Paragraph; do not store par.layout() in a variable,
+	since the pointer may die when breaking paragraphs; pass pars to
+	breakParagraph() instead of Buffer::paragraphs().
+
 2005-01-24  Jürgen Spitzmüller  <[EMAIL PROTECTED]>
 
 	* LaTeXFeatures.[Ch]: Add a static list packages_ that
-	holds the contens of packages.lst. New functions getAvailable
+	holds the contents of packages.lst. New functions getAvailable
 	and isAvailable to parse and check that list, resp.
 	
 	* LyXAction.C:
Index: src/buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.607
diff -u -p -r1.607 buffer.C
--- src/buffer.C	24 Jan 2005 17:12:15 -0000	1.607
+++ src/buffer.C	27 Jan 2005 13:49:27 -0000
@@ -200,6 +200,7 @@ Buffer::Impl::Impl(Buffer & parent, stri
 	  filename(file), filepath(OnlyPath(file)), file_fully_loaded(false),
 		inset(params)
 {
+	inset.setAutoBreakRows(true);
 	lyxvc.buffer(&parent);
 	temppath = createBufferTmpDir();
 	// FIXME: And now do something if temppath == string(), because we
@@ -477,23 +478,22 @@ bool Buffer::readDocument(LyXLex & lex)
 
 // needed to insert the selection
 void Buffer::insertStringAsLines(ParagraphList & pars,
-	pit_type & par, pos_type & pos,
+	pit_type & pit, pos_type & pos,
 	LyXFont const & fn, string const & str, bool autobreakrows)
 {
-	LyXLayout_ptr const & layout = pars[par].layout();
-
 	LyXFont font = fn;
 
-	pars[par].checkInsertChar(font);
+	pars[pit].checkInsertChar(font);
 	// insert the string, don't insert doublespace
 	bool space_inserted = true;
 	for (string::const_iterator cit = str.begin();
-	    cit != str.end(); ++cit) {
+	    cit != str.end(); ++cit) { 
+		Paragraph & par = pars[pit];
 		if (*cit == '\n') {
-			if (autobreakrows && (!pars[par].empty() || pars[par].allowEmpty())) {
-				breakParagraph(params(), paragraphs(), par, pos,
-					       layout->isEnvironment());
-				++par;
+			if (autobreakrows && (!par.empty() || par.allowEmpty())) {
+				breakParagraph(params(), pars, pit, pos,
+					       par.layout()->isEnvironment());
+				++pit;
 				pos = 0;
 				space_inserted = true;
 			} else {
@@ -501,18 +501,18 @@ void Buffer::insertStringAsLines(Paragra
 			}
 			// do not insert consecutive spaces if !free_spacing
 		} else if ((*cit == ' ' || *cit == '\t') &&
-			   space_inserted && !pars[par].isFreeSpacing()) {
+			   space_inserted && !par.isFreeSpacing()) {
 			continue;
 		} else if (*cit == '\t') {
-			if (!pars[par].isFreeSpacing()) {
+			if (!par.isFreeSpacing()) {
 				// tabs are like spaces here
-				pars[par].insertChar(pos, ' ', font);
+				par.insertChar(pos, ' ', font);
 				++pos;
 				space_inserted = true;
 			} else {
 				const pos_type n = 8 - pos % 8;
 				for (pos_type i = 0; i < n; ++i) {
-					pars[par].insertChar(pos, ' ', font);
+					par.insertChar(pos, ' ', font);
 					++pos;
 				}
 				space_inserted = true;
@@ -522,7 +522,7 @@ void Buffer::insertStringAsLines(Paragra
 			continue;
 		} else {
 			// just insert the character
-			pars[par].insertChar(pos, *cit, font);
+			par.insertChar(pos, *cit, font);
 			++pos;
 			space_inserted = (*cit == ' ');
 		}

Reply via email to