Logo Search packages:      
Sourcecode: kbarcode version File versions  Download package

bool DSRichText::parseParagraph (  )  [private]

parse a single pare of

elements

Definition at line 209 of file dsrichtext.cpp.

References formated_word::color, formated_word::font, parseParagraphTag(), and parseStyle().

Referenced by DSRichText().

{
    int alignment = 0;
    formated_word f;
    QString d = parse( text, "<p", "</p>", pos );
    //qDebug("D=" + d );
    //qDebug("POS=%i", pos );

    pos += d.length();
    if( d.isNull() )
        return false;

    d = parseParagraphTag( d, &alignment );

    WordList words;
    QString data;
    initFormat( &f, alignment );

    if( d.isEmpty() ) {
        // found empty paragraph
        words.append( f );
        word_p.append( words );
        return true;
    }

    for( unsigned int i = 0; i < d.length(); ) {
        if( d[i] == '<' || i == (d.length() - 1) ) {
            if( i == (d.length() - 1) )
                data.append( d[i] );

            parseWords( data, &f, &words );
            initFormat( &f, alignment );
            data = QString::null;

            // bail out now, otherwise there is
            // and endless loop for e.g. <p>a</p>
            if( i == (d.length() - 1) )
                break;

            if( d[i] == '<' ) {
                QString span = d.mid( i, d.find( ">", i ) - i + 1 );
                i += span.length();

                if( span.startsWith( "<span " ) ) {
                    initFormat( &f, alignment );
                    f.font = parseStyle( parse( span, "style=\"", "\"", 0 ), &f.color );
                }
            }
        } else {
            data.append( d[i] );
            i++;
        }
    }

    word_p.append( words );
    return true;
}


Generated by  Doxygen 1.6.0   Back to index