status_t Model::SetTo(const node_ref *dirNode, const node_ref *nodeRef, const char *name, bool open, bool writable) { delete fNode; fNode = NULL; DeletePreferredAppVolumeNameLinkTo(); fIconFrom = kUnknownSource; fBaseType = kUnknownNode; fMimeType = ""; fStatBuf.st_dev = nodeRef->device; fStatBuf.st_ino = nodeRef->node; fEntryRef.device = dirNode->device; fEntryRef.directory = dirNode->node; fEntryRef.name = strdup(name); BEntry tmpNode(&fEntryRef); fStatus = tmpNode.InitCheck(); if (fStatus != B_OK) return fStatus; fStatus = tmpNode.GetStat(&fStatBuf); if (fStatus != B_OK) return fStatus; fStatus = OpenNode(writable); if (!open) CloseNode(); return fStatus; }
ObjectGraphNode *ObjectGraph::findNode(cv::Point2i coordinates) { ObjectGraphNode tmpNode(coordinates.x, coordinates.y); auto iterator = nodes.find(&tmpNode); if(iterator == nodes.end()) return 0; return *iterator; }
bool PNS_TOPOLOGY::LeadingRatLine( const PNS_LINE* aTrack, SHAPE_LINE_CHAIN& aRatLine ) { PNS_LINE track( *aTrack ); VECTOR2I end; if( !track.PointCount() ) return false; std::unique_ptr<PNS_NODE> tmpNode( m_world->Branch() ); tmpNode->Add( &track ); PNS_JOINT* jt = tmpNode->FindJoint( track.CPoint( -1 ), &track ); if( !jt ) return false; if( ( !track.EndsWithVia() && jt->LinkCount() >= 2 ) || ( track.EndsWithVia() && jt->LinkCount() >= 3 ) ) // we got something connected { end = jt->Pos(); } else { int anchor; PNS_TOPOLOGY topo( tmpNode.get() ); PNS_ITEM* it = topo.NearestUnconnectedItem( jt, &anchor ); if( !it ) return false; end = it->Anchor( anchor ); } aRatLine.Clear(); aRatLine.Append( track.CPoint( -1 ) ); aRatLine.Append( end ); return true; }
nsresult nsTextAttrsMgr::GetRange(const nsTPtrArray<nsITextAttr>& aTextAttrArray, PRInt32 *aStartHTOffset, PRInt32 *aEndHTOffset) { nsCOMPtr<nsIDOMElement> rootElm = nsCoreUtils::GetDOMElementFor(mHyperTextNode); NS_ENSURE_STATE(rootElm); nsCOMPtr<nsIDOMNode> tmpNode(mOffsetNode); nsCOMPtr<nsIDOMNode> currNode(mOffsetNode); PRUint32 len = aTextAttrArray.Length(); // Navigate backwards and forwards from current node to the root node to // calculate range bounds for the text attribute. Navigation sequence is the // following: // 1. Navigate through the siblings. // 2. If the traversed sibling has children then navigate from its leaf child // to it through whole tree of the traversed sibling. // 3. Get the parent and cycle algorithm until the root node. // Navigate backwards (find the start offset). while (currNode && currNode != rootElm) { nsCOMPtr<nsIDOMElement> currElm(nsCoreUtils::GetDOMElementFor(currNode)); NS_ENSURE_STATE(currElm); if (currNode != mOffsetNode) { PRBool stop = PR_FALSE; for (PRUint32 idx = 0; idx < len; idx++) { nsITextAttr *textAttr = aTextAttrArray[idx]; if (!textAttr->Equal(currElm)) { PRInt32 startHTOffset = 0; nsCOMPtr<nsIAccessible> startAcc; nsresult rv = mHyperTextAcc-> DOMPointToHypertextOffset(tmpNode, -1, &startHTOffset, getter_AddRefs(startAcc)); NS_ENSURE_SUCCESS(rv, rv); if (!startAcc) startHTOffset = 0; if (startHTOffset > *aStartHTOffset) *aStartHTOffset = startHTOffset; stop = PR_TRUE; break; } } if (stop) break; } currNode->GetPreviousSibling(getter_AddRefs(tmpNode)); if (tmpNode) { // Navigate through the subtree of traversed children to calculate // left bound of the range. FindStartOffsetInSubtree(aTextAttrArray, tmpNode, currNode, aStartHTOffset); } currNode->GetParentNode(getter_AddRefs(tmpNode)); currNode.swap(tmpNode); } // Navigate forwards (find the end offset). PRBool moveIntoSubtree = PR_TRUE; currNode = mOffsetNode; while (currNode && currNode != rootElm) { nsCOMPtr<nsIDOMElement> currElm(nsCoreUtils::GetDOMElementFor(currNode)); NS_ENSURE_STATE(currElm); // Stop new end offset searching if the given text attribute changes its // value. PRBool stop = PR_FALSE; for (PRUint32 idx = 0; idx < len; idx++) { nsITextAttr *textAttr = aTextAttrArray[idx]; if (!textAttr->Equal(currElm)) { PRInt32 endHTOffset = 0; nsresult rv = mHyperTextAcc-> DOMPointToHypertextOffset(currNode, -1, &endHTOffset); NS_ENSURE_SUCCESS(rv, rv); if (endHTOffset < *aEndHTOffset) *aEndHTOffset = endHTOffset; stop = PR_TRUE; break; } } if (stop) break; if (moveIntoSubtree) { // Navigate through subtree of traversed node. We use 'moveIntoSubtree' // flag to avoid traversing the same subtree twice. currNode->GetFirstChild(getter_AddRefs(tmpNode)); if (tmpNode) FindEndOffsetInSubtree(aTextAttrArray, tmpNode, aEndHTOffset); } currNode->GetNextSibling(getter_AddRefs(tmpNode)); moveIntoSubtree = PR_TRUE; if (!tmpNode) { currNode->GetParentNode(getter_AddRefs(tmpNode)); moveIntoSubtree = PR_FALSE; } currNode.swap(tmpNode); } return NS_OK; }