Hi lyx-devel,

  Attaching patch (created using svn diff within src/insets/) for 
review/comments. Based on this I can submit a patch that includes 
split-below-row, split-before-column, and split-after-column.

   To test this feature, create and populate a table, enter any cell, and 
enter the following command into the command buffer:

   inset-modify tabular split-above-row

Thanks,
Manoj
Index: InsetTabular.h
===================================================================
--- InsetTabular.h	(revision 33603)
+++ InsetTabular.h	(working copy)
@@ -190,6 +190,8 @@
 		///
 		LONGTABULAR_ALIGN_RIGHT,
 		///
+		SPLIT_ABOVE_ROW,
+		///
 		LAST_ACTION
 	};
 	///
Index: InsetTabular.cpp
===================================================================
--- InsetTabular.cpp	(revision 33603)
+++ InsetTabular.cpp	(working copy)
@@ -175,6 +175,7 @@
 	{ Tabular::LONGTABULAR_ALIGN_LEFT, "longtabular-align-left", false },
 	{ Tabular::LONGTABULAR_ALIGN_CENTER, "longtabular-align-center", false },
 	{ Tabular::LONGTABULAR_ALIGN_RIGHT, "longtabular-align-right", false },
+	{ Tabular::SPLIT_ABOVE_ROW, "split-above-row", false },
 	{ Tabular::LAST_ACTION, "", false }
 };
 
@@ -4277,6 +4278,12 @@
 			status.setOnOff(!tabular.use_booktabs);
 			break;
 
+		case Tabular::SPLIT_ABOVE_ROW: {
+			row_type const row = tabular.cellRow(cur.idx());
+			status.setEnabled(row > 0);
+			break;
+		}
+
 		default:
 			status.clear();
 			status.setEnabled(false);
@@ -5257,6 +5264,23 @@
 		break;
 	}
 
+	case Tabular::SPLIT_ABOVE_ROW: {
+		row_type const row = tabular.cellRow(cur.idx());
+		col_type const col = tabular.cellColumn(cur.idx());
+		row_type const last = tabular.row_info.size() - 1;
+		InsetTabular *topPart = new InsetTabular(*this);
+		// *this keeps all the bottom rows
+		for(row_type r = 0; r < row; ++r)
+			tabular.deleteRow(0);
+		for(row_type r = row; r <= last; ++r)
+			topPart->tabular.deleteRow(row);
+		cur.pop();
+		cur.insert(topPart);
+		cur.posForward();
+		cur.text()->breakParagraph(cur);
+		break;
+	}
+
 	// dummy stuff just to avoid warnings
 	case Tabular::LAST_ACTION:
 		break;

Reply via email to