2
* OpenRPT report writer and rendering engine
3
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
4
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
19
#include "renderobjects.h"
25
ORODocument::ORODocument(const QString & pTitle)
30
ORODocument::~ORODocument()
32
while (!m_pages.isEmpty()) {
33
OROPage * p = m_pages.takeFirst();
39
void ORODocument::setTitle(const QString & pTitle)
44
OROPage* ORODocument::page(int pnum)
46
return m_pages.at(pnum);
49
void ORODocument::addPage(OROPage* p)
54
// check that this page is not already in another document
60
OROSection* ORODocument::section(int pnum)
62
return m_sections.at(pnum);
65
void ORODocument::addSection(OROSection* s)
70
// check that this page is not already in another document
76
void ORODocument::setPageOptions(const ReportPageOptions & options)
78
m_pageOptions = options;
84
OROPage::OROPage(ORODocument * pDocument)
85
: m_document(pDocument)
93
m_document->m_pages.removeAt(page());
97
while (!m_primitives.isEmpty()) {
98
OROPrimitive* p = m_primitives.takeFirst();
104
int OROPage::page() const
107
for (int i = 0; i < m_document->m_pages.size(); i++) {
108
if (m_document->m_pages.at(i) == this)
115
OROPrimitive* OROPage::primitive(int idx)
117
return m_primitives.at(idx);
120
void OROPage::addPrimitive(OROPrimitive* p, bool atBeginning)
125
// check that this primitve is not already in another page
129
m_primitives.prepend(p);
131
m_primitives.append(p);
138
OROSection::OROSection(ORODocument * pDocument)
139
: m_document(pDocument)
142
m_backgroundColor = Qt::white;
145
OROSection::~OROSection()
148
m_document->m_sections.removeAt(row());
152
while (!m_primitives.isEmpty()) {
153
OROPrimitive* p = m_primitives.takeFirst();
158
long OROSection::row() const
163
OROPrimitive* OROSection::primitive(int idx)
165
return m_primitives.at(idx);
168
void OROSection::addPrimitive(OROPrimitive* p)
173
m_primitives.append(p);
176
void OROSection::setHeight(int h)
181
int OROSection::height()
186
void OROSection::setBackgroundColor(const QColor &c)
188
m_backgroundColor = c;
191
QColor OROSection::backgroundColor()
193
return m_backgroundColor;
196
void OROSection::sortPrimatives(Sort s)
199
qSort(m_primitives.begin(), m_primitives.end(), xLessThan);
203
bool OROSection::xLessThan(OROPrimitive* s1, OROPrimitive* s2)
205
return s1->position().x() < s2->position().x();
211
OROPrimitive::OROPrimitive(int pType)
217
OROPrimitive::~OROPrimitive()
220
m_page->m_primitives.removeAt(m_page->m_primitives.indexOf(this));
225
void OROPrimitive::setPosition(const QPointF & p)
233
const int OROTextBox::TextBox = 1;
234
OROTextBox::OROTextBox()
235
: OROPrimitive(OROTextBox::TextBox)
239
m_lineStyle.lineColor = Qt::black;
240
m_lineStyle.weight = 0;
241
m_lineStyle.style = Qt::NoPen;
244
OROTextBox::~OROTextBox()
248
void OROTextBox::setSize(const QSizeF & s)
253
void OROTextBox::setText(const QString & s)
258
void OROTextBox::setTextStyle(const KRTextStyleData & ts)
263
void OROTextBox::setLineStyle(const KRLineStyleData & ls)
268
void OROTextBox::setFont(const QFont & f)
270
m_textStyle.font = f;
273
void OROTextBox::setFlags(int f)
278
OROPrimitive* OROTextBox::clone()
280
OROTextBox *theClone = new OROTextBox();
281
theClone->setSize(m_size);
282
theClone->setPosition(m_position);
283
theClone->setText(m_text);
284
theClone->setTextStyle(m_textStyle);
285
theClone->setLineStyle(m_lineStyle);
286
theClone->setFlags(m_alignment);
294
const int OROLine::Line = 2;
297
: OROPrimitive(OROLine::Line)
306
void OROLine::setStartPoint(const QPointF & p)
311
void OROLine::setEndPoint(const QPointF & p)
316
void OROLine::setLineStyle(const KRLineStyleData& ls)
322
OROPrimitive* OROLine::clone()
324
OROLine *theClone = new OROLine();
325
theClone->setStartPoint(m_position);
326
theClone->setEndPoint(m_endPoint);
327
theClone->setLineStyle(m_lineStyle);
334
const int OROImage::Image = 3;
337
: OROPrimitive(OROImage::Image)
340
m_transformFlags = Qt::FastTransformation;
341
m_aspectFlags = Qt::IgnoreAspectRatio;
344
OROImage::~OROImage()
348
void OROImage::setImage(const QImage & img)
353
void OROImage::setSize(const QSizeF & sz)
358
void OROImage::setScaled(bool b)
363
void OROImage::setTransformationMode(int tm)
365
m_transformFlags = tm;
368
void OROImage::setAspectRatioMode(int arm)
373
OROPrimitive* OROImage::clone()
375
OROImage *theClone = new OROImage();
376
theClone->setSize(m_size);
377
theClone->setPosition(m_position);
378
theClone->setImage(m_image);
379
theClone->setScaled(m_scaled);
380
theClone->setTransformationMode(m_transformFlags);
381
theClone->setAspectRatioMode(m_aspectFlags);
388
const int OROPicture::Picture = 6;
390
OROPicture::OROPicture()
391
: OROPrimitive(OROPicture::Picture)
396
OROPicture::~OROPicture()
400
void OROPicture::setSize(const QSizeF & sz)
405
OROPrimitive* OROPicture::clone()
407
OROPicture *theClone = new OROPicture();
408
theClone->setSize(m_size);
409
theClone->setPosition(m_position);
410
theClone->setPicture(m_picture);
417
const int ORORect::Rect = 4;
420
: OROPrimitive(ORORect::Rect)
428
void ORORect::setSize(const QSizeF & s)
433
void ORORect::setRect(const QRectF & r)
435
setPosition(r.topLeft());
439
void ORORect::setPen(const QPen & p)
444
void ORORect::setBrush(const QBrush & b)
449
OROPrimitive* ORORect::clone()
451
ORORect *theClone = new ORORect();
452
theClone->setSize(m_size);
453
theClone->setPosition(m_position);
454
theClone->setPen(m_pen);
455
theClone->setBrush(m_brush);
461
const int OROEllipse::Ellipse = 5;
463
OROEllipse::OROEllipse()
464
: OROPrimitive(OROEllipse::Ellipse)
468
OROEllipse::~OROEllipse()
472
void OROEllipse::setSize(const QSizeF & s)
477
void OROEllipse::setRect(const QRectF & r)
479
setPosition(r.topLeft());
483
void OROEllipse::setPen(const QPen & p)
488
void OROEllipse::setBrush(const QBrush & b)
493
OROPrimitive* OROEllipse::clone()
495
OROEllipse *theClone = new OROEllipse();
496
theClone->setSize(m_size);
497
theClone->setPosition(m_position);
498
theClone->setPen(m_pen);
499
theClone->setBrush(m_brush);
503
const int OROCheck::Check = 7;
506
: OROPrimitive(OROCheck::Check)
511
OROCheck::~OROCheck()
516
OROPrimitive* OROCheck::clone()
518
OROCheck *theClone = new OROCheck();
519
theClone->setSize(m_size);
520
theClone->setPosition(m_position);
521
theClone->setLineStyle(m_lineStyle);
522
theClone->setForegroundColor(m_fgColor);
523
theClone->setValue(m_value);