~ubuntu-branches/ubuntu/oneiric/koffice/oneiric-updates

« back to all changes in this revision

Viewing changes to kexi/plugins/reports/kexireportpage.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Kexi Report Plugin
3
 
 * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
4
 
 *
5
 
 * This library is free software; you can redistribute it and/or
6
 
 * modify it under the terms of the GNU Lesser General Public
7
 
 * License as published by the Free Software Foundation; either
8
 
 * version 2.1 of the License, or (at your option) any later version.
9
 
 *
10
 
 * This library is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
 
 * Lesser General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU Lesser General Public
16
 
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
17
 
 */
18
 
 
19
 
#include "kexireportpage.h"
20
 
#include <qwidget.h>
21
 
#include <kdebug.h>
22
 
#include <qcolor.h>
23
 
#include <qpixmap.h>
24
 
#include <KoPageFormat.h>
25
 
#include <KoUnit.h>
26
 
#include <KoGlobal.h>
27
 
 
28
 
#include <renderobjects.h>
29
 
#include <QPainter>
30
 
 
31
 
KexiReportPage::KexiReportPage(QWidget *parent, ORODocument *document)
32
 
        : QWidget(parent)
33
 
{
34
 
    setAttribute(Qt::WA_NoBackground);
35
 
    kDebug() << "CREATED PAGE";
36
 
    m_reportDocument = document;
37
 
    m_page = 1;
38
 
    int pageWidth = 0;
39
 
    int pageHeight = 0;
40
 
 
41
 
    if (m_reportDocument) {
42
 
        QString pageSize = m_reportDocument->pageOptions().getPageSize();
43
 
 
44
 
 
45
 
        if (pageSize == "Custom") {
46
 
            // if this is custom sized sheet of paper we will just use those values
47
 
            pageWidth = (int)(m_reportDocument->pageOptions().getCustomWidth());
48
 
            pageHeight = (int)(m_reportDocument->pageOptions().getCustomHeight());
49
 
        } else {
50
 
            // lookup the correct size information for the specified size paper
51
 
            pageWidth = m_reportDocument->pageOptions().widthPx();
52
 
            pageHeight = m_reportDocument->pageOptions().heightPx();
53
 
        }
54
 
    }
55
 
 
56
 
    setFixedSize(pageWidth, pageHeight);
57
 
 
58
 
    kDebug() << "PAGE IS " << pageWidth << "x" << pageHeight;
59
 
    m_repaint = true;
60
 
    m_pixmap = new QPixmap(pageWidth, pageHeight);
61
 
    setAutoFillBackground(true);
62
 
 
63
 
    m_renderer = m_factory.createInstance("screen");
64
 
 
65
 
    renderPage(1);
66
 
}
67
 
 
68
 
KexiReportPage::~KexiReportPage()
69
 
{
70
 
    delete m_renderer;
71
 
    m_renderer = 0;
72
 
}
73
 
 
74
 
void KexiReportPage::paintEvent(QPaintEvent*)
75
 
{
76
 
    QPainter painter(this);
77
 
    painter.drawPixmap(QPoint(0, 0), *m_pixmap);
78
 
}
79
 
 
80
 
void KexiReportPage::renderPage(int page)
81
 
{
82
 
    kDebug() << page;
83
 
//js: is m_page needed?
84
 
    m_page = page;
85
 
    m_pixmap->fill();
86
 
    QPainter qp(m_pixmap);
87
 
    if (m_reportDocument) {
88
 
        KoReportRendererContext cxt;
89
 
        cxt.painter = &qp;
90
 
        m_renderer->render(cxt, m_reportDocument, m_page - 1);
91
 
    }
92
 
    m_repaint = true;
93
 
    repaint();
94
 
}
95
 
 
96
 
#include "kexireportpage.moc"