void lo_FormatJavaObject(MWContext *context, lo_DocState *state, PA_Tag *tag, LO_JavaAppStruct *java_app) { PA_Block buff; buff = lo_FetchParamValue(context, tag, PARAM_CLASSID); if (buff != NULL) { char* str; PA_LOCK(str, char *, buff); if (XP_STRNCASECMP(str, "java:", 5) == 0) java_app->selector_type = LO_JAVA_SELECTOR_OBJECT_JAVA; else if (XP_STRNCASECMP(str, "javaprogram:", 12) == 0) java_app->selector_type = LO_JAVA_SELECTOR_OBJECT_JAVAPROGRAM; else if (XP_STRNCASECMP(str, "javabean:", 8) == 0) java_app->selector_type = LO_JAVA_SELECTOR_OBJECT_JAVABEAN; PA_UNLOCK(buff); XP_FREE(buff); } if (java_app->selector_type == LO_JAVA_SELECTOR_OBJECT_JAVAPROGRAM) { java_app->ele_attrmask |= LO_ELE_HIDDEN; } else { /* Get the HIDDEN parameter */ java_app->ele_attrmask = 0; buff = lo_FetchParamValue(context, tag, PARAM_HIDDEN); if (buff != NULL) { Bool hidden = TRUE; char* str; PA_LOCK(str, char *, buff); if (pa_TagEqual("no", str)) { hidden = FALSE; } else if (pa_TagEqual("false", str)) { hidden = FALSE; } else if (pa_TagEqual("off", str)) { hidden = FALSE; } PA_UNLOCK(buff); PA_FREE(buff); if (hidden != FALSE) { java_app->ele_attrmask |= LO_ELE_HIDDEN; } } } /* Finish formatting the object */ lo_FormatJavaAppInternal(context, state, tag, java_app); }
void lo_ProcessSpacerTag(MWContext *context, lo_DocState *state, PA_Tag *tag) { int32 type; int32 size; PA_Block buff; LO_SpacerStruct *spacer; spacer = (LO_SpacerStruct*)lo_NewElement(context, state, LO_SPACER, NULL, 0); XP_ASSERT(spacer); if (!spacer) { state->top_state->out_of_memory = TRUE; return; } type = SPACE_WORD; buff = lo_FetchParamValue(context, tag, PARAM_TYPE); if (buff != NULL) { char *type_str; PA_LOCK(type_str, char *, buff); if (pa_TagEqual("line", type_str)) { type = SPACE_LINE; } else if (pa_TagEqual("vert", type_str)) { type = SPACE_LINE; } else if (pa_TagEqual("vertical", type_str)) { type = SPACE_LINE; } else if (pa_TagEqual("block", type_str)) { type = SPACE_BLOCK; } PA_UNLOCK(buff); PA_FREE(buff); } size = 0; buff = lo_FetchParamValue(context, tag, PARAM_SIZE); if (buff != NULL) { char *str; PA_LOCK(str, char *, buff); size = XP_ATOI(str); PA_UNLOCK(buff); PA_FREE(buff); if (size < 1) { size = 0; } } spacer->size = size; spacer->type = (int8) type; spacer->tag = tag; lo_AppendSpacerElementToLineList( context, state, spacer ); lo_LayoutSpacerElement(context, state, spacer, FALSE); /* * Spacers of size 0 do nothing. * Unless they are block spacers that use WIDTH and HEIGHT. */ /* if ((size == 0)&&(type != SPACE_BLOCK)) { return; } if (type == SPACE_WORD) { lo_InsertWordBreak(context, state); size = FEUNITS_X(size, context); state->x += size; } else if (type == SPACE_LINE) { lo_SetSoftLineBreakState(context, state, FALSE, 1); size = FEUNITS_Y(size, context); state->y += size; } else if (type == SPACE_BLOCK) { lo_format_block_spacer(context, state, tag); } */ }
/* * 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; }
void lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag) { lo_TopState* top_state = state->top_state; lo_ObjectStack* top; LO_ObjectStruct* object; PA_Block buff; int16 type = LO_NONE; char* str; #ifdef ANTHRAX XP_Bool javaMimetypeHandler = FALSE; char* appletName; NET_cinfo* fileInfo; #endif /* ANTHRAX */ /* * Make a new default object. Passing LO_OBJECT will create an * LO_Element, which being a union of all other layout element types * is guaranteed to be big enough to transmogrify into one of these * specific types later if necessary. */ object = (LO_ObjectStruct*) lo_NewElement(context, state, LO_OBJECT, NULL, 0); if (object == NULL) { state->top_state->out_of_memory = TRUE; return; } top = top_state->object_stack; top->object = object; /* * Set up default fields for this object that are common * to all possible object types. */ object->lo_element.type = LO_NONE; object->lo_element.lo_any.ele_id = NEXT_ELEMENT; object->lo_element.lo_any.x = state->x; object->lo_element.lo_any.x_offset = 0; object->lo_element.lo_any.y = state->y; object->lo_element.lo_any.y_offset = 0; object->lo_element.lo_any.width = 0; object->lo_element.lo_any.height = 0; object->lo_element.lo_any.next = NULL; object->lo_element.lo_any.prev = NULL; /* * Now attempt to figure out what type of object we have. * If the type can be determined here, great; otherwise * we have to block until the type can be determined by * reading in additional data. * * Initially the type of the object is LO_NONE. When * we figure out enough to know the type, we set it to * LO_EMBED, LO_JAVA, or LO_IMAGE. If the type had * already been changed to a different incompatible type, * then the tag is malformed and we should ignore it, so * set the type to LO_UNKNOWN. */ #if 0 /* * Check the "codetype" attribute, which optionally determines * the MIME type of the object code itself (as opposed to its * data). The only code type we know about right now is * application/java-vm for Java applets. */ buff = lo_FetchParamValue(context, tag, PARAM_CODETYPE); if (buff != NULL) { PA_LOCK(str, char *, buff); if (pa_TagEqual(APPLICATION_JAVAVM, str)) { /* It's a Java applet */ if (type == LO_NONE) type = LO_JAVA; else if (type != LO_JAVA) type = LO_UNKNOWN; } else if (pa_TagEqual(APPLICATION_OLEOBJECT, str) || pa_TagEqual(APPLICATION_OLEOBJECT2, str)) { /* It's an OLE object */ if (type == LO_NONE) type = LO_EMBED; else if (type != LO_EMBED) type = LO_UNKNOWN; } PA_UNLOCK(buff); XP_FREE(buff); } #endif /* * Check the "classid" attribute, which optionally determines * the specific implementation of the object. The classid * could be a normal URL, in which case we have to retrieve * that URL and match it against a known code type (see above). * There are also two "magic" URL types supported for classid: * "clsid:", which indicates a COM 376-hex-digit class ID, * and "java:", which indicates a specific java class to run. * Note that the "java:" URL is different from the APPLET * "code" attribute: the "java:" URL specifies a particular * method (e.g. "java:program.run"), while the APPLET CODE * attribute specifies an applet subclass (e.g. "MyApplet.class"). * * Further notes about "java:" * We are adding two related "magic" protocol selectors to * augment "java:". These are "javaprogram:" and "javabean:". * They are used with embedded applications and application * objects. "javaprogram:" identifies an object as being a * subclass of netscape.application.Application, and is used * to start an instance of such application. "javabean:" is * used to add an embedded object to an application. */ buff = lo_FetchParamValue(context, tag, PARAM_CLASSID); if (buff != NULL) { PA_LOCK(str, char *, buff); if (XP_STRNCASECMP(str, "clsid:", 6) == 0) { /* * It's a COM class ID, so make sure we have an * appropriate plug-in to handle ActiveX controls. */ if (NPL_FindPluginEnabledForType(APPLICATION_OLEOBJECT) != NULL) { if (type == LO_NONE) type = LO_EMBED; else if (type != LO_EMBED) type = LO_UNKNOWN; } } else if ( (XP_STRNCASECMP(str, "java:", 5) == 0) || (XP_STRNCASECMP(str, "javaprogram:", 12) == 0) || (XP_STRNCASECMP(str, "javabean:", 9) == 0) ) { /* It's a Java class */ if (type == LO_NONE) type = LO_JAVA; else if (type != LO_JAVA) type = LO_UNKNOWN; } else { /* * Must be a URL to the code; we'll need to fetch it to * determine the type. bing: How should we do this? */ } PA_UNLOCK(buff); XP_FREE(buff); } /* * Check the "type" attribute, which optionally determines * the type of the data for the object. The data type * can be used to infer the object implementation type if * the implementation hasn't been specified via "classid" * or "codetype" (see above). The two kinds of objects * we currently support with typed data are plug-ins and * images; for plug-ins we can ask libplug if the type is * currently handled by a plug-in; for images we just check * against a hard-coded list of image types we natively * support (yuck). */ buff = lo_FetchParamValue(context, tag, PARAM_TYPE); if (buff != NULL) { PA_LOCK(str, char *, buff); if (NPL_FindPluginEnabledForType(str) != NULL) { /* It's a plug-in */ if (type == LO_NONE) type = LO_EMBED; else if (type != LO_EMBED) type = LO_UNKNOWN; } /* Adding a check for applets that handle mimetypes. The pref is stored based on the particular mimetype. We do a lookup and if there is an association, the name of the applet is placed into "appletName". NOTE: PREF_CopyCharPref() allocates memory for appletName and we must free it. 9.23.97 amusil */ #ifdef ANTHRAX if((appletName = NPL_FindAppletEnabledForMimetype(str)) != NULL) { /* Set the type */ type = LO_JAVA; /* set the CLASSID to whatever was put into "appletName" */ lo_SetClassID(tag, appletName); /* set this so that we know later to translate the DATA/SRC param to a Java arg */ javaMimetypeHandler = TRUE; XP_FREE(appletName); } #endif /* ANTHRAX */ #if 0 else if (XP_STRNCASECMP(str, "image/", 6) == 0) { if (XP_STRCASECMP(str, IMAGE_GIF) || XP_STRCASECMP(str, IMAGE_JPG) || XP_STRCASECMP(str, IMAGE_PJPG) || XP_STRCASECMP(str, IMAGE_XBM) || XP_STRCASECMP(str, IMAGE_XBM2) || XP_STRCASECMP(str, IMAGE_XBM3)) { /* It's an image */ if (type == LO_NONE) type = LO_IMAGE; else if (type != LO_IMAGE) type = LO_UNKNOWN; } } #endif /* if 0 */ #ifdef SHACK if (XP_STRNCASECMP(str, "builtin", 7) == 0) { if (type == LO_NONE) type = LO_EMBED; else if (type != LO_EMBED) type = LO_UNKNOWN; } #endif /* SHACK */ PA_UNLOCK(buff); XP_FREE(buff); } #ifdef ANTHRAX else /* we didn't find a TYPE param, so check the filename to get the type - amusil */ { buff = lo_FetchParamValue(context, tag, PARAM_SRC); /* if no src, check if there's a DATA param */ if(buff == NULL) buff = lo_FetchParamValue(context, tag, PARAM_DATA); /* extract the mimetype info */ PA_LOCK(str, char *, buff); fileInfo = NET_cinfo_find_type(str); str = fileInfo->type; if((appletName = NPL_FindAppletEnabledForMimetype(str)) != NULL) { /* Set the type */ type = LO_JAVA; /* set the CLASSID to whatever was put into "appletName" */ lo_SetClassID(tag, appletName); /* set this so that we know later to translate the DATA/SRC param to a Java arg */ javaMimetypeHandler = TRUE; XP_FREE(appletName); /* do we need to free this regardless? */ } if(buff) XP_FREE(buff); } #endif /* ANTRHAX */ if (type == LO_EMBED) { object->lo_element.type = LO_EMBED; } #ifdef JAVA else if (type == LO_JAVA) { if (LJ_GetJavaEnabled() != FALSE) { /* * Close out the current applet if necessary * (people tend to forget "</APPLET>"). */ if (state->current_java != NULL) lo_CloseJavaApp(context, state, state->current_java); object->lo_element.type = LO_JAVA; lo_FormatJavaObject(context, state, tag, (LO_JavaAppStruct*) object); /* If we determined previously that this is an applet to mimetype association, we must set up the SRC or DATA as an arg for the applet. 9.8.97 amusil */ #ifdef ANTHRAX if(javaMimetypeHandler) lo_SetJavaArgs((char*)tag->data, state->current_java); #endif /* ANTHRAX */ } } #endif /* JAVA */ #if 0 else if (type == LO_IMAGE) { object->type = LO_IMAGE; lo_FormatImageObject(context, state, tag, (LO_ImageStruct*) object); } #endif /* if 0 */ else { /* * Check for a "data" attribute; if it exists, we can get * the URL later to see what the type of the object should be. */ buff = lo_FetchParamValue(context, tag, PARAM_DATA); if (buff != NULL) { PA_LOCK(str, char *, buff); if (XP_STRNCASECMP(str, "data:", 5) == 0) { /* bing: deal with magic data URLs here */ PA_UNLOCK(buff); XP_FREE(buff); } else { /* * Block layout until we can read the PARAM tags * and closing </OBJECT> tag, go get the data URL, * and determine its type. At that point (in * either LO_NewObjectStream, or lo_ObjectURLExit), * we know the object type and can unblock. */ top->data_url = str; state->top_state->layout_blocking_element = (LO_Element*) object; PA_UNLOCK(buff); /* Don't free buff; we stored it in the object stack */ } } else { /* * Otherwise we just don't know what to do with this! */ object->lo_element.type = LO_UNKNOWN; } } }