diff --git a/src/common/KReportDocument.h b/src/common/KReportDocument.h --- a/src/common/KReportDocument.h +++ b/src/common/KReportDocument.h @@ -44,9 +44,7 @@ explicit KReportDocument(QObject *parent = 0); ~KReportDocument(); - bool isValid() const { - return m_valid; - } + bool isValid() const; /** \return a list of all objects in the report @@ -73,46 +71,27 @@ */ KReportSectionData* section(const QString&) const; - QString query() const { - return m_query; - } + QString query() const ; #ifdef KREPORT_SCRIPTING - QString script() const { - return m_script; - }; - QString interpreter() const { - return m_interpreter; - } + QString script() const; + + QString interpreter() const; #endif - bool externalData() const { - return m_externalData; - } + bool externalData() const; KReportDetailSectionData* detail() const { return m_detailSection; } - void setName(const QString&n) { - m_name = n; - } - QString name() const { - return m_name; - } + void setName(const QString&n); + QString name() const; + QString title() const; KReportPageOptions pageOptions() const; protected: - QString m_title; - QString m_name; - QString m_query; -#ifdef KREPORT_SCRIPTING - QString m_script; - QString m_interpreter; -#endif - bool m_externalData; - KReportPageOptions page; KReportSectionData * m_pageHeaderFirst; KReportSectionData * m_pageHeaderOdd; @@ -132,9 +111,11 @@ KReportDetailSectionData* m_detailSection; private: - bool m_valid; + class Private; + Private * const d; + void init(); - + friend class KReportPreRendererPrivate; friend class KReportPreRenderer; #ifdef KREPORT_SCRIPTING diff --git a/src/common/KReportDocument.cpp b/src/common/KReportDocument.cpp --- a/src/common/KReportDocument.cpp +++ b/src/common/KReportDocument.cpp @@ -25,26 +25,43 @@ #include #include "kreport_debug.h" +class KReportDocument::Private +{ +public: + bool valid; + QString title; + QString name; + QString query; +#ifdef KREPORT_SCRIPTING + QString script; + QString interpreter; +#endif + bool externalData; + KReportPageOptions page; +}; + void KReportDocument::init() { m_pageHeaderFirst = m_pageHeaderOdd = m_pageHeaderEven = m_pageHeaderLast = m_pageHeaderAny = 0; m_pageFooterFirst = m_pageFooterOdd = m_pageFooterEven = m_pageFooterLast = m_pageFooterAny = 0; m_reportHeader = m_reportFooter = 0; } KReportDocument::KReportDocument(QObject *parent) - : QObject(parent) - , m_detailSection(0) + : QObject(parent), + m_detailSection(0), + d(new Private()) { init(); - m_valid = true; + d->valid = true; } KReportDocument::KReportDocument(const QDomElement & elemSource, QObject *parent) - : QObject(parent) - , m_detailSection(0) + : QObject(parent), + m_detailSection(0), + d(new Private()) { - m_valid = false; + d->valid = false; init(); //kreportDebug(); if (elemSource.tagName() != QLatin1String("report:content")) { @@ -61,31 +78,31 @@ for (int nodeCounter = 0; nodeCounter < sections.count(); nodeCounter++) { QDomElement elemThis = sections.item(nodeCounter).toElement(); if (elemThis.tagName() == QLatin1String("report:title")) { - m_title = elemThis.text(); + d->title = elemThis.text(); #ifdef KREPORT_SCRIPTING } else if (elemThis.tagName() == QLatin1String("report:script")) { - m_script = elemThis.text(); - m_interpreter = elemThis.attribute(QLatin1String("report:script-interpreter")); + d->script = elemThis.text(); + d->interpreter = elemThis.attribute(QLatin1String("report:script-interpreter")); #endif } else if (elemThis.tagName() == QLatin1String("report:page-style")) { QString pagetype = elemThis.firstChild().nodeValue(); if (pagetype == QLatin1String("predefined")) { - page.setPageSize(elemThis.attribute(QLatin1String("report:page-size"), QLatin1String("A4"))); + d->page.setPageSize(elemThis.attribute(QLatin1String("report:page-size"), QLatin1String("A4"))); } else if (pagetype == QLatin1String("custom")) { - page.setCustomWidth(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-width"), QString()))) * dpiX); - page.setCustomHeight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-height"), QString()))) * dpiY); - page.setPageSize(QLatin1String("Custom")); + d->page.setCustomWidth(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-width"), QString()))) * dpiX); + d->page.setCustomHeight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-height"), QString()))) * dpiY); + d->page.setPageSize(QLatin1String("Custom")); } else if (pagetype == QLatin1String("label")) { - page.setLabelType(elemThis.firstChild().nodeValue()); + d->page.setLabelType(elemThis.firstChild().nodeValue()); } //! @todo add config for default margins or add within templates support - page.setMarginBottom(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-bottom"), QLatin1String("1.0cm")))) * dpiY); - page.setMarginTop(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm")))) * dpiY); - page.setMarginLeft(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm")))) * dpiX); - page.setMarginRight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm")))) * dpiX); + d->page.setMarginBottom(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-bottom"), QLatin1String("1.0cm")))) * dpiY); + d->page.setMarginTop(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm")))) * dpiY); + d->page.setMarginLeft(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm")))) * dpiX); + d->page.setMarginRight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm")))) * dpiX); - page.setPortrait(elemThis.attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait")) == QLatin1String("portrait")); + d->page.setPortrait(elemThis.attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait")) == QLatin1String("portrait")); } else if (elemThis.tagName() == QLatin1String("report:body")) { QDomNodeList sectionlist = elemThis.childNodes(); @@ -161,15 +178,16 @@ } } - m_valid = true; + d->valid = true; } } - KReportDocument::~KReportDocument() { + delete d; } + QList KReportDocument::objects() const { QList obs; @@ -300,5 +318,45 @@ KReportPageOptions KReportDocument::pageOptions() const { - return page; + return d->page; +} + +bool KReportDocument::isValid() const +{ + return d->valid; +} + +QString KReportDocument::title() const +{ + return d->title; +} + +bool KReportDocument::externalData() const +{ + return d->externalData; +} + +QString KReportDocument::interpreter() const +{ + return d->interpreter; +} + +QString KReportDocument::name() const +{ + return d->name; +} + +void KReportDocument::setName(const QString& n) +{ + d->name = n; +} + +QString KReportDocument::query() const +{ + return d->query; +} + +QString KReportDocument::script() const +{ + return d->script; } diff --git a/src/renderer/KReportPreRenderer.cpp b/src/renderer/KReportPreRenderer.cpp --- a/src/renderer/KReportPreRenderer.cpp +++ b/src/renderer/KReportPreRenderer.cpp @@ -413,22 +413,22 @@ // Do this check now so we don't have to undo a lot of work later if it fails KReportLabelSizeInfo label; - if (m_reportDocument->page.getPageSize() == QLatin1String("Labels")) { - label = KReportLabelSizeInfo::find(m_reportDocument->page.getLabelType()); + if (m_reportDocument->pageOptions().getPageSize() == QLatin1String("Labels")) { + label = KReportLabelSizeInfo::find(m_reportDocument->pageOptions().getLabelType()); if (label.isNull()) { return false; } } //kreportDebug() << "Creating Document"; - m_document = new ORODocument(m_reportDocument->m_title); + m_document = new ORODocument(m_reportDocument->title()); m_pageCounter = 0; m_yOffset = 0.0; //kreportDebug() << "Calculating Margins"; if (!label.isNull()) { - if (m_reportDocument->page.isPortrait()) { + if (m_reportDocument->pageOptions().isPortrait()) { m_topMargin = (label.startY() / 100.0); m_bottomMargin = 0; m_rightMargin = 0; @@ -440,34 +440,34 @@ m_leftMargin = (label.startY() / 100.0); } } else { - m_topMargin = m_reportDocument->page.getMarginTop(); - m_bottomMargin = m_reportDocument->page.getMarginBottom(); - m_rightMargin = m_reportDocument->page.getMarginRight(); - m_leftMargin = m_reportDocument->page.getMarginLeft(); + m_topMargin = m_reportDocument->pageOptions().getMarginTop(); + m_bottomMargin = m_reportDocument->pageOptions().getMarginBottom(); + m_rightMargin = m_reportDocument->pageOptions().getMarginRight(); + m_leftMargin = m_reportDocument->pageOptions().getMarginLeft(); //kreportDebug() << "Margins:" << m_topMargin << m_bottomMargin << m_rightMargin << m_leftMargin; } //kreportDebug() << "Calculating Page Size"; - KReportPageOptions rpo(m_reportDocument->page); + KReportPageOptions rpo(m_reportDocument->pageOptions()); // This should reflect the information of the report page size - if (m_reportDocument->page.getPageSize() == QLatin1String("Custom")) { - m_maxWidth = m_reportDocument->page.getCustomWidth(); - m_maxHeight = m_reportDocument->page.getCustomHeight(); + if (m_reportDocument->pageOptions().getPageSize() == QLatin1String("Custom")) { + m_maxWidth = m_reportDocument->pageOptions().getCustomWidth(); + m_maxHeight = m_reportDocument->pageOptions().getCustomHeight(); } else { if (!label.isNull()) { m_maxWidth = label.width(); m_maxHeight = label.height(); rpo.setPageSize(label.paper()); } else { // lookup the correct size information for the specified size paper - QSizeF pageSizePx = m_reportDocument->page.pixelSize(); + QSizeF pageSizePx = m_reportDocument->pageOptions().pixelSize(); m_maxWidth = pageSizePx.width(); m_maxHeight = pageSizePx.height(); } } - if (!m_reportDocument->page.isPortrait()) { + if (!m_reportDocument->pageOptions().isPortrait()) { qreal tmp = m_maxWidth; m_maxWidth = m_maxHeight; m_maxHeight = tmp; @@ -519,7 +519,7 @@ qreal tmp; // flip the value around if we are printing landscape - if (!m_reportDocument->page.isPortrait()) { + if (!m_reportDocument->pageOptions().isPortrait()) { w = (label.height() / 100.0); wg = (label.yGap() / 100.0); h = (label.width() / 100.0); diff --git a/src/renderer/scripting/KReportScriptReport.cpp b/src/renderer/scripting/KReportScriptReport.cpp --- a/src/renderer/scripting/KReportScriptReport.cpp +++ b/src/renderer/scripting/KReportScriptReport.cpp @@ -42,7 +42,7 @@ QString Report::title() const { - return m_reportData->m_title; + return m_reportData->title(); } QString Report::name() const