/** Draws the section base objects to the specified painter & x/y offsets */ void MReportSection::drawObjects( FLStylePainter * p, int xoffset, int yoffset, int &newHeight ) { MLineObject * line; MLabelObject *label; MSpecialObject *special; MCalcObject *calcfield; MFieldObject *field; // Set the offsets int xcalc = xoffset; int ycalc = yoffset; int modifiedHeight = 0; csvData_ = ""; QString fieldValue; QObject::setName( QString( "_##%1-%2" ).arg( strIdSec_ ).arg( level ) ); p->beginSection( xcalc, ycalc, width, height, this ); uint countObj = 0; // Draw the line collection for ( line = lines.first(); line != 0; line = lines.next() ) { line->QObject::setName( QString( "_##Line%1-%2" ).arg( idSec_ ).arg( countObj++ ) ); p->beginMark( line->xpos1, line->ypos1, line ); line->draw( p ); p->endMark(); } // Draw the label collection for ( label = labels.first(); label != 0; label = labels.next() ) { label->QObject::setName( QString( "_##Label%1-%2" ).arg( idSec_ ).arg( countObj++ ) ); p->beginMark( label->getX(), label->getY(), label ); modifiedHeight = label->draw( p ); p->endMark(); if ( modifiedHeight && ( label->getY() + modifiedHeight ) > height ) newHeight = label->getY() + modifiedHeight; } // Draw the calculated field collection for ( calcfield = calculatedFields.first(); calcfield != 0; calcfield = calculatedFields.next() ) { if ( !calcfield->getDrawAtHeader() ) { calcfield->QObject::setName( QString( "_##%1-Calc.%2-%3" ).arg( idSec_ ).arg( calcfield->fieldName ).arg( countObj++ ) ); p->beginMark( calcfield->getX(), calcfield->getY(), calcfield ); modifiedHeight = calcfield->draw( p ); p->endMark(); if ( modifiedHeight && ( calcfield->getY() + modifiedHeight ) > height ) newHeight = calcfield->getY() + modifiedHeight; } if ( calcfield->getCalculationType() == MCalcObject::NoOperation || calcfield->getCalculationType() == MCalcObject::CallFunction ) { fieldValue = calcfield->getText(); fieldValue.replace( "\n", "-" ); csvData_ += "|" + fieldValue; } } // Draw the special field collection for ( special = specialFields.first(); special != 0; special = specialFields.next() ) { special->QObject::setName( QString( "_##SpecialField%1-%2" ).arg( idSec_ ).arg( countObj++ ) ); p->beginMark( special->getX(), special->getY(), special ); switch ( special->getType() ) { case MSpecialObject::Date: special->setText( reportDate ); break; case MSpecialObject::PageNumber: special->setText( pageNumber ); break; } special->draw( p ); p->endMark(); } // Draw the field collection for ( field = fields.first(); field != 0; field = fields.next() ) { field->QObject::setName( QString( "_##%1.%2-%3" ).arg( idSec_ ).arg( field->fieldName ).arg( countObj++ ) ); p->beginMark( field->getX(), field->getY(), field ); modifiedHeight = field->draw( p ); p->endMark(); if ( modifiedHeight && ( field->getY() + modifiedHeight ) > height ) newHeight = field->getY() + modifiedHeight; fieldValue = field->getText(); fieldValue.replace( "\n", "-" ); csvData_ += "|" + fieldValue; } p->endSection(); }
//copyright : (C) 2002-2004 InfoSiAL S.L. //email : [email protected] void MReportEngine::drawDetail(MPageCollection *pages, int level, uint &currRecord, const int initRow, const int initCol) { currRecord_ = currRecord; QString detailValue; int nextLevel; int detailHeight = 0; MReportSection *detail = findDetail(level); MReportSection *footer; if (detail) detailHeight = detail->getHeight(); if (!canDrawDetailHeader(level, currRecord, currY)) { if (level > 0) drawAddOnFooter(pages, (level - 1), gDTFooters[(level - 1)], gDTSFooters[(level - 1)]); newPage(pages, level); // Sólo dibujamos el detail header si no hemos dibujado ya el addOnHeader if (!findAddOnHeader(level)) drawDetailHeader(pages, level); } else { drawDetailHeader(pages, level); } if (!detail) { drawDetailFooter(pages, level); return; } gDTFooters[level]->clear(); gDTSFooters[level]->clear(); int currLevel; int chkRow = 0; int loops = 0; if (initCol != 0) currX = leftMargin + (detail->getWidth() * (initCol - 1)); if (initRow != 0) currY = topMargin + (detail->getHeight() * (initRow - 1)); currLevel = level; do { QDomNode record = records.item(currRecord); if (record.nodeType() == QDomNode::ElementNode) { if (currLevel == level) { if ((chkRow = (currRecord / 2) % 20) == 0) emit signalRenderStatus(currRecord / 2); if (cancelRender) { MLabelObject lblCancel; lblCancel.setFont("Arial", 20, MLabelObject::Bold, false); lblCancel.setText(tr("INFORME INCOMPLETO\nCANCELADO POR EL USUARIO")); lblCancel.setGeometry(20, pageHeight / 2, 450, 70); lblCancel.setHorizontalAlignment(MLabelObject::Center); lblCancel.setVerticalAlignment(MLabelObject::Middle); lblCancel.draw(p); return; } QDomNamedNodeMap fields = record.attributes(); reserveSizeForCalcFields(&fields, level); detail->setPageNumber(currPage); detail->setReportDate(currDate); if (!canDrawDetail(level, currRecord, currY)) { if (loops) { drawAddOnFooter(pages, level, gDTFooters[level], gDTSFooters[level]); } else { if (level > 0) { drawAddOnFooter(pages, (level - 1), gDTFooters[(level - 1)], gDTSFooters[(level - 1)]); } } newPage(pages, level); } QDomNode record = records.item(currRecord); QDomNode *ptrRecord = &record; setFieldValues(&fields, level, detail, ptrRecord); if (detail->mustBeDrawed(ptrRecord)) { detail->setCalcFieldData(0, 0, ptrRecord, fillRecords_); int sectionHeight = detail->getHeight(); detail->draw(p, currX, currY, sectionHeight); detailHeight = sectionHeight; currX += detail->getWidth(); if (currX >= (pageWidth - rightMargin - leftMargin)) { currX = leftMargin; currY += sectionHeight; } MReportSection *rS = findDetail(level + 1); if (!rS) { for (uint i = 0; i <= level; i++) { rS = findDetailHeader(i); if (rS) csvData_ += rS->csvData(); rS = findDetail(i); if (rS) csvData_ += rS->csvData(); } csvData_ += "\n"; } } ++currRecord; } else { drawDetail(pages, currLevel, currRecord); } if (currRecord < records.count()) { record = records.item(currRecord); QDomNamedNodeMap fields = record.attributes(); detailValue = fields.namedItem("level").nodeValue(); currLevel = detailValue.toInt(); } if (cancelRender) { MLabelObject lblCancel; lblCancel.setFont("Arial", 20, MLabelObject::Bold, false); lblCancel.setText(tr("INFORME INCOMPLETO\nCANCELADO POR EL USUARIO")); lblCancel.setGeometry(20, pageHeight / 2, 450, 70); lblCancel.setHorizontalAlignment(MLabelObject::Center); lblCancel.setVerticalAlignment(MLabelObject::Middle); lblCancel.draw(p); return; } } loops++; } while (level <= currLevel && currRecord < records.count()); drawDetailFooter(pages, level, gDTFooters[level], gDTSFooters[level]); footer = findDetailFooter(level); if (footer && currRecord < records.count()) if (footer->newPage()) newPage(pages); }