/* INTL_DefaultWinCharSetID, Based on DefaultDocCSID, it determines which Win CSID to use for Display */ PUBLIC int16 INTL_DefaultWinCharSetID(iDocumentContext context) { if (context) { INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(context); if (INTL_GetCSIWinCSID(csi)) return INTL_GetCSIWinCSID(csi); } return INTL_DocToWinCharSetID(INTL_DefaultDocCharSetID(context)); }
PUBLIC int16 INTL_DefaultTextAttributeCharSetID(iDocumentContext context) { if (context) { INTL_CharSetInfo c = LO_GetDocumentCharacterSetInfo(context); if (INTL_GetCSIWinCSID(c)) return INTL_GetCSIWinCSID(c); } return INTL_DefaultWinCharSetID(context); }
static void lo_next_character(MWContext *context, lo_DocState *state, LO_Element **ele_loc, int32 *pos, Bool forward) { INTL_CharSetInfo c = LO_GetDocumentCharacterSetInfo(context); int16 win_csid = INTL_GetCSIWinCSID(c); LO_Element *eptr; int32 position; eptr = *ele_loc; position = *pos; /* * If our current element is text, we may be able to just * move inside of it. */ if (eptr->type == LO_TEXT) { if ((forward != FALSE)&& (position < (eptr->lo_text.text_len - 1))) { #ifdef INTL_FIND /* Add by ftang to provide international find */ position = INTL_NextCharIdxInText(win_csid, (unsigned char*)eptr->lo_text.text, position ); #else position++; #endif *ele_loc = eptr; *pos = position; return; } else if ((forward == FALSE)&&(position > 0)) { #ifdef INTL_FIND /* Add by ftang to provide international find */ position = INTL_PrevCharIdxInText(win_csid, (unsigned char*)eptr->lo_text.text, position ); #else position--; #endif *ele_loc = eptr; *pos = position; return; } } /* * If we didn't return above, we need to move to a new element. */ if (forward != FALSE) { /* * If no next element, see if this is a CELL we can * hop out of. */ if (eptr->lo_any.next == NULL) { int32 no_loop_id; no_loop_id = eptr->lo_any.ele_id; /* * Jump cell boundries if there is one * between here and the next element. */ eptr = lo_JumpCellWall(context, state, eptr); /* * If non-null eptr is the cell we were in, move * to the next cell/element. */ if (eptr != NULL) { eptr = eptr->lo_any.next; } /* * infinite loop prevention */ if ((eptr != NULL)&&(eptr->lo_any.ele_id <= no_loop_id)) { #ifdef DEBUG XP_TRACE(("Find loop avoidance 1\n")); #endif /* DEBUG */ eptr = NULL; } } else { eptr = eptr->lo_any.next; } } else { /* * If no previous element, see if this is a CELL we can * hop out of. */ if (eptr->lo_any.prev == NULL) { int32 no_loop_id; no_loop_id = eptr->lo_any.ele_id; /* * Jump cell boundries if there is one * between here and the previous element. */ eptr = lo_JumpCellWall(context, state, eptr); /* * If non-null eptr is the cell we were in, move * to the previous cell/element. */ if (eptr != NULL) { eptr = eptr->lo_any.prev; } /* * infinite loop prevention */ if ((eptr != NULL)&&(eptr->lo_any.ele_id >= no_loop_id)) { #ifdef DEBUG XP_TRACE(("Find loop avoidance 2\n")); #endif /* DEBUG */ eptr = NULL; } } else { eptr = eptr->lo_any.prev; } } while (eptr != NULL) { if (eptr->type == LO_LINEFEED) { break; } else if ((eptr->type == LO_TEXT)&&(eptr->lo_text.text != NULL)) { break; } else if (eptr->type == LO_CELL) { /* * When we walk onto a cell, we need * to walk into it if it isn't empty. */ if ((forward != FALSE)&& (eptr->lo_cell.cell_list != NULL)) { eptr = eptr->lo_cell.cell_list; continue; } else if ((forward == FALSE)&& (eptr->lo_cell.cell_list_end != NULL)) { eptr = eptr->lo_cell.cell_list_end; continue; } } /* * Move forward or back to the next element */ if (forward != FALSE) { /* * If no next element, see if this is a CELL we can * hop out of. */ if (eptr->lo_any.next == NULL) { int32 no_loop_id; no_loop_id = eptr->lo_any.ele_id; /* * Jump cell boundries if there is one * between here and the next element. */ eptr = lo_JumpCellWall(context, state, eptr); /* * If non-null eptr is the cell we were in, move * to the next cell/element. */ if (eptr != NULL) { eptr = eptr->lo_any.next; } /* * infinite loop prevention */ if ((eptr != NULL)&&( eptr->lo_any.ele_id <= no_loop_id)) { #ifdef DEBUG XP_TRACE(("Find loop avoidance 3\n")); #endif /* DEBUG */ eptr = NULL; } } else { eptr = eptr->lo_any.next; } } else { /* * If no previous element, see if this is a CELL we can * hop out of. */ if (eptr->lo_any.prev == NULL) { int32 no_loop_id; no_loop_id = eptr->lo_any.ele_id; /* * Jump cell boundries if there is one * between here and the previous element. */ eptr = lo_JumpCellWall(context, state, eptr); /* * If non-null eptr is the cell we were in, move * to the previous cell/element. */ if (eptr != NULL) { eptr = eptr->lo_any.prev; } /* * infinite loop prevention */ if ((eptr != NULL)&& (eptr->lo_any.ele_id >= no_loop_id)) { #ifdef DEBUG XP_TRACE(("Find loop avoidance 4\n")); #endif /* DEBUG */ eptr = NULL; } } else { eptr = eptr->lo_any.prev; } } } if (eptr == NULL) { *ele_loc = NULL; *pos = 0; } else if (eptr->type == LO_TEXT) { *ele_loc = eptr; if (forward != FALSE) { *pos = 0; } else { #ifdef INTL_FIND /* Add by ftang to provide international find */ if(eptr->lo_text.text_len == 0) position = 0; else position = INTL_PrevCharIdxInText(win_csid, (unsigned char*)eptr->lo_text.text, eptr->lo_text.text_len ); #else position = eptr->lo_text.text_len - 1; if (position < 0) { position = 0; } #endif *pos = position; } } else if (eptr->type == LO_LINEFEED) { *ele_loc = eptr; *pos = 0; } }
static Bool lo_find_in_list(MWContext *context, lo_DocState *state, LO_Element *eptr, char *cmp_text, int32 len, int32 position, LO_Element **start_ele_loc, int32 *start_position, LO_Element **end_ele_loc, int32 *end_position, Bool use_case, Bool forward) { int32 cnt; LO_Element *start_element, *end_element; int32 start_pos, end_pos; INTL_CharSetInfo c = LO_GetDocumentCharacterSetInfo(context); int16 win_csid = INTL_GetCSIWinCSID(c); while (eptr != NULL) { Bool have_start, not_equal; int charlen = 1; have_start = FALSE; while ((eptr != NULL)&&(have_start == FALSE)) { unsigned char *tptr; unsigned char *str; switch (eptr->type) { #ifndef INTL_FIND char tchar; #endif case LO_TEXT: if (eptr->lo_text.text != NULL) { PA_LOCK(str, unsigned char *, eptr->lo_text.text); tptr = (unsigned char *)(str + position); #ifdef INTL_FIND if (use_case) have_start = INTL_MatchOneCaseChar(win_csid, (unsigned char*)cmp_text,tptr,&charlen); else have_start = INTL_MatchOneChar(win_csid, (unsigned char*)cmp_text,tptr,&charlen); #else if (use_case == FALSE) { tchar = TOLOWER(*tptr); } else { tchar = *tptr; } if (cmp_text[0] == tchar) { have_start = TRUE; } #endif PA_UNLOCK(eptr->lo_text.text); } break; case LO_LINEFEED: if (cmp_text[0] == ' ') { have_start = TRUE; } break; case LO_HRULE: case LO_FORM_ELE: case LO_BULLET: case LO_IMAGE: case LO_SUBDOC: case LO_TABLE: default: break; } if (have_start == FALSE) { lo_next_character(context, state, &eptr, &position, forward); } } if (have_start == FALSE) { return(FALSE); } start_element = eptr; start_pos = position; #ifdef INTL_FIND if (len == charlen) #else if (len == 1) #endif { end_element = eptr; end_pos = position; *start_ele_loc = start_element; *start_position = start_pos; *end_ele_loc = end_element; *end_position = end_pos; return(TRUE); } #ifdef INTL_FIND cnt = charlen; #else cnt = 1; #endif not_equal = FALSE; lo_next_character(context, state, &eptr, &position, TRUE); while ((eptr != NULL)&&(cnt < len)&&(not_equal == FALSE)) { unsigned char *tptr; /* this needs to be an unsigned quantity! chouck 3-Nov-94 */ char *str; switch (eptr->type) { #ifndef INTL_FIND char tchar; #endif case LO_TEXT: if (eptr->lo_text.text != NULL) { PA_LOCK(str, char *, eptr->lo_text.text); tptr = (unsigned char *)(str + position); #ifdef INTL_FIND if (use_case) not_equal = ! INTL_MatchOneCaseChar(win_csid,(unsigned char *) cmp_text+cnt,tptr,&charlen); else not_equal = ! INTL_MatchOneChar(win_csid,(unsigned char *) cmp_text+cnt,tptr,&charlen); #else if (use_case == FALSE) { /* this needs to be an unsigned quantity! chouck 3-Nov-94 */ tchar = TOLOWER(*tptr); } else { tchar = (char) *tptr; } if (tchar != cmp_text[cnt]) { not_equal = TRUE; } #endif PA_UNLOCK(eptr->lo_text.text); } break; case LO_LINEFEED: if (cmp_text[cnt] != ' ') { not_equal = TRUE; } break; case LO_HRULE: case LO_FORM_ELE: case LO_BULLET: case LO_IMAGE: case LO_SUBDOC: case LO_TABLE: default: break; } #ifdef INTL_FIND cnt += charlen; #else cnt++; #endif if ((not_equal == FALSE)&&(cnt < len)) { lo_next_character(context, state, &eptr, &position, TRUE); } }
PUBLIC NET_StreamClass * net_ColorHTMLStream (int format_out, void *data_obj, URL_Struct *URL_s, MWContext *window_id) { DataObject* obj; char *new_markup=0; char *new_url=0; char *old_url; int status, type; NET_StreamClass *next_stream, *new_stream; Bool is_html_stream = FALSE; INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(window_id); INTL_CharSetInfo next_csi; TRACEMSG(("Setting up ColorHTML stream. Have URL: %s\n", URL_s->address)); /* treat the stream as html if the closure data says * it's HTML and it is also not a mail or news message */ type = NET_URL_Type(URL_s->address); if(data_obj && !XP_STRCMP((char *)data_obj, TEXT_HTML) && type != MAILBOX_TYPE_URL && type != IMAP_TYPE_URL && type != NEWS_TYPE_URL) is_html_stream = TRUE; /* use a new named window */ StrAllocCopy(URL_s->window_target, VIEW_SOURCE_TARGET_WINDOW_NAME); /* add the url address to the name so that there can be * one view source window per url */ StrAllocCat(URL_s->window_target, URL_s->address); /* zero position_tag to prevent hash lossage */ URL_s->position_tag = 0; /* alloc a new chrome struct and stick it in the URL * so that we can turn off the relavent stuff */ URL_s->window_chrome = XP_NEW(Chrome); if(URL_s->window_chrome) { /* zero everything to turn off all chrome */ XP_MEMSET(URL_s->window_chrome, 0, sizeof(Chrome)); URL_s->window_chrome->type = MWContextDialog; URL_s->window_chrome->show_scrollbar = TRUE; URL_s->window_chrome->allow_resize = TRUE; URL_s->window_chrome->allow_close = TRUE; } /* call the HTML parser */ StrAllocCopy(URL_s->content_type, INTERNAL_PARSER); /* use the view-source: url instead */ StrAllocCopy(new_url, VIEW_SOURCE_URL_PREFIX); StrAllocCat(new_url, URL_s->address); old_url = URL_s->address; URL_s->address = new_url; format_out = FO_PRESENT; /* open next stream */ next_stream = NET_StreamBuilder(format_out, URL_s, window_id); if(!next_stream) { FREE(old_url); return(NULL); } next_csi = LO_GetDocumentCharacterSetInfo(next_stream->window_id); /* jliu: for international's reason, set the value ASAP, so the following stream can share it */ INTL_SetCSIWinCSID(next_csi, INTL_GetCSIWinCSID(csi)); INTL_SetCSIDocCSID(next_csi, INTL_GetCSIDocCSID(csi)); #define DEF_PICS_LABEL "<META http-equiv=PICS-Label content='(PICS-1.0 \"http://home.netscape.com/default_rating\" l gen true r (s 0))'>" /* add a PICS label */ StrAllocCopy(new_markup, DEF_PICS_LABEL); StrAllocCat(new_markup, "<TITLE>"); StrAllocCat(new_markup, XP_GetString(MK_CVCOLOR_SOURCE_OF)); StrAllocCat(new_markup, old_url); StrAllocCat(new_markup, "</TITLE><BODY BGCOLOR=#C0C0C0>"); if(!is_html_stream) StrAllocCat(new_markup, "<PLAINTEXT>"); else StrAllocCat(new_markup, "<PRE>"); FREE(old_url); status = (*next_stream->put_block)(next_stream, new_markup, XP_STRLEN(new_markup)); FREE(new_markup); if(status < 0) { (*next_stream->abort)(next_stream, status); FREE(next_stream); return(NULL); } if(!is_html_stream) return(next_stream); /* else; continue on and build up this stream module * and attach the next stream to it */ new_stream = XP_NEW(NET_StreamClass); if(new_stream == NULL) { (*next_stream->abort)(next_stream, status); FREE(next_stream); return(NULL); } obj = XP_NEW(DataObject); if (obj == NULL) { (*next_stream->abort)(next_stream, status); FREE(next_stream); FREE(new_stream); return(NULL); } XP_MEMSET(obj, 0, sizeof(DataObject)); obj->state = IN_CONTENT; obj->next_stream = next_stream; obj->tag_type = P_UNKNOWN; new_stream->name = "HTML Colorer"; new_stream->complete = (MKStreamCompleteFunc) net_ColorHTMLComplete; new_stream->abort = (MKStreamAbortFunc) net_ColorHTMLAbort; new_stream->put_block = (MKStreamWriteFunc) net_ColorHTMLWrite; new_stream->is_write_ready = (MKStreamWriteReadyFunc) net_ColorHTMLWriteReady; new_stream->data_object = (void *) obj; /* document info object */ new_stream->window_id = window_id; TRACEMSG(("Returning stream from HTMLColorConverter\n")); return new_stream; }
void XFE_FrameListMenu::cascading() { XP_List * frame_list = getShownFrames(); XFE_Frame * frame; int i; int frame_count = XP_ListCount(frame_list); Cardinal num_children; WidgetList children; int total_slots_needed; int slots_to_add; int count; XfeChildrenGet(m_submenu,&children,&num_children); XP_ASSERT( num_children > 1 ); // Total number of slots needed total_slots_needed = m_firstslot + 1 + frame_count; // Number of slots to add slots_to_add = total_slots_needed - num_children; // Add more slots if needed if (slots_to_add > 0) { for (i = 0; i < slots_to_add; i++) { Widget item = XtVaCreateWidget(xfeCmdFrameListRaiseItem, //xmToggleButtonGadgetClass, xmPushButtonGadgetClass, m_submenu, NULL); XtAddCallback(item, XmNactivateCallback, //XmNvalueChangedCallback, &XFE_FrameListMenu::item_activate_cb, (XtPointer) this); } // Update num_slots, since we added stuff XfeChildrenGet(m_submenu,&children,&num_children); } count = 1; // Configure the items for (i = (int) m_firstslot + 1; i < (int) num_children; i++) { // Get the next frame frame = (XFE_Frame*) XP_ListNextObject(frame_list); // If the frame is valid, add its title to the slot buttons if (frame) { MWContext * context = m_parentFrame->getContext(); INTL_CharSetInfo c = LO_GetDocumentCharacterSetInfo(context); XmFontList font_list; char name[1024]; XP_SPRINTF(name,"%d. %s",count++,frame->getTitle()); INTL_MidTruncateString(INTL_GetCSIWinCSID(c), name, name, MAX_ITEM_WIDTH); XmString label = fe_ConvertToXmString((unsigned char *) name, INTL_GetCSIWinCSID(c), NULL, XmFONT_IS_FONT, &font_list); if (label) { XtVaSetValues(children[i],XmNlabelString,label,NULL); XmStringFree(label); } XtManageChild(children[i]); } // If the frame is not valid, the unmanage the slot button else { XtUnmanageChild(children[i]); } } // Update the display so that the gadget buttons get drawn XmUpdateDisplay(m_submenu); if (frame_list) { XP_ListDestroy(frame_list); } }