/* * The beginning of a usemap MAP record. * Allocate the structure and initialize it. It will be filled * by later AREA tags. */ void lo_BeginMap(MWContext *context, lo_DocState *state, PA_Tag *tag) { PA_Block buff; char *str; lo_MapRec *map; map = XP_NEW(lo_MapRec); if (map == NULL) { state->top_state->out_of_memory = TRUE; return; } map->name = NULL; map->areas = NULL; map->areas_last = NULL; map->next = NULL; buff = lo_FetchParamValue(context, tag, PARAM_NAME); if (buff != NULL) { char *name; PA_LOCK(str, char *, buff); if (str != NULL) { int32 len; len = lo_StripTextWhitespace(str, XP_STRLEN(str)); } name = (char *)XP_ALLOC(XP_STRLEN(str) + 1); if (name == NULL) { map->name = NULL; } else { XP_STRCPY(name, str); map->name = name; } PA_UNLOCK(buff); PA_FREE(buff); } else { map->name = NULL; } if (map->name == NULL) { XP_DELETE(map); return; } state->top_state->current_map = map; }
/* * This is an AREA tag. Create the structure, fill it in based on the * attributes passed, and add it to the map record for the current * MAP tag. */ void lo_BeginMapArea(MWContext *context, lo_DocState *state, PA_Tag *tag) { PA_Block buff; char *str; lo_MapRec *map; lo_MapAreaRec *area; lo_DocLists *doc_lists; doc_lists = lo_GetCurrentDocLists(state); /* * Get the current map, if there is none, error out. */ map = state->top_state->current_map; if (map == NULL) { return; } area = XP_NEW(lo_MapAreaRec); if (area == NULL) { state->top_state->out_of_memory = TRUE; return; } area->type = AREA_SHAPE_RECT; area->coords = NULL; area->coord_cnt = 0; area->anchor = NULL; area->alt = NULL; area->alt_len = 0; area->next = NULL; buff = lo_FetchParamValue(context, tag, PARAM_SHAPE); if (buff != NULL) { PA_LOCK(str, char *, buff); if (pa_TagEqual(S_AREA_SHAPE_RECT, str)) { area->type = AREA_SHAPE_RECT; } else if (pa_TagEqual(S_AREA_SHAPE_CIRCLE, str)) { area->type = AREA_SHAPE_CIRCLE; } else if (pa_TagEqual(S_AREA_SHAPE_POLY, str)) { area->type = AREA_SHAPE_POLY; } else if (pa_TagEqual(S_AREA_SHAPE_POLYGON, str)) { area->type = AREA_SHAPE_POLY; } else if (pa_TagEqual(S_AREA_SHAPE_DEFAULT, str)) { area->type = AREA_SHAPE_DEFAULT; } else { area->type = AREA_SHAPE_UNKNOWN; } PA_UNLOCK(buff); PA_FREE(buff); } /* * Get the alt parameter, and store the resulting * text, and its length. */ buff = lo_FetchParamValue(context, tag, PARAM_ALT); if (buff != NULL) { PA_LOCK(str, char *, buff); area->alt_len = XP_STRLEN(str); area->alt_len = (int16)lo_StripTextNewlines(str, (int32)area->alt_len); PA_UNLOCK(buff); } area->alt = buff; /* * Parse the comma separated coordinate list into an * array of integers. */ buff = lo_FetchParamValue(context, tag, PARAM_COORDS); if (buff != NULL) { int32 cnt; Bool must_be_odd; must_be_odd = FALSE; if (area->type == AREA_SHAPE_POLY) { must_be_odd = TRUE; } PA_LOCK(str, char *, buff); area->coords = lo_parse_coord_list(str, &cnt, must_be_odd); if (area->coords != NULL) { area->coord_cnt = cnt; } PA_UNLOCK(buff); PA_FREE(buff); } /* * Get the HREF, and if one exists, get the TARGET to go along * with it. */ buff = lo_FetchParamValue(context, tag, PARAM_HREF); if (buff != NULL) { char *target; PA_Block targ_buff; PA_Block href_buff; LO_AnchorData *anchor; anchor = NULL; PA_LOCK(str, char *, buff); if (str != NULL) { int32 len; len = lo_StripTextWhitespace(str, XP_STRLEN(str)); } str = NET_MakeAbsoluteURL(state->top_state->base_url, str); if (str == NULL) { href_buff = NULL; } else { href_buff = PA_ALLOC(XP_STRLEN(str) + 1); if (href_buff != NULL) { char *full_url; PA_LOCK(full_url, char *, href_buff); XP_STRCPY(full_url, str); PA_UNLOCK(href_buff); } else { state->top_state->out_of_memory = TRUE; } XP_FREE(str); } PA_UNLOCK(buff); PA_FREE(buff); if (href_buff != NULL) { targ_buff = lo_FetchParamValue(context, tag, PARAM_TARGET); if (targ_buff != NULL) { int32 len; PA_LOCK(target, char *, targ_buff); len = lo_StripTextWhitespace(target, XP_STRLEN(target)); if ((*target == '\0')|| (lo_IsValidTarget(target) == FALSE)) { PA_UNLOCK(targ_buff); PA_FREE(targ_buff); targ_buff = NULL; } else { PA_UNLOCK(targ_buff); } } /* * If there was no target use the default one. * (default provided by BASE tag) */ if ((targ_buff == NULL)&& (state->top_state->base_target != NULL)) { targ_buff = PA_ALLOC(XP_STRLEN( state->top_state->base_target) + 1); if (targ_buff != NULL) { char *targ; PA_LOCK(targ, char *, targ_buff); XP_STRCPY(targ, state->top_state->base_target); PA_UNLOCK(targ_buff); } else { state->top_state->out_of_memory = TRUE; } } anchor = lo_NewAnchor(state, href_buff, targ_buff); if (anchor == NULL) { PA_FREE(href_buff); if (targ_buff != NULL) { PA_FREE(targ_buff); } } /* * If the AREA tag has an ALT attribute, * stick that text into the anchor data. */ else if (area->alt != NULL) { PA_Block alt_buff; char *alt_text; PA_LOCK(alt_text, char *, area->alt); alt_buff = PA_ALLOC(area->alt_len + 1); if (alt_buff != NULL) { char *new_alt; PA_LOCK(new_alt, char *, alt_buff); XP_STRCPY(new_alt, alt_text); PA_UNLOCK(alt_buff); } PA_UNLOCK(area->alt); anchor->alt = alt_buff; }
static void lo_FormatJavaAppInternal(MWContext *context, lo_DocState *state, PA_Tag *tag, LO_JavaAppStruct *java_app) { PA_Block buff; char *str; int32 val; int32 doc_width; Bool widthSpecified = FALSE; Bool heightSpecified = FALSE; lo_DocLists *doc_lists; java_app->nextApplet = NULL; #ifdef MOCHA java_app->mocha_object = NULL; #endif java_app->FE_Data = NULL; java_app->session_data = NULL; java_app->line_height = state->line_height; java_app->base_url = NULL; java_app->attr_code = NULL; java_app->attr_codebase = NULL; java_app->attr_archive = NULL; java_app->attr_name = NULL; java_app->param_cnt = 0; java_app->param_names = NULL; java_app->param_values = NULL; java_app->may_script = FALSE; java_app->alignment = LO_ALIGN_BASELINE; java_app->border_width = JAVA_DEF_BORDER; java_app->border_vert_space = JAVA_DEF_VERTICAL_SPACE; java_app->border_horiz_space = JAVA_DEF_HORIZONTAL_SPACE; java_app->layer = NULL; java_app->tag = tag; /* * Assign a unique index for this object * and increment the master index. */ java_app->embed_index = state->top_state->embed_count++; /* * Save away the base of the document */ buff = PA_ALLOC(XP_STRLEN(state->top_state->base_url) + 1); if (buff != NULL) { char *cp; PA_LOCK(cp, char*, buff); XP_STRCPY(cp, state->top_state->base_url); PA_UNLOCK(buff); java_app->base_url = buff; } else { state->top_state->out_of_memory = TRUE; return; } /* * Check for an align parameter */ buff = lo_FetchParamValue(context, tag, PARAM_ALIGN); if (buff != NULL) { Bool floating; floating = FALSE; PA_LOCK(str, char *, buff); java_app->alignment = lo_EvalAlignParam(str, &floating); if (floating != FALSE) { java_app->ele_attrmask |= LO_ELE_FLOATING; } PA_UNLOCK(buff); PA_FREE(buff); } /* * Get the applet CODE or object CLASSID parameter. In both * cases the value is place in java_app->attr_code */ if (java_app->selector_type == LO_JAVA_SELECTOR_APPLET) { /* APPLET tag CODE attribute */ buff = lo_FetchParamValue(context, tag, PARAM_CODE); } else { /* OBJECT tag CLASSID attribute */ char * str1, * str2; PA_Block new_buff; int selectorLength; selectorLength = 5; if (java_app->selector_type == LO_JAVA_SELECTOR_OBJECT_JAVAPROGRAM) selectorLength = 12; else if (java_app->selector_type == LO_JAVA_SELECTOR_OBJECT_JAVABEAN) selectorLength = 9; buff = lo_FetchParamValue(context, tag, PARAM_CLASSID); if (buff != NULL) { /* remove the "java:", "javaprogram:", or "javabean:" * protocol selector. */ PA_LOCK(str1, char *, buff); new_buff = PA_ALLOC(XP_STRLEN(str1) + 1); PA_LOCK(str2, char *, new_buff); XP_STRCPY(str2, str1 + selectorLength); PA_UNLOCK(new_buff); PA_UNLOCK(buff); PA_FREE(buff); buff = new_buff; } } java_app->attr_code = buff; /* * Check for the loaderbase parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_CODEBASE); java_app->attr_codebase = buff; /* * Check for the archive parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_ARCHIVE); java_app->attr_archive = buff; /* * Check for a mayscript attribute */ buff = lo_FetchParamValue(context, tag, PARAM_MAYSCRIPT); if (buff != NULL) { java_app->may_script = TRUE; PA_FREE(buff); } /* * Get the name of this java applet. */ if (java_app->selector_type != LO_JAVA_SELECTOR_APPLET) buff = lo_FetchParamValue(context, tag, PARAM_ID); else buff = lo_FetchParamValue(context, tag, PARAM_NAME); if (buff != NULL) { PA_LOCK(str, char *, buff); if (str != NULL) { int32 len; len = lo_StripTextWhitespace(str, XP_STRLEN(str)); } PA_UNLOCK(buff); } java_app->attr_name = buff; doc_width = state->right_margin - state->left_margin; /* * Get the width parameter, in absolute or percentage. * If percentage, make it absolute. */ buff = lo_FetchParamValue(context, tag, PARAM_WIDTH); if (buff != NULL) { Bool is_percent; PA_LOCK(str, char *, buff); val = lo_ValueOrPercent(str, &is_percent); if (is_percent != FALSE) { java_app->percent_width = val; } else { java_app->percent_width = 0; java_app->width = val; val = FEUNITS_X(val, context); } PA_UNLOCK(buff); PA_FREE(buff); widthSpecified = TRUE; } val = LO_GetWidthFromStyleSheet(context, state); if(val) { java_app->width = val; widthSpecified = TRUE; } /* * Get the height parameter, in absolute or percentage. * If percentage, make it absolute. */ buff = lo_FetchParamValue(context, tag, PARAM_HEIGHT); if (buff != NULL) { Bool is_percent; PA_LOCK(str, char *, buff); val = lo_ValueOrPercent(str, &is_percent); if (is_percent != FALSE) { java_app->percent_height = val; } else { java_app->percent_height = 0; val = FEUNITS_Y(val, context); } java_app->height = val; PA_UNLOCK(buff); PA_FREE(buff); heightSpecified = TRUE; } val = LO_GetHeightFromStyleSheet(context, state); if(val) { java_app->height = val; heightSpecified = TRUE; } /* If they forgot to specify a width, make one up. */ if (!widthSpecified) { val = 0; if (heightSpecified) { val = java_app->height; } else if (state->allow_percent_width) { val = state->win_width * 90 / 100; } if (val < 1) { val = 600; } java_app->width = val; } /* If they forgot to specify a height, make one up. */ if (!heightSpecified) { val = 0; if (widthSpecified) { val = java_app->width; } else if (state->allow_percent_height) { val = state->win_height / 2; } if (val < 1) { val = 400; } java_app->height = val; } /* After going through all the trouble, just to make sure * the object tag HIDDEN case is covered as well. */ if (java_app->ele_attrmask & LO_ELE_HIDDEN) { java_app->width = 0; java_app->height = 0; } /* * Get the border parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_BORDER); if (buff != NULL) { PA_LOCK(str, char *, buff); val = XP_ATOI(str); if (val < 0) { val = 0; } java_app->border_width = val; PA_UNLOCK(buff); PA_FREE(buff); } java_app->border_width = FEUNITS_X(java_app->border_width, context); /* * Get the extra vertical space parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_VSPACE); if (buff != NULL) { PA_LOCK(str, char *, buff); val = XP_ATOI(str); if (val < 0) { val = 0; } java_app->border_vert_space = val; PA_UNLOCK(buff); PA_FREE(buff); } java_app->border_vert_space = FEUNITS_Y(java_app->border_vert_space, context); /* * Get the extra horizontal space parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_HSPACE); if (buff != NULL) { PA_LOCK(str, char *, buff); val = XP_ATOI(str); if (val < 0) { val = 0; } java_app->border_horiz_space = val; PA_UNLOCK(buff); PA_FREE(buff); } java_app->border_horiz_space = FEUNITS_X(java_app->border_horiz_space, context); lo_FillInJavaAppGeometry(state, java_app, FALSE); /* * See if we have some saved embed/java_app session data to restore. */ if (state->top_state->savedData.EmbedList != NULL) { lo_SavedEmbedListData *embed_list; embed_list = state->top_state->savedData.EmbedList; /* * If there is still valid data to restore available. */ if (java_app->embed_index < embed_list->embed_count) { lo_EmbedDataElement* embed_data_list; PA_LOCK(embed_data_list, lo_EmbedDataElement*, embed_list->embed_data_list); java_app->session_data = embed_data_list[java_app->embed_index].data; PA_UNLOCK(embed_list->embed_data_list); }
/* * Takes a "PARAM" tag and pointers to the object's attribute * count, attribute name array, and attribute value array. * Parses the name and value of the PARAM and adjusts the * attribute count, names, and values accordingly. */ void lo_ObjectParam(MWContext* context, lo_DocState* state, PA_Tag* tag, uint32* count, char*** names, char*** values) { PA_Block buff; char *str; char *param_name = NULL; char *param_value = NULL; char **name_list; char **value_list; /* * Get the name of this parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_NAME); if (buff != NULL) { PA_LOCK(str, char *, buff); if (str != NULL) { int32 len; char *new_str; len = lo_StripTextWhitespace(str, XP_STRLEN(str)); new_str = (char *)XP_ALLOC(len + 1); if (new_str != NULL) { XP_STRCPY(new_str, str); } param_name = new_str; } PA_UNLOCK(buff); PA_FREE(buff); } else { /* If we don't have a parameter name, it's useless */ return; } /* * Get the value of this parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_VALUE); if (buff != NULL) { PA_LOCK(str, char *, buff); if (str != NULL) { int32 len; char *new_str; len = lo_StripTextWhitespace(str, XP_STRLEN(str)); new_str = (char *)XP_ALLOC(len + 1); if (new_str != NULL) { XP_STRCPY(new_str, str); } param_value = new_str; } PA_UNLOCK(buff); PA_FREE(buff); } /* * Add the parameter to the name/value list. */ if (*names == NULL) name_list = (char **)XP_ALLOC(sizeof(char *)); else name_list = (char **)XP_REALLOC(*names, ((*count + 1) * sizeof(char *))); /* * If we run out of memory here, free up what * we can and return. */ if (name_list == NULL) { state->top_state->out_of_memory = TRUE; XP_FREE(param_name); if (param_value != NULL) XP_FREE(param_value); return; } if (*values == NULL) value_list = (char **)XP_ALLOC(sizeof(char *)); else value_list = (char **)XP_REALLOC(*values, ((*count + 1) * sizeof(char *))); /* * If we run out of memory here, free up what * we can and return. */ if (value_list == NULL) { state->top_state->out_of_memory = TRUE; XP_FREE(param_name); if (param_value != NULL) XP_FREE(param_value); return; } *names = name_list; *values = value_list; (*names)[*count] = param_name; (*values)[*count] = param_value; (*count)++; }