18#include "KReportDocument.h"
19#include "KReportUnit.h"
20#include "KReportDetailSectionData.h"
21#include "KReportItemBase.h"
22#include "KReportUtils_p.h"
23#include "KReportPageSize.h"
26#include <QApplication>
27#include "kreport_debug.h"
36#ifdef KREPORT_SCRIPTING
41 KReportPrivate::PageLayout pageLayout;
60 KReportDetailSectionData* detailSection =
nullptr;
77 kreportWarning() <<
"QDomElement is not <report:content> tag"
83 for (
int nodeCounter = 0; nodeCounter <
sections.count(); nodeCounter++) {
86 d->title = elemThis.
text();
87#ifdef KREPORT_SCRIPTING
89 d->script = elemThis.
text();
105 d->pageLayout.setPageSize(custom);
112 QLatin1String(
"fo:margin-left"), DEFAULT_PAGE_MARGIN_STRING)));
114 QLatin1String(
"fo:margin-right"), DEFAULT_PAGE_MARGIN_STRING)));
116 QLatin1String(
"fo:margin-top"), DEFAULT_PAGE_MARGIN_STRING)));
118 QLatin1String(
"fo:margin-bottom"), DEFAULT_PAGE_MARGIN_STRING)));
119 d->pageLayout.setOrientation(
129 for (
int s = 0; s < sectionlist.
count(); ++s) {
130 sec = sectionlist.
item(s);
136 if (!sd->isValid()) {
137 kreportDebug() <<
"Invalid section";
141 switch (sd->type()) {
142 case KReportSectionData::Type::PageHeaderFirst:
143 d->pageHeaderFirst = sd;
145 case KReportSectionData::Type::PageHeaderOdd:
146 d->pageHeaderOdd = sd;
148 case KReportSectionData::Type::PageHeaderEven:
149 d->pageHeaderEven = sd;
151 case KReportSectionData::Type::PageHeaderLast:
152 d->pageHeaderLast = sd;
154 case KReportSectionData::Type::PageHeaderAny:
155 d->pageHeaderAny = sd;
157 case KReportSectionData::Type::ReportHeader:
158 d->reportHeader = sd;
160 case KReportSectionData::Type::ReportFooter:
161 d->reportFooter = sd;
163 case KReportSectionData::Type::PageFooterFirst:
164 d->pageFooterFirst = sd;
166 case KReportSectionData::Type::PageFooterOdd:
167 d->pageFooterOdd = sd;
169 case KReportSectionData::Type::PageFooterEven:
170 d->pageFooterEven = sd;
172 case KReportSectionData::Type::PageFooterLast:
173 d->pageFooterLast = sd;
175 case KReportSectionData::Type::PageFooterAny:
176 d->pageFooterAny = sd;
184 KReportDetailSectionData * dsd =
new KReportDetailSectionData(sec.
toElement(),
this);
186 if (dsd->isValid()) {
187 d->detailSection = dsd;
189 kreportDebug() <<
"Invalid detail section";
194 kreportWarning() <<
"Encountered an unknown Element: " << elemThis.
tagName();
203KReportDocument::~KReportDocument()
211 for (
int i =
static_cast<int>(KReportSectionData::Type::PageHeaderFirst);
212 i <= static_cast<int>(KReportSectionData::Type::PageFooterAny); i++)
216 obs << sec->objects();
220 if (d->detailSection) {
222 foreach(KReportDetailGroupSectionData* g, d->detailSection->groupList) {
223 if (g->groupHeader) {
224 obs << g->groupHeader->objects();
226 if (g->groupFooter) {
227 obs << g->groupFooter->objects();
230 if (d->detailSection->detailSection)
231 obs << d->detailSection->detailSection->objects();
246 if (o->entityName() == n) {
256 for (
int i =
static_cast<int>(KReportSectionData::Type::PageHeaderFirst);
257 i <= static_cast<int>(KReportSectionData::Type::PageFooterAny); i++)
265 if (d->detailSection) {
267 foreach(KReportDetailGroupSectionData* g, d->detailSection->groupList) {
268 if (g->groupHeader) {
269 secs << g->groupHeader;
271 if (g->groupFooter) {
272 secs << g->groupFooter;
275 if (d->detailSection->detailSection)
276 secs << d->detailSection->detailSection;
287 if (sec->name() == sn) {
298 case KReportSectionData::Type::PageHeaderAny:
299 sec = d->pageHeaderAny;
301 case KReportSectionData::Type::PageHeaderEven:
302 sec = d->pageHeaderEven;
304 case KReportSectionData::Type::PageHeaderOdd:
305 sec = d->pageHeaderOdd;
307 case KReportSectionData::Type::PageHeaderFirst:
308 sec = d->pageHeaderFirst;
310 case KReportSectionData::Type::PageHeaderLast:
311 sec = d->pageHeaderLast;
313 case KReportSectionData::Type::PageFooterAny:
314 sec = d->pageFooterAny;
316 case KReportSectionData::Type::PageFooterEven:
317 sec = d->pageFooterEven;
319 case KReportSectionData::Type::PageFooterOdd:
320 sec = d->pageFooterOdd;
322 case KReportSectionData::Type::PageFooterFirst:
323 sec = d->pageFooterFirst;
325 case KReportSectionData::Type::PageFooterLast:
326 sec = d->pageFooterLast;
328 case KReportSectionData::Type::ReportHeader:
329 sec = d->reportHeader;
331 case KReportSectionData::Type::ReportFooter:
332 sec = d->reportFooter;
342 return d->pageLayout;
345bool KReportDocument::isValid()
const
350QString KReportDocument::title()
const
355bool KReportDocument::externalData()
const
357 return d->externalData;
360#ifdef KREPORT_SCRIPTING
361QString KReportDocument::script()
const
366QString KReportDocument::interpreter()
const
368 return d->interpreter;
372QString KReportDocument::name()
const
377void KReportDocument::setName(
const QString& n)
382QString KReportDocument::query()
const
387QString KReportDocument::pageSize()
392void KReportDocument::setPageSize(
const QString& size)
397QString KReportDocument::labelType()
const
402void KReportDocument::setLabelType(
const QString& label)
404 d->labelType =
label;
407KReportDetailSectionData * KReportDocument::detail()
const
409 return d->detailSection;
Top level report document definition. A KReportDocment defines the design of a document,...
KReportDocument(const QDomElement &elemSource, QObject *parent=nullptr)
QList< KReportItemBase * > objects() const
QList< KReportSectionData * > sections() const
KReportItemBase * object(const QString &) const
KReportSectionData * section(KReportSectionData::Type type) const
Base class for items that are drawn syncronously.
KReportSectionData is used to store the information about a specific report section.
static qreal parseValue(const QString &value, qreal defaultVal=0.0)
Parses common KReport and ODF values, like "10cm", "5mm" to pt.
std::optional< QSqlQuery > query(const QString &queryStatement)
KREPORT_EXPORT QPageSize::PageSizeId pageSize(const QString &key)
QString name(StandardAction id)
QString label(StandardShortcut id)
QString attribute(const QString &name, const QString &defValue) const const
QString tagName() const const
QString text() const const
QDomNodeList childNodes() const const
QDomNode firstChild() const const
bool isElement() const const
QString nodeName() const const
QString nodeValue() const const
QDomElement toElement() const const
QDomNode item(int index) const const
QString toLower() const const