{
if (FoTag(e) != TABLE_TAG) {
return;
}
Fop_Block *foppi = new Fop_Block(imagecounter,e,"fo:table"); /* grep current source to play */
qreal tableborderborder = TakeOneBorder(e);
qreal tablewidth
= Unit
(e.
attribute ("width",
QString("0")));
bool IsCorrectCursor
= Tcursor.
movePosition(QTextCursor::End);
int mappos = Tcursor.position(); /* last position from last cursor on class ! */
QTextCursor cellCursor;
/* new cursor only for cell tabbing */ QString tatype
= e.
attribute( "table-layout" );
/* on attribute root table */ QStringList coolsizes;
/* grep column size in pt cm mm ecc... */ coolsizes.clear();
QDomElement bodytable
= e.
firstChildElement("fo:table-body");
int rowCounter = 0;
int columnCounter = 0;
QDomElement column
= e.
firstChildElement("fo:table-column");
while (!column.isNull()) {
const QString sizefromcool
= column.
attribute( "column-width" );
if (sizefromcool.size() > 0) {
coolsizes.append(sizefromcool); /* append unit widht string 22pt */
}
column = column.nextSiblingElement("fo:table-column");
}
if (coolsizes.size() > 0) {
columnCounter = coolsizes.size();
}
QDomElement rows
= bodytable.
firstChildElement("fo:table-row");
while (!rows.isNull()) {
rowCounter++;
rows = rows.nextSiblingElement("fo:table-row");
}
if (rowCounter < 1) {
//////qDebug() << "### false row? " << columnCounter << " list" << coolsizes;
return;
}
////////qDebug() << "### true row " << columnCounter << " list" << coolsizes;
/* #########################base table #######################################*/
QTextTable *qtable
= Tcursor.
insertTable( rowCounter, columnCounter
);
///////qDebug() << "### parse table... ";
////////qDebug() << "### rowCounter " << rowCounter;
////////qDebug() << "### columnCounter " << columnCounter;
QString tbg
= bodytable.
attribute("background-color");
if (tablewidth !=0) {
///////tableFormat.setHeight ( QTextLength ( QTextLength::FixedLength, tablewidth ) );
}
qreal borderDik = TakeOneBorder(bodytable);
////////qDebug() << "### table borderDik " << borderDik; /* qt4 4.3 bug unable to set table border on QGraphicsTextItem */
if (!tbg.isEmpty()) {
tableFormat.
setBackground ( QColor(tbg
) );
}
tableFormat.setBorder(borderDik);
tableFormat.
setCellSpacing(Unit
(bodytable.
attribute ("cell-space",
QString("0"))));
tableFormat.setCellPadding(TakeOnePadding(bodytable));
/* colums on mm cm pt <-> */
if (coolsizes.size() > 0) {
tableFormat.clearColumnWidthConstraints();
QVector<QTextLength> constraints;
for (int i = 0; i < coolsizes.size(); ++i) {
const qreal cellmesure = Unit(coolsizes.at(i));
}
tableFormat.setColumnWidthConstraints(constraints);
}
if (tatype == "fixed") {
tableFormat.setAlignment ( Qt::AlignLeft );
} else {
tableFormat.setAlignment ( Qt::AlignJustify );
}
int qlistlargeNr = -1; /* cell and row count from 0 */
QDomElement setrows
= bodytable.
firstChildElement("fo:table-row");
while (!setrows.isNull()) {
int is_spancol = 0;
int startStorno = 0;
int stopStorno = 0;
bool bypassisactive = false;
qlistlargeNr++;
tdformat.setBottomMargin(0);
tdformat.setTopMargin(0);
QDomElement columnElement
= setrows.
firstChildElement();
/* sub element from row */ int columnCounter = -1; /* cell and row count from 0 */
while ( !columnElement.isNull() ) {
if ( columnElement.tagName().toLower() == "fo:table-cell" ) {
columnCounter++;
is_spancol = columnElement.attribute( "number-columns-spanned" ).trimmed().toInt();
if (is_spancol > 1) {
for (int i = 0; i < is_spancol; ++i) {
QTextTableCell cellstart
= qtable
->cellAt
( qlistlargeNr , columnCounter
+ i
);
if (!columnElement.attribute("background-color").isEmpty()) {
firster.
setBackground(QColor(columnElement.
attribute("background-color")));
}
cellstart.setFormat(firster);
}
/* point to last cell number-columns-spanned to fill text */
qtable->mergeCells ( qlistlargeNr ,columnCounter,1,is_spancol);
cell = qtable->cellAt( qlistlargeNr , columnCounter );
} else {
cell = qtable->cellAt( qlistlargeNr , columnCounter );
}
Tcursor = cell.firstCursorPosition();
const qreal cellpadding
= Unit
(columnElement.
attribute ("padding",
QString("0")));
const qreal cellwidht = Get_Cell_Width(tableFormat,columnCounter);
/* paint cell Background and table border here */
if (!columnElement.attribute("background-color").isEmpty()) {
existformat.
setBackground(QColor(columnElement.
attribute("background-color")));
}
existformat.setToolTip ( foppi->Get_XML() );
cell.setFormat(existformat);
Tcursor = cell.firstCursorPosition();
int FirstcellInitCursor = Tcursor.position();
int blocksDD = 0;
QDomElement cellinside
= columnElement.
firstChildElement("fo:block");
while ( !cellinside.isNull() ) {
blocksDD++;
if (blocksDD == 1) {
ParserParagraph(cellinside,d,layer,FirstcellInitCursor,true);
} else {
ParserParagraph(cellinside,d,layer,CursorStatementPosition,true);
}
cellinside = cellinside.nextSiblingElement("fo:block");
}
}
columnElement = columnElement.nextSiblingElement();
}
setrows = setrows.nextSiblingElement("fo:table-row");
}
qtable->setFormat( tableFormat );
ActualBackgroundColor
= QString(default_background
);
/* reset color background */ CursorStatementPosition = 0; /* go to end document ! */
}