lo_ScrapeElement(MWContext *context, LO_Element *element)
lo_ScrapeElement(MWContext *context, LO_Element *element, Bool freeTableOrCellState )
lo_ScrapeElement(MWContext *context, LO_Element *element){	if (element == NULL)	{		return;	}#ifdef EDITOR    if ( EDT_IS_EDITOR(context) )    {        if ( element->lo_any.edit_element != NULL )        {            EDT_ResetLayoutElement(element->lo_any.edit_element, element->lo_any.edit_offset, element);            element->lo_any.edit_element = NULL;            element->lo_any.edit_offset = 0;        }    }#endif	switch(element->type)	{		case LO_TEXT:			/* BRAIN DAMAGE: We currently override LO_ELE_INVISIBLE to flag that the text element uses the */			/* new layout scheme and hence the text ptr is not a real ptr */			if ( ( element->lo_text.text != NULL ) && !( element->lo_text.ele_attrmask & LO_ELE_INVISIBLE ))			{				PA_FREE(element->lo_text.text);				element->lo_text.text = NULL;			}			break;		case LO_LINEFEED:		case LO_HRULE:		case LO_BULLET:			break;		case LO_EDGE:			FE_FreeEdgeElement(context, (LO_EdgeStruct *)element);			break;		case LO_FORM_ELE:/* * these are now persistent, don't free element->lo_form.element_data */			element->lo_form.element_data = NULL;			break;		case LO_EMBED:			FE_FreeEmbedElement(context, (LO_EmbedStruct *)element);			if (element->lo_embed.embed_src != NULL)			{				PA_FREE(element->lo_embed.embed_src);			}			element->lo_embed.embed_src = NULL;#ifdef OJI            lo_FreeNVListItems( &element->lo_embed.attributes );            lo_FreeNVListItems( &element->lo_embed.parameters );#else  			/* Free all the attribute names */ 			if (element->lo_embed.attribute_list != NULL) 			{ 				int32 	current; 				 				for (current=0; current<element->lo_embed.attribute_cnt; current++) 				{ 					PA_FREE(element->lo_embed.attribute_list[current]); 					element->lo_embed.attribute_list[current] = NULL; 				} 						 				PA_FREE(element->lo_embed.attribute_list); 				element->lo_embed.attribute_list = NULL; 			} 			/* Free all the attribute values */ 			if (element->lo_embed.value_list != NULL) 			{ 				int32 	current; 				 				for (current=0; current<element->lo_embed.attribute_cnt; current++) 				{ 					PA_FREE(element->lo_embed.value_list[current]); 					element->lo_embed.value_list[current] = NULL; 				}  				PA_FREE(element->lo_embed.value_list); 				element->lo_embed.value_list = NULL; 			}#endif /* OJI */			/*			 * If there is session data here after we			 * return from the front end freeing the embed 			 * element, they want us to save this in history,			 * and pass it back if/when we come back here.			 * Otherwise, save the NULL.			 */			lo_AddEmbedData(context,					element->lo_embed.objTag.session_data,					NPL_DeleteSessionData,					element->lo_embed.objTag.embed_index);			element->lo_embed.objTag.session_data = NULL;			break;#ifdef SHACK	    case LO_BUILTIN:			FE_FreeBuiltinElement (context, (LO_BuiltinStruct *)element);			/* maybe other stuff here */			break;#endif /* SHACK */#ifdef JAVA		case LO_JAVA:			FE_HideJavaAppElement(context, element->lo_java.objTag.session_data);			if (element->lo_java.attr_code != NULL)			{				PA_FREE(element->lo_java.attr_code);				element->lo_java.attr_code = NULL;			}			if (element->lo_java.attr_codebase != NULL)			{				PA_FREE(element->lo_java.attr_codebase);				element->lo_java.attr_codebase = NULL;			}			if (element->lo_java.attr_archive != NULL)			{				PA_FREE(element->lo_java.attr_archive);				element->lo_java.attr_archive = NULL;			}			if (element->lo_java.attr_name != NULL)			{				PA_FREE(element->lo_java.attr_name);				element->lo_java.attr_name = NULL;			}			if (element->lo_java.objTag.base_url != NULL)                        {				PA_FREE(element->lo_java.objTag.base_url);				element->lo_java.objTag.base_url = NULL;                        }#ifdef OJI                        lo_FreeNVListItems( &element->lo_java.attributes );                        lo_FreeNVListItems( &element->lo_java.parameters );#else 			if (element->lo_java.param_names != NULL) 			{ 				int32 	current; 				 				for (current=0; current<element->lo_java.param_cnt; current++) 				{ 					PA_FREE(element->lo_java.param_names[current]); 					element->lo_java.param_names[current] = NULL; 				} 						 				PA_FREE(element->lo_java.param_names); 				element->lo_java.param_names = NULL; 			} 			if (element->lo_java.param_values != NULL) 			{ 				int32 	current; 				 				for (current=0; current<element->lo_java.param_cnt; current++) 				{ 					PA_FREE(element->lo_java.param_values[current]); 					element->lo_java.param_values[current] = NULL; 				}  				PA_FREE(element->lo_java.param_values); 				element->lo_java.param_values = NULL; 			}#endif /* OJI */			/*			 * If there is session data here after we			 * return from the front end freeing the java applet 			 * element, they want us to save this in history,			 * and pass it back if/when we come back here.			 * Otherwise, save the NULL.			 */			lo_AddEmbedData(context,					element->lo_java.objTag.session_data,					LJ_DeleteSessionData,					element->lo_java.objTag.embed_index);			element->lo_java.objTag.session_data = NULL;			break;#endif /* JAVA */		case LO_IMAGE:                        if (element->lo_image.image_req != NULL)                             IL_DestroyImage(element->lo_image.image_req);                        element->lo_image.image_req = NULL;                        if (element->lo_image.image_attr &&                            !(element->lo_image.image_attr->attrmask & LO_ATTR_BACKDROP) &&                            element->lo_image.layer) {			    CL_Layer *parent = CL_GetLayerParent(element->lo_image.layer);			    /* We might not have yet attached the image layer to its parent 			       because we don't know which layer it should be place in. */			    if (parent)				CL_RemoveChild(parent, element->lo_image.layer);                            CL_DestroyLayer(element->lo_image.layer);                            element->lo_image.layer = NULL;                        }                    			if (element->lo_image.alt != NULL)			{				PA_FREE(element->lo_image.alt);			}			element->lo_image.alt = NULL;			if (element->lo_image.image_url != NULL)			{				PA_FREE(element->lo_image.image_url);			}			element->lo_image.image_url = NULL;			if (element->lo_image.lowres_image_url != NULL)			{				PA_FREE(element->lo_image.lowres_image_url);			}			element->lo_image.lowres_image_url = NULL;			lo_FreeImageAttributes(element->lo_image.image_attr);			element->lo_image.image_attr = NULL;			/* 			 * make sure this element isn't sitting on the			 *   image list			 */			{			    int32 doc_id;			    lo_TopState *top_state;                            			    doc_id = XP_DOCID(context);			    top_state = lo_FetchTopState(doc_id);			    if (top_state == NULL)				break;			    /* need to remove from the top_state->image_list */                            lo_remove_image(&top_state->doc_lists,                                            element);			}			break;		case LO_CELL:			{			    int32 doc_id;			    lo_TopState *top_state;			    doc_id = XP_DOCID(context);			    top_state = lo_FetchTopState(doc_id);			    if ((top_state != NULL)&&				(top_state->doc_state != NULL))			    {				lo_DocState *state;				state = top_state->doc_state;				if (element->lo_cell.cell_list != NULL)				{				    if (element->lo_cell.cell_list_end != NULL)				    {					element->lo_cell.cell_list_end->lo_any.next = NULL;				    }				    lo_RecycleElements(context, state,					element->lo_cell.cell_list);				    element->lo_cell.cell_list = NULL;				    element->lo_cell.cell_list_end = NULL;				}				if (element->lo_cell.cell_float_list != NULL)				{				    lo_RecycleElements(context, state,					element->lo_cell.cell_float_list);				    element->lo_cell.cell_float_list = NULL;				}                                XP_FREEIF(element->lo_cell.backdrop.bg_color);			    }                            /* Free the background layer */                            if ( element->lo_cell.cell_bg_layer != NULL)                            {                                CL_Layer *layer = element->lo_cell.cell_bg_layer;                                CL_RemoveChild(CL_GetLayerParent(layer),                                               layer);                                CL_DestroyLayer(layer);                                element->lo_cell.cell_bg_layer = NULL;                            }			    /* Free the lo_TableCell record associated with this cell */			    if ( element->lo_cell.table_cell != NULL )			    {				lo_TopState *top_state;				lo_DocState *state;				top_state = lo_FetchTopState( XP_DOCID(context) );				state = top_state->doc_state;				if (state != NULL)				    lo_free_cell_record( context, state, element->lo_cell.table_cell );			    }			}			break;		case LO_TABLE:			{			lo_ScrapeTableElement( context, (LO_TableStruct *) element );			}			break;		case LO_MULTICOLUMN:			/* should we do this? */		  	if (element->lo_multicolumn.tag != NULL)			  {			    PA_FreeTag(element->lo_multicolumn.tag);				if (element->lo_multicolumn.multicol == NULL)				{					XP_DELETE(element->lo_multicolumn.multicol);				}			    element->lo_multicolumn.tag = NULL;			  }			break;		case LO_BLOCKQUOTE:			/* should we do this? */		  	if (element->lo_blockquote.tag != NULL)			  {			    PA_FreeTag(element->lo_blockquote.tag);			    element->lo_blockquote.tag = NULL;			  }			break;		case LO_SPACER:						if (element->lo_spacer.tag != NULL)			  {			    PA_FreeTag(element->lo_spacer.tag);			    element->lo_spacer.tag = NULL;			  }			break;		case LO_TEXTBLOCK:			/* LO_TEXTBLOCK */			if ( element->lo_textBlock.text_buffer != NULL )			{				XP_FREE ( element->lo_textBlock.text_buffer );				element->lo_textBlock.text_buffer = NULL;			}						if ( element->lo_textBlock.break_table != NULL )			{				XP_FREE ( element->lo_textBlock.break_table );				element->lo_textBlock.break_table = NULL;			}			break;	}}