Ejemplo n.º 1
0
/*
	Function name	: CXML::SetAttributeValue
	Description	    : Sets the current nodes attribute name with the new value. if the current 
					: doesn't have such an attribute name the function fails.
	Return type		: bool 
	Argument        : CString csAttributeName
	Argument        : CString csValue
	Tested			: Ok
*/
bool CXML::SetAttributeValue(CString csAttributeName,CString csValue)
{

	if(RemoveAttributeNode(&m_pICurrentNode,csAttributeName))
		if(CreateAttributeNode(&m_pICurrentNode,csAttributeName,csValue))
			return true;

	return false;
}
Ejemplo n.º 2
0
/*
	Function name	: CXML::CreateAttribute
	Description	    : This function adds an attribute to the given node
					: with attributes and value and the text supplied 
	Return type		: bool 
	Argument        : CString  csPathToNode
	Argument        : CString csAttribute
	Argument        : CString csValue
	Argument        : bool bCurrentNodeAsBase
*/
bool CXML::CreateAttribute(CString  csPathToNode,CString csAttribute,CString csValue,bool bCurrentNodeAsBase)
{
	IXMLDOMNode * pNode = NULL;
	if(!GetNode(&pNode,csPathToNode,NULL,NULL,bCurrentNodeAsBase))
		return false;

	bool bRet = CreateAttributeNode(&pNode,csAttribute,csValue);
	
	pNode->Release();
	return bRet;
}
Ejemplo n.º 3
0
BOOL PluginOILFilter::ReadAttributes(xmlNodePtr pNode, CapabilityTree* pCapTree)
{
	// We must loop through the tree of elements

	// pNode is the Attributes element so read the default as attribute

	XPFCapability* pAttrs = NULL;
	XPFConvertType AttrType = XPFCONVTYPE_UNKNOWN;

	BOOL bOK = GetConvertAsType(pNode, &AttrType);
	if (!bOK)
	{
		TRACEUSER("Phil", _T("ReadAttributes GetConvertAsType failed\n"));
		return FALSE;
	}

	// Loop through each child calling the CreateAttributeNode recursive function
	// for each one

	xmlNodePtr pChild;
	pChild = pNode->children;
	XPFCapability* pLast = NULL;

	while (pChild)
	{
		XPFCapability* pCap = CreateAttributeNode(pChild);

		if (pCap)
		{
			// If we have a node then add it to the list
			// If we do not have a node already then set m_pObjects
			if (pLast)
			{
				pLast->SetNext(pCap);
			}
			else
			{
				pAttrs = pCap;
			}
			pLast = pCap;
		}

		pChild = pChild->next;
	}

	pCapTree->SetAttributesTree(pAttrs, AttrType);

	return TRUE;
}
Ejemplo n.º 4
0
bool CXML::SetAttributeValue(CString csPathToNode,CString csAttributeName,CString csValue,bool bCurrentNodeAsBase)
{
	IXMLDOMNode * pNode = NULL;
	if(!GetNode(&pNode,csPathToNode,NULL,NULL,bCurrentNodeAsBase))
		return false;

	if(RemoveAttributeNode(&pNode,csAttributeName))
		if(CreateAttributeNode(&pNode,csAttributeName,csValue))
		{
			pNode->Release();
			m_pIRootNode->Release();
			return true;
		}

	pNode->Release();
	
	return false;
}
Ejemplo n.º 5
0
XPFCapability* PluginOILFilter::CreateAttributeNode(xmlNodePtr pNode)
{
	XPFCapability* pCap = NULL;

	wxString strName = CXMLUtils::ConvertToWXString(pNode->name);
	
	if (strName == _T("#text") || xmlNodeIsText(pNode))
	{
		wxString str = CXMLUtils::ConvertToWXString(xmlNodeGetContent(pNode));
		TRACEUSER("Phil", _T("CreateAttributeNode ignoring text %s\n"), (LPCTSTR)str);
		return(NULL);
	}

	XPFConvertType AsType = XPFCONVTYPE_UNKNOWN;
	BOOL bOK = GetConvertAsType(pNode, &AsType);
	if (!bOK)
	{
		TRACEUSER("Phil", _T("CreateAttributeNode GetConvertAsType failed\n"));
		return NULL;
	}

	if (strName == _T("Fill"))
	{
		XPFProp Shape = XPFP_UNKNOWN;
		bOK = GetXPFProp(pNode, _T("shape"), aFillShapes, &Shape);
		XPFProp Repeat = XPFP_UNKNOWN;
		bOK = GetXPFProp(pNode, _T("repeat"), aFillRepeats, &Repeat);
		XPFBOOL bMultistage = XPFB_UNKNOWN;
		bOK = GetXPFBOOL(pNode, _T("multistage"), &bMultistage);
		XPFProp Effect = XPFP_UNKNOWN;
		bOK = GetXPFProp(pNode, _T("effect"), aColourEffects, &Effect);
		XPFBOOL bProfile = XPFB_UNKNOWN;
		bOK = GetXPFBOOL(pNode, _T("profile"), &bProfile);
		XPFBOOL bContone = XPFB_UNKNOWN;
		bOK = GetXPFBOOL(pNode, _T("contone"), &bContone);
		pCap = new XPFCFill(AsType, Shape, Repeat, bMultistage, Effect, bProfile, bContone);
	}
	else if (strName == _T("FillTrans"))
	{
		XPFProp Shape = XPFP_UNKNOWN;
		bOK = GetXPFProp(pNode, _T("shape"), aFillShapes, &Shape);
		XPFProp Type = XPFP_UNKNOWN;
		bOK = GetXPFProp(pNode, _T("type"), aTransTypes, &Type);
		XPFProp Repeat = XPFP_UNKNOWN;
		bOK = GetXPFProp(pNode, _T("repeat"), aFillRepeats, &Repeat);
		XPFBOOL bProfile = XPFB_UNKNOWN;
		bOK = GetXPFBOOL(pNode, _T("profile"), &bProfile);
		pCap = new XPFCFillTrans(AsType, Shape, Type, Repeat, bProfile);
	}
	else if (strName == _T("Line"))
	{
		XPFBOOL bDash = XPFB_UNKNOWN;
		bOK = GetXPFBOOL(pNode, _T("dash"), &bDash);
		XPFBOOL bArrowhead = XPFB_UNKNOWN;
		bOK = GetXPFBOOL(pNode, _T("arrowhead"), &bArrowhead);
		XPFProp Cap = XPFP_UNKNOWN;
		bOK = GetXPFProp(pNode, _T("cap"), aLineCaps, &Cap);
		XPFProp Join = XPFP_UNKNOWN;
		bOK = GetXPFProp(pNode, _T("join"), aLineJoins, &Join);
		XPFBOOL bStroke = XPFB_UNKNOWN;
		bOK = GetXPFBOOL(pNode, _T("stroke"), &bStroke);
		XPFBOOL bBrush = XPFB_UNKNOWN;
		bOK = GetXPFBOOL(pNode, _T("brush"), &bBrush);
		pCap = new XPFCLine(AsType, bDash, bArrowhead, Cap, Join, bStroke, bBrush);
	}
	else if (strName == _T("LineTrans"))
	{
		XPFProp Type = XPFP_UNKNOWN;
		bOK = GetXPFProp(pNode, _T("type"), aTransTypes, &Type);
		pCap = new XPFCLineTrans(AsType, Type);
	}
	else if (strName == _T("Feather"))
	{
		pCap = new XPFCFeather(AsType);
	}
	else
	{
		ERROR1(NULL, _R(IDE_XPF_BADXML_UNEXPECTED_ATTRTYPE));
	}

	xmlNodePtr pChild;
	pChild = pNode->children;
	XPFCapability* pLast = NULL;

	while (pChild)
	{
		XPFCapability* pCapNode = CreateAttributeNode(pChild);

		if (pCapNode)
		{
			// If we have a node then add it to the list
			// If we do not have a node already then set m_pObjects
			if (pLast)
			{
				pLast->SetNext(pCapNode);
			}
			else
			{
				pCap->SetChild(pCapNode);
			}
			pLast = pCapNode;
		}

		pChild = pChild->next;
	}

	return(pCap);
}
Ejemplo n.º 6
0
bool CXML::CreateAttribute(CString csAttribute,CString csValue)
{
	return CreateAttributeNode(&m_pICurrentNode,csAttribute,csValue);
}
Ejemplo n.º 7
0
/*
	 Function name		: CXML::CreateElement
	 Description	    : This function create an element node set it as the current Node
						: with attributes and value and the text supplied 
	 Return type		: bool 
	 Argument			: IXMLDOMNode **ppRemoveNode
 */	
bool CXML::CreateElement(CString csTagName,LPCTSTR lpszText,char ** ppAttributes,char ** ppValues,int nNoOfAttributes,bool bSetAsCurNode)
{
	IXMLDOMNode * pNode = NULL;
	if(csTagName.IsEmpty())
		return false;

	if(!m_pICurrentNode)
		return false;

	_variant_t vtNodeType((long)NODE_ELEMENT);
	_bstr_t bstrName(csTagName);
	_bstr_t bstrNameSpace("");

	m_hr = m_pXMLDoc->createNode(vtNodeType,bstrName,bstrNameSpace,&pNode);
	if(!SUCCEEDED(m_hr))
		return false;

	if(m_pINewElement)
	{
		m_pINewElement->Release();
		m_pINewElement = NULL;
	}


	if(!AddNode(&m_pICurrentNode,&pNode,&m_pINewElement,NODE_ELEMENT))
	{
		pNode->Release();
		return false;
	} 

	if(!m_pINewElement)
		return false;

	if(lpszText)
	{
		_bstr_t bstrData(lpszText);

		m_hr = pNode->put_text(bstrData);
		if(!SUCCEEDED(m_hr))
		{
			pNode->Release();
			return false;
		}
	}

	pNode->Release();

	if(nNoOfAttributes && ppAttributes && ppValues )
	{
		for(int i = 0;i<nNoOfAttributes;++i)
		{
			if(!CreateAttributeNode(&m_pINewElement,ppAttributes[i],ppValues[i]))
				return false;
		}
	}

	if(bSetAsCurNode)
	{
		if(m_pICurrentNode)
		{
			m_pICurrentNode->Release();
			m_pICurrentNode = NULL;

		}
		m_pICurrentNode = m_pINewElement;
		m_pICurrentNode->AddRef();
	}
	return true;
}