Exemple #1
0
IO_stat MCEPS::load(IO_handle stream, uint32_t version)
{
	IO_stat stat;

	if ((stat = MCObject::load(stream, version)) != IO_NORMAL)
		return stat;
	delete postscript;
	delete prolog;
	if ((stat = IO_read_uint4(&size, stream)) != IO_NORMAL)
		return stat;
	postscript = new char[size + 1];
	if ((stat = IO_read(postscript, size, stream)) != IO_NORMAL)
		return stat;
	postscript[size] = '\0';
	// MW-2013-11-19: [[ UnicodeFileFormat ]] EPS is always ASCII so legacy.
	if ((stat = IO_read_cstring_legacy(prolog, stream, 2)) != IO_NORMAL)
		return stat;
	int4 i;
	if ((stat = IO_read_int4(&i, stream)) != IO_NORMAL)
		return stat;
	xscale = MCU_i4tor8(i);
	if (flags & F_SCALE_INDEPENDENTLY)
	{
		if ((stat = IO_read_int4(&i, stream)) != IO_NORMAL)
			return stat;
		yscale = MCU_i4tor8(i);
	}
	else
		yscale = xscale;
	if ((stat = IO_read_int2(&angle, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_read_int2(&tx, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_read_int2(&ty, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_read_uint2(&ex, stream)) != IO_NORMAL)
		return stat;
	if ((stat = IO_read_uint2(&ey, stream)) != IO_NORMAL)
		return stat;
	if (flags & F_RETAIN_IMAGE)
	{
		image = new MCImage;
		image->setparent(this);
		if ((stat = image->load(stream, version)) != IO_NORMAL)
			return stat;
	}
	if (version > 1300)
	{
		if ((stat = IO_read_uint2(&curpage, stream)) != IO_NORMAL)
			return stat;
		if ((stat = IO_read_uint2(&pagecount, stream)) != IO_NORMAL)
			return stat;
		if (pagecount > 0)
		{
			pageIndex = new uint4[pagecount];
			for (i = 0 ; i < pagecount ; i++)
				if ((stat = IO_read_uint4(&pageIndex[i], stream)) != IO_NORMAL)
					return stat;
		}
	}
	return loadpropsets(stream, version);
}
Exemple #2
0
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;
}