Exemple #1
0
/*----------------------------------------------------------------------------------------------
	Fix up the 'next' or 'basedOn' attributes in the styles, now that we have a complete
	list.
	Attribute:
		flid		- attribute to set
		hmhvostu	- map containing the values ofthe attribute
----------------------------------------------------------------------------------------------*/
void WpStylesheet::FixStyleReferenceAttrs(int flid, HashMap<HVO, StrUni> & hmhvostu)
{
	WpDaPtr wpda = dynamic_cast<WpDa *>(m_qsda.Ptr());

	//	Generate a list of all the style names.
	Vector<StrUni> vstuNames;
	int cst;
	CheckHr(m_qsda->get_VecSize(khvoText, kflidStText_Styles, &cst));
	Assert(cst == m_vhcStyles.Size());
	for (int ist = 0; ist < cst; ist++)
	{
		SmartBstr sbstr;
		CheckHr(wpda->get_UnicodeProp(m_vhcStyles[ist].hvo, kflidStStyle_Name, &sbstr));
		vstuNames.Push(StrUni(sbstr.Chars()));
	}

	//	For each style, if it has a value in the map, find the corresponding style
	//	and set the attribute.
	for (int ist = 0; ist < cst; ist++)
	{
		HVO hvo = m_vhcStyles[ist].hvo;
		StrUni stuRef;
		if (hmhvostu.Retrieve(hvo, &stuRef))
		{
			for (int istTmp = 0; istTmp < cst; istTmp++)
			{
				if (vstuNames[istTmp] == stuRef)
				{
					CheckHr(wpda->CacheObjProp(hvo, flid, m_vhcStyles[istTmp].hvo));
					break;
				}
			}
		}
	}
}