Esempio n. 1
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);

}
Esempio n. 2
0
DOM_Node TreeWalkerImpl::previousNode () {
	
    DOM_Node result;

    if (fCurrentNode.isNull()) return result;

    // get sibling
    result = getPreviousSibling(fCurrentNode);
    if (result.isNull()) {
        result = getParentNode(fCurrentNode);
        if (! result.isNull()) {
            fCurrentNode = result;
            return fCurrentNode;
        }
        return result;
    }

    // get the lastChild of result.
    DOM_Node lastChild  = getLastChild(result);

    // if there is a lastChild which passes filters return it.
    if (! lastChild.isNull()) {
        fCurrentNode = lastChild;
        return fCurrentNode;
    }

    // otherwise return the previous sibling.
    if (! result.isNull()) {
        fCurrentNode = result;
        return fCurrentNode;
    }

    // otherwise return null.
    return result;
}
Esempio n. 3
0
DOMNode* DOMTreeWalkerImpl::previousNode () {
	
    if (!fCurrentNode) return 0;

    // get sibling
    DOMNode* node = getPreviousSibling(fCurrentNode);
    if (node == 0) {
        node = getParentNode(fCurrentNode);
        if ( node != 0) {
            fCurrentNode = node;
        }
        return node;
    }
    else {

        // get the lastChild of result.
        DOMNode* lastChild  = getLastChild(node);

        // if there is a lastChild which passes filters return it.
        if (lastChild != 0) {
            fCurrentNode = lastChild;
        }
        else {
            fCurrentNode = node;
        }
        return fCurrentNode;
    }
}
Esempio n. 4
0
DOMNode* DOMTreeWalkerImpl::previousSibling () {
	
    if (!fCurrentNode) return 0;

    DOMNode* node = getPreviousSibling(fCurrentNode);
    if (node != 0) {
        fCurrentNode = node;
    }
    return node;
}
Esempio n. 5
0
DOM_Node TreeWalkerImpl::previousSibling () {
	
	DOM_Node result;

    if (fCurrentNode.isNull()) return result;

    DOM_Node node = getPreviousSibling(fCurrentNode);
    if (! node.isNull()) {
        fCurrentNode = node;
    }
    return node;
}
Esempio n. 6
0
    ElementPtr Node::getPreviousSiblingElement() const
    {
      NodePtr found = getPreviousSibling();
      while (found)
      {
        if (found->isElement())
          return found->toElement();

        found = found->getPreviousSibling();
      }
      return ElementPtr();
    }
Esempio n. 7
0
// get the previous tag
QSgmlTagConstPointer QSgmlTag::getPreviousElement() const
{
    // Is there a previous tag on the same level
    QSgmlTagConstPointer Return = getPreviousSibling();
    if (Return == NULL)
        Return = d.Parent;
    else
        // search the last child with no children
        while (Return->d.Children.count () != 0)
            Return = Return->d.Children.last ();

    return Return;
}
long PANEElement::getLeftOffset(){
	PANEElement * const parent = dynamic_cast< PANEElement * >( getParentNode() );
	if( NULL == parent ) return 0;

	PANEElement * const prevSibling = dynamic_cast< PANEElement * >( getPreviousSibling() );
	if( NULL == prevSibling )
		return parent->getLeftOffset();

	const unsigned long availableWidth = getAvailableWidth();
	if( availableWidth  < getActualWidth( availableWidth ) )
		return parent->getLeftOffset();

	return prevSibling->getRightOffset();
}
Esempio n. 9
0
DOM_Node TreeWalkerImpl::getPreviousSibling (DOM_Node node) {
		
	DOM_Node result;

    if (node.isNull() || node == fRoot) return result;

    DOM_Node newNode = node.getPreviousSibling();
    if (newNode.isNull()) {

        newNode = node.getParentNode();
        if (newNode.isNull() || node == fRoot)  return result;

        short parentAccept = acceptNode(newNode);

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

        return result;
    }

    short accept = acceptNode(newNode);

    if (accept == DOM_NodeFilter::FILTER_ACCEPT)
        return newNode;
    else
    if (accept == DOM_NodeFilter::FILTER_SKIP) {
        DOM_Node fChild =  getLastChild(newNode);
        if (fChild.isNull()) {
            return getPreviousSibling(newNode);
        }
        return fChild;
    }
    return getPreviousSibling(newNode);

}
long PANEElement::getAvailableWidth() {
	PANEElement * const parent = dynamic_cast< PANEElement * >( getParentNode() );
	if( NULL == parent ) return getWidth();
	const long parentAvailableWidth = parent->getAvailableWidth();

	PANEElement * const prevSibling = dynamic_cast< PANEElement * >( getPreviousSibling() );
	if( NULL == prevSibling )
		return parentAvailableWidth;

	PANEElement * const firstSibling = dynamic_cast< PANEElement * >( parent->getFirstChild() );
	const long firstLeft = firstSibling->getLeftOffset();
	const long prevRight = prevSibling->getRightOffset();
	const long availableWidth = parentAvailableWidth - (prevRight -  firstLeft);

	if( hasDesiredWidth() )
		return std::min( (long) getWidth(), availableWidth );
	return availableWidth;
}
Esempio n. 11
0
DOM_Node TreeWalkerImpl::getLastChild (DOM_Node node) {
	
	DOM_Node result;

    if (node.isNull()) return result;

    DOM_Node newNode = node.getLastChild();
    if (newNode.isNull())  return result;

    short accept = acceptNode(newNode);

    if (accept == DOM_NodeFilter::FILTER_ACCEPT)
        return newNode;
    else
    if (accept == DOM_NodeFilter::FILTER_SKIP
        && newNode.hasChildNodes())
    {
        return getLastChild(newNode);
    }
    return getPreviousSibling(newNode);


}
Esempio n. 12
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);

}
Esempio n. 13
0
 NodePtr Node::getPreviousSiblingChecked() const throw(Exceptions::CheckFailed)
 {
   NodePtr result = getPreviousSibling();
   ZS_THROW_CUSTOM_IF(Exceptions::CheckFailed, !result)
   return result;
 }