/** Renders the report as a page collection - the caller * is responsible for de-allocating the returned * collection * * copyright : (C) 2002-2008 InfoSiAL S.L. * email : [email protected] * */ MPageCollection * MReportEngine::renderReport( int initRow, int initCol ) { cancelRender = false; csvData_ = ""; p->setStyleName( styleName_ ); // Create the page collection MPageCollection *pages = new MPageCollection; // Initialize the basic page data currHeight = pageHeight - ( bottomMargin + pFooter->getHeight() ); currPage = 0; currDate = QDate::currentDate(); // Initialize the grand total array grandTotal->clear(); for ( int i = 0; i < rFooter->getCalcFieldCount(); i++ ) grandTotal->append( new QMemArray < double > ); // Create the first page startPage( pages ); unsigned int rowCount = records.length(); if ( rowCount <= 1 ) rowCount = 2; uint nRecord = 0; // Draw the details drawDetail( pages, 0, nRecord, initRow, initCol ); // Finish the last page of the report endPage( pages ); // Destroy the page painter p->painter()->end(); // Set the page collection attributes pages->setPageDimensions( QSize( pageWidth, pageHeight ) ); pages->setPageSize( pageSize ); pages->setPageOrientation( pageOrientation ); pages->setPrintToPos( printToPos ); // Send final status emit signalRenderStatus( rowCount / 2 ); return pages; }
void FLJasperEngine::updateReportPages() { if (!d->reportPages_) return; if (compileReport().isEmpty() || fillReport().isEmpty()) return; QApplication::setOverrideCursor(Qt::WaitCursor); FLUtil::createProgressDialog(tr("Cargando informe..."), 1, d->jrprintFile_); FLUtil::setProgress(0, d->jrprintFile_); AQ_JASPER_IFACE(JasperPrintManager, printMgr); printMgr->loadJasperPrint(d->jrprintFile_.local8Bit()); int pageCount = printMgr->pageCount(); QString imgFile(d->jrprintFile_ + QString::fromLatin1(".png")); MPageCollection *mpages = d->reportPages_->pageCollection(); int mPagesCount = mpages->pageCount(); QImage img; QPainter pte; FLUtil::setTotalSteps(pageCount, d->jrprintFile_); mpages->setPageOrientation(printMgr->pageOrientation()); mpages->setPageDimensions(QSize(printMgr->pageWidth(), printMgr->pageHeight())); for (int i = 0; i < pageCount; ++i) { if (i >= mPagesCount) mpages->appendPage(); else mpages->setCurrentPage(i); printMgr->printPageToImage(imgFile.local8Bit(), i, "png"); img.load(imgFile, "PNG"); pte.begin(mpages->getCurrentPage()); pte.drawImage(0, 0, img); pte.end(); QFile::remove(imgFile); FLUtil::setProgress(i + 1, d->jrprintFile_); } delete printMgr; FLUtil::destroyProgressDialog(d->jrprintFile_); QApplication::restoreOverrideCursor(); }