void MCCdata::CloneData(const MCCdata& cref, MCField* p_new_owner) { id = cref.id; if (cref.data != NULL && cref.data != (void *)1) { if (id & COMPACT_PARAGRAPHS) data = strclone((char *)cref.data); else { MCParagraph *paragraphs = NULL; MCParagraph *tptr = (MCParagraph *)cref.data; do { // Clone the paragraph MCParagraph *newparagraph = new (nothrow) MCParagraph(*tptr); newparagraph->setparent(p_new_owner); newparagraph->appendto(paragraphs); tptr = (MCParagraph *)tptr->next(); } while (tptr != cref.data); data = paragraphs; } } else data = cref.data; }
IO_stat MCCdata::load(IO_handle stream, MCObject *parent, const char *version) { IO_stat stat; if ((stat = IO_read_uint4(&id, stream)) != IO_NORMAL) return stat; if (parent->gettype() == CT_BUTTON) { uint1 set; stat = IO_read_uint1(&set, stream); data = (void *)(set ? 1 : 0); return stat; } else { if (id & COMPACT_PARAGRAPHS) { char *string; if ((stat = IO_read_string(string, stream, sizeof(uint1))) != IO_NORMAL) return stat; data = string; } else { MCParagraph *paragraphs = NULL; while (True) { uint1 type; if ((stat = IO_read_uint1(&type, stream)) != IO_NORMAL) return stat; switch (type) { // MW-2012-03-04: [[ StackFile5500 ]] Handle either the paragraph or extended // paragraph tag. case OT_PARAGRAPH: case OT_PARAGRAPH_EXT: { MCParagraph *newpar = new MCParagraph; newpar->setparent((MCField *)parent); // MW-2012-03-04: [[ StackFile5500 ]] If the paragraph tab was the extended // variant, then pass the correct is_ext parameter. if ((stat = newpar->load(stream, version, type == OT_PARAGRAPH_EXT)) != IO_NORMAL) { delete newpar; return stat; } newpar->appendto(paragraphs); } break; default: data = paragraphs; MCS_seek_cur(stream, -1); return IO_NORMAL; } } } } return IO_NORMAL; }
IO_stat MCStyledText::load(IO_handle p_stream, const char *p_version) { IO_stat stat; MCParagraph *paragraphs = NULL; while (True) { uint1 type; if ((stat = IO_read_uint1(&type, p_stream)) != IO_NORMAL) return stat; switch (type) { // MW-2012-03-04: [[ StackFile5500 ]] Handle both the paragraph and extended // paragraph record. case OT_PARAGRAPH: case OT_PARAGRAPH_EXT: { MCParagraph *newpar = new MCParagraph; newpar->setparent((MCField *)parent); // MW-2012-03-04: [[ StackFile5500 ]] If the record is extended then // pass in 'true' for 'is_ext'. if ((stat = newpar->load(p_stream, p_version, type == OT_PARAGRAPH_EXT)) != IO_NORMAL) { delete newpar; return stat; } newpar->appendto(paragraphs); } break; default: m_paragraphs = paragraphs; MCS_seek_cur(p_stream, -1); return IO_NORMAL; } } return IO_NORMAL; }
IO_stat MCCdata::load(IO_handle stream, MCObject *parent, uint32_t version) { IO_stat stat; if ((stat = IO_read_uint4(&id, stream)) != IO_NORMAL) return checkloadstat(stat); if (parent->gettype() == CT_BUTTON) { uint1 set; stat = IO_read_uint1(&set, stream); data = reinterpret_cast<void *>(set ? 1 : 0); return checkloadstat(stat); } else { if (id & COMPACT_PARAGRAPHS) { // MW-2013-11-19: [[ UnicodeFileFormat ]] This flag is never set by newer engines // so is just legacy. char *string; if ((stat = IO_read_cstring_legacy(string, stream, sizeof(uint1))) != IO_NORMAL) return checkloadstat(stat); data = string; } else { MCParagraph *paragraphs = NULL; while (True) { uint1 type; if ((stat = IO_read_uint1(&type, stream)) != IO_NORMAL) return checkloadstat(stat); switch (type) { // MW-2012-03-04: [[ StackFile5500 ]] Handle either the paragraph or extended // paragraph tag. case OT_PARAGRAPH: case OT_PARAGRAPH_EXT: { MCParagraph *newpar = new (nothrow) MCParagraph; newpar->setparent((MCField *)parent); // MW-2012-03-04: [[ StackFile5500 ]] If the paragraph tab was the extended // variant, then pass the correct is_ext parameter. if ((stat = newpar->load(stream, version, type == OT_PARAGRAPH_EXT)) != IO_NORMAL) { delete newpar; return checkloadstat(stat); } newpar->appendto(paragraphs); } break; default: data = paragraphs; MCS_seek_cur(stream, -1); return IO_NORMAL; } } } } return IO_NORMAL; }