void lo_FormatJavaApp(MWContext *context, lo_DocState *state, PA_Tag *tag) { LO_JavaAppStruct *java_app; /* * Fill in the java applet structure with default data */ java_app = (LO_JavaAppStruct *)lo_NewElement(context, state, LO_JAVA, NULL, 0); if (java_app == NULL) { return; } java_app->type = LO_JAVA; java_app->ele_id = NEXT_ELEMENT; java_app->x = state->x; java_app->x_offset = 0; java_app->y = state->y; java_app->y_offset = 0; java_app->width = 0; java_app->height = 0; java_app->next = NULL; java_app->prev = NULL; java_app->ele_attrmask = 0; java_app->selector_type = LO_JAVA_SELECTOR_APPLET; /* Finish formatting the object */ lo_FormatJavaAppInternal(context, state, tag, java_app); }
static Bool lo_create_script_blockage(MWContext *context, lo_DocState *state, int type) { lo_TopState *top_state; LO_Element *block_ele; top_state = state->top_state; if (!top_state) { XP_ASSERT(0); return FALSE; } block_ele = lo_NewElement(context, state, LO_SCRIPT, NULL, 0); if (block_ele == NULL) { top_state->out_of_memory = TRUE; return FALSE; } block_ele->type = type; block_ele->lo_any.ele_id = NEXT_ELEMENT; top_state->layout_blocking_element = block_ele; if (type == LO_SCRIPT) top_state->current_script = block_ele; return TRUE; }
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); } */ }
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; } } }
void lo_EndMulticolumn(MWContext *context, lo_DocState *state, PA_Tag *tag, lo_MultiCol *multicol, Bool relayout) { int32 i; lo_ListStack *lptr; int32 height; int32 col_height; int32 x, y; int32 line1, line2; int32 save_doc_min_width; int32 min_multi_width; LO_Element *cell_list; LO_Element *cell_list_end; LO_Element *cell_ele; LO_TableStruct *table_ele; LO_Element *ele; cell_ele = NULL; cell_list = NULL; cell_list_end = NULL; lo_SetLineBreakState (context, state, FALSE, LO_LINEFEED_BREAK_SOFT, 1, relayout); multicol->end_line = state->line_num; multicol->end_y = state->y; /* * Break to clear all left and right margins. */ lo_ClearToBothMargins(context, state); /* * Reset the margins properly in case * we are inside a list. */ lo_FindLineMargins(context, state, !relayout); state->x = state->left_margin; height = multicol->end_y - multicol->start_y; col_height = height / multicol->cols; if (col_height < 1) { col_height = 1; } x = state->x; y = multicol->start_y; line1 = multicol->start_line - 1; for (i=0; i<multicol->cols; i++) { LO_CellStruct *cell; LO_Element *eptr; int32 line; int32 dx, dy; int32 move_height; eptr = lo_FirstElementOfLine(context, state, line1); if (eptr == NULL) { break; } y = eptr->lo_any.y + col_height; line = lo_PointToLine(context, state, x, y); eptr = lo_FirstElementOfLine(context, state, line); if (eptr->lo_any.x > multicol->start_x) { line = lo_find_breaking_line(context, state, line, multicol->start_x, (multicol->start_x + multicol->col_width)); } line2 = line; if (line2 > (multicol->end_line - 2)) { line2 = (multicol->end_line - 2); } cell = NULL; if (i > 0) { eptr = lo_FirstElementOfLine(context, state, line1); if (eptr != NULL) { dx = i * (multicol->col_width + multicol->gutter); dy = multicol->start_y - eptr->lo_any.y; cell = lo_CaptureLines(context, state, multicol->col_width, line1, line2, dx, dy); if (cell == NULL) { move_height = 0; } else { move_height = cell->height - 1; } } else { move_height = 0; } } else { cell = lo_CaptureLines(context, state, multicol->col_width, line1, line2, 0, 0); if (cell == NULL) { move_height = 0; } else { move_height = cell->height - 1; } } line1 = line2 + 1; if (move_height > col_height) { col_height = move_height; } if (cell != NULL) { if (cell_list_end == NULL) { cell_list = (LO_Element *)cell; cell_list_end = cell_list; } else { cell_list_end->lo_any.next = (LO_Element *)cell; cell_list_end = cell_list_end->lo_any.next; } } } lptr = lo_PopList(state, tag); if (lptr != NULL) { XP_DELETE(lptr); } state->left_margin = state->list_stack->old_left_margin; state->right_margin = state->list_stack->old_right_margin; state->top_state->element_id = multicol->start_ele; lo_SetLineArrayEntry(state, NULL, (multicol->start_line - 1)); state->line_num = multicol->start_line; state->end_last_line = multicol->end_last_line; if (state->end_last_line != NULL) { state->end_last_line->lo_any.next = NULL; } state->line_list = NULL; state->y = multicol->start_y; state->display_blocked = multicol->orig_display_blocked; state->display_blocking_element_y = multicol->orig_display_blocking_element_y; table_ele = (LO_TableStruct *)lo_NewElement(context, state, LO_TABLE, NULL, 0); if (table_ele == NULL) { state->top_state->out_of_memory = TRUE; if (multicol->close_table) lo_CloseTable(context, state); return; } table_ele->type = LO_TABLE; table_ele->ele_id = NEXT_ELEMENT; table_ele->x = x; table_ele->x_offset = 0; table_ele->y = multicol->start_y; table_ele->y_offset = 0; table_ele->width = (multicol->cols * multicol->col_width) + ((multicol->cols - 1) * multicol->gutter); table_ele->height = col_height + 1; table_ele->line_height = col_height + 1; table_ele->FE_Data = NULL; table_ele->anchor_href = NULL; table_ele->alignment = LO_ALIGN_LEFT; table_ele->border_width = 0; table_ele->border_vert_space = 0; table_ele->border_horiz_space = 0; table_ele->border_style = BORDER_NONE; table_ele->ele_attrmask = 0; table_ele->sel_start = -1; table_ele->sel_end = -1; table_ele->next = NULL; table_ele->prev = NULL; table_ele->table = NULL; lo_AppendToLineList(context, state, (LO_Element *)table_ele, 0); while (cell_list != NULL) { cell_ele = cell_list; cell_list = cell_list->lo_any.next; cell_ele->lo_any.next = NULL; cell_ele->lo_any.ele_id = NEXT_ELEMENT; lo_RenumberCell(state, (LO_CellStruct *)cell_ele); lo_AppendToLineList(context, state, cell_ele, 0); } if (cell_ele != NULL) { state->x = cell_ele->lo_any.x + multicol->col_width; } else { state->x = table_ele->x + table_ele->width; } state->baseline = 0; state->line_height = col_height + 1; state->linefeed_state = 0; state->at_begin_line = FALSE; state->trailing_space = FALSE; state->cur_ele_type = LO_SUBDOC; min_multi_width = (state->min_width * multicol->cols) + ((multicol->cols - 1) * multicol->gutter); state->min_width = multicol->orig_min_width; save_doc_min_width = state->min_width; lo_SetLineBreakState (context, state, FALSE, LO_LINEFEED_BREAK_SOFT, 2, relayout); if (min_multi_width > save_doc_min_width) { save_doc_min_width = min_multi_width; } state->min_width = save_doc_min_width; state->current_multicol = multicol->next; if (!relayout) { if (multicol->close_table) { PA_Tag *tmp_tag; if (state->in_paragraph != FALSE) { lo_CloseParagraph(context, &state, tag, 2); } tmp_tag = PA_CloneMDLTag(tag); lo_SaveSubdocTags(context, state, tmp_tag); lo_CloseTable(context, state); } } }
LO_CellStruct * lo_CaptureLines(MWContext *context, lo_DocState *state, int32 col_width, int32 line1, int32 line2, int32 dx, int32 dy) { int32 height, max_y; int32 ele1, ele2; LO_Element *eptr; LO_Element *last_eptr; LO_Element *past_eptr; LO_CellStruct *cell; eptr = lo_FirstElementOfLine(context, state, line1); if (eptr == NULL) { return(NULL); } last_eptr = NULL; past_eptr = lo_FirstElementOfLine(context, state, (line2 + 1)); if (past_eptr != NULL) { last_eptr = past_eptr->lo_any.prev; } if (last_eptr == NULL) { last_eptr = lo_FirstElementOfLine(context, state, line2); if (last_eptr == NULL) { last_eptr = eptr; } while (last_eptr->lo_any.next != NULL) { last_eptr = last_eptr->lo_any.next; } } if (past_eptr != NULL) { height = past_eptr->lo_any.y - eptr->lo_any.y; } else { height = last_eptr->lo_any.y + last_eptr->lo_any.line_height - eptr->lo_any.y; } cell = (LO_CellStruct *)lo_NewElement(context, state, LO_CELL, NULL, 0); if (cell == NULL) { state->top_state->out_of_memory = TRUE; return(NULL); } cell->type = LO_CELL; cell->ele_id = NEXT_ELEMENT; cell->x = eptr->lo_any.x + dx; cell->x_offset = 0; cell->y = eptr->lo_any.y + dy; cell->y_offset = 0; cell->width = col_width; cell->height = height; cell->next = NULL; cell->prev = NULL; cell->FE_Data = NULL; cell->cell_float_list = NULL; cell->backdrop.bg_color = NULL; cell->backdrop.url = NULL; cell->border_width = 0; cell->border_vert_space = 0; cell->border_horiz_space = 0; cell->ele_attrmask = 0; cell->sel_start = -1; cell->sel_end = -1; cell->cell_list = eptr; cell->cell_list_end = last_eptr; cell->cell_bg_layer = NULL; cell->cell_inflow_layer = NULL; cell->table_cell = NULL; cell->table_row = NULL; cell->table = NULL; if (eptr->lo_any.prev != NULL) { eptr->lo_any.prev->lo_any.next = NULL; eptr->lo_any.prev = NULL; } if (last_eptr->lo_any.next != NULL) { last_eptr->lo_any.next->lo_any.prev = NULL; last_eptr->lo_any.next = NULL; } ele1 = eptr->lo_any.ele_id; ele2 = last_eptr->lo_any.ele_id; cell->cell_float_list = lo_capture_floating_elements(context, state, ele1, ele2, eptr->lo_any.y, (eptr->lo_any.y + height), &max_y); if ((max_y - eptr->lo_any.y) > cell->height) { cell->height = max_y - eptr->lo_any.y; } lo_ShiftCell(cell, dx, dy); return(cell); }