Am Montag, 15. November 2004 15:05 schrieb Alfredo Braunstein:
> I thought that dialogs were associated with insets somehow. No idea 
how ;-)

The only connection I found so far is parameter exchange via the mailers 
in string form.

> We could just apply the change to the most inner InsetTabular. Would 
this be
> acceptable behaviour?

Yes.

> Something like
> 
> for (unsigned i = cur.size() - 1; i >= 0; --i)
>         if (cur[i].inset().lyxCode() == InsetBase::TABULAR_CODE) {
>                 in = cur[i].inset();
>                 idx = cur[i].idx();
>                 ...
>         }       

It works! Even with nested tables. I changed the keyword parsing in 
InsetTabularMailer::string2params() so that it is similar to 
InsetGraphicsMailer::string2params(), because we don't have the special 
return value -1 anymore.

Is the attached patch ok?


Georg
Index: src/insets/insettabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.439.4.1
diff -u -p -r1.439.4.1 insettabular.C
--- src/insets/insettabular.C	11 Nov 2004 19:09:08 -0000	1.439.4.1
+++ src/insets/insettabular.C	13 Nov 2004 20:45:52 -0000
@@ -156,13 +156,13 @@ bool InsetTabular::hasPasteBuffer() cons
 
 InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
 	: tabular(buf.params(), max(rows, 1), max(columns, 1)),
-	  buffer_(&buf), cursorx_(0)
+	  buffer_(&buf), cursorx_(0), actcell(0)
 {}
 
 
 InsetTabular::InsetTabular(InsetTabular const & tab)
 	: UpdatableInset(tab), tabular(tab.tabular),
-		buffer_(tab.buffer_), cursorx_(0)
+		buffer_(tab.buffer_), cursorx_(0), actcell(0)
 {}
 
 
@@ -963,6 +963,12 @@ InsetText & InsetTabular::cell(int idx)
 }
 
 
+int InsetTabular::getActCell() const
+{
+	return actcell;
+}
+
+
 void InsetTabular::getCursorPos(LCursor const & cur, int & x, int & y) const
 {
 	cell(cur.idx()).getCursorPos(cur, x, y);
@@ -981,7 +987,7 @@ InsetBase * InsetTabular::setPos(LCursor
 			idx_min = i;
 		}
 	}
-	cur.idx() = idx_min;
+	actcell = cur.idx() = idx_min;
 	InsetBase * inset = cell(cur.idx()).text_.editXY(cur, x, y);
 	//lyxerr << "# InsetTabular::setPos()\n" << cur << endl;
 	return inset;
@@ -1005,6 +1011,7 @@ int InsetTabular::getCellXPos(int cell) 
 void InsetTabular::resetPos(LCursor & cur) const
 {
 	BufferView & bv = cur.bv();
+	actcell = cur.idx();
 	int const actcol = tabular.column_of_cell(cur.idx());
 	int const offset = ADD_TO_TABULAR_WIDTH + 2;
 	int const new_x = getCellXPos(cur.idx()) + offset;
@@ -1833,11 +1840,7 @@ int InsetTabularMailer::string2params(st
 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_ << " \\active_cell " << inset.getActCell() << '\n';
 	inset.write(inset.buffer(), data);
 	data << "\\end_inset\n";
 	return data.str();
Index: src/insets/insettabular.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.h,v
retrieving revision 1.194
diff -u -p -r1.194 insettabular.h
--- src/insets/insettabular.h	23 Oct 2004 09:46:33 -0000	1.194
+++ src/insets/insettabular.h	13 Nov 2004 20:45:53 -0000
@@ -111,6 +111,8 @@ public:
 	///
 	InsetText & cell(int);
 	///
+	int getActCell() const;
+	///
 	LyXText * getText(int) const;
 
 	///
@@ -189,6 +191,8 @@ private:
 	mutable int cursorx_;
 	///
 	mutable int first_visible_cell;
+	///
+	mutable int actcell;
 };
 
 

Reply via email to