コード例 #1
0
ファイル: orprintrender.cpp プロジェクト: Wushaowei001/xtuple
bool ORPrintRender::setupPrinter(ORODocument * pDocument, QPrinter * pPrinter)
{
  if(pDocument == 0 || pPrinter == 0)
    return false;

  pPrinter->setCreator("OpenRPT Print Renderer");
  pPrinter->setDocName(pDocument->title());
  pPrinter->setFullPage(true);
  pPrinter->setOrientation((pDocument->pageOptions().isPortrait() ? QPrinter::Portrait : QPrinter::Landscape));
  pPrinter->setPageOrder(QPrinter::FirstPageFirst);

  PageSizeInfo psi = PageSizeInfo::getByName(pDocument->pageOptions().getPageSize());
  if(psi.isNull())
  {
    // TODO:
    psi = PageSizeInfo::findNearest((int)(pDocument->pageOptions().getCustomWidth() * 100), (int)(pDocument->pageOptions().getCustomHeight() * 100));
    if(psi.isNull())
      pPrinter->setPageSize(QPrinter::Custom);
    else
      pPrinter->setPageSize((QPrinter::PageSize)psi.qpValue());
  }
  else
    pPrinter->setPageSize((QPrinter::PageSize)psi.qpValue());

  return true;
}
コード例 #2
0
ファイル: orprintrender.cpp プロジェクト: dwatson78/openrpt
bool ORPrintRender::setupPrinter(ORODocument * pDocument, QPrinter * pPrinter)
{
  if(pDocument == 0 || pPrinter == 0)
    return false;

  pPrinter->setCreator("OpenRPT Print Renderer");
  pPrinter->setDocName(pDocument->title());
  pPrinter->setFullPage(true);
  pPrinter->setOrientation((pDocument->pageOptions().isPortrait() ? QPrinter::Portrait : QPrinter::Landscape));
  pPrinter->setPageOrder(QPrinter::FirstPageFirst);

  PageSizeInfo psi = PageSizeInfo::getByName(pDocument->pageOptions().getPageSize());
  if(psi.isNull())
  {
    pPrinter->setPaperSize(QSizeF(pDocument->pageOptions().getCustomWidth(), pDocument->pageOptions().getCustomHeight()), QPrinter::Inch);
  }
  else 
  {
    #if defined(Q_WS_MAC) && (QT_VERSION < 0x040801) // QTBUG-20882
      pPrinter->setPageSize((QPrinter::PageSize)psi.qpValue());
    #else
      if (pDocument->pageOptions().getPageSize() == "Custom")
        pPrinter->setPaperSize(QSizeF(psi.width()  / 100.0,
                                      psi.height() / 100.0), QPrinter::Inch);
    #endif
  }

  return true;
}