lo_MapRec * lo_FreeMap(lo_MapRec *map) { lo_MapRec *next; if (map->areas != NULL) { lo_MapAreaRec *tmp_area; lo_MapAreaRec *areas; areas = map->areas; while (areas != NULL) { tmp_area = areas; areas = areas->next; if (tmp_area->alt != NULL) { PA_FREE(tmp_area->alt); } if (tmp_area->coords != NULL) { XP_FREE(tmp_area->coords); } XP_DELETE(tmp_area); } } if (map->name != NULL) { XP_FREE(map->name); } next = map->next; XP_DELETE(map); return next; }
intn PA_ParseStringToTags(MWContext *context, char *buf, int32 len, void *output_func) { intn ret; pa_DocData *fake_doc_data; NET_StreamClass s; fake_doc_data = XP_NEW_ZAP(pa_DocData); if (fake_doc_data == NULL) { return(-1); } fake_doc_data->doc_id = 100164; fake_doc_data->window_id = context; fake_doc_data->output_tag = (PA_OutputFunction *)output_func; fake_doc_data->hold_buf = XP_ALLOC(HOLD_BUF_UNIT * sizeof(char)); if (fake_doc_data->hold_buf == NULL) { XP_DELETE(fake_doc_data); return(-1); } fake_doc_data->hold_size = HOLD_BUF_UNIT; fake_doc_data->brute_tag = P_UNKNOWN; fake_doc_data->format_out = FO_PRESENT_INLINE; fake_doc_data->parser_stream = XP_NEW(NET_StreamClass); if (fake_doc_data->parser_stream == NULL) { XP_FREE(fake_doc_data->hold_buf); XP_DELETE(fake_doc_data); return(-1); } /* We don't need most of the fields in the fake stream */ fake_doc_data->parser_stream->complete = PA_MDLComplete; fake_doc_data->parser_stream->data_object = (void *)fake_doc_data; fake_doc_data->is_inline_stream = TRUE; s.data_object=fake_doc_data; ret = PA_ParseBlock(&s, (const char *)buf, (int)len); if (ret > 0) { PA_MDLComplete(&s); } return(ret); }
url_finalize(JSContext *cx, JSObject *obj) { JSURL *url; MochaDecoder *decoder; MWContext *context; LO_AnchorData *anchor_data; url = JS_GetPrivate(cx, obj); if (!url) return; decoder = url->url_decoder; if (url->index != URL_NOT_INDEXED) { context = decoder->window_context; if (context) { LO_LockLayout(); anchor_data = LO_GetLinkByIndex(context, url->layer_id, url->index); if (anchor_data && anchor_data->mocha_object == obj) anchor_data->mocha_object = NULL; LO_UnlockLayout(); } } DROP_BACK_COUNT(decoder); JS_RemoveRoot(cx, &url->href); JS_RemoveRoot(cx, &url->target); JS_RemoveRoot(cx, &url->text); XP_DELETE(url); }
/* * 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; }
/* Release all subtree and the node */ void css_FreeNode(css_node vp) { if (vp) { css_FreeNode(vp->left); css_FreeNode(vp->right); if (vp->string) XP_FREE(vp->string); XP_DELETE(vp); } }
PUBLIC void CSS_ConvertToJS(char * src, int32 src_count, char ** dst, int32 * dst_count) { StyleBuffer sb; XP_Bool translated; *dst = NULL; *dst_count = 0; if (NULL == src || 0 == src_count) return; input_buffer = src; input_buffer_count = src_count; input_buffer_index = 0; css_tree_root = NULL; if (css_parse() != 0) return; sb = XP_NEW_ZAP(StyleBufferRec); if (sb == NULL) return; translated = ConvertStyleSheet(css_tree_root, sb); css_FreeNode(css_tree_root); #if ALLOW_IMPORT if (! translated) EchoCSS(src, src_count, sb); #endif /* The caller should free *dst. */ *dst = sb->buffer; *dst_count = sb->buffer_count; XP_DELETE(sb); }
CStreamData *WPM_UnRegisterContentTypeConverter(const char *pServer, const char *pMimeType, FO_Present_Types iFormatOut) { // Purpose: Remove a content type converter from the list of registered // types. // Arguments: pServer The name of the server. // pMimeType The mime type the server should be // registered to handle. // iFormatOut The format out that the server is registered // to handle. // Returns: CStreamData * The data passed in via RegisterContentTypeConverter, // so the application can free it. NULL on failure. // Comments: This function has intimate knowledge of the CStreamData // class and it's heirs. This is so that it can correctly // find the server in the registration list. // Only automated converters can be unregistered. // Revision History: // 01-08-94 created GAB // // Can't handle any caching formats, shouldn't ever be registered! if((iFormatOut & FO_CACHE_ONLY) || (iFormatOut & FO_ONLY_FROM_CACHE)) { ASSERT(0); return(NULL); } XP_List* pList = NET_GetRegConverterList(iFormatOut); void *objPtr = NULL; CStreamData *pAutoStream = (CStreamData *)NET_GETDataObject(pList, (char *)pMimeType, &objPtr); if(pAutoStream) { switch(pAutoStream->GetType()) { case CStreamData::m_DDE: { CDDEStreamData *pDDEStream = (CDDEStreamData *)pAutoStream; // Compare the server names. // This will not be a case sensitive thing, since DDE isn't // case sensitive. if(0 == pDDEStream->m_csServerName.CompareNoCase(pServer)) { // This is the one. Take it out. XP_ListRemoveObject(pList, objPtr); XP_DELETE(objPtr); objPtr = NULL; return(pAutoStream); } break; } case CStreamData::m_OLE: { COLEStreamData *pOLEStream = (COLEStreamData *)pAutoStream; // Compare the server names. // This will be a case sensitive thing. if(pOLEStream->m_csServerName == pServer) { // This is the one. Take it out. XP_ListRemoveObject(pList, objPtr); XP_DELETE(objPtr); objPtr = NULL; return(pAutoStream); } break; } default: // unknown type. ASSERT(0); break; } } // Not successful. return(NULL); }
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); } } }
void lo_BeginMulticolumn(MWContext *context, lo_DocState *state, PA_Tag *tag, LO_MulticolumnStruct *multicolEle) { lo_MultiCol *multicol; PA_Block buff; char *str; int32 val; int32 doc_width; /* int32 width; */ multicol = XP_NEW(lo_MultiCol); if (multicol == NULL) { state->top_state->out_of_memory = TRUE; return; } multicol->width = 0; multicol->isPercentWidth = FALSE; /* Put a pointer to lo_multicol inside the MULTICOLUMN layout element that will be placed on the line list */ multicolEle->multicol = multicol; /* * If this multicol is within a layer, then we have to create an * artificial TABLE around it (since the multicol code depends on * the state's line array, which isn't in an updated state within * a layer). */ if (state->layer_nest_level > 0) { PA_Tag *tmp_tag; lo_TableRec *table; if (state->in_paragraph != FALSE) { lo_CloseParagraph(context, &state, tag, 2); } lo_BeginTableAttributes(context, state, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); table = state->current_table; if (table) { lo_BeginTableRowAttributes(context, state, table, NULL, NULL, NULL, NULL); lo_BeginTableCellAttributes(context, state, table, NULL, NULL, NULL, NULL, NULL, LO_TILE_BOTH, NULL, NULL, NULL, NULL, FALSE, TRUE); /* * If we've successfully created a subdoc, we need to clone * the MULTICOL tag and save it in the subdoc, since the code * above us doesn't realize we're now in a table. */ if (state->sub_state) { state = state->sub_state; tmp_tag = PA_CloneMDLTag(tag); lo_SaveSubdocTags(context, state, tmp_tag); } multicol->close_table = TRUE; } } else { /* if (line will not be flushed by lo_SetSoftLineBreak) and (there exist some elements on the line list) */ if (state->linefeed_state >= 2 && state->line_list != NULL) { /* Append zero width and height line feed to the line list and flush the line list into the line array. This forces the layout of elements contained within the MULTICOL tags to start on a blank line_list and hence on a new line. lo_EndMultiColumn needs this to do its line array hacking properly. */ lo_AppendZeroWidthAndHeightLF(context, state); } lo_SetSoftLineBreakState(context, state, FALSE, 2); multicol->close_table = FALSE; } /* * Since we are going to block layout during multicol * processing, we need to flush the compositor of any * pending displays. */ if (context->compositor) { CL_CompositeNow(context->compositor); } lo_StartMultiColInit( state, multicol ); /* multicol->end_last_line = state->end_last_line; multicol->start_ele = state->top_state->element_id; multicol->start_line = state->line_num; multicol->end_line = multicol->start_line; multicol->start_x = state->x; multicol->start_y = state->y; multicol->end_y = multicol->start_y; */ multicol->cols = 1; multicol->gutter = MULTICOL_GUTTER_WIDTH; /* * Get the cols parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_COLS); if (buff != NULL) { PA_LOCK(str, char *, buff); multicol->cols = XP_ATOI(str); PA_UNLOCK(buff); PA_FREE(buff); } if (multicol->cols <= 1) { XP_DELETE(multicol); multicolEle->multicol = NULL; return; } /* * Get the gutter parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_GUTTER); if (buff != NULL) { PA_LOCK(str, char *, buff); multicol->gutter = XP_ATOI(str); if (multicol->gutter < 1) { multicol->gutter = 1; } PA_UNLOCK(buff); PA_FREE(buff); } multicol->gutter = FEUNITS_X(multicol->gutter, context); doc_width = state->right_margin - state->left_margin; /* width = doc_width; */ /* * 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) { if (state->allow_percent_width == FALSE) { val = 0; } else { val = doc_width * val / 100; if (val < 1) { val = 1; } } } else { val = FEUNITS_X(val, context); if (val < 1) { val = 1; } } width = val; PA_UNLOCK(buff); PA_FREE(buff); } */ 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) { multicol->width = val; multicol->isPercentWidth = TRUE; } else { multicol->width = val; multicol->isPercentWidth = FALSE; val = FEUNITS_X(val, context); if (val < 1) { val = 1; } } PA_UNLOCK(buff); PA_FREE(buff); } /* width = width - ((multicol->cols - 1) * multicol->gutter); multicol->col_width = width / multicol->cols; if (multicol->col_width < MULTICOL_MIN_WIDTH) { multicol->col_width = MULTICOL_MIN_WIDTH; } multicol->orig_margin = state->right_margin; lo_PushList(state, tag, QUOTE_NONE); */ lo_SetupStateForBeginMulticol( state, multicol, doc_width ); /* state->right_margin = state->left_margin + multicol->col_width; state->x = state->left_margin; state->list_stack->old_left_margin = state->left_margin; state->list_stack->old_right_margin = state->right_margin; multicol->orig_min_width = state->min_width; state->min_width = 0; */ /* * Don't display anything while processing the multicolumn text. */ /* multicol->orig_display_blocking_element_y = state->display_blocking_element_y; state->display_blocking_element_y = -1; multicol->orig_display_blocked = state->display_blocked; state->display_blocked = TRUE; multicol->next = state->current_multicol; state->current_multicol = multicol; */ }