Changeset View
Changeset View
Standalone View
Standalone View
src/renderer/KReportPreRenderer.cpp
Show First 20 Lines • Show All 333 Lines • ▼ Show 20 Line(s) | 323 | { | |||
---|---|---|---|---|---|
334 | sec->setBackgroundColor(sectionData.backgroundColor()); | 334 | sec->setBackgroundColor(sectionData.backgroundColor()); | ||
335 | sec->setType(sectionData.type()); | 335 | sec->setType(sectionData.type()); | ||
336 | m_document->addSection(sec); | 336 | m_document->addSection(sec); | ||
337 | 337 | | |||
338 | //Render section background | 338 | //Render section background | ||
339 | ORORect* bg = new ORORect(); | 339 | ORORect* bg = new ORORect(); | ||
340 | bg->setPen(QPen(Qt::NoPen)); | 340 | bg->setPen(QPen(Qt::NoPen)); | ||
341 | bg->setBrush(sectionData.backgroundColor()); | 341 | bg->setBrush(sectionData.backgroundColor()); | ||
342 | qreal w = m_page->document()->pageOptions().pixelSize().width() - m_page->document()->pageOptions().getMarginRight() - m_leftMargin; | 342 | qreal w = m_page->document()->pageLayout().fullRectPixels(KReportDpi::dpiX()).width() - m_page->document()->pageLayout().marginsPixels(KReportDpi::dpiX()).right() - m_leftMargin; | ||
343 | 343 | | |||
344 | bg->setRect(QRectF(m_leftMargin, m_yOffset, w, sectionHeight)); | 344 | bg->setRect(QRectF(m_leftMargin, m_yOffset, w, sectionHeight)); | ||
345 | m_page->addPrimitive(bg, true); | 345 | m_page->addPrimitive(bg, true); | ||
346 | 346 | | |||
347 | QList<KReportItemBase*> objects = sectionData.objects(); | 347 | QList<KReportItemBase*> objects = sectionData.objects(); | ||
348 | foreach(KReportItemBase *ob, objects) { | 348 | foreach(KReportItemBase *ob, objects) { | ||
349 | QPointF offset(m_leftMargin, m_yOffset); | 349 | QPointF offset(m_leftMargin, m_yOffset); | ||
350 | QVariant itemData = m_kodata->value(ob->itemDataSource()); | 350 | QVariant itemData = m_kodata->value(ob->itemDataSource()); | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 405 | { | |||
408 | } | 408 | } | ||
409 | 409 | | |||
410 | if (!m_valid || !m_reportDocument) { | 410 | if (!m_valid || !m_reportDocument) { | ||
411 | return false; | 411 | return false; | ||
412 | } | 412 | } | ||
413 | 413 | | |||
414 | // Do this check now so we don't have to undo a lot of work later if it fails | 414 | // Do this check now so we don't have to undo a lot of work later if it fails | ||
415 | KReportLabelSizeInfo label; | 415 | KReportLabelSizeInfo label; | ||
416 | if (m_reportDocument->pageOptions().getPageSize() == QLatin1String("Labels")) { | 416 | if (m_reportDocument->pageSize() == QLatin1String("Labels")) { | ||
417 | label = KReportLabelSizeInfo::find(m_reportDocument->pageOptions().getLabelType()); | 417 | label = KReportLabelSizeInfo::find(m_reportDocument->labelType()); | ||
418 | if (label.isNull()) { | 418 | if (label.isNull()) { | ||
419 | return false; | 419 | return false; | ||
420 | } | 420 | } | ||
421 | } | 421 | } | ||
422 | | ||||
423 | //kreportDebug() << "Creating Document"; | 422 | //kreportDebug() << "Creating Document"; | ||
424 | m_document = new ORODocument(m_reportDocument->title()); | 423 | m_document = new ORODocument(m_reportDocument->title()); | ||
425 | 424 | | |||
426 | m_pageCounter = 0; | 425 | m_pageCounter = 0; | ||
427 | m_yOffset = 0.0; | 426 | m_yOffset = 0.0; | ||
428 | 427 | | |||
429 | //kreportDebug() << "Calculating Margins"; | 428 | //kreportDebug() << "Calculating Margins"; | ||
430 | if (!label.isNull()) { | 429 | if (!label.isNull()) { | ||
431 | if (m_reportDocument->pageOptions().isPortrait()) { | 430 | if (m_reportDocument->pageLayout().orientation() == QPageLayout::Portrait) { | ||
432 | m_topMargin = (label.startY() / 100.0); | 431 | m_topMargin = (label.startY() / 100.0); | ||
433 | m_bottomMargin = 0; | 432 | m_bottomMargin = 0; | ||
434 | m_rightMargin = 0; | 433 | m_rightMargin = 0; | ||
435 | m_leftMargin = (label.startX() / 100.0); | 434 | m_leftMargin = (label.startX() / 100.0); | ||
436 | } else { | 435 | } else { | ||
437 | m_topMargin = (label.startX() / 100.0); | 436 | m_topMargin = (label.startX() / 100.0); | ||
438 | m_bottomMargin = 0; | 437 | m_bottomMargin = 0; | ||
439 | m_rightMargin = 0; | 438 | m_rightMargin = 0; | ||
440 | m_leftMargin = (label.startY() / 100.0); | 439 | m_leftMargin = (label.startY() / 100.0); | ||
441 | } | 440 | } | ||
442 | } else { | 441 | } else { | ||
443 | m_topMargin = m_reportDocument->pageOptions().getMarginTop(); | 442 | | ||
444 | m_bottomMargin = m_reportDocument->pageOptions().getMarginBottom(); | 443 | m_topMargin = m_reportDocument->pageLayout().marginsPoints().top(); | ||
445 | m_rightMargin = m_reportDocument->pageOptions().getMarginRight(); | 444 | m_bottomMargin = m_reportDocument->pageLayout().marginsPoints().bottom(); | ||
446 | m_leftMargin = m_reportDocument->pageOptions().getMarginLeft(); | 445 | m_rightMargin = m_reportDocument->pageLayout().marginsPoints().right(); | ||
446 | m_leftMargin = m_reportDocument->pageLayout().marginsPoints().left(); | ||||
447 | //kreportDebug() << "Margins:" << m_topMargin << m_bottomMargin << m_rightMargin << m_leftMargin; | 447 | //kreportDebug() << "Margins:" << m_topMargin << m_bottomMargin << m_rightMargin << m_leftMargin; | ||
448 | } | 448 | } | ||
449 | 449 | | |||
450 | //kreportDebug() << "Calculating Page Size"; | 450 | //kreportDebug() << "Calculating Page Size"; | ||
451 | KReportPageOptions rpo(m_reportDocument->pageOptions()); | 451 | QPageLayout layout = m_reportDocument->pageLayout(); | ||
452 | // This should reflect the information of the report page size | 452 | // This should reflect the information of the report page size | ||
453 | if (m_reportDocument->pageOptions().getPageSize() == QLatin1String("Custom")) { | 453 | if (m_reportDocument->pageSize() == QLatin1String("Custom")) { | ||
454 | m_maxWidth = m_reportDocument->pageOptions().getCustomWidth(); | 454 | m_maxWidth = m_reportDocument->pageLayout().fullRectPoints().width(); | ||
455 | m_maxHeight = m_reportDocument->pageOptions().getCustomHeight(); | 455 | m_maxHeight = m_reportDocument->pageLayout().fullRectPoints().height(); | ||
456 | } else { | 456 | } else { | ||
457 | if (!label.isNull()) { | 457 | if (!label.isNull()) { | ||
458 | m_maxWidth = label.width(); | 458 | m_maxWidth = label.width(); | ||
459 | m_maxHeight = label.height(); | 459 | m_maxHeight = label.height(); | ||
460 | rpo.setPageSize(label.paper()); | 460 | m_reportDocument->pageLayout().setPageSize(QPageSize(KReportPageSize::pageSize(label.paper()))); | ||
461 | } else { | 461 | } else { | ||
462 | // lookup the correct size information for the specified size paper | 462 | // lookup the correct size information for the specified size paper | ||
463 | QSizeF pageSizePx = m_reportDocument->pageOptions().pixelSize(); | 463 | QSizeF pageSizePx = m_reportDocument->pageLayout().fullRectPixels(KReportDpi::dpiX()).size(); | ||
464 | 464 | | |||
465 | m_maxWidth = pageSizePx.width(); | 465 | m_maxWidth = pageSizePx.width(); | ||
466 | m_maxHeight = pageSizePx.height(); | 466 | m_maxHeight = pageSizePx.height(); | ||
467 | } | 467 | } | ||
468 | } | 468 | } | ||
469 | 469 | | |||
470 | if (!m_reportDocument->pageOptions().isPortrait()) { | 470 | if (m_reportDocument->pageLayout().orientation() == QPageLayout::Landscape) { | ||
471 | qreal tmp = m_maxWidth; | 471 | qreal tmp = m_maxWidth; | ||
472 | m_maxWidth = m_maxHeight; | 472 | m_maxWidth = m_maxHeight; | ||
473 | m_maxHeight = tmp; | 473 | m_maxHeight = tmp; | ||
474 | } | 474 | } | ||
475 | 475 | | |||
476 | //kreportDebug() << "Page Size:" << m_maxWidth << m_maxHeight; | 476 | //kreportDebug() << "Page Size:" << m_maxWidth << m_maxHeight; | ||
477 | 477 | | |||
478 | m_document->setPageOptions(rpo); | 478 | m_document->setPageLayout(m_reportDocument->pageLayout()); | ||
479 | m_kodata->setSorting(m_reportDocument->m_detailSection->m_sortedFields); | 479 | m_kodata->setSorting(m_reportDocument->m_detailSection->m_sortedFields); | ||
480 | if (!m_kodata->open()) { | 480 | if (!m_kodata->open()) { | ||
481 | return false; | 481 | return false; | ||
482 | } | 482 | } | ||
483 | 483 | | |||
484 | #ifdef KREPORT_SCRIPTING | 484 | #ifdef KREPORT_SCRIPTING | ||
485 | initEngine(); | 485 | initEngine(); | ||
486 | connect(m_scriptHandler, SIGNAL(groupChanged(QMap<QString, QVariant>)), | 486 | connect(m_scriptHandler, SIGNAL(groupChanged(QMap<QString, QVariant>)), | ||
Show All 27 Lines | 505 | if (!label.isNull()) { | |||
514 | qreal wg = (label.xGap() / 100.0); | 514 | qreal wg = (label.xGap() / 100.0); | ||
515 | qreal h = (label.height() / 100.0); | 515 | qreal h = (label.height() / 100.0); | ||
516 | qreal hg = (label.yGap() / 100.0); | 516 | qreal hg = (label.yGap() / 100.0); | ||
517 | int numCols = label.columns(); | 517 | int numCols = label.columns(); | ||
518 | int numRows = label.rows(); | 518 | int numRows = label.rows(); | ||
519 | qreal tmp; | 519 | qreal tmp; | ||
520 | 520 | | |||
521 | // flip the value around if we are printing landscape | 521 | // flip the value around if we are printing landscape | ||
522 | if (!m_reportDocument->pageOptions().isPortrait()) { | 522 | if (!m_reportDocument->pageLayout().orientation() == QPageLayout::Portrait) { | ||
523 | w = (label.height() / 100.0); | 523 | w = (label.height() / 100.0); | ||
524 | wg = (label.yGap() / 100.0); | 524 | wg = (label.yGap() / 100.0); | ||
525 | h = (label.width() / 100.0); | 525 | h = (label.width() / 100.0); | ||
526 | hg = (label.xGap() / 100.0); | 526 | hg = (label.xGap() / 100.0); | ||
527 | numCols = label.rows(); | 527 | numCols = label.rows(); | ||
528 | numRows = label.columns(); | 528 | numRows = label.columns(); | ||
529 | } | 529 | } | ||
530 | 530 | | |||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | |||||
613 | } | 613 | } | ||
614 | m_postProcText.clear(); | 614 | m_postProcText.clear(); | ||
615 | 615 | | |||
616 | return true; | 616 | return true; | ||
617 | } | 617 | } | ||
618 | 618 | | |||
619 | //===========================KReportPreRenderer=============================== | 619 | //===========================KReportPreRenderer=============================== | ||
620 | 620 | | |||
621 | KReportPreRenderer::KReportPreRenderer(const QDomElement & document) | 621 | KReportPreRenderer::KReportPreRenderer(const QDomElement &document) : d(new KReportPreRendererPrivate(this)) | ||
622 | : d(new KReportPreRendererPrivate(this)) | | |||
623 | { | 622 | { | ||
624 | setDocument(document); | 623 | setDocument(document); | ||
625 | connect(d, &KReportPreRendererPrivate::finishedAllASyncItems, this, &KReportPreRenderer::finishedAllASyncItems); | 624 | connect(d, &KReportPreRendererPrivate::finishedAllASyncItems, this, &KReportPreRenderer::finishedAllASyncItems); | ||
626 | | ||||
627 | } | 625 | } | ||
628 | 626 | | |||
629 | KReportPreRenderer::~KReportPreRenderer() | 627 | KReportPreRenderer::~KReportPreRenderer() | ||
630 | { | 628 | { | ||
631 | delete d; | 629 | delete d; | ||
632 | } | 630 | } | ||
633 | 631 | | |||
634 | void KReportPreRenderer::setName(const QString &n) | 632 | void KReportPreRenderer::setName(const QString &n) | ||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |