Exemple #1
0
ALERROR CCompositeImageDesc::InitEntryFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, CIDCounter &IDGen, IImageEntry **retpEntry)

//	InitEntryFromXML
//
//	Initializes the desc from XML

	{
	ALERROR error;

	IImageEntry *pEntry;
	if (strEquals(pDesc->GetTag(), IMAGE_COMPOSITE_TAG) || strEquals(pDesc->GetTag(), COMPOSITE_TAG))
		pEntry = new CCompositeEntry;
	else if (strEquals(pDesc->GetTag(), IMAGE_EFFECT_TAG) || strEquals(pDesc->GetTag(), EFFECT_TAG))
		pEntry = new CEffectEntry;
	else if (strEquals(pDesc->GetTag(), TABLE_TAG) || strEquals(pDesc->GetTag(), IMAGE_VARIANTS_TAG))
		pEntry = new CTableEntry;
	else if (strEquals(pDesc->GetTag(), FILTER_COLORIZE_TAG))
		pEntry = new CFilterColorizeEntry;
	else if (strEquals(pDesc->GetTag(), LOCATION_CRITERIA_TABLE_TAG))
		pEntry = new CLocationCriteriaTableEntry;

	//	Otherwise, assume that this is either a plain image or an arbitrary tag with
	//	content elements representing the actual image composition.

	else
		{
		if (pDesc->GetContentElementCount() == 0)
			pEntry = new CImageEntry;
		else
			return InitEntryFromXML(Ctx, pDesc->GetContentElement(0), IDGen, retpEntry);
		}

	//	Init

	if (error = pEntry->InitFromXML(Ctx, IDGen, pDesc))
		return error;

	*retpEntry = pEntry;

	return NOERROR;
	}
ALERROR CCompositeImageDesc::InitEntryFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, CIDCounter &IDGen, IImageEntry **retpEntry)

//	InitEntryFromXML
//
//	Initializes the desc from XML

	{
	ALERROR error;

	IImageEntry *pEntry;
	if (strEquals(pDesc->GetTag(), IMAGE_TAG))
		{
		if (pDesc->GetContentElementCount() == 0)
			pEntry = new CImageEntry;
		else
			return InitEntryFromXML(Ctx, pDesc->GetContentElement(0), IDGen, retpEntry);
		}
	else if (strEquals(pDesc->GetTag(), IMAGE_COMPOSITE_TAG) || strEquals(pDesc->GetTag(), COMPOSITE_TAG))
		pEntry = new CCompositeEntry;
	else if (strEquals(pDesc->GetTag(), TABLE_TAG) || strEquals(pDesc->GetTag(), IMAGE_VARIANTS_TAG))
		pEntry = new CTableEntry;
	else if (strEquals(pDesc->GetTag(), FILTER_COLORIZE_TAG))
		pEntry = new CFilterColorizeEntry;
	else
		{
		Ctx.sError = strPatternSubst(CONSTLIT("Unknown image tag: %s"), pDesc->GetTag());
		return ERR_FAIL;
		}

	//	Init

	if (error = pEntry->InitFromXML(Ctx, IDGen, pDesc))
		return error;

	*retpEntry = pEntry;

	return NOERROR;
	}