void FormulaCursor::setCursorTo( const QPointF& point ) { if (m_selecting) { while (!m_currentElement->absoluteBoundingRect().contains(point)) { if ( m_currentElement->parentElement() ) { m_position=0; if (point.x()<m_currentElement->cursorLine(m_mark).p1().x()) { //the point is left of the old selection start, so we move the selection //start after the old current element m_mark=m_currentElement->parentElement()->positionOfChild(m_currentElement)+1; } else { m_mark=m_currentElement->parentElement()->positionOfChild(m_currentElement); } m_currentElement=m_currentElement->parentElement(); } else { return; } } while (!m_currentElement->setCursorTo(*this,point-m_currentElement->absoluteBoundingRect().topLeft())) { if ( m_currentElement->parentElement() ) { m_mark=m_currentElement->parentElement()->positionOfChild(m_currentElement); m_position=0; if (point.x()<m_currentElement->cursorLine(m_mark).p1().x()) { //the point is left of the old selection start, so we move the selection //start after the old current element m_mark++; } m_currentElement=m_currentElement->parentElement(); } else { return; } } } else { BasicElement* formulaElement = m_currentElement; while( formulaElement->parentElement() != 0 ) { formulaElement = formulaElement->parentElement(); } formulaElement->setCursorTo(*this,point); } }
QString AttributeManager::findValue( const QString& attribute, const BasicElement* element ) const { // check if the current element has a value assigned QString value = element->attribute( attribute ); if( !value.isEmpty() ) return value; // if not, check if any of the parent elements inherits a value BasicElement* tmpParent = element->parentElement(); while( tmpParent ) { value = tmpParent->inheritsAttribute( attribute ); if( !value.isEmpty() ) return value; else tmpParent = tmpParent->parentElement(); } // if not, return the default value of the attribute return element->attributesDefaultValue( attribute ); }