parent_layer);
parent_layer, top_state->table_nesting_level);
lo_EndTable(MWContext *context, lo_DocState *state, lo_TableRec *table, Bool relayout){	int32 save_doc_min_width;	int32 x, y;	int32 cell_x, cell_y;	int32 indx;	int32 cell_cnt;	int32 ele_cnt;	int32 table_width, min_table_width;	int32 base_table_width, min_base_table_width;	int32 table_height;	int32 min_table_height;	int32 width_limit;	Bool relayout_pass;	Bool rowspan_pass;	Bool cut_to_window_width;	lo_TableCell blank_cell;	lo_cell_data XP_HUGE *cell_array;	XP_Block cell_array_buff;	lo_table_span *row_max;	lo_table_span *col_max;	lo_TableCell *cell_ptr;	int32 cell_pad;	int32 top_inner_pad;	int32 bottom_inner_pad;	int32 left_inner_pad;	int32 right_inner_pad;	int32 table_pad;	Bool floating;	int32 save_state_x, save_state_y;	LO_Element *save_line_list;#ifdef LOCAL_DEBUGfprintf(stderr, "lo_EndTable called\n");#endif /* LOCAL_DEBUG */	cell_pad = FEUNITS_X(table->inter_cell_pad, context);	table_pad = FEUNITS_X(TABLE_DEF_CELL_BORDER, context);		top_inner_pad = FEUNITS_X(table->inner_top_pad, context);	bottom_inner_pad = FEUNITS_X(table->inner_bottom_pad, context);	left_inner_pad = FEUNITS_X(table->inner_left_pad, context);	right_inner_pad = FEUNITS_X(table->inner_right_pad, context);		relayout_pass = FALSE;	cut_to_window_width = TRUE;	floating = FALSE;	/*	 * So gcc won't complain	 */	save_state_x = 0;	save_state_y = 0;	save_line_list = NULL;/*	state->current_table = NULL;*/	cell_cnt = table->rows * table->cols;	/*	 * Empty tables are completely ignored!	 */	if (cell_cnt <= 0)	{		/*		 * Clear table state, and free up this structure.		 */		state->current_table = NULL;		/* 		 * Don't wanna free table record any more because this information		 * is used during relayout.		 */		/*		if (table != NULL)		{			lo_free_table_record(context, state, table, FALSE);		}		  		*/		return;	}#ifdef XP_WIN16	/*	 * It had better be the case that the size of the struct is a	 * power of 2	 */	XP_ASSERT(sizeof(lo_cell_data) == 8);	cell_array = (lo_cell_data XP_HUGE *)_halloc(cell_cnt, sizeof(lo_cell_data));	/*	 * There isn't a runtime routine that can initialize a huge array	 */	if (cell_cnt * sizeof(lo_cell_data) <= 0xFFFFL)		memset(cell_array, 0, (cell_cnt * sizeof(lo_cell_data)));	else {		BYTE XP_HUGE *tmp = (BYTE XP_HUGE *)cell_array;		for (indx = 0; indx < cell_cnt * sizeof(lo_cell_data); indx++)			tmp[indx] = 0;	}#else	cell_array_buff = XP_ALLOC_BLOCK(cell_cnt * sizeof(lo_cell_data));	XP_LOCK_BLOCK(cell_array, lo_cell_data *, cell_array_buff);	memset(cell_array, 0, (cell_cnt * sizeof(lo_cell_data)));#endif	lo_fill_cell_array(table, cell_array, &blank_cell, cell_pad,		&relayout_pass);	table_width = 0;	min_table_width = 0;	base_table_width = 0;	min_base_table_width = 0;	col_max = table->width_spans;	while (col_max != NULL)	{		base_table_width += col_max->dim;		min_base_table_width += col_max->min_dim;		table_width = table_width + cell_pad + col_max->dim;		min_table_width = min_table_width + cell_pad + col_max->min_dim;		col_max = col_max->next;	}	table_width += cell_pad;	min_table_width += cell_pad;	table_width += (table->table_ele->border_left_width + 		table->table_ele->border_right_width);	min_table_width += (table->table_ele->border_left_width + 		table->table_ele->border_right_width);	if (table->draw_borders == TABLE_BORDERS_OFF)	{		table_width += (2 * table_pad);		min_table_width += (2 * table_pad);	}	/*	 * Take care of cells with percentage widths unless we're in	 * a fixed layout table (has the COLS attribute) in which case	 * the cell widths are already set.	 */	if ((table->has_percent_width_cells != FALSE) &&		(table->fixed_cols == 0))	{		lo_percent_width_cells(table, cell_array, &blank_cell,			cell_pad, table_pad, &table_width, &min_table_width,			&base_table_width, &min_base_table_width);		relayout_pass = TRUE;	}	/*	 * Use state->left_margin here instead of state->win_left to take	 * indent from lists into account.	 */	width_limit = (state->win_width - state->left_margin - state->win_right);	if (table->width > 0)	{		width_limit = table->width;	}	/*	 * Else, if we are a nested table in an infinite width	 * layout space, we don't want to cut to "window width"	 */	else if (state->allow_percent_width == FALSE)	{		cut_to_window_width = FALSE;	}	/*	 * If we're in a fixed layout table, then we never	 * want to cut to "window width" 	 */	if ( table->fixed_cols > 0 )	{		cut_to_window_width = FALSE;	}	/*	 * If the table is too small, we always need to relayout.	 */	if ((min_table_width >= width_limit))	{		lo_table_span *sub_ptr;		relayout_pass = TRUE;		sub_ptr = table->width_spans;		while (sub_ptr != NULL)		{			sub_ptr->dim = sub_ptr->min_dim;			sub_ptr = sub_ptr->next;		}	}	else if ((table_width > width_limit)&&(cut_to_window_width != FALSE))	{		intn pass;		Bool expand_failed;		int32 add_width;		int32 div_width;		int32 div_width_next;		int32 add;		int32 total_to_add;		lo_table_span *add_ptr;		relayout_pass = TRUE;		expand_failed = TRUE;		pass = 0;		total_to_add = width_limit - min_table_width;		div_width = table_width;		while ((total_to_add > 0)&&(pass < 10)&&(expand_failed !=FALSE))		{			int32 extra;			int32 min_extra;			expand_failed = FALSE;			add_ptr = table->width_spans;			add_width = total_to_add;			total_to_add = 0;			div_width_next = (table->cols + 1) * cell_pad;			add = 0;			while (add_ptr->next != NULL)			{				if ((pass > 0)&&					(add_ptr->min_dim == add_ptr->dim))				{					add_ptr = add_ptr->next;					continue;				}				extra = add_width * add_ptr->dim /					div_width;				if ((add_ptr->min_dim + extra) > add_ptr->dim)				{					expand_failed = TRUE;					min_extra = add_ptr->dim -						add_ptr->min_dim;					extra = min_extra;				}				add_ptr->min_dim += extra;				if (add_ptr->min_dim < add_ptr->dim)				{					div_width_next += add_ptr->dim;				}				add += extra;				add_ptr = add_ptr->next;			}			if ((pass == 0)||(add_ptr->min_dim < add_ptr->dim))			{				if (expand_failed == FALSE)				{					extra = add_width - add;				}				else				{					extra = add_width * add_ptr->dim /						div_width;				}				if ((add_ptr->min_dim + extra) > add_ptr->dim)				{					expand_failed = TRUE;					min_extra = add_ptr->dim -						add_ptr->min_dim;					extra = min_extra;				}				add_ptr->min_dim += extra;				if (add_ptr->min_dim < add_ptr->dim)				{					div_width_next += add_ptr->dim;				}				add += extra;			}			total_to_add = add_width - add;			div_width = div_width_next;			pass++;		}		if (total_to_add > 0)		{			add = 0;			add_ptr = table->width_spans;			while ((add_ptr->next != NULL)&&(total_to_add > 0))			{				if ((add_ptr->min_dim + total_to_add) >					add_ptr->dim)				{					add = add_ptr->dim - add_ptr->min_dim;					total_to_add = total_to_add - add;					add_ptr->min_dim += add;				}				else				{					add_ptr->min_dim += total_to_add;					total_to_add = 0;				}				add_ptr = add_ptr->next;			}			add_ptr->min_dim += total_to_add;		}		add_ptr = table->width_spans;		while (add_ptr != NULL)		{			add_ptr->dim = add_ptr->min_dim;			add_ptr = add_ptr->next;		}	}	/*	 * If the user specified a wider width than the minimum	 * width then we grow the sucker.	 */	if ((table->width > 0)&&(width_limit > table_width))	{		int32 add_width;		int32 add;		int32 newWidth;		int32 min_add_width;		int32 min_add;		lo_table_span *add_ptr;		/* relayout to fill all the space we're adding */		relayout_pass = TRUE;				add_ptr = table->width_spans;		add_width = width_limit - table_width;		if ( add_width < 0 )		{			add_width = 0;		}		add = 0;		min_add_width = width_limit - min_table_width;		min_add = 0;		while ((add_ptr != NULL)&&(add_ptr->next != NULL))		{			newWidth = add_width * add_ptr->dim / base_table_width;			add_ptr->dim += newWidth;			add += newWidth;			/*			 * We only want to resize the min_dim's of the spans			 * if we're a fixed width table.			 */			if ( table->table_width_fixed )			{				newWidth = min_add_width * add_ptr->min_dim / min_base_table_width;				add_ptr->min_dim += newWidth;				min_add += newWidth;			}			add_ptr = add_ptr->next;		}		if ( table->table_width_fixed )		{			add_ptr->min_dim += (min_add_width - min_add);		}		add_ptr->dim += (add_width - add);	}	rowspan_pass = FALSE;	if ((state->top_state->doc_state == state) ||		(state->top_state->in_cell_relayout == TRUE))	{		if (state->top_state->doc_state == state)		{			state->top_state->in_cell_relayout = TRUE;		}				if (relayout_pass != FALSE)		{				lo_cell_relayout_pass(context, state, table, cell_array,				&blank_cell, cell_pad, &rowspan_pass, relayout);			}		if (rowspan_pass != FALSE)		{			lo_cell_rowspan_pass(context, table, cell_array, &blank_cell,				cell_pad);		}		if (state->top_state->doc_state == state)		{			state->top_state->in_cell_relayout = FALSE;		}	}	table_width = 0;	min_table_width = 0;	col_max = table->width_spans;	while (col_max != NULL)	{		table_width = table_width + cell_pad + col_max->dim;		min_table_width = min_table_width + cell_pad + col_max->min_dim;		col_max = col_max->next;	}	table_width += cell_pad;	table_width += (table->table_ele->border_left_width + 		table->table_ele->border_right_width);	min_table_width += cell_pad;	min_table_width += (table->table_ele->border_left_width + 		table->table_ele->border_right_width);	table_height = 0;	min_table_height = 0;	row_max = table->height_spans;	while (row_max != NULL)	{		table_height = table_height + cell_pad + row_max->dim;		min_table_height = min_table_height + cell_pad + row_max->min_dim;		row_max = row_max->next;	}	table_height += cell_pad;	min_table_height += cell_pad;	table_height += (table->table_ele->border_top_width + 		table->table_ele->border_bottom_width);	min_table_height += (table->table_ele->border_top_width + 		table->table_ele->border_bottom_width);	if (table->draw_borders == TABLE_BORDERS_OFF)	{		table_width += (2 * table_pad);		min_table_width += (2 * table_pad);		table_height += (2 * table_pad);		min_table_height += (2 * table_pad);	}	/*	 * If the user specified a taller table than the min	 * height we need to adjust the heights of all the rows.	 */	if ((table->height > 0)&&(table->height > min_table_height))	{		int32 add_height;		int32 add;		lo_table_span *add_ptr;		int32 newHeight;		int32 min_add_height;		int32 min_add;		add_ptr = table->height_spans;		add_height = table->height - table_height;		if ( add_height < 0 )		{			add_height = 0;		}		min_add_height = table->height - min_table_height;		add = 0;		min_add = 0;		while((add_ptr != NULL) && (add_ptr->next != NULL))		{			newHeight = add_height * add_ptr->dim / table_height;			add_ptr->dim += newHeight;			add += newHeight;						newHeight = min_add_height * add_ptr->min_dim / table_height;			add_ptr->min_dim += newHeight;			min_add += newHeight;						add_ptr = add_ptr->next;		}		add_ptr->dim += (add_height - add);		add_ptr->min_dim += (min_add_height - min_add);		/*		 * We can't make the height be less than the sum		 * of the row heights.		 */		if (table_height < table->height)		{			table_height = table->height;		}		min_table_height = table->height;	}	table->table_ele->width = table_width;	table->table_ele->height = table_height;	/*	 * Here, if we are floating we don't do the linebreak.	 * We do save some state info and then "fake" a linebreak	 * so we can use common code to place the rest of the table.	 */	if (table->table_ele->ele_attrmask & LO_ELE_FLOATING)	{		save_line_list = state->line_list;		save_state_x = state->x;		save_state_y = state->y;		floating = TRUE;		state->x = state->left_margin;		state->y = state->y + state->line_height;		state->line_list = NULL;	}	else	{		/*		lo_SetSoftLineBreakState(context, state, FALSE, 1);		*/		lo_SetLineBreakState ( context, state, FALSE, LO_LINEFEED_BREAK_SOFT, 1, relayout );	}	table->table_ele->x = state->x;	table->table_ele->y = state->y;	/* Keep the element IDs in order */	table->table_ele->ele_id = NEXT_ELEMENT;        /*cmanske - Save spacing param for drawing table selection in Composer */    table->table_ele->inter_cell_space = table->inter_cell_pad;	lo_AppendToLineList(context, state,		(LO_Element *)table->table_ele, 0);#ifdef EDITOR    /*cmanske - build list of tables we are laying out     * so Editor can readjust it's data after all is finished      */    EDT_AddToRelayoutTables(context, table->table_ele);#endif	state->x += (cell_pad + table->table_ele->border_left_width);	state->y += (cell_pad + table->table_ele->border_top_width);	if (table->draw_borders == TABLE_BORDERS_OFF)	{		state->x += table_pad;		state->y += table_pad;	}	if (table->caption != NULL)	{		int32 new_width;		LO_SubDocStruct *subdoc;		Bool has_elements;		subdoc = table->caption->subdoc;		col_max = table->width_spans;		new_width = col_max->dim;		while (col_max->next != NULL)		{			col_max = col_max->next;			new_width = new_width + cell_pad + col_max->dim;		}		/*		 * Don't relayout documents that have no		 * elements, it causes errors.		 */		has_elements = lo_subdoc_has_elements(subdoc->state);		if ((new_width < table->caption->max_width)&&			(has_elements == FALSE))		{			int32 inside_width;			inside_width = new_width -			    (2 * subdoc->border_width) -			    (2 * subdoc->border_horiz_space) -			    (left_inner_pad + right_inner_pad);			subdoc->width = inside_width;		}		else /* if (new_width < table->caption->max_width) */		{			int32 inside_width;			inside_width = new_width -			    (2 * subdoc->border_width) -			    (2 * subdoc->border_horiz_space) -			    (left_inner_pad + right_inner_pad);			table->caption->subdoc = lo_RelayoutCaptionSubdoc(context,				state, table->caption, subdoc, inside_width, FALSE);			subdoc = table->caption->subdoc;			table->caption->height = subdoc->height +				(2 * subdoc->border_vert_space) +				(top_inner_pad + bottom_inner_pad);			table->caption->max_width = new_width;		}		/*		else		{			table->caption->max_width = new_width;		}		*/	}	state->current_table = NULL;	cell_x = state->x;	cell_y = state->y;	if ((table->caption != NULL)&&		(table->caption->vert_alignment == LO_ALIGN_TOP))	{		LO_SubDocStruct *subdoc;		cell_x = state->x;		subdoc = table->caption->subdoc;		subdoc->x = cell_x;		subdoc->y = table->table_ele->y;		subdoc->x_offset = (int16)subdoc->border_horiz_space;		subdoc->y_offset = (int32)subdoc->border_vert_space;		subdoc->width = table->caption->max_width -			(2 * subdoc->border_horiz_space);		subdoc->height = table->caption->height -			(2 * subdoc->border_vert_space);		ele_cnt = lo_align_subdoc(context, state,			(lo_DocState *)subdoc->state, subdoc, table, NULL);		if (ele_cnt > 0)		{			LO_CellStruct *cell_ele;						if (relayout == FALSE)			{				/*				cell_ele = lo_SquishSubDocToCell(context, state,					subdoc, TRUE);				*/				cell_ele = lo_SquishSubDocToCell(context, state,					subdoc, FALSE);				cell_ele->isCaption = TRUE;				table->caption->cell_ele = cell_ele;			}			else			{				cell_ele = table->caption->cell_ele;				lo_UpdateCaptionCellFromSubDoc(context, state, subdoc, cell_ele);			}			/* table->caption->subdoc = NULL; */			if (cell_ele == NULL)			{				lo_AppendToLineList(context, state,					(LO_Element *)subdoc, 0);			}			else			{                /*cmanske - Save spacing param for drawing cell selection by FEs */                /* should we use cell_pad (converted to FE units) instead? */                cell_ele->inter_cell_space = table->inter_cell_pad;				lo_AppendToLineList(context, state,					(LO_Element *)cell_ele, 0);			}			cell_x = state->x;			cell_y = cell_y + table->caption->height + cell_pad;			table->table_ele->y_offset = cell_y -				table->table_ele->y;			cell_y += (cell_pad + table->table_ele->border_top_width);			if (table->draw_borders == TABLE_BORDERS_OFF)			{				cell_y += table_pad;			}		}		else		{			LO_CellStruct *cell_ele;			/*			 * Free up the useless subdoc			 */			cell_ele = lo_SquishSubDocToCell(context, state,						subdoc, TRUE);			table->caption->subdoc = NULL;			if (cell_ele != NULL)			{				lo_FreeElement(context,					(LO_Element *)cell_ele, TRUE);			}		}	}	row_max = table->height_spans;	for (y=0; y < table->rows; y++)	{		cell_x = state->x;		col_max = table->width_spans;		for (x=0; x < table->cols; x++)		{			LO_CellStruct *cell_struct;			int32 new_x, new_y;			indx = (y * table->cols) + x;			cell_ptr = cell_array[indx].cell;			if ((cell_ptr == &blank_cell)||(cell_ptr == NULL))			{				cell_x = cell_x + col_max->dim + cell_pad;				col_max = col_max->next;				continue;			}			cell_struct = cell_ptr->cell;/*			cell_struct->x = cell_x;			cell_struct->y = cell_y;			cell_struct->x_offset = (int16)cell_struct->border_horiz_space;			cell_struct->y_offset = (int32)cell_struct->border_vert_space;*/			new_x = cell_x + (int16)cell_struct->border_horiz_space + cell_struct->border_width;			new_y = cell_y + (int32)cell_struct->border_vert_space + cell_struct->border_width;			cell_struct->width = col_max->dim;			if (cell_ptr->colspan > 1)			{				int32 i;				lo_table_span *max_ptr;				max_ptr = col_max;				for (i=1; i < cell_ptr->colspan; i++)				{					max_ptr = max_ptr->next;					cell_struct->width = cell_struct->width +						cell_pad + max_ptr->dim;				}			}			cell_struct->width = cell_struct->width -				(2 * cell_struct->border_horiz_space);			cell_struct->height = row_max->dim;			if (cell_ptr->rowspan > 1)			{				int32 i;				lo_table_span *max_ptr;				max_ptr = row_max;				for (i=1; i < cell_ptr->rowspan; i++)				{					max_ptr = max_ptr->next;					cell_struct->height = cell_struct->height +						cell_pad + max_ptr->dim;				}			}			cell_struct->height = cell_struct->height -				(2 * cell_struct->border_vert_space);			lo_ShiftCell(cell_struct,				cell_ptr->cell_base_x, cell_ptr->cell_base_y);			cell_ptr->cell_base_x = 0;			cell_ptr->cell_base_y = 0;			ele_cnt = lo_align_cell(context, state, cell_ptr,					cell_struct, table, row_max);			/*			if (ele_cnt > 0)			*/			{				LO_CellStruct *cell_ele;				int32 shift_x, shift_y;				shift_x = new_x - cell_struct->x -					cell_struct->x_offset -					cell_struct->border_width;				shift_y = new_y - cell_struct->y -					cell_struct->y_offset -					cell_struct->border_width;				cell_struct->x = cell_x;				cell_struct->y = cell_y;				cell_struct->x_offset = (int16)cell_struct->border_horiz_space;				cell_struct->y_offset = (int32)cell_struct->border_vert_space;				cell_ele = cell_struct;/*				lo_ShiftCell(cell_ele, shift_x, shift_y);*/				lo_ShiftCell(cell_ele, new_x, new_y);				/*				 * Keep element ids sequential.				 */				if (cell_ele != NULL)				{					cell_ele->ele_id = NEXT_ELEMENT;					lo_RenumberCell(state, cell_ele);				}				if (cell_ele == NULL)				{					lo_AppendToLineList(context, state,						(LO_Element *)cell_struct, 0);				}				else				{                    /*cmanske - Save spacing param for drawing cell selection by FEs */                    cell_ele->inter_cell_space = table->inter_cell_pad;					lo_AppendToLineList(context, state,						(LO_Element *)cell_ele, 0);				}				if ( relayout == FALSE )				{					/*					 * Cell backgrounds now sit in their own layer. This is needed					 * for selection to work correctly.					 * Cell backgrounds can exist in the main _BODY layer,					 * so we need to special case the parent layer of the					 * cell background,					 */					if (context->compositor &&						(cell_ele->backdrop.bg_color || cell_ele->backdrop.url))					{						lo_TopState *top_state = state->top_state;						CL_Layer *parent_layer = lo_CurrentLayer(state);						if (parent_layer == top_state->doc_layer)							parent_layer = top_state->body_layer;						cell_ele->cell_bg_layer =							lo_CreateCellBackgroundLayer(context, cell_ele,														 parent_layer);					}					else					{						cell_ele->cell_bg_layer = NULL;					}				}			}			/*			else			{			*/				/*				LO_CellStruct *cell_ele;				*/				/*				 * Free up the useless cell				 */						/*				cell_ele = cell_struct;				if (cell_ele != NULL)				{					lo_FreeElement(context,						(LO_Element *)cell_ele, TRUE);				}							}			*/			cell_x = cell_x + col_max->dim + cell_pad;			col_max = col_max->next;		}		cell_y = cell_y + row_max->dim + cell_pad;		row_max = row_max->next;	}	cell_x = cell_x + table->table_ele->border_left_width;	cell_y = cell_y + table->table_ele->border_top_width;	if (table->draw_borders == TABLE_BORDERS_OFF)	{		cell_x += table_pad;		cell_y += table_pad;	}	if ((table->caption != NULL)&&		(table->caption->vert_alignment != LO_ALIGN_TOP))	{		LO_SubDocStruct *subdoc;		subdoc = table->caption->subdoc;		subdoc->x = state->x;		subdoc->y = cell_y;		subdoc->x_offset = (int16)subdoc->border_horiz_space;		subdoc->y_offset = (int32)subdoc->border_vert_space;		subdoc->width = table->caption->max_width -			(2 * subdoc->border_horiz_space);		subdoc->height = table->caption->height -			(2 * subdoc->border_vert_space);		ele_cnt = lo_align_subdoc(context, state,			(lo_DocState *)subdoc->state, subdoc, table, NULL);		if (ele_cnt > 0)		{			LO_CellStruct *cell_ele;			if (relayout == FALSE)			{				/*				cell_ele = lo_SquishSubDocToCell(context, state,						subdoc, TRUE);				*/				cell_ele = lo_SquishSubDocToCell(context, state,						subdoc, FALSE);				cell_ele->isCaption = TRUE;				table->caption->cell_ele = cell_ele;			}			else 			{				cell_ele = table->caption->cell_ele;				lo_UpdateCaptionCellFromSubDoc(context, state, subdoc, cell_ele);			}						/* table->caption->subdoc = NULL; */			if (cell_ele == NULL)			{				lo_AppendToLineList(context, state,					(LO_Element *)subdoc, 0);			}			else			{                /*cmanske - Save spacing param for drawing cell selection by FEs */                cell_ele->inter_cell_space = table->inter_cell_pad;				lo_AppendToLineList(context, state,					(LO_Element *)cell_ele, 0);			}			cell_y = cell_y + table->caption->height + cell_pad;		}		else		{			LO_CellStruct *cell_ele;			/*			 * Free up the useless subdoc			 */			cell_ele = lo_SquishSubDocToCell(context, state,						subdoc, TRUE);			table->caption->subdoc = NULL;						if (cell_ele != NULL)			{				lo_FreeElement(context,					(LO_Element *)cell_ele, TRUE);			}		}	}	/*	 * This table may have contained named anchors.	 * This will correct their positions in the name_list,	 * and unblock us if we were blocked on them.	 */	lo_CheckNameList(context, state, table->table_ele->ele_id);	/*	 * The usual stuff for a table.	 */	if (floating == FALSE)	{		lo_AlignStack *aptr;		int32 indent;		state->x = cell_x;		state->baseline = 0;		state->line_height = cell_y - state->y;		state->linefeed_state = 0;		state->at_begin_line = FALSE;		state->trailing_space = FALSE;		state->cur_ele_type = LO_SUBDOC;		table->table_ele->line_height = state->line_height;		/*		 * Find how far the table might be indented from		 * being inside a list.		 */		indent = state->list_stack->old_left_margin - state->win_left;		if (indent < 0)		{			indent = 0;		}		save_doc_min_width = state->min_width;		if (relayout == FALSE) 		{			lo_SoftLineBreak(context, state, FALSE);		}		else		{			lo_rl_AddBreakAndFlushLine( context, state, LO_LINEFEED_BREAK_SOFT, LO_CLEAR_NONE, FALSE );		}		if ((min_table_width + indent) > save_doc_min_width)		{			save_doc_min_width = min_table_width + indent;		}		state->min_width = save_doc_min_width;				/*		 * Pop the table's alignment.		 */		aptr = lo_PopAlignment(state);		if (aptr != NULL)		{			XP_DELETE(aptr);		}	}	/*	 * Else this is a floating table, rip it out of the "faked"	 * line list, stuff itin the margin, and restore our state	 * to where we left off.	 */	else	{		int32 push_right;		int32 line_height;                LO_Element *tptr;                LO_Element *last;		line_height = cell_y - state->y;		push_right = 0;		if (table->table_ele->alignment == LO_ALIGN_RIGHT)		{			push_right = state->right_margin - cell_x;		}		table->table_ele->x_offset +=			(int16)table->table_ele->border_horiz_space;		table->table_ele->y_offset +=			(int32)table->table_ele->border_vert_space;		last = NULL;		tptr = state->line_list;		while (tptr != NULL)		{			tptr->lo_any.x += push_right;			if (tptr->type == LO_CELL)			{				tptr->lo_any.x +=					table->table_ele->border_horiz_space;				tptr->lo_any.y +=					table->table_ele->border_vert_space;				lo_ShiftCell((LO_CellStruct *)tptr,					(push_right +					table->table_ele->border_horiz_space),					table->table_ele->border_vert_space);			}			last = tptr;			tptr->lo_any.line_height = line_height;			tptr = tptr->lo_any.next;		}		/*		 * Stuff the whole line list into the float list, and		 * restore the line list to its pre-table state.		 */		if (state->line_list != NULL)		{			last->lo_any.next = state->float_list;			state->float_list = state->line_list;			state->line_list = NULL;		}		if (relayout == FALSE)		{			lo_AppendFloatInLineList(state, (LO_Element *)table->table_ele, save_line_list );		}		else		{			state->line_list = save_line_list;		}				table->table_ele->line_height = line_height;		table->table_ele->expected_y = table->table_ele->y;		table->table_ele->y = -1;		lo_AddMarginStack(state,			table->table_ele->x, table->table_ele->y,                        table->table_ele->width, table->table_ele->line_height,                        table->table_ele->border_left_width +                         	table->table_ele->border_right_width,                        table->table_ele->border_vert_space,			table->table_ele->border_horiz_space,                        (intn)table->table_ele->alignment);		/*		 * Restore state to pre-table values.		 */		state->x = save_state_x;		state->y = save_state_y;		/*		 * All the doc_min_width stuff makes state->min_width		 * be correct for tables nested inside tables.		 */		save_doc_min_width = state->min_width;		/*		 * Standard float stuff, if we happen to be at the start		 * of a line, place the table now.		 */		if (state->at_begin_line != FALSE)		{			lo_FindLineMargins(context, state, (! relayout));			state->x = state->left_margin;		}		if (min_table_width > save_doc_min_width)		{			save_doc_min_width = min_table_width;		}		state->min_width = save_doc_min_width;	}	/*  Now cell records get freed when the LO_TABLE element in the line list gets recycled	for (y=0; y < table->rows; y++)	{		for (x=0; x < table->cols; x++)		{			indx = (y * table->cols) + x;			cell_ptr = cell_array[indx].cell;			if ((cell_ptr != &blank_cell)&&(cell_ptr != NULL))			{				lo_free_cell_record(context, state, cell_ptr);			}		}	}	*/	#ifdef XP_WIN16	_hfree(cell_array);#else	XP_UNLOCK_BLOCK(cell_array_buff);	XP_FREE_BLOCK(cell_array_buff);#endif	/* 	 * Don't wanna free the table record any more because this information	 * is used during relayout.	 */	/*	lo_free_table_record(context, state, table, FALSE);	*/}