18 #include "KReportRenderObjects.h"
19 #include "KReportUtils_p.h"
21 #include "kreport_debug.h"
26 return s1->position().
x() < s2->position().
x();
41 KReportPrivate::PageLayout pageLayout;
44 ORODocument::Private::Private()
49 ORODocument::Private::~Private()
56 ORODocument::ORODocument(
const QString& title) : d(new Private())
61 ORODocument::~ORODocument()
66 void ORODocument::setTitle(
const QString &title)
73 return d->pages.value(index);
78 return d->pages.value(index);
87 if (p->document() !=
nullptr && p->document() !=
this) {
97 return d->sections.value(pnum);
102 return d->sections.value(index);
111 if (s->document() !=
nullptr && s->document() !=
this) {
114 s->setDocument(
this);
115 d->sections.append(s);
118 void ORODocument::setPageLayout(
const QPageLayout & options)
120 d->pageLayout = options;
123 void ORODocument::notifyChange(
int pageNo)
125 emit(updated(pageNo));
130 return d->pageLayout;
135 return d->pages.count();
140 return d->sections.count();
143 QString ORODocument::title()
const
150 d->pages.removeOne(
page);
156 d->pages.removeOne(
page);
161 d->sections.removeOne(
section);
167 d->sections.removeOne(
section);
172 return d->pages.indexOf(
const_cast<OROPage*
>(
page));
178 class Q_DECL_HIDDEN
OROPage::Private
187 OROPage::Private::Private()
191 OROPage::Private::~Private()
193 qDeleteAll(primitives);
199 d->document = pDocument;
205 d->document->takePage(
this);
210 int OROPage::pageNumber()
const
213 return d->document->pageIndex(
this);
220 return d->primitives.value(index);
223 const OROPrimitive * OROPage::primitive(
int index)
const
225 return d->primitives.value(index);
229 void OROPage::insertPrimitive(
OROPrimitive* p,
int index)
237 d->primitives.append(p);
239 d->primitives.insert(index, p);
246 d->document->notifyChange(pageNumber());
262 int OROPage::primitiveCount()
const
264 return d->primitives.count();
274 d->primitives.removeOne(primitive);
280 d->primitives.removeOne(primitive);
296 KReportSectionData::Type
type = KReportSectionData::Type::None;
300 OROSection::Private::Private()
305 OROSection::Private::~Private()
307 qDeleteAll(primitives);
311 OROSection::OROSection(
ORODocument* doc) : d(new Private())
316 OROSection::~OROSection()
319 d->document->takeSection(
this);
327 return d->primitives.value(index);
330 const OROPrimitive * OROSection::primitive(
int index)
const
332 return d->primitives.value(index);
337 if (primitive ==
nullptr)
340 d->primitives.append(primitive);
343 void OROSection::setHeight(
int h)
348 int OROSection::height()
const
353 void OROSection::setBackgroundColor(
const QColor& color)
355 d->backgroundColor = color;
358 QColor OROSection::backgroundColor()
const
360 return d->backgroundColor;
366 std::sort(d->primitives.begin(), d->primitives.end(), xLessThan);
381 int OROSection::primitiveCount()
const
383 return d->primitives.count();
386 void OROSection::setType(KReportSectionData::Type type)
391 KReportSectionData::Type OROSection::type()
const
413 OROPrimitive::OROPrimitive()
418 OROPrimitive::~OROPrimitive()
421 d->page->takePrimitive(
this);
427 void OROPrimitive::setPosition(
const QPointF& pos)
432 void OROPrimitive::setSize(
const QSizeF & s)
442 const OROPage * OROPrimitive::page()
const
447 QPointF OROPrimitive::position()
const
452 QSizeF OROPrimitive::size()
const
457 void OROPrimitive::setPage(
OROPage* page)
472 KReportTextStyleData textStyle;
478 bool requiresPostProcessing;
482 OROTextBox::Private::Private()
487 requiresPostProcessing =
false;
490 lineStyle.setWeight(0);
494 OROTextBox::Private::~Private()
498 OROTextBox::OROTextBox() : d(new Private())
503 OROTextBox::~OROTextBox()
508 void OROTextBox::setText(
const QString & s)
513 void OROTextBox::setTextStyle(
const KReportTextStyleData & ts)
523 void OROTextBox::setFont(
const QFont & f)
525 d->textStyle.font = f;
528 void OROTextBox::setFlags(
int f)
533 bool OROTextBox::canGrow()
const
538 int OROTextBox::flags()
const
548 bool OROTextBox::requiresPostProcessing()
const
550 return d->requiresPostProcessing;
553 void OROTextBox::setCanGrow(
bool grow)
558 void OROTextBox::setRequiresPostProcessing(
bool pp)
560 d->requiresPostProcessing = pp;
563 void OROTextBox::setWordWrap(
bool ww)
568 QString OROTextBox::text()
const
573 KReportTextStyleData OROTextBox::textStyle()
const
578 bool OROTextBox::wordWrap()
const
586 theClone->setSize(size());
587 theClone->setPosition(position());
588 theClone->setText(text());
589 theClone->setTextStyle(textStyle());
590 theClone->setLineStyle(lineStyle());
591 theClone->setFlags(flags());
592 theClone->setCanGrow(canGrow());
593 theClone->setWordWrap(wordWrap());
594 theClone->setRequiresPostProcessing(requiresPostProcessing());
603 class Q_DECL_HIDDEN
OROLine::Private
610 OROLine::OROLine() : d(new Private())
620 void OROLine::setStartPoint(
const QPointF & p)
625 void OROLine::setEndPoint(
const QPointF & p)
632 d->lineStyle = style;
635 QPointF OROLine::endPoint()
const
648 theClone->setStartPoint(position());
649 theClone->setEndPoint(endPoint());
650 theClone->setLineStyle(lineStyle());
658 class Q_DECL_HIDDEN
OROImage::Private
667 OROImage::OROImage() : d(new Private())
674 OROImage::~OROImage()
679 void OROImage::setImage(
const QImage & img)
684 void OROImage::setScaled(
bool b)
691 d->transformFlags = transformation;
696 d->aspectFlags = aspectRatioMode;
701 return d->aspectFlags;
704 QImage OROImage::image()
const
709 bool OROImage::isScaled()
const
716 return d->transformFlags;
722 theClone->setSize(size());
723 theClone->setPosition(position());
724 theClone->setImage(image());
725 theClone->setScaled(isScaled());
726 theClone->setTransformationMode(transformationMode());
727 theClone->setAspectRatioMode(aspectRatioMode());
741 OROPicture::OROPicture() : d(new Private())
746 OROPicture::~OROPicture()
754 theClone->setSize(size());
755 theClone->setPosition(position());
765 void OROPicture::setPicture(
const QPicture& p)
774 class Q_DECL_HIDDEN
ORORect::Private
781 ORORect::ORORect() : d(new Private())
790 void ORORect::setRect(
const QRectF & r)
796 void ORORect::setPen(
const QPen & p)
801 void ORORect::setBrush(
const QBrush & b)
806 QBrush ORORect::brush()
const
811 QPen ORORect::pen()
const
816 QRectF ORORect::rect()
const
818 return QRectF(position(), size());
824 theClone->setSize(size());
825 theClone->setPosition(position());
826 theClone->setPen(pen());
827 theClone->setBrush(brush());
841 OROEllipse::OROEllipse() : d(new Private())
845 OROEllipse::~OROEllipse()
850 void OROEllipse::setRect(
const QRectF & r)
856 void OROEllipse::setPen(
const QPen & p)
861 void OROEllipse::setBrush(
const QBrush & b)
866 QBrush OROEllipse::brush()
const
871 QPen OROEllipse::pen()
const
876 QRectF OROEllipse::rect()
const
878 return QRectF(position(), size());
884 theClone->setSize(size());
885 theClone->setPosition(position());
886 theClone->setPen(pen());
887 theClone->setBrush(brush());
898 OROCheckBox::Type checkType;
904 OROCheckBox::OROCheckBox() : d(new Private())
909 OROCheckBox::~OROCheckBox()
914 OROCheckBox::Type OROCheckBox::checkType()
const
919 QColor OROCheckBox::foregroundColor()
const
921 return d->foregroundColor;
929 void OROCheckBox::setForegroundColor(
const QColor& fg)
931 d->foregroundColor = fg;
939 void OROCheckBox::setValue(
bool v)
944 bool OROCheckBox::value()
const
949 void OROCheckBox::setCheckType(Type type)
951 if (type == Type::Cross || type == Type::Tick || type == Type::Dot) {
954 d->checkType = Type::Cross;
961 theClone->setSize(size());
962 theClone->setPosition(position());
963 theClone->setLineStyle(lineStyle());
964 theClone->setForegroundColor(foregroundColor());
965 theClone->setValue(value());
966 theClone->setCheckType(checkType());