示例#1
0
DOMNode* DOMElementImpl::rename(const XMLCh* namespaceURI, const XMLCh* name)
{
    DOMDocumentImpl* doc = (DOMDocumentImpl*) fParent.fOwnerDocument;

    if (!namespaceURI || !*namespaceURI) {
        fName = doc->getPooledString(name);
        fAttributes->reconcileDefaultAttributes(getDefaultAttributes());

        // and fire user data NODE_RENAMED event
        castToNodeImpl(this)->callUserDataHandlers(DOMUserDataHandler::NODE_RENAMED, this, this);

        return this;
    }
    else {

        // create a new ElementNS
        DOMElementNSImpl* newElem = (DOMElementNSImpl*)doc->createElementNS(namespaceURI, name);

        // transfer the userData
        doc->transferUserData(castToNodeImpl(this), castToNodeImpl(newElem));

        // remove old node from parent if any
        DOMNode* parent = getParentNode();
        DOMNode* nextSib = getNextSibling();
        if (parent) {
            parent->removeChild(this);
        }

        // move children to new node
        DOMNode* child = getFirstChild();
        while (child) {
            removeChild(child);
            newElem->appendChild(child);
            child = getFirstChild();
        }

        // insert new node where old one was
        if (parent) {
            parent->insertBefore(newElem, nextSib);
        }

        // move specified attributes to new node
        newElem->fAttributes->moveSpecifiedAttributes(fAttributes);

        // and fire user data NODE_RENAMED event
        castToNodeImpl(newElem)->callUserDataHandlers(DOMUserDataHandler::NODE_RENAMED, this, newElem);

        return newElem;
    }
}
示例#2
0
文件: Connector.cpp 项目: PADrend/GUI
float Connector::getLength()const{
	float l=0.0f;
	Geometry::Vec2 p1;
	Geometry::Vec2 p2;

	for(Component * c=getFirstChild();c!=nullptr;c=c->getNext()){
		p1=p2;
		p2=c->getPosition();
		if(c==getFirstChild())
			continue;
		l+=p1.distance(p2);
	}
	return l;
}
示例#3
0
DOM_Node TreeWalkerImpl::nextNode () {
	
	DOM_Node result;

    if (fCurrentNode.isNull()) return result;

    result = getFirstChild(fCurrentNode);

    if (! result.isNull()) {
        fCurrentNode = result;
        return result;
    }

    result = getNextSibling(fCurrentNode);

    if (! result.isNull()) {
        fCurrentNode = result;
        return result;
    }

    // return parent's 1st sibling.
    DOM_Node parent = getParentNode(fCurrentNode);
    while (! parent.isNull()) {
        result = getNextSibling(parent);
        if (! result.isNull()) {
            fCurrentNode = result;
            return result;
        } else {
            parent = getParentNode(parent);
        }
    }

    // end , return null
    return result;
}
示例#4
0
const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *FollowingAxis::nextNode(DynamicContext *context)
{
  if(toDo_) {
    // initialise
    toDo_ = false;
    node_ = contextNode_;
  }
  
  if(node_ != 0) {
    const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *result = 0;

    if(node_ != contextNode_) {
      result = getFirstChild(node_);
    }

    while(result == 0 && node_ != 0) {
      result = getNextSibling(node_);
      if(result == 0) {
        node_ = getParent(node_);
      }
    }

    node_ = result;
  }

  return node_;
}
示例#5
0
  void
  SVGTextPathElement::glTextTraverse(svgl::Context * svglContext, svgl::GLInfo* glinfo, svgl::TextInfo* textinfo)
  {
    _textinfo = textinfo;
    buildBezier(svglContext, glinfo, textinfo);

    for(dom::Node *n = getFirstChild(); n; n=n->getNextSibling()) {
      _currentPCDATA = 0;
      dom::Text * pcdata = dynamic_cast<dom::Text*>(n);
      if(pcdata) {
	_currentPCDATA = pcdata;
	//SVGTransformable::glTraverse(svglContext, glinfo);
	SVGStylable::glTraverse(svglContext, glinfo, false, true);
      }
      else {
	SVGTextContentElement *e = dynamic_cast<SVGTextContentElement*>(n);
	if(e) {
	  //std::cerr << "text may not be at the right place since transforms are not traversed" __FL__;
	  e->glTextTraverse(svglContext, glinfo, _textinfo);
	  //textinfo->dx = textinfo->distanceIterator->x;
	  //textinfo->dy = textinfo->distanceIterator->y;
	}
      }
    }

    delete _textinfo->distanceIterator;
    _textinfo->distanceIterator=0;

  }
示例#6
0
Test::TestGroup* Test::TestGroup::getGroupFromPathName(const char* pathName, bool omitRoot)
{
	if (!omitRoot || getParent())
	{
		if (strstr(pathName, getName()) != pathName)
			return NULL;

		pathName += strlen(getName());

		if (getFirstChild())
		{
			if (strstr(pathName, "/") != pathName)
				return NULL;

			pathName += strlen("/");
		}
		else
		{
			if (pathName[0] == '\0')
				return this;
			else
				return NULL;
		}
	}

	for (unsigned i = 0; i < mChildren.size(); ++i)
	{
		TestGroup* group = mChildren[i]->getGroupFromPathName(pathName, omitRoot);
		if (group)
			return group;
	}
	return NULL;
}
/**
 * Duplicates this node.
 *
 * @return duplicate node.
 */
NCDNode* NCDElementImpl::cloneNode(
	bool deep		///< [in] if true, also copies children.
) const
{
	NCDElementImpl* newElement = static_cast<NCDElementImpl*>(document->createElement(nodeName));
	
	// copy attributes
	UInt32 attrCount = attributes.getLength();
	UInt32 attrIndex;
	for (attrIndex=0; attrIndex<attrCount; attrIndex++)
	{
		NCDAttr* attr = attributes.attrItem(attrIndex);
		NCDAttr* newAttr = static_cast<NCDAttr*>(attr->cloneNode(true));
		newElement->attributes.setAttrItem(newAttr);
	}
	
	// copy children
	if (deep)
	{
		NCDNode* childNode = getFirstChild();
		while (NULL != childNode)
		{
			NCDNode* newChildNode = childNode->cloneNode(deep);
			newElement->appendChild(newChildNode);
			
			childNode = childNode->getNextSibling();
		}
	}
	
	return newElement;
}
/**
 * Release this node and resources associated with it, and also its children.
 */ 
void NCDElementImpl::release()
{
	if (NULL != getParentNode())
	{
		throw new NCDException(NCDException::INVALID_ACCESS_ERR);
	}

	try
	{
		// release children
		while (hasChildNodes())
		{
			NCDNode* childNode = getFirstChild();
			removeChild(childNode);
			childNode->release();
		}
		
		// dispose this node.
		static_cast<NCDDocumentImpl*>(document)->disposeNode(this);
	}
	catch (NCDException* ex)
	{
		ASSERT(FALSE);
	
		// ignore
		ex->Delete();
	}
}
示例#9
0
XalanNode*
XercesElementWrapper::item(unsigned int		index) const
{
	assert(index < getLength());

	if (m_navigator.getOwnerDocument()->getMappingMode() == true)
	{
		assert(m_xercesNode->getChildNodes()->item(index));

		return m_navigator.mapNode(m_xercesNode->getChildNodes()->item(index));
	}
	else
	{
		XalanNode*	child = getFirstChild();
		assert(child != 0);

		for(unsigned int i = 0; i < index; ++i)
		{
			child = child->getNextSibling();
			assert(child != 0);
		}

		return child;
	}
}
示例#10
0
DOMNode* DOMTreeWalkerImpl::getNextSibling (DOMNode* node) {
	
    if (!node || node == fRoot) return 0;

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

        newNode = node->getParentNode();

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

        short parentAccept = acceptNode(newNode);

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

        return 0;
    }

    short accept = acceptNode(newNode);

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

}
示例#11
0
DOMNode* DOMTreeWalkerImpl::nextNode () {
	
    if (!fCurrentNode) return 0;

    DOMNode* node = getFirstChild(fCurrentNode);

    if (node != 0) {
        fCurrentNode = node;
        return node;
    }
    else {

        node = getNextSibling(fCurrentNode);

        if (node != 0) {
            fCurrentNode = node;
            return node;
        }
        else {

            // return parent's 1st sibling.
            DOMNode* parent = getParentNode(fCurrentNode);
            while ( parent != 0) {
                node = getNextSibling(parent);
                if (node != 0) {
                    fCurrentNode = node;
                    return node;
                } else {
                    parent = getParentNode(parent);
                }
            }
            return node;
        }
    }
}
示例#12
0
/*******************  FUNCTION  *********************/
void ProjectActionOld::genItLoopCCode ( ostream& out, const CMRProjectContext& context, int depth ) const
{
	CMRProjectContext localContext(&context);

	//errors
	assert(name == "cmrSubBlock" && description == "cmrIteratorLoop");
	
	//search the related iterator definition
	const CMRProjectEntity * entity = context.parent->find(eq->latexEntity);
	if (entity == NULL)
	{
		cerr << "Can't find the definition of iterator " << eq->compute << " in current context." << endl;
		abort();
	}

	const CMRProjectIterator * iterator = dynamic_cast<const CMRProjectIterator*>(entity);
	if (iterator == NULL)
	{
		cerr << "Cuation, expect iterator " << eq->compute << " but get another type." << endl;
		context.printDebug();
		abort();
	}
	assert(iterator != NULL);
	
	CMRProjectLocalVariable localVar(eq->compute,eq->compute);
	localContext.addEntry(&localVar);
	out << genCCodeIndent(depth) << "for (int " << eq->compute << " = " << iterator->start << " ; " << eq->compute << " < " << iterator->end << " ; " << eq->compute << "++ )" <<endl;
	out << genCCodeIndent(depth) << "{" << endl;
	for (ConstIterator it = getFirstChild() ; ! it.isEnd() ; ++it)
		it->genCCode(out,it->context,depth+1);
		//it->genCCode(out,localContext,depth+1);
	out << genCCodeIndent(depth) << "}" << endl;
	
	//checkContext(localContext);
}
示例#13
0
文件: Container.cpp 项目: PADrend/GUI
//! ---|> Component
Component::visitorResult_t Container::traverseChildren(Visitor & v) {
	for(Component * c = getFirstChild();c!=nullptr;c = c->getNext()){
		if( v.visit(*c)==EXIT_TRAVERSAL )
			return EXIT_TRAVERSAL;
	}
	return CONTINUE_TRAVERSAL;
}
示例#14
0
    //-----------------------------------------------------------------------
    //                              l a y o u t
    //-----------------------------------------------------------------------
    void TGListBox::layout()
    {
        int     	w, h, y = 0, i = 0;

        getClientSize(w, h);
        w--;

        
        for (TGControlListItr itr = m_children.begin();itr != m_children.end(); ++itr)
        {
            TGListBoxItem* lbi = (TGListBoxItem*)(*itr);
            if( lbi->minimumWidth > (unsigned int)w)
                w = lbi->minimumWidth;
        }
        

        for (TGControlListItr itr = m_children.begin();itr != m_children.end(); ++itr)
        {
            TGListBoxItem* lbi = (TGListBoxItem*)(*itr);
            lbi->index = i++;
            lbi->setBounds(0, y, w, y + lbi->itemHeight - 1);
            y += lbi->itemHeight;
        }

        if (!m_selectedItem)
            m_selectedItem = (TGListBoxItem*)getFirstChild();

        TGScrollBox::layout();
    }
示例#15
0
void HTMLStyleElementImp::handleMutation(EventListenerImp* listener, events::Event event)
{
    // TODO: update type, media, and scoped. Then check type.

    events::MutationEvent mutation(interface_cast<events::MutationEvent>(event));

    DocumentImp* document = getOwnerDocumentImp();
    if (!document)
        return;

    if (mutation.getType() == u"DOMNodeRemoved" && event.getTarget().self() == this)
        styleSheet = 0;
    else {
        std::u16string content;
        for (Node node = getFirstChild(); node; node = node.getNextSibling()) {
            if (TextImp* text = dynamic_cast<TextImp*>(node.self()))  // TODO better to avoid imp call?
                content += text->getData();
        }
        CSSParser parser;
        styleSheet = parser.parse(document, content);
        if (auto imp = dynamic_cast<CSSStyleSheetImp*>(styleSheet.self())) {
            imp->setOwnerNode(this);
            if (4 <= getLogLevel())
                dumpStyleSheet(std::cerr, imp);
        }
    }
    if (WindowImp* view = document->getDefaultWindow())
        view->setFlags(Box::NEED_SELECTOR_REMATCHING);
    document->resetStyleSheets();
}
/**
 * Recursively prints a node and all its children in the dot format "parent -- child"
 */
void CompletionTrie::printNode(PackedNode* parent,
		std::vector<PackedNode*> locus) const {
	PackedNode* child = getFirstChild(parent);
	if (child == parent) {
		return;
	}
	while (true) {
		locus.push_back(child);
		if (child->firstChildOffsetSize_ != 0) {
			printNode(child, locus);
		}
		locus.pop_back();

		if (parent->charactersSize_ == 0) {
			/*
			 * the root element
			 */
			std::cout << "ROOT";
		} else {
			std::cout
					<< std::string(parent->getCharacters(),
							parent->charactersSize_);
		}
		std::cout << " -- " << child->getString() << "[ label = \""<< child->getDeltaScore() <<"\" ];" << std::endl;

		if (child->isLastSibling_) {
			break;
		} else {
			child = reinterpret_cast<PackedNode*>(reinterpret_cast<char*>(child)
					+ child->getSize());
		}
	}
}
示例#17
0
Widget* Container::findDescendant(const char* descendantPath)
	{
	/* Find the next forward slash in the descendant path: */
	const char* slashPtr;
	for(slashPtr=descendantPath;*slashPtr!='\0'&&*slashPtr!='/';++slashPtr)
		;
	
	/* Traverse all children in the container until the first name matches: */
	Widget* child;
	for(child=getFirstChild();child!=0&&!strsegequal(descendantPath,slashPtr,child->getName());child=getNextChild(child))
		;
	
	/* Check if there is another path segment: */
	if(*slashPtr=='/')
		{
		/* Check if the found child is a container: */
		Container* container=dynamic_cast<Container*>(child);
		if(container!=0)
			{
			/* Search the found container: */
			return container->findDescendant(slashPtr+1);
			}
		else
			{
			Misc::throwStdErr("GLMotif::Container::findDescendant: Path component not found");
			return 0; // Just to make compiler happy
			}
		}
	else
		return child;
	}
示例#18
0
Widget* Container::findChild(const char* childName)
	{
	/* Traverse all children in the container until the first name matches: */
	Widget* child;
	for(child=getFirstChild();child!=0&&strcmp(child->getName(),childName)!=0;child=getNextChild(child))
		;
	return child;
	}
示例#19
0
/*******************  FUNCTION  *********************/
void ProjectActionOld::genRootElemCCode ( ostream& out, const CMRProjectContext& context, int depth ) const
{
	CMRProjectContext localContext(&context);
	for (ConstIterator it = getFirstChild() ; ! it.isEnd() ; ++it)
		it->genCCode(out,it->context,depth+1);
		//it->genCCode(out,localContext,depth+1);
	//checkContext(localContext);
}
示例#20
0
Test::TestGroup* Test::TestGroup::getFirstLeaf()
{
	TestGroup* firstChild = getFirstChild();
	if (!firstChild)
		return this;

	return firstChild->getFirstLeaf();
}
示例#21
0
CDontSaveFileItem *CProjectItem::getDontSaveFileItem() const {
    for (CTreeItem *treeItem = getFirstChild(); treeItem; treeItem = treeItem->getNextSibling()) {
        if (treeItem->isInstanceOf(CDontSaveFileItem::_type))
            return dynamic_cast<CDontSaveFileItem *>(treeItem);
    }

    return nullptr;
}
示例#22
0
DOMNode* DOMAttrImpl::rename(const XMLCh* namespaceURI, const XMLCh* name)
{
    DOMElement* el = getOwnerElement();
    DOMDocumentImpl* doc = (DOMDocumentImpl*)fParent.fOwnerDocument;

    if (el)
        el->removeAttributeNode(this);

    if (!namespaceURI || !*namespaceURI) {
        fName = doc->getPooledString(name);

        if (el)
            el->setAttributeNode(this);

        // and fire user data NODE_RENAMED event
        castToNodeImpl(this)->callUserDataHandlers(DOMUserDataHandler::NODE_RENAMED, this, this);

        return this;
    }
    else {

        // create a new AttrNS
        DOMAttr* newAttr = doc->createAttributeNS(namespaceURI, name);

        // transfer the userData
        doc->transferUserData(castToNodeImpl(this), castToNodeImpl(newAttr));

        // move children to new node
        DOMNode* child = getFirstChild();
        while (child) {
            removeChild(child);
            newAttr->appendChild(child);
            child = getFirstChild();
        }

        // reattach attr to element
        if (el)
            el->setAttributeNodeNS(newAttr);

        // and fire user data NODE_RENAMED event
        castToNodeImpl(newAttr)->callUserDataHandlers(DOMUserDataHandler::NODE_RENAMED, this, newAttr);

        return newAttr;
    }
}
示例#23
0
文件: Container.cpp 项目: PADrend/GUI
//! ---|> Component
std::string Container::toString()const {
	std::ostringstream s;
	size_t i = getContentsCount();
	for(Component * c=getFirstChild();c!=nullptr;c=c->getNext()){
		s<<c->toString();
		if (--i>0)s<<",";
	}
	s<<"]";
	return s.str();
}
示例#24
0
文件: CMRXmlDoc.cpp 项目: svalat/CMR
/*******************  FUNCTION  *********************/
CMRXmlNode CMRXmlNode::getUniqChild ( const string& tagname )
{
	CMRXmlNode cur = getFirstChild(tagname);
	if (cur.isValid())
	{
		assert(cur.isNamed(tagname));
		if (cur.getNextSibiling().isValid())
			throw LatexException("Caution, you want to get a tag value, but there is multiple instances of this tag.");
	}
	return cur;
}
示例#25
0
文件: Connector.cpp 项目: PADrend/GUI
//! ---|> Component
void Connector::doDisplay(const Geometry::Rect & region){
	displayChildren(region);

	enableLocalDisplayProperties();
	displayDefaultShapes();	
	std::vector<Geometry::Vec2> points;
	for(Component * c=getFirstChild();c!=nullptr;c=c->getNext())
		points.emplace_back(c->getPosition());
	getGUI().displayLineShape(PROPERTY_CONNECTOR_LINE_SHAPE,points,0);
	disableLocalDisplayProperties();
}
bool BtDecoratorNotNode::execute(BtParams* params)
{
	BtNode* node = getFirstChild();

	if (!node)
	{
		return false;
	}

	return !node->execute(params);
}
示例#27
0
/** Return the first child Node from the current node,
 *  after applying filter, whatToshow.
 *  If result is not null, set the current Node.
 */
DOM_Node TreeWalkerImpl::firstChild () {

	DOM_Node result;

    if (fCurrentNode.isNull()) return result;

    DOM_Node node = getFirstChild(fCurrentNode);
    if (! node.isNull()) {
        fCurrentNode = node;
    }
    return node;
}
bool BtSelectorNode::execute(BtParams* params)
{
	for (BtNode* node = getFirstChild(); node; node = node->getNextSibling())
	{
		if (node->execute(params))
		{
			return true;
		}
	}

	return false;
}
示例#29
0
    ElementPtr Node::getFirstChildElement() const
    {
      NodePtr found = getFirstChild();
      while (found)
      {
        if (found->isElement())
          return found->toElement();

        found = found->getNextSibling();
      }
      return ElementPtr();
    }
示例#30
0
const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *ChildAxis::nextNode(DynamicContext *context)
{
  if(toDo_) {
    // initialise
    toDo_ = false;
    child_ = getFirstChild(contextNode_);
  }
  else if(child_ != 0) {
    child_ = getNextSibling(child_);
  }

  return child_;
}