コード例 #1
0
/** 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;
}
コード例 #2
0
FLReportPages *FLJasperEngine::printReportToPages()
{
  FLReportPages *pages = new FLReportPages();

  if (!d->pluginLinked())
    return pages;

  if (!d->existsJRPrintFile() && fillReport().isEmpty())
    return pages;

  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 = new MPageCollection();
  QImage img;
  QPainter pte;

  FLUtil::setTotalSteps(pageCount, d->jrprintFile_);
  pages->setPageCollection(mpages);
  pages->setPageOrientation(printMgr->pageOrientation());
  pages->setPageDimensions(QSize(printMgr->pageWidth(), printMgr->pageHeight()));
  for (int i = 0; i < pageCount; ++i) {
    mpages->appendPage();
    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();
  d->reportPages_ = pages;
  return pages;
}