form_data->readonly = TRUE;
form_data->read_only = TRUE;
lo_form_input_text(MWContext *context, lo_DocState *state,	PA_Tag *tag, int32 type){	LO_FormElementStruct *form_element;	lo_FormElementTextData *form_data;	PA_Block buff;#if defined(XP_MAC)&&defined(MOCHA)	PA_Block keydown, keypress, keyup;#endif /* defined(XP_MAC)&&defined(MOCHA) */	char *str;	char *tptr;	int16 charset;	form_element = new_form_element(context, state, type);	if (form_element == NULL)	{		return(NULL);	}	form_element->element_data = lo_next_element_data(state, type);	if (form_element->element_data == NULL)	{		lo_FreeElement(context, (LO_Element *)form_element, FALSE);		return(NULL);	}	form_element->element_index =		state->top_state->savedData.FormList->data_index - 1;	form_data = (lo_FormElementTextData *)form_element->element_data;	/*	 * IF our starting type is NONE, this is a new element,	 * an we need to initialize the locations that will later	 * hold persistent data.	 */	if (form_data->type == FORM_TYPE_NONE)	{		form_data->FE_Data = NULL;		form_data->current_text = NULL;	}	form_data->encoding = INPUT_TYPE_ENCODING_NORMAL; /* default */	form_data->type = type;	form_data->name = lo_FetchParamValue(context, tag, PARAM_NAME);	buff = lo_FetchParamValue(context, tag, PARAM_VALUE);	PA_LOCK(tptr, char *, buff);	/*	 * strip newlines from single line text	 * default values.	 */	if ((tptr != NULL)&&(type != FORM_TYPE_PASSWORD))	{		int32 len;		len = XP_STRLEN(tptr);		len = lo_StripTextNewlines(tptr, len);	}	charset = form_element->text_attr->charset;	tptr = FE_TranslateISOText(context, charset, tptr);	PA_UNLOCK(buff);	form_data->default_text = buff;#ifdef OLD_FILE_UPLOAD	if ((form_data->default_text == NULL)&&(type == FORM_TYPE_FILE))	{		form_data->default_text = PA_ALLOC(				(XP_STRLEN(DEF_FILE_ELE_VALUE) + 1)				* sizeof(char));		if (form_data->default_text != NULL)		{			PA_LOCK(tptr, char *, form_data->default_text);			XP_STRCPY(tptr, DEF_FILE_ELE_VALUE);			PA_UNLOCK(form_data->default_text);		}	}#else	/*	 * File upload forms cannot default to a filename	 */	if ((form_data->default_text != NULL)&&(type == FORM_TYPE_FILE))	{		PA_FREE(form_data->default_text);		form_data->default_text = NULL;	}#endif /* OLD_FILE_UPLOAD */	form_data->readonly = FALSE;	if (type != FORM_TYPE_FILE)	  {		buff = lo_FetchParamValue(context, tag, PARAM_READONLY);		if (buff != NULL)		  {			PA_FREE(buff);			form_data->readonly = TRUE;		  }	  }	form_data->size = DEF_TEXT_ELE_SIZE;	buff = lo_FetchParamValue(context, tag, PARAM_SIZE);	if (buff != NULL)	{		PA_LOCK(str, char *, buff);		form_data->size = XP_ATOI(str);		PA_UNLOCK(buff);		PA_FREE(buff);		if (form_data->size < 1)		{			form_data->size = 1;		}	}#ifdef OLD_FILE_UPLOAD	else if ((type == FORM_TYPE_FILE)&&(form_data->default_text != NULL))	{		int32 len;		PA_LOCK(tptr, char *, form_data->default_text);		len = XP_STRLEN(tptr);		PA_UNLOCK(form_data->default_text);		if (len > 0)		{			form_data->size = len;		}	}#endif /* OLD_FILE_UPLOAD */	buff = lo_FetchParamValue(context, tag, PARAM_ENCODING);	if (buff != NULL)	{		PA_LOCK(str, char *, buff);		if(!XP_STRCASECMP(str, "MACBINARY"))			form_data->encoding = INPUT_TYPE_ENCODING_MACBIN;		PA_UNLOCK(buff);		PA_FREE(buff);	}	form_data->max_size = -1;	buff = lo_FetchParamValue(context, tag, PARAM_MAXLENGTH);	if (buff != NULL)	{		PA_LOCK(str, char *, buff);		form_data->max_size = XP_ATOI(str);		PA_UNLOCK(buff);		PA_FREE(buff);	}	#if defined(XP_MAC)&&defined(MOCHA)    keydown = lo_FetchParamValue(context, tag, PARAM_ONKEYDOWN);    keypress = lo_FetchParamValue(context, tag, PARAM_ONKEYPRESS);    keyup = lo_FetchParamValue(context, tag, PARAM_ONKEYUP);    /* Text fields need this info which needs to be carried across table cell relayouts.       Only the mac FE checks the event_handler_present bit. */    if (keydown || keypress || keyup)	form_element->event_handler_present = TRUE;		if (keydown)		PA_FREE(keydown);	if (keypress)		PA_FREE(keypress);	if (keyup)		PA_FREE(keyup);		#endif /* defined(XP_MAC)&&defined(MOCHA) */	return(form_element);}