DOMNode* DOMNodeIteratorImpl::previousNode (DOMNode* node) {
	if (fDetached)
		throw DOMException(DOMException::INVALID_STATE_ERR, 0, GetDOMNodeIteratorMemoryManager);

    DOMNode* result = 0;

    // if we're at the root, return 0.
    if (node == fRoot)
			return 0;

    // get sibling
    result = node->getPreviousSibling();
    if (!result) {
        //if 1st sibling, return parent
        result = node->getParentNode();
        return result;
    }

    // if sibling has children, keep getting last child of child.
    if (result->hasChildNodes()) {
        while ((fExpandEntityReferences || result->getNodeType()!=DOMNode::ENTITY_REFERENCE_NODE) && 
               result->hasChildNodes()) {
            result = result->getLastChild();
        }
    }

    return result;
}
bool CConfigParser::ParseDevices(DOMNodeList* deviceNodeList, ADeviceListener& configClass)
{
	ASSERT(deviceNodeList->getLength() >= 1);
	DOMNode* deviceNode = deviceNodeList->item(0);
	DOMNodeList* devices = deviceNode->getChildNodes();
	for(unsigned long idx = 0; idx < devices->getLength(); idx++)
	{
		DOMNode* currentDevice = devices->item(idx);
		wstring deviceNodeName = currentDevice->getNodeName();
		if(deviceNodeName.compare(L"#text") == 0)
			continue;
		wstring deviceName = currentDevice->getAttributes()->getNamedItem(L"name")->getNodeValue();
		//wstring deviceType = currentDevice->getAttributes()->getNamedItem(L"type")->getNodeValue();
		wstring deviceType = deviceNodeName;
		if(deviceType.compare(L"mouse") == 0)
		{
			configClass.AddDevice(deviceName, new CMouseProc());
		}
		else
		{
			CWin32SpaceNavigatorHIDCapture* deviceToAdd = new CWin32SpaceNavigatorHIDCapture();
			if(currentDevice->hasChildNodes())
			{
				if(!ParseHIDDeviceCommands(currentDevice->getChildNodes(), deviceToAdd))
					return false;
			}
			configClass.AddDevice(deviceName, deviceToAdd);
		}
	}
	return true;
}
Пример #3
0
DOMNode* DOMTreeWalkerImpl::getPreviousSibling (DOMNode* node) {
		
    if (!node || node == fRoot) return 0;

    DOMNode* newNode = node->getPreviousSibling();
    if (!newNode) {

        newNode = node->getParentNode();
        if (!newNode || node == fRoot)  return 0;

        short parentAccept = acceptNode(newNode);

        if (parentAccept == DOMNodeFilter::FILTER_SKIP) {
            return getPreviousSibling(newNode);
        }

        return 0;
    }

    short accept = acceptNode(newNode);

    if (accept == DOMNodeFilter::FILTER_ACCEPT)
        return newNode;
    else
    if (accept == DOMNodeFilter::FILTER_SKIP) {
        DOMNode* fChild =  getLastChild(newNode);
        if (!fChild && !newNode->hasChildNodes()) {
            return getPreviousSibling(newNode);
        }
        return fChild;
    }
    return getPreviousSibling(newNode);

}
bool CConfigParser::ParseDeviceContexts(DOMNodeList* deviceContextNodes, ADeviceListener& configClass)
{
	ASSERT(deviceContextNodes->getLength() == 1);
	DOMNode* deviceContextNode = deviceContextNodes->item(0);
	DOMNodeList* deviceContexts = deviceContextNode->getChildNodes();
	for(unsigned long idx = 0; idx < deviceContexts->getLength(); idx++)
	{
		DOMNode* currentDeviceContext = deviceContexts->item(idx);
		wstring deviceContextNodeName = currentDeviceContext->getNodeName();
		if(deviceContextNodeName.compare(L"#text") == 0)
			continue;
		if(deviceContextNodeName.compare(L"#comment") == 0)
			continue;
		wstring deviceContextName = currentDeviceContext->getAttributes()->getNamedItem(L"name")->getNodeValue();
		wstring deviceName = currentDeviceContext->getAttributes()->getNamedItem(L"device")->getNodeValue();
		bool gestures = false;
		if(currentDeviceContext->getAttributes()->getNamedItem(L"gestures") != NULL)
			gestures = true;
		// Create the device context to add
		CDeviceContext* deviceContextToAdd = NULL;
		if(configClass.GetDevices()[deviceName]->GetType().compare("mouse") == 0)
			deviceContextToAdd = new CMouseDeviceContext(gestures, deviceName);
		else
			deviceContextToAdd = new CDeviceContext(gestures, deviceName);

		// Get the device contexts axis and buttons added
		if(currentDeviceContext->hasChildNodes())
		{
			unsigned char axeIdx = 0;
			DOMNodeList* children = currentDeviceContext->getChildNodes();
			unsigned long childCount = children->getLength();
			for(unsigned long idx = 0; idx < childCount; idx++)
			{
				DOMNode* childNode = children->item(idx);			
				wstring nodeName = childNode->getNodeName();

				if(nodeName.compare(L"axe") == 0)
				{
					ParseAxe(childNode, configClass.GetActions(), deviceContextToAdd, axeIdx);
					axeIdx++;
				}
				if(nodeName.compare(L"buttons") == 0)
					ParseButtons(childNode, configClass.GetActions(), deviceContextToAdd);
				if(nodeName.compare(L"gesture") == 0)
					ParseGesture(childNode, configClass.GetActions(), deviceContextToAdd);
			}
		}
		configClass.AddDeviceContext(deviceContextName, deviceContextToAdd);
		TRACE("Device Context <%S> is 0x%X\r\n", deviceContextName.c_str(), deviceContextToAdd);
	}
	return true;
}
Пример #5
0
void DeltaApplyEngine::Subtree_Insert( DOMNode *insertSubtreeRoot, XID_t parentXID, int position, const char *xidmapStr ) {

	vddprintf(( "        insert xidmap=%s at (parent=%d, pos=%d)\n", xidmapStr, (int)parentXID, position));
	DOMNode* contentNode  = xiddoc->importNode( insertSubtreeRoot, true );
	DOMNode* parentNode   = xiddoc->getXidMap().getNodeWithXID( parentXID );
	if (parentNode==NULL) THROW_AWAY(("parent node with XID=%d not found",(int)parentXID));

	int actual_pos = 1 ;
	if ((position!=1)&&(!parentNode->hasChildNodes())) THROW_AWAY(("parent has no children but position is %d",position));
	DOMNode* brother = parentNode->getFirstChild();
	while (actual_pos < position) {
	  brother = brother->getNextSibling();
		actual_pos++;
		if ((brother==NULL)&&(actual_pos<position)) THROW_AWAY(("parent has %d children but position is %d",actual_pos-1, position));
		}
	
	// Add node to the tree
	if (brother==NULL) parentNode->appendChild( contentNode );
	else parentNode->insertBefore( contentNode, brother );
	
	xiddoc->getXidMap().mapSubtree( xidmapStr, contentNode );

	}
Пример #6
0
DOMNode* DOMTreeWalkerImpl::getLastChild (DOMNode* node) {
	
    if (!node) return 0;

    if(!fExpandEntityReferences && node->getNodeType()==DOMNode::ENTITY_REFERENCE_NODE)
        return 0;

    DOMNode* newNode = node->getLastChild();
    if (!newNode)  return 0;

    short accept = acceptNode(newNode);

    if (accept == DOMNodeFilter::FILTER_ACCEPT)
        return newNode;
    else
    if (accept == DOMNodeFilter::FILTER_SKIP
        && newNode->hasChildNodes())
    {
        return getLastChild(newNode);
    }
    return getPreviousSibling(newNode);

}