RTFStatus RTFState::Restore(void) { RTFStatus t_status; t_status = kRTFStatusSuccess; if (t_status == kRTFStatusSuccess) { if (m_entries == NULL) t_status = kRTFStatusUnderflow; } if (t_status == kRTFStatusSuccess) { Entry *t_entry; t_entry = m_entries; m_entries = t_entry -> previous; MCNameDelete(t_entry -> metadata); MCNameDelete(t_entry -> paragraph_metadata); MCNameDelete(t_entry -> hyperlink); delete t_entry; } return t_status; }
RTFReader::~RTFReader(void) { MCNameDelete(m_attributes . text_link); MCNameDelete(m_attributes . text_metadata); if (m_font_name != NULL) free(m_font_name); if (m_field_inst != NULL) free(m_field_inst); }
void MCS_loadurl(MCObject *p_object, const char *p_url, const char *p_message) { bool t_success = true; MCSLoadUrlState *t_state = nil; char *t_processed = nil; MCNameRef t_message = nil; t_success = MCMemoryNew(t_state) && MCSystemProcessUrl(p_url, kMCSystemUrlOperationStrip, t_processed) && MCNameCreateWithCString(p_message, t_message); if (t_success) { t_state->url = t_processed; t_state->message = t_message; t_state->status = kMCSystemUrlStatusNone; t_state->object = p_object -> gethandle(); t_state->data . bytes = nil; t_state->data . size = 0; t_success = MCSystemLoadUrl(t_processed, MCS_loadurl_callback, t_state); } if (t_success) MCresult->clear(); else { MCCStringFree(t_processed); MCNameDelete(t_message); MCMemoryDelete(t_state); MCurlresult -> clear(); MCresult->sets("error: load URL failed"); } }
static bool MCS_loadurl_callback(void *p_context, MCSystemUrlStatus p_status, const void *p_data) { MCSLoadUrlState *context; context = static_cast<MCSLoadUrlState *>(p_context); context -> status = p_status; if (p_status == kMCSystemUrlStatusError) MCMemoryDelete(context->data.bytes); else if (p_status == kMCSystemUrlStatusLoading) { const MCString *t_data = static_cast<const MCString*>(p_data); MCMemoryReallocate(context->data.bytes, context->data.size + t_data->getlength(), context->data.bytes); MCMemoryCopy(static_cast<uint8_t*>(context->data.bytes) + context->data.size, t_data->getstring(), t_data->getlength()); context->data.size += t_data->getlength(); } send_url_progress(context -> object, p_status, context -> url, context -> data . size, context -> total, (const char *)p_data); if (p_status == kMCSystemUrlStatusError || p_status == kMCSystemUrlStatusFinished) { MCUrlLoadEvent *t_event; t_event = MCUrlLoadEvent::CreateUrlLoadEvent(context->object, context->message, context->url, p_status, context->data.bytes, context->data.size, static_cast<const char *>(p_data)); if (t_event) MCEventQueuePostCustom(t_event); context->object->Release(); MCCStringFree(context->url); MCNameDelete(context->message); MCMemoryDelete(context); } return true; }
MCComref::~MCComref() { while (params != NULL) { MCParameter *tmp = params; params = params->getnext(); delete tmp; } MCNameDelete(name); }
void MCUrlLoadEvent::Destroy(void) { MCCStringFree(m_url); MCNameDelete(m_message); if (m_status == kMCSystemUrlStatusFinished) MCMemoryDelete(m_data.bytes); else if (m_status == kMCSystemUrlStatusError) MCCStringFree(m_error); if (m_object != nil) m_object->Release(); delete this; }
void MCLogicalFontTableFinish(void) { for(uint32_t i = 0; i < s_logical_font_table_size; i++) { MCNameRef t_textfont; uint2 t_textstyle; uint2 t_textsize; bool t_unicode; MCLogicalFontTableGetEntry(i, t_textfont, t_textstyle, t_textsize, t_unicode); MCNameDelete(t_textfont); } MCMemoryDeleteArray(s_logical_font_table); s_logical_font_table_size = 0; s_logical_font_table_capacity = 0; s_logical_font_table = nil; }
MCUrlLoadEvent *MCUrlLoadEvent::CreateUrlLoadEvent(MCObjectHandle *p_object, MCNameRef p_message, const char *p_url, MCSystemUrlStatus p_status, void *p_data, uint32_t p_size, const char *p_error) { MCUrlLoadEvent *t_event; t_event = new MCUrlLoadEvent(); if (t_event == nil) return nil; t_event->m_url = nil; t_event->m_object = nil; t_event->m_status = kMCSystemUrlStatusNone; t_event->m_error = nil; t_event->m_message = nil; bool t_success; t_success = true; if (t_success) t_success = MCCStringClone(p_url, t_event->m_url); if (t_success) t_success = MCNameClone(p_message, t_event->m_message); if (t_success && p_status == kMCSystemUrlStatusError) t_success = MCCStringClone(p_error, t_event->m_error); if (t_success) { t_event->m_status = p_status; t_event->m_object = p_object; t_event->m_object->Retain(); if (t_event->m_status == kMCSystemUrlStatusFinished) { t_event->m_data.bytes = p_data; t_event->m_data.size = p_size; } } else { MCCStringFree(t_event->m_url); MCNameDelete(t_event->m_message); MCCStringFree(t_event->m_error); delete t_event; return nil; } return t_event; }
void MCFontRelease(MCFontRef self) { if (self == nil) return; self -> references -= 1; if (self -> references > 0) return; if (s_fonts != self) { MCFont *t_previous_font; for(t_previous_font = s_fonts; t_previous_font -> next != self; t_previous_font = t_previous_font -> next) ; t_previous_font -> next = self -> next; } else s_fonts = self -> next; MCNameDelete(self -> name); MCMemoryDelete(self); }
RTFStatus RTFReader::Flush(bool p_force) { RTFStatus t_status; t_status = kRTFStatusSuccess; if (!m_attributes_changed && !p_force) return t_status; MCTextBlock t_block; bool t_changed; t_changed = false; if (m_attributes_changed) { t_block . foreground_color = m_state . GetForegroundColor(); t_block . background_color = m_state . GetBackgroundColor(); t_block . font_name = m_state . GetFontName(); if (m_state . GetFontSize() != 0) t_block . font_size = half_points_to_pixels(m_state . GetFontSize()); else t_block . font_size = 0; t_block . font_style = FA_DEFAULT_STYLE; if ((m_state . GetFontStyle() & kRTFFontStyleItalic) != 0) t_block . font_style |= FA_ITALIC; if ((m_state . GetFontStyle() & kRTFFontStyleBold) != 0) t_block . font_style |= FA_BOLD; if ((m_state . GetFontStyle() & kRTFFontStyleUnderline) != 0) t_block . font_style |= FA_UNDERLINE; if ((m_state . GetFontStyle() & kRTFFontStyleStrikethrough) != 0) t_block . font_style |= FA_STRIKEOUT; if ((m_state . GetFontStyle() & kRTFFontStyleLink) != 0) t_block . font_style |= FA_LINK; if ((m_state . GetFontStyle() & kRTFFontStyleSuperscript) != 0) t_block . text_shift = -4; else if ((m_state . GetFontStyle() & kRTFFontStyleSubscript) != 0) t_block . text_shift = 4; else t_block . text_shift = 0; if (m_state . GetHyperlink() != kMCEmptyName) MCNameClone(m_state . GetHyperlink(), t_block . text_link); else t_block . text_link = nil; if (m_state . GetMetadata() != kMCEmptyName) MCNameClone(m_state . GetMetadata(), t_block . text_metadata); else t_block . text_metadata = nil; t_block . string_native = false; t_block . string_buffer = NULL; t_block . string_length = 0; if (t_block . foreground_color != m_attributes . foreground_color || t_block . background_color != m_attributes . background_color || t_block . font_size != m_attributes . font_size || t_block . font_style != m_attributes . font_style || t_block . text_shift != m_attributes . text_shift || CStringCompare(t_block . font_name, m_attributes . font_name) != 0 || t_block . text_link != m_attributes . text_link || t_block . text_metadata != m_attributes . text_metadata) t_changed = true; } const uint2 *t_string_buffer; uint4 t_string_length; if (t_status == kRTFStatusSuccess) t_status = m_text . Borrow(t_string_buffer, t_string_length); if (t_status == kRTFStatusSuccess && t_string_length > 0 && (t_changed || p_force)) { if (m_needs_paragraph) { m_needs_paragraph = false; // MW-2012-03-14: [[ RtfParaStyles ]] Use the 'Paragraph()' method to ensure // paragraph styles get applied. Paragraph(); } m_attributes . string_native = false; m_attributes . string_buffer = t_string_buffer; m_attributes . string_length = t_string_length / 2; m_converter(m_converter_context, NULL, &m_attributes); m_text . Clear(); } if (t_changed) { MCNameDelete(m_attributes . text_metadata); MCNameDelete(m_attributes . text_link); memcpy(&m_attributes, &t_block, sizeof(MCTextBlock)); m_attributes_changed = false; } return t_status; }
void RTFReader::ProcessField(void) { if (m_field_inst == nil) return; char *t_type, *t_data; t_type = m_field_inst; while(isspace(*t_type)) t_type++; t_data = strchr(t_type, ' '); if (t_data != nil) { char *t_type_end; t_type_end = t_data; while(isspace(*t_data)) t_data++; *t_type_end = '\0'; if (*t_data == '"') { char *t_data_end; t_data += 1; t_data_end = t_data; while(*t_data_end != '\0' && *t_data_end != '\"') t_data_end++; if (*t_data_end == '\"') *t_data_end = '\0'; else t_data = nil; } else t_data = nil; } if (t_type != nil && t_data != nil) { MCNameRef t_name; /* UNCHECKED */ MCNameCreateWithCString(t_data, t_name); if (MCU_strcasecmp(t_type, "HYPERLINK") == 0) { m_state . SetHyperlink(t_name); m_state . SetFontStyle(m_state . GetFontStyle() | kRTFFontStyleLink); } else if (MCU_strcasecmp(t_type, "LCANCHOR") == 0) { m_state . SetHyperlink(t_name); } else if (MCU_strcasecmp(t_type, "LCMETADATA") == 0) { MCNameRef t_name; /* UNCHECKED */ MCNameCreateWithCString(t_data, t_name); m_state . SetMetadata(t_name); } else if (MCU_strcasecmp(t_type, "LCLINEMETADATA") == 0) { MCNameRef t_name; /* UNCHECKED */ MCNameCreateWithCString(t_data, t_name); m_state . SetParagraphMetadata(t_name); } MCNameDelete(t_name); } free(m_field_inst); m_field_inst = nil; }
bool MCModeHandleMessageBoxChanged(MCExecPoint& ep) { // IM-2013-04-16: [[ BZ 10836 ]] update revMessageBoxLastObject // if the source of the change is not within the message box MCObject *t_msg_box = nil; if (MCmessageboxredirect != nil) t_msg_box = MCmessageboxredirect; else { if (MCmbstackptr == nil) MCmbstackptr = MCdispatcher->findstackname(MCmessagenamestring); t_msg_box = MCmbstackptr; } MCObject *t_src_object = nil; if (ep.getobj() != nil) t_src_object = ep.getobj(); bool t_in_msg_box = false; MCObject *t_obj_ptr = t_src_object; while (t_obj_ptr != nil) { if (t_obj_ptr == t_msg_box) { t_in_msg_box = true; break; } t_obj_ptr = t_obj_ptr->getparent(); } if (!t_in_msg_box) { if (MCmessageboxlastobject != nil) MCmessageboxlastobject->Release(); MCmessageboxlastobject = t_src_object->gethandle(); MCNameDelete(MCmessageboxlasthandler); MCmessageboxlasthandler = nil; MCNameClone(ep.gethandler()->getname(), MCmessageboxlasthandler); MCmessageboxlastline = ep.getline(); } if (MCmessageboxredirect != NULL) { if (MCmessageboxredirect -> gettype() == CT_FIELD) { MCStack *t_msg_stack; t_msg_stack = MCmessageboxredirect -> getstack(); Window_mode newmode = t_msg_stack -> userlevel() == 0 ? WM_MODELESS : (Window_mode)(t_msg_stack -> userlevel() + WM_TOP_LEVEL_LOCKED); // MW-2011-07-05: [[ Bug 9608 ]] The 'ep' that is passed through to us does // not necessarily have an attached object any more. Given that the 'rel' // parameter of the open stack call is unused, computing it from that // context is redundent. if (t_msg_stack -> getmode() != newmode) t_msg_stack -> openrect(t_msg_stack -> getrect(), newmode, NULL, WP_DEFAULT, OP_NONE); else t_msg_stack -> raise(); ((MCField *)MCmessageboxredirect) -> settext(0, ep . getsvalue(), False); } else { MCAutoNameRef t_msg_changed; /* UNCHECKED */ t_msg_changed . CreateWithCString("msgchanged"); bool t_added; if (MCnexecutioncontexts < MAX_CONTEXTS && ep . getobj() != nil) { MCexecutioncontexts[MCnexecutioncontexts++] = &ep; t_added = true; } MCmessageboxredirect -> message(t_msg_changed); if (t_added) MCnexecutioncontexts--; } return true; } return false; }
void MCU_finalize_names(void) { MCNameDelete(MCN_msg); MCNameDelete(MCN_each); MCNameDelete(MCN_it); MCNameDelete(MCN_default_text_font); MCNameDelete(MCM_apple_event); MCNameDelete(MCM_arrow_key); MCNameDelete(MCM_assert_error); MCNameDelete(MCM_backspace_key); MCNameDelete(MCM_close_background); MCNameDelete(MCM_close_card); MCNameDelete(MCM_close_control); MCNameDelete(MCM_close_field); MCNameDelete(MCM_close_stack); MCNameDelete(MCM_close_stack_request); MCNameDelete(MCM_color_changed); MCNameDelete(MCM_command_key_down); MCNameDelete(MCM_control_key_down); MCNameDelete(MCM_copy_key); MCNameDelete(MCM_current_time_changed); MCNameDelete(MCM_cut_key); MCNameDelete(MCM_debug_str); MCNameDelete(MCM_delete_background); MCNameDelete(MCM_delete_button); MCNameDelete(MCM_delete_card); MCNameDelete(MCM_delete_eps); MCNameDelete(MCM_delete_field); MCNameDelete(MCM_delete_graphic); MCNameDelete(MCM_delete_group); MCNameDelete(MCM_delete_image); MCNameDelete(MCM_delete_key); MCNameDelete(MCM_delete_scrollbar); MCNameDelete(MCM_delete_player); MCNameDelete(MCM_delete_stack); MCNameDelete(MCM_delete_widget); MCNameDelete(MCM_delete_url); MCNameDelete(MCM_desktop_changed); MCNameDelete(MCM_drag_drop); MCNameDelete(MCM_drag_end); MCNameDelete(MCM_drag_enter); MCNameDelete(MCM_drag_leave); MCNameDelete(MCM_drag_move); MCNameDelete(MCM_drag_start); MCNameDelete(MCM_edit_script); MCNameDelete(MCM_enter_in_field); MCNameDelete(MCM_enter_key); MCNameDelete(MCM_error_dialog); MCNameDelete(MCM_escape_key); MCNameDelete(MCM_eval); MCNameDelete(MCM_exit_field); MCNameDelete(MCM_focus_in); MCNameDelete(MCM_focus_out); MCNameDelete(MCM_function_key); MCNameDelete(MCM_get_cached_urls); MCNameDelete(MCM_get_url); MCNameDelete(MCM_get_url_status); MCNameDelete(MCM_gradient_edit_ended); MCNameDelete(MCM_gradient_edit_started); MCNameDelete(MCM_help); MCNameDelete(MCM_hot_spot_clicked); MCNameDelete(MCM_icon_menu_pick); MCNameDelete(MCM_icon_menu_opening); MCNameDelete(MCM_status_icon_menu_pick); MCNameDelete(MCM_status_icon_menu_opening); MCNameDelete(MCM_status_icon_click); MCNameDelete(MCM_status_icon_double_click); MCNameDelete(MCM_iconify_stack); MCNameDelete(MCM_id_changed); MCNameDelete(MCM_idle); MCNameDelete(MCM_internal); MCNameDelete(MCM_internal2); MCNameDelete(MCM_key_down); MCNameDelete(MCM_key_up); MCNameDelete(MCM_keyboard_activated); MCNameDelete(MCM_keyboard_deactivated); MCNameDelete(MCM_library_stack); MCNameDelete(MCM_link_clicked); MCNameDelete(MCM_load_url); MCNameDelete(MCM_main_stack_changed); MCNameDelete(MCM_menu_pick); MCNameDelete(MCM_message); MCNameDelete(MCM_message_handled); MCNameDelete(MCM_message_not_handled); MCNameDelete(MCM_mouse_double_down); MCNameDelete(MCM_mouse_double_up); MCNameDelete(MCM_mouse_down); MCNameDelete(MCM_mouse_down_in_backdrop); MCNameDelete(MCM_mouse_enter); MCNameDelete(MCM_mouse_leave); MCNameDelete(MCM_mouse_move); MCNameDelete(MCM_mouse_release); MCNameDelete(MCM_mouse_still_down); MCNameDelete(MCM_mouse_up); MCNameDelete(MCM_mouse_up_in_backdrop); MCNameDelete(MCM_mouse_within); MCNameDelete(MCM_move_control); MCNameDelete(MCM_move_stack); MCNameDelete(MCM_move_stopped); MCNameDelete(MCM_movie_touched); MCNameDelete(MCM_name_changed); MCNameDelete(MCM_new_background); MCNameDelete(MCM_new_card); MCNameDelete(MCM_new_stack); MCNameDelete(MCM_new_tool); MCNameDelete(MCM_node_changed); MCNameDelete(MCM_object_selection_ended); MCNameDelete(MCM_object_selection_started); MCNameDelete(MCM_open_background); MCNameDelete(MCM_open_card); MCNameDelete(MCM_open_control); MCNameDelete(MCM_open_field); MCNameDelete(MCM_open_stack); MCNameDelete(MCM_option_key_down); MCNameDelete(MCM_paste_key); MCNameDelete(MCM_play_paused); MCNameDelete(MCM_play_started); MCNameDelete(MCM_play_stopped); MCNameDelete(MCM_post_url); MCNameDelete(MCM_preopen_background); MCNameDelete(MCM_preopen_card); MCNameDelete(MCM_preopen_control); MCNameDelete(MCM_preopen_stack); MCNameDelete(MCM_property_changed); MCNameDelete(MCM_put_url); MCNameDelete(MCM_qtdebugstr); MCNameDelete(MCM_raw_key_down); MCNameDelete(MCM_raw_key_up); MCNameDelete(MCM_relaunch); MCNameDelete(MCM_release_stack); MCNameDelete(MCM_reload_stack); MCNameDelete(MCM_resize_control); MCNameDelete(MCM_resize_control_ended); MCNameDelete(MCM_resize_control_started); MCNameDelete(MCM_resize_stack); MCNameDelete(MCM_resolution_error); MCNameDelete(MCM_resume); MCNameDelete(MCM_resume_stack); MCNameDelete(MCM_return_in_field); MCNameDelete(MCM_return_key); MCNameDelete(MCM_save_stack_request); MCNameDelete(MCM_script_error); MCNameDelete(MCM_script_execution_error); MCNameDelete(MCM_scrollbar_beginning); MCNameDelete(MCM_scrollbar_drag); MCNameDelete(MCM_scrollbar_end); MCNameDelete(MCM_scrollbar_line_dec); MCNameDelete(MCM_scrollbar_line_inc); MCNameDelete(MCM_scrollbar_page_dec); MCNameDelete(MCM_scrollbar_page_inc); MCNameDelete(MCM_selected_object_changed); MCNameDelete(MCM_selection_changed); MCNameDelete(MCM_signal); MCNameDelete(MCM_shut_down); MCNameDelete(MCM_shut_down_request); MCNameDelete(MCM_socket_error); MCNameDelete(MCM_socket_closed); MCNameDelete(MCM_socket_timeout); MCNameDelete(MCM_start_up); MCNameDelete(MCM_suspend); MCNameDelete(MCM_suspend_stack); MCNameDelete(MCM_tab_key); MCNameDelete(MCM_text_changed); MCNameDelete(MCM_trace); MCNameDelete(MCM_trace_break); MCNameDelete(MCM_trace_done); MCNameDelete(MCM_trace_error); MCNameDelete(MCM_undo_changed); MCNameDelete(MCM_undo_key); MCNameDelete(MCM_uniconify_stack); MCNameDelete(MCM_unload_url); MCNameDelete(MCM_update_screen); MCNameDelete(MCM_update_var); #ifdef _MOBILE MCNameDelete(MCN_firstname); MCNameDelete(MCN_lastname); MCNameDelete(MCN_middlename); MCNameDelete(MCN_prefix); MCNameDelete(MCN_suffix); MCNameDelete(MCN_nickname); MCNameDelete(MCN_firstnamephonetic); MCNameDelete(MCN_lastnamephonetic); MCNameDelete(MCN_middlenamephonetic); MCNameDelete(MCN_organization); MCNameDelete(MCN_jobtitle); MCNameDelete(MCN_department); MCNameDelete(MCN_note); MCNameDelete(MCN_email); MCNameDelete(MCN_phone); MCNameDelete(MCN_address); MCNameDelete(MCN_home); MCNameDelete(MCN_work); MCNameDelete(MCN_other); MCNameDelete(MCN_mobile); MCNameDelete(MCN_iphone); MCNameDelete(MCN_main); MCNameDelete(MCN_homefax); MCNameDelete(MCN_workfax); MCNameDelete(MCN_otherfax); MCNameDelete(MCN_pager); MCNameDelete(MCN_street); MCNameDelete(MCN_city); MCNameDelete(MCN_state); MCNameDelete(MCN_zip); MCNameDelete(MCN_country); MCNameDelete(MCN_countrycode); MCNameDelete(MCM_touch_start); MCNameDelete(MCM_touch_move); MCNameDelete(MCM_touch_end); MCNameDelete(MCM_touch_release); MCNameDelete(MCM_motion_start); MCNameDelete(MCM_motion_end); MCNameDelete(MCM_motion_release); MCNameDelete(MCM_url_progress); MCNameDelete(MCM_acceleration_changed); MCNameDelete(MCM_orientation_changed); MCNameDelete(MCM_location_changed); MCNameDelete(MCM_location_error); MCNameDelete(MCM_heading_changed); MCNameDelete(MCM_heading_error); MCNameDelete(MCM_purchase_updated); MCNameDelete(MCM_rotation_rate_changed); MCNameDelete(MCM_tracking_error); MCNameDelete(MCM_local_notification_received); MCNameDelete(MCM_push_notification_received); MCNameDelete(MCM_push_notification_registered); MCNameDelete(MCM_push_notification_registration_error); MCNameDelete(MCM_url_wake_up); MCNameDelete(MCM_browser_started_loading); MCNameDelete(MCM_browser_finished_loading); MCNameDelete(MCM_browser_load_failed); MCNameDelete(MCM_sound_finished_on_channel); MCNameDelete(MCM_ad_loaded); MCNameDelete(MCM_ad_clicked); MCNameDelete(MCM_ad_resize_start); MCNameDelete(MCM_ad_resize_end); MCNameDelete(MCM_ad_expand_start); MCNameDelete(MCM_ad_expand_end); MCNameDelete(MCM_scroller_did_scroll); MCNameDelete(MCM_scroller_begin_drag); MCNameDelete(MCM_scroller_end_drag); MCNameDelete(MCM_player_finished); MCNameDelete(MCM_player_error); MCNameDelete(MCM_player_property_available); MCNameDelete(MCM_input_begin_editing); MCNameDelete(MCM_input_end_editing); MCNameDelete(MCM_input_return_key); MCNameDelete(MCM_input_text_changed); #endif #ifdef _IOS_MOBILE MCNameDelete(MCM_browser_load_request); MCNameDelete(MCM_browser_load_requested); MCNameDelete(MCM_scroller_begin_decelerate); MCNameDelete(MCM_scroller_end_decelerate); MCNameDelete(MCM_scroller_scroll_to_top); MCNameDelete(MCM_player_progress_changed); MCNameDelete(MCM_player_enter_fullscreen); MCNameDelete(MCM_player_leave_fullscreen); MCNameDelete(MCM_player_state_changed); MCNameDelete(MCM_player_movie_changed); MCNameDelete(MCM_player_stopped); MCNameDelete(MCM_reachability_changed); #endif }