Ejemplo n.º 1
0
void HtmlExporter::emitFrame( QTextFrame::Iterator frameIt )
{
//     kDebug() << "html" << html;
    if ( !frameIt.atEnd() ) {
        QTextFrame::Iterator next = frameIt;
        ++next;
        if ( next.atEnd()
                && frameIt.currentFrame() == 0
                && frameIt.parentFrame() != doc->rootFrame()
                && frameIt.currentBlock().begin().atEnd() ) {
            return;
        }
    }


    for ( QTextFrame::Iterator it = frameIt;
            !it.atEnd(); ++it ) {;
        if ( QTextFrame *f = it.currentFrame() ) {
//    qDebug() << "Its a frame, not a block" << endl;
            if ( QTextTable * table = qobject_cast<QTextTable *>( f ) ) {
                emitTable( table );
            } else {
//     qDebug() << "isn't table" << endl;
                html += QLatin1String( "\n<table" );
                QTextFrameFormat format = f->frameFormat();

                if ( format.hasProperty( QTextFormat::FrameBorder ) ) {
                    emitAttribute( "border", QString::number( format.border() ) );
                }

                html += QLatin1String( " style=\"-qt-table-type: frame;" );
                emitFloatStyle( format.position(), OmitStyleTag );

                if ( format.hasProperty( QTextFormat::FrameMargin ) ) {
                    const QString margin = QString::number( format.margin() );
                    emitMargins( margin, margin, margin, margin );
                }

                html += QLatin1Char( '\"' );

                emitTextLength( "width", format.width() );
                emitTextLength( "height", format.height() );

                QBrush bg = format.background();
                if ( bg != Qt::NoBrush ) {
                    emitAttribute( "bgcolor", bg.color().name() );
                }

                html += QLatin1Char( '>' );
                html += QLatin1String( "\n<tr>\n<td style=\"border: none;\">" );
                emitFrame( f->begin() );
                html += QLatin1String( "</td></tr></table>" );
            }
        } else if ( it.currentBlock().isValid() ) {
//    qDebug()<< "is valid" << endl;
            emitBlock( it.currentBlock() );
        }
    }
}