diff --git a/src/common/KReportData.cpp b/src/common/KReportData.cpp index 785f8941..74ccf11d 100644 --- a/src/common/KReportData.cpp +++ b/src/common/KReportData.cpp @@ -1,84 +1,152 @@ /* This file is part of the KDE project * Copyright (C) 2007-2010 by Adam Pigg (adam@piggz.co.uk) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "KReportData.h" #include -KReportData::~KReportData() +class KReportData::SortedField::Private { -} + +public: + QString field; + Qt::SortOrder order = Qt::AscendingOrder; +}; + +class KReportData::Private +{ +public: + bool dummy = true; +}; + +//==========KReportData::SortedField========== KReportData::SortedField::SortedField() - : order(Qt::AscendingOrder) + : d(new Private()) +{ +} + +KReportData::SortedField::~SortedField() +{ + delete d; +} + +KReportData::SortedField & KReportData::SortedField::operator=(const KReportData::SortedField& other) +{ + if (this != &other) { + setField(other.field()); + setOrder(other.order()); + } + return *this; +} + +QString KReportData::SortedField::field() +{ + return d->field; +} + +QString KReportData::SortedField::field() const +{ + return d->field; +} + +Qt::SortOrder KReportData::SortedField::order() +{ + return d->order; +} + +Qt::SortOrder KReportData::SortedField::order() const +{ + return d->order; +} + +void KReportData::SortedField::setField(const QString& field) +{ + d->field = field; +} + +void KReportData::SortedField::setOrder(Qt::SortOrder order) +{ + d->order = order; +} + + +//==========KReportData========== + +KReportData::KReportData() : d(new Private()) +{ +} + +KReportData::~KReportData() { + delete d; } QStringList KReportData::fieldKeys() const { return fieldNames(); } QString KReportData::sourceName() const { return QString(); } QString KReportData::sourceClass() const { return QString(); } void KReportData::setSorting(const QList &sorting) { Q_UNUSED(sorting); } void KReportData::addExpression(const QString &field, const QVariant &value, char relation) { Q_UNUSED(field); Q_UNUSED(value); Q_UNUSED(relation); } #ifdef KREPORT_SCRIPTING QStringList KReportData::scriptList() const { return QStringList(); } QString KReportData::scriptCode(const QString &script) const { Q_UNUSED(script); return QString(); } #endif QStringList KReportData::dataSources() const { return QStringList(); } QStringList KReportData::dataSourceNames() const { return dataSources(); } KReportData* KReportData::create(const QString &source) const { Q_UNUSED(source); return 0; } diff --git a/src/common/KReportData.h b/src/common/KReportData.h index 8b2704b1..460d9202 100644 --- a/src/common/KReportData.h +++ b/src/common/KReportData.h @@ -1,122 +1,138 @@ /* This file is part of the KDE project * Copyright (C) 2007-2010 by Adam Pigg (adam@piggz.co.uk) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef KREPORTDATA_H #define KREPORTDATA_H #include #include #include "kreport_export.h" #include "config-kreport.h" /** @brief Abstraction of report data source */ class KREPORT_EXPORT KReportData { public: + KReportData(); virtual ~KReportData(); //! Describes sorting for single field /*! By default the order is ascending. */ class KREPORT_EXPORT SortedField { public: SortedField(); - QString field; - Qt::SortOrder order; + ~SortedField(); + SortedField& operator=(const SortedField &other); + void setField(const QString &field); + void setOrder(Qt::SortOrder order); + QString field() const; + QString field(); + Qt::SortOrder order() const; + Qt::SortOrder order(); + + private: + class Private; + Private * const d; }; //! Open the dataset virtual bool open() = 0; //! Close the dataset virtual bool close() = 0; //! Move to the next record virtual bool moveNext() = 0; //! Move to the previous record virtual bool movePrevious() = 0; //! Move to the first record virtual bool moveFirst() = 0; //! Move to the last record virtual bool moveLast() = 0; //! Return the current position in the dataset virtual qint64 at() const = 0; //! Return the total number of records virtual qint64 recordCount() const = 0; //! Return the index number of the field given by nane field virtual int fieldNumber(const QString &field) const = 0; //! Return the list of field names virtual QStringList fieldNames() const = 0; //! Return the list of field keys. Returns fieldNames() by default virtual QStringList fieldKeys() const; //! Return the value of the field at the given position for the current record virtual QVariant value(unsigned int) const = 0; //! Return the value of the field fir the given name for the current record virtual QVariant value(const QString &field) const = 0; //! Return the name of this source virtual QString sourceName() const; //! @return the class name of this source virtual QString sourceClass() const; //! Sets the sorting for the data //! Should be called before open() so that the data source can be edited accordingly //! Default impl does nothing virtual void setSorting(const QList &sorting); //! Adds an expression to the data source virtual void addExpression(const QString &field, const QVariant &value, char relation = '='); //! Utility Functions //! @todo These are probably eligable to be moved into a new class #ifdef KREPORT_SCRIPTING //! Allow the reportdata implementation to return a list of possible scripts virtual QStringList scriptList() const; //! Allow the reportdata implementation to return some script code based on a specific script name //! as set in the report virtual QString scriptCode(const QString& script) const; #endif //! Return a list of data sources possible for advanced controls virtual QStringList dataSources() const; //! Return a list of data source names possible for advanced controls. //! Returns dataSources() by default virtual QStringList dataSourceNames() const; //! Creates a new instance with data source. Default implementation returns @c nullptr. //! @a source is implementation-specific identifier. //! Owner of the returned pointer is the caller. virtual KReportData* create(const QString &source) const Q_REQUIRED_RESULT; + +private: + Q_DISABLE_COPY(KReportData) + class Private; + Private * const d; }; #endif diff --git a/src/common/KReportDesign.cpp b/src/common/KReportDesign.cpp index 8e6ea707..26378d3a 100644 --- a/src/common/KReportDesign.cpp +++ b/src/common/KReportDesign.cpp @@ -1,185 +1,267 @@ /* This file is part of the KDE project * Copyright (C) 2001-2007 by OpenMFG, LLC * Copyright (C) 2007-2010 by Adam Pigg * Copyright (C) 2011-2015 Jarosław Staniek * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "KReportDesign.h" #include "KReportDesign_p.h" #include "KReportElement.h" #include "KReportUnit.h" #include "KReportUtils.h" #include "KReportPluginManager.h" #include "KReportPluginInterface.h" #include #include #include #include -KReportDesignReadingStatus::KReportDesignReadingStatus() - : lineNumber(-1), columnNumber(-1) +class Q_DECL_HIDDEN KReportDesignReadingStatus::Private { +public: + QString errorMessage; + QString errorDetails; + int errorLineNumber = -1; + int errorColumnNumber = -1; +}; + +KReportDesignReadingStatus::KReportDesignReadingStatus() : d(new Private) +{ +} + +KReportDesignReadingStatus::~KReportDesignReadingStatus() +{ + delete d; +} + +KReportDesignReadingStatus::KReportDesignReadingStatus(const KReportDesignReadingStatus& other) : d(new Private) +{ + *this = other; +} + +KReportDesignReadingStatus& KReportDesignReadingStatus::operator=(const KReportDesignReadingStatus &other) +{ + if (this != &other) { + setErrorMessage(other.errorMessage()); + setErrorDetails(other.errorDetails()); + setErrorLineNumber(other.errorLineNumber()); + setErrorColumnNumber(other.errorColumnNumber()); + } + + return *this; } + bool KReportDesignReadingStatus::isError() const { - return lineNumber >= 0; + return d->errorLineNumber >= 0 && d->errorColumnNumber >= 0; +} + +int KReportDesignReadingStatus::errorColumnNumber() const +{ + return d->errorColumnNumber; +} + +QString KReportDesignReadingStatus::errorDetails() const +{ + return d->errorDetails; +} + +QString KReportDesignReadingStatus::errorMessage() const +{ + return d->errorMessage; +} + + +int KReportDesignReadingStatus::errorLineNumber() const +{ + return d->errorLineNumber; +} + +void KReportDesignReadingStatus::setErrorColumnNumber(int column) +{ + d->errorColumnNumber = column; +} + +void KReportDesignReadingStatus::setErrorDetails(const QString& details) +{ + d->errorDetails = details; +} + +void KReportDesignReadingStatus::setErrorLineNumber(int line) +{ + d->errorLineNumber = line; +} + +void KReportDesignReadingStatus::setErrorMessage(const QString& msg) +{ + d->errorMessage = msg; } QDebug operator<<(QDebug dbg, const KReportDesignReadingStatus& status) { if (status.isError()) { dbg.nospace() << qPrintable( QString::fromLatin1("KReportDesignReadingStatus: errorMessage=\"%1\" " "errorDetails=\"%2\" line=%3 column=%4") - .arg(status.errorMessage).arg(status.errorDetails) - .arg(status.lineNumber).arg(status.columnNumber)); + .arg(status.errorMessage()).arg(status.errorDetails()) + .arg(status.errorLineNumber()).arg(status.errorColumnNumber())); } else { dbg.nospace() << "KReportDesignReadingStatus: OK"; } return dbg.space(); } //----------------------------------- KReportDesign::KReportDesign() : d(new Private(this)) { } KReportDesign::~KReportDesign() { delete d; } bool KReportDesign::setContent(const QString &text, KReportDesignReadingStatus *status) { QDomDocument doc; - if (!doc.setContent(text, status ? &status->errorDetails : 0, status ? &status->lineNumber : 0, - status ? &status->columnNumber : 0)) + QString errorDetails; + int errorLine; + int errorColumn; + + if (!doc.setContent(text, &errorDetails, &errorLine, &errorColumn)) { if (status) { - status->errorMessage = tr("Could not parse XML document."); + status->setErrorMessage(tr("Could not parse XML document.")); + status->setErrorDetails(errorDetails); + status->setErrorLineNumber(errorLine); + status->setErrorColumnNumber(errorColumn); } return false; } - return d->processDocument(doc, status); + bool ret = d->processDocument(doc, status); + if (!ret && status) { + status->setErrorMessage(tr("Error in XML document.")); + } + return ret; } QString KReportDesign::toString(int indent) const { Q_UNUSED(indent); //! @todo return QString(); } QPageLayout KReportDesign::pageLayout() const { return d->pageLayout; } QString KReportDesign::title() const { return d->title; } void KReportDesign::setTitle(const QString &title) { d->title = title; } void KReportDesign::setPageLayout(const QPageLayout &pageLayout) { d->pageLayout = pageLayout; d->pageLayout.setUnits(QPageLayout::Point); } KReportElement KReportDesign::createElement(const QString &typeName, QString *errorMessage) { QDomElement el; KReportDesignReadingStatus status; KReportPluginInterface* plugin = d->findPlugin(typeName, el, &status); if (!plugin) { if (errorMessage) { - *errorMessage = status.errorMessage; + *errorMessage = status.errorMessage(); } return KReportElement(); } return plugin->createElement(); } bool KReportDesign::hasSection(KReportSection::Type type) const { const int index = type - 1; if (0 <= index && index < d->sections.length()) { return d->sections[index]; } return false; } KReportSection KReportDesign::section(KReportSection::Type type) const { const int index = type - 1; if (0 <= index && index < d->sections.length()) { KReportSection *section = d->sections[index]; if (section) { return *section; } } return KReportSection(); } void KReportDesign::addSection(const KReportSection §ion) { const int index = section.type() - 1; if (0 <= index && index < d->sections.length()) { if (d->sections[index]) { *d->sections[index] = section; } else { d->sections[index] = new KReportSection(section); } } } // static QPageLayout KReportDesign::defaultPageLayout() { QPageLayout layout = KReportDesignGlobal::self()->defaultPageLayout; if (!layout.pageSize().isValid()) { if (!QPrinterInfo::defaultPrinter().isNull()) { layout.setPageSize(QPrinterInfo::defaultPrinter().defaultPageSize()); } else { layout.setPageSize(QPageSize(DEFAULT_PAGE_SIZE)); } } return layout; } // static void KReportDesign::setDefaultPageLayout(const QPageLayout &pageLayout) { KReportDesignGlobal::self()->defaultPageLayout = pageLayout; KReportDesignGlobal::self()->defaultPageLayout.setUnits(QPageLayout::Point); } #ifdef KREPORT_SCRIPTING QString KReportDesign::script() const { return d->script; } #endif diff --git a/src/common/KReportDesign.h b/src/common/KReportDesign.h index c03dbce0..b3f12360 100644 --- a/src/common/KReportDesign.h +++ b/src/common/KReportDesign.h @@ -1,139 +1,152 @@ /* This file is part of the KDE project * Copyright (C) 2007-2010 by Adam Pigg * Copyright (C) 2011-2015 Jarosław Staniek * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef KREPORTDESIGN_H #define KREPORTDESIGN_H #include "kreport_export.h" #include "config-kreport.h" #include "KReportSection.h" #include class QPageSize; class QMarginsF; class QPageLayout; class KReportElement; //! The KReportDesignReadStatus represents status of reading a report design in .kreport format. /*! It is used by KReportDesign::setContent(). */ class KREPORT_EXPORT KReportDesignReadingStatus { public: //! Creates an empty status object. /*! For empty status objects isError() returns false. */ KReportDesignReadingStatus(); + ~KReportDesignReadingStatus(); + KReportDesignReadingStatus(const KReportDesignReadingStatus &other); + KReportDesignReadingStatus& operator=(const KReportDesignReadingStatus &other); + //! @return true if the status is error. - //! Equivalent of lineNumber >= 0. + //! Equivalent of errorLineNumber() >= 0 && errorColumnNumber() >= 0. bool isError() const; - + //! Error message suitable for displaying to the user, translated. - QString errorMessage; - - //! Detailed error message, partially translated. - QString errorDetails; - + QString errorMessage() const; + + //! Detailed error message, partially translated. + QString errorDetails() const; + //! Line number (counting from 0) in which the error occured. -1 if there is no error. - int lineNumber; - + int errorLineNumber() const; + //! Column number (counting from 0) in which the error occured. -1 if there is no error. - int columnNumber; + int errorColumnNumber() const; + + void setErrorMessage(const QString& msg); + void setErrorDetails(const QString& details); + void setErrorLineNumber(int line); + void setErrorColumnNumber(int column); + +private: + class Private; + Private * const d; }; //! Sends information about the reading status @a status to debug output @a dbg. KREPORT_EXPORT QDebug operator<<(QDebug dbg, const KReportDesignReadingStatus& status); //! The KReportDesign class represents a report design in .kreport format class KREPORT_EXPORT KReportDesign { Q_DECLARE_TR_FUNCTIONS(KReportDesign) public: KReportDesign(); ~KReportDesign(); //! Reads the XML document in .kreport format from the string @a text //! @return true if the content was successfully parsed //! On failure false is returned and if @a status is provided, it is updated accordingly. bool setContent(const QString &text, KReportDesignReadingStatus *status = 0); //! Converts the report document back to its textual representation. QString toString(int indent = 1) const; //! @return title for this design QString title() const; //! Sets title for this design to @a title void setTitle(const QString &title); //! @return page layout for this design QPageLayout pageLayout() const; //! Sets the page layout to @a pageLayout //! @note Calling this method does not alter page layouts of existing KReportDesign objects. void setPageLayout(const QPageLayout &pageLayout); //! @return true if this design has section defined of type @a type bool hasSection(KReportSection::Type type) const; //! @return section of type @a type KReportSection section(KReportSection::Type type) const; //! Add section @a section. Previous section of the same type is removed from this design. void addSection(const KReportSection §ion); //! Creates and returns report element of type @a typeName //! On success @a errorMessage is cleared, on failure it is set to a nonempty value. KReportElement createElement(const QString &typeName, QString *errorMessage); //! @return default page layout that is used for creating new report designs /*! Attributes that are specified in the design format: - margins: by default equal to equivalent of 1cm in points (QPageLayout::Point). - mode: by default QPageLayout::StandardMode - orientation: by default QPageLayout::Portrait - pageSize: by default equal to default page size of the default printer (QPrinterInfo::defaultPrinter().defaultPageSize()). If there is no default printer, A4 size is used. Passing invalid page size restores defaults explained in documentation of QPageLayout defaultPageLayout(). @todo For KDE Plasma use information from the Locale by using readConfigNumEntry("PageSize", QPrinter::A4, m_pageSize, QPrinter::PageSize) from KLocalePrivate::initFormat() (klocale_kde.cpp) Other attributes are ignored by the design format. In particular units for margins and pageSize are always QPageLayout::Point. */ static QPageLayout defaultPageLayout(); //! Sets default page layout to @a pageLayout //! This information is used when a new report design is created. static void setDefaultPageLayout(const QPageLayout &pageLayout); #ifdef KREPORT_SCRIPTING //! @return text of the script program QString script() const; #endif private: Q_DISABLE_COPY(KReportDesign) class Private; Private * const d; }; #endif // KREPORTDESIGN_H diff --git a/src/common/KReportDesign_p.cpp b/src/common/KReportDesign_p.cpp index c4d3e997..ff0f9335 100644 --- a/src/common/KReportDesign_p.cpp +++ b/src/common/KReportDesign_p.cpp @@ -1,461 +1,458 @@ /* This file is part of the KDE project * Copyright (C) 2001-2007 by OpenMFG, LLC * Copyright (C) 2007-2010 by Adam Pigg * Copyright (C) 2011-2015 Jarosław Staniek * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "KReportDesign_p.h" #include "KReportElement.h" #include "KReportUtils.h" #include "KReportPluginManager.h" #include "KReportPluginInterface.h" #include #include #include #include KReportDesign::Private::Private(KReportDesign *design) : q(design) , showGrid(DEFAULT_SHOW_GRID) , snapToGrid(DEFAULT_SNAP_TO_GRID) , gridDivisions(DEFAULT_GRID_DIVISIONS) , pageUnit(DEFAULT_UNIT) , sections(KReportSection::Detail) { memset(static_cast(sections.data()), 0, sizeof(void*) * sections.length()); pageLayout.setUnits(QPageLayout::Point); // initializate because of https://bugreports.qt.io/browse/QTBUG-47551 } KReportDesign::Private::~Private() { qDeleteAll(sections); } KReportDesignGlobal::KReportDesignGlobal() : defaultSectionHeight(CM_TO_POINT(2.0)) , defaultSectionBackgroundColor(Qt::white) { defaultPageLayout.setUnits(QPageLayout::Point); defaultPageLayout.setMargins(QMarginsF(DEFAULT_PAGE_MARGIN, DEFAULT_PAGE_MARGIN, DEFAULT_PAGE_MARGIN, DEFAULT_PAGE_MARGIN)); defaultPageLayout.setMode(QPageLayout::StandardMode); defaultPageLayout.setOrientation(DEFAULT_PAGE_ORIENTATION); } KReportSection::Type KReportDesignGlobal::sectionType(const QString& typeName) { initSectionTypes(); return sectionTypesForName.value(typeName); // returns InvalidType for invalid name } QString KReportDesignGlobal::sectionTypeName(KReportSection::Type sectionType) { initSectionTypes(); return sectionTypeNames.value(sectionType); } void KReportDesignGlobal::initSectionTypes() { if (!sectionTypesForName.isEmpty()) { return; } for (const SectionTypeInfo *info = sectionTypes; info->name; ++info) { sectionTypesForName.insert(QString::fromLatin1(info->name), info->type); sectionTypeNames.insert(info->type, QString::fromLatin1(info->name)); } } const KReportDesignGlobal::SectionTypeInfo KReportDesignGlobal::sectionTypes[] = { { KReportSection::InvalidType, "" }, { KReportSection::PageHeaderAny, "header-page-any" }, { KReportSection::PageHeaderEven, "header-page-even" }, { KReportSection::PageHeaderOdd, "header-page-odd" }, { KReportSection::PageHeaderFirst, "header-page-first" }, { KReportSection::PageHeaderLast, "header-page-last" }, { KReportSection::PageFooterAny, "footer-page-any" }, { KReportSection::PageFooterEven, "footer-page-even" }, { KReportSection::PageFooterOdd, "footer-page-odd" }, { KReportSection::PageFooterFirst, "footer-page-first" }, { KReportSection::PageFooterLast, "footer-page-last" }, { KReportSection::ReportHeader, "header-report" }, { KReportSection::ReportFooter, "footer-report" }, { KReportSection::GroupHeader, "group-header" }, { KReportSection::GroupFooter, "group-footer" }, { KReportSection::Detail, "detail" }, { KReportSection::InvalidType, 0 } }; Q_GLOBAL_STATIC(KReportDesignGlobal, s_global) //static KReportDesignGlobal* KReportDesignGlobal::self() { return s_global; } static void setStatus(KReportDesignReadingStatus *status, const QString& details, const QDomNode &node) { if (status) { - status->errorDetails = details; - status->lineNumber = node.lineNumber() == -1 ? 0 /* mark error */ : node.lineNumber(); - status->columnNumber = node.columnNumber() == -1 ? 0 /* mark error */ : node.columnNumber(); + status->setErrorDetails(details); + status->setErrorLineNumber(node.lineNumber() == -1 ? 0 /* mark error */ : node.lineNumber()); + status->setErrorColumnNumber(node.columnNumber() == -1 ? 0 /* mark error */ : node.columnNumber()); } } static bool checkElement(const QDomNode &node, KReportDesignReadingStatus *status) { if (node.isElement()) { return true; } setStatus(status, QString::fromLatin1("Element expected inside of <%1>") .arg(node.parentNode().toElement().tagName()), node); return false; } static void setNoAttributeStatus(const QDomElement &el, const char *attrName, KReportDesignReadingStatus *status) { setStatus(status, QString::fromLatin1("Attribute \"%1\" expected inside of <%1>") .arg(QLatin1String(attrName)).arg(el.tagName()), el); } #if 0 // TODO unused for now static bool checkAttribute(const QDomElement &el, const char *attrName, KReportDesignReadingStatus *status) { if (el.hasAttribute(QLatin1String(attrName))) { return true; } setNoAttributeStatus(el, attrName, status); return false; } #endif KReportSection KReportDesign::Private::processSectionElement(const QDomElement &el, KReportDesignReadingStatus *status) { const QString sectionTypeName = KReportUtils::attr(el, "report:section-type", QString()); KReportSection::Type sectionType = s_global->sectionType(sectionTypeName); if (sectionType == KReportSection::InvalidType) { setStatus(status, QString::fromLatin1("Invalid value of report:section-type=\"%1\" in element <%2>") .arg(sectionTypeName).arg(el.tagName()), el); return KReportSection(); } KReportSection section; section.setType(sectionType); qreal height = KReportUtils::attr(el, "svg:height", -1.0); if (height >= 0.0) { section.setHeight(height); } section.setBackgroundColor(QColor(KReportUtils::attr(el, "fo:background-color", QString()))); for (QDomNode node = el.firstChild(); !node.isNull(); node = node.nextSibling()) { if (!checkElement(node, status)) { return KReportSection(); } KReportElement element = processSectionElementChild(node.toElement(), status); if (!element.rect().isValid() || (status && status->isError())) { return KReportSection(); } section.addElement(element); } return section; } KReportPluginInterface* KReportDesign::Private::findPlugin(const QString &typeName, const QDomElement &el, KReportDesignReadingStatus *status) { KReportPluginInterface* plugin = KReportPluginManager::self()->plugin(typeName); if (!plugin) { setStatus(status, QString::fromLatin1("No such plugin \"%1\"").arg(typeName), el); return 0; } return plugin; } KReportElement KReportDesign::Private::processSectionElementChild(const QDomElement &el, KReportDesignReadingStatus *status) { const QByteArray name = el.tagName().toLatin1(); const char* elNamespace = "report:"; if (!name.startsWith(elNamespace)) { unexpectedElement(el, status); return KReportElement(); } const QByteArray reportElementName = name.mid(qstrlen(elNamespace)); //qDebug() << "Found Report Element:" << reportElementName; KReportPluginInterface *plugin = findPlugin(QLatin1String(reportElementName), el, status); if (!plugin) { return KReportElement(); } KReportElement element = plugin->createElement(); if (!plugin->loadElement(&element, el, status)) { return KReportElement(); } element.setName(KReportUtils::attr(el, "report:name", QString())); if (element.name().isEmpty()) { setNoAttributeStatus(el, "report:name", status); return KReportElement(); } return element; } bool KReportDesign::Private::processGroupElement(const QDomElement &el, KReportDesignReadingStatus *status) { Q_UNUSED(el); Q_UNUSED(status); //! @todo return true; } //! The report:detail element contains a single report:section child of type 'detail' //! and 0 or more report:group children. bool KReportDesign::Private::processDetailElement(const QDomElement &el, KReportDesignReadingStatus *status) { QDomElement sectionEl; for (QDomNode node = el.firstChild(); !node.isNull(); node = node.nextSibling()) { if (!checkElement(node, status)) { return false; } QDomElement childEl = node.toElement(); const QByteArray name = childEl.tagName().toLatin1(); if (name == "report:section") { if (!sectionEl.isNull()) { return false; } KReportSection section = processSectionElement(childEl, status); if (status && status->isError()) { return false; } if (section.type() != KReportSection::Detail) { setStatus(status, QString::fromLatin1("Only section of type \"detail\" allowed in "), el); return false; } q->addSection(section); } else if (name == "report:group") { if (!processGroupElement(childEl, status)) { return false; } } else { unexpectedElement(childEl, status); return false; } } // finally make sure we have one report:section (void)requiredChildElement(el, "report:section", status); if (status && status->isError()) { return false; } return true; } /*!
        
         *.. (up to 12 sections)
          
             // any number of groups
              *.. (group-header, group-footer)
            
          
        
     
 */
 bool KReportDesign::Private::processBodyElementChild(const QDomElement &el,
                                                      KReportDesignReadingStatus *status)
 {
     const QByteArray name = el.tagName().toLatin1();
     //kreportDebug() << name;
     if (name == "report:section") {
         KReportSection section = processSectionElement(el, status);
         if (status && status->isError()) {
             return false;
         }
         if (q->hasSection(section.type())) {
             setStatus(status, QString::fromLatin1("Could not add two sections of type \"%1\" "
                                                   "to the same report design")
                                 .arg(s_global->sectionTypeName(section.type())), el);
             return false;
         }
         if (section.type() == KReportSection::Detail) {
             setStatus(status,
                 QString::fromLatin1("Section of type \"detail\" not allowed in "), el);
             return false;
         }
         q->addSection(section);
 #if 0 //TODO
         if (section(KReportSectionData::sectionTypeFromString(sectiontype)) == 0) {
             insertSection(KReportSectionData::sectionTypeFromString(sectiontype));
             section(KReportSectionData::sectionTypeFromString(sectiontype))->initFromXML(sec);
         }
 #endif
     } else if (name == "report:detail") {
         if (!processDetailElement(el, status)) {
             return false;
         }
 #if 0 //TODO
         ReportSectionDetail * rsd = new ReportSectionDetail(this);
         rsd->initFromXML(&sec);
         setDetail(rsd);
 #endif
     }
     return true;
 }
 
 /* NOTE: don't translate these extremely detailed messages. */
 //! @todo Load page options
 bool KReportDesign::Private::processContentElementChild(const QDomElement &el,
                                                         KReportDesignReadingStatus *status)
 {
     const QByteArray name = el.tagName().toLatin1();
     QPageLayout defaultPageLayout = KReportDesign::defaultPageLayout();
     //kreportDebug() << name;
     if (name == "report:title") {
         title = el.text();
 #ifdef KREPORT_SCRIPTING
     } else if (name == "report:script") {
         script = el.firstChildElement().text();
         originalInterpreter = KReportUtils::attr(el, "report:script-interpreter", QString());
 #endif
     } else if (name == "report:grid") {
         showGrid = KReportUtils::attr(el, "report:grid-visible", DEFAULT_SHOW_GRID);
         snapToGrid = KReportUtils::attr(el, "report:grid-snap", DEFAULT_SNAP_TO_GRID);
         gridDivisions = KReportUtils::attr(el, "report:grid-divisions", DEFAULT_GRID_DIVISIONS);
         const QString pageUnitString = KReportUtils::attr(el, "report:page-unit", QString());
         bool found;
         pageUnit = KReportUnit::fromSymbol(pageUnitString, &found);
         if (!found) {
             pageUnit = DEFAULT_UNIT;
             if (!pageUnitString.isEmpty()) {
                 qWarning() << "Invalid page unit" << pageUnitString << "specified in" << name
                            << "element, defaulting to" << pageUnit.symbol();
             }
         }
     }
     else if (name == "report:page-style") { // see https://git.reviewboard.kde.org/r/115314
         const QByteArray pagetype = el.text().toLatin1();
         if (pagetype == "predefined") {
             pageLayout.setPageSize(
                         KReportUtils::pageSize(KReportUtils::attr(el, "report:page-size",
                                                QPageSize(DEFAULT_PAGE_SIZE).key())));
         } else if (pagetype.isEmpty() || pagetype == "custom") {
             QSizeF size(KReportUtils::attr(el, "fo:page-width", -1.0),
                         KReportUtils::attr(el, "fo:page-height", -1.0));
             if (size.isValid()) {
                 pageLayout.setPageSize(QPageSize(size, QPageSize::Point));
             } else {
                 pageLayout.setPageSize(defaultPageLayout.pageSize());
             }
         } else if (pagetype == "label") {
             //! @todo?
             pageLayout.setPageSize(defaultPageLayout.pageSize());
         }
         QMarginsF margins(KReportUtils::attr(el, "fo:margin-left", defaultPageLayout.margins().left()),
                  KReportUtils::attr(el, "fo:margin-top", defaultPageLayout.margins().top()),
                  KReportUtils::attr(el, "fo:margin-right", defaultPageLayout.margins().right()),
                  KReportUtils::attr(el, "fo:margin-bottom", defaultPageLayout.margins().bottom()));
         bool b = pageLayout.setMargins(margins);
         if (!b) {
             qWarning() << "Failed to set page margins to" << margins;
         }
         const QString s = KReportUtils::attr(el, "report:print-orientation", QString());
         if (s == QLatin1String("portrait")) {
             pageLayout.setOrientation(QPageLayout::Portrait);
         } else if (s == QLatin1String("landscape")) {
             pageLayout.setOrientation(QPageLayout::Landscape);
         }
         else {
             pageLayout.setOrientation(defaultPageLayout.orientation());
         }
     } else if (name == "report:body") {
         for (QDomNode node = el.firstChild(); !node.isNull(); node = node.nextSibling()) {
             if (!checkElement(node, status)) {
                 return false;
             }
             if (!processBodyElementChild(node.toElement(), status)) {
                 return false;
             }
         }
     }
     return true;
 }
 
 void KReportDesign::Private::unexpectedElement(const QDomElement &element,
                                                KReportDesignReadingStatus *status) const
 {
     setStatus(status, QString::fromLatin1("Unexpected child element <%1> found in <%2>")
           .arg(element.tagName()).arg(element.parentNode().toElement().tagName()), element);
 }
 
 QDomElement KReportDesign::Private::requiredChildElement(const QDomElement &parent,
                                                          const char* childElementName,
                                                          KReportDesignReadingStatus *status) const
 {
     const QDomElement result = parent.firstChildElement(QLatin1String(childElementName));
     if (result.isNull()) {
         setStatus(status, QString::fromLatin1("Child element <%1> not found in <%2>")
               .arg(QLatin1String(childElementName)).arg(parent.tagName()), parent);
     }
     return result;
 }
 
 /* NOTE: don't translate these extremely detailed messages. */
 bool KReportDesign::Private::processDocument(const QDomDocument &doc,
                                              KReportDesignReadingStatus *status)
 {
     const QDomElement rootEl = doc.documentElement();
     const QLatin1String rootElName("kexireport"); // legacy name kept for compatibility
     if (doc.doctype().name() != rootElName) {
         setStatus(status, QString::fromLatin1("Document type should be \"%1\"").arg(rootElName), rootEl);
         return false;
     }
     if (rootEl.tagName() != rootElName) {
         setStatus(status, QString::fromLatin1("Root element should be <%1>").arg(rootElName), rootEl);
         return false;
     }
     const QDomElement contentEl = requiredChildElement(rootEl, "report:content", status);
     if (status && status->isError()) {
         return false;
     }
     //! @todo check namespaces as in:
     //! 
 
 //    deleteDetail();
 
     for (QDomNode node = contentEl.firstChild(); !node.isNull(); node = node.nextSibling()) {
         if (!checkElement(node, status)) {
             return false;
         }
         if (!processContentElementChild(node.toElement(), status)) {
             return false;
         }
     }
 
     if (status) {
-        status->lineNumber = -1;
-        status->columnNumber = -1;
-        status->errorMessage.clear();
-        status->errorDetails.clear();
+        *status = KReportDesignReadingStatus();
     }
     return true;
 }
diff --git a/src/common/KReportDetailSectionData.cpp b/src/common/KReportDetailSectionData.cpp
index 590dbd4a..a8238610 100644
--- a/src/common/KReportDetailSectionData.cpp
+++ b/src/common/KReportDetailSectionData.cpp
@@ -1,123 +1,123 @@
 /* This file is part of the KDE project
  * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
  * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library.  If not, see .
  */
 
 #include "KReportDetailSectionData.h"
 #include "KReportSectionData.h"
 #include "KReportDocument.h"
 
 #include "kreport_debug.h"
 #include 
 
 KReportDetailSectionData::KReportDetailSectionData(QObject *parent)
  : QObject(parent)
 {
     m_pageBreak = BreakNone;
     m_detailSection = 0;
     m_valid = true;
 }
 
 KReportDetailSectionData::KReportDetailSectionData(const QDomElement &elemSource, KReportDocument *report)
  : QObject(report)
 {
     m_pageBreak = BreakNone;
     m_detailSection = 0;
     m_valid = false;
     //kreportDebug() << elemSource.tagName();
     if (elemSource.tagName() != QLatin1String("report:detail")) {
         return;
     }
 
     QDomNodeList sections = elemSource.childNodes();
 
     for (int nodeCounter = 0; nodeCounter < sections.count(); nodeCounter++) {
         QDomElement elemThis = sections.item(nodeCounter).toElement();
 
         if (elemThis.tagName() == QLatin1String("report:group")) {
             KReportDetailGroupSectionData * dgsd = new KReportDetailGroupSectionData();
 
             if ( elemThis.hasAttribute( QLatin1String("report:group-column") ) ) {
                 dgsd->m_column = elemThis.attribute( QLatin1String("report:group-column") );
             }
 
             if ( elemThis.hasAttribute( QLatin1String("report:group-page-break") ) ) {
                 QString s = elemThis.attribute( QLatin1String("report:group-page-break") );
                 if ( s == QLatin1String("after-footer") ) {
                     dgsd->m_pagebreak = KReportDetailGroupSectionData::BreakAfterGroupFooter;
                 } else if ( s == QLatin1String("before-header") ) {
                     dgsd->m_pagebreak = KReportDetailGroupSectionData::BreakBeforeGroupHeader;
                 } else {
                     dgsd->m_pagebreak = KReportDetailGroupSectionData::BreakNone;
                 }
             }
 
             if (elemThis.attribute(QLatin1String("report:group-sort"), QLatin1String("ascending")) == QLatin1String("ascending")) {
                 dgsd->m_sort = Qt::AscendingOrder;
             } else {
                 dgsd->m_sort = Qt::DescendingOrder;
             }
             
             for ( QDomElement e = elemThis.firstChildElement( QLatin1String("report:section") ); ! e.isNull(); e = e.nextSiblingElement( QLatin1String("report:section") ) ) {
                 QString s = e.attribute( QLatin1String("report:section-type") );
                 if ( s == QLatin1String("group-header") ) {
                     KReportSectionData * sd = new KReportSectionData(e, report);
                     if (sd->isValid()) {
                         dgsd->m_groupHeader = sd;
                     } else {
                         delete sd;
                     }
                 } else if ( s == QLatin1String("group-footer") ) {
                     KReportSectionData * sd = new KReportSectionData(e, report);
                     if (sd->isValid()) {
                         dgsd->m_groupFooter = sd;
                     } else {
                         delete sd;
                     }
                 }
             }
             m_groupList.append(dgsd);
             KReportData::SortedField s;
-            s.field = dgsd->m_column;
-            s.order = dgsd->m_sort;
+            s.setField(dgsd->m_column);
+            s.setOrder(dgsd->m_sort);
             m_sortedFields.append(s);
 	    
         } else if (elemThis.tagName() == QLatin1String("report:section") && elemThis.attribute(QLatin1String("report:section-type")) == QLatin1String("detail")) {
             KReportSectionData * sd = new KReportSectionData(elemThis, report);
             if (sd->isValid()) {
                 m_detailSection = sd;
             } else
                 delete sd;
         } else {
             kreportWarning() << "While parsing detail section encountered an unknown element: " << elemThis.tagName();
         }
     }
     
     m_valid = true;
 }
 
 KReportDetailSectionData::~KReportDetailSectionData()
 {
 }
 
 KReportDetailGroupSectionData::KReportDetailGroupSectionData()
 {
     m_pagebreak = BreakNone;
     m_sort = Qt::AscendingOrder;
     m_groupHeader = 0;
     m_groupFooter = 0;
 }
 
diff --git a/src/wrtembed/KReportDesignerItemBase.h b/src/wrtembed/KReportDesignerItemBase.h
index bdd1ea58..4e967beb 100644
--- a/src/wrtembed/KReportDesignerItemBase.h
+++ b/src/wrtembed/KReportDesignerItemBase.h
@@ -1,87 +1,88 @@
 /* This file is part of the KDE project
  * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
  * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library.  If not, see .
  */
 
 /*
  *     This file contains all the Report Entity classes. Each one is a
  * derivative of ReportEntity, which in turn is derived from QCanvasItem.
  */
 
 #ifndef KREPORTDESIGNERITEMBASE_H
 #define KREPORTDESIGNERITEMBASE_H
 
 #include 
 
 #include "KReportItemBase.h"
 
 class QDomDocument;
 class QDomElement;
 
 class KReportDesigner;
 class KReportPosition;
 class KReportSize;
 
 //
 // ReportEntity
 //
 class KREPORT_EXPORT KReportDesignerItemBase
 {
 public:
     virtual ~KReportDesignerItemBase();
 
     static void buildXML(QGraphicsItem * item, QDomDocument *doc, QDomElement *parent);
     virtual void buildXML(QDomDocument *doc, QDomElement *parent) = 0;
 
     static void buildXMLRect(QDomDocument *doc, QDomElement *entity, KReportItemBase *i);
     static void buildXMLTextStyle(QDomDocument *doc, QDomElement *entity, const KRTextStyleData &ts);
     static void buildXMLLineStyle(QDomDocument *doc, QDomElement *entity, const KReportLineStyle &ls);
 
     virtual KReportDesignerItemBase* clone() = 0;
     virtual void move(const QPointF&) = 0;
 
     KReportDesigner* designer() const;
     void setDesigner(KReportDesigner* rd);
 
     static void addPropertyAsAttribute(QDomElement* e, KProperty* p);
 
 protected:
     explicit KReportDesignerItemBase(KReportDesigner*, KReportItemBase*);
     QString dataSourceAndObjectTypeName(const QString& dataSource, const QString& objectTypeName) const;
 
     /**
      * @brief Updates the text that is shown for the item in the report designer
      * If itemDataSource is set then it is preferred over itemStaticValue
      * itemType is appended to the end of the text
      *
      * @param itemDataSource source field property
      * @param itemStaticValue value property
      * @param itemType type of item
      * @return void
      */
     void updateRenderText(const QString &itemDataSource, const QString &itemStaticValue, const QString &itemType);    
     KReportItemBase *item() const;
     
     void setRenderText(const QString &text);
     QString renderText() const;
 
 private:
+    Q_DISABLE_COPY(KReportDesignerItemBase)
     class Private;
     Private * const d;
 };
 
 #endif