当前位置: 首页>>代码示例>>C++>>正文


C++ NodeAttribute::CascadeDelete方法代码示例

本文整理汇总了C++中NodeAttribute::CascadeDelete方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeAttribute::CascadeDelete方法的具体用法?C++ NodeAttribute::CascadeDelete怎么用?C++ NodeAttribute::CascadeDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeAttribute的用法示例。


在下文中一共展示了NodeAttribute::CascadeDelete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DeleteFactoredOutAttribs

void NodeRenderableInk::DeleteFactoredOutAttribs(BOOL Global, AttrTypeSet* pAffectedAttrTypes)
{
	Node* pGroupNode = FindFirstChild(); 
	while(pGroupNode!=NULL)
	{
		// Karim 30/08/2000
		// Non-optimisable attributes, like feathers and names,
		// must not be automatically deleted - only automatically delete optimisable ones.
		if (pGroupNode->IsAnAttribute() && ((NodeAttribute*)pGroupNode)->ShouldBeOptimized())
		{
			NodeAttribute* pGroupAttr = (NodeAttribute*)pGroupNode;
			CCRuntimeClass* GrouptAttrType = pGroupAttr->GetAttributeType();
			if (pAffectedAttrTypes==NULL || pAffectedAttrTypes->InSet(GrouptAttrType))
			{
				// delete this group attr type from all child objects of this group
				// BUT if obj discards child attrs only delete attr if it also has same value
				for (Node* pNode=FindFirstChild(); pNode!=NULL; pNode=pNode->FindNext())
				{
					if (pNode->IsAnObject())
					{
						NodeRenderableInk* pObject = (NodeRenderableInk*)pNode;
						NodeAttribute* pDeadAttr = pObject->GetChildAttrOfType(GrouptAttrType);
						if (pDeadAttr!=NULL)
						{
							// This code used to only test the attribute for equality if pObject
							// returned TRUE from DiscardsAttributeChildren, otherwise it would 
							// just assume that they are identical and delete it.
							// The DiscardAttributeChildren checks are now done elsewhere so 
							// this code now just assumes it can delete any attributes that have 
							// got this far.
							// This optimisation relies on the tree being in a "legal" state 
							// at the start (i.e. correctly optimised) and also helps to correct 
							// problems where attributes may have been incorrectly left on children
							// (though such "corrections" may change the appearance of the document).

							pDeadAttr->CascadeDelete(); 
							delete pDeadAttr;	
						}
					}
				}
			}
		}
		pGroupNode = pGroupNode->FindNext(); 		
	}

	// Do we need to delete any parent compound's attributes
	if (Global)
	{
		Node* pParent = FindParent(); 
		if (pParent && (pParent->IsCompound()))
		{
			// We need to delete the parent's attributes first  (Recursive bit)
			((NodeRenderableInk*)pParent)->DeleteFactoredOutAttribs(Global, pAffectedAttrTypes); 
		}
	}
} 
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:56,代码来源:ndoptmz.cpp

示例2: NormaliseAttributes

void NodeRenderableInk::NormaliseAttributes()
{

	NodeAttribute* ChildAttribute;	   
	NodeAttribute* GlobalAttribute;

	Node* LocalScan;
	Node* NextLocal;  
	
	// Scan the child attribute block
	LocalScan = FindFirstChild();
	// Stop if we hit an object or if there are no more children 
	// NOTE: Stopping scanning when we find the first RendereblInk node prevents
	// Effect attributes being Normalised. THIS IS DELIBERATE!
	while((LocalScan != NULL) && (!LocalScan->IsAnObject())) 
	{
		// Hand over hand (LocalScan may get deleted)
		NextLocal = LocalScan->FindNext();
		if(LocalScan->IsAnAttribute() && ((NodeAttribute*)LocalScan)->ShouldBeOptimized())	// cos it could be a NodeHidden
		{
			ChildAttribute = (NodeAttribute*)LocalScan;  
			// We now need to search up the tree to see if ChildAttribute is redundant
//		   	Node* GlobalScan = FindPreviousEffectiveNode();
			Node* GlobalScan = NodeAttribute::FindPrevAppliedAttr(this);
			// Search until we can go no higher
			while (GlobalScan != NULL)
			{
				if (GlobalScan->IsAnAttribute())
				{
					GlobalAttribute = (NodeAttribute*)GlobalScan; 
					// An attribute has been found, is it the same class as ChildAttribute ?
					if(GlobalAttribute->GetRuntimeClass() ==
					   ChildAttribute->GetRuntimeClass())
					{
						// Yes it is, so let's check if they are equal
						if ((*GlobalAttribute)==(*ChildAttribute))
						{
							// They are equal so we can nuke the child object because it's 
							// redundant
							ChildAttribute->CascadeDelete();
							delete ChildAttribute;
						}
						break;	 // don't search any further
					}

				}
//				GlobalScan = GlobalScan->FindPreviousEffectiveNode(); // climb higher
				GlobalScan = NodeAttribute::FindPrevAppliedAttr(GlobalScan);
			} 
		}
		LocalScan = NextLocal; // Get the next child 
	}    

}
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:54,代码来源:ndoptmz.cpp


注:本文中的NodeAttribute::CascadeDelete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。