Am Dienstag, 16. November 2004 03:47 schrieb Alfredo Braunstein:
> Georg Baum wrote:
> > Is the attached patch ok?
> 
> No, seems like you picked the wrong patch ;-) 

Ok, second try. It was obviously too late ;-)


Georg
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/frontends/controllers/ChangeLog lyx-1.4-cvs/src/frontends/controllers/ChangeLog
--- lyx-1.4-clean/src/frontends/controllers/ChangeLog	2004-11-09 20:08:09.000000000 +0100
+++ lyx-1.4-cvs/src/frontends/controllers/ChangeLog	2004-11-15 21:31:16.000000000 +0100
@@ -1,3 +1,7 @@
+2004-11-15  Georg Baum  <[EMAIL PROTECTED]>
+
+	* ControlTabular.C (initialiseParams): Compute the active cell
+
 2004-11-09  Georg Baum  <[EMAIL PROTECTED]>
 
 	* ControlInclude.C (browse): Use GetExtension() instead of
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/frontends/controllers/ControlTabular.C lyx-1.4-cvs/src/frontends/controllers/ControlTabular.C
--- lyx-1.4-clean/src/frontends/controllers/ControlTabular.C	2004-05-21 08:55:40.000000000 +0200
+++ lyx-1.4-cvs/src/frontends/controllers/ControlTabular.C	2004-11-15 15:54:55.000000000 +0100
@@ -10,7 +10,9 @@
 
 #include <config.h>
 
+#include "BufferView.h"
 #include "ControlTabular.h"
+#include "cursor.h"
 #include "funcrequest.h"
 #include "lyxrc.h"
 #include "paragraph.h"
@@ -29,12 +31,23 @@ ControlTabular::ControlTabular(Dialog & 
 
 bool ControlTabular::initialiseParams(string const & data)
 {
-	Buffer & buffer = kernel().buffer();
-
-	InsetTabular tmp(buffer);
-	int cell = InsetTabularMailer::string2params(data, tmp);
+	// try to get the current cell
+	BufferView const * const bv = kernel().bufferview();
+	int cell = -1;
+	if (bv) {
+		LCursor const & cur = bv->cursor();
+		// get the innermost tabular inset;
+		// assume that it is "ours"
+		for (int i = cur.size() - 1; i >= 0; --i)
+			if (cur[i].inset().lyxCode() == InsetBase::TABULAR_CODE) {
+				cell = cur[i].idx();
+				break;
+			}
+	}
+	InsetTabular tmp(kernel().buffer());
+	InsetTabularMailer::string2params(data, tmp);
+	params_.reset(new LyXTabular(tmp.tabular));
 	if (cell != -1) {
-		params_.reset(new LyXTabular(tmp.tabular));
 		active_cell_ = cell;
 	}
 	return true;
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/ChangeLog lyx-1.4-cvs/src/insets/ChangeLog
--- lyx-1.4-clean/src/insets/ChangeLog	2004-11-15 19:36:16.000000000 +0100
+++ lyx-1.4-cvs/src/insets/ChangeLog	2004-11-15 21:29:58.000000000 +0100
@@ -1,3 +1,8 @@
+2004-11-15  Georg Baum  <[EMAIL PROTECTED]>
+
+	* insettabular.[Ch] (string2params): Don't pretend to return the
+	active cell anymore and simplify keyword parsing.
+
 2004-11-10  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
 	* insetlatexaccent.h (isLetter): implement, so that word selection
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insettabular.C lyx-1.4-cvs/src/insets/insettabular.C
--- lyx-1.4-clean/src/insets/insettabular.C	2004-11-06 10:51:28.000000000 +0100
+++ lyx-1.4-cvs/src/insets/insettabular.C	2004-11-15 14:08:14.000000000 +0100
@@ -1762,64 +1769,37 @@ string const InsetTabularMailer::inset2s
 }
 
 
-int InsetTabularMailer::string2params(string const & in, InsetTabular & inset)
+void InsetTabularMailer::string2params(string const & in, InsetTabular & inset)
 {
 	istringstream data(in);
 	LyXLex lex(0,0);
 	lex.setStream(data);
 
-#ifdef WITH_WARNINGS
-#warning CHECK verify that this is a sane value to return.
-#endif
 	if (in.empty())
-		return -1;
+		return;
 
-	if (lex.isOK()) {
-		lex.next();
-		string const token = lex.getString();
-		if (token != name_)
-			return -1;
-	}
-
-	int cell = -1;
-	if (lex.isOK()) {
-		lex.next();
-		string const token = lex.getString();
-		if (token != "\\active_cell")
-			return -1;
-		lex.next();
-		cell = lex.getInteger();
-	}
+	string token;
+	lex >> token;
+	if (!lex || token != name_)
+		return print_mailer_error("InsetTabularMailer", in, 1,
+		                          name_);
 
 	// This is part of the inset proper that is usually swallowed
 	// by Buffer::readInset
-	if (lex.isOK()) {
-		lex.next();
-		string const token = lex.getString();
-		if (token != "Tabular")
-			return -1;
-	}
-
-	if (!lex.isOK())
-		return -1;
+	lex >> token;
+	if (!lex || token != "Tabular")
+		return print_mailer_error("InsetTabularMailer", in, 2,
+		                          "Tabular");
 
 	Buffer const & buffer = inset.buffer();
 	inset.read(buffer, lex);
-
-	// We can't set the active cell, but we can tell the frontend
-	// what it is.
-	return cell;
 }
 
 
 string const InsetTabularMailer::params2string(InsetTabular const & inset)
 {
 	ostringstream data;
-#ifdef WITH_WARNINGS
-#warning wrong!
-#endif
-	//data << name_ << " \\active_cell " << inset.getActCell() << '\n';
-	data << name_ << " \\active_cell " << 0 << '\n';
+	data << name_ << ' ';
 	inset.write(inset.buffer(), data);
 	data << "\\end_inset\n";
 	return data.str();
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insettabular.h lyx-1.4-cvs/src/insets/insettabular.h
--- lyx-1.4-clean/src/insets/insettabular.h	2004-10-25 19:50:23.000000000 +0200
+++ lyx-1.4-cvs/src/insets/insettabular.h	2004-11-15 14:00:05.000000000 +0100
@@ -205,8 +205,8 @@ public:
 	virtual std::string const & name() const { return name_; }
 	///
 	virtual std::string const inset2string(Buffer const &) const;
-	/// Returns the active cell if successful, else -1.
-	static int string2params(std::string const &, InsetTabular &);
+	///
+	static void string2params(std::string const &, InsetTabular &);
 	///
 	static std::string const params2string(InsetTabular const &);
 private:

Reply via email to