Esempio n. 1
0
BOOL FreeHandEPSFilter::AddNewNode(Node *pNewNode)
{
	if(IS_A(pNewNode, NodePath))
		pLastPathSeen = (NodePath *)pNewNode;
	
	// check to see if we want to handle this
	if((ComplexPathMode == FALSE) || (pNewNode == 0) || (pNode == 0) || (!IS_A(pNewNode, NodePath)))
		return EPSFilter::AddNewNode(pNewNode);

	// check to see if this is the first...
	if(HadFirstOfComplexPath == FALSE)
	{
		HadFirstOfComplexPath = TRUE;
		return EPSFilter::AddNewNode(pNewNode);
	}

	// find the last child of the node
	Node *pLastChild = pNode->FindLastChild();
	if(pLastChild == 0 || !IS_A(pLastChild, NodePath))
		return EPSFilter::AddNewNode(pNewNode);

	// we know that both of these things are NodePaths.
	Path *pTarget = &((NodePath *)pLastChild)->InkPath;
	Path *pAddition = &((NodePath *)pNewNode)->InkPath;

	// work out the new flags for the target
	BOOL TargetFilled = pTarget->IsFilled;
	BOOL TargetStroked = pTarget->IsStroked;
	if(pAddition->IsFilled)		TargetFilled = TRUE;
	if(pAddition->IsStroked)	TargetStroked = TRUE;

	// add this new path to the old one...
	if(!pTarget->MergeTwoPaths(*pAddition))
		return FALSE;

	// check that the thing we just added isn't already there
	if(!RemoveLastSubPathIfNotUnique(pTarget))
		return FALSE;

	// set it's flags
	pTarget->IsFilled = TargetFilled;
	pTarget->IsStroked = TargetStroked;

	// vape it's attributes
	pLastChild->DeleteChildren(pLastChild->FindFirstChild());

	// apply some new ones
	SetPathFilled(TargetFilled);
	if(!AddAttributes((NodePath *)pLastChild, TargetStroked, TargetFilled))
		return FALSE;

	// hide the nice additional path
	//if(!ImportInfo.pOp->DoHideNode(pNewNode, TRUE))
	//	return FALSE;
	pNewNode->CascadeDelete();
	delete pNewNode;

	// set the last seen path bollox
	pLastPathSeen = (NodePath *)pLastChild;

	// done!
	return TRUE;
}