Пример #1
0
bool MCStyledText::visit(MCVisitStyle p_style, uint32_t p_part, MCObjectVisitor *p_visitor)
{
	bool t_continue;
	t_continue = true;

	if (p_style == VISIT_STYLE_DEPTH_LAST)
		t_continue = p_visitor -> OnStyledText(this);

	if (t_continue && m_paragraphs != NULL)
	{
		MCParagraph *pgptr = m_paragraphs;
		MCParagraph *tpgptr = pgptr;
		do
		{
			t_continue = tpgptr -> visit(p_style, p_part, p_visitor);
			tpgptr = tpgptr->next();
		}
		while(t_continue && tpgptr != pgptr);
	}

	if (p_style == VISIT_STYLE_DEPTH_FIRST)
		t_continue = p_visitor -> OnStyledText(this);

	return t_continue;
}
Пример #2
0
IO_stat MCCdata::save(IO_handle stream, Object_type type, uint4 p_part)
{
	IO_stat stat;

	// If p_part is non-zero it means we only want to save data specific
	// to a given card. In this case, we simply don't save the rest.
	if (p_part != 0 && id != p_part)
		return IO_NORMAL;

	if ((stat = IO_write_uint1(type, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_uint4(p_part != 0 ? 0 : id, stream)) != IO_NORMAL)
		return stat;
	if (type == OT_BDATA)
	{
		uint1 set = data ? 1 : 0;
		return IO_write_uint1(set, stream);
	}
	else
		if (id & COMPACT_PARAGRAPHS)
			return IO_write_string((char *)data, stream, sizeof(uint1));
		else
		{
			MCParagraph *tptr = (MCParagraph *)data;
			if (tptr != NULL)
				do
				{
					if ((stat = tptr->save(stream, p_part)) != IO_NORMAL)
						return stat;
					tptr = (MCParagraph *)tptr->next();
				}
				while (tptr != data);
		}
	return IO_NORMAL;
}
Пример #3
0
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;
}
Пример #4
0
IO_stat MCCdata::save(IO_handle stream, Object_type type, uint4 p_part, MCObject *p_parent, uint32_t p_version)
{
	IO_stat stat;

	// If p_part is non-zero it means we only want to save data specific
	// to a given card. In this case, we simply don't save the rest.
	if (p_part != 0 && id != p_part)
		return IO_NORMAL;

	if ((stat = IO_write_uint1(type, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_write_uint4(p_part != 0 ? 0 : id, stream)) != IO_NORMAL)
		return stat;
	if (type == OT_BDATA)
	{
		uint1 set = data ? 1 : 0;
		return IO_write_uint1(set, stream);
	}
	else
		if (id & COMPACT_PARAGRAPHS)
		{
			// MW-2013-11-19: [[ UnicodeFileFormat ]] This flag is never set by newer engines
			//   so is just legacy. (Indeed, this codepath should never be hit!).
			return IO_write_cstring_legacy((char *)data, stream, sizeof(uint1));
		}
		else
		{
			MCParagraph *tptr = (MCParagraph *)data;
			if (tptr != NULL)
				do
				{
                    // Ensure field's saved MCCdata paragraphs have a parent when needed
                    if (p_parent != nil)
                        tptr -> setparent(MCObjectCast<MCField>(p_parent));
					if ((stat = tptr->save(stream, p_part, p_version)) != IO_NORMAL)
						return stat;
					tptr = (MCParagraph *)tptr->next();
				}
				while (tptr != data);
		}
	return IO_NORMAL;
}
Пример #5
0
// MW-2011-01-13: As styledtext is an internal (not published in anyway) format
//   we can change it to include the paragraph style for now.
IO_stat MCStyledText::save(IO_handle p_stream, uint4 p_part, bool p_force_ext)
{
	IO_stat stat;

	if ((stat = IO_write_uint1(OT_STYLED_TEXT, p_stream)) != IO_NORMAL)
		return stat;

	MCParagraph *tptr = m_paragraphs;
	if (tptr != NULL)
		do
		{
			if ((stat = tptr->save(p_stream, p_part)) != IO_NORMAL)
				return stat;

			tptr = (MCParagraph *)tptr->next();
		}
		while (tptr != m_paragraphs);

	return IO_NORMAL;
}
Пример #6
0
MCCdata::MCCdata(const MCCdata &cref) : MCDLlist(cref)
{
	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
			{
				MCParagraph *newparagraph = new MCParagraph(*tptr);
				newparagraph->appendto(paragraphs);
				tptr = (MCParagraph *)tptr->next();
			}
			while (tptr != cref.data);
			data = paragraphs;
		}
	}
	else
		data = cref.data;
}