Jean-Marc Lasgouttes wrote:

> Wouldn't it be safer to define a Tabular::operator= and update the
> pointers there? Or it is that I do not know what I am talking about?

This would be it. Do I feel more comfortable? Not much, as now one has to
remember to add a member variable to this list (and hopefully I didn't miss
one in the first place). What do you think?

A/


Index: insets/InsetTabular.h
===================================================================
--- insets/InsetTabular.h	(revision 24894)
+++ insets/InsetTabular.h	(working copy)
@@ -236,6 +236,10 @@
 
 	/// constructor
 	Tabular(Buffer const &, col_type columns_arg, row_type rows_arg);
+	/// 
+	Tabular(Tabular const & other);
+	/// 
+	Tabular & operator=(Tabular const & other);
 
 	/// Returns true if there is a topline, returns false if not
 	bool topLine(idx_type cell) const;
Index: insets/InsetTabular.cpp
===================================================================
--- insets/InsetTabular.cpp	(revision 24894)
+++ insets/InsetTabular.cpp	(working copy)
@@ -573,6 +573,38 @@
 }
 
 
+Tabular::Tabular(Tabular const & other)
+{
+	*this = other;
+}
+
+
+Tabular & Tabular::operator=(Tabular const & other)
+{
+	numberofcells = other.numberofcells;
+	buffer_ = other.buffer_;
+	rowofcell = other.rowofcell;
+	columnofcell = other.columnofcell;
+	row_info = other.row_info;
+	column_info = other.column_info;
+	cell_info = other.cell_info;
+	use_booktabs = other.use_booktabs;
+	rotate = other.rotate;
+	is_long_tabular = other.is_long_tabular;
+	endhead = other.endhead;
+	endfirsthead = other.endfirsthead;
+	endfoot = other.endfoot;
+	endlastfoot = other.endlastfoot;
+
+	size_t row_count = row_info.size();
+	size_t column_count = column_info.size();
+	for (row_type i = 0; i < row_count; ++i) {
+		for (col_type j = 0; j < column_count; ++j)
+			cell_info[i][j].inset->setTabular(this);
+	}
+}
+
+
 // activates all lines and sets all widths to 0
 void Tabular::init(Buffer const & buf, row_type rows_arg,
 		      col_type columns_arg)
@@ -591,13 +623,14 @@
 	size_t row_count = row_info.size();
 	size_t column_count = column_info.size();
 	// set silly default lines
-	for (row_type i = 0; i < row_count; ++i)
+	for (row_type i = 0; i < row_count; ++i) {
 		for (col_type j = 0; j < column_count; ++j) {
 			cell_info[i][j].top_line = true;
 			cell_info[i][j].left_line = true;
 			cell_info[i][j].bottom_line = i == 0 || i == row_count - 1;
 			cell_info[i][j].right_line = j == column_count - 1;
 		}
+	}
 }
 
 

Reply via email to