Пример #1
0
bool UnderOverElement::readMathMLContent( const KoXmlElement& parent )
{
    QString name = parent.tagName().toLower();
    BasicElement* tmpElement = 0;
    KoXmlElement tmp;
    forEachElement( tmp, parent ) { 
        tmpElement = ElementFactory::createElement( tmp.tagName(), this );
        if( !tmpElement->readMathML( tmp ) )
            return false;

        if( m_baseElement->elementType() == Basic ) {
            delete m_baseElement; 
            m_baseElement = tmpElement;
        }
        else if( name.contains( "under" ) && m_underElement->elementType() == Basic ) {
            delete m_underElement;
            m_underElement = tmpElement;
        }
        else if( name.contains( "over" ) && m_overElement->elementType() == Basic ) {
            delete m_overElement;
            m_overElement = tmpElement;
        }
        else
            return false;
    }
Пример #2
0
static int count( const QList<BasicElement*>& list )
{
    BasicElement* element;
    int counter = list.count();
    foreach ( element, list )
        counter += count( element->childElements() );

    return counter;
}
Пример #3
0
bool TableRowElement::readMathMLContent( const KoXmlElement& element )
{
    BasicElement* tmpElement = 0;
    KoXmlElement tmp;
    forEachElement( tmp, element ) {
        tmpElement = ElementFactory::createElement( tmp.tagName(), this );
        if (tmpElement->elementType() != TableData)
            return false;

        m_data << static_cast<TableDataElement*>( tmpElement );
        tmpElement->readMathML( tmp );
    }
Пример #4
0
static QString dumpRecurse(const QList<BasicElement*>& list)
{
    BasicElement *element;
    QString       result = "[ ";

    if (list.count() > 0) {
        result.append(QString::number(list.count()));
        result.append(' ');

        foreach ( element, list )
            result.append(dumpRecurse(element->childElements()));
    }
    return result + " ]";
}
Пример #5
0
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 );
}
Пример #6
0
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);
    }
}