Jean-Marc Lasgouttes wrote:
> Well, the real type is idx_type, so I think it is better than size_t.
> I think that the places that use size_t do that to avoid pulling a big
> header.

This has turned out as a can of worms for me. I get tons of error messages 
which I do not understand. So I'd appreciate some help (maybe from someone 
who builds on a 64bit System). Please feel free to do the relevant int -> 
idx_type changes.

BTW I also encountered an incompatibility between the xforms and qt frontend: 
the xforms frontend has a "use minipage" checkbox, while the qt frontend 
hasn't. I think we should do something about that, either remove the minipage 
thing in xforms or add it in qt. Comments? (Personally, I vote for removing).

Furthermore, there is some compatibility code in tabular.C (1294ff). 
Georg/José, shouldn't this be handled by lyx2lyx?

Finally, please have a look at the attached patch. I cannot see why we 
couldn't simplify the code like this. Can I apply this? (The int -> idx_type 
changes should be done, but we have this problem already with the multicolumn 
code).

Regards,
Jürgen
Index: insets/insettabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.445
diff -u -r1.445 insettabular.C
--- insets/insettabular.C	25 Nov 2004 19:13:05 -0000	1.445
+++ insets/insettabular.C	27 Nov 2004 18:22:56 -0000
@@ -1178,6 +1178,8 @@
 	recordUndo(cur, Undo::ATOMIC);
 
 	getSelection(cur, sel_row_start, sel_row_end, sel_col_start, sel_col_end);
+	CursorSlice::idx_type const sel_cell_start = cur.selBegin().idx();
+	CursorSlice::idx_type const sel_cell_end = cur.selEnd().idx();
 	int const row = tabular.row_of_cell(cur.idx());
 	int const column = tabular.column_of_cell(cur.idx());
 	bool flag = true;
@@ -1242,11 +1244,8 @@
 		flag = false;
 	case LyXTabular::TOGGLE_LINE_TOP: {
 		bool lineSet = !tabular.topLine(cur.idx(), flag);
-		for (int i = sel_row_start; i <= sel_row_end; ++i)
-			for (int j = sel_col_start; j <= sel_col_end; ++j)
-				tabular.setTopLine(
-					tabular.getCellNumber(i, j),
-					lineSet, flag);
+		for (size_t i = sel_cell_start; i <= sel_cell_end; ++i)
+			tabular.setTopLine(i, lineSet, flag);
 		break;
 	}
 
@@ -1254,12 +1253,8 @@
 		flag = false;
 	case LyXTabular::TOGGLE_LINE_BOTTOM: {
 		bool lineSet = !tabular.bottomLine(cur.idx(), flag);
-		for (int i = sel_row_start; i <= sel_row_end; ++i)
-			for (int j = sel_col_start; j <= sel_col_end; ++j)
-				tabular.setBottomLine(
-					tabular.getCellNumber(i, j),
-					lineSet,
-					flag);
+		for (size_t i = sel_cell_start; i <= sel_cell_end; ++i)
+			tabular.setBottomLine(i, lineSet, flag);
 		break;
 	}
 
@@ -1267,12 +1262,8 @@
 		flag = false;
 	case LyXTabular::TOGGLE_LINE_LEFT: {
 		bool lineSet = !tabular.leftLine(cur.idx(), flag);
-		for (int i = sel_row_start; i <= sel_row_end; ++i)
-			for (int j = sel_col_start; j <= sel_col_end; ++j)
-				tabular.setLeftLine(
-					tabular.getCellNumber(i,j),
-					lineSet,
-					flag);
+		for (size_t i = sel_cell_start; i <= sel_cell_end; ++i)
+			tabular.setLeftLine(i, lineSet, flag);
 		break;
 	}
 
@@ -1280,12 +1271,8 @@
 		flag = false;
 	case LyXTabular::TOGGLE_LINE_RIGHT: {
 		bool lineSet = !tabular.rightLine(cur.idx(), flag);
-		for (int i = sel_row_start; i <= sel_row_end; ++i)
-			for (int j = sel_col_start; j <= sel_col_end; ++j)
-				tabular.setRightLine(
-					tabular.getCellNumber(i,j),
-					lineSet,
-					flag);
+		for (size_t i = sel_cell_start; i <= sel_cell_end; ++i)
+			tabular.setRightLine(i, lineSet, flag);
 		break;
 	}
 
@@ -1297,12 +1284,8 @@
 	case LyXTabular::ALIGN_RIGHT:
 	case LyXTabular::ALIGN_CENTER:
 	case LyXTabular::ALIGN_BLOCK:
-		for (int i = sel_row_start; i <= sel_row_end; ++i)
-			for (int j = sel_col_start; j <= sel_col_end; ++j)
-				tabular.setAlignment(
-					tabular.getCellNumber(i, j),
-					setAlign,
-					flag);
+		for (size_t i = sel_cell_start; i <= sel_cell_end; ++i)
+			tabular.setAlignment(i, setAlign, flag);
 		break;
 
 	case LyXTabular::M_VALIGN_TOP:
@@ -1312,11 +1295,8 @@
 	case LyXTabular::VALIGN_TOP:
 	case LyXTabular::VALIGN_BOTTOM:
 	case LyXTabular::VALIGN_MIDDLE:
-		for (int i = sel_row_start; i <= sel_row_end; ++i)
-			for (int j = sel_col_start; j <= sel_col_end; ++j)
-				tabular.setVAlignment(
-					tabular.getCellNumber(i, j),
-					setVAlign, flag);
+		for (size_t i = sel_cell_start; i <= sel_cell_end; ++i)
+			tabular.setVAlignment(i, setVAlign, flag);
 		break;
 
 	case LyXTabular::MULTICOLUMN: {
@@ -1339,10 +1319,9 @@
 		}
 		// we have a selection so this means we just add all this
 		// cells to form a multicolumn cell
-		CursorSlice::idx_type const s_start = cur.selBegin().idx();
-		CursorSlice::idx_type const s_end = cur.selEnd().idx();
-		tabular.setMultiColumn(bv.buffer(), s_start, s_end - s_start + 1);
-		cur.idx() = s_start;
+		tabular.setMultiColumn(bv.buffer(), sel_cell_start, 
+			sel_cell_end - sel_cell_start + 1);
+		cur.idx() = sel_cell_start;
 		cur.pit() = 0;
 		cur.pos() = 0;
 		cur.selection() = false;
@@ -1351,14 +1330,12 @@
 
 	case LyXTabular::SET_ALL_LINES:
 		setLines = true;
-	case LyXTabular::UNSET_ALL_LINES:
-#if 0
-		for (int i = sel_row_start; i <= sel_row_end; ++i)
-			for (int j = sel_col_start; j <= sel_col_end; ++j)
-				tabular.setAllLines(
-					tabular.getCellNumber(i,j), setLines);
-#endif
+	
+	case LyXTabular::UNSET_ALL_LINES: {
+		for (size_t i = sel_cell_start; i <= sel_cell_end; ++i)
+			tabular.setAllLines(i, setLines);
 		break;
+	}
 
 	case LyXTabular::SET_LONGTABULAR:
 		tabular.setLongTabular(true);
@@ -1377,26 +1354,21 @@
 		break;
 
 	case LyXTabular::SET_ROTATE_CELL:
-		for (int i = sel_row_start; i <= sel_row_end; ++i)
-			for (int j = sel_col_start; j <= sel_col_end; ++j)
-				tabular.setRotateCell(
-					tabular.getCellNumber(i, j), true);
+		for (size_t i = sel_cell_start; i <= sel_cell_end; ++i)
+			tabular.setRotateCell(i, true);
 		break;
 
 	case LyXTabular::UNSET_ROTATE_CELL:
-		for (int i = sel_row_start; i <= sel_row_end; ++i)
-			for (int j = sel_col_start; j <= sel_col_end; ++j)
-				tabular.setRotateCell(
-					tabular.getCellNumber(i, j), false);
+		for (size_t i = sel_cell_start; i <= sel_cell_end; ++i)
+			tabular.setRotateCell(i, false);
 		break;
 
 	case LyXTabular::SET_USEBOX: {
 		LyXTabular::BoxType val = LyXTabular::BoxType(strToInt(value));
 		if (val == tabular.getUsebox(cur.idx()))
 			val = LyXTabular::BOX_NONE;
-		for (int i = sel_row_start; i <= sel_row_end; ++i)
-			for (int j = sel_col_start; j <= sel_col_end; ++j)
-				tabular.setUsebox(tabular.getCellNumber(i, j), val);
+		for (size_t i = sel_cell_start; i <= sel_cell_end; ++i)
+			tabular.setUsebox(i, val);
 		break;
 	}
 

Reply via email to